summaryrefslogtreecommitdiff
path: root/source/3rd-party/Luax/luax_class.inl
diff options
context:
space:
mode:
Diffstat (limited to 'source/3rd-party/Luax/luax_class.inl')
-rw-r--r--source/3rd-party/Luax/luax_class.inl30
1 files changed, 23 insertions, 7 deletions
diff --git a/source/3rd-party/Luax/luax_class.inl b/source/3rd-party/Luax/luax_class.inl
index 7a24896..e2b8de8 100644
--- a/source/3rd-party/Luax/luax_class.inl
+++ b/source/3rd-party/Luax/luax_class.inl
@@ -87,7 +87,7 @@ namespace Luax
template<typename T>
template<typename U>
- void LuaxNativeClass<T>::LuaRetain(LuaxState& state, U* userdata)
+ void LuaxNativeClass<T>::LuaxRetain(LuaxState& state, U* userdata)
{
if (PushLuaxRefTable(state))
{
@@ -105,7 +105,7 @@ namespace Luax
template<typename T>
template<typename U>
- void LuaxNativeClass<T>::LuaRelease(LuaxState& state, U* userdata)
+ void LuaxNativeClass<T>::LuaxRelease(LuaxState& state, U* userdata)
{
if (PushLuaxRefTable(state))
{
@@ -157,7 +157,7 @@ namespace Luax
}
}
}
- state.SetTop(top);
+ lua_settop(state, top);
lua_pushnil(state);
return false;
}
@@ -250,9 +250,9 @@ namespace Luax
/// Աù
///
template<typename T>
- void LuaxNativeClass<T>::SetMemberRef(LuaxState& state, LuaxMemberRef& memRef, int idx)
+ void LuaxNativeClass<T>::SetLuaxMemberRef(LuaxState& state, LuaxMemberRef& memRef, int idx)
{
- ClearMemberRef(state, memRef);
+ ClearLuaxMemberRef(state, memRef);
if (!lua_isnil(state, idx))
{
idx = state.AbsIndex(idx);
@@ -266,7 +266,7 @@ namespace Luax
}
template<typename T>
- bool LuaxNativeClass<T>::PushMemberRef(LuaxState& state, LuaxMemberRef& memRef)
+ bool LuaxNativeClass<T>::PushLuaxMemberRef(LuaxState& state, LuaxMemberRef& memRef)
{
if (memRef)
{
@@ -285,8 +285,24 @@ namespace Luax
return false;
}
+ template<typename T>
+ bool LuaxNativeClass<T>::PushLuaxMemberRef(LuaxState& state, int refID)
+ {
+ if (PushLuaxRefTable(state))
+ {
+ lua_rawgeti(state, -1, refID);
+ lua_replace(state, -2); // ref table
+ if (lua_isnil(state, -1))
+ goto failed;
+ return true;
+ }
+ lua_pushnil(state);
+ failed:
+ return false;
+ }
+
template<typename T>
- void LuaxNativeClass<T>::ClearMemberRef(LuaxState& state, LuaxMemberRef& memRef)
+ void LuaxNativeClass<T>::ClearLuaxMemberRef(LuaxState& state, LuaxMemberRef& memRef)
{
if (memRef)
{