restructured source tree
[lqt.git] / generator / types.lua
blobd9fe95cce48065e0dbd9a5dd0f2c5dbc022052fa
1 local base_types = (...) or {}
3 local BaseType = function(s)
4 s = tostring(s)
5 return {
6 get = function(j)
7 return 'lua_to'..s..'(L, '..tostring(j)..')', 1
8 end,
9 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
10 return 'lua_push'..s..'(L, '..tostring(j)..')', 1
11 end,
13 end
14 local integer_type = {
15 get = function(j)
16 return 'lua_tointeger(L, '..tostring(j)..')', 1
17 end,
18 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
19 return 'lua_pushinteger(L, '..tostring(j)..')', 1
20 end,
21 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
22 return 'lqtL_isinteger(L, '..tostring(j)..')', 1
23 end,
25 local number_type = {
26 get = function(j)
27 return 'lua_tonumber(L, '..tostring(j)..')', 1
28 end,
29 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
30 return 'lua_pushnumber(L, '..tostring(j)..')', 1
31 end,
32 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
33 return 'lqtL_isnumber(L, '..tostring(j)..')', 1
34 end,
36 local integer_type = {
37 get = function(j)
38 return 'lua_tointeger(L, '..tostring(j)..')', 1
39 end,
40 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
41 return 'lua_pushinteger(L, '..tostring(j)..')', 1
42 end,
43 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
44 return 'lqtL_isinteger(L, '..tostring(j)..')', 1
45 end,
47 local bool_type = {
48 get = function(j)
49 return 'lua_toboolean(L, '..tostring(j)..')', 1
50 end,
51 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
52 return 'lua_pushboolean(L, '..tostring(j)..')', 1
53 end,
54 test = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
55 return 'lqtL_isboolean(L, '..tostring(j)..')', 1
56 end,
59 base_types['char const*'] = {
60 get = function(j)
61 return 'lua_tostring(L, '..tostring(j)..')', 1
62 end,
63 push = function(j) -- must handle arguments (e.g. in virtual callbacks) and return values
64 return 'lua_pushstring(L, '..tostring(j)..')', 1
65 end,
66 test = function(j)
67 return 'lqtL_isstring(L, '..tostring(j)..')', 1
68 end,
70 base_types['char'] = integer_type
71 base_types['unsigned char'] = integer_type
72 base_types['int'] = integer_type
73 base_types['unsigned int'] = integer_type
74 base_types['short'] = integer_type
75 base_types['short int'] = integer_type
76 base_types['unsigned short'] = integer_type
77 base_types['unsigned short int'] = integer_type
78 base_types['short unsigned int'] = integer_type
79 base_types['long'] = integer_type
80 base_types['unsigned long'] = integer_type
81 base_types['long int'] = integer_type
82 base_types['unsigned long int'] = integer_type
83 base_types['long unsigned int'] = integer_type
84 base_types['long long'] = integer_type
85 base_types['unsigned long long'] = integer_type
86 base_types['long long int'] = integer_type
87 base_types['unsigned long long int'] = integer_type
88 base_types['float'] = number_type
89 base_types['double'] = number_type
90 base_types['bool'] = bool_type
92 base_types['QSizeF'] = {
93 get = function(i) return 'QSizeF(lua_tonumber(L, '..i..'), lua_tonumber(L, '..i..'+1))', 2 end,
94 push = function(i) return 'lua_pushnumber(L, '..i..'.width()), lua_pushnumber(L, '..i..'.height())', 2 end,
95 test = function(i) return '(lqtL_isnumber(L, '..i..') && lqtL_isnumber(L, '..i..'+1))', 2 end,
97 base_types['QSizeF const&'] = base_types['QSizeF']
99 base_types['QSize'] = {
100 get = function(i) return 'QSize(lua_tointeger(L, '..i..'), lua_tointeger(L, '..i..'+1))', 2 end,
101 push = function(i) return 'lua_pushinteger(L, '..i..'.width()), lua_pushinteger(L, '..i..'.height())', 2 end,
102 test = function(i) return '(lqtL_isinteger(L, '..i..') && lqtL_isinteger(L, '..i..'+1))', 2 end,
104 base_types['QSize const&'] = base_types['QSize']
106 base_types['QPoint'] = {
107 get = function(i) return 'QPoint(lua_tointeger(L, '..i..'), lua_tointeger(L, '..i..'+1))', 2 end,
108 push = function(i) return 'lua_pushinteger(L, '..i..'.x()), lua_pushinteger(L, '..i..'.y())', 2 end,
109 test = function(i) return '(lqtL_isinteger(L, '..i..') && lqtL_isinteger(L, '..i..'+1))', 2 end,
111 base_types['QPoint const&'] = base_types['QPoint']
113 base_types['QPointF'] = {
114 get = function(i) return 'QPointF(lua_tonumber(L, '..i..'), lua_tonumber(L, '..i..'+1))', 2 end,
115 push = function(i) return 'lua_pushnumber(L, '..i..'.x()), lua_pushnumber(L, '..i..'.y())', 2 end,
116 test = function(i) return '(lqtL_isnumber(L, '..i..') && lqtL_isnumber(L, '..i..'+1))', 2 end,
118 base_types['QPointF const&'] = base_types['QPointF']
120 base_types['QRect'] = {
121 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 end,
122 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,
123 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,
125 base_types['QRect const&'] = base_types['QRect']
127 base_types['QRectF'] = {
128 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 end,
129 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,
130 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,
132 base_types['QRectF const&'] = base_types['QRectF']
134 return base_types