2 * Copyright (c) 2007-2008 Mauro Iazzi
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use,
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
27 #ifndef __LQT_COMMON_HPP
28 #define __LQT_COMMON_HPP
31 #define LQT_EXPORT __declspec(dllexport)
44 //#define lqtL_register(L, p, n) ( (void)L, (void)p, (void)n )
45 //#define lqtL_unregister(L, p) ( (void)L, (void)p )
47 #define LQT_POINTERS "Registry Pointers"
48 #define LQT_REFS "Registry References"
49 #define LQT_ENUMS "Registry Enums"
50 #define LQT_PCALL "Registry PCall Pointer"
51 #define LQT_SUPER "SUPER"
54 #define LQT_METACALLER "Registry MetaCaller"
55 #define LQT_OBJMETASTRING "Lqt MetaStringData"
56 #define LQT_OBJMETADATA "Lqt MetaData"
57 #define LQT_OBJSLOTS "Lqt Slots"
58 #define LQT_OBJSIGS "Lqt Signatures"
60 // macro to ge positive indexes
61 #define LQT_TOPOSITIVE(L, i) (((i)<0)?(lua_gettop(L)+1+(i)):(i))
63 // use standard pcall by default
65 #define lqtL_pcall(L, n, r, e) lua_pcall(L, n, r, e)
67 #define lqtL_pcall(L, n, r, e) lqtL_pcall_debug(L, n, r, e)
70 typedef int (*lqt_PCallPtr
) (lua_State
*L
, int nargs
, int nresults
, int errfunc
);
72 void lqtL_register(lua_State
*, const void *);
73 void lqtL_unregister(lua_State
*, const void *);
75 //int& lqtL_tointref (lua_State *, int);
77 //void lqtL_pusharguments (lua_State *, char**);
78 //char** lqtL_toarguments (lua_State *, int);
79 //bool lqtL_testarguments (lua_State *, int);
81 //void lqtL_manageudata (lua_State *, int);
82 //void lqtL_unmanageudata (lua_State *, int);
83 void lqtL_pushudata (lua_State
*, const void *, const char *);
84 void lqtL_passudata (lua_State
*, const void *, const char *);
85 void lqtL_copyudata (lua_State
*, const void *, const char *);
86 void * lqtL_toudata (lua_State
*, int, const char *);
87 bool lqtL_testudata (lua_State
*, int, const char *);
88 //#define lqtL_checkudata(a...) luaL_checkudata(a)
89 void * lqtL_checkudata (lua_State
*, int, const char *);
90 void lqtL_eraseudata (lua_State
*, int, const char *);
91 #define lqtL_isudata lqtL_testudata
94 bool lqtL_canconvert(lua_State
*L
, int n
, const char *to_type
);
95 void *lqtL_convert(lua_State
*L
, int n
, const char *to_type
);
96 typedef bool (*lqt_testfunc
) (lua_State
*L
, int n
);
97 typedef void* (*lqt_convertfunc
) (lua_State
*L
, int n
);
100 void lqtL_pushenum (lua_State
*, int, const char *);
101 bool lqtL_isenum (lua_State
*, int, const char *);
102 int lqtL_toenum (lua_State
*, int, const char *);
104 bool lqtL_isinteger (lua_State
*, int);
105 bool lqtL_isnumber (lua_State
*, int);
106 bool lqtL_isstring (lua_State
*, int);
107 bool lqtL_isboolean (lua_State
*, int);
109 bool lqtL_missarg (lua_State
*, int, int);
110 //int lqtL_baseindex (lua_State *, int, int);
112 //int lqtL_gc (lua_State *);
113 //int lqtL_index (lua_State *);
114 //int lqtL_newindex (lua_State *);
126 int lqtL_createenum (lua_State
*L
, lqt_Enum e
[], const char *n
);
127 int lqtL_createenumlist (lua_State
*, lqt_Enumlist
[]);
130 const char *basename
;
140 int lqtL_createclass (lua_State
*, const char *, luaL_Reg
*, lqt_Base
*);
142 /* functions to get/push special types */
144 bool * lqtL_toboolref (lua_State
*, int);
145 void * lqtL_getref (lua_State
*, size_t, bool);
146 int * lqtL_tointref (lua_State
*, int);
147 char ** lqtL_toarguments (lua_State
*, int);
148 void lqtL_pusharguments (lua_State
*, char **);
150 int lqtL_getflags (lua_State
*, int, const char *);
151 void lqtL_pushflags (lua_State
*, int, const char *);
152 #define lqtL_isflags(L, i) (lua_istable((L), (i)) || lqtL_isinteger((L), (i)))
154 int lqtL_touintarray (lua_State
*);
156 int lqtL_pcall_debug (lua_State
*L
, int narg
, int nres
, int err
);
158 int lqtL_getoverload (lua_State
*L
, int index
, const char *name
);
160 const char * lqtL_source(lua_State
*L
, int idx
);
162 bool lqtL_is_super(lua_State
*L
, int idx
);
163 void lqtL_register_super(lua_State
*L
);
165 const char * lqtL_pushtrace(lua_State
*L
);
166 void lqtL_pushudatatype(lua_State
*L
, int index
);
167 const char * lqtL_getarglist(lua_State
*L
);
169 #endif // __LQT_COMMON_HPP