class C::Declaration
Public Instance Methods
extract(res = Hash::new { |h, k| h[k] = [] }, declarations: true)
click to toggle source
# File lib/cast-to-yaml/to_yaml.rb, line 60 def extract(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 && type.name s = {} s["name"] = type.name m = [] type.members.each { |mem| mem.extract(res, declarations: false) 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_split } 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| mem.extract(res, declarations: false) m += mem.to_a } s["members"] = m res["unions"].push s end res end
to_a()
click to toggle source
# File lib/cast-to-yaml/to_yaml.rb, line 51 def to_a declarators.collect { |d| res = d.to_h_split(self) res["storage"] = storage.to_s if storage res["inline"] = true if inline? res } end