return error

This commit is contained in:
Glenn Maynard
2006-09-21 23:05:32 +00:00
parent 5a7b061639
commit 81aa418b11
2 changed files with 9 additions and 11 deletions
+6 -9
View File
@@ -138,23 +138,20 @@ void LuaReference::Unregister()
m_iReference = LUA_NOREF;
}
void LuaReference::SetFromExpression( const RString &sExpression )
bool LuaReference::SetFromExpression( const RString &sExpression )
{
RString sFullExpression = "return " + sExpression;
SetName( sFullExpression );
Lua *L = LUA->Get();
if( !LuaHelpers::RunScript(L, sFullExpression, "expression", 1) )
{
bool bSuccess = LuaHelpers::RunScript(L, sFullExpression, "expression", 1);
if( !bSuccess )
this->SetFromNil();
LUA->Release( L );
return;
}
/* Store the result. */
this->SetFromStack( L );
else
this->SetFromStack( L );
LUA->Release( L );
return bSuccess;
}
RString LuaReference::Serialize() const
+3 -2
View File
@@ -22,8 +22,9 @@ public:
void SetFromNil();
/* Evaluate an expression that returns an object; store the object in a reference.
* For example, evaluating "{ 1, 2, 3 }" will result in a reference to a table. */
void SetFromExpression( const RString &sExpression );
* For example, evaluating "{ 1, 2, 3 }" will result in a reference to a table.
* On success, return true. On error, set to nil and return false. */
bool SetFromExpression( const RString &sExpression );
/* Deep-copy tables, detaching this reference from any others. */
void DeepCopy();