Pyolian: implemented eolian Error object

This commit is contained in:
Davide Andreoli 2019-09-29 11:29:38 +02:00
parent d1e27aacfc
commit 4429b16e36
3 changed files with 35 additions and 0 deletions

View File

@ -1342,6 +1342,24 @@ class Documentation_Token(object):
return self._ref
class Error(Object):
def __repr__(self):
return "<eolian.Error '{0.name}', message='{0.message}'>".format(self)
@cached_property
def message(self):
return _str_to_py(lib.eolian_error_message_get(self))
@cached_property
def documentation(self):
c_doc = lib.eolian_error_documentation_get(self)
return Documentation(c_doc) if c_doc else None
@cached_property
def is_extern(self):
return bool(lib.eolian_error_is_extern(self))
# internal string encode/decode #############################################
def _str_to_bytes(s):
@ -1380,6 +1398,7 @@ class _Eolian_Object_Type(IntEnum):
IMPLEMENT = 12
CONSTRUCTOR = 13
DOCUMENTATION = 14
ERROR = 15
_eolian_type_class_mapping = {
@ -1398,6 +1417,7 @@ _eolian_type_class_mapping = {
_Eolian_Object_Type.IMPLEMENT: Implement,
_Eolian_Object_Type.CONSTRUCTOR: Constructor,
_Eolian_Object_Type.DOCUMENTATION: Documentation,
_Eolian_Object_Type.ERROR: Error,
}

View File

@ -692,3 +692,17 @@ lib.eolian_doc_token_text_get.restype = c_void_p # char* TO BE FREED
# EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2);
# lib.eolian_doc_token_ref_resolve.argtypes = (c_void_p, c_void_p, ???, ???)
# lib.eolian_doc_token_ref_resolve.restype = c_int
# Eolian_Error ##############################################################
# EAPI const char *eolian_error_message_get(const Eolian_Error *err);
lib.eolian_error_message_get.argtypes = (c_void_p,)
lib.eolian_error_message_get.restype = c_char_p
# EAPI const Eolian_Documentation *eolian_error_documentation_get(const Eolian_Error *err);
lib.eolian_error_documentation_get.argtypes = (c_void_p,)
lib.eolian_error_documentation_get.restype = c_void_p
# EAPI Eina_Bool eolian_error_is_extern(const Eolian_Error *err);
lib.eolian_error_is_extern.argtypes = (c_void_p,)
lib.eolian_error_is_extern.restype = c_bool

View File

@ -132,6 +132,7 @@ class Template(pyratemp.Template):
'Constant': eolian.Constant,
'Documentation': eolian.Documentation,
'Documentation_Token': eolian.Documentation_Token,
'Error': eolian.Error,
# Eolian Enums
'Eolian_Function_Type': eolian.Eolian_Function_Type,
'Eolian_Parameter_Direction': eolian.Eolian_Parameter_Direction,