8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/ruby-bindgen/type_pointer_formatter.rb', line 8
def pointer_spelling(type)
pointee = type.pointee
if function_pointer_pointee?(pointee)
ptr_const = type.const_qualified? ? " const" : ""
result_type = yield(pointee.result_type)
arg_types = pointee.arg_types.map { |arg_type| yield(arg_type) }.join(", ")
return "#{result_type} (*#{ptr_const})(#{arg_types})"
end
parts = []
current = type
while current.kind == :type_pointer
inner = current.pointee
break if function_pointer_pointee?(inner)
parts << (current.const_qualified? ? "*const" : "*")
current = inner
end
"#{yield(current)} #{parts.reverse.join}"
end
|