diff --git a/lua.lyx b/lua.lyx index 08b8ae58..fba57840 100644 --- a/lua.lyx +++ b/lua.lyx @@ -513,7 +513,44 @@ If conversion is successful, returns (true, {converted-string}). \end_layout \begin_layout Itemize -If conversion was unsuccessful, returns ( +If conversion was unsuccessful, returns (false, {converted-part}, {unconverted-b +ytes}, {error}). + The following errors are defined: +\end_layout + +\begin_deeper +\begin_layout Itemize +INVALID: Invalid byte sequence in input +\end_layout + +\begin_layout Itemize +INCOMPLETE: The input is cut of in middle of multi-byte sequence +\end_layout + +\begin_layout Itemize +INTERNALERR: Internal errror +\end_layout + +\end_deeper +\begin_layout Subsection +identify_class: Identify class of object +\end_layout + +\begin_layout Itemize +Syntax: string identify_class(userdata object) +\end_layout + +\begin_layout Standard +Identifies the class of userdata , if possible. + If no identification is possible, returns +\begin_inset Quotes eld +\end_inset + +unknown +\begin_inset Quotes erd +\end_inset + +. \end_layout \begin_layout Standard diff --git a/lua.pdf b/lua.pdf index db0fc6f2..d917a589 100644 Binary files a/lua.pdf and b/lua.pdf differ diff --git a/src/lua/core.cpp b/src/lua/core.cpp index 109acd6b..a1c4874f 100644 --- a/src/lua/core.cpp +++ b/src/lua/core.cpp @@ -67,8 +67,14 @@ namespace } } - lua::fnptr lua_tostringx(lua_func_misc, "tostringx", [](lua::state& L, const std::string& fname) -> - int { + lua::fnptr lua_ctype(lua_func_misc, "identify_class", [](lua::state& L, const std::string& fname) -> int { + if(L.type(1) != LUA_TUSERDATA) + return 0; + L.pushlstring(try_recognize_userdata(L, 1)); + return 1; + }); + + lua::fnptr lua_tostringx(lua_func_misc, "tostringx", [](lua::state& L, const std::string& fname) -> int { std::set tmp2; std::string y = luavalue_to_string(L, 1, tmp2, false); L.pushlstring(y.c_str(), y.length());