MCPcopy Create free account
hub / github.com/apitrace/apitrace / parse_prototype

Method parse_prototype

specs/scripts/c2api.py:244–278  ·  view source on GitHub ↗
(self, creator = 'Function')

Source from the content-addressed store, hash-verified

242 print()
243
244 def parse_prototype(self, creator = 'Function'):
245 if self.match('extern', 'virtual'):
246 self.consume()
247
248 ret = self.parse_type()
249
250 if self.match('__stdcall', 'WINAPI', 'STDMETHODCALLTYPE'):
251 self.consume()
252 creator = 'Std' + creator
253
254 name = self.consume()
255 extra = ''
256 if not self.has_side_effects(name):
257 extra += ', sideeffects=False'
258 name = name
259
260 self.consume('(')
261 args = []
262 if self.match('void') and self.tokens[1] == ')':
263 self.consume()
264 while self.lookahead() != ')':
265 arg = self.parse_arg()
266 args.append(arg)
267 if self.match(','):
268 self.consume()
269 self.consume(')')
270 if self.match('const', 'CONST'):
271 self.consume()
272 extra = ', const=True' + extra
273
274 if self.lookahead() == '=':
275 self.consume()
276 self.consume('0')
277
278 print(' %s(%s, "%s", [%s]%s),' % (creator, ret, name, ', '.join(args), extra))
279
280 def parse_arg(self):
281 tags = self.parse_tags()

Callers 2

parse_declarationMethod · 0.95
parse_interfaceMethod · 0.95

Calls 6

matchMethod · 0.95
consumeMethod · 0.95
parse_typeMethod · 0.95
has_side_effectsMethod · 0.95
lookaheadMethod · 0.95
parse_argMethod · 0.95

Tested by

no test coverage detected