Free Electron
LuaContext.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __lua_LuaContext_h__
8 #define __lua_LuaContext_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 void *lua_alloc(void *ud, void *ptr, size_t osize, size_t nsize);
16 
17 class LuaBaseType;
18 
19 class LuaContext : public Counted
20 {
21  public:
22  LuaContext(sp<Master> spMaster, lua_State *pLuaState);
23 virtual ~LuaContext(void);
24 
25  lua_State *state(void);
26 
27  void pushInstance(Instance &instance);
28  Instance popCreateInstance(void);
29  void popInstance(Instance &instance, bool create=false);
30 
31  sp<LuaBaseType> lookup(FE_UWORD tid);
32  sp<TypeMaster> typeMaster(void) {return m_hpMaster->typeMaster();}
33  sp<Master> master(void) {return m_hpMaster;}
34 
35  void setWindowEventEnums(void);
36  void set(const char *tbl, const char *name, double value);
37 
38  //* offset past these lines in debugging
39  void setPreamble(I32 a_lineCount)
40  { m_preamble=a_lineCount; }
41 
42  enum
43  {
44  e_record = 0,
45  e_array,
46  e_arrayit,
47  e_group,
48  e_groupit,
49  e_layout,
50  e_scope,
51  e_component,
52  e_intarray,
53  e_intarrayit,
54  e_vector,
55  e_vector2,
56  e_vector3,
57  e_vector4,
58  e_vector4f,
59  e_transform,
60  e_statecatalog,
61  e_size
62  };
63 
64 static int debug(lua_State *pLuaState);
65 static void error(lua_State *pLuaState, const char *message);
66 static int manage(lua_State *pLuaState);
67 static int catalog(lua_State *pLuaState);
68 static int create(lua_State *pLuaState);
69 static int createRecordArray(lua_State *pLuaState);
70 static int createScope(lua_State *pLuaState);
71 static int createScopeComponent(lua_State *pLuaState);
72 static int createRecordGroup(lua_State *pLuaState);
73 static int createRecord(lua_State *pLuaState);
74 static int createVector3(lua_State *pLuaState);
75 static int b_or(lua_State *pLuaState);
76 static int b_and(lua_State *pLuaState);
77 
78 const String& name(void) const { return m_name; }
79 
80  void alias(String a_aliasName,String a_trueName)
81  { m_aliasMap[a_aliasName]=a_trueName; }
82  String aliasedName(String a_name)
83  {
84  if(m_aliasMap.find(a_name)==m_aliasMap.end())
85  {
86  return a_name;
87  }
88  return m_aliasMap[a_name];
89  }
90 
91  private:
92  lua_State *m_pLuaState;
93  sp<BaseType> m_spBooleanType;
94  sp<BaseType> m_spIntegerType;
95  sp<BaseType> m_spFloatType;
96  sp<BaseType> m_spDoubleType;
97  sp<BaseType> m_spStringType;
98  sp<BaseType> m_spRecordType;
99  sp<BaseType> m_spGroupType;
100  sp<BaseType> m_spArrayType;
101  sp<BaseType> m_spComponentType;
102  sp<BaseType> m_spIntArrayType;
103  sp<BaseType> m_spVector2Type;
104  sp<BaseType> m_spVector3Type;
105  sp<BaseType> m_spVector4Type;
106  sp<BaseType> m_spVector4fType;
107  sp<BaseType> m_spTransformType;
108  sp<BaseType> m_spStateCatalogType;
109  sp<BaseType> m_spScopeType;
110  sp<BaseType> m_spLayoutType;
111 
112  hp<Master> m_hpMaster;
113 
114  Array<sp<LuaBaseType> > m_luaTypes;
115 
116  String m_name;
117  std::map<String,String> m_aliasMap;
118 #if FE_COUNTED_TRACK
119  Array<void*> m_trackArray;
120 #endif
121  I32 m_preamble;
122 };
123 
124 
125 } /* namespace ext */
126 } /* namespace fe */
127 
128 
129 #endif /* __lua_LuaContext_h__ */
130 
kernel
Definition: namespace.dox:3