From e5d5f09d83ba6e77e2950e0b23528cef656f316b Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 30 Apr 2023 14:42:17 +0800 Subject: [PATCH] ... --- src/obj.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/obj.h b/src/obj.h index 5dd9ffab..9cc17c63 100644 --- a/src/obj.h +++ b/src/obj.h @@ -12,17 +12,23 @@ struct Function; class VM; typedef PyObject* (*NativeFuncC)(VM*, ArgsView); -typedef shared_ptr CodeObject_; +typedef int (*LuaStyleFuncC)(VM*); struct NativeFunc { NativeFuncC f; int argc; // DONOT include self bool method; + + // this is designed for lua style C bindings + // access it via `CAST(NativeFunc&, args[-2])._lua_f` + LuaStyleFuncC _lua_f; - NativeFunc(NativeFuncC f, int argc, bool method) : f(f), argc(argc), method(method) {} + NativeFunc(NativeFuncC f, int argc, bool method) : f(f), argc(argc), method(method), _lua_f(nullptr) {} PyObject* operator()(VM* vm, ArgsView args) const; }; +typedef shared_ptr CodeObject_; + struct FuncDecl { struct KwArg { int key; // index in co->varnames