浏览代码

From Lua 5.2: Add lua_version().

Contributed by François Perrad.
Mike Pall 8 年之前
父节点
当前提交
c67a098292
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. 7 0
      src/lj_api.c
  2. 1 0
      src/lua.h

+ 7 - 0
src/lj_api.c

@@ -112,6 +112,13 @@ LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
   from->top = f;
 }
 
+LUA_API const lua_Number *lua_version(lua_State *L)
+{
+  static const lua_Number version = LUA_VERSION_NUM;
+  UNUSED(L);
+  return &version;
+}
+
 /* -- Stack manipulation -------------------------------------------------- */
 
 LUA_API int lua_gettop(lua_State *L)

+ 1 - 0
src/lua.h

@@ -348,6 +348,7 @@ LUA_API void *lua_upvalueid (lua_State *L, int idx, int n);
 LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2);
 LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt,
 		       const char *chunkname, const char *mode);
+LUA_API const lua_Number *lua_version (lua_State *L);
 
 
 struct lua_Debug {