Eolian: Make Type its own iterator
This commit is contained in:
parent
10c60e812b
commit
3d196ef231
|
@ -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 * <Eo *>`` 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 * <Eo *>`` 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):
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue