MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / to_python

Method to_python

bindings/frankenswig/function.py:89–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

87 return result
88
89 def to_python(self):
90 if self.static:
91 args = self.args
92 else:
93 args = [Var(self.args[0].type, 'self')] + self.args[1:]
94 pyargs = ', '.join(a.type.wrap_python_value(a.name) for a in args)
95
96 body = f'result = _lib.{self.name}({pyargs})\n'
97 body += '_check_errors()\n'
98 body += self.type.python_postfix()
99 body += 'return result\n'
100 if self.static:
101 pre = '@staticmethod\n'
102 elif self.getter:
103 pre = '@property\n'
104 else:
105 pre = ''
106 return pre + Function.pyentry(self.type, args, self.pyname, self.docs) + s(body, indent=4)
107
108class FunctionWrapper(Function):
109 def __init__(self, program, type, name, args):

Callers 1

pyentryMethod · 0.45

Calls 5

VarClass · 0.85
sFunction · 0.85
pyentryMethod · 0.80
wrap_python_valueMethod · 0.45
python_postfixMethod · 0.45

Tested by

no test coverage detected