New calling conventions, start on print.cpp

This commit is contained in:
2021-09-07 17:37:23 -04:00
parent 924a5ec987
commit 6b2ebba84d
16 changed files with 216 additions and 104 deletions

View File

@@ -319,38 +319,6 @@ private:
void push_any_values() {
}
// Call the CFunction, pushing and popping arguments appropriately.
template<int NRET, typename... T>
void call_cfunction(int otop, LuaSlot s, T... args) {
call_cfunction<NRET+1>(otop, args...);
pop_any_value(s);
}
template<int NRET, typename... T>
void call_cfunction(int otop, lua_Integer &s, T... args) {
call_cfunction<NRET+1>(otop, args...);
pop_any_value(s);
}
template<int NRET, typename... T>
void call_cfunction(int otop, lua_Number &s, T... args) {
call_cfunction<NRET+1>(otop, args...);
pop_any_value(s);
}
template<int NRET, typename... T>
void call_cfunction(int otop, std::string &s, T... args) {
call_cfunction<NRET+1>(otop, args...);
pop_any_value(s);
}
template<int NRET, typename... T>
void call_cfunction(int otop, lua_CFunction fn, T... args) {
push_any_values(args...);
int nret = fn(L_);
check_nret(NRET, otop, nret);
}
// Check number of return values: xpected number of return values,
// original stack top, and number of declared return values.
void check_nret(int xnret, int otop, int nret) const;
template<typename T>
static void delete_pointer(void *p) { delete (T*)p; }
static void do_not_delete(void *p) { }
@@ -477,14 +445,6 @@ public:
lua_rawseti(L_, tab, key);
}
// Call invokes any C function. It pushes the arguments on the stack,
// calls the cfunction, verifies that the number of return values is as
// expected, and pops the return values into LuaVars.
template<typename... T>
void call(T&... args) {
call_cfunction<0>(lua_gettop(L_), args...);
}
// Lua flagbits manipulation: Table types.
int gettabletype(LuaSlot tab) const;
void settabletype(LuaSlot tab, int t) const;
@@ -521,9 +481,9 @@ public:
#define LuaDefine(name, mode) \
int name(lua_State *L); \
LuaFunctionReg reg_##name(mode, #name, name); \
int name(lua_State *L)
int lfn_##name(lua_State *L); \
LuaFunctionReg reg_##name(mode, #name, lfn_##name); \
int lfn_##name(lua_State *L)
#define LuaStringify(x) #x