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