2009-02-08 22:33:26 -08:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
2012-02-18 06:25:45 -08:00
# ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
# else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
# endif
2009-02-08 22:33:26 -08:00
2009-10-25 04:19:12 -07:00
# include <string.h>
# include <limits.h>
# include <unistd.h>
# include <sys/stat.h>
2008-10-26 10:18:19 -07:00
# include <Ecore_Evas.h>
2003-06-11 06:20:48 -07:00
# include "edje_cc.h"
2010-08-09 10:34:03 -07:00
# include "edje_convert.h"
2011-11-04 05:18:13 -07:00
# include "edje_multisense_convert.h"
2003-06-11 06:20:48 -07:00
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
# include <lua.h>
# include <lauxlib.h>
2009-11-23 07:03:19 -08:00
typedef struct _External_Lookup External_Lookup ;
2003-06-13 20:06:36 -07:00
typedef struct _Part_Lookup Part_Lookup ;
2013-10-15 02:15:07 -07:00
typedef struct _Part_Lookup_Key Part_Lookup_Key ;
2003-06-16 06:55:13 -07:00
typedef struct _Program_Lookup Program_Lookup ;
2008-04-11 16:36:35 -07:00
typedef struct _Group_Lookup Group_Lookup ;
2010-06-01 06:31:07 -07:00
typedef struct _Image_Lookup Image_Lookup ;
2004-04-01 01:30:45 -08:00
typedef struct _Code_Lookup Code_Lookup ;
2003-06-13 20:06:36 -07:00
2009-11-23 07:03:19 -08:00
struct _External_Lookup
{
char * name ;
} ;
2013-10-15 02:15:07 -07:00
struct _Part_Lookup_Key
2003-06-13 20:06:36 -07:00
{
2010-08-15 11:14:33 -07:00
Edje_Part_Collection * pc ;
2013-10-15 02:15:07 -07:00
union {
int * dest ;
struct {
unsigned char * * base ;
int offset ;
} reallocated ;
} mem ;
2014-04-22 10:19:09 -07:00
char * * dest2 ;
2013-10-15 02:15:07 -07:00
Eina_Bool stable : 1 ;
} ;
struct _Part_Lookup
{
Part_Lookup_Key key ;
2003-06-13 20:06:36 -07:00
char * name ;
} ;
2003-06-16 06:55:13 -07:00
struct _Program_Lookup
{
2010-08-15 11:14:33 -07:00
Edje_Part_Collection * pc ;
2010-08-24 09:39:51 -07:00
union
{
char * name ;
Edje_Program * ep ;
} u ;
2003-06-16 06:55:13 -07:00
int * dest ;
2010-08-24 09:39:51 -07:00
Eina_Bool anonymous : 1 ;
2003-06-16 06:55:13 -07:00
} ;
2008-04-11 16:36:35 -07:00
struct _Group_Lookup
{
char * name ;
2011-12-19 09:25:00 -08:00
Edje_Part * part ;
2008-04-11 16:36:35 -07:00
} ;
2006-08-02 03:52:44 -07:00
struct _String_Lookup
2003-06-13 20:06:36 -07:00
{
char * name ;
int * dest ;
} ;
2010-06-01 06:31:07 -07:00
struct _Image_Lookup
{
char * name ;
int * dest ;
Eina_Bool * set ;
} ;
2004-04-01 01:30:45 -08:00
struct _Code_Lookup
{
char * ptr ;
int len ;
int val ;
2010-06-01 06:31:07 -07:00
Eina_Bool set ;
2004-04-01 01:30:45 -08:00
} ;
2012-05-15 19:15:45 -07:00
typedef struct _Script_Lua_Writer Script_Lua_Writer ;
struct _Script_Lua_Writer
{
char * buf ;
int size ;
} ;
2013-06-20 04:08:36 -07:00
typedef struct _Script_Write Script_Write ;
2012-05-15 19:15:45 -07:00
typedef struct _Head_Write Head_Write ;
typedef struct _Fonts_Write Fonts_Write ;
typedef struct _Image_Write Image_Write ;
typedef struct _Sound_Write Sound_Write ;
2014-03-19 21:00:20 -07:00
typedef struct _Vibration_Write Vibration_Write ;
2012-05-15 19:15:45 -07:00
typedef struct _Group_Write Group_Write ;
2014-03-05 23:33:06 -08:00
typedef struct _License_Write License_Write ;
2012-05-15 19:15:45 -07:00
struct _Script_Write
2012-05-15 05:29:22 -07:00
{
Eet_File * ef ;
Code * cd ;
int i ;
Ecore_Exe * exe ;
int tmpn_fd , tmpo_fd ;
2014-09-10 06:41:59 -07:00
Eina_Tmpstr * tmpn ;
Eina_Tmpstr * tmpo ;
2012-05-15 05:29:22 -07:00
char * errstr ;
2012-05-15 19:15:45 -07:00
} ;
struct _Head_Write
{
Eet_File * ef ;
char * errstr ;
} ;
struct _Fonts_Write
{
Eet_File * ef ;
2012-12-06 18:04:44 -08:00
Edje_Font * fn ;
2012-05-15 19:15:45 -07:00
char * errstr ;
} ;
struct _Image_Write
{
Eet_File * ef ;
Edje_Image_Directory_Entry * img ;
Evas_Object * im ;
int w , h ;
int alpha ;
unsigned int * data ;
char * path ;
char * errstr ;
} ;
struct _Sound_Write
{
Eet_File * ef ;
Edje_Sound_Sample * sample ;
int i ;
} ;
2014-03-19 21:00:20 -07:00
struct _Vibration_Write
{
Eet_File * ef ;
Edje_Vibration_Sample * sample ;
int i ;
} ;
2012-05-15 19:15:45 -07:00
struct _Group_Write
{
Eet_File * ef ;
Edje_Part_Collection * pc ;
char * errstr ;
} ;
2012-05-15 05:29:22 -07:00
2014-03-05 23:33:06 -08:00
struct _License_Write
{
Eet_File * ef ;
const char * file ;
Eina_Bool master ;
} ;
2013-11-03 22:28:59 -08:00
struct _Image_Unused_Ids
{
int old_id ;
int new_id ;
} ;
typedef struct _Image_Unused_Ids Image_Unused_Ids ;
2012-05-15 05:29:22 -07:00
static int pending_threads = 0 ;
2012-01-25 01:07:36 -08:00
static void data_process_string ( Edje_Part_Collection * pc , const char * prefix , char * s , void ( * func ) ( Edje_Part_Collection * pc , char * name , char * ptr , int len ) ) ;
2004-04-01 01:53:11 -08:00
2010-08-15 11:14:33 -07:00
Edje_File * edje_file = NULL ;
2008-10-22 04:34:42 -07:00
Eina_List * edje_collections = NULL ;
2012-09-10 21:10:13 -07:00
Eina_Hash * edje_collections_lookup = NULL ;
2009-11-23 07:03:19 -08:00
Eina_List * externals = NULL ;
2008-10-22 04:34:42 -07:00
Eina_List * fonts = NULL ;
Eina_List * codes = NULL ;
Eina_List * code_lookups = NULL ;
Eina_List * aliases = NULL ;
2003-06-11 06:20:48 -07:00
2003-06-13 20:06:36 -07:00
static Eet_Data_Descriptor * edd_edje_file = NULL ;
2003-06-16 06:55:13 -07:00
static Eet_Data_Descriptor * edd_edje_part_collection = NULL ;
2003-06-13 20:06:36 -07:00
2008-10-22 04:34:42 -07:00
static Eina_List * program_lookups = NULL ;
static Eina_List * group_lookups = NULL ;
2012-12-11 06:09:03 -08:00
static Eina_List * face_group_lookups = NULL ;
2008-10-22 04:34:42 -07:00
static Eina_List * image_lookups = NULL ;
2015-02-05 06:29:03 -08:00
static Eina_List * model_lookups = NULL ;
2003-06-11 06:20:48 -07:00
2012-09-10 20:39:27 -07:00
static Eina_Hash * part_dest_lookup = NULL ;
static Eina_Hash * part_pc_dest_lookup = NULL ;
2010-08-09 10:34:03 -07:00
void
2013-01-03 18:08:14 -08:00
error_and_abort ( Eet_File * ef EINA_UNUSED , const char * fmt , . . . )
2008-08-20 20:58:11 -07:00
{
va_list ap ;
va_start ( ap , fmt ) ;
2012-07-31 15:42:03 -07:00
eina_log_vprint ( _edje_cc_log_dom , EINA_LOG_LEVEL_CRITICAL ,
" unknown " , " unknown " , 0 , fmt , ap ) ;
2008-08-20 20:58:11 -07:00
va_end ( ap ) ;
2012-05-26 01:41:49 -07:00
unlink ( file_out ) ;
2012-09-17 02:34:29 -07:00
if ( watchfile ) unlink ( watchfile ) ;
2012-05-26 01:41:49 -07:00
exit ( - 1 ) ;
2008-08-20 20:58:11 -07:00
}
2012-09-10 20:39:27 -07:00
static unsigned int
2013-10-15 02:15:07 -07:00
_part_lookup_key_length ( const void * key EINA_UNUSED )
2012-09-10 20:39:27 -07:00
{
2013-10-15 02:15:07 -07:00
return sizeof ( Part_Lookup_Key ) ;
2012-09-10 20:39:27 -07:00
}
static int
2013-10-15 02:15:07 -07:00
_part_lookup_key_pc_cmp ( const void * key1 , int key1_length EINA_UNUSED ,
2013-01-03 18:08:14 -08:00
const void * key2 , int key2_length EINA_UNUSED )
2012-09-10 20:39:27 -07:00
{
2013-10-15 02:15:07 -07:00
const Part_Lookup_Key * a = key1 ;
const Part_Lookup_Key * b = key2 ;
uintptr_t delta ;
delta = a - > pc - b - > pc ;
if ( delta ) return delta ;
if ( a - > stable ) return a - > mem . dest - b - > mem . dest ;
delta = a - > mem . reallocated . base - b - > mem . reallocated . base ;
if ( delta ) return delta ;
return a - > mem . reallocated . offset - b - > mem . reallocated . offset ;
2012-09-10 20:39:27 -07:00
}
static int
2013-10-15 02:15:07 -07:00
_part_lookup_key_pc_hash ( const void * key , int key_length EINA_UNUSED )
2012-09-10 20:39:27 -07:00
{
2013-10-15 02:15:07 -07:00
const Part_Lookup_Key * a = key ;
if ( a - > stable )
{
2013-11-09 02:48:31 -08:00
# ifdef EFL64
2013-11-09 03:07:27 -08:00
return eina_hash_int64 ( ( unsigned long long int * ) & a - > pc , sizeof ( void * ) ) ^
eina_hash_int64 ( ( unsigned long long int * ) & a - > mem . dest , sizeof ( void * ) ) ;
2012-09-10 20:39:27 -07:00
# else
2013-10-27 08:44:31 -07:00
return eina_hash_int32 ( ( uintptr_t * ) & a - > pc , sizeof ( void * ) ) ^
eina_hash_int32 ( ( uintptr_t * ) & a - > mem . dest , sizeof ( void * ) ) ;
2012-09-10 20:39:27 -07:00
# endif
2013-10-15 02:15:07 -07:00
}
else
{
2013-11-09 02:48:31 -08:00
# ifdef EFL64
2013-11-09 03:07:27 -08:00
return eina_hash_int64 ( ( unsigned long long int * ) & a - > pc , sizeof ( void * ) ) ^
eina_hash_int64 ( ( unsigned long long int * ) & a - > mem . reallocated . base , sizeof ( void * ) ) ^
2013-10-15 02:15:07 -07:00
eina_hash_int32 ( ( unsigned int * ) & a - > mem . reallocated . offset , sizeof ( int ) ) ;
# else
return eina_hash_int32 ( ( uintptr_t * ) & a - > pc , sizeof ( void * ) ) ^
eina_hash_int32 ( ( uintptr_t * ) & a - > mem . reallocated . base , sizeof ( void * ) ) ^
eina_hash_int32 ( ( unsigned int * ) & a - > mem . reallocated . offset , sizeof ( int ) ) ;
# endif
}
}
static int
_part_lookup_key_cmp ( const void * key1 , int key1_length EINA_UNUSED ,
const void * key2 , int key2_length EINA_UNUSED )
{
const Part_Lookup_Key * a = key1 ;
const Part_Lookup_Key * b = key2 ;
uintptr_t delta ;
if ( a - > stable ) return a - > mem . dest - b - > mem . dest ;
delta = a - > mem . reallocated . base - b - > mem . reallocated . base ;
if ( delta ) return delta ;
return a - > mem . reallocated . offset - b - > mem . reallocated . offset ;
}
static int
_part_lookup_key_hash ( const void * key , int key_length EINA_UNUSED )
{
const Part_Lookup_Key * a = key ;
if ( a - > stable )
{
2013-11-09 02:48:31 -08:00
# ifdef EFL64
2013-11-09 03:07:27 -08:00
return eina_hash_int64 ( ( unsigned long long int * ) & a - > mem . dest , sizeof ( void * ) ) ;
2013-10-15 02:15:07 -07:00
# else
return eina_hash_int32 ( ( uintptr_t * ) & a - > mem . dest , sizeof ( void * ) ) ;
# endif
}
else
{
2013-11-09 02:48:31 -08:00
# ifdef EFL64
2013-11-09 03:07:27 -08:00
return eina_hash_int64 ( ( unsigned long long int * ) & a - > mem . reallocated . base , sizeof ( void * ) ) ^
2013-10-15 02:15:07 -07:00
eina_hash_int32 ( ( unsigned int * ) & a - > mem . reallocated . offset , sizeof ( int ) ) ;
# else
return eina_hash_int32 ( ( uintptr_t * ) & a - > mem . reallocated . base , sizeof ( void * ) ) ^
eina_hash_int32 ( ( unsigned int * ) & a - > mem . reallocated . offset , sizeof ( int ) ) ;
# endif
}
2012-09-10 20:39:27 -07:00
}
static void
data_part_lookup_free ( Part_Lookup * pl )
{
free ( pl - > name ) ;
free ( pl ) ;
}
2003-06-11 06:20:48 -07:00
void
data_setup ( void )
{
2003-06-17 01:15:06 -07:00
edd_edje_file = _edje_edd_edje_file ;
edd_edje_part_collection = _edje_edd_edje_part_collection ;
2012-09-10 20:39:27 -07:00
2013-10-15 02:15:07 -07:00
part_dest_lookup = eina_hash_new ( EINA_KEY_LENGTH ( _part_lookup_key_length ) ,
EINA_KEY_CMP ( _part_lookup_key_cmp ) ,
EINA_KEY_HASH ( _part_lookup_key_hash ) ,
EINA_FREE_CB ( eina_list_free ) ,
8 ) ;
part_pc_dest_lookup = eina_hash_new ( EINA_KEY_LENGTH ( _part_lookup_key_length ) ,
EINA_KEY_CMP ( _part_lookup_key_pc_cmp ) ,
EINA_KEY_HASH ( _part_lookup_key_pc_hash ) ,
2012-09-10 20:39:27 -07:00
EINA_FREE_CB ( data_part_lookup_free ) ,
8 ) ;
2003-06-11 06:20:48 -07:00
}
2004-10-23 10:33:27 -07:00
static void
2012-05-15 05:29:22 -07:00
check_image_part_desc ( Edje_Part_Collection * pc , Edje_Part * ep ,
Edje_Part_Description_Image * epd , Eet_File * ef )
2004-10-23 10:33:27 -07:00
{
2010-08-15 11:14:33 -07:00
unsigned int i ;
2012-08-23 00:54:58 -07:00
2012-07-12 19:50:58 -07:00
if ( epd - > image . id = = - 1 & & epd - > common . visible )
WRN ( " Collection %s(%i): image attributes missing for "
" part \" %s \" , description \" %s \" %f " ,
2010-08-15 11:14:33 -07:00
pc - > part , pc - > id , ep - > name , epd - > common . state . name , epd - > common . state . value ) ;
2004-10-23 10:33:27 -07:00
2010-08-15 11:14:33 -07:00
for ( i = 0 ; i < epd - > image . tweens_count ; + + i )
2004-10-23 10:33:27 -07:00
{
2010-08-15 11:14:33 -07:00
if ( epd - > image . tweens [ i ] - > id = = - 1 )
2008-08-20 20:58:11 -07:00
error_and_abort ( ef , " Collection %i: tween image id missing for "
2012-07-31 15:42:03 -07:00
" part \" %s \" , description \" %s \" %f " ,
2010-07-16 04:37:58 -07:00
pc - > id , ep - > name , epd - > common . state . name , epd - > common . state . value ) ;
2008-08-20 20:58:11 -07:00
}
2004-10-23 10:33:27 -07:00
}
2015-01-29 12:21:05 -08:00
/* This function check loops between groups.
For example :
> part in group A . It ' s source is B .
> part in group B . It ' s source is C .
> part in group C . It ' s source is A < - here is error .
It ' s loop that we need to avoid ! */
static void
check_source_links ( Edje_Part_Collection * pc , Edje_Part * ep , Eet_File * ef , Eina_List * group_path )
{
unsigned int i ;
char * data ;
Edje_Part_Collection * pc_source ;
Eina_List * l ;
EINA_LIST_FOREACH ( edje_collections , l , pc_source )
{
/* Find sourced group */
2015-02-12 06:24:27 -08:00
if ( ep - > source & & pc_source - > part & & strcmp ( ep - > source , pc_source - > part ) = = 0 )
2015-01-29 12:21:05 -08:00
{
/* Go through every part to find parts with type GROUP */
for ( i = 0 ; i < pc_source - > parts_count ; + + i )
{
if ( ( pc_source - > parts [ i ] - > type = = EDJE_PART_TYPE_GROUP ) & &
( pc_source - > parts [ i ] - > source ) )
{
/* Make sure that this group isn't already in the tree of parents */
EINA_LIST_FOREACH ( group_path , l , data )
{
if ( data = = pc_source - > parts [ i ] - > source )
{
error_and_abort ( ef , " Recursive loop group '%s' "
" already included inside "
" part '%s' of group '%s' " ,
data , pc_source - > parts [ i ] - > name ,
pc - > part ) ;
}
}
group_path = eina_list_append ( group_path , ep - > source ) ;
check_source_links ( pc , pc_source - > parts [ i ] , ef , group_path ) ;
}
}
}
}
}
2008-11-23 21:15:15 -08:00
static void
2010-08-15 11:14:33 -07:00
check_packed_items ( Edje_Part_Collection * pc , Edje_Part * ep , Eet_File * ef )
2008-11-23 21:15:15 -08:00
{
2010-08-15 11:14:33 -07:00
unsigned int i ;
2015-01-28 08:47:54 -08:00
char * def_name ;
2008-11-23 21:15:15 -08:00
2010-08-15 11:14:33 -07:00
for ( i = 0 ; i < ep - > items_count ; + + i )
2008-11-23 21:15:15 -08:00
{
2015-01-28 08:47:54 -08:00
if ( ! ep - > items [ i ] - > name )
{
def_name = alloca ( strlen ( " item_ " ) + strlen ( " 0xFFFFFFFFFFFFFFFF " ) + 1 ) ;
sprintf ( def_name , " item_%p " , def_name ) ;
ep - > items [ i ] - > name = strdup ( def_name ) ;
}
2010-08-15 11:14:33 -07:00
if ( ep - > items [ i ] - > type = = EDJE_PART_TYPE_GROUP & & ! ep - > items [ i ] - > source )
2008-11-23 21:15:15 -08:00
error_and_abort ( ef , " Collection %i: missing source on packed item "
2012-07-31 15:42:03 -07:00
" of type GROUP in part \" %s \" " ,
2008-11-23 21:15:15 -08:00
pc - > id , ep - > name ) ;
2010-08-15 11:14:33 -07:00
if ( ep - > type = = EDJE_PART_TYPE_TABLE & & ( ep - > items [ i ] - > col < 0 | | ep - > items [ i ] - > row < 0 ) )
2008-12-17 18:43:20 -08:00
error_and_abort ( ef , " Collection %i: missing col/row on packed item "
2012-07-31 15:42:03 -07:00
" for part \" %s \" of type TABLE " ,
2008-12-17 18:43:20 -08:00
pc - > id , ep - > name ) ;
2008-11-23 21:15:15 -08:00
}
}
2010-09-30 14:31:00 -07:00
static void
check_nameless_state ( Edje_Part_Collection * pc , Edje_Part * ep , Edje_Part_Description_Common * ed , Eet_File * ef )
{
2014-03-21 12:35:08 -07:00
Edje_Part_Collection_Directory_Entry * de ;
if ( ed - > state . name ) return ;
de = eina_hash_find ( edje_collections_lookup , & pc - > id ) ;
error_and_abort ( ef , " Group '%s': part \" %s \" has description with missing state " ,
de - > entry , ep - > name ) ;
2010-09-30 14:31:00 -07:00
}
2004-10-23 10:33:27 -07:00
static void
2012-05-15 05:29:22 -07:00
check_part ( Edje_Part_Collection * pc , Edje_Part * ep , Eet_File * ef )
2004-10-23 10:33:27 -07:00
{
2010-09-30 14:31:00 -07:00
unsigned int i ;
2015-01-29 12:21:05 -08:00
Eina_List * group_path = NULL ;
2010-06-01 06:31:07 -07:00
/* FIXME: check image set and sort them. */
2010-08-15 11:14:33 -07:00
if ( ! ep - > default_desc )
2008-08-20 20:58:11 -07:00
error_and_abort ( ef , " Collection %i: default description missing "
2012-07-31 15:42:03 -07:00
" for part \" %s \" " , pc - > id , ep - > name ) ;
2004-10-23 10:33:27 -07:00
2010-09-30 14:31:00 -07:00
for ( i = 0 ; i < ep - > other . desc_count ; + + i )
check_nameless_state ( pc , ep , ep - > other . desc [ i ] , ef ) ;
2004-10-23 10:33:27 -07:00
if ( ep - > type = = EDJE_PART_TYPE_IMAGE )
{
2010-08-15 11:14:33 -07:00
check_image_part_desc ( pc , ep , ( Edje_Part_Description_Image * ) ep - > default_desc , ef ) ;
for ( i = 0 ; i < ep - > other . desc_count ; + + i )
check_image_part_desc ( pc , ep , ( Edje_Part_Description_Image * ) ep - > other . desc [ i ] , ef ) ;
2004-10-23 10:33:27 -07:00
}
2008-12-17 18:43:20 -08:00
else if ( ( ep - > type = = EDJE_PART_TYPE_BOX ) | |
( ep - > type = = EDJE_PART_TYPE_TABLE ) )
2008-11-23 21:15:15 -08:00
check_packed_items ( pc , ep , ef ) ;
2015-01-29 12:21:05 -08:00
else if ( ep - > type = = EDJE_PART_TYPE_GROUP )
check_source_links ( pc , ep , ef , group_path ) ;
2012-07-13 02:15:17 -07:00
/* FIXME: When mask are supported remove this check */
if ( ep - > clip_to_id ! = - 1 & &
2014-11-16 20:16:56 -08:00
( pc - > parts [ ep - > clip_to_id ] - > type ! = EDJE_PART_TYPE_RECTANGLE ) & &
( pc - > parts [ ep - > clip_to_id ] - > type ! = EDJE_PART_TYPE_IMAGE ) )
error_and_abort ( ef , " Collection %i: clip_to point to a non RECT/IMAGE part '%s' ! " ,
2012-07-13 02:15:17 -07:00
pc - > id , pc - > parts [ ep - > clip_to_id ] - > name ) ;
2004-10-23 10:33:27 -07:00
}
static void
2012-05-15 05:29:22 -07:00
check_program ( Edje_Part_Collection * pc , Edje_Program * ep , Eet_File * ef )
2004-10-23 10:33:27 -07:00
{
2007-08-26 05:54:51 -07:00
switch ( ep - > action )
2006-08-04 01:55:05 -07:00
{
2004-10-23 10:33:27 -07:00
case EDJE_ACTION_TYPE_STATE_SET :
case EDJE_ACTION_TYPE_ACTION_STOP :
case EDJE_ACTION_TYPE_DRAG_VAL_SET :
case EDJE_ACTION_TYPE_DRAG_VAL_STEP :
case EDJE_ACTION_TYPE_DRAG_VAL_PAGE :
2007-08-26 05:54:51 -07:00
if ( ! ep - > targets )
2008-08-20 20:58:11 -07:00
error_and_abort ( ef , " Collection %i: target missing in program "
2012-07-31 15:42:03 -07:00
" \" %s \" " , pc - > id , ep - > name ) ;
2004-10-23 10:33:27 -07:00
break ;
default :
break ;
2006-08-04 01:55:05 -07:00
}
}
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_head ( void * data , Ecore_Thread * thread EINA_UNUSED )
2003-06-11 06:20:48 -07:00
{
2012-05-15 05:29:22 -07:00
Head_Write * hw = data ;
2008-08-20 20:57:20 -07:00
int bytes = 0 ;
2012-05-15 05:29:22 -07:00
char buf [ PATH_MAX ] ;
2007-08-26 05:54:51 -07:00
2010-08-15 11:14:33 -07:00
if ( edje_file )
2003-06-16 06:55:13 -07:00
{
2010-08-15 11:14:33 -07:00
if ( edje_file - > collection )
2006-10-11 22:35:14 -07:00
{
2010-08-09 10:34:03 -07:00
Edje_Part_Collection_Directory_Entry * ce ;
EINA_LIST_FREE ( aliases , ce )
2006-10-11 22:35:14 -07:00
{
2010-08-12 08:05:56 -07:00
Edje_Part_Collection_Directory_Entry * sce ;
2010-08-09 10:34:03 -07:00
if ( ! ce - > entry )
2012-05-15 05:29:22 -07:00
{
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Collection %i: name missing. " , ce - > id ) ;
2012-05-15 05:29:22 -07:00
hw - > errstr = strdup ( buf ) ;
return ;
}
2010-08-12 08:05:56 -07:00
2012-09-10 21:10:13 -07:00
sce = eina_hash_find ( edje_collections_lookup , & ce - > id ) ;
if ( sce )
2012-05-15 05:29:22 -07:00
{
2012-09-10 21:10:13 -07:00
memcpy ( & ce - > count , & sce - > count , sizeof ( ce - > count ) ) ;
2012-05-15 05:29:22 -07:00
}
2012-09-10 21:10:13 -07:00
else
2012-05-15 05:29:22 -07:00
{
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Collection %s (%i) can't find an correct alias. " ,
2012-05-15 05:29:22 -07:00
ce - > entry , ce - > id ) ;
hw - > errstr = strdup ( buf ) ;
return ;
}
2012-09-10 21:10:13 -07:00
2010-08-15 11:14:33 -07:00
eina_hash_direct_add ( edje_file - > collection , ce - > entry , ce ) ;
2006-10-11 22:35:14 -07:00
}
}
2012-05-15 05:29:22 -07:00
bytes = eet_data_write ( hw - > ef , edd_edje_file , " edje/file " , edje_file ,
compress_mode ) ;
2003-10-18 19:11:06 -07:00
if ( bytes < = 0 )
2012-05-15 05:29:22 -07:00
{
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Unable to write \" edje_file \" entry to \" %s \" " ,
2012-05-15 05:29:22 -07:00
file_out ) ;
hw - > errstr = strdup ( buf ) ;
return ;
}
2003-06-16 06:55:13 -07:00
}
2008-08-20 20:57:20 -07:00
2012-07-31 15:42:03 -07:00
INF ( " Wrote %9i bytes (%4iKb) for \" edje_file \" header " ,
bytes , ( bytes + 512 ) / 1024 ) ;
2012-05-15 05:29:22 -07:00
}
static void
2013-01-03 18:08:14 -08:00
data_thread_head_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Head_Write * hw = data ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
if ( hw - > errstr )
2003-06-16 06:55:13 -07:00
{
2012-05-15 05:29:22 -07:00
error_and_abort ( hw - > ef , hw - > errstr ) ;
free ( hw - > errstr ) ;
2003-06-16 06:55:13 -07:00
}
2012-05-15 05:29:22 -07:00
free ( hw ) ;
}
2008-08-20 20:57:20 -07:00
2012-05-15 05:29:22 -07:00
static void
data_write_header ( Eet_File * ef )
{
Head_Write * hw ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
hw = calloc ( 1 , sizeof ( Head_Write ) ) ;
hw - > ef = ef ;
pending_threads + + ;
2012-05-16 00:43:14 -07:00
if ( threads )
ecore_thread_run ( data_thread_head , data_thread_head_end , NULL , hw ) ;
else
{
data_thread_head ( hw , NULL ) ;
data_thread_head_end ( hw , NULL ) ;
}
2008-08-20 20:57:20 -07:00
}
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_fonts ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
2012-05-15 19:15:45 -07:00
Fonts_Write * fc = data ;
2012-05-15 05:29:22 -07:00
Eina_List * ll ;
2012-05-20 00:06:57 -07:00
Eina_File * f = NULL ;
void * m = NULL ;
2012-05-15 05:29:22 -07:00
int bytes = 0 ;
char buf [ PATH_MAX ] ;
char buf2 [ PATH_MAX ] ;
2012-05-20 00:06:57 -07:00
f = eina_file_open ( fc - > fn - > file , 0 ) ;
2012-05-15 05:29:22 -07:00
if ( f )
2004-01-22 18:13:42 -08:00
{
2012-09-03 19:13:05 -07:00
using_file ( fc - > fn - > file , ' F ' ) ;
2012-05-20 00:06:57 -07:00
m = eina_file_map_all ( f , EINA_FILE_SEQUENTIAL ) ;
2012-05-15 05:29:22 -07:00
}
else
{
char * dat ;
2012-05-20 00:06:57 -07:00
2012-05-15 05:29:22 -07:00
EINA_LIST_FOREACH ( fnt_dirs , ll , dat )
{
snprintf ( buf , sizeof ( buf ) , " %s/%s " , dat , fc - > fn - > file ) ;
2012-05-20 00:06:57 -07:00
f = eina_file_open ( buf , 0 ) ;
2012-05-15 05:29:22 -07:00
if ( f )
{
2012-09-03 19:13:05 -07:00
using_file ( buf , ' F ' ) ;
2012-05-20 00:06:57 -07:00
m = eina_file_map_all ( f , EINA_FILE_SEQUENTIAL ) ;
if ( m ) break ;
eina_file_close ( f ) ;
f = NULL ;
2012-05-15 05:29:22 -07:00
}
}
}
2012-05-20 00:06:57 -07:00
if ( ! m )
2012-05-15 05:29:22 -07:00
{
2012-05-20 00:06:57 -07:00
if ( f ) eina_file_close ( f ) ;
2012-05-15 05:29:22 -07:00
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Unable to load font part \" %s \" entry to %s " ,
2012-05-15 05:29:22 -07:00
fc - > fn - > file , file_out ) ;
fc - > errstr = strdup ( buf ) ;
return ;
}
2012-05-20 00:06:57 -07:00
snprintf ( buf , sizeof ( buf ) , " edje/fonts/%s " , fc - > fn - > name ) ;
bytes = eet_write ( fc - > ef , buf , m , eina_file_size_get ( f ) , compress_mode ) ;
2012-05-22 21:22:41 -07:00
if ( ( bytes < = 0 ) | | eina_file_map_faulted ( f , m ) )
2012-05-15 05:29:22 -07:00
{
2012-05-20 00:06:57 -07:00
eina_file_map_free ( f , m ) ;
eina_file_close ( f ) ;
snprintf ( buf2 , sizeof ( buf2 ) ,
" Unable to write font part \" %s \" as \" %s \" "
2012-07-31 15:42:03 -07:00
" part entry to %s " , fc - > fn - > file , buf , file_out ) ;
2012-05-20 00:06:57 -07:00
fc - > errstr = strdup ( buf2 ) ;
return ;
2012-05-15 05:29:22 -07:00
}
2012-05-20 00:06:57 -07:00
2012-07-31 15:42:03 -07:00
INF ( " Wrote %9i bytes (%4iKb) for \" %s \" font entry \" %s \" compress: [real: %2.1f%%] " ,
bytes , ( bytes + 512 ) / 1024 , buf , fc - > fn - > file ,
100 - ( 100 * ( double ) bytes ) / ( ( double ) ( eina_file_size_get ( f ) ) )
) ;
2012-05-20 00:06:57 -07:00
eina_file_map_free ( f , m ) ;
eina_file_close ( f ) ;
2012-05-15 05:29:22 -07:00
}
2007-08-26 05:54:51 -07:00
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_fonts_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
2012-05-15 19:15:45 -07:00
Fonts_Write * fc = data ;
2012-05-15 05:29:22 -07:00
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
if ( fc - > errstr )
{
error_and_abort ( fc - > ef , fc - > errstr ) ;
free ( fc - > errstr ) ;
}
free ( fc ) ;
}
2007-08-26 05:54:51 -07:00
2012-05-15 05:29:22 -07:00
static void
data_write_fonts ( Eet_File * ef , int * font_num )
{
Eina_Iterator * it ;
2012-12-06 18:04:44 -08:00
Edje_Font * fn ;
2008-08-20 20:58:11 -07:00
2012-05-15 05:29:22 -07:00
if ( ! edje_file - > fonts ) return ;
2008-08-20 20:58:11 -07:00
2012-05-15 05:29:22 -07:00
it = eina_hash_iterator_data_new ( edje_file - > fonts ) ;
EINA_ITERATOR_FOREACH ( it , fn )
{
2012-05-15 19:15:45 -07:00
Fonts_Write * fc ;
2012-05-20 00:06:57 -07:00
2012-05-15 19:15:45 -07:00
fc = calloc ( 1 , sizeof ( Fonts_Write ) ) ;
2012-05-15 05:29:22 -07:00
if ( ! fc ) continue ;
fc - > ef = ef ;
fc - > fn = fn ;
2012-05-16 00:43:14 -07:00
pending_threads + + ;
if ( threads )
ecore_thread_run ( data_thread_fonts , data_thread_fonts_end , NULL , fc ) ;
else
{
data_thread_fonts ( fc , NULL ) ;
data_thread_fonts_end ( fc , NULL ) ;
}
2012-05-15 05:29:22 -07:00
* font_num + = 1 ;
2004-01-22 18:13:42 -08:00
}
2010-08-27 11:52:41 -07:00
eina_iterator_free ( it ) ;
2008-08-20 20:57:20 -07:00
}
2009-12-22 15:56:11 -08:00
static void
error_and_abort_image_load_error ( Eet_File * ef , const char * file , int error )
{
const char * errmsg = evas_load_error_str ( error ) ;
char hint [ 1024 ] = " " ;
if ( error = = EVAS_LOAD_ERROR_DOES_NOT_EXIST )
{
snprintf
( hint , sizeof ( hint ) ,
" Check if path to file \" %s \" is correct "
" (both directory and file name). " ,
file ) ;
}
else if ( error = = EVAS_LOAD_ERROR_CORRUPT_FILE )
{
snprintf
( hint , sizeof ( hint ) ,
" Check if file \" %s \" is consistent. " ,
file ) ;
}
else if ( error = = EVAS_LOAD_ERROR_UNKNOWN_FORMAT )
{
const char * ext = strrchr ( file , ' . ' ) ;
const char * * itr , * known_loaders [ ] = {
/* list from evas_image_load.c */
" png " ,
" jpg " ,
" jpeg " ,
" jfif " ,
" eet " ,
" edj " ,
" eap " ,
" edb " ,
" xpm " ,
" tiff " ,
" tif " ,
" svg " ,
" svgz " ,
" gif " ,
" pbm " ,
" pgm " ,
" ppm " ,
" pnm " ,
2012-05-15 19:15:45 -07:00
" bmp " ,
" ico " ,
" tga " ,
2014-04-17 21:12:03 -07:00
" tgv " ,
2009-12-22 15:56:11 -08:00
NULL
} ;
if ( ! ext )
{
snprintf
( hint , sizeof ( hint ) ,
" File \" %s \" does not have an extension, "
" maybe it should? " ,
file ) ;
goto show_err ;
}
ext + + ;
for ( itr = known_loaders ; * itr ; itr + + )
{
if ( strcasecmp ( ext , * itr ) = = 0 )
{
snprintf
( hint , sizeof ( hint ) ,
" Check if Evas was compiled with %s module enabled and "
" all required dependencies exist. " ,
ext ) ;
goto show_err ;
}
}
snprintf ( hint , sizeof ( hint ) ,
" Check if Evas supports loading files of type \" %s \" (%s) "
" and this module was compiled and all its dependencies exist. " ,
ext , file ) ;
}
show_err :
error_and_abort
2012-07-31 15:42:03 -07:00
( ef , " Unable to load image \" %s \" used by file \" %s \" : %s.%s " ,
2009-12-22 15:56:11 -08:00
file , file_out , errmsg , hint ) ;
}
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_image ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Image_Write * iw = data ;
2012-07-06 20:25:31 -07:00
char buf [ PATH_MAX ] , buf2 [ PATH_MAX ] ;
2012-05-15 05:29:22 -07:00
unsigned int * start , * end ;
Eina_Bool opaque = EINA_TRUE ;
2008-08-20 20:57:20 -07:00
int bytes = 0 ;
2012-05-15 05:29:22 -07:00
if ( ( iw - > data ) & & ( iw - > w > 0 ) & & ( iw - > h > 0 ) )
2003-06-11 06:20:48 -07:00
{
2014-04-17 03:04:31 -07:00
Eet_Image_Encoding lossy = EET_IMAGE_LOSSLESS ;
2014-04-17 21:12:03 -07:00
int mode , qual , comp = 0 ;
2012-05-20 00:06:57 -07:00
2012-05-15 05:29:22 -07:00
snprintf ( buf , sizeof ( buf ) , " edje/images/%i " , iw - > img - > id ) ;
qual = 80 ;
if ( ( iw - > img - > source_type = = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT ) & &
( iw - > img - > source_param = = 0 ) )
mode = 0 ; /* RAW */
else if ( ( iw - > img - > source_type = = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT ) & &
( iw - > img - > source_param = = 1 ) )
mode = 1 ; /* COMPRESS */
2014-04-18 00:39:37 -07:00
else if ( iw - > img - > source_type = = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1 )
mode = 3 ; /* LOSSY_ETC1 */
2014-06-13 01:37:12 -07:00
else if ( iw - > img - > source_type = = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2 )
mode = 4 ; /* LOSSY_ETC2 */
2012-05-15 05:29:22 -07:00
else
mode = 2 ; /* LOSSY */
if ( ( mode = = 0 ) & & ( no_raw ) )
{
mode = 1 ; /* promote compression */
iw - > img - > source_param = 95 ;
}
2014-06-13 01:37:12 -07:00
if ( ( mode = = 4 ) & & ( no_etc2 ) ) mode = 2 ; /* demote etc2 to jpeg */
2014-04-18 00:39:37 -07:00
if ( ( mode = = 3 ) & & ( no_etc1 ) ) mode = 2 ; /* demote etc1 to jpeg */
2012-05-15 05:29:22 -07:00
if ( ( mode = = 2 ) & & ( no_lossy ) ) mode = 1 ; /* demote compression */
if ( ( mode = = 1 ) & & ( no_comp ) )
{
if ( no_lossy ) mode = 0 ; /* demote compression */
else if ( no_raw )
{
iw - > img - > source_param = 90 ;
mode = 2 ; /* no choice. lossy */
}
}
if ( mode = = 2 )
{
qual = iw - > img - > source_param ;
if ( qual < min_quality ) qual = min_quality ;
if ( qual > max_quality ) qual = max_quality ;
2014-04-18 00:39:37 -07:00
lossy = EET_IMAGE_JPEG ;
}
2012-05-15 05:29:22 -07:00
if ( iw - > alpha )
{
start = ( unsigned int * ) iw - > data ;
end = start + ( iw - > w * iw - > h ) ;
while ( start < end )
{
if ( ( * start & 0xff000000 ) ! = 0xff000000 )
{
opaque = EINA_FALSE ;
break ;
}
start + + ;
}
if ( opaque ) iw - > alpha = 0 ;
}
2014-06-13 01:37:12 -07:00
if ( mode = = 3 )
{
qual = iw - > img - > source_param ;
if ( qual < min_quality ) qual = min_quality ;
if ( qual > max_quality ) qual = max_quality ;
// Enable TGV with LZ4. A bit redundant with EET compression.
comp = ! no_comp ;
2014-07-10 23:18:52 -07:00
lossy = opaque ? EET_IMAGE_ETC1 : EET_IMAGE_ETC1_ALPHA ;
2014-06-13 01:37:12 -07:00
}
if ( mode = = 4 )
{
qual = iw - > img - > source_param ;
if ( qual < min_quality ) qual = min_quality ;
if ( qual > max_quality ) qual = max_quality ;
lossy = opaque ? EET_IMAGE_ETC2_RGB : EET_IMAGE_ETC2_RGBA ;
}
2012-05-15 05:29:22 -07:00
if ( mode = = 0 )
bytes = eet_data_image_write ( iw - > ef , buf ,
iw - > data , iw - > w , iw - > h ,
iw - > alpha ,
0 , 0 , 0 ) ;
else if ( mode = = 1 )
bytes = eet_data_image_write ( iw - > ef , buf ,
iw - > data , iw - > w , iw - > h ,
iw - > alpha ,
compress_mode ,
0 , 0 ) ;
2014-06-13 01:37:12 -07:00
else if ( mode > = 2 )
2012-05-15 05:29:22 -07:00
bytes = eet_data_image_write ( iw - > ef , buf ,
iw - > data , iw - > w , iw - > h ,
iw - > alpha ,
2014-04-17 21:12:03 -07:00
comp , qual , lossy ) ;
2012-05-15 05:29:22 -07:00
if ( bytes < = 0 )
{
2012-07-06 20:25:31 -07:00
snprintf ( buf2 , sizeof ( buf2 ) ,
2012-05-15 05:29:22 -07:00
" Unable to write image part "
" \" %s \" as \" %s \" part entry to "
2012-07-31 15:42:03 -07:00
" %s " , iw - > img - > entry , buf , file_out ) ;
2012-07-06 20:25:31 -07:00
iw - > errstr = strdup ( buf2 ) ;
2012-05-15 05:29:22 -07:00
return ;
}
}
else
{
2012-08-20 00:46:51 -07:00
snprintf ( buf , sizeof ( buf ) , " edje/images/%i " , iw - > img - > id ) ;
2012-07-06 20:25:31 -07:00
snprintf ( buf2 , sizeof ( buf2 ) ,
2012-05-15 05:29:22 -07:00
" Unable to load image part "
" \" %s \" as \" %s \" part entry to "
2012-07-31 15:42:03 -07:00
" %s " , iw - > img - > entry , buf , file_out ) ;
2012-07-06 20:25:31 -07:00
iw - > errstr = strdup ( buf2 ) ;
2012-05-15 05:29:22 -07:00
return ;
}
2012-05-20 00:06:57 -07:00
2012-07-31 15:42:03 -07:00
if ( eina_log_domain_level_check ( _edje_cc_log_dom , EINA_LOG_LEVEL_INFO ) )
2012-05-15 05:29:22 -07:00
{
struct stat st ;
2012-05-15 19:15:45 -07:00
2012-05-20 00:06:57 -07:00
if ( ! iw - > path | | ( stat ( iw - > path , & st ) ) ) st . st_size = 0 ;
2013-08-05 04:42:31 -07:00
if ( st . st_size > 0 )
{
INF ( " Wrote %9i bytes (%4iKb) for \" %s \" image entry \" %s \" compress: [raw: %2.1f%%] [real: %2.1f%%] " ,
bytes , ( bytes + 512 ) / 1024 , buf , iw - > img - > entry ,
100 - ( 100 * ( double ) bytes ) / ( ( double ) ( iw - > w * iw - > h * 4 ) ) ,
100 - ( 100 * ( double ) bytes ) / ( ( double ) ( st . st_size ) )
) ;
}
2012-05-15 05:29:22 -07:00
}
}
2008-08-20 20:58:11 -07:00
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_image_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Image_Write * iw = data ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
if ( iw - > errstr )
{
error_and_abort ( iw - > ef , iw - > errstr ) ;
free ( iw - > errstr ) ;
2003-06-11 06:20:48 -07:00
}
2012-05-15 19:15:45 -07:00
if ( iw - > path ) free ( iw - > path ) ;
2012-05-15 05:29:22 -07:00
evas_object_del ( iw - > im ) ;
free ( iw ) ;
}
2004-10-23 10:33:27 -07:00
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_image_preload_done ( void * data , Evas * e EINA_UNUSED , Evas_Object * o , void * event_info EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Image_Write * iw = data ;
evas_object_image_size_get ( o , & iw - > w , & iw - > h ) ;
iw - > alpha = evas_object_image_alpha_get ( o ) ;
iw - > data = evas_object_image_data_get ( o , 0 ) ;
2012-05-16 00:43:14 -07:00
if ( threads )
ecore_thread_run ( data_thread_image , data_thread_image_end , NULL , iw ) ;
else
{
data_thread_image ( iw , NULL ) ;
data_thread_image_end ( iw , NULL ) ;
}
2008-08-20 20:57:20 -07:00
}
2012-05-15 05:29:22 -07:00
static void
data_write_images ( Eet_File * ef , int * image_num )
2011-11-04 05:18:13 -07:00
{
2012-05-15 05:29:22 -07:00
int i ;
Ecore_Evas * ee ;
Evas * evas ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
if ( ! ( ( edje_file ) & & ( edje_file - > image_dir ) ) ) return ;
ecore_evas_init ( ) ;
ee = ecore_evas_buffer_new ( 1 , 1 ) ;
if ( ! ee )
2012-07-31 15:42:03 -07:00
error_and_abort ( ef , " Cannot create buffer engine canvas for image load. " ) ;
2012-05-15 05:29:22 -07:00
evas = ecore_evas_get ( ee ) ;
2012-08-23 00:54:58 -07:00
2012-05-15 19:15:45 -07:00
for ( i = 0 ; i < ( int ) edje_file - > image_dir - > entries_count ; i + + )
2011-11-04 05:18:13 -07:00
{
2012-05-15 05:29:22 -07:00
Edje_Image_Directory_Entry * img ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
img = & edje_file - > image_dir - > entries [ i ] ;
if ( ( img - > source_type = = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL ) | |
( img - > entry = = NULL ) )
2011-11-04 05:18:13 -07:00
{
2012-05-15 05:29:22 -07:00
}
else
{
Evas_Object * im ;
Eina_List * ll ;
char * s ;
int load_err = EVAS_LOAD_ERROR_NONE ;
Image_Write * iw ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
iw = calloc ( 1 , sizeof ( Image_Write ) ) ;
iw - > ef = ef ;
iw - > img = img ;
iw - > im = im = evas_object_image_add ( evas ) ;
2012-07-06 20:25:31 -07:00
if ( threads )
evas_object_event_callback_add ( im ,
EVAS_CALLBACK_IMAGE_PRELOADED ,
data_image_preload_done ,
iw ) ;
2012-05-15 05:29:22 -07:00
EINA_LIST_FOREACH ( img_dirs , ll , s )
2011-11-04 05:18:13 -07:00
{
2012-05-15 05:29:22 -07:00
char buf [ PATH_MAX ] ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
snprintf ( buf , sizeof ( buf ) , " %s/%s " , s , img - > entry ) ;
evas_object_image_file_set ( im , buf , NULL ) ;
load_err = evas_object_image_load_error_get ( im ) ;
if ( load_err = = EVAS_LOAD_ERROR_NONE )
{
2012-05-15 19:15:45 -07:00
* image_num + = 1 ;
iw - > path = strdup ( buf ) ;
2012-05-15 05:29:22 -07:00
pending_threads + + ;
2012-07-06 20:25:31 -07:00
if ( threads )
evas_object_image_preload ( im , 0 ) ;
2012-09-03 19:13:05 -07:00
using_file ( buf , ' I ' ) ;
2012-07-06 20:25:31 -07:00
if ( ! threads )
data_image_preload_done ( iw , evas , im , NULL ) ;
2012-05-15 05:29:22 -07:00
break ;
}
2011-11-04 05:18:13 -07:00
}
2012-05-15 05:29:22 -07:00
if ( load_err ! = EVAS_LOAD_ERROR_NONE )
2011-11-04 05:18:13 -07:00
{
2012-05-15 05:29:22 -07:00
evas_object_image_file_set ( im , img - > entry , NULL ) ;
load_err = evas_object_image_load_error_get ( im ) ;
if ( load_err = = EVAS_LOAD_ERROR_NONE )
{
2012-05-15 19:15:45 -07:00
* image_num + = 1 ;
iw - > path = strdup ( img - > entry ) ;
2012-05-15 05:29:22 -07:00
pending_threads + + ;
2012-07-06 20:25:31 -07:00
if ( threads )
evas_object_image_preload ( im , 0 ) ;
2012-09-03 19:13:05 -07:00
using_file ( img - > entry , ' I ' ) ;
2012-07-06 20:25:31 -07:00
if ( ! threads )
data_image_preload_done ( iw , evas , im , NULL ) ;
2012-05-15 05:29:22 -07:00
}
else
2013-12-11 01:20:13 -08:00
{
error_and_abort_image_load_error
( ef , img - > entry , load_err ) ;
exit ( 1 ) ; // ensure static analysis tools know we exit
}
2011-11-04 05:18:13 -07:00
}
2012-05-15 05:29:22 -07:00
}
}
}
static void
2013-01-03 18:08:14 -08:00
data_thread_sounds ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Sound_Write * sw = data ;
Eina_List * ll ;
2011-11-04 05:18:13 -07:00
# ifdef HAVE_LIBSNDFILE
2012-05-15 05:29:22 -07:00
Edje_Sound_Encode * enc_info ;
# endif
char * dir_path = NULL ;
char snd_path [ PATH_MAX ] ;
char sndid_str [ 15 ] ;
2012-05-20 00:06:57 -07:00
Eina_File * f = NULL ;
void * m = NULL ;
2012-05-15 05:29:22 -07:00
int bytes = 0 ;
// Search the Sound file in all the -sd ( sound directory )
EINA_LIST_FOREACH ( snd_dirs , ll , dir_path )
{
snprintf ( ( char * ) snd_path , sizeof ( snd_path ) , " %s/%s " , dir_path ,
sw - > sample - > snd_src ) ;
2012-05-20 00:06:57 -07:00
f = eina_file_open ( snd_path , 0 ) ;
if ( f ) break ;
2012-05-15 05:29:22 -07:00
}
2012-05-20 00:06:57 -07:00
if ( ! f )
2012-05-15 05:29:22 -07:00
{
snprintf ( ( char * ) snd_path , sizeof ( snd_path ) , " %s " ,
sw - > sample - > snd_src ) ;
2012-05-20 00:06:57 -07:00
f = eina_file_open ( snd_path , 0 ) ;
2012-05-15 05:29:22 -07:00
}
# ifdef HAVE_LIBSNDFILE
2012-05-20 00:06:57 -07:00
if ( f ) eina_file_close ( f ) ;
2012-05-15 05:29:22 -07:00
enc_info = _edje_multisense_encode ( snd_path , sw - > sample ,
sw - > sample - > quality ) ;
2012-05-20 00:06:57 -07:00
f = eina_file_open ( enc_info - > file , 0 ) ;
2012-09-03 19:13:05 -07:00
if ( f ) using_file ( enc_info - > file , ' S ' ) ;
2011-11-04 05:18:13 -07:00
# else
2012-09-03 19:13:05 -07:00
if ( f ) using_file ( snd_path , ' S ' ) ;
2011-11-04 05:18:13 -07:00
# endif
2012-05-20 00:06:57 -07:00
if ( ! f )
2012-05-15 05:29:22 -07:00
{
2012-07-31 15:42:03 -07:00
ERR ( " Unable to load sound data of: %s " , sw - > sample - > name ) ;
2012-05-15 05:29:22 -07:00
exit ( - 1 ) ;
}
2012-05-20 00:06:57 -07:00
2012-05-15 05:29:22 -07:00
snprintf ( sndid_str , sizeof ( sndid_str ) , " edje/sounds/%i " , sw - > sample - > id ) ;
2012-05-20 00:06:57 -07:00
m = eina_file_map_all ( f , EINA_FILE_WILLNEED ) ;
if ( m )
2012-05-15 05:29:22 -07:00
{
2012-05-20 00:06:57 -07:00
bytes = eet_write ( sw - > ef , sndid_str , m , eina_file_size_get ( f ) ,
EET_COMPRESSION_NONE ) ;
if ( eina_file_map_faulted ( f , m ) )
{
2012-07-31 15:42:03 -07:00
ERR ( " File access error when reading '%s' " ,
eina_file_filename_get ( f ) ) ;
2012-05-20 00:06:57 -07:00
exit ( - 1 ) ;
}
eina_file_map_free ( f , m ) ;
2012-05-15 05:29:22 -07:00
}
2012-05-20 00:06:57 -07:00
eina_file_close ( f ) ;
2011-11-04 05:18:13 -07:00
# ifdef HAVE_LIBSNDFILE
2012-05-15 05:29:22 -07:00
//If encoded temporary file, delete it.
if ( enc_info - > encoded ) unlink ( enc_info - > file ) ;
2011-11-04 05:18:13 -07:00
# endif
# ifdef HAVE_LIBSNDFILE
2012-07-31 15:42:03 -07:00
INF ( " Wrote %9i bytes (%4iKb) for \" %s \" %s sound entry \" %s \" " ,
bytes , ( bytes + 512 ) / 1024 ,
sndid_str , enc_info - > comp_type , sw - > sample - > name ) ;
2011-11-04 05:18:13 -07:00
# else
2012-07-31 15:42:03 -07:00
INF ( " Wrote %9i bytes (%4iKb) for \" %s \" %s sound entry \" %s \" " ,
bytes , ( bytes + 512 ) / 1024 ,
sndid_str , " RAW PCM " , sw - > sample - > name ) ;
2011-11-04 05:18:13 -07:00
# endif
2012-07-31 15:42:03 -07:00
2011-11-04 05:18:13 -07:00
# ifdef HAVE_LIBSNDFILE
2012-05-15 05:29:22 -07:00
if ( ( enc_info - > file ) & & ( ! enc_info - > encoded ) )
eina_stringshare_del ( enc_info - > file ) ;
if ( enc_info ) free ( enc_info ) ;
enc_info = NULL ;
2011-11-04 05:18:13 -07:00
# endif
2012-05-15 05:29:22 -07:00
}
static void
2013-01-03 18:08:14 -08:00
data_thread_sounds_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Sound_Write * sw = data ;
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
free ( sw ) ;
}
static void
data_write_sounds ( Eet_File * ef , int * sound_num )
{
if ( ( edje_file ) & & ( edje_file - > sound_dir ) )
{
int i ;
for ( i = 0 ; i < ( int ) edje_file - > sound_dir - > samples_count ; i + + )
{
Sound_Write * sw ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
sw = calloc ( 1 , sizeof ( Sound_Write ) ) ;
if ( ! sw ) continue ;
sw - > ef = ef ;
sw - > sample = & edje_file - > sound_dir - > samples [ i ] ;
sw - > i = i ;
* sound_num + = 1 ;
pending_threads + + ;
2012-05-16 00:43:14 -07:00
if ( threads )
ecore_thread_run ( data_thread_sounds , data_thread_sounds_end , NULL , sw ) ;
else
{
data_thread_sounds ( sw , NULL ) ;
data_thread_sounds_end ( sw , NULL ) ;
}
2011-11-04 05:18:13 -07:00
}
}
}
2014-03-19 21:00:20 -07:00
static void
data_thread_vibrations ( void * data , Ecore_Thread * thread EINA_UNUSED )
{
Vibration_Write * vw = data ;
Eina_List * ll ;
char * dir_path = NULL ;
char path [ PATH_MAX ] ;
char id_str [ 30 ] ;
Eina_File * f = NULL ;
void * m = NULL ;
int bytes = 0 ;
EINA_LIST_FOREACH ( vibration_dirs , ll , dir_path )
{
snprintf ( ( char * ) path , sizeof ( path ) , " %s/%s " , dir_path ,
vw - > sample - > src ) ;
f = eina_file_open ( path , 0 ) ;
if ( f ) break ;
}
if ( ! f )
{
snprintf ( ( char * ) path , sizeof ( path ) , " %s " ,
vw - > sample - > src ) ;
f = eina_file_open ( path , 0 ) ;
}
if ( f ) using_file ( path , ' S ' ) ;
if ( ! f )
{
ERR ( " Unable to load vibration data of: %s " , vw - > sample - > src ) ;
exit ( - 1 ) ;
}
snprintf ( id_str , sizeof ( id_str ) , " edje/vibrations/%i " , vw - > sample - > id ) ;
m = eina_file_map_all ( f , EINA_FILE_WILLNEED ) ;
if ( m )
{
bytes = eet_write ( vw - > ef , id_str , m , eina_file_size_get ( f ) ,
EET_COMPRESSION_NONE ) ;
if ( eina_file_map_faulted ( f , m ) )
{
ERR ( " File access error when reading '%s' " ,
eina_file_filename_get ( f ) ) ;
exit ( - 1 ) ;
}
eina_file_map_free ( f , m ) ;
}
eina_file_close ( f ) ;
INF ( " Wrote %9i bytes (%4iKb) for \" %s \" %s vibration entry \" %s \" " ,
bytes , ( bytes + 512 ) / 1024 ,
id_str , " RAW " , vw - > sample - > name ) ;
}
static void
data_thread_vibrations_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
{
Vibration_Write * sw = data ;
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
free ( sw ) ;
}
static void
data_write_vibrations ( Eet_File * ef , int * num )
{
if ( ( edje_file ) & & ( edje_file - > vibration_dir ) )
{
int i ;
for ( i = 0 ; i < ( int ) edje_file - > vibration_dir - > samples_count ; i + + )
{
Vibration_Write * vw ;
vw = calloc ( 1 , sizeof ( Vibration_Write ) ) ;
if ( ! vw ) continue ;
vw - > ef = ef ;
vw - > sample = & edje_file - > vibration_dir - > samples [ i ] ;
vw - > i = i ;
* num + = 1 ;
pending_threads + + ;
if ( threads )
ecore_thread_run ( data_thread_vibrations , data_thread_vibrations_end , NULL , vw ) ;
else
{
data_thread_vibrations ( vw , NULL ) ;
data_thread_vibrations_end ( vw , NULL ) ;
}
}
}
}
2008-08-20 20:57:20 -07:00
static void
check_groups ( Eet_File * ef )
{
2010-08-15 11:14:33 -07:00
Edje_Part_Collection * pc ;
2008-10-22 04:34:42 -07:00
Eina_List * l ;
2008-08-20 20:57:20 -07:00
2004-10-23 10:33:27 -07:00
/* sanity checks for parts and programs */
2008-10-22 04:34:42 -07:00
EINA_LIST_FOREACH ( edje_collections , l , pc )
2003-06-16 06:55:13 -07:00
{
2010-08-15 11:14:33 -07:00
unsigned int i ;
for ( i = 0 ; i < pc - > parts_count ; + + i )
check_part ( pc , pc - > parts [ i ] , ef ) ;
2008-10-22 04:34:42 -07:00
2010-08-15 11:14:33 -07:00
# define CHECK_PROGRAM(Type, Pc, It) \
for ( It = 0 ; It < Pc - > programs . Type # # _count ; + + It ) \
check_program ( Pc , Pc - > programs . Type [ i ] , ef ) ; \
CHECK_PROGRAM ( fnmatch , pc , i ) ;
CHECK_PROGRAM ( strcmp , pc , i ) ;
CHECK_PROGRAM ( strncmp , pc , i ) ;
CHECK_PROGRAM ( strrncmp , pc , i ) ;
CHECK_PROGRAM ( nocmp , pc , i ) ;
2004-01-22 18:13:42 -08:00
}
2008-08-20 20:57:20 -07:00
}
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_group ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Group_Write * gw = data ;
char buf [ PATH_MAX ] ;
snprintf ( buf , sizeof ( buf ) , " edje/collections/%i " , gw - > pc - > id ) ;
2014-01-10 01:45:01 -08:00
eet_data_write ( gw - > ef , edd_edje_part_collection , buf , gw - > pc ,
compress_mode ) ;
2012-05-15 05:29:22 -07:00
return ;
}
static void
2013-01-03 18:08:14 -08:00
data_thread_group_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Group_Write * gw = data ;
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
if ( gw - > errstr )
{
error_and_abort ( gw - > ef , gw - > errstr ) ;
free ( gw - > errstr ) ;
}
free ( gw ) ;
}
static void
2008-08-20 20:57:20 -07:00
data_write_groups ( Eet_File * ef , int * collection_num )
{
2008-10-22 04:34:42 -07:00
Eina_List * l ;
2010-08-09 10:34:03 -07:00
Edje_Part_Collection * pc ;
2008-08-20 20:57:20 -07:00
2008-10-22 04:34:42 -07:00
EINA_LIST_FOREACH ( edje_collections , l , pc )
2004-01-22 18:13:42 -08:00
{
2012-05-15 05:29:22 -07:00
Group_Write * gw ;
2008-08-20 20:58:11 -07:00
2012-05-15 05:29:22 -07:00
gw = calloc ( 1 , sizeof ( Group_Write ) ) ;
if ( ! gw )
{
2012-07-31 15:42:03 -07:00
error_and_abort ( ef , " Cannot allocate memory for group writer " ) ;
2012-05-15 05:29:22 -07:00
return ;
}
gw - > ef = ef ;
gw - > pc = pc ;
pending_threads + + ;
2012-05-16 00:43:14 -07:00
if ( threads )
ecore_thread_run ( data_thread_group , data_thread_group_end , NULL , gw ) ;
else
{
data_thread_group ( gw , NULL ) ;
data_thread_group_end ( gw , NULL ) ;
}
2012-05-15 05:29:22 -07:00
* collection_num + = 1 ;
2003-06-16 06:55:13 -07:00
}
2008-08-20 20:57:20 -07:00
}
static void
2011-06-14 00:02:14 -07:00
create_script_file ( Eet_File * ef , const char * filename , const Code * cd , int fd )
2008-08-20 20:57:20 -07:00
{
2011-06-14 00:02:14 -07:00
FILE * f = fdopen ( fd , " wb " ) ;
2008-08-20 20:57:56 -07:00
if ( ! f )
2008-08-20 20:58:11 -07:00
error_and_abort ( ef , " Unable to open temp file \" %s \" for script "
2012-07-31 15:42:03 -07:00
" compilation. " , filename ) ;
2008-08-20 20:57:20 -07:00
2008-10-22 04:34:42 -07:00
Eina_List * ll ;
Code_Program * cp ;
2008-08-20 20:57:56 -07:00
fprintf ( f , " #include <edje> \n " ) ;
int ln = 2 ;
if ( cd - > shared )
{
while ( ln < ( cd - > l1 - 1 ) )
{
fprintf ( f , " \n " ) ;
ln + + ;
}
{
char * sp ;
int hash = 0 ;
int newlined = 0 ;
for ( sp = cd - > shared ; * sp ; sp + + )
{
if ( ( sp [ 0 ] = = ' # ' ) & & ( newlined ) )
{
hash = 1 ;
}
newlined = 0 ;
if ( sp [ 0 ] = = ' \n ' ) newlined = 1 ;
if ( ! hash ) fputc ( sp [ 0 ] , f ) ;
else if ( sp [ 0 ] = = ' \n ' ) hash = 0 ;
}
fputc ( ' \n ' , f ) ;
}
ln + = cd - > l2 - cd - > l1 + 1 ;
}
2008-10-22 04:34:42 -07:00
EINA_LIST_FOREACH ( cd - > programs , ll , cp )
2008-08-20 20:57:56 -07:00
{
if ( cp - > script )
{
while ( ln < ( cp - > l1 - 1 ) )
{
fprintf ( f , " \n " ) ;
ln + + ;
}
/* FIXME: this prototype needs to be */
/* formalised and set in stone */
fprintf ( f , " public _p%i(sig[], src[]) { " , cp - > id ) ;
{
char * sp ;
int hash = 0 ;
int newlined = 0 ;
for ( sp = cp - > script ; * sp ; sp + + )
{
if ( ( sp [ 0 ] = = ' # ' ) & & ( newlined ) )
{
hash = 1 ;
}
newlined = 0 ;
if ( sp [ 0 ] = = ' \n ' ) newlined = 1 ;
if ( ! hash ) fputc ( sp [ 0 ] , f ) ;
else if ( sp [ 0 ] = = ' \n ' ) hash = 0 ;
}
}
2011-05-16 05:16:54 -07:00
fprintf ( f , " } \n " ) ;
2008-08-20 20:57:56 -07:00
ln + = cp - > l2 - cp - > l1 + 1 ;
}
}
fclose ( f ) ;
}
static void
2013-01-03 18:08:14 -08:00
data_thread_script ( void * data , Ecore_Thread * thread EINA_UNUSED )
2008-08-20 20:57:56 -07:00
{
2012-05-15 19:15:45 -07:00
Script_Write * sc = data ;
2008-08-20 20:57:56 -07:00
FILE * f ;
2012-05-15 05:29:22 -07:00
int size ;
char buf [ PATH_MAX ] ;
2007-08-26 05:54:51 -07:00
2012-05-15 05:29:22 -07:00
f = fdopen ( sc - > tmpo_fd , " rb " ) ;
2008-08-20 20:57:56 -07:00
if ( ! f )
2012-05-15 05:29:22 -07:00
{
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Unable to open script object \" %s \" for reading. " ,
2012-05-15 05:29:22 -07:00
sc - > tmpo ) ;
sc - > errstr = strdup ( buf ) ;
return ;
}
2008-08-20 20:57:56 -07:00
fseek ( f , 0 , SEEK_END ) ;
2012-05-15 05:29:22 -07:00
size = ftell ( f ) ;
2008-08-20 20:57:56 -07:00
rewind ( f ) ;
if ( size > 0 )
{
2012-05-15 05:29:22 -07:00
void * dat = malloc ( size ) ;
2008-08-20 20:57:56 -07:00
2012-05-15 05:29:22 -07:00
if ( dat )
2004-03-27 21:26:17 -08:00
{
2012-05-15 05:29:22 -07:00
if ( fread ( dat , size , 1 , f ) ! = 1 )
{
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Unable to read all of script object \" %s \" " ,
2012-05-15 05:29:22 -07:00
sc - > tmpo ) ;
sc - > errstr = strdup ( buf ) ;
2013-06-25 08:23:03 -07:00
free ( dat ) ;
2013-08-05 07:32:12 -07:00
fclose ( f ) ;
2012-05-15 05:29:22 -07:00
return ;
}
snprintf ( buf , sizeof ( buf ) , " edje/scripts/embryo/compiled/%i " ,
sc - > i ) ;
eet_write ( sc - > ef , buf , dat , size , compress_mode ) ;
free ( dat ) ;
2008-08-20 20:57:56 -07:00
}
2012-05-15 05:29:22 -07:00
else
{
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Alloc failed for %lu bytes " , ( unsigned long ) size ) ;
2012-05-15 05:29:22 -07:00
sc - > errstr = strdup ( buf ) ;
2013-08-05 07:32:12 -07:00
fclose ( f ) ;
2012-05-15 05:29:22 -07:00
return ;
}
2008-08-20 20:57:56 -07:00
}
fclose ( f ) ;
2012-05-15 05:29:22 -07:00
2014-08-21 12:03:28 -07:00
if ( no_save )
WRN ( " You are removing the source from this Edje file. This may break some use cases. \n Be aware of your choice and the poor kitten you are harming with it! " ) ;
else
2012-05-15 05:29:22 -07:00
{
Eina_List * ll ;
Code_Program * cp ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
if ( sc - > cd - > original )
{
snprintf ( buf , PATH_MAX , " edje/scripts/embryo/source/%i " , sc - > i ) ;
eet_write ( sc - > ef , buf , sc - > cd - > original ,
strlen ( sc - > cd - > original ) + 1 , compress_mode ) ;
}
EINA_LIST_FOREACH ( sc - > cd - > programs , ll , cp )
{
if ( ! cp - > original ) continue ;
snprintf ( buf , PATH_MAX , " edje/scripts/embryo/source/%i/%i " ,
sc - > i , cp - > id ) ;
eet_write ( sc - > ef , buf , cp - > original ,
strlen ( cp - > original ) + 1 , compress_mode ) ;
}
}
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
unlink ( sc - > tmpn ) ;
unlink ( sc - > tmpo ) ;
2014-09-10 06:41:59 -07:00
eina_tmpstr_del ( sc - > tmpn ) ;
eina_tmpstr_del ( sc - > tmpo ) ;
2012-05-15 05:29:22 -07:00
close ( sc - > tmpn_fd ) ;
close ( sc - > tmpo_fd ) ;
}
static void
2013-01-03 18:08:14 -08:00
data_thread_script_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
2012-05-15 19:15:45 -07:00
Script_Write * sc = data ;
2012-05-15 05:29:22 -07:00
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
if ( sc - > errstr )
{
error_and_abort ( sc - > ef , sc - > errstr ) ;
free ( sc - > errstr ) ;
}
free ( sc ) ;
}
static Eina_Bool
2013-01-03 18:08:14 -08:00
data_scripts_exe_del_cb ( void * data EINA_UNUSED , int evtype EINA_UNUSED , void * evinfo )
2012-05-15 05:29:22 -07:00
{
2012-05-15 19:15:45 -07:00
Script_Write * sc = data ;
2012-05-15 05:29:22 -07:00
Ecore_Exe_Event_Del * ev = evinfo ;
2012-05-23 22:37:36 -07:00
2012-05-15 05:29:22 -07:00
if ( ! ev - > exe ) return ECORE_CALLBACK_RENEW ;
if ( ecore_exe_data_get ( ev - > exe ) ! = sc ) return ECORE_CALLBACK_RENEW ;
if ( ev - > exit_code ! = 0 )
{
2012-07-31 15:42:03 -07:00
error_and_abort ( sc - > ef , " Compiling script code not clean. " ) ;
2012-05-15 05:29:22 -07:00
return ECORE_CALLBACK_CANCEL ;
}
2012-05-16 00:43:14 -07:00
if ( threads )
2012-05-23 22:37:36 -07:00
{
ecore_thread_run ( data_thread_script , data_thread_script_end , NULL , sc ) ;
}
2012-05-16 00:43:14 -07:00
else
{
data_thread_script ( sc , NULL ) ;
data_thread_script_end ( sc , NULL ) ;
}
2012-05-23 22:37:36 -07:00
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
2012-05-15 05:29:22 -07:00
return ECORE_CALLBACK_CANCEL ;
2008-08-20 20:57:56 -07:00
}
static void
data_write_scripts ( Eet_File * ef )
{
2008-10-22 04:34:42 -07:00
Eina_List * l ;
2013-01-03 18:08:14 -08:00
char embryo_cc_path [ PATH_MAX ] = " " ;
char inc_path [ PATH_MAX ] = " " ;
2008-08-20 20:57:56 -07:00
int i ;
2008-06-06 11:31:49 -07:00
2013-01-03 18:08:14 -08:00
# ifdef _WIN32
# define BIN_EXT ".exe"
# else
# define BIN_EXT
# endif
if ( getenv ( " EFL_RUN_IN_TREE " ) )
{
snprintf ( embryo_cc_path , sizeof ( embryo_cc_path ) ,
" %s/src/bin/embryo/embryo_cc " BIN_EXT ,
PACKAGE_BUILD_DIR ) ;
snprintf ( inc_path , sizeof ( inc_path ) ,
2013-01-10 19:57:29 -08:00
" %s/data/edje/include " , PACKAGE_SRC_DIR ) ;
2013-01-03 18:08:14 -08:00
if ( ! ecore_file_exists ( embryo_cc_path ) )
embryo_cc_path [ 0 ] = ' \0 ' ;
}
if ( embryo_cc_path [ 0 ] = = ' \0 ' )
{
snprintf ( embryo_cc_path , sizeof ( embryo_cc_path ) ,
" %s/embryo_cc " BIN_EXT ,
eina_prefix_bin_get ( pfx ) ) ;
snprintf ( inc_path , sizeof ( inc_path ) ,
" %s/include " ,
eina_prefix_data_get ( pfx ) ) ;
}
# undef BIN_EXT
2008-10-22 04:34:42 -07:00
for ( i = 0 , l = codes ; l ; l = eina_list_next ( l ) , i + + )
2008-08-20 20:57:56 -07:00
{
2008-10-22 04:34:42 -07:00
Code * cd = eina_list_data_get ( l ) ;
2012-05-15 19:15:45 -07:00
Script_Write * sc ;
2012-05-15 05:29:22 -07:00
char buf [ PATH_MAX ] ;
2011-10-09 19:49:50 -07:00
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
if ( cd - > is_lua )
continue ;
2008-08-20 20:57:56 -07:00
if ( ( ! cd - > shared ) & & ( ! cd - > programs ) )
continue ;
2012-05-15 19:15:45 -07:00
sc = calloc ( 1 , sizeof ( Script_Write ) ) ;
2012-05-15 05:29:22 -07:00
sc - > ef = ef ;
sc - > cd = cd ;
sc - > i = i ;
2014-09-10 06:41:59 -07:00
sc - > tmpn_fd = eina_file_mkstemp ( " edje_cc.sma-tmp-XXXXXX " , & sc - > tmpn ) ;
2012-05-15 05:29:22 -07:00
if ( sc - > tmpn_fd < 0 )
error_and_abort ( ef , " Unable to open temp file \" %s \" for script "
2012-07-31 15:42:03 -07:00
" compilation. " , sc - > tmpn ) ;
2014-09-10 06:41:59 -07:00
sc - > tmpo_fd = eina_file_mkstemp ( " edje_cc.amx-tmp-XXXXXX " , & sc - > tmpo ) ;
2012-05-15 05:29:22 -07:00
if ( sc - > tmpo_fd < 0 )
2010-11-30 07:37:20 -08:00
{
2012-05-15 05:29:22 -07:00
unlink ( sc - > tmpn ) ;
2014-09-10 06:41:59 -07:00
eina_tmpstr_del ( sc - > tmpn ) ;
2012-05-15 05:29:22 -07:00
error_and_abort ( ef , " Unable to open temp file \" %s \" for script "
2014-09-10 06:27:35 -07:00
" compilation. " , sc - > tmpo ) ;
2010-11-30 07:37:20 -08:00
}
2012-05-15 05:29:22 -07:00
create_script_file ( ef , sc - > tmpn , cd , sc - > tmpn_fd ) ;
snprintf ( buf , sizeof ( buf ) ,
2013-01-03 18:08:14 -08:00
" %s -i %s -o %s %s " , embryo_cc_path , inc_path ,
2012-06-21 01:55:38 -07:00
sc - > tmpo , sc - > tmpn ) ;
2012-05-23 22:37:36 -07:00
pending_threads + + ;
2012-05-15 05:29:22 -07:00
sc - > exe = ecore_exe_run ( buf , sc ) ;
ecore_event_handler_add ( ECORE_EXE_EVENT_DEL ,
data_scripts_exe_del_cb , sc ) ;
2004-03-27 21:26:17 -08:00
}
2008-08-20 20:57:20 -07:00
}
2009-10-25 04:40:06 -07:00
# ifdef LUA_BINARY
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
static int
2013-01-03 18:08:14 -08:00
_edje_lua_script_writer ( lua_State * L EINA_UNUSED , const void * chunk_buf , size_t chunk_size , void * _data )
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
{
2012-05-15 19:15:45 -07:00
Script_Lua_Writer * data ;
2009-10-25 04:40:06 -07:00
void * old ;
2009-10-25 04:24:55 -07:00
2014-12-11 19:22:49 -08:00
2012-05-15 19:15:45 -07:00
data = ( Script_Lua_Writer * ) _data ;
2009-10-25 04:40:06 -07:00
old = data - > buf ;
2014-12-11 19:22:49 -08:00
data - > buf = realloc ( data - > buf , data - > size + chunk_size ) ;
if ( data - > buf )
{
memcpy ( & ( ( data - > buf ) [ data - > size ] ) , chunk_buf , chunk_size ) ;
data - > size + = chunk_size ;
}
else
{
ERR ( " Failed to copy chunk buffer. \n " ) ;
data - > buf = old ;
}
2009-10-25 04:40:06 -07:00
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
return 0 ;
}
2009-10-25 04:40:06 -07:00
# endif
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
void
2012-05-15 19:15:45 -07:00
_edje_lua_error_and_abort ( lua_State * L , int err_code , Script_Write * sc )
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
{
2012-05-15 05:29:22 -07:00
char buf [ PATH_MAX ] ;
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
char * err_type ;
2012-08-23 00:54:58 -07:00
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
switch ( err_code )
{
2012-05-15 05:29:22 -07:00
case LUA_ERRRUN :
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
err_type = " runtime " ;
break ;
2012-05-15 05:29:22 -07:00
case LUA_ERRSYNTAX :
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
err_type = " syntax " ;
break ;
2012-05-15 05:29:22 -07:00
case LUA_ERRMEM :
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
err_type = " memory allocation " ;
break ;
2012-05-15 05:29:22 -07:00
case LUA_ERRERR :
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
err_type = " error handler " ;
break ;
2012-05-15 05:29:22 -07:00
default :
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
err_type = " unknown " ;
break ;
}
2012-05-15 05:29:22 -07:00
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Lua %s error: %s " , err_type , lua_tostring ( L , - 1 ) ) ;
2012-05-15 05:29:22 -07:00
sc - > errstr = strdup ( buf ) ;
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
}
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_lua_script ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
2012-05-15 19:15:45 -07:00
Script_Write * sc = data ;
2012-05-15 05:29:22 -07:00
char buf [ PATH_MAX ] ;
lua_State * L ;
int ln = 1 ;
luaL_Buffer b ;
2012-05-15 19:15:45 -07:00
Script_Lua_Writer dat ;
2012-05-15 05:29:22 -07:00
Eina_List * ll ;
Code_Program * cp ;
# ifdef LUA_BINARY
int err_code ;
# endif
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
L = luaL_newstate ( ) ;
if ( ! L )
{
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Lua error: Lua state could not be initialized " ) ;
2012-05-15 05:29:22 -07:00
sc - > errstr = strdup ( buf ) ;
return ;
}
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
luaL_buffinit ( L , & b ) ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
dat . buf = NULL ;
dat . size = 0 ;
if ( sc - > cd - > shared )
{
while ( ln < ( sc - > cd - > l1 - 1 ) )
{
luaL_addchar ( & b , ' \n ' ) ;
ln + + ;
}
luaL_addstring ( & b , sc - > cd - > shared ) ;
ln + = sc - > cd - > l2 - sc - > cd - > l1 ;
}
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
EINA_LIST_FOREACH ( sc - > cd - > programs , ll , cp )
{
if ( cp - > script )
{
while ( ln < ( cp - > l1 - 1 ) )
{
luaL_addchar ( & b , ' \n ' ) ;
ln + + ;
}
luaL_addstring ( & b , " _G[ " ) ;
lua_pushnumber ( L , cp - > id ) ;
luaL_addvalue ( & b ) ;
luaL_addstring ( & b , " ] = function (ed, signal, source) " ) ;
luaL_addstring ( & b , cp - > script ) ;
luaL_addstring ( & b , " end \n " ) ;
ln + = cp - > l2 - cp - > l1 + 1 ;
}
}
luaL_pushresult ( & b ) ;
# ifdef LUA_BINARY
if ( err_code = luaL_loadstring ( L , lua_tostring ( L , - 1 ) ) )
{
_edje_lua_error_and_abort ( L , err_code , sc ) ;
return ;
}
lua_dump ( L , _edje_lua_script_writer , & dat ) ;
# else // LUA_PLAIN_TEXT
dat . buf = ( char * ) lua_tostring ( L , - 1 ) ;
dat . size = strlen ( dat . buf ) ;
# endif
//printf("lua chunk size: %d\n", dat.size);
2012-08-23 00:54:58 -07:00
/*
2012-05-15 05:29:22 -07:00
* TODO load and test Lua chunk
*/
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
/*
if ( luaL_loadbuffer ( L , globbuf , globbufsize , " edje_lua_script " ) )
printf ( " lua load error: %s \n " , lua_tostring ( L , - 1 ) ) ;
if ( lua_pcall ( L , 0 , 0 , 0 ) )
printf ( " lua call error: %s \n " , lua_tostring ( L , - 1 ) ) ;
*/
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
snprintf ( buf , sizeof ( buf ) , " edje/scripts/lua/%i " , sc - > i ) ;
if ( eet_write ( sc - > ef , buf , dat . buf , dat . size , compress_mode ) < = 0 )
{
snprintf ( buf , sizeof ( buf ) ,
2012-07-31 15:42:03 -07:00
" Unable to write script %i " , sc - > i ) ;
2012-05-15 05:29:22 -07:00
sc - > errstr = strdup ( buf ) ;
return ;
}
# ifdef LUA_BINARY
free ( dat . buf ) ;
# endif
lua_close ( L ) ;
}
static void
2013-01-03 18:08:14 -08:00
data_thread_lua_script_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
2012-05-15 19:15:45 -07:00
Script_Write * sc = data ;
2012-05-15 05:29:22 -07:00
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
if ( sc - > errstr )
{
error_and_abort ( sc - > ef , sc - > errstr ) ;
free ( sc - > errstr ) ;
}
free ( sc ) ;
}
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
static void
data_write_lua_scripts ( Eet_File * ef )
{
Eina_List * l ;
int i ;
for ( i = 0 , l = codes ; l ; l = eina_list_next ( l ) , i + + )
{
2012-05-15 05:29:22 -07:00
Code * cd ;
2012-05-15 19:15:45 -07:00
Script_Write * sc ;
2012-08-23 00:54:58 -07:00
2012-05-15 05:29:22 -07:00
cd = ( Code * ) eina_list_data_get ( l ) ;
if ( ! cd - > is_lua )
continue ;
if ( ( ! cd - > shared ) & & ( ! cd - > programs ) )
continue ;
2012-08-23 00:54:58 -07:00
2012-05-15 19:15:45 -07:00
sc = calloc ( 1 , sizeof ( Script_Write ) ) ;
2012-05-15 05:29:22 -07:00
sc - > ef = ef ;
sc - > cd = cd ;
sc - > i = i ;
pending_threads + + ;
2012-05-16 00:43:14 -07:00
if ( threads )
ecore_thread_run ( data_thread_lua_script , data_thread_lua_script_end , NULL , sc ) ;
else
{
data_thread_lua_script ( sc , NULL ) ;
data_thread_lua_script_end ( sc , NULL ) ;
}
2012-05-15 05:29:22 -07:00
}
}
2009-10-25 04:40:06 -07:00
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_source ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Eet_File * ef = data ;
source_append ( ef ) ;
}
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_source_end ( void * data EINA_UNUSED , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
}
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
2014-03-03 03:39:53 -08:00
static void
data_thread_license ( void * data , Ecore_Thread * thread EINA_UNUSED )
2014-03-05 23:33:06 -08:00
{
License_Write * lw = data ;
Eet_File * ef = lw - > ef ;
Eina_File * f ;
void * m ;
int bytes ;
f = eina_file_open ( lw - > file , 0 ) ;
if ( ! f ) return ;
m = eina_file_map_all ( f , EINA_FILE_WILLNEED ) ;
if ( ! m ) goto on_error ;
if ( lw - > master )
{
bytes = eet_write ( ef , " edje/license " , m , eina_file_size_get ( f ) , compress_mode ) ;
}
else
{
char * s = alloca ( strlen ( lw - > file ) + 1 + 13 ) ;
strcpy ( s , lw - > file ) ;
sprintf ( s , " edje/license/%s " , basename ( s ) ) ;
bytes = eet_write ( ef , s , m , eina_file_size_get ( f ) , compress_mode ) ;
}
if ( ( bytes < = 0 ) | | eina_file_map_faulted ( f , m ) )
{
ERR ( " Unable to write license part \" %s \" . " , lw - > file ) ;
}
else
{
INF ( " Wrote %9i bytes (%4iKb) for \" %s \" license entry compress: [real: %2.1f%%] " ,
bytes , ( bytes + 512 ) / 1024 , license ,
100 - ( 100 * ( double ) bytes ) / ( ( double ) ( eina_file_size_get ( f ) ) ) ) ;
}
eina_file_map_free ( f , m ) ;
on_error :
eina_file_close ( f ) ;
}
static void
data_thread_license_end ( void * data , Ecore_Thread * thread EINA_UNUSED )
{
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
free ( data ) ;
}
static void
data_write_license ( Eet_File * ef )
{
License_Write * lw ;
Eina_List * l ;
const char * file ;
if ( ! license ) return ;
lw = calloc ( 1 , sizeof ( License_Write ) ) ;
if ( ! lw ) return ;
lw - > ef = ef ;
lw - > file = license ;
lw - > master = EINA_TRUE ;
pending_threads + + ;
if ( threads )
ecore_thread_run ( data_thread_license , data_thread_license_end , NULL , lw ) ;
else
{
data_thread_license ( lw , NULL ) ;
data_thread_license_end ( lw , NULL ) ;
}
EINA_LIST_FOREACH ( licenses , l , file )
{
lw = calloc ( 1 , sizeof ( License_Write ) ) ;
if ( ! lw ) return ;
lw - > ef = ef ;
lw - > file = file ;
lw - > master = EINA_FALSE ;
pending_threads + + ;
if ( threads )
ecore_thread_run ( data_thread_license , data_thread_license_end , NULL , lw ) ;
else
{
data_thread_license ( lw , NULL ) ;
data_thread_license_end ( lw , NULL ) ;
}
}
}
static void
data_thread_authors ( void * data , Ecore_Thread * thread EINA_UNUSED )
2014-03-03 03:39:53 -08:00
{
Eet_File * ef = data ;
Eina_File * f ;
void * m ;
int bytes ;
2014-03-05 23:33:06 -08:00
f = eina_file_open ( authors , 0 ) ;
2014-03-03 03:39:53 -08:00
if ( ! f ) return ;
m = eina_file_map_all ( f , EINA_FILE_WILLNEED ) ;
if ( ! m ) goto on_error ;
2014-03-05 23:33:06 -08:00
bytes = eet_write ( ef , " edje/authors " , m , eina_file_size_get ( f ) , compress_mode ) ;
2014-03-03 03:39:53 -08:00
if ( ( bytes < = 0 ) | | eina_file_map_faulted ( f , m ) )
{
2014-11-13 09:03:03 -08:00
ERR ( " Unable to write authors part \" %s \" . " , authors ) ;
2014-03-03 03:39:53 -08:00
}
else
{
2014-11-13 09:03:03 -08:00
INF ( " Wrote %9i bytes (%4iKb) for \" %s \" authors entry compress: [real: %2.1f%%] " ,
2014-03-03 03:39:53 -08:00
bytes , ( bytes + 512 ) / 1024 , license ,
100 - ( 100 * ( double ) bytes ) / ( ( double ) ( eina_file_size_get ( f ) ) ) ) ;
}
eina_file_map_free ( f , m ) ;
on_error :
eina_file_close ( f ) ;
}
static void
2014-03-05 23:33:06 -08:00
data_thread_authors_end ( void * data EINA_UNUSED , Ecore_Thread * thread EINA_UNUSED )
2014-03-03 03:39:53 -08:00
{
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
}
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_fontmap ( void * data , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
Eet_File * ef = data ;
source_fontmap_save ( ef , fonts ) ;
}
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
2012-05-15 05:29:22 -07:00
static void
2013-01-03 18:08:14 -08:00
data_thread_fontmap_end ( void * data EINA_UNUSED , Ecore_Thread * thread EINA_UNUSED )
2012-05-15 05:29:22 -07:00
{
pending_threads - - ;
if ( pending_threads < = 0 ) ecore_main_loop_quit ( ) ;
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
}
2008-08-20 20:57:20 -07:00
void
data_write ( void )
{
Eet_File * ef ;
2013-01-10 20:28:50 -08:00
Eet_Error err ;
2008-08-20 20:57:20 -07:00
int image_num = 0 ;
2011-11-04 05:18:13 -07:00
int sound_num = 0 ;
2014-03-19 21:00:20 -07:00
int vibration_num = 0 ;
2008-08-20 20:57:20 -07:00
int font_num = 0 ;
int collection_num = 0 ;
2012-05-15 05:29:22 -07:00
double t ;
2012-06-07 00:59:18 -07:00
2010-08-09 11:22:48 -07:00
if ( ! edje_file )
{
2012-07-31 15:42:03 -07:00
ERR ( " No data to put in \" %s \" " , file_out ) ;
2010-08-09 11:22:48 -07:00
exit ( - 1 ) ;
}
2008-08-20 20:57:20 -07:00
ef = eet_open ( file_out , EET_FILE_MODE_WRITE ) ;
if ( ! ef )
{
2012-07-31 15:42:03 -07:00
ERR ( " Unable to open \" %s \" for writing output " , file_out ) ;
2008-08-20 20:57:20 -07:00
exit ( - 1 ) ;
}
2010-08-09 10:34:03 -07:00
check_groups ( ef ) ;
2012-05-15 05:29:22 -07:00
ecore_thread_max_set ( ecore_thread_max_get ( ) * 2 ) ;
2012-05-20 00:06:57 -07:00
2012-05-23 22:37:36 -07:00
pending_threads + + ;
2012-05-15 05:29:22 -07:00
t = ecore_time_get ( ) ;
data_write_header ( ef ) ;
2012-07-31 15:42:03 -07:00
INF ( " header: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2012-05-15 05:29:22 -07:00
data_write_groups ( ef , & collection_num ) ;
2012-07-31 15:42:03 -07:00
INF ( " groups: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2008-08-20 20:57:20 -07:00
data_write_scripts ( ef ) ;
2012-07-31 15:42:03 -07:00
INF ( " scripts: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
data_write_lua_scripts ( ef ) ;
2012-07-31 15:42:03 -07:00
INF ( " lua scripts: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2014-08-21 02:14:22 -07:00
if ( ! no_save )
2012-05-16 00:43:14 -07:00
{
2014-08-21 02:14:22 -07:00
pending_threads + + ;
if ( threads )
ecore_thread_run ( data_thread_source , data_thread_source_end , NULL , ef ) ;
else
{
data_thread_source ( ef , NULL ) ;
data_thread_source_end ( ef , NULL ) ;
}
2012-05-16 00:43:14 -07:00
}
2012-07-31 15:42:03 -07:00
INF ( " source: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2012-05-15 05:29:22 -07:00
pending_threads + + ;
2012-05-16 00:43:14 -07:00
if ( threads )
ecore_thread_run ( data_thread_fontmap , data_thread_fontmap_end , NULL , ef ) ;
else
{
data_thread_fontmap ( ef , NULL ) ;
data_thread_fontmap_end ( ef , NULL ) ;
}
2012-07-31 15:42:03 -07:00
INF ( " fontmap: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2012-05-15 05:29:22 -07:00
data_write_images ( ef , & image_num ) ;
2012-07-31 15:42:03 -07:00
INF ( " images: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2012-05-15 05:29:22 -07:00
data_write_fonts ( ef , & font_num ) ;
2012-07-31 15:42:03 -07:00
INF ( " fonts: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2012-05-15 05:29:22 -07:00
data_write_sounds ( ef , & sound_num ) ;
2012-07-31 15:42:03 -07:00
INF ( " sounds: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2014-03-19 21:00:20 -07:00
data_write_vibrations ( ef , & vibration_num ) ;
INF ( " vibrations: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
2014-03-05 23:33:06 -08:00
data_write_license ( ef ) ;
INF ( " license: %3.5f " , ecore_time_get ( ) - t ) ; t = ecore_time_get ( ) ;
if ( authors )
2014-03-03 03:39:53 -08:00
{
pending_threads + + ;
if ( threads )
2014-03-05 23:33:06 -08:00
ecore_thread_run ( data_thread_authors , data_thread_authors_end , NULL , ef ) ;
2014-03-03 03:39:53 -08:00
else
{
2014-03-05 23:33:06 -08:00
data_thread_authors ( ef , NULL ) ;
data_thread_authors_end ( ef , NULL ) ;
2014-03-03 03:39:53 -08:00
}
}
2012-05-23 22:37:36 -07:00
pending_threads - - ;
2012-05-30 05:51:21 -07:00
if ( pending_threads > 0 ) ecore_main_loop_begin ( ) ;
2012-12-11 09:38:20 -08:00
INF ( " THREADS: %3.5f " , ecore_time_get ( ) - t ) ;
2012-05-16 00:43:14 -07:00
2013-01-10 20:28:50 -08:00
err = eet_close ( ef ) ;
if ( err )
{
ERR ( " Couldn't write file: \" %s \" " , file_out ) ;
exit ( - 1 ) ;
}
2012-05-15 05:29:22 -07:00
2012-07-31 15:42:03 -07:00
if ( eina_log_domain_level_check ( _edje_cc_log_dom , EINA_LOG_LEVEL_INFO ) )
{
printf ( " Summary: \n "
" Wrote %i collections \n "
" Wrote %i images \n "
" Wrote %i sounds \n "
" Wrote %i fonts \n "
,
collection_num ,
image_num ,
sound_num ,
font_num ) ;
}
2003-06-11 06:20:48 -07:00
}
2003-06-13 20:06:36 -07:00
2011-09-28 18:29:21 -07:00
void
reorder_parts ( void )
{
Edje_Part_Collection * pc ;
Edje_Part * * parts ;
Edje_Part_Parser * ep , * ep2 ;
Eina_List * l ;
/* sanity checks for parts and programs */
EINA_LIST_FOREACH ( edje_collections , l , pc )
{
unsigned int i , j , k ;
Eina_Bool found = EINA_FALSE ;
for ( i = 0 ; i < pc - > parts_count ; i + + )
{
ep = ( Edje_Part_Parser * ) pc - > parts [ i ] ;
if ( ep - > reorder . insert_before & & ep - > reorder . insert_after )
2012-07-31 15:42:03 -07:00
ERR ( " Unable to use together insert_before and insert_after in part \" %s \" . " , pc - > parts [ i ] - > name ) ;
2011-09-28 18:29:21 -07:00
if ( ep - > reorder . done )
{
continue ;
}
if ( ep - > reorder . insert_before | | ep - > reorder . insert_after )
{
found = EINA_FALSE ;
for ( j = 0 ; j < pc - > parts_count ; j + + )
{
if ( ep - > reorder . insert_before & &
! strcmp ( ep - > reorder . insert_before , pc - > parts [ j ] - > name ) )
{
ep2 = ( Edje_Part_Parser * ) pc - > parts [ j ] ;
if ( ep2 - > reorder . after )
2012-07-31 15:42:03 -07:00
ERR ( " The part \" %s \" is ambiguous ordered part. " ,
pc - > parts [ i ] - > name ) ;
2011-09-28 18:29:21 -07:00
if ( ep2 - > reorder . linked_prev )
2012-07-31 15:42:03 -07:00
ERR ( " Unable to insert two or more parts in same part \" %s \" . " ,
pc - > parts [ j ] - > name ) ;
2012-12-18 05:54:02 -08:00
/* Need it to be able to insert an element before the first */
if ( j = = 0 ) k = 0 ;
else k = j - 1 ;
2011-09-28 18:29:21 -07:00
found = EINA_TRUE ;
ep2 - > reorder . linked_prev + = ep - > reorder . linked_prev + 1 ;
ep - > reorder . before = ( Edje_Part_Parser * ) pc - > parts [ j ] ;
while ( ep2 - > reorder . before )
{
ep2 - > reorder . before - > reorder . linked_prev = ep2 - > reorder . linked_prev + 1 ;
ep2 = ep2 - > reorder . before ;
}
break ;
}
else if ( ep - > reorder . insert_after & &
! strcmp ( ep - > reorder . insert_after , pc - > parts [ j ] - > name ) )
{
ep2 = ( Edje_Part_Parser * ) pc - > parts [ j ] ;
if ( ep2 - > reorder . before )
2012-07-31 15:42:03 -07:00
ERR ( " The part \" %s \" is ambiguous ordered part. " , pc - > parts [ i ] - > name ) ;
2011-09-28 18:29:21 -07:00
if ( ep2 - > reorder . linked_next )
2012-07-31 15:42:03 -07:00
ERR ( " Unable to insert two or more parts in same part \" %s \" . " , pc - > parts [ j ] - > name ) ;
2011-09-28 18:29:21 -07:00
k = j ;
found = EINA_TRUE ;
ep2 - > reorder . linked_next + = ep - > reorder . linked_next + 1 ;
ep - > reorder . after = ( Edje_Part_Parser * ) pc - > parts [ j ] ;
while ( ep2 - > reorder . after )
{
ep2 - > reorder . after - > reorder . linked_next = ep2 - > reorder . linked_next + 1 ;
ep2 = ep2 - > reorder . after ;
}
break ;
}
}
if ( found )
{
unsigned int amount , linked ;
if ( ( ( i > k ) & & ( ( i - ep - > reorder . linked_prev ) < = k ) )
| | ( ( i < k ) & & ( ( i + ep - > reorder . linked_next ) > = k ) ) )
2012-07-31 15:42:03 -07:00
ERR ( " The part order is wrong. It has circular dependency. " ) ;
2011-09-28 18:29:21 -07:00
amount = ep - > reorder . linked_prev + ep - > reorder . linked_next + 1 ;
linked = i - ep - > reorder . linked_prev ;
2013-07-16 04:45:09 -07:00
parts = malloc ( amount * sizeof ( Edje_Part * ) ) ;
2011-09-28 18:29:21 -07:00
for ( j = 0 ; j < amount ; j + + )
{
parts [ j ] = pc - > parts [ linked ] ;
linked + + ;
}
if ( i > k )
{
2012-12-18 05:54:02 -08:00
for ( j = i - ep - > reorder . linked_prev ; j > k ; j - - )
2011-09-28 18:29:21 -07:00
{
2012-12-18 05:54:02 -08:00
pc - > parts [ j + amount - 1 ] = pc - > parts [ j - 1 ] ;
pc - > parts [ j + amount - 1 ] - > id = j + amount - 1 ;
2011-09-28 18:29:21 -07:00
}
for ( j = 0 ; j < amount ; j + + )
{
pc - > parts [ j + k ] = parts [ j ] ;
pc - > parts [ j + k ] - > id = j + k ;
}
}
else if ( i < k )
{
for ( j = i + ep - > reorder . linked_next + 1 ; j < = k ; j + + )
{
pc - > parts [ j - amount ] = pc - > parts [ j ] ;
pc - > parts [ j - amount ] - > id = j - amount ;
}
for ( j = 0 ; j < amount ; j + + )
{
pc - > parts [ j + k - amount + 1 ] = parts [ j ] ;
pc - > parts [ j + k - amount + 1 ] - > id = j + k - amount + 1 ;
}
i - = amount ;
}
ep - > reorder . done = EINA_TRUE ;
free ( parts ) ;
}
}
}
}
}
2008-04-11 16:36:35 -07:00
void
2011-12-19 09:25:00 -08:00
data_queue_group_lookup ( const char * name , Edje_Part * part )
2008-04-11 16:36:35 -07:00
{
Group_Lookup * gl ;
2011-12-21 12:09:23 -08:00
if ( ! name | | ! name [ 0 ] ) return ;
2011-12-19 09:25:00 -08:00
2008-04-11 16:36:35 -07:00
gl = mem_alloc ( SZ ( Group_Lookup ) ) ;
2008-10-22 04:34:42 -07:00
group_lookups = eina_list_append ( group_lookups , gl ) ;
2008-04-11 16:36:35 -07:00
gl - > name = mem_strdup ( name ) ;
2011-12-19 09:25:00 -08:00
gl - > part = part ;
2008-04-11 16:36:35 -07:00
}
2012-12-11 06:09:03 -08:00
void
data_queue_face_group_lookup ( const char * name )
{
char * group_name ;
if ( ! name | | ! name [ 0 ] ) return ;
group_name = mem_strdup ( name ) ;
face_group_lookups = eina_list_append ( face_group_lookups , group_name ) ;
}
2003-06-13 20:06:36 -07:00
void
2010-08-15 11:14:33 -07:00
data_queue_part_lookup ( Edje_Part_Collection * pc , const char * name , int * dest )
2014-04-22 10:19:09 -07:00
{
data_queue_part_nest_lookup ( pc , name , dest , NULL ) ;
}
void
data_queue_part_nest_lookup ( Edje_Part_Collection * pc , const char * name , int * dest , char * * dest2 )
2003-06-13 20:06:36 -07:00
{
2013-10-15 02:15:07 -07:00
Part_Lookup_Key key ;
2012-05-15 05:29:22 -07:00
Part_Lookup * pl = NULL ;
2012-09-10 20:39:27 -07:00
Eina_List * list ;
2013-10-15 02:15:07 -07:00
key . pc = pc ;
key . mem . dest = dest ;
key . stable = EINA_TRUE ;
2012-05-22 20:12:25 -07:00
2012-09-10 20:39:27 -07:00
pl = eina_hash_find ( part_pc_dest_lookup , & key ) ;
2012-05-15 05:29:22 -07:00
if ( pl )
2011-09-28 18:29:21 -07:00
{
2012-05-15 05:29:22 -07:00
if ( name [ 0 ] )
2011-09-28 18:29:21 -07:00
{
2012-11-23 15:15:48 -08:00
free ( pl - > name ) ;
2012-09-10 20:39:27 -07:00
pl - > name = mem_strdup ( name ) ;
2011-09-28 18:29:21 -07:00
}
2012-09-10 20:39:27 -07:00
else
2012-05-22 20:12:25 -07:00
{
2013-10-15 02:15:07 -07:00
list = eina_hash_find ( part_dest_lookup , & pl - > key ) ;
2012-09-10 20:39:27 -07:00
list = eina_list_remove ( list , pl ) ;
2013-10-15 02:15:07 -07:00
eina_hash_set ( part_dest_lookup , & pl - > key , list ) ;
2012-11-23 15:15:48 -08:00
eina_hash_del ( part_pc_dest_lookup , & key , pl ) ;
2012-05-22 20:12:25 -07:00
}
2013-06-20 04:28:18 -07:00
return ;
2012-05-22 20:12:25 -07:00
}
2012-09-10 20:39:27 -07:00
2011-12-15 16:29:05 -08:00
if ( ! name [ 0 ] ) return ;
2011-09-28 18:29:21 -07:00
2003-06-13 20:06:36 -07:00
pl = mem_alloc ( SZ ( Part_Lookup ) ) ;
pl - > name = mem_strdup ( name ) ;
2013-10-15 02:15:07 -07:00
pl - > key . pc = pc ;
pl - > key . mem . dest = dest ;
2014-04-22 10:19:09 -07:00
pl - > key . dest2 = dest2 ;
2013-10-15 02:15:07 -07:00
pl - > key . stable = EINA_TRUE ;
eina_hash_add ( part_pc_dest_lookup , & key , pl ) ;
list = eina_hash_find ( part_dest_lookup , & pl - > key ) ;
list = eina_list_prepend ( list , pl ) ;
eina_hash_set ( part_dest_lookup , & pl - > key , list ) ;
}
void
data_queue_part_reallocated_lookup ( Edje_Part_Collection * pc , const char * name ,
unsigned char * * base , int offset )
{
Part_Lookup_Key key ;
Part_Lookup * pl = NULL ;
Eina_List * list ;
key . pc = pc ;
key . mem . reallocated . base = base ;
key . mem . reallocated . offset = offset ;
key . stable = EINA_FALSE ;
pl = eina_hash_find ( part_pc_dest_lookup , & key ) ;
if ( pl )
{
if ( name [ 0 ] )
{
free ( pl - > name ) ;
pl - > name = mem_strdup ( name ) ;
}
else
{
list = eina_hash_find ( part_dest_lookup , & pl - > key ) ;
list = eina_list_remove ( list , pl ) ;
eina_hash_set ( part_dest_lookup , & pl - > key , list ) ;
eina_hash_del ( part_pc_dest_lookup , & key , pl ) ;
}
return ;
}
if ( ! name [ 0 ] ) return ;
pl = mem_alloc ( SZ ( Part_Lookup ) ) ;
pl - > name = mem_strdup ( name ) ;
pl - > key . pc = pc ;
pl - > key . mem . reallocated . base = base ;
pl - > key . mem . reallocated . offset = offset ;
pl - > key . stable = EINA_FALSE ;
2012-08-23 00:54:58 -07:00
2012-09-10 20:39:27 -07:00
eina_hash_add ( part_pc_dest_lookup , & key , pl ) ;
2013-10-15 02:15:07 -07:00
list = eina_hash_find ( part_dest_lookup , & pl - > key ) ;
2012-09-10 20:39:27 -07:00
list = eina_list_prepend ( list , pl ) ;
2013-10-15 02:15:07 -07:00
eina_hash_set ( part_dest_lookup , & pl - > key , list ) ;
2003-06-13 20:06:36 -07:00
}
2014-10-20 01:46:16 -07:00
void
part_lookup_del ( Edje_Part_Collection * pc , int * dest )
{
Part_Lookup_Key key ;
Part_Lookup * pl = NULL ;
Eina_List * list ;
key . pc = pc ;
key . mem . dest = dest ;
key . stable = EINA_TRUE ;
pl = eina_hash_find ( part_pc_dest_lookup , & key ) ;
if ( ! pl ) return ;
list = eina_hash_find ( part_dest_lookup , & pl - > key ) ;
if ( list )
eina_hash_del ( part_dest_lookup , & pl - > key , list ) ;
eina_hash_del ( part_pc_dest_lookup , & key , pl ) ;
}
2014-04-23 08:57:06 -07:00
void
part_lookup_delete ( Edje_Part_Collection * pc , const char * name , int * dest , char * * dest2 )
{
Part_Lookup_Key key ;
Part_Lookup * pl = NULL ;
2014-10-19 16:26:35 -07:00
Part_Lookup * lpl ;
2014-04-23 08:57:06 -07:00
Eina_List * list , * l , * ll ;
key . pc = pc ;
key . mem . dest = dest ;
key . stable = EINA_TRUE ;
pl = eina_hash_find ( part_pc_dest_lookup , & key ) ;
if ( ! pl ) return ;
list = eina_hash_find ( part_dest_lookup , & pl - > key ) ;
2014-10-19 16:26:35 -07:00
EINA_LIST_FOREACH_SAFE ( list , l , ll , lpl )
2014-04-23 08:57:06 -07:00
{
2014-10-19 16:26:35 -07:00
if ( strcmp ( lpl - > name , name ) | | ( lpl - > key . dest2 ! = dest2 ) ) continue ;
free ( lpl - > name ) ;
2014-04-23 08:57:06 -07:00
list = eina_list_remove_list ( list , l ) ;
2014-10-19 16:26:35 -07:00
free ( lpl ) ;
2014-04-23 08:57:06 -07:00
}
eina_hash_set ( part_dest_lookup , & pl - > key , list ) ;
}
2011-09-28 18:29:21 -07:00
void
data_queue_copied_part_lookup ( Edje_Part_Collection * pc , int * src , int * dest )
2014-04-22 10:19:09 -07:00
{
data_queue_copied_part_nest_lookup ( pc , src , dest , NULL ) ;
}
void
data_queue_copied_part_nest_lookup ( Edje_Part_Collection * pc , int * src , int * dest , char * * dest2 )
2011-09-28 18:29:21 -07:00
{
2012-09-10 20:39:27 -07:00
Eina_List * list ;
2012-05-26 01:41:49 -07:00
Eina_List * l ;
2011-09-28 18:29:21 -07:00
Part_Lookup * pl ;
2013-10-15 02:15:07 -07:00
Part_Lookup_Key key ;
2011-09-28 18:29:21 -07:00
2013-10-15 02:15:07 -07:00
key . pc = NULL ;
key . mem . dest = src ;
key . stable = EINA_TRUE ;
list = eina_hash_find ( part_dest_lookup , & key ) ;
2012-05-15 05:29:22 -07:00
EINA_LIST_FOREACH ( list , l , pl )
2013-10-15 02:15:07 -07:00
if ( pl - > key . stable )
2014-04-22 10:19:09 -07:00
data_queue_part_nest_lookup ( pc , pl - > name , dest , dest2 ) ;
2011-09-28 18:29:21 -07:00
}
2010-08-24 09:39:51 -07:00
void
data_queue_anonymous_lookup ( Edje_Part_Collection * pc , Edje_Program * ep , int * dest )
{
2013-10-15 02:15:07 -07:00
Eina_List * l , * l1 , * l2 , * l3 ;
2010-08-24 09:39:51 -07:00
Program_Lookup * pl ;
2013-06-20 04:28:18 -07:00
if ( ! ep ) return ; /* FIXME: should we stop compiling ? */
2010-08-24 09:39:51 -07:00
2013-10-15 02:15:07 -07:00
EINA_LIST_FOREACH_SAFE ( program_lookups , l , l1 , pl )
2011-09-28 18:29:21 -07:00
{
if ( pl - > u . ep = = ep )
{
Code * cd ;
Code_Program * cp ;
cd = eina_list_data_get ( eina_list_last ( codes ) ) ;
2013-10-15 02:15:07 -07:00
EINA_LIST_FOREACH_SAFE ( cd - > programs , l2 , l3 , cp )
2011-09-28 18:29:21 -07:00
{
if ( & ( cp - > id ) = = pl - > dest )
{
2013-10-15 02:15:07 -07:00
cd - > programs = eina_list_remove_list ( cd - > programs , l2 ) ;
2011-09-28 18:29:21 -07:00
free ( cp ) ;
cp = NULL ;
}
}
2013-10-15 02:15:07 -07:00
program_lookups = eina_list_remove_list ( program_lookups , l ) ;
2011-09-28 18:29:21 -07:00
free ( pl ) ;
}
}
if ( dest )
{
pl = mem_alloc ( SZ ( Program_Lookup ) ) ;
program_lookups = eina_list_append ( program_lookups , pl ) ;
pl - > pc = pc ;
pl - > u . ep = ep ;
pl - > dest = dest ;
pl - > anonymous = EINA_TRUE ;
}
}
void
data_queue_copied_anonymous_lookup ( Edje_Part_Collection * pc , int * src , int * dest )
{
Eina_List * l ;
Program_Lookup * pl ;
unsigned int i ;
EINA_LIST_FOREACH ( program_lookups , l , pl )
{
2012-09-12 02:08:24 -07:00
if ( pl - > dest = = src & & pl - > u . ep - > name )
2011-09-28 18:29:21 -07:00
{
for ( i = 0 ; i < pc - > programs . fnmatch_count ; i + + )
{
2012-09-12 02:08:24 -07:00
if ( pc - > programs . fnmatch [ i ] - > name & &
2012-09-11 01:15:33 -07:00
! strcmp ( pl - > u . ep - > name , pc - > programs . fnmatch [ i ] - > name ) )
2011-09-28 18:29:21 -07:00
data_queue_anonymous_lookup ( pc , pc - > programs . fnmatch [ i ] , dest ) ;
}
for ( i = 0 ; i < pc - > programs . strcmp_count ; i + + )
{
2012-09-12 02:08:24 -07:00
if ( pc - > programs . strcmp [ i ] - > name & &
2012-09-11 01:15:33 -07:00
! strcmp ( pl - > u . ep - > name , pc - > programs . strcmp [ i ] - > name ) )
2011-09-28 18:29:21 -07:00
data_queue_anonymous_lookup ( pc , pc - > programs . strcmp [ i ] , dest ) ;
}
for ( i = 0 ; i < pc - > programs . strncmp_count ; i + + )
{
2012-09-12 02:08:24 -07:00
if ( pc - > programs . strncmp [ i ] - > name & &
2012-09-11 01:15:33 -07:00
! strcmp ( pl - > u . ep - > name , pc - > programs . strncmp [ i ] - > name ) )
2011-09-28 18:29:21 -07:00
data_queue_anonymous_lookup ( pc , pc - > programs . strncmp [ i ] , dest ) ;
}
for ( i = 0 ; i < pc - > programs . strrncmp_count ; i + + )
{
2012-09-12 02:08:24 -07:00
if ( pc - > programs . strrncmp [ i ] - > name & &
2012-09-11 01:15:33 -07:00
! strcmp ( pl - > u . ep - > name , pc - > programs . strrncmp [ i ] - > name ) )
2011-09-28 18:29:21 -07:00
data_queue_anonymous_lookup ( pc , pc - > programs . strrncmp [ i ] , dest ) ;
}
for ( i = 0 ; i < pc - > programs . nocmp_count ; i + + )
{
2012-09-12 02:08:24 -07:00
if ( pc - > programs . nocmp [ i ] - > name & &
2012-09-11 01:15:33 -07:00
! strcmp ( pl - > u . ep - > name , pc - > programs . nocmp [ i ] - > name ) )
2011-09-28 18:29:21 -07:00
data_queue_anonymous_lookup ( pc , pc - > programs . nocmp [ i ] , dest ) ;
}
}
}
2010-08-24 09:39:51 -07:00
}
2014-03-21 21:51:05 -07:00
void *
2010-08-15 11:14:33 -07:00
data_queue_program_lookup ( Edje_Part_Collection * pc , const char * name , int * dest )
2003-06-16 06:55:13 -07:00
{
Program_Lookup * pl ;
2014-03-24 12:09:16 -07:00
Edje_Part_Collection_Parser * pcp = ( Edje_Part_Collection_Parser * ) pc ;
if ( pcp - > inherit_only & & ( ! current_group_inherit ) ) return NULL ;
2007-08-26 05:54:51 -07:00
2014-03-21 21:51:05 -07:00
if ( ! name ) return NULL ; /* FIXME: should we stop compiling ? */
2010-08-24 09:39:51 -07:00
2003-06-16 06:55:13 -07:00
pl = mem_alloc ( SZ ( Program_Lookup ) ) ;
2008-10-22 04:34:42 -07:00
program_lookups = eina_list_append ( program_lookups , pl ) ;
2003-06-16 06:55:13 -07:00
pl - > pc = pc ;
2010-08-24 09:39:51 -07:00
pl - > u . name = mem_strdup ( name ) ;
2003-06-16 06:55:13 -07:00
pl - > dest = dest ;
2010-08-24 09:39:51 -07:00
pl - > anonymous = EINA_FALSE ;
2014-03-21 21:51:05 -07:00
return pl ;
}
void
program_lookup_rename ( void * p , const char * name )
{
Program_Lookup * pl = p ;
free ( pl - > u . name ) ;
pl - > u . name = strdup ( name ) ;
2003-06-16 06:55:13 -07:00
}
2014-03-21 23:18:54 -07:00
void
copied_program_lookup_delete ( Edje_Part_Collection * pc , const char * name )
{
Program_Lookup * pl ;
Eina_List * l , * ll ;
EINA_LIST_FOREACH_SAFE ( program_lookups , l , ll , pl )
{
if ( pl - > anonymous | | ( pl - > pc ! = pc ) | | strcmp ( pl - > u . name , name ) ) continue ;
free ( pl - > u . name ) ;
program_lookups = eina_list_remove_list ( program_lookups , l ) ;
free ( pl ) ;
}
}
2011-09-28 18:29:21 -07:00
void
data_queue_copied_program_lookup ( Edje_Part_Collection * pc , int * src , int * dest )
{
Eina_List * l ;
Program_Lookup * pl ;
EINA_LIST_FOREACH ( program_lookups , l , pl )
{
if ( pl - > dest = = src )
data_queue_program_lookup ( pc , pl - > u . name , dest ) ;
}
}
2003-06-13 20:06:36 -07:00
void
2010-06-01 06:31:07 -07:00
data_queue_image_lookup ( char * name , int * dest , Eina_Bool * set )
2003-06-13 20:06:36 -07:00
{
Image_Lookup * il ;
2007-08-26 05:54:51 -07:00
2003-06-13 20:06:36 -07:00
il = mem_alloc ( SZ ( Image_Lookup ) ) ;
2008-10-22 04:34:42 -07:00
image_lookups = eina_list_append ( image_lookups , il ) ;
2003-06-13 20:06:36 -07:00
il - > name = mem_strdup ( name ) ;
il - > dest = dest ;
2010-06-01 06:31:07 -07:00
il - > set = set ;
2003-06-13 20:06:36 -07:00
}
2012-01-25 01:07:36 -08:00
void
data_queue_image_remove ( int * dest , Eina_Bool * set )
{
Eina_List * l ;
Image_Lookup * il ;
EINA_LIST_FOREACH ( image_lookups , l , il )
{
if ( il - > dest = = dest & & il - > set = = set )
{
image_lookups = eina_list_remove_list ( image_lookups , l ) ;
2012-07-13 01:33:26 -07:00
free ( il - > name ) ;
2012-01-25 08:47:38 -08:00
free ( il ) ;
2013-06-20 04:28:18 -07:00
return ;
2012-01-25 01:07:36 -08:00
}
}
2012-01-25 08:47:38 -08:00
}
2012-01-25 01:07:36 -08:00
2015-02-05 06:29:03 -08:00
void
data_queue_model_lookup ( char * name , int * dest , Eina_Bool * set )
{
Image_Lookup * il ;
il = mem_alloc ( SZ ( Image_Lookup ) ) ;
model_lookups = eina_list_append ( model_lookups , il ) ;
il - > name = mem_strdup ( name ) ;
il - > dest = dest ;
il - > set = set ;
}
void
data_queue_model_remove ( int * dest , Eina_Bool * set )
{
Eina_List * l ;
Image_Lookup * il ;
EINA_LIST_FOREACH ( model_lookups , l , il )
{
if ( il - > dest = = dest & & il - > set = = set )
{
model_lookups = eina_list_remove_list ( model_lookups , l ) ;
free ( il - > name ) ;
free ( il ) ;
return ;
}
}
}
2011-09-28 18:29:21 -07:00
void
data_queue_copied_image_lookup ( int * src , int * dest , Eina_Bool * set )
{
Eina_List * l ;
Image_Lookup * il ;
EINA_LIST_FOREACH ( image_lookups , l , il )
{
if ( il - > dest = = src )
data_queue_image_lookup ( il - > name , dest , set ) ;
}
}
2004-10-19 09:37:20 -07:00
2014-04-22 10:19:09 -07:00
static Eina_Bool
2013-10-15 02:15:07 -07:00
data_process_part_set ( Part_Lookup * target , int value )
{
if ( target - > key . stable )
{
* ( target - > key . mem . dest ) = value ;
2014-04-22 10:19:09 -07:00
if ( target - > key . dest2 ) return EINA_TRUE ;
2013-10-15 02:15:07 -07:00
}
else
{
* ( ( int * ) ( * target - > key . mem . reallocated . base +
target - > key . mem . reallocated . offset ) ) = value ;
}
2014-04-22 10:19:09 -07:00
return EINA_FALSE ;
2013-10-15 02:15:07 -07:00
}
2014-11-10 03:45:33 -08:00
static int
_data_image_w_size_compare_cb ( const void * data1 , const void * data2 )
{
const Edje_Image_Directory_Set_Entry * img1 = data1 ;
const Edje_Image_Directory_Set_Entry * img2 = data2 ;
if ( img1 - > size . w < img2 - > size . w ) return - 1 ;
if ( img1 - > size . w > img2 - > size . w ) return 1 ;
return 0 ;
}
static int
_data_image_h_size_compare_cb ( const void * data1 , const void * data2 )
{
const Edje_Image_Directory_Set_Entry * img1 = data1 ;
const Edje_Image_Directory_Set_Entry * img2 = data2 ;
if ( img1 - > size . h < img2 - > size . h ) return - 1 ;
if ( img1 - > size . h > img2 - > size . h ) return 1 ;
return 0 ;
}
static void
_data_image_sets_size_set ( )
{
Evas * evas ;
Ecore_Evas * ee ;
Edje_Image_Directory_Set * set ;
Edje_Image_Directory_Set_Entry * simg , * preimg ;
Eina_List * l , * entries ;
unsigned int i ;
ecore_evas_init ( ) ;
ee = ecore_evas_buffer_new ( 1 , 1 ) ;
if ( ! ee )
{
ERR ( " Cannot create buffer engine canvas for image load. " ) ;
exit ( - 1 ) ;
}
evas = ecore_evas_get ( ee ) ;
for ( i = 0 ; i < edje_file - > image_dir - > sets_count ; i + + )
{
set = edje_file - > image_dir - > sets + i ;
2015-04-08 21:33:41 -07:00
if ( ! set - > entries ) continue ;
2014-11-10 03:45:33 -08:00
EINA_LIST_FOREACH ( set - > entries , l , simg )
{
Evas_Object * im ;
Eina_List * ll ;
char * s ;
im = evas_object_image_add ( evas ) ;
EINA_LIST_FOREACH ( img_dirs , ll , s )
{
char buf [ PATH_MAX ] ;
int load_err = EVAS_LOAD_ERROR_NONE ;
snprintf ( buf , sizeof ( buf ) , " %s/%s " , s , simg - > name ) ;
evas_object_image_file_set ( im , buf , NULL ) ;
load_err = evas_object_image_load_error_get ( im ) ;
if ( load_err = = EVAS_LOAD_ERROR_NONE )
{
evas_object_image_size_get ( im , & simg - > size . w , & simg - > size . h ) ;
break ;
}
}
evas_object_del ( im ) ;
}
entries = eina_list_clone ( set - > entries ) ;
entries = eina_list_sort ( entries , 0 , _data_image_w_size_compare_cb ) ;
preimg = eina_list_data_get ( entries ) ;
EINA_LIST_FOREACH ( entries , l , simg )
{
if ( simg = = preimg ) continue ;
if ( ! ( preimg - > size . max . w ) & & ! ( simg - > size . min . w ) )
{
preimg - > size . max . w = ( preimg - > size . w + simg - > size . w ) / 2 ;
simg - > size . min . w = preimg - > size . max . w + 1 ;
if ( simg - > size . min . w < = ( simg - > border . l + simg - > border . r ) )
{
preimg - > size . max . w = simg - > border . l + simg - > border . r ;
simg - > size . min . w = preimg - > size . max . w + 1 ;
}
}
else if ( preimg - > size . max . w & & ! ( simg - > size . min . w ) )
simg - > size . min . w = preimg - > size . max . w + 1 ;
else if ( ! ( preimg - > size . max . w ) & & simg - > size . min . w )
preimg - > size . max . w = simg - > size . min . w - 1 ;
preimg = simg ;
}
simg = eina_list_data_get ( eina_list_last ( entries ) ) ;
if ( ! ( simg - > size . max . w ) ) simg - > size . max . w = 99999 ;
entries = eina_list_sort ( entries , 0 , _data_image_h_size_compare_cb ) ;
preimg = eina_list_data_get ( entries ) ;
EINA_LIST_FOREACH ( entries , l , simg )
{
if ( simg = = preimg ) continue ;
if ( ! ( preimg - > size . max . h ) & & ! ( simg - > size . min . h ) )
{
preimg - > size . max . h = ( preimg - > size . h + simg - > size . h ) / 2 ;
simg - > size . min . h = preimg - > size . max . h + 1 ;
if ( simg - > size . min . h < = ( simg - > border . t + simg - > border . b ) )
{
preimg - > size . max . h = simg - > border . t + simg - > border . b ;
simg - > size . min . h = preimg - > size . max . h + 1 ;
}
}
else if ( preimg - > size . max . h & & ! ( simg - > size . min . h ) )
simg - > size . min . h = preimg - > size . max . h + 1 ;
else if ( ! ( preimg - > size . max . h ) & & simg - > size . min . h )
preimg - > size . max . h = simg - > size . min . h - 1 ;
preimg = simg ;
}
simg = eina_list_data_get ( eina_list_last ( entries ) ) ;
if ( ! ( simg - > size . max . h ) ) simg - > size . max . h = 99999 ;
eina_list_free ( entries ) ;
}
}
2013-11-03 22:28:59 -08:00
static void
_data_image_id_update ( Eina_List * images_unused_list )
{
Image_Unused_Ids * iui ;
Edje_Part_Collection * pc ;
Edje_Part * part ;
Edje_Part_Description_Image * part_desc_image ;
2015-02-05 06:29:03 -08:00
Edje_Part_Description_Mesh_Node * part_desc_mesh_node ;
2013-11-03 22:28:59 -08:00
Edje_Part_Image_Id * tween_id ;
unsigned int i , j , desc_it ;
Eina_List * l , * l2 , * l3 ;
# define PART_DESC_IMAGE_ID_UPDATE \
EINA_LIST_FOREACH ( images_unused_list , l3 , iui ) \
{ \
if ( part_desc_image - > image . id = = iui - > old_id ) \
{ \
part_desc_image - > image . id = iui - > new_id ; \
break ; \
} \
} \
for ( desc_it = 0 ; desc_it < part_desc_image - > image . tweens_count ; desc_it + + ) \
{ \
tween_id = part_desc_image - > image . tweens [ desc_it ] ; \
EINA_LIST_FOREACH ( images_unused_list , l3 , iui ) \
{ \
if ( tween_id - > id = = iui - > old_id ) \
{ \
tween_id - > id = iui - > new_id ; \
break ; \
} \
} \
}
2015-02-05 06:29:03 -08:00
# define PART_DESC_PROXY_ID_UPDATE \
EINA_LIST_FOREACH ( images_unused_list , l3 , iui ) \
{ \
if ( part_desc_mesh_node - > mesh_node . texture . id = = iui - > old_id ) \
{ \
part_desc_mesh_node - > mesh_node . texture . id = iui - > new_id ; \
break ; \
} \
}
2013-11-03 22:28:59 -08:00
EINA_LIST_FOREACH_SAFE ( edje_collections , l , l2 , pc )
{
for ( i = 0 ; i < pc - > parts_count ; i + + )
{
part = pc - > parts [ i ] ;
if ( part - > type = = EDJE_PART_TYPE_IMAGE )
{
part_desc_image = ( Edje_Part_Description_Image * ) part - > default_desc ;
2014-03-28 20:52:16 -07:00
if ( ! part_desc_image ) continue ;
2013-11-03 22:28:59 -08:00
PART_DESC_IMAGE_ID_UPDATE
for ( j = 0 ; j < part - > other . desc_count ; j + + )
{
part_desc_image = ( Edje_Part_Description_Image * ) part - > other . desc [ j ] ;
PART_DESC_IMAGE_ID_UPDATE
}
}
2015-02-05 06:29:03 -08:00
else if ( part - > type = = EDJE_PART_TYPE_MESH_NODE )
{
part_desc_mesh_node = ( Edje_Part_Description_Mesh_Node * ) part - > default_desc ;
if ( ! part_desc_mesh_node ) continue ;
PART_DESC_PROXY_ID_UPDATE
for ( j = 0 ; j < part - > other . desc_count ; j + + )
{
part_desc_mesh_node = ( Edje_Part_Description_Mesh_Node * ) part - > other . desc [ j ] ;
PART_DESC_PROXY_ID_UPDATE
}
}
2013-11-03 22:28:59 -08:00
}
}
2014-10-29 05:04:37 -07:00
for ( i = 0 ; i < edje_file - > image_dir - > sets_count ; i + + )
{
2014-10-29 08:07:39 -07:00
Eina_List * entries , * list ;
2014-10-29 05:04:37 -07:00
Edje_Image_Directory_Set_Entry * entry ;
entries = edje_file - > image_dir - > sets [ i ] . entries ;
2014-10-29 08:07:39 -07:00
EINA_LIST_FOREACH ( entries , list , entry )
2014-10-29 05:04:37 -07:00
{
EINA_LIST_FOREACH ( images_unused_list , l3 , iui )
{
if ( entry - > id = = iui - > old_id )
{
entry - > id = iui - > new_id ;
break ;
}
}
}
}
2013-11-03 22:28:59 -08:00
}
2015-02-05 06:29:03 -08:00
static void
_data_model_id_update ( Eina_List * models_unused_list )
{
Image_Unused_Ids * iui ;
Edje_Part_Collection * pc ;
Edje_Part * part ;
Edje_Part_Description_Mesh_Node * part_desc_mesh_node ;
unsigned int i , j ;
Eina_List * l , * l2 , * l3 ;
# define PART_DESC_MODEL_ID_UPDATE \
EINA_LIST_FOREACH ( models_unused_list , l3 , iui ) \
{ \
if ( part_desc_mesh_node - > mesh_node . mesh . id = = iui - > old_id ) \
{ \
part_desc_mesh_node - > mesh_node . mesh . id = iui - > new_id ; \
break ; \
} \
} \
EINA_LIST_FOREACH_SAFE ( edje_collections , l , l2 , pc )
{
for ( i = 0 ; i < pc - > parts_count ; i + + )
{
part = pc - > parts [ i ] ;
if ( part - > type = = EDJE_PART_TYPE_MESH_NODE )
{
part_desc_mesh_node = ( Edje_Part_Description_Mesh_Node * ) part - > default_desc ;
if ( ! part_desc_mesh_node ) continue ;
PART_DESC_MODEL_ID_UPDATE
for ( j = 0 ; j < part - > other . desc_count ; j + + )
{
part_desc_mesh_node = ( Edje_Part_Description_Mesh_Node * ) part - > other . desc [ j ] ;
PART_DESC_MODEL_ID_UPDATE
}
}
}
}
}
2003-06-13 20:06:36 -07:00
void
data_process_lookups ( void )
{
2010-08-15 11:14:33 -07:00
Edje_Part_Collection * pc ;
2012-09-10 20:39:27 -07:00
Eina_Iterator * it ;
2010-08-15 11:14:33 -07:00
Part_Lookup * part ;
Program_Lookup * program ;
Group_Lookup * group ;
Image_Lookup * image ;
2015-02-05 06:29:03 -08:00
Image_Lookup * model ;
2012-01-25 08:47:38 -08:00
Eina_List * l2 ;
2008-10-22 04:34:42 -07:00
Eina_List * l ;
2012-01-25 01:07:36 -08:00
Eina_Hash * images_in_use ;
2015-02-05 06:29:03 -08:00
Eina_Hash * models_in_use ;
2012-12-11 06:09:03 -08:00
char * group_name ;
2012-03-01 08:42:03 -08:00
Eina_Bool is_lua = EINA_FALSE ;
2013-11-03 22:28:59 -08:00
Image_Unused_Ids * iui ;
2007-08-26 05:54:51 -07:00
2012-01-25 08:47:38 -08:00
/* remove all unreferenced Edje_Part_Collection */
EINA_LIST_FOREACH_SAFE ( edje_collections , l , l2 , pc )
{
Edje_Part_Collection_Directory_Entry * alias ;
Edje_Part_Collection_Directory_Entry * find ;
Eina_List * l3 ;
unsigned int id = 0 ;
unsigned int i ;
2012-08-09 01:57:35 -07:00
if ( ! pc - > part )
{
ERR ( " A collection without a name was detected, that's not allowed. " ) ;
exit ( - 1 ) ;
}
2012-01-25 08:47:38 -08:00
find = eina_hash_find ( edje_file - > collection , pc - > part ) ;
if ( find & & find - > id = = pc - > id )
continue ;
EINA_LIST_FOREACH ( aliases , l3 , alias )
if ( alias - > id = = pc - > id )
continue ;
/* This Edje_Part_Collection is not used at all */
edje_collections = eina_list_remove_list ( edje_collections , l ) ;
l3 = eina_list_nth_list ( codes , pc - > id ) ;
codes = eina_list_remove_list ( codes , l3 ) ;
/* Unref all image used by that group */
for ( i = 0 ; i < pc - > parts_count ; + + i )
part_description_image_cleanup ( pc - > parts [ i ] ) ;
/* Correct all id */
EINA_LIST_FOREACH ( edje_collections , l3 , pc )
{
Eina_List * l4 ;
/* Some group could be removed from the collection, but still be referenced by alias */
find = eina_hash_find ( edje_file - > collection , pc - > part ) ;
if ( pc - > id ! = find - > id ) find = NULL ;
/* Update all matching alias */
EINA_LIST_FOREACH ( aliases , l4 , alias )
if ( pc - > id = = alias - > id )
alias - > id = id ;
pc - > id = id + + ;
if ( find ) find - > id = pc - > id ;
}
}
2010-08-15 11:14:33 -07:00
EINA_LIST_FOREACH ( edje_collections , l , pc )
2003-06-13 20:06:36 -07:00
{
2012-04-19 01:41:47 -07:00
unsigned int count = 0 ;
unsigned int i ;
2007-08-26 05:54:51 -07:00
2012-03-01 07:46:33 -08:00
if ( pc - > lua_script_only )
2012-04-19 01:41:47 -07:00
is_lua = EINA_TRUE ;
2010-08-15 11:14:33 -07:00
# define PROGRAM_ID_SET(Type, Pc, It, Count) \
2012-04-19 01:41:47 -07:00
for ( It = 0 ; It < Pc - > programs . Type # # _count ; + + It ) \
{ \
Pc - > programs . Type [ It ] - > id = Count + + ; \
}
2010-08-15 11:14:33 -07:00
2012-04-19 01:41:47 -07:00
PROGRAM_ID_SET ( fnmatch , pc , i , count ) ;
PROGRAM_ID_SET ( strcmp , pc , i , count ) ;
PROGRAM_ID_SET ( strncmp , pc , i , count ) ;
PROGRAM_ID_SET ( strrncmp , pc , i , count ) ;
PROGRAM_ID_SET ( nocmp , pc , i , count ) ;
2010-08-15 11:14:33 -07:00
# undef PROGRAM_ID_SET
}
2007-08-26 05:54:51 -07:00
2012-09-10 20:39:27 -07:00
it = eina_hash_iterator_data_new ( part_pc_dest_lookup ) ;
EINA_ITERATOR_FOREACH ( it , part )
2010-08-15 11:14:33 -07:00
{
2012-04-19 01:41:47 -07:00
Edje_Part * ep ;
unsigned int i ;
2010-08-15 11:14:33 -07:00
2012-04-18 20:35:29 -07:00
if ( ! strcmp ( part - > name , " - " ) )
{
2013-10-15 02:15:07 -07:00
data_process_part_set ( part , - 1 ) ;
2012-04-18 20:35:29 -07:00
}
else
{
2014-04-22 10:19:09 -07:00
char * alias , * ap ;
2013-10-15 02:15:07 -07:00
alias = eina_hash_find ( part - > key . pc - > alias , part - > name ) ;
2012-06-23 23:01:12 -07:00
if ( ! alias )
alias = part - > name ;
2014-04-22 10:19:09 -07:00
ap = strchr ( alias , EDJE_PART_PATH_SEPARATOR ) ;
if ( ap )
{
char * tmp ;
tmp = alloca ( strlen ( alias ) + 1 ) ;
memcpy ( tmp , alias , ap - alias ) ;
tmp [ ap - alias ] = 0 ;
ap + = 1 ;
alias = tmp ;
}
2013-10-15 02:15:07 -07:00
for ( i = 0 ; i < part - > key . pc - > parts_count ; + + i )
2012-04-18 20:35:29 -07:00
{
2013-10-15 02:15:07 -07:00
ep = part - > key . pc - > parts [ i ] ;
2012-04-19 01:41:47 -07:00
2012-06-23 23:01:12 -07:00
if ( ( ep - > name ) & & ( ! strcmp ( ep - > name , alias ) ) )
2012-04-18 20:35:29 -07:00
{
2014-04-22 10:19:09 -07:00
if ( data_process_part_set ( part , ep - > id ) )
* part - > key . dest2 = ap ;
2012-04-18 20:35:29 -07:00
break ;
}
}
2010-08-15 11:14:33 -07:00
2014-03-24 12:09:16 -07:00
if ( ( i = = part - > key . pc - > parts_count ) & & ( ! ( ( Edje_Part_Collection_Parser * ) part - > key . pc ) - > inherit_only ) )
2012-04-18 20:35:29 -07:00
{
2012-07-31 15:42:03 -07:00
ERR ( " Unable to find part name \" %s \" needed in group '%s'. " ,
2013-10-15 02:15:07 -07:00
alias , part - > key . pc - > part ) ;
2012-04-18 20:35:29 -07:00
exit ( - 1 ) ;
}
}
2003-06-13 20:06:36 -07:00
}
2012-09-10 20:39:27 -07:00
eina_iterator_free ( it ) ;
eina_hash_free ( part_dest_lookup ) ;
eina_hash_free ( part_pc_dest_lookup ) ;
2003-06-13 20:06:36 -07:00
2010-08-15 11:14:33 -07:00
EINA_LIST_FREE ( program_lookups , program )
2003-06-16 06:55:13 -07:00
{
2012-04-19 01:41:47 -07:00
unsigned int i ;
Eina_Bool find = EINA_FALSE ;
2010-08-15 11:14:33 -07:00
# define PROGRAM_MATCH(Type, Pl, It) \
2012-04-19 01:41:47 -07:00
for ( It = 0 ; It < Pl - > pc - > programs . Type # # _count ; + + It ) \
{ \
Edje_Program * ep ; \
\
ep = Pl - > pc - > programs . Type [ It ] ; \
\
if ( ( Pl - > anonymous & & ep = = Pl - > u . ep ) | | \
( ( ! Pl - > anonymous ) & & ( ep - > name ) & & ( ! strcmp ( ep - > name , Pl - > u . name ) ) ) ) \
{ \
* ( Pl - > dest ) = ep - > id ; \
find = EINA_TRUE ; \
break ; \
} \
}
2007-08-26 05:54:51 -07:00
2012-04-19 01:41:47 -07:00
PROGRAM_MATCH ( fnmatch , program , i ) ;
PROGRAM_MATCH ( strcmp , program , i ) ;
PROGRAM_MATCH ( strncmp , program , i ) ;
PROGRAM_MATCH ( strrncmp , program , i ) ;
PROGRAM_MATCH ( nocmp , program , i ) ;
2007-08-26 05:54:51 -07:00
2010-08-15 11:14:33 -07:00
# undef PROGRAM_MATCH
2012-04-19 01:41:47 -07:00
if ( ! find )
{
if ( ! program - > anonymous )
2012-07-31 15:42:03 -07:00
ERR ( " Unable to find program name \" %s \" . " ,
program - > u . name ) ;
2012-04-19 01:41:47 -07:00
else
2012-07-31 15:42:03 -07:00
ERR ( " Unable to find anonymous program. " ) ;
2012-04-19 01:41:47 -07:00
exit ( - 1 ) ;
}
2010-08-15 11:14:33 -07:00
2012-04-19 01:41:47 -07:00
if ( ! program - > anonymous )
free ( program - > u . name ) ;
free ( program ) ;
2003-06-16 06:55:13 -07:00
}
2007-08-26 05:54:51 -07:00
2010-08-15 11:14:33 -07:00
EINA_LIST_FREE ( group_lookups , group )
2008-04-11 16:36:35 -07:00
{
2012-04-19 01:41:47 -07:00
Edje_Part_Collection_Directory_Entry * de ;
2008-10-22 04:34:42 -07:00
2011-12-20 02:28:30 -08:00
if ( group - > part )
2012-04-19 01:41:47 -07:00
{
if ( group - > part - > type ! = EDJE_PART_TYPE_GROUP
& & group - > part - > type ! = EDJE_PART_TYPE_TEXTBLOCK
& & group - > part - > type ! = EDJE_PART_TYPE_BOX
& & group - > part - > type ! = EDJE_PART_TYPE_TABLE )
goto free_group ;
}
2011-12-19 09:25:00 -08:00
2012-04-19 01:41:47 -07:00
de = eina_hash_find ( edje_file - > collection , group - > name ) ;
2008-04-11 16:36:35 -07:00
2012-04-19 01:41:47 -07:00
if ( ! de )
{
2011-12-19 09:25:00 -08:00
Eina_Bool found = EINA_FALSE ;
EINA_LIST_FOREACH ( aliases , l , de )
if ( strcmp ( de - > entry , group - > name ) = = 0 )
{
found = EINA_TRUE ;
break ;
}
if ( ! found ) de = NULL ;
2012-04-19 01:41:47 -07:00
}
2011-12-19 09:25:00 -08:00
2012-04-19 01:41:47 -07:00
if ( ! de )
2008-04-11 16:36:35 -07:00
{
2012-07-31 15:42:03 -07:00
ERR ( " Unable to find group name \" %s \" . " , group - > name ) ;
2008-04-11 16:36:35 -07:00
exit ( - 1 ) ;
}
2010-08-15 11:14:33 -07:00
2012-04-19 01:41:47 -07:00
free_group :
2010-08-15 11:14:33 -07:00
free ( group - > name ) ;
free ( group ) ;
2008-04-11 16:36:35 -07:00
}
2012-12-11 06:09:03 -08:00
EINA_LIST_FREE ( face_group_lookups , group_name )
{
Edje_Part_Collection_Directory_Entry * de ;
de = eina_hash_find ( edje_file - > collection , group_name ) ;
if ( ! de )
{
Eina_Bool found = EINA_FALSE ;
EINA_LIST_FOREACH ( aliases , l , de )
if ( strcmp ( de - > entry , group_name ) = = 0 )
{
found = EINA_TRUE ;
break ;
}
if ( ! found ) de = NULL ;
}
if ( ! de )
{
ERR ( " Unable to find group name \" %s \" . " , group_name ) ;
exit ( - 1 ) ;
}
free ( group_name ) ;
}
2012-01-25 01:07:36 -08:00
images_in_use = eina_hash_string_superfast_new ( NULL ) ;
2010-08-15 11:14:33 -07:00
EINA_LIST_FREE ( image_lookups , image )
2003-06-13 20:06:36 -07:00
{
2012-04-19 01:41:47 -07:00
Eina_Bool find = EINA_FALSE ;
2007-08-26 05:54:51 -07:00
2012-04-19 01:41:47 -07:00
if ( edje_file - > image_dir )
{
2012-01-25 01:07:36 -08:00
Edje_Image_Directory_Entry * de ;
2012-04-19 01:41:47 -07:00
unsigned int i ;
2010-08-15 11:14:33 -07:00
2012-04-19 01:41:47 -07:00
for ( i = 0 ; i < edje_file - > image_dir - > entries_count ; + + i )
{
de = edje_file - > image_dir - > entries + i ;
2010-08-15 11:14:33 -07:00
2012-04-19 01:41:47 -07:00
if ( ( de - > entry ) & & ( ! strcmp ( de - > entry , image - > name ) ) )
{
if ( de - > source_type = = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL )
* ( image - > dest ) = - de - > id - 1 ;
else
* ( image - > dest ) = de - > id ;
* ( image - > set ) = EINA_FALSE ;
find = EINA_TRUE ;
2012-01-25 01:07:36 -08:00
if ( ! eina_hash_find ( images_in_use , image - > name ) )
eina_hash_direct_add ( images_in_use , de - > entry , de ) ;
2012-04-19 01:41:47 -07:00
break ;
}
}
2010-06-01 06:31:07 -07:00
2012-04-19 01:41:47 -07:00
if ( ! find )
{
Edje_Image_Directory_Set * set ;
2007-08-26 05:54:51 -07:00
2012-04-19 01:41:47 -07:00
for ( i = 0 ; i < edje_file - > image_dir - > sets_count ; + + i )
{
set = edje_file - > image_dir - > sets + i ;
if ( ( set - > name ) & & ( ! strcmp ( set - > name , image - > name ) ) )
{
Edje_Image_Directory_Set_Entry * child ;
Eina_List * lc ;
* ( image - > dest ) = set - > id ;
* ( image - > set ) = EINA_TRUE ;
find = EINA_TRUE ;
EINA_LIST_FOREACH ( set - > entries , lc , child )
if ( ! eina_hash_find ( images_in_use , child - > name ) )
eina_hash_direct_add ( images_in_use , child - > name , child ) ;
if ( ! eina_hash_find ( images_in_use , image - > name ) )
eina_hash_direct_add ( images_in_use , set - > name , set ) ;
break ;
}
}
}
}
if ( ! find )
{
2012-07-31 15:42:03 -07:00
ERR ( " Unable to find image name \" %s \" . " , image - > name ) ;
2012-04-19 01:41:47 -07:00
exit ( - 1 ) ;
}
2004-10-19 09:37:20 -07:00
2012-04-19 01:41:47 -07:00
free ( image - > name ) ;
free ( image ) ;
2004-10-19 09:37:20 -07:00
}
2012-03-01 07:46:33 -08:00
if ( edje_file - > image_dir & & ! is_lua )
2012-01-25 01:07:36 -08:00
{
2013-11-03 22:28:59 -08:00
Edje_Image_Directory_Entry * de , * de_last , * img ;
2012-01-25 01:07:36 -08:00
Edje_Image_Directory_Set * set ;
2013-11-03 22:28:59 -08:00
Edje_Image_Directory_Set_Entry * set_e ;
Eina_List * images_unused_list = NULL ;
2012-01-25 01:07:36 -08:00
unsigned int i ;
for ( i = 0 ; i < edje_file - > image_dir - > entries_count ; + + i )
{
de = edje_file - > image_dir - > entries + i ;
if ( de - > entry & & eina_hash_find ( images_in_use , de - > entry ) )
continue ;
2012-07-31 15:42:03 -07:00
INF ( " Image '%s' in resource 'edje/image/%i' will not be included as it is unused. " ,
de - > entry , de - > id ) ;
2012-01-25 01:07:36 -08:00
2013-11-03 22:28:59 -08:00
/* so as not to write the unused images, moved last image in the
list to unused image position and check it */
free ( ( void * ) de - > entry ) ;
2012-01-25 01:07:36 -08:00
de - > entry = NULL ;
2013-11-03 22:28:59 -08:00
de_last = edje_file - > image_dir - > entries + edje_file - > image_dir - > entries_count - 1 ;
iui = mem_alloc ( SZ ( Image_Unused_Ids ) ) ;
iui - > old_id = de_last - > id ;
images_unused_list = eina_list_append ( images_unused_list , iui ) ;
iui - > new_id = i ;
de_last - > id = i ;
memcpy ( de , de_last , sizeof ( Edje_Image_Directory_Entry ) ) ;
- - i ; /* need to check a moved image on this index */
edje_file - > image_dir - > entries_count - - ;
img = realloc ( edje_file - > image_dir - > entries ,
sizeof ( Edje_Image_Directory_Entry ) * edje_file - > image_dir - > entries_count ) ;
edje_file - > image_dir - > entries = img ;
2012-01-25 01:07:36 -08:00
}
for ( i = 0 ; i < edje_file - > image_dir - > sets_count ; + + i )
{
set = edje_file - > image_dir - > sets + i ;
if ( set - > name & & eina_hash_find ( images_in_use , set - > name ) )
continue ;
2012-07-31 15:42:03 -07:00
INF ( " Set '%s' will not be included as it is unused. " , set - > name ) ;
2012-01-25 01:07:36 -08:00
2013-11-03 22:28:59 -08:00
free ( ( void * ) set - > name ) ;
EINA_LIST_FREE ( set - > entries , set_e )
{
free ( ( void * ) set_e - > name ) ;
free ( set_e ) ;
}
2012-01-25 01:07:36 -08:00
}
2014-11-10 03:45:33 -08:00
2013-11-03 22:28:59 -08:00
/* update image id in parts */
if ( images_unused_list ) _data_image_id_update ( images_unused_list ) ;
EINA_LIST_FREE ( images_unused_list , iui )
free ( iui ) ;
2014-11-10 03:45:33 -08:00
_data_image_sets_size_set ( ) ;
2012-01-25 01:07:36 -08:00
}
eina_hash_free ( images_in_use ) ;
2015-02-05 06:29:03 -08:00
models_in_use = eina_hash_string_superfast_new ( NULL ) ;
EINA_LIST_FREE ( model_lookups , model )
{
Eina_Bool find = EINA_FALSE ;
if ( edje_file - > model_dir )
{
Edje_Model_Directory_Entry * de ;
unsigned int i ;
for ( i = 0 ; i < edje_file - > model_dir - > entries_count ; + + i )
{
de = edje_file - > model_dir - > entries + i ;
if ( ( de - > entry ) & & ( ! strcmp ( de - > entry , model - > name ) ) )
{
* ( model - > dest ) = de - > id ;
* ( model - > set ) = EINA_FALSE ;
find = EINA_TRUE ;
if ( ! eina_hash_find ( models_in_use , model - > name ) )
eina_hash_direct_add ( models_in_use , de - > entry , de ) ;
break ;
}
}
}
if ( ! find )
{
ERR ( " Unable to find model name \" %s \" . " , model - > name ) ;
exit ( - 1 ) ;
}
free ( model - > name ) ;
free ( model ) ;
}
if ( edje_file - > model_dir & & ! is_lua )
{
Edje_Model_Directory_Entry * de , * de_last , * mdl ;
Eina_List * models_unused_list = NULL ;
unsigned int i ;
for ( i = 0 ; i < edje_file - > model_dir - > entries_count ; + + i )
{
de = edje_file - > model_dir - > entries + i ;
if ( de - > entry & & eina_hash_find ( models_in_use , de - > entry ) )
continue ;
INF ( " Model '%s' in resource 'edje/model/%i' will not be included as it is unused. " ,
de - > entry , de - > id ) ;
/* so as not to write the unused models, moved last model in the
list to unused model position and check it */
free ( ( void * ) de - > entry ) ;
de - > entry = NULL ;
de_last = edje_file - > model_dir - > entries + edje_file - > model_dir - > entries_count - 1 ;
iui = mem_alloc ( SZ ( Image_Unused_Ids ) ) ;
iui - > old_id = de_last - > id ;
models_unused_list = eina_list_append ( models_unused_list , iui ) ;
iui - > new_id = i ;
de_last - > id = i ;
memcpy ( de , de_last , sizeof ( Edje_Model_Directory_Entry ) ) ;
- - i ; /* need to check a moved model on this index */
edje_file - > model_dir - > entries_count - - ;
mdl = realloc ( edje_file - > model_dir - > entries ,
sizeof ( Edje_Model_Directory_Entry ) * edje_file - > model_dir - > entries_count ) ;
edje_file - > model_dir - > entries = mdl ;
}
/* update model id in parts */
if ( models_unused_list ) _data_model_id_update ( models_unused_list ) ;
EINA_LIST_FREE ( models_unused_list , iui )
free ( iui ) ;
}
eina_hash_free ( models_in_use ) ;
2003-06-13 20:06:36 -07:00
}
2004-04-01 01:30:45 -08:00
static void
2010-08-15 11:14:33 -07:00
data_process_string ( Edje_Part_Collection * pc , const char * prefix , char * s , void ( * func ) ( Edje_Part_Collection * pc , char * name , char * ptr , int len ) )
2004-04-01 01:30:45 -08:00
{
char * p ;
char * key ;
int keyl ;
int quote , escape ;
2007-08-26 05:54:51 -07:00
2014-01-19 19:47:46 -08:00
keyl = strlen ( prefix ) + 2 ;
key = alloca ( keyl + 1 ) ;
2004-04-01 01:30:45 -08:00
if ( ! key ) return ;
strcpy ( key , prefix ) ;
strcat ( key , " : \" " ) ;
quote = 0 ;
escape = 0 ;
for ( p = s ; ( p ) & & ( * p ) ; p + + )
{
if ( ! quote )
{
if ( * p = = ' \" ' )
{
quote = 1 ;
p + + ;
}
}
if ( ! quote )
{
if ( ! strncmp ( p , key , keyl ) )
{
2008-04-11 16:36:35 -07:00
char * ptr ;
int len ;
int inesc = 0 ;
char * name ;
ptr = p ;
p + = keyl ;
while ( ( * p ) )
2004-04-01 01:30:45 -08:00
{
2008-04-11 16:36:35 -07:00
if ( ! inesc )
{
2012-08-23 00:54:58 -07:00
if ( * p = = ' \\ ' ) inesc = 1 ;
2008-04-11 16:36:35 -07:00
else if ( * p = = ' \" ' )
2004-04-01 01:30:45 -08:00
{
2008-04-11 16:36:35 -07:00
/* string concatenation, see below */
if ( * ( p + 1 ) ! = ' \" ' )
break ;
else
p + + ;
2004-04-01 01:30:45 -08:00
}
}
2008-04-11 16:36:35 -07:00
else
inesc = 0 ;
p + + ;
}
len = p - ptr + 1 ;
name = alloca ( len ) ;
if ( name )
{
char * pp ;
int i ;
name [ 0 ] = 0 ;
pp = ptr + keyl ;
inesc = 0 ;
i = 0 ;
while ( * pp )
{
2012-08-23 00:54:58 -07:00
if ( ! inesc )
2004-04-01 01:30:45 -08:00
{
2008-04-11 16:36:35 -07:00
if ( * pp = = ' \\ ' ) inesc = 1 ;
else if ( * pp = = ' \" ' )
2012-08-23 00:54:58 -07:00
{
2008-04-11 16:36:35 -07:00
/* concat strings like "foo""bar" to "foobar" */
if ( * ( pp + 1 ) = = ' \" ' )
pp + + ;
2004-04-01 01:30:45 -08:00
else
2008-04-11 16:36:35 -07:00
{
2012-08-23 00:54:58 -07:00
name [ i ] = 0 ;
2008-04-11 16:36:35 -07:00
break ;
2004-04-01 01:30:45 -08:00
}
}
else
2008-04-11 16:36:35 -07:00
{
name [ i ] = * pp ;
name [ i + 1 ] = 0 ;
i + + ;
}
2004-04-01 01:30:45 -08:00
}
2008-04-11 16:36:35 -07:00
else
inesc = 0 ;
pp + + ;
}
func ( pc , name , ptr , len ) ;
}
}
2004-04-01 01:30:45 -08:00
}
else
{
if ( ! escape )
{
if ( * p = = ' \" ' ) quote = 0 ;
else if ( * p = = ' \\ ' ) escape = 1 ;
}
else if ( escape )
{
escape = 0 ;
}
}
}
}
2004-04-01 01:53:11 -08:00
static void
2010-08-15 11:14:33 -07:00
_data_queue_part_lookup ( Edje_Part_Collection * pc , char * name , char * ptr , int len )
2004-04-01 01:30:45 -08:00
{
2008-04-11 16:36:35 -07:00
Code_Lookup * cl ;
2012-09-11 01:15:33 -07:00
2008-04-11 16:36:35 -07:00
cl = mem_alloc ( SZ ( Code_Lookup ) ) ;
cl - > ptr = ptr ;
cl - > len = len ;
data_queue_part_lookup ( pc , name , & ( cl - > val ) ) ;
2008-10-22 04:34:42 -07:00
code_lookups = eina_list_append ( code_lookups , cl ) ;
2008-04-11 16:36:35 -07:00
}
static void
2010-08-15 11:14:33 -07:00
_data_queue_program_lookup ( Edje_Part_Collection * pc , char * name , char * ptr , int len )
2008-04-11 16:36:35 -07:00
{
Code_Lookup * cl ;
2009-10-25 04:24:55 -07:00
2008-04-11 16:36:35 -07:00
cl = mem_alloc ( SZ ( Code_Lookup ) ) ;
cl - > ptr = ptr ;
cl - > len = len ;
data_queue_program_lookup ( pc , name , & ( cl - > val ) ) ;
2008-10-22 04:34:42 -07:00
code_lookups = eina_list_append ( code_lookups , cl ) ;
2008-04-11 16:36:35 -07:00
}
static void
2013-01-03 18:08:14 -08:00
_data_queue_group_lookup ( Edje_Part_Collection * pc EINA_UNUSED , char * name , char * ptr EINA_UNUSED , int len EINA_UNUSED )
2008-04-11 16:36:35 -07:00
{
2011-12-19 09:25:00 -08:00
data_queue_group_lookup ( name , NULL ) ;
2008-04-11 16:36:35 -07:00
}
static void
2013-01-03 18:08:14 -08:00
_data_queue_image_pc_lookup ( Edje_Part_Collection * pc EINA_UNUSED , char * name , char * ptr , int len )
2008-04-11 16:36:35 -07:00
{
Code_Lookup * cl ;
2009-10-25 04:24:55 -07:00
2008-04-11 16:36:35 -07:00
cl = mem_alloc ( SZ ( Code_Lookup ) ) ;
cl - > ptr = ptr ;
cl - > len = len ;
2010-06-01 06:31:07 -07:00
data_queue_image_lookup ( name , & ( cl - > val ) , & ( cl - > set ) ) ;
2008-04-11 16:36:35 -07:00
2008-10-22 04:34:42 -07:00
code_lookups = eina_list_append ( code_lookups , cl ) ;
2004-04-01 01:30:45 -08:00
}
void
data_process_scripts ( void )
{
2008-10-22 04:34:42 -07:00
Eina_List * l , * l2 ;
2007-08-26 05:54:51 -07:00
2008-10-22 04:34:42 -07:00
for ( l = codes , l2 = edje_collections ; ( l ) & & ( l2 ) ; l = eina_list_next ( l ) , l2 = eina_list_next ( l2 ) )
2004-04-01 01:30:45 -08:00
{
2010-08-15 11:14:33 -07:00
Edje_Part_Collection * pc ;
2004-04-01 01:30:45 -08:00
Code * cd ;
2007-08-26 05:54:51 -07:00
2008-10-22 04:34:42 -07:00
cd = eina_list_data_get ( l ) ;
pc = eina_list_data_get ( l2 ) ;
2010-08-15 11:14:33 -07:00
if ( ( cd - > shared ) & & ( ! cd - > is_lua ) )
{
data_process_string ( pc , " PART " , cd - > shared , _data_queue_part_lookup ) ;
data_process_string ( pc , " PROGRAM " , cd - > shared , _data_queue_program_lookup ) ;
data_process_string ( pc , " IMAGE " , cd - > shared , _data_queue_image_pc_lookup ) ;
data_process_string ( pc , " GROUP " , cd - > shared , _data_queue_group_lookup ) ;
}
if ( cd - > programs )
2004-04-01 01:30:45 -08:00
{
2008-10-22 04:34:42 -07:00
Code_Program * cp ;
2010-08-15 11:14:33 -07:00
Eina_List * ll ;
2007-08-26 05:54:51 -07:00
2008-10-22 04:34:42 -07:00
EINA_LIST_FOREACH ( cd - > programs , ll , cp )
2004-04-01 01:30:45 -08:00
{
if ( cp - > script )
{
2008-04-11 16:36:35 -07:00
data_process_string ( pc , " PART " , cp - > script , _data_queue_part_lookup ) ;
data_process_string ( pc , " PROGRAM " , cp - > script , _data_queue_program_lookup ) ;
data_process_string ( pc , " IMAGE " , cp - > script , _data_queue_image_pc_lookup ) ;
data_process_string ( pc , " GROUP " , cp - > script , _data_queue_group_lookup ) ;
2004-04-01 01:30:45 -08:00
}
}
}
}
}
void
data_process_script_lookups ( void )
{
2008-10-22 04:34:42 -07:00
Eina_List * l ;
Code_Lookup * cl ;
2007-08-26 05:54:51 -07:00
2008-10-22 04:34:42 -07:00
EINA_LIST_FOREACH ( code_lookups , l , cl )
2004-04-01 01:30:45 -08:00
{
2009-02-25 09:08:17 -08:00
char buf [ 12 ] ;
int n ;
2004-04-01 01:30:45 -08:00
2010-06-01 06:31:07 -07:00
/* FIXME !! Handle set in program */
2009-02-25 09:08:17 -08:00
n = eina_convert_itoa ( cl - > val , buf ) ;
2004-04-01 01:30:45 -08:00
if ( n > cl - > len )
{
2012-07-31 15:42:03 -07:00
ERR ( " The unexpected happened. A numeric replacement string was larger than the original! " ) ;
2004-04-01 01:30:45 -08:00
exit ( - 1 ) ;
}
2009-02-25 09:08:17 -08:00
memset ( cl - > ptr , ' ' , cl - > len ) ;
2004-04-01 01:30:45 -08:00
strncpy ( cl - > ptr , buf , n ) ;
}
}
2012-05-08 03:35:57 -07:00
void
2012-09-03 19:13:05 -07:00
using_file ( const char * filename , const char type )
2012-05-08 03:35:57 -07:00
{
2012-05-15 05:29:22 -07:00
FILE * f ;
2012-05-08 03:35:57 -07:00
2015-04-06 07:01:19 -07:00
if ( depfile )
2012-09-03 19:13:05 -07:00
{
2015-04-06 07:01:19 -07:00
f = fopen ( depfile , " ab " ) ;
if ( ! f ) return ;
if ( type ! = ' O ' )
{
fprintf ( f , " \\ \n %s " , filename ) ;
}
fclose ( f ) ;
2012-09-03 19:13:05 -07:00
}
2015-04-06 07:01:19 -07:00
else if ( watchfile )
2012-09-03 19:13:05 -07:00
{
2015-04-06 07:01:19 -07:00
f = fopen ( watchfile , " ab " ) ;
if ( ! f ) return ;
if ( anotate )
{
fprintf ( f , " %c: %s \n " , type , filename ) ;
}
else
{
fputs ( filename , f ) ;
fputc ( ' \n ' , f ) ;
}
fclose ( f ) ;
2012-09-03 19:13:05 -07:00
}
2012-05-08 03:35:57 -07:00
}