5 entities
.is_function
= function(f
)
6 if type(f
)~='table' or string.find(f
.label
, 'Function')~=1 then
12 local is_function
= entities
.is_function
15 entities
.is_constructor
= function(f
)
16 assert(is_function(f
), 'argument is not a function')
17 return (f
.xarg
.member_of_class
and f
.xarg
.member_of_class
~=''
18 and f
.xarg
.fullname
==(f
.xarg
.member_of_class
..'::'..f
.xarg
.name
) -- this should be always true
19 and string.match(f
.xarg
.member_of_class
, f
.xarg
.name
..'$')) and '[constructor]'
21 local is_constructor
= entities
.is_constructor
23 entities
.is_destructor
= function(f
)
24 assert(is_function(f
), 'argument is not a function')
25 return f
.xarg
.name
:sub(1,1)=='~' and '[destructor]'
27 local is_destructor
= entities
.is_destructor
29 entities
.takes_this_pointer
= function(f
)
30 assert(is_function(f
), 'argument is not a function')
31 if f
.xarg
.member_of_class
and not (f
.xarg
.static
=='1') and f
.xarg
.member_of_class
~=''
32 and not is_constructor(f
) then
33 return f
.xarg
.member_of_class
.. '*;'
37 local takes_this_pointer
= entities
.takes_this_pointer
39 entities
.is_class
= function(c
)
40 if type(c
)=='table' and c
.label
=='Class' then
46 local is_class
= entities
.is_class
48 entities
.class_is_copy_constructible
= function(c
)
49 -- TODO: cache the response into the class itself (c.xarg.is_copy_constructible)
50 assert(is_class(c
), 'this is NOT a class')
51 for _
, m
in ipairs(c
) do
55 and m
.xarg
.access
=='public'
56 and (m
[1].xarg
.type_name
==c
.xarg
.fullname
..' const&'
57 or m
[1].xarg
.type_name
==c
.xarg
.fullname
..'&'
58 or m
[1].xarg
.type_name
==c
.xarg
.fullname
) then
64 local class_is_copy_constructible
= entities
.class_is_copy_constructible
66 entities
.class_is_default_constructible
= function(c
)
67 -- TODO: cache the response into the class itself (c.xarg.is_copy_constructible)
68 assert(is_class(c
), 'this is NOT a class')
69 for _
, m
in ipairs(c
) do
73 and m
.xarg
.access
=='public' then
79 local class_is_default_constructible
= entities
.class_is_default_constructible
81 entities
.default_constructor
= function(t
)
82 if t
.xarg
.type_name
then
83 if t
.xarg
.type_name
:match
'%b[]$' then
85 elseif t
.xarg
.type_name
:match
'%(%*%)' then
87 elseif t
.xarg
.type_name
:match
'%&$' then
89 elseif t
.xarg
.indirections
then
92 return 'static_cast< '..t
.xarg
.type_name
..' >(0)'
95 if t
.label
=='Class' and class_is_default_constructible(t
) then
96 return t
.xarg
.fullname
..'()'
97 elseif t
.label
=='Class' then
100 return 'static_cast< '..t
.xarg
.type_name
..' >(0)'