Eolian: Handle param conversions in constructors

This commit is contained in:
Kai Huuhko 2014-10-11 07:24:54 +03:00
parent 46e5b7edd1
commit 336548178a
1 changed files with 7 additions and 1 deletions

View File

@ -17,7 +17,7 @@ log.setLevel(log_level)
import eolian
from converters import convert_in_param, convert_out_param, conv_type_ret, \
from .converters import convert_in_param, convert_out_param, conv_type_ret, \
conv_cls_name, EolianTypeError, event_conversion_get
# XXX: C namespaces don't include this top level name
@ -493,6 +493,7 @@ class Constructor(object):
header_params = []
c_ctors = []
conv_in_py_exps = []
for ctor in self.ctors:
func = ctor.function
@ -516,6 +517,7 @@ class Constructor(object):
c_type = p.type.c_type
conv_expr_py, c_type, name = convert_in_param(p.type, p.name, p.is_nonull)
conv_in_py_exps.append(conv_expr_py)
header_params.append((c_type, p.name))
c_call_params.append(name)
@ -527,6 +529,10 @@ class Constructor(object):
gen.write("def __init__(self, %s):" % (", ".join([" ".join((t, n)).strip() for t, n in header_params])))
gen.indent()
for e in conv_in_py_exps:
if e:
gen.write(e)
gen.write("cdef Eo *added_obj = eo_add_ref(")
gen.indent()
gen.write("%s(), <Eo *>parent.obj if parent is not None else NULL," % (cls_get))