summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r--src/Bindings/LuaState.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 142242162..3b4ce3376 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -46,7 +46,7 @@ const cLuaState::cRet cLuaState::Return = {};
// cLuaState:
cLuaState::cLuaState(const AString & a_SubsystemName) :
- m_LuaState(NULL),
+ m_LuaState(nullptr),
m_IsOwned(false),
m_SubsystemName(a_SubsystemName),
m_NumCurrentFunctionArgs(-1)
@@ -90,7 +90,7 @@ cLuaState::~cLuaState()
void cLuaState::Create(void)
{
- if (m_LuaState != NULL)
+ if (m_LuaState != nullptr)
{
LOGWARNING("%s: Trying to create an already-existing LuaState, ignoring.", __FUNCTION__);
return;
@@ -119,7 +119,7 @@ void cLuaState::RegisterAPILibs(void)
void cLuaState::Close(void)
{
- if (m_LuaState == NULL)
+ if (m_LuaState == nullptr)
{
LOGWARNING("%s: Trying to close an invalid LuaState, ignoring.", __FUNCTION__);
return;
@@ -134,7 +134,7 @@ void cLuaState::Close(void)
return;
}
lua_close(m_LuaState);
- m_LuaState = NULL;
+ m_LuaState = nullptr;
m_IsOwned = false;
}
@@ -144,7 +144,7 @@ void cLuaState::Close(void)
void cLuaState::Attach(lua_State * a_State)
{
- if (m_LuaState != NULL)
+ if (m_LuaState != nullptr)
{
LOGINFO("%s: Already contains a LuaState (0x%p), will be closed / detached.", __FUNCTION__, m_LuaState);
if (m_IsOwned)
@@ -166,7 +166,7 @@ void cLuaState::Attach(lua_State * a_State)
void cLuaState::Detach(void)
{
- if (m_LuaState == NULL)
+ if (m_LuaState == nullptr)
{
return;
}
@@ -179,7 +179,7 @@ void cLuaState::Detach(void)
Close();
return;
}
- m_LuaState = NULL;
+ m_LuaState = nullptr;
}
@@ -828,7 +828,7 @@ void cLuaState::GetStackValue(int a_StackPos, AString & a_Value)
{
size_t len = 0;
const char * data = lua_tolstring(m_LuaState, a_StackPos, &len);
- if (data != NULL)
+ if (data != nullptr)
{
a_Value.assign(data, len);
}
@@ -878,7 +878,7 @@ void cLuaState::GetStackValue(int a_StackPos, pBoundingBox & a_ReturnedVal)
{
if (lua_isnil(m_LuaState, a_StackPos))
{
- a_ReturnedVal = NULL;
+ a_ReturnedVal = nullptr;
return;
}
tolua_Error err;
@@ -896,7 +896,7 @@ void cLuaState::GetStackValue(int a_StackPos, pWorld & a_ReturnedVal)
{
if (lua_isnil(m_LuaState, a_StackPos))
{
- a_ReturnedVal = NULL;
+ a_ReturnedVal = nullptr;
return;
}
tolua_Error err;
@@ -961,7 +961,7 @@ bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable,
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
- AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
+ AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
@@ -994,7 +994,7 @@ bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, in
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
- AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
+ AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
@@ -1027,7 +1027,7 @@ bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
- AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
+ AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
@@ -1060,7 +1060,7 @@ bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
- AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
+ AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
@@ -1093,7 +1093,7 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
- AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
+ AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
@@ -1126,7 +1126,7 @@ bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s",
- (entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str()
+ (entry.name != nullptr) ? entry.name : "?", i, GetTypeText(i).c_str()
);
return false;
} // for i - Param
@@ -1159,7 +1159,7 @@ bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam)
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s",
- (entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str()
+ (entry.name != nullptr) ? entry.name : "?", i, GetTypeText(i).c_str()
);
return false;
} // for i - Param
@@ -1183,7 +1183,7 @@ bool cLuaState::CheckParamEnd(int a_Param)
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
- AString ErrMsg = Printf("#ferror in function '%s': Too many arguments.", (entry.name != NULL) ? entry.name : "?");
+ AString ErrMsg = Printf("#ferror in function '%s': Too many arguments.", (entry.name != nullptr) ? entry.name : "?");
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
}
@@ -1362,7 +1362,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
case LUA_TUSERDATA:
{
// Get the class name:
- const char * type = NULL;
+ const char * type = nullptr;
if (lua_getmetatable(a_SrcLuaState, i) == 0)
{
LOGWARNING("%s: Unknown class in pos %d, cannot copy.", __FUNCTION__, i);
@@ -1374,7 +1374,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
lua_pop(a_SrcLuaState, 1); // Stack -1
// Copy the value:
- void * ud = tolua_touserdata(a_SrcLuaState, i, NULL);
+ void * ud = tolua_touserdata(a_SrcLuaState, i, nullptr);
tolua_pushusertype(m_LuaState, ud, type);
break;
}
@@ -1400,7 +1400,7 @@ void cLuaState::ToString(int a_StackPos, AString & a_String)
{
size_t len;
const char * s = lua_tolstring(m_LuaState, a_StackPos, &len);
- if (s != NULL)
+ if (s != nullptr)
{
a_String.assign(s, len);
}
@@ -1422,7 +1422,7 @@ void cLuaState::LogStack(const char * a_Header)
void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
{
// Format string consisting only of %s is used to appease the compiler
- LOG("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
+ LOG("%s", (a_Header != nullptr) ? a_Header : "Lua C API Stack contents:");
for (int i = lua_gettop(a_LuaState); i > 0; i--)
{
AString Value;
@@ -1459,7 +1459,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
// cLuaState::cRef:
cLuaState::cRef::cRef(void) :
- m_LuaState(NULL),
+ m_LuaState(nullptr),
m_Ref(LUA_REFNIL)
{
}
@@ -1469,7 +1469,7 @@ cLuaState::cRef::cRef(void) :
cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) :
- m_LuaState(NULL),
+ m_LuaState(nullptr),
m_Ref(LUA_REFNIL)
{
RefStack(a_LuaState, a_StackPos);
@@ -1481,7 +1481,7 @@ cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) :
cLuaState::cRef::~cRef()
{
- if (m_LuaState != NULL)
+ if (m_LuaState != nullptr)
{
UnRef();
}
@@ -1494,7 +1494,7 @@ cLuaState::cRef::~cRef()
void cLuaState::cRef::RefStack(cLuaState & a_LuaState, int a_StackPos)
{
ASSERT(a_LuaState.IsValid());
- if (m_LuaState != NULL)
+ if (m_LuaState != nullptr)
{
UnRef();
}
@@ -1515,7 +1515,7 @@ void cLuaState::cRef::UnRef(void)
{
luaL_unref(*m_LuaState, LUA_REGISTRYINDEX, m_Ref);
}
- m_LuaState = NULL;
+ m_LuaState = nullptr;
m_Ref = LUA_REFNIL;
}