Eolian: WIP
This commit is contained in:
parent
60ebcabd1e
commit
8d116e2822
|
@ -100,13 +100,11 @@ def convert_in_param(tp, name, is_nonull=None):
|
|||
conv_expr = conv_expr.format(name)
|
||||
|
||||
if not key in mapping_in:
|
||||
raise TypeError("Unknown type: %s" % (key))
|
||||
raise TypeError("Unknown IN type: %s" % (key))
|
||||
|
||||
conv_t = mapping_in.get(key)
|
||||
if conv_t is None:
|
||||
if key not in builtin_types:
|
||||
log.warn("Unknown in param %s (type=%s, c_type=%s)", tp.name, tp.type, c_type)
|
||||
conv_t = ""
|
||||
conv_t = mapping_in[key]
|
||||
#if conv_t is None:
|
||||
#conv_t = ""
|
||||
|
||||
if not is_nonull:
|
||||
key = "<{0}>{1} if {1} is not None else NULL".format(c_type, name)
|
||||
|
@ -122,36 +120,33 @@ def convert_out_param(tp, name):
|
|||
return tp.c_type, name
|
||||
|
||||
key = tp.name if tp.name else tp.c_type
|
||||
conv = conversions_out.get(key)
|
||||
|
||||
if not conv:
|
||||
if not key in builtin_types:
|
||||
log.warn("Unknown out param %s (type=%s, c_type=%s)", tp.name, tp.type, tp.c_type)
|
||||
if key in builtin_types:
|
||||
return tp.c_type, name
|
||||
|
||||
if not key in mapping_out:
|
||||
raise TypeError("Unknown OUT type: %s" % (key))
|
||||
|
||||
conv = conversions_out.get(key)
|
||||
|
||||
name = conv.format(name)
|
||||
return tp.c_type, name
|
||||
|
||||
|
||||
def conv_type_ret(tp):
|
||||
if not tp:
|
||||
return
|
||||
|
||||
if tp.type == eolian.TypeType.POINTER:
|
||||
tp = tp.base_type
|
||||
|
||||
c_type = tp.c_type
|
||||
key = tp.name if tp.name else c_type
|
||||
|
||||
#c_t = remove_type_prefixes(tp)
|
||||
if key in builtin_types:
|
||||
return c_type, c_type
|
||||
|
||||
py_t = mapping_out.get(key)
|
||||
if py_t is None:
|
||||
if key not in builtin_types:
|
||||
log.warn("Unknown ret type: %s, %s", key, tp.type)
|
||||
return c_type, c_type
|
||||
raise TypeError("Unknown RET type: %s" % (key))
|
||||
|
||||
py_ret_type = py_t[0]
|
||||
|
||||
#c_ret_type = remove_type_prefixes(c_type)
|
||||
|
||||
return py_ret_type, c_type
|
||||
|
|
|
@ -179,6 +179,8 @@ class Function(object):
|
|||
RET_PARAM = "py_efl_ret"
|
||||
|
||||
def __init__(self, func, prefix, isget=None):
|
||||
self.name = func.name
|
||||
|
||||
self.func = func
|
||||
self.prefix = prefix
|
||||
self.isget = isget
|
||||
|
@ -368,6 +370,8 @@ class Function(object):
|
|||
|
||||
class Property(object):
|
||||
def __init__(self, prop, prefix):
|
||||
self.name = prop.name
|
||||
|
||||
self.prop = prop
|
||||
self.prefix = prefix
|
||||
self.py_name = prop.name
|
||||
|
@ -508,7 +512,6 @@ class Class(object):
|
|||
)
|
||||
continue
|
||||
self.props.append(o)
|
||||
generated_function_counter["_".join((prefix, prop.name))] += 1
|
||||
|
||||
methods = cls.functions_get(eolian.FunctionType.METHOD)
|
||||
for method in methods:
|
||||
|
@ -527,7 +530,6 @@ class Class(object):
|
|||
% (cls.name, method.name))
|
||||
continue
|
||||
self.methods.append(o)
|
||||
generated_function_counter["_".join((prefix, method.name))] += 1
|
||||
|
||||
generated_class_counter[cls.name] += 1
|
||||
|
||||
|
@ -574,15 +576,23 @@ class Class(object):
|
|||
else:
|
||||
for o in (
|
||||
self.ctor +
|
||||
list(self.methods) +
|
||||
list(self.props) +
|
||||
list(self.events)
|
||||
):
|
||||
if o:
|
||||
try:
|
||||
o.generate(gen)
|
||||
except Exception:
|
||||
log.exception("Error while generating %r", o)
|
||||
try:
|
||||
o.generate(gen)
|
||||
except Exception:
|
||||
log.exception("Error while generating %r", o)
|
||||
|
||||
for o in (
|
||||
list(self.methods) +
|
||||
list(self.props)
|
||||
):
|
||||
try:
|
||||
o.generate(gen)
|
||||
except Exception:
|
||||
log.exception("Error while generating %r", o)
|
||||
else:
|
||||
generated_function_counter["_".join((o.prefix, o.name))] += 1
|
||||
|
||||
gen.dedent()
|
||||
gen.write()
|
||||
|
@ -632,7 +642,7 @@ class File(object):
|
|||
self.pygen = Generator()
|
||||
self.cls = eolian.Class.get_by_file(filepath)
|
||||
if not self.cls:
|
||||
raise RuntimeError("Could not get class")
|
||||
raise RuntimeError("Could not get class from %s" % (filepath))
|
||||
self.gencls = Class.parse(self.cls)
|
||||
|
||||
def cdefs_generate(self):
|
||||
|
@ -748,9 +758,23 @@ for path in args.paths:
|
|||
if not eolian.eo_file_parse(f):
|
||||
log.warn("Errors in parsing %s" % (f))
|
||||
|
||||
eolf = File(filename)
|
||||
eolf.cdefs_generate()
|
||||
eolf.pyx_generate()
|
||||
try:
|
||||
eolf = File(filename)
|
||||
except Exception:
|
||||
log.exception("Exception while creating %s" % (filename))
|
||||
continue
|
||||
|
||||
try:
|
||||
eolf.cdefs_generate()
|
||||
except Exception:
|
||||
log.exception("Exception while generating cdefs for %s" % (filename))
|
||||
continue
|
||||
|
||||
try:
|
||||
eolf.pyx_generate()
|
||||
except Exception:
|
||||
log.exception("Exception while generating pyx for %s" % (filename))
|
||||
continue
|
||||
|
||||
|
||||
def report():
|
||||
|
|
Loading…
Reference in New Issue