diff --git a/docs/source/api/usertype.rst b/docs/source/api/usertype.rst index d31d38ff..d589a541 100644 --- a/docs/source/api/usertype.rst +++ b/docs/source/api/usertype.rst @@ -123,11 +123,14 @@ enumerations less_than, less_than_or_equal_to, garbage_collect, - call_function, + call_function = call, + pairs }; + typedef meta_function meta_method; -Use this enumeration to specify names in a manner friendlier than memorizing the special lua metamethod names for each of these. Each binds to a specific operation indicated by the descriptive name of the enum. + +Use this enumeration to specify names in a manner friendlier than memorizing the special lua metamethod names for each of these. Each binds to a specific operation indicated by the descriptive name of the enum. You can read more about `the metamethods in the Lua manual`_ and learn about how they work and are supposed to be implemented there. Each of the names here (except for the ones used as shortcuts to other names like ``meta_function::call_function`` and ``meta_function::involution`` and not including ``construct``, which just maps to the name ``new``) link directly to the Lua name for the operation. ``meta_function::pairs`` is only available in Lua 5.2 and above (does not include LuaJIT or Lua 5.1). members ------- @@ -372,3 +375,4 @@ performance note .. _destructible: http://en.cppreference.com/w/cpp/types/is_destructible .. _default_constructible: http://en.cppreference.com/w/cpp/types/is_constructible .. _runtime extensible: https://github.com/ThePhD/sol2/blob/develop/examples/usertype_advanced.cpp#L81 +.. _the metamethods in the Lua manual: https://www.lua.org/manual/5.3/manual.html#2.4 diff --git a/docs/source/usertypes.rst b/docs/source/usertypes.rst index 5d322db8..e0cac45c 100644 --- a/docs/source/usertypes.rst +++ b/docs/source/usertypes.rst @@ -19,7 +19,7 @@ The examples folder also has a number of really great examples for you to see. T - If you need dynamic callbacks or runtime overridable functions, have a ``std::function`` member variable and get/set it on the usertype object - ``std::function`` works as a member variable or in passing as an argument / returning as a value (you can even use it with ``sol::property``) - You can also create an entirely dynamic object: see the `dynamic_object example`_ for more details -* (Advanced) You can override the iteration function for Lua 5.2 and above (LuaJIT not included) `as shown in the pairs example`_ +* (Advanced) You can override the iteration function for Lua 5.2 and above (LuaJIT does not have the capability) `as shown in the pairs example`_ * You can use :doc:`filters` to control dependencies and streamline return values, as well as apply custom behavior to a functions return * Please note that the colon is necessary to "automatically" pass the ``this``/``self`` argument to Lua methods - ``obj:method_name()`` is how you call "member" methods in Lua @@ -53,4 +53,4 @@ The examples folder also has a number of really great examples for you to see. T .. _C++: https://github.com/ThePhD/sol2/blob/develop/examples/usertype_simple.cpp#L51 .. _Certain operators: https://github.com/ThePhD/sol2/blob/develop/examples/usertype_automatic_operators.cpp .. _dynamic_object example: https://github.com/ThePhD/sol2/blob/develop/examples/dynamic_object.cpp -.. _as shown in this example: https://github.com/ThePhD/sol2/blob/develop/examples/pairs.cpp +.. _as shown in the pairs example: https://github.com/ThePhD/sol2/blob/develop/examples/pairs.cpp