From 83eaf14f32e3fb804b97906af6e0af70303bf24b Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Tue, 1 Oct 2013 16:38:01 +0900 Subject: [PATCH] evas: make Evas_Loader.h a real public API. --- src/lib/evas/Evas_Common.h | 11 ----- src/lib/evas/Evas_Loader.h | 78 ++++++++++++++++++++++++++++++++- src/lib/evas/file/evas_module.h | 68 ---------------------------- 3 files changed, 77 insertions(+), 80 deletions(-) diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 77f65bd4d6..0c2d9b3655 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -400,17 +400,6 @@ typedef struct _Evas_Event_Key_Up Evas_Event_Key_Up; /**< Event structure typedef struct _Evas_Event_Hold Evas_Event_Hold; /**< Event structure for #EVAS_CALLBACK_HOLD event callbacks */ typedef struct _Evas_Event_Render_Post Evas_Event_Render_Post; /**< Event structure that may come with #EVAS_CALLBACK_RENDER_POST event callbacks @since 1.8 */ -typedef enum _Evas_Load_Error -{ - EVAS_LOAD_ERROR_NONE = 0, /**< No error on load */ - EVAS_LOAD_ERROR_GENERIC = 1, /**< A non-specific error occurred */ - EVAS_LOAD_ERROR_DOES_NOT_EXIST = 2, /**< File (or file path) does not exist */ - EVAS_LOAD_ERROR_PERMISSION_DENIED = 3, /**< Permission denied to an existing file (or path) */ - EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4, /**< Allocation of resources failure prevented load */ - EVAS_LOAD_ERROR_CORRUPT_FILE = 5, /**< File corrupt (but was detected as a known format) */ - EVAS_LOAD_ERROR_UNKNOWN_FORMAT = 6 /**< File is not a known format */ -} Evas_Load_Error; /**< Evas image load error codes one can get - see evas_load_error_str() too. */ - typedef enum _Evas_Alloc_Error { EVAS_ALLOC_ERROR_NONE = 0, /**< No allocation error */ diff --git a/src/lib/evas/Evas_Loader.h b/src/lib/evas/Evas_Loader.h index c0965655b6..258f92ad39 100644 --- a/src/lib/evas/Evas_Loader.h +++ b/src/lib/evas/Evas_Loader.h @@ -1,13 +1,72 @@ #ifndef _EVAS_LOADER_H #define _EVAS_LOADER_H -#include "eina_stringshare.h" +#include "Eina.h" + +/* the module api version */ +#define EVAS_MODULE_API_VERSION 2 + +/* the module types */ +typedef enum _Evas_Module_Type +{ + EVAS_MODULE_TYPE_ENGINE = 0, + EVAS_MODULE_TYPE_IMAGE_LOADER = 1, + EVAS_MODULE_TYPE_IMAGE_SAVER = 2, + EVAS_MODULE_TYPE_OBJECT = 3 +} Evas_Module_Type; + +typedef struct _Evas_Module_Api Evas_Module_Api; +typedef struct _Evas_Module Evas_Module; +typedef struct _Evas_Module_Path Evas_Module_Path; +typedef struct _Evas_Module_Engine Evas_Module_Engine; +typedef struct _Evas_Module_Public Evas_Module_Public; + +/* the module api structure, all modules should define this struct */ +struct _Evas_Module_Api +{ + int version; + const char *name; + const char *author; + + struct + { + int (*open)(Evas_Module *); + void (*close)(Evas_Module *); + } func; +}; + +/* the module structure */ +struct _Evas_Module +{ + const Evas_Module_Api *definition; + + void *functions; /* this are the functions exported by the module */ + int id_engine; /* some internal data for the module i.e the id for engines */ + + int ref; /* how many refs */ + int last_used; /* the cycle count when it was last used */ + + Eina_Lock lock; + + unsigned char loaded : 1; +}; typedef struct _Evas_Image_Load_Opts Evas_Image_Load_Opts; typedef struct _Evas_Image_Animated Evas_Image_Animated; typedef struct _Evas_Image_Property Evas_Image_Property; typedef struct _Evas_Image_Load_Func Evas_Image_Load_Func; +typedef enum _Evas_Load_Error +{ + EVAS_LOAD_ERROR_NONE = 0, /**< No error on load */ + EVAS_LOAD_ERROR_GENERIC = 1, /**< A non-specific error occurred */ + EVAS_LOAD_ERROR_DOES_NOT_EXIST = 2, /**< File (or file path) does not exist */ + EVAS_LOAD_ERROR_PERMISSION_DENIED = 3, /**< Permission denied to an existing file (or path) */ + EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4, /**< Allocation of resources failure prevented load */ + EVAS_LOAD_ERROR_CORRUPT_FILE = 5, /**< File corrupt (but was detected as a known format) */ + EVAS_LOAD_ERROR_UNKNOWN_FORMAT = 6 /**< File is not a known format */ +} Evas_Load_Error; /**< Evas image load error codes one can get - see evas_load_error_str() too. */ + typedef enum _Evas_Image_Animated_Loop_Hint { EVAS_IMAGE_ANIMATED_HINT_NONE = 0, @@ -88,4 +147,21 @@ struct _Evas_Image_Load_Func Eina_Bool do_region; }; +EAPI Eina_Bool evas_module_register (const Evas_Module_Api *module, Evas_Module_Type type); +EAPI Eina_Bool evas_module_unregister (const Evas_Module_Api *module, Evas_Module_Type type); + +#define EVAS_MODULE_DEFINE(Type, Tn, Name) \ + Eina_Bool evas_##Tn##_##Name##_init(void) \ + { \ + return evas_module_register(&evas_modapi, Type); \ + } \ + void evas_##Tn##_##Name##_shutdown(void) \ + { \ + evas_module_unregister(&evas_modapi, Type); \ + } + +#define EVAS_EINA_MODULE_DEFINE(Tn, Name) \ + EINA_MODULE_INIT(evas_##Tn##_##Name##_init); \ + EINA_MODULE_SHUTDOWN(evas_##Tn##_##Name##_shutdown); + #endif diff --git a/src/lib/evas/file/evas_module.h b/src/lib/evas/file/evas_module.h index 8699b6bcb6..c3ea5331ff 100644 --- a/src/lib/evas/file/evas_module.h +++ b/src/lib/evas/file/evas_module.h @@ -1,58 +1,6 @@ #ifndef _EVAS_MODULE_H #define _EVAS_MODULE_H - -/* the module api version */ -#define EVAS_MODULE_API_VERSION 2 - - -/* the module types */ -typedef enum _Evas_Module_Type -{ - EVAS_MODULE_TYPE_ENGINE = 0, - EVAS_MODULE_TYPE_IMAGE_LOADER = 1, - EVAS_MODULE_TYPE_IMAGE_SAVER = 2, - EVAS_MODULE_TYPE_OBJECT = 3 -} Evas_Module_Type; - - -typedef struct _Evas_Module_Api Evas_Module_Api; -typedef struct _Evas_Module Evas_Module; -typedef struct _Evas_Module_Path Evas_Module_Path; -typedef struct _Evas_Module_Engine Evas_Module_Engine; -typedef struct _Evas_Module_Public Evas_Module_Public; - -/* the module api structure, all modules should define this struct */ -struct _Evas_Module_Api -{ - int version; - const char *name; - const char *author; - - struct - { - int (*open)(Evas_Module *); - void (*close)(Evas_Module *); - } func; -}; - -/* the module structure */ -struct _Evas_Module -{ - const Evas_Module_Api *definition; - - void *functions; /* this are the functions exported by the module */ - int id_engine; /* some internal data for the module i.e the id for engines */ - - int ref; /* how many refs */ - int last_used; /* the cycle count when it was last used */ - - LK(lock); - - unsigned char loaded : 1; -}; - - /* the internals of the module api use this struct to reference a path with a module type * instead of deduce the type from the path. * */ @@ -74,21 +22,5 @@ void evas_module_unref (Evas_Module *em); void evas_module_use (Evas_Module *em); void evas_module_clean (void); void evas_module_shutdown (void); -EAPI Eina_Bool evas_module_register (const Evas_Module_Api *module, Evas_Module_Type type); -EAPI Eina_Bool evas_module_unregister (const Evas_Module_Api *module, Evas_Module_Type type); - -#define EVAS_MODULE_DEFINE(Type, Tn, Name) \ - Eina_Bool evas_##Tn##_##Name##_init(void) \ - { \ - return evas_module_register(&evas_modapi, Type); \ - } \ - void evas_##Tn##_##Name##_shutdown(void) \ - { \ - evas_module_unregister(&evas_modapi, Type); \ - } - -#define EVAS_EINA_MODULE_DEFINE(Tn, Name) \ - EINA_MODULE_INIT(evas_##Tn##_##Name##_init); \ - EINA_MODULE_SHUTDOWN(evas_##Tn##_##Name##_shutdown); #endif /* _EVAS_MODULE_H */