1 #ifndef EDJE_CC_H
2 #define EDJE_CC_H
3 
4 #include <edje_private.h>
5 
6 extern Eina_Prefix *pfx;
7 
8 /*
9  * On Windows, if the file is not opened in binary mode,
10  * read does not return the correct size, because of
11  * CR / LF translation.
12  */
13 #ifndef O_BINARY
14 # define O_BINARY 0
15 #endif
16 
17 /* logging variables */
18 extern int _edje_cc_log_dom ;
19 #define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
20 
21 #ifdef ERR
22 # undef ERR
23 #endif
24 #define ERR(...) EINA_LOG_DOM_ERR(_edje_cc_log_dom, __VA_ARGS__)
25 #ifdef INF
26 # undef INF
27 #endif
28 #define INF(...) EINA_LOG_DOM_INFO(_edje_cc_log_dom, __VA_ARGS__)
29 #ifdef WRN
30 # undef WRN
31 #endif
32 #define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__)
33 #ifdef CRI
34 # undef CRI
35 #endif
36 #define CRI(...) EINA_LOG_DOM_CRIT(_edje_cc_log_dom, __VA_ARGS__)
37 #ifdef DBG
38 # undef DBG
39 #endif
40 #define DBG(...) EINA_LOG_DOM_DBG(_edje_cc_log_dom, __VA_ARGS__)
41 
42 /* types */
43 typedef struct _New_Object_Handler    New_Object_Handler;
44 typedef struct _New_Statement_Handler New_Statement_Handler;
45 typedef struct _New_Nested_Handler    New_Nested_Handler;
46 typedef struct _External_List         External_List;
47 typedef struct _External              External;
48 typedef struct _Code                  Code;
49 typedef struct _Code_Program          Code_Program;
50 typedef struct _SrcFile               SrcFile;
51 typedef struct _SrcFile_List          SrcFile_List;
52 
53 typedef struct _Edje_Program_Parser                  Edje_Program_Parser;
54 typedef struct _Edje_Pack_Element_Parser             Edje_Pack_Element_Parser;
55 typedef struct _Edje_Part_Parser                     Edje_Part_Parser;
56 typedef struct _Edje_Part_Collection_Parser          Edje_Part_Collection_Parser;
57 
58 struct _New_Object_Handler
59 {
60    const char *type;
61    void (*func)(void);
62 };
63 
64 struct _New_Statement_Handler
65 {
66    const char *type;
67    void (*func)(void);
68 };
69 
70 struct _New_Nested_Handler
71 {
72    const char *type;
73    const char *token;
74    void (*func_push)(void);
75    void (*func_pop)(void);
76 };
77 
78 struct _External_List
79 {
80    Eina_List *list;
81 };
82 
83 struct _External
84 {
85     char *name;
86 };
87 
88 struct _Code
89 {
90    int       l1, l2;
91    char      *shared;
92    char      *original;
93    Eina_List *programs;
94    Eina_List *vars;
95    Eina_List *func;
96    Eina_Bool  parsed : 1;
97    Eina_Bool  is_lua : 1;
98 };
99 
100 struct _Code_Program
101 {
102    int        l1, l2;
103    int        id;
104    char      *script;
105    char      *original;
106 };
107 
108 struct _SrcFile
109 {
110    char *name;
111    char *file;
112 };
113 
114 struct _SrcFile_List
115 {
116    Eina_List *list;
117 };
118 
119 struct _Edje_Program_Parser
120 {
121    Edje_Program common;
122    Eina_Bool can_override;
123 };
124 
125 struct _Edje_Pack_Element_Parser
126 {
127    Edje_Pack_Element common;
128    Eina_Bool can_override;
129 };
130 
131 struct _Edje_Part_Parser
132 {
133    Edje_Part common;
134    struct {
135       Eina_Bool           done;
136       const char         *insert_before; /* the part name for insertion in front of */
137       const char         *insert_after; /* the part name for insertion behind of */
138       Edje_Part_Parser   *before;
139       Edje_Part_Parser   *after;
140       int                 linked_prev; /* the number linked previous part for reorder */
141       int                 linked_next; /* the number linked next part for reorder */
142    } reorder;
143    Eina_Bool can_override;
144 };
145 
146 typedef struct Edje_Target_Group
147 {
148    char *name;
149    char **targets;
150 } Edje_Target_Group;
151 
152 typedef struct Edje_Part_Description_Link
153 {
154    Edje_Program *pr;
155    Edje_Part_Description_Common *ed;
156    Edje_Part_Parser *epp;
157 } Edje_Part_Description_Link;
158 
159 struct _Edje_Part_Collection_Parser
160 {
161    Edje_Part_Collection common;
162    char *default_source;
163    Eina_List *target_groups;
164    Eina_List *links;
165    Eina_Hash *link_hash;
166    Eina_List *base_codes;
167    Eina_Bool default_mouse_events;
168    Eina_Bool inherit_only;
169    Eina_Bool inherit_script : 1;
170    Eina_Bool skip_namespace_validation : 1;
171 };
172 
173 typedef enum
174 {
175    EDJE_PART_ANCHOR_LINE_RELATIVE = -1,
176    EDJE_PART_ANCHOR_LINE_NONE,
177    EDJE_PART_ANCHOR_LINE_TOP,
178    EDJE_PART_ANCHOR_LINE_BOTTOM,
179    EDJE_PART_ANCHOR_LINE_LEFT,
180    EDJE_PART_ANCHOR_LINE_RIGHT,
181    EDJE_PART_ANCHOR_LINE_VERTICAL_CENTER,
182    EDJE_PART_ANCHOR_LINE_HORIZONTAL_CENTER
183 } Edje_Part_Anchor_Line;
184 
185 typedef enum
186 {
187    EDJE_PART_ANCHOR_FILL_BOTH,
188    EDJE_PART_ANCHOR_FILL_HORIZONTAL,
189    EDJE_PART_ANCHOR_FILL_VERTICAL
190 } Edje_Part_Anchor_Fill;
191 
192 typedef struct
193 {
194    union {
195       Edje_Part_Anchor_Line line;
196       Edje_Part_Anchor_Fill fill;
197    } base;
198    Eina_Bool set : 1;
199 } Edje_Part_Anchor;
200 
201 typedef struct
202 {
203    Edje_Part_Anchor top;
204    Edje_Part_Anchor bottom;
205    Edje_Part_Anchor left;
206    Edje_Part_Anchor right;
207    Edje_Part_Anchor vertical_center;
208    Edje_Part_Anchor horizontal_center;
209    Edje_Part_Anchor fill;
210 } Edje_Part_Description_Anchors;
211 
212 /* global fn calls */
213 void    data_setup(void);
214 void    data_write(void);
215 void    data_queue_face_group_lookup(const char *name);
216 void    data_queue_group_lookup(const char *name, Edje_Part *part);
217 void    data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest);
218 void    data_queue_part_nest_lookup(Edje_Part_Collection *pc, const char *name, int *dest, char **dest2);
219 void    data_queue_copied_part_nest_lookup(Edje_Part_Collection *pc, int *src, int *dest, char **dest2);
220 void    data_queue_part_reallocated_lookup(Edje_Part_Collection *pc, const char *name,
221 					   unsigned char **base, int offset);
222 void    part_lookup_del(Edje_Part_Collection *pc, int *dest);
223 void    part_lookup_delete(Edje_Part_Collection *pc, const char *name, int *dest, char **dest2);
224 void    data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest);
225 void   *data_queue_program_lookup(Edje_Part_Collection *pc, const char *name, int *dest);
226 void    program_lookup_rename(void *p, const char *name);
227 void    copied_program_lookup_delete(Edje_Part_Collection *pc, const char *name);
228 Eina_Bool     data_queue_copied_program_lookup(Edje_Part_Collection *pc, int *src, int *dest);
229 void    copied_program_anonymous_lookup_delete(Edje_Part_Collection *pc, int *dest);
230 void    data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest);
231 void    data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest);
232 void    data_queue_image_lookup(char *name, int *dest, Eina_Bool *set);
233 void    data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set);
234 void    data_queue_image_remove(int *dest, Eina_Bool *set);
235 void    data_process_lookups(void);
236 void    data_process_scripts(void);
237 void    data_process_script_lookups(void);
238 void    process_color_tree(char *s, const char *file_in, int line);
239 
240 void    part_description_image_cleanup(Edje_Part *ep);
241 
242 int     is_verbatim(void);
243 void    track_verbatim(int on);
244 void    set_verbatim(char *s, int l1, int l2);
245 char   *get_verbatim(void);
246 int     get_verbatim_line1(void);
247 int     get_verbatim_line2(void);
248 void    compile(void);
249 int     is_param(int n);
250 int     is_num(int n);
251 char   *parse_str(int n);
252 int     parse_enum(int n, ...);
253 int     parse_flags(int n, ...);
254 int     parse_int(int n);
255 int     parse_int_range(int n, int f, int t);
256 int     parse_bool(int n);
257 double  parse_float(int n);
258 double  parse_float_range(int n, double f, double t);
259 int     get_arg_count(void);
260 void    check_arg_count(int n);
261 void    check_min_arg_count(int n);
262 int     check_range_arg_count(int n, int m);
263 int     param_had_quote(int n);
264 
265 int     object_handler_num(void);
266 int     object_handler_short_num(void);
267 int     statement_handler_num(void);
268 int     statement_handler_short_num(void);
269 int     statement_handler_short_single_num(void);
270 int     nested_handler_num(void);
271 int     nested_handler_short_num(void);
272 
273 void    reorder_parts(void);
274 void    source_edd(void);
275 void    source_fetch(void);
276 int     source_append(Eet_File *ef);
277 SrcFile_List *source_load(Eet_File *ef);
278 int     source_fontmap_save(Eet_File *ef, Eina_List *fonts);
279 Edje_Font_List *source_fontmap_load(Eet_File *ef);
280 
281 void   *mem_alloc(size_t size);
282 char   *mem_strdup(const char *s);
283 #define SZ sizeof
284 
285 void    using_file(const char *filename, const char type);
286 
287 void    error_and_abort(Eet_File *ef, const char *fmt, ...);
288 
289 void stack_push_quick(const char *str);
290 char *stack_pop_quick(Eina_Bool check_last, Eina_Bool do_free);
291 void stack_replace_quick(const char *token);
292 Eina_Bool edje_cc_handlers_wildcard(void);
293 void edje_cc_handlers_hierarchy_alloc(void);
294 void edje_cc_handlers_hierarchy_free(void);
295 void edje_cc_handlers_pop_notify(const char *token);
296 int get_param_index(char *str);
297 
298 void color_tree_root_free(void);
299 void convert_color_code(char *str, int *r, int *g, int *b, int *a);
300 
301 void script_rewrite(Code *code);
302 
303 /* global vars */
304 extern Eina_List             *ext_dirs;
305 extern Eina_List             *img_dirs;
306 extern Eina_List             *fnt_dirs;
307 extern Eina_List             *snd_dirs;
308 extern Eina_List             *mo_dirs;
309 extern Eina_List             *vibration_dirs;
310 extern Eina_List             *data_dirs;
311 extern char                  *file_in;
312 extern char                  *file_out;
313 extern char                  *watchfile;
314 extern char                  *depfile;
315 extern char                  *license;
316 extern char                  *authors;
317 extern Eina_List             *licenses;
318 extern int                    no_lossy;
319 extern int                    no_comp;
320 extern int                    no_raw;
321 extern int                    no_etc1;
322 extern int                    no_etc2;
323 extern int                    no_save;
324 extern int                    min_quality;
325 extern int                    max_quality;
326 extern int                    line;
327 extern Eina_List             *stack;
328 extern Edje_File             *edje_file;
329 extern Eina_List             *edje_collections;
330 extern Eina_Hash             *edje_collections_lookup;
331 extern Eina_List             *externals;
332 extern Eina_List             *fonts;
333 extern Eina_List             *codes;
334 extern Eina_List             *defines;
335 extern Eina_List             *aliases;
336 extern New_Object_Handler     object_handlers[];
337 extern New_Object_Handler     object_handlers_short[];
338 extern New_Statement_Handler  statement_handlers[];
339 extern New_Statement_Handler  statement_handlers_short[];
340 extern New_Statement_Handler  statement_handlers_short_single[];
341 extern New_Nested_Handler     nested_handlers[];
342 extern New_Nested_Handler     nested_handlers_short[];
343 extern int                    compress_mode;
344 extern int                    threads;
345 extern int                    annotate;
346 extern Eina_Bool current_group_inherit;
347 extern Eina_List             *color_tree_root;
348 extern int                    beta;
349 
350 extern int had_quote;
351 
352 extern unsigned int max_open_files;
353 extern Eina_Array *requires;
354 extern Eina_Bool namespace_verify;
355 #endif
356