Debian Codegraph @

3rdparty/toluapp/include/tolua++.h

raw
1 /* tolua
2 ** Support code for Lua bindings.
3 ** Written by Waldemar Celes
4 ** TeCGraf/PUC-Rio
5 ** Apr 2003
6 ** $Id: $
7 */
8
9 /* This code is free software; you can redistribute it and/or modify it.
10 ** The software provided hereunder is on an "as is" basis, and
11 ** the author has no obligation to provide maintenance, support, updates,
12 ** enhancements, or modifications.
13 */
14
15 #ifndef TOLUA_H
16 #define TOLUA_H
17
18 #ifndef TOLUA_API
19 #ifdef __cplusplus
20 #define TOLUA_API extern "C"
21 #else /* __cplusplus */
22 #define TOLUA_API extern
23 #endif /* __cplusplus */
24 #endif
25
26 #define TOLUA_VERSION "tolua++-1.0.92"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #define tolua_pushcppstring(x, y) tolua_pushstring(x, y.c_str())
33 #define tolua_iscppstring tolua_isstring
34
35 #define tolua_iscppstringarray tolua_isstringarray
36 #define tolua_pushfieldcppstring(L, lo, idx, s) \
37 tolua_pushfieldstring(L, lo, idx, s.c_str())
38
39 #ifndef TEMPLATE_BIND
40 #define TEMPLATE_BIND(p)
41 #endif
42
43 #define TOLUA_TEMPLATE_BIND(p)
44
45 #define TOLUA_PROTECTED_DESTRUCTOR
46 #define TOLUA_PROPERTY_TYPE(p)
47
48 typedef int lua_Object;
49
50 #include <lauxlib.h>
51 #include <lua.h>
52
53 struct tolua_Error {
54 int index;
55 int array;
56 const char* type;
57 };
58 typedef struct tolua_Error tolua_Error;
59
60 #define TOLUA_NOPEER LUA_REGISTRYINDEX /* for lua 5.1 */
61
62 TOLUA_API const char* tolua_typename(lua_State* L, int lo);
63 TOLUA_API void tolua_error(lua_State* L, const char* msg, tolua_Error* err);
64 TOLUA_API int tolua_isnoobj(lua_State* L, int lo, tolua_Error* err);
65 TOLUA_API int tolua_isvalue(lua_State* L, int lo, int def, tolua_Error* err);
66 TOLUA_API int tolua_isvaluenil(lua_State* L, int lo, tolua_Error* err);
67 TOLUA_API int tolua_isboolean(lua_State* L, int lo, int def, tolua_Error* err);
68 TOLUA_API int tolua_isnumber(lua_State* L, int lo, int def, tolua_Error* err);
69 TOLUA_API int tolua_isstring(lua_State* L, int lo, int def, tolua_Error* err);
70 TOLUA_API int tolua_istable(lua_State* L, int lo, int def, tolua_Error* err);
71 TOLUA_API int tolua_isusertable(lua_State* L, int lo, const char* type, int def,
72 tolua_Error* err);
73 TOLUA_API int tolua_isuserdata(lua_State* L, int lo, int def, tolua_Error* err);
74 TOLUA_API int tolua_isusertype(lua_State* L, int lo, const char* type, int def,
75 tolua_Error* err);
76 TOLUA_API int tolua_isvaluearray(lua_State* L, int lo, int dim, int def,
77 tolua_Error* err);
78 TOLUA_API int tolua_isbooleanarray(lua_State* L, int lo, int dim, int def,
79 tolua_Error* err);
80 TOLUA_API int tolua_isnumberarray(lua_State* L, int lo, int dim, int def,
81 tolua_Error* err);
82 TOLUA_API int tolua_isstringarray(lua_State* L, int lo, int dim, int def,
83 tolua_Error* err);
84 TOLUA_API int tolua_istablearray(lua_State* L, int lo, int dim, int def,
85 tolua_Error* err);
86 TOLUA_API int tolua_isuserdataarray(lua_State* L, int lo, int dim, int def,
87 tolua_Error* err);
88 TOLUA_API int tolua_isusertypearray(lua_State* L, int lo, const char* type,
89 int dim, int def, tolua_Error* err);
90
91 TOLUA_API void tolua_open(lua_State* L);
92
93 TOLUA_API void* tolua_copy(lua_State* L, void* value, unsigned int size);
94 TOLUA_API int tolua_register_gc(lua_State* L, int lo);
95 TOLUA_API int tolua_default_collect(lua_State* tolua_S);
96
97 TOLUA_API void tolua_usertype(lua_State* L, const char* type);
98 TOLUA_API void tolua_beginmodule(lua_State* L, const char* name);
99 TOLUA_API void tolua_endmodule(lua_State* L);
100 TOLUA_API void tolua_module(lua_State* L, const char* name, int hasvar);
101 TOLUA_API void tolua_class(lua_State* L, const char* name, const char* base);
102 TOLUA_API void tolua_cclass(lua_State* L, const char* lname, const char* name,
103 const char* base, lua_CFunction col);
104 TOLUA_API void tolua_function(lua_State* L, const char* name,
105 lua_CFunction func);
106 TOLUA_API void tolua_constant(lua_State* L, const char* name, lua_Number value);
107 TOLUA_API void tolua_variable(lua_State* L, const char* name, lua_CFunction get,
108 lua_CFunction set);
109 TOLUA_API void tolua_array(lua_State* L, const char* name, lua_CFunction get,
110 lua_CFunction set);
111
112 /* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char*
113 * type); */
114 /* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */
115
116 TOLUA_API void tolua_pushvalue(lua_State* L, int lo);
117 TOLUA_API void tolua_pushboolean(lua_State* L, int value);
118 TOLUA_API void tolua_pushnumber(lua_State* L, lua_Number value);
119 TOLUA_API void tolua_pushstring(lua_State* L, const char* value);
120 TOLUA_API void tolua_pushuserdata(lua_State* L, void* value);
121 TOLUA_API void tolua_pushusertype(lua_State* L, void* value, const char* type);
122 TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value,
123 const char* type);
124 TOLUA_API void tolua_pushfieldvalue(lua_State* L, int lo, int index, int v);
125 TOLUA_API void tolua_pushfieldboolean(lua_State* L, int lo, int index, int v);
126 TOLUA_API void tolua_pushfieldnumber(lua_State* L, int lo, int index,
127 lua_Number v);
128 TOLUA_API void tolua_pushfieldstring(lua_State* L, int lo, int index,
129 const char* v);
130 TOLUA_API void tolua_pushfielduserdata(lua_State* L, int lo, int index,
131 void* v);
132 TOLUA_API void tolua_pushfieldusertype(lua_State* L, int lo, int index, void* v,
133 const char* type);
134 TOLUA_API void tolua_pushfieldusertype_and_takeownership(lua_State* L, int lo,
135 int index, void* v,
136 const char* type);
137
138 TOLUA_API lua_Number tolua_tonumber(lua_State* L, int narg, lua_Number def);
139 TOLUA_API const char* tolua_tostring(lua_State* L, int narg, const char* def);
140 TOLUA_API void* tolua_touserdata(lua_State* L, int narg, void* def);
141 TOLUA_API void* tolua_tousertype(lua_State* L, int narg, void* def);
142 TOLUA_API int tolua_tovalue(lua_State* L, int narg, int def);
143 TOLUA_API int tolua_toboolean(lua_State* L, int narg, int def);
144 TOLUA_API lua_Number tolua_tofieldnumber(lua_State* L, int lo, int index,
145 lua_Number def);
146 TOLUA_API const char* tolua_tofieldstring(lua_State* L, int lo, int index,
147 const char* def);
148 TOLUA_API void* tolua_tofielduserdata(lua_State* L, int lo, int index,
149 void* def);
150 TOLUA_API void* tolua_tofieldusertype(lua_State* L, int lo, int index,
151 void* def);
152 TOLUA_API int tolua_tofieldvalue(lua_State* L, int lo, int index, int def);
153 TOLUA_API int tolua_getfieldboolean(lua_State* L, int lo, int index, int def);
154
155 TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size,
156 const char* name);
157
158 TOLUA_API int class_gc_event(lua_State* L);
159
160 #ifdef __cplusplus
161 static inline const char* tolua_tocppstring(lua_State* L, int narg,
162 const char* def) {
163 const char* s = tolua_tostring(L, narg, def);
164 return s ? s : "";
165 }
166
167 static inline const char* tolua_tofieldcppstring(lua_State* L, int lo,
168 int index, const char* def) {
169 const char* s = tolua_tofieldstring(L, lo, index, def);
170 return s ? s : "";
171 }
172
173 #else
174 #define tolua_tocppstring tolua_tostring
175 #define tolua_tofieldcppstring tolua_tofieldstring
176 #endif
177
178 TOLUA_API int tolua_fast_isa(lua_State* L, int mt_indexa, int mt_indexb,
179 int super_index);
180
181 #ifndef Mtolua_new
182 #define Mtolua_new(EXP) new EXP
183 #endif
184
185 #ifndef Mtolua_delete
186 #define Mtolua_delete(EXP) delete EXP
187 #endif
188
189 #ifndef Mtolua_new_dim
190 #define Mtolua_new_dim(EXP, len) new EXP[len]
191 #endif
192
193 #ifndef Mtolua_delete_dim
194 #define Mtolua_delete_dim(EXP) delete[] EXP
195 #endif
196
197 #ifndef tolua_outside
198 #define tolua_outside
199 #endif
200
201 #ifndef tolua_owned
202 #define tolua_owned
203 #endif
204
205 #ifdef __cplusplus
206 }
207 #endif
208
209 #endif