30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/cast-to-yaml/to_yaml.rb', line 30
def (res = Hash::new { |h, k| h[k] = [] })
if typedef?
declarators.each { |d|
res["typedefs"].push d.to_h(self)
}
else
declarators.each { |d|
if d.indirect_type && d.indirect_type.kind_of?(Function)
f = {}
f["name"] = d.name
if d.indirect_type.type
f["type"] = d.indirect_type.type.to_h(self)
else
f["type"] = type.to_h(self)
end
if d.indirect_type.params
f["params"] = d.indirect_type.params.collect { |p| p.to_h }
end
res["functions"].push f
else
res["declarations"].push d.to_h(self)
end
}
end
if type.kind_of?(Struct) && type.members && type.name
s = {}
s["name"] = type.name
m = []
type.members.each { |mem|
m += mem.to_a
}
s["members"] = m
res["structs"].push s
elsif type.kind_of?(Enum) && type.members && type.name
s = {}
s["name"] = type.name
m = []
type.members.each { |mem|
m.push mem.to_h
}
s["members"] = m
res["enums"].push s
elsif type.kind_of?(Union) && type.members && type.name
s = {}
s["name"] = type.name
m = []
type.members.each { |mem|
m += mem.to_a
}
s["members"] = m
res["unions"].push s
end
res
end
|