Eolian: Improve error handling, add logging
This commit is contained in:
parent
3d196ef231
commit
e5c82e08d6
|
@ -1,8 +1,12 @@
|
|||
|
||||
from libc.stdint cimport uintptr_t
|
||||
from cpython cimport PyUnicode_AsUTF8String
|
||||
from efl.eina cimport eina_inlist_count
|
||||
from efl.eina cimport eina_inlist_count, EINA_LOG_DOM_DBG, \
|
||||
EINA_LOG_DOM_INFO, EINA_LOG_DOM_WARN, EINA_LOG_DOM_ERR, EINA_LOG_DOM_CRIT
|
||||
from efl.utils.conversions cimport _ctouni, eina_list_strings_to_python_list
|
||||
from efl.utils.logger cimport add_logger
|
||||
|
||||
cdef int EOLIAN_DOM = add_logger("efl.eolian").eina_log_domain
|
||||
|
||||
from efl.utils.enum import IntEnum
|
||||
|
||||
|
@ -39,6 +43,12 @@ cdef list eina_list_obj_to_python_list(const Eina_List *lst, type cls):
|
|||
cdef:
|
||||
list ret = list()
|
||||
while lst:
|
||||
if lst.data == NULL:
|
||||
EINA_LOG_DOM_DBG(
|
||||
EOLIAN_DOM, "Eina lists data pointer is NULL", NULL
|
||||
)
|
||||
lst = lst.next
|
||||
|
||||
if cls is Class:
|
||||
o = eolian_class_to_python_obj(<Eolian_Class>lst.data)
|
||||
elif cls is Function:
|
||||
|
@ -52,7 +62,9 @@ cdef list eina_list_obj_to_python_list(const Eina_List *lst, type cls):
|
|||
elif cls is Event:
|
||||
o = eolian_event_to_python_obj(<Eolian_Event>lst.data)
|
||||
else:
|
||||
print("Unknown type")
|
||||
EINA_LOG_DOM_WARN(
|
||||
EOLIAN_DOM, "Unknown type for conversion", NULL
|
||||
)
|
||||
return
|
||||
ret.append(o)
|
||||
lst = lst.next
|
||||
|
@ -60,32 +72,62 @@ cdef list eina_list_obj_to_python_list(const Eina_List *lst, type cls):
|
|||
|
||||
|
||||
cdef Class eolian_class_to_python_obj(Eolian_Class o):
|
||||
if o == NULL:
|
||||
EINA_LOG_DOM_DBG(
|
||||
EOLIAN_DOM, "Eolian_Class is NULL", NULL
|
||||
)
|
||||
return None
|
||||
cdef Class ret = Class.__new__(Class)
|
||||
ret._set_obj(o)
|
||||
return ret
|
||||
|
||||
cdef Function eolian_func_to_python_obj(Eolian_Function o):
|
||||
if o == NULL:
|
||||
EINA_LOG_DOM_DBG(
|
||||
EOLIAN_DOM, "Eolian_Function is NULL", NULL
|
||||
)
|
||||
return None
|
||||
cdef Function ret = Function.__new__(Function)
|
||||
ret._set_obj(o)
|
||||
return ret
|
||||
|
||||
cdef FunctionParameter eolian_func_param_to_python_obj(
|
||||
Eolian_Function_Parameter o):
|
||||
if o == NULL:
|
||||
EINA_LOG_DOM_DBG(
|
||||
EOLIAN_DOM, "Eolian_Function_Parameter is NULL", NULL
|
||||
)
|
||||
return None
|
||||
cdef FunctionParameter ret = FunctionParameter.__new__(FunctionParameter)
|
||||
ret._set_obj(o)
|
||||
return ret
|
||||
|
||||
cdef Type eolian_type_to_python_obj(Eolian_Type o):
|
||||
if o == NULL:
|
||||
EINA_LOG_DOM_DBG(
|
||||
EOLIAN_DOM, "Eolian_Type is NULL", NULL
|
||||
)
|
||||
return None
|
||||
cdef Type ret = Type.__new__(Type)
|
||||
ret._set_obj(o)
|
||||
return ret
|
||||
|
||||
cdef Implement eolian_implement_to_python_obj(Eolian_Implement o):
|
||||
if o == NULL:
|
||||
EINA_LOG_DOM_DBG(
|
||||
EOLIAN_DOM, "Eolian_Implement is NULL", NULL
|
||||
)
|
||||
return None
|
||||
cdef Implement ret = Implement.__new__(Implement)
|
||||
ret._set_obj(o)
|
||||
return ret
|
||||
|
||||
cdef Event eolian_event_to_python_obj(Eolian_Event o):
|
||||
if o == NULL:
|
||||
EINA_LOG_DOM_DBG(
|
||||
EOLIAN_DOM, "Eolian_Event is NULL", NULL
|
||||
)
|
||||
return None
|
||||
cdef Event ret = Event.__new__(Event)
|
||||
ret._set_obj(o)
|
||||
return ret
|
||||
|
@ -101,7 +143,10 @@ def eo_file_parse(filename):
|
|||
|
||||
"""
|
||||
if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename)
|
||||
return bool(eolian_eo_file_parse(filename))
|
||||
cdef bint ret = eolian_eo_file_parse(filename)
|
||||
if not ret:
|
||||
EINA_LOG_DOM_WARN(EOLIAN_DOM, "Failure in directory_scan()", NULL)
|
||||
return ret
|
||||
|
||||
def init():
|
||||
"""Init Eolian.
|
||||
|
@ -109,6 +154,7 @@ def init():
|
|||
:rtype: int
|
||||
|
||||
"""
|
||||
EINA_LOG_DOM_INFO(EOLIAN_DOM, "Initializing efl.eolian", NULL)
|
||||
return eolian_init()
|
||||
|
||||
def shutdown():
|
||||
|
@ -117,6 +163,7 @@ def shutdown():
|
|||
:rtype: int
|
||||
|
||||
"""
|
||||
EINA_LOG_DOM_INFO(EOLIAN_DOM, "Shutting down efl.eolian", NULL)
|
||||
return eolian_shutdown()
|
||||
|
||||
def directory_scan(directory):
|
||||
|
@ -129,7 +176,10 @@ def directory_scan(directory):
|
|||
|
||||
"""
|
||||
if isinstance(directory, unicode): directory = PyUnicode_AsUTF8String(directory)
|
||||
return bool(eolian_directory_scan(directory))
|
||||
cdef bint ret = eolian_directory_scan(directory)
|
||||
if not ret:
|
||||
EINA_LOG_DOM_WARN(EOLIAN_DOM, "Failure in directory_scan()", NULL)
|
||||
return ret
|
||||
|
||||
def all_eo_files_parse():
|
||||
"""Force parsing of all the files located in the directories
|
||||
|
@ -140,7 +190,10 @@ def all_eo_files_parse():
|
|||
:see: :py:func:`directory_scan`
|
||||
|
||||
"""
|
||||
return bool(eolian_all_eo_files_parse())
|
||||
cdef bint ret = eolian_all_eo_files_parse()
|
||||
if not ret:
|
||||
EINA_LOG_DOM_WARN(EOLIAN_DOM, "Failure in all_eo_files_parse()", NULL)
|
||||
return ret
|
||||
|
||||
def show(Class klass=None):
|
||||
"""Show information about a given class.
|
||||
|
@ -151,9 +204,12 @@ def show(Class klass=None):
|
|||
:param klass: the class to show
|
||||
|
||||
"""
|
||||
return bool(eolian_show(
|
||||
cdef bint ret = eolian_show(
|
||||
klass.klass if klass is not None else NULL
|
||||
))
|
||||
)
|
||||
if not ret:
|
||||
EINA_LOG_DOM_WARN(EOLIAN_DOM, "Failure in show()", NULL)
|
||||
return ret
|
||||
|
||||
def class_find_by_name(class_name):
|
||||
"""Finds a class by its name
|
||||
|
@ -762,6 +818,10 @@ cdef class Implement(object):
|
|||
&function,
|
||||
&type
|
||||
):
|
||||
EINA_LOG_DOM_WARN(
|
||||
EOLIAN_DOM, "Fetching info for %s failed",
|
||||
eolian_implement_full_name_get(self.impl)
|
||||
)
|
||||
return None
|
||||
|
||||
return (
|
||||
|
@ -807,6 +867,9 @@ cdef class Event(object):
|
|||
if not eolian_class_event_information_get(
|
||||
self.event, &event_name, &event_type, &event_desc
|
||||
):
|
||||
EINA_LOG_DOM_WARN(
|
||||
EOLIAN_DOM, "Fetching info for an event failed", NULL
|
||||
)
|
||||
return None
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue