diff --git a/efl/eolian/__init__.pyx b/efl/eolian/__init__.pyx index ddc11f8..7ea9642 100644 --- a/efl/eolian/__init__.pyx +++ b/efl/eolian/__init__.pyx @@ -1,6 +1,7 @@ from libc.stdint cimport uintptr_t from cpython cimport PyUnicode_AsUTF8String +from efl.eina cimport eina_inlist_count from efl.utils.conversions cimport _ctouni, eina_list_strings_to_python_list from efl.utils.enum import IntEnum @@ -675,14 +676,26 @@ cdef class FunctionParameter(object): cdef class Type(object): + """A type iterator + + An Eolian type is an inlist of basic C types. For example: + ``Eina_List * `` contains two basic types. + The first Eolian type of the list stores ``Eina_List *``, the next one + ``Eo *``. + + :return: C type, ownership + (indicates if the ownership has to pass to the caller/callee.) + :rtype: (string, bool) + + """ cdef Eolian_Type etype cdef _set_obj(self, Eolian_Type obj): self.etype = obj - def __init__(self): - pass + def __iter__(self): + return self def __next__(self): cdef: @@ -690,42 +703,19 @@ cdef class Type(object): Eina_Bool own Eolian_Type etype + if self.etype == NULL: + raise StopIteration + etype = eolian_type_information_get( self.etype, &type, &own ) - if etype == NULL: - raise StopIteration self.etype = etype return _ctouni(type), bool(own) - property information: - """Get information on given type. + def __len__(self): + return eina_inlist_count(self.etype) - An Eolian type is an inlist of basic C types. For example: - ``Eina_List * `` contains two basic types. - The first Eolian type of the list stores ``Eina_List *``, the next one - ``Eo *``. - - :return: C type, ownership - (indicates if the ownership has to pass to the caller/callee.) - :rtype: (string, bool) - - """ - def __get__(self): - cdef: - const char *type - Eina_Bool own - Eolian_Type etype - - etype = eolian_type_information_get( - self.etype, &type, &own - ) - if etype == NULL: - return None - - self.etype = etype - return _ctouni(type), bool(own) cdef class Implement(object): diff --git a/include/efl.eina.pxd b/include/efl.eina.pxd index 5a1c057..6c16eba 100644 --- a/include/efl.eina.pxd +++ b/include/efl.eina.pxd @@ -190,3 +190,5 @@ cdef extern from "Eina.h": void EINA_LOG_DOM_WARN(int DOM, const char *fmt, ...) void EINA_LOG_DOM_INFO(int DOM, const char *fmt, ...) void EINA_LOG_DOM_DBG(int DOM, const char *fmt, ...) + + unsigned int eina_inlist_count(const Eina_Inlist *list)