ScummVM API documentation
lua_persistence_util.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distri8buted in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
26/* Tamed Pluto - Heavy-duty persistence for Lua
27 * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
28 * domain. People making use of this software as part of an application
29 * are politely requested to email the author at sneftel@gmail.com
30 * with a brief description of the application, primarily to satisfy his
31 * curiosity.
32 *
33 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
35 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
36 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
37 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
38 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
39 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 *
41 * Instrumented by Stefan Reich (info@luaos.net)
42 * for Mobile Lua (http://luaos.net/pages/mobile-lua.php)
43 */
44
45
46#ifndef LUA_PERISTENCE_UTIL_H
47#define LUA_PERISTENCE_UTIL_H
48
49
50struct lua_State;
51
52#include "lobject.h"
53
54typedef TValue *StkId;
55
56namespace Lua {
57
58#define lua_malloc(luaState, nsize) lua_realloc(luaState, nullptr, 0, nsize)
59#define lua_reallocv(luaState, block, on, n, e) lua_realloc(luaState, block, (on) * (e), (n) * (e))
60#define lua_reallocvector(luaState, vec, oldn, n, T) ((vec) = (T *)(lua_reallocv(luaState, vec, oldn, n, sizeof(T))))
61#define lua_newVector(luaState, num, T) ((T *)lua_reallocv(luaState, nullptr, 0, num, sizeof(T)))
62#define lua_new(luaState,T) (T *)lua_malloc(luaState, sizeof(T))
63
64void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize);
65
66void pushObject(lua_State *luaState, TValue *obj);
67void pushProto(lua_State *luaState, Proto *proto);
68void pushUpValue(lua_State *luaState, UpVal *upval);
69void pushString(lua_State *luaState, TString *str);
70
71StkId getObject(lua_State *luaState, int stackpos);
72
73void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type);
74
75#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1))
76
77Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable);
78void pushClosure(lua_State *luaState, Closure *closure);
79
80Proto *createProto(lua_State *luaState);
81Proto *makeFakeProto(lua_State *L, lu_byte nups);
82
83TString *createString(lua_State *luaState, const char *str, size_t len);
84
85UpVal *createUpValue(lua_State *luaState, int stackpos);
86void unboxUpValue(lua_State *luaState);
87
88/* Appends one stack to another stack, but the stack is reversed in the process */
89size_t appendStackToStack_reverse(lua_State *from, lua_State *to);
90void correctStack(lua_State *L, TValue *oldstack);
91void lua_reallocstack(lua_State *L, int newsize);
92
93void lua_reallocCallInfo(lua_State *lauState, int newsize);
94
95/* Does basically the opposite of luaC_link().
96 * Right now this function is rather inefficient; it requires traversing the
97 * entire root GC set in order to find one object. If the GC list were doubly
98 * linked this would be much easier, but there's no reason for Lua to have
99 * that. */
100void GCUnlink(lua_State *luaState, GCObject *gco);
101
102TString *lua_newlstr(lua_State *luaState, const char *str, size_t len);
103void lua_link(lua_State *luaState, GCObject *o, lu_byte tt);
104Proto *lua_newproto(lua_State *luaState) ;
105
106UpVal *makeUpValue(lua_State *luaState, int stackPos);
115void boxUpValue_start(lua_State *luaState);
116void boxUpValue_finish(lua_State *luaState);
117
118} // End of namespace Lua
119
120#endif
Definition: lobject.h:231
Definition: lobject.h:338
Definition: lobject.h:274
Definition: lstate.h:100
Definition: lobject.h:73
Definition: lobject.h:309
Definition: lstate.h:136
Definition: lobject.h:199