summaryrefslogtreecommitdiff
path: root/Source/3rdParty/Luax/luax_reftable.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-12 23:08:31 +0800
committerchai <chaifix@163.com>2019-03-12 23:08:31 +0800
commit6016ece202eef94ed76bd20d4f7879ccc71cc2e6 (patch)
treeda0d0be011ee24489174bde1ec1c436ce7aaa1b2 /Source/3rdParty/Luax/luax_reftable.h
parent9eba034f5c2ffd49f33d38c283b24230f9e362e0 (diff)
*luax
Diffstat (limited to 'Source/3rdParty/Luax/luax_reftable.h')
-rw-r--r--Source/3rdParty/Luax/luax_reftable.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/Source/3rdParty/Luax/luax_reftable.h b/Source/3rdParty/Luax/luax_reftable.h
new file mode 100644
index 0000000..0ba42f7
--- /dev/null
+++ b/Source/3rdParty/Luax/luax_reftable.h
@@ -0,0 +1,65 @@
+#ifndef __LUAX_REFTABLE_H__
+#define __LUAX_REFTABLE_H__
+
+#include "luax_config.h"
+
+namespace Luax
+{
+
+ class LuaxState;
+
+ ///
+ /// ref table strong ref tableweak ref tabletableĴ
+ ///
+ class LuaxRefTable
+ {
+ public:
+
+ enum
+ {
+ WEAK_KEY = 1,
+ WEAK_VALUE = 1 << 1
+ };
+
+ LuaxRefTable();
+ ~LuaxRefTable();
+
+ void Init(LuaxState& state, cc8* name, cc8* mode = nullptr);
+
+ bool IsKeyWeak();
+ bool IsValueWeak();
+
+ ///
+ /// stack[idx]ʵڴref tableһãrefID
+ ///
+ int Ref(LuaxState& state, int idx);
+ void Unref(LuaxState& state, int refID);
+
+ ///
+ /// ref table ջ
+ ///
+ void PushRefTable(LuaxState& state);
+
+ ///
+ /// reftable[refID] ջ
+ ///
+ void PushRef(LuaxState& state, int refID);
+
+ ///
+ /// ref tableLUA_REGISTRYINDEX[mName]
+ ///
+ void Clear(LuaxState& state);
+
+ private:
+
+ friend class LuaxState;
+
+ lua_State* mState; // һЩȷϹ
+ cc8* mName; // ref table
+ int mMode; // ref table
+
+ };
+
+}
+
+#endif \ No newline at end of file