mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Fiiixes! Thanks to @CatPlusPlus and @melak47 for helping me fix this one.
Closes #112 .
This commit is contained in:
parent
c079c86d99
commit
58fc314e6f
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -59,3 +59,6 @@ docs/build/
|
||||||
m.lua
|
m.lua
|
||||||
single/sol.hpp
|
single/sol.hpp
|
||||||
*.db
|
*.db
|
||||||
|
lua53.dll
|
||||||
|
main.exe
|
||||||
|
main.o
|
||||||
|
|
|
@ -246,12 +246,6 @@ namespace sol {
|
||||||
return f.find_call(std::false_type(), std::make_index_sequence<std::tuple_size<Tuple>::value>(), L, accessor);
|
return f.find_call(std::false_type(), std::make_index_sequence<std::tuple_size<Tuple>::value>(), L, accessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gc_call(lua_State* L) {
|
|
||||||
usertype_metatable& f = stack::get<light<usertype_metatable>>(L, up_value_index(1));
|
|
||||||
f.~usertype_metatable();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int push_um(lua_State* L) override {
|
virtual int push_um(lua_State* L) override {
|
||||||
return stack::push(L, std::move(*this));
|
return stack::push(L, std::move(*this));
|
||||||
}
|
}
|
||||||
|
@ -335,10 +329,15 @@ namespace sol {
|
||||||
t.pop();
|
t.pop();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// NOT NEEDED
|
||||||
|
// Perhaps we should look into
|
||||||
|
// whether or not doing ti like this
|
||||||
|
// is better than just letting user<T> handle it?
|
||||||
|
|
||||||
// Add cleanup to metatable
|
// Add cleanup to metatable
|
||||||
// Essentially, when the metatable dies,
|
// Essentially, when the metatable dies,
|
||||||
// this too will call the class and kill itself
|
// this too will call the class and kill itself
|
||||||
const char* metakey = &usertype_traits<T>::gc_table[0];
|
/*const char* metakey = &usertype_traits<T>::gc_table[0];
|
||||||
lua_createtable(L, 1, 0);
|
lua_createtable(L, 1, 0);
|
||||||
stack_reference cleanup(L, -1);
|
stack_reference cleanup(L, -1);
|
||||||
stack::set_field(L, meta_function::garbage_collect, make_closure(umt_t::gc_call, umt), cleanup.stack_index());
|
stack::set_field(L, meta_function::garbage_collect, make_closure(umt_t::gc_call, umt), cleanup.stack_index());
|
||||||
|
@ -348,7 +347,7 @@ namespace sol {
|
||||||
// otherwise, it will trigger the __index metamethod
|
// otherwise, it will trigger the __index metamethod
|
||||||
// we just set
|
// we just set
|
||||||
stack::raw_set_field(L, metakey, t, t.stack_index());
|
stack::raw_set_field(L, metakey, t, t.stack_index());
|
||||||
cleanup.pop();
|
cleanup.pop();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user