should return nil when it does not add a new entry
[lqt.git] / common / lqt_common.hpp
blob402d744595c1f86f4934bb98a7360ce2062f7a09
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 #ifdef _WIN32
31 #define LQT_EXPORT __declspec(dllexport)
32 #else
33 #define LQT_EXPORT
34 #endif
36 extern "C" {
37 #include <lua.h>
38 #include <lualib.h>
39 #include <lauxlib.h>
42 //#include <iostream>
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 Enumerations"
51 // Qt-specific fields
52 #define LQT_METACALLER "Registry MetaCaller"
53 #define LQT_OBJMETASTRING "Lqt MetaStringData"
54 #define LQT_OBJMETADATA "Lqt MetaData"
55 #define LQT_OBJSLOTS "Lqt Slots"
56 #define LQT_OBJSIGS "Lqt Signatures"
58 void lqtL_register(lua_State *, const void *);
59 void lqtL_unregister(lua_State *, const void *);
61 //int& lqtL_tointref (lua_State *, int);
63 //void lqtL_pusharguments (lua_State *, char**);
64 //char** lqtL_toarguments (lua_State *, int);
65 //bool lqtL_testarguments (lua_State *, int);
67 //void lqtL_manageudata (lua_State *, int);
68 //void lqtL_unmanageudata (lua_State *, int);
69 void lqtL_pushudata (lua_State *, const void *, const char *);
70 void lqtL_passudata (lua_State *, const void *, const char *);
71 void lqtL_copyudata (lua_State *, const void *, const char *);
72 void * lqtL_toudata (lua_State *, int, const char *);
73 bool lqtL_testudata (lua_State *, int, const char *);
74 //#define lqtL_checkudata(a...) luaL_checkudata(a)
75 void * lqtL_checkudata (lua_State *, int, const char *);
76 #define lqtL_isudata lqtL_testudata
78 void lqtL_pushenum (lua_State *, int, const char *);
79 bool lqtL_isenum (lua_State *, int, const char *);
80 int lqtL_toenum (lua_State *, int, const char *);
82 bool lqtL_isinteger (lua_State *, int);
83 bool lqtL_isnumber (lua_State *, int);
84 bool lqtL_isstring (lua_State *, int);
85 bool lqtL_isboolean (lua_State *, int);
87 bool lqtL_missarg (lua_State *, int, int);
88 //int lqtL_baseindex (lua_State *, int, int);
90 //int lqtL_gc (lua_State *);
91 //int lqtL_index (lua_State *);
92 //int lqtL_newindex (lua_State *);
94 typedef struct {
95 const char *name;
96 int value;
97 } lqt_Enum;
99 typedef struct {
100 lqt_Enum *enums;
101 const char *name;
102 } lqt_Enumlist;
104 int lqtL_createenumlist (lua_State *, lqt_Enumlist[]);
106 typedef struct {
107 const char *basename;
108 ptrdiff_t offset;
109 } lqt_Base;
111 typedef struct {
112 luaL_Reg *mt;
113 lqt_Base *bases;
114 const char * name;
115 } lqt_Class;
117 int lqtL_createclasses (lua_State *, lqt_Class *);
118 int lqtL_createclass (lua_State *, const char *, luaL_Reg *, lqt_Base *);
120 /* functions to get/push special types */
122 void * lqtL_getref (lua_State *, size_t);
123 int * lqtL_tointref (lua_State *, int);
124 char ** lqtL_toarguments (lua_State *, int);
125 void lqtL_pusharguments (lua_State *, char **);
127 int lqtL_getflags (lua_State *, int, const char *);
128 void lqtL_pushflags (lua_State *, int, const char *);
130 int lqtL_touintarray (lua_State *);
133 #endif // __LQT_COMMON_HPP