edje external support, part 1.

Patch by Fabiano Fidêncio <fidencio@profusion.mobi>



SVN revision: 43927
devs/devilhorns/wayland_egl
Gustavo Sverzut Barbieri 13 years ago
parent 5175806e0c
commit d40d8d123d
  1. 1
      legacy/edje/configure.ac
  2. 14
      legacy/edje/src/bin/edje_cc.h
  3. 63
      legacy/edje/src/bin/edje_cc_handlers.c
  4. 8
      legacy/edje/src/bin/edje_cc_out.c
  5. 11
      legacy/edje/src/bin/edje_cc_sources.c
  6. 5
      legacy/edje/src/lib/Edje.h
  7. 3
      legacy/edje/src/lib/Makefile.am
  8. 16
      legacy/edje/src/lib/edje_data.c
  9. 3
      legacy/edje/src/lib/edje_main.c
  10. 150
      legacy/edje/src/lib/edje_module.c
  11. 22
      legacy/edje/src/lib/edje_private.h

@ -224,6 +224,7 @@ PKG_CHECK_MODULES([EDJE],
evas >= 0.9.9
ecore >= 0.9.9
ecore-job >= 0.9.9
ecore-file >= 0.9.9
embryo >= 0.9.1
])

@ -15,6 +15,8 @@
/* 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;
@ -34,6 +36,16 @@ struct _New_Statement_Handler
void (*func)(void);
};
struct _External_List
{
Eina_List *list;
};
struct _External
{
char *name;
};
struct _Font_List
{
Eina_List *list;
@ -121,6 +133,7 @@ char *mem_strdup(const char *s);
#define SZ sizeof
/* global vars */
extern Eina_List *ext_dirs;
extern Eina_List *img_dirs;
extern Eina_List *fnt_dirs;
extern char *file_in;
@ -138,6 +151,7 @@ extern Eina_List *stack;
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;

@ -54,6 +54,8 @@
* <table class="edcref" border="0">
*/
static void st_externals_external(void);
static void st_images_image(void);
static void st_fonts_font(void);
@ -222,6 +224,7 @@ static void ob_collections_group_programs_program_lua_script(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},
@ -236,6 +239,7 @@ New_Statement_Handler statement_handlers[] =
/*{"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 */
@ -254,6 +258,7 @@ New_Statement_Handler statement_handlers[] =
{"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 */
@ -501,6 +506,7 @@ New_Statement_Handler statement_handlers[] =
New_Object_Handler object_handlers[] =
{
{"externals", NULL},
{"images", NULL},
{"fonts", NULL},
{"data", NULL},
@ -632,6 +638,63 @@ statement_handler_num(void)
/*****/
/**
@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

@ -36,6 +36,7 @@ void *alloca (size_t);
#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;
@ -44,6 +45,12 @@ typedef struct _String_Lookup Spectrum_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;
@ -86,6 +93,7 @@ static void data_process_string(Edje_Part_Collection *pc, const char *prefix, ch
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;

@ -15,6 +15,9 @@
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;
@ -34,6 +37,14 @@ source_edd(void)
_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);

@ -411,6 +411,11 @@ extern "C" {
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

@ -41,7 +41,8 @@ edje_edit.c \
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

@ -9,6 +9,8 @@ EAPI Eet_Data_Descriptor *_edje_edd_edje_style = NULL;
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;
@ -43,6 +45,8 @@ _edje_edd_shutdown(void)
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);
@ -68,6 +72,17 @@ _edje_edd_init(void)
{
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 =
@ -171,6 +186,7 @@ _edje_edd_init(void)
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);

@ -97,6 +97,7 @@ edje_init(void)
_edje_text_init();
_edje_box_init();
_edje_external_init();
_edje_module_init();
_edje_lua_init();
_edje_message_init();
@ -127,6 +128,7 @@ edje_init(void)
_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();
@ -185,6 +187,7 @@ edje_shutdown(void)
_edje_message_shutdown();
_edje_lua_shutdown();
_edje_module_shutdown();
_edje_external_shutdown();
_edje_box_shutdown();
_edje_text_class_members_free();

@ -0,0 +1,150 @@
#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;
}

@ -118,6 +118,8 @@ typedef struct _Edje_File Edje_File;
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;
@ -207,6 +209,7 @@ struct _Edje_File
{
const char *path;
Edje_External_Directory *external_dir;
Edje_Font_Directory *font_dir;
Edje_Image_Directory *image_dir;
Edje_Spectrum_Directory *spectrum_dir;
@ -267,6 +270,22 @@ struct _Edje_Font_Directory_Entry
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 */
};
/*----------*/
/*----------*/
@ -1350,4 +1369,7 @@ void _edje_external_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params
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

Loading…
Cancel
Save