Fix QIoDevice::write missing (unknown type __int64), reported by Mostafa Vahedi
[lqt/mk.git] / generator / types.lua
blob8958fe27912a1b37b7e8267a4103157ba0a1de96
1 #!/usr/bin/lua
3 --[[
5 Copyright (c) 2007-2009 Mauro Iazzi
7 Permission is hereby granted, free of charge, to any person
8 obtaining a copy of this software and associated documentation
9 files (the "Software"), to deal in the Software without
10 restriction, including without limitation the rights to use,
11 copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following
14 conditions:
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 OTHER DEALINGS IN THE SOFTWARE.
28 --]]
30 local base_types = (...) or {}
32 local number_type = function(d) return {
33 get = function(j)
34 return 'lua_tonumber(L, '..tostring(j)..')', 1
35 end,
36 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
37 return 'lua_pushnumber(L, '..tostring(j)..')', 1
38 end,
39 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
40 return 'lqtL_isnumber(L, '..tostring(j)..')', 1
41 end,
42 onstack = 'number,',
43 defect = d,
44 } end
45 local integer_type = function(d) return {
46 get = function(j)
47 return 'lua_tointeger(L, '..tostring(j)..')', 1
48 end,
49 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
50 return 'lua_pushinteger(L, '..tostring(j)..')', 1
51 end,
52 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
53 return 'lqtL_isinteger(L, '..tostring(j)..')', 1
54 end,
55 onstack = 'integer,',
56 defect = d,
57 } end
58 local bool_type = function(d) return {
59 get = function(j)
60 return 'lua_toboolean(L, '..tostring(j)..')', 1
61 end,
62 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
63 return 'lua_pushboolean(L, '..tostring(j)..')', 1
64 end,
65 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
66 return 'lqtL_isboolean(L, '..tostring(j)..')', 1
67 end,
68 onstack = 'boolean,',
69 defect = d,
70 } end
72 base_types['char const*'] = {
73 get = function(j)
74 return 'lua_tostring(L, '..tostring(j)..')', 1
75 end,
76 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
77 return 'lua_pushstring(L, '..tostring(j)..')', 1
78 end,
79 test = function(j)
80 return 'lqtL_isstring(L, '..tostring(j)..')', 1
81 end,
82 onstack = 'string,',
84 base_types['char'] = integer_type(3)
85 base_types['unsigned char'] = integer_type(3)
86 base_types['int'] = integer_type(1)
87 base_types['unsigned'] = integer_type(1)
88 base_types['unsigned int'] = integer_type(1)
89 base_types['short'] = integer_type(2)
90 base_types['short int'] = integer_type(2)
91 base_types['unsigned short'] = integer_type(2)
92 base_types['unsigned short int'] = integer_type(2)
93 base_types['short unsigned int'] = integer_type(2)
94 base_types['long'] = integer_type(0)
95 base_types['unsigned long'] = integer_type(0)
96 base_types['long int'] = integer_type(0)
97 base_types['unsigned long int'] = integer_type(0)
98 base_types['long unsigned int'] = integer_type(0)
99 base_types['long long'] = integer_type(0)
100 base_types['__int64'] = integer_type(0)
101 base_types['unsigned long long'] = integer_type(0)
102 base_types['long long int'] = integer_type(0)
103 base_types['unsigned long long int'] = integer_type(0)
104 base_types['float'] = number_type(1)
105 base_types['double'] = number_type(0)
106 base_types['double const&'] = number_type(1)
107 base_types['bool'] = bool_type()
109 ---[[
110 base_types['bool*'] = {
111 get = function(j)
112 return 'lqtL_toboolref(L, '..j..')', 1
113 end,
114 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
115 return 'lua_pushboolean(L, *'..tostring(j)..')', 1
116 end,
117 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
118 return 'lqtL_isboolean(L, '..tostring(j)..')', 1
119 end,
120 onstack = 'boolean,',
122 base_types['int&'] = {
123 get = function(j)
124 return '*lqtL_tointref(L, '..j..')', 1
125 end,
126 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
127 return 'lua_pushinteger(L, '..tostring(j)..')', 1
128 end,
129 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
130 return 'lqtL_isinteger(L, '..tostring(j)..')', 1
131 end,
132 onstack = 'integer,',
134 base_types['int*'] = {
135 get = function(j)
136 return 'lqtL_tointref(L, '..j..')', 1
137 end,
138 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
139 return 'lua_pushinteger(L, *'..tostring(j)..')', 1
140 end,
141 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
142 return 'lqtL_isinteger(L, '..tostring(j)..')', 1
143 end,
144 onstack = 'integer,',
146 base_types['char**'] = {
147 get = function(j)
148 return 'lqtL_toarguments(L, '..tostring(j)..')', 1
149 end,
150 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
151 return 'lqtL_pusharguments(L, '..tostring(j)..')', 1
152 end,
153 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
154 return 'lua_istable(L, '..tostring(j)..')', 1
155 end,
156 onstack = 'table,',
158 --]]
159 base_types['std::string const&'] = {
160 get = function(i)
161 return 'std::string(lua_tostring(L, '..i..'), lua_objlen(L, '..i..'))', 1
162 end,
163 push = function(i)
164 return 'lua_pushlstring(L, '..i..'.c_str(), '..i..'.size())', 1
165 end,
166 test = function(i)
167 return 'lua_isstring(L, '..i..')', 1
168 end,
169 onstack = 'string,',
171 base_types['std::string'] = base_types['std::string const&']
174 return base_types