Skip to content

Commit e0659a0

Browse files
committed
gcc-c-api/xml-to-h.py: write out decls for functions within types
1 parent 0a69415 commit e0659a0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

gcc-c-api/xml-to-h.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,23 @@ def write_api(api, out):
150150
writer.writeln(' void *user_data);')
151151
writer.writeln()
152152

153+
# add functions:
154+
for fun in type_.iter_functions():
155+
doc = fun.get_doc()
156+
if doc:
157+
writer.write_doc_comment(doc)
158+
writer.writeln('GCC_PUBLIC_API(%s)' % fun.get_c_return_type())
159+
paramstrs = ['%s %s' % (type_.get_c_name(),
160+
type_.get_varname())]
161+
for param in fun.iter_params():
162+
paramstrs.append('%s %s' % (param.get_c_type(),
163+
param.get_xml_name()))
164+
writer.writeln('%s_%s(%s);'
165+
% (type_.get_c_prefix(),
166+
fun.get_c_name(),
167+
', '.join(paramstrs)))
168+
writer.writeln()
169+
153170
# add upcasts
154171
for base in type_.get_bases():
155172
writer.writeln('GCC_PUBLIC_API(%s)'

gcc-c-api/xmltypes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ def iter_iters(self):
136136
for node in self.node.iter('iterator'):
137137
yield Iterator(self.api, node)
138138

139+
def iter_functions(self):
140+
for node in self.node.findall('function'):
141+
yield Function(self, node)
142+
139143
class Attribute(XmlWrapper, HasDocsMixin):
140144
def get_xml_name(self):
141145
return self.node.get('name')

0 commit comments

Comments
 (0)