added the offset in the structure that describes bases
[lqt.git] / common / lqt_common.hpp
bloba25692d04c014fb5b497a5652f4af52c84c8ad76
1 /*
2 * Copyright (c) 2007-2008 Mauro Iazzi
3 *
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
11 * conditions:
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
30 extern "C" {
31 #include <lua.h>
32 #include <lualib.h>
33 #include <lauxlib.h>
36 //#include <iostream>
38 //#define lqtL_register(L, p, n) ( (void)L, (void)p, (void)n )
39 //#define lqtL_unregister(L, p) ( (void)L, (void)p )
41 #define LQT_POINTERS "Registry Pointers"
42 #define LQT_REFS "Registry References"
43 #define LQT_ENUMS "Registry Enumerations"
45 extern void lqtL_register(lua_State *, const void *);
46 extern void lqtL_unregister(lua_State *, const void *);
48 //extern int& lqtL_tointref (lua_State *, int);
50 //extern void lqtL_pusharguments (lua_State *, char**);
51 //extern char** lqtL_toarguments (lua_State *, int);
52 //extern bool lqtL_testarguments (lua_State *, int);
54 //extern void lqtL_manageudata (lua_State *, int);
55 //extern void lqtL_unmanageudata (lua_State *, int);
56 extern void lqtL_pushudata (lua_State *, const void *, const char *);
57 extern void lqtL_passudata (lua_State *, const void *, const char *);
58 extern void lqtL_copyudata (lua_State *, const void *, const char *);
59 extern void * lqtL_toudata (lua_State *, int, const char *);
60 extern bool lqtL_testudata (lua_State *, int, const char *);
61 //#define lqtL_checkudata(a...) luaL_checkudata(a)
62 extern void * lqtL_checkudata (lua_State *, int, const char *);
63 #define lqtL_isudata lqtL_testudata
65 extern void lqtL_pushenum (lua_State *, int, const char *);
66 extern bool lqtL_isenum (lua_State *, int, const char *);
67 extern int lqtL_toenum (lua_State *, int, const char *);
69 extern bool lqtL_isinteger (lua_State *, int);
70 extern bool lqtL_isnumber (lua_State *, int);
71 extern bool lqtL_isstring (lua_State *, int);
72 extern bool lqtL_isboolean (lua_State *, int);
74 extern bool lqtL_missarg (lua_State *, int, int);
75 //extern int lqtL_baseindex (lua_State *, int, int);
77 //extern int lqtL_gc (lua_State *);
78 //extern int lqtL_index (lua_State *);
79 //extern int lqtL_newindex (lua_State *);
81 typedef struct {
82 const char *name;
83 int value;
84 } lqt_Enum;
86 typedef struct {
87 lqt_Enum *enums;
88 const char *name;
89 } lqt_Enumlist;
91 extern int lqtL_createenumlist (lua_State *, lqt_Enumlist[]);
93 typedef struct {
94 const char *basename;
95 ptrdiff_t offset;
96 } lqt_Base;
98 typedef struct {
99 luaL_Reg *mt;
100 lqt_Base *bases;
101 const char * name;
102 } lqt_Class;
104 extern int lqtL_createclasses (lua_State *, lqt_Class *);
105 extern int lqtL_createclass (lua_State *, const char *, luaL_Reg *, lqt_Base *);
107 /* functions to get/push special types */
109 extern void * lqtL_getref (lua_State *, size_t);
110 extern int * lqtL_tointref (lua_State *, int);
111 extern char ** lqtL_toarguments (lua_State *, int);
112 extern void lqtL_pusharguments (lua_State *, char **);
114 extern int lqtL_getflags (lua_State *, int, const char *);
115 extern void lqtL_pushflags (lua_State *, int, const char *);
117 extern "C" int luaopen_qtbase (lua_State *);
120 #endif // __LQT_COMMON_HPP