From 4429b16e36254087f9e6f952677c561f2236d8c0 Mon Sep 17 00:00:00 2001 From: Dave Andreoli Date: Sun, 29 Sep 2019 11:29:38 +0200 Subject: [PATCH] Pyolian: implemented eolian Error object --- src/scripts/pyolian/eolian.py | 20 ++++++++++++++++++++ src/scripts/pyolian/eolian_lib.py | 14 ++++++++++++++ src/scripts/pyolian/generator.py | 1 + 3 files changed, 35 insertions(+) diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py index fb6963cd4f..2c23fa2c5b 100644 --- a/src/scripts/pyolian/eolian.py +++ b/src/scripts/pyolian/eolian.py @@ -1342,6 +1342,24 @@ class Documentation_Token(object): return self._ref +class Error(Object): + def __repr__(self): + return "".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, } diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py index 4ab968eb4d..a92d896972 100644 --- a/src/scripts/pyolian/eolian_lib.py +++ b/src/scripts/pyolian/eolian_lib.py @@ -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 diff --git a/src/scripts/pyolian/generator.py b/src/scripts/pyolian/generator.py index 71fb312ad6..0b7e8024e3 100755 --- a/src/scripts/pyolian/generator.py +++ b/src/scripts/pyolian/generator.py @@ -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,