Permalink
Browse files

Update LuaPlus code and samples against Lua 5.3 RC2

  • Loading branch information...
jjensen committed Dec 26, 2014
1 parent 3977c40 commit 63d805953f56febf77bd74083c44de732e6f5270
@@ -137,8 +137,31 @@ int new_VECTOR2(lua_State* L) {
int ENTITY___gc(lua_State* L) {
ENTITY* entity = (ENTITY*)*(void**)lua_touserdata(L, 1);
delete entity;
void** ud = (void**)lua_touserdata(L, 1);
if (ud) {
ENTITY* entity = (ENTITY*)(*ud);
delete entity;
}
return 0;
}
int POSITION_ENTITY___gc(lua_State* L) {
void** ud = (void**)lua_touserdata(L, 1);
if (ud) {
POSITION_ENTITY* entity = (POSITION_ENTITY*)(*ud);
delete entity;
}
return 0;
}
int MONSTER___gc(lua_State* L) {
void** ud = (void**)lua_touserdata(L, 1);
if (ud) {
MONSTER* entity = (MONSTER*)(*ud);
delete entity;
}
return 0;
}
@@ -217,14 +240,14 @@ void Vector4MonsterMetatableTest() {
// POSITION_ENTITY
LPCD::Class(L, "POSITION_ENTITY", "ENTITY")
.Property("position", &POSITION_ENTITY::position)
.MetatableFunction("__gc", &ENTITY___gc)
.MetatableFunction("__gc", &POSITION_ENTITY___gc)
;
// MONSTER
LPCD::Class(L, "MONSTER", "POSITION_ENTITY")
.ObjectDirect("printMe", (MONSTER*)0, &MONSTER::printMe)
.Property("alive", &MONSTER::alive)
.MetatableFunction("__gc", &ENTITY___gc)
.MetatableFunction("__gc", &MONSTER___gc)
;
@@ -326,7 +326,7 @@ void LuaTableIteratorTest()
for ( LuaTableIterator it( obj ); it; it.Next() )
{
const char* key = it.GetKey().GetString();
int num = it.GetValue().GetInteger();
lua_Integer num = it.GetValue().GetInteger();
}
}
@@ -683,7 +683,7 @@ void DumpTest()
}
#if LUAPLUS_EXTENSIONS
#if LUAPLUS_EXTENSIONS && LUA_VERSION_NUM <= 501
void TestANSIFile()
{
@@ -2198,7 +2198,7 @@ int __cdecl main(int argc, char* argv[])
TestStdString();
VectorMonsterMetatableTest();
#if LUAPLUS_EXTENSIONS
#if LUAPLUS_EXTENSIONS && LUA_VERSION_NUM <= 501
TestANSIFile();
TestUnicodeFile();
ReadUnicodeFile();
@@ -1077,7 +1077,11 @@ TEST(LuaObject_Assign)
CHECK(obj.Type() == LUA_TNUMBER);
CHECK(obj.IsNumber());
CHECK(obj.GetNumber() == 5.5);
#if LUA_VERSION_NUM >= 503
CHECK(obj.GetInteger() == 0);
#else
CHECK(obj.GetInteger() == 5 || obj.GetInteger() == 6);
#endif
CHECK(strcmp(obj.TypeName(), "number") == 0);
obj.Assign(state, "Hello");
@@ -384,4 +384,70 @@ local LUA53_SRCS =
LuaSharedLibrary lua53 : $(LUA53_SRCS) : lua53 ;
##################################################################
local LUA53_LUAPLUS_SRCS =
lua53-luaplus/src/lapi.c
lua53-luaplus/src/lapi.h
lua53-luaplus/src/lauxlib.c
lua53-luaplus/src/lauxlib.h
lua53-luaplus/src/lbaselib.c
lua53-luaplus/src/lbitlib.c
lua53-luaplus/src/lcode.c
lua53-luaplus/src/lcode.h
lua53-luaplus/src/lcorolib.c
lua53-luaplus/src/lctype.c
lua53-luaplus/src/lctype.h
lua53-luaplus/src/ldblib.c
lua53-luaplus/src/ldebug.c
lua53-luaplus/src/ldebug.h
lua53-luaplus/src/ldo.c
lua53-luaplus/src/ldo.h
lua53-luaplus/src/ldump.c
lua53-luaplus/src/lfunc.c
lua53-luaplus/src/lfunc.h
lua53-luaplus/src/lgc.c
lua53-luaplus/src/lgc.h
lua53-luaplus/src/linit.c
lua53-luaplus/src/liolib.c
lua53-luaplus/src/llex.c
lua53-luaplus/src/llex.h
lua53-luaplus/src/llimits.h
lua53-luaplus/src/lmathlib.c
lua53-luaplus/src/lmem.c
lua53-luaplus/src/lmem.h
lua53-luaplus/src/loadlib.c
lua53-luaplus/src/lobject.c
lua53-luaplus/src/lobject.h
lua53-luaplus/src/lopcodes.c
lua53-luaplus/src/lopcodes.h
lua53-luaplus/src/loslib.c
lua53-luaplus/src/lparser.c
lua53-luaplus/src/lparser.h
lua53-luaplus/src/lstate.c
lua53-luaplus/src/lstate.h
lua53-luaplus/src/lstring.c
lua53-luaplus/src/lstring.h
lua53-luaplus/src/lstrlib.c
lua53-luaplus/src/ltable.c
lua53-luaplus/src/ltable.h
lua53-luaplus/src/ltablib.c
lua53-luaplus/src/ltm.c
lua53-luaplus/src/ltm.h
#lua53-luaplus/src/lua.c
lua53-luaplus/src/lua.h
lua53-luaplus/src/lua.hpp
#lua53-luaplus/src/luac.c
lua53-luaplus/src/luaconf.h
lua53-luaplus/src/lualib.h
lua53-luaplus/src/lundump.c
lua53-luaplus/src/lundump.h
lua53-luaplus/src/lutf8lib.c
lua53-luaplus/src/lvm.c
lua53-luaplus/src/lvm.h
lua53-luaplus/src/lzio.c
lua53-luaplus/src/lzio.h
;
LuaSharedLibrary lua53-luaplus : $(LUA53_LUAPLUS_SRCS) : lua53 ;
}
@@ -397,7 +397,7 @@ local LUA53_SRCS =
ActiveTarget lua53-static ;
SourceGroup : lua53 : $(LUA52_SRCS) ;
SourceGroup : lua53 : $(LUA53_SRCS) ;
SourceGroup : LuaPlus : $(LUAPLUS_SRCS) ;
C.IncludeDirectories : lua53/src ;
@@ -410,4 +410,82 @@ C.OutputName : lua53-static ;
C.Library : $(LUA53_SRCS) $(LUAPLUS_SRCS) ;
##################################################################
local LUA53_LUAPLUS_SRCS =
lua53-luaplus/src/lapi.c
lua53-luaplus/src/lapi.h
lua53-luaplus/src/lauxlib.c
lua53-luaplus/src/lauxlib.h
lua53-luaplus/src/lbaselib.c
lua53-luaplus/src/lbitlib.c
lua53-luaplus/src/lcode.c
lua53-luaplus/src/lcode.h
lua53-luaplus/src/lcorolib.c
lua53-luaplus/src/lctype.c
lua53-luaplus/src/lctype.h
lua53-luaplus/src/ldblib.c
lua53-luaplus/src/ldebug.c
lua53-luaplus/src/ldebug.h
lua53-luaplus/src/ldo.c
lua53-luaplus/src/ldo.h
lua53-luaplus/src/ldump.c
lua53-luaplus/src/lfunc.c
lua53-luaplus/src/lfunc.h
lua53-luaplus/src/lgc.c
lua53-luaplus/src/lgc.h
lua53-luaplus/src/linit.c
lua53-luaplus/src/liolib.c
lua53-luaplus/src/llex.c
lua53-luaplus/src/llex.h
lua53-luaplus/src/llimits.h
lua53-luaplus/src/lmathlib.c
lua53-luaplus/src/lmem.c
lua53-luaplus/src/lmem.h
lua53-luaplus/src/loadlib.c
lua53-luaplus/src/lobject.c
lua53-luaplus/src/lobject.h
lua53-luaplus/src/lopcodes.c
lua53-luaplus/src/lopcodes.h
lua53-luaplus/src/loslib.c
lua53-luaplus/src/lparser.c
lua53-luaplus/src/lparser.h
lua53-luaplus/src/lstate.c
lua53-luaplus/src/lstate.h
lua53-luaplus/src/lstring.c
lua53-luaplus/src/lstring.h
lua53-luaplus/src/lstrlib.c
lua53-luaplus/src/ltable.c
lua53-luaplus/src/ltable.h
lua53-luaplus/src/ltablib.c
lua53-luaplus/src/ltm.c
lua53-luaplus/src/ltm.h
#lua53-luaplus/src/lua.c
lua53-luaplus/src/lua.h
lua53-luaplus/src/lua.hpp
#lua53-luaplus/src/luac.c
lua53-luaplus/src/luaconf.h
lua53-luaplus/src/lualib.h
lua53-luaplus/src/lundump.c
lua53-luaplus/src/lundump.h
lua53-luaplus/src/lvm.c
lua53-luaplus/src/lvm.h
lua53-luaplus/src/lzio.c
lua53-luaplus/src/lzio.h
;
ActiveTarget lua53-luaplus-static ;
SourceGroup : lua53 : $(LUA53_SRCS) ;
SourceGroup : LuaPlus : $(LUAPLUS_SRCS) ;
C.IncludeDirectories : lua53-luaplus/src ;
C.Defines : LUA_OPNAMES ;
LuaPlusDefines lua53-luaplus-static ;
C.OutputName : lua53-luaplus-static ;
C.Library : $(LUA53_SRCS) $(LUAPLUS_SRCS) ;
}
View
@@ -52,6 +52,9 @@ class LuaState {
void PushGlobalTable();
void PushValue(int index);
void PushValue(LuaStackObject& object);
#if LUA_VERSION_NUM >= 503
void Rotate(int index, int n);
#endif
void Remove(int index);
void Insert(int index);
void Replace(int index);
@@ -64,6 +67,7 @@ class LuaState {
int IsNumber(int index) const;
int IsString(int index) const;
int IsCFunction(int index) const;
int IsInteger(int index) const;
int IsUserdata(int index) const;
int IsFunction(int index) const;
int IsTable(int index) const;
@@ -134,8 +138,9 @@ class LuaState {
// get functions (Lua -> stack)
void GetTable(int index);
void GetField(int index, const char* key);
void GetI(int index, lua_Integer key);
void RawGet(int index);
void RawGetI(int index, int n);
void RawGetI(int index, lua_Integer n);
void RawGetP(int index, const void* p);
LuaStackObject CreateTable(int narr = 0, int nrec = 0);
LuaStackObject NewUserdata(size_t size);
@@ -156,18 +161,29 @@ class LuaState {
void SetGlobal(const char* key);
void SetTable(int index);
void SetField(int index, const char* key);
void SetI(int index, lua_Integer key);
void RawSet(int index);
void RawSetI(int index, int n);
void RawSetI(int index, lua_Integer n);
void RawSetP(int index, const void* p);
void SetMetatable(int index);
void SetUservalue(int index);
void SetFEnv(int index);
// `load' and `call' functions (load and run Lua code)
#if LUA_VERSION_NUM == 501 || LUA_VERSION_NUM == 502
void CallK(int nargs, int nresults, int ctx, lua_CFunction k);
#else
void CallK(int nargs, int nresults, lua_KContext ctx, lua_KFunction k);
#endif
void Call(int nargs, int nresults);
#if LUA_VERSION_NUM == 501 || LUA_VERSION_NUM == 502
int GetCtx(int *ctx);
#endif
#if LUA_VERSION_NUM == 501 || LUA_VERSION_NUM == 502
int PCallK(int nargs, int nresults, int errfunc, int ctx, lua_CFunction k);
#else
int PCallK(int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k);
#endif
int PCall(int nargs, int nresults, int errfunc);
int CPCall(lua_CFunction func, void* ud);
int Load(lua_Reader reader, void* data, const char* chunkname, const char* mode);
@@ -181,11 +197,18 @@ class LuaState {
/*
** coroutine functions
*/
#if LUA_VERSION_NUM == 501 || LUA_VERSION_NUM == 502
int YieldK(int nresults, int ctx, lua_CFunction k);
#else
int YieldK(int nresults, lua_KContext ctx, lua_KFunction k);
#endif
int Yield_(int nresults);
int Resume(lua_State *from, int narg);
int Resume(LuaState *from, int narg);
int Status();
#if LUA_VERSION_NUM >= 503
int IsYieldable();
#endif
/*
** garbage-collection function and options
@@ -203,7 +226,7 @@ class LuaState {
void Len(int index);
int StrToNum(const char *s, size_t len);
int StringToNumber(const char *s);
lua_Alloc GetAllocF(void **ud);
void SetAllocF(lua_Alloc f, void *ud);
Oops, something went wrong.

0 comments on commit 63d8059

Please sign in to comment.