From dc2493e7525bb7633f697ef10f72b72b46222249 Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Fri, 30 Aug 2019 00:45:36 -0400 Subject: Forget what I said, I just need to change git attributes to mark for vendor --- lib/sol2/docs/source/api/make_reference.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/sol2/docs/source/api/make_reference.rst (limited to 'lib/sol2/docs/source/api/make_reference.rst') diff --git a/lib/sol2/docs/source/api/make_reference.rst b/lib/sol2/docs/source/api/make_reference.rst new file mode 100644 index 0000000..a127333 --- /dev/null +++ b/lib/sol2/docs/source/api/make_reference.rst @@ -0,0 +1,26 @@ +make_object/make_reference +========================== +*create a value in the lua registry / on the Lua stack and return it* + + +.. code-block:: cpp + :caption: function: make_reference + :name: make-reference + + template + R make_reference(lua_State* L, T&& value); + template + R make_reference(lua_State* L, Args&&... args); + +Makes an ``R`` out of the value. The first overload deduces the type from the passed in argument, the second allows you to specify a template parameter and forward any relevant arguments to ``sol::stack::push``. The type figured out for ``R`` is what is referenced from the stack. This allows you to request arbitrary pop-able types from sol and have it constructed from ``R(lua_State* L, int stack_index)``. If the template boolean ``should_pop`` is ``true``, the value that was pushed will be popped off the stack. It defaults to popping, but if it encounters a type such as :doc:`sol::stack_reference` (or any of its typically derived types in sol), it will leave the pushed values on the stack. + +.. code-block:: cpp + :caption: function: make_object + :name: make-object + + template + object make_object(lua_State* L, T&& value); + template + object make_object(lua_State* L, Args&&... args); + +Makes an object out of the value. It pushes it onto the stack, then pops it into the returned ``sol::object``. The first overload deduces the type from the passed in argument, the second allows you to specify a template parameter and forward any relevant arguments to ``sol::stack::push``. The implementation essentially defers to :ref:`sol::make_reference` with the specified arguments, ``R == object`` and ``should_pop == true``. It is preferred that one uses the :ref:`in_place object constructor instead`, since it's probably easier to deal with, but both versions will be supported for forever, since there's really no reason not to and people already have dependencies on ``sol::make_object``. -- cgit v1.2.3