[Scummvm-cvs-logs] SF.net SVN: scummvm:[33147] residual/trunk/engine/lua
aquadran at users.sourceforge.net
aquadran at users.sourceforge.net
Sun Jul 20 23:08:47 CEST 2008
Revision: 33147
http://scummvm.svn.sourceforge.net/scummvm/?rev=33147&view=rev
Author: aquadran
Date: 2008-07-20 21:08:22 +0000 (Sun, 20 Jul 2008)
Log Message:
-----------
unify types
Modified Paths:
--------------
residual/trunk/engine/lua/lapi.cpp
residual/trunk/engine/lua/lapi.h
residual/trunk/engine/lua/lauxlib.cpp
residual/trunk/engine/lua/lauxlib.h
residual/trunk/engine/lua/lbuffer.cpp
residual/trunk/engine/lua/lbuiltin.cpp
residual/trunk/engine/lua/ldo.cpp
residual/trunk/engine/lua/ldo.h
residual/trunk/engine/lua/lfunc.cpp
residual/trunk/engine/lua/lfunc.h
residual/trunk/engine/lua/lgc.cpp
residual/trunk/engine/lua/lgc.h
residual/trunk/engine/lua/liolib.cpp
residual/trunk/engine/lua/llex.cpp
residual/trunk/engine/lua/llex.h
residual/trunk/engine/lua/lmathlib.cpp
residual/trunk/engine/lua/lmem.cpp
residual/trunk/engine/lua/lmem.h
residual/trunk/engine/lua/lobject.cpp
residual/trunk/engine/lua/lobject.h
residual/trunk/engine/lua/lparser.cpp
residual/trunk/engine/lua/lparser.h
residual/trunk/engine/lua/lrestore.cpp
residual/trunk/engine/lua/lsave.cpp
residual/trunk/engine/lua/lstate.cpp
residual/trunk/engine/lua/lstate.h
residual/trunk/engine/lua/lstring.cpp
residual/trunk/engine/lua/lstring.h
residual/trunk/engine/lua/lstrlib.cpp
residual/trunk/engine/lua/ltable.cpp
residual/trunk/engine/lua/ltable.h
residual/trunk/engine/lua/ltask.cpp
residual/trunk/engine/lua/ltask.h
residual/trunk/engine/lua/ltm.cpp
residual/trunk/engine/lua/ltm.h
residual/trunk/engine/lua/lua.h
residual/trunk/engine/lua/luadebug.h
residual/trunk/engine/lua/lualib.h
residual/trunk/engine/lua/lundump.cpp
residual/trunk/engine/lua/lvm.cpp
residual/trunk/engine/lua/lvm.h
residual/trunk/engine/lua/lzio.cpp
residual/trunk/engine/lua/lzio.h
Modified: residual/trunk/engine/lua/lapi.cpp
===================================================================
--- residual/trunk/engine/lua/lapi.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lapi.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,9 +5,6 @@
*/
-#include <stdlib.h>
-#include <string.h>
-
#include "lapi.h"
#include "lauxlib.h"
#include "ldo.h"
@@ -35,9 +32,9 @@
}
-static int normalized_type (TObject *o)
+static int32 normalized_type (TObject *o)
{
- int t = ttype(o);
+ int32 t = ttype(o);
switch (t) {
case LUA_T_PMARK:
return LUA_T_PROTO;
@@ -71,7 +68,7 @@
}
-int luaA_passresults (void)
+int32 luaA_passresults (void)
{
luaD_checkstack(L->Cstack.num);
memcpy(L->stack.top, L->Cstack.lua2C+L->stack.stack,
@@ -81,7 +78,7 @@
}
-static void checkCparams (int nParams)
+static void checkCparams (int32 nParams)
{
if (L->stack.top-L->stack.stack < L->Cstack.base+nParams)
lua_error("API error - wrong number of arguments in C2lua stack");
@@ -115,7 +112,7 @@
** Get a parameter, returning the object handle or LUA_NOOBJECT on error.
** 'number' must be 1 to get the first parameter.
*/
-lua_Object lua_lua2C (int number)
+lua_Object lua_lua2C (int32 number)
{
if (number <= 0 || number > L->Cstack.num) return LUA_NOOBJECT;
/* Ref(L->stack.stack+(L->Cstack.lua2C+number-1)) ==
@@ -124,7 +121,7 @@
}
-int lua_callfunction (lua_Object function)
+int32 lua_callfunction (lua_Object function)
{
if (function == LUA_NOOBJECT)
return 1;
@@ -136,13 +133,13 @@
}
-lua_Object lua_gettagmethod (int tag, const char *event)
+lua_Object lua_gettagmethod (int32 tag, const char *event)
{
return put_luaObject(luaT_gettagmethod(tag, event));
}
-lua_Object lua_settagmethod (int tag, const char *event)
+lua_Object lua_settagmethod (int32 tag, const char *event)
{
checkCparams(1);
luaT_settagmethod(tag, event, L->stack.top-1);
@@ -240,40 +237,40 @@
-int lua_isnil (lua_Object o)
+int32 lua_isnil (lua_Object o)
{
return (o == LUA_NOOBJECT) || (ttype(Address(o)) == LUA_T_NIL);
}
-int lua_istable (lua_Object o)
+int32 lua_istable (lua_Object o)
{
return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_ARRAY);
}
-int lua_isuserdata (lua_Object o)
+int32 lua_isuserdata (lua_Object o)
{
return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_USERDATA);
}
-int lua_iscfunction (lua_Object o)
+int32 lua_iscfunction (lua_Object o)
{
return (lua_tag(o) == LUA_T_CPROTO);
}
-int lua_isnumber (lua_Object o)
+int32 lua_isnumber (lua_Object o)
{
return (o!= LUA_NOOBJECT) && (tonumber(Address(o)) == 0);
}
-int lua_isstring (lua_Object o)
+int32 lua_isstring (lua_Object o)
{
- int t = lua_tag(o);
+ int32 t = lua_tag(o);
return (t == LUA_T_STRING) || (t == LUA_T_NUMBER);
}
-int lua_isfunction (lua_Object o)
+int32 lua_isfunction (lua_Object o)
{
- int t = lua_tag(o);
+ int32 t = lua_tag(o);
return (t == LUA_T_PROTO) || (t == LUA_T_CPROTO);
}
@@ -293,11 +290,11 @@
else return (svalue(Address(object)));
}
-long lua_strlen (lua_Object object)
+int32 lua_strlen (lua_Object object)
{
luaC_checkGC(); /* "tostring" may create a new string */
if (object == LUA_NOOBJECT || tostring(Address(object)))
- return 0L;
+ return 0;
else return (tsvalue(Address(object))->u.s.len);
}
@@ -329,7 +326,7 @@
incr_top;
}
-void lua_pushlstring (const char *s, long len)
+void lua_pushlstring (const char *s, int32 len)
{
tsvalue(L->stack.top) = luaS_newlstr(s, len);
ttype(L->stack.top) = LUA_T_STRING;
@@ -345,7 +342,7 @@
lua_pushlstring(s, strlen(s));
}
-void lua_pushcclosure (lua_CFunction fn, int n)
+void lua_pushcclosure (lua_CFunction fn, int32 n)
{
if (fn == NULL)
lua_error("API error - attempt to push a NULL Cfunction");
@@ -357,7 +354,7 @@
luaC_checkGC();
}
-void lua_pushusertag (void *u, int tag)
+void lua_pushusertag (void *u, int32 tag)
{
if (tag < 0 && tag != LUA_ANYTAG)
luaT_realtag(tag); /* error if tag is not valid */
@@ -384,13 +381,13 @@
}
-int lua_tag (lua_Object lo)
+int32 lua_tag (lua_Object lo)
{
if (lo == LUA_NOOBJECT)
return LUA_T_NIL;
else {
TObject *o = Address(lo);
- int t;
+ int32 t;
switch (t = ttype(o)) {
case LUA_T_USERDATA:
return o->value.ts->u.d.tag;
@@ -413,7 +410,7 @@
}
-void lua_settag (int tag)
+void lua_settag (int32 tag)
{
checkCparams(1);
luaT_realtag(tag);
@@ -444,11 +441,11 @@
lua_LHFunction lua_linehook = NULL;
-lua_Function lua_stackedfunction (int level)
+lua_Function lua_stackedfunction (int32 level)
{
StkId i;
for (i = (L->stack.top-1)-L->stack.stack; i>=0; i--) {
- int t = L->stack.stack[i].ttype;
+ int32 t = L->stack.stack[i].ttype;
if (t == LUA_T_CLMARK || t == LUA_T_PMARK || t == LUA_T_CMARK)
if (level-- == 0)
return Ref(L->stack.stack+i);
@@ -457,7 +454,7 @@
}
-int lua_currentline (lua_Function func)
+int32 lua_currentline (lua_Function func)
{
TObject *f = Address(func);
return (f+1 < L->stack.top && (f+1)->ttype == LUA_T_LINE) ?
@@ -465,7 +462,7 @@
}
-lua_Object lua_getlocal (lua_Function func, int local_number, char **name)
+lua_Object lua_getlocal (lua_Function func, int32 local_number, char **name)
{
/* check whether func is a Lua function */
if (lua_tag(func) != LUA_T_PROTO)
@@ -485,7 +482,7 @@
}
-int lua_setlocal (lua_Function func, int local_number)
+int32 lua_setlocal (lua_Function func, int32 local_number)
{
/* check whether func is a Lua function */
if (lua_tag(func) != LUA_T_PROTO)
@@ -508,7 +505,7 @@
}
-void lua_funcinfo (lua_Object func, const char **filename, int *linedefined)
+void lua_funcinfo (lua_Object func, const char **filename, int32 *linedefined)
{
if (!lua_isfunction(func))
lua_error("API - `funcinfo' called with a non-function value");
@@ -526,7 +523,7 @@
}
-static int checkfunc (TObject *o)
+static int32 checkfunc (TObject *o)
{
return luaO_equalObj(o, L->stack.top);
}
@@ -566,9 +563,9 @@
-int lua_ref (int lock)
+int32 lua_ref (int32 lock)
{
- int ref;
+ int32 ref;
checkCparams(1);
ref = luaC_ref(L->stack.top-1, lock);
L->stack.top--;
@@ -577,7 +574,7 @@
-lua_Object lua_getref (int ref)
+lua_Object lua_getref (int32 ref)
{
TObject *o = luaC_getref(ref);
return (o ? put_luaObject(o) : LUA_NOOBJECT);
@@ -589,11 +586,11 @@
** Derived functions
** =======================================================
*/
-int (lua_call) (char *name) { return lua_call(name); }
+int32 (lua_call) (char *name) { return lua_call(name); }
-void (lua_pushref) (int ref) { lua_pushref(ref); }
+void (lua_pushref) (int32 ref) { lua_pushref(ref); }
-int (lua_refobject) (lua_Object o, int l) { return lua_refobject(o, l); }
+int32 (lua_refobject) (lua_Object o, int32 l) { return lua_refobject(o, l); }
void (lua_register) (char *n, lua_CFunction f) { lua_register(n, f); }
@@ -601,7 +598,7 @@
void (lua_pushcfunction) (lua_CFunction f) { lua_pushcfunction(f); }
-int (lua_clonetag) (int t) { return lua_clonetag(t); }
+int32 (lua_clonetag) (int32 t) { return lua_clonetag(t); }
@@ -611,7 +608,7 @@
** API: set a function as a fallback
*/
-static void do_unprotectedrun (lua_CFunction f, int nParams, int nResults)
+static void do_unprotectedrun (lua_CFunction f, int32 nParams, int32 nResults)
{
StkId base = (L->stack.top-L->stack.stack)-nParams;
luaD_openstack(nParams);
Modified: residual/trunk/engine/lua/lapi.h
===================================================================
--- residual/trunk/engine/lua/lapi.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lapi.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -15,6 +15,6 @@
TObject *luaA_Address (lua_Object o);
void luaA_pushobject (TObject *o);
void luaA_packresults (void);
-int luaA_passresults (void);
+int32 luaA_passresults (void);
#endif
Modified: residual/trunk/engine/lua/lauxlib.cpp
===================================================================
--- residual/trunk/engine/lua/lauxlib.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lauxlib.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,11 +5,6 @@
*/
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
/* Please Notice: This file uses only the official API of Lua
** Any function declared here could be written as an application
** function. With care, these functions can be used by other libraries.
@@ -20,15 +15,15 @@
#include "lmem.h"
-int luaL_findstring (const char *name, const char *list[]) {
- int i;
+int32 luaL_findstring (const char *name, const char *list[]) {
+ int32 i;
for (i=0; list[i]; i++)
if (strcmp(list[i], name) == 0)
return i;
return -1; /* name not found */
}
-void luaL_argerror (int numarg, const char *extramsg)
+void luaL_argerror (int32 numarg, const char *extramsg)
{
const char *funcname;
lua_getobjname(lua_stackedfunction(0), &funcname);
@@ -41,7 +36,7 @@
numarg, funcname, extramsg);
}
-const char *luaL_check_lstr (int numArg, long *len)
+const char *luaL_check_lstr (int32 numArg, int32 *len)
{
lua_Object o = lua_getparam(numArg);
luaL_arg_check(lua_isstring(o), numArg, "string expected");
@@ -49,13 +44,13 @@
return lua_getstring(o);
}
-const char *luaL_opt_lstr (int numArg, const char *def, long *len)
+const char *luaL_opt_lstr (int32 numArg, const char *def, int32 *len)
{
return (lua_getparam(numArg) == LUA_NOOBJECT) ? def :
luaL_check_lstr(numArg, len);
}
-double luaL_check_number (int numArg)
+double luaL_check_number (int32 numArg)
{
lua_Object o = lua_getparam(numArg);
luaL_arg_check(lua_isnumber(o), numArg, "number expected");
@@ -63,28 +58,28 @@
}
-double luaL_opt_number (int numArg, double def)
+double luaL_opt_number (int32 numArg, double def)
{
return (lua_getparam(numArg) == LUA_NOOBJECT) ? def :
luaL_check_number(numArg);
}
-lua_Object luaL_tablearg (int arg)
+lua_Object luaL_tablearg (int32 arg)
{
lua_Object o = lua_getparam(arg);
luaL_arg_check(lua_istable(o), arg, "table expected");
return o;
}
-lua_Object luaL_functionarg (int arg)
+lua_Object luaL_functionarg (int32 arg)
{
lua_Object o = lua_getparam(arg);
luaL_arg_check(lua_isfunction(o), arg, "function expected");
return o;
}
-lua_Object luaL_nonnullarg (int numArg)
+lua_Object luaL_nonnullarg (int32 numArg)
{
lua_Object o = lua_getparam(numArg);
luaL_arg_check(o != LUA_NOOBJECT, numArg, "value expected");
@@ -93,7 +88,7 @@
luaL_libList *list_of_libs = NULL;
-void luaL_addlibtolist(luaL_reg *l, int n) {
+void luaL_addlibtolist(luaL_reg *l, int32 n) {
luaL_libList *list = (luaL_libList *)luaM_malloc(sizeof(luaL_libList));
list->list = l;
list->number = n;
@@ -110,9 +105,9 @@
}
}
-void luaL_openlib (struct luaL_reg *l, int n)
+void luaL_openlib (struct luaL_reg *l, int32 n)
{
- int i;
+ int32 i;
lua_open(); /* make sure lua is already open */
for (i=0; i<n; i++)
lua_register(l[i].name, l[i].func);
Modified: residual/trunk/engine/lua/lauxlib.h
===================================================================
--- residual/trunk/engine/lua/lauxlib.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lauxlib.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -19,7 +19,7 @@
struct luaL_libList {
luaL_reg *list;
- int number;
+ int32 number;
luaL_libList *next;
};
@@ -28,28 +28,28 @@
#define luaL_arg_check(cond,numarg,extramsg) if (!(cond)) \
luaL_argerror(numarg,extramsg)
-void luaL_openlib (struct luaL_reg *l, int n);
-void luaL_addlibtolist(luaL_reg *l, int n);
-void luaL_argerror (int numarg, const char *extramsg);
+void luaL_openlib (struct luaL_reg *l, int32 n);
+void luaL_addlibtolist(luaL_reg *l, int32 n);
+void luaL_argerror (int32 numarg, const char *extramsg);
#define luaL_check_string(n) (luaL_check_lstr((n), NULL))
-const char *luaL_check_lstr (int numArg, long *len);
+const char *luaL_check_lstr (int32 numArg, int32 *len);
#define luaL_opt_string(n, d) (luaL_opt_lstr((n), (d), NULL))
-const char *luaL_opt_lstr (int numArg, const char *def, long *len);
-double luaL_check_number (int numArg);
-double luaL_opt_number (int numArg, double def);
-lua_Object luaL_functionarg (int arg);
-lua_Object luaL_tablearg (int arg);
-lua_Object luaL_nonnullarg (int numArg);
+const char *luaL_opt_lstr (int32 numArg, const char *def, int32 *len);
+double luaL_check_number (int32 numArg);
+double luaL_opt_number (int32 numArg, double def);
+lua_Object luaL_functionarg (int32 arg);
+lua_Object luaL_tablearg (int32 arg);
+lua_Object luaL_nonnullarg (int32 numArg);
void luaL_verror (const char *fmt, ...);
-char *luaL_openspace (int size);
+char *luaL_openspace (int32 size);
void luaL_resetbuffer (void);
-void luaL_addchar (int c);
-int luaL_getsize (void);
-void luaL_addsize (int n);
-int luaL_newbuffer (int size);
-void luaL_oldbuffer (int old);
+void luaL_addchar (int32 c);
+int32 luaL_getsize (void);
+void luaL_addsize (int32 n);
+int32 luaL_newbuffer (int32 size);
+void luaL_oldbuffer (int32 old);
char *luaL_buffer (void);
-int luaL_findstring (const char *name, const char *list[]);
+int32 luaL_findstring (const char *name, const char *list[]);
#endif
Modified: residual/trunk/engine/lua/lbuffer.cpp
===================================================================
--- residual/trunk/engine/lua/lbuffer.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lbuffer.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,8 +5,6 @@
*/
-#include <stdio.h>
-
#include "lauxlib.h"
#include "lmem.h"
#include "lstate.h"
@@ -20,10 +18,10 @@
#define openspace(size) if (L->Mbuffnext+(size) > L->Mbuffsize) Openspace(size)
-static void Openspace (int size)
+static void Openspace (int32 size)
{
lua_State *l = L; /* to optimize */
- int base = l->Mbuffbase-l->Mbuffer;
+ int32 base = l->Mbuffbase-l->Mbuffer;
l->Mbuffsize *= 2;
if (l->Mbuffnext+size > l->Mbuffsize) /* still not big enough? */
l->Mbuffsize = l->Mbuffnext+size;
@@ -32,14 +30,14 @@
}
-char *luaL_openspace (int size)
+char *luaL_openspace (int32 size)
{
openspace(size);
return L->Mbuffer+L->Mbuffnext;
}
-void luaL_addchar (int c)
+void luaL_addchar (int32 c)
{
openspace(BUFF_STEP);
L->Mbuffer[L->Mbuffnext++] = c;
@@ -52,26 +50,26 @@
}
-void luaL_addsize (int n)
+void luaL_addsize (int32 n)
{
L->Mbuffnext += n;
}
-int luaL_getsize (void)
+int32 luaL_getsize (void)
{
return L->Mbuffnext-(L->Mbuffbase-L->Mbuffer);
}
-int luaL_newbuffer (int size)
+int32 luaL_newbuffer (int32 size)
{
- int old = L->Mbuffbase-L->Mbuffer;
+ int32 old = L->Mbuffbase-L->Mbuffer;
openspace(size);
L->Mbuffbase = L->Mbuffer+L->Mbuffnext;
return old;
}
-void luaL_oldbuffer (int old)
+void luaL_oldbuffer (int32 old)
{
L->Mbuffnext = L->Mbuffbase-L->Mbuffer;
L->Mbuffbase = L->Mbuffer+old;
Modified: residual/trunk/engine/lua/lbuiltin.cpp
===================================================================
--- residual/trunk/engine/lua/lbuiltin.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lbuiltin.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,11 +5,6 @@
*/
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "lapi.h"
#include "lauxlib.h"
#include "lbuiltin.h"
@@ -100,7 +95,7 @@
{
TObject t = *luaA_Address(luaL_tablearg(1));
TObject f = *luaA_Address(luaL_functionarg(2));
- int i;
+ int32 i;
for (i=0; i<avalue(&t)->nhash; i++) {
Node *nd = &(avalue(&t)->node[i]);
if (ttype(ref(nd)) != LUA_T_NIL && ttype(val(nd)) != LUA_T_NIL) {
@@ -118,7 +113,7 @@
static void internaldostring (void)
{
- long l;
+ int32 l;
const char *s = luaL_check_lstr(1, &l);
if (*s == ID_CHUNK)
lua_error("`dostring' cannot run pre-compiled code");
@@ -185,7 +180,7 @@
static void luaI_print (void) {
TaggedString *ts = luaS_new("tostring");
lua_Object obj;
- int i = 1;
+ int32 i = 1;
while ((obj = lua_getparam(i++)) != LUA_NOOBJECT) {
luaA_pushobject(&ts->u.s.globalval);
lua_pushobject(obj);
@@ -209,7 +204,7 @@
static void tonumber (void)
{
- int base = (int)luaL_opt_number(2, 10);
+ int32 base = (int32)luaL_opt_number(2, 10);
if (base == 10) { /* standard conversion */
lua_Object o = lua_getparam(1);
if (lua_isnumber(o))
@@ -217,10 +212,10 @@
}
else {
const char *s = luaL_check_string(1);
- char *e;
- unsigned long n;
+ char *e;
+ int32 n;
luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
- n = strtol(s, &e, base);
+ n = (int32)strtol(s, &e, base);
while (isspace(*e)) e++; /* skip trailing spaces */
if (*e) lua_pushnil(); /* invalid format: return nil */
else lua_pushnumber(n);
@@ -276,12 +271,12 @@
}
-static int getnarg (lua_Object table)
+static int32 getnarg (lua_Object table)
{
lua_Object temp;
/* temp = table.n */
lua_pushobject(table); lua_pushstring("n"); temp = lua_rawgettable();
- return (lua_isnumber(temp) ? (int)lua_getnumber(temp) : MAX_INT);
+ return (lua_isnumber(temp) ? (int32)lua_getnumber(temp) : MAX_INT);
}
static void luaI_call (void)
@@ -290,8 +285,8 @@
lua_Object arg = luaL_tablearg(2);
const char *options = luaL_opt_string(3, "");
lua_Object err = lua_getparam(4);
- int narg = getnarg(arg);
- int i, status;
+ int32 narg = getnarg(arg);
+ int32 i, status;
if (err != LUA_NOOBJECT) { /* set new error method */
lua_pushobject(err);
err = lua_seterrormethod();
@@ -331,7 +326,7 @@
{
lua_Object o = luaL_tablearg(1);
lua_pushobject(o);
- lua_settag((int)luaL_check_number(2));
+ lua_settag((int32)luaL_check_number(2));
lua_pushobject(o); /* returns first argument */
}
@@ -344,8 +339,8 @@
static void copytagmethods (void)
{
- lua_pushnumber(lua_copytagmethods((int)luaL_check_number(1),
- (int)luaL_check_number(2)));
+ lua_pushnumber(lua_copytagmethods((int32)luaL_check_number(1),
+ (int32)luaL_check_number(2)));
}
@@ -370,14 +365,14 @@
{
lua_Object nf = luaL_nonnullarg(3);
lua_pushobject(nf);
- lua_pushobject(lua_settagmethod((int)luaL_check_number(1),
+ lua_pushobject(lua_settagmethod((int32)luaL_check_number(1),
luaL_check_string(2)));
}
static void gettagmethod (void)
{
- lua_pushobject(lua_gettagmethod((int)luaL_check_number(1),
+ lua_pushobject(lua_gettagmethod((int32)luaL_check_number(1),
luaL_check_string(2)));
}
@@ -392,7 +387,7 @@
static void luaI_collectgarbage (void)
{
- lua_pushnumber(lua_collectgarbage((long int)luaL_opt_number(1, 0)));
+ lua_pushnumber(lua_collectgarbage((int32)luaL_opt_number(1, 0)));
}
@@ -415,7 +410,7 @@
char *s = luaL_check_string(1);
GCnode *l = (s[0]=='t') ? L->roottable.next : (s[0]=='c') ? L->rootcl.next :
(s[0]=='p') ? L->rootproto.next : L->rootglobal.next;
- int i=0;
+ int32 i=0;
while (l) {
i++;
l = l->next;
@@ -429,7 +424,7 @@
#define getnum(s) ((*s++) - '0')
#define getname(s) (nome[0] = *s++, nome)
- static int locks[10];
+ static int32 locks[10];
lua_Object reg[10];
char nome[2];
char *s = luaL_check_string(1);
@@ -447,16 +442,16 @@
break;
}
case 'P': reg[getnum(s)] = lua_pop(); break;
- case 'g': { int n=getnum(s); reg[n]=lua_getglobal(getname(s)); break; }
- case 'G': { int n = getnum(s);
+ case 'g': { int32 n=getnum(s); reg[n]=lua_getglobal(getname(s)); break; }
+ case 'G': { int32 n = getnum(s);
reg[n] = lua_rawgetglobal(getname(s));
break;
}
case 'l': locks[getnum(s)] = lua_ref(1); break;
case 'L': locks[getnum(s)] = lua_ref(0); break;
- case 'r': { int n=getnum(s); reg[n]=lua_getref(locks[getnum(s)]); break; }
+ case 'r': { int32 n=getnum(s); reg[n]=lua_getref(locks[getnum(s)]); break; }
case 'u': lua_unref(locks[getnum(s)]); break;
- case 'p': { int n = getnum(s); reg[n] = lua_getparam(getnum(s)); break; }
+ case 'p': { int32 n = getnum(s); reg[n] = lua_getparam(getnum(s)); break; }
case '=': lua_setglobal(getname(s)); break;
case 's': lua_pushstring(getname(s)); break;
case 'o': lua_pushobject(reg[getnum(s)]); break;
Modified: residual/trunk/engine/lua/ldo.cpp
===================================================================
--- residual/trunk/engine/lua/ldo.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/ldo.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,11 +5,6 @@
*/
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "ldo.h"
#include "lfunc.h"
#include "lgc.h"
@@ -74,12 +69,12 @@
}
-void luaD_checkstack (int n)
+void luaD_checkstack (int32 n)
{
struct Stack *S = &L->stack;
if (S->last-S->top <= n) {
StkId top = S->top-S->stack;
- int stacksize = (S->last-S->stack)+1+STACK_UNIT+n;
+ int32 stacksize = (S->last-S->stack)+1+STACK_UNIT+n;
S->stack = luaM_reallocvector(S->stack, stacksize, TObject);
S->last = S->stack+(stacksize-1);
S->top = S->stack + top;
@@ -98,7 +93,7 @@
*/
void luaD_adjusttop (StkId newtop)
{
- int diff = newtop-(L->stack.top-L->stack.stack);
+ int32 diff = newtop-(L->stack.top-L->stack.stack);
if (diff <= 0)
L->stack.top += diff;
else {
@@ -112,7 +107,7 @@
/*
** Open a hole below "nelems" from the L->stack.top.
*/
-void luaD_openstack (int nelems)
+void luaD_openstack (int32 nelems)
{
luaO_memup(L->stack.top-nelems+1, L->stack.top-nelems,
nelems*sizeof(TObject));
@@ -120,7 +115,7 @@
}
-void luaD_lineHook (int line)
+void luaD_lineHook (int32 line)
{
struct C_Lua_Stack oldCLS = L->Cstack;
StkId old_top = L->Cstack.lua2C = L->Cstack.base = L->stack.top-L->stack.stack;
@@ -131,7 +126,7 @@
}
-void luaD_callHook (StkId base, TProtoFunc *tf, int isreturn)
+void luaD_callHook (StkId base, TProtoFunc *tf, int32 isreturn)
{
struct C_Lua_Stack oldCLS = L->Cstack;
StkId old_top = L->Cstack.lua2C = L->Cstack.base = L->stack.top-L->stack.stack;
@@ -160,7 +155,7 @@
struct C_Lua_Stack *CS = &L->Cstack;
struct C_Lua_Stack oldCLS = *CS;
StkId firstResult;
- int numarg = (L->stack.top-L->stack.stack) - base;
+ int32 numarg = (L->stack.top-L->stack.stack) - base;
CS->num = numarg;
CS->lua2C = base;
CS->base = base+numarg; /* == top-stack */
@@ -178,7 +173,7 @@
static StkId callCclosure (struct Closure *cl, lua_CFunction f, StkId base)
{
TObject *pbase;
- int nup = cl->nelems; /* number of upvalues */
+ int32 nup = cl->nelems; /* number of upvalues */
luaD_checkstack(nup);
pbase = L->stack.stack+base; /* care: previous call may change this */
/* open space for upvalues as extra arguments */
@@ -190,7 +185,7 @@
}
-void luaD_callTM (TObject *f, int nParams, int nResults)
+void luaD_callTM (TObject *f, int32 nParams, int32 nResults)
{
luaD_openstack(nParams);
*(L->stack.top-nParams-1) = *f;
@@ -211,13 +206,13 @@
/*
** Prepare the stack for calling a Lua function.
*/
-void luaD_precall (TObject *f, StkId base, int nResults)
+void luaD_precall (TObject *f, StkId base, int32 nResults)
{
/* Create a new CallInfo record */
if (L->ci+1 == L->end_ci) {
- int size_ci = L->end_ci - L->base_ci;
- int index_ci = L->ci - L->base_ci;
- int new_ci_size = size_ci * 2 * sizeof(CallInfo);
+ int32 size_ci = L->end_ci - L->base_ci;
+ int32 index_ci = L->ci - L->base_ci;
+ int32 new_ci_size = size_ci * 2 * sizeof(CallInfo);
CallInfo *new_ci = (CallInfo *)luaM_malloc(new_ci_size);
memcpy(new_ci, L->base_ci, L->base_ci_size);
memset(new_ci + (L->base_ci_size / sizeof(CallInfo)), 0, (new_ci_size) - L->base_ci_size);
@@ -260,9 +255,9 @@
** Adjust the stack to the desired number of results
*/
void luaD_postret (StkId firstResult) {
- int i;
+ int32 i;
StkId base = L->ci->base;
- int nResults = L->ci->nResults;
+ int32 nResults = L->ci->nResults;
if (L->ci == L->base_ci)
lua_error("call stack underflow");
/* adjust the number of results */
@@ -284,7 +279,7 @@
** When returns, the results are on the L->stack.stack, between [L->stack.stack+base-1,L->stack.top).
** The number of results is nResults, unless nResults=MULT_RET.
*/
-void luaD_call (StkId base, int nResults)
+void luaD_call (StkId base, int32 nResults)
{
StkId firstResult;
TObject *func = L->stack.stack+base-1;
@@ -322,7 +317,7 @@
}
-static void travstack (struct Stack *S, int (*fn)(TObject *)) {
+static void travstack (struct Stack *S, int32 (*fn)(TObject *)) {
StkId i;
for (i = (S->top-1)-S->stack; i>=0; i--)
fn(S->stack+i);
@@ -331,7 +326,7 @@
/*
** Traverse all objects on L->stack.stack, and all other active stacks
*/
-void luaD_travstack (int (*fn)(TObject *))
+void luaD_travstack (int32 (*fn)(TObject *))
{
struct lua_Task *t;
travstack(&L->stack, fn);
@@ -369,7 +364,7 @@
** Call the function at L->Cstack.base, and incorporate results on
** the Lua2C structure.
*/
-static void do_callinc (int nResults)
+static void do_callinc (int32 nResults)
{
StkId base = L->Cstack.base;
luaD_call(base+1, nResults);
@@ -383,13 +378,13 @@
** Execute a protected call. Assumes that function is at L->Cstack.base and
** parameters are on top of it. Leave nResults on the stack.
*/
-int luaD_protectedrun (int nResults)
+int32 luaD_protectedrun (int32 nResults)
{
jmp_buf myErrorJmp;
- int status;
+ int32 status;
struct C_Lua_Stack oldCLS = L->Cstack;
jmp_buf *oldErr = L->errorJmp;
- int ci_len = L->ci - L->base_ci;
+ int32 ci_len = L->ci - L->base_ci;
L->errorJmp = &myErrorJmp;
if (setjmp(myErrorJmp) == 0) {
do_callinc(nResults);
@@ -409,9 +404,9 @@
/*
** returns 0 = chunk loaded; 1 = error; 2 = no more chunks to load
*/
-static int protectedparser (ZIO *z, int bin)
+static int32 protectedparser (ZIO *z, int32 bin)
{
- volatile int status;
+ volatile int32 status;
TProtoFunc *volatile tf;
jmp_buf myErrorJmp;
jmp_buf *volatile oldErr = L->errorJmp;
@@ -435,16 +430,16 @@
}
-static int do_main (ZIO *z, int bin)
+static int32 do_main (ZIO *z, int32 bin)
{
- int status;
+ int32 status;
do {
- long old_blocks = (luaC_checkGC(), L->nblocks);
+ int32 old_blocks = (luaC_checkGC(), L->nblocks);
status = protectedparser(z, bin);
if (status == 1) return 1; /* error */
else if (status == 2) return 0; /* 'natural' end */
else {
- unsigned long newelems2 = 2*(L->nblocks-old_blocks);
+ int32 newelems2 = 2*(L->nblocks-old_blocks);
L->GCthreshold += newelems2;
status = luaD_protectedrun(MULT_RET);
L->GCthreshold -= newelems2;
@@ -465,12 +460,12 @@
}
-int lua_dofile (const char *filename)
+int32 lua_dofile (const char *filename)
{
ZIO z;
- int status;
- int c;
- int bin;
+ int32 status;
+ int32 c;
+ int32 bin;
FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
if (f == NULL)
return 2;
@@ -508,15 +503,15 @@
}
-int lua_dostring (const char *str) {
+int32 lua_dostring (const char *str) {
return lua_dobuffer(str, strlen(str), NULL);
}
-int lua_dobuffer (const char *buff, int size, const char *name) {
+int32 lua_dobuffer (const char *buff, int32 size, const char *name) {
char newname[SIZE_PREF+25];
ZIO z;
- int status;
+ int32 status;
if (name==NULL) {
build_name(buff, newname);
name = newname;
Modified: residual/trunk/engine/lua/ldo.h
===================================================================
--- residual/trunk/engine/lua/ldo.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/ldo.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -33,17 +33,17 @@
void luaD_init (void);
void luaD_initthr (void);
void luaD_adjusttop (StkId newtop);
-void luaD_openstack (int nelems);
-void luaD_lineHook (int line);
-void luaD_callHook (StkId base, TProtoFunc *tf, int isreturn);
-void luaD_precall (TObject *f, StkId base, int nResults);
+void luaD_openstack (int32 nelems);
+void luaD_lineHook (int32 line);
+void luaD_callHook (StkId base, TProtoFunc *tf, int32 isreturn);
+void luaD_precall (TObject *f, StkId base, int32 nResults);
void luaD_postret (StkId firstResult);
-void luaD_call (StkId base, int nResults);
-void luaD_callTM (TObject *f, int nParams, int nResults);
-int luaD_protectedrun (int nResults);
+void luaD_call (StkId base, int32 nResults);
+void luaD_callTM (TObject *f, int32 nParams, int32 nResults);
+int32 luaD_protectedrun (int32 nResults);
void luaD_gcIM (TObject *o);
-void luaD_travstack (int (*fn)(TObject *));
-void luaD_checkstack (int n);
+void luaD_travstack (int32 (*fn)(TObject *));
+void luaD_checkstack (int32 n);
#endif
Modified: residual/trunk/engine/lua/lfunc.cpp
===================================================================
--- residual/trunk/engine/lua/lfunc.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lfunc.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,7 +5,6 @@
*/
-#include <stdlib.h>
#include "lfunc.h"
#include "lmem.h"
@@ -16,7 +15,7 @@
-Closure *luaF_newclosure (int nelems)
+Closure *luaF_newclosure (int32 nelems)
{
Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject));
luaO_insertlist(&(L->rootcl), (GCnode *)c);
@@ -77,9 +76,9 @@
** Look for n-th local variable at line "line" in function "func".
** Returns NULL if not found.
*/
-char *luaF_getlocalname (TProtoFunc *func, int local_number, int line)
+char *luaF_getlocalname (TProtoFunc *func, int32 local_number, int32 line)
{
- int count = 0;
+ int32 count = 0;
char *varname = NULL;
LocVar *lv = func->locvars;
if (lv == NULL)
Modified: residual/trunk/engine/lua/lfunc.h
===================================================================
--- residual/trunk/engine/lua/lfunc.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lfunc.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -13,11 +13,11 @@
TProtoFunc *luaF_newproto (void);
-Closure *luaF_newclosure (int nelems);
+Closure *luaF_newclosure (int32 nelems);
void luaF_freeproto (TProtoFunc *l);
void luaF_freeclosure (Closure *l);
-char *luaF_getlocalname (TProtoFunc *func, int local_number, int line);
+char *luaF_getlocalname (TProtoFunc *func, int32 local_number, int32 line);
#endif
Modified: residual/trunk/engine/lua/lgc.cpp
===================================================================
--- residual/trunk/engine/lua/lgc.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lgc.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -18,7 +18,7 @@
-static int markobject (TObject *o);
+static int32 markobject (TObject *o);
@@ -29,9 +29,9 @@
*/
-int luaC_ref (TObject *o, int lock)
+int32 luaC_ref (TObject *o, int32 lock)
{
- int ref;
+ int32 ref;
if (ttype(o) == LUA_T_NIL)
ref = -1; /* special ref for nil */
else {
@@ -39,7 +39,7 @@
if (L->refArray[ref].status == FREE)
goto found;
/* no more empty spaces */ {
- int oldSize = L->refSize;
+ int32 oldSize = L->refSize;
L->refSize = luaM_growvector(&L->refArray, L->refSize, struct ref,
refEM, MAX_INT);
for (ref=oldSize; ref<L->refSize; ref++)
@@ -53,14 +53,14 @@
}
-void lua_unref (int ref)
+void lua_unref (int32 ref)
{
if (ref >= 0 && ref < L->refSize)
L->refArray[ref].status = FREE;
}
-TObject* luaC_getref (int ref)
+TObject* luaC_getref (int32 ref)
{
if (ref == -1)
return &luaO_nilobject;
@@ -74,14 +74,14 @@
static void travlock (void)
{
- int i;
+ int32 i;
for (i=0; i<L->refSize; i++)
if (L->refArray[i].status == LOCK)
markobject(&L->refArray[i].o);
}
-static int ismarked (TObject *o)
+static int32 ismarked (TObject *o)
{
/* valid only for locked objects */
switch (o->ttype) {
@@ -106,7 +106,7 @@
static void invalidaterefs (void)
{
- int i;
+ int32 i;
for (i=0; i<L->refSize; i++)
if (L->refArray[i].status == HOLD && !ismarked(&L->refArray[i].o))
L->refArray[i].status = COLLECTED;
@@ -167,7 +167,7 @@
{
if (!f->head.marked) {
LocVar *v = f->locvars;
- int i;
+ int32 i;
f->head.marked = 1;
if (f->fileName)
strmark(f->fileName);
@@ -185,7 +185,7 @@
static void closuremark (Closure *f)
{
if (!f->head.marked) {
- int i;
+ int32 i;
f->head.marked = 1;
for (i=f->nelems; i>=0; i--)
markobject(&f->consts[i]);
@@ -196,7 +196,7 @@
static void hashmark (Hash *h)
{
if (!h->head.marked) {
- int i;
+ int32 i;
h->head.marked = 1;
for (i=0; i<nhash(h); i++) {
Node *n = node(h,i);
@@ -222,7 +222,7 @@
}
-static int markobject (TObject *o)
+static int32 markobject (TObject *o)
{
switch (ttype(o)) {
case LUA_T_USERDATA: case LUA_T_STRING:
@@ -253,9 +253,9 @@
}
-long lua_collectgarbage (long limit)
+int32 lua_collectgarbage (int32 limit)
{
- unsigned long recovered = L->nblocks; /* to subtract nblocks after gc */
+ int32 recovered = L->nblocks; /* to subtract nblocks after gc */
Hash *freetable;
TaggedString *freestr;
TProtoFunc *freefunc;
Modified: residual/trunk/engine/lua/lgc.h
===================================================================
--- residual/trunk/engine/lua/lgc.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lgc.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -12,8 +12,8 @@
void luaC_checkGC (void);
-TObject* luaC_getref (int ref);
-int luaC_ref (TObject *o, int lock);
+TObject* luaC_getref (int32 ref);
+int luaC_ref (TObject *o, int32 lock);
void luaC_hashcallIM (Hash *l);
void luaC_strcallIM (TaggedString *l);
Modified: residual/trunk/engine/lua/liolib.cpp
===================================================================
--- residual/trunk/engine/lua/liolib.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/liolib.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,35 +5,17 @@
*/
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
#include "lauxlib.h"
#include "lua.h"
#include "luadebug.h"
#include "lualib.h"
+#include <time.h>
+
#ifdef LUA_ADD_CUSTOM_FOPEN
#include "../resource.h"
#endif
-#ifndef OLD_ANSI
-#include <locale.h>
-#else
-#define setlocale(a,b) 0
-#define LC_ALL 0
-#define LC_COLLATE 0
-#define LC_CTYPE 0
-#define LC_MONETARY 0
-#define LC_NUMERIC 0
-#define LC_TIME 0
-#define strerror(e) "(no error message provided by operating system)"
-#endif
-
-
#define CLOSEDTAG 2
#define IOTAG 1
@@ -43,21 +25,16 @@
#define FOUTPUT "_OUTPUT"
-#ifdef POPEN
-FILE *popen();
-int pclose();
-#else
#define popen(x,y) NULL /* that is, popen always fails */
#define pclose(x) (-1)
-#endif
-static int gettag (int i)
+static int32 gettag (int32 i)
{
- return (int)lua_getnumber(lua_getparam(i));
+ return (int32)lua_getnumber(lua_getparam(i));
}
-static void pushresult (int i)
+static void pushresult (int32 i)
{
if (i)
lua_pushuserdata(NULL);
@@ -68,7 +45,7 @@
}
-static int ishandler (lua_Object f)
+static int32 ishandler (lua_Object f)
{
if (lua_isuserdata(f)) {
if (lua_tag(f) == gettag(CLOSEDTAG))
@@ -87,7 +64,7 @@
}
-static FILE *getfileparam (const char *name, int *arg)
+static FILE *getfileparam (const char *name, int32 *arg)
{
lua_Object f = lua_getparam(*arg);
if (ishandler(f)) {
@@ -110,7 +87,7 @@
}
-static void setfile (FILE *f, const char *name, int tag)
+static void setfile (FILE *f, const char *name, int32 tag)
{
lua_pushusertag(f, tag);
lua_setglobal(name);
@@ -119,7 +96,7 @@
static void setreturn (FILE *f, const char *name)
{
- int tag = gettag(IOTAG);
+ int32 tag = gettag(IOTAG);
setfile(f, name, tag);
lua_pushusertag(f, tag);
}
@@ -191,9 +168,9 @@
#define NEED_OTHER (EOF-1) /* just some flag different from EOF */
-static void read_until (FILE *f, int lim) {
- int l = 0;
- int c;
+static void read_until (FILE *f, int32 lim) {
+ int32 l = 0;
+ int32 c;
for (c = getc(f); c != EOF && c != lim; c = getc(f)) {
luaL_addchar(c);
l++;
@@ -203,7 +180,7 @@
}
static void io_read (void) {
- int arg = FIRSTARG;
+ int32 arg = FIRSTARG;
FILE *f = getfileparam(FINPUT, &arg);
const char *p = luaL_opt_string(arg, NULL);
luaL_resetbuffer();
@@ -212,9 +189,9 @@
else if (p[0] == '.' && p[1] == '*' && p[2] == 0) /* p = ".*" */
read_until(f, EOF);
else {
- int l = 0; /* number of chars read in buffer */
- int inskip = 0; /* to control {skips} */
- int c = NEED_OTHER;
+ int32 l = 0; /* number of chars read in buffer */
+ int32 inskip = 0; /* to control {skips} */
+ int32 c = NEED_OTHER;
while (*p) {
switch (*p) {
case '{':
@@ -229,7 +206,7 @@
continue;
default: {
const char *ep; /* get what is next */
- int m; /* match result */
+ int32 m; /* match result */
if (c == NEED_OTHER) c = getc(f);
if (c == EOF) {
luaI_singlematch(0, p, &ep); /* to set "ep" */
@@ -270,13 +247,13 @@
static void io_write (void)
{
- int arg = FIRSTARG;
+ int32 arg = FIRSTARG;
FILE *f = getfileparam(FOUTPUT, &arg);
- int status = 1;
+ int32 status = 1;
const char *s;
- long l;
+ int32 l;
while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL)
- status = status && (fwrite(s, 1, l, f) == (unsigned long)l);
+ status = status && (fwrite(s, 1, l, f) == (size_t)l);
pushresult(status);
}
@@ -334,11 +311,11 @@
static void setloc (void)
{
- static int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC,
+ static int32 cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC,
LC_TIME};
static const char *catnames[] = {"all", "collate", "ctype", "monetary",
"numeric", "time", NULL};
- int op = luaL_findstring(luaL_opt_string(2, "all"), catnames);
+ int32 op = luaL_findstring(luaL_opt_string(2, "all"), catnames);
luaL_arg_check(op != -1, 2, "invalid option");
lua_pushstring(setlocale(cat[op], luaL_check_string(1)));
}
@@ -347,7 +324,7 @@
static void io_exit (void)
{
lua_Object o = lua_getparam(1);
- exit(lua_isnumber(o) ? (int)lua_getnumber(o) : 1);
+ exit((int)lua_isnumber(o) ? (int)lua_getnumber(o) : 1);
}
@@ -365,13 +342,13 @@
static void lua_printstack (FILE *f)
{
- int level = 1; /* skip level 0 (it's this function) */
+ int32 level = 1; /* skip level 0 (it's this function) */
lua_Object func;
while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) {
const char *name;
- int currentline;
+ int32 currentline;
const char *filename;
- int linedefined;
+ int32 linedefined;
lua_funcinfo(func, &filename, &linedefined);
fprintf(f, (level==2) ? "Active Stack:\n\t" : "\t");
switch (*lua_getobjname(func, &name)) {
@@ -432,9 +409,9 @@
static void openwithtags (void)
{
- int iotag = lua_newtag();
- int closedtag = lua_newtag();
- unsigned int i;
+ int32 iotag = lua_newtag();
+ int32 closedtag = lua_newtag();
+ int32 i;
for (i=0; i<sizeof(iolibtag)/sizeof(iolibtag[0]); i++) {
/* put both tags as upvalues for these functions */
lua_pushnumber(iotag);
Modified: residual/trunk/engine/lua/llex.cpp
===================================================================
--- residual/trunk/engine/lua/llex.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/llex.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,9 +5,6 @@
*/
-#include <ctype.h>
-#include <string.h>
-
#include "lauxlib.h"
#include "llex.h"
#include "lmem.h"
@@ -20,7 +17,7 @@
-int lua_debug=0;
+int32 lua_debug=0;
#define next(LS) (LS->current = zgetc(LS->lex_z))
@@ -37,7 +34,7 @@
void luaX_init (void)
{
- unsigned int i;
+ int32 i;
for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) {
TaggedString *ts = luaS_new(reserved[i]);
ts->head.marked = FIRST_RESERVED+i; /* reserved word (always > 255) */
@@ -59,7 +56,7 @@
}
-void luaX_token2str (LexState * /*ls*/, int token, char *s) {
+void luaX_token2str (LexState * /*ls*/, int32 token, char *s) {
if (token < 255) {
s[0] = token;
s[1] = 0;
@@ -69,7 +66,7 @@
}
-static void luaX_invalidchar (LexState *ls, int c) {
+static void luaX_invalidchar (LexState *ls, int32 c) {
char buff[10];
sprintf(buff, "0x%X", c);
luaX_syntaxerror(ls, "invalid control char", buff);
@@ -78,7 +75,7 @@
static void firstline (LexState *LS)
{
- int c = zgetc(LS->lex_z);
+ int32 c = zgetc(LS->lex_z);
if (c == '#')
while ((c=zgetc(LS->lex_z)) != '\n' && c != EOZ) /* skip first line */;
zungetc(LS->lex_z);
@@ -115,12 +112,12 @@
}
-static int checkcond (LexState *LS, char *buff)
+static int32 checkcond (LexState *LS, char *buff)
{
static const char *opts[] = {"nil", "1", NULL};
- int i = luaL_findstring(buff, opts);
+ int32 i = luaL_findstring(buff, opts);
if (i >= 0) return i;
- else if (isalpha((unsigned char)buff[0]) || buff[0] == '_')
+ else if (isalpha((byte)buff[0]) || buff[0] == '_')
return luaS_globaldefined(buff);
else {
luaX_syntaxerror(LS, "invalid $if condition", buff);
@@ -131,7 +128,7 @@
static void readname (LexState *LS, char *buff)
{
- int i = 0;
+ int32 i = 0;
skipspace(LS);
while (isalnum(LS->current) || LS->current == '_') {
if (i >= PRAGMASIZE) {
@@ -168,8 +165,8 @@
++LS->linenumber;
if (LS->current == '$') { /* is a pragma? */
char buff[PRAGMASIZE+1];
- int ifnot = 0;
- int skip = LS->ifstate[LS->iflevel].skip;
+ int32 ifnot = 0;
+ int32 skip = LS->ifstate[LS->iflevel].skip;
next(LS); /* skip $ */
readname(LS, buff);
switch (luaL_findstring(buff, pragmas)) {
@@ -231,9 +228,9 @@
-static int read_long_string (LexState *LS)
+static int32 read_long_string (LexState *LS)
{
- int cont = 0;
+ int32 cont = 0;
while (1) {
switch (LS->current) {
case EOZ:
@@ -269,7 +266,7 @@
}
-int luaX_lex (LexState *LS) {
+int32 luaX_lex (LexState *LS) {
double a;
luaL_resetbuffer();
while (1) {
@@ -320,7 +317,7 @@
case '"':
case '\'': {
- int del = LS->current;
+ int32 del = LS->current;
save_and_next(LS);
while (LS->current != del) {
switch (LS->current) {
@@ -341,8 +338,8 @@
case '\n': save('\n'); inclinenumber(LS); break;
default : {
if (isdigit(LS->current)) {
- int c = 0;
- int i = 0;
+ int32 c = 0;
+ int32 i = 0;
do {
c = 10*c + (LS->current-'0');
next(LS);
@@ -410,8 +407,8 @@
save_and_next(LS);
}
if (toupper(LS->current) == 'E') {
- int e = 0;
- int neg;
+ int32 e = 0;
+ int32 neg;
double ea;
save_and_next(LS);
neg = (LS->current=='-');
@@ -439,7 +436,7 @@
default:
if (LS->current != '_' && !isalpha(LS->current)) {
- int c = LS->current;
+ int32 c = LS->current;
if (iscntrl(c))
luaX_invalidchar(LS, c);
save_and_next(LS);
Modified: residual/trunk/engine/lua/llex.h
===================================================================
--- residual/trunk/engine/lua/llex.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/llex.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -30,33 +30,33 @@
/* "ifstate" keeps the state of each nested $if the lexical is dealing with. */
struct ifState {
- int elsepart; /* true if its in the $else part */
- int condition; /* true if $if condition is true */
- int skip; /* true if part must be skipped */
+ int32 elsepart; /* true if its in the $else part */
+ int32 condition; /* true if $if condition is true */
+ int32 skip; /* true if part must be skipped */
};
typedef struct LexState {
- int current; /* look ahead character */
- int token; /* look ahead token */
+ int32 current; /* look ahead character */
+ int32 token; /* look ahead token */
struct FuncState *fs; /* 'FuncState' is private for the parser */
union {
real r;
TaggedString *ts;
} seminfo; /* semantics information */
struct zio *lex_z; /* input stream */
- int linenumber; /* input line counter */
- int iflevel; /* level of nested $if's (for lexical analysis) */
+ int32 linenumber; /* input line counter */
+ int32 iflevel; /* level of nested $if's (for lexical analysis) */
struct ifState ifstate[MAX_IFS];
} LexState;
void luaX_init (void);
void luaX_setinput (LexState *LS, ZIO *z);
-int luaX_lex (LexState *LS);
+int32 luaX_lex (LexState *LS);
void luaX_syntaxerror (LexState *ls, const char *s, const char *token);
void luaX_error (LexState *ls, const char *s);
-void luaX_token2str (LexState *ls, int token, char *s);
+void luaX_token2str (LexState *ls, int32 token, char *s);
#endif
Modified: residual/trunk/engine/lua/lmathlib.cpp
===================================================================
--- residual/trunk/engine/lua/lmathlib.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lmathlib.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,9 +5,6 @@
*/
-#include <stdlib.h>
-#include <math.h>
-
#include "lauxlib.h"
#include "lua.h"
#include "lualib.h"
@@ -114,20 +111,20 @@
}
static void math_frexp (void) {
- int e;
+ int32 e;
lua_pushnumber(frexp(luaL_check_number(1), &e));
lua_pushnumber(e);
}
static void math_ldexp (void) {
- lua_pushnumber(ldexp(luaL_check_number(1), (int)luaL_check_number(2)));
+ lua_pushnumber(ldexp(luaL_check_number(1), (int32)luaL_check_number(2)));
}
static void math_min (void)
{
- int i = 1;
+ int32 i = 1;
double dmin = luaL_check_number(i);
while (lua_getparam(++i) != LUA_NOOBJECT) {
double d = luaL_check_number(i);
@@ -140,7 +137,7 @@
static void math_max (void)
{
- int i = 1;
+ int32 i = 1;
double dmax = luaL_check_number(i);
while (lua_getparam(++i) != LUA_NOOBJECT) {
double d = luaL_check_number(i);
@@ -160,7 +157,7 @@
if (l == 0)
lua_pushnumber(r);
else
- lua_pushnumber((int)(r*l)+1);
+ lua_pushnumber((int32)(r*l)+1);
}
Modified: residual/trunk/engine/lua/lmem.cpp
===================================================================
--- residual/trunk/engine/lua/lmem.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lmem.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,7 +5,6 @@
*/
-#include <stdlib.h>
#include "lmem.h"
#include "lstate.h"
@@ -13,8 +12,8 @@
-int luaM_growaux (void **block, unsigned long nelems, int size,
- const char *errormsg, unsigned long limit)
+int32 luaM_growaux (void **block, int32 nelems, int32 size,
+ const char *errormsg, int32 limit)
{
if (nelems >= limit)
lua_error(errormsg);
@@ -22,7 +21,7 @@
if (nelems > limit)
nelems = limit;
*block = luaM_realloc(*block, nelems*size);
- return (int)nelems;
+ return (int32)nelems;
}
@@ -35,7 +34,7 @@
** since realloc(NULL, s)==malloc(s) and realloc(b, 0)==free(b).
** But some systems (e.g. Sun OS) are not that ANSI...
*/
-void *luaM_realloc (void *block, unsigned long size)
+void *luaM_realloc (void *block, int32 size)
{
size_t s = (size_t)size;
if (s != size)
@@ -64,14 +63,14 @@
#define MARK 55
-unsigned long numblocks = 0;
-unsigned long totalmem = 0;
+int32 numblocks = 0;
+int32 totalmem = 0;
static void *checkblock (void *block)
{
- unsigned long *b = (unsigned long *)((char *)block - HEADER);
- unsigned long size = *b;
+ int32 *b = (uint32 *)((char *)block - HEADER);
+ int32 size = *b;
LUA_ASSERT(*(((char *)b)+size+HEADER) == MARK,
"corrupted block");
numblocks--;
@@ -80,14 +79,14 @@
}
-void *luaM_realloc (void *block, unsigned long size)
+void *luaM_realloc (void *block, int32 size)
{
- unsigned long realsize = HEADER+size+1;
+ int32 realsize = HEADER+size+1;
if (realsize != (size_t)realsize)
lua_error("Allocation Error: Block too big");
if (size == 0) { /* ANSI dosen't need this, but some machines... */
if (block) {
- unsigned long *b = (unsigned long *)((char *)block - HEADER);
+ int32 *b = (int32 *)((char *)block - HEADER);
memset(block, -1, *b); /* erase block */
block = checkblock(block);
free(block);
@@ -96,17 +95,17 @@
}
if (block) {
block = checkblock(block);
- block = (unsigned long *)realloc(block, realsize);
+ block = (int32 *)realloc(block, realsize);
}
else
- block = (unsigned long *)malloc(realsize);
+ block = (int32 *)malloc(realsize);
if (block == NULL)
lua_error(memEM);
totalmem += size;
numblocks++;
- *(unsigned long *)block = size;
+ *(int32 *)block = size;
*(((char *)block)+size+HEADER) = MARK;
- return (unsigned long *)((char *)block+HEADER);
+ return (int32 *)((char *)block+HEADER);
}
Modified: residual/trunk/engine/lua/lmem.h
===================================================================
--- residual/trunk/engine/lua/lmem.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lmem.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -7,7 +7,9 @@
#ifndef lmem_h
#define lmem_h
+#include "common\sys.h"
+
#ifndef NULL
#define NULL 0
#endif
@@ -20,9 +22,9 @@
#define tableEM "table overflow"
#define memEM "not enough memory"
-void *luaM_realloc (void *oldblock, unsigned long size);
-int luaM_growaux (void **block, unsigned long nelems, int size,
- const char *errormsg, unsigned long limit);
+void *luaM_realloc (void *oldblock, int32 size);
+int32 luaM_growaux (void **block, int32 nelems, int32 size,
+ const char *errormsg, int32 limit);
#define luaM_free(b) free((b))
#define luaM_malloc(t) malloc((t))
@@ -34,8 +36,8 @@
#ifdef DEBUG
-extern unsigned long numblocks;
-extern unsigned long totalmem;
+extern int32 numblocks;
+extern int32 totalmem;
#endif
Modified: residual/trunk/engine/lua/lobject.cpp
===================================================================
--- residual/trunk/engine/lua/lobject.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lobject.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -21,15 +21,15 @@
/* hash dimensions values */
-static long dimensions[] =
- {5L, 11L, 23L, 47L, 97L, 197L, 397L, 797L, 1597L, 3203L, 6421L,
- 12853L, 25717L, 51437L, 102811L, 205619L, 411233L, 822433L,
- 1644817L, 3289613L, 6579211L, 13158023L, MAX_INT};
+static int32 dimensions[] =
+ {5, 11, 23, 47, 97, 197, 397, 797, 1597, 3203, 6421,
+ 12853, 25717, 51437, 102811, 205619, 411233, 822433,
+ 1644817, 3289613, 6579211, 13158023, MAX_INT};
-int luaO_redimension (int oldsize)
+int32 luaO_redimension (int32 oldsize)
{
- int i;
+ int32 i;
for (i=0; dimensions[i]<MAX_INT; i++) {
if (dimensions[i] > oldsize)
return dimensions[i];
@@ -39,7 +39,7 @@
}
-int luaO_equalObj (TObject *t1, TObject *t2)
+int32 luaO_equalObj (TObject *t1, TObject *t2)
{
if (ttype(t1) != ttype(t2)) return 0;
switch (ttype(t1)) {
@@ -64,21 +64,3 @@
root->next = node;
node->marked = 0;
}
-
-#ifdef OLD_ANSI
-void luaO_memup (void *dest, void *src, int size)
-{
- char *d = dest;
- char *s = src;
- while (size--) d[size]=s[size];
-}
-
-void luaO_memdown (void *dest, void *src, int size)
-{
- char *d = dest;
- char *s = src;
- int i;
- for (i=0; i<size; i++) d[i]=s[i];
-}
-#endif
-
Modified: residual/trunk/engine/lua/lobject.h
===================================================================
--- residual/trunk/engine/lua/lobject.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lobject.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -8,8 +8,6 @@
#define lobject_h
-#include <limits.h>
-
#include "lua.h"
@@ -40,18 +38,12 @@
typedef LUA_NUM_TYPE real;
#define Byte lua_Byte /* some systems have Byte as a predefined type */
-typedef unsigned char Byte; /* unsigned 8 bits */
+typedef byte Byte; /* unsigned 8 bits */
-#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
+#define MAX_INT (2147483647-2) /* maximum value of an int (-2 for safety) */
+#define MAX_WORD 65534
-/* maximum value of a word of 2 bytes (-2 for safety); must fit in an "int" */
-#if MAX_INT < 65534
-#define MAX_WORD MAX_INT
-#else
-#define MAX_WORD 65534
-#endif
-
typedef unsigned long IntPoint; /* unsigned with same size as a pointer (for hashing) */
@@ -87,7 +79,7 @@
struct TProtoFunc *tf; /* LUA_T_PROTO, LUA_T_PMARK */
struct Closure *cl; /* LUA_T_CLOSURE, LUA_T_CLMARK */
struct Hash *a; /* LUA_T_ARRAY */
- int i; /* LUA_T_LINE */
+ int32 i; /* LUA_T_LINE */
} Value;
@@ -103,7 +95,7 @@
*/
typedef struct GCnode {
struct GCnode *next;
- int marked;
+ int32 marked;
} GCnode;
@@ -114,14 +106,14 @@
typedef struct TaggedString {
GCnode head;
unsigned long hash;
- int constindex; /* hint to reuse constants (= -1 if this is a userdata) */
+ int32 constindex; /* hint to reuse constants (= -1 if this is a userdata) */
union {
struct {
TObject globalval;
- long len; /* if this is a string, here is its length */
+ int32 len; /* if this is a string, here is its length */
} s;
struct {
- int tag;
+ int32 tag;
void *v; /* if this is a userdata, here is its value */
} d;
} u;
@@ -137,16 +129,16 @@
typedef struct TProtoFunc {
GCnode head;
struct TObject *consts;
- int nconsts;
+ int32 nconsts;
Byte *code; /* ends with opcode ENDCODE */
- int lineDefined;
+ int32 lineDefined;
TaggedString *fileName;
struct LocVar *locvars; /* ends with line = -1 */
} TProtoFunc;
typedef struct LocVar {
TaggedString *varname; /* NULL signals end of scope */
- int line;
+ int32 line;
} LocVar;
@@ -171,7 +163,7 @@
*/
typedef struct Closure {
GCnode head;
- int nelems; /* not included the first one (always the prototype) */
+ int32 nelems; /* not included the first one (always the prototype) */
TObject consts[1]; /* at least one for prototype */
} Closure;
@@ -185,9 +177,9 @@
typedef struct Hash {
GCnode head;
Node *node;
- int nhash;
- int nuse;
- int htag;
+ int32 nhash;
+ int32 nuse;
+ int32 htag;
} Hash;
@@ -195,17 +187,11 @@
extern TObject luaO_nilobject;
-int luaO_equalObj (TObject *t1, TObject *t2);
-int luaO_redimension (int oldsize);
+int32 luaO_equalObj (TObject *t1, TObject *t2);
+int32 luaO_redimension (int32 oldsize);
void luaO_insertlist (GCnode *root, GCnode *node);
-#ifdef OLD_ANSI
-void luaO_memup (void *dest, void *src, int size);
-void luaO_memdown (void *dest, void *src, int size);
-#else
-#include <string.h>
#define luaO_memup(d,s,n) memmove(d,s,n)
#define luaO_memdown(d,s,n) memmove(d,s,n)
-#endif
#endif
Modified: residual/trunk/engine/lua/lparser.cpp
===================================================================
--- residual/trunk/engine/lua/lparser.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lparser.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,9 +5,6 @@
*/
-#include <stdlib.h>
-#include <stdio.h>
-
#include "lauxlib.h"
#include "ldo.h"
#include "lfunc.h"
@@ -52,7 +49,7 @@
typedef struct {
varkind k;
- int info;
+ int32 info;
} vardesc;
@@ -63,8 +60,8 @@
** where is its pc index of "nparam"
*/
typedef struct {
- int n;
- int pc; /* 0 if last expression is closed */
+ int32 n;
+ int32 pc; /* 0 if last expression is closed */
} listdesc;
@@ -75,8 +72,8 @@
** or empty (k = ';' or '}')
*/
typedef struct {
- int n;
- int k;
+ int32 n;
+ int32 k;
} constdesc;
@@ -84,32 +81,32 @@
typedef struct FuncState {
TProtoFunc *f; /* current function header */
struct FuncState *prev; /* enclosuring function */
- int pc; /* next position to code */
- int stacksize; /* number of values on activation register */
- int maxstacksize; /* maximum number of values on activation register */
- int nlocalvar; /* number of active local variables */
- int nupvalues; /* number of upvalues */
- int nvars; /* number of entries in f->locvars */
- int maxcode; /* size of f->code */
- int maxvars; /* size of f->locvars (-1 if no debug information) */
- int maxconsts; /* size of f->consts */
- int lastsetline; /* line where last SETLINE was issued */
+ int32 pc; /* next position to code */
+ int32 stacksize; /* number of values on activation register */
+ int32 maxstacksize; /* maximum number of values on activation register */
+ int32 nlocalvar; /* number of active local variables */
+ int32 nupvalues; /* number of upvalues */
+ int32 nvars; /* number of entries in f->locvars */
+ int32 maxcode; /* size of f->code */
+ int32 maxvars; /* size of f->locvars (-1 if no debug information) */
+ int32 maxconsts; /* size of f->consts */
+ int32 lastsetline; /* line where last SETLINE was issued */
vardesc upvalues[MAXUPVALUES]; /* upvalues */
TaggedString *localvar[MAXLOCALS]; /* store local variable names */
} FuncState;
-static int assignment (LexState *ls, vardesc *v, int nvars);
-static int cond (LexState *ls);
-static int funcname (LexState *ls, vardesc *v);
-static int funcparams (LexState *ls, int slf);
-static int listfields (LexState *ls);
-static int localnamelist (LexState *ls);
-static int optional (LexState *ls, int c);
-static int recfields (LexState *ls);
-static int stat (LexState *ls);
+static int32 assignment (LexState *ls, vardesc *v, int32 nvars);
+static int32 cond (LexState *ls);
+static int32 funcname (LexState *ls, vardesc *v);
+static int32 funcparams (LexState *ls, int32 slf);
+static int32 listfields (LexState *ls);
+static int32 localnamelist (LexState *ls);
+static int32 optional (LexState *ls, int32 c);
+static int32 recfields (LexState *ls);
+static int32 stat (LexState *ls);
static void block (LexState *ls);
-static void body (LexState *ls, int needself, int line);
+static void body (LexState *ls, int32 needself, int32 line);
static void chunk (LexState *ls);
static void constructor (LexState *ls);
static void decinit (LexState *ls, listdesc *d);
@@ -130,7 +127,7 @@
-static void check_pc (FuncState *fs, int n) {
+static void check_pc (FuncState *fs, int32 n) {
if (fs->pc+n > fs->maxcode)
fs->maxcode = luaM_growvector(&fs->f->code, fs->maxcode,
Byte, codeEM, MAX_INT);
@@ -143,7 +140,7 @@
}
-static void deltastack (LexState *ls, int delta) {
+static void deltastack (LexState *ls, int32 delta) {
FuncState *fs = ls->fs;
fs->stacksize += delta;
if (fs->stacksize > fs->maxstacksize) {
@@ -154,8 +151,8 @@
}
-static int code_oparg_at (LexState *ls, int pc, OpCode op, int builtin,
- int arg, int delta) {
+static int32 code_oparg_at (LexState *ls, int32 pc, OpCode op, int32 builtin,
+ int32 arg, int32 delta) {
Byte *code = ls->fs->f->code;
deltastack(ls, delta);
if (arg < builtin) {
@@ -178,7 +175,7 @@
}
-static int fix_opcode (LexState *ls, int pc, OpCode op, int builtin, int arg) {
+static int32 fix_opcode (LexState *ls, int32 pc, OpCode op, int32 builtin, int32 arg) {
FuncState *fs = ls->fs;
TProtoFunc *f = fs->f;
if (arg < builtin) { /* close space */
@@ -193,25 +190,25 @@
return code_oparg_at(ls, pc, op, builtin, arg, 0) - 2;
}
-static void code_oparg (LexState *ls, OpCode op, int builtin, int arg,
- int delta) {
+static void code_oparg (LexState *ls, OpCode op, int32 builtin, int32 arg,
+ int32 delta) {
check_pc(ls->fs, 3); /* maximum code size */
ls->fs->pc += code_oparg_at(ls, ls->fs->pc, op, builtin, arg, delta);
}
-static void code_opcode (LexState *ls, OpCode op, int delta) {
+static void code_opcode (LexState *ls, OpCode op, int32 delta) {
deltastack(ls, delta);
code_byte(ls->fs, op);
}
-static void code_constant (LexState *ls, int c) {
+static void code_constant (LexState *ls, int32 c) {
code_oparg(ls, PUSHCONSTANT, 8, c, 1);
}
-static int next_constant (FuncState *fs) {
+static int32 next_constant (FuncState *fs) {
TProtoFunc *f = fs->f;
if (f->nconsts >= fs->maxconsts) {
fs->maxconsts = luaM_growvector(&f->consts, fs->maxconsts, TObject,
@@ -221,9 +218,9 @@
}
-static int string_constant (FuncState *fs, TaggedString *s) {
+static int32 string_constant (FuncState *fs, TaggedString *s) {
TProtoFunc *f = fs->f;
- int c = s->constindex;
+ int32 c = s->constindex;
if (!(c < f->nconsts &&
ttype(&f->consts[c]) == LUA_T_STRING && tsvalue(&f->consts[c]) == s)) {
c = next_constant(fs);
@@ -241,11 +238,11 @@
#define LIM 20
-static int real_constant (FuncState *fs, real r) {
+static int32 real_constant (FuncState *fs, real r) {
/* check whether 'r' has appeared within the last LIM entries */
TObject *cnt = fs->f->consts;
- int c = fs->f->nconsts;
- int lim = c < LIM ? 0 : c-LIM;
+ int32 c = fs->f->nconsts;
+ int32 lim = c < LIM ? 0 : c-LIM;
while (--c >= lim) {
if (ttype(&cnt[c]) == LUA_T_NUMBER && nvalue(&cnt[c]) == r)
return c;
@@ -260,21 +257,21 @@
static void code_number (LexState *ls, real f) {
- int i;
- if (f >= 0 && f <= (real)MAX_WORD && (real)(i=(int)f) == f)
+ int32 i;
+ if (f >= 0 && f <= (real)MAX_WORD && (real)(i=(int32)f) == f)
code_oparg(ls, PUSHNUMBER, 3, i, 1); /* f has a short integer value */
else
code_constant(ls, real_constant(ls->fs, f));
}
-static void flush_record (LexState *ls, int n) {
+static void flush_record (LexState *ls, int32 n) {
if (n > 0)
code_oparg(ls, SETMAP, 1, n-1, -2*n);
}
-static void flush_list (LexState *ls, int m, int n) {
+static void flush_list (LexState *ls, int32 m, int32 n) {
if (n == 0) return;
code_oparg(ls, SETLIST, 1, m, -n);
code_byte(ls->fs, n);
@@ -282,7 +279,7 @@
static void luaI_registerlocalvar (FuncState *fs, TaggedString *varname,
- int line) {
+ int32 line) {
if (fs->maxvars != -1) { /* debug information? */
TProtoFunc *f = fs->f;
if (fs->nvars >= fs->maxvars)
@@ -295,12 +292,12 @@
}
-static void luaI_unregisterlocalvar (FuncState *fs, int line) {
+static void luaI_unregisterlocalvar (FuncState *fs, int32 line) {
luaI_registerlocalvar(fs, NULL, line);
}
-static void store_localvar (LexState *ls, TaggedString *name, int n) {
+static void store_localvar (LexState *ls, TaggedString *name, int32 n) {
FuncState *fs = ls->fs;
if (fs->nlocalvar+n < MAXLOCALS)
fs->localvar[fs->nlocalvar+n] = name;
@@ -316,17 +313,17 @@
}
-static int aux_localname (FuncState *fs, TaggedString *n) {
- int i;
+static int32 aux_localname (FuncState *fs, TaggedString *n) {
+ int32 i;
for (i=fs->nlocalvar-1; i >= 0; i--)
if (n == fs->localvar[i]) return i; /* local var index */
return -1; /* not found */
}
-static void singlevar (LexState *ls, TaggedString *n, vardesc *var, int prev) {
+static void singlevar (LexState *ls, TaggedString *n, vardesc *var, int32 prev) {
FuncState *fs = prev ? ls->fs->prev : ls->fs;
- int i = aux_localname(fs, n);
+ int32 i = aux_localname(fs, n);
if (i >= 0) { /* local value */
var->k = VLOCAL;
var->info = i;
@@ -342,10 +339,10 @@
}
-static int indexupvalue (LexState *ls, TaggedString *n) {
+static int32 indexupvalue (LexState *ls, TaggedString *n) {
FuncState *fs = ls->fs;
vardesc v;
- int i;
+ int32 i;
singlevar(ls, n, &v, 1);
for (i=0; i<fs->nupvalues; i++) {
if (fs->upvalues[i].k == v.k && fs->upvalues[i].info == v.info)
@@ -361,7 +358,7 @@
static void pushupvalue (LexState *ls, TaggedString *n) {
- int i;
+ int32 i;
if (ls->fs->prev == NULL)
luaX_syntaxerror(ls, "cannot access upvalue in main", n->str);
if (aux_localname(ls->fs, n) >= 0)
@@ -380,7 +377,7 @@
}
-static void adjuststack (LexState *ls, int n) {
+static void adjuststack (LexState *ls, int32 n) {
if (n > 0)
code_oparg(ls, POP, 2, n-1, -n);
else if (n < 0)
@@ -388,10 +385,10 @@
}
-static void close_exp (LexState *ls, int pc, int nresults) {
+static void close_exp (LexState *ls, int32 pc, int32 nresults) {
if (pc > 0) { /* expression is an open function call */
Byte *code = ls->fs->f->code;
- int nparams = code[pc]; /* save nparams */
+ int32 nparams = code[pc]; /* save nparams */
pc += fix_opcode(ls, pc-2, CALLFUNC, 2, nresults);
code[pc] = nparams; /* restore nparams */
if (nresults != MULT_RET)
@@ -401,8 +398,8 @@
}
-static void adjust_mult_assign (LexState *ls, int nvars, listdesc *d) {
- int diff = d->n - nvars;
+static void adjust_mult_assign (LexState *ls, int32 nvars, listdesc *d) {
+ int32 diff = d->n - nvars;
if (d->pc == 0) { /* list is closed */
/* push or pop eventual difference between list lengths */
adjuststack(ls, diff);
@@ -421,7 +418,7 @@
}
-static void code_args (LexState *ls, int nparams, int dots) {
+static void code_args (LexState *ls, int32 nparams, int32 dots) {
FuncState *fs = ls->fs;
fs->nlocalvar += nparams; /* "self" may already be there */
nparams = fs->nlocalvar;
@@ -477,22 +474,22 @@
}
-static int fixJump (LexState *ls, int pc, OpCode op, int n) {
+static int32 fixJump (LexState *ls, int32 pc, OpCode op, int32 n) {
/* jump is relative to position following jump instruction */
return fix_opcode(ls, pc, op, 0, n-(pc+JMPSIZE));
}
-static void fix_upjmp (LexState *ls, OpCode op, int pos) {
- int delta = ls->fs->pc+JMPSIZE - pos; /* jump is relative */
+static void fix_upjmp (LexState *ls, OpCode op, int32 pos) {
+ int32 delta = ls->fs->pc+JMPSIZE - pos; /* jump is relative */
if (delta > 255) delta++;
code_oparg(ls, op, 0, delta, 0);
}
-static void codeIf (LexState *ls, int thenAdd, int elseAdd) {
+static void codeIf (LexState *ls, int32 thenAdd, int32 elseAdd) {
FuncState *fs = ls->fs;
- int elseinit = elseAdd+JMPSIZE;
+ int32 elseinit = elseAdd+JMPSIZE;
if (fs->pc == elseinit) { /* no else part */
fs->pc -= JMPSIZE;
elseinit = fs->pc;
@@ -505,8 +502,8 @@
static void func_onstack (LexState *ls, FuncState *func) {
FuncState *fs = ls->fs;
- int i;
- int c = next_constant(fs);
+ int32 i;
+ int32 c = next_constant(fs);
ttype(&fs->f->consts[c]) = LUA_T_PROTO;
fs->f->consts[c].value.tf = func->f;
if (func->nupvalues == 0)
@@ -560,11 +557,11 @@
-static int expfollow [] = {ELSE, ELSEIF, THEN, IF, WHILE, REPEAT, DO, NAME,
+static int32 expfollow [] = {ELSE, ELSEIF, THEN, IF, WHILE, REPEAT, DO, NAME,
LOCAL, FUNCTION, END, UNTIL, RETURN, ')', ']', '}', ';', EOS, ',', 0};
-static int is_in (int tok, int *toks) {
- int *t = toks;
+static int32 is_in (int32 tok, int32 *toks) {
+ int32 *t = toks;
while (*t) {
if (*t == tok)
return t-toks;
@@ -579,14 +576,14 @@
}
-static void error_expected (LexState *ls, int token) {
+static void error_expected (LexState *ls, int32 token) {
char buff[100], t[TOKEN_LEN];
luaX_token2str(ls, token, t);
sprintf(buff, "`%s' expected", t);
luaX_error(ls, buff);
}
-static void error_unmatched (LexState *ls, int what, int who, int where) {
+static void error_unmatched (LexState *ls, int32 what, int32 who, int32 where) {
if (where == ls->linenumber)
error_expected(ls, what);
else {
@@ -600,13 +597,13 @@
}
}
-static void check (LexState *ls, int c) {
+static void check (LexState *ls, int32 c) {
if (ls->token != c)
error_expected(ls, c);
next(ls);
}
-static void check_match (LexState *ls, int what, int who, int where) {
+static void check_match (LexState *ls, int32 what, int32 who, int32 where) {
if (ls->token != what)
error_unmatched(ls, what, who, where);
check_debugline(ls); /* to 'mark' the 'what' */
@@ -623,7 +620,7 @@
}
-static int optional (LexState *ls, int c) {
+static int32 optional (LexState *ls, int32 c) {
if (ls->token == c) {
next(ls);
return 1;
@@ -666,8 +663,8 @@
}
}
-static int stat (LexState *ls) {
- int line = ls->linenumber; /* may be needed for error messages */
+static int32 stat (LexState *ls) {
+ int32 line = ls->linenumber; /* may be needed for error messages */
FuncState *fs = ls->fs;
switch (ls->token) {
case IF: { /* stat -> IF ifpart END */
@@ -679,8 +676,8 @@
case WHILE: { /* stat -> WHILE cond DO block END */
TProtoFunc *f = fs->f;
- int while_init = fs->pc;
- int cond_end, cond_size;
+ int32 while_init = fs->pc;
+ int32 cond_end, cond_size;
next(ls);
cond_end = cond(ls);
check(ls, DO);
@@ -703,7 +700,7 @@
}
case REPEAT: { /* stat -> REPEAT block UNTIL exp1 */
- int repeat_init = fs->pc;
+ int32 repeat_init = fs->pc;
next(ls);
block(ls);
check_match(ls, UNTIL, REPEAT, line);
@@ -714,7 +711,7 @@
}
case FUNCTION: { /* stat -> FUNCTION funcname body */
- int needself;
+ int32 needself;
vardesc v;
if (ls->fs->prev) /* inside other function? */
return 0;
@@ -728,7 +725,7 @@
case LOCAL: { /* stat -> LOCAL localnamelist decinit */
listdesc d;
- int nvars;
+ int32 nvars;
check_debugline(ls);
next(ls);
nvars = localnamelist(ls);
@@ -748,7 +745,7 @@
close_exp(ls, v.info, 0);
}
else {
- int left = assignment(ls, &v, 1); /* stat -> ['%'] NAME assignment */
+ int32 left = assignment(ls, &v, 1); /* stat -> ['%'] NAME assignment */
adjuststack(ls, left); /* remove eventual 'garbage' left on stack */
}
return 1;
@@ -764,19 +761,19 @@
}
}
-static int SaveWord (LexState *ls) {
- int res = ls->fs->pc;
+static int32 SaveWord (LexState *ls) {
+ int32 res = ls->fs->pc;
check_pc(ls->fs, JMPSIZE);
ls->fs->pc += JMPSIZE; /* open space */
return res;
}
-static int SaveWordPop (LexState *ls) {
+static int32 SaveWordPop (LexState *ls) {
deltastack(ls, -1); /* pop condition */
return SaveWord(ls);
}
-static int cond (LexState *ls) {
+static int32 cond (LexState *ls) {
/* cond -> exp1 */
exp1(ls);
return SaveWordPop(ls);
@@ -785,16 +782,16 @@
static void block (LexState *ls) {
/* block -> chunk */
FuncState *fs = ls->fs;
- int nlocalvar = fs->nlocalvar;
+ int32 nlocalvar = fs->nlocalvar;
chunk(ls);
adjuststack(ls, fs->nlocalvar - nlocalvar);
for (; fs->nlocalvar > nlocalvar; fs->nlocalvar--)
luaI_unregisterlocalvar(fs, ls->linenumber);
}
-static int funcname (LexState *ls, vardesc *v) {
+static int32 funcname (LexState *ls, vardesc *v) {
/* funcname -> NAME [':' NAME | '.' NAME] */
- int needself = 0;
+ int32 needself = 0;
singlevar(ls, checkname(ls), v, 0);
if (ls->token == ':' || ls->token == '.') {
needself = (ls->token == ':');
@@ -806,7 +803,7 @@
return needself;
}
-static void body (LexState *ls, int needself, int line) {
+static void body (LexState *ls, int32 needself, int32 line) {
/* body -> '(' parlist ')' chunk END */
FuncState newfs;
init_state(ls, &newfs, ls->fs->f->fileName);
@@ -824,8 +821,8 @@
static void ifpart (LexState *ls) {
/* ifpart -> cond THEN block [ELSE block | ELSEIF ifpart] */
- int c = cond(ls);
- int e;
+ int32 c = cond(ls);
+ int32 e;
check(ls, THEN);
block(ls);
e = SaveWord(ls);
@@ -872,10 +869,10 @@
*/
#define POW 13
-static int binop [] = {EQ, NE, '>', '<', LE, GE, CONC,
+static int32 binop [] = {EQ, NE, '>', '<', LE, GE, CONC,
'+', '-', '*', '/', '^', 0};
-static int priority [POW+1] = {5, 5, 1, 1, 1, 1, 1, 1, 2, 3, 3, 4, 4, 6};
+static int32 priority [POW+1] = {5, 5, 1, 1, 1, 1, 1, 1, 2, 3, 3, 4, 4, 6};
static OpCode opcodes [POW+1] = {NOTOP, MINUSOP, EQOP, NEQOP, GTOP, LTOP,
LEOP, GEOP, CONCOP, ADDOP, SUBOP, MULTOP, DIVOP, POWOP};
@@ -883,8 +880,8 @@
#define MAXOPS 20
typedef struct {
- int ops[MAXOPS];
- int top;
+ int32 ops[MAXOPS];
+ int32 top;
} stack_op;
@@ -900,8 +897,8 @@
static void exp0 (LexState *ls, vardesc *v) {
exp2(ls, v);
while (ls->token == AND || ls->token == OR) {
- int is_and = (ls->token == AND);
- int pc;
+ int32 is_and = (ls->token == AND);
+ int32 pc;
lua_pushvar(ls, v);
next(ls);
pc = SaveWordPop(ls);
@@ -912,7 +909,7 @@
}
-static void push (LexState *ls, stack_op *s, int op) {
+static void push (LexState *ls, stack_op *s, int32 op) {
if (s->top == MAXOPS)
luaX_error(ls, "expression too complex");
s->ops[s->top++] = op;
@@ -926,8 +923,8 @@
}
}
-static void pop_to (LexState *ls, stack_op *s, int prio) {
- int op;
+static void pop_to (LexState *ls, stack_op *s, int32 prio) {
+ int32 op;
while (s->top > 0 && priority[(op=s->ops[s->top-1])] >= prio) {
code_opcode(ls, opcodes[op], op<FIRSTBIN?0:-1);
s->top--;
@@ -936,7 +933,7 @@
static void exp2 (LexState *ls, vardesc *v) {
stack_op s;
- int op;
+ int32 op;
s.top = 0;
prefix(ls, &s);
simpleexp(ls, v);
@@ -991,7 +988,7 @@
break;
case FUNCTION: { /* simpleexp -> FUNCTION body */
- int line = ls->linenumber;
+ int32 line = ls->linenumber;
next(ls);
body(ls, 0, line);
v->k = VEXP; v->info = 0;
@@ -1057,9 +1054,9 @@
}
}
-static int funcparams (LexState *ls, int slf) {
+static int32 funcparams (LexState *ls, int32 slf) {
FuncState *fs = ls->fs;
- int nparams = 1; /* default value */
+ int32 nparams = 1; /* default value */
switch (ls->token) {
case '(': { /* funcparams -> '(' explist ')' */
listdesc e;
@@ -1122,8 +1119,8 @@
}
static void parlist (LexState *ls) {
- int nparams = 0;
- int dots = 0;
+ int32 nparams = 0;
+ int32 dots = 0;
switch (ls->token) {
case DOTS: /* parlist -> DOTS */
next(ls);
@@ -1156,9 +1153,9 @@
code_args(ls, nparams, dots);
}
-static int localnamelist (LexState *ls) {
+static int32 localnamelist (LexState *ls) {
/* localnamelist -> NAME {',' NAME} */
- int i = 1;
+ int32 i = 1;
store_localvar(ls, checkname(ls), 0);
while (ls->token == ',') {
next(ls);
@@ -1179,8 +1176,8 @@
}
}
-static int assignment (LexState *ls, vardesc *v, int nvars) {
- int left = 0;
+static int32 assignment (LexState *ls, vardesc *v, int32 nvars) {
+ int32 left = 0;
/* dotted variables <a.x> must be stored like regular indexed vars <a["x"]> */
if (v->k == VDOT) {
code_constant(ls, v->info);
@@ -1213,9 +1210,9 @@
static void constructor (LexState *ls) {
/* constructor -> '{' part [';' part] '}' */
- int line = ls->linenumber;
- int pc = SaveWord(ls);
- int nelems;
+ int32 line = ls->linenumber;
+ int32 pc = SaveWord(ls);
+ int32 nelems;
constdesc cd;
deltastack(ls, 1);
check(ls, '{');
@@ -1281,9 +1278,9 @@
}
}
-static int recfields (LexState *ls) {
+static int32 recfields (LexState *ls) {
/* recfields -> { ',' recfield } [','] */
- int n = 1; /* one has been read before */
+ int32 n = 1; /* one has been read before */
while (ls->token == ',') {
next(ls);
if (ls->token == ';' || ls->token == '}')
@@ -1297,9 +1294,9 @@
return n;
}
-static int listfields (LexState *ls) {
+static int32 listfields (LexState *ls) {
/* listfields -> { ',' exp1 } [','] */
- int n = 1; /* one has been read before */
+ int32 n = 1; /* one has been read before */
while (ls->token == ',') {
next(ls);
if (ls->token == ';' || ls->token == '}')
Modified: residual/trunk/engine/lua/lparser.h
===================================================================
--- residual/trunk/engine/lua/lparser.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lparser.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -11,7 +11,7 @@
#include "lzio.h"
-void luaY_codedebugline (int line);
+void luaY_codedebugline (int32 line);
TProtoFunc *luaY_parser (ZIO *z);
void luaY_error (char *s);
void luaY_syntaxerror (char *s, char *token);
Modified: residual/trunk/engine/lua/lrestore.cpp
===================================================================
--- residual/trunk/engine/lua/lrestore.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lrestore.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -1,7 +1,3 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-
#include "ltask.h"
#include "lauxlib.h"
#include "lmem.h"
@@ -17,10 +13,10 @@
struct ArrayIDObj {
void *object;
- unsigned int idObj;
+ int32 idObj;
};
-static int sortCallback(const void *id1, const void *id2) {
+static int32 sortCallback(const void *id1, const void *id2) {
if (((ArrayIDObj *)id1)->idObj > ((ArrayIDObj *)id2)->idObj) {
return 1;
} else if (((ArrayIDObj *)id1)->idObj < ((ArrayIDObj *)id2)->idObj) {
@@ -30,10 +26,10 @@
}
}
-int arrayHashTablesCount = 0;
-int arrayProtoFuncsCount = 0;
-int arrayClosuresCount = 0;
-int arrayStringsCount = 0;
+int32 arrayHashTablesCount = 0;
+int32 arrayProtoFuncsCount = 0;
+int32 arrayClosuresCount = 0;
+int32 arrayStringsCount = 0;
ArrayIDObj *arrayStrings = NULL;
ArrayIDObj *arrayHashTables = NULL;
ArrayIDObj *arrayClosures = NULL;
@@ -113,33 +109,33 @@
L = luaM_new(lua_State);
lua_resetglobals();
- restoreFunc(&arrayStringsCount, sizeof(int));
- restoreFunc(&arrayClosuresCount, sizeof(int));
- restoreFunc(&arrayHashTablesCount, sizeof(int));
- restoreFunc(&arrayProtoFuncsCount, sizeof(int));
- int rootGlobalCount;
- restoreFunc(&rootGlobalCount, sizeof(int));
+ restoreFunc(&arrayStringsCount, sizeof(int32));
+ restoreFunc(&arrayClosuresCount, sizeof(int32));
+ restoreFunc(&arrayHashTablesCount, sizeof(int32));
+ restoreFunc(&arrayProtoFuncsCount, sizeof(int32));
+ int32 rootGlobalCount;
+ restoreFunc(&rootGlobalCount, sizeof(int32));
arrayStrings = (ArrayIDObj *)luaM_malloc(sizeof(ArrayIDObj) * arrayStringsCount);
ArrayIDObj *arraysObj = arrayStrings;
- int maxStringsLength;
- restoreFunc(&maxStringsLength, sizeof(int));
+ int32 maxStringsLength;
+ restoreFunc(&maxStringsLength, sizeof(int32));
char *tempStringBuffer = (char *)luaM_malloc(maxStringsLength);
- int i;
+ int32 i;
for (i = 0; i < arrayStringsCount; i++) {
- restoreFunc(&arraysObj->idObj, sizeof(unsigned int));
- int constIndex;
- restoreFunc(&constIndex, sizeof(int));
+ restoreFunc(&arraysObj->idObj, sizeof(int32));
+ int32 constIndex;
+ restoreFunc(&constIndex, sizeof(int32));
lua_Type tag;
- restoreFunc(&tag, sizeof(int));
+ restoreFunc(&tag, sizeof(int32));
void *value;
restoreFunc(&value, sizeof(void *));
TaggedString *tempString;
if (constIndex != -1) {
- long length;
- restoreFunc(&length, sizeof(long));
+ int32 length;
+ restoreFunc(&length, sizeof(int32));
restoreFunc(tempStringBuffer, length);
tempString = luaS_newlstr(tempStringBuffer, length);
tempString->u.s.globalval.ttype = tag;
@@ -159,14 +155,14 @@
}
luaM_free(tempStringBuffer);
- int l;
+ int32 l;
Closure *tempClosure;
arraysObj = (ArrayIDObj *)luaM_malloc(sizeof(ArrayIDObj) * arrayClosuresCount);
arrayClosures = arraysObj;
for (i = 0; i < arrayClosuresCount; i++) {
- restoreFunc(&arraysObj->idObj, sizeof(unsigned int));
- int countElements;
- restoreFunc(&countElements, sizeof(int));
+ restoreFunc(&arraysObj->idObj, sizeof(int32));
+ int32 countElements;
+ restoreFunc(&countElements, sizeof(int32));
tempClosure = (Closure *)luaM_malloc((countElements * sizeof(TObject)) + sizeof(Closure));
luaO_insertlist(&L->rootcl, (GCnode *)tempClosure);
@@ -183,11 +179,11 @@
arraysObj = (ArrayIDObj *)luaM_malloc(sizeof(ArrayIDObj) * arrayHashTablesCount);
arrayHashTables = arraysObj;
for (i = 0; i < arrayHashTablesCount; i++) {
- restoreFunc(&arraysObj->idObj, sizeof(unsigned int));
+ restoreFunc(&arraysObj->idObj, sizeof(int32));
tempHash = luaM_new(Hash);
- restoreFunc(&tempHash->nhash, sizeof(int));
- restoreFunc(&tempHash->nuse, sizeof(int));
- restoreFunc(&tempHash->htag, sizeof(int));
+ restoreFunc(&tempHash->nhash, sizeof(int32));
+ restoreFunc(&tempHash->nuse, sizeof(int32));
+ restoreFunc(&tempHash->htag, sizeof(int32));
tempHash->node = hashnodecreate(tempHash->nhash);
luaO_insertlist(&L->roottable, (GCnode *)tempHash);
@@ -205,12 +201,12 @@
arrayProtoFuncs = (ArrayIDObj *)luaM_malloc(sizeof(ArrayIDObj) * arrayProtoFuncsCount);
arraysObj = arrayProtoFuncs;
for (i = 0; i < arrayProtoFuncsCount; i++) {
- restoreFunc(&arraysObj->idObj, sizeof(unsigned int));
+ restoreFunc(&arraysObj->idObj, sizeof(int32));
tempProtoFunc = luaM_new(TProtoFunc);
luaO_insertlist(&L->rootproto, (GCnode *)tempProtoFunc);
restoreFunc(&tempProtoFunc->fileName, sizeof(TaggedString *));
- restoreFunc(&tempProtoFunc->lineDefined, sizeof(int));
- restoreFunc(&tempProtoFunc->nconsts, sizeof(int));
+ restoreFunc(&tempProtoFunc->lineDefined, sizeof(int32));
+ restoreFunc(&tempProtoFunc->nconsts, sizeof(int32));
tempProtoFunc->consts = (TObject *)luaM_malloc(tempProtoFunc->nconsts * sizeof(TObject));
for (l = 0; l < tempProtoFunc->nconsts; l++) {
@@ -218,8 +214,8 @@
restoreFunc(&tempProtoFunc->consts[l].value, sizeof(Value));
}
- int countVariables;
- restoreFunc(&countVariables, sizeof(int));
+ int32 countVariables;
+ restoreFunc(&countVariables, sizeof(int32));
if (countVariables != 0) {
tempProtoFunc->locvars = (LocVar *)luaM_malloc(countVariables * sizeof(LocVar));
} else {
@@ -228,11 +224,11 @@
for (l = 0; l < countVariables; l++) {
restoreFunc(&tempProtoFunc->locvars[l].varname, sizeof(TaggedString *));
- restoreFunc(&tempProtoFunc->locvars[l].line, sizeof(int));
+ restoreFunc(&tempProtoFunc->locvars[l].line, sizeof(int32));
}
- int codeSize;
- restoreFunc(&codeSize, sizeof(int));
+ int32 codeSize;
+ restoreFunc(&codeSize, sizeof(int32));
tempProtoFunc->code = (lua_Byte *)luaM_malloc(codeSize);
restoreFunc(tempProtoFunc->code, codeSize);
arraysObj->object = tempProtoFunc;
@@ -318,7 +314,7 @@
restoreFunc(&L->errorim.value, sizeof(Value));
recreateObj(&L->errorim);
- restoreFunc(&L->IMtable_size, sizeof(int));
+ restoreFunc(&L->IMtable_size, sizeof(int32));
L->IMtable = (IM *)luaM_malloc(L->IMtable_size * sizeof(IM));
for (i = 0; i < L->IMtable_size; i++) {
IM *im = &L->IMtable[i];
@@ -329,8 +325,8 @@
}
}
- restoreFunc(&L->last_tag, sizeof(int));
- restoreFunc(&L->refSize, sizeof(int));
+ restoreFunc(&L->last_tag, sizeof(int32));
+ restoreFunc(&L->refSize, sizeof(int32));
L->refArray = (ref *)luaM_malloc(L->refSize * sizeof(ref));
for (i = 0; i < L->refSize; i++) {
restoreFunc(&L->refArray[i].o.ttype, sizeof(lua_Type));
@@ -339,22 +335,22 @@
restoreFunc(&L->refArray[i].status, sizeof(Status));
}
- restoreFunc(&L->GCthreshold, sizeof(unsigned long));
- restoreFunc(&L->nblocks, sizeof(unsigned long));
+ restoreFunc(&L->GCthreshold, sizeof(int32));
+ restoreFunc(&L->nblocks, sizeof(int32));
- restoreFunc(&L->Mbuffsize, sizeof(int));
+ restoreFunc(&L->Mbuffsize, sizeof(int32));
L->Mbuffer = (char *)luaM_malloc(L->Mbuffsize);
restoreFunc(L->Mbuffer, L->Mbuffsize);
- int MbaseOffset;
- restoreFunc(&MbaseOffset, sizeof(int));
+ int32 MbaseOffset;
+ restoreFunc(&MbaseOffset, sizeof(int32));
L->Mbuffbase = MbaseOffset + L->Mbuffer;
- restoreFunc(&L->Mbuffnext, sizeof(int));
+ restoreFunc(&L->Mbuffnext, sizeof(int32));
- restoreFunc(&globalTaskSerialId, sizeof(int));
+ restoreFunc(&globalTaskSerialId, sizeof(int32));
- int countTasks;
+ int32 countTasks;
lua_Task *tempTask = NULL;
- restoreFunc(&countTasks, sizeof(int));
+ restoreFunc(&countTasks, sizeof(int32));
lua_Task *prevTask = L->root_task;
for (l = 0; l < countTasks; l++) {
tempTask = luaM_new(lua_Task);
@@ -362,13 +358,13 @@
prevTask->next = tempTask;
prevTask = tempTask;
- int stackLastSize;
- restoreFunc(&stackLastSize, sizeof(int));
+ int32 stackLastSize;
+ restoreFunc(&stackLastSize, sizeof(int32));
tempTask->stack.stack = (TObject *)luaM_malloc(stackLastSize * sizeof(TObject));
tempTask->stack.last = tempTask->stack.stack + stackLastSize - 1;
- int stackTopSize;
- restoreFunc(&stackTopSize, sizeof(int));
+ int32 stackTopSize;
+ restoreFunc(&stackTopSize, sizeof(int32));
tempTask->stack.top = tempTask->stack.stack + stackTopSize;
for (i = 0; i < stackTopSize; i++) {
restoreFunc(&tempTask->stack.stack[i].ttype, sizeof(lua_Type));
@@ -378,21 +374,21 @@
restoreFunc(&tempTask->Cstack.base, sizeof(StkId));
restoreFunc(&tempTask->Cstack.lua2C, sizeof(StkId));
- restoreFunc(&tempTask->Cstack.num, sizeof(int));
+ restoreFunc(&tempTask->Cstack.num, sizeof(int32));
- restoreFunc(&tempTask->numCblocks, sizeof(int));
+ restoreFunc(&tempTask->numCblocks, sizeof(int32));
for (i = 0; i < tempTask->numCblocks; i++) {
restoreFunc(&tempTask->Cblocks[i].base, sizeof(StkId));
restoreFunc(&tempTask->Cblocks[i].lua2C, sizeof(StkId));
- restoreFunc(&tempTask->Cblocks[i].num, sizeof(int));
+ restoreFunc(&tempTask->Cblocks[i].num, sizeof(int32));
}
- int pcOffset, taskCi;
- restoreFunc(&tempTask->base_ci_size, sizeof(int));
+ int32 pcOffset, taskCi;
+ restoreFunc(&tempTask->base_ci_size, sizeof(int32));
tempTask->base_ci = (CallInfo *)luaM_malloc(tempTask->base_ci_size * sizeof(CallInfo));
memset(tempTask->base_ci, 0, sizeof(CallInfo) * tempTask->base_ci_size);
CallInfo *tempCi = tempTask->base_ci;
- int countCi = tempTask->base_ci_size / sizeof(CallInfo);
+ int32 countCi = tempTask->base_ci_size / sizeof(CallInfo);
for (i = 0; i < countCi; i++) {
TObject tempObj;
tempObj.ttype = LUA_T_CLOSURE;
@@ -404,27 +400,27 @@
recreateObj(&tempObj);
tempCi->tf = (TProtoFunc *)tempObj.value.tf;
- restoreFunc(&pcOffset, sizeof(int));
+ restoreFunc(&pcOffset, sizeof(int32));
if (pcOffset != 0)
tempCi->pc = tempCi->tf->code + pcOffset;
else
tempCi->pc = NULL;
restoreFunc(&tempCi->base, sizeof(StkId));
- restoreFunc(&tempCi->nResults, sizeof(int));
+ restoreFunc(&tempCi->nResults, sizeof(int32));
tempCi++;
}
- restoreFunc(&taskCi, sizeof(int));
+ restoreFunc(&taskCi, sizeof(int32));
tempTask->ci = tempTask->base_ci + taskCi;
tempTask->end_ci = tempTask->base_ci + countCi;
- int Mbasepos;
- restoreFunc(&Mbasepos, sizeof(int));
+ int32 Mbasepos;
+ restoreFunc(&Mbasepos, sizeof(int32));
tempTask->Mbuffbase = Mbasepos + tempTask->Mbuffer;
- restoreFunc(&tempTask->Mbuffnext, sizeof(int));
+ restoreFunc(&tempTask->Mbuffnext, sizeof(int32));
restoreFunc(&tempTask->Tstate, sizeof(TaskState));
- restoreFunc(&tempTask->id, sizeof(int));
+ restoreFunc(&tempTask->id, sizeof(int32));
}
L->last_task = tempTask;
Modified: residual/trunk/engine/lua/lsave.cpp
===================================================================
--- residual/trunk/engine/lua/lsave.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lsave.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -1,7 +1,3 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-
#include "ltask.h"
#include "lauxlib.h"
#include "lmem.h"
@@ -18,12 +14,12 @@
saveFunc(&object->ttype, sizeof(lua_Type));
if (object->ttype == LUA_T_CPROTO) {
luaL_libList *list = list_of_libs;
- unsigned int idObj = 0;
+ int32 idObj = 0;
while (list != NULL) {
- for (int l = 0; l < list->number; l++) {
+ for (int32 l = 0; l < list->number; l++) {
if (list->list[l].func == object->value.f) {
idObj = (idObj << 16) | l;
- saveFunc(&idObj, sizeof(unsigned int));
+ saveFunc(&idObj, sizeof(int32));
return;
}
}
@@ -36,7 +32,7 @@
}
}
-static int opcodeSizeTable[] = {
+static int32 opcodeSizeTable[] = {
1, 2, 1, 2, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -56,12 +52,12 @@
printf("lua_Save() started.\n");
lua_collectgarbage(0);
- int i, l;
- int countElements = 0;
- int maxStringLength = 0;
+ int32 i, l;
+ int32 countElements = 0;
+ int32 maxStringLength = 0;
for (i = 0; i < NUM_HASHS; i++) {
stringtable *tempStringTable = &L->string_root[i];
- for (int l = 0; l < tempStringTable->size; l++) {
+ for (int32 l = 0; l < tempStringTable->size; l++) {
if ((tempStringTable->hash[l] != NULL) && (tempStringTable->hash[l] != &EMPTY)) {
countElements++;
if (tempStringTable->hash[l]->constindex != -1) {
@@ -73,7 +69,7 @@
}
}
- saveFunc(&countElements, sizeof(int));
+ saveFunc(&countElements, sizeof(int32));
countElements = 0;
GCnode *tempNode;
@@ -82,7 +78,7 @@
countElements++;
tempNode = tempNode->next;
}
- saveFunc(&countElements, sizeof(int));
+ saveFunc(&countElements, sizeof(int32));
countElements = 0;
tempNode = L->roottable.next;
@@ -90,7 +86,7 @@
countElements++;
tempNode = tempNode->next;
}
- saveFunc(&countElements, sizeof(int));
+ saveFunc(&countElements, sizeof(int32));
countElements = 0;
tempNode = L->rootproto.next;
@@ -98,7 +94,7 @@
countElements++;
tempNode = tempNode->next;
}
- saveFunc(&countElements, sizeof(int));
+ saveFunc(&countElements, sizeof(int32));
countElements = 0;
tempNode = L->rootglobal.next;
@@ -106,9 +102,9 @@
countElements++;
tempNode = tempNode->next;
}
- saveFunc(&countElements, sizeof(int));
+ saveFunc(&countElements, sizeof(int32));
- saveFunc(&maxStringLength, sizeof(int));
+ saveFunc(&maxStringLength, sizeof(int32));
TaggedString *tempString;
for (i = 0; i < NUM_HASHS; i++) {
@@ -117,10 +113,10 @@
if ((tempStringTable->hash[l] != NULL) && (tempStringTable->hash[l] != &EMPTY)) {
tempString = tempStringTable->hash[l];
saveFunc(&tempString, sizeof(TaggedString *));
- saveFunc(&tempString->constindex, sizeof(int));
+ saveFunc(&tempString->constindex, sizeof(int32));
if (tempString->constindex != -1) {
saveObjectValue(&tempString->u.s.globalval, saveFunc);
- saveFunc(&tempString->u.s.len, sizeof(long));
+ saveFunc(&tempString->u.s.len, sizeof(int32));
saveFunc(tempString->str, tempString->u.s.len);
} else {
if (saveCallback != NULL) {
@@ -135,7 +131,7 @@
Closure *tempClosure = (Closure *)L->rootcl.next;
while (tempClosure != NULL) {
saveFunc(&tempClosure, sizeof(Closure *));
- saveFunc(&tempClosure->nelems, sizeof(int));
+ saveFunc(&tempClosure->nelems, sizeof(int32));
for(i = 0; i <= tempClosure->nelems; i++) {
saveObjectValue(&tempClosure->consts[i], saveFunc);
}
@@ -145,16 +141,16 @@
Hash *tempHash = (Hash *)L->roottable.next;
while (tempHash != NULL) {
saveFunc(&tempHash, sizeof(Hash *));
- saveFunc(&tempHash->nhash, sizeof(unsigned int));
- int countUsedHash = 0;
+ saveFunc(&tempHash->nhash, sizeof(uint32));
+ int32 countUsedHash = 0;
for(i = 0; i < tempHash->nhash; i++) {
Node *newNode = &tempHash->node[i];
if ((newNode->ref.ttype != LUA_T_NIL) && (newNode->val.ttype != LUA_T_NIL)) {
countUsedHash++;
}
}
- saveFunc(&countUsedHash, sizeof(int));
- saveFunc(&tempHash->htag, sizeof(int));
+ saveFunc(&countUsedHash, sizeof(int32));
+ saveFunc(&tempHash->htag, sizeof(int32));
for (i = 0; i < tempHash->nhash; i++) {
Node *newNode = &tempHash->node[i];
if ((newNode->val.ttype != LUA_T_NIL) && (newNode->ref.ttype != LUA_T_NIL)) {
@@ -169,31 +165,31 @@
while (tempProtoFunc != NULL) {
saveFunc(&tempProtoFunc, sizeof(TProtoFunc *));
saveFunc(&tempProtoFunc->fileName, sizeof(TaggedString *));
- saveFunc(&tempProtoFunc->lineDefined, sizeof(unsigned int));
- saveFunc(&tempProtoFunc->nconsts, sizeof(unsigned int));
+ saveFunc(&tempProtoFunc->lineDefined, sizeof(int32));
+ saveFunc(&tempProtoFunc->nconsts, sizeof(int32));
for (i = 0; i < tempProtoFunc->nconsts; i++) {
saveObjectValue(&tempProtoFunc->consts[i], saveFunc);
}
- int countVariables = 0;
+ int32 countVariables = 0;
if (tempProtoFunc->locvars) {
for (; tempProtoFunc->locvars[countVariables++].line != -1;) { }
}
- saveFunc(&countVariables, sizeof(int));
+ saveFunc(&countVariables, sizeof(int32));
for (i = 0; i < countVariables; i++) {
saveFunc(&tempProtoFunc->locvars[i].varname, sizeof(TaggedString *));
- saveFunc(&tempProtoFunc->locvars[i].line, sizeof(int));
+ saveFunc(&tempProtoFunc->locvars[i].line, sizeof(int32));
}
Byte *codePtr = tempProtoFunc->code + 2;
Byte *tmpPtr = codePtr;
- int opcodeId;
+ int32 opcodeId;
do {
opcodeId = *tmpPtr;
tmpPtr += opcodeSizeTable[opcodeId];
} while (opcodeId != ENDCODE);
- int codeSize = (tmpPtr - codePtr) + 2;
- saveFunc(&codeSize, sizeof(int));
+ int32 codeSize = (tmpPtr - codePtr) + 2;
+ saveFunc(&codeSize, sizeof(int32));
saveFunc(tempProtoFunc->code, codeSize);
tempProtoFunc = (TProtoFunc *)tempProtoFunc->head.next;
}
@@ -207,7 +203,7 @@
saveObjectValue(&L->errorim, saveFunc);
IM *tempIm = L->IMtable;
- saveFunc(&L->IMtable_size, sizeof(int));
+ saveFunc(&L->IMtable_size, sizeof(int32));
for (i = 0; i < L->IMtable_size; i++) {
for (l = 0; l < IM_N; l++) {
saveObjectValue(&tempIm->int_method[l], saveFunc);
@@ -215,58 +211,58 @@
tempIm++;
}
- saveFunc(&L->last_tag, sizeof(int));
- saveFunc(&L->refSize, sizeof(int));
+ saveFunc(&L->last_tag, sizeof(int32));
+ saveFunc(&L->refSize, sizeof(int32));
for (i = 0 ; i < L->refSize; i++) {
saveObjectValue(&L->refArray[i].o, saveFunc);
saveFunc(&L->refArray[i].status, sizeof(Status));
}
- saveFunc(&L->GCthreshold, sizeof(unsigned long));
- saveFunc(&L->nblocks, sizeof(unsigned long));
+ saveFunc(&L->GCthreshold, sizeof(int32));
+ saveFunc(&L->nblocks, sizeof(int32));
- saveFunc(&L->Mbuffsize, sizeof(int));
+ saveFunc(&L->Mbuffsize, sizeof(int32));
saveFunc(L->Mbuffer, L->Mbuffsize);
- int MbaseOffset = L->Mbuffbase - L->Mbuffer;
- saveFunc(&MbaseOffset, sizeof(int));
- saveFunc(&L->Mbuffnext, sizeof(int));
+ int32 MbaseOffset = L->Mbuffbase - L->Mbuffer;
+ saveFunc(&MbaseOffset, sizeof(int32));
+ saveFunc(&L->Mbuffnext, sizeof(int32));
- saveFunc(&globalTaskSerialId, sizeof(int));
+ saveFunc(&globalTaskSerialId, sizeof(int32));
- int countTasks = 0;
+ int32 countTasks = 0;
lua_Task *tempTask = L->root_task->next;
while (tempTask != NULL) {
countTasks++;
tempTask = tempTask->next;
}
- saveFunc(&countTasks, sizeof(int));
+ saveFunc(&countTasks, sizeof(int32));
tempTask = L->root_task->next;
while (tempTask != NULL) {
- int stackLastSize = (tempTask->stack.last - tempTask->stack.stack) + 1;
- saveFunc(&stackLastSize, sizeof(int));
- int stackTopSize = tempTask->stack.top - tempTask->stack.stack;
- saveFunc(&stackTopSize, sizeof(int));
+ int32 stackLastSize = (tempTask->stack.last - tempTask->stack.stack) + 1;
+ saveFunc(&stackLastSize, sizeof(int32));
+ int32 stackTopSize = tempTask->stack.top - tempTask->stack.stack;
+ saveFunc(&stackTopSize, sizeof(int32));
for (i = 0; i < stackTopSize; i++) {
saveObjectValue(&tempTask->stack.stack[i], saveFunc);
}
saveFunc(&tempTask->Cstack.base, sizeof(StkId));
saveFunc(&tempTask->Cstack.lua2C, sizeof(StkId));
- saveFunc(&tempTask->Cstack.num, sizeof(int));
+ saveFunc(&tempTask->Cstack.num, sizeof(int32));
- saveFunc(&tempTask->numCblocks, sizeof(int));
+ saveFunc(&tempTask->numCblocks, sizeof(int32));
for (i = 0; i < tempTask->numCblocks; i++) {
saveFunc(&tempTask->Cblocks[i].base, sizeof(StkId));
saveFunc(&tempTask->Cblocks[i].lua2C, sizeof(StkId));
- saveFunc(&tempTask->Cblocks[i].num, sizeof(int));
+ saveFunc(&tempTask->Cblocks[i].num, sizeof(int32));
}
- int pcOffset, taskCi = -1;
- saveFunc(&tempTask->base_ci_size, sizeof(int));
+ int32 pcOffset, taskCi = -1;
+ saveFunc(&tempTask->base_ci_size, sizeof(int32));
assert(tempTask->base_ci);
CallInfo *tempCi = tempTask->base_ci;
- int countCi = tempTask->base_ci_size / sizeof(CallInfo);
+ int32 countCi = tempTask->base_ci_size / sizeof(CallInfo);
for (i = 0; i < countCi; i++) {
saveFunc(&tempCi->c, sizeof(Closure *));
saveFunc(&tempCi->tf, sizeof(TProtoFunc *));
@@ -274,22 +270,22 @@
pcOffset = tempCi->pc - tempCi->tf->code;
else
pcOffset = 0;
- saveFunc(&pcOffset, sizeof(int));
+ saveFunc(&pcOffset, sizeof(int32));
saveFunc(&tempCi->base, sizeof(StkId));
- saveFunc(&tempCi->nResults, sizeof(int));
+ saveFunc(&tempCi->nResults, sizeof(int32));
if (tempCi == tempTask->ci)
taskCi = i;
tempCi++;
}
assert(taskCi != -1);
- saveFunc(&taskCi, sizeof(int));
+ saveFunc(&taskCi, sizeof(int32));
MbaseOffset = tempTask->Mbuffbase - tempTask->Mbuffer;
- saveFunc(&MbaseOffset, sizeof(int));
- saveFunc(&tempTask->Mbuffnext, sizeof(int));
+ saveFunc(&MbaseOffset, sizeof(int32));
+ saveFunc(&tempTask->Mbuffnext, sizeof(int32));
saveFunc(&tempTask->Tstate, sizeof(TaskState));
- saveFunc(&tempTask->id, sizeof(int));
+ saveFunc(&tempTask->id, sizeof(int32));
tempTask = tempTask->next;
}
Modified: residual/trunk/engine/lua/lstate.cpp
===================================================================
--- residual/trunk/engine/lua/lstate.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lstate.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,7 +5,6 @@
*/
-#include <stdlib.h>
#include "lbuiltin.h"
#include "ldo.h"
#include "lauxlib.h"
@@ -22,7 +21,7 @@
lua_State *lua_state = NULL;
-int globalTaskSerialId;
+int32 globalTaskSerialId;
void stderrorim (void);
Modified: residual/trunk/engine/lua/lstate.h
===================================================================
--- residual/trunk/engine/lua/lstate.h 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lstate.h 2008-07-20 21:08:22 UTC (rev 33147)
@@ -18,7 +18,7 @@
#define GARBAGE_BLOCK 150
-typedef int StkId; /* index to stack elements */
+typedef int32 StkId; /* index to stack elements */
struct Stack {
TObject *top;
@@ -30,13 +30,13 @@
StkId base; /* when Lua calls C or C calls Lua, points to */
/* the first slot after the last parameter. */
StkId lua2C; /* points to first element of "array" lua2C */
- int num; /* size of "array" lua2C */
+ int32 num; /* size of "array" lua2C */
};
typedef struct {
- int size;
- int nuse; /* number of elements (including EMPTYs) */
+ int32 size;
+ int32 nuse; /* number of elements (including EMPTYs) */
TaggedString **hash;
} stringtable;
@@ -54,7 +54,7 @@
TProtoFunc *tf; /* Set to NULL for C function */
StkId base;
Byte *pc;
- int nResults;
+ int32 nResults;
};
@@ -66,17 +66,17 @@
jmp_buf *errorJmp;
struct CallInfo *ci;
struct CallInfo *base_ci;
- int base_ci_size;
+ int32 base_ci_size;
struct CallInfo *end_ci;
char *Mbuffer;
char *Mbuffbase;
- int Mbuffsize;
- int Mbuffnext;
+ int32 Mbuffsize;
+ int32 Mbuffnext;
struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
- int numCblocks;
+ int32 numCblocks;
enum TaskState Tstate;
struct lua_Task *next;
- int id;
+ int32 id;
};
struct lua_State {
@@ -86,14 +86,14 @@
jmp_buf *errorJmp; /* current error recover point */
struct CallInfo *ci; /* call info for current function */
struct CallInfo *base_ci; /* array of CallInfo's */
- int base_ci_size;
+ int32 base_ci_size;
struct CallInfo *end_ci; /* points after end of ci array */
char *Mbuffer; /* global buffer */
char *Mbuffbase; /* current first position of Mbuffer */
- int Mbuffsize; /* size of Mbuffer */
- int Mbuffnext; /* next position to fill in Mbuffer */
+ int32 Mbuffsize; /* size of Mbuffer */
+ int32 Mbuffnext; /* next position to fill in Mbuffer */
struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
- int numCblocks; /* number of nested Cblocks */
+ int32 numCblocks; /* number of nested Cblocks */
enum TaskState Tstate; /* state of current thread */
/* global state */
struct lua_Task *root_task; /* first task created */
@@ -106,18 +106,18 @@
GCnode rootglobal; /* list of strings with global values */
stringtable *string_root; /* array of hash tables for strings and udata */
struct IM *IMtable; /* table for tag methods */
- int IMtable_size; /* size of IMtable */
- int last_tag; /* last used tag in IMtable */
+ int32 IMtable_size; /* size of IMtable */
+ int32 last_tag; /* last used tag in IMtable */
struct ref *refArray; /* locked objects */
- int refSize; /* size of refArray */
- unsigned long GCthreshold;
- unsigned long nblocks; /* number of 'blocks' currently allocated */
+ int32 refSize; /* size of refArray */
+ int32 GCthreshold;
+ int32 nblocks; /* number of 'blocks' currently allocated */
};
extern lua_State *lua_state;
-extern int globalTaskSerialId;
+extern int32 globalTaskSerialId;
#define L lua_state
Modified: residual/trunk/engine/lua/lstring.cpp
===================================================================
--- residual/trunk/engine/lua/lstring.cpp 2008-07-20 19:25:16 UTC (rev 33146)
+++ residual/trunk/engine/lua/lstring.cpp 2008-07-20 21:08:22 UTC (rev 33147)
@@ -5,9 +5,6 @@
*/
-#include <stdlib.h>
-#include <string.h>
-
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
@@ -27,7 +24,7 @@
void luaS_init (void)
{
- int i;
+ int32 i;
L->string_root = luaM_newvector(NUM_HASHS, stringtable);
for (i=0; i<NUM_HASHS; i++) {
L->string_root[i].size = 0;
@@ -37,19 +34,19 @@
}
-static unsigned long hash_s (const char *s, long l)
+static uint32 hash_s (const char *s, int32 l)
{
- unsigned long h = 0;
+ uint32 h = 0;
while (l--)
- h = ((h<<5)-h)^(unsigned char)*(s++);
+ h = ((h<<5)-h)^(byte)*(s++);
return h;
}
-static int newsize (stringtable *tb)
+static int32 newsize (stringtable *tb)
{
- int size = tb->size;
- int realuse = 0;
- int i;
+ int32 size = tb->size;
+ int32 realuse = 0;
+ int32 i;
/* count how many entries are really in use */
for (i=0; i<size; i++)
if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY)
@@ -64,16 +61,16 @@
static void grow (stringtable *tb)
{
- int ns = newsize(tb);
+ int32 ns = newsize(tb);
TaggedString **newhash = luaM_newvector(ns, TaggedString *);
- int i;
+ int32 i;
for (i=0; i<ns; i++)
newhash[i] = NULL;
/* rehash */
tb->nuse = 0;
for (i=0; i<tb->size; i++) {
if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY) {
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list