From 0b98c7b0bfccd5f48ea538d7ac05847ab0559beb Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Tue, 16 Jan 2024 16:27:36 +0800 Subject: [PATCH] ... --- .github/workflows/main.yml | 5 +++++ 3rd/lua_bridge/src/lua_bridge.cpp | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ae76353..3f5d37af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,6 +65,11 @@ jobs: run: python3 scripts/run_tests.py benchmark - name: C Binding Test run: bash run_c_binding_test.sh + - name: Lua Bridge Test + run: | + cd examples/python-call-lua + bash build.sh + ./main build_linux_x86: runs-on: ubuntu-latest steps: diff --git a/3rd/lua_bridge/src/lua_bridge.cpp b/3rd/lua_bridge/src/lua_bridge.cpp index ed464c98..c7c496c0 100644 --- a/3rd/lua_bridge/src/lua_bridge.cpp +++ b/3rd/lua_bridge/src/lua_bridge.cpp @@ -43,6 +43,7 @@ struct PyLuaTable: PyLuaObject{ static void _register(VM* vm, PyObject* mod, PyObject* type){ Type t = PK_OBJ_GET(Type, type); PyTypeInfo* ti = &vm->_all_types[t]; + ti->subclass_enabled = false; ti->m__getattr__ = [](VM* vm, PyObject* obj, StrName name){ const PyLuaTable& self = _CAST(PyLuaTable&, obj); LUA_PROTECTED( @@ -68,7 +69,7 @@ struct PyLuaTable: PyLuaObject{ vm->bind_constructor<1>(type, [](VM* vm, ArgsView args){ lua_newtable(_L); // push an empty table onto the stack - PyObject* obj = vm->heap.gcnew(PyLuaTable::_type(vm)); + PyObject* obj = vm->heap.gcnew(PK_OBJ_GET(Type, args[0])); return obj; }); @@ -186,6 +187,7 @@ struct PyLuaFunction: PyLuaObject{ static void _register(VM* vm, PyObject* mod, PyObject* type){ vm->bind_notimplemented_constructor(type); + vm->_all_types[PK_OBJ_GET(Type, type)].subclass_enabled = false; vm->bind_method<-1>(type, "__call__", [](VM* vm, ArgsView args){ if(args.size() < 1) vm->TypeError("__call__ takes at least 1 argument");