diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-18 14:20:56 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-18 14:20:56 -0300 |
commit | d2ebdc045bae7c8ed0e62729ca455444c076b1bb (patch) | |
tree | 3237f58be972a4e328380e6ec1f96bbf1b8b70d4 /lapi.c | |
parent | 81ede6bfcedb9304974110e00a2a4ba301afb4f7 (diff) | |
download | lua-d2ebdc045bae7c8ed0e62729ca455444c076b1bb.tar.gz lua-d2ebdc045bae7c8ed0e62729ca455444c076b1bb.tar.bz2 lua-d2ebdc045bae7c8ed0e62729ca455444c076b1bb.zip |
new macro 'lua_checkversion' to check whether core and application are
compatible
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.67 2008/07/04 18:27:11 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.68 2008/08/01 17:01:16 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -121,6 +121,16 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { | |||
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | LUA_API void lua_checkversion_ (lua_State *L, int version) { | ||
125 | lua_lock(L); | ||
126 | if (version != LUA_VERSION_NUM) | ||
127 | luaG_runerror(L, "application and Lua core using different Lua versions"); | ||
128 | if (G(L)->nilobjp != luaO_nilobject) | ||
129 | luaG_runerror(L, "application using two incompatible Lua VMs"); | ||
130 | lua_unlock(L); | ||
131 | } | ||
132 | |||
133 | |||
124 | 134 | ||
125 | /* | 135 | /* |
126 | ** basic stack manipulation | 136 | ** basic stack manipulation |