Eolian: Use IntEnum for enumerations
This commit is contained in:
parent
db8f8ff2f6
commit
a4fa686a27
|
@ -1,8 +1,30 @@
|
|||
from efl.eina cimport Eina_Inlist, Eina_Bool, Eina_List, Eina_Stringshare
|
||||
from enums cimport Eolian_Function_Type, Eolian_Parameter_Dir, \
|
||||
Eolian_Class_Type, Eolian_Function_Scope
|
||||
|
||||
cdef extern from "Eolian.h":
|
||||
ctypedef enum Eolian_Function_Type:
|
||||
EOLIAN_UNRESOLVED
|
||||
EOLIAN_PROPERTY
|
||||
EOLIAN_PROP_SET
|
||||
EOLIAN_PROP_GET
|
||||
EOLIAN_METHOD
|
||||
EOLIAN_CTOR
|
||||
|
||||
ctypedef enum Eolian_Parameter_Dir:
|
||||
EOLIAN_IN_PARAM
|
||||
EOLIAN_OUT_PARAM
|
||||
EOLIAN_INOUT_PARAM
|
||||
|
||||
ctypedef enum Eolian_Class_Type:
|
||||
EOLIAN_CLASS_UNKNOWN_TYPE
|
||||
EOLIAN_CLASS_REGULAR
|
||||
EOLIAN_CLASS_ABSTRACT
|
||||
EOLIAN_CLASS_MIXIN
|
||||
EOLIAN_CLASS_INTERFACE
|
||||
|
||||
ctypedef enum Eolian_Function_Scope:
|
||||
EOLIAN_SCOPE_PUBLIC
|
||||
EOLIAN_SCOPE_PROTECTED
|
||||
|
||||
#Class type used to extract information on classes
|
||||
ctypedef struct _Class_Desc
|
||||
ctypedef _Class_Desc* Eolian_Class
|
||||
|
|
|
@ -51,28 +51,32 @@ Function Scope
|
|||
from libc.stdint cimport uintptr_t
|
||||
from cpython cimport PyUnicode_AsUTF8String
|
||||
from efl.utils.conversions cimport _ctouni, eina_list_strings_to_python_list
|
||||
cimport enums
|
||||
|
||||
from efl.utils.enum import IntEnum
|
||||
|
||||
EOLIAN_UNRESOLVED = enums.EOLIAN_UNRESOLVED
|
||||
EOLIAN_PROPERTY = enums.EOLIAN_PROPERTY
|
||||
EOLIAN_PROP_SET = enums.EOLIAN_PROP_SET
|
||||
EOLIAN_PROP_GET = enums.EOLIAN_PROP_GET
|
||||
EOLIAN_METHOD = enums.EOLIAN_METHOD
|
||||
EOLIAN_CTOR = enums.EOLIAN_CTOR
|
||||
class FunctionType(IntEnum):
|
||||
UNRESOLVED = EOLIAN_UNRESOLVED
|
||||
PROPERTY = EOLIAN_PROPERTY
|
||||
PROP_SET = EOLIAN_PROP_SET
|
||||
PROP_GET = EOLIAN_PROP_GET
|
||||
METHOD = EOLIAN_METHOD
|
||||
CTOR = EOLIAN_CTOR
|
||||
|
||||
EOLIAN_IN_PARAM = enums.EOLIAN_IN_PARAM
|
||||
EOLIAN_OUT_PARAM = enums.EOLIAN_OUT_PARAM
|
||||
EOLIAN_INOUT_PARAM = enums.EOLIAN_INOUT_PARAM
|
||||
class ParameterDir(IntEnum):
|
||||
IN_PARAM = EOLIAN_IN_PARAM
|
||||
OUT_PARAM = EOLIAN_OUT_PARAM
|
||||
INOUT_PARAM = EOLIAN_INOUT_PARAM
|
||||
|
||||
EOLIAN_CLASS_UNKNOWN_TYPE = enums.EOLIAN_CLASS_UNKNOWN_TYPE
|
||||
EOLIAN_CLASS_REGULAR = enums.EOLIAN_CLASS_REGULAR
|
||||
EOLIAN_CLASS_ABSTRACT = enums.EOLIAN_CLASS_ABSTRACT
|
||||
EOLIAN_CLASS_MIXIN = enums.EOLIAN_CLASS_MIXIN
|
||||
EOLIAN_CLASS_INTERFACE = enums.EOLIAN_CLASS_INTERFACE
|
||||
class ClassType(IntEnum):
|
||||
UNKNOWN = EOLIAN_CLASS_UNKNOWN_TYPE
|
||||
REGULAR = EOLIAN_CLASS_REGULAR
|
||||
ABSTRACT = EOLIAN_CLASS_ABSTRACT
|
||||
MIXIN = EOLIAN_CLASS_MIXIN
|
||||
INTERFACE = EOLIAN_CLASS_INTERFACE
|
||||
|
||||
EOLIAN_SCOPE_PUBLIC = enums.EOLIAN_SCOPE_PUBLIC
|
||||
EOLIAN_SCOPE_PROTECTED = enums.EOLIAN_SCOPE_PROTECTED
|
||||
class FunctionScope(IntEnum):
|
||||
PUBLIC = EOLIAN_SCOPE_PUBLIC
|
||||
PROTECTED = EOLIAN_SCOPE_PROTECTED
|
||||
|
||||
|
||||
cdef list eina_list_obj_to_python_list(const Eina_List *lst, type cls):
|
||||
|
@ -232,6 +236,13 @@ cdef class Class(object):
|
|||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return (
|
||||
"<%s (full_name=%s, filename=%s, type=%s, description=%s)>" % (
|
||||
self.name, self.full_name, self.filename,
|
||||
self.type, self.description
|
||||
))
|
||||
|
||||
property filename:
|
||||
"""Returns the name of the file containing the given class.
|
||||
|
||||
|
@ -280,7 +291,7 @@ cdef class Class(object):
|
|||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eolian_class_type_get(self.klass)
|
||||
return ClassType(eolian_class_type_get(self.klass))
|
||||
|
||||
property description:
|
||||
"""Returns the description of a class.
|
||||
|
@ -424,6 +435,12 @@ cdef class Function(object):
|
|||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return (
|
||||
"<%s (type=%s, scope=%s, is_const=%r)>" % (
|
||||
self.name, self.type, self.scope, self.object_is_const,
|
||||
))
|
||||
|
||||
property type:
|
||||
"""Returns the type of a function
|
||||
|
||||
|
@ -431,7 +448,7 @@ cdef class Function(object):
|
|||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eolian_function_type_get(self.function_id)
|
||||
return FunctionType(eolian_function_type_get(self.function_id))
|
||||
|
||||
property scope:
|
||||
"""Returns the scope of a function
|
||||
|
@ -440,7 +457,7 @@ cdef class Function(object):
|
|||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eolian_function_scope_get(self.function_id)
|
||||
return FunctionScope(eolian_function_scope_get(self.function_id))
|
||||
|
||||
property name:
|
||||
"""Returns the name of a function
|
||||
|
@ -618,6 +635,13 @@ cdef class FunctionParameter(object):
|
|||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
info = self.information
|
||||
return (
|
||||
"<%s (type=%s, direction=%s, is_nonull=%r)>" % (
|
||||
info[2], info[1], info[0], self.is_nonull,
|
||||
))
|
||||
|
||||
property information:
|
||||
"""Get information about a function parameter
|
||||
|
||||
|
@ -635,7 +659,8 @@ cdef class FunctionParameter(object):
|
|||
self.param, ¶m_dir, &type, &name, &description
|
||||
)
|
||||
return (
|
||||
param_dir, _ctouni(type), _ctouni(name), _ctouni(description)
|
||||
ParameterDir(param_dir), _ctouni(type), _ctouni(name),
|
||||
_ctouni(description)
|
||||
)
|
||||
|
||||
property type:
|
||||
|
@ -753,6 +778,15 @@ cdef class Implement(object):
|
|||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
info = self.information
|
||||
if not info:
|
||||
info = (None, None, None)
|
||||
return (
|
||||
"<%s (class=%r, function=%r, type=%r)>" % (
|
||||
self.full_name, info[0], info[1], info[2],
|
||||
))
|
||||
|
||||
property full_name:
|
||||
"""Get full string of an overriding function (implement).
|
||||
|
||||
|
@ -767,7 +801,6 @@ cdef class Implement(object):
|
|||
|
||||
:type: overridden :py:class:`Class`, overridden :py:func:`Function`,
|
||||
overridden :ref:`Eolian_Function_Type`
|
||||
:raise RuntimeError: on failure
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
|
@ -780,12 +813,12 @@ cdef class Implement(object):
|
|||
&function,
|
||||
&type
|
||||
):
|
||||
raise RuntimeError("Could not fetch information")
|
||||
return None
|
||||
|
||||
return (
|
||||
eolian_class_to_python_obj(klass),
|
||||
eolian_func_to_python_obj(function),
|
||||
type
|
||||
FunctionType(type)
|
||||
)
|
||||
|
||||
|
||||
|
@ -799,12 +832,21 @@ cdef class Event(object):
|
|||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
info = self.information
|
||||
if info:
|
||||
return (
|
||||
"<%s (type=%s, description=%s)>" % (
|
||||
info[0], info[1], info[2]
|
||||
))
|
||||
else:
|
||||
return "<Event>"
|
||||
|
||||
property information:
|
||||
"""Get information about an event.
|
||||
|
||||
:type: name of the event (string), type of the event (string),
|
||||
description of the event (string)
|
||||
:raise RuntimeError: on failure
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
|
@ -816,9 +858,11 @@ cdef class Event(object):
|
|||
if not eolian_class_event_information_get(
|
||||
self.event, &event_name, &event_type, &event_desc
|
||||
):
|
||||
raise RuntimeError("could not fetch event information")
|
||||
return None
|
||||
|
||||
return (event_name, event_type, event_desc)
|
||||
return (
|
||||
_ctouni(event_name), _ctouni(event_type), _ctouni(event_desc)
|
||||
)
|
||||
|
||||
|
||||
def type_find_by_alias(alias):
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
cdef extern from "Eolian.h":
|
||||
ctypedef enum Eolian_Function_Type:
|
||||
EOLIAN_UNRESOLVED
|
||||
EOLIAN_PROPERTY
|
||||
EOLIAN_PROP_SET
|
||||
EOLIAN_PROP_GET
|
||||
EOLIAN_METHOD
|
||||
EOLIAN_CTOR
|
||||
|
||||
ctypedef enum Eolian_Parameter_Dir:
|
||||
EOLIAN_IN_PARAM
|
||||
EOLIAN_OUT_PARAM
|
||||
EOLIAN_INOUT_PARAM
|
||||
|
||||
ctypedef enum Eolian_Class_Type:
|
||||
EOLIAN_CLASS_UNKNOWN_TYPE
|
||||
EOLIAN_CLASS_REGULAR
|
||||
EOLIAN_CLASS_ABSTRACT
|
||||
EOLIAN_CLASS_MIXIN
|
||||
EOLIAN_CLASS_INTERFACE
|
||||
|
||||
ctypedef enum Eolian_Function_Scope:
|
||||
EOLIAN_SCOPE_PUBLIC
|
||||
EOLIAN_SCOPE_PROTECTED
|
Loading…
Reference in New Issue