mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Grumblemumble goddamn Xeo grumbleMumble
This commit is contained in:
parent
9c67e9310e
commit
57333bb529
|
@ -12,7 +12,7 @@ In general, we always insert a T* in the first `sizeof(T*)` bytes, so the any fr
|
||||||
For ``T``
|
For ``T``
|
||||||
---------
|
---------
|
||||||
|
|
||||||
These are classified with the metatable from ``
|
These are classified with the metatable name from :ref:`usertype_traits\<T><usertype-traits>`.
|
||||||
|
|
||||||
The data layout for references is as follows::
|
The data layout for references is as follows::
|
||||||
|
|
||||||
|
@ -44,4 +44,4 @@ The data layout for these kinds of types is as follows::
|
||||||
| T* | void(*)(void*) function_pointer | T |
|
| T* | void(*)(void*) function_pointer | T |
|
||||||
^-sizeof(T*) bytes-^-sizeof(void(*)(void*)) bytes, deleter-^- sizeof(T) bytes, actal data -^
|
^-sizeof(T*) bytes-^-sizeof(void(*)(void*)) bytes, deleter-^- sizeof(T) bytes, actal data -^
|
||||||
|
|
||||||
Note that we put a special deleter function before the actual data. This is because the custom deleter must know where the offset to the data is, not the rest of the library. Sol just needs to know about ``T*`` and the userdata (and userdata metatable) to work, everything else is for preserving construction / destruction syntax.
|
Note that we put a special deleter function before the actual data. This is because the custom deleter must know where the offset to the data is, not the rest of the library. Sol just needs to know about ``T*`` and the userdata (and userdata metatable) to work, everything else is for preserving construction / destruction semantics.
|
|
@ -3,6 +3,10 @@ run-time type information (rtti)
|
||||||
because somebody's going to want to shut this off, too...
|
because somebody's going to want to shut this off, too...
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
Sol does not use RTTI anymore.
|
||||||
|
|
||||||
|
*THE BELOW IS NO LONGER NEEDED.*
|
||||||
|
|
||||||
Not compiling with C++'s run-time type information? Do a ``#define SOL_NO_RTII`` before you include ``sol.hpp`` or define ``SOL_NO_RTTI`` on your command line. Be sure to understand the :ref:`implications<usertype-inheritance>` of doing so if you also turn off exceptions.
|
Not compiling with C++'s run-time type information? Do a ``#define SOL_NO_RTII`` before you include ``sol.hpp`` or define ``SOL_NO_RTTI`` on your command line. Be sure to understand the :ref:`implications<usertype-inheritance>` of doing so if you also turn off exceptions.
|
||||||
|
|
||||||
If you come across bugs or can't compile because there's a stray `typeid` or `typeinfo` that wasn't hidden behind a ``#ifndef SOL_NO_RTTI``, please file `an issue`_ or even make a pull request so it can be fixed for everyone.
|
If you come across bugs or can't compile because there's a stray `typeid` or `typeinfo` that wasn't hidden behind a ``#ifndef SOL_NO_RTTI``, please file `an issue`_ or even make a pull request so it can be fixed for everyone.
|
||||||
|
|
|
@ -6,12 +6,12 @@ Sol was designed to be correct and fast, and in the pursuit of both uses the reg
|
||||||
Note that you can obtain safety with regards to functions you bind by using the :doc:`protect<api/protect>` wrapper around function/variable bindings you set into Lua.
|
Note that you can obtain safety with regards to functions you bind by using the :doc:`protect<api/protect>` wrapper around function/variable bindings you set into Lua.
|
||||||
|
|
||||||
``SOL_SAFE_USERTYPE`` triggers the following change:
|
``SOL_SAFE_USERTYPE`` triggers the following change:
|
||||||
* If the userdata to a usertype function is nill, will trigger an error instead of letting things go through and letting the system segfault
|
* If the userdata to a usertype function is nil, will trigger an error instead of letting things go through and letting the system segfault.
|
||||||
|
|
||||||
``SOL_CHECK_ARGUMENTS`` triggers the following changes:
|
``SOL_CHECK_ARGUMENTS`` triggers the following changes:
|
||||||
* ``sol::stack::get`` (used everywhere) defaults to using ``sol::stack::check_get`` and dereferencing the argument. It uses ``sol::type_panic`` as the handler if something goes wrong.
|
* ``sol::stack::get`` (used everywhere) defaults to using ``sol::stack::check_get`` and dereferencing the argument. It uses ``sol::type_panic`` as the handler if something goes wrong.
|
||||||
* ``sol::stack::call`` and its variants will, if no templated boolean is specified, check all of the arguments for a function call.
|
* ``sol::stack::call`` and its variants will, if no templated boolean is specified, check all of the arguments for a function call.
|
||||||
* If ``SOL_SAFE_USERTYPE`` is not defined, it gets defined to turn it on
|
* If ``SOL_SAFE_USERTYPE`` is not defined, it gets defined to turn being on.
|
||||||
|
|
||||||
Remember that if you want these features, you must explicitly turn them on. Additionally, you can have basic boolean checks when using the API by just converting to a :doc:`sol::optional\<T><api/optional>` when necessary. Tests are compiled with this on to ensure everythign is going as expected.
|
Remember that if you want these features, you must explicitly turn them on. Additionally, you can have basic boolean checks when using the API by just converting to a :doc:`sol::optional\<T><api/optional>` when necessary. Tests are compiled with this on to ensure everythign is going as expected.
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,11 @@ namespace sol {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
#elif defined(__GNUC__) || defined(__clang__)
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
template <typename T>
|
template <typename T, class seperator_mark = int>
|
||||||
inline std::string ctti_get_type_name() {
|
inline std::string ctti_get_type_name() {
|
||||||
const static std::array<std::string, 2> removals = { { "{anonymous}", "(anonymous namespace)" } };
|
const static std::array<std::string, 2> removals = { { "{anonymous}", "(anonymous namespace)" } };
|
||||||
std::string name = __PRETTY_FUNCTION__;
|
std::string name = __PRETTY_FUNCTION__;
|
||||||
std::size_t start = name.find_last_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(']');
|
||||||
if (end == std::string::npos)
|
if (end == std::string::npos)
|
||||||
|
@ -76,21 +76,21 @@ namespace sol {
|
||||||
if (start < name.size() - 1)
|
if (start < name.size() - 1)
|
||||||
start += 1;
|
start += 1;
|
||||||
name = name.substr(start, end - start);
|
name = name.substr(start, end - start);
|
||||||
start = name.find(";");
|
start = name.rfind("seperator_mark");
|
||||||
if (start != std::string::npos) {
|
if (start != std::string::npos) {
|
||||||
name.erase(start, name.length());
|
name.erase(start - 2, name.length());
|
||||||
}
|
}
|
||||||
while (!name.empty() && std::isblank(name.front())) name.erase(name.begin());
|
while (!name.empty() && std::isblank(name.front())) name.erase(name.begin());
|
||||||
while (!name.empty() && std::isblank(name.back())) name.pop_back();
|
while (!name.empty() && std::isblank(name.back())) name.pop_back();
|
||||||
|
|
||||||
for (std::size_t r = 0; r < removals.size(); ++r) {
|
for (std::size_t r = 0; r < removals.size(); ++r) {
|
||||||
auto found = name.find(removals[r]);
|
auto found = name.find(removals[r]);
|
||||||
while (found != std::string::npos) {
|
while (found != std::string::npos) {
|
||||||
name.erase(found, removals[r].size());
|
name.erase(found, removals[r].size());
|
||||||
found = name.find(removals[r]);
|
found = name.find(removals[r]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user