diff --git a/docs/source/api/api-top.rst b/docs/source/api/api-top.rst index e04f766c..2dcf1d12 100644 --- a/docs/source/api/api-top.rst +++ b/docs/source/api/api-top.rst @@ -35,6 +35,7 @@ Browse the various function and classes :doc:`Sol<../index>` utilizes to make yo types user usertype + simple_usertype userdata usertype_memory unique_usertype_traits diff --git a/docs/source/api/simple_usertype.rst b/docs/source/api/simple_usertype.rst new file mode 100644 index 00000000..9284c34b --- /dev/null +++ b/docs/source/api/simple_usertype.rst @@ -0,0 +1,14 @@ +simple_usertype +================== +structures and classes from C++ made available to Lua code (simpler) +-------------------------------------------------------------------- + + +This type is no different from :doc:`regular usertype`, but with the following caveats: + +* Dot (".") syntax is not natively supported for simple usertypes (e.g., typical member variable / property bindings) + - All member variables become functions of that name and are get/set in Lua with the syntax ``local v = obj:value()`` to get, and ``obj:value(24)`` to set + - :doc:`properties` also become functions, similar to how member variables are treated above +* Automatic "__index" and "__newindex" handling is not done + - Overriding either of these properties leaves it entirely up to you to handle how you find variables + - If you override "__index" or "__newindex", you must perform a raw get on the original table and return a valid function / value if you want it to find the members you already set on the ``simple_usertype`` diff --git a/docs/source/api/usertype.rst b/docs/source/api/usertype.rst index c0c7dbcd..0b1a60dc 100644 --- a/docs/source/api/usertype.rst +++ b/docs/source/api/usertype.rst @@ -145,6 +145,9 @@ The constructor of usertype takes a variable number of arguments. It takes an ev .. _constructor: +* ``sol::simple`` + - Only allowed as the first argument to the usertype constructor + - This tag triggers the :doc:`simple usertype` changes / optimizations * ``"{name}", constructors`` - ``Type-List-N`` must be a ``sol::types``, where ``Args...`` is a list of types that a constructor takes. Supports overloading by default - If you pass the ``constructors<...>`` argument first when constructing the usertype, then it will automatically be given a ``"{name}"`` of ``"new"`` @@ -250,6 +253,15 @@ traits This trait is used to provide names for the various metatables and global tables used to perform cleanup and lookup. They are automatically generated at runtime. In the case of RTTI being present, Sol will attempt to demangle the name from ``std::type_info`` to produce a valid name. If RTTI is disabled, Sol attempts to parse the output of ``__PRETTY_FUCNTION__`` (``g++``/``clang++``) or ``_FUNCDSIG`` (``vc++``) to get the proper type name. If you have a special need you can override the names for your specific type. + +compilation speed +----------------- + +.. note:: + + If you find that compilation times are too long and you're only binding member functions, consider perhaps using :doc:`simple usertypes`. This can reduce compile times (but may cost memory size and speed). See the simple usertypes documentation for more details. + + performance note ---------------- diff --git a/docs/source/conf.py b/docs/source/conf.py index 90268a18..4fa51836 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -59,9 +59,9 @@ author = 'ThePhD' # built documents. # # The short X.Y version. -version = '2.8' +version = '2.9' # The full version, including alpha/beta/rc tags. -release = '2.8.6' +release = '2.9.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/source/index.rst b/docs/source/index.rst index 492e7bee..911d9cf8 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -7,7 +7,7 @@ :target: https://github.com/ThePhD/sol2 :alt: sol2 repository -Sol 2.8 +Sol 2.9 ======= a fast, simple C++ and Lua Binding ---------------------------------- diff --git a/sol/simple_usertype_metatable.hpp b/sol/simple_usertype_metatable.hpp index d9ca7739..2893aca7 100644 --- a/sol/simple_usertype_metatable.hpp +++ b/sol/simple_usertype_metatable.hpp @@ -60,7 +60,7 @@ namespace sol { simple_usertype_metatable(usertype_detail::verified_tag, std::index_sequence, lua_State* L, Tuple&& args) : callconstructfunc(nil) { registrations.reserve(std::tuple_size>::value); - detail::swallow{ 0, + (void)detail::swallow{ 0, (add(L, detail::forward_get(args), detail::forward_get(args)),0)... }; }