From e0a68a235eb122b3e5ce7e09b9921459b7e40a9e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 21 Sep 2006 01:56:08 +0000 Subject: [PATCH] eliminate LuaData type; move Serialize into LuaReference Nothing uses Serialize right now. I havn't decided whether to keep it around. --- stepmania/src/LuaReference.cpp | 20 +------------------- stepmania/src/LuaReference.h | 11 ++--------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/stepmania/src/LuaReference.cpp b/stepmania/src/LuaReference.cpp index 2d9c1d9d38..9962b50e3c 100644 --- a/stepmania/src/LuaReference.cpp +++ b/stepmania/src/LuaReference.cpp @@ -157,7 +157,7 @@ void LuaExpression::SetFromExpression( const RString &sExpression ) LUA->Release( L ); } -RString LuaData::Serialize() const +RString LuaReference::Serialize() const { /* Call Serialize(t), where t is our referenced object. */ Lua *L = LUA->Get(); @@ -184,24 +184,6 @@ RString LuaData::Serialize() const return sRet; } -void LuaData::LoadFromString( const RString &s ) -{ - Lua *L = LUA->Get(); - - /* Restore the serialized data by evaluating it. */ - RString sError; - if( !LuaHelpers::RunScript( L, s, "serialization", sError, 1 ) ) - { - /* Serialize() should never return an invalid script. Drop the failed - * script into the log (it may be too big to pass to FAIL_M) and fail. */ - LOG->Warn( "Unserialization of \"%s\" failed: %s", s.c_str(), sError.c_str() ); - FAIL_M( "Unserialization failed" ); - } - - this->SetFromStack( L ); - LUA->Release( L ); -} - LuaTable::LuaTable() { Lua *L = LUA->Get(); diff --git a/stepmania/src/LuaReference.h b/stepmania/src/LuaReference.h index e55b32733e..ca758df5e0 100644 --- a/stepmania/src/LuaReference.h +++ b/stepmania/src/LuaReference.h @@ -38,6 +38,8 @@ public: void SetName( const RString &sName ); RString GetName() const { return m_sName; } + RString Serialize() const; + private: void Unregister(); int m_iReference; @@ -55,15 +57,6 @@ public: void SetFromExpression( const RString &sExpression ); }; -/* Reference a trivially restorable Lua object (any object that Serialize can handle). - * The object will be saved and restored across Lua resets. */ -class LuaData: public LuaReference -{ -public: - virtual RString Serialize() const; - virtual void LoadFromString( const RString &s ); -}; - class LuaTable: public LuaReference { public: