diff options
author | chai <chaifix@163.com> | 2019-03-19 23:06:27 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-19 23:06:27 +0800 |
commit | 1497dccd63a84b7ee2b229b1ad9c5c02718f2a78 (patch) | |
tree | f8d1bff50da13e126d08c7345653e002e293202d /source/3rd-party/Luax/luax_reftable.h | |
parent | 5e2a973516e0729b225da9de0b03015dc5854ac4 (diff) |
*rename
Diffstat (limited to 'source/3rd-party/Luax/luax_reftable.h')
-rw-r--r-- | source/3rd-party/Luax/luax_reftable.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/source/3rd-party/Luax/luax_reftable.h b/source/3rd-party/Luax/luax_reftable.h new file mode 100644 index 0000000..58e4b9c --- /dev/null +++ b/source/3rd-party/Luax/luax_reftable.h @@ -0,0 +1,67 @@ +#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(); + + inline operator bool() { return mState; }; + + 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 |