Eolian: Have constructors use infra like current bindings

This commit is contained in:
Kai Huuhko 2014-06-17 14:56:53 +03:00
parent 9734b81fd1
commit 11bc1b64a5
1 changed files with 6 additions and 2 deletions

View File

@ -403,10 +403,12 @@ class Constructor(Method):
c_params = ", ".join([c[1] for c in self.c_params])
gen.write("self = cls.__new__(cls)")
gen.write(
"eo_add_custom(%s, parent.obj, %s(%s))" % (
"cdef Eo *obj = eo_add_custom"
"(%s, parent.obj if parent is not None else NULL, %s(%s))" % (
cls_get, self.c_name, c_params
)
)
gen.write("self._set_obj(obj)")
gen.write("return self")
gen.dedent()
@ -420,10 +422,12 @@ class DefaultConstructor(Constructor):
gen.write("def __init__(self, parent=None):")
gen.indent()
gen.write(
"eo_add(%s, parent.obj if parent is not None else NULL)" % (
"cdef Eo *obj = eo_add"
"(%s, parent.obj if parent is not None else NULL)" % (
cls_get
)
)
gen.write("self._set_obj(obj)")
gen.dedent()
gen.write()