the list of duplicates is ready (still not used)
[lqt.git] / generator / qtypes.lua
blob0c5c73886c3a9087afb4c27a2344307986c96964
1 #!/usr/bin/lua
3 --[[
5 Copyright (c) 2007-2008 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 qt_types = (...) or {}
32 qt_types['QSizeF'] = {
33 get = function(i) return 'QSizeF(lua_tonumber(L, '..i..'), lua_tonumber(L, '..i..'+1))', 2, 'QSizeF' end,
34 push = function(i) return 'lua_pushnumber(L, '..i..'.width()), lua_pushnumber(L, '..i..'.height())', 2 end,
35 test = function(i) return '(lqtL_isnumber(L, '..i..') && lqtL_isnumber(L, '..i..'+1))', 2 end,
36 onstack = 'number,number,',
38 qt_types['QSizeF const&'] = qt_types['QSizeF']
40 qt_types['QSize'] = {
41 get = function(i) return 'QSize(lua_tointeger(L, '..i..'), lua_tointeger(L, '..i..'+1))', 2, 'QSize' end,
42 push = function(i) return 'lua_pushinteger(L, '..i..'.width()), lua_pushinteger(L, '..i..'.height())', 2 end,
43 test = function(i) return '(lqtL_isinteger(L, '..i..') && lqtL_isinteger(L, '..i..'+1))', 2 end,
44 onstack = 'integer,integer,',
46 qt_types['QSize const&'] = qt_types['QSize']
48 qt_types['QPoint'] = {
49 get = function(i) return 'QPoint(lua_tointeger(L, '..i..'), lua_tointeger(L, '..i..'+1))', 2, 'QPoint' end,
50 push = function(i) return 'lua_pushinteger(L, '..i..'.x()), lua_pushinteger(L, '..i..'.y())', 2 end,
51 test = function(i) return '(lqtL_isinteger(L, '..i..') && lqtL_isinteger(L, '..i..'+1))', 2 end,
52 onstack = 'integer,integer,',
54 qt_types['QPoint const&'] = qt_types['QPoint']
56 qt_types['QPointF'] = {
57 get = function(i) return 'QPointF(lua_tonumber(L, '..i..'), lua_tonumber(L, '..i..'+1))', 2, 'QPointF' end,
58 push = function(i) return 'lua_pushnumber(L, '..i..'.x()), lua_pushnumber(L, '..i..'.y())', 2 end,
59 test = function(i) return '(lqtL_isnumber(L, '..i..') && lqtL_isnumber(L, '..i..'+1))', 2 end,
60 onstack = 'number,number,',
62 qt_types['QPointF const&'] = qt_types['QPointF']
64 qt_types['QRect'] = {
65 get = function(i) return 'QRect(lua_tointeger(L, '..i..'), lua_tointeger(L, '..i..'+1), lua_tointeger(L, '..i..'+2), lua_tointeger(L, '..i..'+3))', 4, 'QRect' end,
66 push = function(i) return 'lua_pushinteger(L, '..i..'.x()), lua_pushinteger(L, '..i..'.y()), lua_pushinteger(L, '..i..'.width()), lua_pushinteger(L, '..i..'.height())', 4 end,
67 test = function(i) return '(lqtL_isinteger(L, '..i..') && lqtL_isinteger(L, '..i..'+1) && lqtL_isinteger(L, '..i..'+2) && lqtL_isinteger(L, '..i..'+3))', 4 end,
68 onstack = 'integer,integer,integer,integer,',
70 qt_types['QRect const&'] = qt_types['QRect']
72 qt_types['QRectF'] = {
73 get = function(i) return 'QRectF(lua_tonumber(L, '..i..'), lua_tonumber(L, '..i..'+1), lua_tonumber(L, '..i..'+2), lua_tonumber(L, '..i..'+3))', 4, 'QRectF' end,
74 push = function(i) return 'lua_pushnumber(L, '..i..'.x()), lua_pushnumber(L, '..i..'.y()), lua_pushnumber(L, '..i..'.width()), lua_pushnumber(L, '..i..'.height())', 4 end,
75 test = function(i) return '(lqtL_isnumber(L, '..i..') && lqtL_isnumber(L, '..i..'+1) && lqtL_isnumber(L, '..i..'+2) && lqtL_isnumber(L, '..i..'+3))', 4 end,
76 onstack = 'number,number,number,number,',
78 qt_types['QRectF const&'] = qt_types['QRectF']
80 qt_types['QByteArray'] = {
81 get = function(i) return 'QByteArray(lua_tostring(L, '..i..'), lua_objlen(L, '..i..'))', 1, 'QByteArray' end,
82 push = function(i) return 'lua_pushlstring(L, '..i..'.constData(), '..i..'.size())', 1 end,
83 test = function(i) return 'lua_isstring(L, '..i..')', 1 end,
84 onstack = 'string,',
86 qt_types['QByteArray const&'] = qt_types['QByteArray']
88 if not getmetatable(qt_types) then
89 setmetatable(qt_types, {
90 __index = function(t, k)
91 if type(k)=='string'
92 and string.match(k, '^QFlags<[%w:]+>$') then
93 local e = string.match(k, '^QFlags<([%w:]+)>$')
94 if not qt_types[e] then return nil end
95 e = string.gsub(e, '::', '.')
96 local ret = {
97 get = function(i)
98 return '('..k..'(lqtL_getflags(L, '..i..', "'..e..'")))', 1
99 end,
100 push = function(i)
101 return 'lqtL_pushflags(L, '..i..', "'..e..'")', 1
102 end,
103 test = function(i)
104 return 'lqtL_isflags(L, '..i..')', 1
105 end,
106 onstack = 'table,',
108 return ret
110 end,
114 return qt_types