Upgraded Lua to 5.3.0
Former-commit-id: 1f5ac994e0bc7ec6467dff7ce02c199cf192b2e2
This commit is contained in:
parent
4c659a6442
commit
774e44333a
|
|
@ -38,8 +38,8 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
|||
void CheckAny(int index) const;
|
||||
bool CheckBoolean(int index) const;
|
||||
bool CheckBoolean(int index, bool defValue) const;
|
||||
int CheckInteger(int index) const;
|
||||
int CheckInteger(int index, int defValue) const;
|
||||
long long CheckInteger(int index) const;
|
||||
long long CheckInteger(int index, long long defValue) const;
|
||||
double CheckNumber(int index) const;
|
||||
double CheckNumber(int index, double defValue) const;
|
||||
void CheckStack(int space, const char* error = nullptr) const;
|
||||
|
|
@ -47,8 +47,6 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
|||
const char* CheckString(int index, std::size_t* length = nullptr) const;
|
||||
const char* CheckString(int index, const char* defValue, std::size_t* length = nullptr) const;
|
||||
void CheckType(int index, nzLuaType type) const;
|
||||
unsigned int CheckUnsigned(int index) const;
|
||||
unsigned int CheckUnsigned(int index, unsigned int defValue) const;
|
||||
void* CheckUserdata(int index, const char* tname) const;
|
||||
void* CheckUserdata(int index, const NzString& tname) const;
|
||||
|
||||
|
|
@ -71,19 +69,19 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
|||
bool ExecuteFromStream(NzInputStream& stream);
|
||||
|
||||
int GetAbsIndex(int index) const;
|
||||
void GetField(const char* fieldName, int index = -1) const;
|
||||
void GetField(const NzString& fieldName, int index = -1) const;
|
||||
void GetGlobal(const char* name) const;
|
||||
void GetGlobal(const NzString& name) const;
|
||||
nzLuaType GetField(const char* fieldName, int index = -1) const;
|
||||
nzLuaType GetField(const NzString& fieldName, int index = -1) const;
|
||||
nzLuaType GetGlobal(const char* name) const;
|
||||
nzLuaType GetGlobal(const NzString& name) const;
|
||||
lua_State* GetInternalState() const;
|
||||
NzString GetLastError() const;
|
||||
nzUInt32 GetMemoryLimit() const;
|
||||
nzUInt32 GetMemoryUsage() const;
|
||||
void GetMetatable(const char* tname) const;
|
||||
void GetMetatable(const NzString& tname) const;
|
||||
nzLuaType GetMetatable(const char* tname) const;
|
||||
nzLuaType GetMetatable(const NzString& tname) const;
|
||||
bool GetMetatable(int index) const;
|
||||
unsigned int GetStackTop() const;
|
||||
void GetTable(int index = -2) const;
|
||||
nzLuaType GetTable(int index = -2) const;
|
||||
nzUInt32 GetTimeLimit() const;
|
||||
nzLuaType GetType(int index) const;
|
||||
const char* GetTypeName(nzLuaType type) const;
|
||||
|
|
@ -108,7 +106,7 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
|||
void PushBoolean(bool value);
|
||||
void PushCFunction(NzLuaCFunction func, int upvalueCount = 0);
|
||||
void PushFunction(NzLuaFunction func);
|
||||
void PushInteger(int value);
|
||||
void PushInteger(long long value);
|
||||
void PushLightUserdata(void* value);
|
||||
void PushMetatable(const char* str);
|
||||
void PushMetatable(const NzString& str);
|
||||
|
|
@ -118,7 +116,6 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
|||
void PushString(const char* str);
|
||||
void PushString(const NzString& str);
|
||||
void PushTable(unsigned int sequenceElementCount = 0, unsigned int arrayElementCount = 0);
|
||||
void PushUnsigned(unsigned int value);
|
||||
void* PushUserdata(unsigned int size);
|
||||
void PushValue(int index);
|
||||
|
||||
|
|
@ -137,11 +134,10 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
|||
void SetTimeLimit(nzUInt32 timeLimit);
|
||||
|
||||
bool ToBoolean(int index) const;
|
||||
int ToInteger(int index, bool* succeeded = nullptr) const;
|
||||
long long ToInteger(int index, bool* succeeded = nullptr) const;
|
||||
double ToNumber(int index, bool* succeeded = nullptr) const;
|
||||
const void* ToPointer(int index) const;
|
||||
const char* ToString(int index, std::size_t* length = nullptr) const;
|
||||
unsigned int ToUnsigned(int index, bool* succeeded = nullptr) const;
|
||||
void* ToUserdata(int index) const;
|
||||
void* ToUserdata(int index, const char* tname) const;
|
||||
void* ToUserdata(int index, const NzString& tname) const;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,45 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
nzLuaType FromLuaType(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case LUA_TBOOLEAN:
|
||||
return nzLuaType_Boolean;
|
||||
|
||||
case LUA_TFUNCTION:
|
||||
return nzLuaType_Function;
|
||||
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
return nzLuaType_LightUserdata;
|
||||
|
||||
case LUA_TNIL:
|
||||
return nzLuaType_Nil;
|
||||
|
||||
case LUA_TNONE:
|
||||
return nzLuaType_None;
|
||||
|
||||
case LUA_TNUMBER:
|
||||
return nzLuaType_Number;
|
||||
|
||||
case LUA_TSTRING:
|
||||
return nzLuaType_String;
|
||||
|
||||
case LUA_TTABLE:
|
||||
return nzLuaType_Table;
|
||||
|
||||
case LUA_TTHREAD:
|
||||
return nzLuaType_Thread;
|
||||
|
||||
case LUA_TUSERDATA:
|
||||
return nzLuaType_Userdata;
|
||||
|
||||
default:
|
||||
return nzLuaType_None;
|
||||
}
|
||||
}
|
||||
|
||||
struct StreamData
|
||||
{
|
||||
NzInputStream* stream;
|
||||
|
|
@ -145,14 +184,14 @@ bool NzLuaInstance::CheckBoolean(int index, bool defValue) const
|
|||
return lua_toboolean(m_state, index);
|
||||
}
|
||||
|
||||
int NzLuaInstance::CheckInteger(int index) const
|
||||
long long NzLuaInstance::CheckInteger(int index) const
|
||||
{
|
||||
return luaL_checkint(m_state, index);
|
||||
return luaL_checkinteger(m_state, index);
|
||||
}
|
||||
|
||||
int NzLuaInstance::CheckInteger(int index, int defValue) const
|
||||
long long NzLuaInstance::CheckInteger(int index, long long defValue) const
|
||||
{
|
||||
return luaL_optint(m_state, index, defValue);
|
||||
return luaL_optinteger(m_state, index, defValue);
|
||||
}
|
||||
|
||||
double NzLuaInstance::CheckNumber(int index) const
|
||||
|
|
@ -198,16 +237,6 @@ void NzLuaInstance::CheckType(int index, nzLuaType type) const
|
|||
luaL_checktype(m_state, index, s_types[type]);
|
||||
}
|
||||
|
||||
unsigned int NzLuaInstance::CheckUnsigned(int index) const
|
||||
{
|
||||
return luaL_checkunsigned(m_state, index);
|
||||
}
|
||||
|
||||
unsigned int NzLuaInstance::CheckUnsigned(int index, unsigned int defValue) const
|
||||
{
|
||||
return luaL_optunsigned(m_state, index, defValue);
|
||||
}
|
||||
|
||||
void* NzLuaInstance::CheckUserdata(int index, const char* tname) const
|
||||
{
|
||||
return luaL_checkudata(m_state, index, tname);
|
||||
|
|
@ -395,24 +424,24 @@ int NzLuaInstance::GetAbsIndex(int index) const
|
|||
return lua_absindex(m_state, index);
|
||||
}
|
||||
|
||||
void NzLuaInstance::GetField(const char* fieldName, int index) const
|
||||
nzLuaType NzLuaInstance::GetField(const char* fieldName, int index) const
|
||||
{
|
||||
lua_getfield(m_state, index, fieldName);
|
||||
return FromLuaType(lua_getfield(m_state, index, fieldName));
|
||||
}
|
||||
|
||||
void NzLuaInstance::GetField(const NzString& fieldName, int index) const
|
||||
nzLuaType NzLuaInstance::GetField(const NzString& fieldName, int index) const
|
||||
{
|
||||
lua_getfield(m_state, index, fieldName.GetConstBuffer());
|
||||
return FromLuaType(lua_getfield(m_state, index, fieldName.GetConstBuffer()));
|
||||
}
|
||||
|
||||
void NzLuaInstance::GetGlobal(const char* name) const
|
||||
nzLuaType NzLuaInstance::GetGlobal(const char* name) const
|
||||
{
|
||||
lua_getglobal(m_state, name);
|
||||
return FromLuaType(lua_getglobal(m_state, name));
|
||||
}
|
||||
|
||||
void NzLuaInstance::GetGlobal(const NzString& name) const
|
||||
nzLuaType NzLuaInstance::GetGlobal(const NzString& name) const
|
||||
{
|
||||
lua_getglobal(m_state, name.GetConstBuffer());
|
||||
return FromLuaType(lua_getglobal(m_state, name.GetConstBuffer()));
|
||||
}
|
||||
|
||||
lua_State* NzLuaInstance::GetInternalState() const
|
||||
|
|
@ -435,14 +464,14 @@ nzUInt32 NzLuaInstance::GetMemoryUsage() const
|
|||
return m_memoryUsage;
|
||||
}
|
||||
|
||||
void NzLuaInstance::GetMetatable(const char* tname) const
|
||||
nzLuaType NzLuaInstance::GetMetatable(const char* tname) const
|
||||
{
|
||||
luaL_getmetatable(m_state, tname);
|
||||
return FromLuaType(luaL_getmetatable(m_state, tname));
|
||||
}
|
||||
|
||||
void NzLuaInstance::GetMetatable(const NzString& tname) const
|
||||
nzLuaType NzLuaInstance::GetMetatable(const NzString& tname) const
|
||||
{
|
||||
luaL_getmetatable(m_state, tname.GetConstBuffer());
|
||||
return FromLuaType(luaL_getmetatable(m_state, tname.GetConstBuffer()));
|
||||
}
|
||||
|
||||
bool NzLuaInstance::GetMetatable(int index) const
|
||||
|
|
@ -455,9 +484,9 @@ unsigned int NzLuaInstance::GetStackTop() const
|
|||
return lua_gettop(m_state);
|
||||
}
|
||||
|
||||
void NzLuaInstance::GetTable(int index) const
|
||||
nzLuaType NzLuaInstance::GetTable(int index) const
|
||||
{
|
||||
lua_gettable(m_state, index);
|
||||
return FromLuaType(lua_gettable(m_state, index));
|
||||
}
|
||||
|
||||
nzUInt32 NzLuaInstance::GetTimeLimit() const
|
||||
|
|
@ -467,41 +496,7 @@ nzUInt32 NzLuaInstance::GetTimeLimit() const
|
|||
|
||||
nzLuaType NzLuaInstance::GetType(int index) const
|
||||
{
|
||||
switch (lua_type(m_state, index))
|
||||
{
|
||||
case LUA_TBOOLEAN:
|
||||
return nzLuaType_Boolean;
|
||||
|
||||
case LUA_TFUNCTION:
|
||||
return nzLuaType_Function;
|
||||
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
return nzLuaType_LightUserdata;
|
||||
|
||||
case LUA_TNIL:
|
||||
return nzLuaType_Nil;
|
||||
|
||||
case LUA_TNONE:
|
||||
return nzLuaType_None;
|
||||
|
||||
case LUA_TNUMBER:
|
||||
return nzLuaType_Number;
|
||||
|
||||
case LUA_TSTRING:
|
||||
return nzLuaType_String;
|
||||
|
||||
case LUA_TTABLE:
|
||||
return nzLuaType_Table;
|
||||
|
||||
case LUA_TTHREAD:
|
||||
return nzLuaType_Thread;
|
||||
|
||||
case LUA_TUSERDATA:
|
||||
return nzLuaType_Userdata;
|
||||
|
||||
default:
|
||||
return nzLuaType_None;
|
||||
}
|
||||
return FromLuaType(lua_type(m_state, index));
|
||||
}
|
||||
|
||||
const char* NzLuaInstance::GetTypeName(nzLuaType type) const
|
||||
|
|
@ -625,7 +620,7 @@ void NzLuaInstance::PushFunction(NzLuaFunction func)
|
|||
lua_pushcclosure(m_state, ProxyFunc, 1);
|
||||
}
|
||||
|
||||
void NzLuaInstance::PushInteger(int value)
|
||||
void NzLuaInstance::PushInteger(long long value)
|
||||
{
|
||||
lua_pushinteger(m_state, value);
|
||||
}
|
||||
|
|
@ -675,11 +670,6 @@ void NzLuaInstance::PushTable(unsigned int sequenceElementCount, unsigned int ar
|
|||
lua_createtable(m_state, sequenceElementCount, arrayElementCount);
|
||||
}
|
||||
|
||||
void NzLuaInstance::PushUnsigned(unsigned int value)
|
||||
{
|
||||
lua_pushunsigned(m_state, value);
|
||||
}
|
||||
|
||||
void* NzLuaInstance::PushUserdata(unsigned int size)
|
||||
{
|
||||
return lua_newuserdata(m_state, size);
|
||||
|
|
@ -763,10 +753,10 @@ bool NzLuaInstance::ToBoolean(int index) const
|
|||
return lua_toboolean(m_state, index);
|
||||
}
|
||||
|
||||
int NzLuaInstance::ToInteger(int index, bool* succeeded) const
|
||||
long long NzLuaInstance::ToInteger(int index, bool* succeeded) const
|
||||
{
|
||||
int success;
|
||||
int result = lua_tointegerx(m_state, index, &success);
|
||||
long long result = lua_tointegerx(m_state, index, &success);
|
||||
|
||||
if (succeeded)
|
||||
*succeeded = (success == 1);
|
||||
|
|
@ -795,17 +785,6 @@ const char* NzLuaInstance::ToString(int index, std::size_t* length) const
|
|||
return lua_tolstring(m_state, index, length);
|
||||
}
|
||||
|
||||
unsigned int NzLuaInstance::ToUnsigned(int index, bool* succeeded) const
|
||||
{
|
||||
int success;
|
||||
unsigned int result = lua_tounsignedx(m_state, index, &success);
|
||||
|
||||
if (succeeded)
|
||||
*succeeded = (success == 1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void* NzLuaInstance::ToUserdata(int index) const
|
||||
{
|
||||
return lua_touserdata(m_state, index);
|
||||
|
|
|
|||
Loading…
Reference in New Issue