mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
[ci skip] update info
This commit is contained in:
parent
1e62e3cde1
commit
0c5d73b67a
|
@ -1,4 +1,4 @@
|
|||
## Sol 2.11
|
||||
## Sol 2.12
|
||||
|
||||
[![Build Status](https://travis-ci.org/ThePhD/sol2.svg?branch=develop)](https://travis-ci.org/ThePhD/sol2)
|
||||
[![Documentation Status](https://readthedocs.org/projects/sol2/badge/?version=latest)](http://sol2.readthedocs.io/en/latest/?badge=latest)
|
||||
|
|
|
@ -31,6 +31,7 @@ Browse the various function and classes :doc:`Sol<../index>` utilizes to make yo
|
|||
optional
|
||||
state
|
||||
table
|
||||
as_table
|
||||
metatable_key
|
||||
this_state
|
||||
thread
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
as_function
|
||||
===========
|
||||
make sure a parameter is pushed as a function
|
||||
---------------------------------------------
|
||||
make sure an object is pushed as a function
|
||||
-------------------------------------------
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
|
24
docs/source/api/as_table.rst
Normal file
24
docs/source/api/as_table.rst
Normal file
|
@ -0,0 +1,24 @@
|
|||
as_table
|
||||
===========
|
||||
make sure an object is pushed as a table
|
||||
----------------------------------------
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
template <typename T>
|
||||
as_table_t { ... };
|
||||
|
||||
template <typename T>
|
||||
as_table_t<T> as_function ( T&& container );
|
||||
|
||||
This function serves the purpose of ensuring that an object is pushed -- if possible -- like a table into Lua. The container passed here can be a pointer, a reference, a ``std::reference_wrapper`` around a container, or just a plain container value. It must have a begin/end function, and if it has a ``std::pair<Key, Value>`` as its ``value_type``, it will be pushed as a dictionary. Otherwise, it's pushed as a sequence.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
sol::state lua;
|
||||
lua.open_libraries();
|
||||
lua.set("my_table", sol::as_table(std::vector<int>{ 1, 2, 3, 4, 5 }));
|
||||
lua.script("for k, v in ipairs(my_table) do print(k, v) assert(k == v) end");
|
||||
|
||||
|
||||
Note that any caveats with Lua tables apply the moment it is serialized, and the data cannot be gotten out back out in C++ as a vector without explicitly using the ``as_table_t`` marker for your get and conversion operations using Sol.
|
|
@ -59,9 +59,9 @@ author = 'ThePhD'
|
|||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '2.11'
|
||||
version = '2.12'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '2.11.7'
|
||||
release = '2.12.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2016-08-24 12:40:13.351588 UTC
|
||||
// This header was generated with sol v2.11.7 (revision 54cffb7)
|
||||
// Generated 2016-08-24 13:16:37.429596 UTC
|
||||
// This header was generated with sol 2.12.0 (revision 1e62e3c)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
|
Loading…
Reference in New Issue
Block a user