edje: Unify load error types for image and edje (EO)

Most of the values were the same, with edje having just a couple
more error codes.

Not entirely sure the prefix Efl.Image is correct for this type.
Maybe just Efl.Load.Error?
This commit is contained in:
Jean-Philippe Andre 2017-05-26 10:29:05 +09:00
parent 3cc8bc2173
commit 76ef772d0a
8 changed files with 93 additions and 56 deletions

View File

@ -1838,22 +1838,6 @@ EAPI void edje_file_collection_list_free (Eina_List *lst);
*/
EAPI Eina_Bool edje_file_group_exists (const char *file, const char *glob);
/**
* @brief Converts the given Edje file load error code into a string
* describing it in English.
*
* @param error the error code, a value in ::Edje_Load_Error.
* @return Always returns a valid string. If the given @p error is not
* supported, <code>"Unknown error"</code> is returned.
*
* edje_object_file_set() is a function which sets an error value,
* afterwards, which can be fetched with
* edje_object_load_error_get(). The function in question is meant
* to be used in conjunction with the latter, for pretty-printing any
* possible error cause.
*/
EAPI const char *edje_load_error_str (Edje_Load_Error error);
/**
* @}
*/

View File

@ -97,6 +97,57 @@ EAPI void *edje_object_signal_callback_del (Evas_Object *obj, const char
*/
EAPI void *edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
/** Edje file loading error codes one can get - see edje_load_error_str() too. */
typedef enum
{
EDJE_LOAD_ERROR_NONE = 0, /**< No error happened, the loading was successful */
EDJE_LOAD_ERROR_GENERIC = 1, /**< A generic error happened during the loading */
EDJE_LOAD_ERROR_DOES_NOT_EXIST = 2, /**< The file pointed to did not exist */
EDJE_LOAD_ERROR_PERMISSION_DENIED = 3, /**< Permission to read the given file was denied */
EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4, /**< Resource allocation failed during the loading */
EDJE_LOAD_ERROR_CORRUPT_FILE = 5, /**< The file pointed to was corrupt */
EDJE_LOAD_ERROR_UNKNOWN_FORMAT = 6, /**< The file pointed to had an unknown format */
EDJE_LOAD_ERROR_INCOMPATIBLE_FILE = 7, /**< The file pointed to is incompatible, i.e., it doesn't
* match the library's current version's format */
EDJE_LOAD_ERROR_UNKNOWN_COLLECTION = 8, /**< The group/collection set to load
* from was not found in the file */
EDJE_LOAD_ERROR_RECURSIVE_REFERENCE = 9 /**< The group/collection set to load from had
* <b>recursive references</b> on its components */
} Edje_Load_Error;
/**
* @brief Gets the (last) file loading error for a given Edje object
*
* This function is meant to be used after an Edje EDJ file loading, what takes
* place with the edje_object_file_set() function. If that function does not
* return @c true, one should check for the reason of failure with this one.
*
* @ref edje_load_error_str()
*
* @return The Edje loading error, one of: - #EDJE_LOAD_ERROR_NONE -
* #EDJE_LOAD_ERROR_GENERIC - #EDJE_LOAD_ERROR_DOES_NOT_EXIST -
* #EDJE_LOAD_ERROR_PERMISSION_DENIED -
* #EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED - #EDJE_LOAD_ERROR_CORRUPT_FILE
* - #EDJE_LOAD_ERROR_UNKNOWN_FORMAT - #EDJE_LOAD_ERROR_INCOMPATIBLE_FILE -
* #EDJE_LOAD_ERROR_UNKNOWN_COLLECTION - #EDJE_LOAD_ERROR_RECURSIVE_REFERENCE
*/
EAPI Edje_Load_Error edje_object_load_error_get(const Evas_Object *obj);
/**
* @brief Converts the given Edje file load error code into a string
* describing it in English.
*
* @param error the error code, a value in ::Edje_Load_Error.
* @return Always returns a valid string. If the given @p error is not
* supported, <code>"Unknown error"</code> is returned.
*
* edje_object_file_set() is a function which sets an error value,
* afterwards, which can be fetched with
* edje_object_load_error_get(). The function in question is meant
* to be used in conjunction with the latter, for pretty-printing any
* possible error cause.
*/
EAPI const char *edje_load_error_str (Edje_Load_Error error);
/**
* @ingroup Edje_Object_Communication_Interface_Message

View File

@ -167,9 +167,32 @@ _edje_object_efl_file_file_get(Eo *obj EINA_UNUSED, Edje *ed, const char **file,
if (group) *group = ed->group;
}
EOLIAN Edje_Load_Error
EOLIAN Efl_Image_Load_Error
_edje_object_load_error_get(Eo *obj EINA_UNUSED, Edje *ed)
{
switch (ed->load_error)
{
case EDJE_LOAD_ERROR_NONE: return EFL_IMAGE_LOAD_ERROR_NONE;
case EDJE_LOAD_ERROR_GENERIC: return EFL_IMAGE_LOAD_ERROR_GENERIC;
case EDJE_LOAD_ERROR_DOES_NOT_EXIST: return EFL_IMAGE_LOAD_ERROR_DOES_NOT_EXIST;
case EDJE_LOAD_ERROR_PERMISSION_DENIED: return EFL_IMAGE_LOAD_ERROR_PERMISSION_DENIED;
case EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED: return EFL_IMAGE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
case EDJE_LOAD_ERROR_CORRUPT_FILE: return EFL_IMAGE_LOAD_ERROR_CORRUPT_FILE;
case EDJE_LOAD_ERROR_UNKNOWN_FORMAT: return EFL_IMAGE_LOAD_ERROR_UNKNOWN_FORMAT;
case EDJE_LOAD_ERROR_INCOMPATIBLE_FILE: return EFL_IMAGE_LOAD_ERROR_INCOMPATIBLE_FILE;
case EDJE_LOAD_ERROR_UNKNOWN_COLLECTION: return EFL_IMAGE_LOAD_ERROR_UNKNOWN_COLLECTION;
case EDJE_LOAD_ERROR_RECURSIVE_REFERENCE: return EFL_IMAGE_LOAD_ERROR_RECURSIVE_REFERENCE;
default: return EFL_IMAGE_LOAD_ERROR_GENERIC;
}
}
EAPI Edje_Load_Error
edje_object_load_error_get(const Eo *obj)
{
Edje *ed;
ed = _edje_fetch(obj);
if (!ed) return EDJE_LOAD_ERROR_GENERIC;
return ed->load_error;
}
@ -3098,4 +3121,3 @@ _edje_svg_node_free(Svg_Node *node)
}
free(node);
}

View File

@ -302,23 +302,15 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
[[Gets the (last) file loading error for a given Edje object
This function is meant to be used after an Edje EDJ file
loading, what takes place with the edje_object_file_set()
function. If that function does not return $true, one should
check for the reason of failure with this one.
\@ref edje_load_error_str()]]
return: Edje.Load_Error; [[The Edje loading error, one of:
- #EDJE_LOAD_ERROR_NONE
- #EDJE_LOAD_ERROR_GENERIC
- #EDJE_LOAD_ERROR_DOES_NOT_EXIST
- #EDJE_LOAD_ERROR_PERMISSION_DENIED
- #EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED
- #EDJE_LOAD_ERROR_CORRUPT_FILE
- #EDJE_LOAD_ERROR_UNKNOWN_FORMAT
- #EDJE_LOAD_ERROR_INCOMPATIBLE_FILE
- #EDJE_LOAD_ERROR_UNKNOWN_COLLECTION
- #EDJE_LOAD_ERROR_RECURSIVE_REFERENCE]]
loading, what takes place with the $file_set() function. If that
function does not return $true, one should check for the reason
of failure with this one.
]]
legacy: null;
}
values {
error: Efl.Image.Load.Error(Efl.Image.Load.Error.generic);
[[The load error code.]]
}
}
size_min_calc {

View File

@ -67,14 +67,14 @@ _edje_object_efl_object_dbg_info_get(Eo *eo_obj, Edje *_pd EINA_UNUSED, Efl_Dbg_
{
efl_dbg_info_get(efl_super(eo_obj, MY_CLASS), root);
Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, MY_CLASS_NAME);
Edje_Load_Error error;
const char *file, *edje_group;
efl_file_get(eo_obj, &file, &edje_group);
EFL_DBG_INFO_APPEND(group, "File", EINA_VALUE_TYPE_STRING, file);
EFL_DBG_INFO_APPEND(group, "Group", EINA_VALUE_TYPE_STRING, edje_group);
Edje_Load_Error error = EDJE_LOAD_ERROR_NONE;
error = edje_obj_load_error_get(eo_obj);
error = edje_object_load_error_get(eo_obj);
if (error != EDJE_LOAD_ERROR_NONE)
{
EFL_DBG_INFO_APPEND(group, "Error", EINA_VALUE_TYPE_STRING,

View File

@ -17,21 +17,6 @@ enum Edje.Drag_Dir {
xy = 3 [[X and Y dragable value]]
}
enum Edje.Load_Error {
[[Edje file loading error codes one can get - see edje_load_error_str() too.]]
none = 0, [[No error happened, the loading was successful]]
generic = 1, [[A generic error happened during the loading]]
does_not_exist = 2, [[The file pointed to did not exist]]
permission_denied = 3, [[Permission to read the given file was denied]]
resource_allocation_failed = 4, [[Resource allocation failed during the loading]]
corrupt_file = 5, [[The file pointed to was corrupt]]
unknown_format = 6, [[The file pointed to had an unknown format]]
incompatible_file = 7, [[The file pointed to is incompatible, i.e., it doesn't match the library's current version's format]]
unknown_collection = 8, [[The group/collection set to load from was not found in the file]]
recursive_reference = 9 [[The group/collection set to load from had <b>recursive references</b> on its components]]
}
enum Edje.Text.Autocapital_Type {
[[All Text auto capital mode type values]]
none, [[None mode value]]

View File

@ -183,7 +183,7 @@ enum Efl.Gfx.Size.Hint.Aspect
enum Efl.Image.Load.Error
{
[[Image load error type]]
[[Image or Edje load error type]]
none = 0, [[No error on load]]
generic = 1, [[A non-specific error occurred]]
does_not_exist = 2, [[File (or file path) does not exist]]
@ -191,7 +191,10 @@ enum Efl.Image.Load.Error
resource_allocation_failed = 4, [[Allocation of resources failure prevented load]]
corrupt_file = 5, [[File corrupt (but was detected as a known format)]]
unknown_format = 6, [[File is not a known format]]
cancelled = 7 [[Reading operation has been cancelled during decoding]]
cancelled = 7, [[Reading operation has been cancelled during decoding]]
incompatible_file = 8, [[(Edje only) The file pointed to is incompatible, i.e., it doesn't match the library's current version's format.]]
unknown_collection = 9, [[(Edje only) The group/collection set to load from was not found in the file]]
recursive_reference = 10 [[(Edje only) The group/collection set to load from had recursive references on its components]]
}
enum Efl.Gfx.Size.Hint.Mode {

View File

@ -1898,13 +1898,13 @@ _elm_layout_efl_object_dbg_info_get(Eo *eo_obj, Elm_Layout_Smart_Data *_pd EINA_
Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, MY_CLASS_NAME);
const char *file, *edje_group;
Evas_Object *edje_obj = wd->resize_obj;
Edje_Load_Error error;
efl_file_get(edje_obj, &file, &edje_group);
EFL_DBG_INFO_APPEND(group, "File", EINA_VALUE_TYPE_STRING, file);
EFL_DBG_INFO_APPEND(group, "Group", EINA_VALUE_TYPE_STRING, edje_group);
Edje_Load_Error error = EDJE_LOAD_ERROR_GENERIC;
error = edje_obj_load_error_get(edje_obj);
error = edje_object_load_error_get(edje_obj);
if (error != EDJE_LOAD_ERROR_NONE)
{
EFL_DBG_INFO_APPEND(group, "Error", EINA_VALUE_TYPE_STRING,