evas >= 0.9.9
ecore >= 0.9.9
ecore-job >= 0.9.9
+ ecore-file >= 0.9.9
embryo >= 0.9.1
])
/* types */
typedef struct _New_Object_Handler New_Object_Handler;
typedef struct _New_Statement_Handler New_Statement_Handler;
+typedef struct _External_List External_List;
+typedef struct _External External;
typedef struct _Font_List Font_List;
typedef struct _Font Font;
typedef struct _Code Code;
void (*func)(void);
};
+struct _External_List
+{
+ Eina_List *list;
+};
+
+struct _External
+{
+ char *name;
+};
+
struct _Font_List
{
Eina_List *list;
#define SZ sizeof
/* global vars */
+extern Eina_List *ext_dirs;
extern Eina_List *img_dirs;
extern Eina_List *fnt_dirs;
extern char *file_in;
extern Eina_List *params;
extern Edje_File *edje_file;
extern Eina_List *edje_collections;
+extern Eina_List *externals;
extern Eina_List *fonts;
extern Eina_List *codes;
extern Eina_List *defines;
* <table class="edcref" border="0">
*/
+static void st_externals_external(void);
+
static void st_images_image(void);
static void st_fonts_font(void);
New_Statement_Handler statement_handlers[] =
{
+ {"externals.external", st_externals_external},
{"images.image", st_images_image},
{"fonts.font", st_fonts_font},
{"data.item", st_data_item},
/*{"spectra.spectrum", st_spectrum},*/
{"spectra.spectrum.name", st_spectrum_name},
{"spectra.spectrum.color", st_spectrum_color},
+ {"collections.externals.external", st_externals_external}, /* dup */
{"collections.image", st_images_image}, /* dup */
{"collections.images.image", st_images_image}, /* dup */
{"collections.font", st_fonts_font}, /* dup */
{"collections.group.min", st_collections_group_min},
{"collections.group.max", st_collections_group_max},
{"collections.group.data.item", st_collections_group_data_item},
+ {"collections.group.externals.external", st_externals_external}, /* dup */
{"collections.group.image", st_images_image}, /* dup */
{"collections.group.images.image", st_images_image}, /* dup */
{"collections.group.font", st_fonts_font}, /* dup */
New_Object_Handler object_handlers[] =
{
+ {"externals", NULL},
{"images", NULL},
{"fonts", NULL},
{"data", NULL},
@page edcref
@block
+ externals
+ @context
+ externals {
+ external: "name";
+ }
+ @description
+ The "externals" block is used to list each external module file that will be used in others
+ programs.
+ @endblock
+
+ @property
+ external
+ @parameters
+ [external filename]
+ @endproperty
+ */
+static void
+st_externals_external(void)
+{
+ External *ex;
+ Edje_External_Directory_Entry *ext;
+
+ check_arg_count(1);
+
+ if (!edje_file->external_dir)
+ edje_file->external_dir = mem_alloc(SZ(Edje_External_Directory));
+
+ ex = mem_alloc(SZ(External));
+ ex->name = parse_str(0);
+ {
+ Eina_List *l;
+ External *lex;
+
+ EINA_LIST_FOREACH(externals, l, lex)
+ {
+ if (!strcmp(lex->name, ex->name))
+ {
+ free(ex->name);
+ free(ex);
+ return;
+ }
+ }
+ }
+ externals = eina_list_append(externals, ex);
+
+ if (edje_file->external_dir)
+ {
+ ext = mem_alloc(SZ(Edje_External_Directory_Entry));
+ ext->entry = mem_strdup(ex->name);
+ edje_file->external_dir->entries = eina_list_append(edje_file->external_dir->entries, ext);
+ }
+}
+
+/**
+ @page edcref
+
+ @block
images
@context
images {
#include <lua.h>
#include <lauxlib.h>
+typedef struct _External_Lookup External_Lookup;
typedef struct _Part_Lookup Part_Lookup;
typedef struct _Program_Lookup Program_Lookup;
typedef struct _Group_Lookup Group_Lookup;
typedef struct _Slave_Lookup Slave_Lookup;
typedef struct _Code_Lookup Code_Lookup;
+
+struct _External_Lookup
+{
+ char *name;
+};
+
struct _Part_Lookup
{
Edje_Part_Collection *pc;
Edje_File *edje_file = NULL;
Eina_List *edje_collections = NULL;
+Eina_List *externals = NULL;
Eina_List *fonts = NULL;
Eina_List *codes = NULL;
Eina_List *code_lookups = NULL;
static Eet_Data_Descriptor *_srcfile_edd = NULL;
static Eet_Data_Descriptor *_srcfile_list_edd = NULL;
+static Eet_Data_Descriptor *_external_edd = NULL;
+static Eet_Data_Descriptor *_external_list_edd = NULL;
+
static Eet_Data_Descriptor *_font_edd = NULL;
static Eet_Data_Descriptor *_font_list_edd = NULL;
_srcfile_list_edd = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(_srcfile_list_edd, SrcFile_List, "list", list, _srcfile_edd);
+ eet_eina_stream_data_descriptor_class_set(&eddc, "external", sizeof (External));
+ _external_edd = eet_data_descriptor_stream_new(&eddc);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_external_edd, External, "name", name, EET_T_INLINED_STRING);
+
+ eet_eina_stream_data_descriptor_class_set(&eddc, "external_list", sizeof (External_List));
+ _external_list_edd = eet_data_descriptor_stream_new(&eddc);
+ EET_DATA_DESCRIPTOR_ADD_LIST(_external_list_edd, External_List, "list", list, _external_edd);
+
eet_eina_stream_data_descriptor_class_set(&eddc, "font", sizeof (Font));
_font_edd = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_font_edd, Font, "file", file, EET_T_INLINED_STRING);
EAPI Eina_Bool edje_external_param_double_get(const Eina_List *params, const char *key, double *ret);
EAPI Eina_Bool edje_external_param_string_get(const Eina_List *params, const char *key, const char **ret);
+ /* edje_module.c */
+ EAPI Eina_Bool edje_module_load(const char *module);
+ EAPI const Eina_List *edje_available_modules_get(void);
+
+
#ifdef __cplusplus
}
#endif
edje_script_only.c \
edje_lua_script_only.c \
edje_entry.c \
-edje_external.c
+edje_external.c \
+edje_module.c
if EDJE_AMALGAMATION
nodist_libedje_la_SOURCES = edje_amalgamation.c
EAPI Eet_Data_Descriptor *_edje_edd_edje_style_tag = NULL;
EAPI Eet_Data_Descriptor *_edje_edd_edje_color_class = NULL;
EAPI Eet_Data_Descriptor *_edje_edd_edje_data = NULL;
+EAPI Eet_Data_Descriptor *_edje_edd_edje_external_directory = NULL;
+EAPI Eet_Data_Descriptor *_edje_edd_edje_external_directory_entry = NULL;
EAPI Eet_Data_Descriptor *_edje_edd_edje_font_directory = NULL;
EAPI Eet_Data_Descriptor *_edje_edd_edje_font_directory_entry = NULL;
EAPI Eet_Data_Descriptor *_edje_edd_edje_image_directory = NULL;
FREED(_edje_edd_edje_style_tag);
FREED(_edje_edd_edje_color_class);
FREED(_edje_edd_edje_data);
+ FREED(_edje_edd_edje_external_directory);
+ FREED(_edje_edd_edje_external_directory_entry);
FREED(_edje_edd_edje_font_directory);
FREED(_edje_edd_edje_font_directory_entry);
FREED(_edje_edd_edje_image_directory);
{
Eet_Data_Descriptor_Class eddc;
+ /* external directory */
+ EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Directory_Entry);
+ _edje_edd_edje_external_directory_entry =
+ eet_data_descriptor_file_new(&eddc);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_directory_entry, Edje_External_Directory_Entry, "entry", entry, EET_T_STRING);
+
+ EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Directory);
+ _edje_edd_edje_external_directory =
+ eet_data_descriptor_file_new(&eddc);
+ EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_external_directory, Edje_External_Directory, "entries", entries, _edje_edd_edje_external_directory_entry);
+
/* font directory */
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Font_Directory_Entry);
_edje_edd_edje_font_directory_entry =
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "compiler", compiler, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "version", version, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "feature_ver", feature_ver, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "external_dir", external_dir, _edje_edd_edje_external_directory);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "font_dir", font_dir, _edje_edd_edje_font_directory);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "spectrum_dir", spectrum_dir, _edje_edd_edje_spectrum_directory);
_edje_text_init();
_edje_box_init();
_edje_external_init();
+ _edje_module_init();
_edje_lua_init();
_edje_message_init();
_edje_real_part_mp = NULL;
_edje_message_shutdown();
_edje_lua_shutdown();
+ _edje_module_shutdown();
_edje_external_shutdown();
_edje_box_shutdown();
_edje_text_class_members_free();
_edje_message_shutdown();
_edje_lua_shutdown();
+ _edje_module_shutdown();
_edje_external_shutdown();
_edje_box_shutdown();
_edje_text_class_members_free();
--- /dev/null
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#elif defined __GNUC__
+# define alloca __builtin_alloca
+#elif defined _AIX
+# define alloca __alloca
+#elif defined _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+#else
+# include <stddef.h>
+# ifdef __cplusplus
+extern "C"
+# endif
+void *alloca (size_t);
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <libgen.h>
+#include <Eina.h>
+#include <Ecore_File.h>
+#include "Edje.h"
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define MODULE_EXTENSION ".dll"
+#else
+# define MODULE_EXTENSION ".so"
+#endif /* !defined(_WIN32) && !defined(__CYGWIN__) */
+
+#define LOG_COLOR "\033[36m"
+
+Eina_Hash *_registered_modules = NULL;
+Eina_Array *_available_modules = NULL;
+Eina_List *_modules_name = NULL;
+static int _edje_modules_log_dom = -1;
+
+const char *
+_edje_module_name_get(Eina_Module *m)
+{
+ const char *name;
+ ssize_t len;
+
+ name = ecore_file_file_get(eina_module_file_get(m));
+ len = strlen(name);
+ len -= sizeof(MODULE_EXTENSION) - 1;
+ if (len <= 0) return NULL;
+ return eina_stringshare_add_length(name, len);
+}
+
+EAPI Eina_Bool
+edje_module_load(const char *module)
+{
+ Eina_Module *m;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(module, EINA_FALSE);
+ m = eina_module_find(_available_modules, module);
+
+ if (!m)
+ {
+ EINA_LOG_ERR("Could not find the module %s", module);
+ return EINA_FALSE;
+ }
+
+ if (!eina_module_load(m))
+ {
+ EINA_LOG_ERR("Could not load the module %s", module);
+ return EINA_TRUE;
+ }
+
+ return !!eina_hash_add(_registered_modules, module, m);
+}
+
+void
+_edje_module_init(void)
+{
+ _edje_modules_log_dom = eina_log_domain_register("edje_module", LOG_COLOR);
+
+ if (_edje_modules_log_dom < 0)
+ {
+ EINA_LOG_ERR("Could not register log domain: edje_module");
+ return;
+ }
+
+ _registered_modules = eina_hash_string_small_new(NULL);
+ _available_modules = eina_module_list_get(_available_modules,
+ PACKAGE_LIB_DIR "/lib/edje", 0, NULL, NULL);
+
+ if (!_available_modules)
+ {
+ eina_hash_free(_registered_modules);
+ return;
+ }
+
+ unsigned int i;
+ Eina_Array_Iterator it;
+ Eina_Module *m;
+
+ EINA_ARRAY_ITER_NEXT(_available_modules, i, m, it)
+ {
+ const char *name;
+
+ name = _edje_module_name_get(m);
+ _modules_name = eina_list_append(_modules_name, name);
+ }
+
+}
+
+void
+_edje_module_shutdown(void)
+{
+ Eina_List *l;
+ const char *data;
+
+ eina_module_list_flush(_available_modules);
+ if (_available_modules)
+ {
+ eina_array_free(_available_modules);
+ _available_modules = NULL;
+ }
+
+ if (_registered_modules)
+ {
+ eina_hash_free(_registered_modules);
+ _registered_modules = NULL;
+ }
+
+ if (_modules_name)
+ {
+ EINA_LIST_FOREACH(_modules_name, l, data)
+ {
+ eina_stringshare_del(data);
+ }
+ _modules_name = NULL;
+ }
+
+ eina_log_domain_unregister(_edje_modules_log_dom);
+ _edje_modules_log_dom = -1;
+}
+
+EAPI const Eina_List *
+edje_available_modules_get(void)
+{
+ return _modules_name;
+}
typedef struct _Edje_Style Edje_Style;
typedef struct _Edje_Style_Tag Edje_Style_Tag;
typedef struct _Edje_Data Edje_Data;
+typedef struct _Edje_External_Directory Edje_External_Directory;
+typedef struct _Edje_External_Directory_Entry Edje_External_Directory_Entry;
typedef struct _Edje_Font_Directory Edje_Font_Directory;
typedef struct _Edje_Font_Directory_Entry Edje_Font_Directory_Entry;
typedef struct _Edje_Image_Directory Edje_Image_Directory;
{
const char *path;
+ Edje_External_Directory *external_dir;
Edje_Font_Directory *font_dir;
Edje_Image_Directory *image_dir;
Edje_Spectrum_Directory *spectrum_dir;
const char *path;
};
+/*----------*/
+
+struct _Edje_External_Directory
+{
+ Eina_List *entries; /* a list of Edje_External_Directory_Entry */
+};
+
+struct _Edje_External_Directory_Entry
+{
+ const char *entry; /* the name of the external */
+};
+
+
+/*----------*/
+
+
/*----------*/
void *_edje_external_params_parse(Evas_Object *obj, const Eina_List *params);
void _edje_external_parsed_params_free(Evas_Object *obj, void *params);
+void _edje_module_init();
+void _edje_module_shutdown();
+
#endif