added various Qt-specific macros
[lqt.git] / common / lqt_common.hpp
blob756b9b14f20f3650a177e995be1e11202fe9b1e4
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 // Qt-specific fields
46 #define LQT_METACALLER "Registry MetaCaller"
47 #define LQT_OBJMETASTRING "Lqt MetaStringData"
48 #define LQT_OBJMETADATA "Lqt MetaData"
49 #define LQT_OBJSLOTS "Lqt Slots"
50 #define LQT_OBJSIGS "Lqt Signatures"
52 extern void lqtL_register(lua_State *, const void *);
53 extern void lqtL_unregister(lua_State *, const void *);
55 //extern int& lqtL_tointref (lua_State *, int);
57 //extern void lqtL_pusharguments (lua_State *, char**);
58 //extern char** lqtL_toarguments (lua_State *, int);
59 //extern bool lqtL_testarguments (lua_State *, int);
61 //extern void lqtL_manageudata (lua_State *, int);
62 //extern void lqtL_unmanageudata (lua_State *, int);
63 extern void lqtL_pushudata (lua_State *, const void *, const char *);
64 extern void lqtL_passudata (lua_State *, const void *, const char *);
65 extern void lqtL_copyudata (lua_State *, const void *, const char *);
66 extern void * lqtL_toudata (lua_State *, int, const char *);
67 extern bool lqtL_testudata (lua_State *, int, const char *);
68 //#define lqtL_checkudata(a...) luaL_checkudata(a)
69 extern void * lqtL_checkudata (lua_State *, int, const char *);
70 #define lqtL_isudata lqtL_testudata
72 extern void lqtL_pushenum (lua_State *, int, const char *);
73 extern bool lqtL_isenum (lua_State *, int, const char *);
74 extern int lqtL_toenum (lua_State *, int, const char *);
76 extern bool lqtL_isinteger (lua_State *, int);
77 extern bool lqtL_isnumber (lua_State *, int);
78 extern bool lqtL_isstring (lua_State *, int);
79 extern bool lqtL_isboolean (lua_State *, int);
81 extern bool lqtL_missarg (lua_State *, int, int);
82 //extern int lqtL_baseindex (lua_State *, int, int);
84 //extern int lqtL_gc (lua_State *);
85 //extern int lqtL_index (lua_State *);
86 //extern int lqtL_newindex (lua_State *);
88 typedef struct {
89 const char *name;
90 int value;
91 } lqt_Enum;
93 typedef struct {
94 lqt_Enum *enums;
95 const char *name;
96 } lqt_Enumlist;
98 extern int lqtL_createenumlist (lua_State *, lqt_Enumlist[]);
100 typedef struct {
101 const char *basename;
102 ptrdiff_t offset;
103 } lqt_Base;
105 typedef struct {
106 luaL_Reg *mt;
107 lqt_Base *bases;
108 const char * name;
109 } lqt_Class;
111 extern int lqtL_createclasses (lua_State *, lqt_Class *);
112 extern int lqtL_createclass (lua_State *, const char *, luaL_Reg *, lqt_Base *);
114 /* functions to get/push special types */
116 extern void * lqtL_getref (lua_State *, size_t);
117 extern int * lqtL_tointref (lua_State *, int);
118 extern char ** lqtL_toarguments (lua_State *, int);
119 extern void lqtL_pusharguments (lua_State *, char **);
121 extern int lqtL_getflags (lua_State *, int, const char *);
122 extern void lqtL_pushflags (lua_State *, int, const char *);
124 extern int lqtL_touintarray (lua_State *);
127 #endif // __LQT_COMMON_HPP