disable custom binding for QPoint, QRect etc.
[lqt/mk.git] / generator / qtypes.lua
blob1cebc540c3c954ffc4daa399a98d3a8d98a1a6d1
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 --[[
33 qt_types['QSizeF'] = {
34 get = function(i) return 'QSizeF(lua_tonumber(L, '..i..'), lua_tonumber(L, '..i..'+1))', 2, 'QSizeF' end,
35 push = function(i) return 'lua_pushnumber(L, '..i..'.width()), lua_pushnumber(L, '..i..'.height())', 2 end,
36 test = function(i) return '(lqtL_isnumber(L, '..i..') && lqtL_isnumber(L, '..i..'+1))', 2 end,
37 onstack = 'number,number,',
39 qt_types['QSizeF const&'] = qt_types['QSizeF']
41 qt_types['QSize'] = {
42 get = function(i) return 'QSize(lua_tointeger(L, '..i..'), lua_tointeger(L, '..i..'+1))', 2, 'QSize' end,
43 push = function(i) return 'lua_pushinteger(L, '..i..'.width()), lua_pushinteger(L, '..i..'.height())', 2 end,
44 test = function(i) return '(lqtL_isinteger(L, '..i..') && lqtL_isinteger(L, '..i..'+1))', 2 end,
45 onstack = 'integer,integer,',
47 qt_types['QSize const&'] = qt_types['QSize']
49 qt_types['QPoint'] = {
50 get = function(i) return 'QPoint(lua_tointeger(L, '..i..'), lua_tointeger(L, '..i..'+1))', 2, 'QPoint' end,
51 push = function(i) return 'lua_pushinteger(L, '..i..'.x()), lua_pushinteger(L, '..i..'.y())', 2 end,
52 test = function(i) return '(lqtL_isinteger(L, '..i..') && lqtL_isinteger(L, '..i..'+1))', 2 end,
53 onstack = 'integer,integer,',
55 qt_types['QPoint const&'] = qt_types['QPoint']
57 qt_types['QPointF'] = {
58 get = function(i) return 'QPointF(lua_tonumber(L, '..i..'), lua_tonumber(L, '..i..'+1))', 2, 'QPointF' end,
59 push = function(i) return 'lua_pushnumber(L, '..i..'.x()), lua_pushnumber(L, '..i..'.y())', 2 end,
60 test = function(i) return '(lqtL_isnumber(L, '..i..') && lqtL_isnumber(L, '..i..'+1))', 2 end,
61 onstack = 'number,number,',
63 qt_types['QPointF const&'] = qt_types['QPointF']
65 qt_types['QRect'] = {
66 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,
67 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,
68 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,
69 onstack = 'integer,integer,integer,integer,',
71 qt_types['QRect const&'] = qt_types['QRect']
73 qt_types['QRectF'] = {
74 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,
75 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,
76 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,
77 onstack = 'number,number,number,number,',
79 qt_types['QRectF const&'] = qt_types['QRectF']
82 qt_types['QByteArray'] = {
83 get = function(i) return 'QByteArray(lua_tostring(L, '..i..'), lua_objlen(L, '..i..'))', 1, 'QByteArray' end,
84 push = function(i) return 'lua_pushlstring(L, '..i..'.constData(), '..i..'.size())', 1 end,
85 test = function(i) return 'lua_isstring(L, '..i..')', 1 end,
86 onstack = 'string,',
88 qt_types['QByteArray const&'] = qt_types['QByteArray']
90 if not getmetatable(qt_types) then
91 setmetatable(qt_types, {
92 __index = function(t, k)
93 if type(k)=='string'
94 and string.match(k, '^QFlags<[%w:]+>$') then
95 local e = string.match(k, '^QFlags<([%w:]+)>$')
96 if not qt_types[e] then return nil end
97 e = string.gsub(e, '::', '.')
98 local ret = {
99 get = function(i)
100 return '('..k..'(lqtL_getflags(L, '..i..', "'..e..'")))', 1
101 end,
102 push = function(i)
103 return 'lqtL_pushflags(L, '..i..', "'..e..'")', 1
104 end,
105 test = function(i)
106 return 'lqtL_isflags(L, '..i..')', 1
107 end,
108 onstack = 'table,',
110 return ret
112 end,
116 return qt_types