|
31 | 31 | #include "../LuaError.hpp" |
32 | 32 | #include "../LuaFunction.hpp" |
33 | 33 | #include "../LuaTable.hpp" |
34 | | -#include "../utils/MethodBindByName.hpp" |
35 | 34 | #include "../utils/VariantArguments.hpp" |
36 | 35 | #include "../utils/convert_godot_lua.hpp" |
37 | 36 | #include "../utils/function_wrapper.hpp" |
| 37 | +#include "../utils/method_bind_impl.hpp" |
38 | 38 | #include "../utils/string_names.hpp" |
39 | 39 |
|
40 | 40 | namespace luagdextension { |
@@ -328,7 +328,7 @@ static int lua_index(lua_State *L) { |
328 | 328 | if (LuaScriptInstance *instance = LuaScriptInstance::find_instance(self)) { |
329 | 329 | StringName key_name = key.as<StringName>(); |
330 | 330 | if (instance->owner->has_method(key_name)) { |
331 | | - sol::stack::push(L, MethodBindByName(key_name)); |
| 331 | + sol::stack::push(L, LuaScriptInstanceMethodBind(instance, key_name)); |
332 | 332 | } |
333 | 333 | else { |
334 | 334 | Variant value = instance->owner->get(key_name); |
@@ -368,14 +368,16 @@ static int lua_to_string(lua_State *L) { |
368 | 368 | } |
369 | 369 |
|
370 | 370 | void LuaScriptInstance::register_lua(lua_State *L) { |
371 | | - metatable = sol::state_view(L).create_table_with( |
| 371 | + sol::state_view state(L); |
| 372 | + metatable = state.create_table_with( |
372 | 373 | "__index", lua_index, |
373 | 374 | "__newindex", lua_newindex, |
374 | 375 | "__tostring", lua_to_string, |
375 | 376 | "__metatable", "LuaScriptInstance" |
376 | 377 | ); |
377 | 378 | rawget = wrap_function(L, _rawget); |
378 | 379 | rawset = wrap_function(L, _rawset); |
| 380 | + LuaScriptInstanceMethodBind::register_usertype(state); |
379 | 381 | } |
380 | 382 |
|
381 | 383 | void LuaScriptInstance::unregister_lua(lua_State *L) { |
|
0 commit comments