4 lqt
.classes
= lqt
.classes
or {}
7 local pointer_t
= function(fn
)
8 local cn
= string.gsub(fn
, '::', '.')
10 -- the argument is a pointer to class
12 return 'lqtL_passudata(L, '..n
..', "'..cn
..'*")', 1
15 return 'static_cast<'..fn
..'*>'
16 ..'(lqtL_toudata(L, '..n
..', "'..cn
..'*"))', 1
19 return 'lqtL_isudata(L, '..n
..', "'..cn
..'*")', 1
23 local pointer_const_t
= function(fn
)
24 local cn
= string.gsub(fn
, '::', '.')
26 -- the argument is a pointer to constant class instance
28 return 'lqtL_passudata(L, '..n
..', "'..cn
..'*")', 1
31 return 'static_cast<'..fn
..'*>'
32 ..'(lqtL_toudata(L, '..n
..', "'..cn
..'*"))', 1
35 return 'lqtL_isudata(L, '..n
..', "'..cn
..'*")', 1
39 local ref_t
= function(fn
)
40 local cn
= string.gsub(fn
, '::', '.')
42 -- the argument is a reference to class
44 return 'lqtL_pushudata(L, &'..n
..', "'..cn
..'*")', 1
47 return '*static_cast<'..fn
..'*>'
48 ..'(lqtL_toudata(L, '..n
..', "'..cn
..'*"))', 1
51 return 'lqtL_isudata(L, '..n
..', "'..cn
..'*")', 1
55 local instance_t
= function(fn
)
56 local cn
= string.gsub(fn
, '::', '.')
58 -- the argument is the class itself
60 return 'lqtL_copyudata(L, &'..n
..', "'..cn
..'*")', 1
63 return '*static_cast<'..fn
..'*>'
64 ..'(lqtL_toudata(L, '..n
..', "'..cn
..'*"))', 1
67 return 'lqtL_isudata(L, '..n
..', "'..cn
..'*")', 1
71 local const_ref_t
= function(fn
)
72 local cn
= string.gsub(fn
, '::', '.')
74 -- the argument is a pointer to class
76 return 'lqtL_copyudata(L, &'..n
..', "'..cn
..'*")', 1, string.gsub(fn
, ' const&$', '')
79 return '*static_cast<'..fn
..'*>'
80 ..'(lqtL_toudata(L, '..n
..', "'..cn
..'*"))', 1
83 return 'lqtL_isudata(L, '..n
..', "'..cn
..'*")', 1
88 lqt
.classes
.insert
= function(cname
, types
) --, cancopy)
89 if types
[cname
]==nil then
90 types
[cname
..'*'] = pointer_t(cname
)
91 types
[cname
..' const*'] = pointer_const_t(cname
)
92 types
[cname
..'&'] = ref_t(cname
)
94 types
[cname
] = instance_t(cname
)
95 types
[cname
..' const&'] = const_ref_t(cname
)