Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/script/src/orxonox/script/tolua++.h @ 954

Last change on this file since 954 was 946, checked in by bknecht, 16 years ago

trying to link lua into the project and start with creating an interface to lua. still does not compile. stupid cmake

File size: 6.9 KB
Line 
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
16#ifndef TOLUA_H
17#define TOLUA_H
18
19#ifndef TOLUA_API
20#define TOLUA_API extern
21#endif
22
23#define TOLUA_VERSION "tolua++-1.0.92"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#define tolua_pushcppstring(x,y)        tolua_pushstring(x,y.c_str())
30#define tolua_iscppstring       tolua_isstring
31
32#define tolua_iscppstringarray tolua_isstringarray
33#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str())
34
35#ifndef TEMPLATE_BIND
36 #define TEMPLATE_BIND(p)
37#endif
38
39#define TOLUA_TEMPLATE_BIND(p)
40
41#define TOLUA_PROTECTED_DESTRUCTOR
42#define TOLUA_PROPERTY_TYPE(p)
43
44typedef int lua_Object;
45
46#include "lua.h"
47#include "lauxlib.h"
48
49struct tolua_Error
50{
51        int index;
52        int array;
53        const char* type;
54};
55typedef struct tolua_Error tolua_Error;
56
57#define TOLUA_NOPEER    LUA_REGISTRYINDEX /* for lua 5.1 */
58
59TOLUA_API const char* tolua_typename (lua_State* L, int lo);
60TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err);
61TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err);
62TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err);
63TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err);
64TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err);
65TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err);
66TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err);
67TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err);
68TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
69TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err);
70TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
71TOLUA_API int tolua_isvaluearray
72 (lua_State* L, int lo, int dim, int def, tolua_Error* err);
73TOLUA_API int tolua_isbooleanarray
74 (lua_State* L, int lo, int dim, int def, tolua_Error* err);
75TOLUA_API int tolua_isnumberarray
76 (lua_State* L, int lo, int dim, int def, tolua_Error* err);
77TOLUA_API int tolua_isstringarray
78 (lua_State* L, int lo, int dim, int def, tolua_Error* err);
79TOLUA_API int tolua_istablearray
80 (lua_State* L, int lo, int dim, int def, tolua_Error* err);
81TOLUA_API int tolua_isuserdataarray
82 (lua_State* L, int lo, int dim, int def, tolua_Error* err);
83TOLUA_API int tolua_isusertypearray
84 (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err);
85
86TOLUA_API void tolua_open (lua_State* L);
87
88TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size);
89TOLUA_API int tolua_register_gc (lua_State* L, int lo);
90TOLUA_API int tolua_default_collect (lua_State* tolua_S);
91
92TOLUA_API void tolua_usertype (lua_State* L, char* type);
93TOLUA_API void tolua_beginmodule (lua_State* L, char* name);
94TOLUA_API void tolua_endmodule (lua_State* L);
95TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar);
96TOLUA_API void tolua_class (lua_State* L, char* name, char* base);
97TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col);
98TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func);
99TOLUA_API void tolua_constant (lua_State* L, char* name, lua_Number value);
100TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set);
101TOLUA_API void tolua_array (lua_State* L,char* name, lua_CFunction get, lua_CFunction set);
102
103/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */
104/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */
105
106TOLUA_API void tolua_pushvalue (lua_State* L, int lo);
107TOLUA_API void tolua_pushboolean (lua_State* L, int value);
108TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value);
109TOLUA_API void tolua_pushstring (lua_State* L, const char* value);
110TOLUA_API void tolua_pushuserdata (lua_State* L, void* value);
111TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type);
112TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type);
113TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v);
114TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v);
115TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v);
116TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v);
117TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v);
118TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type);
119TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type);
120
121TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def);
122TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def);
123TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def);
124TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def);
125TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def);
126TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def);
127TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def);
128TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def);
129TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def);
130TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def);
131TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def);
132TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def);
133
134TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name);
135
136TOLUA_API int class_gc_event (lua_State* L);
137
138#ifdef __cplusplus
139static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) {
140
141        const char* s = tolua_tostring(L, narg, def);
142        return s?s:"";
143};
144
145static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) {
146
147        const char* s = tolua_tofieldstring(L, lo, index, def);
148        return s?s:"";
149};
150
151#else
152#define tolua_tocppstring tolua_tostring
153#define tolua_tofieldcppstring tolua_tofieldstring
154#endif
155
156TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index);
157
158#ifndef Mtolua_new
159#define Mtolua_new(EXP) new EXP
160#endif
161
162#ifndef Mtolua_delete
163#define Mtolua_delete(EXP) delete EXP
164#endif
165
166#ifndef Mtolua_delete_dim
167#define Mtolua_delete_dim(EXP) delete [] EXP
168#endif
169
170#ifndef tolua_outside
171#define tolua_outside
172#endif
173
174#ifndef tolua_owned
175#define tolua_owned
176#endif
177
178#ifdef __cplusplus
179}
180#endif
181
182#endif
Note: See TracBrowser for help on using the repository browser.