Update single and fix shitty proxy documentation!

This commit is contained in:
ThePhD 2020-07-04 04:43:29 -04:00
parent 7d8532b5f8
commit 6869ad35a3
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
3 changed files with 40 additions and 22 deletions

View File

@ -29,19 +29,19 @@ proxy
.. literalinclude:: ../../../examples/source/table_proxy.cpp .. literalinclude:: ../../../examples/source/table_proxy.cpp
:linenos: :linenos:
:lines: 11-15 :lines: 9-13
After loading that file in or putting it in a string and reading the string directly in lua (see :doc:`state`), you can start kicking around with it in C++ like so: After loading that file in or putting it in a string and reading the string directly in lua (see :doc:`state`), you can start kicking around with it in C++ like so:
.. literalinclude:: ../../../examples/source/table_proxy.cpp .. literalinclude:: ../../../examples/source/table_proxy.cpp
:linenos: :linenos:
:lines: 1-8,18-40 :lines: 1-6,16-38
We don't recommend using ``proxy`` lazy evaluation the above to be used across classes or between function: it's more of something you can do to save a reference to a value you like, call a script or run a lua function, and then get it afterwards. You can also set functions (and function objects) this way, and retrieve them as well: We don't recommend using ``proxy`` lazy evaluation the above to be used across classes or between function: it's more of something you can do to save a reference to a value you like, call a script or run a lua function, and then get it afterwards. You can also set functions (and function objects) this way, and retrieve them as well:
.. literalinclude:: ../../../examples/source/table_proxy.cpp .. literalinclude:: ../../../examples/source/table_proxy.cpp
:linenos: :linenos:
:lines: 41- :lines: 40-
members members
------- -------

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2020-07-04 07:55:36.492765 UTC // Generated 2020-07-04 08:02:02.982843 UTC
// This header was generated with sol v3.2.1 (revision 62a831c) // This header was generated with sol v3.2.1 (revision 7d8532b)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2020-07-04 07:55:34.972735 UTC // Generated 2020-07-04 08:02:02.484853 UTC
// This header was generated with sol v3.2.1 (revision 62a831c) // This header was generated with sol v3.2.1 (revision 7d8532b)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -7509,8 +7509,8 @@ namespace sol {
return trampoline(L, f); return trampoline(L, f);
} }
#else #else
template <lua_CFunction f>
int static_trampoline(lua_State* L) { inline int impl_static_trampoline(lua_State* L, lua_CFunction f) {
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT) #if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
return f(L); return f(L);
@ -7539,6 +7539,11 @@ namespace sol {
#endif // Safe exceptions #endif // Safe exceptions
} }
template <lua_CFunction f>
int static_trampoline(lua_State* L) {
return impl_static_trampoline(L, f);
}
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE #ifdef SOL_NOEXCEPT_FUNCTION_TYPE
#if 0 #if 0
// impossible: g++/clang++ choke as they think this function is ambiguous: // impossible: g++/clang++ choke as they think this function is ambiguous:
@ -7653,11 +7658,9 @@ namespace detail {
"`anonymous namespace'" } }; "`anonymous namespace'" } };
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
template <typename T, class seperator_mark = int> inline std::string ctti_get_type_name_from_sig(std::string name) {
inline std::string ctti_get_type_name() {
// cardinal sins from MINGW // cardinal sins from MINGW
using namespace std; using namespace std;
std::string name = __PRETTY_FUNCTION__;
std::size_t start = name.find_first_of('['); std::size_t start = name.find_first_of('[');
start = name.find_first_of('=', start); start = name.find_first_of('=', start);
std::size_t end = name.find_last_of(']'); std::size_t end = name.find_last_of(']');
@ -7687,10 +7690,13 @@ namespace detail {
return name; return name;
} }
template <typename T, class seperator_mark = int>
inline std::string ctti_get_type_name() {
return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__);
}
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
template <typename T> inline std::string ctti_get_type_name_from_sig(std::string name) {
std::string ctti_get_type_name() {
std::string name = __FUNCSIG__;
std::size_t start = name.find("get_type_name"); std::size_t start = name.find("get_type_name");
if (start == std::string::npos) if (start == std::string::npos)
start = 0; start = 0;
@ -7721,6 +7727,11 @@ namespace detail {
return name; return name;
} }
template <typename T>
std::string ctti_get_type_name() {
return ctti_get_type_name_from_sig(__FUNCSIG__);
}
#else #else
#error Compiler not supported for demangling #error Compiler not supported for demangling
#endif // compilers #endif // compilers
@ -7731,9 +7742,7 @@ namespace detail {
return realname; return realname;
} }
template <typename T> inline std::string short_demangle_from_type_name(std::string realname) {
std::string short_demangle_once() {
std::string realname = ctti_get_type_name<T>();
// This isn't the most complete but it'll do for now...? // This isn't the most complete but it'll do for now...?
static const std::array<std::string, 10> ops = {{"operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*"}}; static const std::array<std::string, 10> ops = {{"operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*"}};
int level = 0; int level = 0;
@ -7769,6 +7778,12 @@ namespace detail {
return realname; return realname;
} }
template <typename T>
std::string short_demangle_once() {
std::string realname = ctti_get_type_name<T>();
return short_demangle_from_type_name(realname);
}
template <typename T> template <typename T>
const std::string& demangle() { const std::string& demangle() {
static const std::string d = demangle_once<T>(); static const std::string d = demangle_once<T>();
@ -10692,9 +10707,7 @@ namespace sol {
namespace sol { namespace stack { namespace sol { namespace stack {
namespace stack_detail { namespace stack_detail {
template <typename T, bool poptable = true> inline bool impl_check_metatable(lua_State* L, int index, const std::string& metakey, bool poptable) {
inline bool check_metatable(lua_State* L, int index = -2) {
const auto& metakey = usertype_traits<T>::metatable();
luaL_getmetatable(L, &metakey[0]); luaL_getmetatable(L, &metakey[0]);
const type expectedmetatabletype = static_cast<type>(lua_type(L, -1)); const type expectedmetatabletype = static_cast<type>(lua_type(L, -1));
if (expectedmetatabletype != type::lua_nil) { if (expectedmetatabletype != type::lua_nil) {
@ -10707,6 +10720,11 @@ namespace sol { namespace stack {
return false; return false;
} }
template <typename T, bool poptable = true>
inline bool check_metatable(lua_State* L, int index = -2) {
return impl_check_metatable(L, index, usertype_traits<T>::metatable(), poptable);
}
template <type expected, int (*check_func)(lua_State*, int)> template <type expected, int (*check_func)(lua_State*, int)>
struct basic_check { struct basic_check {
template <typename Handler> template <typename Handler>