You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 lines
6.8 KiB

#ifndef EDJE_CC_H
#define EDJE_CC_H
#include <edje_private.h>
extern Eina_Prefix *pfx;
/*
* On Windows, if the file is not opened in binary mode,
* read does not return the correct size, because of
* CR / LF translation.
*/
#ifndef O_BINARY
# define O_BINARY 0
#endif
/* logging variables */
extern int _edje_cc_log_dom ;
#define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
#ifdef ERR
# undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(_edje_cc_log_dom, __VA_ARGS__)
#ifdef INF
# undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(_edje_cc_log_dom, __VA_ARGS__)
#ifdef WRN
# undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__)
#ifdef CRIT
# undef CRIT
#endif
#define CRIT(...) EINA_LOG_DOM_CRIT(_edje_cc_log_dom, __VA_ARGS__)
#ifdef DBG
# undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_edje_cc_log_dom, __VA_ARGS__)
/* types */
typedef struct _New_Object_Handler New_Object_Handler;
typedef struct _New_Statement_Handler New_Statement_Handler;
typedef struct _New_Nested_Handler New_Nested_Handler;
typedef struct _External_List External_List;
typedef struct _External External;
typedef struct _Code Code;
typedef struct _Code_Program Code_Program;
typedef struct _SrcFile SrcFile;
typedef struct _SrcFile_List SrcFile_List;
typedef struct _Edje_Program_Parser Edje_Program_Parser;
typedef struct _Edje_Pack_Element_Parser Edje_Pack_Element_Parser;
typedef struct _Edje_Part_Parser Edje_Part_Parser;
struct _New_Object_Handler
{
const char *type;
void (*func)(void);
};
struct _New_Statement_Handler
{
const char *type;
void (*func)(void);
};
struct _New_Nested_Handler
{
const char *type;
const char *token;
void (*func_push)(void);
void (*func_pop)(void);
};
struct _External_List
{
Eina_List *list;
};
struct _External
{
char *name;
};
struct _Code
{
int l1, l2;
char *shared;
char *original;
Eina_List *programs;
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
14 years ago
int is_lua;
};
struct _Code_Program
{
int l1, l2;
int id;
char *script;
char *original;
};
struct _SrcFile
{
char *name;
char *file;
};
struct _SrcFile_List
{
Eina_List *list;
};
struct _Edje_Program_Parser
{
Edje_Program common;
Eina_Bool can_override;
};
struct _Edje_Pack_Element_Parser
{
Edje_Pack_Element common;
Eina_Bool can_override;
};
struct _Edje_Part_Parser
{
Edje_Part common;
struct {
Eina_Bool done;
const char *insert_before; /* the part name for insertion in front of */
const char *insert_after; /* the part name for insertion behind of */
Edje_Part_Parser *before;
Edje_Part_Parser *after;
int linked_prev; /* the number linked previous part for reorder */
int linked_next; /* the number linked next part for reorder */
} reorder;
Eina_Bool can_override;
};
/* global fn calls */
void data_setup(void);
void data_write(void);
void data_queue_face_group_lookup(const char *name);
void data_queue_group_lookup(const char *name, Edje_Part *part);
void data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest);
void data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest);
void data_queue_program_lookup(Edje_Part_Collection *pc, const char *name, int *dest);
void data_queue_copied_program_lookup(Edje_Part_Collection *pc, int *src, int *dest);
void data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest);
void data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest);
void data_queue_image_lookup(char *name, int *dest, Eina_Bool *set);
void data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set);
void data_queue_image_remove(int *dest, Eina_Bool *set);
void data_queue_part_slave_lookup(int *master, int *slave);
void data_queue_image_slave_lookup(int *master, int *slave);
void data_queue_spectrum_lookup(char *name, int *dest);
void data_queue_spectrum_slave_lookup(int *master, int *slave);
void data_process_lookups(void);
void data_process_scripts(void);
void data_process_script_lookups(void);
void part_description_image_cleanup(Edje_Part *ep);
int is_verbatim(void);
void track_verbatim(int on);
void set_verbatim(char *s, int l1, int l2);
char *get_verbatim(void);
int get_verbatim_line1(void);
int get_verbatim_line2(void);
void compile(void);
int is_param(int n);
int is_num(int n);
char *parse_str(int n);
int parse_enum(int n, ...);
int parse_flags(int n, ...);
int parse_int(int n);
int parse_int_range(int n, int f, int t);
int parse_bool(int n);
double parse_float(int n);
double parse_float_range(int n, double f, double t);
int get_arg_count(void);
void check_arg_count(int n);
void check_min_arg_count(int n);
int object_handler_num(void);
int statement_handler_num(void);
int nested_handler_num(void);
void reorder_parts(void);
void source_edd(void);
void source_fetch(void);
int source_append(Eet_File *ef);
SrcFile_List *source_load(Eet_File *ef);
int source_fontmap_save(Eet_File *ef, Eina_List *fonts);
Edje_Font_List *source_fontmap_load(Eet_File *ef);
void *mem_alloc(size_t size);
char *mem_strdup(const char *s);
#define SZ sizeof
void using_file(const char *filename, const char type);
void error_and_abort(Eet_File *ef, const char *fmt, ...);
void edje_cc_handlers_hierarchy_alloc(void);
void edje_cc_handlers_hierarchy_free(void);
/* global vars */
extern Eina_List *ext_dirs;
extern Eina_List *img_dirs;
extern Eina_List *fnt_dirs;
extern Eina_List *snd_dirs;
extern char *file_in;
extern char *tmp_dir;
extern char *file_out;
extern char *watchfile;
extern int no_lossy;
extern int no_comp;
extern int no_raw;
extern int no_save;
extern int min_quality;
extern int max_quality;
extern int line;
extern Eina_List *stack;
extern Edje_File *edje_file;
extern Eina_List *edje_collections;
extern Eina_Hash *edje_collections_lookup;
extern Eina_List *externals;
extern Eina_List *fonts;
extern Eina_List *codes;
extern Eina_List *defines;
extern Eina_List *aliases;
extern New_Object_Handler object_handlers[];
extern New_Statement_Handler statement_handlers[];
extern New_Nested_Handler nested_handlers[];
extern int compress_mode;
extern int threads;
extern int anotate;
#endif