This commit is contained in:
blueloveTH 2023-04-30 14:42:17 +08:00
parent e33d9fe595
commit e5d5f09d83

View File

@ -12,17 +12,23 @@ struct Function;
class VM;
typedef PyObject* (*NativeFuncC)(VM*, ArgsView);
typedef shared_ptr<CodeObject> 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> CodeObject_;
struct FuncDecl {
struct KwArg {
int key; // index in co->varnames