forked from enlightenment/efl
Pyolian: reformat code to make pycharm happy
and fix some typos in the code
This commit is contained in:
parent
a864d62ecf
commit
d1e27aacfc
|
@ -35,8 +35,8 @@ except ImportError:
|
||||||
|
|
||||||
_already_halted = False
|
_already_halted = False
|
||||||
|
|
||||||
### Eolian Enums ############################################################
|
|
||||||
|
|
||||||
|
# Eolian Enums ##############################################################
|
||||||
class Eolian_Function_Type(IntEnum):
|
class Eolian_Function_Type(IntEnum):
|
||||||
UNRESOLVED = 0
|
UNRESOLVED = 0
|
||||||
PROPERTY = 1
|
PROPERTY = 1
|
||||||
|
@ -45,12 +45,14 @@ class Eolian_Function_Type(IntEnum):
|
||||||
METHOD = 4
|
METHOD = 4
|
||||||
FUNCTION_POINTER = 5
|
FUNCTION_POINTER = 5
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Parameter_Direction(IntEnum):
|
class Eolian_Parameter_Direction(IntEnum):
|
||||||
UNKNOWN = 0
|
UNKNOWN = 0
|
||||||
IN = 1
|
IN = 1
|
||||||
OUT = 2
|
OUT = 2
|
||||||
INOUT = 3
|
INOUT = 3
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Class_Type(IntEnum):
|
class Eolian_Class_Type(IntEnum):
|
||||||
UNKNOWN_TYPE = 0
|
UNKNOWN_TYPE = 0
|
||||||
REGULAR = 1
|
REGULAR = 1
|
||||||
|
@ -58,12 +60,14 @@ class Eolian_Class_Type(IntEnum):
|
||||||
MIXIN = 3
|
MIXIN = 3
|
||||||
INTERFACE = 4
|
INTERFACE = 4
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Object_Scope(IntEnum):
|
class Eolian_Object_Scope(IntEnum):
|
||||||
UNKNOWN = 0
|
UNKNOWN = 0
|
||||||
PUBLIC = 1
|
PUBLIC = 1
|
||||||
PRIVATE = 2
|
PRIVATE = 2
|
||||||
PROTECTED = 3
|
PROTECTED = 3
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Typedecl_Type(IntEnum):
|
class Eolian_Typedecl_Type(IntEnum):
|
||||||
UNKNOWN = 0
|
UNKNOWN = 0
|
||||||
STRUCT = 1
|
STRUCT = 1
|
||||||
|
@ -72,6 +76,7 @@ class Eolian_Typedecl_Type(IntEnum):
|
||||||
ALIAS = 4
|
ALIAS = 4
|
||||||
FUNCTION_POINTER = 5
|
FUNCTION_POINTER = 5
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Type_Type(IntEnum):
|
class Eolian_Type_Type(IntEnum):
|
||||||
UNKNOWN_TYPE = 0
|
UNKNOWN_TYPE = 0
|
||||||
VOID = 1
|
VOID = 1
|
||||||
|
@ -79,6 +84,7 @@ class Eolian_Type_Type(IntEnum):
|
||||||
CLASS = 3
|
CLASS = 3
|
||||||
UNDEFINED = 4
|
UNDEFINED = 4
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Type_Builtin_Type(IntEnum):
|
class Eolian_Type_Builtin_Type(IntEnum):
|
||||||
INVALID = 0
|
INVALID = 0
|
||||||
BYTE = 1
|
BYTE = 1
|
||||||
|
@ -141,6 +147,7 @@ class Eolian_Type_Builtin_Type(IntEnum):
|
||||||
HASH = 47
|
HASH = 47
|
||||||
VOID_PTR = 48
|
VOID_PTR = 48
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Expression_Type(IntEnum):
|
class Eolian_Expression_Type(IntEnum):
|
||||||
UNKNOWN = 0
|
UNKNOWN = 0
|
||||||
INT = 1
|
INT = 1
|
||||||
|
@ -159,18 +166,20 @@ class Eolian_Expression_Type(IntEnum):
|
||||||
UNARY = 14
|
UNARY = 14
|
||||||
BINARY = 15
|
BINARY = 15
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Expression_Mask(IntEnum):
|
class Eolian_Expression_Mask(IntEnum):
|
||||||
SINT = 1 << 0
|
SINT = 1 << 0
|
||||||
UINT = 1 << 1
|
UINT = 1 << 1
|
||||||
INT = SINT | UINT
|
INT = SINT | UINT
|
||||||
FLOAT = 1 << 2
|
FLOAT = 1 << 2
|
||||||
BOOL = 1 << 3
|
BOOL = 1 << 3
|
||||||
STRING = 1 << 4
|
STRING = 1 << 4
|
||||||
CHAR = 1 << 5
|
CHAR = 1 << 5
|
||||||
NULL = 1 << 6
|
NULL = 1 << 6
|
||||||
SIGNED = SINT | FLOAT
|
SIGNED = SINT | FLOAT
|
||||||
NUMBER = INT | FLOAT
|
NUMBER = INT | FLOAT
|
||||||
ALL = NUMBER | BOOL | STRING | CHAR | NULL
|
ALL = NUMBER | BOOL | STRING | CHAR | NULL
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Binary_Operator(IntEnum):
|
class Eolian_Binary_Operator(IntEnum):
|
||||||
INVALID = 0
|
INVALID = 0
|
||||||
|
@ -186,12 +195,13 @@ class Eolian_Binary_Operator(IntEnum):
|
||||||
GE = 10 # >= int, float
|
GE = 10 # >= int, float
|
||||||
LE = 11 # <= int, float
|
LE = 11 # <= int, float
|
||||||
AND = 12 # && all types
|
AND = 12 # && all types
|
||||||
OR = 13 # || all types
|
OR = 13 # || all types
|
||||||
BAND = 14 # & int
|
BAND = 14 # & int
|
||||||
BOR = 15 # | int
|
BOR = 15 # | int
|
||||||
BXOR = 16 # ^ int
|
BXOR = 16 # ^ int
|
||||||
LSH = 17 # << int
|
LSH = 17 # << int
|
||||||
RSH = 18 # >> int
|
RSH = 18 # >> int
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Unary_Operator(IntEnum):
|
class Eolian_Unary_Operator(IntEnum):
|
||||||
INVALID = 0
|
INVALID = 0
|
||||||
|
@ -200,6 +210,7 @@ class Eolian_Unary_Operator(IntEnum):
|
||||||
NOT = 3 # ! int, float, bool
|
NOT = 3 # ! int, float, bool
|
||||||
BNOT = 4 # ~ int
|
BNOT = 4 # ~ int
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Doc_Token_Type(IntEnum):
|
class Eolian_Doc_Token_Type(IntEnum):
|
||||||
UNKNOWN = 0
|
UNKNOWN = 0
|
||||||
TEXT = 1
|
TEXT = 1
|
||||||
|
@ -211,12 +222,12 @@ class Eolian_Doc_Token_Type(IntEnum):
|
||||||
MARKUP_MONOSPACE = 7
|
MARKUP_MONOSPACE = 7
|
||||||
|
|
||||||
|
|
||||||
### internal Classes ########################################################
|
# Internal Classes ##########################################################
|
||||||
|
|
||||||
class Iterator(object):
|
class Iterator(object):
|
||||||
""" Generic eina iterator wrapper """
|
""" Generic eina iterator wrapper """
|
||||||
def __init__(self, conv_func, iterator):
|
def __init__(self, conv_func, iterator):
|
||||||
self.next = self.__next__ # py2 compat
|
self.next = self.__next__ # py2 compat
|
||||||
self._conv = conv_func
|
self._conv = conv_func
|
||||||
self._iter = c_void_p(iterator)
|
self._iter = c_void_p(iterator)
|
||||||
self._tmp = c_void_p(0)
|
self._tmp = c_void_p(0)
|
||||||
|
@ -251,6 +262,7 @@ class cached_property(object):
|
||||||
|
|
||||||
class EolianBaseObject(object):
|
class EolianBaseObject(object):
|
||||||
__instances_cache = {}
|
__instances_cache = {}
|
||||||
|
|
||||||
def __new__(cls, c_obj_pointer=None, *args, **kargs):
|
def __new__(cls, c_obj_pointer=None, *args, **kargs):
|
||||||
# cannot cache without a pointer
|
# cannot cache without a pointer
|
||||||
if c_obj_pointer is None:
|
if c_obj_pointer is None:
|
||||||
|
@ -307,7 +319,7 @@ class EolianBaseObject(object):
|
||||||
return self._obj
|
return self._obj
|
||||||
|
|
||||||
|
|
||||||
### Main Eolian Unit ########################################################
|
# Main Eolian Unit ##########################################################
|
||||||
|
|
||||||
class Eolian_Unit(EolianBaseObject):
|
class Eolian_Unit(EolianBaseObject):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -451,7 +463,7 @@ class Eolian_State(Eolian_Unit):
|
||||||
|
|
||||||
def objects_by_file_get(self, file_name):
|
def objects_by_file_get(self, file_name):
|
||||||
return Iterator(Object,
|
return Iterator(Object,
|
||||||
lib.eolian_state_objects_by_file_get(self, _str_to_bytes(file_name)))
|
lib.eolian_state_objects_by_file_get(self, _str_to_bytes(file_name)))
|
||||||
|
|
||||||
def class_by_file_get(self, file_name):
|
def class_by_file_get(self, file_name):
|
||||||
c_cls = lib.eolian_state_class_by_file_get(self, _str_to_bytes(file_name))
|
c_cls = lib.eolian_state_class_by_file_get(self, _str_to_bytes(file_name))
|
||||||
|
@ -459,22 +471,22 @@ class Eolian_State(Eolian_Unit):
|
||||||
|
|
||||||
def constants_by_file_get(self, file_name):
|
def constants_by_file_get(self, file_name):
|
||||||
return Iterator(Constant,
|
return Iterator(Constant,
|
||||||
lib.eolian_state_constants_by_file_get(self, _str_to_bytes(file_name)))
|
lib.eolian_state_constants_by_file_get(self, _str_to_bytes(file_name)))
|
||||||
|
|
||||||
def aliases_by_file_get(self, file_name):
|
def aliases_by_file_get(self, file_name):
|
||||||
return Iterator(Typedecl,
|
return Iterator(Typedecl,
|
||||||
lib.eolian_state_aliases_by_file_get(self, _str_to_bytes(file_name)))
|
lib.eolian_state_aliases_by_file_get(self, _str_to_bytes(file_name)))
|
||||||
|
|
||||||
def structs_by_file_get(self, file_name):
|
def structs_by_file_get(self, file_name):
|
||||||
return Iterator(Typedecl,
|
return Iterator(Typedecl,
|
||||||
lib.eolian_state_structs_by_file_get(self, _str_to_bytes(file_name)))
|
lib.eolian_state_structs_by_file_get(self, _str_to_bytes(file_name)))
|
||||||
|
|
||||||
def enums_by_file_get(self, file_name):
|
def enums_by_file_get(self, file_name):
|
||||||
return Iterator(Typedecl,
|
return Iterator(Typedecl,
|
||||||
lib.eolian_state_enums_by_file_get(self, _str_to_bytes(file_name)))
|
lib.eolian_state_enums_by_file_get(self, _str_to_bytes(file_name)))
|
||||||
|
|
||||||
|
|
||||||
### Namespace Utility Class #################################################
|
# Namespace Utility Class ###################################################
|
||||||
|
|
||||||
class Namespace(object):
|
class Namespace(object):
|
||||||
def __init__(self, unit, namespace_name):
|
def __init__(self, unit, namespace_name):
|
||||||
|
@ -512,55 +524,55 @@ class Namespace(object):
|
||||||
def sub_namespaces(self):
|
def sub_namespaces(self):
|
||||||
base = self._name + '.'
|
base = self._name + '.'
|
||||||
deep = self._name.count('.') + 1
|
deep = self._name.count('.') + 1
|
||||||
return [ ns for ns in self._unit.all_namespaces
|
return [ns for ns in self._unit.all_namespaces
|
||||||
if ns.name.startswith(base) and ns.name.count('.') == deep ]
|
if ns.name.startswith(base) and ns.name.count('.') == deep]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def classes(self):
|
def classes(self):
|
||||||
return sorted([ c for c in self._unit.classes
|
return sorted([c for c in self._unit.classes
|
||||||
if c.namespace == self._name ])
|
if c.namespace == self._name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def regulars(self):
|
def regulars(self):
|
||||||
return sorted([ c for c in self._unit.classes
|
return sorted([c for c in self._unit.classes
|
||||||
if c.type == Eolian_Class_Type.REGULAR and
|
if c.type == Eolian_Class_Type.REGULAR
|
||||||
c.namespace == self._name])
|
and c.namespace == self._name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def abstracts(self):
|
def abstracts(self):
|
||||||
return sorted([ c for c in self._unit.classes
|
return sorted([c for c in self._unit.classes
|
||||||
if c.type == Eolian_Class_Type.ABSTRACT and
|
if c.type == Eolian_Class_Type.ABSTRACT
|
||||||
c.namespace == self._name])
|
and c.namespace == self._name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mixins(self):
|
def mixins(self):
|
||||||
return sorted([ c for c in self._unit.classes
|
return sorted([c for c in self._unit.classes
|
||||||
if c.type == Eolian_Class_Type.MIXIN and
|
if c.type == Eolian_Class_Type.MIXIN
|
||||||
c.namespace == self._name])
|
and c.namespace == self._name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def interfaces(self):
|
def interfaces(self):
|
||||||
return sorted([ c for c in self._unit.classes
|
return sorted([c for c in self._unit.classes
|
||||||
if c.type == Eolian_Class_Type.INTERFACE and
|
if c.type == Eolian_Class_Type.INTERFACE
|
||||||
c.namespace == self._name])
|
and c.namespace == self._name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def aliases(self):
|
def aliases(self):
|
||||||
return sorted([ td for td in self._unit.aliases
|
return sorted([td for td in self._unit.aliases
|
||||||
if td.namespace == self._name])
|
if td.namespace == self._name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def structs(self):
|
def structs(self):
|
||||||
return sorted([ td for td in self._unit.structs
|
return sorted([td for td in self._unit.structs
|
||||||
if td.namespace == self._name])
|
if td.namespace == self._name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enums(self):
|
def enums(self):
|
||||||
return sorted([ td for td in self._unit.enums
|
return sorted([td for td in self._unit.enums
|
||||||
if td.namespace == self._name])
|
if td.namespace == self._name])
|
||||||
|
|
||||||
|
|
||||||
### Eolian Classes ##########################################################
|
# Eolian Classes ############################################################
|
||||||
|
|
||||||
class Object(EolianBaseObject):
|
class Object(EolianBaseObject):
|
||||||
def __new__(cls, c_obj_pointer):
|
def __new__(cls, c_obj_pointer):
|
||||||
|
@ -680,27 +692,27 @@ class Class(Object):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def inherits_full(self):
|
def inherits_full(self):
|
||||||
L = []
|
li = []
|
||||||
|
|
||||||
def do_class_recursive(cls):
|
def do_class_recursive(cls):
|
||||||
if cls.parent:
|
if cls.parent:
|
||||||
L.append(cls.parent)
|
li.append(cls.parent)
|
||||||
for other in cls.extensions:
|
for other in cls.extensions:
|
||||||
if other not in L:
|
if other not in li:
|
||||||
L.append(other)
|
li.append(other)
|
||||||
do_class_recursive(other)
|
do_class_recursive(other)
|
||||||
|
|
||||||
do_class_recursive(self)
|
do_class_recursive(self)
|
||||||
return L
|
return li
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def hierarchy(self):
|
def hierarchy(self):
|
||||||
L = []
|
li = []
|
||||||
base = self.parent
|
base = self.parent
|
||||||
while base:
|
while base:
|
||||||
L.append(base)
|
li.append(base)
|
||||||
base = base.parent
|
base = base.parent
|
||||||
return L
|
return li
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def ctor_enable(self):
|
def ctor_enable(self):
|
||||||
|
@ -710,10 +722,10 @@ class Class(Object):
|
||||||
def dtor_enable(self):
|
def dtor_enable(self):
|
||||||
return bool(lib.eolian_class_dtor_enable_get(self))
|
return bool(lib.eolian_class_dtor_enable_get(self))
|
||||||
|
|
||||||
def function_by_name_get(self, func_name,
|
def function_by_name_get(self, function_name,
|
||||||
ftype=Eolian_Function_Type.UNRESOLVED):
|
ftype=Eolian_Function_Type.UNRESOLVED):
|
||||||
f = lib.eolian_class_function_by_name_get(self,
|
f = lib.eolian_class_function_by_name_get(self,
|
||||||
_str_to_bytes(func_name),
|
_str_to_bytes(function_name),
|
||||||
ftype)
|
ftype)
|
||||||
return Function(f) if f else None
|
return Function(f) if f else None
|
||||||
|
|
||||||
|
@ -868,36 +880,40 @@ class Function(Object):
|
||||||
return Iterator(Function_Parameter,
|
return Iterator(Function_Parameter,
|
||||||
lib.eolian_function_parameters_get(self))
|
lib.eolian_function_parameters_get(self))
|
||||||
|
|
||||||
def values_get(self, ftype): # TODO rename in property_values_get (or implement a proper Property class?)
|
def values_get(self, ftype):
|
||||||
|
# TODO rename in property_values_get
|
||||||
|
# (or implement a proper Property class?)
|
||||||
return Iterator(Function_Parameter,
|
return Iterator(Function_Parameter,
|
||||||
lib.eolian_property_values_get(self, ftype))
|
lib.eolian_property_values_get(self, ftype))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def getter_values(self): # TODO rename ...
|
def getter_values(self): # TODO rename ...
|
||||||
return self.values_get(Eolian_Function_Type.PROP_GET)
|
return self.values_get(Eolian_Function_Type.PROP_GET)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def setter_values(self): # TODO rename ...
|
def setter_values(self): # TODO rename ...
|
||||||
return self.values_get(Eolian_Function_Type.PROP_SET)
|
return self.values_get(Eolian_Function_Type.PROP_SET)
|
||||||
|
|
||||||
def keys_get(self, ftype): # TODO rename in property_keys_get (or implement a proper Property class?)
|
def keys_get(self, ftype):
|
||||||
|
# TODO rename in property_keys_get
|
||||||
|
# (or implement a proper Property class?)
|
||||||
return Iterator(Function_Parameter,
|
return Iterator(Function_Parameter,
|
||||||
lib.eolian_property_keys_get(self, ftype))
|
lib.eolian_property_keys_get(self, ftype))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def getter_keys(self): # TODO rename ...
|
def getter_keys(self): # TODO rename ...
|
||||||
return self.keys_get(Eolian_Function_Type.PROP_GET)
|
return self.keys_get(Eolian_Function_Type.PROP_GET)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def setter_keys(self): # TODO rename ...
|
def setter_keys(self): # TODO rename ...
|
||||||
return self.keys_get(Eolian_Function_Type.PROP_SET)
|
return self.keys_get(Eolian_Function_Type.PROP_SET)
|
||||||
|
|
||||||
def return_type_get(self, ftype):
|
def return_type_get(self, ftype):
|
||||||
c_type = lib.eolian_function_return_type_get(self, ftype)
|
c_type = lib.eolian_function_return_type_get(self, ftype)
|
||||||
return Type(c_type) if c_type else None
|
return Type(c_type) if c_type else None
|
||||||
|
|
||||||
def return_default_value(self, ftye):
|
def return_default_value(self, ftype):
|
||||||
c_expr = lib.eolian_function_return_default_value_get(sel._obj, ftype)
|
c_expr = lib.eolian_function_return_default_value_get(self._obj, ftype)
|
||||||
return Expression(c_expr) if c_expr else None
|
return Expression(c_expr) if c_expr else None
|
||||||
|
|
||||||
def return_documentation(self, ftype):
|
def return_documentation(self, ftype):
|
||||||
|
@ -1019,7 +1035,7 @@ class Implement(Object):
|
||||||
|
|
||||||
class Type(Object):
|
class Type(Object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
# return "<eolian.Type '{0.name}', type: {0.type!s}, c_type: '{0.c_type}'>".format(self)
|
# return "<eolian.Type '{0.name}', type: {0.type!s}, c_type: '{0.c_type}'>".format(self)
|
||||||
return "<eolian.Type '{0.name}', type={0.type!s}>".format(self)
|
return "<eolian.Type '{0.name}', type={0.type!s}>".format(self)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
@ -1326,11 +1342,12 @@ class Documentation_Token(object):
|
||||||
return self._ref
|
return self._ref
|
||||||
|
|
||||||
|
|
||||||
### internal string encode/decode ###########################################
|
# internal string encode/decode #############################################
|
||||||
|
|
||||||
def _str_to_bytes(s):
|
def _str_to_bytes(s):
|
||||||
return s.encode('utf-8')
|
return s.encode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
def _str_to_py(s):
|
def _str_to_py(s):
|
||||||
if s is None:
|
if s is None:
|
||||||
return None
|
return None
|
||||||
|
@ -1345,7 +1362,7 @@ def _str_to_py(s):
|
||||||
print('WARNING !!!!!!!!! Unknown type: %s' % type(s))
|
print('WARNING !!!!!!!!! Unknown type: %s' % type(s))
|
||||||
|
|
||||||
|
|
||||||
### internal Object type -> Class mapping ###################################
|
# internal Object type -> Class mapping #####################################
|
||||||
|
|
||||||
class _Eolian_Object_Type(IntEnum):
|
class _Eolian_Object_Type(IntEnum):
|
||||||
UNKNOWN = 0
|
UNKNOWN = 0
|
||||||
|
@ -1364,6 +1381,7 @@ class _Eolian_Object_Type(IntEnum):
|
||||||
CONSTRUCTOR = 13
|
CONSTRUCTOR = 13
|
||||||
DOCUMENTATION = 14
|
DOCUMENTATION = 14
|
||||||
|
|
||||||
|
|
||||||
_eolian_type_class_mapping = {
|
_eolian_type_class_mapping = {
|
||||||
_Eolian_Object_Type.UNKNOWN: Object,
|
_Eolian_Object_Type.UNKNOWN: Object,
|
||||||
_Eolian_Object_Type.CLASS: Class,
|
_Eolian_Object_Type.CLASS: Class,
|
||||||
|
@ -1382,17 +1400,20 @@ _eolian_type_class_mapping = {
|
||||||
_Eolian_Object_Type.DOCUMENTATION: Documentation,
|
_Eolian_Object_Type.DOCUMENTATION: Documentation,
|
||||||
}
|
}
|
||||||
|
|
||||||
### module init/shutdown ####################################################
|
|
||||||
|
# module init/shutdown ######################################################
|
||||||
|
|
||||||
def _cleanup():
|
def _cleanup():
|
||||||
global _already_halted
|
global _already_halted
|
||||||
lib.eolian_shutdown()
|
lib.eolian_shutdown()
|
||||||
_already_halted = True
|
_already_halted = True
|
||||||
|
|
||||||
|
|
||||||
lib.eolian_init()
|
lib.eolian_init()
|
||||||
atexit.register(_cleanup)
|
atexit.register(_cleanup)
|
||||||
|
|
||||||
|
|
||||||
### API coverage statistics #################################################
|
# API coverage statistics ###################################################
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -29,7 +29,7 @@ for lib_dir in search_in:
|
||||||
file_path = f
|
file_path = f
|
||||||
|
|
||||||
if not file_path:
|
if not file_path:
|
||||||
raise RuntimeError('Error: cannot find a built eolian library in source tree')
|
raise RuntimeError('Error: cannot find a built eolian lib in source tree')
|
||||||
|
|
||||||
lib = CDLL(file_path)
|
lib = CDLL(file_path)
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ lib.eolian_init.restype = c_int
|
||||||
lib.eolian_shutdown.argtypes = None
|
lib.eolian_shutdown.argtypes = None
|
||||||
lib.eolian_shutdown.restype = c_int
|
lib.eolian_shutdown.restype = c_int
|
||||||
|
|
||||||
### Eolian_State ############################################################
|
|
||||||
|
# Eolian_State ##############################################################
|
||||||
|
|
||||||
# EAPI Eolian_State *eolian_state_new(void);
|
# EAPI Eolian_State *eolian_state_new(void);
|
||||||
lib.eolian_state_new.argtypes = None
|
lib.eolian_state_new.argtypes = None
|
||||||
|
@ -124,7 +125,8 @@ lib.eolian_state_structs_by_file_get.restype = c_void_p
|
||||||
lib.eolian_state_enums_by_file_get.argtypes = (c_void_p, c_char_p)
|
lib.eolian_state_enums_by_file_get.argtypes = (c_void_p, c_char_p)
|
||||||
lib.eolian_state_enums_by_file_get.restype = c_void_p
|
lib.eolian_state_enums_by_file_get.restype = c_void_p
|
||||||
|
|
||||||
### Eolian_Unit #############################################################
|
|
||||||
|
# Eolian_Unit ###############################################################
|
||||||
|
|
||||||
# EAPI Eina_Iterator *eolian_unit_children_get(const Eolian_Unit *unit);
|
# EAPI Eina_Iterator *eolian_unit_children_get(const Eolian_Unit *unit);
|
||||||
lib.eolian_unit_children_get.argtypes = (c_void_p,)
|
lib.eolian_unit_children_get.argtypes = (c_void_p,)
|
||||||
|
@ -186,7 +188,8 @@ lib.eolian_unit_constant_by_name_get.restype = c_void_p
|
||||||
lib.eolian_unit_constants_get.argtypes = (c_void_p,)
|
lib.eolian_unit_constants_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_unit_constants_get.restype = c_void_p
|
lib.eolian_unit_constants_get.restype = c_void_p
|
||||||
|
|
||||||
### Eolian_Object ###########################################################
|
|
||||||
|
# Eolian_Object #############################################################
|
||||||
|
|
||||||
# EAPI Eolian_Object_Type eolian_object_type_get(const Eolian_Object *obj);
|
# EAPI Eolian_Object_Type eolian_object_type_get(const Eolian_Object *obj);
|
||||||
lib.eolian_object_type_get.argtypes = (c_void_p,)
|
lib.eolian_object_type_get.argtypes = (c_void_p,)
|
||||||
|
@ -224,7 +227,8 @@ lib.eolian_object_namespaces_get.restype = c_void_p
|
||||||
lib.eolian_object_is_beta.argtypes = (c_void_p,)
|
lib.eolian_object_is_beta.argtypes = (c_void_p,)
|
||||||
lib.eolian_object_is_beta.restype = c_bool
|
lib.eolian_object_is_beta.restype = c_bool
|
||||||
|
|
||||||
### Eolian_Class ############################################################
|
|
||||||
|
# Eolian_Class ##############################################################
|
||||||
|
|
||||||
# EAPI Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass);
|
# EAPI Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass);
|
||||||
lib.eolian_class_type_get.argtypes = (c_void_p,)
|
lib.eolian_class_type_get.argtypes = (c_void_p,)
|
||||||
|
@ -302,7 +306,8 @@ lib.eolian_class_c_macro_get.restype = c_void_p # Stringshare TO BE FREED
|
||||||
lib.eolian_class_c_data_type_get.argtypes = (c_void_p,)
|
lib.eolian_class_c_data_type_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_class_c_data_type_get.restype = c_void_p # Stringshare TO BE FREED
|
lib.eolian_class_c_data_type_get.restype = c_void_p # Stringshare TO BE FREED
|
||||||
|
|
||||||
### Eolian_Function #########################################################
|
|
||||||
|
# Eolian_Function ###########################################################
|
||||||
|
|
||||||
# EAPI Eolian_Function_Type eolian_function_type_get(const Eolian_Function *function_id);
|
# EAPI Eolian_Function_Type eolian_function_type_get(const Eolian_Function *function_id);
|
||||||
lib.eolian_function_type_get.argtypes = (c_void_p,)
|
lib.eolian_function_type_get.argtypes = (c_void_p,)
|
||||||
|
@ -369,7 +374,8 @@ lib.eolian_property_keys_get.restype = c_void_p
|
||||||
lib.eolian_property_values_get.argtypes = (c_void_p, c_int)
|
lib.eolian_property_values_get.argtypes = (c_void_p, c_int)
|
||||||
lib.eolian_property_values_get.restype = c_void_p
|
lib.eolian_property_values_get.restype = c_void_p
|
||||||
|
|
||||||
### Eolian_Function_Parameter ###############################################
|
|
||||||
|
# Eolian_Function_Parameter #################################################
|
||||||
|
|
||||||
# EAPI Eolian_Parameter_Direction eolian_parameter_direction_get(const Eolian_Function_Parameter *param);
|
# EAPI Eolian_Parameter_Direction eolian_parameter_direction_get(const Eolian_Function_Parameter *param);
|
||||||
lib.eolian_parameter_direction_get.argtypes = (c_void_p,)
|
lib.eolian_parameter_direction_get.argtypes = (c_void_p,)
|
||||||
|
@ -391,7 +397,8 @@ lib.eolian_parameter_documentation_get.restype = c_void_p
|
||||||
lib.eolian_parameter_is_optional.argtypes = (c_void_p,)
|
lib.eolian_parameter_is_optional.argtypes = (c_void_p,)
|
||||||
lib.eolian_parameter_is_optional.restype = c_bool
|
lib.eolian_parameter_is_optional.restype = c_bool
|
||||||
|
|
||||||
### Eolian_Implement ########################################################
|
|
||||||
|
# Eolian_Implement ##########################################################
|
||||||
|
|
||||||
# EAPI const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
|
# EAPI const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
|
||||||
lib.eolian_implement_class_get.argtypes = (c_void_p,)
|
lib.eolian_implement_class_get.argtypes = (c_void_p,)
|
||||||
|
@ -425,7 +432,8 @@ lib.eolian_implement_is_prop_get.restype = c_bool
|
||||||
lib.eolian_implement_is_prop_set.argtypes = (c_void_p,)
|
lib.eolian_implement_is_prop_set.argtypes = (c_void_p,)
|
||||||
lib.eolian_implement_is_prop_set.restype = c_bool
|
lib.eolian_implement_is_prop_set.restype = c_bool
|
||||||
|
|
||||||
### Eolian_Constructor ######################################################
|
|
||||||
|
# Eolian_Constructor ########################################################
|
||||||
|
|
||||||
# EAPI const Eolian_Class *eolian_constructor_class_get(const Eolian_Constructor *ctor);
|
# EAPI const Eolian_Class *eolian_constructor_class_get(const Eolian_Constructor *ctor);
|
||||||
lib.eolian_constructor_class_get.argtypes = (c_void_p,)
|
lib.eolian_constructor_class_get.argtypes = (c_void_p,)
|
||||||
|
@ -439,7 +447,8 @@ lib.eolian_constructor_function_get.restype = c_void_p
|
||||||
lib.eolian_constructor_is_optional.argtypes = (c_void_p,)
|
lib.eolian_constructor_is_optional.argtypes = (c_void_p,)
|
||||||
lib.eolian_constructor_is_optional.restype = c_bool
|
lib.eolian_constructor_is_optional.restype = c_bool
|
||||||
|
|
||||||
### Eolian_Event ############################################################
|
|
||||||
|
# Eolian_Event ##############################################################
|
||||||
|
|
||||||
# EAPI Eina_Stringshare *eolian_event_c_macro_get(const Eolian_Event *event);
|
# EAPI Eina_Stringshare *eolian_event_c_macro_get(const Eolian_Event *event);
|
||||||
lib.eolian_event_c_macro_get.argtypes = (c_void_p,)
|
lib.eolian_event_c_macro_get.argtypes = (c_void_p,)
|
||||||
|
@ -465,7 +474,8 @@ lib.eolian_event_is_hot.restype = c_bool
|
||||||
lib.eolian_event_is_restart.argtypes = (c_void_p,)
|
lib.eolian_event_is_restart.argtypes = (c_void_p,)
|
||||||
lib.eolian_event_is_restart.restype = c_bool
|
lib.eolian_event_is_restart.restype = c_bool
|
||||||
|
|
||||||
### Eolian_Part #############################################################
|
|
||||||
|
# Eolian_Part ###############################################################
|
||||||
|
|
||||||
# EAPI const Eolian_Class *eolian_part_class_get(const Eolian_Part *part);
|
# EAPI const Eolian_Class *eolian_part_class_get(const Eolian_Part *part);
|
||||||
lib.eolian_part_class_get.argtypes = (c_void_p,)
|
lib.eolian_part_class_get.argtypes = (c_void_p,)
|
||||||
|
@ -475,7 +485,8 @@ lib.eolian_part_class_get.restype = c_void_p
|
||||||
lib.eolian_part_documentation_get.argtypes = (c_void_p,)
|
lib.eolian_part_documentation_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_part_documentation_get.restype = c_void_p
|
lib.eolian_part_documentation_get.restype = c_void_p
|
||||||
|
|
||||||
### Eolian_Typedecl #########################################################
|
|
||||||
|
# Eolian_Typedecl ###########################################################
|
||||||
|
|
||||||
# EAPI Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp);
|
# EAPI Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp);
|
||||||
lib.eolian_typedecl_type_get.argtypes = (c_void_p,)
|
lib.eolian_typedecl_type_get.argtypes = (c_void_p,)
|
||||||
|
@ -549,7 +560,8 @@ lib.eolian_typedecl_free_func_get.restype = c_char_p
|
||||||
lib.eolian_typedecl_function_pointer_get.argtypes = (c_void_p,)
|
lib.eolian_typedecl_function_pointer_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_typedecl_function_pointer_get.restype = c_void_p
|
lib.eolian_typedecl_function_pointer_get.restype = c_void_p
|
||||||
|
|
||||||
### Eolian_Type #############################################################
|
|
||||||
|
# Eolian_Type ###############################################################
|
||||||
|
|
||||||
# EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
|
# EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
|
||||||
lib.eolian_type_type_get.argtypes = (c_void_p,)
|
lib.eolian_type_type_get.argtypes = (c_void_p,)
|
||||||
|
@ -588,10 +600,11 @@ lib.eolian_type_is_ptr.argtypes = (c_void_p,)
|
||||||
lib.eolian_type_is_ptr.restype = c_bool
|
lib.eolian_type_is_ptr.restype = c_bool
|
||||||
|
|
||||||
# EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp);
|
# EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp);
|
||||||
lib.eolian_type_c_type_get.argtypes = (c_void_p)
|
lib.eolian_type_c_type_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_type_c_type_get.restype = c_void_p # Stringshare TO BE FREED
|
lib.eolian_type_c_type_get.restype = c_void_p # Stringshare TO BE FREED
|
||||||
|
|
||||||
### Eolian_Expression #######################################################
|
|
||||||
|
# Eolian_Expression #########################################################
|
||||||
|
|
||||||
# EAPI Eina_Stringshare *eolian_expression_serialize(const Eolian_Expression *expr);
|
# EAPI Eina_Stringshare *eolian_expression_serialize(const Eolian_Expression *expr);
|
||||||
lib.eolian_expression_serialize.argtypes = (c_void_p,)
|
lib.eolian_expression_serialize.argtypes = (c_void_p,)
|
||||||
|
@ -621,7 +634,8 @@ lib.eolian_expression_unary_operator_get.restype = c_int
|
||||||
lib.eolian_expression_unary_expression_get.argtypes = (c_void_p,)
|
lib.eolian_expression_unary_expression_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_expression_unary_expression_get.restype = c_void_p
|
lib.eolian_expression_unary_expression_get.restype = c_void_p
|
||||||
|
|
||||||
### Eolian_Constant #########################################################
|
|
||||||
|
# Eolian_Constant ###########################################################
|
||||||
|
|
||||||
# EAPI const Eolian_Documentation *eolian_constant_documentation_get(const Eolian_Constant *var);
|
# EAPI const Eolian_Documentation *eolian_constant_documentation_get(const Eolian_Constant *var);
|
||||||
lib.eolian_constant_documentation_get.argtypes = (c_void_p,)
|
lib.eolian_constant_documentation_get.argtypes = (c_void_p,)
|
||||||
|
@ -639,7 +653,8 @@ lib.eolian_constant_value_get.restype = c_void_p
|
||||||
lib.eolian_constant_is_extern.argtypes = (c_void_p,)
|
lib.eolian_constant_is_extern.argtypes = (c_void_p,)
|
||||||
lib.eolian_constant_is_extern.restype = c_bool
|
lib.eolian_constant_is_extern.restype = c_bool
|
||||||
|
|
||||||
### Eolian_Documentation ####################################################
|
|
||||||
|
# Eolian_Documentation ######################################################
|
||||||
|
|
||||||
# EAPI Eina_Stringshare *eolian_documentation_summary_get(const Eolian_Documentation *doc);
|
# EAPI Eina_Stringshare *eolian_documentation_summary_get(const Eolian_Documentation *doc);
|
||||||
lib.eolian_documentation_summary_get.argtypes = (c_void_p,)
|
lib.eolian_documentation_summary_get.argtypes = (c_void_p,)
|
||||||
|
@ -677,4 +692,3 @@ lib.eolian_doc_token_text_get.restype = c_void_p # char* TO BE FREED
|
||||||
# EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2);
|
# EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2);
|
||||||
# lib.eolian_doc_token_ref_resolve.argtypes = (c_void_p, c_void_p, ???, ???)
|
# lib.eolian_doc_token_ref_resolve.argtypes = (c_void_p, c_void_p, ???, ???)
|
||||||
# lib.eolian_doc_token_ref_resolve.restype = c_int
|
# lib.eolian_doc_token_ref_resolve.restype = c_int
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ PYTHON_PATH, fe:
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
|
import atexit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import eolian
|
from . import eolian
|
||||||
|
@ -70,11 +71,13 @@ if not eolian_db.all_eot_files_parse():
|
||||||
if not eolian_db.all_eo_files_parse():
|
if not eolian_db.all_eo_files_parse():
|
||||||
raise(RuntimeError('Eolian, failed to parse all EO files'))
|
raise(RuntimeError('Eolian, failed to parse all EO files'))
|
||||||
|
|
||||||
|
|
||||||
# cleanup the database on exit
|
# cleanup the database on exit
|
||||||
import atexit
|
|
||||||
def cleanup_db():
|
def cleanup_db():
|
||||||
global eolian_db
|
global eolian_db
|
||||||
del eolian_db
|
del eolian_db
|
||||||
|
|
||||||
|
|
||||||
atexit.register(cleanup_db)
|
atexit.register(cleanup_db)
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,11 +95,12 @@ class Template(pyratemp.Template):
|
||||||
filename: Template file to load. (REQUIRED)
|
filename: Template file to load. (REQUIRED)
|
||||||
context: User provided context for the template (dict).
|
context: User provided context for the template (dict).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, filename, encoding='utf-8', context=None, escape=None,
|
def __init__(self, filename, encoding='utf-8', context=None, escape=None,
|
||||||
loader_class=pyratemp.LoaderFile,
|
loader_class=pyratemp.LoaderFile,
|
||||||
parser_class=pyratemp.Parser,
|
parser_class=pyratemp.Parser,
|
||||||
renderer_class=pyratemp.Renderer,
|
renderer_class=pyratemp.Renderer,
|
||||||
eval_class=pyratemp.EvalPseudoSandbox):
|
eval_class=pyratemp.EvalPseudoSandbox):
|
||||||
|
|
||||||
# Build the global context for the template
|
# Build the global context for the template
|
||||||
global_ctx = {}
|
global_ctx = {}
|
||||||
|
@ -154,7 +158,7 @@ class Template(pyratemp.Template):
|
||||||
eval_class=eval_class)
|
eval_class=eval_class)
|
||||||
|
|
||||||
def render(self, filename=None, verbose=True, cls=None, ns=None,
|
def render(self, filename=None, verbose=True, cls=None, ns=None,
|
||||||
struct=None, enum=None, alias=None, **kargs):
|
struct=None, enum=None, alias=None, **kargs):
|
||||||
# Build the context for the template
|
# Build the context for the template
|
||||||
ctx = {}
|
ctx = {}
|
||||||
if kargs:
|
if kargs:
|
||||||
|
|
|
@ -99,26 +99,26 @@ class TestEolianUnit(unittest.TestCase):
|
||||||
|
|
||||||
@unittest.skip('Skipped until unit/state support is fixed')
|
@unittest.skip('Skipped until unit/state support is fixed')
|
||||||
def test_children_listing(self):
|
def test_children_listing(self):
|
||||||
l = list(eolian_db.children)
|
li = list(eolian_db.children)
|
||||||
self.assertGreater(len(l), 500)
|
self.assertGreater(len(li), 500)
|
||||||
self.assertIsInstance(l[0], eolian.Eolian_Unit)
|
self.assertIsInstance(li[0], eolian.Eolian_Unit)
|
||||||
|
|
||||||
def test_file_listing(self):
|
def test_file_listing(self):
|
||||||
l = list(eolian_db.eo_file_paths)
|
li = list(eolian_db.eo_file_paths)
|
||||||
self.assertGreater(len(l), 400)
|
self.assertGreater(len(li), 400)
|
||||||
self.assertTrue(l[0].endswith('.eo'))
|
self.assertTrue(li[0].endswith('.eo'))
|
||||||
|
|
||||||
l = list(eolian_db.eo_files)
|
li = list(eolian_db.eo_files)
|
||||||
self.assertGreater(len(l), 400)
|
self.assertGreater(len(li), 400)
|
||||||
self.assertTrue(l[0].endswith('.eo'))
|
self.assertTrue(li[0].endswith('.eo'))
|
||||||
|
|
||||||
l = list(eolian_db.eot_file_paths)
|
li = list(eolian_db.eot_file_paths)
|
||||||
self.assertGreater(len(l), 10)
|
self.assertGreater(len(li), 10)
|
||||||
self.assertTrue(l[0].endswith('.eot'))
|
self.assertTrue(li[0].endswith('.eot'))
|
||||||
|
|
||||||
l = list(eolian_db.eot_files)
|
li = list(eolian_db.eot_files)
|
||||||
self.assertGreater(len(l), 10)
|
self.assertGreater(len(li), 10)
|
||||||
self.assertTrue(l[0].endswith('.eot'))
|
self.assertTrue(li[0].endswith('.eot'))
|
||||||
|
|
||||||
def test_object_listing(self):
|
def test_object_listing(self):
|
||||||
unit = eolian_db.unit_by_file_get('efl_ui_win.eo')
|
unit = eolian_db.unit_by_file_get('efl_ui_win.eo')
|
||||||
|
@ -137,10 +137,10 @@ class TestEolianUnit(unittest.TestCase):
|
||||||
self.assertGreater(count, 5)
|
self.assertGreater(count, 5)
|
||||||
|
|
||||||
def test_enum_listing(self):
|
def test_enum_listing(self):
|
||||||
l = list(eolian_db.enums_by_file_get('efl_ui_win.eo'))
|
li = list(eolian_db.enums_by_file_get('efl_ui_win.eo'))
|
||||||
self.assertGreater(len(l), 5)
|
self.assertGreater(len(li), 5)
|
||||||
self.assertIsInstance(l[0], eolian.Typedecl)
|
self.assertIsInstance(li[0], eolian.Typedecl)
|
||||||
self.assertEqual(l[0].type, eolian.Eolian_Typedecl_Type.ENUM)
|
self.assertEqual(li[0].type, eolian.Eolian_Typedecl_Type.ENUM)
|
||||||
|
|
||||||
all_count = 0
|
all_count = 0
|
||||||
for enum in eolian_db.enums:
|
for enum in eolian_db.enums:
|
||||||
|
@ -150,10 +150,10 @@ class TestEolianUnit(unittest.TestCase):
|
||||||
self.assertGreater(all_count, 50)
|
self.assertGreater(all_count, 50)
|
||||||
|
|
||||||
def test_struct_listing(self):
|
def test_struct_listing(self):
|
||||||
l = list(eolian_db.structs_by_file_get('eina_types.eot'))
|
li = list(eolian_db.structs_by_file_get('eina_types.eot'))
|
||||||
self.assertGreater(len(l), 10)
|
self.assertGreater(len(li), 10)
|
||||||
self.assertIsInstance(l[0], eolian.Typedecl)
|
self.assertIsInstance(li[0], eolian.Typedecl)
|
||||||
self.assertIn(l[0].type, (
|
self.assertIn(li[0].type, (
|
||||||
eolian.Eolian_Typedecl_Type.STRUCT,
|
eolian.Eolian_Typedecl_Type.STRUCT,
|
||||||
eolian.Eolian_Typedecl_Type.STRUCT_OPAQUE))
|
eolian.Eolian_Typedecl_Type.STRUCT_OPAQUE))
|
||||||
|
|
||||||
|
@ -167,27 +167,27 @@ class TestEolianUnit(unittest.TestCase):
|
||||||
self.assertGreater(all_count, 50)
|
self.assertGreater(all_count, 50)
|
||||||
|
|
||||||
def test_alias_listing(self):
|
def test_alias_listing(self):
|
||||||
l = list(eolian_db.aliases_by_file_get('eina_types.eot'))
|
li = list(eolian_db.aliases_by_file_get('eina_types.eot'))
|
||||||
self.assertGreater(len(l), 2)
|
self.assertGreater(len(li), 2)
|
||||||
self.assertIsInstance(l[0], eolian.Typedecl)
|
self.assertIsInstance(li[0], eolian.Typedecl)
|
||||||
|
|
||||||
all_count = 0
|
all_count = 0
|
||||||
for alias in eolian_db.aliases:
|
for alias in eolian_db.aliases:
|
||||||
self.assertIsInstance(alias, eolian.Typedecl)
|
self.assertIsInstance(alias, eolian.Typedecl)
|
||||||
self.assertIn(alias.type, (
|
self.assertIn(alias.type, (
|
||||||
eolian.Eolian_Typedecl_Type.ALIAS,
|
eolian.Eolian_Typedecl_Type.ALIAS,
|
||||||
eolian.Eolian_Typedecl_Type.FUNCTION_POINTER)) # TODO is this correct ??
|
eolian.Eolian_Typedecl_Type.FUNCTION_POINTER)) # TODO is this correct ??
|
||||||
all_count += 1
|
all_count += 1
|
||||||
self.assertGreater(all_count, 10)
|
self.assertGreater(all_count, 10)
|
||||||
|
|
||||||
def test_constant_listing(self):
|
def test_constant_listing(self):
|
||||||
l = list(eolian_db.constants)
|
li = list(eolian_db.constants)
|
||||||
self.assertGreater(len(l), 2)
|
self.assertGreater(len(li), 2)
|
||||||
self.assertIsInstance(l[0], eolian.Constant)
|
self.assertIsInstance(li[0], eolian.Constant)
|
||||||
|
|
||||||
l = list(eolian_db.constants_by_file_get('efl_gfx_stack.eo'))
|
li = list(eolian_db.constants_by_file_get('efl_gfx_stack.eo'))
|
||||||
self.assertGreater(len(l), 1)
|
self.assertGreater(len(li), 1)
|
||||||
self.assertIsInstance(l[0], eolian.Constant)
|
self.assertIsInstance(li[0], eolian.Constant)
|
||||||
|
|
||||||
def test_class_listing(self):
|
def test_class_listing(self):
|
||||||
all_count = 0
|
all_count = 0
|
||||||
|
@ -219,7 +219,7 @@ class TestEolianNamespace(unittest.TestCase):
|
||||||
'Ector.Software.Buffer',
|
'Ector.Software.Buffer',
|
||||||
'Eio.Sentry',
|
'Eio.Sentry',
|
||||||
'Eldbus.Model',
|
'Eldbus.Model',
|
||||||
]
|
]
|
||||||
for ns in eolian_db.all_namespaces:
|
for ns in eolian_db.all_namespaces:
|
||||||
cls = eolian_db.class_by_name_get(ns.name)
|
cls = eolian_db.class_by_name_get(ns.name)
|
||||||
# Some legacy classes are parsed and still make this fail.
|
# Some legacy classes are parsed and still make this fail.
|
||||||
|
@ -344,8 +344,8 @@ class TestEolianClass(unittest.TestCase):
|
||||||
self.assertEqual(cls.c_get_function_name, 'efl_loop_timer_class_get')
|
self.assertEqual(cls.c_get_function_name, 'efl_loop_timer_class_get')
|
||||||
self.assertEqual(cls.c_macro, 'EFL_LOOP_TIMER_CLASS')
|
self.assertEqual(cls.c_macro, 'EFL_LOOP_TIMER_CLASS')
|
||||||
self.assertEqual(cls.c_data_type, 'Efl_Loop_Timer_Data')
|
self.assertEqual(cls.c_data_type, 'Efl_Loop_Timer_Data')
|
||||||
self.assertEqual([f.name for f in cls.methods], ['timer_reset','timer_loop_reset','timer_delay'])
|
self.assertEqual([f.name for f in cls.methods], ['timer_reset', 'timer_loop_reset', 'timer_delay'])
|
||||||
self.assertEqual([f.name for f in cls.properties], ['timer_interval','time_pending'])
|
self.assertEqual([f.name for f in cls.properties], ['timer_interval', 'time_pending'])
|
||||||
self.assertGreater(len(list(cls.implements)), 5)
|
self.assertGreater(len(list(cls.implements)), 5)
|
||||||
self.assertIsInstance(list(cls.implements)[0], eolian.Implement)
|
self.assertIsInstance(list(cls.implements)[0], eolian.Implement)
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ class TestEolianImplement(unittest.TestCase):
|
||||||
self.assertEqual(im.name, 'Efl.Loop_Timer.timer_delay')
|
self.assertEqual(im.name, 'Efl.Loop_Timer.timer_delay')
|
||||||
self.assertIsInstance(im.class_, eolian.Class)
|
self.assertIsInstance(im.class_, eolian.Class)
|
||||||
self.assertIsInstance(im.function, eolian.Function)
|
self.assertIsInstance(im.function, eolian.Function)
|
||||||
self.assertIsInstance(im.documentation_get(), eolian.Documentation) # TODO is UNRESOLVED correct ?
|
self.assertIsInstance(im.documentation_get(), eolian.Documentation) # TODO is UNRESOLVED correct ?
|
||||||
self.assertFalse(im.is_auto())
|
self.assertFalse(im.is_auto())
|
||||||
self.assertFalse(im.is_empty())
|
self.assertFalse(im.is_empty())
|
||||||
self.assertFalse(im.is_pure_virtual())
|
self.assertFalse(im.is_pure_virtual())
|
||||||
|
@ -473,7 +473,7 @@ class TestEolianConstant(unittest.TestCase):
|
||||||
self.assertEqual(var.short_name, 'Hint_Expand')
|
self.assertEqual(var.short_name, 'Hint_Expand')
|
||||||
self.assertEqual(var.file, 'efl_gfx_hint.eo')
|
self.assertEqual(var.file, 'efl_gfx_hint.eo')
|
||||||
self.assertFalse(var.is_extern)
|
self.assertFalse(var.is_extern)
|
||||||
self.assertEqual(list(var.namespaces), ['Efl','Gfx'])
|
self.assertEqual(list(var.namespaces), ['Efl', 'Gfx'])
|
||||||
self.assertIsInstance(var.documentation, eolian.Documentation)
|
self.assertIsInstance(var.documentation, eolian.Documentation)
|
||||||
self.assertIsInstance(var.type, eolian.Type)
|
self.assertIsInstance(var.type, eolian.Type)
|
||||||
self.assertIsInstance(var.value, eolian.Expression)
|
self.assertIsInstance(var.value, eolian.Expression)
|
||||||
|
@ -487,7 +487,7 @@ class TestEolianTypedecl(unittest.TestCase):
|
||||||
self.assertEqual(td.name, 'Efl.Net.Http.Version')
|
self.assertEqual(td.name, 'Efl.Net.Http.Version')
|
||||||
self.assertEqual(td.short_name, 'Version')
|
self.assertEqual(td.short_name, 'Version')
|
||||||
self.assertEqual(td.file, 'efl_net_http_types.eot')
|
self.assertEqual(td.file, 'efl_net_http_types.eot')
|
||||||
self.assertEqual(list(td.namespaces), ['Efl','Net','Http'])
|
self.assertEqual(list(td.namespaces), ['Efl', 'Net', 'Http'])
|
||||||
self.assertIsInstance(td.documentation, eolian.Documentation)
|
self.assertIsInstance(td.documentation, eolian.Documentation)
|
||||||
self.assertIsNone(td.base_type) # TODO find a better test
|
self.assertIsNone(td.base_type) # TODO find a better test
|
||||||
self.assertIsNone(td.free_func) # TODO find a better test
|
self.assertIsNone(td.free_func) # TODO find a better test
|
||||||
|
@ -511,7 +511,7 @@ class TestEolianTypedecl(unittest.TestCase):
|
||||||
self.assertEqual(td.name, 'Efl.Gfx.Color32')
|
self.assertEqual(td.name, 'Efl.Gfx.Color32')
|
||||||
self.assertEqual(td.short_name, 'Color32')
|
self.assertEqual(td.short_name, 'Color32')
|
||||||
self.assertEqual(td.file, 'efl_canvas_filter_internal.eo')
|
self.assertEqual(td.file, 'efl_canvas_filter_internal.eo')
|
||||||
self.assertEqual(list(td.namespaces), ['Efl','Gfx'])
|
self.assertEqual(list(td.namespaces), ['Efl', 'Gfx'])
|
||||||
self.assertIsInstance(td.documentation, eolian.Documentation)
|
self.assertIsInstance(td.documentation, eolian.Documentation)
|
||||||
self.assertIsNone(td.base_type) # TODO find a better test
|
self.assertIsNone(td.base_type) # TODO find a better test
|
||||||
self.assertIsNone(td.free_func) # TODO find a better test
|
self.assertIsNone(td.free_func) # TODO find a better test
|
||||||
|
@ -544,13 +544,13 @@ class TestEolianType(unittest.TestCase):
|
||||||
cls = eolian_db.class_by_name_get('Efl.Loop_Timer')
|
cls = eolian_db.class_by_name_get('Efl.Loop_Timer')
|
||||||
func = cls.function_by_name_get('timer_delay')
|
func = cls.function_by_name_get('timer_delay')
|
||||||
param = list(func.parameters)[0]
|
param = list(func.parameters)[0]
|
||||||
t = param.type # type: double
|
t = param.type # type double
|
||||||
self.assertIsInstance(t, eolian.Type)
|
self.assertIsInstance(t, eolian.Type)
|
||||||
self.assertEqual(t.name, 'double')
|
self.assertEqual(t.name, 'double')
|
||||||
self.assertEqual(t.short_name, 'double')
|
self.assertEqual(t.short_name, 'double')
|
||||||
self.assertEqual(t.type, eolian.Eolian_Type_Type.REGULAR)
|
self.assertEqual(t.type, eolian.Eolian_Type_Type.REGULAR)
|
||||||
self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.DOUBLE)
|
self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.DOUBLE)
|
||||||
self.assertEqual(t.file, 'efl_loop_timer.eo') # TODO is this correct ?
|
self.assertEqual(t.file, 'efl_loop_timer.eo') # TODO is this correct ?
|
||||||
self.assertIsNone(t.base_type) # TODO find a better test
|
self.assertIsNone(t.base_type) # TODO find a better test
|
||||||
self.assertIsNone(t.next_type) # TODO find a better test
|
self.assertIsNone(t.next_type) # TODO find a better test
|
||||||
self.assertFalse(t.is_const)
|
self.assertFalse(t.is_const)
|
||||||
|
@ -563,7 +563,7 @@ class TestEolianType(unittest.TestCase):
|
||||||
cls = eolian_db.class_by_name_get('Efl.Gfx.Entity')
|
cls = eolian_db.class_by_name_get('Efl.Gfx.Entity')
|
||||||
func = cls.function_by_name_get('geometry')
|
func = cls.function_by_name_get('geometry')
|
||||||
param = list(func.setter_values)[0]
|
param = list(func.setter_values)[0]
|
||||||
t = param.type # type: Eina.Rect
|
t = param.type # type Eina.Rect
|
||||||
self.assertIsInstance(t, eolian.Type)
|
self.assertIsInstance(t, eolian.Type)
|
||||||
self.assertEqual(t.name, 'Eina.Rect')
|
self.assertEqual(t.name, 'Eina.Rect')
|
||||||
self.assertEqual(t.short_name, 'Rect')
|
self.assertEqual(t.short_name, 'Rect')
|
||||||
|
@ -582,7 +582,7 @@ class TestEolianType(unittest.TestCase):
|
||||||
cls = eolian_db.class_by_name_get('Efl.Content')
|
cls = eolian_db.class_by_name_get('Efl.Content')
|
||||||
func = cls.function_by_name_get('content')
|
func = cls.function_by_name_get('content')
|
||||||
param = list(func.setter_values)[0]
|
param = list(func.setter_values)[0]
|
||||||
t = param.type # type: Efl.Gfx (class interface)
|
t = param.type # type Efl.Gfx (class interface)
|
||||||
self.assertIsInstance(t, eolian.Type)
|
self.assertIsInstance(t, eolian.Type)
|
||||||
self.assertEqual(t.name, 'Efl.Gfx.Entity')
|
self.assertEqual(t.name, 'Efl.Gfx.Entity')
|
||||||
self.assertEqual(t.short_name, 'Entity')
|
self.assertEqual(t.short_name, 'Entity')
|
||||||
|
@ -612,11 +612,11 @@ class TestEolianExpression(unittest.TestCase):
|
||||||
self.assertIsInstance(exp, eolian.Expression)
|
self.assertIsInstance(exp, eolian.Expression)
|
||||||
self.assertEqual(exp.type, eolian.Eolian_Expression_Type.UNARY)
|
self.assertEqual(exp.type, eolian.Eolian_Expression_Type.UNARY)
|
||||||
self.assertEqual(float(exp.serialize), 32768.0) # TODO is this a bug? isn't -1.0 ?
|
self.assertEqual(float(exp.serialize), 32768.0) # TODO is this a bug? isn't -1.0 ?
|
||||||
self.assertEqual(exp.unary_operator, eolian.Eolian_Unary_Operator.UNM) # Invalid -> NOP
|
self.assertEqual(exp.unary_operator, eolian.Eolian_Unary_Operator.UNM) # Invalid -> NOP
|
||||||
unary = exp.unary_expression
|
unary = exp.unary_expression
|
||||||
self.assertIsInstance(unary, eolian.Expression)
|
self.assertIsInstance(unary, eolian.Expression)
|
||||||
self.assertEqual(unary.type, eolian.Eolian_Expression_Type.INT)
|
self.assertEqual(unary.type, eolian.Eolian_Expression_Type.INT)
|
||||||
self.assertEqual(float(exp.serialize), 32768.0) # Bug too?
|
self.assertEqual(float(exp.serialize), 32768.0) # Bug too?
|
||||||
|
|
||||||
# TODO test_expression_binary
|
# TODO test_expression_binary
|
||||||
# exp.binary_operator # TODO find a better test (only works for BINARY expr)
|
# exp.binary_operator # TODO find a better test (only works for BINARY expr)
|
||||||
|
@ -624,7 +624,6 @@ class TestEolianExpression(unittest.TestCase):
|
||||||
# exp.binary_rhs # TODO find a better test (only works for BINARY expr)
|
# exp.binary_rhs # TODO find a better test (only works for BINARY expr)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# create main eolian state
|
# create main eolian state
|
||||||
eolian_db = eolian.Eolian_State()
|
eolian_db = eolian.Eolian_State()
|
||||||
|
|
Loading…
Reference in New Issue