diff --git a/eolian/__init__.pxd b/eolian/__init__.pxd index 8ca4bb8..dc97748 100644 --- a/eolian/__init__.pxd +++ b/eolian/__init__.pxd @@ -33,7 +33,6 @@ cdef extern from "Eolian.h": EOLIAN_TYPE_REGULAR_ENUM EOLIAN_TYPE_COMPLEX EOLIAN_TYPE_POINTER - EOLIAN_TYPE_FUNCTION EOLIAN_TYPE_STRUCT EOLIAN_TYPE_STRUCT_OPAQUE EOLIAN_TYPE_ENUM @@ -174,16 +173,12 @@ cdef extern from "Eolian.h": ctypedef _Eolian_Value Eolian_Value - #define EOLIAN_LEGACY "legacy" - #define EOLIAN_LEGACY_GET "legacy_get" - #define EOLIAN_LEGACY_SET "legacy_set" - #define EOLIAN_COMMENT "comment" - #define EOLIAN_COMMENT_SET "comment_set" - #define EOLIAN_COMMENT_GET "comment_get" - - Eina_Bool eolian_eo_file_parse(const char *filename) Eina_Bool eolian_eot_file_parse(const char *filepath) + Eina_Iterator *eolian_all_eo_file_paths_get() + Eina_Iterator *eolian_all_eot_file_paths_get() + Eina_Iterator *eolian_all_eo_files_get() + Eina_Iterator *eolian_all_eot_files_get() int eolian_init() int eolian_shutdown() Eina_Bool eolian_directory_scan(const char *dir) @@ -224,6 +219,7 @@ cdef extern from "Eolian.h": Eina_Bool eolian_function_is_empty(const Eolian_Function *function_id, Eolian_Function_Type f_type) Eina_Bool eolian_function_is_legacy_only(const Eolian_Function *function_id, Eolian_Function_Type ftype) Eina_Bool eolian_function_is_class(const Eolian_Function *function_id) + Eina_Bool eolian_function_is_c_only(const Eolian_Function *function_id) Eina_Bool eolian_function_is_constructor(const Eolian_Function *function_id, const Eolian_Class *klass) const Eolian_Function_Parameter *eolian_function_parameter_get_by_name(const Eolian_Function *function_id, const char *param_name) Eina_Iterator *eolian_function_parameters_get(const Eolian_Function *function_id) @@ -236,11 +232,15 @@ cdef extern from "Eolian.h": Eina_Stringshare *eolian_parameter_description_get(const Eolian_Function_Parameter *param) Eina_Bool eolian_parameter_const_attribute_get(const Eolian_Function_Parameter *param_desc, Eina_Bool is_get) Eina_Bool eolian_parameter_is_nonull(const Eolian_Function_Parameter *param_desc) + Eina_Bool eolian_parameter_is_nullable(const Eolian_Function_Parameter *param_desc) + Eina_Bool eolian_parameter_is_optional(const Eolian_Function_Parameter *param_desc) const Eolian_Type *eolian_function_return_type_get(const Eolian_Function *function_id, Eolian_Function_Type ftype) const Eolian_Expression *eolian_function_return_default_value_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype) Eina_Stringshare *eolian_function_return_comment_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype) Eina_Bool eolian_function_return_is_warn_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype) Eina_Bool eolian_function_object_is_const(const Eolian_Function *function_id) + const Eolian_Class *eolian_function_class_get(const Eolian_Function *function_id) + Eina_Bool eolian_function_is_implemented(const Eolian_Function *function_id, Eolian_Function_Type func_type, const Eolian_Class *klass) Eina_Stringshare *eolian_implement_full_name_get(const Eolian_Implement *impl) const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl) const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type) @@ -253,6 +253,7 @@ cdef extern from "Eolian.h": Eina_Stringshare *eolian_constructor_full_name_get(const Eolian_Constructor *ctor) const Eolian_Class *eolian_constructor_class_get(const Eolian_Constructor *ctor) const Eolian_Function *eolian_constructor_function_get(const Eolian_Constructor *ctor) + Eina_Bool eolian_constructor_is_optional(const Eolian_Constructor *ctor) Eina_Iterator *eolian_class_constructors_get(const Eolian_Class *klass) Eina_Iterator *eolian_class_events_get(const Eolian_Class *klass) Eina_Stringshare *eolian_event_name_get(const Eolian_Event *event) @@ -270,7 +271,6 @@ cdef extern from "Eolian.h": Eina_Iterator *eolian_type_structs_get_by_file(const char *fname) Eina_Iterator *eolian_type_enums_get_by_file(const char *fname) Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp) - Eina_Iterator *eolian_type_arguments_get(const Eolian_Type *tp) Eina_Iterator *eolian_type_subtypes_get(const Eolian_Type *tp) Eina_Iterator *eolian_type_struct_fields_get(const Eolian_Type *tp) const Eolian_Struct_Type_Field *eolian_type_struct_field_get(const Eolian_Type *tp, const char *field) @@ -285,7 +285,6 @@ cdef extern from "Eolian.h": Eina_Stringshare *eolian_type_enum_legacy_prefix_get(const Eolian_Type *tp) Eina_Stringshare *eolian_type_description_get(const Eolian_Type *tp) Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp) - const Eolian_Type *eolian_type_return_type_get(const Eolian_Type *tp) const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp) const Eolian_Class *eolian_type_class_get(const Eolian_Type *tp) Eina_Bool eolian_type_is_own(const Eolian_Type *tp) diff --git a/eolian/__init__.pyx b/eolian/__init__.pyx index 202171d..53da3d1 100644 --- a/eolian/__init__.pyx +++ b/eolian/__init__.pyx @@ -58,7 +58,6 @@ class TypeType(IntEnum): REGULAR_ENUM = EOLIAN_TYPE_REGULAR_ENUM COMPLEX = EOLIAN_TYPE_COMPLEX POINTER = EOLIAN_TYPE_POINTER - FUNCTION = EOLIAN_TYPE_FUNCTION STRUCT = EOLIAN_TYPE_STRUCT STRUCT_OPAQUE = EOLIAN_TYPE_STRUCT_OPAQUE ENUM = EOLIAN_TYPE_ENUM @@ -321,6 +320,42 @@ def eot_file_parse(filename): EINA_LOG_DOM_WARN(EOLIAN_DOM, "Failure in eot_file_parse()", NULL) return ret +def all_eo_file_paths_get(): + """Get an iterator to all .eo file names with paths. + + :rtype: EinaIterator + """ + cdef EinaIterator ret = EinaIterator(unicode) + ret._set_obj(eolian_all_eo_file_paths_get()) + return ret + +def all_eot_file_paths_get(): + """Get an iterator to all .eot file names with paths. + + :rtype: EinaIterator + """ + cdef EinaIterator ret = EinaIterator(unicode) + ret._set_obj(eolian_all_eot_file_paths_get()) + return ret + +def all_eo_files_get(): + """Get an iterator to all .eo file names (without paths). + + :rtype: EinaIterator + """ + cdef EinaIterator ret = EinaIterator(unicode) + ret._set_obj(eolian_all_eo_files_get()) + return ret + +def all_eot_files_get(): + """Get an iterator to all .eot file names (without paths). + + :rtype: EinaIterator + """ + cdef EinaIterator ret = EinaIterator(unicode) + ret._set_obj(eolian_all_eot_files_get()) + return ret + def init(): """Init Eolian. @@ -467,13 +502,6 @@ def show_enum(name): :return: True on success, False otherwise (when enum is not found). - @see eolian_show_class - @see eolian_show_typedef - @see eolian_show_struct - @see eolian_show_global - @see eolian_show_constant - @see eolian_show_all - """ if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name) cdef bint ret = eolian_show_enum( @@ -494,13 +522,6 @@ def show_global(name): :return: True on success, False otherwise (when global is not found). - @see eolian_show_class - @see eolian_show_typedef - @see eolian_show_struct - @see eolian_show_enum - @see eolian_show_constant - @see eolian_show_all - """ if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name) cdef bint ret = eolian_show_global( @@ -521,13 +542,6 @@ def show_constant(name): :return: True on success, False otherwise (when constant is not found). - @see eolian_show_class - @see eolian_show_typedef - @see eolian_show_struct - @see eolian_show_enum - @see eolian_show_global - @see eolian_show_all - """ if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name) cdef bint ret = eolian_show_constant( @@ -1073,6 +1087,16 @@ cdef class Function(object): def __get__(self): return bool(eolian_function_is_class(self.function_id)) + property is_c_only: + """Get whether a function is C only (i.e. not bindable). + + @param[in] function_id Id of the function + @return EINA_TRUE and EINA_FALSE respectively + + """ + def __get__(self): + return bool(eolian_function_is_c_only(self.function_id)) + def is_constructor(self, Class klass): """Indicates if a function is a constructing function of a given class. @@ -1206,6 +1230,27 @@ cdef class Function(object): def __get__(self): return bool(eolian_function_object_is_const(self.function_id)) + property klass: + """Return the Eolian class associated to the function. + + @param[in] function_id id of the function + @return the class, NULL otherwise + + """ + def __get__(self): + return eolian_class_to_python_obj(eolian_function_class_get(self.function_id)) + + def is_implemented(self, Eolian_Function_Type f_type, Class klass): + """Determine if a function is implemented in the inheritance of the given class + + @param[in] function_id id of the function + @param[in] func_type type requested + @param[in] klass the top class to begin with + @return EINA_TRUE if found, EINA_FALSE otherwise + + """ + return bool(eolian_function_is_implemented(self.function_id, f_type, klass.klass)) + cdef class FunctionParameter(object): @@ -1296,6 +1341,25 @@ cdef class FunctionParameter(object): def __get__(self): return bool(eolian_parameter_is_nonull(self.param)) + property is_nullable: + """Indicates if a parameter is nullable. + + @param[in] param_desc parameter handle + @return EINA_TRUE if nullable, EINA_FALSE otherwise + + """ + def __get__(self): + return bool(eolian_parameter_is_nullable(self.param)) + + property is_optional: + """Indicates if a parameter is optional. + + @param[in] param_desc parameter handle + @return EINA_TRUE if optional, EINA_FALSE otherwise + + """ + def __get__(self): + return bool(eolian_parameter_is_optional(self.param)) cdef class Implement(object): @@ -1438,6 +1502,15 @@ cdef class Constructor(object): def __get__(self): return eolian_func_to_python_obj(eolian_constructor_function_get(self.ctor)) + property is_optional: + """Checks if a constructor is tagged optional. + + :type: bool + + """ + def __get__(self): + return bool(eolian_constructor_is_optional(self.ctor)) + cdef class Event(object): @@ -1540,7 +1613,7 @@ cdef class Type(object): """ cdef: Type ret = cls.__new__(cls) - Eolian_Type *obj + const Eolian_Type *obj if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name) obj = eolian_type_alias_get_by_name(name) if obj == NULL: @@ -1558,7 +1631,7 @@ cdef class Type(object): """ cdef: Type ret = cls.__new__(cls) - Eolian_Type *obj + const Eolian_Type *obj if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name) obj = eolian_type_struct_get_by_name(name) if obj == NULL: @@ -1576,17 +1649,6 @@ cdef class Type(object): def __get__(self): return TypeType(eolian_type_type_get(self.tp)) - property arguments: - """Get an iterator to all arguments of a function type. - - :return: the iterator when ``tp`` is an EOLIAN_TYPE_FUNCTION, None otherwise. - - """ - def __get__(self): - cdef EinaIterator ret = EinaIterator(Type) - ret._set_obj(eolian_type_arguments_get(self.tp)) - return ret - property subtypes: """Get an iterator to all subtypes of a type. @@ -1678,15 +1740,6 @@ cdef class Type(object): def __get__(self): return _ctouni(eolian_type_file_get(self.tp)) - property return_type: - """Get the return type of a function type. - - :return: the return type when ``tp`` is an EOLIAN_TYPE_FUNCTION, None otherwise. - - """ - def __get__(self): - return eolian_type_to_python_obj(eolian_type_return_type_get(self.tp)) - property base_type: """Get the base type of a pointer or alias type.