67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/cast-to-yaml/to_yaml.rb', line 67
def (res = Hash::new { |h, k| h[k] = [] }, declarations: true)
if typedef?
declarators.each { |d|
res["typedefs"].push d.to_h_split(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_split(self)
else
f["type"] = type.to_h_split(self)
end
if d.indirect_type.params
f["params"] = d.indirect_type.params.collect { |p| p.to_h_split }
end
if d.indirect_type.var_args?
f["var_args"] = true
end
if inline?
f["inline"] = true
end
if storage
f["storage"] = storage.to_s
end
res["functions"].push f
elsif declarations
r = d.to_h_split(self)
r["storage"] = storage.to_s if storage
r["inline"] = true if inline?
res["declarations"].push r
end
}
end
if type.kind_of?(Struct) && type.members
m = []
type.members.each { |mem|
mem.(res, declarations: false)
m += mem.to_a
}
if type.name
s = {}
s["name"] = type.name
s["members"] = m
res["structs"].push s
end
elsif type.kind_of?(Enum) && type.members && (type.name || (declarators.empty? && declarations))
s = {}
s["name"] = type.name if type.name
m = []
type.members.each { |mem|
m.push mem.to_h_split
}
s["members"] = m
res["enums"].push s
elsif type.kind_of?(Union) && type.members
m = []
type.members.each { |mem|
mem.(res, declarations: false)
m += mem.to_a
}
if type.name
s = {}
s["name"] = type.name
s["members"] = m
res["unions"].push s
end
end
res
end
|