blob: d3de7d6b298a4cbfd288c9ebf22bd29e8585cab5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#ifndef __LUA_BIND_REFTABLE_H__
#define __LUA_BIND_REFTABLE_H__
#include "LuaBindConfig.h"
namespace LuaBind
{
class State;
class VM;
// ref table ��������strong ref table��weak ref table����table�Ĵ�����
// ������global_State.l_registry��������������µ�����Э�̹�����
class RefTable
{
public:
enum
{
WEAK_KEY = 1,
WEAK_VALUE = 1 << 1
};
RefTable(LuaBind::VM* vm);
~RefTable();
inline operator bool() { return mVM; };
void Init(cc8* name, cc8* mode = nullptr);
bool IsKeyWeak();
bool IsValueWeak();
// ��stack[idx]��ʵ���ڴ�ref table������һ�����ã�������refID
int Ref(State& state, int idx);
void UnRef(int refID);
// ���� ref table ����ջ��
void PushRefTable(State& state);
// �� reftable[refID] ����ջ��
void PushRef(State& state, int refID);
// ��� ref table����������LUA_REGISTRYINDEX[mName]
void Clear();
private:
friend class VM;
friend class State;
VM* mVM; // �����������
cc8* mName; // ref table������
int mMode; // ref table������
};
}
#endif
|