Revert "Build System Updated"

This commit is contained in:
Alex
2019-10-12 21:07:06 -07:00
committed by GitHub
parent 579471afcc
commit b9f57f1f28
193 changed files with 14124 additions and 10507 deletions
+137 -93
View File
@@ -24,129 +24,173 @@
#include <luabind/lua_include.hpp>
#include <luabind/class.hpp>
#include <luabind/luabind.hpp>
#include <luabind/function.hpp>
#include <luabind/get_main_thread.hpp>
#include <luabind/set_package_preload.hpp>
#include <luabind/function_introspection.hpp>
#include <luabind/detail/garbage_collector.hpp>
namespace luabind {
namespace
{
namespace
{
int make_property(lua_State* L)
{
int args = lua_gettop(L);
int make_property(lua_State* L)
{
int args = lua_gettop(L);
if(args == 0 || args > 2)
{
lua_pushstring(L, "make_property() called with wrong number of arguments.");
lua_error(L);
}
if (args == 0 || args > 2)
{
lua_pushstring(L, "make_property() called with wrong number of arguments.");
lua_error(L);
}
if(args == 1)
lua_pushnil(L);
if (args == 1)
lua_pushnil(L);
lua_pushcclosure(L, &detail::property_tag, 2);
return 1;
}
lua_pushcclosure(L, &detail::property_tag, 2);
return 1;
}
int main_thread_tag;
int main_thread_tag;
int deprecated_super(lua_State* L)
{
lua_pushstring(L,
"DEPRECATION: 'super' has been deprecated in favor of "
"directly calling the base class __init() function. "
"This error can be disabled by calling 'luabind::disable_super_deprecation()'."
);
lua_error(L);
int deprecated_super(lua_State* L)
{
lua_pushstring(L,
"DEPRECATION: 'super' has been deprecated in favor of "
"directly calling the base class __init() function. "
"This error can be disabled by calling 'luabind::disable_super_deprecation()'."
);
lua_error(L);
return 0;
}
return 0;
}
} // namespace unnamed
int destroy_class_id_map(lua_State* L)
{
detail::class_id_map* m =
(detail::class_id_map*)lua_touserdata(L, 1);
m->~class_id_map();
return 0;
}
LUABIND_API lua_State* get_main_thread(lua_State* L)
{
lua_pushlightuserdata(L, &main_thread_tag);
lua_rawget(L, LUA_REGISTRYINDEX);
lua_State* result = static_cast<lua_State*>(lua_touserdata(L, -1));
lua_pop(L, 1);
int destroy_cast_graph(lua_State* L)
{
detail::cast_graph* g =
(detail::cast_graph*)lua_touserdata(L, 1);
g->~cast_graph();
return 0;
}
if(!result)
throw std::runtime_error("Unable to get main thread, luabind::open() not called?");
int destroy_class_map(lua_State* L)
{
detail::class_map* m =
(detail::class_map*)lua_touserdata(L, 1);
m->~class_map();
return 0;
}
return result;
}
} // namespace unnamed
namespace {
LUABIND_API lua_State* get_main_thread(lua_State* L)
{
lua_pushlightuserdata(L, &main_thread_tag);
lua_rawget(L, LUA_REGISTRYINDEX);
lua_State* result = static_cast<lua_State*>(lua_touserdata(L, -1));
lua_pop(L, 1);
template<typename T>
inline void * shared_create_userdata(lua_State* L, const char * name) {
lua_pushstring(L, name);
void* storage = lua_newuserdata(L, sizeof(T));
if (!result)
throw std::runtime_error("Unable to get main thread, luabind::open() not called?");
// set gc metatable
lua_newtable(L);
lua_pushcclosure(L, &detail::garbage_collector<T>, 0);
lua_setfield(L, -2, "__gc");
lua_setmetatable(L, -2);
return result;
}
lua_settable(L, LUA_REGISTRYINDEX);
return storage;
}
LUABIND_API void open(lua_State* L)
{
bool is_main_thread = lua_pushthread(L) == 1;
lua_pop(L, 1);
template<typename T>
inline void createGarbageCollectedRegistryUserdata(lua_State* L, const char * name) {
void * storage = shared_create_userdata<T>(L, name);
// placement "new"
new (storage) T;
}
if (!is_main_thread)
{
throw std::runtime_error(
"luabind::open() must be called with the main thread "
"lua_State*"
);
}
template<typename T, typename A1>
inline void createGarbageCollectedRegistryUserdata(lua_State* L, const char * name, A1 constructorArg) {
void * storage = shared_create_userdata<T>(L, name);
if (detail::class_registry::get_registry(L))
return;
// placement "new"
new (storage) T(constructorArg);
}
lua_pushstring(L, "__luabind_classes");
detail::class_registry* r = static_cast<detail::class_registry*>(
lua_newuserdata(L, sizeof(detail::class_registry)));
} // namespace anonymous
// set gc metatable
lua_newtable(L);
lua_pushstring(L, "__gc");
lua_pushcclosure(
L
, detail::garbage_collector_s<
detail::class_registry
>::apply
, 0);
LUABIND_API void open(lua_State* L)
{
bool is_main_thread = lua_pushthread(L) == 1;
lua_pop(L, 1);
lua_settable(L, -3);
lua_setmetatable(L, -2);
if(!is_main_thread)
{
throw std::runtime_error(
"luabind::open() must be called with the main thread "
"lua_State*"
);
}
new(r) detail::class_registry(L);
lua_settable(L, LUA_REGISTRYINDEX);
createGarbageCollectedRegistryUserdata<detail::class_registry>(L, "__luabind_classes", L);
createGarbageCollectedRegistryUserdata<detail::class_id_map>(L, "__luabind_class_id_map");
createGarbageCollectedRegistryUserdata<detail::cast_graph>(L, "__luabind_cast_graph");
createGarbageCollectedRegistryUserdata<detail::class_map>(L, "__luabind_class_map");
lua_pushstring(L, "__luabind_class_id_map");
void* classes_storage = lua_newuserdata(L, sizeof(detail::class_id_map));
detail::class_id_map* class_ids = new (classes_storage) detail::class_id_map;
(void)class_ids;
// add functions (class, cast etc...)
lua_pushcclosure(L, detail::create_class::stage1, 0);
lua_setglobal(L, "class");
lua_newtable(L);
lua_pushcclosure(L, &destroy_class_id_map, 0);
lua_setfield(L, -2, "__gc");
lua_setmetatable(L, -2);
lua_pushcclosure(L, &make_property, 0);
lua_setglobal(L, "property");
lua_settable(L, LUA_REGISTRYINDEX);
lua_pushlightuserdata(L, &main_thread_tag);
lua_pushlightuserdata(L, L);
lua_rawset(L, LUA_REGISTRYINDEX);
lua_pushstring(L, "__luabind_cast_graph");
void* cast_graph_storage = lua_newuserdata(
L, sizeof(detail::cast_graph));
detail::cast_graph* graph = new (cast_graph_storage) detail::cast_graph;
(void)graph;
lua_pushcclosure(L, &deprecated_super, 0);
lua_setglobal(L, "super");
}
lua_newtable(L);
lua_pushcclosure(L, &destroy_cast_graph, 0);
lua_setfield(L, -2, "__gc");
lua_setmetatable(L, -2);
lua_settable(L, LUA_REGISTRYINDEX);
lua_pushstring(L, "__luabind_class_map");
void* class_map_storage = lua_newuserdata(
L, sizeof(detail::class_map));
detail::class_map* classes = new (class_map_storage) detail::class_map;
(void)classes;
lua_newtable(L);
lua_pushcclosure(L, &destroy_class_map, 0);
lua_setfield(L, -2, "__gc");
lua_setmetatable(L, -2);
lua_settable(L, LUA_REGISTRYINDEX);
// add functions (class, cast etc...)
lua_pushcclosure(L, detail::create_class::stage1, 0);
lua_setglobal(L, "class");
lua_pushcclosure(L, &make_property, 0);
lua_setglobal(L, "property");
lua_pushlightuserdata(L, &main_thread_tag);
lua_pushlightuserdata(L, L);
lua_rawset(L, LUA_REGISTRYINDEX);
lua_pushcclosure(L, &deprecated_super, 0);
lua_setglobal(L, "super");
}
} // namespace luabind