mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
new function 'lua_version' (so that 'checkversion' can be implemented
in the auxiliary library)
This commit is contained in:
parent
bc3e02a1b7
commit
1d6ebce296
14
lapi.c
14
lapi.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 2.81 2009/06/17 18:38:54 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.82 2009/06/18 16:36:40 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -129,13 +129,11 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
|
||||
}
|
||||
|
||||
|
||||
LUA_API void lua_checkversion_ (lua_State *L, int version) {
|
||||
lua_lock(L);
|
||||
if (version != LUA_VERSION_NUM)
|
||||
luaG_runerror(L, "app./library not compiled with header " LUA_VERSION);
|
||||
if (G(L)->nilobjp != luaO_nilobject)
|
||||
luaG_runerror(L, "application using multiple Lua VMs");
|
||||
lua_unlock(L);
|
||||
static const lua_Number l_version = LUA_VERSION_NUM;
|
||||
|
||||
LUA_API const lua_Number *lua_version (lua_State *L) {
|
||||
if (L == NULL) return &l_version;
|
||||
else return G(L)->version;
|
||||
}
|
||||
|
||||
|
||||
|
4
lstate.c
4
lstate.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstate.c,v 2.54 2009/04/28 19:04:36 roberto Exp roberto $
|
||||
** $Id: lstate.c,v 2.55 2009/06/01 19:09:26 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -208,7 +208,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
|
||||
setnilvalue(registry(L));
|
||||
luaZ_initbuffer(L, &g->buff);
|
||||
g->panic = NULL;
|
||||
g->nilobjp = luaO_nilobject;
|
||||
g->version = lua_version(NULL);
|
||||
g->gcstate = GCSpause;
|
||||
g->rootgc = obj2gco(L);
|
||||
g->sweepstrgc = 0;
|
||||
|
4
lstate.h
4
lstate.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstate.h,v 2.43 2009/04/17 22:00:01 roberto Exp roberto $
|
||||
** $Id: lstate.h,v 2.44 2009/06/01 19:09:26 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -148,9 +148,9 @@ typedef struct global_State {
|
||||
TValue l_registry;
|
||||
struct lua_State *mainthread;
|
||||
UpVal uvhead; /* head of double-linked list of all open upvalues */
|
||||
const lua_Number *version; /* pointer to version number */
|
||||
struct Table *mt[NUM_TAGS]; /* metatables for basic types */
|
||||
TString *tmname[TM_N]; /* array with tag-method names */
|
||||
const TValue *nilobjp; /* pointer to nil object (to check consistency) */
|
||||
} global_State;
|
||||
|
||||
|
||||
|
5
lua.h
5
lua.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lua.h,v 1.238 2009/06/15 19:51:31 roberto Exp roberto $
|
||||
** $Id: lua.h,v 1.239 2009/06/17 17:49:44 roberto Exp roberto $
|
||||
** Lua - An Extensible Extension Language
|
||||
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
||||
** See Copyright Notice at the end of this file
|
||||
@ -118,8 +118,7 @@ LUA_API lua_State *(lua_mainthread) (lua_State *L);
|
||||
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
|
||||
|
||||
|
||||
LUA_API void lua_checkversion_ (lua_State *L, int version);
|
||||
#define lua_checkversion(L) (lua_checkversion_(L, LUA_VERSION_NUM))
|
||||
LUA_API const lua_Number *lua_version (lua_State *L);
|
||||
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user