This commit is contained in:
blueloveTH 2024-01-16 16:27:36 +08:00
parent 3489567386
commit 0b98c7b0bf
2 changed files with 8 additions and 1 deletions

View File

@ -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:

View File

@ -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>(PyLuaTable::_type(vm));
PyObject* obj = vm->heap.gcnew<PyLuaTable>(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<PyLuaFunction>(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");