diff --git a/inttest/core/LuaApiMock.h b/inttest/core/LuaApiMock.h index c45342ab..12fbf565 100644 --- a/inttest/core/LuaApiMock.h +++ b/inttest/core/LuaApiMock.h @@ -54,7 +54,6 @@ class LuaApiMock : public terrame::lua::LuaApi MOCK_METHOD1(getTopIndex, int(lua_State* L)); MOCK_METHOD2(nextAt, int(lua_State* L, int index)); MOCK_METHOD2(getTypeAt, int(lua_State* L, int index)); - MOCK_METHOD0(getRefNilValue, int()); MOCK_METHOD2(isStringAt, bool(lua_State* L, int index)); MOCK_METHOD2(isNumberAt, bool(lua_State* L, int index)); diff --git a/inttest/core/LuaCellTest.cpp b/inttest/core/LuaCellTest.cpp index 19153cac..aae281d8 100644 --- a/inttest/core/LuaCellTest.cpp +++ b/inttest/core/LuaCellTest.cpp @@ -62,11 +62,6 @@ TEST_F(LuaCellTest, Constructor) { LuaApiMock* luaApiMock = new LuaApiMock(); terrame::lua::LuaSystem::getInstance().setLuaApi(luaApiMock); - - EXPECT_CALL(*luaApiMock, getRefNilValue()) - .Times(testing::AnyNumber()) - .WillRepeatedly(testing::Return(-1)); - luaCell* lc = new luaCell(L); delete luaApiMock; @@ -76,11 +71,6 @@ TEST_F(LuaCellTest, SetAndGetId) { LuaApiMock* luaApiMock = new LuaApiMock(); terrame::lua::LuaSystem::getInstance().setLuaApi(luaApiMock); - - EXPECT_CALL(*luaApiMock, getRefNilValue()) - .Times(testing::AnyNumber()) - .WillRepeatedly(testing::Return(-1)); - luaCell* lc = new luaCell(L); EXPECT_CALL(*luaApiMock, getStringAtTop(testing::_)) @@ -101,10 +91,6 @@ TEST_F(LuaCellTest, CreateObserverAndKill) LuaBindingMock* bindMock = new LuaBindingMock(); terrame::lua::LuaBindingDelegate::getInstance().setBinding(bindMock); - EXPECT_CALL(*luaApiMock, getRefNilValue()) - .Times(testing::AnyNumber()) - .WillRepeatedly(testing::Return(-1)); - luaCell* lc = new luaCell(L); EXPECT_CALL(*luaApiMock, getStringAtTop(testing::_)) diff --git a/src/core/LuaApi.h b/src/core/LuaApi.h index 038acc60..03fd0a4a 100644 --- a/src/core/LuaApi.h +++ b/src/core/LuaApi.h @@ -67,7 +67,6 @@ namespace terrame virtual int getTopIndex(lua_State* L) = 0; virtual int nextAt(lua_State* L, int index) = 0; virtual int getTypeAt(lua_State* L, int index) = 0; - virtual int getRefNilValue() = 0; virtual bool isStringAt(lua_State* L, int index) = 0; virtual bool isNumberAt(lua_State* L, int index) = 0; diff --git a/src/core/LuaFacade.cpp b/src/core/LuaFacade.cpp index 9cd621a9..d9da1e5e 100644 --- a/src/core/LuaFacade.cpp +++ b/src/core/LuaFacade.cpp @@ -137,11 +137,6 @@ int terrame::lua::LuaFacade::getTypeAt(lua_State* L, int index) return lua_type(L, index); } -int terrame::lua::LuaFacade::getRefNilValue() -{ - return LUA_REFNIL; -} - bool terrame::lua::LuaFacade::isStringAt(lua_State* L, int index) { return lua_type(L, index) == getStringType(); diff --git a/src/core/LuaFacade.h b/src/core/LuaFacade.h index ab16954e..b8227076 100644 --- a/src/core/LuaFacade.h +++ b/src/core/LuaFacade.h @@ -68,7 +68,6 @@ namespace terrame int getTopIndex(lua_State* L); int nextAt(lua_State* L, int index); int getTypeAt(lua_State* L, int index); - int getRefNilValue(); bool isStringAt(lua_State* L, int index); bool isNumberAt(lua_State* L, int index); diff --git a/src/core/reference.h b/src/core/reference.h index c63da403..6c13d585 100644 --- a/src/core/reference.h +++ b/src/core/reference.h @@ -35,15 +35,10 @@ template class Reference { public: - Reference() - { - m_ref = terrame::lua::LuaSystem::getInstance().getLuaApi()->getRefNilValue(); - } - /// Sets the reference for the Lua object using the cObj pointer. int setReference(lua_State *L) { - if (m_ref == terrame::lua::LuaSystem::getInstance().getLuaApi()->getRefNilValue()) + if (m_ref == LUA_REFNIL) { m_ref = terrame::lua::LuaSystem::getInstance().getLuaApi()->createWeakTable(L); } @@ -63,7 +58,10 @@ class Reference private: // Index for the table holding the objects on the Lua Registry - int m_ref; + static int m_ref; }; +template +int Reference::m_ref = LUA_REFNIL; + #endif // REFFERENCE_H