More work on moving engine into dlmalloc heap

This commit is contained in:
2022-02-25 19:57:23 -05:00
parent 08f6aa2092
commit ff932dba10
52 changed files with 351 additions and 484 deletions

View File

@@ -155,7 +155,6 @@
#define LUASTACK_HPP
#include "wrap-string.hpp"
#include "wrap-vector.hpp"
extern "C" {
#include "lua.h"
@@ -296,6 +295,7 @@ private:
void push_any_value(LuaNilMarker s) const { lua_pushnil(L_); }
void push_any_value(LuaSlot s) const { lua_pushvalue(L_, s); }
void push_any_value(const eng::string &s) const { lua_pushlstring(L_, s.c_str(), s.size()); }
void push_any_value(std::string_view s) const { lua_pushlstring(L_, s.data(), s.size()); }
void push_any_value(const char *s) const { lua_pushstring(L_, s); }
void push_any_value(float s) const { lua_pushnumber(L_, s); }
void push_any_value(double s) const { lua_pushnumber(L_, s); }
@@ -334,6 +334,8 @@ public:
int result();
public:
static lua_State *newstate (lua_Alloc allocf);
lua_State *state() const { return L_; }
int type(LuaSlot s) const { return lua_type(L_, s); }
@@ -379,7 +381,7 @@ public:
// Return true if the classname is legal.
bool validclassname(LuaSlot value) const;
static bool validclassname(const eng::string &cname);
static bool validclassname(std::string_view cname);
// Return the class name if x is a valid classtab.
// Otherwise, returns empty string. If nonempty, the
@@ -392,15 +394,13 @@ public:
// There are lots of error conditions, including such things
// as no such class, corrupted class, classname invalid, etc.
eng::string getclass(LuaSlot tab, LuaSlot name) const;
eng::string getclass(LuaSlot tab, const char *name) const;
eng::string getclass(LuaSlot tab, const eng::string &name) const;
eng::string getclass(LuaSlot tab, std::string_view name) const;
// Create a class, or look up an existing class.
// WARNING: this routine assert-fails if the parameter is not
// a valid classname. Check the classname before calling this!
void makeclass(LuaSlot tab, LuaSlot name) const;
void makeclass(LuaSlot tab, const char *name) const;
void makeclass(LuaSlot tab, const eng::string &name) const;
void makeclass(LuaSlot tab, std::string_view name) const;
// Get the ID of a tangible. It's a little weird to put this in
// this module.
@@ -478,19 +478,16 @@ private:
lua_CFunction func_;
LuaFunctionReg *next_;
static LuaFunctionReg *LuaFunctionRegistry;
public:
using List = eng::vector<LuaFunctionReg *>;
static LuaFunctionReg *All;
LuaFunctionReg(const char *name, const char *args, const char *docs, lua_CFunction f);
static List all();
static const LuaFunctionReg *lookup(lua_CFunction fn);
const char *get_name() const { return name_; }
const char *get_args() const { return args_; }
const char *get_docs() const { return docs_; }
lua_CFunction get_func() const { return func_; }
LuaFunctionReg *next() const { return next_; }
void set_func(lua_CFunction fn) { func_ = fn; }
};