Added two new stack disciplines to LuaStack
This commit is contained in:
@@ -42,7 +42,7 @@ World::World(WorldType wt) {
|
||||
|
||||
// Prepare to manipulate the lua state.
|
||||
LuaVar world, globtab;
|
||||
LuaStack LS(state(), world, globtab);
|
||||
LuaOldStack LS(state(), world, globtab);
|
||||
|
||||
// Put the world pointer into the lua registry.
|
||||
World::store_global_pointer(state(), this);
|
||||
@@ -134,7 +134,7 @@ World::TanVector World::tangible_get_all(const IdVector &ids) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
Tangible *World::tangible_get(const LuaStack &LS, LuaSlot tab, bool allowdel) {
|
||||
Tangible *World::tangible_get(const LuaCoreStack &LS, LuaSlot tab, bool allowdel) {
|
||||
int64_t id = LS.tanid(tab);
|
||||
if (id == 0) {
|
||||
luaL_error(LS.state(), "parameter is not a tangible");
|
||||
@@ -158,7 +158,7 @@ Tangible *World::tangible_make(lua_State *L, int64_t id, const eng::string &plan
|
||||
|
||||
LuaVar metatab;
|
||||
LuaRet database;
|
||||
LuaStack LS(L, database, metatab);
|
||||
LuaOldStack LS(L, database, metatab);
|
||||
|
||||
// Create the C++ part of the structure.
|
||||
UniqueTangible &t = tangibles_[id];
|
||||
@@ -185,7 +185,7 @@ Tangible *World::tangible_make(lua_State *L, int64_t id, const eng::string &plan
|
||||
void World::tangible_delete(int64_t id) {
|
||||
lua_State *L = state();
|
||||
LuaVar tangibles, database, metatab;
|
||||
LuaStack LS(L, tangibles, database, metatab);
|
||||
LuaOldStack LS(L, tangibles, database, metatab);
|
||||
|
||||
// Fetch the C++ side of the tangible.
|
||||
auto iter = tangibles_.find(id);
|
||||
@@ -243,7 +243,7 @@ int64_t World::create_login_actor() {
|
||||
Tangible *tan = tangible_make(state(), id, "nowhere", true);
|
||||
LuaArg database;
|
||||
LuaVar classtab, mt;
|
||||
LuaStack LS(state(), database, classtab, mt);
|
||||
LuaOldStack LS(state(), database, classtab, mt);
|
||||
LS.makeclass(classtab, "login");
|
||||
LS.getmetatable(mt, database);
|
||||
LS.rawset(mt, "__index", classtab);
|
||||
@@ -264,7 +264,7 @@ eng::string World::probe_lua(int64_t actor_id, const eng::string &lua) {
|
||||
}
|
||||
|
||||
LuaVar closure;
|
||||
LuaStack LS(L, closure);
|
||||
LuaOldStack LS(L, closure);
|
||||
|
||||
// create the compiled closure.
|
||||
int status = luaL_loadbuffer(L, lua.c_str(), lua.size(), "=probe");
|
||||
@@ -316,7 +316,7 @@ void World::update_gui(int64_t actor_id, int64_t place_id, Gui *gui) {
|
||||
lua_State *L = state();
|
||||
|
||||
LuaVar actor, place, ugui, func, tangibles, mt, index;
|
||||
LuaStack LS(L, actor, place, ugui, func, tangibles, mt, index);
|
||||
LuaOldStack LS(L, actor, place, ugui, func, tangibles, mt, index);
|
||||
|
||||
// Get the actor and place.
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
@@ -394,7 +394,7 @@ void World::http_response(const HttpParser &response) {
|
||||
|
||||
// Get the place and thread as lua objects.
|
||||
LuaVar tangibles, place, mt, threads, thinfo, thread;
|
||||
LuaStack LS(state(), tangibles, place, mt, threads, thinfo, thread);
|
||||
LuaOldStack LS(state(), tangibles, place, mt, threads, thinfo, thread);
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
LS.rawget(place, tangibles, request.place_id());
|
||||
if (!LS.istable(place)) {
|
||||
@@ -420,7 +420,7 @@ void World::http_response(const HttpParser &response) {
|
||||
|
||||
// Push the response onto the awakening thread.
|
||||
LuaRet responsetable;
|
||||
LuaStack LSCO(CO, responsetable);
|
||||
LuaOldStack LSCO(CO, responsetable);
|
||||
response.store(LSCO, responsetable);
|
||||
|
||||
// Clean up lua stacks.
|
||||
@@ -475,7 +475,7 @@ HttpServerResponse World::http_serve(const HttpParser &request) {
|
||||
|
||||
lua_State *L = state();
|
||||
LuaVar www, func, reqtab;
|
||||
LuaStack LS(L, www, func, reqtab);
|
||||
LuaOldStack LS(L, www, func, reqtab);
|
||||
|
||||
// Get the www class. If there's no such class,
|
||||
// return a 503 Service Unavailable to the client.
|
||||
@@ -605,7 +605,7 @@ void World::invoke_lua(int64_t actor_id, int64_t place_id, const eng::string &ac
|
||||
// Set up for lua manipulation.
|
||||
lua_State *L = state();
|
||||
LuaVar func, tangibles, place, mt, thread, thinfo, threads;
|
||||
LuaStack LS(L, func, tangibles, place, mt, thread, thinfo, threads);
|
||||
LuaOldStack LS(L, func, tangibles, place, mt, thread, thinfo, threads);
|
||||
|
||||
// create the compiled closure.
|
||||
int status = luaL_loadbuffer(L, action.c_str(), action.size(), "=invoke");
|
||||
@@ -689,7 +689,7 @@ void World::invoke_plan(int64_t actor_id, int64_t place_id, const eng::string &a
|
||||
// Set up for Lua manipulation.
|
||||
lua_State *L = state();
|
||||
LuaVar actor, place, func, tangibles, mt, index, thread, threads, thinfo, message, invdata;
|
||||
LuaStack LS(L, actor, place, func, tangibles, mt, index, thread, threads, thinfo, message, invdata);
|
||||
LuaOldStack LS(L, actor, place, func, tangibles, mt, index, thread, threads, thinfo, message, invdata);
|
||||
|
||||
// Get the actor and place.
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
@@ -794,7 +794,7 @@ void World::guard_blockable(lua_State *L, const char *fn) {
|
||||
|
||||
void World::guard_nopredict(lua_State *L, const char *fn) {
|
||||
// Caution: this code must be equivalent to the
|
||||
// code in LuaStack::guard_nopredict.
|
||||
// code in LuaOldStack::guard_nopredict.
|
||||
if (lthread_thread_id_ == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -815,7 +815,7 @@ void World::run_scheduled_threads() {
|
||||
assert(stack_is_clear());
|
||||
lua_State *L = state();
|
||||
LuaVar tangibles, place, mt, threads, thinfo, actorid, isnew, useppool, thread, print;
|
||||
LuaStack LS(L, tangibles, place, mt, threads, thinfo, actorid, isnew, useppool, thread, print);
|
||||
LuaOldStack LS(L, tangibles, place, mt, threads, thinfo, actorid, isnew, useppool, thread, print);
|
||||
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
while (thread_sched_.ready(clock_)) {
|
||||
@@ -865,7 +865,7 @@ void World::run_scheduled_threads() {
|
||||
// Remove from thread table.
|
||||
LS.rawget(print, thinfo, "print");
|
||||
LS.rawset(threads, sched.thread_id(), LuaNil);
|
||||
LuaStack LSCO(CO);
|
||||
LuaOldStack LSCO(CO);
|
||||
if (LS.ckboolean(print)) {
|
||||
for (int i = 1; i <= lua_gettop(CO); i++) {
|
||||
pprint(LSCO, LuaSpecial(i), PrettyPrintOptions(), ostream);
|
||||
|
||||
Reference in New Issue
Block a user