summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2016-11-07 13:31:30 -0600
committer cracyc <cracyc@users.noreply.github.com>2016-11-07 13:31:30 -0600
commit673e7536216e6792c3da1a7c800c0edbe8e2f286 (patch)
treeaaf00d33ed2a4097ebbe34cea16163f7ddee50b3 /3rdparty
parentd733b5451ace5b45b2009add6495fb894fbb4d44 (diff)
update sol2 (nw)
Diffstat (limited to '3rdparty')
-rw-r--r--3rdparty/sol2/docs/source/api/containers.rst14
-rw-r--r--3rdparty/sol2/single/sol/sol.hpp6
-rw-r--r--3rdparty/sol2/sol/stack_push.hpp2
-rw-r--r--3rdparty/sol2/test_containers.cpp64
4 files changed, 80 insertions, 6 deletions
diff --git a/3rdparty/sol2/docs/source/api/containers.rst b/3rdparty/sol2/docs/source/api/containers.rst
index dba03df8a58..81bbdc40584 100644
--- a/3rdparty/sol2/docs/source/api/containers.rst
+++ b/3rdparty/sol2/docs/source/api/containers.rst
@@ -53,7 +53,17 @@ Here's a complete working example of it working for Lua 5.3 and Lua 5.2, and how
return 0;
}
-Note that this will not work well in 5.1, as it has explicit table checks and does not check metamethods, even when ``pairs`` or ``ipairs`` is passed a table. In that case, you will need to use a more manual iteration scheme or you will have to convert it to a table. In C++, you can use :doc:`sol::as_table<as_table>` when passing something to the library to get a table out of it.
+
+Note that this will not work well in Lua 5.1, as it has explicit table checks and does not check metamethods, even when ``pairs`` or ``ipairs`` is passed a table. In that case, you will need to use a more manual iteration scheme or you will have to convert it to a table. In C++, you can use :doc:`sol::as_table<as_table>` when passing something to the library to get a table out of it: ``lua["arr"] = as_table( std::vector<int>{ ... });``. For manual iteration in Lua code without using ``as_table`` for something with indices, try:
+
+.. code-block:: lua
+ :caption: iteration.lua
+
+ for i = 1, #vec do
+ print(i, vec[i])
+ end
+
+There are also other ways to iterate over key/values, but they can be difficult due to not having proper support in Lua 5.1. We recommend that you upgrade to Lua 5.2 or 5.3.
additional functions
@@ -90,4 +100,4 @@ If you have a type that has ``begin`` or ``end`` member functions but don't prov
namespace sol {
template <>
struct is_container<not_container> : std::false_type {};
- } \ No newline at end of file
+ }
diff --git a/3rdparty/sol2/single/sol/sol.hpp b/3rdparty/sol2/single/sol/sol.hpp
index b681f7e32bf..29fcf1d30ba 100644
--- a/3rdparty/sol2/single/sol/sol.hpp
+++ b/3rdparty/sol2/single/sol/sol.hpp
@@ -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-11-06 21:33:58.899927 UTC
-// This header was generated with sol v2.15.0 (revision 34fe8a1)
+// Generated 2016-11-07 18:50:10.518977 UTC
+// This header was generated with sol v2.15.0 (revision 29f10c4)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP
@@ -5922,7 +5922,7 @@ namespace sol {
};
template<typename T>
- struct pusher<T*, meta::disable_if_t<meta::all<meta::has_begin_end<meta::unqualified_t<T>>, meta::neg<meta::any<std::is_base_of<reference, meta::unqualified_t<T>>, std::is_base_of<stack_reference, meta::unqualified_t<T>>>>>::value>> {
+ struct pusher<T*, meta::disable_if_t<meta::all<is_container<T>, meta::neg<meta::any<std::is_base_of<reference, meta::unqualified_t<T>>, std::is_base_of<stack_reference, meta::unqualified_t<T>>>>>::value>> {
template <typename... Args>
static int push(lua_State* L, Args&&... args) {
return pusher<detail::as_pointer_tag<T>>{}.push(L, std::forward<Args>(args)...);
diff --git a/3rdparty/sol2/sol/stack_push.hpp b/3rdparty/sol2/sol/stack_push.hpp
index cf39d1e40c8..0478bcbe1ff 100644
--- a/3rdparty/sol2/sol/stack_push.hpp
+++ b/3rdparty/sol2/sol/stack_push.hpp
@@ -108,7 +108,7 @@ namespace sol {
};
template<typename T>
- struct pusher<T*, meta::disable_if_t<meta::all<meta::has_begin_end<meta::unqualified_t<T>>, meta::neg<meta::any<std::is_base_of<reference, meta::unqualified_t<T>>, std::is_base_of<stack_reference, meta::unqualified_t<T>>>>>::value>> {
+ struct pusher<T*, meta::disable_if_t<meta::all<is_container<T>, meta::neg<meta::any<std::is_base_of<reference, meta::unqualified_t<T>>, std::is_base_of<stack_reference, meta::unqualified_t<T>>>>>::value>> {
template <typename... Args>
static int push(lua_State* L, Args&&... args) {
return pusher<detail::as_pointer_tag<T>>{}.push(L, std::forward<Args>(args)...);
diff --git a/3rdparty/sol2/test_containers.cpp b/3rdparty/sol2/test_containers.cpp
index d43db52d4b4..1ed07e24a9f 100644
--- a/3rdparty/sol2/test_containers.cpp
+++ b/3rdparty/sol2/test_containers.cpp
@@ -359,3 +359,67 @@ a_ref = b.a_list[2]
REQUIRE(&b.a_list[1] == &a_ref);
REQUIRE(b.a_list[1].a == a_ref.a);
}
+
+struct options {
+ static int livingcount;
+ static options* last;
+ options() {
+ ++livingcount;
+ last = this;
+ INFO("constructor: " << this);
+ }
+
+ std::string output_help() {
+ last = this;
+ INFO("func: " << this);
+ return "";
+ }
+
+ void begin() {}
+ void end() {}
+
+ ~options() {
+ last = this;
+ --livingcount;
+ }
+};
+
+options* options::last = nullptr;
+int options::livingcount = 0;
+
+struct machine {
+ options opt;
+};
+
+namespace sol {
+ template <>
+ struct is_container<options> : std::false_type {};
+}
+
+TEST_CASE("containers/is-container", "make sure the is_container trait behaves properly") {
+ sol::state lua;
+ lua.open_libraries();
+
+ lua.new_usertype<options>("options_type",
+ "output_help", &options::output_help
+ );
+
+ lua.new_usertype<machine>("machine_type",
+ "new", sol::no_constructor,
+ "opt", [](machine& m) { return &m.opt; },
+ "copy_opt", [](machine& m) { return m.opt; }
+ );
+
+ {
+ machine m;
+ lua["machine"] = &m;
+
+ lua.script(R"(
+ machine:opt():output_help()
+ )");
+
+ REQUIRE(options::last == &m.opt);
+ REQUIRE(options::livingcount == 1);
+ }
+ REQUIRE(options::livingcount == 0);
+}