-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathXLuaGlobal.java
More file actions
84 lines (62 loc) · 1.77 KB
/
Copy pathXLuaGlobal.java
File metadata and controls
84 lines (62 loc) · 1.77 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
import org.luaj.vm2.*;
/**
*
* @author admin
*/
public class XLuaGlobal {
private static XLuaGlobal ref;
private Map<Integer, XLuaState> stateTable;
private Map<LuaValue, XLuaState> stateLookup;
private Map<XLuaState, Integer> idLookup;
//public List<XLuaState> winiStates;
private XLuaGlobal () {
stateTable = new HashMap<Integer, XLuaState>();
stateLookup = new HashMap<LuaValue, XLuaState>();
idLookup = new HashMap<XLuaState, Integer>();
}
public static synchronized XLuaGlobal Get () {
if (ref == null) {
ref = new XLuaGlobal();
}
return ref;
}
public Object clone () throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
public boolean CreateState (int sid) {
DeleteState(sid);
XLuaState state = new XLuaState();
stateTable.put(sid, state);
if (!state.ready) {
return false;
}
stateLookup.put(state._G, state);
return true;
}
public boolean DeleteState (int sid) {
XLuaState state = stateTable.get(sid);
if (state != null) {
stateTable.remove(sid);
stateLookup.remove(state._G);
return true;
}
return false;
}
public boolean DeleteState (XLuaState s) {
if (idLookup.containsKey(s)) {
return DeleteState(idLookup.get(s));
}
return false;
}
public XLuaState GetState (int sid) {
return stateTable.get(sid);
}
public XLuaState GetStateByState (LuaValue state) {
return stateLookup.get(state);
}
}