Eolian: WIP

This commit is contained in:
Kai Huuhko 2014-09-26 17:23:33 +03:00
parent 5fcb8fa569
commit 60ebcabd1e
2 changed files with 24 additions and 14 deletions

View File

@ -92,10 +92,16 @@ def convert_in_param(tp, name, is_nonull=None):
key = tp.name if tp.name else c_type
if key in builtin_types:
return "", "", key
conv_expr = conversions_in.get(key)
if conv_expr is not None:
conv_expr = conv_expr.format(name)
if not key in mapping_in:
raise TypeError("Unknown type: %s" % (key))
conv_t = mapping_in.get(key)
if conv_t is None:
if key not in builtin_types:

View File

@ -171,7 +171,7 @@ class PyxGenerator(Generator):
self.write(")")
self.dedent()
self.write("_eo_do_end(self.obj)")
#self.write("_eo_do_end(self.obj)")
class Function(object):
@ -183,7 +183,7 @@ class Function(object):
self.prefix = prefix
self.isget = isget
self.c_name = func.full_c_name_get(self.prefix)
self.c_name = func.full_c_name
self.c_params = []
@ -407,7 +407,7 @@ class Constructor(object):
for ctor in self.ctors:
func = ctor.function
c_name = func.full_c_name_get(self.prefix)
c_name = func.full_c_name
c_call_params = []
@ -435,7 +435,7 @@ class Constructor(object):
gen.write("def __init__(self, %s):" % (", ".join([" ".join((t, n)).strip() for t, n in header_params])))
gen.indent()
gen.write("cdef Eo *obj = eo_add(")
gen.write("cdef Eo *obj = eo_add_ref(")
gen.indent()
gen.write("%s, parent.obj if parent is not None else NULL," % (cls_get))
for ctor in c_ctors:
@ -532,14 +532,13 @@ class Class(object):
generated_class_counter[cls.name] += 1
for event in cls.events:
print(event)
#self.events.append(Event(event))
self.events.append(Event(event))
return self
def cdefs_generate(self, gen):
if self.ctor or self.methods or self.props:
for o in self.ctor + self.methods + self.props:
for o in self.ctor + self.methods + self.props + self.events:
try:
o.cdef_generate(gen)
except Exception:
@ -576,7 +575,8 @@ class Class(object):
for o in (
self.ctor +
list(self.methods) +
list(self.props)
list(self.props) +
list(self.events)
):
if o:
try:
@ -643,6 +643,8 @@ class File(object):
gen.write('struct CFILE "__FILE__"')
gen.write('struct CLINE "__LINE__"')
gen.write('struct CFUNC "__FUNCTION__"')
gen.dedent()
gen.write()
# gen.write('cdef extern from "Eina.h":')
# gen.indent()
@ -654,7 +656,7 @@ class File(object):
gen.indent()
#gen.write('Eina_Bool _eo_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, Eina_Bool is_main_loop, const char *file, const char *func, int line)')
gen.write('Eina_Bool _eo_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, const char *file, const char *func, int line)')
gen.write('void _eo_do_end(const Eo **ojb)')
#gen.write('void _eo_do_end(const Eo **ojb)')
gen.dedent()
gen.write()
@ -679,11 +681,12 @@ class File(object):
for f in base.struct_fields:
gen.write("%s %s" % (f.type.c_type, f.name))
gen.dedent()
print(i.name, i.full_name, i.filename, i.description, i.base_type)
else:
log.warning("Unhandled alias! %s %s %s %s", i.name, i.full_name, i.filename, i.description)
for i in eolian.type_structs_get_by_file(self.filepath):
print(i.name, i.full_name, i.filename, i.description)
log.warning("Type struct not handled! %s %s %s %s", i.name, i.full_name, i.filename, i.description)
for i in eolian.type_enums_get_by_file(self.filepath):
print(i.name, i.full_name, i.filename, i.description)
log.warning("Type enum not handled! %s %s %s %s", i.name, i.full_name, i.filename, i.description)
self.gencls.cdefs_generate(gen)
@ -719,10 +722,11 @@ class File(object):
class Event(object):
def __init__(self, event):
pass
self.event = event
#print(event)
def cdef_generate(self, gen):
pass
gen.write("enum: %s" % (self.event.c_name))
def generate(self, gen):
pass