aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/bin
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/edje/src/bin
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r--libraries/edje/src/bin/Makefile.am72
-rw-r--r--libraries/edje/src/bin/Makefile.in1149
-rw-r--r--libraries/edje/src/bin/edje_cc.c250
-rw-r--r--libraries/edje/src/bin/edje_cc.h226
-rw-r--r--libraries/edje/src/bin/edje_cc_handlers.c7763
-rw-r--r--libraries/edje/src/bin/edje_cc_mem.c40
-rw-r--r--libraries/edje/src/bin/edje_cc_out.c1995
-rw-r--r--libraries/edje/src/bin/edje_cc_parse.c1552
-rw-r--r--libraries/edje/src/bin/edje_cc_sources.c259
-rw-r--r--libraries/edje/src/bin/edje_convert.c459
-rw-r--r--libraries/edje/src/bin/edje_convert.h154
-rw-r--r--libraries/edje/src/bin/edje_data_convert.c451
-rw-r--r--libraries/edje/src/bin/edje_decc.c472
-rw-r--r--libraries/edje/src/bin/edje_decc.h61
-rw-r--r--libraries/edje/src/bin/edje_external_inspector.c663
-rw-r--r--libraries/edje/src/bin/edje_inspector.c1639
-rw-r--r--libraries/edje/src/bin/edje_multisense_convert.c329
-rw-r--r--libraries/edje/src/bin/edje_multisense_convert.h25
-rw-r--r--libraries/edje/src/bin/edje_player.c795
-rw-r--r--libraries/edje/src/bin/edje_recc69
-rw-r--r--libraries/edje/src/bin/epp/Makefile.am59
-rw-r--r--libraries/edje/src/bin/epp/Makefile.in756
-rw-r--r--libraries/edje/src/bin/epp/cppalloc.c70
-rw-r--r--libraries/edje/src/bin/epp/cpperror.c147
-rw-r--r--libraries/edje/src/bin/epp/cppexp.c1090
-rw-r--r--libraries/edje/src/bin/epp/cpphash.c198
-rw-r--r--libraries/edje/src/bin/epp/cpphash.h41
-rw-r--r--libraries/edje/src/bin/epp/cpplib.c7427
-rw-r--r--libraries/edje/src/bin/epp/cpplib.h641
-rw-r--r--libraries/edje/src/bin/epp/cppmain.c142
30 files changed, 28994 insertions, 0 deletions
diff --git a/libraries/edje/src/bin/Makefile.am b/libraries/edje/src/bin/Makefile.am
new file mode 100644
index 0000000..a936d5a
--- /dev/null
+++ b/libraries/edje/src/bin/Makefile.am
@@ -0,0 +1,72 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3if BUILD_EPP
4 SUBDIRS = epp
5endif
6
7bin_SCRIPTS = @EDJE_RECC_PRG@
8
9bin_PROGRAMS = @EDJE_CC_PRG@ @EDJE_DECC_PRG@ @EDJE_PLAYER_PRG@ @EDJE_INSPECTOR_PRG@ @EDJE_EXTERNAL_INSPECTOR_PRG@
10
11EXTRA_PROGRAMS = edje_cc edje_decc edje_player edje_inspector edje_external_inspector
12
13edje_cc_SOURCES = \
14edje_cc.c \
15edje_cc_out.c \
16edje_cc_parse.c \
17edje_cc_mem.c \
18edje_cc_handlers.c \
19edje_cc_sources.c \
20edje_multisense_convert.c
21
22edje_cc_CPPFLAGS = \
23-I$(top_srcdir)/src/bin \
24-I$(top_srcdir)/src/lib \
25-DPACKAGE_BIN_DIR=\"$(bindir)\" \
26-DPACKAGE_LIB_DIR=\"$(libdir)\" \
27-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
28-DEPP_DIR=\"$(libdir)/$(PACKAGE)/utils\" \
29@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EVIL_CFLAGS@ @SNDFILE_CFLAGS@
30edje_cc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_CC_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ -lm
31edje_cc_LDFLAGS = @lt_enable_auto_import@
32
33
34edje_decc_SOURCES = \
35edje_decc.c \
36edje_decc.h \
37edje_cc_mem.c \
38edje_cc_sources.c
39
40edje_decc_CPPFLAGS = \
41-I$(top_srcdir)/src/bin \
42-I$(top_srcdir)/src/lib \
43@EDJE_CFLAGS@ @EDJE_DECC_CFLAGS@ @EVIL_CFLAGS@
44edje_decc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_DECC_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
45edje_decc_LDFLAGS = @lt_enable_auto_import@
46
47edje_player_SOURCES = edje_player.c
48edje_player_CPPFLAGS = \
49-I$(top_srcdir)/src/bin \
50-I$(top_srcdir)/src/lib \
51@EDJE_PLAYER_CFLAGS@ @EVIL_CFLAGS@
52edje_player_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_PLAYER_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
53edje_player_LDFLAGS = @lt_enable_auto_import@
54
55edje_inspector_SOURCES = edje_inspector.c
56edje_inspector_CPPFLAGS = \
57-I$(top_srcdir)/src/bin \
58-I$(top_srcdir)/src/lib \
59@EDJE_INSPECTOR_CFLAGS@
60edje_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@
61edje_inspector_LDFLAGS = @lt_enable_auto_import@
62
63edje_external_inspector_SOURCES = edje_external_inspector.c
64edje_external_inspector_CPPFLAGS = \
65-I$(top_srcdir)/src/bin \
66-I$(top_srcdir)/src/lib \
67@EDJE_EXTERNAL_INSPECTOR_CFLAGS@
68edje_external_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_EXTERNAL_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
69edje_external_inspector_LDFLAGS = @lt_enable_auto_import@
70
71EXTRA_DIST = @EDJE_RECC_PRG@ edje_cc.h edje_convert.h edje_convert.c edje_multisense_convert.h edje_data_convert.c
72EXTRA_SCRIPTS = edje_recc
diff --git a/libraries/edje/src/bin/Makefile.in b/libraries/edje/src/bin/Makefile.in
new file mode 100644
index 0000000..877bcb2
--- /dev/null
+++ b/libraries/edje/src/bin/Makefile.in
@@ -0,0 +1,1149 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18
19VPATH = @srcdir@
20pkgdatadir = $(datadir)/@PACKAGE@
21pkgincludedir = $(includedir)/@PACKAGE@
22pkglibdir = $(libdir)/@PACKAGE@
23pkglibexecdir = $(libexecdir)/@PACKAGE@
24am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
25install_sh_DATA = $(install_sh) -c -m 644
26install_sh_PROGRAM = $(install_sh) -c
27install_sh_SCRIPT = $(install_sh) -c
28INSTALL_HEADER = $(INSTALL_DATA)
29transform = $(program_transform_name)
30NORMAL_INSTALL = :
31PRE_INSTALL = :
32POST_INSTALL = :
33NORMAL_UNINSTALL = :
34PRE_UNINSTALL = :
35POST_UNINSTALL = :
36build_triplet = @build@
37host_triplet = @host@
38EXTRA_PROGRAMS = edje_cc$(EXEEXT) edje_decc$(EXEEXT) \
39 edje_player$(EXEEXT) edje_inspector$(EXEEXT) \
40 edje_external_inspector$(EXEEXT)
41subdir = src/bin
42DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
43ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
44am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
45 $(top_srcdir)/m4/efl_binary.m4 \
46 $(top_srcdir)/m4/efl_coverage.m4 \
47 $(top_srcdir)/m4/efl_doxygen.m4 \
48 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
49 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
50 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
51 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
52am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
53 $(ACLOCAL_M4)
54mkinstalldirs = $(install_sh) -d
55CONFIG_HEADER = $(top_builddir)/config.h
56CONFIG_CLEAN_FILES =
57CONFIG_CLEAN_VPATH_FILES =
58am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
59PROGRAMS = $(bin_PROGRAMS)
60am_edje_cc_OBJECTS = edje_cc-edje_cc.$(OBJEXT) \
61 edje_cc-edje_cc_out.$(OBJEXT) edje_cc-edje_cc_parse.$(OBJEXT) \
62 edje_cc-edje_cc_mem.$(OBJEXT) \
63 edje_cc-edje_cc_handlers.$(OBJEXT) \
64 edje_cc-edje_cc_sources.$(OBJEXT) \
65 edje_cc-edje_multisense_convert.$(OBJEXT)
66edje_cc_OBJECTS = $(am_edje_cc_OBJECTS)
67edje_cc_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la
68AM_V_lt = $(am__v_lt_$(V))
69am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
70am__v_lt_0 = --silent
71edje_cc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
72 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
73 $(edje_cc_LDFLAGS) $(LDFLAGS) -o $@
74am_edje_decc_OBJECTS = edje_decc-edje_decc.$(OBJEXT) \
75 edje_decc-edje_cc_mem.$(OBJEXT) \
76 edje_decc-edje_cc_sources.$(OBJEXT)
77edje_decc_OBJECTS = $(am_edje_decc_OBJECTS)
78edje_decc_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la
79edje_decc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
80 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
81 $(edje_decc_LDFLAGS) $(LDFLAGS) -o $@
82am_edje_external_inspector_OBJECTS = \
83 edje_external_inspector-edje_external_inspector.$(OBJEXT)
84edje_external_inspector_OBJECTS = \
85 $(am_edje_external_inspector_OBJECTS)
86edje_external_inspector_DEPENDENCIES = \
87 $(top_builddir)/src/lib/libedje.la
88edje_external_inspector_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
89 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
90 $(AM_CFLAGS) $(CFLAGS) $(edje_external_inspector_LDFLAGS) \
91 $(LDFLAGS) -o $@
92am_edje_inspector_OBJECTS = edje_inspector-edje_inspector.$(OBJEXT)
93edje_inspector_OBJECTS = $(am_edje_inspector_OBJECTS)
94edje_inspector_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la
95edje_inspector_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
96 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
97 $(AM_CFLAGS) $(CFLAGS) $(edje_inspector_LDFLAGS) $(LDFLAGS) -o \
98 $@
99am_edje_player_OBJECTS = edje_player-edje_player.$(OBJEXT)
100edje_player_OBJECTS = $(am_edje_player_OBJECTS)
101edje_player_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la
102edje_player_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
103 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
104 $(edje_player_LDFLAGS) $(LDFLAGS) -o $@
105am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
106am__vpath_adj = case $$p in \
107 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
108 *) f=$$p;; \
109 esac;
110am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
111am__install_max = 40
112am__nobase_strip_setup = \
113 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
114am__nobase_strip = \
115 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
116am__nobase_list = $(am__nobase_strip_setup); \
117 for p in $$list; do echo "$$p $$p"; done | \
118 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
119 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
120 if (++n[$$2] == $(am__install_max)) \
121 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
122 END { for (dir in files) print dir, files[dir] }'
123am__base_list = \
124 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
125 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
126SCRIPTS = $(bin_SCRIPTS)
127DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
128depcomp = $(SHELL) $(top_srcdir)/depcomp
129am__depfiles_maybe = depfiles
130am__mv = mv -f
131COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
132 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
133LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
134 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
135 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
136 $(AM_CFLAGS) $(CFLAGS)
137AM_V_CC = $(am__v_CC_$(V))
138am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
139am__v_CC_0 = @echo " CC " $@;
140AM_V_at = $(am__v_at_$(V))
141am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
142am__v_at_0 = @
143CCLD = $(CC)
144LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
145 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
146 $(AM_LDFLAGS) $(LDFLAGS) -o $@
147AM_V_CCLD = $(am__v_CCLD_$(V))
148am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
149am__v_CCLD_0 = @echo " CCLD " $@;
150AM_V_GEN = $(am__v_GEN_$(V))
151am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
152am__v_GEN_0 = @echo " GEN " $@;
153SOURCES = $(edje_cc_SOURCES) $(edje_decc_SOURCES) \
154 $(edje_external_inspector_SOURCES) $(edje_inspector_SOURCES) \
155 $(edje_player_SOURCES)
156DIST_SOURCES = $(edje_cc_SOURCES) $(edje_decc_SOURCES) \
157 $(edje_external_inspector_SOURCES) $(edje_inspector_SOURCES) \
158 $(edje_player_SOURCES)
159RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
160 html-recursive info-recursive install-data-recursive \
161 install-dvi-recursive install-exec-recursive \
162 install-html-recursive install-info-recursive \
163 install-pdf-recursive install-ps-recursive install-recursive \
164 installcheck-recursive installdirs-recursive pdf-recursive \
165 ps-recursive uninstall-recursive
166RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
167 distclean-recursive maintainer-clean-recursive
168AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
169 $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
170 distdir
171ETAGS = etags
172CTAGS = ctags
173DIST_SUBDIRS = epp
174DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
175am__relativize = \
176 dir0=`pwd`; \
177 sed_first='s,^\([^/]*\)/.*$$,\1,'; \
178 sed_rest='s,^[^/]*/*,,'; \
179 sed_last='s,^.*/\([^/]*\)$$,\1,'; \
180 sed_butlast='s,/*[^/]*$$,,'; \
181 while test -n "$$dir1"; do \
182 first=`echo "$$dir1" | sed -e "$$sed_first"`; \
183 if test "$$first" != "."; then \
184 if test "$$first" = ".."; then \
185 dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
186 dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
187 else \
188 first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
189 if test "$$first2" = "$$first"; then \
190 dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
191 else \
192 dir2="../$$dir2"; \
193 fi; \
194 dir0="$$dir0"/"$$first"; \
195 fi; \
196 fi; \
197 dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
198 done; \
199 reldir="$$dir2"
200ACLOCAL = @ACLOCAL@
201ALLOCA = @ALLOCA@
202ALSA_CFLAGS = @ALSA_CFLAGS@
203ALSA_LIBS = @ALSA_LIBS@
204AMTAR = @AMTAR@
205AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
206AR = @AR@
207AS = @AS@
208AUTOCONF = @AUTOCONF@
209AUTOHEADER = @AUTOHEADER@
210AUTOMAKE = @AUTOMAKE@
211AWK = @AWK@
212CC = @CC@
213CCDEPMODE = @CCDEPMODE@
214CFLAGS = @CFLAGS@
215CHECK_CFLAGS = @CHECK_CFLAGS@
216CHECK_LIBS = @CHECK_LIBS@
217CPP = @CPP@
218CPPFLAGS = @CPPFLAGS@
219CYGPATH_W = @CYGPATH_W@
220DEFS = @DEFS@
221DEPDIR = @DEPDIR@
222DLLTOOL = @DLLTOOL@
223DSYMUTIL = @DSYMUTIL@
224DUMPBIN = @DUMPBIN@
225ECHO_C = @ECHO_C@
226ECHO_N = @ECHO_N@
227ECHO_T = @ECHO_T@
228ECORE_IMF_CFLAGS = @ECORE_IMF_CFLAGS@
229ECORE_IMF_LIBS = @ECORE_IMF_LIBS@
230EDJE_CC_CFLAGS = @EDJE_CC_CFLAGS@
231EDJE_CC_LIBS = @EDJE_CC_LIBS@
232EDJE_CC_PRG = @EDJE_CC_PRG@
233EDJE_CFLAGS = @EDJE_CFLAGS@
234EDJE_DECC_CFLAGS = @EDJE_DECC_CFLAGS@
235EDJE_DECC_LIBS = @EDJE_DECC_LIBS@
236EDJE_DECC_PRG = @EDJE_DECC_PRG@
237EDJE_EXTERNAL_INSPECTOR_CFLAGS = @EDJE_EXTERNAL_INSPECTOR_CFLAGS@
238EDJE_EXTERNAL_INSPECTOR_LIBS = @EDJE_EXTERNAL_INSPECTOR_LIBS@
239EDJE_EXTERNAL_INSPECTOR_PRG = @EDJE_EXTERNAL_INSPECTOR_PRG@
240EDJE_INSPECTOR_CFLAGS = @EDJE_INSPECTOR_CFLAGS@
241EDJE_INSPECTOR_LIBS = @EDJE_INSPECTOR_LIBS@
242EDJE_INSPECTOR_PRG = @EDJE_INSPECTOR_PRG@
243EDJE_LIBS = @EDJE_LIBS@
244EDJE_PLAYER_CFLAGS = @EDJE_PLAYER_CFLAGS@
245EDJE_PLAYER_LIBS = @EDJE_PLAYER_LIBS@
246EDJE_PLAYER_PRG = @EDJE_PLAYER_PRG@
247EDJE_RECC_PRG = @EDJE_RECC_PRG@
248EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
249EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
250EFL_EDJE_BUILD = @EFL_EDJE_BUILD@
251EGREP = @EGREP@
252EVIL_CFLAGS = @EVIL_CFLAGS@
253EVIL_LIBS = @EVIL_LIBS@
254EXEEXT = @EXEEXT@
255FGREP = @FGREP@
256FLAC_CFLAGS = @FLAC_CFLAGS@
257FLAC_LIBS = @FLAC_LIBS@
258GREP = @GREP@
259INSTALL = @INSTALL@
260INSTALL_DATA = @INSTALL_DATA@
261INSTALL_PROGRAM = @INSTALL_PROGRAM@
262INSTALL_SCRIPT = @INSTALL_SCRIPT@
263INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
264LD = @LD@
265LDFLAGS = @LDFLAGS@
266LIBOBJS = @LIBOBJS@
267LIBS = @LIBS@
268LIBTOOL = @LIBTOOL@
269LIPO = @LIPO@
270LN_S = @LN_S@
271LTLIBOBJS = @LTLIBOBJS@
272LUA_CFLAGS = @LUA_CFLAGS@
273LUA_LIBS = @LUA_LIBS@
274MAKEINFO = @MAKEINFO@
275MINIMAL_CFLAGS = @MINIMAL_CFLAGS@
276MINIMAL_LIBS = @MINIMAL_LIBS@
277MKDIR_P = @MKDIR_P@
278MODULE_ARCH = @MODULE_ARCH@
279NM = @NM@
280NMEDIT = @NMEDIT@
281OBJDUMP = @OBJDUMP@
282OBJEXT = @OBJEXT@
283OTOOL = @OTOOL@
284OTOOL64 = @OTOOL64@
285PACKAGE = @PACKAGE@
286PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
287PACKAGE_NAME = @PACKAGE_NAME@
288PACKAGE_STRING = @PACKAGE_STRING@
289PACKAGE_TARNAME = @PACKAGE_TARNAME@
290PACKAGE_URL = @PACKAGE_URL@
291PACKAGE_VERSION = @PACKAGE_VERSION@
292PATH_SEPARATOR = @PATH_SEPARATOR@
293PKG_CONFIG = @PKG_CONFIG@
294PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
295PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
296PYTHON = @PYTHON@
297PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
298PYTHON_PLATFORM = @PYTHON_PLATFORM@
299PYTHON_PREFIX = @PYTHON_PREFIX@
300PYTHON_VERSION = @PYTHON_VERSION@
301RANLIB = @RANLIB@
302REMIX_CFLAGS = @REMIX_CFLAGS@
303REMIX_LIBS = @REMIX_LIBS@
304REMIX_PLUGIN_DIR = @REMIX_PLUGIN_DIR@
305SED = @SED@
306SET_MAKE = @SET_MAKE@
307SHELL = @SHELL@
308SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
309SNDFILE_LIBS = @SNDFILE_LIBS@
310STRIP = @STRIP@
311VERSION = @VERSION@
312VMAJ = @VMAJ@
313VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
314VORBISENC_LIBS = @VORBISENC_LIBS@
315abs_builddir = @abs_builddir@
316abs_srcdir = @abs_srcdir@
317abs_top_builddir = @abs_top_builddir@
318abs_top_srcdir = @abs_top_srcdir@
319ac_ct_CC = @ac_ct_CC@
320ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
321am__include = @am__include@
322am__leading_dot = @am__leading_dot@
323am__quote = @am__quote@
324am__tar = @am__tar@
325am__untar = @am__untar@
326bindir = @bindir@
327build = @build@
328build_alias = @build_alias@
329build_cpu = @build_cpu@
330build_os = @build_os@
331build_vendor = @build_vendor@
332builddir = @builddir@
333datadir = @datadir@
334datarootdir = @datarootdir@
335docdir = @docdir@
336dvidir = @dvidir@
337edje_cc = @edje_cc@
338efl_doxygen = @efl_doxygen@
339efl_have_doxygen = @efl_have_doxygen@
340exec_prefix = @exec_prefix@
341have_lcov = @have_lcov@
342host = @host@
343host_alias = @host_alias@
344host_cpu = @host_cpu@
345host_os = @host_os@
346host_vendor = @host_vendor@
347htmldir = @htmldir@
348includedir = @includedir@
349infodir = @infodir@
350install_sh = @install_sh@
351libdir = @libdir@
352libexecdir = @libexecdir@
353localedir = @localedir@
354localstatedir = @localstatedir@
355lt_ECHO = @lt_ECHO@
356lt_enable_auto_import = @lt_enable_auto_import@
357lua_libs = @lua_libs@
358mandir = @mandir@
359mkdir_p = @mkdir_p@
360oldincludedir = @oldincludedir@
361pdfdir = @pdfdir@
362pkgconfig_requires_private = @pkgconfig_requires_private@
363pkgpyexecdir = @pkgpyexecdir@
364pkgpythondir = @pkgpythondir@
365prefix = @prefix@
366program_transform_name = @program_transform_name@
367psdir = @psdir@
368pyexecdir = @pyexecdir@
369pythondir = @pythondir@
370release_info = @release_info@
371requirement_edje = @requirement_edje@
372sbindir = @sbindir@
373sharedstatedir = @sharedstatedir@
374srcdir = @srcdir@
375sysconfdir = @sysconfdir@
376target_alias = @target_alias@
377top_build_prefix = @top_build_prefix@
378top_builddir = @top_builddir@
379top_srcdir = @top_srcdir@
380version_info = @version_info@
381vimdir = @vimdir@
382MAINTAINERCLEANFILES = Makefile.in
383@BUILD_EPP_TRUE@SUBDIRS = epp
384bin_SCRIPTS = @EDJE_RECC_PRG@
385bin_PROGRAMS = @EDJE_CC_PRG@ @EDJE_DECC_PRG@ @EDJE_PLAYER_PRG@ @EDJE_INSPECTOR_PRG@ @EDJE_EXTERNAL_INSPECTOR_PRG@
386edje_cc_SOURCES = \
387edje_cc.c \
388edje_cc_out.c \
389edje_cc_parse.c \
390edje_cc_mem.c \
391edje_cc_handlers.c \
392edje_cc_sources.c \
393edje_multisense_convert.c
394
395edje_cc_CPPFLAGS = \
396-I$(top_srcdir)/src/bin \
397-I$(top_srcdir)/src/lib \
398-DPACKAGE_BIN_DIR=\"$(bindir)\" \
399-DPACKAGE_LIB_DIR=\"$(libdir)\" \
400-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
401-DEPP_DIR=\"$(libdir)/$(PACKAGE)/utils\" \
402@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EVIL_CFLAGS@ @SNDFILE_CFLAGS@
403
404edje_cc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_CC_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ -lm
405edje_cc_LDFLAGS = @lt_enable_auto_import@
406edje_decc_SOURCES = \
407edje_decc.c \
408edje_decc.h \
409edje_cc_mem.c \
410edje_cc_sources.c
411
412edje_decc_CPPFLAGS = \
413-I$(top_srcdir)/src/bin \
414-I$(top_srcdir)/src/lib \
415@EDJE_CFLAGS@ @EDJE_DECC_CFLAGS@ @EVIL_CFLAGS@
416
417edje_decc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_DECC_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
418edje_decc_LDFLAGS = @lt_enable_auto_import@
419edje_player_SOURCES = edje_player.c
420edje_player_CPPFLAGS = \
421-I$(top_srcdir)/src/bin \
422-I$(top_srcdir)/src/lib \
423@EDJE_PLAYER_CFLAGS@ @EVIL_CFLAGS@
424
425edje_player_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_PLAYER_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
426edje_player_LDFLAGS = @lt_enable_auto_import@
427edje_inspector_SOURCES = edje_inspector.c
428edje_inspector_CPPFLAGS = \
429-I$(top_srcdir)/src/bin \
430-I$(top_srcdir)/src/lib \
431@EDJE_INSPECTOR_CFLAGS@
432
433edje_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@
434edje_inspector_LDFLAGS = @lt_enable_auto_import@
435edje_external_inspector_SOURCES = edje_external_inspector.c
436edje_external_inspector_CPPFLAGS = \
437-I$(top_srcdir)/src/bin \
438-I$(top_srcdir)/src/lib \
439@EDJE_EXTERNAL_INSPECTOR_CFLAGS@
440
441edje_external_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_EXTERNAL_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
442edje_external_inspector_LDFLAGS = @lt_enable_auto_import@
443EXTRA_DIST = @EDJE_RECC_PRG@ edje_cc.h edje_convert.h edje_convert.c edje_multisense_convert.h edje_data_convert.c
444EXTRA_SCRIPTS = edje_recc
445all: all-recursive
446
447.SUFFIXES:
448.SUFFIXES: .c .lo .o .obj
449$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
450 @for dep in $?; do \
451 case '$(am__configure_deps)' in \
452 *$$dep*) \
453 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
454 && { if test -f $@; then exit 0; else break; fi; }; \
455 exit 1;; \
456 esac; \
457 done; \
458 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/bin/Makefile'; \
459 $(am__cd) $(top_srcdir) && \
460 $(AUTOMAKE) --gnu src/bin/Makefile
461.PRECIOUS: Makefile
462Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
463 @case '$?' in \
464 *config.status*) \
465 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
466 *) \
467 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
468 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
469 esac;
470
471$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
472 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
473
474$(top_srcdir)/configure: $(am__configure_deps)
475 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
476$(ACLOCAL_M4): $(am__aclocal_m4_deps)
477 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
478$(am__aclocal_m4_deps):
479install-binPROGRAMS: $(bin_PROGRAMS)
480 @$(NORMAL_INSTALL)
481 test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
482 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
483 for p in $$list; do echo "$$p $$p"; done | \
484 sed 's/$(EXEEXT)$$//' | \
485 while read p p1; do if test -f $$p || test -f $$p1; \
486 then echo "$$p"; echo "$$p"; else :; fi; \
487 done | \
488 sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
489 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
490 sed 'N;N;N;s,\n, ,g' | \
491 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
492 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
493 if ($$2 == $$4) files[d] = files[d] " " $$1; \
494 else { print "f", $$3 "/" $$4, $$1; } } \
495 END { for (d in files) print "f", d, files[d] }' | \
496 while read type dir files; do \
497 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
498 test -z "$$files" || { \
499 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
500 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
501 } \
502 ; done
503
504uninstall-binPROGRAMS:
505 @$(NORMAL_UNINSTALL)
506 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
507 files=`for p in $$list; do echo "$$p"; done | \
508 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
509 -e 's/$$/$(EXEEXT)/' `; \
510 test -n "$$list" || exit 0; \
511 echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
512 cd "$(DESTDIR)$(bindir)" && rm -f $$files
513
514clean-binPROGRAMS:
515 @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
516 echo " rm -f" $$list; \
517 rm -f $$list || exit $$?; \
518 test -n "$(EXEEXT)" || exit 0; \
519 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
520 echo " rm -f" $$list; \
521 rm -f $$list
522edje_cc$(EXEEXT): $(edje_cc_OBJECTS) $(edje_cc_DEPENDENCIES)
523 @rm -f edje_cc$(EXEEXT)
524 $(AM_V_CCLD)$(edje_cc_LINK) $(edje_cc_OBJECTS) $(edje_cc_LDADD) $(LIBS)
525edje_decc$(EXEEXT): $(edje_decc_OBJECTS) $(edje_decc_DEPENDENCIES)
526 @rm -f edje_decc$(EXEEXT)
527 $(AM_V_CCLD)$(edje_decc_LINK) $(edje_decc_OBJECTS) $(edje_decc_LDADD) $(LIBS)
528edje_external_inspector$(EXEEXT): $(edje_external_inspector_OBJECTS) $(edje_external_inspector_DEPENDENCIES)
529 @rm -f edje_external_inspector$(EXEEXT)
530 $(AM_V_CCLD)$(edje_external_inspector_LINK) $(edje_external_inspector_OBJECTS) $(edje_external_inspector_LDADD) $(LIBS)
531edje_inspector$(EXEEXT): $(edje_inspector_OBJECTS) $(edje_inspector_DEPENDENCIES)
532 @rm -f edje_inspector$(EXEEXT)
533 $(AM_V_CCLD)$(edje_inspector_LINK) $(edje_inspector_OBJECTS) $(edje_inspector_LDADD) $(LIBS)
534edje_player$(EXEEXT): $(edje_player_OBJECTS) $(edje_player_DEPENDENCIES)
535 @rm -f edje_player$(EXEEXT)
536 $(AM_V_CCLD)$(edje_player_LINK) $(edje_player_OBJECTS) $(edje_player_LDADD) $(LIBS)
537install-binSCRIPTS: $(bin_SCRIPTS)
538 @$(NORMAL_INSTALL)
539 test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
540 @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
541 for p in $$list; do \
542 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
543 if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
544 done | \
545 sed -e 'p;s,.*/,,;n' \
546 -e 'h;s|.*|.|' \
547 -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
548 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
549 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
550 if ($$2 == $$4) { files[d] = files[d] " " $$1; \
551 if (++n[d] == $(am__install_max)) { \
552 print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
553 else { print "f", d "/" $$4, $$1 } } \
554 END { for (d in files) print "f", d, files[d] }' | \
555 while read type dir files; do \
556 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
557 test -z "$$files" || { \
558 echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
559 $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
560 } \
561 ; done
562
563uninstall-binSCRIPTS:
564 @$(NORMAL_UNINSTALL)
565 @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
566 files=`for p in $$list; do echo "$$p"; done | \
567 sed -e 's,.*/,,;$(transform)'`; \
568 test -n "$$list" || exit 0; \
569 echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
570 cd "$(DESTDIR)$(bindir)" && rm -f $$files
571
572mostlyclean-compile:
573 -rm -f *.$(OBJEXT)
574
575distclean-compile:
576 -rm -f *.tab.c
577
578@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc.Po@am__quote@
579@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_handlers.Po@am__quote@
580@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_mem.Po@am__quote@
581@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_out.Po@am__quote@
582@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_parse.Po@am__quote@
583@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_sources.Po@am__quote@
584@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_multisense_convert.Po@am__quote@
585@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_decc-edje_cc_mem.Po@am__quote@
586@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_decc-edje_cc_sources.Po@am__quote@
587@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_decc-edje_decc.Po@am__quote@
588@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_external_inspector-edje_external_inspector.Po@am__quote@
589@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_inspector-edje_inspector.Po@am__quote@
590@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_player-edje_player.Po@am__quote@
591
592.c.o:
593@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
594@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
595@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
596@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
597@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
598@am__fastdepCC_FALSE@ $(COMPILE) -c $<
599
600.c.obj:
601@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
602@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
603@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
604@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
605@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
606@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
607
608.c.lo:
609@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
610@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
611@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
612@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
613@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
614@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
615
616edje_cc-edje_cc.o: edje_cc.c
617@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc.o -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc.Tpo -c -o edje_cc-edje_cc.o `test -f 'edje_cc.c' || echo '$(srcdir)/'`edje_cc.c
618@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc.Tpo $(DEPDIR)/edje_cc-edje_cc.Po
619@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
620@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc.c' object='edje_cc-edje_cc.o' libtool=no @AMDEPBACKSLASH@
621@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
622@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc.o `test -f 'edje_cc.c' || echo '$(srcdir)/'`edje_cc.c
623
624edje_cc-edje_cc.obj: edje_cc.c
625@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc.obj -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc.Tpo -c -o edje_cc-edje_cc.obj `if test -f 'edje_cc.c'; then $(CYGPATH_W) 'edje_cc.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc.c'; fi`
626@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc.Tpo $(DEPDIR)/edje_cc-edje_cc.Po
627@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
628@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc.c' object='edje_cc-edje_cc.obj' libtool=no @AMDEPBACKSLASH@
629@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
630@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc.obj `if test -f 'edje_cc.c'; then $(CYGPATH_W) 'edje_cc.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc.c'; fi`
631
632edje_cc-edje_cc_out.o: edje_cc_out.c
633@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_out.o -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_out.Tpo -c -o edje_cc-edje_cc_out.o `test -f 'edje_cc_out.c' || echo '$(srcdir)/'`edje_cc_out.c
634@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_out.Tpo $(DEPDIR)/edje_cc-edje_cc_out.Po
635@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
636@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_out.c' object='edje_cc-edje_cc_out.o' libtool=no @AMDEPBACKSLASH@
637@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
638@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_out.o `test -f 'edje_cc_out.c' || echo '$(srcdir)/'`edje_cc_out.c
639
640edje_cc-edje_cc_out.obj: edje_cc_out.c
641@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_out.obj -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_out.Tpo -c -o edje_cc-edje_cc_out.obj `if test -f 'edje_cc_out.c'; then $(CYGPATH_W) 'edje_cc_out.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_out.c'; fi`
642@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_out.Tpo $(DEPDIR)/edje_cc-edje_cc_out.Po
643@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
644@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_out.c' object='edje_cc-edje_cc_out.obj' libtool=no @AMDEPBACKSLASH@
645@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
646@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_out.obj `if test -f 'edje_cc_out.c'; then $(CYGPATH_W) 'edje_cc_out.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_out.c'; fi`
647
648edje_cc-edje_cc_parse.o: edje_cc_parse.c
649@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_parse.o -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_parse.Tpo -c -o edje_cc-edje_cc_parse.o `test -f 'edje_cc_parse.c' || echo '$(srcdir)/'`edje_cc_parse.c
650@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_parse.Tpo $(DEPDIR)/edje_cc-edje_cc_parse.Po
651@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
652@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_parse.c' object='edje_cc-edje_cc_parse.o' libtool=no @AMDEPBACKSLASH@
653@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
654@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_parse.o `test -f 'edje_cc_parse.c' || echo '$(srcdir)/'`edje_cc_parse.c
655
656edje_cc-edje_cc_parse.obj: edje_cc_parse.c
657@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_parse.obj -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_parse.Tpo -c -o edje_cc-edje_cc_parse.obj `if test -f 'edje_cc_parse.c'; then $(CYGPATH_W) 'edje_cc_parse.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_parse.c'; fi`
658@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_parse.Tpo $(DEPDIR)/edje_cc-edje_cc_parse.Po
659@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
660@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_parse.c' object='edje_cc-edje_cc_parse.obj' libtool=no @AMDEPBACKSLASH@
661@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
662@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_parse.obj `if test -f 'edje_cc_parse.c'; then $(CYGPATH_W) 'edje_cc_parse.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_parse.c'; fi`
663
664edje_cc-edje_cc_mem.o: edje_cc_mem.c
665@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_mem.o -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_mem.Tpo -c -o edje_cc-edje_cc_mem.o `test -f 'edje_cc_mem.c' || echo '$(srcdir)/'`edje_cc_mem.c
666@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_mem.Tpo $(DEPDIR)/edje_cc-edje_cc_mem.Po
667@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
668@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_mem.c' object='edje_cc-edje_cc_mem.o' libtool=no @AMDEPBACKSLASH@
669@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
670@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_mem.o `test -f 'edje_cc_mem.c' || echo '$(srcdir)/'`edje_cc_mem.c
671
672edje_cc-edje_cc_mem.obj: edje_cc_mem.c
673@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_mem.obj -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_mem.Tpo -c -o edje_cc-edje_cc_mem.obj `if test -f 'edje_cc_mem.c'; then $(CYGPATH_W) 'edje_cc_mem.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_mem.c'; fi`
674@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_mem.Tpo $(DEPDIR)/edje_cc-edje_cc_mem.Po
675@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
676@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_mem.c' object='edje_cc-edje_cc_mem.obj' libtool=no @AMDEPBACKSLASH@
677@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
678@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_mem.obj `if test -f 'edje_cc_mem.c'; then $(CYGPATH_W) 'edje_cc_mem.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_mem.c'; fi`
679
680edje_cc-edje_cc_handlers.o: edje_cc_handlers.c
681@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_handlers.o -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_handlers.Tpo -c -o edje_cc-edje_cc_handlers.o `test -f 'edje_cc_handlers.c' || echo '$(srcdir)/'`edje_cc_handlers.c
682@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_handlers.Tpo $(DEPDIR)/edje_cc-edje_cc_handlers.Po
683@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
684@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_handlers.c' object='edje_cc-edje_cc_handlers.o' libtool=no @AMDEPBACKSLASH@
685@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
686@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_handlers.o `test -f 'edje_cc_handlers.c' || echo '$(srcdir)/'`edje_cc_handlers.c
687
688edje_cc-edje_cc_handlers.obj: edje_cc_handlers.c
689@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_handlers.obj -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_handlers.Tpo -c -o edje_cc-edje_cc_handlers.obj `if test -f 'edje_cc_handlers.c'; then $(CYGPATH_W) 'edje_cc_handlers.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_handlers.c'; fi`
690@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_handlers.Tpo $(DEPDIR)/edje_cc-edje_cc_handlers.Po
691@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
692@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_handlers.c' object='edje_cc-edje_cc_handlers.obj' libtool=no @AMDEPBACKSLASH@
693@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
694@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_handlers.obj `if test -f 'edje_cc_handlers.c'; then $(CYGPATH_W) 'edje_cc_handlers.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_handlers.c'; fi`
695
696edje_cc-edje_cc_sources.o: edje_cc_sources.c
697@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_sources.o -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_sources.Tpo -c -o edje_cc-edje_cc_sources.o `test -f 'edje_cc_sources.c' || echo '$(srcdir)/'`edje_cc_sources.c
698@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_sources.Tpo $(DEPDIR)/edje_cc-edje_cc_sources.Po
699@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
700@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_sources.c' object='edje_cc-edje_cc_sources.o' libtool=no @AMDEPBACKSLASH@
701@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
702@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_sources.o `test -f 'edje_cc_sources.c' || echo '$(srcdir)/'`edje_cc_sources.c
703
704edje_cc-edje_cc_sources.obj: edje_cc_sources.c
705@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_cc_sources.obj -MD -MP -MF $(DEPDIR)/edje_cc-edje_cc_sources.Tpo -c -o edje_cc-edje_cc_sources.obj `if test -f 'edje_cc_sources.c'; then $(CYGPATH_W) 'edje_cc_sources.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_sources.c'; fi`
706@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_sources.Tpo $(DEPDIR)/edje_cc-edje_cc_sources.Po
707@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
708@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_sources.c' object='edje_cc-edje_cc_sources.obj' libtool=no @AMDEPBACKSLASH@
709@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
710@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_cc_sources.obj `if test -f 'edje_cc_sources.c'; then $(CYGPATH_W) 'edje_cc_sources.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_sources.c'; fi`
711
712edje_cc-edje_multisense_convert.o: edje_multisense_convert.c
713@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_multisense_convert.o -MD -MP -MF $(DEPDIR)/edje_cc-edje_multisense_convert.Tpo -c -o edje_cc-edje_multisense_convert.o `test -f 'edje_multisense_convert.c' || echo '$(srcdir)/'`edje_multisense_convert.c
714@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_multisense_convert.Tpo $(DEPDIR)/edje_cc-edje_multisense_convert.Po
715@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
716@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_multisense_convert.c' object='edje_cc-edje_multisense_convert.o' libtool=no @AMDEPBACKSLASH@
717@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
718@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_multisense_convert.o `test -f 'edje_multisense_convert.c' || echo '$(srcdir)/'`edje_multisense_convert.c
719
720edje_cc-edje_multisense_convert.obj: edje_multisense_convert.c
721@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_cc-edje_multisense_convert.obj -MD -MP -MF $(DEPDIR)/edje_cc-edje_multisense_convert.Tpo -c -o edje_cc-edje_multisense_convert.obj `if test -f 'edje_multisense_convert.c'; then $(CYGPATH_W) 'edje_multisense_convert.c'; else $(CYGPATH_W) '$(srcdir)/edje_multisense_convert.c'; fi`
722@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_multisense_convert.Tpo $(DEPDIR)/edje_cc-edje_multisense_convert.Po
723@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
724@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_multisense_convert.c' object='edje_cc-edje_multisense_convert.obj' libtool=no @AMDEPBACKSLASH@
725@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
726@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_cc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_cc-edje_multisense_convert.obj `if test -f 'edje_multisense_convert.c'; then $(CYGPATH_W) 'edje_multisense_convert.c'; else $(CYGPATH_W) '$(srcdir)/edje_multisense_convert.c'; fi`
727
728edje_decc-edje_decc.o: edje_decc.c
729@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_decc-edje_decc.o -MD -MP -MF $(DEPDIR)/edje_decc-edje_decc.Tpo -c -o edje_decc-edje_decc.o `test -f 'edje_decc.c' || echo '$(srcdir)/'`edje_decc.c
730@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_decc.Tpo $(DEPDIR)/edje_decc-edje_decc.Po
731@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
732@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_decc.c' object='edje_decc-edje_decc.o' libtool=no @AMDEPBACKSLASH@
733@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
734@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_decc-edje_decc.o `test -f 'edje_decc.c' || echo '$(srcdir)/'`edje_decc.c
735
736edje_decc-edje_decc.obj: edje_decc.c
737@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_decc-edje_decc.obj -MD -MP -MF $(DEPDIR)/edje_decc-edje_decc.Tpo -c -o edje_decc-edje_decc.obj `if test -f 'edje_decc.c'; then $(CYGPATH_W) 'edje_decc.c'; else $(CYGPATH_W) '$(srcdir)/edje_decc.c'; fi`
738@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_decc.Tpo $(DEPDIR)/edje_decc-edje_decc.Po
739@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
740@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_decc.c' object='edje_decc-edje_decc.obj' libtool=no @AMDEPBACKSLASH@
741@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
742@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_decc-edje_decc.obj `if test -f 'edje_decc.c'; then $(CYGPATH_W) 'edje_decc.c'; else $(CYGPATH_W) '$(srcdir)/edje_decc.c'; fi`
743
744edje_decc-edje_cc_mem.o: edje_cc_mem.c
745@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_decc-edje_cc_mem.o -MD -MP -MF $(DEPDIR)/edje_decc-edje_cc_mem.Tpo -c -o edje_decc-edje_cc_mem.o `test -f 'edje_cc_mem.c' || echo '$(srcdir)/'`edje_cc_mem.c
746@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_cc_mem.Tpo $(DEPDIR)/edje_decc-edje_cc_mem.Po
747@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
748@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_mem.c' object='edje_decc-edje_cc_mem.o' libtool=no @AMDEPBACKSLASH@
749@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
750@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_decc-edje_cc_mem.o `test -f 'edje_cc_mem.c' || echo '$(srcdir)/'`edje_cc_mem.c
751
752edje_decc-edje_cc_mem.obj: edje_cc_mem.c
753@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_decc-edje_cc_mem.obj -MD -MP -MF $(DEPDIR)/edje_decc-edje_cc_mem.Tpo -c -o edje_decc-edje_cc_mem.obj `if test -f 'edje_cc_mem.c'; then $(CYGPATH_W) 'edje_cc_mem.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_mem.c'; fi`
754@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_cc_mem.Tpo $(DEPDIR)/edje_decc-edje_cc_mem.Po
755@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
756@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_mem.c' object='edje_decc-edje_cc_mem.obj' libtool=no @AMDEPBACKSLASH@
757@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
758@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_decc-edje_cc_mem.obj `if test -f 'edje_cc_mem.c'; then $(CYGPATH_W) 'edje_cc_mem.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_mem.c'; fi`
759
760edje_decc-edje_cc_sources.o: edje_cc_sources.c
761@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_decc-edje_cc_sources.o -MD -MP -MF $(DEPDIR)/edje_decc-edje_cc_sources.Tpo -c -o edje_decc-edje_cc_sources.o `test -f 'edje_cc_sources.c' || echo '$(srcdir)/'`edje_cc_sources.c
762@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_cc_sources.Tpo $(DEPDIR)/edje_decc-edje_cc_sources.Po
763@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
764@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_sources.c' object='edje_decc-edje_cc_sources.o' libtool=no @AMDEPBACKSLASH@
765@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
766@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_decc-edje_cc_sources.o `test -f 'edje_cc_sources.c' || echo '$(srcdir)/'`edje_cc_sources.c
767
768edje_decc-edje_cc_sources.obj: edje_cc_sources.c
769@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_decc-edje_cc_sources.obj -MD -MP -MF $(DEPDIR)/edje_decc-edje_cc_sources.Tpo -c -o edje_decc-edje_cc_sources.obj `if test -f 'edje_cc_sources.c'; then $(CYGPATH_W) 'edje_cc_sources.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_sources.c'; fi`
770@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_cc_sources.Tpo $(DEPDIR)/edje_decc-edje_cc_sources.Po
771@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
772@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_sources.c' object='edje_decc-edje_cc_sources.obj' libtool=no @AMDEPBACKSLASH@
773@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
774@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_decc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_decc-edje_cc_sources.obj `if test -f 'edje_cc_sources.c'; then $(CYGPATH_W) 'edje_cc_sources.c'; else $(CYGPATH_W) '$(srcdir)/edje_cc_sources.c'; fi`
775
776edje_external_inspector-edje_external_inspector.o: edje_external_inspector.c
777@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_external_inspector_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_external_inspector-edje_external_inspector.o -MD -MP -MF $(DEPDIR)/edje_external_inspector-edje_external_inspector.Tpo -c -o edje_external_inspector-edje_external_inspector.o `test -f 'edje_external_inspector.c' || echo '$(srcdir)/'`edje_external_inspector.c
778@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_external_inspector-edje_external_inspector.Tpo $(DEPDIR)/edje_external_inspector-edje_external_inspector.Po
779@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
780@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_external_inspector.c' object='edje_external_inspector-edje_external_inspector.o' libtool=no @AMDEPBACKSLASH@
781@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
782@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_external_inspector_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_external_inspector-edje_external_inspector.o `test -f 'edje_external_inspector.c' || echo '$(srcdir)/'`edje_external_inspector.c
783
784edje_external_inspector-edje_external_inspector.obj: edje_external_inspector.c
785@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_external_inspector_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_external_inspector-edje_external_inspector.obj -MD -MP -MF $(DEPDIR)/edje_external_inspector-edje_external_inspector.Tpo -c -o edje_external_inspector-edje_external_inspector.obj `if test -f 'edje_external_inspector.c'; then $(CYGPATH_W) 'edje_external_inspector.c'; else $(CYGPATH_W) '$(srcdir)/edje_external_inspector.c'; fi`
786@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_external_inspector-edje_external_inspector.Tpo $(DEPDIR)/edje_external_inspector-edje_external_inspector.Po
787@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
788@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_external_inspector.c' object='edje_external_inspector-edje_external_inspector.obj' libtool=no @AMDEPBACKSLASH@
789@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
790@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_external_inspector_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_external_inspector-edje_external_inspector.obj `if test -f 'edje_external_inspector.c'; then $(CYGPATH_W) 'edje_external_inspector.c'; else $(CYGPATH_W) '$(srcdir)/edje_external_inspector.c'; fi`
791
792edje_inspector-edje_inspector.o: edje_inspector.c
793@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_inspector_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_inspector-edje_inspector.o -MD -MP -MF $(DEPDIR)/edje_inspector-edje_inspector.Tpo -c -o edje_inspector-edje_inspector.o `test -f 'edje_inspector.c' || echo '$(srcdir)/'`edje_inspector.c
794@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_inspector-edje_inspector.Tpo $(DEPDIR)/edje_inspector-edje_inspector.Po
795@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
796@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_inspector.c' object='edje_inspector-edje_inspector.o' libtool=no @AMDEPBACKSLASH@
797@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
798@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_inspector_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_inspector-edje_inspector.o `test -f 'edje_inspector.c' || echo '$(srcdir)/'`edje_inspector.c
799
800edje_inspector-edje_inspector.obj: edje_inspector.c
801@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_inspector_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_inspector-edje_inspector.obj -MD -MP -MF $(DEPDIR)/edje_inspector-edje_inspector.Tpo -c -o edje_inspector-edje_inspector.obj `if test -f 'edje_inspector.c'; then $(CYGPATH_W) 'edje_inspector.c'; else $(CYGPATH_W) '$(srcdir)/edje_inspector.c'; fi`
802@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_inspector-edje_inspector.Tpo $(DEPDIR)/edje_inspector-edje_inspector.Po
803@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
804@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_inspector.c' object='edje_inspector-edje_inspector.obj' libtool=no @AMDEPBACKSLASH@
805@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
806@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_inspector_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_inspector-edje_inspector.obj `if test -f 'edje_inspector.c'; then $(CYGPATH_W) 'edje_inspector.c'; else $(CYGPATH_W) '$(srcdir)/edje_inspector.c'; fi`
807
808edje_player-edje_player.o: edje_player.c
809@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_player_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_player-edje_player.o -MD -MP -MF $(DEPDIR)/edje_player-edje_player.Tpo -c -o edje_player-edje_player.o `test -f 'edje_player.c' || echo '$(srcdir)/'`edje_player.c
810@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_player-edje_player.Tpo $(DEPDIR)/edje_player-edje_player.Po
811@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
812@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_player.c' object='edje_player-edje_player.o' libtool=no @AMDEPBACKSLASH@
813@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
814@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_player_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_player-edje_player.o `test -f 'edje_player.c' || echo '$(srcdir)/'`edje_player.c
815
816edje_player-edje_player.obj: edje_player.c
817@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_player_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT edje_player-edje_player.obj -MD -MP -MF $(DEPDIR)/edje_player-edje_player.Tpo -c -o edje_player-edje_player.obj `if test -f 'edje_player.c'; then $(CYGPATH_W) 'edje_player.c'; else $(CYGPATH_W) '$(srcdir)/edje_player.c'; fi`
818@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_player-edje_player.Tpo $(DEPDIR)/edje_player-edje_player.Po
819@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
820@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_player.c' object='edje_player-edje_player.obj' libtool=no @AMDEPBACKSLASH@
821@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
822@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(edje_player_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o edje_player-edje_player.obj `if test -f 'edje_player.c'; then $(CYGPATH_W) 'edje_player.c'; else $(CYGPATH_W) '$(srcdir)/edje_player.c'; fi`
823
824mostlyclean-libtool:
825 -rm -f *.lo
826
827clean-libtool:
828 -rm -rf .libs _libs
829
830# This directory's subdirectories are mostly independent; you can cd
831# into them and run `make' without going through this Makefile.
832# To change the values of `make' variables: instead of editing Makefiles,
833# (1) if the variable is set in `config.status', edit `config.status'
834# (which will cause the Makefiles to be regenerated when you run `make');
835# (2) otherwise, pass the desired values on the `make' command line.
836$(RECURSIVE_TARGETS):
837 @fail= failcom='exit 1'; \
838 for f in x $$MAKEFLAGS; do \
839 case $$f in \
840 *=* | --[!k]*);; \
841 *k*) failcom='fail=yes';; \
842 esac; \
843 done; \
844 dot_seen=no; \
845 target=`echo $@ | sed s/-recursive//`; \
846 list='$(SUBDIRS)'; for subdir in $$list; do \
847 echo "Making $$target in $$subdir"; \
848 if test "$$subdir" = "."; then \
849 dot_seen=yes; \
850 local_target="$$target-am"; \
851 else \
852 local_target="$$target"; \
853 fi; \
854 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
855 || eval $$failcom; \
856 done; \
857 if test "$$dot_seen" = "no"; then \
858 $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
859 fi; test -z "$$fail"
860
861$(RECURSIVE_CLEAN_TARGETS):
862 @fail= failcom='exit 1'; \
863 for f in x $$MAKEFLAGS; do \
864 case $$f in \
865 *=* | --[!k]*);; \
866 *k*) failcom='fail=yes';; \
867 esac; \
868 done; \
869 dot_seen=no; \
870 case "$@" in \
871 distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
872 *) list='$(SUBDIRS)' ;; \
873 esac; \
874 rev=''; for subdir in $$list; do \
875 if test "$$subdir" = "."; then :; else \
876 rev="$$subdir $$rev"; \
877 fi; \
878 done; \
879 rev="$$rev ."; \
880 target=`echo $@ | sed s/-recursive//`; \
881 for subdir in $$rev; do \
882 echo "Making $$target in $$subdir"; \
883 if test "$$subdir" = "."; then \
884 local_target="$$target-am"; \
885 else \
886 local_target="$$target"; \
887 fi; \
888 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
889 || eval $$failcom; \
890 done && test -z "$$fail"
891tags-recursive:
892 list='$(SUBDIRS)'; for subdir in $$list; do \
893 test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
894 done
895ctags-recursive:
896 list='$(SUBDIRS)'; for subdir in $$list; do \
897 test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
898 done
899
900ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
901 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
902 unique=`for i in $$list; do \
903 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
904 done | \
905 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
906 END { if (nonempty) { for (i in files) print i; }; }'`; \
907 mkid -fID $$unique
908tags: TAGS
909
910TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
911 $(TAGS_FILES) $(LISP)
912 set x; \
913 here=`pwd`; \
914 if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
915 include_option=--etags-include; \
916 empty_fix=.; \
917 else \
918 include_option=--include; \
919 empty_fix=; \
920 fi; \
921 list='$(SUBDIRS)'; for subdir in $$list; do \
922 if test "$$subdir" = .; then :; else \
923 test ! -f $$subdir/TAGS || \
924 set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
925 fi; \
926 done; \
927 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
928 unique=`for i in $$list; do \
929 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
930 done | \
931 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
932 END { if (nonempty) { for (i in files) print i; }; }'`; \
933 shift; \
934 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
935 test -n "$$unique" || unique=$$empty_fix; \
936 if test $$# -gt 0; then \
937 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
938 "$$@" $$unique; \
939 else \
940 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
941 $$unique; \
942 fi; \
943 fi
944ctags: CTAGS
945CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
946 $(TAGS_FILES) $(LISP)
947 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
948 unique=`for i in $$list; do \
949 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
950 done | \
951 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
952 END { if (nonempty) { for (i in files) print i; }; }'`; \
953 test -z "$(CTAGS_ARGS)$$unique" \
954 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
955 $$unique
956
957GTAGS:
958 here=`$(am__cd) $(top_builddir) && pwd` \
959 && $(am__cd) $(top_srcdir) \
960 && gtags -i $(GTAGS_ARGS) "$$here"
961
962distclean-tags:
963 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
964
965distdir: $(DISTFILES)
966 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
967 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
968 list='$(DISTFILES)'; \
969 dist_files=`for file in $$list; do echo $$file; done | \
970 sed -e "s|^$$srcdirstrip/||;t" \
971 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
972 case $$dist_files in \
973 */*) $(MKDIR_P) `echo "$$dist_files" | \
974 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
975 sort -u` ;; \
976 esac; \
977 for file in $$dist_files; do \
978 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
979 if test -d $$d/$$file; then \
980 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
981 if test -d "$(distdir)/$$file"; then \
982 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
983 fi; \
984 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
985 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
986 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
987 fi; \
988 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
989 else \
990 test -f "$(distdir)/$$file" \
991 || cp -p $$d/$$file "$(distdir)/$$file" \
992 || exit 1; \
993 fi; \
994 done
995 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
996 if test "$$subdir" = .; then :; else \
997 test -d "$(distdir)/$$subdir" \
998 || $(MKDIR_P) "$(distdir)/$$subdir" \
999 || exit 1; \
1000 fi; \
1001 done
1002 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
1003 if test "$$subdir" = .; then :; else \
1004 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
1005 $(am__relativize); \
1006 new_distdir=$$reldir; \
1007 dir1=$$subdir; dir2="$(top_distdir)"; \
1008 $(am__relativize); \
1009 new_top_distdir=$$reldir; \
1010 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
1011 echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
1012 ($(am__cd) $$subdir && \
1013 $(MAKE) $(AM_MAKEFLAGS) \
1014 top_distdir="$$new_top_distdir" \
1015 distdir="$$new_distdir" \
1016 am__remove_distdir=: \
1017 am__skip_length_check=: \
1018 am__skip_mode_fix=: \
1019 distdir) \
1020 || exit 1; \
1021 fi; \
1022 done
1023check-am: all-am
1024check: check-recursive
1025all-am: Makefile $(PROGRAMS) $(SCRIPTS)
1026installdirs: installdirs-recursive
1027installdirs-am:
1028 for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
1029 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
1030 done
1031install: install-recursive
1032install-exec: install-exec-recursive
1033install-data: install-data-recursive
1034uninstall: uninstall-recursive
1035
1036install-am: all-am
1037 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
1038
1039installcheck: installcheck-recursive
1040install-strip:
1041 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
1042 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
1043 `test -z '$(STRIP)' || \
1044 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
1045mostlyclean-generic:
1046
1047clean-generic:
1048
1049distclean-generic:
1050 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
1051 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
1052
1053maintainer-clean-generic:
1054 @echo "This command is intended for maintainers to use"
1055 @echo "it deletes files that may require special tools to rebuild."
1056 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
1057clean: clean-recursive
1058
1059clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
1060
1061distclean: distclean-recursive
1062 -rm -rf ./$(DEPDIR)
1063 -rm -f Makefile
1064distclean-am: clean-am distclean-compile distclean-generic \
1065 distclean-tags
1066
1067dvi: dvi-recursive
1068
1069dvi-am:
1070
1071html: html-recursive
1072
1073html-am:
1074
1075info: info-recursive
1076
1077info-am:
1078
1079install-data-am:
1080
1081install-dvi: install-dvi-recursive
1082
1083install-dvi-am:
1084
1085install-exec-am: install-binPROGRAMS install-binSCRIPTS
1086
1087install-html: install-html-recursive
1088
1089install-html-am:
1090
1091install-info: install-info-recursive
1092
1093install-info-am:
1094
1095install-man:
1096
1097install-pdf: install-pdf-recursive
1098
1099install-pdf-am:
1100
1101install-ps: install-ps-recursive
1102
1103install-ps-am:
1104
1105installcheck-am:
1106
1107maintainer-clean: maintainer-clean-recursive
1108 -rm -rf ./$(DEPDIR)
1109 -rm -f Makefile
1110maintainer-clean-am: distclean-am maintainer-clean-generic
1111
1112mostlyclean: mostlyclean-recursive
1113
1114mostlyclean-am: mostlyclean-compile mostlyclean-generic \
1115 mostlyclean-libtool
1116
1117pdf: pdf-recursive
1118
1119pdf-am:
1120
1121ps: ps-recursive
1122
1123ps-am:
1124
1125uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS
1126
1127.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
1128 install-am install-strip tags-recursive
1129
1130.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
1131 all all-am check check-am clean clean-binPROGRAMS \
1132 clean-generic clean-libtool ctags ctags-recursive distclean \
1133 distclean-compile distclean-generic distclean-libtool \
1134 distclean-tags distdir dvi dvi-am html html-am info info-am \
1135 install install-am install-binPROGRAMS install-binSCRIPTS \
1136 install-data install-data-am install-dvi install-dvi-am \
1137 install-exec install-exec-am install-html install-html-am \
1138 install-info install-info-am install-man install-pdf \
1139 install-pdf-am install-ps install-ps-am install-strip \
1140 installcheck installcheck-am installdirs installdirs-am \
1141 maintainer-clean maintainer-clean-generic mostlyclean \
1142 mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
1143 pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
1144 uninstall-binPROGRAMS uninstall-binSCRIPTS
1145
1146
1147# Tell versions [3.59,3.63) of GNU make to not export all variables.
1148# Otherwise a system limit (for SysV at least) may be exceeded.
1149.NOEXPORT:
diff --git a/libraries/edje/src/bin/edje_cc.c b/libraries/edje/src/bin/edje_cc.c
new file mode 100644
index 0000000..adcbbb6
--- /dev/null
+++ b/libraries/edje/src/bin/edje_cc.c
@@ -0,0 +1,250 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <string.h>
6#include <locale.h>
7#include <limits.h>
8#include <sys/stat.h>
9
10#include "edje_cc.h"
11int _edje_cc_log_dom = -1;
12static void main_help(void);
13
14Eina_Prefix *pfx = NULL;
15Eina_List *snd_dirs = NULL;
16Eina_List *img_dirs = NULL;
17Eina_List *fnt_dirs = NULL;
18Eina_List *defines = NULL;
19char *file_in = NULL;
20char *tmp_dir = NULL;
21char *file_out = NULL;
22char *progname = NULL;
23int verbose = 0;
24
25int no_lossy = 0;
26int no_comp = 0;
27int no_raw = 0;
28int no_save = 0;
29int min_quality = 0;
30int max_quality = 100;
31
32static void
33main_help(void)
34{
35 printf
36 ("Usage:\n"
37 "\t%s [OPTIONS] input_file.edc [output_file.edj]\n"
38 "\n"
39 "Where OPTIONS is one or more of:\n"
40 "\n"
41 "-id image/directory Add a directory to look in for relative path images\n"
42 "-fd font/directory Add a directory to look in for relative path fonts\n"
43 "-sd sound/directory Add a directory to look in for relative path sounds samples\n"
44 "-td temp/directory Directory to store temporary files\n"
45 "-v Verbose output\n"
46 "-no-lossy Do NOT allow images to be lossy\n"
47 "-no-comp Do NOT allow images to be stored with lossless compression\n"
48 "-no-raw Do NOT allow images to be stored with zero compression (raw)\n"
49 "-no-save Do NOT store the input EDC file in the EDJ file\n"
50 "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n"
51 "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n"
52 "-Ddefine_val=to CPP style define to define input macro definitions to the .edc source\n"
53 ,progname);
54}
55
56int
57main(int argc, char **argv)
58{
59 int i;
60 struct stat st;
61 char rpath[PATH_MAX], rpath2[PATH_MAX];
62
63 setlocale(LC_NUMERIC, "C");
64
65 if (!eina_init())
66 return -1;
67
68 _edje_cc_log_dom = eina_log_domain_register
69 ("edje_cc", EDJE_CC_DEFAULT_LOG_COLOR);
70 if (_edje_cc_log_dom < 0)
71 {
72 EINA_LOG_ERR("Enable to create a log domain.");
73 exit(-1);
74 }
75 tmp_dir = getenv("TMPDIR");
76
77 img_dirs = eina_list_append(img_dirs, ".");
78
79 progname = argv[0];
80 for (i = 1; i < argc; i++)
81 {
82 if (!strcmp(argv[i], "-h"))
83 {
84 main_help();
85 exit(0);
86 }
87 else if (!strcmp(argv[i], "-v"))
88 {
89 verbose = 1;
90 }
91 else if (!strcmp(argv[i], "-no-lossy"))
92 {
93 no_lossy = 1;
94 }
95 else if (!strcmp(argv[i], "-no-comp"))
96 {
97 no_comp = 1;
98 }
99 else if (!strcmp(argv[i], "-no-raw"))
100 {
101 no_raw = 1;
102 }
103 else if (!strcmp(argv[i], "-no-save"))
104 {
105 no_save = 1;
106 }
107 else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1)))
108 {
109 i++;
110 img_dirs = eina_list_append(img_dirs, argv[i]);
111 }
112 else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1)))
113 {
114 i++;
115 fnt_dirs = eina_list_append(fnt_dirs, argv[i]);
116 }
117 else if ((!strcmp(argv[i], "-sd") || !strcmp(argv[i], "--sound_dir")) && (i < (argc - 1)))
118 {
119 i++;
120 snd_dirs = eina_list_append(snd_dirs, argv[i]);
121 }
122 else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1)))
123 {
124 i++;
125 if (!tmp_dir)
126 tmp_dir = argv[i];
127 }
128 else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
129 {
130 i++;
131 min_quality = atoi(argv[i]);
132 if (min_quality < 0) min_quality = 0;
133 if (min_quality > 100) min_quality = 100;
134 }
135 else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1)))
136 {
137 i++;
138 max_quality = atoi(argv[i]);
139 if (max_quality < 0) max_quality = 0;
140 if (max_quality > 100) max_quality = 100;
141 }
142 else if (!strncmp(argv[i], "-D", 2))
143 {
144 defines = eina_list_append(defines, mem_strdup(argv[i]));
145 }
146 else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1)))
147 {
148 i++;
149 file_out = argv[i];
150 }
151 else if (!file_in)
152 file_in = argv[i];
153 else if (!file_out)
154 file_out = argv[i];
155 }
156 if (!file_in)
157 {
158 fprintf(stderr, "%s: Error: no input file specified.\n", progname);
159 main_help();
160 exit(-1);
161 }
162
163 pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */
164 main, /* an optional symbol to check path of */
165 "EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */
166 "edje", /* dir to add after "share" (PREFIX/share/DIRNAME) */
167 "include/edje.inc", /* a magic file to check for in PREFIX/share/DIRNAME for success */
168 PACKAGE_BIN_DIR, /* package bin dir @ compile time */
169 PACKAGE_LIB_DIR, /* package lib dir @ compile time */
170 PACKAGE_DATA_DIR, /* package data dir @ compile time */
171 PACKAGE_DATA_DIR /* if locale needed use LOCALE_DIR */
172 );
173
174 /* check whether file_in exists */
175#ifdef HAVE_REALPATH
176 if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
177#else
178 if (stat(file_in, &st) || !S_ISREG(st.st_mode))
179#endif
180 {
181 fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in);
182 main_help();
183 exit(-1);
184 }
185
186 if (!file_out)
187 {
188 char *suffix;
189
190 if ((suffix = strstr(file_in,".edc")) && (suffix[4] == 0))
191 {
192 file_out = strdup(file_in);
193 if (file_out)
194 {
195 suffix = strstr(file_out,".edc");
196 strcpy(suffix,".edj");
197 }
198 }
199 }
200 if (!file_out)
201 {
202 fprintf(stderr, "%s: Error: no output file specified.\n", progname);
203 main_help();
204 exit(-1);
205 }
206
207#ifdef HAVE_REALPATH
208 if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
209#else
210 if (!strcmp (file_in, file_out))
211#endif
212 {
213 fprintf(stderr, "%s: Error: input file equals output file.\n", progname);
214 main_help();
215 exit(-1);
216 }
217
218 if (!edje_init())
219 exit(-1);
220
221 edje_file = mem_alloc(SZ(Edje_File));
222 edje_file->compiler = strdup("edje_cc");
223 edje_file->version = EDJE_FILE_VERSION;
224 edje_file->minor = EDJE_FILE_MINOR;
225 edje_file->feature_ver = 1; /* increment this every time we add a field
226 * or feature to the edje file format that
227 * does not load nicely as a NULL or 0 value
228 * and needs a special fallback initialization
229 */
230
231 source_edd();
232 source_fetch();
233
234 data_setup();
235 compile();
236 reorder_parts();
237 data_process_scripts();
238 data_process_lookups();
239 data_process_script_lookups();
240 data_write();
241
242 eina_prefix_free(pfx);
243 pfx = NULL;
244
245 edje_shutdown();
246 eina_log_domain_unregister(_edje_cc_log_dom);
247 eina_shutdown();
248
249 return 0;
250}
diff --git a/libraries/edje/src/bin/edje_cc.h b/libraries/edje/src/bin/edje_cc.h
new file mode 100644
index 0000000..bcd31a1
--- /dev/null
+++ b/libraries/edje/src/bin/edje_cc.h
@@ -0,0 +1,226 @@
1#ifndef EDJE_CC_H
2#define EDJE_CC_H
3
4#include <edje_private.h>
5
6extern 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 */
18extern int _edje_cc_log_dom ;
19#define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
20#ifdef ERR
21# undef ERR
22#endif
23#define ERR(...) EINA_LOG_DOM_ERR(_edje_cc_log_dom, __VA_ARGS__)
24#ifdef INF
25# undef INF
26#endif
27#define INF(...) EINA_LOG_DOM_INFO(_edje_cc_log_dom, __VA_ARGS__)
28#ifdef WRN
29# undef WRN
30#endif
31#define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__)
32
33
34/* types */
35typedef struct _New_Object_Handler New_Object_Handler;
36typedef struct _New_Statement_Handler New_Statement_Handler;
37typedef struct _External_List External_List;
38typedef struct _External External;
39typedef struct _Font_List Font_List;
40typedef struct _Font Font;
41typedef struct _Code Code;
42typedef struct _Code_Program Code_Program;
43typedef struct _SrcFile SrcFile;
44typedef struct _SrcFile_List SrcFile_List;
45
46typedef struct _Edje_Program_Parser Edje_Program_Parser;
47typedef struct _Edje_Pack_Element_Parser Edje_Pack_Element_Parser;
48typedef struct _Edje_Part_Parser Edje_Part_Parser;
49
50struct _New_Object_Handler
51{
52 const char *type;
53 void (*func)(void);
54};
55
56struct _New_Statement_Handler
57{
58 const char *type;
59 void (*func)(void);
60};
61
62struct _External_List
63{
64 Eina_List *list;
65};
66
67struct _External
68{
69 char *name;
70};
71
72struct _Font_List
73{
74 Eina_List *list;
75};
76
77struct _Font
78{
79 char *name;
80 char *file;
81};
82
83struct _Code
84{
85 int l1, l2;
86 char *shared;
87 char *original;
88 Eina_List *programs;
89 int is_lua;
90};
91
92struct _Code_Program
93{
94 int l1, l2;
95 int id;
96 char *script;
97 char *original;
98};
99
100struct _SrcFile
101{
102 char *name;
103 char *file;
104};
105
106struct _SrcFile_List
107{
108 Eina_List *list;
109};
110
111struct _Edje_Program_Parser
112{
113 Edje_Program common;
114 Eina_Bool can_override;
115};
116
117struct _Edje_Pack_Element_Parser
118{
119 Edje_Pack_Element common;
120 Eina_Bool can_override;
121};
122
123struct _Edje_Part_Parser
124{
125 Edje_Part common;
126 struct {
127 Eina_Bool done;
128 const char *insert_before; /* the part name for insertion in front of */
129 const char *insert_after; /* the part name for insertion behind of */
130 Edje_Part_Parser *before;
131 Edje_Part_Parser *after;
132 int linked_prev; /* the number linked previous part for reorder */
133 int linked_next; /* the number linked next part for reorder */
134 } reorder;
135 Eina_Bool can_override;
136};
137
138/* global fn calls */
139void data_setup(void);
140void data_write(void);
141void data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest);
142void data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest);
143void data_queue_program_lookup(Edje_Part_Collection *pc, const char *name, int *dest);
144void data_queue_copied_program_lookup(Edje_Part_Collection *pc, int *src, int *dest);
145void data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest);
146void data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest);
147void data_queue_image_lookup(char *name, int *dest, Eina_Bool *set);
148void data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set);
149void data_queue_part_slave_lookup(int *master, int *slave);
150void data_queue_image_slave_lookup(int *master, int *slave);
151void data_queue_spectrum_lookup(char *name, int *dest);
152void data_queue_spectrum_slave_lookup(int *master, int *slave);
153void data_process_lookups(void);
154void data_process_scripts(void);
155void data_process_script_lookups(void);
156
157
158int is_verbatim(void);
159void track_verbatim(int on);
160void set_verbatim(char *s, int l1, int l2);
161char *get_verbatim(void);
162int get_verbatim_line1(void);
163int get_verbatim_line2(void);
164void compile(void);
165int is_param(int n);
166int is_num(int n);
167char *parse_str(int n);
168int parse_enum(int n, ...);
169int parse_flags(int n, ...);
170int parse_int(int n);
171int parse_int_range(int n, int f, int t);
172int parse_bool(int n);
173double parse_float(int n);
174double parse_float_range(int n, double f, double t);
175int get_arg_count(void);
176void check_arg_count(int n);
177void check_min_arg_count(int n);
178
179int object_handler_num(void);
180int statement_handler_num(void);
181
182void reorder_parts(void);
183void source_edd(void);
184void source_fetch(void);
185int source_append(Eet_File *ef);
186SrcFile_List *source_load(Eet_File *ef);
187int source_fontmap_save(Eet_File *ef, Eina_List *fonts);
188Font_List *source_fontmap_load(Eet_File *ef);
189
190void *mem_alloc(size_t size);
191char *mem_strdup(const char *s);
192#define SZ sizeof
193
194void error_and_abort(Eet_File *ef, const char *fmt, ...);
195
196/* global vars */
197extern Eina_List *ext_dirs;
198extern Eina_List *img_dirs;
199extern Eina_List *fnt_dirs;
200extern Eina_List *snd_dirs;
201extern char *file_in;
202extern char *tmp_dir;
203extern char *file_out;
204extern char *progname;
205extern int verbose;
206extern int no_lossy;
207extern int no_comp;
208extern int no_raw;
209extern int no_save;
210extern int min_quality;
211extern int max_quality;
212extern int line;
213extern Eina_List *stack;
214extern Eina_List *params;
215extern Edje_File *edje_file;
216extern Eina_List *edje_collections;
217extern Eina_List *externals;
218extern Eina_List *fonts;
219extern Eina_List *codes;
220extern Eina_List *defines;
221extern Eina_List *aliases;
222extern New_Object_Handler object_handlers[];
223extern New_Statement_Handler statement_handlers[];
224
225
226#endif
diff --git a/libraries/edje/src/bin/edje_cc_handlers.c b/libraries/edje/src/bin/edje_cc_handlers.c
new file mode 100644
index 0000000..8bfc262
--- /dev/null
+++ b/libraries/edje/src/bin/edje_cc_handlers.c
@@ -0,0 +1,7763 @@
1/*
2 Concerning the EDC reference:
3
4 The formatting for blocks and properties has been implemented as a table
5 which is filled using ALIASES.
6 For maximum flexibility I implemented them in the \@code/\@encode style,
7 this means that missing one or changing the order most certainly cause
8 formatting errors.
9
10 \@block
11 block name
12 \@context
13 code sample of the block
14 \@description
15 the block's description
16 \@endblock
17
18 \@property
19 property name
20 \@parameters
21 property's parameter list
22 \@effect
23 the property description (lol)
24 \@endproperty
25*/
26
27#ifdef HAVE_CONFIG_H
28# include "config.h"
29#endif
30
31#include <string.h>
32#include <errno.h>
33#include <sys/stat.h>
34#include <fcntl.h>
35#include <sys/mman.h>
36#include <unistd.h>
37
38#include "edje_cc.h"
39
40/**
41 * @page edcref Edje Data Collection reference
42 * An Edje Data Collection, it's a plain text file (normally identified with the
43 * .edc extension),consisting of instructions for the Edje Compiler.
44 *
45 * The syntax for the edje data collection files follows a simple structure of
46 * "blocks { .. }" that can contain "properties: ..", more blocks, or both.
47 *
48 * @anchor sec_quickaccess Quick access to block descriptions:
49 * <ul>
50 * <li>@ref sec_toplevel "Top-Level"</li>
51 * <li>@ref sec_group "Group"</li>
52 * <li>@ref sec_description "State description"</li>
53 * <ul>
54 * <li>@ref sec_description_image "Image"</li>
55 * <li>@ref sec_description_text "Text"</li>
56 * <li>@ref sec_description_box "Box"</li>
57 * <li>@ref sec_description_table "Table"</li>
58 * <li>@ref sec_description_map "Map (3d/transformations)"</li>
59 * </ul>
60 * <li>@ref sec_program "Program block"</li>
61 * </ul>
62 *
63 * @author Andres Blanc (dresb) andresblanc@gmail.com
64 *
65 * <table class="edcref" border="0">
66 */
67
68static Edje_Part_Collection_Directory_Entry *current_de = NULL;
69static Edje_Part *current_part = NULL;
70static Edje_Pack_Element *current_item = NULL;
71static Edje_Part_Description_Common *current_desc = NULL;
72static Edje_Part_Description_Common *parent_desc = NULL;
73static Edje_Program *current_program = NULL;
74
75static void st_externals_external(void);
76
77static void st_images_image(void);
78static void ob_images_set(void);
79static void st_images_set_name(void);
80static void ob_images_set_image(void);
81static void st_images_set_image_image(void);
82static void st_images_set_image_size(void);
83
84static void st_fonts_font(void);
85
86static void st_data_item(void);
87static void st_data_file(void);
88
89static void ob_styles_style(void);
90static void st_styles_style_name(void);
91static void st_styles_style_base(void);
92static void st_styles_style_tag(void);
93
94static void ob_color_class(void);
95static void st_color_class_name(void);
96static void st_color_class_color(void);
97static void st_color_class_color2(void);
98static void st_color_class_color3(void);
99
100static void ob_collections(void);
101
102static void ob_collections_group(void);
103static void st_collections_group_name(void);
104static void st_collections_group_inherit(void);
105static void st_collections_group_script_only(void);
106static void st_collections_group_alias(void);
107static void st_collections_group_min(void);
108static void st_collections_group_max(void);
109static void st_collections_group_data_item(void);
110static void st_collections_group_orientation(void);
111
112static void st_collections_group_limits_vertical(void);
113static void st_collections_group_limits_horizontal(void);
114
115static void ob_collections_group_script(void);
116static void ob_collections_group_lua_script(void);
117
118static void st_collections_group_parts_alias(void);
119
120static void ob_collections_group_parts_part(void);
121static void st_collections_group_parts_part_name(void);
122static void st_collections_group_parts_part_type(void);
123static void st_collections_group_parts_part_insert_before(void);
124static void st_collections_group_parts_part_insert_after(void);
125static void st_collections_group_parts_part_effect(void);
126static void st_collections_group_parts_part_mouse_events(void);
127static void st_collections_group_parts_part_repeat_events(void);
128static void st_collections_group_parts_part_ignore_flags(void);
129static void st_collections_group_parts_part_scale(void);
130static void st_collections_group_parts_part_pointer_mode(void);
131static void st_collections_group_parts_part_precise_is_inside(void);
132static void st_collections_group_parts_part_use_alternate_font_metrics(void);
133static void st_collections_group_parts_part_clip_to_id(void);
134static void st_collections_group_parts_part_source(void);
135static void st_collections_group_parts_part_source2(void);
136static void st_collections_group_parts_part_source3(void);
137static void st_collections_group_parts_part_source4(void);
138static void st_collections_group_parts_part_source5(void);
139static void st_collections_group_parts_part_source6(void);
140static void st_collections_group_parts_part_entry_mode(void);
141static void st_collections_group_parts_part_select_mode(void);
142static void st_collections_group_parts_part_cursor_mode(void);
143static void st_collections_group_parts_part_multiline(void);
144static void st_collections_group_parts_part_dragable_x(void);
145static void st_collections_group_parts_part_dragable_y(void);
146static void st_collections_group_parts_part_dragable_confine(void);
147static void st_collections_group_parts_part_dragable_events(void);
148
149/* box and table items share these */
150static void ob_collections_group_parts_part_box_items_item(void);
151static void st_collections_group_parts_part_box_items_item_type(void);
152static void st_collections_group_parts_part_box_items_item_name(void);
153static void st_collections_group_parts_part_box_items_item_source(void);
154static void st_collections_group_parts_part_box_items_item_min(void);
155static void st_collections_group_parts_part_box_items_item_prefer(void);
156static void st_collections_group_parts_part_box_items_item_max(void);
157static void st_collections_group_parts_part_box_items_item_padding(void);
158static void st_collections_group_parts_part_box_items_item_align(void);
159static void st_collections_group_parts_part_box_items_item_weight(void);
160static void st_collections_group_parts_part_box_items_item_aspect(void);
161static void st_collections_group_parts_part_box_items_item_aspect_mode(void);
162static void st_collections_group_parts_part_box_items_item_options(void);
163/* but these are only for table */
164static void st_collections_group_parts_part_table_items_item_position(void);
165static void st_collections_group_parts_part_table_items_item_span(void);
166
167static void ob_collections_group_parts_part_description(void);
168static void st_collections_group_parts_part_description_inherit(void);
169static void st_collections_group_parts_part_description_source(void);
170static void st_collections_group_parts_part_description_state(void);
171static void st_collections_group_parts_part_description_visible(void);
172static void st_collections_group_parts_part_description_align(void);
173static void st_collections_group_parts_part_description_fixed(void);
174static void st_collections_group_parts_part_description_min(void);
175static void st_collections_group_parts_part_description_max(void);
176static void st_collections_group_parts_part_description_step(void);
177static void st_collections_group_parts_part_description_aspect(void);
178static void st_collections_group_parts_part_description_aspect_preference(void);
179static void st_collections_group_parts_part_description_rel1_relative(void);
180static void st_collections_group_parts_part_description_rel1_offset(void);
181static void st_collections_group_parts_part_description_rel1_to(void);
182static void st_collections_group_parts_part_description_rel1_to_x(void);
183static void st_collections_group_parts_part_description_rel1_to_y(void);
184static void st_collections_group_parts_part_description_rel2_relative(void);
185static void st_collections_group_parts_part_description_rel2_offset(void);
186static void st_collections_group_parts_part_description_rel2_to(void);
187static void st_collections_group_parts_part_description_rel2_to_x(void);
188static void st_collections_group_parts_part_description_rel2_to_y(void);
189static void st_collections_group_parts_part_description_image_normal(void);
190static void st_collections_group_parts_part_description_image_tween(void);
191static void st_collections_group_parts_part_description_image_border(void);
192static void st_collections_group_parts_part_description_image_middle(void);
193static void st_collections_group_parts_part_description_image_border_scale(void);
194static void st_collections_group_parts_part_description_image_border_scale_by(void);
195static void st_collections_group_parts_part_description_image_scale_hint(void);
196static void st_collections_group_parts_part_description_fill_smooth(void);
197static void st_collections_group_parts_part_description_fill_origin_relative(void);
198static void st_collections_group_parts_part_description_fill_origin_offset(void);
199static void st_collections_group_parts_part_description_fill_size_relative(void);
200static void st_collections_group_parts_part_description_fill_size_offset(void);
201static void st_collections_group_parts_part_description_fill_spread(void);
202static void st_collections_group_parts_part_description_fill_type(void);
203static void st_collections_group_parts_part_description_color_class(void);
204static void st_collections_group_parts_part_description_color(void);
205static void st_collections_group_parts_part_description_color2(void);
206static void st_collections_group_parts_part_description_color3(void);
207static void st_collections_group_parts_part_description_text_text(void);
208static void st_collections_group_parts_part_description_text_text_class(void);
209static void st_collections_group_parts_part_description_text_font(void);
210static void st_collections_group_parts_part_description_text_style(void);
211static void st_collections_group_parts_part_description_text_repch(void);
212static void st_collections_group_parts_part_description_text_size(void);
213static void st_collections_group_parts_part_description_text_size_range(void);
214static void st_collections_group_parts_part_description_text_fit(void);
215static void st_collections_group_parts_part_description_text_min(void);
216static void st_collections_group_parts_part_description_text_max(void);
217static void st_collections_group_parts_part_description_text_align(void);
218static void st_collections_group_parts_part_description_text_source(void);
219static void st_collections_group_parts_part_description_text_text_source(void);
220static void st_collections_group_parts_part_description_text_elipsis(void);
221static void st_collections_group_parts_part_description_box_layout(void);
222static void st_collections_group_parts_part_description_box_align(void);
223static void st_collections_group_parts_part_description_box_padding(void);
224static void st_collections_group_parts_part_description_box_min(void);
225static void st_collections_group_parts_part_description_table_homogeneous(void);
226static void st_collections_group_parts_part_description_table_align(void);
227static void st_collections_group_parts_part_description_table_padding(void);
228static void st_collections_group_parts_part_description_table_min(void);
229static void st_collections_group_parts_part_description_map_perspective(void);
230static void st_collections_group_parts_part_description_map_light(void);
231static void st_collections_group_parts_part_description_map_rotation_center(void);
232static void st_collections_group_parts_part_description_map_rotation_x(void);
233static void st_collections_group_parts_part_description_map_rotation_y(void);
234static void st_collections_group_parts_part_description_map_rotation_z(void);
235static void st_collections_group_parts_part_description_map_on(void);
236static void st_collections_group_parts_part_description_map_smooth(void);
237static void st_collections_group_parts_part_description_map_alpha(void);
238static void st_collections_group_parts_part_description_map_backface_cull(void);
239static void st_collections_group_parts_part_description_map_perspective_on(void);
240static void st_collections_group_parts_part_description_perspective_zplane(void);
241static void st_collections_group_parts_part_description_perspective_focal(void);
242static void st_collections_group_parts_part_api(void);
243
244/* external part parameters */
245static void st_collections_group_parts_part_description_params_int(void);
246static void ob_collections_group_programs_program(void);
247static void st_collections_group_parts_part_description_params_double(void);
248
249static void st_collections_group_programs_program_name(void);
250static void st_collections_group_parts_part_description_params_string(void);
251static void st_collections_group_parts_part_description_params_bool(void);
252static void st_collections_group_parts_part_description_params_choice(void);
253static void st_collections_group_programs_program_signal(void);
254static void st_collections_group_programs_program_source(void);
255static void st_collections_group_programs_program_filter(void);
256static void st_collections_group_programs_program_in(void);
257static void st_collections_group_programs_program_action(void);
258static void st_collections_group_programs_program_transition(void);
259static void st_collections_group_programs_program_target(void);
260static void st_collections_group_programs_program_after(void);
261static void st_collections_group_programs_program_api(void);
262
263static void ob_collections_group_programs_program_script(void);
264
265#ifdef ENABLE_MULTISENSE
266static void st_collections_group_sound_sample_name(void);
267static void st_collections_group_sound_sample_source(void);
268static void st_collections_group_sound_tone(void);
269#endif
270
271/*****/
272
273New_Statement_Handler statement_handlers[] =
274{
275 {"externals.external", st_externals_external},
276 {"images.image", st_images_image},
277 {"images.set.name", st_images_set_name},
278 {"images.set.image.image", st_images_set_image_image},
279 {"images.set.image.size", st_images_set_image_size},
280 {"fonts.font", st_fonts_font},
281 {"data.item", st_data_item},
282 {"data.file", st_data_file},
283 {"styles.style.name", st_styles_style_name},
284 {"styles.style.base", st_styles_style_base},
285 {"styles.style.tag", st_styles_style_tag},
286 {"color_classes.color_class.name", st_color_class_name},
287 {"color_classes.color_class.color", st_color_class_color},
288 {"color_classes.color_class.color2", st_color_class_color2},
289 {"color_classes.color_class.color3", st_color_class_color3},
290 {"collections.externals.external", st_externals_external}, /* dup */
291 {"collections.image", st_images_image}, /* dup */
292 {"collections.set.name", st_images_set_name}, /* dup */
293 {"collections.set.image.image", st_images_set_image_image}, /* dup */
294 {"collections.set.image.size", st_images_set_image_size}, /* dup */
295 {"collections.images.image", st_images_image}, /* dup */
296 {"collections.images.set.name", st_images_set_name}, /* dup */
297 {"collections.images.set.image.image", st_images_set_image_image}, /* dup */
298 {"collections.images.set.image.size", st_images_set_image_size}, /* dup */
299 {"collections.font", st_fonts_font}, /* dup */
300 {"collections.fonts.font", st_fonts_font}, /* dup */
301 {"collections.styles.style.name", st_styles_style_name}, /* dup */
302 {"collections.styles.style.base", st_styles_style_base}, /* dup */
303 {"collections.styles.style.tag", st_styles_style_tag}, /* dup */
304 {"collections.color_classes.color_class.name", st_color_class_name}, /* dup */
305 {"collections.color_classes.color_class.color", st_color_class_color}, /* dup */
306 {"collections.color_classes.color_class.color2", st_color_class_color2}, /* dup */
307 {"collections.color_classes.color_class.color3", st_color_class_color3}, /* dup */
308#ifdef ENABLE_MULTISENSE
309 {"collections.sounds.sample.name", st_collections_group_sound_sample_name},
310 {"collections.sounds.sample.source", st_collections_group_sound_sample_source},
311 {"collections.group.sounds.sample.name", st_collections_group_sound_sample_name}, /* dup */
312 {"collections.group.sounds.sample.source", st_collections_group_sound_sample_source}, /* dup */
313 {"collections.sounds.tone", st_collections_group_sound_tone},
314 {"collections.group.sounds.tone", st_collections_group_sound_tone}, /* dup */
315#endif
316 {"collections.group.name", st_collections_group_name},
317 {"collections.group.inherit", st_collections_group_inherit},
318 {"collections.group.script_only", st_collections_group_script_only},
319 {"collections.group.lua_script_only", st_collections_group_script_only},
320 {"collections.group.alias", st_collections_group_alias},
321 {"collections.group.min", st_collections_group_min},
322 {"collections.group.max", st_collections_group_max},
323 {"collections.group.orientation", st_collections_group_orientation},
324 {"collections.group.data.item", st_collections_group_data_item},
325 {"collections.group.limits.horizontal", st_collections_group_limits_horizontal},
326 {"collections.group.limits.vertical", st_collections_group_limits_vertical},
327 {"collections.group.externals.external", st_externals_external}, /* dup */
328 {"collections.group.image", st_images_image}, /* dup */
329 {"collections.group.set.name", st_images_set_name},
330 {"collections.group.set.image.image", st_images_set_image_image},
331 {"collections.group.set.image.size", st_images_set_image_size},
332 {"collections.group.images.image", st_images_image}, /* dup */
333 {"collections.group.images.set.name", st_images_set_name},
334 {"collections.group.images.set.image.image", st_images_set_image_image},
335 {"collections.group.images.set.image.size", st_images_set_image_size},
336 {"collections.group.font", st_fonts_font}, /* dup */
337 {"collections.group.fonts.font", st_fonts_font}, /* dup */
338 {"collections.group.styles.style.name", st_styles_style_name}, /* dup */
339 {"collections.group.styles.style.base", st_styles_style_base}, /* dup */
340 {"collections.group.styles.style.tag", st_styles_style_tag}, /* dup */
341 {"collections.group.color_classes.color_class.name", st_color_class_name}, /* dup */
342 {"collections.group.color_classes.color_class.color", st_color_class_color}, /* dup */
343 {"collections.group.color_classes.color_class.color2", st_color_class_color2}, /* dup */
344 {"collections.group.color_classes.color_class.color3", st_color_class_color3}, /* dup */
345 {"collections.group.parts.alias", st_collections_group_parts_alias },
346 {"collections.group.parts.image", st_images_image}, /* dup */
347 {"collections.group.parts.set.name", st_images_set_name},
348 {"collections.group.parts.set.image.image", st_images_set_image_image},
349 {"collections.group.parts.set.image.size", st_images_set_image_size},
350 {"collections.group.parts.images.image", st_images_image}, /* dup */
351 {"collections.group.parts.images.set.name", st_images_set_name},
352 {"collections.group.parts.images.set.image.image", st_images_set_image_image},
353 {"collections.group.parts.images.set.image.size", st_images_set_image_size},
354 {"collections.group.parts.font", st_fonts_font}, /* dup */
355 {"collections.group.parts.fonts.font", st_fonts_font}, /* dup */
356 {"collections.group.parts.styles.style.name", st_styles_style_name}, /* dup */
357 {"collections.group.parts.styles.style.base", st_styles_style_base}, /* dup */
358 {"collections.group.parts.styles.style.tag", st_styles_style_tag}, /* dup */
359 {"collections.group.parts.color_classes.color_class.name", st_color_class_name}, /* dup */
360 {"collections.group.parts.color_classes.color_class.color", st_color_class_color}, /* dup */
361 {"collections.group.parts.color_classes.color_class.color2", st_color_class_color2}, /* dup */
362 {"collections.group.parts.color_classes.color_class.color3", st_color_class_color3}, /* dup */
363 {"collections.group.parts.part.name", st_collections_group_parts_part_name},
364 {"collections.group.parts.part.api", st_collections_group_parts_part_api},
365 {"collections.group.parts.part.type", st_collections_group_parts_part_type},
366 {"collections.group.parts.part.insert_before", st_collections_group_parts_part_insert_before},
367 {"collections.group.parts.part.insert_after", st_collections_group_parts_part_insert_after},
368 {"collections.group.parts.part.effect", st_collections_group_parts_part_effect},
369 {"collections.group.parts.part.mouse_events", st_collections_group_parts_part_mouse_events},
370 {"collections.group.parts.part.repeat_events", st_collections_group_parts_part_repeat_events},
371 {"collections.group.parts.part.ignore_flags", st_collections_group_parts_part_ignore_flags},
372 {"collections.group.parts.part.scale", st_collections_group_parts_part_scale},
373 {"collections.group.parts.part.pointer_mode", st_collections_group_parts_part_pointer_mode},
374 {"collections.group.parts.part.precise_is_inside", st_collections_group_parts_part_precise_is_inside},
375 {"collections.group.parts.part.use_alternate_font_metrics", st_collections_group_parts_part_use_alternate_font_metrics},
376 {"collections.group.parts.part.clip_to", st_collections_group_parts_part_clip_to_id},
377 {"collections.group.parts.part.source", st_collections_group_parts_part_source},
378 {"collections.group.parts.part.source2", st_collections_group_parts_part_source2},
379 {"collections.group.parts.part.source3", st_collections_group_parts_part_source3},
380 {"collections.group.parts.part.source4", st_collections_group_parts_part_source4},
381 {"collections.group.parts.part.source5", st_collections_group_parts_part_source5},
382 {"collections.group.parts.part.source6", st_collections_group_parts_part_source6},
383 {"collections.group.parts.part.dragable.x", st_collections_group_parts_part_dragable_x},
384 {"collections.group.parts.part.dragable.y", st_collections_group_parts_part_dragable_y},
385 {"collections.group.parts.part.dragable.confine", st_collections_group_parts_part_dragable_confine},
386 {"collections.group.parts.part.dragable.events", st_collections_group_parts_part_dragable_events},
387 {"collections.group.parts.part.entry_mode", st_collections_group_parts_part_entry_mode},
388 {"collections.group.parts.part.select_mode", st_collections_group_parts_part_select_mode},
389 {"collections.group.parts.part.cursor_mode", st_collections_group_parts_part_cursor_mode},
390 {"collections.group.parts.part.multiline", st_collections_group_parts_part_multiline},
391 {"collections.group.parts.part.image", st_images_image}, /* dup */
392 {"collections.group.parts.part.set.name", st_images_set_name},
393 {"collections.group.parts.part.set.image.image", st_images_set_image_image},
394 {"collections.group.parts.part.set.image.size", st_images_set_image_size},
395 {"collections.group.parts.part.images.image", st_images_image}, /* dup */
396 {"collections.group.parts.part.images.set.name", st_images_set_name},
397 {"collections.group.parts.part.images.set.image.image", st_images_set_image_image},
398 {"collections.group.parts.part.images.set.image.size", st_images_set_image_size},
399 {"collections.group.parts.part.font", st_fonts_font}, /* dup */
400 {"collections.group.parts.part.fonts.font", st_fonts_font}, /* dup */
401 {"collections.group.parts.part.styles.style.name", st_styles_style_name}, /* dup */
402 {"collections.group.parts.part.styles.style.base", st_styles_style_base}, /* dup */
403 {"collections.group.parts.part.styles.style.tag", st_styles_style_tag}, /* dup */
404 {"collections.group.parts.part.color_classes.color_class.name", st_color_class_name}, /* dup */
405 {"collections.group.parts.part.color_classes.color_class.color", st_color_class_color}, /* dup */
406 {"collections.group.parts.part.color_classes.color_class.color2", st_color_class_color2}, /* dup */
407 {"collections.group.parts.part.color_classes.color_class.color3", st_color_class_color3}, /* dup */
408 {"collections.group.parts.part.box.items.item.type", st_collections_group_parts_part_box_items_item_type},
409 {"collections.group.parts.part.box.items.item.name", st_collections_group_parts_part_box_items_item_name},
410 {"collections.group.parts.part.box.items.item.source", st_collections_group_parts_part_box_items_item_source},
411 {"collections.group.parts.part.box.items.item.min", st_collections_group_parts_part_box_items_item_min},
412 {"collections.group.parts.part.box.items.item.prefer", st_collections_group_parts_part_box_items_item_prefer},
413 {"collections.group.parts.part.box.items.item.max", st_collections_group_parts_part_box_items_item_max},
414 {"collections.group.parts.part.box.items.item.padding", st_collections_group_parts_part_box_items_item_padding},
415 {"collections.group.parts.part.box.items.item.align", st_collections_group_parts_part_box_items_item_align},
416 {"collections.group.parts.part.box.items.item.weight", st_collections_group_parts_part_box_items_item_weight},
417 {"collections.group.parts.part.box.items.item.aspect", st_collections_group_parts_part_box_items_item_aspect},
418 {"collections.group.parts.part.box.items.item.aspect_mode", st_collections_group_parts_part_box_items_item_aspect_mode},
419 {"collections.group.parts.part.box.items.item.options", st_collections_group_parts_part_box_items_item_options},
420 {"collections.group.parts.part.table.items.item.type", st_collections_group_parts_part_box_items_item_type}, /* dup */
421 {"collections.group.parts.part.table.items.item.name", st_collections_group_parts_part_box_items_item_name}, /* dup */
422 {"collections.group.parts.part.table.items.item.source", st_collections_group_parts_part_box_items_item_source}, /* dup */
423 {"collections.group.parts.part.table.items.item.min", st_collections_group_parts_part_box_items_item_min}, /* dup */
424 {"collections.group.parts.part.table.items.item.prefer", st_collections_group_parts_part_box_items_item_prefer}, /* dup */
425 {"collections.group.parts.part.table.items.item.max", st_collections_group_parts_part_box_items_item_max}, /* dup */
426 {"collections.group.parts.part.table.items.item.padding", st_collections_group_parts_part_box_items_item_padding}, /* dup */
427 {"collections.group.parts.part.table.items.item.align", st_collections_group_parts_part_box_items_item_align}, /* dup */
428 {"collections.group.parts.part.table.items.item.weight", st_collections_group_parts_part_box_items_item_weight}, /* dup */
429 {"collections.group.parts.part.table.items.item.aspect", st_collections_group_parts_part_box_items_item_aspect}, /* dup */
430 {"collections.group.parts.part.table.items.item.aspect_mode", st_collections_group_parts_part_box_items_item_aspect_mode}, /* dup */
431 {"collections.group.parts.part.table.items.item.options", st_collections_group_parts_part_box_items_item_options}, /* dup */
432 {"collections.group.parts.part.table.items.item.position", st_collections_group_parts_part_table_items_item_position},
433 {"collections.group.parts.part.table.items.item.span", st_collections_group_parts_part_table_items_item_span},
434 {"collections.group.parts.part.description.inherit", st_collections_group_parts_part_description_inherit},
435 {"collections.group.parts.part.description.source", st_collections_group_parts_part_description_source},
436 {"collections.group.parts.part.description.state", st_collections_group_parts_part_description_state},
437 {"collections.group.parts.part.description.visible", st_collections_group_parts_part_description_visible},
438 {"collections.group.parts.part.description.align", st_collections_group_parts_part_description_align},
439 {"collections.group.parts.part.description.fixed", st_collections_group_parts_part_description_fixed},
440 {"collections.group.parts.part.description.min", st_collections_group_parts_part_description_min},
441 {"collections.group.parts.part.description.max", st_collections_group_parts_part_description_max},
442 {"collections.group.parts.part.description.step", st_collections_group_parts_part_description_step},
443 {"collections.group.parts.part.description.aspect", st_collections_group_parts_part_description_aspect},
444 {"collections.group.parts.part.description.aspect_preference", st_collections_group_parts_part_description_aspect_preference},
445 {"collections.group.parts.part.description.rel1.relative", st_collections_group_parts_part_description_rel1_relative},
446 {"collections.group.parts.part.description.rel1.offset", st_collections_group_parts_part_description_rel1_offset},
447 {"collections.group.parts.part.description.rel1.to", st_collections_group_parts_part_description_rel1_to},
448 {"collections.group.parts.part.description.rel1.to_x", st_collections_group_parts_part_description_rel1_to_x},
449 {"collections.group.parts.part.description.rel1.to_y", st_collections_group_parts_part_description_rel1_to_y},
450 {"collections.group.parts.part.description.rel2.relative", st_collections_group_parts_part_description_rel2_relative},
451 {"collections.group.parts.part.description.rel2.offset", st_collections_group_parts_part_description_rel2_offset},
452 {"collections.group.parts.part.description.rel2.to", st_collections_group_parts_part_description_rel2_to},
453 {"collections.group.parts.part.description.rel2.to_x", st_collections_group_parts_part_description_rel2_to_x},
454 {"collections.group.parts.part.description.rel2.to_y", st_collections_group_parts_part_description_rel2_to_y},
455 {"collections.group.parts.part.description.image.normal", st_collections_group_parts_part_description_image_normal},
456 {"collections.group.parts.part.description.image.tween", st_collections_group_parts_part_description_image_tween},
457 {"collections.group.parts.part.description.image.image", st_images_image}, /* dup */
458 {"collections.group.parts.part.description.image.set.name", st_images_set_name},
459 {"collections.group.parts.part.description.image.set.image.image", st_images_set_image_image},
460 {"collections.group.parts.part.description.image.set.image.size", st_images_set_image_size},
461 {"collections.group.parts.part.description.image.images.image", st_images_image}, /* dup */
462 {"collections.group.parts.part.description.image.images.set.name", st_images_set_name},
463 {"collections.group.parts.part.description.image.images.set.image.image", st_images_set_image_image},
464 {"collections.group.parts.part.description.image.images.set.image.size", st_images_set_image_size},
465 {"collections.group.parts.part.description.image.border", st_collections_group_parts_part_description_image_border},
466 {"collections.group.parts.part.description.image.middle", st_collections_group_parts_part_description_image_middle},
467 {"collections.group.parts.part.description.image.border_scale", st_collections_group_parts_part_description_image_border_scale},
468 {"collections.group.parts.part.description.image.border_scale_by", st_collections_group_parts_part_description_image_border_scale_by},
469 {"collections.group.parts.part.description.image.scale_hint", st_collections_group_parts_part_description_image_scale_hint},
470 {"collections.group.parts.part.description.fill.smooth", st_collections_group_parts_part_description_fill_smooth},
471 {"collections.group.parts.part.description.fill.origin.relative", st_collections_group_parts_part_description_fill_origin_relative},
472 {"collections.group.parts.part.description.fill.origin.offset", st_collections_group_parts_part_description_fill_origin_offset},
473 {"collections.group.parts.part.description.fill.size.relative", st_collections_group_parts_part_description_fill_size_relative},
474 {"collections.group.parts.part.description.fill.size.offset", st_collections_group_parts_part_description_fill_size_offset},
475 {"collections.group.parts.part.description.fill.spread", st_collections_group_parts_part_description_fill_spread},
476 {"collections.group.parts.part.description.fill.type", st_collections_group_parts_part_description_fill_type},
477 {"collections.group.parts.part.description.color_class", st_collections_group_parts_part_description_color_class},
478 {"collections.group.parts.part.description.color", st_collections_group_parts_part_description_color},
479 {"collections.group.parts.part.description.color2", st_collections_group_parts_part_description_color2},
480 {"collections.group.parts.part.description.color3", st_collections_group_parts_part_description_color3},
481 {"collections.group.parts.part.description.text.text", st_collections_group_parts_part_description_text_text},
482 {"collections.group.parts.part.description.text.text_class", st_collections_group_parts_part_description_text_text_class},
483 {"collections.group.parts.part.description.text.font", st_collections_group_parts_part_description_text_font},
484 {"collections.group.parts.part.description.text.style", st_collections_group_parts_part_description_text_style},
485 {"collections.group.parts.part.description.text.repch", st_collections_group_parts_part_description_text_repch},
486 {"collections.group.parts.part.description.text.size", st_collections_group_parts_part_description_text_size},
487 {"collections.group.parts.part.description.text.size_range", st_collections_group_parts_part_description_text_size_range},
488 {"collections.group.parts.part.description.text.fit", st_collections_group_parts_part_description_text_fit},
489 {"collections.group.parts.part.description.text.min", st_collections_group_parts_part_description_text_min},
490 {"collections.group.parts.part.description.text.max", st_collections_group_parts_part_description_text_max},
491 {"collections.group.parts.part.description.text.align", st_collections_group_parts_part_description_text_align},
492 {"collections.group.parts.part.description.text.source", st_collections_group_parts_part_description_text_source},
493 {"collections.group.parts.part.description.text.text_source", st_collections_group_parts_part_description_text_text_source},
494 {"collections.group.parts.part.description.text.font", st_fonts_font}, /* dup */
495 {"collections.group.parts.part.description.text.fonts.font", st_fonts_font}, /* dup */
496 {"collections.group.parts.part.description.text.elipsis", st_collections_group_parts_part_description_text_elipsis},
497 {"collections.group.parts.part.description.text.ellipsis", st_collections_group_parts_part_description_text_elipsis},
498 {"collections.group.parts.part.description.box.layout", st_collections_group_parts_part_description_box_layout},
499 {"collections.group.parts.part.description.box.align", st_collections_group_parts_part_description_box_align},
500 {"collections.group.parts.part.description.box.padding", st_collections_group_parts_part_description_box_padding},
501 {"collections.group.parts.part.description.box.min", st_collections_group_parts_part_description_box_min},
502 {"collections.group.parts.part.description.table.homogeneous", st_collections_group_parts_part_description_table_homogeneous},
503 {"collections.group.parts.part.description.table.align", st_collections_group_parts_part_description_table_align},
504 {"collections.group.parts.part.description.table.padding", st_collections_group_parts_part_description_table_padding},
505 {"collections.group.parts.part.description.table.min", st_collections_group_parts_part_description_table_min},
506 {"collections.group.parts.part.description.map.perspective", st_collections_group_parts_part_description_map_perspective},
507 {"collections.group.parts.part.description.map.light", st_collections_group_parts_part_description_map_light},
508 {"collections.group.parts.part.description.map.rotation.center", st_collections_group_parts_part_description_map_rotation_center},
509 {"collections.group.parts.part.description.map.rotation.x", st_collections_group_parts_part_description_map_rotation_x},
510 {"collections.group.parts.part.description.map.rotation.y", st_collections_group_parts_part_description_map_rotation_y},
511 {"collections.group.parts.part.description.map.rotation.z", st_collections_group_parts_part_description_map_rotation_z},
512 {"collections.group.parts.part.description.map.on", st_collections_group_parts_part_description_map_on},
513 {"collections.group.parts.part.description.map.smooth", st_collections_group_parts_part_description_map_smooth},
514 {"collections.group.parts.part.description.map.alpha", st_collections_group_parts_part_description_map_alpha},
515 {"collections.group.parts.part.description.map.backface_cull", st_collections_group_parts_part_description_map_backface_cull},
516 {"collections.group.parts.part.description.map.perspective_on", st_collections_group_parts_part_description_map_perspective_on},
517 {"collections.group.parts.part.description.perspective.zplane", st_collections_group_parts_part_description_perspective_zplane},
518 {"collections.group.parts.part.description.perspective.focal", st_collections_group_parts_part_description_perspective_focal},
519 {"collections.group.parts.part.description.params.int", st_collections_group_parts_part_description_params_int},
520 {"collections.group.parts.part.description.params.double", st_collections_group_parts_part_description_params_double},
521 {"collections.group.parts.part.description.params.string", st_collections_group_parts_part_description_params_string},
522 {"collections.group.parts.part.description.params.bool", st_collections_group_parts_part_description_params_bool},
523 {"collections.group.parts.part.description.params.choice", st_collections_group_parts_part_description_params_choice},
524 {"collections.group.parts.part.description.images.image", st_images_image}, /* dup */
525 {"collections.group.parts.part.description.images.set.name", st_images_set_name},
526 {"collections.group.parts.part.description.images.set.image.image", st_images_set_image_image},
527 {"collections.group.parts.part.description.images.set.image.size", st_images_set_image_size},
528 {"collections.group.parts.part.description.font", st_fonts_font}, /* dup */
529 {"collections.group.parts.part.description.fonts.font", st_fonts_font}, /* dup */
530 {"collections.group.parts.part.description.styles.style.name", st_styles_style_name}, /* dup */
531 {"collections.group.parts.part.description.styles.style.base", st_styles_style_base}, /* dup */
532 {"collections.group.parts.part.description.styles.style.tag", st_styles_style_tag}, /* dup */
533 {"collections.group.parts.part.description.color_classes.color_class.name", st_color_class_name}, /* dup */
534 {"collections.group.parts.part.description.color_classes.color_class.color", st_color_class_color}, /* dup */
535 {"collections.group.parts.part.description.color_classes.color_class.color2", st_color_class_color2}, /* dup */
536 {"collections.group.parts.part.description.color_classes.color_class.color3", st_color_class_color3}, /* dup */
537 {"collections.group.parts.part.description.programs.image", st_images_image}, /* dup */
538 {"collections.group.parts.part.description.programs.set.name", st_images_set_name},
539 {"collections.group.parts.part.description.programs.set.image.image", st_images_set_image_image},
540 {"collections.group.parts.part.description.programs.set.image.size", st_images_set_image_size},
541 {"collections.group.parts.part.description.programs.images.image", st_images_image}, /* dup */
542 {"collections.group.parts.part.description.programs.images.set.name", st_images_set_name},
543 {"collections.group.parts.part.description.programs.images.set.image.image", st_images_set_image_image},
544 {"collections.group.parts.part.description.programs.images.set.image.size", st_images_set_image_size},
545 {"collections.group.parts.part.description.programs.font", st_fonts_font}, /* dup */
546 {"collections.group.parts.part.description.programs.fonts.font", st_fonts_font}, /* dup */
547 {"collections.group.parts.part.description.programs.program.name", st_collections_group_programs_program_name}, /* dup */
548 {"collections.group.parts.part.description.programs.program.signal", st_collections_group_programs_program_signal}, /* dup */
549 {"collections.group.parts.part.description.programs.program.source", st_collections_group_programs_program_source}, /* dup */
550 {"collections.group.parts.part.description.programs.program.in", st_collections_group_programs_program_in}, /* dup */
551 {"collections.group.parts.part.description.programs.program.action", st_collections_group_programs_program_action}, /* dup */
552 {"collections.group.parts.part.description.programs.program.transition", st_collections_group_programs_program_transition}, /* dup */
553 {"collections.group.parts.part.description.programs.program.target", st_collections_group_programs_program_target}, /* dup */
554 {"collections.group.parts.part.description.programs.program.after", st_collections_group_programs_program_after}, /* dup */
555 {"collections.group.parts.part.description.programs.program.api", st_collections_group_programs_program_api}, /* dup */
556 {"collections.group.parts.part.description.program.name", st_collections_group_programs_program_name}, /* dup */
557 {"collections.group.parts.part.description.program.signal", st_collections_group_programs_program_signal}, /* dup */
558 {"collections.group.parts.part.description.program.source", st_collections_group_programs_program_source}, /* dup */
559 {"collections.group.parts.part.description.program.in", st_collections_group_programs_program_in}, /* dup */
560 {"collections.group.parts.part.description.program.action", st_collections_group_programs_program_action}, /* dup */
561 {"collections.group.parts.part.description.program.transition", st_collections_group_programs_program_transition}, /* dup */
562 {"collections.group.parts.part.description.program.target", st_collections_group_programs_program_target}, /* dup */
563 {"collections.group.parts.part.description.program.after", st_collections_group_programs_program_after}, /* dup */
564 {"collections.group.parts.part.description.program.api", st_collections_group_programs_program_api}, /* dup */
565 {"collections.group.parts.part.programs.image", st_images_image}, /* dup */
566 {"collections.group.parts.part.programs.set.name", st_images_set_name},
567 {"collections.group.parts.part.programs.set.image.image", st_images_set_image_image},
568 {"collections.group.parts.part.programs.set.image.size", st_images_set_image_size},
569 {"collections.group.parts.part.programs.images.image", st_images_image}, /* dup */
570 {"collections.group.parts.part.programs.images.set.name", st_images_set_name},
571 {"collections.group.parts.part.programs.images.set.image.image", st_images_set_image_image},
572 {"collections.group.parts.part.programs.images.set.image.size", st_images_set_image_size},
573 {"collections.group.parts.part.programs.font", st_fonts_font}, /* dup */
574 {"collections.group.parts.part.programs.fonts.font", st_fonts_font}, /* dup */
575 {"collections.group.parts.part.programs.program.name", st_collections_group_programs_program_name}, /* dup */
576 {"collections.group.parts.part.programs.program.signal", st_collections_group_programs_program_signal}, /* dup */
577 {"collections.group.parts.part.programs.program.source", st_collections_group_programs_program_source}, /* dup */
578 {"collections.group.parts.part.programs.program.in", st_collections_group_programs_program_in}, /* dup */
579 {"collections.group.parts.part.programs.program.action", st_collections_group_programs_program_action}, /* dup */
580 {"collections.group.parts.part.programs.program.transition", st_collections_group_programs_program_transition}, /* dup */
581 {"collections.group.parts.part.programs.program.target", st_collections_group_programs_program_target}, /* dup */
582 {"collections.group.parts.part.programs.program.after", st_collections_group_programs_program_after}, /* dup */
583 {"collections.group.parts.part.programs.program.api", st_collections_group_programs_program_api}, /* dup */
584 {"collections.group.parts.part.program.name", st_collections_group_programs_program_name}, /* dup */
585 {"collections.group.parts.part.program.signal", st_collections_group_programs_program_signal}, /* dup */
586 {"collections.group.parts.part.program.source", st_collections_group_programs_program_source}, /* dup */
587 {"collections.group.parts.part.program.in", st_collections_group_programs_program_in}, /* dup */
588 {"collections.group.parts.part.program.action", st_collections_group_programs_program_action}, /* dup */
589 {"collections.group.parts.part.program.transition", st_collections_group_programs_program_transition}, /* dup */
590 {"collections.group.parts.part.program.target", st_collections_group_programs_program_target}, /* dup */
591 {"collections.group.parts.part.program.after", st_collections_group_programs_program_after}, /* dup */
592 {"collections.group.parts.part.program.api", st_collections_group_programs_program_api}, /* dup */
593 {"collections.group.parts.programs.image", st_images_image}, /* dup */
594 {"collections.group.parts.programs.set.name", st_images_set_name},
595 {"collections.group.parts.programs.set.image.image", st_images_set_image_image},
596 {"collections.group.parts.programs.set.image.size", st_images_set_image_size},
597 {"collections.group.parts.programs.images.image", st_images_image}, /* dup */
598 {"collections.group.parts.programs.images.set.name", st_images_set_name},
599 {"collections.group.parts.programs.images.set.image.image", st_images_set_image_image},
600 {"collections.group.parts.programs.images.set.image.size", st_images_set_image_size},
601 {"collections.group.parts.programs.font", st_fonts_font}, /* dup */
602 {"collections.group.parts.programs.fonts.font", st_fonts_font}, /* dup */
603 {"collections.group.parts.programs.program.name", st_collections_group_programs_program_name}, /* dup */
604 {"collections.group.parts.programs.program.signal", st_collections_group_programs_program_signal}, /* dup */
605 {"collections.group.parts.programs.program.source", st_collections_group_programs_program_source}, /* dup */
606 {"collections.group.parts.programs.program.filter", st_collections_group_programs_program_filter}, /* dup */
607 {"collections.group.parts.programs.program.in", st_collections_group_programs_program_in}, /* dup */
608 {"collections.group.parts.programs.program.action", st_collections_group_programs_program_action}, /* dup */
609 {"collections.group.parts.programs.program.transition", st_collections_group_programs_program_transition}, /* dup */
610 {"collections.group.parts.programs.program.target", st_collections_group_programs_program_target}, /* dup */
611 {"collections.group.parts.programs.program.after", st_collections_group_programs_program_after},
612 {"collections.group.parts.programs.program.api", st_collections_group_programs_program_api},
613 {"collections.group.parts.program.name", st_collections_group_programs_program_name}, /* dup */
614 {"collections.group.parts.program.signal", st_collections_group_programs_program_signal}, /* dup */
615 {"collections.group.parts.program.source", st_collections_group_programs_program_source}, /* dup */
616 {"collections.group.parts.program.filter", st_collections_group_programs_program_filter}, /* dup */
617 {"collections.group.parts.program.in", st_collections_group_programs_program_in}, /* dup */
618 {"collections.group.parts.program.action", st_collections_group_programs_program_action}, /* dup */
619 {"collections.group.parts.program.transition", st_collections_group_programs_program_transition}, /* dup */
620 {"collections.group.parts.program.target", st_collections_group_programs_program_target}, /* dup */
621 {"collections.group.parts.program.after", st_collections_group_programs_program_after}, /* dup */
622 {"collections.group.parts.program.api", st_collections_group_programs_program_api}, /* dup */
623 {"collections.group.program.name", st_collections_group_programs_program_name}, /* dup */
624 {"collections.group.program.signal", st_collections_group_programs_program_signal}, /* dup */
625 {"collections.group.program.source", st_collections_group_programs_program_source}, /* dup */
626 {"collections.group.program.filter", st_collections_group_programs_program_filter}, /* dup */
627 {"collections.group.program.in", st_collections_group_programs_program_in}, /* dup */
628 {"collections.group.program.action", st_collections_group_programs_program_action}, /* dup */
629 {"collections.group.program.transition", st_collections_group_programs_program_transition}, /* dup */
630 {"collections.group.program.target", st_collections_group_programs_program_target}, /* dup */
631 {"collections.group.program.after", st_collections_group_programs_program_after}, /* dup */
632 {"collections.group.program.api", st_collections_group_programs_program_api}, /* dup */
633 {"collections.group.programs.program.name", st_collections_group_programs_program_name},
634 {"collections.group.programs.program.signal", st_collections_group_programs_program_signal},
635 {"collections.group.programs.program.source", st_collections_group_programs_program_source},
636 {"collections.group.programs.program.filter", st_collections_group_programs_program_filter}, /* dup */
637 {"collections.group.programs.program.in", st_collections_group_programs_program_in},
638 {"collections.group.programs.program.action", st_collections_group_programs_program_action},
639 {"collections.group.programs.program.transition", st_collections_group_programs_program_transition},
640 {"collections.group.programs.program.target", st_collections_group_programs_program_target},
641 {"collections.group.programs.program.after", st_collections_group_programs_program_after},
642 {"collections.group.programs.program.api", st_collections_group_programs_program_api},
643 {"collections.group.programs.image", st_images_image}, /* dup */
644 {"collections.group.programs.set.name", st_images_set_name},
645 {"collections.group.programs.set.image.image", st_images_set_image_image},
646 {"collections.group.programs.set.image.size", st_images_set_image_size},
647 {"collections.group.programs.images.image", st_images_image}, /* dup */
648 {"collections.group.programs.images.set.name", st_images_set_name},
649 {"collections.group.programs.images.set.image.image", st_images_set_image_image},
650 {"collections.group.programs.images.set.image.size", st_images_set_image_size},
651 {"collections.group.programs.font", st_fonts_font}, /* dup */
652 {"collections.group.programs.fonts.font", st_fonts_font} /* dup */
653};
654
655New_Object_Handler object_handlers[] =
656{
657 {"externals", NULL},
658 {"images", NULL},
659 {"images.set", ob_images_set},
660 {"images.set.image", ob_images_set_image},
661 {"fonts", NULL},
662 {"data", NULL},
663 {"styles", NULL},
664 {"styles.style", ob_styles_style},
665 {"color_classes", NULL},
666 {"color_classes.color_class", ob_color_class},
667 {"spectra", NULL},
668 {"collections", ob_collections},
669 {"collections.externals", NULL}, /* dup */
670 {"collections.set", ob_images_set}, /* dup */
671 {"collections.set.image", ob_images_set_image}, /* dup */
672 {"collections.images", NULL}, /* dup */
673 {"collections.images.set", ob_images_set}, /* dup */
674 {"collections.images.set.image", ob_images_set_image}, /* dup */
675 {"collections.fonts", NULL}, /* dup */
676 {"collections.styles", NULL}, /* dup */
677 {"collections.styles.style", ob_styles_style}, /* dup */
678 {"collections.color_classes", NULL}, /* dup */
679 {"collections.color_classes.color_class", ob_color_class}, /* dup */
680#ifdef ENABLE_MULTISENSE
681 {"collections.sounds", NULL},
682 {"collections.group.sounds", NULL}, /* dup */
683 {"collections.sounds.sample", NULL},
684 {"collections.group.sounds.sample", NULL}, /* dup */
685#endif
686 {"collections.group", ob_collections_group},
687 {"collections.group.data", NULL},
688 {"collections.group.script", ob_collections_group_script},
689 {"collections.group.lua_script", ob_collections_group_lua_script},
690 {"collections.group.externals", NULL}, /* dup */
691 {"collections.group.set", ob_images_set}, /* dup */
692 {"collections.group.set.image", ob_images_set_image}, /* dup */
693 {"collections.group.images", NULL}, /* dup */
694 {"collections.group.images.set", ob_images_set}, /* dup */
695 {"collections.group.images.set.image", ob_images_set_image}, /* dup */
696 {"collections.group.fonts", NULL}, /* dup */
697 {"collections.group.styles", NULL}, /* dup */
698 {"collections.group.styles.style", ob_styles_style}, /* dup */
699 {"collections.group.color_classes", NULL}, /* dup */
700 {"collections.group.color_classes.color_class", ob_color_class}, /* dup */
701 {"collections.group.parts", NULL},
702 {"collections.group.parts.set", ob_images_set}, /* dup */
703 {"collections.group.parts.set.image", ob_images_set_image}, /* dup */
704 {"collections.group.parts.images", NULL}, /* dup */
705 {"collections.group.parts.images.set", ob_images_set}, /* dup */
706 {"collections.group.parts.images.set.image", ob_images_set_image}, /* dup */
707 {"collections.group.parts.fonts", NULL}, /* dup */
708 {"collections.group.parts.styles", NULL}, /* dup */
709 {"collections.group.parts.styles.style", ob_styles_style}, /* dup */
710 {"collections.group.parts.color_classes", NULL}, /* dup */
711 {"collections.group.parts.color_classes.color_class", ob_color_class}, /* dup */
712 {"collections.group.parts.part", ob_collections_group_parts_part},
713 {"collections.group.parts.part.dragable", NULL},
714 {"collections.group.parts.part.set", ob_images_set}, /* dup */
715 {"collections.group.parts.part.set.image", ob_images_set_image}, /* dup */
716 {"collections.group.parts.part.images", NULL}, /* dup */
717 {"collections.group.parts.part.images.set", ob_images_set}, /* dup */
718 {"collections.group.parts.part.images.set.image", ob_images_set_image}, /* dup */
719 {"collections.group.parts.part.fonts", NULL}, /* dup */
720 {"collections.group.parts.part.styles", NULL}, /* dup */
721 {"collections.group.parts.part.styles.style", ob_styles_style}, /* dup */
722 {"collections.group.parts.part.color_classes", NULL}, /* dup */
723 {"collections.group.parts.part.color_classes.color_class", ob_color_class}, /* dup */
724 {"collections.group.parts.part.box", NULL},
725 {"collections.group.parts.part.box.items", NULL},
726 {"collections.group.parts.part.box.items.item", ob_collections_group_parts_part_box_items_item},
727 {"collections.group.parts.part.table", NULL},
728 {"collections.group.parts.part.table.items", NULL},
729 {"collections.group.parts.part.table.items.item", ob_collections_group_parts_part_box_items_item}, /* dup */
730 {"collections.group.parts.part.description", ob_collections_group_parts_part_description},
731 {"collections.group.parts.part.description.rel1", NULL},
732 {"collections.group.parts.part.description.rel2", NULL},
733 {"collections.group.parts.part.description.image", NULL}, /* dup */
734 {"collections.group.parts.part.description.image.set", ob_images_set}, /* dup */
735 {"collections.group.parts.part.description.image.set.image", ob_images_set_image}, /* dup */
736 {"collections.group.parts.part.description.image.images", NULL}, /* dup */
737 {"collections.group.parts.part.description.image.images.set", ob_images_set}, /* dup */
738 {"collections.group.parts.part.description.image.images.set.image", ob_images_set_image}, /* dup */
739 {"collections.group.parts.part.description.fill", NULL},
740 {"collections.group.parts.part.description.fill.origin", NULL},
741 {"collections.group.parts.part.description.fill.size", NULL},
742 {"collections.group.parts.part.description.text", NULL},
743 {"collections.group.parts.part.description.text.fonts", NULL}, /* dup */
744 {"collections.group.parts.part.description.images", NULL}, /* dup */
745 {"collections.group.parts.part.description.images.set", ob_images_set}, /* dup */
746 {"collections.group.parts.part.description.images.set.image", ob_images_set_image}, /* dup */
747 {"collections.group.parts.part.description.fonts", NULL}, /* dup */
748 {"collections.group.parts.part.description.styles", NULL}, /* dup */
749 {"collections.group.parts.part.description.styles.style", ob_styles_style}, /* dup */
750 {"collections.group.parts.part.description.box", NULL},
751 {"collections.group.parts.part.description.table", NULL},
752 {"collections.group.parts.part.description.map", NULL},
753 {"collections.group.parts.part.description.map.rotation", NULL},
754 {"collections.group.parts.part.description.perspective", NULL},
755 {"collections.group.parts.part.description.params", NULL},
756 {"collections.group.parts.part.description.color_classes", NULL}, /* dup */
757 {"collections.group.parts.part.description.color_classes.color_class", ob_color_class}, /* dup */
758 {"collections.group.parts.part.description.program", ob_collections_group_programs_program}, /* dup */
759 {"collections.group.parts.part.description.program.script", ob_collections_group_programs_program_script}, /* dup */
760 {"collections.group.parts.part.description.programs", NULL}, /* dup */
761 {"collections.group.parts.part.description.programs.set", ob_images_set}, /* dup */
762 {"collections.group.parts.part.description.programs.set.image", ob_images_set_image}, /* dup */
763 {"collections.group.parts.part.description.programs.images", NULL}, /* dup */
764 {"collections.group.parts.part.description.programs.images.set", ob_images_set},
765 {"collections.group.parts.part.description.programs.images.set.image", ob_images_set_image}, /* dup */
766 {"collections.group.parts.part.description.programs.fonts", NULL}, /* dup */
767 {"collections.group.parts.part.description.programs.program", ob_collections_group_programs_program}, /* dup */
768 {"collections.group.parts.part.description.programs.program.script", ob_collections_group_programs_program_script}, /* dup */
769 {"collections.group.parts.part.description.script", ob_collections_group_script}, /* dup */
770 {"collections.group.parts.part.program", ob_collections_group_programs_program}, /* dup */
771 {"collections.group.parts.part.program.script", ob_collections_group_programs_program_script}, /* dup */
772 {"collections.group.parts.part.programs", NULL}, /* dup */
773 {"collections.group.parts.part.programs.set", ob_images_set}, /* dup */
774 {"collections.group.parts.part.programs.set.image", ob_images_set_image}, /* dup */
775 {"collections.group.parts.part.programs.images", NULL}, /* dup */
776 {"collections.group.parts.part.programs.images.set", ob_images_set}, /* dup */
777 {"collections.group.parts.part.programs.images.set.image", ob_images_set_image}, /* dup */
778 {"collections.group.parts.part.programs.fonts", NULL}, /* dup */
779 {"collections.group.parts.part.programs.program", ob_collections_group_programs_program}, /* dup */
780 {"collections.group.parts.part.programs.program.script", ob_collections_group_programs_program_script}, /* dup */
781 {"collections.group.parts.part.script", ob_collections_group_script}, /* dup */
782 {"collections.group.parts.program", ob_collections_group_programs_program}, /* dup */
783 {"collections.group.parts.program.script", ob_collections_group_programs_program_script}, /* dup */
784 {"collections.group.parts.programs", NULL}, /* dup */
785 {"collections.group.parts.programs.set", ob_images_set}, /* dup */
786 {"collections.group.parts.programs.set.image", ob_images_set_image}, /* dup */
787 {"collections.group.parts.programs.images", NULL}, /* dup */
788 {"collections.group.parts.programs.images.set", ob_images_set}, /* dup */
789 {"collections.group.parts.programs.images.set.image", ob_images_set_image}, /* dup */
790 {"collections.group.parts.programs.fonts", NULL}, /* dup */
791 {"collections.group.parts.programs.program", ob_collections_group_programs_program}, /* dup */
792 {"collections.group.parts.programs.program.script", ob_collections_group_programs_program_script}, /* dup */
793 {"collections.group.parts.script", ob_collections_group_script}, /* dup */
794 {"collections.group.program", ob_collections_group_programs_program}, /* dup */
795 {"collections.group.program.script", ob_collections_group_programs_program_script}, /* dup */
796 {"collections.group.programs", NULL},
797 {"collections.group.programs.set", ob_images_set}, /* dup */
798 {"collections.group.programs.set.image", ob_images_set_image}, /* dup */
799 {"collections.group.programs.images", NULL}, /* dup */
800 {"collections.group.programs.images.set", ob_images_set}, /* dup */
801 {"collections.group.programs.images.set.image", ob_images_set_image}, /* dup */
802 {"collections.group.programs.fonts", NULL}, /* dup */
803 {"collections.group.programs.program", ob_collections_group_programs_program},
804 {"collections.group.programs.program.script", ob_collections_group_programs_program_script},
805 {"collections.group.programs.script", ob_collections_group_script} /* dup */
806};
807
808/*****/
809
810int
811object_handler_num(void)
812{
813 return sizeof(object_handlers) / sizeof (New_Object_Handler);
814}
815
816int
817statement_handler_num(void)
818{
819 return sizeof(statement_handlers) / sizeof (New_Object_Handler);
820}
821
822static void
823_edje_part_description_fill(Edje_Part_Description_Spec_Fill *fill)
824{
825 fill->smooth = 1;
826 fill->pos_rel_x = FROM_DOUBLE(0.0);
827 fill->pos_abs_x = 0;
828 fill->rel_x = FROM_DOUBLE(1.0);
829 fill->abs_x = 0;
830 fill->pos_rel_y = FROM_DOUBLE(0.0);
831 fill->pos_abs_y = 0;
832 fill->rel_y = FROM_DOUBLE(1.0);
833 fill->abs_y = 0;
834 fill->angle = 0;
835 fill->spread = 0;
836 fill->type = EDJE_FILL_TYPE_SCALE;
837}
838
839static Edje_Part_Description_Common *
840_edje_part_description_alloc(unsigned char type, const char *collection, const char *part)
841{
842 Edje_Part_Description_Common *result = NULL;
843
844 switch (type)
845 {
846 case EDJE_PART_TYPE_RECTANGLE:
847 case EDJE_PART_TYPE_SWALLOW:
848 case EDJE_PART_TYPE_GROUP:
849 result = mem_alloc(SZ(Edje_Part_Description_Common));
850 break;
851 case EDJE_PART_TYPE_TEXT:
852 case EDJE_PART_TYPE_TEXTBLOCK:
853 {
854 Edje_Part_Description_Text *ed;
855
856 ed = mem_alloc(SZ(Edje_Part_Description_Text));
857
858 ed->text.color3.r = 0;
859 ed->text.color3.g = 0;
860 ed->text.color3.b = 0;
861 ed->text.color3.a = 128;
862 ed->text.align.x = FROM_DOUBLE(0.5);
863 ed->text.align.y = FROM_DOUBLE(0.5);
864 ed->text.id_source = -1;
865 ed->text.id_text_source = -1;
866
867 result = &ed->common;
868 break;
869 }
870 case EDJE_PART_TYPE_IMAGE:
871 {
872 Edje_Part_Description_Image *ed;
873
874 ed = mem_alloc(SZ(Edje_Part_Description_Image));
875
876 ed->image.id = -1;
877
878 _edje_part_description_fill(&ed->image.fill);
879
880 result = &ed->common;
881 break;
882 }
883 case EDJE_PART_TYPE_PROXY:
884 {
885 Edje_Part_Description_Proxy *ed;
886
887 ed = mem_alloc(SZ(Edje_Part_Description_Proxy));
888
889 ed->proxy.id = -1;
890
891 _edje_part_description_fill(&ed->proxy.fill);
892
893 result = &ed->common;
894 break;
895 }
896 case EDJE_PART_TYPE_BOX:
897 {
898 Edje_Part_Description_Box *ed;
899
900 ed = mem_alloc(SZ(Edje_Part_Description_Box));
901
902 ed->box.layout = NULL;
903 ed->box.alt_layout = NULL;
904 ed->box.align.x = FROM_DOUBLE(0.5);
905 ed->box.align.y = FROM_DOUBLE(0.5);
906 ed->box.padding.x = 0;
907 ed->box.padding.y = 0;
908
909 result = &ed->common;
910 break;
911 }
912 case EDJE_PART_TYPE_TABLE:
913 {
914 Edje_Part_Description_Table *ed;
915
916 ed = mem_alloc(SZ(Edje_Part_Description_Table));
917
918 ed->table.homogeneous = EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE;
919 ed->table.align.x = FROM_DOUBLE(0.5);
920 ed->table.align.y = FROM_DOUBLE(0.5);
921 ed->table.padding.x = 0;
922 ed->table.padding.y = 0;
923
924 result = &ed->common;
925 break;
926 }
927 case EDJE_PART_TYPE_EXTERNAL:
928 {
929 Edje_Part_Description_External *ed;
930
931 ed = mem_alloc(SZ(Edje_Part_Description_External));
932
933 ed->external_params = NULL;
934
935 result = &ed->common;
936 break;
937 }
938 }
939
940 if (!result)
941 {
942 ERR("%s: Error. Unknown type %i of part %s in collection %s.", progname, type, part, collection);
943 exit(-1);
944 }
945
946 return result;
947}
948
949static void
950_edje_program_check(const char *name, Edje_Program *me, Edje_Program **pgrms, unsigned int count)
951{
952 Edje_Part_Collection *pc;
953 unsigned int i;
954 Edje_Program_Parser *epp;
955
956 pc = eina_list_data_get(eina_list_last(edje_collections));
957
958 for (i = 0; i < count; ++i)
959 if (pgrms[i]->name)
960 if (pgrms[i] != me && (!strcmp(name, pgrms[i]->name)))
961 {
962 epp = (Edje_Program_Parser *)pgrms[i];
963 if (!epp->can_override)
964 {
965 ERR("%s: Error. parse error %s:%i. There is already a program of the name %s\n",
966 progname, file_in, line - 1, name);
967 exit(-1);
968 }
969 else
970 {
971 _edje_program_remove(pc, me);
972 current_program = pgrms[i];
973 epp->can_override = EINA_FALSE;
974 return;
975 }
976 }
977}
978
979static void
980_edje_program_copy(Edje_Program *ep, Edje_Program *ep2)
981{
982 Edje_Part_Collection *pc;
983 Edje_Program_Target *et, *et2;
984 Edje_Program_After *pa, *pa2;
985 Edje_Program_Parser *epp;
986 Eina_List *l;
987 char *name;
988 char *copy;
989
990 pc = eina_list_data_get(eina_list_last(edje_collections));
991
992 #define STRDUP(x) x ? strdup(x) : NULL
993 ep->name = STRDUP(ep2->name);
994
995 _edje_program_remove(pc, current_program);
996 ep->signal = STRDUP(ep2->signal);
997 ep->source = STRDUP(ep2->source);
998 _edje_program_insert(pc, current_program);
999
1000 ep->filter.part = STRDUP(ep2->filter.part);
1001 ep->filter.state = STRDUP(ep2->filter.state);
1002 ep->in.from = ep2->in.from;
1003 ep->in.range = ep2->in.range;
1004 ep->action = ep2->action;
1005 ep->state = STRDUP(ep2->state);
1006 ep->state2 = STRDUP(ep2->state2);
1007 ep->value = ep2->value;
1008 ep->value2 = ep2->value2;
1009 ep->tween.mode = ep2->tween.mode;
1010 ep->tween.time = ep2->tween.time;
1011 ep->tween.v1 = ep2->tween.v1;
1012 ep->tween.v2 = ep2->tween.v2;
1013
1014 EINA_LIST_FOREACH(ep2->targets, l, et2)
1015 {
1016 name = (char*) (et2 + 1);
1017 et = mem_alloc(SZ(Edje_Program_Target) + strlen(name) + 1);
1018 ep->targets = eina_list_append(ep->targets, et);
1019 copy = (char*) (et + 1);
1020
1021 memcpy(copy, name, strlen(name) + 1);
1022
1023 if (ep2->action == EDJE_ACTION_TYPE_STATE_SET)
1024 data_queue_copied_part_lookup(pc, &(et2->id), &(et->id));
1025 else if (ep2->action == EDJE_ACTION_TYPE_ACTION_STOP)
1026 data_queue_copied_program_lookup(pc, &(et2->id), &(et->id));
1027 else if (ep2->action == EDJE_ACTION_TYPE_DRAG_VAL_SET)
1028 data_queue_copied_part_lookup(pc, &(et2->id), &(et->id));
1029 else if (ep2->action == EDJE_ACTION_TYPE_DRAG_VAL_STEP)
1030 data_queue_copied_part_lookup(pc, &(et2->id), &(et->id));
1031 else if (ep2->action == EDJE_ACTION_TYPE_DRAG_VAL_PAGE)
1032 data_queue_copied_part_lookup(pc, &(et2->id), &(et->id));
1033 else if (ep2->action == EDJE_ACTION_TYPE_FOCUS_SET)
1034
1035 data_queue_copied_part_lookup(pc, &(et2->id), &(et->id));
1036 else if (ep2->action == EDJE_ACTION_TYPE_FOCUS_OBJECT)
1037 data_queue_copied_part_lookup(pc, &(et2->id), &(et->id));
1038 else
1039 {
1040 ERR("%s: Error. parse error %s:%i. "
1041 "target may only be used after action",
1042 progname, file_in, line - 1);
1043 exit(-1);
1044 }
1045 }
1046
1047 EINA_LIST_FOREACH(ep2->after, l, pa2)
1048 {
1049 pa = mem_alloc(SZ(Edje_Program_After));
1050 ep->after = eina_list_append(ep->after, pa);
1051
1052 data_queue_copied_program_lookup(pc, &(pa2->id), &(pa->id));
1053 }
1054
1055 ep->api.name = STRDUP(ep2->api.name);
1056 ep->api.description = STRDUP(ep2->api.description);
1057 data_queue_copied_part_lookup(pc, &(ep2->param.src), &(ep->param.src));
1058 data_queue_copied_part_lookup(pc, &(ep2->param.dst), &(ep->param.dst));
1059
1060 epp = (Edje_Program_Parser *)ep;
1061 epp->can_override = EINA_TRUE;
1062
1063 #undef STRDUP
1064}
1065
1066/*****/
1067
1068/**
1069 @edcsection{toplevel,Top-Level blocks}
1070 */
1071
1072/**
1073 @page edcref
1074
1075 @block
1076 externals
1077 @context
1078 externals {
1079 external: "name";
1080 }
1081 @description
1082 The "externals" block is used to list each external module file that will be used in others
1083 programs.
1084 @endblock
1085
1086 @property
1087 external
1088 @parameters
1089 [external filename]
1090 @effect
1091 Used to add a file to the externals list.
1092 @endproperty
1093 */
1094static void
1095st_externals_external(void)
1096{
1097 External *ex;
1098
1099 check_arg_count(1);
1100
1101 if (!edje_file->external_dir)
1102 edje_file->external_dir = mem_alloc(SZ(Edje_External_Directory));
1103
1104 ex = mem_alloc(SZ(External));
1105 ex->name = parse_str(0);
1106 {
1107 Eina_List *l;
1108 External *lex;
1109
1110 EINA_LIST_FOREACH(externals, l, lex)
1111 {
1112 if (!strcmp(lex->name, ex->name))
1113 {
1114 free(ex->name);
1115 free(ex);
1116 return;
1117 }
1118 }
1119 }
1120 externals = eina_list_append(externals, ex);
1121
1122 if (edje_file->external_dir)
1123 {
1124 edje_file->external_dir->entries_count++;
1125 edje_file->external_dir->entries = realloc(edje_file->external_dir->entries,
1126 sizeof (Edje_External_Directory) * edje_file->external_dir->entries_count);
1127 memset(edje_file->external_dir->entries + edje_file->external_dir->entries_count - 1,
1128 0, sizeof (Edje_External_Directory));
1129 if (!edje_file->external_dir->entries)
1130 {
1131 ERR("%s: Error. not enough memory", progname);
1132 exit(-1);
1133 }
1134
1135 edje_file->external_dir->entries[edje_file->external_dir->entries_count - 1].entry = mem_strdup(ex->name);
1136 }
1137}
1138
1139/**
1140 @page edcref
1141
1142 @block
1143 images
1144 @context
1145 images {
1146 image: "filename1.ext" COMP;
1147 image: "filename2.ext" LOSSY 99;
1148 set {
1149 name: "image_name_used";
1150 image {
1151 image: "filename3.ext" LOSSY 90;
1152 size: 201 201 500 500;
1153 }
1154 image {
1155 image: "filename4.ext" COMP;
1156 size: 51 51 200 200;
1157 }
1158 image {
1159 image: "filename5.ext" COMP;
1160 size: 11 11 50 50;
1161 }
1162 image {
1163 image: "filename6.ext" RAW;
1164 size: 0 0 10 10;
1165 }
1166 }
1167 ..
1168 }
1169 @description
1170 The "images" block is used to list each image file that will be used in
1171 the theme along with its compression method (if any).
1172 Besides the document's root, additional "images" blocks can be
1173 included inside other blocks, normally "collections", "group" and
1174 "part", easing maintenance of the file list when the theme is split
1175 among multiple files.
1176 @endblock
1177
1178 @property
1179 image
1180 @parameters
1181 [image file] [compression method] (compression level)
1182 @effect
1183 Used to include each image file. The full path to the directory holding
1184 the images can be defined later with edje_cc's "-id" option.
1185 Compression methods:
1186 @li RAW: Uncompressed.
1187 @li COMP: Lossless compression.
1188 @li LOSSY [0-100]: Lossy comression with quality from 0 to 100.
1189 @li USER: Do not embed the file, refer to the external file instead.
1190 @endproperty
1191 */
1192static void
1193st_images_image(void)
1194{
1195 Edje_Image_Directory_Entry *img;
1196 const char *tmp;
1197 unsigned int i;
1198 int v;
1199
1200 if (!edje_file->image_dir)
1201 edje_file->image_dir = mem_alloc(SZ(Edje_Image_Directory));
1202
1203 tmp = parse_str(0);
1204
1205 for (i = 0; i < edje_file->image_dir->entries_count; ++i)
1206 if (!strcmp(edje_file->image_dir->entries[i].entry, tmp))
1207 {
1208 free((char*) tmp);
1209 return;
1210 }
1211
1212 edje_file->image_dir->entries_count++;
1213 edje_file->image_dir->entries = realloc(edje_file->image_dir->entries,
1214 sizeof (Edje_Image_Directory_Entry) * edje_file->image_dir->entries_count);
1215 memset(edje_file->image_dir->entries + edje_file->image_dir->entries_count - 1,
1216 0, sizeof (Edje_Image_Directory_Entry));
1217 if (!edje_file->image_dir->entries)
1218 {
1219 ERR("%s: Error. No enough memory.", progname);
1220 exit(-1);
1221 }
1222
1223 img = edje_file->image_dir->entries + edje_file->image_dir->entries_count - 1;
1224
1225 img->entry = tmp;
1226 img->id = edje_file->image_dir->entries_count - 1;
1227 v = parse_enum(1,
1228 "RAW", 0,
1229 "COMP", 1,
1230 "LOSSY", 2,
1231 "USER", 3,
1232 NULL);
1233 if (v == 0)
1234 {
1235 img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT;
1236 img->source_param = 0;
1237 }
1238 else if (v == 1)
1239 {
1240 img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT;
1241 img->source_param = 1;
1242 }
1243 else if (v == 2)
1244 {
1245 img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY;
1246 img->source_param = 0;
1247 }
1248 else if (v == 3)
1249 {
1250 img->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL;
1251 img->source_param = 0;
1252 }
1253 if (img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY)
1254 check_arg_count(2);
1255 else
1256 {
1257 img->source_param = parse_int_range(2, 0, 100);
1258 check_arg_count(3);
1259 }
1260}
1261
1262/**
1263 @page edcref
1264
1265 @block
1266 set
1267 @context
1268 set {
1269 name: "image_name_used";
1270 image {
1271 image: "filename3.ext" LOSSY 90;
1272 size: 201 201 500 500;
1273 }
1274 image {
1275 image: "filename4.ext" COMP;
1276 size: 51 51 200 200;
1277 }
1278 image {
1279 image: "filename5.ext" COMP;
1280 size: 11 11 50 50;
1281 }
1282 image {
1283 image: "filename6.ext" RAW;
1284 size: 0 0 10 10;
1285 }
1286 }
1287 @description
1288 The "set" block is used to define an image with different content depending on their size.
1289 Besides the document's root, additional "set" blocks can be
1290 included inside other blocks, normally "collections", "group" and
1291 "part", easing maintenance of the file list when the theme is split
1292 among multiple files.
1293 @endblock
1294 */
1295static void
1296ob_images_set(void)
1297{
1298 if (!edje_file->image_dir)
1299 edje_file->image_dir = mem_alloc(SZ(Edje_Image_Directory));
1300
1301 edje_file->image_dir->sets_count++;
1302 edje_file->image_dir->sets = realloc(edje_file->image_dir->sets,
1303 sizeof (Edje_Image_Directory_Set) * edje_file->image_dir->sets_count);
1304 memset(edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1,
1305 0, sizeof (Edje_Image_Directory_Set));
1306 if (!edje_file->image_dir->sets)
1307 {
1308 ERR("%s: Error. Not enough memory.", progname);
1309 exit(-1);
1310 }
1311 edje_file->image_dir->sets[edje_file->image_dir->sets_count - 1].id = edje_file->image_dir->sets_count - 1;
1312}
1313
1314/**
1315 @page edcref
1316
1317 @property
1318 name
1319 @parameters
1320 [image name]
1321 @effect
1322 Define the name that refer to this image description.
1323 @endproperty
1324*/
1325static void
1326st_images_set_name(void)
1327{
1328 check_arg_count(1);
1329
1330 edje_file->image_dir->sets[edje_file->image_dir->sets_count - 1].name = parse_str(0);
1331}
1332
1333static void
1334ob_images_set_image(void)
1335{
1336 Edje_Image_Directory_Set_Entry *entry;
1337 Edje_Image_Directory_Set *set;
1338
1339 set = edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1;
1340
1341 entry = mem_alloc(SZ(Edje_Image_Directory_Set_Entry));
1342
1343 set->entries = eina_list_append(set->entries, entry);
1344}
1345
1346static void
1347st_images_set_image_image(void)
1348{
1349 Edje_Image_Directory_Set_Entry *entry;
1350 Edje_Image_Directory_Set *set;
1351 unsigned int i;
1352
1353 set = edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1;
1354 entry = eina_list_data_get(eina_list_last(set->entries));
1355
1356 /* Add the image to the global pool with the same syntax. */
1357 st_images_image();
1358
1359 entry->name = parse_str(0);
1360
1361 for (i = 0; i < edje_file->image_dir->entries_count; ++i)
1362 if (!strcmp(edje_file->image_dir->entries[i].entry, entry->name))
1363 {
1364 entry->id = i;
1365 return;
1366 }
1367}
1368
1369/**
1370 @page edcref
1371
1372 @property
1373 size
1374 @parameters
1375 [minw minh maxw mawh]
1376 @effect
1377 Define the minimal and maximal size that will select the specified image.
1378 @endproperty
1379*/
1380static void
1381st_images_set_image_size(void)
1382{
1383 Edje_Image_Directory_Set_Entry *entry;
1384 Edje_Image_Directory_Set *set;
1385
1386 set = edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1;
1387 entry = eina_list_data_get(eina_list_last(set->entries));
1388
1389 entry->size.min.w = parse_int(0);
1390 entry->size.min.h = parse_int(1);
1391 entry->size.max.w = parse_int(2);
1392 entry->size.max.h = parse_int(3);
1393
1394 if (entry->size.min.w > entry->size.max.w
1395 || entry->size.min.h > entry->size.max.h)
1396 {
1397 ERR("%s: Error. parse error %s:%i. Image min and max size are not in the right order ([%i, %i] < [%i, %i])",
1398 progname, file_in, line - 1,
1399 entry->size.min.w, entry->size.min.h,
1400 entry->size.max.w, entry->size.max.h);
1401 exit(-1);
1402 }
1403}
1404
1405/**
1406 @page edcref
1407
1408 @block
1409 fonts
1410 @context
1411 fonts {
1412 font: "filename1.ext" "fontname";
1413 font: "filename2.ext" "otherfontname";
1414 ..
1415 }
1416 @description
1417 The "fonts" block is used to list each font file with an alias used later
1418 in the theme. As with the "images" block, additional "fonts" blocks can
1419 be included inside other blocks.
1420 @endblock
1421
1422 @property
1423 font
1424 @parameters
1425 [font filename] [font alias]
1426 @effect
1427 Defines each font "file" and "alias", the full path to the directory
1428 holding the font files can be defined with edje_cc's "-fd" option.
1429 @endproperty
1430 */
1431static void
1432st_fonts_font(void)
1433{
1434 Font *fn;
1435
1436 check_arg_count(2);
1437
1438 if (!edje_file->fonts)
1439 edje_file->fonts = eina_hash_string_small_new(free);
1440
1441 fn = mem_alloc(SZ(Font));
1442 fn->file = parse_str(0);
1443 fn->name = parse_str(1);
1444
1445 if (eina_hash_find(edje_file->fonts, fn->name))
1446 {
1447 free(fn->file);
1448 free(fn->name);
1449 free(fn);
1450 return;
1451 }
1452
1453 eina_hash_direct_add(edje_file->fonts, fn->name, fn);
1454}
1455
1456/**
1457 @page edcref
1458 @block
1459 data
1460 @context
1461 data {
1462 item: "key" "value";
1463 file: "otherkey" "filename.ext";
1464 ..
1465 }
1466 @description
1467 The "data" block is used to pass arbitrary parameters from the theme to
1468 the application. Unlike the "images" and "fonts" blocks, additional
1469 "data" blocks can only be included inside the "group" block.
1470 @endblock
1471
1472 @property
1473 item
1474 @parameters
1475 [parameter name] [parameter value]
1476 @effect
1477 Defines a new parameter, the value will be the string specified next to
1478 it.
1479 @endproperty
1480 */
1481static void
1482st_data_item(void)
1483{
1484 Edje_String *es;
1485 char *key;
1486
1487 check_arg_count(2);
1488
1489 key = parse_str(0);
1490
1491 es = mem_alloc(SZ(Edje_String));
1492 es->str = parse_str(1);
1493
1494 if (!edje_file->data)
1495 edje_file->data = eina_hash_string_small_new(free);
1496
1497 /* FIXME: check if data already exist */
1498 eina_hash_direct_add(edje_file->data, key, es);
1499}
1500
1501/**
1502 @page edcref
1503 @property
1504 file
1505 @parameters
1506 [parameter name] [parameter filename]
1507 @effect
1508 Defines a new parameter , the value will be the contents of the
1509 specified file formated as a single string of text. This property only
1510 works with plain text files.
1511 @endproperty
1512 */
1513static void
1514st_data_file(void)
1515{
1516 const char *data;
1517 const char *over;
1518 Edje_String *es;
1519 char *filename;
1520 char *value;
1521 char *key;
1522 int fd;
1523 int i;
1524 struct stat buf;
1525
1526 check_arg_count(2);
1527
1528 key = parse_str(0);
1529
1530 es = mem_alloc(SZ(Edje_String));
1531 filename = parse_str(1);
1532
1533 fd = open(filename, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR);
1534 if (fd < 0)
1535 {
1536 ERR("%s: Error. %s:%i when opening file \"%s\": \"%s\"",
1537 progname, file_in, line, filename, strerror(errno));
1538 exit(-1);
1539 }
1540
1541 if (fstat(fd, &buf))
1542 {
1543 ERR("%s: Error. %s:%i when stating file \"%s\": \"%s\"",
1544 progname, file_in, line, filename, strerror(errno));
1545 exit(-1);
1546 }
1547
1548 data = mmap(NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0);
1549 if (data == MAP_FAILED)
1550 {
1551 ERR("%s: Error. %s:%i when mapping file \"%s\": \"%s\"",
1552 progname, file_in, line, filename, strerror(errno));
1553 exit(-1);
1554 }
1555
1556 over = data;
1557 for (i = 0; i < buf.st_size; ++i, ++over)
1558 if (*over == '\0')
1559 {
1560 ERR("%s: Error. %s:%i file \"%s\" is a binary file.",
1561 progname, file_in, line, filename);
1562 exit(-1);
1563 }
1564
1565 value = malloc(sizeof (char) * buf.st_size + 1);
1566 snprintf(value, buf.st_size + 1, "%s", data);
1567
1568 munmap((void*)data, buf.st_size);
1569 close(fd);
1570
1571 es->str = value;
1572
1573 eina_hash_direct_add(edje_file->data, key, es);
1574
1575 free(filename);
1576}
1577
1578/**
1579 @page edcref
1580 @block
1581 color_classes
1582 @context
1583 color_classes {
1584 color_class {
1585 name: "colorclassname";
1586 color: [0-255] [0-255] [0-255] [0-255];
1587 color2: [0-255] [0-255] [0-255] [0-255];
1588 color3: [0-255] [0-255] [0-255] [0-255]
1589 }
1590 ..
1591 }
1592 @description
1593 The "color_classes" block contains a list of one or more "color_class"
1594 blocks. Each "color_class" allows the designer to name an arbitrary
1595 group of colors to be used in the theme, the application can use that
1596 name to alter the color values at runtime.
1597 @endblock
1598*/
1599static void
1600ob_color_class(void)
1601{
1602 Edje_Color_Class *cc;
1603
1604 cc = mem_alloc(SZ(Edje_Color_Class));
1605 edje_file->color_classes = eina_list_append(edje_file->color_classes, cc);
1606
1607 cc->r = 0;
1608 cc->g = 0;
1609 cc->b = 0;
1610 cc->a = 0;
1611 cc->r2 = 0;
1612 cc->g2 = 0;
1613 cc->b2 = 0;
1614 cc->a2 = 0;
1615 cc->r3 = 0;
1616 cc->g3 = 0;
1617 cc->b3 = 0;
1618 cc->a3 = 0;
1619}
1620
1621/**
1622 @page edcref
1623
1624 @property
1625 name
1626 @parameters
1627 [color class name]
1628 @effect
1629 Sets the name for the color class, used as reference by both the theme
1630 and the application.
1631 @endproperty
1632*/
1633static void
1634st_color_class_name(void)
1635{
1636 Edje_Color_Class *cc, *tcc;
1637 Eina_List *l;
1638
1639 cc = eina_list_data_get(eina_list_last(edje_file->color_classes));
1640 cc->name = parse_str(0);
1641 EINA_LIST_FOREACH(edje_file->color_classes, l, tcc)
1642 {
1643 if ((cc != tcc) && (!strcmp(cc->name, tcc->name)))
1644 {
1645 fprintf(stderr, "%s: Error. parse error %s:%i. There is already a color class named \"%s\"\n",
1646 progname, file_in, line - 1, cc->name);
1647 exit(-1);
1648 }
1649 }
1650}
1651
1652/**
1653 @page edcref
1654 @property
1655 color
1656 @parameters
1657 [red] [green] [blue] [alpha]
1658 @effect
1659 The main color.
1660 @endproperty
1661*/
1662static void
1663st_color_class_color(void)
1664{
1665 Edje_Color_Class *cc;
1666
1667 check_arg_count(4);
1668
1669 cc = eina_list_data_get(eina_list_last(edje_file->color_classes));
1670 cc->r = parse_int_range(0, 0, 255);
1671 cc->g = parse_int_range(1, 0, 255);
1672 cc->b = parse_int_range(2, 0, 255);
1673 cc->a = parse_int_range(3, 0, 255);
1674}
1675
1676/**
1677 @page edcref
1678 @property
1679 color2
1680 @parameters
1681 [red] [green] [blue] [alpha]
1682 @effect
1683 Used as shadow in text and textblock parts.
1684 @endproperty
1685*/
1686static void
1687st_color_class_color2(void)
1688{
1689 Edje_Color_Class *cc;
1690
1691 check_arg_count(4);
1692
1693 cc = eina_list_data_get(eina_list_last(edje_file->color_classes));
1694 cc->r2 = parse_int_range(0, 0, 255);
1695 cc->g2 = parse_int_range(1, 0, 255);
1696 cc->b2 = parse_int_range(2, 0, 255);
1697 cc->a2 = parse_int_range(3, 0, 255);
1698}
1699
1700/**
1701 @page edcref
1702 @property
1703 color3
1704 @parameters
1705 [red] [green] [blue] [alpha]
1706 @effect
1707 Used as outline in text and textblock parts.
1708 @endproperty
1709*/
1710static void
1711st_color_class_color3(void)
1712{
1713 Edje_Color_Class *cc;
1714
1715 check_arg_count(4);
1716
1717 cc = eina_list_data_get(eina_list_last(edje_file->color_classes));
1718 cc->r3 = parse_int_range(0, 0, 255);
1719 cc->g3 = parse_int_range(1, 0, 255);
1720 cc->b3 = parse_int_range(2, 0, 255);
1721 cc->a3 = parse_int_range(3, 0, 255);
1722}
1723
1724/**
1725 @page edcref
1726 @block
1727 styles
1728 @context
1729 styles {
1730 style {
1731 name: "stylename";
1732 base: "..default style properties..";
1733
1734 tag: "tagname" "..style properties..";
1735 ..
1736 }
1737 ..
1738 }
1739 @description
1740 The "styles" block contains a list of one or more "style" blocks. A
1741 "style" block is used to create style \<tags\> for advanced TEXTBLOCK
1742 formatting.
1743 @endblock
1744*/
1745static void
1746ob_styles_style(void)
1747{
1748 Edje_Style *stl;
1749
1750 stl = mem_alloc(SZ(Edje_Style));
1751 edje_file->styles = eina_list_append(edje_file->styles, stl);
1752}
1753
1754/**
1755 @page edcref
1756 @property
1757 name
1758 @parameters
1759 [style name]
1760 @effect
1761 The name of the style to be used as reference later in the theme.
1762 @endproperty
1763*/
1764static void
1765st_styles_style_name(void)
1766{
1767 Edje_Style *stl, *tstl;
1768 Eina_List *l;
1769
1770 stl = eina_list_data_get(eina_list_last(edje_file->styles));
1771 stl->name = parse_str(0);
1772 EINA_LIST_FOREACH(edje_file->styles, l, tstl)
1773 {
1774 if (stl->name && tstl->name && (stl != tstl) && (!strcmp(stl->name, tstl->name)))
1775 {
1776 ERR("%s: Error. parse error %s:%i. There is already a style named \"%s\"",
1777 progname, file_in, line - 1, stl->name);
1778 exit(-1);
1779 }
1780 }
1781}
1782
1783/**
1784 @page edcref
1785 @property
1786 base
1787 @parameters
1788 [style properties string]
1789 @effect
1790 The default style properties that will be applied to the complete
1791 text.
1792 @endproperty
1793*/
1794static void
1795st_styles_style_base(void)
1796{
1797 Edje_Style *stl;
1798 Edje_Style_Tag *tag;
1799
1800 stl = eina_list_data_get(eina_list_last(edje_file->styles));
1801 if (stl->tags)
1802 {
1803 ERR("%s: Error. parse error %s:%i. There is already a basic format for the style",
1804 progname, file_in, line - 1);
1805 exit(-1);
1806 }
1807 tag = mem_alloc(SZ(Edje_Style_Tag));
1808 tag->key = mem_strdup("DEFAULT");
1809 tag->value = parse_str(0);
1810 stl->tags = eina_list_append(stl->tags, tag);
1811}
1812
1813/**
1814 @page edcref
1815 @property
1816 tag
1817 @parameters
1818 [tag name] [style properties string]
1819 @effect
1820 Style to be applied only to text between style \<tags\>..\</tags\>.
1821 When creating "paired" tags, like \<bold\>\</bold\>, A '+' should be added at the start of the style properties of the first part (\<bold\>).
1822 If the second part (\</bold\>) is also defined, a '-' should be prepended to it's style properties.
1823 This only applies to paired tags; Single tags, like \<tab\>, must not include a starting '+'.
1824 @endproperty
1825*/
1826static void
1827st_styles_style_tag(void)
1828{
1829 Edje_Style *stl;
1830 Edje_Style_Tag *tag;
1831
1832 stl = eina_list_data_get(eina_list_last(edje_file->styles));
1833 tag = mem_alloc(SZ(Edje_Style_Tag));
1834 tag->key = parse_str(0);
1835 tag->value = parse_str(1);
1836 stl->tags = eina_list_append(stl->tags, tag);
1837}
1838
1839#ifdef ENABLE_MULTISENSE
1840/* add to below doc
1841sounds { }
1842 */
1843#endif
1844
1845/**
1846 @page edcref
1847 @block
1848 collections
1849 @context
1850 collections {
1851 ..
1852 group { }
1853 group { }
1854 ..
1855 }
1856 @description
1857 The "collections" block is used to list the groups that compose the
1858 theme. Additional "collections" blocks do not prevent overriding group
1859 names. The "sounds" block comprises of all sound definitions.
1860 @endblock
1861*/
1862static void
1863ob_collections(void)
1864{
1865 if (!edje_file->collection)
1866 edje_file->collection = eina_hash_string_small_new(NULL);
1867}
1868
1869#ifdef ENABLE_MULTISENSE
1870/* * delete space before *
1871 @page edcref
1872 @block
1873 sounds
1874 @context
1875 sounds {
1876 sample {
1877 name: "sound_file1" COMP;
1878 source: "sound_file1.wav";
1879 }
1880 sample {
1881 name: "sound_file2" LOSSY 0.4;
1882 source: "sound_file2.wav";
1883 }
1884 tone: "tone-1" 2300;
1885 }
1886
1887 @description
1888 The "sounds" block contains a list of one or more sound sample and tones items.
1889 @endblock
1890 @block
1891 sample
1892 @context
1893 sample {
1894 name: "sound_file1" RAW;
1895 source: "sound_file1.wav";
1896 }
1897 sample {
1898 name: "sound_file2" LOSSY 0.5;
1899 source: "sound_file2.wav";
1900 }
1901 sample {
1902 name: "sound_file3" COMP;
1903 source: "sound_file3.wav";
1904 }
1905 sample {
1906 name: "sound_file4" AS-IS;
1907 source: "sound_file1.wav";
1908 }
1909 @description
1910 The sample block defines the sound sample.
1911 @endblock
1912 @property
1913 name
1914 @parameters
1915 [sample name] [compression type] [if lossy, then quality]
1916 @effect
1917 Used to include each sound file. The full path to the directory holding
1918 the sounds can be defined later with edje_cc's "-sd" option.
1919 @li RAW: Uncompressed.
1920 @li COMP: Lossless compression.
1921 @li LOSSY [-0.1 - 1.0]: Lossy comression with quality from 0 to 1.0.
1922 @li AS_IS: Check for re-encoding, no compression/encoding, just write the file information as it is.
1923 @endproperty
1924 @since 1.1.0
1925 */
1926static void
1927st_collections_group_sound_sample_name(void)
1928{
1929 Edje_Sound_Sample *sample;
1930 const char *tmp;
1931 unsigned int i;
1932
1933 if (!edje_file->sound_dir)
1934 edje_file->sound_dir = mem_alloc(SZ(Edje_Sound_Directory));
1935
1936 tmp = parse_str(0);
1937
1938 for (i = 0; i < edje_file->sound_dir->samples_count; i++)
1939 {
1940 if (!strcmp(edje_file->sound_dir->samples[i].name, tmp))
1941 {
1942 free((char *)tmp);
1943 return;
1944 }
1945 }
1946
1947 edje_file->sound_dir->samples_count++;
1948 edje_file->sound_dir->samples =
1949 realloc(edje_file->sound_dir->samples,
1950 sizeof(Edje_Sound_Sample) *
1951 edje_file->sound_dir->samples_count);
1952
1953 if (!edje_file->sound_dir->samples)
1954 {
1955 ERR("%s: Error. No enough memory.", progname);
1956 exit(-1);
1957 }
1958
1959 sample =
1960 edje_file->sound_dir->samples +
1961 edje_file->sound_dir->samples_count - 1;
1962 memset(sample, 0, sizeof (Edje_Sound_Sample));
1963
1964 sample->name = tmp;
1965 sample->id = edje_file->sound_dir->samples_count - 1;
1966 sample->compression = parse_enum(1,
1967 "RAW", EDJE_SOUND_SOURCE_TYPE_INLINE_RAW,
1968 "COMP", EDJE_SOUND_SOURCE_TYPE_INLINE_COMP,
1969 "LOSSY", EDJE_SOUND_SOURCE_TYPE_INLINE_LOSSY,
1970 "AS_IS", EDJE_SOUND_SOURCE_TYPE_INLINE_AS_IS,
1971 NULL);
1972
1973 if (sample->compression == EDJE_SOUND_SOURCE_TYPE_INLINE_LOSSY)
1974 {
1975 sample->quality = parse_float_range(2, 45.0, 1000.0);
1976 check_arg_count(3);
1977 }
1978 else
1979 check_arg_count(2);
1980
1981}
1982
1983/* * delete space before *
1984 @page edcref
1985 @property
1986 source
1987 @parameters
1988 [sound file name]
1989 @effect
1990 The Sound source file name (Source can be mono/stereo WAV file.
1991 Only files with 44.1 KHz sample rate supported now)
1992 @endproperty
1993 @since 1.1.0
1994 */
1995static void
1996st_collections_group_sound_sample_source(void)
1997{
1998 Edje_Sound_Sample *sample;
1999
2000 if (!edje_file->sound_dir->samples)
2001 {
2002 ERR("%s: Error. Invalid sound sample source definition.", progname);
2003 exit(-1);
2004 }
2005
2006 sample =
2007 edje_file->sound_dir->samples +
2008 edje_file->sound_dir->samples_count - 1;
2009
2010 if (!sample)
2011 {
2012 ERR("%s: Error. Invalid sound sample source definition.", progname);
2013 exit(-1);
2014 }
2015 sample->snd_src = parse_str(0);
2016 check_arg_count(1);
2017}
2018
2019/* * delete space before *
2020 @page edcref
2021 @property
2022 tone
2023 @parameters
2024 [tone name] [frequency]
2025 @effect
2026 sound of specific frequency
2027 @endproperty
2028 @since 1.1.0
2029 */
2030static void
2031st_collections_group_sound_tone(void)
2032{
2033 Edje_Sound_Tone *tone;
2034 const char *tmp;
2035 unsigned int i;
2036 int value;
2037
2038 check_arg_count(2);
2039
2040 if (!edje_file->sound_dir)
2041 edje_file->sound_dir = mem_alloc(SZ(Edje_Sound_Directory));
2042
2043 tmp = parse_str(0);
2044 /* Audible range 20 to 20KHz */
2045 value = parse_int_range(1, 20, 20000);
2046
2047 /* Check for Tone duplication */
2048 for (i = 0; i < edje_file->sound_dir->tones_count; i++)
2049 {
2050 if (!strcmp(edje_file->sound_dir->tones[i].name, tmp))
2051 {
2052 ERR("%s: Error. Tone name: %s already exist.", progname, tmp);
2053 free((char *)tmp);
2054 exit(-1);
2055 }
2056 if (edje_file->sound_dir->tones[i].value == value)
2057 {
2058 ERR("%s: Error. Tone name %s with same frequency %d exist.",
2059 progname, edje_file->sound_dir->tones[i].name, value);
2060 exit(-1);
2061 }
2062 }
2063 edje_file->sound_dir->tones_count++;
2064 edje_file->sound_dir->tones =
2065 realloc(edje_file->sound_dir->tones,
2066 sizeof (Edje_Sound_Tone) *
2067 edje_file->sound_dir->tones_count);
2068
2069 if (!edje_file->sound_dir->tones)
2070 {
2071 ERR("%s: Error. No enough memory.", progname);
2072 exit(-1);
2073 }
2074
2075 tone = edje_file->sound_dir->tones + edje_file->sound_dir->tones_count - 1;
2076 memset(tone, 0, sizeof (Edje_Sound_Tone));
2077
2078 tone->name = tmp;
2079 tone->value = value;
2080 tone->id = edje_file->sound_dir->tones_count - 1;
2081}
2082#endif
2083
2084/**
2085 @edcsection{group,Group sub blocks}
2086 */
2087
2088/**
2089 @page edcref
2090 @block
2091 group
2092 @context
2093 collections {
2094 ..
2095 group {
2096 name: "nameusedbytheapplication";
2097 alias: "anothername";
2098 min: width height;
2099 max: width height;
2100
2101 data { }
2102 script { }
2103 parts { }
2104 programs { }
2105 }
2106 ..
2107 }
2108 @description
2109 A "group" block contains the list of parts and programs that compose a
2110 given Edje Object.
2111 @endblock
2112*/
2113static void
2114ob_collections_group(void)
2115{
2116 Edje_Part_Collection *pc;
2117 Code *cd;
2118
2119 if (current_de && !current_de->entry)
2120 {
2121 ERR("%p: Error. A collection without a name was detected, that's not allowed.", progname);
2122 exit(-1);
2123 }
2124
2125 current_de = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry));
2126 current_de->id = eina_list_count(edje_collections);
2127
2128 pc = mem_alloc(SZ(Edje_Part_Collection));
2129 edje_collections = eina_list_append(edje_collections, pc);
2130 pc->id = current_de->id;
2131
2132 cd = mem_alloc(SZ(Code));
2133 codes = eina_list_append(codes, cd);
2134}
2135
2136/**
2137 @page edcref
2138 @property
2139 name
2140 @parameters
2141 [group name]
2142 @effect
2143 The name that will be used by the application to load the resulting
2144 Edje object and to identify the group to swallow in a GROUP part. If a
2145 group with the same name exists already it will be completely overriden
2146 by the new group.
2147 @endproperty
2148*/
2149static void
2150st_collections_group_name(void)
2151{
2152 Edje_Part_Collection_Directory_Entry *older;
2153 Edje_Part_Collection *current_pc;
2154
2155 check_arg_count(1);
2156
2157 current_pc = eina_list_data_get(eina_list_last(edje_collections));
2158
2159 current_de->entry = parse_str(0);
2160 current_pc->part = current_de->entry;
2161
2162 older = eina_hash_find(edje_file->collection, current_de->entry);
2163
2164 if (older)
2165 {
2166 Edje_Part_Collection *pc;
2167 Eina_List *l;
2168 Code *cd;
2169 int i = 0;
2170
2171 pc = eina_list_nth(edje_collections, older->id);
2172 cd = eina_list_nth(codes, older->id);
2173
2174 eina_hash_del(edje_file->collection, current_de->entry, older);
2175 edje_collections = eina_list_remove(edje_collections, pc);
2176 codes = eina_list_remove(codes, cd);
2177
2178 EINA_LIST_FOREACH(edje_collections, l, pc)
2179 {
2180 older = eina_hash_find(edje_file->collection, pc->part);
2181
2182 pc->id = i++;
2183 if (older) older->id = pc->id;
2184 }
2185 }
2186
2187 eina_hash_direct_add(edje_file->collection, current_de->entry, current_de);
2188}
2189
2190typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data;
2191struct _Edje_List_Foreach_Data
2192{
2193 Eina_List *list;
2194};
2195
2196static Eina_Bool
2197_edje_data_item_list_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata)
2198{
2199 Edje_List_Foreach_Data *fd;
2200
2201 fd = fdata;
2202 fd->list = eina_list_append(fd->list, strdup(key));
2203
2204 return EINA_TRUE;
2205}
2206
2207/**
2208 @page edcref
2209 @property
2210 inherit
2211 @parameters
2212 [parent group name]
2213 @effect
2214 Parent group name for inheritance.
2215 Group "inherit" is used to inherit any predefined group and change
2216 some property which belongs to "part", "description", "items" or "program".
2217 The child group has the same property as parent group. If you specify the
2218 type again in an inherited part, it will cause an error (unless you plan
2219 to fix that).
2220 @endproperty
2221 @since 1.1.0
2222*/
2223static void
2224st_collections_group_inherit(void)
2225{
2226 Edje_Part_Collection *pc, *pc2;
2227 Edje_Part *ep, *ep2;
2228 Edje_Part_Parser *epp, *epp2;
2229 Edje_Pack_Element *item, *item2;
2230 Edje_Pack_Element_Parser *pitem;
2231 Edje_Part_Description_Common *ed, *ed2;
2232 Edje_List_Foreach_Data fdata;
2233 Edje_String *es;
2234 Eina_List *l;
2235 char *parent_name;
2236 unsigned int i, j;
2237
2238 check_arg_count(1);
2239
2240 pc = eina_list_data_get(eina_list_last(edje_collections));
2241
2242 parent_name = parse_str(0);
2243
2244 EINA_LIST_FOREACH(edje_collections, l, pc2)
2245 {
2246 if (!strcmp(parent_name, pc2->part))
2247 break;
2248 }
2249 if (!pc2)
2250 {
2251 ERR("%s: Error. parse error %s:%i. There isn't a group with the name %s",
2252 progname, file_in, line - 1, parent_name);
2253 exit(-1);
2254 }
2255
2256 if (pc2->data)
2257 {
2258 char *key;
2259
2260 memset(&fdata, 0, sizeof(Edje_List_Foreach_Data));
2261 eina_hash_foreach(pc2->data,
2262 _edje_data_item_list_foreach, &fdata);
2263
2264 if (!pc->data)
2265 pc->data = eina_hash_string_small_new(free);
2266
2267
2268 EINA_LIST_FREE(fdata.list, key)
2269 {
2270 es = mem_alloc(SZ(Edje_String));
2271 es = (Edje_String *)eina_hash_find(pc2->data, key);
2272 eina_hash_direct_add(pc->data, key, es);
2273 }
2274 }
2275
2276 pc->prop.min.w = pc2->prop.min.w;
2277 pc->prop.min.h = pc2->prop.min.h;
2278 pc->prop.orientation = pc2->prop.orientation;
2279
2280 pc->lua_script_only = pc2->lua_script_only;
2281
2282 #define STRDUP(x) x ? strdup(x) : NULL
2283 for (i = 0 ; i < pc2->parts_count ; i++)
2284 {
2285 // copy the part
2286 ob_collections_group_parts_part();
2287 ep = pc->parts[i];
2288 ep2 = pc2->parts[i];
2289 ep->name = STRDUP(ep2->name);
2290 ep->source = STRDUP(ep2->source);
2291 ep->source2 = STRDUP(ep2->source2);
2292 ep->source3 = STRDUP(ep2->source3);
2293 ep->source4 = STRDUP(ep2->source4);
2294 ep->source5 = STRDUP(ep2->source5);
2295 ep->source6 = STRDUP(ep2->source6);
2296
2297 data_queue_copied_part_lookup(pc, &(ep2->clip_to_id), &(ep->clip_to_id));
2298
2299 ep->type = ep2->type;
2300 ep->mouse_events = ep2->mouse_events;
2301 ep->repeat_events = ep2->repeat_events;
2302 ep->ignore_flags = ep2->ignore_flags;
2303 ep->scale = ep2->scale;
2304 ep->pointer_mode = ep2->pointer_mode;
2305 ep->precise_is_inside = ep2->precise_is_inside;
2306 ep->use_alternate_font_metrics = ep2->use_alternate_font_metrics;
2307 ep->effect = ep2->effect;
2308 ep->entry_mode = ep2->entry_mode;
2309 ep->select_mode = ep2->select_mode;
2310 ep->cursor_mode = ep2->cursor_mode;
2311 ep->multiline = ep2->multiline;
2312 ep->dragable.x = ep2->dragable.x;
2313 ep->dragable.step_x = ep2->dragable.step_x;
2314 ep->dragable.count_x = ep2->dragable.count_x;
2315 ep->dragable.y = ep2->dragable.y;
2316 ep->dragable.step_y = ep2->dragable.step_y;
2317 ep->dragable.count_y = ep2->dragable.count_y;
2318
2319 data_queue_copied_part_lookup(pc, &(ep2->dragable.confine_id), &(ep->dragable.confine_id));
2320 data_queue_copied_part_lookup(pc, &(ep2->dragable.event_id), &(ep->dragable.event_id));
2321
2322 epp = (Edje_Part_Parser *)ep;
2323 epp2 = (Edje_Part_Parser *)ep2;
2324 epp->reorder.insert_before = STRDUP(epp2->reorder.insert_before);
2325 epp->reorder.insert_after = STRDUP(epp2->reorder.insert_after);
2326 epp->can_override = EINA_TRUE;
2327
2328 for (j = 0 ; j < ep2->items_count ; j++)
2329 {
2330 ob_collections_group_parts_part_box_items_item();
2331 item = ep->items[j];
2332 item2 = ep2->items[j];
2333 item->type = item2->type;
2334 item->name = STRDUP(item2->name);
2335 item->source = STRDUP(item2->source);
2336 item->min.w = item2->min.w;
2337 item->min.h = item2->min.h;
2338 item->prefer.w = item2->prefer.w;
2339 item->prefer.h = item2->prefer.h;
2340 item->max.w = item2->max.w;
2341 item->max.h = item2->max.h;
2342 item->padding.l = item2->padding.l;
2343 item->padding.r = item2->padding.r;
2344 item->padding.t = item2->padding.t;
2345 item->padding.b = item2->padding.b;
2346 item->align.x = item2->align.x;
2347 item->align.y = item2->align.y;
2348 item->weight.x = item2->weight.x;
2349 item->weight.y = item2->weight.y;
2350 item->aspect.w = item2->aspect.w;
2351 item->aspect.h = item2->aspect.h;
2352 item->aspect.mode = item2->aspect.mode;
2353 item->options = STRDUP(item2->options);
2354 item->col = item2->col;
2355 item->row = item2->row;
2356 item->colspan = item2->colspan;
2357 item->rowspan = item2->rowspan;
2358
2359 pitem = (Edje_Pack_Element_Parser *)item;
2360 pitem->can_override = EINA_TRUE;
2361 }
2362
2363 ep->api.name = STRDUP(ep2->api.name);
2364 if (ep2->api.description) ep->api.description = STRDUP(ep2->api.description);
2365
2366 // copy default description
2367 ob_collections_group_parts_part_description();
2368 ed = ep->default_desc;
2369 parent_desc = ed2 = ep2->default_desc;
2370 ed->state.name = STRDUP(ed2->state.name);
2371 ed->state.value = ed2->state.value;
2372 st_collections_group_parts_part_description_inherit();
2373 parent_desc = NULL;
2374
2375 // copy other description
2376 for (j = 0 ; j < ep2->other.desc_count ; j++)
2377 {
2378 ob_collections_group_parts_part_description();
2379 ed = ep->other.desc[j];
2380 parent_desc = ed2 = ep2->other.desc[j];
2381 ed->state.name = STRDUP(ed2->state.name);
2382 ed->state.value = ed2->state.value;
2383 st_collections_group_parts_part_description_inherit();
2384 parent_desc = NULL;
2385 }
2386 }
2387
2388 //copy programs
2389 for (j = 0 ; j < pc2->programs.fnmatch_count ; j++)
2390 {
2391 ob_collections_group_programs_program();
2392 _edje_program_copy(current_program, pc2->programs.fnmatch[j]);
2393 }
2394 for (j = 0 ; j < pc2->programs.strcmp_count ; j++)
2395 {
2396 ob_collections_group_programs_program();
2397 _edje_program_copy(current_program, pc2->programs.strcmp[j]);
2398 }
2399 for (j = 0 ; j < pc2->programs.strncmp_count ; j++)
2400 {
2401 ob_collections_group_programs_program();
2402 _edje_program_copy(current_program, pc2->programs.strncmp[j]);
2403 }
2404 for (j = 0 ; j < pc2->programs.strrncmp_count ; j++)
2405 {
2406 ob_collections_group_programs_program();
2407 _edje_program_copy(current_program, pc2->programs.strrncmp[j]);
2408 }
2409 for (j = 0 ; j < pc2->programs.nocmp_count ; j++)
2410 {
2411 ob_collections_group_programs_program();
2412 _edje_program_copy(current_program, pc2->programs.nocmp[j]);
2413 }
2414
2415 Code *cd, *cd2;
2416 Code_Program *cp, *cp2;
2417 Edje_Part_Collection_Directory_Entry *de;
2418
2419 de = eina_hash_find(edje_file->collection, pc2->part);
2420 cd2 = eina_list_nth(codes, de->id);
2421 cd = eina_list_data_get(eina_list_last(codes));
2422
2423 EINA_LIST_FOREACH(cd2->programs, l, cp2)
2424 {
2425 cp = mem_alloc(SZ(Code_Program));
2426
2427 cp->l1 = cp2->l1;
2428 cp->l2 = cp2->l2;
2429 cp->script = STRDUP(cp2->script);
2430 cd->is_lua = cd2->is_lua;
2431 cd->programs = eina_list_append(cd->programs, cp);
2432 data_queue_copied_anonymous_lookup(pc, &(cp2->id), &(cp->id));
2433 }
2434
2435 free(parent_name);
2436 #undef STRDUP
2437}
2438
2439/**
2440 @page edcref
2441 @property
2442 script_only
2443 @parameters
2444 [on/off]
2445 @effect
2446 The flag (on/off) as to if this group is defined ONLY by script
2447 callbacks such as init(), resize() and shutdown()
2448 @endproperty
2449*/
2450static void
2451st_collections_group_script_only(void)
2452{
2453 Edje_Part_Collection *pc;
2454
2455 check_arg_count(1);
2456
2457 pc = eina_list_data_get(eina_list_last(edje_collections));
2458 pc->lua_script_only = parse_bool(0);
2459}
2460
2461/**
2462 @page edcref
2463 @property
2464 alias
2465 @parameters
2466 [aditional group name]
2467 @effect
2468 Additional name to serve as identifier. Defining multiple aliases is
2469 supported.
2470 @endproperty
2471*/
2472static void
2473st_collections_group_alias(void)
2474{
2475 Edje_Part_Collection_Directory_Entry *alias;
2476
2477 check_arg_count(1);
2478
2479 alias = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry));
2480 alias->id = current_de->id;
2481 alias->entry = parse_str(0);
2482
2483 aliases = eina_list_append(aliases, alias);
2484}
2485
2486/**
2487 @page edcref
2488 @property
2489 min
2490 @parameters
2491 [width] [height]
2492 @effect
2493 The minimum size for the container defined by the composition of the
2494 parts. It is not enforced.
2495 @endproperty
2496*/
2497static void
2498st_collections_group_min(void)
2499{
2500 Edje_Part_Collection *pc;
2501
2502 check_arg_count(2);
2503
2504 pc = eina_list_data_get(eina_list_last(edje_collections));
2505 pc->prop.min.w = parse_int_range(0, 0, 0x7fffffff);
2506 pc->prop.min.h = parse_int_range(1, 0, 0x7fffffff);
2507}
2508
2509/**
2510 @page edcref
2511 @property
2512 max
2513 @parameters
2514 [width] [height]
2515 @effect
2516 The maximum size for the container defined by the totality of the
2517 parts. It is not enforced.
2518 @endproperty
2519*/
2520static void
2521st_collections_group_max(void)
2522{
2523 Edje_Part_Collection *pc;
2524
2525 check_arg_count(2);
2526
2527 pc = eina_list_data_get(eina_list_last(edje_collections));
2528 pc->prop.max.w = parse_int_range(0, 0, 0x7fffffff);
2529 pc->prop.max.h = parse_int_range(1, 0, 0x7fffffff);
2530}
2531
2532/**
2533 @page edcref
2534 @block
2535 script
2536 @context
2537 ..
2538 group {
2539 script {
2540 //embryo script
2541 }
2542 ..
2543 program {
2544 script {
2545 //embryo script
2546 }
2547 }
2548 ..
2549 }
2550 ..
2551 @description
2552 This block is used to "inject" embryo scripts to a given Edje theme and
2553 it functions in two modalities. When it's included inside a "program"
2554 block, the script will be executed every time the program is run, on
2555 the other hand, when included directly into a "group", "part" or
2556 "description" block, it will be executed once at load time, in the
2557 load order.
2558 @endblock
2559*/
2560static void
2561ob_collections_group_script(void)
2562{
2563 Code *cd;
2564
2565 cd = eina_list_data_get(eina_list_last(codes));
2566
2567 if (!is_verbatim()) track_verbatim(1);
2568 else
2569 {
2570 char *s;
2571
2572 s = get_verbatim();
2573 if (s)
2574 {
2575 cd->l1 = get_verbatim_line1();
2576 cd->l2 = get_verbatim_line2();
2577 if (cd->shared)
2578 {
2579 ERR("%s: Error. parse error %s:%i. There is already an existing script section for the group",
2580 progname, file_in, line - 1);
2581 exit(-1);
2582 }
2583 cd->shared = s;
2584 cd->original = strdup(s);
2585 cd->is_lua = 0;
2586 set_verbatim(NULL, 0, 0);
2587 }
2588 }
2589}
2590
2591static void
2592ob_collections_group_lua_script(void)
2593{
2594 Code *cd;
2595
2596 cd = eina_list_data_get(eina_list_last(codes));
2597
2598 if (!is_verbatim()) track_verbatim(1);
2599 else
2600 {
2601 char *s;
2602
2603 s = get_verbatim();
2604 if (s)
2605 {
2606 cd->l1 = get_verbatim_line1();
2607 cd->l2 = get_verbatim_line2();
2608 if (cd->shared)
2609 {
2610 ERR("%s: Error. parse error %s:%i. There is already an existing script section for the group",
2611 progname, file_in, line - 1);
2612 exit(-1);
2613 }
2614 cd->shared = s;
2615 cd->is_lua = 1;
2616 set_verbatim(NULL, 0, 0);
2617 }
2618 }
2619}
2620
2621static void
2622st_collections_group_data_item(void)
2623{
2624 Edje_Part_Collection *pc;
2625 Edje_String *es;
2626 char *key;
2627
2628 check_arg_count(2);
2629
2630 pc = eina_list_data_get(eina_list_last(edje_collections));
2631
2632 if (!pc->data)
2633 pc->data = eina_hash_string_small_new(free);
2634
2635 key = parse_str(0);
2636
2637 es = mem_alloc(SZ(Edje_String));
2638 es->str = parse_str(1);
2639
2640 if (eina_hash_find(pc->data, key))
2641 eina_hash_modify(pc->data, key, es);
2642 else
2643 eina_hash_direct_add(pc->data, key, es);
2644}
2645
2646/**
2647 @page edcref
2648 @property
2649 orientation
2650 @parameters
2651 enum AUTO, LTR, RTL
2652 @effect
2653 This defines GROUP orientation.
2654 This is useful if you want match interface orientation with language.
2655 AUTO - Follow system defs.
2656 LTR - suitable for Left To Right Languages (latin)
2657 RTL - suitable for Right To Left Languages (Hebrew, Arabic interface)
2658 @endproperty
2659*/
2660static void
2661st_collections_group_orientation(void)
2662{
2663 Edje_Part_Collection *pc;
2664
2665 check_arg_count(1);
2666
2667 pc = eina_list_data_get(eina_list_last(edje_collections));
2668 pc->prop.orientation = parse_enum(0,
2669 "AUTO", EDJE_ORIENTATION_AUTO,
2670 "LTR", EDJE_ORIENTATION_LTR,
2671 "RTL", EDJE_ORIENTATION_RTL,
2672 NULL);
2673}
2674
2675/**
2676 @page edcref
2677 @block
2678 limits
2679 @context
2680 group {
2681 limits {
2682 vertical: "limit_name" height_barrier;
2683 horizontal: "limit_name" width_barrier;
2684 ..
2685 }
2686 ..
2687 }
2688 ..
2689 @description
2690 This block is used to trigger some signal when the Edje object is resized.
2691 @endblock
2692
2693 @edcref
2694 @property
2695 vertical
2696 @parameters
2697 [name] [height barrier]
2698 @effect
2699 It will send a signal: "limit,name,over" when the object is resized and pass
2700 the limit by growing over it. And it will send: "limit,name,below" when
2701 it pass below that limit.
2702 This limit will be applied on the y absis.
2703 @endproperty
2704*/
2705static void
2706st_collections_group_limits_vertical(void)
2707{
2708 Edje_Part_Collection *pc;
2709 Edje_Limit *el;
2710
2711 check_arg_count(2);
2712
2713 el = mem_alloc(SZ(Edje_Limit));
2714
2715 pc = eina_list_data_get(eina_list_last(edje_collections));
2716 pc->limits.vertical_count++;
2717 pc->limits.vertical = realloc(pc->limits.vertical, pc->limits.vertical_count * sizeof (Edje_Limit *));
2718 if (!pc->limits.vertical || !el)
2719 {
2720 ERR("%s: Error. Not enough memory.", progname);
2721 exit(-1);
2722 }
2723
2724 pc->limits.vertical[pc->limits.vertical_count - 1] = el;
2725
2726 el->name = parse_str(0);
2727 el->value = parse_int_range(1, 1, 0xffff);
2728}
2729
2730/**
2731 @page edcref
2732 @property
2733 horizontal
2734 @parameters
2735 [name] [width barrier]
2736 @effect
2737 It will send a signal: "limit,name,over" when the object is resized and pass
2738 the limit by growing over it. And it will send: "limit,name,below" when
2739 it pass below that limit.
2740 This limit will be applied on the x absis.
2741 @endproperty
2742*/
2743static void
2744st_collections_group_limits_horizontal(void)
2745{
2746 Edje_Part_Collection *pc;
2747 Edje_Limit *el;
2748
2749 check_arg_count(2);
2750
2751 el = mem_alloc(SZ(Edje_Limit));
2752
2753 pc = eina_list_data_get(eina_list_last(edje_collections));
2754 pc->limits.horizontal_count++;
2755 pc->limits.horizontal = realloc(pc->limits.horizontal, pc->limits.horizontal_count * sizeof (Edje_Limit *));
2756 if (!pc->limits.horizontal || !el)
2757 {
2758 ERR("%s: Error. Not enough memory.", progname);
2759 exit(-1);
2760 }
2761
2762 pc->limits.horizontal[pc->limits.horizontal_count - 1] = el;
2763
2764 el->name = parse_str(0);
2765 el->value = parse_int_range(1, 1, 0xffff);
2766}
2767
2768/**
2769 @page edcref
2770 @block
2771 parts
2772 @context
2773 group {
2774 parts {
2775 alias: "theme_part_path" "real_part_path";
2776 ..
2777 }
2778 }
2779 @description
2780 Alias of part give a chance to let the designer put the real one
2781 in a box or reuse one from a GROUP or inside a BOX.
2782 @endblock
2783*/
2784static void
2785st_collections_group_parts_alias(void)
2786{
2787 Edje_Part_Collection *pc;
2788 const char *alias;
2789 const char *aliased;
2790
2791 check_arg_count(2);
2792
2793 pc = eina_list_data_get(eina_list_last(edje_collections));
2794
2795 alias = parse_str(0);
2796 aliased = parse_str(1);
2797
2798 if (!pc->alias) pc->alias = eina_hash_string_small_new(NULL);
2799 eina_hash_add(pc->alias, alias, aliased);
2800
2801 if (!pc->aliased) pc->aliased = eina_hash_string_small_new(NULL);
2802 eina_hash_add(pc->aliased, aliased, alias);
2803}
2804
2805
2806/**
2807 @page edcref
2808 @block
2809 part
2810 @context
2811 group {
2812 parts {
2813 ..
2814 part {
2815 name: "partname";
2816 type: IMAGE;
2817 mouse_events: 1;
2818 repeat_events: 0;
2819 ignore_flags: NONE;
2820 clip_to: "anotherpart";
2821 source: "groupname";
2822 pointer_mode: AUTOGRAB;
2823 use_alternate_font_metrics: 0;
2824
2825 description { }
2826 dragable { }
2827 items { }
2828 }
2829 ..
2830 }
2831 }
2832 @description
2833 Parts are used to represent the most basic design elements of the
2834 theme, for example, a part can represent a line in a border or a label
2835 on a button.
2836 @endblock
2837*/
2838static void
2839ob_collections_group_parts_part(void)
2840{
2841 Edje_Part_Collection *pc;
2842 Edje_Part *ep;
2843 Edje_Part_Parser *epp;
2844
2845 ep = mem_alloc(SZ(Edje_Part_Parser));
2846
2847 pc = eina_list_data_get(eina_list_last(edje_collections));
2848 pc->parts_count++;
2849 pc->parts = realloc(pc->parts, pc->parts_count * sizeof (Edje_Part *));
2850 if (!pc->parts)
2851 {
2852 ERR("%s: Error. Not enough memory.", progname);
2853 exit(-1);
2854 }
2855 current_part = pc->parts[pc->parts_count - 1] = ep;
2856
2857 ep->id = pc->parts_count - 1;
2858 ep->type = EDJE_PART_TYPE_IMAGE;
2859 ep->mouse_events = 1;
2860 ep->repeat_events = 0;
2861 ep->ignore_flags = EVAS_EVENT_FLAG_NONE;
2862 ep->scale = 0;
2863 ep->pointer_mode = EVAS_OBJECT_POINTER_MODE_AUTOGRAB;
2864 ep->precise_is_inside = 0;
2865 ep->use_alternate_font_metrics = 0;
2866 ep->clip_to_id = -1;
2867 ep->dragable.confine_id = -1;
2868 ep->dragable.event_id = -1;
2869 ep->items = NULL;
2870
2871 epp = (Edje_Part_Parser *)ep;
2872 epp->reorder.insert_before = NULL;
2873 epp->reorder.insert_after = NULL;
2874 epp->reorder.before = NULL;
2875 epp->reorder.after = NULL;
2876 epp->reorder.linked_prev = 0;
2877 epp->reorder.linked_next = 0;
2878 epp->reorder.done = EINA_FALSE;
2879 epp->can_override = EINA_FALSE;
2880}
2881
2882/**
2883 @page edcref
2884 @property
2885 name
2886 @parameters
2887 [part name]
2888 @effect
2889 The part's name will be used as reference in the theme's relative
2890 positioning system, by programs and in some cases by the application.
2891 It must be unique within the group.
2892 @endproperty
2893*/
2894static void
2895st_collections_group_parts_part_name(void)
2896{
2897 Edje_Part_Collection *pc;
2898 Edje_Part *ep;
2899 Edje_Part_Parser *epp;
2900
2901 check_arg_count(1);
2902
2903 pc = eina_list_data_get(eina_list_last(edje_collections));
2904 ep = current_part;
2905 ep->name = parse_str(0);
2906
2907 if (ep->name)
2908 {
2909 unsigned int i;
2910
2911 for (i = 0; i < (pc->parts_count - 1); i++)
2912 {
2913 if (pc->parts[i]->name && (!strcmp(pc->parts[i]->name, ep->name)))
2914 {
2915 epp = (Edje_Part_Parser *)pc->parts[i];
2916 if (!epp->can_override)
2917 {
2918 ERR("%s: Error. parse error %s:%i. There is already a part of the name %s",
2919 progname, file_in, line - 1, ep->name);
2920 exit(-1);
2921 }
2922 else
2923 {
2924 free(ep);
2925 pc->parts_count--;
2926 pc->parts = realloc(pc->parts, pc->parts_count * sizeof (Edje_Part *));
2927 ep = current_part = pc->parts[i];
2928 epp->can_override = EINA_FALSE;
2929 break;
2930 }
2931 }
2932 }
2933 }
2934}
2935
2936/**
2937 @page edcref
2938 @property
2939 type
2940 @parameters
2941 [TYPE]
2942 @effect
2943 Set the type (all caps) from among the available types, it's set to
2944 IMAGE by default. Valid types:
2945 @li RECT
2946 @li TEXT
2947 @li IMAGE
2948 @li SWALLOW
2949 @li TEXTBLOCK
2950 @li GROUP
2951 @li BOX
2952 @li TABLE
2953 @li EXTERNAL
2954 @li PROXY
2955 @endproperty
2956*/
2957static void
2958st_collections_group_parts_part_type(void)
2959{
2960 check_arg_count(1);
2961
2962 current_part->type = parse_enum(0,
2963 "NONE", EDJE_PART_TYPE_NONE,
2964 "RECT", EDJE_PART_TYPE_RECTANGLE,
2965 "TEXT", EDJE_PART_TYPE_TEXT,
2966 "IMAGE", EDJE_PART_TYPE_IMAGE,
2967 "SWALLOW", EDJE_PART_TYPE_SWALLOW,
2968 "TEXTBLOCK", EDJE_PART_TYPE_TEXTBLOCK,
2969 "GROUP", EDJE_PART_TYPE_GROUP,
2970 "BOX", EDJE_PART_TYPE_BOX,
2971 "TABLE", EDJE_PART_TYPE_TABLE,
2972 "EXTERNAL", EDJE_PART_TYPE_EXTERNAL,
2973 "PROXY", EDJE_PART_TYPE_PROXY,
2974 NULL);
2975}
2976
2977/**
2978 @page edcref
2979 @property
2980 insert_before
2981 @parameters
2982 [another part's name]
2983 @effect
2984 The part's name which this part is inserted before. One part cannot
2985 have both insert_before and insert_after. One part cannot refer
2986 more than one by insert_before.
2987 @endproperty
2988 @since 1.1.0
2989*/
2990static void
2991st_collections_group_parts_part_insert_before(void)
2992{
2993 Edje_Part_Parser *epp;
2994 check_arg_count(1);
2995
2996 epp = (Edje_Part_Parser *)current_part;
2997 epp->reorder.insert_before = parse_str(0);
2998}
2999
3000/**
3001 @page edcref
3002 @property
3003 insert_after
3004 @parameters
3005 [another part's name]
3006 @effect
3007 The part's name which this part is inserted after. One part cannot
3008 have both insert_before and insert_after. One part cannot refer
3009 more than one by insert_after.
3010 @endproperty
3011 @since 1.1.0
3012*/
3013static void
3014st_collections_group_parts_part_insert_after(void)
3015{
3016 Edje_Part_Parser *epp;
3017 check_arg_count(1);
3018
3019 epp = (Edje_Part_Parser *)current_part;
3020 epp->reorder.insert_after = parse_str(0);
3021}
3022
3023/**
3024 @page edcref
3025 @property
3026 mouse_events
3027 @parameters
3028 [1 or 0]
3029 @effect
3030 Specifies whether the part will emit signals, although it is named
3031 "mouse_events", disabling it (0) will prevent the part from emitting
3032 any type of signal at all. It's set to 1 by default.
3033 @endproperty
3034*/
3035static void
3036st_collections_group_parts_part_mouse_events(void)
3037{
3038 check_arg_count(1);
3039
3040 current_part->mouse_events = parse_bool(0);
3041}
3042
3043/**
3044 @page edcref
3045 @property
3046 repeat_events
3047 @parameters
3048 [1 or 0]
3049 @effect
3050 Specifies whether a part echoes a mouse event to other parts below the
3051 pointer (1), or not (0). It's set to 0 by default.
3052 @endproperty
3053*/
3054static void
3055st_collections_group_parts_part_repeat_events(void)
3056{
3057 check_arg_count(1);
3058
3059 current_part->repeat_events = parse_bool(0);
3060}
3061
3062/**
3063 @page edcref
3064 @property
3065 ignore_flags
3066 @parameters
3067 [FLAG] ...
3068 @effect
3069 Specifies whether events with the given flags should be ignored,
3070 i.e., will not have the signals emitted to the parts. Multiple flags
3071 must be separated by spaces, the effect will be ignoring all events
3072 with one of the flags specified. Possible flags:
3073 @li NONE (default value, no event will be ignored)
3074 @li ON_HOLD
3075 @endproperty
3076*/
3077static void
3078st_collections_group_parts_part_ignore_flags(void)
3079{
3080 check_min_arg_count(1);
3081
3082 current_part->ignore_flags = parse_flags(0,
3083 "NONE", EVAS_EVENT_FLAG_NONE,
3084 "ON_HOLD", EVAS_EVENT_FLAG_ON_HOLD,
3085 NULL);
3086}
3087
3088/**
3089 @page edcref
3090 @property
3091 scale
3092 @parameters
3093 [1 or 0]
3094 @effect
3095 Specifies whether the part will scale its size with an edje scaling
3096 factor. By default scale is off (0) and the default scale factor is
3097 1.0 - that means no scaling. This would be used to scale properties
3098 such as font size, min/max size of the part, and possibly can be used
3099 to scale based on DPI of the target device. The reason to be selective
3100 is that some things work well being scaled, others do not, so the
3101 designer gets to choose what works best.
3102 @endproperty
3103*/
3104static void
3105st_collections_group_parts_part_scale(void)
3106{
3107 check_arg_count(1);
3108
3109 current_part->scale = parse_bool(0);
3110}
3111
3112/**
3113 @page edcref
3114 @property
3115 pointer_mode
3116 @parameters
3117 [MODE]
3118 @effect
3119 Sets the mouse pointer behavior for a given part. The default value is
3120 AUTOGRAB. Aviable modes:
3121 @li AUTOGRAB, when the part is clicked and the button remains
3122 pressed, the part will be the source of all future mouse
3123 signals emitted, even outside the object, until the button is
3124 released.
3125 @li NOGRAB, the effect will be limited to the part's container.
3126 @endproperty
3127*/
3128static void
3129st_collections_group_parts_part_pointer_mode(void)
3130{
3131 check_arg_count(1);
3132
3133 current_part->pointer_mode = parse_enum(0,
3134 "AUTOGRAB", EVAS_OBJECT_POINTER_MODE_AUTOGRAB,
3135 "NOGRAB", EVAS_OBJECT_POINTER_MODE_NOGRAB,
3136 NULL);
3137}
3138
3139/**
3140 @page edcref
3141 @property
3142 precise_is_inside
3143 @parameters
3144 [1 or 0]
3145 @effect
3146 Enables precise point collision detection for the part, which is more
3147 resource intensive. Disabled by default.
3148 @endproperty
3149*/
3150static void
3151st_collections_group_parts_part_precise_is_inside(void)
3152{
3153 check_arg_count(1);
3154
3155 current_part->precise_is_inside = parse_bool(0);
3156}
3157
3158/**
3159 @page edcref
3160 @property
3161 use_alternate_font_metrics
3162 @parameters
3163 [1 or 0]
3164 @effect
3165 Only affects text and textblock parts, when enabled Edje will use
3166 different size measurement functions. Disabled by default. (note from
3167 the author: I don't know what this is exactlu useful for?)
3168 @endproperty
3169*/
3170static void
3171st_collections_group_parts_part_use_alternate_font_metrics(void)
3172{
3173 check_arg_count(1);
3174
3175 current_part->use_alternate_font_metrics = parse_bool(0);
3176}
3177
3178/**
3179 @page edcref
3180 @property
3181 clip_to
3182 @parameters
3183 [another part's name]
3184 @effect
3185 Only renders the area of part that coincides with another part's
3186 container. Overflowing content will not be displayed.
3187 @endproperty
3188*/
3189static void
3190st_collections_group_parts_part_clip_to_id(void)
3191{
3192 Edje_Part_Collection *pc;
3193
3194 check_arg_count(1);
3195
3196 pc = eina_list_data_get(eina_list_last(edje_collections));
3197 {
3198 char *name;
3199
3200 name = parse_str(0);
3201 data_queue_part_lookup(pc, name, &(current_part->clip_to_id));
3202 free(name);
3203 }
3204}
3205
3206/**
3207 @page edcref
3208 @property
3209 source
3210 @parameters
3211 [another group's name]
3212 @effect
3213 Only available to GROUP or TEXTBLOCK parts. Swallows the specified
3214 group into the part's container if a GROUP. If TEXTBLOCK it is used
3215 for the group to be loaded and used for selection display UNDER the
3216 selected text. source2 is used for on top of the selected text, if
3217 source2 is specified.
3218 @endproperty
3219*/
3220static void
3221st_collections_group_parts_part_source(void)
3222{
3223 check_arg_count(1);
3224
3225 //FIXME: validate this somehow (need to decide on the format also)
3226 current_part->source = parse_str(0);
3227}
3228
3229/**
3230 @page edcref
3231 @property
3232 source2
3233 @parameters
3234 [another group's name]
3235 @effect
3236 Only available to TEXTBLOCK parts. It is used for the group to be
3237 loaded and used for selection display OVER the selected text. source
3238 is used for under of the selected text, if source is specified.
3239 @endproperty
3240*/
3241static void
3242st_collections_group_parts_part_source2(void)
3243{
3244 check_arg_count(1);
3245
3246 //FIXME: validate this somehow (need to decide on the format also)
3247 current_part->source2 = parse_str(0);
3248}
3249
3250/**
3251 @page edcref
3252 @property
3253 source3
3254 @parameters
3255 [another group's name]
3256 @effect
3257 Only available to TEXTBLOCK parts. It is used for the group to be
3258 loaded and used for cursor display UNDER the cursor position. source4
3259 is used for over the cursor text, if source4 is specified.
3260 @endproperty
3261*/
3262static void
3263st_collections_group_parts_part_source3(void)
3264{
3265 check_arg_count(1);
3266
3267 //FIXME: validate this somehow (need to decide on the format also)
3268 current_part->source3 = parse_str(0);
3269}
3270
3271/**
3272 @page edcref
3273 @property
3274 source4
3275 @parameters
3276 [another group's name]
3277 @effect
3278 Only available to TEXTBLOCK parts. It is used for the group to be
3279 loaded and used for cursor display OVER the cursor position. source3
3280 is used for under the cursor text, if source4 is specified.
3281 @endproperty
3282*/
3283static void
3284st_collections_group_parts_part_source4(void)
3285{
3286 check_arg_count(1);
3287
3288 //FIXME: validate this somehow (need to decide on the format also)
3289 current_part->source4 = parse_str(0);
3290}
3291
3292/**
3293 @page edcref
3294 @property
3295 source5
3296 @parameters
3297 [another group's name]
3298 @effect
3299 Only available to TEXTBLOCK parts. It is used for the group to be
3300 loaded and used for anchors display UNDER the anchor position. source6
3301 is used for over the anchors text, if source6 is specified.
3302 @endproperty
3303*/
3304static void
3305st_collections_group_parts_part_source5(void)
3306{
3307 check_arg_count(1);
3308
3309 //FIXME: validate this somehow (need to decide on the format also)
3310 current_part->source5 = parse_str(0);
3311}
3312
3313/**
3314 @page edcref
3315 @property
3316 source6
3317 @parameters
3318 [another group's name]
3319 @effect
3320 Only available to TEXTBLOCK parts. It is used for the group to be
3321 loaded and used for anchor display OVER the anchor position. source5
3322 is used for under the anchor text, if source6 is specified.
3323 @endproperty
3324*/
3325static void
3326st_collections_group_parts_part_source6(void)
3327{
3328 check_arg_count(1);
3329
3330 //FIXME: validate this somehow (need to decide on the format also)
3331 current_part->source6 = parse_str(0);
3332}
3333
3334/**
3335 @page edcref
3336
3337 @property
3338 effect
3339 @parameters
3340 [EFFECT]
3341 (optional) [SHADOW DIRECTION]
3342 @effect
3343 Causes Edje to draw the selected effect among:
3344 @li PLAIN
3345 @li OUTLINE
3346 @li SOFT_OUTLINE
3347 @li SHADOW
3348 @li SOFT_SHADOW
3349 @li OUTLINE_SHADOW
3350 @li OUTLINE_SOFT_SHADOW
3351 @li FAR_SHADOW
3352 @li FAR_SOFT_SHADOW
3353 @li GLOW
3354
3355 Shadow directions (default if not given is BOTTOM_RIGHT):
3356 @li BOTTOM_RIGHT
3357 @li BOTTOM
3358 @li BOTTOM_LEFT
3359 @li LEFT
3360 @li TOP_LEFT
3361 @li TOP
3362 @li TOP_RIGHT
3363 @li RIGHT
3364 @endproperty
3365*/
3366static void
3367st_collections_group_parts_part_effect(void)
3368{
3369 check_min_arg_count(1);
3370
3371 current_part->effect = parse_enum(0,
3372 "NONE", EDJE_TEXT_EFFECT_NONE,
3373 "PLAIN", EDJE_TEXT_EFFECT_PLAIN,
3374 "OUTLINE", EDJE_TEXT_EFFECT_OUTLINE,
3375 "SOFT_OUTLINE", EDJE_TEXT_EFFECT_SOFT_OUTLINE,
3376 "SHADOW", EDJE_TEXT_EFFECT_SHADOW,
3377 "SOFT_SHADOW", EDJE_TEXT_EFFECT_SOFT_SHADOW,
3378 "OUTLINE_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SHADOW,
3379 "OUTLINE_SOFT_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW,
3380 "FAR_SHADOW", EDJE_TEXT_EFFECT_FAR_SHADOW,
3381 "FAR_SOFT_SHADOW", EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW,
3382 "GLOW", EDJE_TEXT_EFFECT_GLOW,
3383 NULL);
3384 if (get_arg_count() >= 2)
3385 {
3386 unsigned char shadow;
3387
3388 shadow = parse_enum(1,
3389 "BOTTOM_RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT,
3390 "BOTTOM", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM,
3391 "BOTTOM_LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT,
3392 "LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT,
3393 "TOP_LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT,
3394 "TOP", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP,
3395 "TOP_RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT,
3396 "RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT,
3397 NULL);
3398 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_SET(current_part->effect, shadow);
3399 }
3400}
3401
3402/**
3403 @page edcref
3404 @property
3405 entry_mode
3406 @parameters
3407 [MODE]
3408 @effect
3409 Sets the edit mode for a textblock part to one of:
3410 @li NONE
3411 @li PLAIN
3412 @li EDITABLE
3413 @li PASSWORD
3414 It causes the part be editable if the edje object has the keyboard
3415 focus AND the part has the edje focus (or selectable always
3416 regardless of focus) and in the event of password mode, not
3417 selectable and all text chars replaced with *'s but editable and
3418 pastable.
3419 @endproperty
3420*/
3421static void
3422st_collections_group_parts_part_entry_mode(void)
3423{
3424 check_arg_count(1);
3425
3426 current_part->entry_mode = parse_enum(0,
3427 "NONE", EDJE_ENTRY_EDIT_MODE_NONE,
3428 "PLAIN", EDJE_ENTRY_EDIT_MODE_SELECTABLE,
3429 "EDITABLE", EDJE_ENTRY_EDIT_MODE_EDITABLE,
3430 "PASSWORD", EDJE_ENTRY_EDIT_MODE_PASSWORD,
3431 NULL);
3432}
3433
3434/**
3435 @page edcref
3436 @property
3437 select_mode
3438 @parameters
3439 [MODE]
3440 @effect
3441 Sets the selection mode for a textblock part to one of:
3442 @li DEFAULT
3443 @li EXPLICIT
3444 DEFAULT selection mode is what you would expect on any desktop. Press
3445 mouse, drag and release to end. EXPLICIT mode requires the application
3446 controlling the edje object has to explicitly begin and end selection
3447 modes, and the selection itself is dragable at both ends.
3448 @endproperty
3449*/
3450static void
3451st_collections_group_parts_part_select_mode(void)
3452{
3453 check_arg_count(1);
3454
3455 current_part->select_mode = parse_enum(0,
3456 "DEFAULT", EDJE_ENTRY_SELECTION_MODE_DEFAULT,
3457 "EXPLICIT", EDJE_ENTRY_SELECTION_MODE_EXPLICIT,
3458 NULL);
3459}
3460
3461/**
3462 @page edcref
3463 @property
3464 cursor_mode
3465 @parameters
3466 [MODE]
3467 @effect
3468 Sets the cursor mode for a textblock part to one of:
3469 @li UNDER
3470 @li BEFORE
3471 UNDER cursor mode means the cursor will draw below the character pointed
3472 at. That's the default.
3473 BEFORE cursor mode means the cursor is drawn as a vertical line before
3474 the current character, just like many other GUI toolkits handle it.
3475 @endproperty
3476*/
3477static void
3478st_collections_group_parts_part_cursor_mode(void)
3479{
3480 check_arg_count(1);
3481
3482 current_part->cursor_mode = parse_enum(0,
3483 "UNDER", EDJE_ENTRY_CURSOR_MODE_UNDER,
3484 "BEFORE", EDJE_ENTRY_CURSOR_MODE_BEFORE,
3485 NULL);
3486}
3487
3488/**
3489 @page edcref
3490 @property
3491 multiline
3492 @parameters
3493 [1 or 0]
3494 @effect
3495 It causes a textblock that is editable to allow multiple lines for
3496 editing.
3497 @endproperty
3498*/
3499static void
3500st_collections_group_parts_part_multiline(void)
3501{
3502 check_arg_count(1);
3503
3504 current_part->multiline = parse_bool(0);
3505}
3506
3507/**
3508 @page edcref
3509 @block
3510 dragable
3511 @context
3512 part {
3513 ..
3514 dragable {
3515 confine: "another part";
3516 events: "another dragable part";
3517 x: 0 0 0;
3518 y: 0 0 0;
3519 }
3520 ..
3521 }
3522 @description
3523 When this block is used the resulting part can be dragged around the
3524 interface, do not confuse with external drag & drop. By default Edje
3525 (and most applications) will attempt to use the minimal size possible
3526 for a dragable part. If the min property is not set in the description
3527 the part will be (most likely) set to 0px width and 0px height, thus
3528 invisible.
3529 @endblock
3530
3531 @property
3532 x
3533 @parameters
3534 [enable/disable] [step] [count]
3535 @effect
3536 Used to setup dragging events for the X axis. The first parameter is
3537 used to enable (1 or -1) and disable (0) dragging along the axis. When
3538 enabled, 1 will set the starting point at 0.0 and -1 at 1.0. The second
3539 parameter takes any integer and will limit movement to values
3540 divisible by it, causing the part to jump from position to position.
3541 The third parameter, (question from the author: What is count for?).
3542 @endproperty
3543*/
3544static void
3545st_collections_group_parts_part_dragable_x(void)
3546{
3547 check_arg_count(3);
3548
3549 current_part->dragable.x = parse_int_range(0, -1, 1);
3550 current_part->dragable.step_x = parse_int_range(1, 0, 0x7fffffff);
3551 current_part->dragable.count_x = parse_int_range(2, 0, 0x7fffffff);
3552}
3553
3554/**
3555 @page edcref
3556 @property
3557 y
3558 @parameters
3559 [enable/disable] [step] [count]
3560 @effect
3561 Used to setup dragging events for the Y axis. The first parameter is
3562 used to enable (1 or -1) and disable (0) dragging along the axis. When
3563 enabled, 1 will set the starting point at 0.0 and -1 at 1.0. The second
3564 parameter takes any integer and will limit movement to values
3565 divisibles by it, causing the part to jump from position to position.
3566 The third parameter, (question from the author: What is count for?).
3567 @endproperty
3568*/
3569static void
3570st_collections_group_parts_part_dragable_y(void)
3571{
3572 check_arg_count(3);
3573
3574 current_part->dragable.y = parse_int_range(0, -1, 1);
3575 current_part->dragable.step_y = parse_int_range(1, 0, 0x7fffffff);
3576 current_part->dragable.count_y = parse_int_range(2, 0, 0x7fffffff);
3577}
3578
3579/**
3580 @page edcref
3581 @property
3582 confine
3583 @parameters
3584 [another part's name]
3585 @effect
3586 When set, limits the movement of the dragged part to another part's
3587 container. When you use confine don't forget to set a min size for the
3588 part, or the draggie will not show up.
3589 @endproperty
3590*/
3591static void
3592st_collections_group_parts_part_dragable_confine(void)
3593{
3594 Edje_Part_Collection *pc;
3595
3596 check_arg_count(1);
3597
3598 pc = eina_list_data_get(eina_list_last(edje_collections));
3599 {
3600 char *name;
3601
3602 name = parse_str(0);
3603 data_queue_part_lookup(pc, name, &(current_part->dragable.confine_id));
3604 free(name);
3605 }
3606}
3607
3608/**
3609 @page edcref
3610 @property
3611 events
3612 @parameters
3613 [another dragable part's name]
3614 @effect
3615 It causes the part to forward the drag events to another part, thus
3616 ignoring them for itself.
3617 @endproperty
3618*/
3619static void
3620st_collections_group_parts_part_dragable_events(void)
3621{
3622 Edje_Part_Collection *pc;
3623
3624 check_arg_count(1);
3625
3626 pc = eina_list_data_get(eina_list_last(edje_collections));
3627 {
3628 char *name;
3629
3630 name = parse_str(0);
3631 data_queue_part_lookup(pc, name, &(current_part->dragable.event_id));
3632 free(name);
3633 }
3634}
3635
3636/**
3637 @page edcref
3638 @block
3639 items
3640 @context
3641 part {
3642 ..
3643 box {
3644 items {
3645 item {
3646 type: TYPE;
3647 source: "some source";
3648 min: 1 1;
3649 max: 100 100;
3650 padding: 1 1 2 2;
3651 }
3652 item {
3653 type: TYPE;
3654 source: "some other source";
3655 name: "some name";
3656 align: 1.0 0.5;
3657 }
3658 ..
3659 }
3660 }
3661 ..
3662 }
3663 @description
3664 On a part of type BOX, this block can be used to set other groups
3665 as elements of the box. These can be mixed with external objects set
3666 by the application through the edje_object_part_box_* API.
3667 @endblock
3668*/
3669static void ob_collections_group_parts_part_box_items_item(void)
3670{
3671 Edje_Part *ep;
3672 Edje_Pack_Element *item;
3673 Edje_Pack_Element_Parser *pitem;
3674
3675 ep = current_part;
3676
3677 if ((ep->type != EDJE_PART_TYPE_BOX) && (ep->type != EDJE_PART_TYPE_TABLE))
3678 {
3679 ERR("%s: Error. parse error %s:%i. "
3680 "box attributes in non-BOX or TABLE part.",
3681 progname, file_in, line - 1);
3682 exit(-1);
3683 }
3684
3685 ep->items_count++;
3686 ep->items = realloc(ep->items, sizeof (Edje_Pack_Element*) * ep->items_count);
3687 if (!ep->items)
3688 {
3689 ERR("%s: Error. Not enough memory.", progname);
3690 exit(-1);
3691 }
3692
3693 item = mem_alloc(SZ(Edje_Pack_Element_Parser));
3694 current_item = ep->items[ep->items_count - 1] = item;
3695 item->type = EDJE_PART_TYPE_GROUP;
3696 item->name = NULL;
3697 item->source = NULL;
3698 item->min.w = 0;
3699 item->min.h = 0;
3700 item->prefer.w = 0;
3701 item->prefer.h = 0;
3702 item->max.w = -1;
3703 item->max.h = -1;
3704 item->padding.l = 0;
3705 item->padding.r = 0;
3706 item->padding.t = 0;
3707 item->padding.b = 0;
3708 item->align.x = FROM_DOUBLE(0.5);
3709 item->align.y = FROM_DOUBLE(0.5);
3710 item->weight.x = FROM_DOUBLE(0.0);
3711 item->weight.y = FROM_DOUBLE(0.0);
3712 item->aspect.w = 0;
3713 item->aspect.h = 0;
3714 item->aspect.mode = EDJE_ASPECT_CONTROL_NONE;
3715 item->options = NULL;
3716 item->col = -1;
3717 item->row = -1;
3718 item->colspan = 1;
3719 item->rowspan = 1;
3720 pitem = (Edje_Pack_Element_Parser *)item;
3721 pitem->can_override = EINA_FALSE;
3722}
3723
3724/**
3725 @page edcref
3726 @property
3727 type
3728 @parameters
3729 Only GROUP for now (defaults to it)
3730 @effect
3731 Sets the type of the object this item will hold.
3732 @endproperty
3733*/
3734static void st_collections_group_parts_part_box_items_item_type(void)
3735{
3736 check_arg_count(1);
3737
3738 {
3739 char *s;
3740
3741 s = parse_str(0);
3742 if (strcmp(s, "GROUP"))
3743 {
3744 ERR("%s: Error. parse error %s:%i. "
3745 "token %s not one of: GROUP.",
3746 progname, file_in, line - 1, s);
3747 exit(-1);
3748 }
3749 /* FIXME: handle the enum, once everything else is supported */
3750 current_item->type = EDJE_PART_TYPE_GROUP;
3751 }
3752}
3753
3754/**
3755 @page edcref
3756 @property
3757 name
3758 @parameters
3759 [name for the object]
3760 @effect
3761 Sets the name of the object via evas_object_name_set().
3762 @endproperty
3763*/
3764static void st_collections_group_parts_part_box_items_item_name(void)
3765{
3766 Edje_Part *ep;
3767 Edje_Pack_Element *item;
3768 Edje_Pack_Element_Parser *pitem;
3769
3770 check_arg_count(1);
3771
3772 ep = current_part;
3773 item = ep->items[ep->items_count - 1];
3774
3775 item->name = parse_str(0);
3776
3777 {
3778 unsigned int i;
3779
3780 for (i = 0; i < ep->items_count - 1; ++i)
3781 {
3782 if (ep->items[i]->name && (!strcmp(ep->items[i]->name, item->name)))
3783 {
3784 pitem = (Edje_Pack_Element_Parser *)ep->items[i];
3785 if (!pitem->can_override)
3786 {
3787 ERR("%s: Error. parse error %s:%i. There is already a item of the name %s",
3788 progname, file_in, line - 1, item->name);
3789 exit(-1);
3790 }
3791 else
3792 {
3793 free(item);
3794 ep->items_count--;
3795 ep->items = realloc(ep->items, ep->items_count * sizeof (Edje_Pack_Element *));
3796 current_item = ep->items[i];
3797 pitem->can_override = EINA_FALSE;
3798 }
3799 }
3800 }
3801 }
3802}
3803
3804/**
3805 @page edcref
3806 @property
3807 source
3808 @parameters
3809 [another group's name]
3810 @effect
3811 Sets the group this object will be made from.
3812 @endproperty
3813*/
3814static void st_collections_group_parts_part_box_items_item_source(void)
3815{
3816 check_arg_count(1);
3817
3818 current_item->source = parse_str(0);
3819}
3820
3821/**
3822 @page edcref
3823 @property
3824 min
3825 @parameters
3826 [width] [height]
3827 @effect
3828 Sets the minimum size hints for this object.
3829 @endproperty
3830*/
3831static void st_collections_group_parts_part_box_items_item_min(void)
3832{
3833 check_arg_count(2);
3834
3835 current_item->min.w = parse_int_range(0, 0, 0x7ffffff);
3836 current_item->min.h = parse_int_range(1, 0, 0x7ffffff);
3837}
3838
3839/**
3840 @page edcref
3841 @property
3842 prefer
3843 @parameters
3844 [width] [height]
3845 @effect
3846 Sets the preferred size hints for this object.
3847 @endproperty
3848*/
3849static void st_collections_group_parts_part_box_items_item_prefer(void)
3850{
3851 check_arg_count(2);
3852
3853 current_item->prefer.w = parse_int_range(0, 0, 0x7ffffff);
3854 current_item->prefer.h = parse_int_range(1, 0, 0x7ffffff);
3855}
3856/**
3857 @page edcref
3858 @property
3859 max
3860 @parameters
3861 [width] [height]
3862 @effect
3863 Sets the maximum size hints for this object.
3864 @endproperty
3865*/
3866static void st_collections_group_parts_part_box_items_item_max(void)
3867{
3868 check_arg_count(2);
3869
3870 current_item->max.w = parse_int_range(0, 0, 0x7ffffff);
3871 current_item->max.h = parse_int_range(1, 0, 0x7ffffff);
3872}
3873
3874/**
3875 @page edcref
3876 @property
3877 padding
3878 @parameters
3879 [left] [right] [top] [bottom]
3880 @effect
3881 Sets the padding hints for this object.
3882 @endproperty
3883*/
3884static void st_collections_group_parts_part_box_items_item_padding(void)
3885{
3886 check_arg_count(4);
3887
3888 current_item->padding.l = parse_int_range(0, 0, 0x7ffffff);
3889 current_item->padding.r = parse_int_range(1, 0, 0x7ffffff);
3890 current_item->padding.t = parse_int_range(2, 0, 0x7ffffff);
3891 current_item->padding.b = parse_int_range(3, 0, 0x7ffffff);
3892}
3893
3894/**
3895 @page edcref
3896 @property
3897 align
3898 @parameters
3899 [x] [y]
3900 @effect
3901 Sets the alignment hints for this object.
3902 @endproperty
3903*/
3904static void st_collections_group_parts_part_box_items_item_align(void)
3905{
3906 check_arg_count(2);
3907
3908 current_item->align.x = FROM_DOUBLE(parse_float_range(0, -1.0, 1.0));
3909 current_item->align.y = FROM_DOUBLE(parse_float_range(1, -1.0, 1.0));
3910}
3911
3912/**
3913 @page edcref
3914 @property
3915 weight
3916 @parameters
3917 [x] [y]
3918 @effect
3919 Sets the weight hints for this object.
3920 @endproperty
3921*/
3922static void st_collections_group_parts_part_box_items_item_weight(void)
3923{
3924 check_arg_count(2);
3925
3926 current_item->weight.x = FROM_DOUBLE(parse_float_range(0, 0.0, 99999.99));
3927 current_item->weight.y = FROM_DOUBLE(parse_float_range(1, 0.0, 99999.99));
3928}
3929
3930/**
3931 @page edcref
3932 @property
3933 aspect
3934 @parameters
3935 [w] [h]
3936 @effect
3937 Sets the aspect width and height hints for this object.
3938 @endproperty
3939*/
3940static void st_collections_group_parts_part_box_items_item_aspect(void)
3941{
3942 check_arg_count(2);
3943
3944 current_item->aspect.w = parse_int_range(0, 0, 0x7fffffff);
3945 current_item->aspect.h = parse_int_range(1, 0, 0x7fffffff);
3946}
3947
3948/**
3949 @page edcref
3950 @property
3951 aspect_mode
3952 @parameters
3953 NONE, NEITHER, HORIZONTAL, VERTICAL, BOTH
3954 @effect
3955 Sets the aspect control hints for this object.
3956 @endproperty
3957*/
3958static void st_collections_group_parts_part_box_items_item_aspect_mode(void)
3959{
3960 check_arg_count(1);
3961
3962 current_item->aspect.mode = parse_enum(0,
3963 "NONE", EDJE_ASPECT_CONTROL_NONE,
3964 "NEITHER", EDJE_ASPECT_CONTROL_NEITHER,
3965 "HORIZONTAL", EDJE_ASPECT_CONTROL_HORIZONTAL,
3966 "VERTICAL", EDJE_ASPECT_CONTROL_VERTICAL,
3967 "BOTH", EDJE_ASPECT_CONTROL_BOTH,
3968 NULL);
3969}
3970
3971/**
3972 @page edcref
3973 @property
3974 options
3975 @parameters
3976 [extra options]
3977 @effect
3978 Sets extra options for the object. Unused for now.
3979 @endproperty
3980*/
3981static void st_collections_group_parts_part_box_items_item_options(void)
3982{
3983 check_arg_count(1);
3984
3985 current_item->options = parse_str(0);
3986}
3987
3988/**
3989 @page edcref
3990 @property
3991 position
3992 @parameters
3993 [col] [row]
3994 @effect
3995 Sets the position this item will have in the table.
3996 This is required for parts of type TABLE.
3997 @endproperty
3998*/
3999static void st_collections_group_parts_part_table_items_item_position(void)
4000{
4001 check_arg_count(2);
4002
4003 if (current_part->type != EDJE_PART_TYPE_TABLE)
4004 {
4005 ERR("%s: Error. parse error %s:%i. "
4006 "table attributes in non-TABLE part.",
4007 progname, file_in, line - 1);
4008 exit(-1);
4009 }
4010
4011 current_item->col = parse_int_range(0, 0, 0xffff);
4012 current_item->row = parse_int_range(1, 0, 0xffff);
4013}
4014
4015/**
4016 @page edcref
4017 @property
4018 span
4019 @parameters
4020 [col] [row]
4021 @effect
4022 Sets how many columns/rows this item will use.
4023 Defaults to 1 1.
4024 @endproperty
4025*/
4026static void st_collections_group_parts_part_table_items_item_span(void)
4027{
4028 check_arg_count(2);
4029
4030 if (current_part->type != EDJE_PART_TYPE_TABLE)
4031 {
4032 ERR("%s: Error. parse error %s:%i. "
4033 "table attributes in non-TABLE part.",
4034 progname, file_in, line - 1);
4035 exit(-1);
4036 }
4037
4038 current_item->colspan = parse_int_range(0, 1, 0xffff);
4039 current_item->rowspan = parse_int_range(1, 1, 0xffff);
4040}
4041
4042/**
4043 @edcsection{description,State description sub blocks}
4044 */
4045
4046/**
4047 @page edcref
4048 @block
4049 description
4050 @context
4051 description {
4052 inherit: "another_description" INDEX;
4053 state: "description_name" INDEX;
4054 visible: 1;
4055 min: 0 0;
4056 max: -1 -1;
4057 align: 0.5 0.5;
4058 fixed: 0 0;
4059 step: 0 0;
4060 aspect: 1 1;
4061
4062 rel1 {
4063 ..
4064 }
4065
4066 rel2 {
4067 ..
4068 }
4069 }
4070 @description
4071 Every part can have one or more description blocks. Each description is
4072 used to define style and layout properties of a part in a given
4073 "state".
4074 @endblock
4075*/
4076static void
4077ob_collections_group_parts_part_description(void)
4078{
4079 Edje_Part_Collection *pc;
4080 Edje_Part *ep;
4081 Edje_Part_Description_Common *ed;
4082
4083 pc = eina_list_data_get(eina_list_last(edje_collections));
4084 ep = current_part;
4085
4086 ed = _edje_part_description_alloc(ep->type, pc->part, ep->name);
4087
4088 if (!ep->default_desc)
4089 {
4090 current_desc = ep->default_desc = ed;
4091 }
4092 else
4093 {
4094 ep->other.desc_count++;
4095 ep->other.desc = realloc(ep->other.desc,
4096 sizeof (Edje_Part_Description_Common*) * ep->other.desc_count);
4097 current_desc = ep->other.desc[ep->other.desc_count - 1] = ed;
4098 }
4099
4100 ed->visible = 1;
4101 ed->align.x = FROM_DOUBLE(0.5);
4102 ed->align.y = FROM_DOUBLE(0.5);
4103 ed->min.w = 0;
4104 ed->min.h = 0;
4105 ed->fixed.w = 0;
4106 ed->fixed.h = 0;
4107 ed->max.w = -1;
4108 ed->max.h = -1;
4109 ed->rel1.relative_x = FROM_DOUBLE(0.0);
4110 ed->rel1.relative_y = FROM_DOUBLE(0.0);
4111 ed->rel1.offset_x = 0;
4112 ed->rel1.offset_y = 0;
4113 ed->rel1.id_x = -1;
4114 ed->rel1.id_y = -1;
4115 ed->rel2.relative_x = FROM_DOUBLE(1.0);
4116 ed->rel2.relative_y = FROM_DOUBLE(1.0);
4117 ed->rel2.offset_x = -1;
4118 ed->rel2.offset_y = -1;
4119 ed->rel2.id_x = -1;
4120 ed->rel2.id_y = -1;
4121 ed->color_class = NULL;
4122 ed->color.r = 255;
4123 ed->color.g = 255;
4124 ed->color.b = 255;
4125 ed->color.a = 255;
4126 ed->color2.r = 0;
4127 ed->color2.g = 0;
4128 ed->color2.b = 0;
4129 ed->color2.a = 255;
4130 ed->map.id_persp = -1;
4131 ed->map.id_light = -1;
4132 ed->map.rot.id_center = -1;
4133 ed->map.rot.x = FROM_DOUBLE(0.0);
4134 ed->map.rot.y = FROM_DOUBLE(0.0);
4135 ed->map.rot.z = FROM_DOUBLE(0.0);
4136 ed->map.on = 0;
4137 ed->map.smooth = 1;
4138 ed->map.alpha = 1;
4139 ed->map.backcull = 0;
4140 ed->map.persp_on = 0;
4141 ed->persp.zplane = 0;
4142 ed->persp.focal = 1000;
4143}
4144
4145/**
4146 @page edcref
4147 @property
4148 inherit
4149 @parameters
4150 [another description's name] [another description's index]
4151 @effect
4152 When set, the description will inherit all the properties from the
4153 named description. The properties defined in this part will override
4154 the inherited properties, reducing the amount of necessary code for
4155 simple state changes. Note: inheritance in Edje is single level only.
4156 @endproperty
4157*/
4158static void
4159st_collections_group_parts_part_description_inherit(void)
4160{
4161 Edje_Part_Collection *pc;
4162 Edje_Part *ep;
4163 Edje_Part_Description_Common *ed, *parent = NULL;
4164 Edje_Part_Image_Id *iid;
4165 char *parent_name;
4166 const char *state_name;
4167 double parent_val, state_val;
4168
4169 pc = eina_list_data_get(eina_list_last(edje_collections));
4170 ep = current_part;
4171 ed = current_desc;
4172
4173 if (!ed->state.name)
4174 {
4175 ERR("%s: Error. parse error %s:%i. "
4176 "inherit may only be used after state",
4177 progname, file_in, line - 1);
4178 exit(-1);
4179 }
4180
4181 parent = parent_desc;
4182 if (!parent)
4183 {
4184 check_arg_count(2);
4185
4186 /* inherit may not be used in the default description */
4187 if (!ep->other.desc_count)
4188 {
4189 ERR("%s: Error. parse error %s:%i. "
4190 "inherit may not be used in the default description",
4191 progname, file_in, line - 1);
4192 exit(-1);
4193 }
4194
4195 /* find the description that we inherit from */
4196 parent_name = parse_str(0);
4197 parent_val = parse_float_range(1, 0.0, 1.0);
4198
4199 if (!strcmp (parent_name, "default") && parent_val == 0.0)
4200 parent = ep->default_desc;
4201 else
4202 {
4203 Edje_Part_Description_Common *d;
4204 double min_dst = 999.0;
4205 unsigned int i;
4206
4207 if (!strcmp(parent_name, "default"))
4208 {
4209 parent = ep->default_desc;
4210 min_dst = ABS(ep->default_desc->state.value - parent_val);
4211 }
4212
4213 for (i = 0; i < ep->other.desc_count; ++i)
4214 {
4215 d = ep->other.desc[i];
4216
4217 if (!strcmp (d->state.name, parent_name))
4218 {
4219
4220 double dst;
4221
4222 dst = ABS(d->state.value - parent_val);
4223 if (dst < min_dst)
4224 {
4225 parent = d;
4226 min_dst = dst;
4227 }
4228 }
4229 }
4230 }
4231
4232 if (!parent)
4233 {
4234 ERR("%s: Error. parse error %s:%i. "
4235 "cannot find referenced part state %s %lf",
4236 ep->name, file_in, line - 1, parent_name, parent_val);
4237 exit(-1);
4238 }
4239
4240 free(parent_name);
4241 }
4242 /* now do a full copy, only state info will be kept */
4243 state_name = ed->state.name;
4244 state_val = ed->state.value;
4245
4246 *ed = *parent;
4247
4248 ed->state.name = state_name;
4249 ed->state.value = state_val;
4250
4251 data_queue_copied_part_lookup(pc, &parent->rel1.id_x, &ed->rel1.id_x);
4252 data_queue_copied_part_lookup(pc, &parent->rel1.id_y, &ed->rel1.id_y);
4253 data_queue_copied_part_lookup(pc, &parent->rel2.id_x, &ed->rel2.id_x);
4254 data_queue_copied_part_lookup(pc, &parent->rel2.id_y, &ed->rel2.id_y);
4255
4256 data_queue_copied_part_lookup(pc, &parent->map.id_persp, &ed->map.id_persp);
4257 data_queue_copied_part_lookup(pc, &parent->map.id_light, &ed->map.id_light);
4258 data_queue_copied_part_lookup(pc, &parent->map.rot.id_center, &ed->map.rot.id_center);
4259
4260 /* make sure all the allocated memory is getting copied, not just
4261 * referenced
4262 */
4263#define STRDUP(x) x ? strdup(x) : NULL
4264
4265 ed->color_class = STRDUP(ed->color_class);
4266 switch (ep->type)
4267 {
4268 case EDJE_PART_TYPE_RECTANGLE:
4269 case EDJE_PART_TYPE_SWALLOW:
4270 case EDJE_PART_TYPE_GROUP:
4271 /* Nothing todo, this part only have a common description. */
4272 break;
4273 case EDJE_PART_TYPE_TEXT:
4274 case EDJE_PART_TYPE_TEXTBLOCK:
4275 {
4276 Edje_Part_Description_Text *ted = (Edje_Part_Description_Text*) ed;
4277 Edje_Part_Description_Text *tparent = (Edje_Part_Description_Text*) parent;
4278
4279 ted->text = tparent->text;
4280
4281 ted->text.text.str = STRDUP(ted->text.text.str);
4282 ted->text.text_class = STRDUP(ted->text.text_class);
4283 ted->text.font.str = STRDUP(ted->text.font.str);
4284
4285 data_queue_copied_part_lookup(pc, &(tparent->text.id_source), &(ted->text.id_source));
4286 data_queue_copied_part_lookup(pc, &(tparent->text.id_text_source), &(ted->text.id_text_source));
4287
4288 break;
4289 }
4290 case EDJE_PART_TYPE_IMAGE:
4291 {
4292 Edje_Part_Description_Image *ied = (Edje_Part_Description_Image *) ed;
4293 Edje_Part_Description_Image *iparent = (Edje_Part_Description_Image *) parent;
4294 unsigned int i;
4295
4296 ied->image = iparent->image;
4297
4298 data_queue_copied_image_lookup(&iparent->image.id, &ied->image.id, &ied->image.set);
4299
4300 ied->image.tweens = calloc(iparent->image.tweens_count,
4301 sizeof (Edje_Part_Image_Id*));
4302 for (i = 0; i < iparent->image.tweens_count; i++)
4303 {
4304 Edje_Part_Image_Id *iid_new;
4305
4306 iid = iparent->image.tweens[i];
4307
4308 iid_new = mem_alloc(SZ(Edje_Part_Image_Id));
4309 data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set));
4310 ied->image.tweens[i] = iid_new;
4311 }
4312
4313 break;
4314 }
4315 case EDJE_PART_TYPE_PROXY:
4316 {
4317 Edje_Part_Description_Proxy *ped = (Edje_Part_Description_Proxy*) ed;
4318 Edje_Part_Description_Proxy *pparent = (Edje_Part_Description_Proxy*) parent;
4319
4320 data_queue_copied_part_lookup(pc, &(pparent->proxy.id), &(ped->proxy.id));
4321
4322 break;
4323 }
4324 case EDJE_PART_TYPE_BOX:
4325 {
4326 Edje_Part_Description_Box *bed = (Edje_Part_Description_Box *) ed;
4327 Edje_Part_Description_Box *bparent = (Edje_Part_Description_Box *) parent;
4328
4329 bed->box = bparent->box;
4330
4331 break;
4332 }
4333 case EDJE_PART_TYPE_TABLE:
4334 {
4335 Edje_Part_Description_Table *ted = (Edje_Part_Description_Table *) ed;
4336 Edje_Part_Description_Table *tparent = (Edje_Part_Description_Table *) parent;
4337
4338 ted->table = tparent->table;
4339
4340 break;
4341 }
4342 case EDJE_PART_TYPE_EXTERNAL:
4343 {
4344 Edje_Part_Description_External *eed = (Edje_Part_Description_External *) ed;
4345 Edje_Part_Description_External *eparent = (Edje_Part_Description_External *) parent;
4346
4347 if (eparent->external_params)
4348 {
4349 Eina_List *l;
4350 Edje_External_Param *param, *new_param;
4351
4352 eed->external_params = NULL;
4353 EINA_LIST_FOREACH(eparent->external_params, l, param)
4354 {
4355 new_param = mem_alloc(SZ(Edje_External_Param));
4356 *new_param = *param;
4357 eed->external_params = eina_list_append(eed->external_params, new_param);
4358 }
4359 }
4360 break;
4361 }
4362 }
4363
4364#undef STRDUP
4365}
4366
4367/**
4368 @page edcref
4369
4370 @property
4371 source
4372 @parameters
4373 [another part's name]
4374 @effect
4375 Causes the part to use another part content as the content of this part.
4376 Only work with PROXY part.
4377 @endproperty
4378*/
4379static void
4380st_collections_group_parts_part_description_source(void)
4381{
4382 Edje_Part_Collection *pc;
4383 Edje_Part_Description_Proxy *ed;
4384 char *name;
4385
4386 check_arg_count(1);
4387
4388 pc = eina_list_data_get(eina_list_last(edje_collections));
4389
4390 if (current_part->type != EDJE_PART_TYPE_PROXY)
4391 {
4392 ERR("%s: Error. parse error %s:%i. "
4393 "source attributes in non-PROXY part.",
4394 progname, file_in, line - 1);
4395 exit(-1);
4396 }
4397
4398 ed = (Edje_Part_Description_Proxy*) current_desc;
4399
4400 name = parse_str(0);
4401
4402 data_queue_part_lookup(pc, name, &(ed->proxy.id));
4403 free(name);
4404}
4405
4406/**
4407 @page edcref
4408 @property
4409 state
4410 @parameters
4411 [a name for the description] [an index]
4412 @effect
4413 Sets a name used to identify a description inside a given part.
4414 Multiple descriptions are used to declare different states of the same
4415 part, like "clicked" or "invisible". All states declarations are also
4416 coupled with an index number between 0.0 and 1.0. All parts must have
4417 at least one description named "default 0.0".
4418 @endproperty
4419*/
4420static void
4421st_collections_group_parts_part_description_state(void)
4422{
4423 Edje_Part *ep;
4424 Edje_Part_Description_Common *ed;
4425 char *s;
4426
4427 check_arg_count(2);
4428
4429 ep = current_part;
4430
4431 ed = ep->default_desc;
4432 if (ep->other.desc_count) ed = ep->other.desc[ep->other.desc_count - 1];
4433
4434 s = parse_str(0);
4435 if (!strcmp (s, "custom"))
4436 {
4437 ERR("%s: Error. parse error %s:%i. "
4438 "invalid state name: '%s'.",
4439 progname, file_in, line - 1, s);
4440 exit(-1);
4441 }
4442
4443 ed->state.name = s;
4444 ed->state.value = parse_float_range(1, 0.0, 1.0);
4445
4446 if (ed != ep->default_desc)
4447 {
4448 if ((ep->default_desc->state.name && !strcmp(s, ep->default_desc->state.name) && ed->state.value == ep->default_desc->state.value) ||
4449 (!ep->default_desc->state.name && !strcmp(s, "default") && ed->state.value == ep->default_desc->state.value))
4450 {
4451 free(ed);
4452 ep->other.desc_count--;
4453 ep->other.desc = realloc(ep->other.desc,
4454 sizeof (Edje_Part_Description_Common*) * ep->other.desc_count);
4455 current_desc = ep->default_desc;
4456 }
4457 else if (ep->other.desc_count)
4458 {
4459 unsigned int i;
4460 for (i = 0; i < ep->other.desc_count - 1; ++i)
4461 {
4462 if (!strcmp(s, ep->other.desc[i]->state.name) && ed->state.value == ep->other.desc[i]->state.value)
4463 {
4464 free(ed);
4465 ep->other.desc_count--;
4466 ep->other.desc = realloc(ep->other.desc,
4467 sizeof (Edje_Part_Description_Common*) * ep->other.desc_count);
4468 current_desc = ep->other.desc[i];
4469 break;
4470 }
4471 }
4472 }
4473 }
4474}
4475
4476/**
4477 @page edcref
4478 @property
4479 visible
4480 @parameters
4481 [0 or 1]
4482 @effect
4483 Takes a boolean value specifying whether part is visible (1) or not
4484 (0). Non-visible parts do not emit signals. The default value is 1.
4485 @endproperty
4486*/
4487static void
4488st_collections_group_parts_part_description_visible(void)
4489{
4490 check_arg_count(1);
4491
4492 current_desc->visible = parse_bool(0);
4493}
4494
4495/**
4496 @page edcref
4497 @property
4498 align
4499 @parameters
4500 [X axis] [Y axis]
4501 @effect
4502 When the displayed object's size is smaller than its container, this
4503 property moves it relatively along both axis inside its container. The
4504 default value is "0.5 0.5".
4505 @endproperty
4506*/
4507static void
4508st_collections_group_parts_part_description_align(void)
4509{
4510 check_arg_count(2);
4511
4512 current_desc->align.x = FROM_DOUBLE(parse_float_range(0, 0.0, 1.0));
4513 current_desc->align.y = FROM_DOUBLE(parse_float_range(1, 0.0, 1.0));
4514}
4515
4516/**
4517 @page edcref
4518 @property
4519 fixed
4520 @parameters
4521 [width, 0 or 1] [height, 0 or 1]
4522 @effect
4523 This affects the minimum size calculation. See
4524 edje_object_size_min_calc() and edje_object_size_min_restricted_calc().
4525 This tells the min size calculation routine that this part does not
4526 change size in width or height (1 for it doesn't, 0 for it does), so
4527 the routine should not try and expand or contract the part.
4528 @endproperty
4529*/
4530static void
4531st_collections_group_parts_part_description_fixed(void)
4532{
4533 check_arg_count(2);
4534
4535 current_desc->fixed.w = parse_float_range(0, 0, 1);
4536 current_desc->fixed.h = parse_float_range(1, 0, 1);
4537}
4538
4539/**
4540 @page edcref
4541 @property
4542 min
4543 @parameters
4544 [width] [height]
4545 @effect
4546 The minimum size of the state.
4547 @endproperty
4548*/
4549static void
4550st_collections_group_parts_part_description_min(void)
4551{
4552 check_arg_count(2);
4553
4554 current_desc->min.w = parse_float_range(0, 0, 0x7fffffff);
4555 current_desc->min.h = parse_float_range(1, 0, 0x7fffffff);
4556}
4557
4558/**
4559 @page edcref
4560 @property
4561 max
4562 @parameters
4563 [width] [height]
4564 @effect
4565 The maximum size of the state. A size of -1.0 means that it will be ignored in one direction.
4566 @endproperty
4567*/
4568static void
4569st_collections_group_parts_part_description_max(void)
4570{
4571 check_arg_count(2);
4572
4573 current_desc->max.w = parse_float_range(0, -1.0, 0x7fffffff);
4574 current_desc->max.h = parse_float_range(1, -1.0, 0x7fffffff);
4575}
4576
4577/**
4578 @page edcref
4579 @property
4580 step
4581 @parameters
4582 [width] [height]
4583 @effect
4584 Restricts resizing of each dimension to values divisibles by its value.
4585 This causes the part to jump from value to value while resizing. The
4586 default value is "0 0" disabling stepping.
4587 @endproperty
4588*/
4589static void
4590st_collections_group_parts_part_description_step(void)
4591{
4592 check_arg_count(2);
4593
4594 current_desc->step.x = parse_float_range(0, 0, 0x7fffffff);
4595 current_desc->step.y = parse_float_range(1, 0, 0x7fffffff);
4596}
4597
4598/**
4599 @page edcref
4600 @property
4601 aspect
4602 @parameters
4603 [min] [max]
4604 @effect
4605 Normally width and height can be resized to any values independently.
4606 The aspect property forces the width to height ratio to be kept between
4607 the minimum and maximum set. For example, "1.0 1.0" will increase the
4608 width a pixel for every pixel added to heigh. The default value is
4609 "0.0 0.0" disabling aspect.
4610 @endproperty
4611*/
4612static void
4613st_collections_group_parts_part_description_aspect(void)
4614{
4615 check_arg_count(2);
4616
4617 current_desc->aspect.min = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0));
4618 current_desc->aspect.max = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0));
4619}
4620
4621/**
4622 @page edcref
4623 @property
4624 aspect_preference
4625 @parameters
4626 [DIMENSION]
4627 @effect
4628 Sets the scope of the "aspect" property to a given dimension. Available
4629 options are BOTH, VERTICAL, HORIZONTAL and NONE
4630 @endproperty
4631*/
4632static void
4633st_collections_group_parts_part_description_aspect_preference(void)
4634{
4635 check_arg_count(1);
4636
4637 current_desc->aspect.prefer = parse_enum(0,
4638 "NONE", EDJE_ASPECT_PREFER_NONE,
4639 "VERTICAL", EDJE_ASPECT_PREFER_VERTICAL,
4640 "HORIZONTAL", EDJE_ASPECT_PREFER_HORIZONTAL,
4641 "BOTH", EDJE_ASPECT_PREFER_BOTH,
4642 NULL);
4643}
4644
4645/**
4646 @page edcref
4647 @property
4648 color_class
4649 @parameters
4650 [color class name]
4651 @effect
4652 The part will use the color values of the named color_class, these
4653 values can be overrided by the "color", "color2" and "color3"
4654 properties set below.
4655 @endproperty
4656*/
4657static void
4658st_collections_group_parts_part_description_color_class(void)
4659{
4660 check_arg_count(1);
4661
4662 current_desc->color_class = parse_str(0);
4663}
4664
4665/**
4666 @page edcref
4667 @property
4668 color
4669 @parameters
4670 [red] [green] [blue] [alpha]
4671 @effect
4672 Sets the main color to the specified values (between 0 and 255).
4673 @endproperty
4674*/
4675static void
4676st_collections_group_parts_part_description_color(void)
4677{
4678 check_arg_count(4);
4679
4680 current_desc->color.r = parse_int_range(0, 0, 255);
4681 current_desc->color.g = parse_int_range(1, 0, 255);
4682 current_desc->color.b = parse_int_range(2, 0, 255);
4683 current_desc->color.a = parse_int_range(3, 0, 255);
4684}
4685
4686/**
4687 @page edcref
4688 @property
4689 color2
4690 @parameters
4691 [red] [green] [blue] [alpha]
4692 @effect
4693 Sets the text shadow color to the specified values (0 to 255).
4694 @endproperty
4695*/
4696static void
4697st_collections_group_parts_part_description_color2(void)
4698{
4699 check_arg_count(4);
4700
4701 current_desc->color2.r = parse_int_range(0, 0, 255);
4702 current_desc->color2.g = parse_int_range(1, 0, 255);
4703 current_desc->color2.b = parse_int_range(2, 0, 255);
4704 current_desc->color2.a = parse_int_range(3, 0, 255);
4705}
4706
4707/**
4708 @page edcref
4709 @property
4710 color3
4711 @parameters
4712 [red] [green] [blue] [alpha]
4713 @effect
4714 Sets the text outline color to the specified values (0 to 255).
4715 @endproperty
4716*/
4717static void
4718st_collections_group_parts_part_description_color3(void)
4719{
4720 Edje_Part_Collection *pc;
4721 Edje_Part_Description_Text *ed;
4722
4723 check_arg_count(4);
4724
4725 pc = eina_list_data_get(eina_list_last(edje_collections));
4726
4727 if (current_part->type != EDJE_PART_TYPE_TEXT
4728 && current_part->type != EDJE_PART_TYPE_TEXTBLOCK)
4729 {
4730 ERR("%s: Error. Setting color3 in part %s from %s not of type TEXT or TEXTBLOCK.", progname, current_part->name, pc->part);
4731 exit(-1);
4732 }
4733
4734 ed = (Edje_Part_Description_Text*)current_desc;
4735
4736 ed->text.color3.r = parse_int_range(0, 0, 255);
4737 ed->text.color3.g = parse_int_range(1, 0, 255);
4738 ed->text.color3.b = parse_int_range(2, 0, 255);
4739 ed->text.color3.a = parse_int_range(3, 0, 255);
4740}
4741
4742/**
4743 @page edcref
4744 @block
4745 rel1/rel2
4746 @context
4747 description {
4748 ..
4749 rel1 {
4750 relative: 0.0 0.0;
4751 offset: 0 0;
4752 }
4753 ..
4754 rel2 {
4755 relative: 1.0 1.0;
4756 offset: -1 -1;
4757 }
4758 ..
4759 }
4760 @description
4761 The rel1 and rel2 blocks are used to define the position of each corner
4762 of the part's container. With rel1 being the left-up corner and rel2
4763 being the right-down corner.
4764 @endblock
4765
4766 @property
4767 relative
4768 @parameters
4769 [X axis] [Y axis]
4770 @effect
4771 Moves a corner to a relative position inside the container of the
4772 relative "to" part. Values from 0.0 (0%, beginning) to 1.0 (100%, end)
4773 of each axis.
4774 @endproperty
4775*/
4776static void
4777st_collections_group_parts_part_description_rel1_relative(void)
4778{
4779 check_arg_count(2);
4780
4781 current_desc->rel1.relative_x = FROM_DOUBLE(parse_float(0));
4782 current_desc->rel1.relative_y = FROM_DOUBLE(parse_float(1));
4783}
4784
4785/**
4786 @page edcref
4787 @property
4788 offset
4789 @parameters
4790 [X axis] [Y axis]
4791 @effect
4792 Affects the corner position a fixed number of pixels along each axis.
4793 @endproperty
4794*/
4795static void
4796st_collections_group_parts_part_description_rel1_offset(void)
4797{
4798 check_arg_count(2);
4799
4800 current_desc->rel1.offset_x = parse_int(0);
4801 current_desc->rel1.offset_y = parse_int(1);
4802}
4803
4804/**
4805 @page edcref
4806 @property
4807 to
4808 @parameters
4809 [another part's name]
4810 @effect
4811 Causes a corner to be positioned relatively to another part's
4812 container. Setting to "" will un-set this value for inherited
4813 parts.
4814 @endproperty
4815*/
4816static void
4817st_collections_group_parts_part_description_rel1_to(void)
4818{
4819 Edje_Part_Collection *pc;
4820
4821 check_arg_count(1);
4822
4823 pc = eina_list_data_get(eina_list_last(edje_collections));
4824
4825 {
4826 char *name;
4827
4828 name = parse_str(0);
4829 data_queue_part_lookup(pc, name, &(current_desc->rel1.id_x));
4830 data_queue_part_lookup(pc, name, &(current_desc->rel1.id_y));
4831 free(name);
4832 }
4833}
4834
4835/**
4836 @page edcref
4837 @property
4838 to_x
4839 @parameters
4840 [another part's name]
4841 @effect
4842 Causes a corner to be positioned relatively to the X axis of another
4843 part's container. Simply put affects the first parameter of "relative".
4844 Setting to "" will un-set this value for inherited parts.
4845 @endproperty
4846*/
4847static void
4848st_collections_group_parts_part_description_rel1_to_x(void)
4849{
4850 Edje_Part_Collection *pc;
4851
4852 check_arg_count(1);
4853
4854 pc = eina_list_data_get(eina_list_last(edje_collections));
4855
4856 {
4857 char *name;
4858
4859 name = parse_str(0);
4860 data_queue_part_lookup(pc, name, &(current_desc->rel1.id_x));
4861 free(name);
4862 }
4863}
4864
4865/**
4866 @page edcref
4867 @property
4868 to_y
4869 @parameters
4870 [another part's name]
4871 @effect
4872 Causes a corner to be positioned relatively to the Y axis of another
4873 part's container. Simply put, affects the second parameter of
4874 "relative". Setting to "" will un-set this value for inherited parts.
4875 @endproperty
4876*/
4877static void
4878st_collections_group_parts_part_description_rel1_to_y(void)
4879{
4880 Edje_Part_Collection *pc;
4881
4882 check_arg_count(1);
4883
4884 pc = eina_list_data_get(eina_list_last(edje_collections));
4885
4886 {
4887 char *name;
4888
4889 name = parse_str(0);
4890 data_queue_part_lookup(pc, name, &(current_desc->rel1.id_y));
4891 free(name);
4892 }
4893}
4894
4895static void
4896st_collections_group_parts_part_description_rel2_relative(void)
4897{
4898 check_arg_count(2);
4899
4900 current_desc->rel2.relative_x = FROM_DOUBLE(parse_float(0));
4901 current_desc->rel2.relative_y = FROM_DOUBLE(parse_float(1));
4902}
4903
4904static void
4905st_collections_group_parts_part_description_rel2_offset(void)
4906{
4907 check_arg_count(2);
4908
4909 current_desc->rel2.offset_x = parse_int(0);
4910 current_desc->rel2.offset_y = parse_int(1);
4911}
4912
4913static void
4914st_collections_group_parts_part_description_rel2_to(void)
4915{
4916 Edje_Part_Collection *pc;
4917
4918 check_arg_count(1);
4919
4920 pc = eina_list_data_get(eina_list_last(edje_collections));
4921
4922 {
4923 char *name;
4924
4925 name = parse_str(0);
4926 data_queue_part_lookup(pc, name, &(current_desc->rel2.id_x));
4927 data_queue_part_lookup(pc, name, &(current_desc->rel2.id_y));
4928 free(name);
4929 }
4930}
4931
4932static void
4933st_collections_group_parts_part_description_rel2_to_x(void)
4934{
4935 Edje_Part_Collection *pc;
4936
4937 check_arg_count(1);
4938
4939 pc = eina_list_data_get(eina_list_last(edje_collections));
4940
4941 {
4942 char *name;
4943
4944 name = parse_str(0);
4945 data_queue_part_lookup(pc, name, &(current_desc->rel2.id_x));
4946 free(name);
4947 }
4948}
4949
4950static void
4951st_collections_group_parts_part_description_rel2_to_y(void)
4952{
4953 Edje_Part_Collection *pc;
4954
4955 check_arg_count(1);
4956
4957 pc = eina_list_data_get(eina_list_last(edje_collections));
4958
4959 {
4960 char *name;
4961
4962 name = parse_str(0);
4963 data_queue_part_lookup(pc, name, &(current_desc->rel2.id_y));
4964 free(name);
4965 }
4966}
4967
4968/**
4969 @edcsection{description_image,Image state description sub blocks}
4970 */
4971
4972/**
4973 @page edcref
4974 @block
4975 image
4976 @context
4977 description {
4978 ..
4979 image {
4980 normal: "filename.ext";
4981 tween: "filename2.ext";
4982 ..
4983 tween: "filenameN.ext";
4984 border: left right top bottom;
4985 middle: 0/1/NONE/DEFAULT/SOLID;
4986 }
4987 ..
4988 }
4989 @description
4990 @endblock
4991
4992 @property
4993 normal
4994 @parameters
4995 [image's filename]
4996 @effect
4997 Name of image to be used as previously declared in the images block.
4998 In an animation, this is the first and last image displayed. It's
4999 required in any image part
5000 @endproperty
5001*/
5002static void
5003st_collections_group_parts_part_description_image_normal(void)
5004{
5005 Edje_Part_Description_Image *ed;
5006
5007 check_arg_count(1);
5008
5009 if (current_part->type != EDJE_PART_TYPE_IMAGE)
5010 {
5011 ERR("%s: Error. parse error %s:%i. "
5012 "image attributes in non-IMAGE part.",
5013 progname, file_in, line - 1);
5014 exit(-1);
5015 }
5016
5017 ed = (Edje_Part_Description_Image*) current_desc;
5018
5019 {
5020 char *name;
5021
5022 name = parse_str(0);
5023 data_queue_image_lookup(name, &(ed->image.id), &(ed->image.set));
5024 free(name);
5025 }
5026}
5027
5028/**
5029 @page edcref
5030 @property
5031 tween
5032 @parameters
5033 [image's filename]
5034 @effect
5035 Name of an image to be used in an animation loop, an image block can
5036 have none, one or multiple tween declarations. Images are displayed in
5037 the order they are listed.
5038 @endproperty
5039*/
5040static void
5041st_collections_group_parts_part_description_image_tween(void)
5042{
5043 Edje_Part_Description_Image *ed;
5044
5045 check_arg_count(1);
5046
5047 if (current_part->type != EDJE_PART_TYPE_IMAGE)
5048 {
5049 ERR("%s: Error. parse error %s:%i. "
5050 "image attributes in non-IMAGE part.",
5051 progname, file_in, line - 1);
5052 exit(-1);
5053 }
5054
5055 ed = (Edje_Part_Description_Image*) current_desc;
5056
5057 {
5058 char *name;
5059 Edje_Part_Image_Id *iid;
5060
5061 iid = mem_alloc(SZ(Edje_Part_Image_Id));
5062 ed->image.tweens_count++;
5063 ed->image.tweens = realloc(ed->image.tweens,
5064 sizeof (Edje_Part_Image_Id*) * ed->image.tweens_count);
5065 ed->image.tweens[ed->image.tweens_count - 1] = iid;
5066 name = parse_str(0);
5067 data_queue_image_lookup(name, &(iid->id), &(iid->set));
5068 free(name);
5069 }
5070}
5071
5072/**
5073 @page edcref
5074 @property
5075 border
5076 @parameters
5077 [left] [right] [top] [bottom]
5078 @effect
5079 If set, the area (in pixels) of each side of the image will be
5080 displayed as a fixed size border, from the side -> inwards, preventing
5081 the corners from being changed on a resize.
5082 @endproperty
5083*/
5084static void
5085st_collections_group_parts_part_description_image_border(void)
5086{
5087 Edje_Part_Description_Image *ed;
5088
5089 check_arg_count(4);
5090
5091 if (current_part->type != EDJE_PART_TYPE_IMAGE)
5092 {
5093 ERR("%s: Error. parse error %s:%i. "
5094 "image attributes in non-IMAGE part.",
5095 progname, file_in, line - 1);
5096 exit(-1);
5097 }
5098
5099 ed = (Edje_Part_Description_Image*) current_desc;
5100
5101 ed->image.border.l = parse_int_range(0, 0, 0x7fffffff);
5102 ed->image.border.r = parse_int_range(1, 0, 0x7fffffff);
5103 ed->image.border.t = parse_int_range(2, 0, 0x7fffffff);
5104 ed->image.border.b = parse_int_range(3, 0, 0x7fffffff);
5105}
5106
5107/**
5108 @page edcref
5109 @property
5110 middle
5111 @parameters
5112 0, 1, NONE, DEFAULT, SOLID
5113 @effect
5114 If border is set, this value tells Edje if the rest of the
5115 image (not covered by the defined border) will be displayed or not
5116 or be assumed to be solid (without alpha). The default is 1/DEFAULT.
5117 @endproperty
5118*/
5119static void
5120st_collections_group_parts_part_description_image_middle(void)
5121{
5122 Edje_Part_Description_Image *ed;
5123
5124 check_arg_count(1);
5125
5126 if (current_part->type != EDJE_PART_TYPE_IMAGE)
5127 {
5128 ERR("%s: Error. parse error %s:%i. "
5129 "image attributes in non-IMAGE part.",
5130 progname, file_in, line - 1);
5131 exit(-1);
5132 }
5133
5134 ed = (Edje_Part_Description_Image*) current_desc;
5135
5136 ed->image.border.no_fill = parse_enum(0,
5137 "1", 0,
5138 "DEFAULT", 0,
5139 "0", 1,
5140 "NONE", 1,
5141 "SOLID", 2,
5142 NULL);
5143}
5144
5145/**
5146 @page edcref
5147 @property
5148 border_scale_by
5149 @parameters
5150 0.0 or bigger (0.0 or 1.0 to turn it off)
5151 @effect
5152 If border scaling is enabled then normally the OUTPUT border sizes
5153 (e.g. if 3 pixels on the left edge are set as a border, then normally
5154 at scale 1.0, those 3 columns will always be the exact 3 columns of
5155 output, or at scale 2.0 they will be 6 columns, or 0.33 they will merge
5156 into a single column). This property multiplies the input scale
5157 factor by this multiplier, allowing the creation of "supersampled"
5158 borders to make much higher resolution outputs possible by always using
5159 the highest resolution artwork and then runtime scaling it down.
5160 @endproperty
5161*/
5162static void
5163st_collections_group_parts_part_description_image_border_scale_by(void)
5164{
5165 Edje_Part_Description_Image *ed;
5166
5167 check_arg_count(1);
5168
5169 if (current_part->type != EDJE_PART_TYPE_IMAGE)
5170 {
5171 ERR("%s: Error. parse error %s:%i. "
5172 "image attributes in non-IMAGE part.",
5173 progname, file_in, line - 1);
5174 exit(-1);
5175 }
5176
5177 ed = (Edje_Part_Description_Image*) current_desc;
5178
5179 ed->image.border.scale_by = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0));
5180}
5181
5182/**
5183 @page edcref
5184 @property
5185 border_scale
5186 @parameters
5187 0, 1
5188 @effect
5189 If border is set, this value tells Edje if the border should be scaled
5190 by the object/global edje scale factors
5191 @endproperty
5192*/
5193static void
5194st_collections_group_parts_part_description_image_border_scale(void)
5195{
5196 Edje_Part_Description_Image *ed;
5197
5198 check_arg_count(1);
5199
5200 if (current_part->type != EDJE_PART_TYPE_IMAGE)
5201 {
5202 ERR("%s: Error. parse error %s:%i. "
5203 "image attributes in non-IMAGE part.",
5204 progname, file_in, line - 1);
5205 exit(-1);
5206 }
5207
5208 ed = (Edje_Part_Description_Image*) current_desc;
5209
5210 ed->image.border.scale = parse_enum(0,
5211 "0", 0,
5212 "1", 1,
5213 NULL);
5214}
5215
5216/**
5217 @page edcref
5218 @property
5219 scale_hint
5220 @parameters
5221 0, NONE, DYNAMIC, STATIC
5222 @effect
5223 Sets the evas image scale hint letting the engine more effectively save
5224 cached copies of the scaled image if it makes sense
5225 @endproperty
5226*/
5227static void
5228st_collections_group_parts_part_description_image_scale_hint(void)
5229{
5230 Edje_Part_Description_Image *ed;
5231
5232 check_arg_count(1);
5233
5234 if (current_part->type != EDJE_PART_TYPE_IMAGE)
5235 {
5236 ERR("%s: Error. parse error %s:%i. "
5237 "image attributes in non-IMAGE part.",
5238 progname, file_in, line - 1);
5239 exit(-1);
5240 }
5241
5242 ed = (Edje_Part_Description_Image*) current_desc;
5243
5244 ed->image.scale_hint = parse_enum(0,
5245 "NONE", EVAS_IMAGE_SCALE_HINT_NONE,
5246 "DYNAMIC", EVAS_IMAGE_SCALE_HINT_DYNAMIC,
5247 "STATIC", EVAS_IMAGE_SCALE_HINT_STATIC,
5248 "0", EVAS_IMAGE_SCALE_HINT_NONE,
5249 NULL);
5250}
5251
5252/**
5253 @page edcref
5254 @block
5255 fill
5256 @context
5257 description {
5258 ..
5259 fill {
5260 smooth: 0-1;
5261 origin {
5262 relative: X-axis Y-axis;
5263 offset: X-axis Y-axis;
5264 }
5265 size {
5266 relative: width height;
5267 offset: width height;
5268 }
5269 }
5270 ..
5271 }
5272 @description
5273 The fill method is an optional block that defines the way an IMAGE part
5274 is going to be displayed inside its container.
5275 @endblock
5276
5277 @property
5278 smooth
5279 @parameters
5280 [0 or 1]
5281 @effect
5282 The smooth property takes a boolean value to decide if the image will
5283 be smoothed on scaling (1) or not (0). The default value is 1.
5284 @endproperty
5285*/
5286static void
5287st_collections_group_parts_part_description_fill_smooth(void)
5288{
5289 Edje_Part_Description_Spec_Fill *fill;
5290
5291 check_arg_count(1);
5292
5293 switch (current_part->type)
5294 {
5295 case EDJE_PART_TYPE_IMAGE:
5296 {
5297 Edje_Part_Description_Image *ed;
5298
5299 ed = (Edje_Part_Description_Image*) current_desc;
5300
5301 fill = &ed->image.fill;
5302 break;
5303 }
5304 case EDJE_PART_TYPE_PROXY:
5305 {
5306 Edje_Part_Description_Proxy *ed;
5307
5308 ed = (Edje_Part_Description_Proxy*) current_desc;
5309
5310 fill = &ed->proxy.fill;
5311 break;
5312 }
5313 default:
5314 {
5315 ERR("%s: Error. parse error %s:%i. "
5316 "image and proxy attributes in non-IMAGE, non-PROXY `%s` part (%i).",
5317 progname, file_in, line - 1, current_part->name, current_part->type);
5318 exit(-1);
5319 }
5320 }
5321
5322 fill->smooth = parse_bool(0);
5323}
5324
5325/**
5326 @page edcref
5327
5328 @property
5329 spread
5330 @parameters
5331 TODO
5332 @effect
5333 TODO
5334 @endproperty
5335*/
5336static void
5337st_collections_group_parts_part_description_fill_spread(void)
5338{
5339#if 0
5340 Edje_Part_Collection *pc;
5341 Edje_Part *ep;
5342 Edje_Part_Description_Image *ed;
5343#endif
5344
5345 check_arg_count(1);
5346
5347 /* XXX this will need to include IMAGES when spread support is added to evas images */
5348 {
5349 ERR("%s: Error. parse error %s:%i. "
5350 "fill.spread not supported yet.",
5351 progname, file_in, line - 1);
5352 exit(-1);
5353 }
5354
5355#if 0
5356 pc = eina_list_data_get(eina_list_last(edje_collections));
5357
5358 ep = pc->parts[pc->parts_count - 1];
5359
5360 if (ep->type != EDJE_PART_TYPE_IMAGE)
5361 {
5362 ERR("%s: Error. parse error %s:%i. "
5363 "image attributes in non-IMAGE part.",
5364 progname, file_in, line - 1);
5365 exit(-1);
5366 }
5367
5368 ed = (Edje_Part_Description_Image*) ep->default_desc;
5369 if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1];
5370
5371 ed->image.fill.spread = parse_int_range(0, 0, 1);
5372#endif
5373}
5374
5375/**
5376 @page edcref
5377
5378 @property
5379 type
5380 @parameters
5381 TODO
5382 @effect
5383 TODO
5384 @endproperty
5385*/
5386static void
5387st_collections_group_parts_part_description_fill_type(void)
5388{
5389 Edje_Part_Description_Spec_Fill *fill;
5390
5391 check_arg_count(1);
5392
5393 switch (current_part->type)
5394 {
5395 case EDJE_PART_TYPE_IMAGE:
5396 {
5397 Edje_Part_Description_Image *ed;
5398
5399 ed = (Edje_Part_Description_Image*) current_desc;
5400
5401 fill = &ed->image.fill;
5402 break;
5403 }
5404 case EDJE_PART_TYPE_PROXY:
5405 {
5406 Edje_Part_Description_Proxy *ed;
5407
5408 ed = (Edje_Part_Description_Proxy*) current_desc;
5409
5410 fill = &ed->proxy.fill;
5411 break;
5412 }
5413 default:
5414 {
5415 ERR("%s: Error. parse error %s:%i. "
5416 "image and proxy attributes in non-IMAGE, non-PROXY part.",
5417 progname, file_in, line - 1);
5418 exit(-1);
5419 }
5420 }
5421
5422 fill->type = parse_enum(0,
5423 "SCALE", EDJE_FILL_TYPE_SCALE,
5424 "TILE", EDJE_FILL_TYPE_TILE,
5425 NULL);
5426}
5427
5428/**
5429 @page edcref
5430 @block
5431 origin
5432 @context
5433 description {
5434 ..
5435 fill {
5436 ..
5437 origin {
5438 relative: 0.0 0.0;
5439 offset: 0 0;
5440 }
5441 ..
5442 }
5443 ..
5444 }
5445 @description
5446 The origin block is used to place the starting point, inside the
5447 displayed element, that will be used to render the tile. By default,
5448 the origin is set at the element's left-up corner.
5449 @endblock
5450
5451 @property
5452 relative
5453 @parameters
5454 [X axis] [Y axis]
5455 @effect
5456 Sets the starting point relatively to displayed element's content.
5457 @endproperty
5458*/
5459static void
5460st_collections_group_parts_part_description_fill_origin_relative(void)
5461{
5462 Edje_Part_Description_Spec_Fill *fill;
5463
5464 check_arg_count(2);
5465
5466 switch (current_part->type)
5467 {
5468 case EDJE_PART_TYPE_IMAGE:
5469 {
5470 Edje_Part_Description_Image *ed;
5471
5472 ed = (Edje_Part_Description_Image*) current_desc;
5473
5474 fill = &ed->image.fill;
5475 break;
5476 }
5477 case EDJE_PART_TYPE_PROXY:
5478 {
5479 Edje_Part_Description_Proxy *ed;
5480
5481 ed = (Edje_Part_Description_Proxy*) current_desc;
5482
5483 fill = &ed->proxy.fill;
5484 break;
5485 }
5486 default:
5487 {
5488 ERR("%s: Error. parse error %s:%i. "
5489 "image and proxy attributes in non-IMAGE, non-PROXY part.",
5490 progname, file_in, line - 1);
5491 exit(-1);
5492 }
5493 }
5494
5495 fill->pos_rel_x = FROM_DOUBLE(parse_float_range(0, -999999999.0, 999999999.0));
5496 fill->pos_rel_y = FROM_DOUBLE(parse_float_range(1, -999999999.0, 999999999.0));
5497}
5498
5499/**
5500 @page edcref
5501 @property
5502 offset
5503 @parameters
5504 [X axis] [Y axis]
5505 @effect
5506 Affects the starting point a fixed number of pixels along each axis.
5507 @endproperty
5508*/
5509static void
5510st_collections_group_parts_part_description_fill_origin_offset(void)
5511{
5512 Edje_Part_Description_Spec_Fill *fill;
5513
5514 check_arg_count(2);
5515
5516 switch (current_part->type)
5517 {
5518 case EDJE_PART_TYPE_IMAGE:
5519 {
5520 Edje_Part_Description_Image *ed;
5521
5522 ed = (Edje_Part_Description_Image*) current_desc;
5523
5524 fill = &ed->image.fill;
5525 break;
5526 }
5527 case EDJE_PART_TYPE_PROXY:
5528 {
5529 Edje_Part_Description_Proxy *ed;
5530
5531 ed = (Edje_Part_Description_Proxy*) current_desc;
5532
5533 fill = &ed->proxy.fill;
5534 break;
5535 }
5536 default:
5537 {
5538 ERR("%s: Error. parse error %s:%i. "
5539 "image and proxy attributes in non-IMAGE, non-PROXY part.",
5540 progname, file_in, line - 1);
5541 exit(-1);
5542 }
5543 }
5544
5545 fill->pos_abs_x = parse_int(0);
5546 fill->pos_abs_y = parse_int(1);
5547}
5548
5549/**
5550 @page edcref
5551 @block
5552 size
5553 @context
5554 description {
5555 ..
5556 fill {
5557 ..
5558 size {
5559 relative: 1.0 1.0;
5560 offset: -1 -1;
5561 }
5562 ..
5563 }
5564 ..
5565 }
5566 @description
5567 The size block defines the tile size of the content that will be
5568 displayed.
5569 @endblock
5570
5571 @property
5572 relative
5573 @parameters
5574 [width] [height]
5575 @effect
5576 Takes a pair of decimal values that represent the a percentual value
5577 of the original size of the element. For example, "0.5 0.5" represents
5578 half the size, while "2.0 2.0" represents the double. The default
5579 value is "1.0 1.0".
5580 @endproperty
5581*/
5582static void
5583st_collections_group_parts_part_description_fill_size_relative(void)
5584{
5585 Edje_Part_Description_Spec_Fill *fill;
5586
5587 check_arg_count(2);
5588
5589 switch (current_part->type)
5590 {
5591 case EDJE_PART_TYPE_IMAGE:
5592 {
5593 Edje_Part_Description_Image *ed;
5594
5595 ed = (Edje_Part_Description_Image*) current_desc;
5596
5597 fill = &ed->image.fill;
5598 break;
5599 }
5600 case EDJE_PART_TYPE_PROXY:
5601 {
5602 Edje_Part_Description_Proxy *ed;
5603
5604 ed = (Edje_Part_Description_Proxy*) current_desc;
5605
5606 fill = &ed->proxy.fill;
5607 break;
5608 }
5609 default:
5610 {
5611 ERR("%s: Error. parse error %s:%i. "
5612 "image and proxy attributes in non-IMAGE, non-PROXY part.",
5613 progname, file_in, line - 1);
5614 exit(-1);
5615 }
5616 }
5617
5618 fill->rel_x = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0));
5619 fill->rel_y = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0));
5620}
5621
5622/**
5623 @page edcref
5624 @property
5625 offset
5626 @parameters
5627 [X axis] [Y axis]
5628 @effect
5629 Affects the size of the tile a fixed number of pixels along each axis.
5630 @endproperty
5631*/
5632static void
5633st_collections_group_parts_part_description_fill_size_offset(void)
5634{
5635 Edje_Part_Description_Spec_Fill *fill;
5636
5637 check_arg_count(2);
5638
5639 switch (current_part->type)
5640 {
5641 case EDJE_PART_TYPE_IMAGE:
5642 {
5643 Edje_Part_Description_Image *ed;
5644
5645 ed = (Edje_Part_Description_Image*) current_desc;
5646
5647 fill = &ed->image.fill;
5648 break;
5649 }
5650 case EDJE_PART_TYPE_PROXY:
5651 {
5652 Edje_Part_Description_Proxy *ed;
5653
5654 ed = (Edje_Part_Description_Proxy*) current_desc;
5655
5656 fill = &ed->proxy.fill;
5657 break;
5658 }
5659 default:
5660 {
5661 ERR("%s: Error. parse error %s:%i. "
5662 "image and proxy attributes in non-IMAGE, non-PROXY part.",
5663 progname, file_in, line - 1);
5664 exit(-1);
5665 }
5666 }
5667
5668 fill->abs_x = parse_int(0);
5669 fill->abs_y = parse_int(1);
5670}
5671
5672
5673/**
5674 @edcsection{description_text,Text state description sub blocks}
5675 */
5676
5677/**
5678 @page edcref
5679
5680 @block
5681 text
5682 @context
5683 part {
5684 description {
5685 ..
5686 text {
5687 text: "some string of text to display";
5688 font: "font_name";
5689 size: SIZE;
5690 text_class: "class_name";
5691 fit: horizontal vertical;
5692 min: horizontal vertical;
5693 max: horizontal vertical;
5694 align: X-axis Y-axis;
5695 source: "part_name";
5696 text_source: "text_part_name";
5697 ellipsis: 0.0-1.0;
5698 style: "stylename";
5699 }
5700 ..
5701 }
5702 }
5703 @description
5704 @endblock
5705
5706 @property
5707 text
5708 @parameters
5709 [a string of text, or nothing]
5710 @effect
5711 Sets the default content of a text part, normally the application is
5712 the one changing its value.
5713 @endproperty
5714*/
5715static void
5716st_collections_group_parts_part_description_text_text(void)
5717{
5718 Edje_Part_Description_Text *ed;
5719 char *str = NULL;
5720 int i;
5721
5722 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
5723 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
5724 {
5725 ERR("%s: Error. parse error %s:%i. "
5726 "text attributes in non-TEXT part.",
5727 progname, file_in, line - 1);
5728 exit(-1);
5729 }
5730
5731 ed = (Edje_Part_Description_Text*) current_desc;
5732
5733 for (i = 0; ;i++)
5734 {
5735 char *s;
5736
5737 if (!is_param(i)) break;
5738 s = parse_str(i);
5739 if (!str) str = s;
5740 else
5741 {
5742 str = realloc(str, strlen(str) + strlen(s) + 1);
5743 strcat(str, s);
5744 free(s);
5745 }
5746 }
5747 ed->text.text.str = str;
5748}
5749
5750/**
5751 @page edcref
5752
5753 @property
5754 text_class
5755 @parameters
5756 [text class name]
5757 @effect
5758 Similar to color_class, this is the name used by the application
5759 to alter the font family and size at runtime.
5760 @endproperty
5761*/
5762static void
5763st_collections_group_parts_part_description_text_text_class(void)
5764{
5765 Edje_Part_Description_Text *ed;
5766
5767 check_arg_count(1);
5768
5769 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
5770 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
5771 {
5772 ERR("%s: Error. parse error %s:%i. "
5773 "text attributes in non-TEXT part.",
5774 progname, file_in, line - 1);
5775 exit(-1);
5776 }
5777
5778 ed = (Edje_Part_Description_Text*) current_desc;
5779
5780 ed->text.text_class = parse_str(0);
5781}
5782
5783/**
5784 @page edcref
5785
5786 @property
5787 font
5788 @parameters
5789 [font alias]
5790 @effect
5791 This sets the font family to one of the aliases set up in the "fonts"
5792 block. Can be overrided by the application.
5793 @endproperty
5794*/
5795static void
5796st_collections_group_parts_part_description_text_font(void)
5797{
5798 Edje_Part_Description_Text *ed;
5799
5800 check_arg_count(1);
5801
5802 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
5803 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
5804 {
5805 ERR("%s: Error. parse error %s:%i. "
5806 "text attributes in non-TEXT part.",
5807 progname, file_in, line - 1);
5808 exit(-1);
5809 }
5810
5811 ed = (Edje_Part_Description_Text*) current_desc;
5812
5813 ed->text.font.str = parse_str(0);
5814}
5815
5816/**
5817 @page edcref
5818
5819 @property
5820 style
5821 @parameters
5822 [the style name]
5823 @effect
5824 Causes the part to use the default style and tags defined in the
5825 "style" block with the specified name.
5826 @endproperty
5827*/
5828static void
5829st_collections_group_parts_part_description_text_style(void)
5830{
5831 Edje_Part_Description_Text *ed;
5832
5833 check_arg_count(1);
5834
5835 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
5836 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
5837 {
5838 ERR("%s: Error. parse error %s:%i. "
5839 "text attributes in non-TEXT part.",
5840 progname, file_in, line - 1);
5841 exit(-1);
5842 }
5843
5844 ed = (Edje_Part_Description_Text*) current_desc;
5845
5846 ed->text.style.str = parse_str(0);
5847}
5848
5849/**
5850 @page edcref
5851
5852 @property
5853 repch
5854 @parameters
5855 [the replacement character string]
5856 @effect
5857 If this is a textblock and is in PASSWORD mode this string is used
5858 to replace every character to hide the details of the entry. Normally
5859 you would use a "*", but you can use anything you like.
5860 @endproperty
5861*/
5862static void
5863st_collections_group_parts_part_description_text_repch(void)
5864{
5865 Edje_Part_Description_Text *ed;
5866
5867 check_arg_count(1);
5868
5869 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
5870 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
5871 {
5872 ERR("%s: Error. parse error %s:%i. "
5873 "text attributes in non-TEXT part.",
5874 progname, file_in, line - 1);
5875 exit(-1);
5876 }
5877
5878 ed = (Edje_Part_Description_Text*) current_desc;
5879
5880 ed->text.repch.str = parse_str(0);
5881}
5882
5883/**
5884 @page edcref
5885
5886 @property
5887 size
5888 @parameters
5889 [font size in points (pt)]
5890 @effect
5891 Sets the default font size for the text part. Can be overrided by the
5892 application.
5893 @endproperty
5894*/
5895static void
5896st_collections_group_parts_part_description_text_size(void)
5897{
5898 Edje_Part_Description_Text *ed;
5899
5900 check_arg_count(1);
5901
5902 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
5903 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
5904 {
5905 ERR("%s: Error. parse error %s:%i. "
5906 "text attributes in non-TEXT part.",
5907 progname, file_in, line - 1);
5908 exit(-1);
5909 }
5910
5911 ed = (Edje_Part_Description_Text*)current_desc;
5912
5913 ed->text.size = parse_int_range(0, 0, 255);
5914}
5915
5916/**
5917 @page edcref
5918
5919 @property
5920 size_range
5921 @parameters
5922 [font min size in points (pt)] [font max size in points (pt)]
5923 @effect
5924 Sets the allowed font size for the text part. Setting min and max to 0
5925 means we won't restrict the sizing (default).
5926 @endproperty
5927 @since 1.1.0
5928*/
5929static void
5930st_collections_group_parts_part_description_text_size_range(void)
5931{
5932 Edje_Part_Description_Text *ed;
5933
5934 check_arg_count(2);
5935
5936 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
5937 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
5938 {
5939 ERR("%s: Error. parse error %s:%i. "
5940 "text attributes in non-TEXT part.",
5941 progname, file_in, line - 1);
5942 exit(-1);
5943 }
5944
5945 ed = (Edje_Part_Description_Text*) current_desc;
5946
5947 ed->text.size_range_min = parse_int_range(0, 0, 255);
5948 ed->text.size_range_max = parse_int_range(1, 0, 255);
5949 if (ed->text.size_range_min > ed->text.size_range_max)
5950 {
5951 ERR("%s: Error. parse error %s:%i. "
5952 "min size is bigger than max size.",
5953 progname, file_in, line - 1);
5954 exit(-1);
5955 }
5956}
5957
5958/**
5959 @page edcref
5960
5961 @property
5962 fit
5963 @parameters
5964 [horizontal] [vertical]
5965 @effect
5966 When any of the parameters is set to 1 edje will resize the text for it
5967 to fit in it's container. Both are disabled by default.
5968 @endproperty
5969*/
5970static void
5971st_collections_group_parts_part_description_text_fit(void)
5972{
5973 Edje_Part_Description_Text *ed;
5974
5975 check_arg_count(2);
5976
5977 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
5978 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
5979 {
5980 ERR("%s: Error. parse error %s:%i. "
5981 "text attributes in non-TEXT part.",
5982 progname, file_in, line - 1);
5983 exit(-1);
5984 }
5985
5986 ed = (Edje_Part_Description_Text*) current_desc;
5987
5988 ed->text.fit_x = parse_bool(0);
5989 ed->text.fit_y = parse_bool(1);
5990}
5991
5992/**
5993 @page edcref
5994
5995 @property
5996 min
5997 @parameters
5998 [horizontal] [vertical]
5999 @effect
6000 When any of the parameters is enabled (1) it forces the minimum size of
6001 the container to be equal to the minimum size of the text. The default
6002 value is "0 0".
6003 @endproperty
6004*/
6005static void
6006st_collections_group_parts_part_description_text_min(void)
6007{
6008 Edje_Part_Description_Text *ed;
6009
6010 check_arg_count(2);
6011
6012 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
6013 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
6014 {
6015 ERR("%s: Error. parse error %s:%i. "
6016 "text attributes in non-TEXT part.",
6017 progname, file_in, line - 1);
6018 exit(-1);
6019 }
6020
6021 ed = (Edje_Part_Description_Text*)current_desc;
6022
6023 ed->text.min_x = parse_bool(0);
6024 ed->text.min_y = parse_bool(1);
6025}
6026
6027/**
6028 @page edcref
6029
6030 @property
6031 max
6032 @parameters
6033 [horizontal] [vertical]
6034 @effect
6035 When any of the parameters is enabled (1) it forces the maximum size of
6036 the container to be equal to the maximum size of the text. The default
6037 value is "0 0".
6038 @endproperty
6039*/
6040static void
6041st_collections_group_parts_part_description_text_max(void)
6042{
6043 Edje_Part_Description_Text *ed;
6044
6045 check_arg_count(2);
6046
6047 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
6048 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
6049 {
6050 ERR("%s: Error. parse error %s:%i. "
6051 "text attributes in non-TEXT part.",
6052 progname, file_in, line - 1);
6053 exit(-1);
6054 }
6055
6056 ed = (Edje_Part_Description_Text*) current_desc;
6057
6058 ed->text.max_x = parse_bool(0);
6059 ed->text.max_y = parse_bool(1);
6060}
6061
6062/**
6063 @page edcref
6064
6065 @property
6066 align
6067 @parameters
6068 [horizontal] [vertical]
6069 @effect
6070 Change the position of the point of balance inside the container. The
6071 default value is 0.5 0.5.
6072 @endproperty
6073*/
6074static void
6075st_collections_group_parts_part_description_text_align(void)
6076{
6077 Edje_Part_Description_Text *ed;
6078
6079 check_arg_count(2);
6080
6081 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
6082 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
6083 {
6084 ERR("%s: Error. parse error %s:%i. "
6085 "text attributes in non-TEXT part.",
6086 progname, file_in, line - 1);
6087 exit(-1);
6088 }
6089
6090 ed = (Edje_Part_Description_Text*) current_desc;
6091
6092 ed->text.align.x = FROM_DOUBLE(parse_float_range(0, -1.0, 1.0));
6093 ed->text.align.y = FROM_DOUBLE(parse_float_range(1, 0.0, 1.0));
6094}
6095
6096/**
6097 @page edcref
6098
6099 @property
6100 source
6101 @parameters
6102 [another TEXT part's name]
6103 @effect
6104 Causes the part to use the text properties (like font and size) of
6105 another part and update them as they change.
6106 @endproperty
6107*/
6108static void
6109st_collections_group_parts_part_description_text_source(void)
6110{
6111 Edje_Part_Collection *pc;
6112 Edje_Part_Description_Text *ed;
6113
6114 check_arg_count(1);
6115
6116 pc = eina_list_data_get(eina_list_last(edje_collections));
6117
6118 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
6119 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
6120 {
6121 ERR("%s: Error. parse error %s:%i. "
6122 "text attributes in non-TEXT part.",
6123 progname, file_in, line - 1);
6124 exit(-1);
6125 }
6126
6127 ed = (Edje_Part_Description_Text*) current_desc;
6128
6129 {
6130 char *name;
6131
6132 name = parse_str(0);
6133 data_queue_part_lookup(pc, name, &(ed->text.id_source));
6134 free(name);
6135 }
6136}
6137
6138/**
6139 @page edcref
6140
6141 @property
6142 text_source
6143 @parameters
6144 [another TEXT part's name]
6145 @effect
6146 Causes the part to display the text content of another part and update
6147 them as they change.
6148 @endproperty
6149*/
6150static void
6151st_collections_group_parts_part_description_text_text_source(void)
6152{
6153 Edje_Part_Collection *pc;
6154 Edje_Part_Description_Text *ed;
6155
6156 check_arg_count(1);
6157
6158 pc = eina_list_data_get(eina_list_last(edje_collections));
6159
6160 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
6161 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
6162 {
6163 ERR("%s: Error. parse error %s:%i. "
6164 "text attributes in non-TEXT part.",
6165 progname, file_in, line - 1);
6166 exit(-1);
6167 }
6168
6169 ed = (Edje_Part_Description_Text*) current_desc;
6170
6171 {
6172 char *name;
6173
6174 name = parse_str(0);
6175 data_queue_part_lookup(pc, name, &(ed->text.id_text_source));
6176 free(name);
6177 }
6178}
6179
6180/**
6181 @page edcref
6182
6183 @property
6184 ellipsis
6185 @parameters
6186 [point of balance]
6187 @effect
6188 Used to balance the text in a relative point from 0.0 to 1.0, this
6189 point is the last section of the string to be cut out in case of a
6190 resize that is smaller than the text itself. The default value is 0.0.
6191 @endproperty
6192*/
6193static void
6194st_collections_group_parts_part_description_text_elipsis(void)
6195{
6196 Edje_Part_Description_Text *ed;
6197
6198 check_arg_count(1);
6199
6200 if ((current_part->type != EDJE_PART_TYPE_TEXT) &&
6201 (current_part->type != EDJE_PART_TYPE_TEXTBLOCK))
6202 {
6203 ERR("%s: Error. parse error %s:%i. "
6204 "text attributes in non-TEXT part.",
6205 progname, file_in, line - 1);
6206 exit(-1);
6207 }
6208
6209 ed = (Edje_Part_Description_Text*) current_desc;
6210
6211 ed->text.elipsis = parse_float_range(0, 0.0, 1.0);
6212}
6213
6214
6215/**
6216 @edcsection{description_box,Box state description sub blocks}
6217 */
6218
6219/**
6220 @page edcref
6221
6222 @block
6223 box
6224 @context
6225 part {
6226 description {
6227 ..
6228 box {
6229 layout: "vertical";
6230 padding: 0 2;
6231 align: 0.5 0.5;
6232 min: 0 0;
6233 }
6234 ..
6235 }
6236 }
6237 @description
6238 A box block can contain other objects and display them in different
6239 layouts, any of the predefined set, or a custom one, set by the
6240 application.
6241 @endblock
6242
6243 @property
6244 layout
6245 @parameters
6246 [primary layout] [fallback layout]
6247 @effect
6248 Sets the layout for the box:
6249 @li horizontal (default)
6250 @li vertical
6251 @li horizontal_homogeneous
6252 @li vertical_homogeneous
6253 @li horizontal_max (homogeneous to the max sized child)
6254 @li vertical_max
6255 @li horizontal_flow
6256 @li vertical_flow
6257 @li stack
6258 @li some_other_custom_layout_set_by_the_application
6259 You could set a custom layout as fallback, it makes very
6260 very little sense though, and if that one fails, it will
6261 default to horizontal.
6262 @endproperty
6263
6264 @property
6265 align
6266 @parameters
6267 [horizontal] [vertical]
6268 @effect
6269 Change the position of the point of balance inside the container. The
6270 default value is 0.5 0.5.
6271 @endproperty
6272
6273 @property
6274 padding
6275 @parameters
6276 [horizontal] [vertical]
6277 @effect
6278 Sets the space between cells in pixels. Defaults to 0 0.
6279 @endproperty
6280
6281 @property
6282 min
6283 @parameters
6284 [horizontal] [vertical]
6285 @effect
6286 When any of the parameters is enabled (1) it forces the minimum size of
6287 the box to be equal to the minimum size of the items. The default
6288 value is "0 0".
6289 @endproperty
6290*/
6291static void st_collections_group_parts_part_description_box_layout(void)
6292{
6293 Edje_Part_Description_Box *ed;
6294
6295 check_min_arg_count(1);
6296
6297 if (current_part->type != EDJE_PART_TYPE_BOX)
6298 {
6299 ERR("%s: Error. parse error %s:%i. "
6300 "box attributes in non-BOX part.",
6301 progname, file_in, line - 1);
6302 exit(-1);
6303 }
6304
6305 ed = (Edje_Part_Description_Box*) current_desc;
6306
6307 ed->box.layout = parse_str(0);
6308 if (is_param(1))
6309 ed->box.alt_layout = parse_str(1);
6310}
6311
6312static void st_collections_group_parts_part_description_box_align(void)
6313{
6314 Edje_Part_Description_Box *ed;
6315
6316 check_arg_count(2);
6317
6318 if (current_part->type != EDJE_PART_TYPE_BOX)
6319 {
6320 ERR("%s: Error. parse error %s:%i. "
6321 "box attributes in non-BOX part.",
6322 progname, file_in, line - 1);
6323 exit(-1);
6324 }
6325
6326 ed = (Edje_Part_Description_Box*) current_desc;
6327
6328 ed->box.align.x = FROM_DOUBLE(parse_float_range(0, -1.0, 1.0));
6329 ed->box.align.y = FROM_DOUBLE(parse_float_range(1, -1.0, 1.0));
6330}
6331
6332static void st_collections_group_parts_part_description_box_padding(void)
6333{
6334 Edje_Part_Description_Box *ed;
6335
6336 check_arg_count(2);
6337
6338 if (current_part->type != EDJE_PART_TYPE_BOX)
6339 {
6340 ERR("%s: Error. parse error %s:%i. "
6341 "box attributes in non-BOX part.",
6342 progname, file_in, line - 1);
6343 exit(-1);
6344 }
6345
6346 ed = (Edje_Part_Description_Box*) current_desc;
6347
6348 ed->box.padding.x = parse_int_range(0, 0, 0x7fffffff);
6349 ed->box.padding.y = parse_int_range(1, 0, 0x7fffffff);
6350}
6351
6352static void
6353st_collections_group_parts_part_description_box_min(void)
6354{
6355 Edje_Part_Description_Box *ed;
6356
6357 check_arg_count(2);
6358
6359 if (current_part->type != EDJE_PART_TYPE_BOX)
6360 {
6361 ERR("%s: Error. parse error %s:%i. "
6362 "box attributes in non-BOX part.",
6363 progname, file_in, line - 1);
6364 exit(-1);
6365 }
6366
6367 ed = (Edje_Part_Description_Box*) current_desc;
6368
6369 ed->box.min.h = parse_bool(0);
6370 ed->box.min.v = parse_bool(1);
6371}
6372
6373
6374/**
6375 @edcsection{description_table,Table state description sub blocks}
6376 */
6377
6378/**
6379 @page edcref
6380
6381 @block
6382 table
6383 @context
6384 part {
6385 description {
6386 ..
6387 table {
6388 homogeneous: TABLE;
6389 padding: 0 2;
6390 align: 0.5 0.5;
6391 min: 0 0;
6392 }
6393 ..
6394 }
6395 }
6396 @description
6397 A table block can contain other objects packed in multiple columns
6398 and rows, and each item can span across more than one column and/or
6399 row.
6400 @endblock
6401
6402 @property
6403 homogeneous
6404 @parameters
6405 [homogeneous mode]
6406 @effect
6407 Sets the homogeneous mode for the table:
6408 @li NONE (default)
6409 @li TABLE
6410 @li ITEM
6411 @endproperty
6412
6413 @property
6414 align
6415 @parameters
6416 [horizontal] [vertical]
6417 @effect
6418 Change the position of the point of balance inside the container. The
6419 default value is 0.5 0.5.
6420 @endproperty
6421
6422 @property
6423 padding
6424 @parameters
6425 [horizontal] [vertical]
6426 @effect
6427 Sets the space between cells in pixels. Defaults to 0 0.
6428 @endproperty
6429
6430 @property
6431 min
6432 @parameters
6433 [horizontal] [vertical]
6434 @effect
6435 When any of the parameters is enabled (1) it forces the minimum size of
6436 the table to be equal to the minimum size of the items. The default
6437 value is "0 0".
6438 @endproperty
6439*/
6440static void st_collections_group_parts_part_description_table_homogeneous(void)
6441{
6442 Edje_Part_Description_Table *ed;
6443
6444 check_min_arg_count(1);
6445
6446 if (current_part->type != EDJE_PART_TYPE_TABLE)
6447 {
6448 ERR("%s: Error. parse error %s:%i. "
6449 "table attributes in non-TABLE part.",
6450 progname, file_in, line - 1);
6451 exit(-1);
6452 }
6453
6454 ed = (Edje_Part_Description_Table*) current_desc;
6455
6456 ed->table.homogeneous = parse_enum(0,
6457 "NONE", EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE,
6458 "TABLE", EDJE_OBJECT_TABLE_HOMOGENEOUS_TABLE,
6459 "ITEM", EDJE_OBJECT_TABLE_HOMOGENEOUS_ITEM,
6460 NULL);
6461}
6462
6463static void st_collections_group_parts_part_description_table_align(void)
6464{
6465 Edje_Part_Description_Table *ed;
6466
6467 check_arg_count(2);
6468
6469 if (current_part->type != EDJE_PART_TYPE_TABLE)
6470 {
6471 ERR("%s: Error. parse error %s:%i. "
6472 "table attributes in non-TABLE part.",
6473 progname, file_in, line - 1);
6474 exit(-1);
6475 }
6476
6477 ed = (Edje_Part_Description_Table*) current_desc;
6478
6479 ed->table.align.x = FROM_DOUBLE(parse_float_range(0, -1.0, 1.0));
6480 ed->table.align.y = FROM_DOUBLE(parse_float_range(1, -1.0, 1.0));
6481}
6482
6483static void st_collections_group_parts_part_description_table_padding(void)
6484{
6485 Edje_Part_Description_Table *ed;
6486
6487 check_arg_count(2);
6488
6489 if (current_part->type != EDJE_PART_TYPE_TABLE)
6490 {
6491 ERR("%s: Error. parse error %s:%i. "
6492 "table attributes in non-TABLE part.",
6493 progname, file_in, line - 1);
6494 exit(-1);
6495 }
6496
6497 ed = (Edje_Part_Description_Table*) current_desc;
6498
6499 ed->table.padding.x = parse_int_range(0, 0, 0x7fffffff);
6500 ed->table.padding.y = parse_int_range(1, 0, 0x7fffffff);
6501}
6502
6503static void
6504st_collections_group_parts_part_description_table_min(void)
6505{
6506 Edje_Part_Description_Table *ed;
6507
6508 check_arg_count(2);
6509
6510 if (current_part->type != EDJE_PART_TYPE_TABLE)
6511 {
6512 ERR("%s: Error. parse error %s:%i. "
6513 "box attributes in non-TABLE part.",
6514 progname, file_in, line - 1);
6515 exit(-1);
6516 }
6517
6518 ed = (Edje_Part_Description_Table*) current_desc;
6519
6520 ed->table.min.h = parse_bool(0);
6521 ed->table.min.v = parse_bool(1);
6522}
6523
6524/**
6525 @edcsection{description_map,Map state description sub blocks}
6526 */
6527
6528/**
6529 @page edcref
6530 @block
6531 map
6532 @context
6533 description {
6534 ..
6535 map {
6536 perspective: "name";
6537 light: "name";
6538 on: 1;
6539 smooth: 1;
6540 perspective_on: 1;
6541 backface_cull: 1;
6542 alpha: 1;
6543
6544 rotation {
6545 ..
6546 }
6547 }
6548 ..
6549 }
6550
6551 @description
6552 @endblock
6553
6554 @property
6555 perspective
6556 @parameters
6557 [another part's name]
6558 @effect
6559 This sets the part that is used as the "perspective point" for giving
6560 a part a "3d look". The perspective point should have a perspective
6561 section that provides zplane and focal properties. The center of this
6562 part will be used as the focal point, so size, color and visibility
6563 etc. are not relevant just center point, zplane and focal are used.
6564 This also implicitly enables perspective transforms (see the on
6565 parameter for the map section).
6566 @endproperty
6567*/
6568static void
6569st_collections_group_parts_part_description_map_perspective(void)
6570{
6571 Edje_Part_Collection *pc;
6572
6573 check_arg_count(1);
6574
6575 pc = eina_list_data_get(eina_list_last(edje_collections));
6576
6577 {
6578 char *name;
6579
6580 name = parse_str(0);
6581 data_queue_part_lookup(pc, name, &(current_desc->map.id_persp));
6582 free(name);
6583 }
6584
6585 current_desc->map.persp_on = 1;
6586}
6587
6588/**
6589 @page edcref
6590 @property
6591 light
6592 @parameters
6593 [another part's name]
6594 @effect
6595 This sets the part that is used as the "light" for calculating the
6596 brightness (based on how directly the part's surface is facing the
6597 light source point). Like the perspective point part, the center point
6598 is used and zplane is used for the z position (0 being the zero-plane
6599 where all 2D objects normally live) and positive values being further
6600 away into the distance. The light part color is used as the light
6601 color (alpha not used for light color). The color2 color is used for
6602 the ambient lighting when calculating brightness (alpha also not
6603 used).
6604 @endproperty
6605*/
6606static void
6607st_collections_group_parts_part_description_map_light(void)
6608{
6609 Edje_Part_Collection *pc;
6610
6611 check_arg_count(1);
6612
6613 pc = eina_list_data_get(eina_list_last(edje_collections));
6614
6615 {
6616 char *name;
6617
6618 name = parse_str(0);
6619 data_queue_part_lookup(pc, name, &(current_desc->map.id_light));
6620 free(name);
6621 }
6622}
6623
6624/**
6625 @page edcref
6626 @property
6627 on
6628 @parameters
6629 [1 or 0]
6630 @effect
6631 This enables mapping for the part. Default is 0.
6632 @endproperty
6633*/
6634static void
6635st_collections_group_parts_part_description_map_on(void)
6636{
6637 check_arg_count(1);
6638
6639 current_desc->map.on = parse_bool(0);
6640}
6641
6642/**
6643 @page edcref
6644 @property
6645 smooth
6646 @parameters
6647 [1 or 0]
6648 @effect
6649 This enable smooth map rendering. This may be linear interpolation,
6650 anisotropic filtering or anything the engine decides is "smooth".
6651 This is a best-effort hint and may not produce precisely the same
6652 results in all engines and situations. Default is 1
6653 @endproperty
6654*/
6655static void
6656st_collections_group_parts_part_description_map_smooth(void)
6657{
6658 check_arg_count(1);
6659
6660 current_desc->map.smooth = parse_bool(0);
6661}
6662
6663/**
6664 @page edcref
6665 @property
6666 alpha
6667 @parameters
6668 [1 or 0]
6669 @effect
6670 This enable alpha channel when map rendering. Default is 1.
6671 @endproperty
6672*/
6673static void
6674st_collections_group_parts_part_description_map_alpha(void)
6675{
6676 check_arg_count(1);
6677
6678 current_desc->map.alpha = parse_bool(0);
6679}
6680
6681/**
6682 @page edcref
6683 @property
6684 backface_cull
6685 @parameters
6686 [1 or 0]
6687 @effect
6688 This enables backface culling (when the rotated part that normally
6689 faces the camera is facing away after being rotated etc.). This means
6690 that the object will be hidden when "backface culled".
6691 @endproperty
6692*/
6693static void
6694st_collections_group_parts_part_description_map_backface_cull(void)
6695{
6696 check_arg_count(1);
6697
6698 current_desc->map.backcull = parse_bool(0);
6699}
6700
6701/**
6702 @page edcref
6703 @property
6704 perspective_on
6705 @parameters
6706 [1 or 0]
6707 @effect
6708 Enable perspective when rotating even without a perspective point object.
6709 This would use perspective set for the object itself or for the
6710 canvas as a whole as the global perspective with
6711 edje_perspective_set() and edje_perspective_global_set().
6712 @endproperty
6713*/
6714static void
6715st_collections_group_parts_part_description_map_perspective_on(void)
6716{
6717 check_arg_count(1);
6718
6719 current_desc->map.persp_on = parse_bool(0);
6720}
6721/**
6722 @page edcref
6723 @block
6724 rotation
6725 @context
6726 map {
6727 ..
6728 rotation {
6729 center: "name";
6730 x: 45.0;
6731 y: 45.0;
6732 z: 45.0;
6733 }
6734 ..
6735 }
6736 @description
6737 Rotates the part, optionally with the center on another part.
6738 @endblock
6739
6740 @property
6741 center
6742 @parameters
6743 [another part's name]
6744 @effect
6745 This sets the part that is used as the center of rotation when
6746 rotating the part with this description. The part's center point
6747 is used as the rotation center when applying rotation around the
6748 x, y and z axes. If no center is given, the parts original center
6749 itself is used for the rotation center.
6750 @endproperty
6751*/
6752static void
6753st_collections_group_parts_part_description_map_rotation_center(void)
6754{
6755 Edje_Part_Collection *pc;
6756
6757 check_arg_count(1);
6758
6759 pc = eina_list_data_get(eina_list_last(edje_collections));
6760
6761 {
6762 char *name;
6763
6764 name = parse_str(0);
6765 data_queue_part_lookup(pc, name, &(current_desc->map.rot.id_center));
6766 free(name);
6767 }
6768}
6769
6770/**
6771 @page edcref
6772 @property
6773 x
6774 @parameters
6775 [X degrees]
6776 @effect
6777 This sets the rotation around the x axis of the part considering
6778 the center set. In degrees.
6779 @endproperty
6780*/
6781static void
6782st_collections_group_parts_part_description_map_rotation_x(void)
6783{
6784 check_arg_count(1);
6785
6786 current_desc->map.rot.x = FROM_DOUBLE(parse_float(0));
6787}
6788
6789/**
6790 @page edcref
6791 @property
6792 y
6793 @parameters
6794 [Y degrees]
6795 @effect
6796 This sets the rotation around the u axis of the part considering
6797 the center set. In degrees.
6798 @endproperty
6799*/
6800static void
6801st_collections_group_parts_part_description_map_rotation_y(void)
6802{
6803 check_arg_count(1);
6804
6805 current_desc->map.rot.y = FROM_DOUBLE(parse_float(0));
6806}
6807
6808/**
6809 @page edcref
6810 @property
6811 z
6812 @parameters
6813 [Z degrees]
6814 @effect
6815 This sets the rotation around the z axis of the part considering
6816 the center set. In degrees.
6817 @endproperty
6818*/
6819static void
6820st_collections_group_parts_part_description_map_rotation_z(void)
6821{
6822 check_arg_count(1);
6823
6824 current_desc->map.rot.z = FROM_DOUBLE(parse_float(0));
6825}
6826
6827/**
6828 @page edcref
6829 @block
6830 perspective
6831 @context
6832 description {
6833 ..
6834 perspective {
6835 zplane: 0;
6836 focal: 1000;
6837 }
6838 ..
6839 }
6840 @description
6841 Adds focal and plane perspective to the part. Active if perspective_on is true.
6842 Must be provided if the part is being used by other part as it's perspective target.
6843 @endblock
6844
6845 @property
6846 zplane
6847 @parameters
6848 [unscaled Z value]
6849 @effect
6850 This sets the z value that will not be scaled. Normally this is 0 as
6851 that is the z distance that all objects are at normally.
6852 @endproperty
6853*/
6854static void
6855st_collections_group_parts_part_description_perspective_zplane(void)
6856{
6857 check_arg_count(1);
6858
6859 current_desc->persp.zplane = parse_int(0);
6860}
6861
6862
6863/**
6864 @page edcref
6865 @property
6866 focal
6867 @parameters
6868 [distance]
6869 @effect
6870 This sets the distance from the focal z plane (zplane) and the
6871 camera - i.e. very much equating to focal length of the camera
6872 @endproperty
6873*/
6874static void
6875st_collections_group_parts_part_description_perspective_focal(void)
6876{
6877 check_arg_count(1);
6878
6879 current_desc->persp.focal = parse_int_range(0, 1, 0x7fffffff);
6880}
6881
6882
6883/**
6884 @edcsection{description_params,Params state description sub blocks}
6885 */
6886
6887/**
6888 @page edcref
6889 @block
6890 params
6891 @context
6892 description {
6893 ..
6894 params {
6895 int: "name" 0;
6896 double: "other_name" 0.0;
6897 string: "another_name" "some text";
6898 bool: "name" 1;
6899 choice: "some_name" "value";
6900 }
6901 ..
6902 }
6903 @description
6904 Set parameters for EXTERNAL parts. The value overwrites previous
6905 definitions with the same name.
6906 @endblock
6907*/
6908static void
6909_st_collections_group_parts_part_description_params(Edje_External_Param_Type type)
6910{
6911 Edje_Part_Description_External *ed;
6912 Edje_External_Param *param;
6913 Eina_List *l;
6914 const char *name;
6915 int found = 0;
6916
6917 check_arg_count(2);
6918
6919 if (current_part->type != EDJE_PART_TYPE_EXTERNAL)
6920 {
6921 ERR("%s: Error. parse error %s:%i. "
6922 "params in non-EXTERNAL part.",
6923 progname, file_in, line - 1);
6924 exit(-1);
6925 }
6926
6927 ed = (Edje_Part_Description_External*) current_desc;
6928
6929 name = parse_str(0);
6930
6931 /* if a param with this name already exists, overwrite it */
6932 EINA_LIST_FOREACH(ed->external_params, l, param)
6933 {
6934 if (!strcmp(param->name, name))
6935 {
6936 found = 1;
6937 break;
6938 }
6939 }
6940
6941 if (!found)
6942 {
6943 param = mem_alloc(SZ(Edje_External_Param));
6944 param->name = name;
6945 }
6946
6947 param->type = type;
6948 param->i = 0;
6949 param->d = 0;
6950 param->s = NULL;
6951
6952 switch (type)
6953 {
6954 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
6955 case EDJE_EXTERNAL_PARAM_TYPE_INT:
6956 param->i = parse_int(1);
6957 break;
6958 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
6959 param->d = parse_float(1);
6960 break;
6961 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
6962 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
6963 param->s = parse_str(1);
6964 break;
6965 default:
6966 ERR("%s: Error. parse error %s:%i. Invalid param type.\n",
6967 progname, file_in, line - 1);
6968 break;
6969 }
6970
6971 if (!found)
6972 ed->external_params = eina_list_append(ed->external_params, param);
6973}
6974
6975/**
6976 @page edcref
6977 @property
6978 int
6979 @parameters
6980 [param_name] [int_value]
6981 @effect
6982 Adds an integer parameter for an external object
6983 @endproperty
6984*/
6985static void
6986st_collections_group_parts_part_description_params_int(void)
6987{
6988 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_INT);
6989}
6990
6991/**
6992 @page edcref
6993 @property
6994 double
6995 @parameters
6996 [param_name] [double_value]
6997 @effect
6998 Adds a double parameter for an external object
6999 @endproperty
7000*/
7001static void
7002st_collections_group_parts_part_description_params_double(void)
7003{
7004 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_DOUBLE);
7005}
7006
7007/**
7008 @page edcref
7009 @property
7010 string
7011 @parameters
7012 [param_name] [string_value]
7013 @effect
7014 Adds a string parameter for an external object
7015 @endproperty
7016*/
7017static void
7018st_collections_group_parts_part_description_params_string(void)
7019{
7020 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_STRING);
7021}
7022
7023/**
7024 @page edcref
7025 @property
7026 bool
7027 @parameters
7028 [param_name] [bool_value]
7029 @effect
7030 Adds an boolean parameter for an external object. Value must be 0 or 1.
7031 @endproperty
7032*/
7033static void
7034st_collections_group_parts_part_description_params_bool(void)
7035{
7036 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_BOOL);
7037}
7038
7039/**
7040 @page edcref
7041 @property
7042 choice
7043 @parameters
7044 [param_name] [choice_string]
7045 @effect
7046 Adds a choice parameter for an external object. The possible
7047 choice values are defined by external type at their register time
7048 and will be validated at runtime.
7049 @endproperty
7050*/
7051static void
7052st_collections_group_parts_part_description_params_choice(void)
7053{
7054 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_CHOICE);
7055}
7056
7057
7058/**
7059 @edcsection{program, Program block}
7060 */
7061
7062/**
7063 @page edcref
7064 @block
7065 program
7066 @context
7067 group {
7068 programs {
7069 ..
7070 program {
7071 name: "programname";
7072 signal: "signalname";
7073 source: "partname";
7074 filter: "partname" "statename";
7075 in: 0.3 0.0;
7076 action: STATE_SET "statename" state_value;
7077 transition: LINEAR 0.5;
7078 target: "partname";
7079 target: "anotherpart";
7080 after: "programname";
7081 after: "anotherprogram";
7082 }
7083 ..
7084 }
7085 }
7086 @description
7087 Programs define how your interface reacts to events.
7088 Programs can change the state of parts, react to events or trigger
7089 other events.
7090 @endblock
7091*/
7092static void
7093ob_collections_group_programs_program(void)
7094{
7095 Edje_Part_Collection *pc;
7096 Edje_Program *ep;
7097 Edje_Program_Parser *epp;
7098
7099 pc = eina_list_data_get(eina_list_last(edje_collections));
7100
7101 ep = mem_alloc(SZ(Edje_Program_Parser));
7102 ep->id = -1;
7103 ep->tween.mode = EDJE_TWEEN_MODE_LINEAR;
7104 ep->after = NULL;
7105 epp = (Edje_Program_Parser *)ep;
7106 epp->can_override = EINA_FALSE;
7107
7108 _edje_program_insert(pc, ep);
7109
7110 current_program = ep;
7111}
7112
7113/**
7114 @page edcref
7115 @property
7116 name
7117 @parameters
7118 [program name]
7119 @effect
7120 Symbolic name of program as a unique identifier.
7121 @endproperty
7122*/
7123static void
7124st_collections_group_programs_program_name(void)
7125{
7126 Edje_Part_Collection *pc;
7127
7128 check_arg_count(1);
7129
7130 pc = eina_list_data_get(eina_list_last(edje_collections));
7131 current_program->name = parse_str(0);
7132
7133 _edje_program_check(current_program->name, current_program, pc->programs.fnmatch, pc->programs.fnmatch_count);
7134 _edje_program_check(current_program->name, current_program, pc->programs.strcmp, pc->programs.strcmp_count);
7135 _edje_program_check(current_program->name, current_program, pc->programs.strncmp, pc->programs.strncmp_count);
7136 _edje_program_check(current_program->name, current_program, pc->programs.strrncmp, pc->programs.strrncmp_count);
7137 _edje_program_check(current_program->name, current_program, pc->programs.nocmp, pc->programs.nocmp_count);
7138}
7139
7140/**
7141 @page edcref
7142 @property
7143 signal
7144 @parameters
7145 [signal name]
7146 @effect
7147 Specifies signal(s) that should cause the program to run. The signal
7148 received must match the specified source to run.
7149 Signals may be globbed, but only one signal keyword per program
7150 may be used. ex: signal: "mouse,clicked,*"; (clicking any mouse button
7151 that matches source starts program).
7152 @endproperty
7153*/
7154static void
7155st_collections_group_programs_program_signal(void)
7156{
7157 Edje_Part_Collection *pc;
7158
7159 check_arg_count(1);
7160
7161 pc = eina_list_data_get(eina_list_last(edje_collections));
7162
7163 _edje_program_remove(pc, current_program);
7164 current_program->signal = parse_str(0);
7165 _edje_program_insert(pc, current_program);
7166}
7167
7168/**
7169 @page edcref
7170 @property
7171 source
7172 @parameters
7173 [source name]
7174 @effect
7175 Source of accepted signal. Sources may be globbed, but only one source
7176 keyword per program may be used. ex:source: "button-*"; (Signals from
7177 any part or program named "button-*" are accepted).
7178 @endproperty
7179*/
7180static void
7181st_collections_group_programs_program_source(void)
7182{
7183 Edje_Part_Collection *pc;
7184
7185 check_arg_count(1);
7186
7187 pc = eina_list_data_get(eina_list_last(edje_collections));
7188
7189 _edje_program_remove(pc, current_program);
7190 current_program->source = parse_str(0);
7191 _edje_program_insert(pc, current_program);
7192}
7193
7194/**
7195 @page edcref
7196 @property
7197 filter
7198 @parameters
7199 [part] [state]
7200 @effect
7201 Filter signals to be only accepted if the part [part] is in state named [state].
7202 Only one filter per program can be used. If [state] is not given, the source of
7203 the event will be used instead.
7204 @endproperty
7205*/
7206static void
7207st_collections_group_programs_program_filter(void)
7208{
7209 check_min_arg_count(1);
7210
7211 if(is_param(1)) {
7212 current_program->filter.part = parse_str(0);
7213 current_program->filter.state = parse_str(1);
7214 } else {
7215 current_program->filter.state = parse_str(0);
7216 }
7217}
7218
7219/**
7220 @page edcref
7221 @property
7222 in
7223 @parameters
7224 [from] [range]
7225 @effect
7226 Wait 'from' seconds before executing the program. And add a random
7227 number of seconds (from 0 to 'range') to the total waiting time.
7228 @endproperty
7229*/
7230static void
7231st_collections_group_programs_program_in(void)
7232{
7233 check_arg_count(2);
7234
7235 current_program->in.from = parse_float_range(0, 0.0, 999999999.0);
7236 current_program->in.range = parse_float_range(1, 0.0, 999999999.0);
7237}
7238
7239#ifdef ENABLE_MULTISENSE
7240/* add to docs below
7241, PLAY_SAMPLE, PLAY_TONE
7242
7243 action: PLAY_SAMPLE "sample name";\n
7244 action: PLAY_TONE "tone name" duration in seconds ( Range 0.1 to 10.0 );\n
7245*/
7246#endif
7247
7248/**
7249 @page edcref
7250 @property
7251 action
7252 @parameters
7253 [type] [param1] [param2]
7254 @effect
7255 Action to be performed by the program. Valid actions are: STATE_SET,
7256 ACTION_STOP, SIGNAL_EMIT, DRAG_VAL_SET, DRAG_VAL_STEP, DRAG_VAL_PAGE,
7257 FOCUS_SET, PARAM_COPY, PARAM_SET
7258 Only one action can be specified per program. Examples:\n
7259 action: STATE_SET "statename" 0.5;\n
7260 action: ACTION_STOP;\n
7261 action: SIGNAL_EMIT "signalname" "emitter";\n
7262 action: DRAG_VAL_SET 0.5 0.0;\n
7263 action: DRAG_VAL_STEP 1.0 0.0;\n
7264 action: DRAG_VAL_PAGE 0.0 0.0;\n
7265 action: FOCUS_SET;\n
7266 action: FOCUS_OBJECT;\n
7267 action: PARAM_COPY "src_part" "src_param" "dst_part" "dst_param";\n
7268 action: PARAM_SET "part" "param" "value";\n
7269 @endproperty
7270*/
7271static void
7272st_collections_group_programs_program_action(void)
7273{
7274 Edje_Part_Collection *pc;
7275 Edje_Program *ep;
7276
7277 pc = eina_list_data_get(eina_list_last(edje_collections));
7278 ep = current_program;
7279 ep->action = parse_enum(0,
7280 "STATE_SET", EDJE_ACTION_TYPE_STATE_SET,
7281 "ACTION_STOP", EDJE_ACTION_TYPE_ACTION_STOP,
7282 "SIGNAL_EMIT", EDJE_ACTION_TYPE_SIGNAL_EMIT,
7283 "DRAG_VAL_SET", EDJE_ACTION_TYPE_DRAG_VAL_SET,
7284 "DRAG_VAL_STEP", EDJE_ACTION_TYPE_DRAG_VAL_STEP,
7285 "DRAG_VAL_PAGE", EDJE_ACTION_TYPE_DRAG_VAL_PAGE,
7286 "SCRIPT", EDJE_ACTION_TYPE_SCRIPT,
7287 "FOCUS_SET", EDJE_ACTION_TYPE_FOCUS_SET,
7288 "FOCUS_OBJECT", EDJE_ACTION_TYPE_FOCUS_OBJECT,
7289 "PARAM_COPY", EDJE_ACTION_TYPE_PARAM_COPY,
7290 "PARAM_SET", EDJE_ACTION_TYPE_PARAM_SET,
7291#ifdef ENABLE_MULTISENSE
7292 "PLAY_SAMPLE", EDJE_ACTION_TYPE_SOUND_SAMPLE,
7293 "PLAY_TONE", EDJE_ACTION_TYPE_SOUND_TONE,
7294#endif
7295 NULL);
7296 if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
7297 {
7298 ep->state = parse_str(1);
7299 ep->value = parse_float_range(2, 0.0, 1.0);
7300 }
7301 else if (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT)
7302 {
7303 ep->state = parse_str(1);
7304 ep->state2 = parse_str(2);
7305 }
7306#ifdef ENABLE_MULTISENSE
7307 else if (ep->action == EDJE_ACTION_TYPE_SOUND_SAMPLE)
7308 {
7309 int i;
7310
7311 ep->sample_name = parse_str(1);
7312 for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++)
7313 {
7314 if (!strcmp(edje_file->sound_dir->samples[i].name, ep->sample_name))
7315 break;
7316 if (i == (int)(edje_file->sound_dir->samples_count - 1))
7317 {
7318 ERR("%s: Error. No Sample name %s exist.", progname,
7319 ep->sample_name);
7320 exit(-1);
7321 }
7322 }
7323 ep->speed = parse_float_range(2, 0.0, 10.0);
7324 }
7325 else if (ep->action == EDJE_ACTION_TYPE_SOUND_TONE)
7326 {
7327 int i;
7328
7329 ep->tone_name = parse_str(1);
7330 for (i = 0; i < (int)edje_file->sound_dir->tones_count; i++)
7331 {
7332 if (!strcmp(edje_file->sound_dir->tones[i].name, ep->tone_name))
7333 break;
7334 if (i == (int)(edje_file->sound_dir->tones_count - 1))
7335 {
7336 ERR("%s: Error. No Tone name %s exist.", progname,
7337 ep->tone_name);
7338 exit(-1);
7339 }
7340 }
7341 ep->duration = parse_float_range(2, 0.1, 10.0);
7342 }
7343#endif
7344 else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_SET)
7345 {
7346 ep->value = parse_float(1);
7347 ep->value2 = parse_float(2);
7348 }
7349 else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_STEP)
7350 {
7351 ep->value = parse_float(1);
7352 ep->value2 = parse_float(2);
7353 }
7354 else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_PAGE)
7355 {
7356 ep->value = parse_float(1);
7357 ep->value2 = parse_float(2);
7358 }
7359 else if (ep->action == EDJE_ACTION_TYPE_PARAM_COPY)
7360 {
7361 char *src_part, *dst_part;
7362
7363 src_part = parse_str(1);
7364 ep->state = parse_str(2);
7365 dst_part = parse_str(3);
7366 ep->state2 = parse_str(4);
7367
7368 data_queue_part_lookup(pc, src_part, &(ep->param.src));
7369 data_queue_part_lookup(pc, dst_part, &(ep->param.dst));
7370
7371 free(src_part);
7372 free(dst_part);
7373 }
7374 else if (ep->action == EDJE_ACTION_TYPE_PARAM_SET)
7375 {
7376 char *part;
7377
7378 part = parse_str(1);
7379 ep->state = parse_str(2);
7380 ep->state2 = parse_str(3);
7381
7382 data_queue_part_lookup(pc, part, &(ep->param.dst));
7383 free(part);
7384 }
7385
7386 switch (ep->action)
7387 {
7388 case EDJE_ACTION_TYPE_ACTION_STOP:
7389 check_arg_count(1);
7390 break;
7391 case EDJE_ACTION_TYPE_SCRIPT:
7392 /* this is implicitly set by script {} so this is here just for
7393 * completeness */
7394 break;
7395 case EDJE_ACTION_TYPE_FOCUS_OBJECT:
7396 case EDJE_ACTION_TYPE_FOCUS_SET:
7397 check_arg_count(1);
7398 break;
7399 case EDJE_ACTION_TYPE_PARAM_COPY:
7400 check_arg_count(5);
7401 break;
7402 case EDJE_ACTION_TYPE_PARAM_SET:
7403 check_arg_count(4);
7404 break;
7405#ifdef ENABLE_MULTISENSE
7406 case EDJE_ACTION_TYPE_SOUND_SAMPLE:
7407 check_arg_count(3);
7408 break;
7409 case EDJE_ACTION_TYPE_SOUND_TONE:
7410 check_arg_count(3);
7411 break;
7412#endif
7413 default:
7414 check_arg_count(3);
7415 }
7416}
7417
7418/**
7419 @page edcref
7420 @property
7421 transition
7422 @parameters
7423 [type] [length] [[interp val 1]] [[interp val 2]] [[option]]
7424 @effect
7425 Defines how transitions occur using STATE_SET action.\n
7426 Where 'type' is the style of the transition and 'length' is a double
7427 specifying the number of seconds in which to preform the transition.\n
7428 Valid types are: LIN or LINEAR, SIN or SINUSOIDAL,
7429 ACCEL or ACCELERATE, DECEL or DECELERATE,
7430 ACCEL_FAC or ACCELERATE_FACTOR, DECEL_FAC or DECELERATE_FACTOR,
7431 SIN_FAC or SINUSOIDAL_FACTOR, DIVIS or DIVISOR_INTERP,
7432 BOUNCE, SPRING.
7433
7434 ACCEL_FAC, DECEL_FAC and SIN_FAC need the extra optional
7435 "interp val 1" to determine the "factor" of curviness. 1.0 is the same
7436 as their non-factor counterparts, where 0.0 is equal to linear.
7437 numbers higher than one make the curve angles steeper with a more
7438 prnounced curve point.
7439
7440 DIVIS, BOUNCE and SPRING also require "interp val 2" in addition
7441 to "interp val 1".
7442
7443 DIVIS uses val 1 as the initial graident start
7444 (0.0 is horizontal, 1.0 is diagonal (linear), 2.0 is twice the
7445 gradient of linear etc.). val 2 is interpreted as an integer factor
7446 defining how much the value swings "outside" the gradient only to come
7447 back to the final resting spot at the end. 0.0 for val 2 is equivalent
7448 to linear interpolation. Note that DIVIS can exceed 1.0
7449
7450 BOUNCE uses val 2 as the number of bounces (so its rounded down to
7451 the nearest integer value), with val 2 determining how much the
7452 bounce decays, with 0.0 giving linear decay per bounce, and higher
7453 values giving much more decay.
7454
7455 SPRING is similar to bounce, where val 2 specifies the number of
7456 spring "swings" and val 1 specifies the decay, but it can exceed 1.0
7457 on the outer swings.
7458
7459 Valid option is CURRENT.
7460
7461 CURRENT is the option which causes the edje object to move from its current position.
7462 It can be used as the last parameter of any transition type. (@since 1.1.0)
7463
7464 @endproperty
7465*/
7466static void
7467st_collections_group_programs_program_transition(void)
7468{
7469 check_min_arg_count(2);
7470
7471 current_program->tween.mode = parse_enum(0,
7472 // short names
7473 "LIN", EDJE_TWEEN_MODE_LINEAR,
7474 "SIN", EDJE_TWEEN_MODE_SINUSOIDAL,
7475 "ACCEL", EDJE_TWEEN_MODE_ACCELERATE,
7476 "DECEL", EDJE_TWEEN_MODE_DECELERATE,
7477 "ACCEL_FAC", EDJE_TWEEN_MODE_ACCELERATE_FACTOR,
7478 "DECEL_FAC", EDJE_TWEEN_MODE_DECELERATE_FACTOR,
7479 "SIN_FAC", EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR,
7480 "DIVIS", EDJE_TWEEN_MODE_DIVISOR_INTERP,
7481
7482 // long/full names
7483 "LINEAR", EDJE_TWEEN_MODE_LINEAR,
7484 "SINUSOIDAL", EDJE_TWEEN_MODE_SINUSOIDAL,
7485 "ACCELERATE", EDJE_TWEEN_MODE_ACCELERATE,
7486 "DECELERATE", EDJE_TWEEN_MODE_DECELERATE,
7487 "ACCELERATE_FACTOR", EDJE_TWEEN_MODE_ACCELERATE_FACTOR,
7488 "DECELERATE_FACTOR", EDJE_TWEEN_MODE_DECELERATE_FACTOR,
7489 "SINUSOIDAL_FACTOR", EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR,
7490 "DIVISOR_INTERP", EDJE_TWEEN_MODE_DIVISOR_INTERP,
7491
7492 // long/full is short enough
7493 "BOUNCE", EDJE_TWEEN_MODE_BOUNCE,
7494 "SPRING", EDJE_TWEEN_MODE_SPRING,
7495 NULL);
7496 current_program->tween.time = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0));
7497 if ((current_program->tween.mode >= EDJE_TWEEN_MODE_LINEAR) &&
7498 (current_program->tween.mode <= EDJE_TWEEN_MODE_DECELERATE))
7499 {
7500 if ((get_arg_count() == 3) && (!strcmp(parse_str(2), "CURRENT")))
7501 current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
7502 else if (get_arg_count() != 2)
7503 {
7504 ERR("%s: Error. parse error %s:%i. "
7505 "Need 2rd parameter to set time",
7506 progname, file_in, line - 1);
7507 exit(-1);
7508 }
7509 }
7510 // the following need v1
7511 // EDJE_TWEEN_MODE_ACCELERATE_FACTOR
7512 // EDJE_TWEEN_MODE_DECELERATE_FACTOR
7513 // EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR
7514 // current_program->tween.v1
7515 else if ((current_program->tween.mode >= EDJE_TWEEN_MODE_ACCELERATE_FACTOR) &&
7516 (current_program->tween.mode <= EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR))
7517 {
7518 if ((get_arg_count() == 4) && (!strcmp(parse_str(3), "CURRENT")))
7519 current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
7520 else if (get_arg_count() != 3)
7521 {
7522 ERR("%s: Error. parse error %s:%i. "
7523 "Need 3rd parameter to set factor",
7524 progname, file_in, line - 1);
7525 exit(-1);
7526 }
7527 current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0));
7528 }
7529 // the followjng also need v2
7530 // EDJE_TWEEN_MODE_DIVISOR_INTERP
7531 // EDJE_TWEEN_MODE_BOUNCE
7532 // EDJE_TWEEN_MODE_SPRING
7533 // current_program->tween.v2
7534 else if ((current_program->tween.mode >= EDJE_TWEEN_MODE_DIVISOR_INTERP) &&
7535 (current_program->tween.mode <= EDJE_TWEEN_MODE_SPRING))
7536 {
7537 if ((get_arg_count() == 5) && (!strcmp(parse_str(4), "CURRENT")))
7538 current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
7539 else if (get_arg_count() != 4)
7540 {
7541 ERR("%s: Error. parse error %s:%i. "
7542 "Need 3rd and 4th parameters to set factor and counts",
7543 progname, file_in, line - 1);
7544 exit(-1);
7545 }
7546 current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0));
7547 current_program->tween.v2 = FROM_DOUBLE(parse_float_range(3, 0.0, 999999999.0));
7548 }
7549}
7550
7551/**
7552 @page edcref
7553 @property
7554 target
7555 @parameters
7556 [target]
7557 @effect
7558 Program or part on which the specified action acts. Multiple target
7559 keywords may be specified, one per target. SIGNAL_EMITs do not have
7560 targets.
7561 @endproperty
7562*/
7563static void
7564st_collections_group_programs_program_target(void)
7565{
7566 Edje_Part_Collection *pc;
7567 Edje_Program *ep;
7568
7569 check_arg_count(1);
7570
7571 pc = eina_list_data_get(eina_list_last(edje_collections));
7572 ep = current_program;
7573 {
7574 Edje_Program_Target *et;
7575 Edje_Program_Target *etw;
7576 Eina_List *l;
7577 char *name;
7578 char *copy;
7579
7580 name = parse_str(0);
7581
7582 EINA_LIST_FOREACH(ep->targets, l, etw)
7583 {
7584 if (!strcmp(name, (char*) (etw + 1)))
7585 {
7586 free(name);
7587 return;
7588 }
7589 }
7590
7591 et = mem_alloc(SZ(Edje_Program_Target) + strlen(name) + 1);
7592 ep->targets = eina_list_append(ep->targets, et);
7593 copy = (char*) (et + 1);
7594
7595 memcpy(copy, name, strlen(name) + 1);
7596
7597 if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
7598 data_queue_part_lookup(pc, name, &(et->id));
7599 else if (ep->action == EDJE_ACTION_TYPE_ACTION_STOP)
7600 data_queue_program_lookup(pc, name, &(et->id));
7601 else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_SET)
7602 data_queue_part_lookup(pc, name, &(et->id));
7603 else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_STEP)
7604 data_queue_part_lookup(pc, name, &(et->id));
7605 else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_PAGE)
7606 data_queue_part_lookup(pc, name, &(et->id));
7607 else if (ep->action == EDJE_ACTION_TYPE_FOCUS_SET)
7608 data_queue_part_lookup(pc, name, &(et->id));
7609 else if (ep->action == EDJE_ACTION_TYPE_FOCUS_OBJECT)
7610 data_queue_part_lookup(pc, name, &(et->id));
7611 else
7612 {
7613 ERR("%s: Error. parse error %s:%i. "
7614 "target may only be used after action",
7615 progname, file_in, line - 1);
7616 exit(-1);
7617 }
7618 free(name);
7619 }
7620}
7621
7622/**
7623 @page edcref
7624 @property
7625 after
7626 @parameters
7627 [after]
7628 @effect
7629 Specifies a program to run after the current program completes. The
7630 source and signal parameters of a program run as an "after" are ignored.
7631 Multiple "after" statements can be specified per program.
7632 @endproperty
7633*/
7634static void
7635st_collections_group_programs_program_after(void)
7636{
7637 Edje_Part_Collection *pc;
7638 Edje_Program *ep;
7639
7640 check_arg_count(1);
7641
7642 pc = eina_list_data_get(eina_list_last(edje_collections));
7643 ep = current_program;
7644 {
7645 Edje_Program_After *pa;
7646 char *name;
7647
7648 name = parse_str(0);
7649
7650 pa = mem_alloc(SZ(Edje_Program_After));
7651 pa->id = -1;
7652 ep->after = eina_list_append(ep->after, pa);
7653
7654 data_queue_program_lookup(pc, name, &(pa->id));
7655 free(name);
7656 }
7657}
7658
7659/**
7660 @page edcref
7661 @property
7662 api
7663 @parameters
7664 [name] [description]
7665 @effect
7666 Specifies a hint to let applications (or IDE's) know how to bind
7667 things. The parameter name should contain the name of the function that
7668 the application should use, and description describes how it should
7669 be used.
7670 @endproperty
7671*/
7672static void
7673st_collections_group_programs_program_api(void)
7674{
7675 check_min_arg_count(1);
7676
7677 current_program->api.name = parse_str(0);
7678
7679 if (is_param(1))
7680 {
7681 check_arg_count(2);
7682 current_program->api.description = parse_str(1);
7683 }
7684}
7685
7686static void
7687st_collections_group_parts_part_api(void)
7688{
7689 check_min_arg_count(1);
7690
7691 current_part->api.name = parse_str(0);
7692 if (is_param(1))
7693 {
7694 check_arg_count(2);
7695 current_part->api.description = parse_str(1);
7696 }
7697}
7698
7699static void
7700ob_collections_group_programs_program_script(void)
7701{
7702 Edje_Part_Collection *pc;
7703 Code *cd;
7704
7705 pc = eina_list_data_get(eina_list_last(edje_collections));
7706 cd = eina_list_data_get(eina_list_last(codes));
7707
7708 if (!is_verbatim()) track_verbatim(1);
7709 else
7710 {
7711 Eina_Bool empty = EINA_TRUE;
7712 char *s;
7713 int i, len;
7714
7715 s = get_verbatim();
7716 if (s)
7717 {
7718 Code_Program *cp;
7719
7720 /* FIXME: Need to store the script somewhere to be restored when using edje_edit API */
7721 cp = mem_alloc(SZ(Code_Program));
7722 cp->l1 = get_verbatim_line1();
7723 cp->l2 = get_verbatim_line2();
7724 cp->script = s;
7725 cp->original = strdup(s);
7726 if (cd->shared && cd->is_lua)
7727 {
7728 ERR("%s: Error. parse error %s:%i. You're trying to mix Embryo and Lua scripting in the same group",
7729 progname, file_in, line - 1);
7730 exit(-1);
7731 }
7732 cd->is_lua = 0;
7733
7734 len = strlen(cp->script);
7735 for (i = 0; i < len; i++)
7736 {
7737 if (((cp->script[i] > 'a') && (cp->script[i] < 'z')) ||
7738 ((cp->script[i] > 'A') && (cp->script[i] < 'Z')) ||
7739 ((cp->script[i] > '0') && (cp->script[i] < '9')))
7740 empty = EINA_FALSE;
7741 }
7742
7743 if (!empty)
7744 {
7745 cd->programs = eina_list_append(cd->programs, cp);
7746 data_queue_anonymous_lookup(pc, current_program, &(cp->id));
7747 current_program->action = EDJE_ACTION_TYPE_SCRIPT;
7748 }
7749 else
7750 {
7751 data_queue_anonymous_lookup(pc, current_program, NULL);
7752 free(cp);
7753 cp = NULL;
7754 }
7755
7756 set_verbatim(NULL, 0, 0);
7757 }
7758 }
7759}
7760/**
7761 @page edcref
7762 </table>
7763*/
diff --git a/libraries/edje/src/bin/edje_cc_mem.c b/libraries/edje/src/bin/edje_cc_mem.c
new file mode 100644
index 0000000..7c1a5c9
--- /dev/null
+++ b/libraries/edje/src/bin/edje_cc_mem.c
@@ -0,0 +1,40 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <string.h>
6#include <errno.h>
7
8#include "edje_cc.h"
9
10#ifdef _WIN32
11# define FMT_SIZE_T "%Iu"
12#else
13# define FMT_SIZE_T "%zu"
14#endif
15
16void *
17mem_alloc(size_t size)
18{
19 void *mem;
20
21 mem = calloc(1, size);
22 if (mem) return mem;
23 ERR("%s: Error. %s:%i memory allocation of " FMT_SIZE_T " bytes failed. %s",
24 progname, file_in, line, size, strerror(errno));
25 exit(-1);
26 return NULL;
27}
28
29char *
30mem_strdup(const char *s)
31{
32 void *str;
33
34 str = strdup(s);
35 if (str) return str;
36 ERR("%s: Error. %s:%i memory allocation of " FMT_SIZE_T " bytes failed. %s. string being duplicated: \"%s\"",
37 progname, file_in, line, strlen(s) + 1, strerror(errno), s);
38 exit(-1);
39 return NULL;
40}
diff --git a/libraries/edje/src/bin/edje_cc_out.c b/libraries/edje/src/bin/edje_cc_out.c
new file mode 100644
index 0000000..443a702
--- /dev/null
+++ b/libraries/edje/src/bin/edje_cc_out.c
@@ -0,0 +1,1995 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#ifdef HAVE_ALLOCA_H
6# include <alloca.h>
7#elif defined __GNUC__
8# define alloca __builtin_alloca
9#elif defined _AIX
10# define alloca __alloca
11#elif defined _MSC_VER
12# include <malloc.h>
13# define alloca _alloca
14#else
15# include <stddef.h>
16# ifdef __cplusplus
17extern "C"
18# endif
19void *alloca (size_t);
20#endif
21
22#include <string.h>
23#include <limits.h>
24#include <unistd.h>
25#include <sys/stat.h>
26
27#include <Ecore_Evas.h>
28
29#include "edje_cc.h"
30#include "edje_convert.h"
31#include "edje_multisense_convert.h"
32
33#include <lua.h>
34#include <lauxlib.h>
35
36typedef struct _External_Lookup External_Lookup;
37typedef struct _Part_Lookup Part_Lookup;
38typedef struct _Program_Lookup Program_Lookup;
39typedef struct _Group_Lookup Group_Lookup;
40typedef struct _Image_Lookup Image_Lookup;
41typedef struct _Slave_Lookup Slave_Lookup;
42typedef struct _Code_Lookup Code_Lookup;
43
44
45struct _External_Lookup
46{
47 char *name;
48};
49
50struct _Part_Lookup
51{
52 Edje_Part_Collection *pc;
53 char *name;
54 int *dest;
55};
56
57struct _Program_Lookup
58{
59 Edje_Part_Collection *pc;
60
61 union
62 {
63 char *name;
64 Edje_Program *ep;
65 } u;
66
67 int *dest;
68
69 Eina_Bool anonymous : 1;
70};
71
72struct _Group_Lookup
73{
74 char *name;
75};
76
77struct _String_Lookup
78{
79 char *name;
80 int *dest;
81};
82
83struct _Image_Lookup
84{
85 char *name;
86 int *dest;
87 Eina_Bool *set;
88};
89
90struct _Slave_Lookup
91{
92 int *master;
93 int *slave;
94};
95
96struct _Code_Lookup
97{
98 char *ptr;
99 int len;
100 int val;
101 Eina_Bool set;
102};
103
104static 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));
105
106Edje_File *edje_file = NULL;
107Eina_List *edje_collections = NULL;
108Eina_List *externals = NULL;
109Eina_List *fonts = NULL;
110Eina_List *codes = NULL;
111Eina_List *code_lookups = NULL;
112Eina_List *aliases = NULL;
113
114static Eet_Data_Descriptor *edd_edje_file = NULL;
115static Eet_Data_Descriptor *edd_edje_part_collection = NULL;
116
117static Eina_List *part_lookups = NULL;
118static Eina_List *program_lookups = NULL;
119static Eina_List *group_lookups = NULL;
120static Eina_List *image_lookups = NULL;
121static Eina_List *part_slave_lookups = NULL;
122static Eina_List *image_slave_lookups= NULL;
123
124#define ABORT_WRITE(eet_file, file) \
125 eet_close(eet_file); \
126 unlink(file); \
127 exit(-1);
128
129void
130error_and_abort(Eet_File *ef, const char *fmt, ...)
131{
132 va_list ap;
133
134 fprintf(stderr, "%s: Error. ", progname);
135
136 va_start(ap, fmt);
137 vfprintf(stderr, fmt, ap);
138 va_end(ap);
139 ABORT_WRITE(ef, file_out);
140}
141
142void
143data_setup(void)
144{
145 edd_edje_file = _edje_edd_edje_file;
146 edd_edje_part_collection = _edje_edd_edje_part_collection;
147}
148
149static void
150check_image_part_desc (Edje_Part_Collection *pc, Edje_Part *ep,
151 Edje_Part_Description_Image *epd, Eet_File *ef)
152{
153 unsigned int i;
154
155#if 0 /* FIXME: This check sounds like not a useful one */
156 if (epd->image.id == -1)
157 ERR(ef, "Collection %s(%i): image attributes missing for "
158 "part \"%s\", description \"%s\" %f\n",
159 pc->part, pc->id, ep->name, epd->common.state.name, epd->common.state.value);
160#endif
161
162 for (i = 0; i < epd->image.tweens_count; ++i)
163 {
164 if (epd->image.tweens[i]->id == -1)
165 error_and_abort(ef, "Collection %i: tween image id missing for "
166 "part \"%s\", description \"%s\" %f\n",
167 pc->id, ep->name, epd->common.state.name, epd->common.state.value);
168 }
169}
170
171static void
172check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
173{
174 unsigned int i;
175
176 for (i = 0; i < ep->items_count; ++i)
177 {
178 if (ep->items[i]->type == EDJE_PART_TYPE_GROUP && !ep->items[i]->source)
179 error_and_abort(ef, "Collection %i: missing source on packed item "
180 "of type GROUP in part \"%s\"\n",
181 pc->id, ep->name);
182 if (ep->type == EDJE_PART_TYPE_TABLE && (ep->items[i]->col < 0 || ep->items[i]->row < 0))
183 error_and_abort(ef, "Collection %i: missing col/row on packed item "
184 "for part \"%s\" of type TABLE\n",
185 pc->id, ep->name);
186 }
187}
188
189static void
190check_nameless_state(Edje_Part_Collection *pc, Edje_Part *ep, Edje_Part_Description_Common *ed, Eet_File *ef)
191{
192 if (!ed->state.name)
193 error_and_abort(ef, "Collection %i: description with state missing on part \"%s\"\n",
194 pc->id, ep->name);
195}
196
197static void
198check_part (Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
199{
200 unsigned int i;
201 /* FIXME: check image set and sort them. */
202 if (!ep->default_desc)
203 error_and_abort(ef, "Collection %i: default description missing "
204 "for part \"%s\"\n", pc->id, ep->name);
205
206 for (i = 0; i < ep->other.desc_count; ++i)
207 check_nameless_state(pc, ep, ep->other.desc[i], ef);
208
209 if (ep->type == EDJE_PART_TYPE_IMAGE)
210 {
211 check_image_part_desc(pc, ep, (Edje_Part_Description_Image*) ep->default_desc, ef);
212
213 for (i = 0; i < ep->other.desc_count; ++i)
214 check_image_part_desc (pc, ep, (Edje_Part_Description_Image*) ep->other.desc[i], ef);
215 }
216 else if ((ep->type == EDJE_PART_TYPE_BOX) ||
217 (ep->type == EDJE_PART_TYPE_TABLE))
218 check_packed_items(pc, ep, ef);
219}
220
221static void
222check_program (Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef)
223{
224 switch (ep->action)
225 {
226 case EDJE_ACTION_TYPE_STATE_SET:
227 case EDJE_ACTION_TYPE_ACTION_STOP:
228 case EDJE_ACTION_TYPE_DRAG_VAL_SET:
229 case EDJE_ACTION_TYPE_DRAG_VAL_STEP:
230 case EDJE_ACTION_TYPE_DRAG_VAL_PAGE:
231 if (!ep->targets)
232 error_and_abort(ef, "Collection %i: target missing in program "
233 "\"%s\"\n", pc->id, ep->name);
234 break;
235 default:
236 break;
237 }
238}
239
240static int
241data_write_header(Eet_File *ef)
242{
243 int bytes = 0;
244
245 if (edje_file)
246 {
247 if (edje_file->collection)
248 {
249 Edje_Part_Collection_Directory_Entry *ce;
250
251 /* copy aliases into collection directory */
252 EINA_LIST_FREE(aliases, ce)
253 {
254 Edje_Part_Collection_Directory_Entry *sce;
255 Eina_Iterator *it;
256
257 if (!ce->entry)
258 error_and_abort(ef, "Collection %i: name missing.\n", ce->id);
259
260 it = eina_hash_iterator_data_new(edje_file->collection);
261
262 EINA_ITERATOR_FOREACH(it, sce)
263 if (ce->id == sce->id)
264 {
265 memcpy(&ce->count, &sce->count, sizeof (ce->count));
266 break;
267 }
268
269 if (!sce)
270 error_and_abort(ef, "Collection %s (%i) can't find an correct alias.\n", ce->entry, ce->id);
271
272 eina_iterator_free(it);
273
274 eina_hash_direct_add(edje_file->collection, ce->entry, ce);
275 }
276 }
277 bytes = eet_data_write(ef, edd_edje_file, "edje/file", edje_file, 1);
278 if (bytes <= 0)
279 error_and_abort(ef, "Unable to write \"edje_file\" entry to \"%s\" \n",
280 file_out);
281 }
282
283 if (verbose)
284 {
285 printf("%s: Wrote %9i bytes (%4iKb) for \"edje_file\" header\n",
286 progname, bytes, (bytes + 512) / 1024);
287 }
288
289 return bytes;
290}
291
292static int
293data_write_fonts(Eet_File *ef, int *font_num, int *input_bytes, int *input_raw_bytes)
294{
295 Eina_Iterator *it;
296 int bytes = 0;
297 int total_bytes = 0;
298 Font *fn;
299
300 if (!edje_file->fonts)
301 return 0;
302
303 it = eina_hash_iterator_data_new(edje_file->fonts);
304 EINA_ITERATOR_FOREACH(it, fn)
305 {
306 void *fdata = NULL;
307 int fsize = 0;
308 Eina_List *ll;
309 FILE *f;
310
311 f = fopen(fn->file, "rb");
312 if (f)
313 {
314 long pos;
315
316 fseek(f, 0, SEEK_END);
317 pos = ftell(f);
318 rewind(f);
319 fdata = malloc(pos);
320 if (fdata)
321 {
322 if (fread(fdata, pos, 1, f) != 1)
323 error_and_abort(ef, "Unable to read all of font "
324 "file \"%s\"\n", fn->file);
325 fsize = pos;
326 }
327 fclose(f);
328 }
329 else
330 {
331 char *data;
332
333 EINA_LIST_FOREACH(fnt_dirs, ll, data)
334 {
335 char buf[4096];
336
337 snprintf(buf, sizeof(buf), "%s/%s", data, fn->file);
338 f = fopen(buf, "rb");
339 if (f)
340 {
341 long pos;
342
343 fseek(f, 0, SEEK_END);
344 pos = ftell(f);
345 rewind(f);
346 fdata = malloc(pos);
347 if (fdata)
348 {
349 if (fread(fdata, pos, 1, f) != 1)
350 error_and_abort(ef, "Unable to read all of font "
351 "file \"%s\"\n", buf);
352 fsize = pos;
353 }
354 fclose(f);
355 if (fdata) break;
356 }
357 }
358 }
359 if (!fdata)
360 {
361 error_and_abort(ef, "Unable to load font part \"%s\" entry "
362 "to %s \n", fn->file, file_out);
363 }
364 else
365 {
366 char buf[4096];
367
368 snprintf(buf, sizeof(buf), "edje/fonts/%s", fn->name);
369 bytes = eet_write(ef, buf, fdata, fsize, 1);
370 if (bytes <= 0)
371 error_and_abort(ef, "Unable to write font part \"%s\" as \"%s\" "
372 "part entry to %s \n", fn->file, buf, file_out);
373
374 *font_num += 1;
375 total_bytes += bytes;
376 *input_bytes += fsize;
377 *input_raw_bytes += fsize;
378
379 if (verbose)
380 {
381 printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" font entry \"%s\" compress: [real: %2.1f%%]\n",
382 progname, bytes, (bytes + 512) / 1024, buf, fn->file,
383 100 - (100 * (double)bytes) / ((double)(fsize))
384 );
385 }
386 free(fdata);
387 }
388 }
389 eina_iterator_free(it);
390
391 return total_bytes;
392}
393
394static void
395error_and_abort_image_load_error(Eet_File *ef, const char *file, int error)
396{
397 const char *errmsg = evas_load_error_str(error);
398 char hint[1024] = "";
399
400 if (error == EVAS_LOAD_ERROR_DOES_NOT_EXIST)
401 {
402 snprintf
403 (hint, sizeof(hint),
404 " Check if path to file \"%s\" is correct "
405 "(both directory and file name).",
406 file);
407 }
408 else if (error == EVAS_LOAD_ERROR_CORRUPT_FILE)
409 {
410 snprintf
411 (hint, sizeof(hint),
412 " Check if file \"%s\" is consistent.",
413 file);
414 }
415 else if (error == EVAS_LOAD_ERROR_UNKNOWN_FORMAT)
416 {
417 const char *ext = strrchr(file, '.');
418 const char **itr, *known_loaders[] = {
419 /* list from evas_image_load.c */
420 "png",
421 "jpg",
422 "jpeg",
423 "jfif",
424 "eet",
425 "edj",
426 "eap",
427 "edb",
428 "xpm",
429 "tiff",
430 "tif",
431 "svg",
432 "svgz",
433 "gif",
434 "pbm",
435 "pgm",
436 "ppm",
437 "pnm",
438 NULL
439 };
440
441 if (!ext)
442 {
443 snprintf
444 (hint, sizeof(hint),
445 " File \"%s\" does not have an extension, "
446 "maybe it should?",
447 file);
448 goto show_err;
449 }
450
451 ext++;
452 for (itr = known_loaders; *itr; itr++)
453 {
454 if (strcasecmp(ext, *itr) == 0)
455 {
456 snprintf
457 (hint, sizeof(hint),
458 " Check if Evas was compiled with %s module enabled and "
459 "all required dependencies exist.",
460 ext);
461 goto show_err;
462 }
463 }
464
465 snprintf(hint, sizeof(hint),
466 " Check if Evas supports loading files of type \"%s\" (%s) "
467 "and this module was compiled and all its dependencies exist.",
468 ext, file);
469 }
470 show_err:
471 error_and_abort
472 (ef, "Unable to load image \"%s\" used by file \"%s\": %s.%s\n",
473 file, file_out, errmsg, hint);
474}
475
476static int
477data_write_images(Eet_File *ef, int *image_num, int *input_bytes, int *input_raw_bytes)
478{
479 unsigned int i;
480 int bytes = 0;
481 int total_bytes = 0;
482
483 if ((edje_file) && (edje_file->image_dir))
484 {
485 Ecore_Evas *ee;
486 Evas *evas;
487 Edje_Image_Directory_Entry *img;
488
489 ecore_init();
490 ecore_evas_init();
491
492 ee = ecore_evas_buffer_new(1, 1);
493 if (!ee)
494 error_and_abort(ef, "Cannot create buffer engine canvas for image "
495 "load.\n");
496
497 evas = ecore_evas_get(ee);
498 for (i = 0; i < edje_file->image_dir->entries_count; i++)
499 {
500 img = &edje_file->image_dir->entries[i];
501
502 if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL)
503 {
504 }
505 else
506 {
507 Evas_Object *im;
508 Eina_List *ll;
509 char *data;
510 int load_err = EVAS_LOAD_ERROR_NONE;
511
512 im = NULL;
513 EINA_LIST_FOREACH(img_dirs, ll, data)
514 {
515 char buf[4096];
516
517 snprintf(buf, sizeof(buf), "%s/%s",
518 data, img->entry);
519 im = evas_object_image_add(evas);
520 if (im)
521 {
522 evas_object_image_file_set(im, buf, NULL);
523 load_err = evas_object_image_load_error_get(im);
524 if (load_err == EVAS_LOAD_ERROR_NONE)
525 break;
526 evas_object_del(im);
527 im = NULL;
528 if (load_err != EVAS_LOAD_ERROR_DOES_NOT_EXIST)
529 break;
530 }
531 }
532 if ((!im) && (load_err == EVAS_LOAD_ERROR_DOES_NOT_EXIST))
533 {
534 im = evas_object_image_add(evas);
535 if (im)
536 {
537 evas_object_image_file_set(im, img->entry, NULL);
538 load_err = evas_object_image_load_error_get(im);
539 if (load_err != EVAS_LOAD_ERROR_NONE)
540 {
541 evas_object_del(im);
542 im = NULL;
543 }
544 }
545 }
546 if (im)
547 {
548 void *im_data;
549 int im_w, im_h;
550 int im_alpha;
551 char buf[256];
552
553 evas_object_image_size_get(im, &im_w, &im_h);
554 im_alpha = evas_object_image_alpha_get(im);
555 im_data = evas_object_image_data_get(im, 0);
556 if ((im_data) && (im_w > 0) && (im_h > 0))
557 {
558 int mode, qual;
559
560 snprintf(buf, sizeof(buf), "edje/images/%i", img->id);
561 qual = 80;
562 if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) &&
563 (img->source_param == 0))
564 mode = 0; /* RAW */
565 else if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) &&
566 (img->source_param == 1))
567 mode = 1; /* COMPRESS */
568 else
569 mode = 2; /* LOSSY */
570 if ((mode == 0) && (no_raw))
571 {
572 mode = 1; /* promote compression */
573 img->source_param = 95;
574 }
575 if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */
576 if ((mode == 1) && (no_comp))
577 {
578 if (no_lossy) mode = 0; /* demote compression */
579 else if (no_raw)
580 {
581 img->source_param = 90;
582 mode = 2; /* no choice. lossy */
583 }
584 }
585 if (mode == 2)
586 {
587 qual = img->source_param;
588 if (qual < min_quality) qual = min_quality;
589 if (qual > max_quality) qual = max_quality;
590 }
591 if (mode == 0)
592 bytes = eet_data_image_write(ef, buf,
593 im_data, im_w, im_h,
594 im_alpha,
595 0, 0, 0);
596 else if (mode == 1)
597 bytes = eet_data_image_write(ef, buf,
598 im_data, im_w, im_h,
599 im_alpha,
600 1, 0, 0);
601 else if (mode == 2)
602 bytes = eet_data_image_write(ef, buf,
603 im_data, im_w, im_h,
604 im_alpha,
605 0, qual, 1);
606 if (bytes <= 0)
607 error_and_abort(ef, "Unable to write image part "
608 "\"%s\" as \"%s\" part entry to "
609 "%s\n", img->entry, buf,
610 file_out);
611
612 *image_num += 1;
613 total_bytes += bytes;
614 }
615 else
616 {
617 error_and_abort_image_load_error
618 (ef, img->entry, load_err);
619 }
620
621 if (verbose)
622 {
623 struct stat st;
624 const char *file = NULL;
625
626 evas_object_image_file_get(im, &file, NULL);
627 if (!file || (stat(file, &st) != 0))
628 st.st_size = 0;
629 *input_bytes += st.st_size;
630 *input_raw_bytes += im_w * im_h * 4;
631 printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\" compress: [raw: %2.1f%%] [real: %2.1f%%]\n",
632 progname, bytes, (bytes + 512) / 1024, buf, img->entry,
633 100 - (100 * (double)bytes) / ((double)(im_w * im_h * 4)),
634 100 - (100 * (double)bytes) / ((double)(st.st_size))
635 );
636 }
637 evas_object_del(im);
638 }
639 else
640 {
641 error_and_abort_image_load_error
642 (ef, img->entry, load_err);
643 }
644 }
645 }
646 ecore_evas_free(ee);
647 ecore_evas_shutdown();
648 ecore_shutdown();
649 }
650
651 return total_bytes;
652}
653
654static int
655data_write_sounds(Eet_File * ef, int *sound_num, int *input_bytes, int *input_raw_bytes)
656{
657 int bytes = 0;
658 int total_bytes = 0;
659
660 if ((edje_file) && (edje_file->sound_dir))
661 {
662 Eina_List *ll;
663 Edje_Sound_Sample *sample;
664#ifdef HAVE_LIBSNDFILE
665 Edje_Sound_Encode *enc_info;
666#endif
667 char *dir_path = NULL;
668 char snd_path[PATH_MAX];
669 char sndid_str[15];
670 void *fdata;
671 FILE *fp = NULL;
672 struct stat st;
673 int size = 0;
674 int i;
675
676 for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++)
677 {
678 sample = &edje_file->sound_dir->samples[i];
679 memset(&st, 0, sizeof(struct stat));
680
681 // Search the Sound file in all the -sd ( sound directory )
682 EINA_LIST_FOREACH(snd_dirs, ll, dir_path)
683 {
684 snprintf((char *)snd_path, sizeof(snd_path), "%s/%s", dir_path,
685 sample->snd_src);
686 stat(snd_path, &st);
687 if (st.st_size) break;
688 }
689 if (!st.st_size)
690 {
691 snprintf((char *)snd_path, sizeof(snd_path), "%s",
692 sample->snd_src);
693 stat(snd_path, &st);
694 }
695 size = st.st_size;
696 if (!size)
697 {
698 ERR("%s: Error. Unable to load sound source file : %s",
699 progname, sample->snd_src);
700 exit(-1);
701 }
702#ifdef HAVE_LIBSNDFILE
703 enc_info = _edje_multisense_encode(snd_path, sample, sample->quality);
704
705 stat(enc_info->file, &st);
706 size = st.st_size;
707 fp = fopen(enc_info->file, "rb");
708#else
709 fp = fopen(snd_path, "rb");
710#endif
711 if (!fp)
712 {
713 ERR("%s: Error: Unable to load sound data of: %s",
714 progname, sample->name);
715 exit(-1);
716 }
717
718 snprintf(sndid_str, sizeof(sndid_str), "edje/sounds/%i", sample->id);
719 fdata = malloc(size);
720 if (!fdata)
721 {
722 ERR("%s: Error. %s:%i while allocating memory to load file \"%s\"",
723 progname, file_in, line, snd_path);
724 exit(-1);
725 }
726 if (fread(fdata, size, 1, fp))
727 bytes = eet_write(ef, sndid_str, fdata, size, EINA_FALSE);
728 free(fdata);
729 fclose(fp);
730
731#ifdef HAVE_LIBSNDFILE
732 //If encoded temporary file, delete it.
733 if (enc_info->encoded) unlink(enc_info->file);
734#endif
735 *sound_num += 1;
736 total_bytes += bytes;
737 *input_bytes += size;
738 *input_raw_bytes += size;
739
740 if (verbose)
741 {
742#ifdef HAVE_LIBSNDFILE
743 printf ("%s: Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry"
744 "\"%s\" \n", progname, bytes, (bytes + 512) / 1024,
745 sndid_str, enc_info->comp_type, sample->name);
746#else
747 printf ("%s: Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry"
748 "\"%s\" \n", progname, bytes, (bytes + 512) / 1024,
749 sndid_str, "RAW PCM", sample->name);
750#endif
751 }
752#ifdef HAVE_LIBSNDFILE
753 if ((enc_info->file) && (!enc_info->encoded)) eina_stringshare_del(enc_info->file);
754 if (enc_info) free(enc_info);
755 enc_info = NULL;
756#endif
757 }
758 }
759 return total_bytes;
760}
761
762static void
763check_groups(Eet_File *ef)
764{
765 Edje_Part_Collection *pc;
766 Eina_List *l;
767
768 /* sanity checks for parts and programs */
769 EINA_LIST_FOREACH(edje_collections, l, pc)
770 {
771 unsigned int i;
772
773 for (i = 0; i < pc->parts_count; ++i)
774 check_part(pc, pc->parts[i], ef);
775
776#define CHECK_PROGRAM(Type, Pc, It) \
777 for (It = 0; It < Pc->programs.Type ## _count; ++It) \
778 check_program(Pc, Pc->programs.Type[i], ef); \
779
780 CHECK_PROGRAM(fnmatch, pc, i);
781 CHECK_PROGRAM(strcmp, pc, i);
782 CHECK_PROGRAM(strncmp, pc, i);
783 CHECK_PROGRAM(strrncmp, pc, i);
784 CHECK_PROGRAM(nocmp, pc, i);
785 }
786}
787
788static int
789data_write_groups(Eet_File *ef, int *collection_num)
790{
791 Eina_List *l;
792 Edje_Part_Collection *pc;
793 int bytes = 0;
794 int total_bytes = 0;
795
796 EINA_LIST_FOREACH(edje_collections, l, pc)
797 {
798 char buf[4096];
799
800 snprintf(buf, sizeof(buf), "edje/collections/%i", pc->id);
801 bytes = eet_data_write(ef, edd_edje_part_collection, buf, pc, 1);
802 if (bytes <= 0)
803 error_and_abort(ef, "Error. Unable to write \"%s\" part entry "
804 "to %s\n", buf, file_out);
805
806 *collection_num += 1;
807 total_bytes += bytes;
808
809 if (verbose)
810 {
811 printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" collection entry\n",
812 progname, bytes, (bytes + 512) / 1024, buf);
813 }
814 }
815
816 return total_bytes;
817}
818
819static void
820create_script_file(Eet_File *ef, const char *filename, const Code *cd, int fd)
821{
822 FILE *f = fdopen(fd, "wb");
823 if (!f)
824 error_and_abort(ef, "Unable to open temp file \"%s\" for script "
825 "compilation.\n", filename);
826
827 Eina_List *ll;
828 Code_Program *cp;
829
830 fprintf(f, "#include <edje>\n");
831 int ln = 2;
832
833 if (cd->shared)
834 {
835 while (ln < (cd->l1 - 1))
836 {
837 fprintf(f, " \n");
838 ln++;
839 }
840 {
841 char *sp;
842 int hash = 0;
843 int newlined = 0;
844
845 for (sp = cd->shared; *sp; sp++)
846 {
847 if ((sp[0] == '#') && (newlined))
848 {
849 hash = 1;
850 }
851 newlined = 0;
852 if (sp[0] == '\n') newlined = 1;
853 if (!hash) fputc(sp[0], f);
854 else if (sp[0] == '\n') hash = 0;
855 }
856 fputc('\n', f);
857 }
858 ln += cd->l2 - cd->l1 + 1;
859 }
860 EINA_LIST_FOREACH(cd->programs, ll, cp)
861 {
862 if (cp->script)
863 {
864 while (ln < (cp->l1 - 1))
865 {
866 fprintf(f, " \n");
867 ln++;
868 }
869 /* FIXME: this prototype needs to be */
870 /* formalised and set in stone */
871 fprintf(f, "public _p%i(sig[], src[]) {", cp->id);
872 {
873 char *sp;
874 int hash = 0;
875 int newlined = 0;
876
877 for (sp = cp->script; *sp; sp++)
878 {
879 if ((sp[0] == '#') && (newlined))
880 {
881 hash = 1;
882 }
883 newlined = 0;
884 if (sp[0] == '\n') newlined = 1;
885 if (!hash) fputc(sp[0], f);
886 else if (sp[0] == '\n') hash = 0;
887 }
888 }
889 fprintf(f, "}\n");
890 ln += cp->l2 - cp->l1 + 1;
891 }
892 }
893
894 fclose(f);
895}
896
897static void
898compile_script_file(Eet_File *ef, const char *source, const char *output,
899 int script_num, int fd)
900{
901 FILE *f;
902 char buf[4096];
903 int ret;
904
905 snprintf(buf, sizeof(buf),
906 "embryo_cc -i %s/include -o %s %s",
907 eina_prefix_data_get(pfx), output, source);
908 ret = system(buf);
909
910 /* accept warnings in the embryo code */
911 if (ret < 0 || ret > 1)
912 error_and_abort(ef, "Compiling script code not clean.\n");
913
914 f = fdopen(fd, "rb");
915 if (!f)
916 error_and_abort(ef, "Unable to open script object \"%s\" for reading.\n",
917 output);
918
919 fseek(f, 0, SEEK_END);
920 int size = ftell(f);
921 rewind(f);
922
923 if (size > 0)
924 {
925 void *data = malloc(size);
926
927 if (data)
928 {
929 if (fread(data, size, 1, f) != 1)
930 error_and_abort(ef, "Unable to read all of script object "
931 "\"%s\"\n", output);
932
933 snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", script_num);
934 eet_write(ef, buf, data, size, 1);
935 free(data);
936 }
937 }
938
939 fclose(f);
940}
941
942static void
943data_write_scripts(Eet_File *ef)
944{
945 Eina_List *l;
946 int i;
947
948 if (!tmp_dir)
949#ifdef HAVE_EVIL
950 tmp_dir = (char *)evil_tmpdir_get();
951#else
952 tmp_dir = "/tmp";
953#endif
954
955 for (i = 0, l = codes; l; l = eina_list_next(l), i++)
956 {
957 char tmpn[PATH_MAX];
958 char tmpo[PATH_MAX];
959 int fd;
960 Code *cd = eina_list_data_get(l);
961
962 if (cd->is_lua)
963 continue;
964 if ((!cd->shared) && (!cd->programs))
965 continue;
966
967 snprintf(tmpn, PATH_MAX, "%s/edje_cc.sma-tmp-XXXXXX", tmp_dir);
968 fd = mkstemp(tmpn);
969 if (fd < 0)
970 error_and_abort(ef, "Unable to open temp file \"%s\" for script "
971 "compilation.\n", tmpn);
972
973 create_script_file(ef, tmpn, cd, fd);
974
975 snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir);
976 fd = mkstemp(tmpo);
977 if (fd < 0)
978 {
979 unlink(tmpn);
980 error_and_abort(ef, "Unable to open temp file \"%s\" for script "
981 "compilation.\n", tmpn);
982 }
983 compile_script_file(ef, tmpn, tmpo, i, fd);
984
985 unlink(tmpn);
986 unlink(tmpo);
987
988 if (!no_save)
989 {
990 char buf[PATH_MAX];
991 Eina_List *ll;
992 Code_Program *cp;
993
994 if (cd->original)
995 {
996 snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i", i);
997 eet_write(ef, buf, cd->original, strlen(cd->original) + 1, 1);
998 }
999 EINA_LIST_FOREACH(cd->programs, ll, cp)
1000 {
1001 if (!cp->original)
1002 continue;
1003 snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i/%i", i,
1004 cp->id);
1005 eet_write(ef, buf, cp->original, strlen(cp->original) + 1, 1);
1006 }
1007 }
1008 }
1009}
1010
1011typedef struct _Edje_Lua_Script_Writer_Struct Edje_Lua_Script_Writer_Struct;
1012
1013struct _Edje_Lua_Script_Writer_Struct
1014{
1015 char *buf;
1016 int size;
1017};
1018
1019#ifdef LUA_BINARY
1020static int
1021_edje_lua_script_writer(lua_State *L __UNUSED__, const void *chunk_buf, size_t chunk_size, void *_data)
1022{
1023 Edje_Lua_Script_Writer_Struct *data;
1024 void *old;
1025
1026 data = (Edje_Lua_Script_Writer_Struct *)_data;
1027 old = data->buf;
1028 data->buf = malloc (data->size + chunk_size);
1029 memcpy (data->buf, old, data->size);
1030 memcpy (&((data->buf)[data->size]), chunk_buf, chunk_size);
1031 if (old)
1032 free (old);
1033 data->size += chunk_size;
1034
1035 return 0;
1036}
1037#endif
1038
1039void
1040_edje_lua_error_and_abort(lua_State * L, int err_code, Eet_File *ef)
1041{
1042 char *err_type;
1043
1044 switch (err_code)
1045 {
1046 case LUA_ERRRUN:
1047 err_type = "runtime";
1048 break;
1049 case LUA_ERRSYNTAX:
1050 err_type = "syntax";
1051 break;
1052 case LUA_ERRMEM:
1053 err_type = "memory allocation";
1054 break;
1055 case LUA_ERRERR:
1056 err_type = "error handler";
1057 break;
1058 default:
1059 err_type = "unknown";
1060 break;
1061 }
1062 error_and_abort(ef, "Lua %s error: %s\n", err_type, lua_tostring(L, -1));
1063}
1064
1065
1066static void
1067data_write_lua_scripts(Eet_File *ef)
1068{
1069 Eina_List *l;
1070 Eina_List *ll;
1071 Code_Program *cp;
1072 int i;
1073
1074 for (i = 0, l = codes; l; l = eina_list_next(l), i++)
1075 {
1076 char buf[4096];
1077 Code *cd;
1078 lua_State *L;
1079 int ln = 1;
1080 luaL_Buffer b;
1081 Edje_Lua_Script_Writer_Struct data;
1082#ifdef LUA_BINARY
1083 int err_code;
1084#endif
1085
1086 cd = (Code *)eina_list_data_get(l);
1087 if (!cd->is_lua)
1088 continue;
1089 if ((!cd->shared) && (!cd->programs))
1090 continue;
1091
1092 L = luaL_newstate();
1093 if (!L)
1094 error_and_abort(ef, "Lua error: Lua state could not be initialized\n");
1095
1096 luaL_buffinit(L, &b);
1097
1098 data.buf = NULL;
1099 data.size = 0;
1100 if (cd->shared)
1101 {
1102 while (ln < (cd->l1 - 1))
1103 {
1104 luaL_addchar(&b, '\n');
1105 ln++;
1106 }
1107 luaL_addstring(&b, cd->shared);
1108 ln += cd->l2 - cd->l1;
1109 }
1110
1111 EINA_LIST_FOREACH(cd->programs, ll, cp)
1112 {
1113 if (cp->script)
1114 {
1115 while (ln < (cp->l1 - 1))
1116 {
1117 luaL_addchar(&b, '\n');
1118 ln++;
1119 }
1120 luaL_addstring(&b, "_G[");
1121 lua_pushnumber(L, cp->id);
1122 luaL_addvalue(&b);
1123 luaL_addstring(&b, "] = function (ed, signal, source)");
1124 luaL_addstring(&b, cp->script);
1125 luaL_addstring(&b, "end\n");
1126 ln += cp->l2 - cp->l1 + 1;
1127 }
1128 }
1129 luaL_pushresult(&b);
1130#ifdef LUA_BINARY
1131 if (err_code = luaL_loadstring(L, lua_tostring (L, -1)))
1132 _edje_lua_error_and_abort(L, err_code, ef);
1133 lua_dump(L, _edje_lua_script_writer, &data);
1134#else // LUA_PLAIN_TEXT
1135 data.buf = (char *)lua_tostring(L, -1);
1136 data.size = strlen(data.buf);
1137#endif
1138 //printf("lua chunk size: %d\n", data.size);
1139
1140 /*
1141 * TODO load and test Lua chunk
1142 */
1143
1144 /*
1145 if (luaL_loadbuffer(L, globbuf, globbufsize, "edje_lua_script"))
1146 printf("lua load error: %s\n", lua_tostring (L, -1));
1147 if (lua_pcall(L, 0, 0, 0))
1148 printf("lua call error: %s\n", lua_tostring (L, -1));
1149 */
1150
1151 snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", i);
1152 eet_write(ef, buf, data.buf, data.size, 1);
1153#ifdef LUA_BINARY
1154 free(data.buf);
1155#endif
1156 lua_close(L);
1157 }
1158}
1159
1160void
1161data_write(void)
1162{
1163 Eet_File *ef;
1164 int input_bytes = 0;
1165 int total_bytes = 0;
1166 int src_bytes = 0;
1167 int fmap_bytes = 0;
1168 int input_raw_bytes = 0;
1169 int image_num = 0;
1170 int sound_num = 0;
1171 int font_num = 0;
1172 int collection_num = 0;
1173
1174 if (!edje_file)
1175 {
1176 ERR("%s: Error. No data to put in \"%s\"",
1177 progname, file_out);
1178 exit(-1);
1179 }
1180
1181 ef = eet_open(file_out, EET_FILE_MODE_WRITE);
1182 if (!ef)
1183 {
1184 ERR("%s: Error. Unable to open \"%s\" for writing output",
1185 progname, file_out);
1186 exit(-1);
1187 }
1188
1189 check_groups(ef);
1190
1191 total_bytes += data_write_header(ef);
1192 total_bytes += data_write_fonts(ef, &font_num, &input_bytes,
1193 &input_raw_bytes);
1194 total_bytes += data_write_images(ef, &image_num, &input_bytes,
1195 &input_raw_bytes);
1196 total_bytes += data_write_sounds(ef, &sound_num, &input_bytes,
1197 &input_raw_bytes);
1198
1199 total_bytes += data_write_groups(ef, &collection_num);
1200 data_write_scripts(ef);
1201 data_write_lua_scripts(ef);
1202
1203 src_bytes = source_append(ef);
1204 total_bytes += src_bytes;
1205 fmap_bytes = source_fontmap_save(ef, fonts);
1206 total_bytes += fmap_bytes;
1207
1208 eet_close(ef);
1209
1210 if (verbose)
1211 {
1212 struct stat st;
1213
1214 if (stat(file_in, &st) != 0)
1215 st.st_size = 0;
1216 input_bytes += st.st_size;
1217 input_raw_bytes += st.st_size;
1218 printf("Summary:\n"
1219 " Wrote %i collections\n"
1220 " Wrote %i images\n"
1221 " Wrote %i sounds\n"
1222 " Wrote %i fonts\n"
1223 " Wrote %i bytes (%iKb) of original source data\n"
1224 " Wrote %i bytes (%iKb) of original source font map\n"
1225 "Conservative compression summary:\n"
1226 " Wrote total %i bytes (%iKb) from %i (%iKb) input data\n"
1227 " Output file is %3.1f%% the size of the input data\n"
1228 " Saved %i bytes (%iKb)\n"
1229 "Raw compression summary:\n"
1230 " Wrote total %i bytes (%iKb) from %i (%iKb) raw input data\n"
1231 " Output file is %3.1f%% the size of the raw input data\n"
1232 " Saved %i bytes (%iKb)\n"
1233 ,
1234 collection_num,
1235 image_num,
1236 sound_num,
1237 font_num,
1238 src_bytes, (src_bytes + 512) / 1024,
1239 fmap_bytes, (fmap_bytes + 512) / 1024,
1240 total_bytes, (total_bytes + 512) / 1024,
1241 input_bytes, (input_bytes + 512) / 1024,
1242 (100.0 * (double)total_bytes) / (double)input_bytes,
1243 input_bytes - total_bytes,
1244 (input_bytes - total_bytes + 512) / 1024,
1245 total_bytes, (total_bytes + 512) / 1024,
1246 input_raw_bytes, (input_raw_bytes + 512) / 1024,
1247 (100.0 * (double)total_bytes) / (double)input_raw_bytes,
1248 input_raw_bytes - total_bytes,
1249 (input_raw_bytes - total_bytes + 512) / 1024);
1250 }
1251}
1252
1253void
1254reorder_parts(void)
1255{
1256 Edje_Part_Collection *pc;
1257 Edje_Part **parts;
1258 Edje_Part_Parser *ep, *ep2;
1259 Eina_List *l;
1260
1261 /* sanity checks for parts and programs */
1262 EINA_LIST_FOREACH(edje_collections, l, pc)
1263 {
1264 unsigned int i, j, k;
1265 Eina_Bool found = EINA_FALSE;
1266
1267 for (i = 0; i < pc->parts_count; i++)
1268 {
1269 ep = (Edje_Part_Parser *)pc->parts[i];
1270 if (ep->reorder.insert_before && ep->reorder.insert_after)
1271 ERR("%s: Error. Unable to use together insert_before and insert_after in part \"%s\".", progname, pc->parts[i]->name);
1272
1273 if (ep->reorder.done)
1274 {
1275 continue;
1276 }
1277 if (ep->reorder.insert_before || ep->reorder.insert_after)
1278 {
1279 found = EINA_FALSE;
1280 for (j = 0; j < pc->parts_count; j++)
1281 {
1282 if (ep->reorder.insert_before &&
1283 !strcmp(ep->reorder.insert_before, pc->parts[j]->name))
1284 {
1285 ep2 = (Edje_Part_Parser *)pc->parts[j];
1286 if (ep2->reorder.after)
1287 ERR("%s: Error. The part \"%s\" is ambiguous ordered part.", progname, pc->parts[i]->name);
1288 if (ep2->reorder.linked_prev)
1289 ERR("%s: Error. Unable to insert two or more parts in same part \"%s\".", progname, pc->parts[j]->name);
1290 k = j - 1;
1291 found = EINA_TRUE;
1292 ep2->reorder.linked_prev += ep->reorder.linked_prev + 1;
1293 ep->reorder.before = (Edje_Part_Parser *)pc->parts[j];
1294 while (ep2->reorder.before)
1295 {
1296 ep2->reorder.before->reorder.linked_prev = ep2->reorder.linked_prev + 1;
1297 ep2 = ep2->reorder.before;
1298 }
1299 break;
1300 }
1301 else if (ep->reorder.insert_after &&
1302 !strcmp(ep->reorder.insert_after, pc->parts[j]->name))
1303 {
1304 ep2 = (Edje_Part_Parser *)pc->parts[j];
1305 if (ep2->reorder.before)
1306 ERR("%s: Error. The part \"%s\" is ambiguous ordered part.", progname, pc->parts[i]->name);
1307 if (ep2->reorder.linked_next)
1308 ERR("%s: Error. Unable to insert two or more parts in same part \"%s\".", progname, pc->parts[j]->name);
1309 k = j;
1310 found = EINA_TRUE;
1311 ep2->reorder.linked_next += ep->reorder.linked_next + 1;
1312 ep->reorder.after = (Edje_Part_Parser *)pc->parts[j];
1313 while (ep2->reorder.after)
1314 {
1315 ep2->reorder.after->reorder.linked_next = ep2->reorder.linked_next + 1;
1316 ep2 = ep2->reorder.after;
1317 }
1318 break;
1319 }
1320 }
1321 if (found)
1322 {
1323 unsigned int amount, linked;
1324
1325 if (((i > k) && ((i - ep->reorder.linked_prev) <= k))
1326 || ((i < k) && ((i + ep->reorder.linked_next) >= k)))
1327 ERR("%s: Error. The part order is wrong. It has circular dependency.",
1328 progname);
1329
1330 amount = ep->reorder.linked_prev + ep->reorder.linked_next + 1;
1331 linked = i - ep->reorder.linked_prev;
1332 parts = malloc(amount * sizeof(Edje_Part));
1333 for (j = 0 ; j < amount ; j++)
1334 {
1335 parts[j] = pc->parts[linked];
1336 linked++;
1337 }
1338 if (i > k)
1339 {
1340 for (j = i - ep->reorder.linked_prev - 1 ; j >= k ; j--)
1341 {
1342 pc->parts[j + amount] = pc->parts[j];
1343 pc->parts[j + amount]->id = j + amount;
1344 }
1345 for (j = 0 ; j < amount ; j++)
1346 {
1347 pc->parts[j + k] = parts[j];
1348 pc->parts[j + k]->id = j + k;
1349 }
1350 }
1351 else if (i < k)
1352 {
1353 for (j = i + ep->reorder.linked_next + 1 ; j <= k ; j++)
1354 {
1355 pc->parts[j - amount] = pc->parts[j];
1356 pc->parts[j - amount]->id = j - amount;
1357 }
1358 for (j = 0 ; j < amount ; j++)
1359 {
1360 pc->parts[j + k - amount + 1] = parts[j];
1361 pc->parts[j + k - amount + 1]->id = j + k - amount + 1;
1362 }
1363 i -= amount;
1364 }
1365 ep->reorder.done = EINA_TRUE;
1366 free(parts);
1367 }
1368 }
1369 }
1370 }
1371}
1372
1373void
1374data_queue_group_lookup(char *name)
1375{
1376 Group_Lookup *gl;
1377
1378 gl = mem_alloc(SZ(Group_Lookup));
1379 group_lookups = eina_list_append(group_lookups, gl);
1380 gl->name = mem_strdup(name);
1381}
1382
1383void
1384data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest)
1385{
1386 Eina_List *l;
1387 Part_Lookup *pl;
1388
1389 EINA_LIST_FOREACH(part_lookups, l, pl)
1390 {
1391 if ((pl->pc == pc) && (pl->dest == dest))
1392 {
1393 free(pl->name);
1394 if (name[0])
1395 pl->name = mem_strdup(name);
1396 else
1397 {
1398 part_lookups = eina_list_remove(part_lookups, pl);
1399 free(pl);
1400 }
1401 return;
1402 }
1403 }
1404 if (!name[0]) return;
1405
1406 pl = mem_alloc(SZ(Part_Lookup));
1407 part_lookups = eina_list_append(part_lookups, pl);
1408 pl->pc = pc;
1409 pl->name = mem_strdup(name);
1410 pl->dest = dest;
1411}
1412
1413void
1414data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest)
1415{
1416 Eina_List *l;
1417 Part_Lookup *pl;
1418
1419 EINA_LIST_FOREACH(part_lookups, l, pl)
1420 {
1421 if (pl->dest == src)
1422 data_queue_part_lookup(pc, pl->name, dest);
1423 }
1424}
1425
1426void
1427data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest)
1428{
1429 Eina_List *l, *l2;
1430 Program_Lookup *pl;
1431
1432 if (!ep) return ; /* FIXME: should we stop compiling ? */
1433
1434 EINA_LIST_FOREACH(program_lookups, l, pl)
1435 {
1436 if (pl->u.ep == ep)
1437 {
1438 Code *cd;
1439 Code_Program *cp;
1440
1441 cd = eina_list_data_get(eina_list_last(codes));
1442
1443 EINA_LIST_FOREACH(cd->programs, l2, cp)
1444 {
1445 if (&(cp->id) == pl->dest)
1446 {
1447 cd->programs = eina_list_remove(cd->programs, cp);
1448 free(cp);
1449 cp = NULL;
1450 }
1451 }
1452 program_lookups = eina_list_remove(program_lookups, pl);
1453 free(pl);
1454 }
1455 }
1456
1457 if (dest)
1458 {
1459 pl = mem_alloc(SZ(Program_Lookup));
1460 program_lookups = eina_list_append(program_lookups, pl);
1461 pl->pc = pc;
1462 pl->u.ep = ep;
1463 pl->dest = dest;
1464 pl->anonymous = EINA_TRUE;
1465 }
1466}
1467
1468void
1469data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest)
1470{
1471 Eina_List *l;
1472 Program_Lookup *pl;
1473 unsigned int i;
1474
1475 EINA_LIST_FOREACH(program_lookups, l, pl)
1476 {
1477 if (pl->dest == src)
1478 {
1479 for (i = 0 ; i < pc->programs.fnmatch_count ; i++)
1480 {
1481 if (!strcmp(pl->u.ep->name, pc->programs.fnmatch[i]->name))
1482 data_queue_anonymous_lookup(pc, pc->programs.fnmatch[i], dest);
1483 }
1484 for (i = 0 ; i < pc->programs.strcmp_count ; i++)
1485 {
1486 if (!strcmp(pl->u.ep->name, pc->programs.strcmp[i]->name))
1487 data_queue_anonymous_lookup(pc, pc->programs.strcmp[i], dest);
1488 }
1489 for (i = 0 ; i < pc->programs.strncmp_count ; i++)
1490 {
1491 if (!strcmp(pl->u.ep->name, pc->programs.strncmp[i]->name))
1492 data_queue_anonymous_lookup(pc, pc->programs.strncmp[i], dest);
1493 }
1494 for (i = 0 ; i < pc->programs.strrncmp_count ; i++)
1495 {
1496 if (!strcmp(pl->u.ep->name, pc->programs.strrncmp[i]->name))
1497 data_queue_anonymous_lookup(pc, pc->programs.strrncmp[i], dest);
1498 }
1499 for (i = 0 ; i < pc->programs.nocmp_count ; i++)
1500 {
1501 if (!strcmp(pl->u.ep->name, pc->programs.nocmp[i]->name))
1502 data_queue_anonymous_lookup(pc, pc->programs.nocmp[i], dest);
1503 }
1504 }
1505 }
1506}
1507
1508void
1509data_queue_program_lookup(Edje_Part_Collection *pc, const char *name, int *dest)
1510{
1511 Program_Lookup *pl;
1512
1513 if (!name) return ; /* FIXME: should we stop compiling ? */
1514
1515 pl = mem_alloc(SZ(Program_Lookup));
1516 program_lookups = eina_list_append(program_lookups, pl);
1517 pl->pc = pc;
1518 pl->u.name = mem_strdup(name);
1519 pl->dest = dest;
1520 pl->anonymous = EINA_FALSE;
1521}
1522
1523void
1524data_queue_copied_program_lookup(Edje_Part_Collection *pc, int *src, int *dest)
1525{
1526 Eina_List *l;
1527 Program_Lookup *pl;
1528
1529 EINA_LIST_FOREACH(program_lookups, l, pl)
1530 {
1531 if (pl->dest == src)
1532 data_queue_program_lookup(pc, pl->u.name, dest);
1533 }
1534}
1535
1536void
1537data_queue_image_lookup(char *name, int *dest, Eina_Bool *set)
1538{
1539 Image_Lookup *il;
1540
1541 il = mem_alloc(SZ(Image_Lookup));
1542 image_lookups = eina_list_append(image_lookups, il);
1543 il->name = mem_strdup(name);
1544 il->dest = dest;
1545 il->set = set;
1546}
1547
1548void
1549data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set)
1550{
1551 Eina_List *l;
1552 Image_Lookup *il;
1553
1554 EINA_LIST_FOREACH(image_lookups, l, il)
1555 {
1556 if (il->dest == src)
1557 data_queue_image_lookup(il->name, dest, set);
1558 }
1559}
1560void
1561data_queue_part_slave_lookup(int *master, int *slave)
1562{
1563 Slave_Lookup *sl;
1564
1565 sl = mem_alloc(SZ(Slave_Lookup));
1566 part_slave_lookups = eina_list_append(part_slave_lookups, sl);
1567 sl->master = master;
1568 sl->slave = slave;
1569}
1570
1571void
1572data_queue_image_slave_lookup(int *master, int *slave)
1573{
1574 Slave_Lookup *sl;
1575
1576 sl = mem_alloc(SZ(Slave_Lookup));
1577 image_slave_lookups = eina_list_append(image_slave_lookups, sl);
1578 sl->master = master;
1579 sl->slave = slave;
1580}
1581
1582void
1583handle_slave_lookup(Eina_List *list, int *master, int value)
1584{
1585 Eina_List *l;
1586 Slave_Lookup *sl;
1587
1588 EINA_LIST_FOREACH(list, l, sl)
1589 if (sl->master == master)
1590 *sl->slave = value;
1591}
1592
1593void
1594data_process_lookups(void)
1595{
1596 Edje_Part_Collection *pc;
1597 Part_Lookup *part;
1598 Program_Lookup *program;
1599 Group_Lookup *group;
1600 Image_Lookup *image;
1601 Eina_List *l;
1602 void *data;
1603
1604 EINA_LIST_FOREACH(edje_collections, l, pc)
1605 {
1606 unsigned int count = 0;
1607 unsigned int i;
1608
1609#define PROGRAM_ID_SET(Type, Pc, It, Count) \
1610 for (It = 0; It < Pc->programs.Type ## _count; ++It) \
1611 { \
1612 Pc->programs.Type[It]->id = Count++; \
1613 }
1614
1615 PROGRAM_ID_SET(fnmatch, pc, i, count);
1616 PROGRAM_ID_SET(strcmp, pc, i, count);
1617 PROGRAM_ID_SET(strncmp, pc, i, count);
1618 PROGRAM_ID_SET(strrncmp, pc, i, count);
1619 PROGRAM_ID_SET(nocmp, pc, i, count);
1620
1621#undef PROGRAM_ID_SET
1622 }
1623
1624 EINA_LIST_FREE(part_lookups, part)
1625 {
1626 Edje_Part *ep;
1627 unsigned int i;
1628
1629 for (i = 0; i < part->pc->parts_count; ++i)
1630 {
1631 ep = part->pc->parts[i];
1632
1633 if ((ep->name) && (!strcmp(ep->name, part->name)))
1634 {
1635 handle_slave_lookup(part_slave_lookups, part->dest, ep->id);
1636 *(part->dest) = ep->id;
1637 break;
1638 }
1639 }
1640
1641 if (i == part->pc->parts_count)
1642 {
1643 ERR("%s: Error. Unable to find part name \"%s\".",
1644 progname, part->name);
1645 exit(-1);
1646 }
1647
1648 free(part->name);
1649 free(part);
1650 }
1651
1652 EINA_LIST_FREE(program_lookups, program)
1653 {
1654 unsigned int i;
1655 Eina_Bool find = EINA_FALSE;
1656
1657#define PROGRAM_MATCH(Type, Pl, It) \
1658 for (It = 0; It < Pl->pc->programs.Type ## _count; ++It) \
1659 { \
1660 Edje_Program *ep; \
1661 \
1662 ep = Pl->pc->programs.Type[It]; \
1663 \
1664 if ((Pl->anonymous && ep == Pl->u.ep) || \
1665 ((!Pl->anonymous) && (ep->name) && (!strcmp(ep->name, Pl->u.name)))) \
1666 { \
1667 *(Pl->dest) = ep->id; \
1668 find = EINA_TRUE; \
1669 break; \
1670 } \
1671 }
1672
1673 PROGRAM_MATCH(fnmatch, program, i);
1674 PROGRAM_MATCH(strcmp, program, i);
1675 PROGRAM_MATCH(strncmp, program, i);
1676 PROGRAM_MATCH(strrncmp, program, i);
1677 PROGRAM_MATCH(nocmp, program, i);
1678
1679#undef PROGRAM_MATCH
1680
1681 if (!find)
1682 {
1683 if (!program->anonymous)
1684 ERR("%s: Error. Unable to find program name \"%s\".",
1685 progname, program->u.name);
1686 else
1687 ERR("%s: Error. Unable to find anonymous program.",
1688 progname);
1689 exit(-1);
1690 }
1691
1692 if (!program->anonymous)
1693 free(program->u.name);
1694 free(program);
1695 }
1696
1697 EINA_LIST_FREE(group_lookups, group)
1698 {
1699 Edje_Part_Collection_Directory_Entry *de;
1700
1701 de = eina_hash_find(edje_file->collection, group->name);
1702
1703 if (!de)
1704 {
1705 ERR("%s: Error. Unable to find group name \"%s\".",
1706 progname, group->name);
1707 exit(-1);
1708 }
1709
1710 free(group->name);
1711 free(group);
1712 }
1713
1714 EINA_LIST_FREE(image_lookups, image)
1715 {
1716 Edje_Image_Directory_Entry *de;
1717 Eina_Bool find = EINA_FALSE;
1718
1719 if (edje_file->image_dir)
1720 {
1721 unsigned int i;
1722
1723 for (i = 0; i < edje_file->image_dir->entries_count; ++i)
1724 {
1725 de = edje_file->image_dir->entries + i;
1726
1727 if ((de->entry) && (!strcmp(de->entry, image->name)))
1728 {
1729 handle_slave_lookup(image_slave_lookups, image->dest, de->id);
1730 if (de->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL)
1731 *(image->dest) = -de->id - 1;
1732 else
1733 *(image->dest) = de->id;
1734 *(image->set) = EINA_FALSE;
1735 find = EINA_TRUE;
1736 break;
1737 }
1738 }
1739
1740 if (!find)
1741 {
1742 Edje_Image_Directory_Set *set;
1743
1744 for (i = 0; i < edje_file->image_dir->sets_count; ++i)
1745 {
1746 set = edje_file->image_dir->sets + i;
1747
1748 if ((set->name) && (!strcmp(set->name, image->name)))
1749 {
1750 handle_slave_lookup(image_slave_lookups, image->dest, set->id);
1751 *(image->dest) = set->id;
1752 *(image->set) = EINA_TRUE;
1753 find = EINA_TRUE;
1754 break;
1755 }
1756 }
1757 }
1758 }
1759
1760 if (!find)
1761 {
1762 ERR("%s: Error. Unable to find image name \"%s\".",
1763 progname, image->name);
1764 exit(-1);
1765 }
1766
1767 free(image->name);
1768 free(image);
1769 }
1770
1771 EINA_LIST_FREE(part_slave_lookups, data)
1772 free(data);
1773
1774 EINA_LIST_FREE(image_slave_lookups, data)
1775 free(data);
1776}
1777
1778static void
1779data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len))
1780{
1781 char *p;
1782 char *key;
1783 int keyl;
1784 int quote, escape;
1785
1786 key = alloca(strlen(prefix) + 2 + 1);
1787 if (!key) return;
1788 strcpy(key, prefix);
1789 strcat(key, ":\"");
1790 keyl = strlen(key);
1791 quote = 0;
1792 escape = 0;
1793 for (p = s; (p) && (*p); p++)
1794 {
1795 if (!quote)
1796 {
1797 if (*p == '\"')
1798 {
1799 quote = 1;
1800 p++;
1801 }
1802 }
1803 if (!quote)
1804 {
1805 if (!strncmp(p, key, keyl))
1806 {
1807 char *ptr;
1808 int len;
1809 int inesc = 0;
1810 char *name;
1811
1812 ptr = p;
1813 p += keyl;
1814 while ((*p))
1815 {
1816 if (!inesc)
1817 {
1818 if (*p == '\\') inesc = 1;
1819 else if (*p == '\"')
1820 {
1821 /* string concatenation, see below */
1822 if (*(p + 1) != '\"')
1823 break;
1824 else
1825 p++;
1826 }
1827 }
1828 else
1829 inesc = 0;
1830 p++;
1831 }
1832 len = p - ptr + 1;
1833 name = alloca(len);
1834 if (name)
1835 {
1836 char *pp;
1837 int i;
1838
1839 name[0] = 0;
1840 pp = ptr + keyl;
1841 inesc = 0;
1842 i = 0;
1843 while (*pp)
1844 {
1845 if (!inesc)
1846 {
1847 if (*pp == '\\') inesc = 1;
1848 else if (*pp == '\"')
1849 {
1850 /* concat strings like "foo""bar" to "foobar" */
1851 if (*(pp + 1) == '\"')
1852 pp++;
1853 else
1854 {
1855 name[i] = 0;
1856 break;
1857 }
1858 }
1859 else
1860 {
1861 name[i] = *pp;
1862 name[i + 1] = 0;
1863 i++;
1864 }
1865 }
1866 else
1867 inesc = 0;
1868 pp++;
1869 }
1870 func(pc, name, ptr, len);
1871 }
1872 }
1873 }
1874 else
1875 {
1876 if (!escape)
1877 {
1878 if (*p == '\"') quote = 0;
1879 else if (*p == '\\') escape = 1;
1880 }
1881 else if (escape)
1882 {
1883 escape = 0;
1884 }
1885 }
1886 }
1887}
1888
1889static void
1890_data_queue_part_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len)
1891{
1892 Code_Lookup *cl;
1893 cl = mem_alloc(SZ(Code_Lookup));
1894 cl->ptr = ptr;
1895 cl->len = len;
1896
1897 data_queue_part_lookup(pc, name, &(cl->val));
1898
1899 code_lookups = eina_list_append(code_lookups, cl);
1900}
1901static void
1902_data_queue_program_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len)
1903{
1904 Code_Lookup *cl;
1905
1906 cl = mem_alloc(SZ(Code_Lookup));
1907 cl->ptr = ptr;
1908 cl->len = len;
1909
1910 data_queue_program_lookup(pc, name, &(cl->val));
1911
1912 code_lookups = eina_list_append(code_lookups, cl);
1913}
1914static void
1915_data_queue_group_lookup(Edje_Part_Collection *pc __UNUSED__, char *name, char *ptr __UNUSED__, int len __UNUSED__)
1916{
1917 data_queue_group_lookup(name);
1918}
1919static void
1920_data_queue_image_pc_lookup(Edje_Part_Collection *pc __UNUSED__, char *name, char *ptr, int len)
1921{
1922 Code_Lookup *cl;
1923
1924 cl = mem_alloc(SZ(Code_Lookup));
1925 cl->ptr = ptr;
1926 cl->len = len;
1927
1928 data_queue_image_lookup(name, &(cl->val), &(cl->set));
1929
1930 code_lookups = eina_list_append(code_lookups, cl);
1931}
1932
1933void
1934data_process_scripts(void)
1935{
1936 Eina_List *l, *l2;
1937
1938 for (l = codes, l2 = edje_collections; (l) && (l2); l = eina_list_next(l), l2 = eina_list_next(l2))
1939 {
1940 Edje_Part_Collection *pc;
1941 Code *cd;
1942
1943 cd = eina_list_data_get(l);
1944 pc = eina_list_data_get(l2);
1945
1946 if ((cd->shared) && (!cd->is_lua))
1947 {
1948 data_process_string(pc, "PART", cd->shared, _data_queue_part_lookup);
1949 data_process_string(pc, "PROGRAM", cd->shared, _data_queue_program_lookup);
1950 data_process_string(pc, "IMAGE", cd->shared, _data_queue_image_pc_lookup);
1951 data_process_string(pc, "GROUP", cd->shared, _data_queue_group_lookup);
1952 }
1953
1954 if (cd->programs)
1955 {
1956 Code_Program *cp;
1957 Eina_List *ll;
1958
1959 EINA_LIST_FOREACH(cd->programs, ll, cp)
1960 {
1961 if (cp->script)
1962 {
1963 data_process_string(pc, "PART", cp->script, _data_queue_part_lookup);
1964 data_process_string(pc, "PROGRAM", cp->script, _data_queue_program_lookup);
1965 data_process_string(pc, "IMAGE", cp->script, _data_queue_image_pc_lookup);
1966 data_process_string(pc, "GROUP", cp->script, _data_queue_group_lookup);
1967 }
1968 }
1969 }
1970 }
1971}
1972
1973void
1974data_process_script_lookups(void)
1975{
1976 Eina_List *l;
1977 Code_Lookup *cl;
1978
1979 EINA_LIST_FOREACH(code_lookups, l, cl)
1980 {
1981 char buf[12];
1982 int n;
1983
1984 /* FIXME !! Handle set in program */
1985 n = eina_convert_itoa(cl->val, buf);
1986 if (n > cl->len)
1987 {
1988 ERR("%s: Error. The unexpected happened. A numeric replacement string was larger than the original!",
1989 progname);
1990 exit(-1);
1991 }
1992 memset(cl->ptr, ' ', cl->len);
1993 strncpy(cl->ptr, buf, n);
1994 }
1995}
diff --git a/libraries/edje/src/bin/edje_cc_parse.c b/libraries/edje/src/bin/edje_cc_parse.c
new file mode 100644
index 0000000..ae68e00
--- /dev/null
+++ b/libraries/edje/src/bin/edje_cc_parse.c
@@ -0,0 +1,1552 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#ifdef HAVE_ALLOCA_H
6# include <alloca.h>
7#elif defined __GNUC__
8# define alloca __builtin_alloca
9#elif defined _AIX
10# define alloca __alloca
11#elif defined _MSC_VER
12# include <malloc.h>
13# define alloca _alloca
14#else
15# include <stddef.h>
16# ifdef __cplusplus
17extern "C"
18# endif
19void *alloca (size_t);
20#endif
21
22#include <string.h>
23#include <ctype.h>
24#include <limits.h>
25#include <errno.h>
26#include <sys/types.h>
27#include <sys/stat.h>
28#include <unistd.h>
29#include <fcntl.h>
30#include <math.h>
31
32#include "edje_cc.h"
33#include <Ecore.h>
34#include <Ecore_File.h>
35
36#ifdef _WIN32
37# define EPP_EXT ".exe"
38#else
39# define EPP_EXT
40#endif
41
42static void new_object(void);
43static void new_statement(void);
44static char *perform_math (char *input);
45static int isdelim(char c);
46static char *next_token(char *p, char *end, char **new_p, int *delim);
47static char *stack_id(void);
48static void stack_chop_top(void);
49static void parse(char *data, off_t size);
50
51/* simple expression parsing protos */
52static int my_atoi(const char * s);
53static char * _alphai(char *s, int * val);
54static char * _betai(char *s, int * val);
55static char * _gammai(char *s, int * val);
56static char * _deltai(char *s, int * val);
57static char * _get_numi(char *s, int * val);
58static int _is_numi(char c);
59static int _is_op1i(char c);
60static int _is_op2i(char c);
61static int _calci(char op, int a, int b);
62
63static double my_atof(const char * s);
64static char * _alphaf(char *s, double * val);
65static char * _betaf(char *s, double * val);
66static char * _gammaf(char *s, double * val);
67static char * _deltaf(char *s, double * val);
68static char * _get_numf(char *s, double * val);
69static int _is_numf(char c);
70static int _is_op1f(char c);
71static int _is_op2f(char c);
72static double _calcf(char op, double a, double b);
73static int strstrip(const char *in, char *out, size_t size);
74
75
76int line = 0;
77Eina_List *stack = NULL;
78Eina_List *params = NULL;
79
80static char file_buf[4096];
81static int verbatim = 0;
82static int verbatim_line1 = 0;
83static int verbatim_line2 = 0;
84static char *verbatim_str = NULL;
85
86static void
87err_show_stack(void)
88{
89 char *s;
90
91 s = stack_id();
92 if (s)
93 {
94 printf("PARSE STACK:\n%s\n", s);
95 free(s);
96 }
97 else
98 printf("NO PARSE STACK\n");
99}
100
101static void
102err_show_params(void)
103{
104 Eina_List *l;
105 char *p;
106
107 printf("PARAMS:");
108 EINA_LIST_FOREACH(params, l, p)
109 {
110 printf(" %s", p);
111 }
112 printf("\n");
113}
114
115static void
116err_show(void)
117{
118 err_show_stack();
119 err_show_params();
120}
121
122static void
123new_object(void)
124{
125 char *id;
126 int i;
127 int handled = 0;
128
129 id = stack_id();
130 for (i = 0; i < object_handler_num(); i++)
131 {
132 if (!strcmp(object_handlers[i].type, id))
133 {
134 handled = 1;
135 if (object_handlers[i].func)
136 {
137 object_handlers[i].func();
138 }
139 break;
140 }
141 }
142 if (!handled)
143 {
144 for (i = 0; i < statement_handler_num(); i++)
145 {
146 if (!strcmp(statement_handlers[i].type, id))
147 {
148 free(id);
149 return;
150 }
151 }
152 }
153 if (!handled)
154 {
155 ERR("%s: Error. %s:%i unhandled keyword %s",
156 progname, file_in, line - 1,
157 (char *)eina_list_data_get(eina_list_last(stack)));
158 err_show();
159 exit(-1);
160 }
161 free(id);
162}
163
164static void
165new_statement(void)
166{
167 char *id;
168 int i;
169 int handled = 0;
170
171 id = stack_id();
172 for (i = 0; i < statement_handler_num(); i++)
173 {
174 if (!strcmp(statement_handlers[i].type, id))
175 {
176 handled = 1;
177 if (statement_handlers[i].func)
178 {
179 statement_handlers[i].func();
180 }
181 break;
182 }
183 }
184 if (!handled)
185 {
186 ERR("%s: Error. %s:%i unhandled keyword %s",
187 progname, file_in, line - 1,
188 (char *)eina_list_data_get(eina_list_last(stack)));
189 err_show();
190 exit(-1);
191 }
192 free(id);
193}
194
195static char *
196perform_math (char *input)
197{
198 char buf[256];
199 double res;
200
201 /* FIXME
202 * Always apply floating-point arithmetic.
203 * Does this cause problems for integer parameters? (yes it will)
204 *
205 * What we should do is, loop over the string and figure out whether
206 * there are floating point operands, too and then switch to
207 * floating point math.
208 */
209 res = my_atof(input);
210 snprintf(buf, sizeof (buf), "%lf", res);
211 return strdup(buf);
212}
213
214static int
215isdelim(char c)
216{
217 const char *delims = "{},;:";
218 char *d;
219
220 d = (char *)delims;
221 while (*d)
222 {
223 if (c == *d) return 1;
224 d++;
225 }
226 return 0;
227}
228
229static char *
230next_token(char *p, char *end, char **new_p, int *delim)
231{
232 char *tok_start = NULL, *tok_end = NULL, *tok = NULL, *sa_start = NULL;
233 int in_tok = 0;
234 int in_quote = 0;
235 int in_parens = 0;
236 int in_comment_ss = 0;
237 int in_comment_cpp = 0;
238 int in_comment_sa = 0;
239 int had_quote = 0;
240 int is_escaped = 0;
241 char *cpp_token_line = NULL;
242 char *cpp_token_file = NULL;
243
244 *delim = 0;
245 if (p >= end) return NULL;
246 while (p < end)
247 {
248 if (*p == '\n')
249 {
250 in_comment_ss = 0;
251 in_comment_cpp = 0;
252 cpp_token_line = NULL;
253 cpp_token_file = NULL;
254 line++;
255 }
256 if ((!in_comment_ss) && (!in_comment_sa))
257 {
258 if ((!in_quote) && (*p == '/') && (p < (end - 1)) && (*(p + 1) == '/'))
259 in_comment_ss = 1;
260 if ((!in_quote) && (*p == '#'))
261 in_comment_cpp = 1;
262 if ((!in_quote) && (*p == '/') && (p < (end - 1)) && (*(p + 1) == '*'))
263 {
264 in_comment_sa = 1;
265 sa_start = p;
266 }
267 }
268 if ((in_comment_cpp) && (*p == '#'))
269 {
270 char *pp, fl[4096];
271 char *tmpstr = NULL;
272 int l, nm;
273
274 /* handle cpp comments */
275 /* their line format is
276 * #line <line no. of next line> <filename from next line on> [??]
277 */
278 cpp_token_line = NULL;
279 cpp_token_file = NULL;
280
281 pp = p;
282 while ((pp < end) && (*pp != '\n'))
283 {
284 pp++;
285 }
286 l = pp - p;
287 tmpstr = alloca(l + 1);
288 if (!tmpstr)
289 {
290 ERR("%s: Error. %s:%i malloc %i bytes failed",
291 progname, file_in, line - 1, l + 1);
292 exit(-1);
293 }
294 strncpy(tmpstr, p, l);
295 tmpstr[l] = 0;
296 l = sscanf(tmpstr, "%*s %i \"%[^\"]\"", &nm, fl);
297 if (l == 2)
298 {
299 strcpy(file_buf, fl);
300 line = nm;
301 file_in = file_buf;
302 }
303 }
304 else if ((!in_comment_ss) && (!in_comment_sa) && (!in_comment_cpp))
305 {
306 if (!in_tok)
307 {
308 if (!in_quote)
309 {
310 if (!isspace(*p))
311 {
312 if (*p == '"')
313 {
314 in_quote = 1;
315 had_quote = 1;
316 }
317 else if (*p == '(')
318 in_parens++;
319
320 in_tok = 1;
321 tok_start = p;
322 if (isdelim(*p)) *delim = 1;
323 }
324 }
325 }
326 else
327 {
328 if (in_quote)
329 {
330 if ((*p) == '\\')
331 is_escaped = !is_escaped;
332 else if (((*p) == '"') && (!is_escaped))
333 {
334 in_quote = 0;
335 had_quote = 1;
336 }
337 else if (is_escaped)
338 is_escaped = 0;
339 }
340 else if (in_parens)
341 {
342 if (((*p) == ')') && (!is_escaped))
343 in_parens--;
344 }
345 else
346 {
347 if (*p == '"')
348 {
349 in_quote = 1;
350 had_quote = 1;
351 }
352 else if (*p == '(')
353 in_parens++;
354
355 /* check for end-of-token */
356 if (
357 (isspace(*p)) ||
358 ((*delim) && (!isdelim(*p))) ||
359 (isdelim(*p))
360 )
361 {/*the line below this is never used because it skips to
362 * the 'done' label which is after the return call for
363 * in_tok being 0. is this intentional?
364 */
365 in_tok = 0;
366
367 tok_end = p - 1;
368 if (*p == '\n') line--;
369 goto done;
370 }
371 }
372 }
373 }
374 if (in_comment_sa)
375 {
376 if ((*p == '/') && (*(p - 1) == '*') && ((p - sa_start) > 2))
377 in_comment_sa = 0;
378 }
379 p++;
380 }
381 if (!in_tok) return NULL;
382 tok_end = p - 1;
383
384 done:
385 *new_p = p;
386
387 tok = mem_alloc(tok_end - tok_start + 2);
388 strncpy(tok, tok_start, tok_end - tok_start + 1);
389 tok[tok_end - tok_start + 1] = 0;
390
391 if (had_quote)
392 {
393 is_escaped = 0;
394 p = tok;
395
396 while (*p)
397 {
398 if ((*p == '\"') && (!is_escaped))
399 {
400 memmove(p, p + 1, strlen(p));
401 }
402 else if ((*p == '\\') && (*(p + 1) == 'n'))
403 {
404 memmove(p, p + 1, strlen(p));
405 *p = '\n';
406 }
407 else if ((*p == '\\') && (*(p + 1) == 't'))
408 {
409 memmove(p, p + 1, strlen(p));
410 *p = '\t';
411 }
412 else if (*p == '\\')
413 {
414 memmove(p, p + 1, strlen(p));
415 if (*p == '\\') p++;
416 else is_escaped = 1;
417 }
418 else
419 {
420 if (is_escaped) is_escaped = 0;
421 p++;
422 }
423 }
424 }
425 else if ((tok) && (*tok == '('))
426 {
427 char *tmp;
428 tmp = tok;
429 tok = perform_math(tok);
430 free(tmp);
431 }
432
433 return tok;
434}
435
436static char *
437stack_id(void)
438{
439 char *id;
440 int len;
441 Eina_List *l;
442 char *data;
443
444 len = 0;
445 EINA_LIST_FOREACH(stack, l, data)
446 len += strlen(data) + 1;
447 id = mem_alloc(len);
448 id[0] = 0;
449 EINA_LIST_FOREACH(stack, l, data)
450 {
451 strcat(id, data);
452 if (eina_list_next(l)) strcat(id, ".");
453 }
454 return id;
455}
456
457static void
458stack_chop_top(void)
459{
460 char *top;
461
462 /* remove top from stack */
463 top = eina_list_data_get(eina_list_last(stack));
464 if (top)
465 {
466 free(top);
467 stack = eina_list_remove(stack, top);
468 }
469 else
470 {
471 ERR("%s: Error. parse error %s:%i. } marker without matching { marker",
472 progname, file_in, line - 1);
473 err_show();
474 exit(-1);
475 }
476}
477
478static void
479parse(char *data, off_t size)
480{
481 char *p, *end, *token;
482 int delim = 0;
483 int do_params = 0;
484
485 if (verbose)
486 {
487 INF("%s: Parsing input file",
488 progname);
489 }
490 p = data;
491 end = data + size;
492 line = 1;
493 while ((token = next_token(p, end, &p, &delim)))
494 {
495 /* if we are in param mode, the only delimiter
496 * we'll accept is the semicolon
497 */
498 if (do_params && delim && *token != ';')
499 {
500 ERR("%s: Error. parse error %s:%i. %c marker before ; marker",
501 progname, file_in, line - 1, *token);
502 err_show();
503 exit(-1);
504 }
505 else if (delim)
506 {
507 if (*token == ',' || *token == ':') do_params = 1;
508 else if (*token == '}')
509 {
510 if (do_params)
511 {
512 ERR("%s: Error. parse error %s:%i. } marker before ; marker",
513 progname, file_in, line - 1);
514 err_show();
515 exit(-1);
516 }
517 else
518 stack_chop_top();
519 }
520 else if (*token == ';')
521 {
522 if (do_params)
523 {
524 do_params = 0;
525 new_statement();
526 /* clear out params */
527 while (params)
528 {
529 free(eina_list_data_get(params));
530 params = eina_list_remove(params, eina_list_data_get(params));
531 }
532 /* remove top from stack */
533 stack_chop_top();
534 }
535 }
536 else if (*token == '{')
537 {
538 if (do_params)
539 {
540 ERR("%s: Error. parse error %s:%i. { marker before ; marker",
541 progname, file_in, line - 1);
542 err_show();
543 exit(-1);
544 }
545 }
546 free(token);
547 }
548 else
549 {
550 if (do_params)
551 params = eina_list_append(params, token);
552 else
553 {
554 stack = eina_list_append(stack, token);
555 new_object();
556 if ((verbatim == 1) && (p < (end - 2)))
557 {
558 int escaped = 0;
559 int inquotes = 0;
560 int insquotes = 0;
561 int squigglie = 1;
562 int l1 = 0, l2 = 0;
563 char *verbatim_1;
564 char *verbatim_2;
565
566 l1 = line;
567 while ((p[0] != '{') && (p < end))
568 {
569 if (*p == '\n') line++;
570 p++;
571 }
572 p++;
573 verbatim_1 = p;
574 verbatim_2 = NULL;
575 for (; p < end; p++)
576 {
577 if (*p == '\n') line++;
578 if (escaped) escaped = 0;
579 if (!escaped)
580 {
581 if (p[0] == '\\') escaped = 1;
582 else if (p[0] == '\"')
583 {
584 if (!insquotes)
585 {
586 if (inquotes) inquotes = 0;
587 else inquotes = 1;
588 }
589 }
590 else if (p[0] == '\'')
591 {
592 if (!inquotes)
593 {
594 if (insquotes) insquotes = 0;
595 else insquotes = 1;
596 }
597 }
598 else if ((!inquotes) && (!insquotes))
599 {
600 if (p[0] == '{') squigglie++;
601 else if (p[0] == '}') squigglie--;
602 if (squigglie == 0)
603 {
604 verbatim_2 = p - 1;
605 l2 = line;
606 break;
607 }
608 }
609 }
610 }
611 if (verbatim_2 > verbatim_1)
612 {
613 int l;
614 char *v;
615
616 l = verbatim_2 - verbatim_1 + 1;
617 v = malloc(l + 1);
618 strncpy(v, verbatim_1, l);
619 v[l] = 0;
620 set_verbatim(v, l1, l2);
621 }
622 else
623 {
624 ERR("%s: Error. parse error %s:%i. { marker does not have matching } marker",
625 progname, file_in, line - 1);
626 err_show();
627 exit(-1);
628 }
629 new_object();
630 verbatim = 0;
631 }
632 }
633 }
634 }
635 if (verbose)
636 {
637 INF("%s: Parsing done",
638 progname);
639 }
640}
641
642static char *clean_file = NULL;
643static void
644clean_tmp_file(void)
645{
646 if (clean_file) unlink(clean_file);
647}
648
649int
650is_verbatim(void)
651{
652 return verbatim;
653}
654
655void
656track_verbatim(int on)
657{
658 verbatim = on;
659}
660
661void
662set_verbatim(char *s, int l1, int l2)
663{
664 verbatim_line1 = l1;
665 verbatim_line2 = l2;
666 verbatim_str = s;
667}
668
669char *
670get_verbatim(void)
671{
672 return verbatim_str;
673}
674
675int
676get_verbatim_line1(void)
677{
678 return verbatim_line1;
679}
680
681int
682get_verbatim_line2(void)
683{
684 return verbatim_line2;
685}
686
687void
688compile(void)
689{
690 char buf[4096], buf2[4096];
691 char inc[4096];
692 static char tmpn[4096];
693 int fd;
694 off_t size;
695 char *data, *p;
696 Eina_List *l;
697 Edje_Style *stl;
698
699 if (!tmp_dir)
700#ifdef HAVE_EVIL
701 tmp_dir = (char *)evil_tmpdir_get();
702#else
703 tmp_dir = "/tmp";
704#endif
705
706 strncpy(inc, file_in, 4000);
707 inc[4001] = 0;
708 p = strrchr(inc, '/');
709 if (!p) strcpy(inc, "./");
710 else *p = 0;
711 snprintf(tmpn, PATH_MAX, "%s/edje_cc.edc-tmp-XXXXXX", tmp_dir);
712 fd = mkstemp(tmpn);
713 if (fd >= 0)
714 {
715 int ret;
716 char *def;
717
718 clean_file = tmpn;
719 close(fd);
720 atexit(clean_tmp_file);
721 if (!defines)
722 def = mem_strdup("");
723 else
724 {
725 int len;
726 char *define;
727
728 len = 0;
729 EINA_LIST_FOREACH(defines, l, define)
730 len += strlen(define) + 1;
731 def = mem_alloc(len + 1);
732 def[0] = 0;
733 EINA_LIST_FOREACH(defines, l, define)
734 {
735 strcat(def, define);
736 strcat(def, " ");
737 }
738 }
739
740 /*
741 * Run the input through the C pre-processor.
742 */
743 ret = -1;
744 snprintf(buf2, sizeof(buf2), "%s/edje/utils/epp" EPP_EXT,
745 eina_prefix_lib_get(pfx));
746 if (ecore_file_exists(buf2))
747 {
748 snprintf(buf, sizeof(buf), "%s %s -I%s %s -o %s",
749 buf2, file_in, inc, def, tmpn);
750 ret = system(buf);
751 }
752 else
753 {
754 ERR("Error. Cannot run epp: %s", buf2);
755 exit(-1);
756 }
757 if (ret == EXIT_SUCCESS)
758 file_in = tmpn;
759 else
760 {
761 ERR("Error. Exit code of epp not clean: %i", ret);
762 exit(-1);
763 }
764 free(def);
765 }
766 fd = open(file_in, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR);
767 if (fd < 0)
768 {
769 ERR("%s: Error. cannot open file \"%s\" for input. %s",
770 progname, file_in, strerror(errno));
771 exit(-1);
772 }
773 if (verbose)
774 {
775 INF("%s: Opening \"%s\" for input", progname, file_in);
776 }
777
778 size = lseek(fd, 0, SEEK_END);
779 lseek(fd, 0, SEEK_SET);
780 data = malloc(size);
781 if (data && (read(fd, data, size) == size))
782 parse(data, size);
783 else
784 {
785 ERR("%s: Error. cannot read file \"%s\". %s",
786 progname, file_in, strerror(errno));
787 exit(-1);
788 }
789 free(data);
790 close(fd);
791
792 EINA_LIST_FOREACH(edje_file->styles, l, stl)
793 {
794 if (!stl->name)
795 {
796 ERR("%s: Error. style must have a name.", progname);
797 exit(-1);
798 }
799 }
800}
801
802int
803is_param(int n)
804{
805 char *str;
806
807 str = eina_list_nth(params, n);
808 if (str) return 1;
809 return 0;
810}
811
812int
813is_num(int n)
814{
815 char *str;
816 char *end;
817 long int ret;
818
819 str = eina_list_nth(params, n);
820 if (!str)
821 {
822 ERR("%s: Error. %s:%i no parameter supplied as argument %i",
823 progname, file_in, line - 1, n + 1);
824 err_show();
825 exit(-1);
826 }
827 if (str[0] == 0) return 0;
828 end = str;
829 ret = strtol(str, &end, 0);
830 if ((ret == LONG_MIN) || (ret == LONG_MAX))
831 {
832 n = 0; // do nothing. shut gcc warnings up
833 }
834 if ((end != str) && (end[0] == 0)) return 1;
835 return 0;
836}
837
838char *
839parse_str(int n)
840{
841 char *str;
842 char *s;
843
844 str = eina_list_nth(params, n);
845 if (!str)
846 {
847 ERR("%s: Error. %s:%i no parameter supplied as argument %i",
848 progname, file_in, line - 1, n + 1);
849 err_show();
850 exit(-1);
851 }
852 s = mem_strdup(str);
853 return s;
854}
855
856static int
857_parse_enum(char *str, va_list va)
858{
859 va_list va2;
860 va_copy(va2, va); /* iterator for the error message */
861
862 for (;;)
863 {
864 char *s;
865 int v;
866
867 s = va_arg(va, char *);
868
869 /* End of the list, nothing matched. */
870 if (!s)
871 {
872 fprintf(stderr, "%s: Error. %s:%i token %s not one of:",
873 progname, file_in, line - 1, str);
874 s = va_arg(va2, char *);
875 while (s)
876 {
877 va_arg(va2, int);
878 fprintf(stderr, " %s", s);
879 s = va_arg(va2, char *);
880 if (!s) break;
881 }
882 fprintf(stderr, "\n");
883 va_end(va2);
884 va_end(va);
885 err_show();
886 exit(-1);
887 }
888
889 v = va_arg(va, int);
890 if (!strcmp(s, str))
891 {
892 va_end(va2);
893 va_end(va);
894 return v;
895 }
896 }
897 va_end(va2);
898 va_end(va);
899 return 0;
900}
901
902int
903parse_enum(int n, ...)
904{
905 char *str;
906 int result;
907 va_list va;
908
909 str = eina_list_nth(params, n);
910 if (!str)
911 {
912 ERR("%s: Error. %s:%i no parameter supplied as argument %i",
913 progname, file_in, line - 1, n + 1);
914 err_show();
915 exit(-1);
916 }
917
918 va_start(va, n);
919 result = _parse_enum(str, va);
920 va_end(va);
921
922 return result;
923}
924
925int
926parse_flags(int n, ...)
927{
928 Eina_List *lst;
929 int result = 0;
930 va_list va;
931 char *data;
932
933 va_start(va, n);
934 EINA_LIST_FOREACH(eina_list_nth_list(params, n), lst, data)
935 result |= _parse_enum(data, va);
936 va_end(va);
937
938 return result;
939}
940
941int
942parse_int(int n)
943{
944 char *str;
945 int i;
946
947 str = eina_list_nth(params, n);
948 if (!str)
949 {
950 ERR("%s: Error. %s:%i no parameter supplied as argument %i",
951 progname, file_in, line - 1, n + 1);
952 err_show();
953 exit(-1);
954 }
955 i = my_atoi(str);
956 return i;
957}
958
959int
960parse_int_range(int n, int f, int t)
961{
962 char *str;
963 int i;
964
965 str = eina_list_nth(params, n);
966 if (!str)
967 {
968 ERR("%s: Error. %s:%i no parameter supplied as argument %i",
969 progname, file_in, line - 1, n + 1);
970 err_show();
971 exit(-1);
972 }
973 i = my_atoi(str);
974 if ((i < f) || (i > t))
975 {
976 ERR("%s: Error. %s:%i integer %i out of range of %i to %i inclusive",
977 progname, file_in, line - 1, i, f, t);
978 err_show();
979 exit(-1);
980 }
981 return i;
982}
983
984int
985parse_bool(int n)
986{
987 char *str, buf[4096];
988 int i;
989
990 str = eina_list_nth(params, n);
991 if (!str)
992 {
993 ERR("%s: Error. %s:%i no parameter supplied as argument %i",
994 progname, file_in, line - 1, n + 1);
995 err_show();
996 exit(-1);
997 }
998
999 if (!strstrip(str, buf, sizeof (buf)))
1000 {
1001 ERR("%s: Error. %s:%i expression is too long",
1002 progname, file_in, line - 1);
1003 return 0;
1004 }
1005
1006 if (!strcasecmp(buf, "false") || !strcasecmp(buf, "off"))
1007 return 0;
1008 if (!strcasecmp(buf, "true") || !strcasecmp(buf, "on"))
1009 return 1;
1010
1011 i = my_atoi(str);
1012 if ((i < 0) || (i > 1))
1013 {
1014 ERR("%s: Error. %s:%i integer %i out of range of 0 to 1 inclusive",
1015 progname, file_in, line - 1, i);
1016 err_show();
1017 exit(-1);
1018 }
1019 return i;
1020}
1021
1022double
1023parse_float(int n)
1024{
1025 char *str;
1026 double i;
1027
1028 str = eina_list_nth(params, n);
1029 if (!str)
1030 {
1031 ERR("%s: Error. %s:%i no parameter supplied as argument %i",
1032 progname, file_in, line - 1, n + 1);
1033 err_show();
1034 exit(-1);
1035 }
1036 i = my_atof(str);
1037 return i;
1038}
1039
1040double
1041parse_float_range(int n, double f, double t)
1042{
1043 char *str;
1044 double i;
1045
1046 str = eina_list_nth(params, n);
1047 if (!str)
1048 {
1049 ERR("%s: Error. %s:%i no parameter supplied as argument %i",
1050 progname, file_in, line - 1, n + 1);
1051 err_show();
1052 exit(-1);
1053 }
1054 i = my_atof(str);
1055 if ((i < f) || (i > t))
1056 {
1057 ERR("%s: Error. %s:%i float %3.3f out of range of %3.3f to %3.3f inclusive",
1058 progname, file_in, line - 1, i, f, t);
1059 err_show();
1060 exit(-1);
1061 }
1062 return i;
1063}
1064
1065int
1066get_arg_count(void)
1067{
1068 return eina_list_count (params);
1069}
1070
1071void
1072check_arg_count(int required_args)
1073{
1074 int num_args = eina_list_count (params);
1075
1076 if (num_args != required_args)
1077 {
1078 ERR("%s: Error. %s:%i got %i arguments, but expected %i",
1079 progname, file_in, line - 1, num_args, required_args);
1080 err_show();
1081 exit(-1);
1082 }
1083}
1084
1085void
1086check_min_arg_count(int min_required_args)
1087{
1088 int num_args = eina_list_count (params);
1089
1090 if (num_args < min_required_args)
1091 {
1092 ERR("%s: Error. %s:%i got %i arguments, "
1093 "but expected at least %i",
1094 progname, file_in, line - 1, num_args, min_required_args);
1095 err_show();
1096 exit(-1);
1097 }
1098}
1099
1100/* simple expression parsing stuff */
1101
1102/*
1103 * alpha ::= beta + beta || beta
1104 * beta ::= gamma + gamma || gamma
1105 * gamma ::= num || delta
1106 * delta ::= '(' alpha ')'
1107 *
1108 */
1109
1110/* int set of function */
1111
1112static int
1113my_atoi(const char *s)
1114{
1115 int res = 0;
1116 char buf[4096];
1117
1118 if (!s) return 0;
1119 if (!strstrip(s, buf, sizeof(buf)))
1120 {
1121 ERR("%s: Error. %s:%i expression is too long\n",
1122 progname, file_in, line - 1);
1123 return 0;
1124 }
1125 _alphai(buf, &res);
1126 return res;
1127}
1128
1129static char *
1130_deltai(char *s, int *val)
1131{
1132 if (!val) return NULL;
1133 if ('(' != s[0])
1134 {
1135 ERR("%s: Error. %s:%i unexpected character at %s\n",
1136 progname, file_in, line - 1, s);
1137 return s;
1138 }
1139 else
1140 {
1141 s++;
1142 s = _alphai(s, val);
1143 s++;
1144 return s;
1145 }
1146 return s;
1147}
1148
1149static char *
1150_funci(char *s, int *val)
1151{
1152 if (!strncmp(s, "floor(", 6))
1153 {
1154 s += 5;
1155 s = _deltai(s, val);
1156 *val = *val;
1157 }
1158 else if (!strncmp(s, "ceil(", 5))
1159 {
1160 s += 4;
1161 s = _deltai(s, val);
1162 *val = *val;
1163 }
1164 else
1165 {
1166 ERR("%s: Error. %s:%i unexpected character at %s\n",
1167 progname, file_in, line - 1, s);
1168 }
1169 return s;
1170}
1171
1172static char *
1173_gammai(char *s, int *val)
1174{
1175 if (!val) return NULL;
1176 if (_is_numi(s[0]))
1177 {
1178 s = _get_numi(s, val);
1179 return s;
1180 }
1181 else if ('(' == s[0])
1182 {
1183 s = _deltai(s, val);
1184 return s;
1185 }
1186 else
1187 {
1188 s = _funci(s, val);
1189// ERR("%s: Error. %s:%i unexpected character at %s\n",
1190// progname, file_in, line - 1, s);
1191 }
1192 return s;
1193}
1194
1195static char *
1196_betai(char *s, int *val)
1197{
1198 int a1, a2;
1199 char op;
1200
1201 if (!val) return NULL;
1202 s = _gammai(s, &a1);
1203 while (_is_op1i(s[0]))
1204 {
1205 op = s[0];
1206 s++;
1207 s = _gammai(s, &a2);
1208 a1 = _calci(op, a1, a2);
1209 }
1210 (*val) = a1;
1211 return s;
1212}
1213
1214static char *
1215_alphai(char *s, int *val)
1216{
1217 int a1, a2;
1218 char op;
1219
1220 if (!val) return NULL;
1221 s = _betai(s, &a1);
1222 while (_is_op2i(s[0]))
1223 {
1224 op = s[0];
1225 s++;
1226 s = _betai(s, &a2);
1227 a1 = _calci(op, a1, a2);
1228 }
1229 (*val) = a1;
1230 return s;
1231}
1232
1233char *
1234_get_numi(char *s, int *val)
1235{
1236 char buf[4096];
1237 int pos = 0;
1238
1239 if (!val) return s;
1240 while ((('0' <= s[pos]) && ('9' >= s[pos])) ||
1241 ((0 == pos) && ('-' == s[pos])))
1242 {
1243 buf[pos] = s[pos];
1244 pos++;
1245 }
1246 buf[pos] = '\0';
1247 (*val) = atoi(buf);
1248 return (s + pos);
1249}
1250
1251int
1252_is_numi(char c)
1253{
1254 if (((c >= '0') && (c <= '9')) || ('-' == c) || ('+' == c))
1255 return 1;
1256 else
1257 return 0;
1258}
1259
1260int
1261_is_op1i(char c)
1262{
1263 switch (c)
1264 {
1265 case '*':;
1266 case '%':;
1267 case '/': return 1;
1268 default: break;
1269 }
1270 return 0;
1271}
1272
1273int
1274_is_op2i(char c)
1275{
1276 switch (c)
1277 {
1278 case '+':;
1279 case '-': return 1;
1280 default: break;
1281 }
1282 return 0;
1283}
1284
1285int
1286_calci(char op, int a, int b)
1287{
1288 switch(op)
1289 {
1290 case '+':
1291 a += b;
1292 return a;
1293 case '-':
1294 a -= b;
1295 return a;
1296 case '/':
1297 if (0 != b) a /= b;
1298 else
1299 ERR("%s: Error. %s:%i divide by zero\n",
1300 progname, file_in, line - 1);
1301 return a;
1302 case '*':
1303 a *= b;
1304 return a;
1305 case '%':
1306 if (0 != b) a = a % b;
1307 else
1308 ERR("%s: Error. %s:%i modula by zero\n",
1309 progname, file_in, line - 1);
1310 return a;
1311 default:
1312 ERR("%s: Error. %s:%i unexpected character '%c'\n",
1313 progname, file_in, line - 1, op);
1314 }
1315 return a;
1316}
1317
1318/* float set of functoins */
1319
1320double
1321my_atof(const char *s)
1322{
1323 double res = 0;
1324 char buf[4096];
1325
1326 if (!s) return 0;
1327
1328 if (!strstrip(s, buf, sizeof (buf)))
1329 {
1330 ERR("%s: Error. %s:%i expression is too long",
1331 progname, file_in, line - 1);
1332 return 0;
1333 }
1334 _alphaf(buf, &res);
1335 return res;
1336}
1337
1338static char *
1339_deltaf(char *s, double *val)
1340{
1341 if (!val) return NULL;
1342 if ('(' != s[0])
1343 {
1344 ERR("%s: Error. %s:%i unexpected character at %s",
1345 progname, file_in, line - 1, s);
1346 return s;
1347 }
1348 else
1349 {
1350 s++;
1351 s = _alphaf(s, val);
1352 s++;
1353 }
1354 return s;
1355}
1356
1357static char *
1358_funcf(char *s, double *val)
1359{
1360 if (!strncmp(s, "floor(", 6))
1361 {
1362 s += 5;
1363 s = _deltaf(s, val);
1364 *val = floor(*val);
1365 }
1366 else if (!strncmp(s, "ceil(", 5))
1367 {
1368 s += 4;
1369 s = _deltaf(s, val);
1370 *val = ceil(*val);
1371 }
1372 else
1373 {
1374 ERR("%s: Error. %s:%i unexpected character at %s\n",
1375 progname, file_in, line - 1, s);
1376 }
1377 return s;
1378}
1379
1380static char *
1381_gammaf(char *s, double *val)
1382{
1383 if (!val) return NULL;
1384
1385 if (_is_numf(s[0]))
1386 {
1387 s = _get_numf(s, val);
1388 return s;
1389 }
1390 else if ('(' == s[0])
1391 {
1392 s = _deltaf(s, val);
1393 return s;
1394 }
1395 else
1396 {
1397 s = _funcf(s, val);
1398// ERR("%s: Error. %s:%i unexpected character at %s\n",
1399// progname, file_in, line - 1, s);
1400 }
1401 return s;
1402}
1403
1404static char *
1405_betaf(char *s, double *val)
1406{
1407 double a1=0, a2=0;
1408 char op;
1409
1410 if (!val) return NULL;
1411 s = _gammaf(s, &a1);
1412 while (_is_op1f(s[0]))
1413 {
1414 op = s[0];
1415 s++;
1416 s = _gammaf(s, &a2);
1417 a1 = _calcf(op, a1, a2);
1418 }
1419 (*val) = a1;
1420 return s;
1421}
1422
1423static char *
1424_alphaf(char *s, double *val)
1425{
1426 double a1=0, a2=0;
1427 char op;
1428
1429 if (!val) return NULL;
1430 s = _betaf(s, &a1);
1431 while (_is_op2f(s[0]))
1432 {
1433 op = s[0];
1434 s++;
1435 s = _betaf(s, &a2);
1436 a1 = _calcf(op, a1, a2);
1437 }
1438 (*val) = a1;
1439 return s;
1440}
1441
1442static char *
1443_get_numf(char *s, double *val)
1444{
1445 char buf[4096];
1446 int pos = 0;
1447
1448 if (!val) return s;
1449
1450 while ((('0' <= s[pos]) && ('9' >= s[pos])) ||
1451 ('.' == s[pos]) ||
1452 ((0 == pos) && ('-' == s[pos])))
1453 {
1454 buf[pos] = s[pos];
1455 pos++;
1456 }
1457 buf[pos] = '\0';
1458 (*val) = atof(buf);
1459 return (s+pos);
1460}
1461
1462static int
1463_is_numf(char c)
1464{
1465 if (((c >= '0') && (c <= '9'))
1466 || ('-' == c)
1467 || ('.' == c)
1468 || ('+' == c))
1469 return 1;
1470 return 0;
1471}
1472
1473static int
1474_is_op1f(char c)
1475{
1476 switch(c)
1477 {
1478 case '*':;
1479 case '%':;
1480 case '/': return 1;
1481 default: break;
1482 }
1483 return 0;
1484}
1485
1486static int
1487_is_op2f(char c)
1488{
1489 switch(c)
1490 {
1491 case '+':;
1492 case '-': return 1;
1493 default: break;
1494 }
1495 return 0;
1496}
1497
1498static double
1499_calcf(char op, double a, double b)
1500{
1501 switch(op)
1502 {
1503 case '+':
1504 a += b;
1505 return a;
1506 case '-':
1507 a -= b;
1508 return a;
1509 case '/':
1510 if (b != 0) a /= b;
1511 else
1512 ERR("%s: Error. %s:%i divide by zero\n",
1513 progname, file_in, line - 1);
1514 return a;
1515 case '*':
1516 a *= b;
1517 return a;
1518 case '%':
1519 if (0 != b) a = (double)((int)a % (int)b);
1520 else
1521 ERR("%s: Error. %s:%i modula by zero\n",
1522 progname, file_in, line - 1);
1523 return a;
1524 default:
1525 ERR("%s: Error. %s:%i unexpected character '%c'\n",
1526 progname, file_in, line - 1, op);
1527 }
1528 return a;
1529}
1530
1531static int
1532strstrip(const char *in, char *out, size_t size)
1533{
1534 if ((size -1 ) < strlen(in))
1535 {
1536 ERR("%s: Error. %s:%i expression is too long",
1537 progname, file_in, line - 1);
1538 return 0;
1539 }
1540 /* remove spaces and tabs */
1541 while (*in)
1542 {
1543 if ((0x20 != *in) && (0x09 != *in))
1544 {
1545 *out = *in;
1546 out++;
1547 }
1548 in++;
1549 }
1550 *out = '\0';
1551 return 1;
1552}
diff --git a/libraries/edje/src/bin/edje_cc_sources.c b/libraries/edje/src/bin/edje_cc_sources.c
new file mode 100644
index 0000000..d9cd0c1
--- /dev/null
+++ b/libraries/edje/src/bin/edje_cc_sources.c
@@ -0,0 +1,259 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <string.h>
6#include <ctype.h>
7#include <limits.h>
8
9#include "edje_cc.h"
10
11static Eet_Data_Descriptor *_srcfile_edd = NULL;
12static Eet_Data_Descriptor *_srcfile_list_edd = NULL;
13
14static Eet_Data_Descriptor *_external_edd = NULL;
15static Eet_Data_Descriptor *_external_list_edd = NULL;
16
17static Eet_Data_Descriptor *_font_edd = NULL;
18static Eet_Data_Descriptor *_font_list_edd = NULL;
19
20static SrcFile_List srcfiles = {NULL};
21
22void
23source_edd(void)
24{
25 Eet_Data_Descriptor_Class eddc;
26
27 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "srcfile", sizeof (SrcFile));
28 _srcfile_edd = eet_data_descriptor_stream_new(&eddc);
29 EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "name", name, EET_T_INLINED_STRING);
30 EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "file", file, EET_T_INLINED_STRING);
31
32 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "srcfile_list", sizeof (SrcFile_List));
33 _srcfile_list_edd = eet_data_descriptor_stream_new(&eddc);
34 EET_DATA_DESCRIPTOR_ADD_LIST(_srcfile_list_edd, SrcFile_List, "list", list, _srcfile_edd);
35
36 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "external", sizeof (External));
37 _external_edd = eet_data_descriptor_stream_new(&eddc);
38 EET_DATA_DESCRIPTOR_ADD_BASIC(_external_edd, External, "name", name, EET_T_INLINED_STRING);
39
40 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "external_list", sizeof (External_List));
41 _external_list_edd = eet_data_descriptor_stream_new(&eddc);
42 EET_DATA_DESCRIPTOR_ADD_LIST(_external_list_edd, External_List, "list", list, _external_edd);
43
44 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "font", sizeof (Font));
45 _font_edd = eet_data_descriptor_stream_new(&eddc);
46 EET_DATA_DESCRIPTOR_ADD_BASIC(_font_edd, Font, "file", file, EET_T_INLINED_STRING);
47 EET_DATA_DESCRIPTOR_ADD_BASIC(_font_edd, Font, "name", name, EET_T_INLINED_STRING);
48
49 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "font_list", sizeof (Font_List));
50 _font_list_edd = eet_data_descriptor_stream_new(&eddc);
51 EET_DATA_DESCRIPTOR_ADD_LIST(_font_list_edd, Font_List, "list", list, _font_edd);
52}
53
54static void source_fetch_file(const char *fil, const char *filname);
55
56static void
57source_fetch_file(const char *fil, const char *filname)
58{
59 FILE *f;
60 char buf[16 * 1024], *dir = NULL;
61 long sz;
62 size_t tmp;
63 ssize_t dir_len = 0;
64 SrcFile *sf;
65
66 f = fopen(fil, "rb");
67 if (!f)
68 {
69 ERR("%s: Warning. Cannot open file '%s'",
70 progname, fil);
71 exit(-1);
72 }
73
74 fseek(f, 0, SEEK_END);
75 sz = ftell(f);
76 fseek(f, 0, SEEK_SET);
77 sf = mem_alloc(SZ(SrcFile));
78 sf->name = mem_strdup(filname);
79 sf->file = mem_alloc(sz + 1);
80 if (sz > 0)
81 {
82 tmp = fread(sf->file, sz, 1, f);
83 if (tmp != 1)
84 {
85 ERR("%s: Warning file length for (%s) doesn't match !",
86 progname, filname);
87 exit(-1);
88 }
89 }
90
91 sf->file[sz] = '\0';
92 fseek(f, 0, SEEK_SET);
93 srcfiles.list = eina_list_append(srcfiles.list, sf);
94
95 while (fgets(buf, sizeof(buf), f))
96 {
97 char *p, *pp;
98 int got_hash = 0;
99 int forgetit = 0;
100 int haveinclude = 0;
101 char *file = NULL, *fname = NULL;
102
103 p = buf;
104 while ((!forgetit) && (*p))
105 {
106 if (!got_hash)
107 {
108 if (!isspace(*p))
109 {
110 if (*p == '#')
111 got_hash = 1;
112 else
113 forgetit = 1;
114 }
115 p++;
116 }
117
118 if (!haveinclude)
119 {
120 if (!isspace(*p))
121 {
122 if (!strncmp(p, "include", 7))
123 {
124 haveinclude = 1;
125 p += 7;
126 }
127 /* HACK! the logic above should be fixed so
128 * preprocessor statements don't have to begin
129 * in column 0.
130 * otoh, edje_cc should print a warning in that case,
131 * since according to the standard, preprocessor
132 * statements need to be put in column 0.
133 */
134 else if (!strncmp(p, "#include", 8))
135 {
136 haveinclude = 1;
137 p += 8;
138 }
139 else
140 forgetit = 1;
141 }
142 }
143 else
144 {
145 if (!isspace(*p))
146 {
147 char end = '\0';
148
149 if (*p == '"') end = '"';
150 else if (*p == '<') end = '>';
151
152 if (end)
153 {
154 pp = strchr(p + 1, end);
155 if (!pp)
156 forgetit = 1;
157 else
158 {
159 char *slash;
160 ssize_t l = 0;
161
162 /* get the directory of the current file
163 * if we haven't already done so
164 */
165 if ((!dir) && (strrchr(fil, '/')))
166 {
167 dir = mem_strdup(fil);
168 slash = strrchr(dir, '/');
169 *slash = '\0';
170 dir_len = strlen(dir);
171 }
172
173 l = pp - p + dir_len + 1;
174 file = mem_alloc(l);
175
176 if (!dir_len)
177 {
178 snprintf(file, l - 1, "%s", p + 1);
179 file[l - 2] = 0;
180 }
181 else
182 {
183 snprintf(file, l, "%s/%s", dir, p + 1);
184 file[l - 1] = 0;
185 }
186
187
188 fname = strdup(p + 1);
189 pp = strrchr(fname, end);
190 if (pp) *pp = 0;
191 forgetit = 1;
192 }
193 }
194 else
195 forgetit = 1;
196 }
197 else
198 p++;
199 }
200
201 got_hash = 0;
202 }
203 if ((file) && (fname))
204 {
205 source_fetch_file(file, fname);
206 free(file);
207 free(fname);
208 }
209 }
210 free(dir);
211 fclose(f);
212}
213
214void
215source_fetch(void)
216{
217 char buf[PATH_MAX] = {0}, *ptr;
218
219 ptr = strrchr(file_in, '/');
220 if (ptr)
221 {
222 snprintf(buf, sizeof (buf), "%s", ptr + 1);
223 }
224
225 source_fetch_file(file_in, buf[0] ? buf : file_in);
226}
227
228int
229source_append(Eet_File *ef)
230{
231 return eet_data_write(ef, _srcfile_list_edd, "edje_sources", &srcfiles, 1);
232}
233
234SrcFile_List *
235source_load(Eet_File *ef)
236{
237 SrcFile_List *s;
238
239 s = eet_data_read(ef, _srcfile_list_edd, "edje_sources");
240 return s;
241}
242
243int
244source_fontmap_save(Eet_File *ef, Eina_List *font_list)
245{
246 Font_List fl;
247
248 fl.list = font_list;
249 return eet_data_write(ef, _font_list_edd, "edje_source_fontmap", &fl, 1);
250}
251
252Font_List *
253source_fontmap_load(Eet_File *ef)
254{
255 Font_List *fl;
256
257 fl = eet_data_read(ef, _font_list_edd, "edje_source_fontmap");
258 return fl;
259}
diff --git a/libraries/edje/src/bin/edje_convert.c b/libraries/edje/src/bin/edje_convert.c
new file mode 100644
index 0000000..63d11ba
--- /dev/null
+++ b/libraries/edje/src/bin/edje_convert.c
@@ -0,0 +1,459 @@
1#include "edje_private.h"
2
3#include "edje_cc.h"
4#include "edje_convert.h"
5
6static const Edje_File *_current_edje_file = NULL;
7
8const Edje_File *
9_edje_file_get(void)
10{
11 return _current_edje_file;
12}
13
14void
15_edje_file_set(const Edje_File *edf)
16{
17 _current_edje_file = edf;
18}
19
20static Eina_Bool
21_edje_file_convert_external(Edje_File *edf, Old_Edje_File *oedf)
22{
23 Edje_External_Directory_Entry *ede;
24 unsigned int max;
25 unsigned int i = 0;
26
27 edf->external_dir = calloc(1, sizeof (Edje_External_Directory));
28 if (!edf->external_dir) return EINA_FALSE;
29 if (!oedf->external_dir) return EINA_TRUE;
30
31 max = eina_list_count(oedf->external_dir->entries);
32 edf->external_dir->entries = calloc(1, sizeof (Edje_External_Directory_Entry) * max);
33 edf->external_dir->entries_count = max;
34
35 if (!edf->external_dir->entries && max)
36 return EINA_FALSE;
37
38 EINA_LIST_FREE(oedf->external_dir->entries, ede)
39 {
40 edf->external_dir->entries[i++].entry = ede->entry;
41 free(ede);
42 }
43
44 free(oedf->external_dir);
45 oedf->external_dir = NULL;
46
47 return EINA_TRUE;
48}
49
50static Eina_Bool
51_edje_file_convert_images(Edje_File *edf, Old_Edje_File *oedf)
52{
53 Edje_Image_Directory_Entry *de;
54 Edje_Image_Directory_Set *ds;
55 Eina_List *l;
56 int max;
57
58 edf->image_dir = calloc(1, sizeof (Edje_Image_Directory));
59 if (!edf->image_dir) return EINA_FALSE;
60 if (!oedf->image_dir) return EINA_TRUE;
61
62 max = -1;
63 EINA_LIST_FOREACH(oedf->image_dir->entries, l, de)
64 if (max < de->id)
65 max = de->id;
66
67 edf->image_dir->entries = calloc(1, sizeof (Edje_Image_Directory_Entry) * (max + 1));
68 edf->image_dir->entries_count = max + 1;
69
70 if (!edf->image_dir->entries && edf->image_dir->entries_count)
71 return EINA_FALSE;
72
73 EINA_LIST_FREE(oedf->image_dir->entries, de)
74 {
75 memcpy(edf->image_dir->entries + de->id,
76 de,
77 sizeof (Edje_Image_Directory_Entry));
78 free(de);
79 }
80
81 max = -1;
82 EINA_LIST_FOREACH(oedf->image_dir->sets, l, ds)
83 if (max < ds->id)
84 max = ds->id;
85
86 edf->image_dir->sets = calloc(1, sizeof (Edje_Image_Directory_Set) * (max + 1));
87 edf->image_dir->sets_count = max + 1;
88
89 if (!edf->image_dir->sets && edf->image_dir->sets_count)
90 {
91 free(edf->image_dir->entries);
92 edf->image_dir->entries = NULL;
93 return EINA_FALSE;
94 }
95
96 EINA_LIST_FREE(oedf->image_dir->sets, ds)
97 {
98 memcpy(edf->image_dir->sets + ds->id,
99 ds,
100 sizeof (Edje_Image_Directory_Set));
101 free(ds);
102 }
103
104 return EINA_TRUE;
105}
106
107Edje_File *
108_edje_file_convert(Eet_File *ef, Old_Edje_File *oedf)
109{
110 Edje_Part_Collection_Directory_Entry *ce;
111 Edje_Font_Directory_Entry *fnt;
112 Edje_File *edf;
113 Eina_List *l;
114 Old_Edje_Data *ed;
115
116 if (oedf->version < 2) return NULL;
117
118 edf = calloc(1, sizeof (Edje_File));
119 if (!edf) return NULL;
120
121 edf->free_strings = 0;
122
123 edf->fonts = eina_hash_string_small_new(free);
124 edf->collection = eina_hash_string_small_new(free);
125 edf->data = eina_hash_string_small_new(free);
126
127 if (!edf->fonts || !edf->collection || !edf->data)
128 goto on_error;
129
130 EINA_LIST_FREE(oedf->data, ed)
131 {
132 Edje_String *es;
133
134 es = calloc(1, sizeof (Edje_String));
135 if (!es) continue;
136
137 es->str = ed->value;
138
139 eina_hash_direct_add(edf->data, ed->key, es);
140 free(ed);
141 }
142
143 EINA_LIST_FOREACH(oedf->collection_dir->entries, l, ce)
144 if (ce->entry)
145 eina_hash_direct_add(edf->collection, ce->entry, ce);
146 else
147 error_and_abort(ef, "Collection %i: name missing.\n", ce->id);
148
149 if (oedf->font_dir)
150 EINA_LIST_FOREACH(oedf->font_dir->entries, l, fnt)
151 eina_hash_direct_add(edf->fonts, fnt->entry, fnt);
152
153 if (!_edje_file_convert_images(edf, oedf))
154 goto on_error;
155
156 if (!_edje_file_convert_external(edf, oedf))
157 goto on_error;
158
159 edf->styles = oedf->styles;
160 edf->color_classes = oedf->color_classes;
161 edf->version = EDJE_FILE_VERSION;
162 edf->feature_ver = oedf->feature_ver;
163 edf->compiler = oedf->compiler;
164
165 edf->dangling = EINA_FALSE;
166 edf->warning = EINA_FALSE;
167
168 /* Below you will find all memory structure that could be cleaned when under
169 memory pressure */
170 edf->collection_cache = NULL;
171 edf->collection_patterns = NULL;
172
173 return edf;
174
175 on_error:
176 eina_hash_free(edf->fonts);
177 eina_hash_free(edf->collection);
178 eina_hash_free(edf->data);
179 free(edf->image_dir);
180 free(edf->external_dir);
181 free(edf);
182 return NULL;
183}
184
185static void
186_edje_collection_program_add(Edje_Program ***array,
187 unsigned int *count,
188 Edje_Program *add)
189{
190 Edje_Program **tmp;
191
192 tmp = realloc(*array, sizeof (Edje_Program*) * (*count + 1));
193 if (!tmp) return ;
194
195 tmp[(*count)++] = add;
196 *array = tmp;
197}
198
199Edje_Part_Collection *
200_edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, Old_Edje_Part_Collection *oedc)
201{
202 Edje_Part_Collection *edc;
203 Old_Edje_Part *part;
204 Edje_Program *pg;
205 Old_Edje_Data *di;
206 Eina_List *l;
207 char *buffer;
208 unsigned int k;
209
210 oedc->part = ce->entry;
211
212 /* Count each type part and their respective state */
213 EINA_LIST_FOREACH(oedc->parts, l, part)
214 {
215 int *count;
216 int dummy = 0;
217
218
219 switch (part->type)
220 {
221#define CSP(Tp, Ce) \
222 case EDJE_PART_TYPE_##Tp : \
223 count = &Ce->count.Tp; \
224 break;
225
226 CSP(RECTANGLE, ce);
227 CSP(TEXT, ce);
228 CSP(IMAGE, ce);
229 CSP(SWALLOW, ce);
230 CSP(TEXTBLOCK, ce);
231 CSP(GROUP, ce);
232 CSP(BOX, ce);
233 CSP(TABLE, ce);
234 CSP(EXTERNAL, ce);
235 default:
236 count = &dummy;
237 break;
238 }
239
240 *count += eina_list_count(part->other_desc) + 1;
241 }
242 ce->count.part = eina_list_count(oedc->parts);
243
244#define CONVERT_EMN(Tp, Sz, Ce) \
245 buffer = alloca(strlen(ce->entry) + strlen(#Tp) + 2); \
246 sprintf(buffer, "%s/%s", ce->entry, #Tp); \
247 Ce->mp.Tp = eina_mempool_add("one_big", buffer, NULL, sizeof (Sz), Ce->count.Tp);
248
249 CONVERT_EMN(RECTANGLE, Edje_Part_Description_Common, ce);
250 CONVERT_EMN(TEXT, Edje_Part_Description_Text, ce);
251 CONVERT_EMN(IMAGE, Edje_Part_Description_Image, ce);
252 CONVERT_EMN(SWALLOW, Edje_Part_Description_Common, ce);
253 CONVERT_EMN(TEXTBLOCK, Edje_Part_Description_Text, ce);
254 CONVERT_EMN(GROUP, Edje_Part_Description_Common, ce);
255 CONVERT_EMN(BOX, Edje_Part_Description_Box, ce);
256 CONVERT_EMN(TABLE, Edje_Part_Description_Table, ce);
257 CONVERT_EMN(EXTERNAL, Edje_Part_Description_External, ce);
258 CONVERT_EMN(part, Edje_Part, ce);
259
260 /* Change structure layout */
261 edc = calloc(1, sizeof (Edje_Part_Collection));
262 if (!edc) error_and_abort(ef, "Not enough memory\n");
263 ce->ref = edc;
264
265 EINA_LIST_FREE(oedc->programs, pg)
266 {
267 if (!pg->signal && !pg->source)
268 _edje_collection_program_add(&edc->programs.nocmp,
269 &edc->programs.nocmp_count,
270 pg);
271 else if (pg->signal && !strpbrk(pg->signal, "*?[\\")
272 && pg->source && !strpbrk(pg->source, "*?[\\"))
273 _edje_collection_program_add(&edc->programs.strcmp,
274 &edc->programs.strcmp_count,
275 pg);
276 else if (pg->signal && edje_program_is_strncmp(pg->signal)
277 && pg->source && edje_program_is_strncmp(pg->source))
278 _edje_collection_program_add(&edc->programs.strncmp,
279 &edc->programs.strncmp_count,
280 pg);
281 else if (pg->signal && edje_program_is_strrncmp(pg->signal)
282 && pg->source && edje_program_is_strrncmp(pg->source))
283 _edje_collection_program_add(&edc->programs.strrncmp,
284 &edc->programs.strrncmp_count,
285 pg);
286 else
287 _edje_collection_program_add(&edc->programs.fnmatch,
288 &edc->programs.fnmatch_count,
289 pg);
290 }
291
292 edc->data = eina_hash_string_small_new(NULL);
293 EINA_LIST_FREE(oedc->data, di)
294 {
295 Edje_String *es;
296
297 es = calloc(1, sizeof (Edje_String));
298 if (!es) continue ;
299
300 es->str = di->value;
301
302 eina_hash_direct_add(edc->data, di->key, es);
303 free(di);
304 }
305
306 edc->parts_count = eina_list_count(oedc->parts);
307 edc->parts = calloc(edc->parts_count, sizeof (Edje_Part *));
308 if (edc->parts_count && !edc->parts)
309 error_and_abort(ef, "Not enough memory\n");
310 k = 0;
311
312 EINA_LIST_FREE(oedc->parts, part)
313 {
314 Old_Edje_Part_Description *oepd;
315 Edje_Pack_Element *elm;
316 Edje_Part *replacement;
317 unsigned int i;
318
319 replacement = eina_mempool_malloc(ce->mp.part, sizeof (Edje_Part));
320 if (!replacement)
321 error_and_abort(ef, "Not enough memory\n");
322
323 replacement->name = part->name;
324 replacement->default_desc = _edje_description_convert(part->type, ce, part->default_desc);
325
326 replacement->other.desc_count = eina_list_count(part->other_desc);
327 replacement->other.desc = calloc(replacement->other.desc_count, sizeof (Edje_Part_Description_Common*));
328
329 i = 0;
330 EINA_LIST_FREE(part->other_desc, oepd)
331 replacement->other.desc[i++] = _edje_description_convert(part->type, ce, oepd);
332
333 replacement->source = part->source;
334 replacement->source2 = part->source2;
335 replacement->source3 = part->source3;
336 replacement->source4 = part->source4;
337 replacement->source5 = part->source5;
338 replacement->source6 = part->source6;
339 replacement->id = part->id;
340 replacement->clip_to_id = part->clip_to_id;
341 replacement->dragable = part->dragable;
342 replacement->items_count = eina_list_count(part->items);
343 replacement->items = calloc(replacement->items_count, sizeof (Edje_Pack_Element*));
344
345 i = 0;
346 EINA_LIST_FREE(part->items, elm)
347 replacement->items[i++] = elm;
348
349 replacement->type = part->type;
350 replacement->effect = part->effect;
351 replacement->mouse_events = part->mouse_events;
352 replacement->repeat_events = part->repeat_events;
353 replacement->ignore_flags = part->ignore_flags;
354 replacement->scale = part->scale;
355 replacement->precise_is_inside = part->precise_is_inside;
356 replacement->use_alternate_font_metrics = part->use_alternate_font_metrics;
357 replacement->pointer_mode = part->pointer_mode;
358 replacement->entry_mode = part->entry_mode;
359 replacement->select_mode = part->select_mode;
360 replacement->multiline = part->multiline;
361 replacement->api = part->api;
362
363 edc->parts[k++] = replacement;
364
365 free(part);
366 }
367
368 edc->id = oedc->id;
369 edc->alias = oedc->alias;
370 edc->prop.min = oedc->prop.min;
371 edc->prop.max = oedc->prop.max;
372 edc->script = oedc->script;
373 edc->part = oedc->part;
374 edc->script_only = oedc->script_only;
375 edc->lua_script_only = oedc->lua_script_only;
376 edc->checked = oedc->checked;
377
378 free(oedc);
379
380 return edc;
381}
382
383Edje_Part_Description_Common*
384_edje_description_convert(int type,
385 Edje_Part_Collection_Directory_Entry *ce,
386 Old_Edje_Part_Description *oed)
387{
388 Edje_Part_Description_Common *result = NULL;
389
390 switch (type)
391 {
392 case EDJE_PART_TYPE_RECTANGLE:
393 result = eina_mempool_malloc(ce->mp.RECTANGLE,
394 sizeof (Edje_Part_Description_Common));
395 break;
396 case EDJE_PART_TYPE_SWALLOW:
397 result = eina_mempool_malloc(ce->mp.SWALLOW,
398 sizeof (Edje_Part_Description_Common));
399 break;
400 case EDJE_PART_TYPE_GROUP:
401 result = eina_mempool_malloc(ce->mp.GROUP,
402 sizeof (Edje_Part_Description_Common));
403 break;
404
405 case EDJE_PART_TYPE_IMAGE:
406 {
407 Edje_Part_Description_Image *img;
408 Edje_Part_Image_Id *id;
409 unsigned int i = 0;
410
411 img = eina_mempool_malloc(ce->mp.IMAGE, sizeof (Edje_Part_Description_Image));
412
413 img->image.tweens_count = eina_list_count(oed->image.tween_list);
414 img->image.tweens = calloc(img->image.tweens_count,
415 sizeof (Edje_Part_Image_Id*));
416 if (img->image.tweens_count > 0 && !img->image.tweens)
417 {
418 eina_mempool_free(ce->mp.IMAGE, img);
419 return NULL;
420 }
421
422 EINA_LIST_FREE(oed->image.tween_list, id)
423 img->image.tweens[i++] = id;
424
425 img->image.id = oed->image.id;
426 img->image.scale_hint = oed->image.scale_hint;
427 img->image.set = oed->image.set;
428
429 img->image.border = oed->image.border;
430 img->image.fill = oed->image.fill;
431
432 result = &img->common;
433 break;
434 }
435
436#define CONVERT_ALLOC_POOL(Short, Type, Name) \
437 case EDJE_PART_TYPE_##Short: \
438 { \
439 Edje_Part_Description_##Type *Name; \
440 \
441 Name = eina_mempool_malloc(ce->mp.Short, sizeof (Edje_Part_Description_##Type)); \
442 Name->Name = oed->Name; \
443 result = &Name->common; \
444 break; \
445 }
446
447 CONVERT_ALLOC_POOL(TEXT, Text, text);
448 CONVERT_ALLOC_POOL(TEXTBLOCK, Text, text);
449 CONVERT_ALLOC_POOL(BOX, Box, box);
450 CONVERT_ALLOC_POOL(TABLE, Table, table);
451 CONVERT_ALLOC_POOL(EXTERNAL, External, external_params);
452 }
453
454 if (result)
455 *result = oed->common;
456
457 free(oed);
458 return result;
459}
diff --git a/libraries/edje/src/bin/edje_convert.h b/libraries/edje/src/bin/edje_convert.h
new file mode 100644
index 0000000..0bbb38e
--- /dev/null
+++ b/libraries/edje/src/bin/edje_convert.h
@@ -0,0 +1,154 @@
1#ifndef EDJE_CONVERT_H__
2# define EDJE_CONVERT_H__
3
4
5typedef struct _Old_Edje_File Old_Edje_File;
6typedef struct _Old_Edje_Image_Directory Old_Edje_Image_Directory;
7typedef struct _Old_Edje_Font_Directory Old_Edje_Font_Directory;
8typedef struct _Old_Edje_External_Directory Old_Edje_External_Directory;
9typedef struct _Old_Edje_Part Old_Edje_Part;
10typedef struct _Old_Edje_Part_Collection Old_Edje_Part_Collection;
11typedef struct _Old_Edje_Part_Collection_Directory Old_Edje_Part_Collection_Directory;
12typedef struct _Old_Edje_Part_Description Old_Edje_Part_Description;
13typedef struct _Old_Edje_Part_Description_Spec_Image Old_Edje_Part_Description_Spec_Image;
14typedef struct _Old_Edje_Data Old_Edje_Data;
15
16struct _Old_Edje_Data
17{
18 const char *key;
19 char *value;
20};
21
22/*----------*/
23
24struct _Old_Edje_Font_Directory
25{
26 Eina_List *entries; /* a list of Edje_Font_Directory_Entry */
27};
28
29struct _Old_Edje_Image_Directory
30{
31 Eina_List *entries; /* a list of Edje_Image_Directory_Entry */
32 Eina_List *sets; /* a list of Edje_Image_Directory_Set */
33};
34
35struct _Old_Edje_External_Directory
36{
37 Eina_List *entries; /* a list of Edje_External_Directory_Entry */
38};
39
40struct _Old_Edje_File
41{
42 const char *path;
43 time_t mtime;
44
45 Old_Edje_External_Directory *external_dir;
46 Old_Edje_Font_Directory *font_dir;
47 Old_Edje_Image_Directory *image_dir;
48 Old_Edje_Part_Collection_Directory *collection_dir;
49 Eina_List *data;
50 Eina_List *styles;
51 Eina_List *color_classes;
52
53 const char *compiler;
54 int version;
55 int feature_ver;
56};
57
58struct _Old_Edje_Part_Collection
59{
60 Eina_List *programs; /* a list of Edje_Program */
61 Eina_List *parts; /* a list of Edje_Part */
62 Eina_List *data;
63
64 int id; /* the collection id */
65
66 Eina_Hash *alias; /* aliasing part*/
67
68 struct {
69 Edje_Size min, max;
70 } prop;
71
72 int references;
73#ifdef EDJE_PROGRAM_CACHE
74 struct {
75 Eina_Hash *no_matches;
76 Eina_Hash *matches;
77 } prog_cache;
78#endif
79
80 Embryo_Program *script; /* all the embryo script code for this group */
81 const char *part;
82
83 unsigned char script_only;
84
85 unsigned char lua_script_only;
86
87 unsigned char checked : 1;
88};
89
90struct _Old_Edje_Part
91{
92 const char *name; /* the name if any of the part */
93 Old_Edje_Part_Description *default_desc; /* the part descriptor for default */
94 Eina_List *other_desc; /* other possible descriptors */
95 const char *source, *source2, *source3, *source4, *source5, *source6;
96 int id; /* its id number */
97 int clip_to_id; /* the part id to clip this one to */
98 Edje_Part_Dragable dragable;
99 Eina_List *items; /* packed items for box and table */
100 unsigned char type; /* what type (image, rect, text) */
101 unsigned char effect; /* 0 = plain... */
102 unsigned char mouse_events; /* it will affect/respond to mouse events */
103 unsigned char repeat_events; /* it will repeat events to objects below */
104 Evas_Event_Flags ignore_flags;
105 unsigned char scale; /* should certain properties scale with edje scale factor? */
106 unsigned char precise_is_inside;
107 unsigned char use_alternate_font_metrics;
108 unsigned char pointer_mode;
109 unsigned char entry_mode;
110 unsigned char select_mode;
111 unsigned char multiline;
112 Edje_Part_Api api;
113};
114
115struct _Old_Edje_Part_Description_Spec_Image
116{
117 Eina_List *tween_list; /* list of Edje_Part_Image_Id */
118 int id; /* the image id to use */
119 int scale_hint; /* evas scale hint */
120 Eina_Bool set; /* if image condition it's content */
121
122 Edje_Part_Description_Spec_Border border;
123 Edje_Part_Description_Spec_Fill fill;
124};
125
126struct _Old_Edje_Part_Description
127{
128 Edje_Part_Description_Common common;
129 Old_Edje_Part_Description_Spec_Image image;
130 Edje_Part_Description_Spec_Text text;
131 Edje_Part_Description_Spec_Box box;
132 Edje_Part_Description_Spec_Table table;
133
134 Eina_List *external_params; /* parameters for external objects */
135};
136
137struct _Old_Edje_Part_Collection_Directory
138{
139 Eina_List *entries; /* a list of Edje_Part_Collection_Directory_Entry */
140
141 int references;
142};
143
144Edje_File *_edje_file_convert(Eet_File *ef, Old_Edje_File *oedf);
145Edje_Part_Collection *_edje_collection_convert(Eet_File *ef,
146 Edje_Part_Collection_Directory_Entry *ce,
147 Old_Edje_Part_Collection *oedc);
148Edje_Part_Description_Common *_edje_description_convert(int type,
149 Edje_Part_Collection_Directory_Entry *ce,
150 Old_Edje_Part_Description *oed);
151const Edje_File *_edje_file_get(void);
152void _edje_file_set(const Edje_File *edf);
153
154#endif
diff --git a/libraries/edje/src/bin/edje_data_convert.c b/libraries/edje/src/bin/edje_data_convert.c
new file mode 100644
index 0000000..5fb129e
--- /dev/null
+++ b/libraries/edje/src/bin/edje_data_convert.c
@@ -0,0 +1,451 @@
1#include "edje_private.h"
2#include "edje_convert.h"
3
4Eet_Data_Descriptor *_edje_edd_old_edje_file = NULL;
5Eet_Data_Descriptor *_edje_edd_old_edje_style = NULL;
6Eet_Data_Descriptor *_edje_edd_old_edje_style_tag = NULL;
7Eet_Data_Descriptor *_edje_edd_old_edje_color_class = NULL;
8Eet_Data_Descriptor *_edje_edd_old_edje_data = NULL;
9Eet_Data_Descriptor *_edje_edd_old_edje_external_directory = NULL;
10Eet_Data_Descriptor *_edje_edd_old_edje_external_directory_entry = NULL;
11Eet_Data_Descriptor *_edje_edd_old_edje_font_directory = NULL;
12Eet_Data_Descriptor *_edje_edd_old_edje_font_directory_entry = NULL;
13Eet_Data_Descriptor *_edje_edd_old_edje_image_directory = NULL;
14Eet_Data_Descriptor *_edje_edd_old_edje_image_directory_entry = NULL;
15Eet_Data_Descriptor *_edje_edd_old_edje_image_directory_set = NULL;
16Eet_Data_Descriptor *_edje_edd_old_edje_image_directory_set_entry = NULL;
17Eet_Data_Descriptor *_edje_edd_old_edje_program = NULL;
18Eet_Data_Descriptor *_edje_edd_old_edje_program_target = NULL;
19Eet_Data_Descriptor *_edje_edd_old_edje_program_after = NULL;
20Eet_Data_Descriptor *_edje_edd_old_edje_part_collection_directory = NULL;
21Eet_Data_Descriptor *_edje_edd_old_edje_part_collection_directory_entry = NULL;
22Eet_Data_Descriptor *_edje_edd_old_edje_pack_element = NULL;
23Eet_Data_Descriptor *_edje_edd_old_edje_part_collection = NULL;
24Eet_Data_Descriptor *_edje_edd_old_edje_part = NULL;
25Eet_Data_Descriptor *_edje_edd_old_edje_part_description = NULL;
26Eet_Data_Descriptor *_edje_edd_old_edje_part_image_id = NULL;
27Eet_Data_Descriptor *_edje_edd_old_edje_external_param = NULL;
28
29#define FREED(eed) \
30 if (eed) \
31 { \
32 eet_data_descriptor_free((eed)); \
33 (eed) = NULL; \
34 }
35
36void
37_edje_edd_old_shutdown(void)
38{
39 FREED(_edje_edd_old_edje_file);
40 FREED(_edje_edd_old_edje_style);
41 FREED(_edje_edd_old_edje_style_tag);
42 FREED(_edje_edd_old_edje_color_class);
43 FREED(_edje_edd_old_edje_data);
44 FREED(_edje_edd_old_edje_external_directory);
45 FREED(_edje_edd_old_edje_external_directory_entry);
46 FREED(_edje_edd_old_edje_font_directory);
47 FREED(_edje_edd_old_edje_font_directory_entry);
48 FREED(_edje_edd_old_edje_image_directory);
49 FREED(_edje_edd_old_edje_image_directory_entry);
50 FREED(_edje_edd_old_edje_program);
51 FREED(_edje_edd_old_edje_program_target);
52 FREED(_edje_edd_old_edje_program_after);
53 FREED(_edje_edd_old_edje_part_collection_directory);
54 FREED(_edje_edd_old_edje_part_collection_directory_entry);
55 FREED(_edje_edd_old_edje_pack_element);
56 FREED(_edje_edd_old_edje_part_collection);
57 FREED(_edje_edd_old_edje_part);
58 FREED(_edje_edd_old_edje_part_description);
59 FREED(_edje_edd_old_edje_part_image_id);
60 FREED(_edje_edd_old_edje_external_param);
61 FREED(_edje_edd_old_edje_image_directory_set);
62 FREED(_edje_edd_old_edje_image_directory_set_entry);
63}
64
65void
66_edje_edd_old_init(void)
67{
68 Eet_Data_Descriptor_Class eddc;
69
70 /* external directory */
71 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Directory_Entry);
72 _edje_edd_old_edje_external_directory_entry =
73 eet_data_descriptor_file_new(&eddc);
74 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_directory_entry, Edje_External_Directory_Entry, "entry", entry, EET_T_STRING);
75
76 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
77 "Edje_External_Directory",
78 sizeof (Old_Edje_External_Directory));
79 _edje_edd_old_edje_external_directory =
80 eet_data_descriptor_file_new(&eddc);
81 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_external_directory, Edje_External_Directory, "entries", entries, _edje_edd_old_edje_external_directory_entry);
82
83 /* font directory */
84 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Font_Directory_Entry);
85 _edje_edd_old_edje_font_directory_entry =
86 eet_data_descriptor_file_new(&eddc);
87 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_font_directory_entry, Edje_Font_Directory_Entry, "entry", entry, EET_T_STRING);
88 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_font_directory_entry, Edje_Font_Directory_Entry, "file", file, EET_T_STRING);
89
90 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
91 "Edje_Font_Directory",
92 sizeof (Old_Edje_Font_Directory));
93 _edje_edd_old_edje_font_directory =
94 eet_data_descriptor_file_new(&eddc);
95 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_font_directory, Old_Edje_Font_Directory, "entries", entries, _edje_edd_old_edje_font_directory_entry);
96
97 /* image directory */
98 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Entry);
99 _edje_edd_old_edje_image_directory_entry =
100 eet_data_descriptor_file_new(&eddc);
101 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_entry, Edje_Image_Directory_Entry, "entry", entry, EET_T_STRING);
102 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_type", source_type, EET_T_INT);
103 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_param", source_param, EET_T_INT);
104 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_entry, Edje_Image_Directory_Entry, "id", id, EET_T_INT);
105
106 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set_Entry);
107 _edje_edd_old_edje_image_directory_set_entry =
108 eet_data_descriptor_file_new(&eddc);
109 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "name", name, EET_T_STRING);
110 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "id", id, EET_T_INT);
111 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "min.w", size.min.w, EET_T_INT);
112 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "min.h", size.min.h, EET_T_INT);
113 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "max.w", size.max.w, EET_T_INT);
114 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "max.h", size.max.h, EET_T_INT);
115
116 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set);
117 _edje_edd_old_edje_image_directory_set =
118 eet_data_descriptor_file_new(&eddc);
119 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "name", name, EET_T_STRING);
120 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "id", id, EET_T_INT);
121 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "entries", entries, _edje_edd_old_edje_image_directory_set_entry);
122
123 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
124 "Edje_Image_Directory",
125 sizeof (Old_Edje_Image_Directory));
126 _edje_edd_old_edje_image_directory =
127 eet_data_descriptor_file_new(&eddc);
128 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_image_directory, Old_Edje_Image_Directory, "entries", entries, _edje_edd_old_edje_image_directory_entry);
129 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_image_directory, Old_Edje_Image_Directory, "sets", sets, _edje_edd_old_edje_image_directory_set);
130
131 /* collection directory */
132 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Collection_Directory_Entry);
133 _edje_edd_old_edje_part_collection_directory_entry =
134 eet_data_descriptor_file_new(&eddc);
135 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "entry", entry, EET_T_STRING);
136 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "id", id, EET_T_INT);
137
138 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
139 "Edje_Part_Collection_Directory",
140 sizeof (Old_Edje_Part_Collection_Directory));
141 _edje_edd_old_edje_part_collection_directory =
142 eet_data_descriptor_file_new(&eddc);
143 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection_directory, Old_Edje_Part_Collection_Directory, "entries", entries, _edje_edd_old_edje_part_collection_directory_entry);
144
145 /* generic data attachment */
146 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
147 "Edje_Data", sizeof (Old_Edje_Data));
148 _edje_edd_old_edje_data =
149 eet_data_descriptor_file_new(&eddc);
150 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_data, Old_Edje_Data, "key", key, EET_T_STRING);
151 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_data, Old_Edje_Data, "value", value, EET_T_STRING);
152
153 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style_Tag);
154 _edje_edd_old_edje_style_tag =
155 eet_data_descriptor_file_new(&eddc);
156 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_style_tag, Edje_Style_Tag, "key", key, EET_T_STRING);
157 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_style_tag, Edje_Style_Tag, "value", value, EET_T_STRING);
158
159 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style);
160 _edje_edd_old_edje_style =
161 eet_data_descriptor_file_new(&eddc);
162 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_style, Edje_Style, "name", name, EET_T_STRING);
163 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_style, Edje_Style, "tags", tags, _edje_edd_old_edje_style_tag);
164
165 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Color_Class);
166 _edje_edd_old_edje_color_class =
167 eet_data_descriptor_file_new(&eddc);
168 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "name", name, EET_T_STRING);
169 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "r", r, EET_T_UCHAR);
170 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "g", g, EET_T_UCHAR);
171 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "b", b, EET_T_UCHAR);
172 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "a", a, EET_T_UCHAR);
173 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "r2", r2, EET_T_UCHAR);
174 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "g2", g2, EET_T_UCHAR);
175 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "b2", b2, EET_T_UCHAR);
176 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "a2", a2, EET_T_UCHAR);
177 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "r3", r3, EET_T_UCHAR);
178 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "g3", g3, EET_T_UCHAR);
179 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "b3", b3, EET_T_UCHAR);
180 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "a3", a3, EET_T_UCHAR);
181
182 /* the main file directory */
183 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
184 "Edje_File", sizeof (Old_Edje_File));
185 _edje_edd_old_edje_file =
186 eet_data_descriptor_file_new(&eddc);
187 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_file, Old_Edje_File, "compiler", compiler, EET_T_STRING);
188 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_file, Old_Edje_File, "version", version, EET_T_INT);
189 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_file, Old_Edje_File, "feature_ver", feature_ver, EET_T_INT);
190 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_file, Old_Edje_File, "external_dir", external_dir, _edje_edd_old_edje_external_directory);
191 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_file, Old_Edje_File, "font_dir", font_dir, _edje_edd_old_edje_font_directory);
192 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_file, Old_Edje_File, "image_dir", image_dir, _edje_edd_old_edje_image_directory);
193 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_file, Old_Edje_File, "collection_dir", collection_dir, _edje_edd_old_edje_part_collection_directory);
194 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, "data", data, _edje_edd_old_edje_data);
195 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, "styles", styles, _edje_edd_old_edje_style);
196 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, "color_classes", color_classes, _edje_edd_old_edje_color_class);
197
198 /* parts & programs - loaded induvidually */
199 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_Target);
200 _edje_edd_old_edje_program_target =
201 eet_data_descriptor_file_new(&eddc);
202 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program_target, Edje_Program_Target, "id", id, EET_T_INT);
203
204 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_After);
205 _edje_edd_old_edje_program_after =
206 eet_data_descriptor_file_new(&eddc);
207 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program_after,
208 Edje_Program_After, "id", id, EET_T_INT);
209
210 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program);
211 _edje_edd_old_edje_program =
212 eet_data_descriptor_file_new(&eddc);
213 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "id", id, EET_T_INT);
214 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "name", name, EET_T_STRING);
215 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "signal", signal, EET_T_STRING);
216 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "source", source, EET_T_STRING);
217 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "filter_part", filter.part, EET_T_STRING);
218 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "filter_state", filter.state, EET_T_STRING);
219 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "in.from", in.from, EET_T_DOUBLE);
220 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "in.range", in.range, EET_T_DOUBLE);
221 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "action", action, EET_T_INT);
222 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "state", state, EET_T_STRING);
223 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "state2", state2, EET_T_STRING);
224 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "value", value, EET_T_DOUBLE);
225 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "value2", value2, EET_T_DOUBLE);
226 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "tween.mode", tween.mode, EET_T_INT);
227 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "tween.time", tween.time, EDJE_T_FLOAT);
228 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_program, Edje_Program, "targets", targets, _edje_edd_old_edje_program_target);
229 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_program, Edje_Program, "after", after, _edje_edd_old_edje_program_after);
230 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "api.name", api.name, EET_T_STRING);
231 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "api.description", api.description, EET_T_STRING);
232
233 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "param.src", param.src, EET_T_INT);
234 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "param.dst", param.dst, EET_T_INT);
235
236 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Image_Id);
237 _edje_edd_old_edje_part_image_id =
238 eet_data_descriptor_file_new(&eddc);
239 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_image_id, Edje_Part_Image_Id, "id", id, EET_T_INT);
240 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_image_id, Edje_Part_Image_Id, "set", set, EET_T_UCHAR);
241
242 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Param);
243 _edje_edd_old_edje_external_param =
244 eet_data_descriptor_file_new(&eddc);
245 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "name", name, EET_T_STRING);
246 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "type", type, EET_T_INT);
247 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "i", i, EET_T_INT);
248 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "d", d, EET_T_DOUBLE);
249 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "s", s, EET_T_STRING);
250
251 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Edje_Part_Description", sizeof (Old_Edje_Part_Description));
252 _edje_edd_old_edje_part_description =
253 eet_data_descriptor_file_new(&eddc);
254 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "state.name", common.state.name, EET_T_STRING);
255 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "state.value", common.state.value, EET_T_DOUBLE);
256 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "visible", common.visible, EET_T_CHAR);
257 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "align.x", common.align.x, EDJE_T_FLOAT);
258 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "align.y", common.align.y, EDJE_T_FLOAT);
259 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fixed.w", common.fixed.w, EET_T_UCHAR);
260 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fixed.h", common.fixed.h, EET_T_UCHAR);
261 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "min.w", common.min.w, EET_T_INT);
262 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "min.h", common.min.h, EET_T_INT);
263 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "max.w", common.max.w, EET_T_INT);
264 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "max.h", common.max.h, EET_T_INT);
265 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "step.x", common.step.x, EET_T_INT);
266 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "step.y", common.step.y, EET_T_INT);
267 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "aspect.min", common.aspect.min, EDJE_T_FLOAT);
268 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "aspect.max", common.aspect.max, EDJE_T_FLOAT);
269 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "aspect.prefer", common.aspect.prefer, EET_T_CHAR);
270 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel1.relative_x", common.rel1.relative_x, EDJE_T_FLOAT);
271 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel1.relative_y", common.rel1.relative_y, EDJE_T_FLOAT);
272 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel1.offset_x", common.rel1.offset_x, EET_T_INT);
273 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel1.offset_y", common.rel1.offset_y, EET_T_INT);
274 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel1.id_x", common.rel1.id_x, EET_T_INT);
275 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel1.id_y", common.rel1.id_y, EET_T_INT);
276 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel2.relative_x", common.rel2.relative_x, EDJE_T_FLOAT);
277 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel2.relative_y", common.rel2.relative_y, EDJE_T_FLOAT);
278 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel2.offset_x", common.rel2.offset_x, EET_T_INT);
279 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel2.offset_y", common.rel2.offset_y, EET_T_INT);
280 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel2.id_x", common.rel2.id_x, EET_T_INT);
281 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "rel2.id_y", common.rel2.id_y, EET_T_INT);
282 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "image.id", image.id, EET_T_INT);
283 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "image.set", image.set, EET_T_UCHAR);
284 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "image.tween_list", image.tween_list, _edje_edd_old_edje_part_image_id);
285
286 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.l", image.border.l, EET_T_INT);
287 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.r", image.border.r, EET_T_INT);
288 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.t", image.border.t, EET_T_INT);
289 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.b", image.border.b, EET_T_INT);
290 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.no_fill", image.border.no_fill, EET_T_UCHAR);
291 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.scale", image.border.scale, EET_T_UCHAR);
292 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.smooth", image.fill.smooth, EET_T_CHAR);
293 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.pos_rel_x", image.fill.pos_rel_x, EDJE_T_FLOAT);
294 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.pos_abs_x", image.fill.pos_abs_x, EET_T_INT);
295 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.rel_x", image.fill.rel_x, EDJE_T_FLOAT);
296 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.abs_x", image.fill.abs_x, EET_T_INT);
297 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.pos_rel_y", image.fill.pos_rel_y, EDJE_T_FLOAT);
298 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.pos_abs_y", image.fill.pos_abs_y, EET_T_INT);
299 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.rel_y", image.fill.rel_y, EDJE_T_FLOAT);
300 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.abs_y", image.fill.abs_y, EET_T_INT);
301 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.angle", image.fill.angle, EET_T_INT);
302 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.spread", image.fill.spread, EET_T_INT);
303 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.type", image.fill.type, EET_T_CHAR);
304 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color_class", common.color_class, EET_T_STRING);
305 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color.r", common.color.r, EET_T_UCHAR);
306 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color.g", common.color.g, EET_T_UCHAR);
307 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color.b", common.color.b, EET_T_UCHAR);
308 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color.a", common.color.a, EET_T_UCHAR);
309 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color2.r", common.color2.r, EET_T_UCHAR);
310 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color2.g", common.color2.g, EET_T_UCHAR);
311 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color2.b", common.color2.b, EET_T_UCHAR);
312 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color2.a", common.color2.a, EET_T_UCHAR);
313 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color3.r", text.color3.r, EET_T_UCHAR);
314 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color3.g", text.color3.g, EET_T_UCHAR);
315 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color3.b", text.color3.b, EET_T_UCHAR);
316 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color3.a", text.color3.a, EET_T_UCHAR);
317 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.text", text.text.str, EET_T_STRING);
318 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.text_class", text.text_class, EET_T_STRING);
319 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.style", text.style.str, EET_T_STRING);
320 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.font", text.font.str, EET_T_STRING);
321 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.repch", text.repch.str, EET_T_STRING);
322 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.size", text.size, EET_T_INT);
323 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.fit_x", text.fit_x, EET_T_UCHAR);
324 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.fit_y", text.fit_y, EET_T_UCHAR);
325 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.min_x", text.min_x, EET_T_UCHAR);
326 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.min_y", text.min_y, EET_T_UCHAR);
327 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.max_x", text.max_x, EET_T_UCHAR);
328 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.max_y", text.max_y, EET_T_UCHAR);
329 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.align.x", text.align.x, EDJE_T_FLOAT);
330 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.align.y", text.align.y, EDJE_T_FLOAT);
331 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.id_source", text.id_source, EET_T_INT);
332 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.id_text_source", text.id_text_source, EET_T_INT);
333 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.elipsis", text.elipsis, EET_T_DOUBLE);
334 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.layout", box.layout, EET_T_STRING);
335 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.alt_layout", box.alt_layout, EET_T_STRING);
336 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.align.x", box.align.x, EDJE_T_FLOAT);
337 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.align.y", box.align.y, EDJE_T_FLOAT);
338 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.padding.x", box.padding.x, EET_T_INT);
339 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.padding.y", box.padding.y, EET_T_INT);
340 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.min.h", box.min.h, EET_T_UCHAR);
341 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.min.v", box.min.v, EET_T_UCHAR);
342 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.homogeneous", table.homogeneous, EET_T_UCHAR);
343 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.align.x", table.align.x, EDJE_T_FLOAT);
344 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.align.y", table.align.y, EDJE_T_FLOAT);
345 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.padding.x", table.padding.x, EET_T_INT);
346 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.padding.y", table.padding.y, EET_T_INT);
347 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.id_persp", common.map.id_persp, EET_T_INT);
348 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.id_light", common.map.id_light, EET_T_INT);
349 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.rot.id_center", common.map.rot.id_center, EET_T_INT);
350 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.rot.x", common.map.rot.x, EDJE_T_FLOAT);
351 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.rot.y", common.map.rot.y, EDJE_T_FLOAT);
352 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.rot.z", common.map.rot.z, EDJE_T_FLOAT);
353 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.on", common.map.on, EET_T_UCHAR);
354 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.smooth", common.map.smooth, EET_T_UCHAR);
355 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.alpha", common.map.alpha, EET_T_UCHAR);
356 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.persp_on", common.map.persp_on, EET_T_UCHAR);
357 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.backcull", common.map.backcull, EET_T_UCHAR);
358 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "persp.zplane", common.persp.zplane, EET_T_INT);
359 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "persp.focal", common.persp.focal, EET_T_INT);
360 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "external_params", external_params, _edje_edd_old_edje_external_param);
361
362 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Pack_Element);
363 _edje_edd_old_edje_pack_element =
364 eet_data_descriptor_file_new(&eddc);
365 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "type", type, EET_T_UCHAR);
366 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "name", name, EET_T_STRING);
367 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "source", source, EET_T_STRING);
368 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "min.w", min.w, EET_T_INT);
369 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "min.h", min.h, EET_T_INT);
370 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "prefer.w", prefer.w, EET_T_INT);
371 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "prefer.h", prefer.h, EET_T_INT);
372 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "max.w", max.w, EET_T_INT);
373 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "max.h", max.h, EET_T_INT);
374 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "padding.l", padding.l, EET_T_INT);
375 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "padding.r", padding.r, EET_T_INT);
376 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "padding.t", padding.t, EET_T_INT);
377 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "padding.b", padding.b, EET_T_INT);
378 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "align.x", align.x, EDJE_T_FLOAT);
379 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "align.y", align.y, EDJE_T_FLOAT);
380 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "weight.x", weight.x, EDJE_T_FLOAT);
381 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "weight.y", weight.y, EDJE_T_FLOAT);
382 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "aspect.w", aspect.w, EET_T_INT);
383 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "aspect.h", aspect.h, EET_T_INT);
384 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "aspect.mode", aspect.mode, EET_T_UCHAR);
385 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "options", options, EET_T_STRING);
386 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "col", col, EET_T_INT);
387 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "row", row, EET_T_INT);
388 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "colspan", colspan, EET_T_USHORT);
389 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "rowspan", rowspan, EET_T_USHORT);
390
391 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Edje_Part", sizeof (Old_Edje_Part));
392 _edje_edd_old_edje_part =
393 eet_data_descriptor_file_new(&eddc);
394 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "name", name, EET_T_STRING);
395 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "id", id, EET_T_INT);
396 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "type", type, EET_T_UCHAR);
397 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "effect", effect, EET_T_UCHAR);
398 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "mouse_events", mouse_events, EET_T_UCHAR);
399 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "repeat_events", repeat_events, EET_T_UCHAR);
400 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "ignore_flags", ignore_flags, EET_T_INT);
401 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "scale", scale, EET_T_UCHAR);
402 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "pointer_mode", pointer_mode, EET_T_UCHAR);
403 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "precise_is_inside", precise_is_inside, EET_T_UCHAR);
404 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "clip_to_id", clip_to_id, EET_T_INT);
405 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "use_alternate_font_metrics", use_alternate_font_metrics, EET_T_UCHAR);
406 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_part, Old_Edje_Part, "default_desc", default_desc, _edje_edd_old_edje_part_description);
407 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part, Old_Edje_Part, "other_desc", other_desc, _edje_edd_old_edje_part_description);
408 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.x", dragable.x, EET_T_CHAR);
409 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.step_x", dragable.step_x, EET_T_INT);
410 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.count_x", dragable.count_x, EET_T_INT);
411 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.y", dragable.y, EET_T_CHAR);
412 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.step_y", dragable.step_y, EET_T_INT);
413 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.count_y", dragable.count_y, EET_T_INT);
414 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.counfine_id", dragable.confine_id, EET_T_INT);
415 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.events_id", dragable.event_id, EET_T_INT);
416 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "entry_mode", entry_mode, EET_T_UCHAR);
417 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "select_mode", select_mode, EET_T_UCHAR);
418 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "multiline", multiline, EET_T_UCHAR);
419 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source", source, EET_T_STRING);
420 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source2", source2, EET_T_STRING);
421 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source3", source3, EET_T_STRING);
422 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source4", source4, EET_T_STRING);
423 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source5", source5, EET_T_STRING);
424 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source6", source6, EET_T_STRING);
425 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part, Old_Edje_Part, "items", items, _edje_edd_old_edje_pack_element);
426 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "api.name", api.name, EET_T_STRING);
427 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "api.description", api.description, EET_T_STRING);
428
429 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Edje_Part_Collection", sizeof (Old_Edje_Part_Collection));
430 _edje_edd_old_edje_part_collection =
431 eet_data_descriptor_file_new(&eddc);
432 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "programs", programs, _edje_edd_old_edje_program);
433 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "parts", parts, _edje_edd_old_edje_part);
434 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "data", data, _edje_edd_old_edje_data);
435 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "prop.min.w", prop.min.w, EET_T_INT);
436 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "prop.min.h", prop.min.h, EET_T_INT);
437 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT);
438 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "prop.max.h", prop.max.h, EET_T_INT);
439 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "id", id, EET_T_INT);
440 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "script_only", script_only, EET_T_UCHAR);
441 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "lua_script_only", lua_script_only, EET_T_UCHAR);
442
443 {
444 Old_Edje_Part_Collection epc;
445
446 eet_data_descriptor_element_add(_edje_edd_old_edje_part_collection,
447 "alias", EET_T_STRING, EET_G_HASH,
448 (char *)(&(epc.alias)) - (char *)(&(epc)),
449 0, /* 0, */NULL, NULL);
450 }
451}
diff --git a/libraries/edje/src/bin/edje_decc.c b/libraries/edje/src/bin/edje_decc.c
new file mode 100644
index 0000000..1b79e13
--- /dev/null
+++ b/libraries/edje/src/bin/edje_decc.c
@@ -0,0 +1,472 @@
1/* ugly ugly. avert your eyes. */
2
3#ifdef HAVE_CONFIG_H
4# include <config.h>
5#endif
6
7#include <string.h>
8#include <ctype.h>
9#include <unistd.h>
10#include <locale.h>
11#include <sys/types.h>
12#include <sys/stat.h>
13#include <errno.h>
14
15
16#include <Ecore_File.h>
17#include <Ecore_Evas.h>
18
19#include "edje_decc.h"
20
21int _edje_cc_log_dom = -1;
22char *progname = NULL;
23char *file_in = NULL;
24char *file_out = NULL;
25
26Edje_File *edje_file = NULL;
27SrcFile_List *srcfiles = NULL;
28Font_List *fontlist = NULL;
29
30int line = 0;
31int build_sh = 1;
32int new_dir = 1;
33
34int decomp(void);
35void output(void);
36static int compiler_cmd_is_sane();
37static int root_filename_is_sane();
38
39static void
40main_help(void)
41{
42 printf
43 ("Usage:\n"
44 "\t%s input_file.edj [-main-out file.edc] [-no-build-sh] [-current-dir]\n"
45 "\n"
46 " -main-out\tCreate a symbolic link to the main edc \n"
47 " -no-build-sh\tDon't output build.sh \n"
48 " -current-dir\tOutput to current directory \n"
49 "\n"
50 ,progname);
51}
52
53Eet_File *ef;
54Eet_Dictionary *ed;
55
56int
57main(int argc, char **argv)
58{
59 int i;
60
61 setlocale(LC_NUMERIC, "C");
62 if (!eina_init())
63 exit(-1);
64 _edje_cc_log_dom = eina_log_domain_register
65 ("edje_decc", EDJE_CC_DEFAULT_LOG_COLOR);
66 if (_edje_cc_log_dom < 0)
67 {
68 EINA_LOG_ERR("Impossible to create a log domain.");
69 eina_shutdown();
70 exit(-1);
71 }
72 eina_log_level_set(EINA_LOG_LEVEL_INFO);
73 progname = argv[0];
74 for (i = 1; i < argc; i++)
75 {
76 if (!strcmp(argv[i], "-h"))
77 {
78 main_help();
79 exit(0);
80 }
81 if (!file_in)
82 file_in = argv[i];
83 else if ((!strcmp(argv[i], "-main-out")) && (i < (argc - 1)))
84 {
85 i++;
86 file_out = argv[i];
87 }
88 else if (!strcmp(argv[i], "-no-build-sh"))
89 build_sh = 0;
90 else if (!strcmp(argv[i], "-current-dir"))
91 new_dir = 0;
92 }
93 if (!file_in)
94 {
95 ERR("%s: Error: no input file specified.", progname);
96 main_help();
97 exit(-1);
98 }
99
100 if (!edje_init())
101 exit(-1);
102 source_edd();
103
104 if (!decomp()) return -1;
105 output();
106
107 printf("WARNING! If any Image or audio data was encoded in a LOSSY way, then\n"
108 "re-encoding will drop quality even more. You need access to the original\n"
109 "data to ensure no loss of quality.\n");
110 eet_close(ef);
111 edje_shutdown();
112 eina_log_domain_unregister(_edje_cc_log_dom);
113 _edje_cc_log_dom = -1;
114 eina_shutdown();
115 return 0;
116}
117
118int
119decomp(void)
120{
121 ef = eet_open(file_in, EET_FILE_MODE_READ);
122 if (!ef)
123 {
124 ERR("ERROR: cannot open %s", file_in);
125 return 0;
126 }
127
128 srcfiles = source_load(ef);
129 if (!srcfiles || !srcfiles->list)
130 {
131 ERR("ERROR: %s has no decompile information", file_in);
132 eet_close(ef);
133 return 0;
134 }
135 if (!eina_list_data_get(srcfiles->list) || !root_filename_is_sane())
136 {
137 ERR("ERROR: Invalid root filename: '%s'", (char *) eina_list_data_get(srcfiles->list));
138 eet_close(ef);
139 return 0;
140 }
141 edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje/file");
142 if (!edje_file)
143 {
144 ERR("ERROR: %s does not appear to be an edje file", file_in);
145 eet_close(ef);
146 return 0;
147 }
148 /* force compiler to be edje_cc */
149 edje_file->compiler = strdup("edje_cc");
150 if (!edje_file->compiler)
151 {
152 edje_file->compiler = strdup("edje_cc");
153 }
154 else if (!compiler_cmd_is_sane())
155 {
156 ERR("ERROR: invalid compiler executable: '%s'", edje_file->compiler);
157 eet_close(ef);
158 return 0;
159 }
160 fontlist = source_fontmap_load(ef);
161 return 1;
162}
163
164void
165output(void)
166{
167 Eina_List *l;
168 Eet_File *tef;
169 SrcFile *sf;
170 char *outdir, *p;
171
172 if (!new_dir)
173 outdir = strdup(".");
174 else
175 {
176 p = strrchr(file_in, '/');
177 if (p)
178 outdir = strdup(p + 1);
179 else
180 outdir = strdup(file_in);
181 p = strrchr(outdir, '.');
182 if (p) *p = 0;
183 ecore_file_mkpath(outdir);
184 }
185
186
187 tef = eet_open(file_in, EET_FILE_MODE_READ);
188
189 if (edje_file->image_dir)
190 {
191 Edje_Image_Directory_Entry *ei;
192 unsigned int i;
193
194 for (i = 0; i < edje_file->image_dir->entries_count; ++i)
195 {
196 ei = &edje_file->image_dir->entries[i];
197
198 if ((ei->source_type > EDJE_IMAGE_SOURCE_TYPE_NONE) &&
199 (ei->source_type < EDJE_IMAGE_SOURCE_TYPE_LAST) &&
200 (ei->source_type != EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
201 (ei->entry))
202 {
203 Ecore_Evas *ee;
204 Evas *evas;
205 Evas_Object *im;
206 char buf[4096];
207 char out[4096];
208 char *pp;
209
210 ecore_init();
211 ecore_evas_init();
212 ee = ecore_evas_buffer_new(1, 1);
213 if (!ee)
214 {
215 ERR("Cannot create buffer engine canvas for image save.");
216 exit(-1);
217 }
218 evas = ecore_evas_get(ee);
219 im = evas_object_image_add(evas);
220 if (!im)
221 {
222 ERR("Cannot create image object for save.");
223 exit(-1);
224 }
225 snprintf(buf, sizeof(buf), "edje/images/%i", ei->id);
226 evas_object_image_file_set(im, file_in, buf);
227 snprintf(out, sizeof(out), "%s/%s", outdir, ei->entry);
228 printf("Output Image: %s\n", out);
229 pp = strdup(out);
230 p = strrchr(pp, '/');
231 *p = 0;
232 if (strstr(pp, "../"))
233 {
234 ERR("Potential security violation. attempt to write in parent dir.");
235 exit(-1);
236 }
237 ecore_file_mkpath(pp);
238 free(pp);
239 if (!evas_object_image_save(im, out, NULL, "quality=100 compress=9"))
240 {
241 ERR("Cannot write file %s. Perhaps missing JPEG or PNG saver modules for Evas.", out);
242 exit(-1);
243 }
244 evas_object_del(im);
245 ecore_evas_free(ee);
246 ecore_evas_shutdown();
247 ecore_shutdown();
248 }
249 }
250 }
251
252 EINA_LIST_FOREACH(srcfiles->list, l, sf)
253 {
254 char out[4096];
255 FILE *f;
256 char *pp;
257
258 snprintf(out, sizeof(out), "%s/%s", outdir, sf->name);
259 INF("Output Source File: %s\n", out);
260 pp = strdup(out);
261 p = strrchr(pp, '/');
262 *p = 0;
263 if (strstr(pp, "../"))
264 {
265 ERR("Potential security violation. attempt to write in parent dir.");
266 exit (-1);
267 }
268 ecore_file_mkpath(pp);
269 free(pp);
270 if (strstr(out, "../"))
271 {
272 ERR("Potential security violation. attempt to write in parent dir.");
273 exit (-1);
274 }
275 f = fopen(out, "wb");
276 if (!f)
277 {
278 ERR("Unable to write file (%s).", out);
279 exit (-1);
280 }
281
282 /* if the file is empty, sf->file will be NULL.
283 * note that that's not an error
284 */
285 if (sf->file) fputs(sf->file, f);
286 fclose(f);
287 }
288 if (edje_file->fonts)
289 {
290 Edje_Font_Directory_Entry *fn;
291 Eina_Iterator *it;
292
293 it = eina_hash_iterator_data_new(edje_file->fonts);
294 EINA_ITERATOR_FOREACH(it, fn)
295 {
296 void *font;
297 int fontsize;
298 char out[4096];
299 /* FIXME!!!! */
300 /* should be fn->entry -v */
301 snprintf(out, sizeof(out), "edje/fonts/%s", fn->file);
302 font = eet_read(tef, out, &fontsize);
303 if (font)
304 {
305 FILE *f;
306 char *pp;
307
308 /* should be fn->file -v */
309 snprintf(out, sizeof(out), "%s/%s", outdir, fn->entry);
310 INF("Output Font: %s", out);
311 pp = strdup(out);
312 p = strrchr(pp, '/');
313 *p = 0;
314 if (strstr(pp, "../"))
315 {
316 ERR("Potential security violation. attempt to write in parent dir.");
317 exit (-1);
318 }
319 ecore_file_mkpath(pp);
320 free(pp);
321 if (strstr(out, "../"))
322 {
323 ERR("Potential security violation. attempt to write in parent dir.");
324 exit (-1);
325 }
326 if (!(f = fopen(out, "wb")))
327 {
328 ERR("Could not open file: %s", out);
329 exit (-1);
330 }
331 if (fwrite(font, fontsize, 1, f) != 1)
332 ERR("Could not write font: %s", strerror(errno));
333 if (f) fclose(f);
334 free(font);
335 }
336 }
337 eina_iterator_free(it);
338 }
339 {
340 char out[4096];
341 FILE *f;
342 sf = eina_list_data_get(srcfiles->list);
343
344
345 if (build_sh)
346 {
347 snprintf(out, sizeof(out), "%s/build.sh", outdir);
348 printf("Output Build Script: %s\n", out);
349 if (strstr(out, "../"))
350 {
351 ERR("potential security violation. attempt to write in parent dir.\n");
352 exit (-1);
353 }
354 f = fopen(out, "wb");
355 fprintf(f, "#!/bin/sh\n");
356 fprintf(f, "%s $@ -id . -fd . %s -o %s.edj\n", edje_file->compiler, sf->name, outdir);
357 fclose(f);
358
359 WRN("\n*** CAUTION ***\n"
360 "Please check the build script for anything malicious "
361 "before running it!\n\n");
362 }
363
364 if (file_out)
365 {
366 snprintf(out, sizeof(out), "%s/%s", outdir, file_out);
367 if (ecore_file_symlink(sf->name, out) != EINA_TRUE)
368 {
369 ERR("symlink %s -> %s failed\n", sf->name, out);
370 }
371 }
372
373 chmod(out, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP);
374
375 }
376
377 if (edje_file->sound_dir)
378 {
379 Edje_Sound_Sample *sample;
380 void *sound_data;
381 char out[PATH_MAX];
382 char out1[PATH_MAX];
383 char *pp;
384 int sound_data_size;
385 FILE *f;
386 int i;
387
388 for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++)
389 {
390 sample = &edje_file->sound_dir->samples[i];
391 if ((!sample) || (!sample->name)) continue;
392 snprintf(out, sizeof(out), "edje/sounds/%i", sample->id);
393 sound_data = (void *)eet_read_direct(tef, out, &sound_data_size);
394 if (sound_data)
395 {
396 snprintf(out1, sizeof(out1), "%s/%s", outdir, sample->name);
397 pp = strdup(out1);
398 p = strrchr(pp, '/');
399 *p = 0;
400 if (strstr(pp, "../"))
401 {
402 ERR("Potential security violation. attempt to write in parent dir.");
403 exit(-1);
404 }
405 ecore_file_mkpath(pp);
406 free(pp);
407 if (strstr(out, "../"))
408 {
409 ERR("Potential security violation. attempt to write in parent dir.");
410 exit(-1);
411 }
412 f = fopen(out1, "wb");
413 if (fwrite(sound_data, sound_data_size, 1, f) != 1)
414 ERR("Could not write sound: %s", strerror(errno));
415 fclose(f);
416 free(sound_data);
417 }
418 }
419
420 }
421 eet_close(tef);
422}
423
424static int
425compiler_cmd_is_sane()
426{
427 const char *c = edje_file->compiler, *ptr;
428
429 if ((!c) || (!*c))
430 {
431 return 0;
432 }
433
434 for (ptr = c; ptr && *ptr; ptr++)
435 {
436 /* only allow [a-z][A-Z][0-9]_- */
437 if ((!isalnum(*ptr)) && (*ptr != '_') && (*ptr != '-'))
438 {
439 return 0;
440 }
441 }
442
443 return 1;
444}
445
446static int
447root_filename_is_sane()
448{
449 SrcFile *sf = eina_list_data_get(srcfiles->list);
450 char *f = sf->name, *ptr;
451
452 if (!f || !*f)
453 {
454 return 0;
455 }
456
457 for (ptr = f; ptr && *ptr; ptr++)
458 {
459 /* only allow [a-z][A-Z][0-9]_-./ */
460 switch (*ptr)
461 {
462 case '_': case '-': case '.': case '/':
463 break;
464 default:
465 if (!isalnum(*ptr))
466 {
467 return 0;
468 }
469 }
470 }
471 return 1;
472}
diff --git a/libraries/edje/src/bin/edje_decc.h b/libraries/edje/src/bin/edje_decc.h
new file mode 100644
index 0000000..43e988d
--- /dev/null
+++ b/libraries/edje/src/bin/edje_decc.h
@@ -0,0 +1,61 @@
1#ifndef EDJE_DECC_H
2#define EDJE_DECC_H
3
4#include <edje_private.h>
5
6/* logging variables */
7extern int _edje_cc_log_dom ;
8#define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
9#ifdef ERR
10# undef ERR
11#endif
12#define ERR(...) EINA_LOG_DOM_ERR(_edje_cc_log_dom, __VA_ARGS__)
13#ifdef INF
14# undef INF
15#endif
16#define INF(...) EINA_LOG_DOM_INFO(_edje_cc_log_dom, __VA_ARGS__)
17#ifdef WRN
18# undef WRN
19#endif
20#define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__)
21
22/* types */
23typedef struct _Font Font;
24typedef struct _Font_List Font_List;
25typedef struct _SrcFile SrcFile;
26typedef struct _SrcFile_List SrcFile_List;
27
28struct _Font
29{
30 char *file;
31 char *name;
32};
33
34struct _Font_List
35{
36 Eina_List *list;
37};
38
39struct _SrcFile
40{
41 char *name;
42 char *file;
43};
44
45struct _SrcFile_List
46{
47 Eina_List *list;
48};
49
50void source_edd(void);
51void source_fetch(void);
52int source_append(Eet_File *ef);
53SrcFile_List *source_load(Eet_File *ef);
54int source_fontmap_save(Eet_File *ef, Eina_List *fonts);
55Font_List *source_fontmap_load(Eet_File *ef);
56
57void *mem_alloc(size_t size);
58char *mem_strdup(const char *s);
59#define SZ sizeof
60
61#endif
diff --git a/libraries/edje/src/bin/edje_external_inspector.c b/libraries/edje/src/bin/edje_external_inspector.c
new file mode 100644
index 0000000..6bd9a35
--- /dev/null
+++ b/libraries/edje/src/bin/edje_external_inspector.c
@@ -0,0 +1,663 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <locale.h>
6#include <fnmatch.h>
7
8#include <Ecore.h>
9#include <Ecore_Getopt.h>
10
11#include "Edje.h"
12
13static int _log_dom;
14#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
15#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
16#define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__)
17#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
18#define CRIT(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__)
19
20#define INDENT " "
21#define INDENT2 INDENT INDENT
22#define INDENT3 INDENT2 INDENT
23#define INDENT4 INDENT3 INDENT
24
25static char *module_patterns_str = NULL;
26
27static int detail = 1;
28static Eina_Bool machine = EINA_FALSE;
29static char *type_glob = NULL;
30static char * const *module_patterns;
31static const Eina_List *modules;
32
33
34static char *
35_module_patterns_str_new(void)
36{
37 Eina_Strbuf *buf;
38 char * const *itr;
39 char *ret;
40 if (!module_patterns) return strdup("*");
41
42 buf = eina_strbuf_new();
43 for (itr = module_patterns; *itr != NULL; itr++)
44 {
45 eina_strbuf_append(buf, *itr);
46 if (itr[1]) eina_strbuf_append(buf, ", ");
47 }
48 ret = eina_strbuf_string_steal(buf);
49 eina_strbuf_free(buf);
50 return ret;
51}
52
53static Eina_Bool
54module_matches(const char *name)
55{
56 char * const *itr;
57 if (!module_patterns) return EINA_TRUE;
58
59 for (itr = module_patterns; *itr != NULL; itr++)
60 if (fnmatch(*itr, name, 0) == 0) return EINA_TRUE;
61
62 return EINA_FALSE;
63}
64
65static inline Eina_Bool
66type_matches(const char *name)
67{
68 if (!type_glob) return EINA_TRUE;
69 return fnmatch(type_glob, name, 0) == 0;
70}
71
72static int
73_types_sort(const void *pa, const void *pb)
74{
75 const Eina_Hash_Tuple *ha = pa, *hb = pb;
76 const Edje_External_Type *ta = ha->data, *tb = hb->data;
77 const char *na = ha->key, *nb = hb->key;
78 int r;
79
80 if (!ta->module) return -1;
81 if (!tb->module) return 1;
82 r = strcmp(ta->module, tb->module);
83 if (r != 0) return r;
84
85 if (!na) return -1;
86 if (!nb) return 1;
87 return strcmp(na, nb);
88}
89
90static const char *
91_param_type_str_get(const Edje_External_Param_Info *param)
92{
93 switch (param->type)
94 {
95 case EDJE_EXTERNAL_PARAM_TYPE_INT: return "int";
96 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: return "double";
97 case EDJE_EXTERNAL_PARAM_TYPE_STRING: return "string";
98 case EDJE_EXTERNAL_PARAM_TYPE_BOOL: return "bool";
99 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: return "choice";
100 default:
101 ERR("Unknown parameter type %d", param->type);
102 return "???";
103 }
104}
105
106static const char *
107_param_value_str_get(const Edje_External_Type *type, const Edje_External_Param_Info *param, char *buf, size_t buflen)
108{
109 switch (param->type)
110 {
111 case EDJE_EXTERNAL_PARAM_TYPE_INT:
112 if (param->info.i.def == EDJE_EXTERNAL_INT_UNSET) return NULL;
113 snprintf(buf, buflen, "%d", param->info.i.def);
114 return buf;
115
116 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
117 if (param->info.d.def == EDJE_EXTERNAL_DOUBLE_UNSET) return NULL;
118 snprintf(buf, buflen, "%g", param->info.d.def);
119 return buf;
120
121 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
122 return param->info.s.def;
123
124 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
125 if (param->info.b.def == 0) return "0";
126 else if (param->info.b.def == 1) return "1";
127 return NULL;
128
129 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
130 {
131 char *def;
132 if (param->info.c.def) return param->info.c.def;
133 if (!param->info.c.def_get) return NULL;
134 def = param->info.c.def_get(type->data, param);
135 if (!def) return NULL;
136 eina_strlcpy(buf, def, buflen);
137 free(def);
138 return buf;
139 }
140
141 default:
142 ERR("Unknown parameter type %d", param->type);
143 return NULL;
144 }
145}
146
147static const char *
148_param_flags_str_get(const Edje_External_Param_Info *param)
149{
150 static char buf[] = "GET|SET|STATE|CONSTRUCTOR";
151
152 if (param->flags == EDJE_EXTERNAL_PARAM_FLAGS_NONE) return "NONE";
153 if (param->flags == EDJE_EXTERNAL_PARAM_FLAGS_REGULAR) return "REGULAR";
154
155 buf[0] = '\0';
156
157 if (param->flags & EDJE_EXTERNAL_PARAM_FLAGS_GET)
158 strcat(buf, "GET");
159
160 if (param->flags & EDJE_EXTERNAL_PARAM_FLAGS_SET)
161 {
162 if (buf[0] != '\0') strcat(buf, "|");
163 strcat(buf, "SET");
164 }
165
166 if (param->flags & EDJE_EXTERNAL_PARAM_FLAGS_STATE)
167 {
168 if (buf[0] != '\0') strcat(buf, "|");
169 strcat(buf, "STATE");
170 }
171
172 if (param->flags & EDJE_EXTERNAL_PARAM_FLAGS_CONSTRUCTOR)
173 {
174 if (buf[0] != '\0') strcat(buf, "|");
175 strcat(buf, "CONSTRUCTOR");
176 }
177
178 return buf;
179}
180
181static void
182_param_choices_print(const char * const *choices)
183{
184 if (machine) puts("CHOICES-BEGIN");
185 else fputs(", choices:", stdout);
186 for (; *choices != NULL; choices++)
187 {
188 if (machine) puts(*choices);
189 else printf(" \"%s\"", *choices);
190 }
191 if (machine) puts("CHOICES-END");
192}
193
194static void
195_param_extra_details(const Edje_External_Type *type, const Edje_External_Param_Info *param)
196{
197 const char *str = _param_flags_str_get(param);
198 if (machine) printf("FLAGS: %s\n", str);
199 else printf(" /* flags: %s", str);
200
201 switch (param->type)
202 {
203 case EDJE_EXTERNAL_PARAM_TYPE_INT:
204 if (param->info.i.min != EDJE_EXTERNAL_INT_UNSET)
205 {
206 if (machine) printf("MIN: %d\n", param->info.i.min);
207 else printf(", min: %d", param->info.i.min);
208 }
209 if (param->info.i.max != EDJE_EXTERNAL_INT_UNSET)
210 {
211 if (machine) printf("MAX: %d\n", param->info.i.max);
212 else printf(", max: %d", param->info.i.max);
213 }
214 if (param->info.i.step != EDJE_EXTERNAL_INT_UNSET)
215 {
216 if (machine) printf("STEP: %d\n", param->info.i.step);
217 else printf(", step: %d", param->info.i.step);
218 }
219 break;
220
221 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
222 if (param->info.d.min != EDJE_EXTERNAL_DOUBLE_UNSET)
223 {
224 if (machine) printf("MIN: %g\n", param->info.d.min);
225 else printf(", min: %g", param->info.d.min);
226 }
227 if (param->info.d.max != EDJE_EXTERNAL_DOUBLE_UNSET)
228 {
229 if (machine) printf("MAX: %g\n", param->info.d.max);
230 else printf(", max: %g", param->info.d.max);
231 }
232 if (param->info.d.step != EDJE_EXTERNAL_DOUBLE_UNSET)
233 {
234 if (machine) printf("STEP: %g\n", param->info.d.step);
235 else printf(", step: %g", param->info.d.step);
236 }
237 break;
238
239 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
240 if (param->info.s.accept_fmt)
241 {
242 if (machine) printf("ACCEPT_FMT: %s\n", param->info.s.accept_fmt);
243 else printf(", accept_fmt: \"%s\"", param->info.s.accept_fmt);
244 }
245 if (param->info.s.deny_fmt)
246 {
247 if (machine) printf("DENY_FMT: %s\n", param->info.s.deny_fmt);
248 else printf(", deny_fmt: \"%s\"", param->info.s.deny_fmt);
249 }
250 break;
251
252 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
253 if (param->info.b.false_str)
254 {
255 if (machine) printf("FALSE_STR: %s\n", param->info.b.false_str);
256 else printf(", false_str: \"%s\"", param->info.b.false_str);
257 }
258 if (param->info.b.true_str)
259 {
260 if (machine) printf("TRUE_STR: %s\n", param->info.b.true_str);
261 else printf(", true_str: \"%s\"", param->info.b.true_str);
262 }
263 break;
264
265 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
266 {
267 if (param->info.c.choices)
268 _param_choices_print(param->info.c.choices);
269 else if (param->info.c.query)
270 {
271 char **choices = param->info.c.query(type->data, param);
272 if (choices)
273 {
274 char **itr;
275 _param_choices_print((const char * const*)choices);
276 for (itr = choices; *itr; itr++) free(*itr);
277 free(choices);
278 }
279 }
280 }
281 break;
282
283 default:
284 ERR("Unknown parameter type %d", param->type);
285 }
286
287 if (!machine) fputs(" */", stdout); /* \n not desired */
288}
289
290static int
291_info_list(void)
292{
293 Eina_Iterator *itr;
294 Eina_List *types;
295 const Eina_Hash_Tuple *tuple;
296 const Eina_List *l;
297 const char *name, *last_module;
298 Eina_Bool module_found = EINA_FALSE, type_found = EINA_FALSE;
299 Eina_Bool in_module = EINA_FALSE;
300
301 EINA_LIST_FOREACH(modules, l, name)
302 {
303 if (!module_matches(name))
304 {
305 DBG("filter out module '%s': does not match '%s'",
306 name, module_patterns_str);
307 continue;
308 }
309
310 if (!edje_module_load(name))
311 {
312 ERR("error loading external '%s'", name);
313 continue;
314 }
315
316 module_found = EINA_TRUE;
317 }
318
319 itr = edje_external_iterator_get();
320 types = NULL;
321 EINA_ITERATOR_FOREACH(itr, tuple)
322 {
323 const Edje_External_Type *type = tuple->data;
324 name = tuple->key;
325
326 if (!type)
327 {
328 ERR("no type value for '%s'", name);
329 continue;
330 }
331 else if (type->abi_version != edje_external_type_abi_version_get())
332 {
333 ERR("type '%s' with incorrect abi_version %u (expected %u)",
334 name, type->abi_version, edje_external_type_abi_version_get());
335 continue;
336 }
337
338 if (!type_matches(name))
339 {
340 DBG("filter out type '%s': does not match '%s'", name, type_glob);
341 continue;
342 }
343
344 types = eina_list_append(types, tuple);
345 type_found = EINA_TRUE;
346 }
347 eina_iterator_free(itr);
348
349 last_module = NULL;
350 types = eina_list_sort(types, 0, _types_sort);
351 EINA_LIST_FREE(types, tuple)
352 {
353 Eina_Bool changed_module = EINA_FALSE;
354 const Edje_External_Type *type = tuple->data;
355 const Edje_External_Param_Info *param;
356 name = tuple->key;
357
358 if ((last_module) && (type->module))
359 {
360 changed_module = ((last_module != type->module) &&
361 (!strcmp(last_module, type->module)));
362 }
363 else if ((!last_module) && (type->module))
364 changed_module = EINA_TRUE;
365
366 if (changed_module)
367 {
368 if (in_module)
369 {
370 if (machine) puts("TYPES-END\nMODULE-END");
371 else puts(INDENT "}\n}");
372 }
373
374 if (machine)
375 printf("MODULE-BEGIN\n"
376 "NAME: %s\n"
377 "FRIENDLY-NAME: %s\n"
378 "TYPES-BEGIN\n",
379 type->module, type->module_name);
380 else
381 printf("module {\n"
382 INDENT "name: \"%s\";\n"
383 INDENT "friendly_name: \"%s\";\n"
384 INDENT "types {\n",
385 type->module, type->module_name);
386
387 in_module = EINA_TRUE;
388 }
389
390 if (machine) printf("TYPE-BEGIN\nNAME: %s\n", name);
391 else printf(INDENT2 "type {\n" INDENT3 "name: \"%s\";\n", name);
392
393 if (detail > 1)
394 {
395 const char *str;
396
397 if (!type->label_get) str = NULL;
398 else str = type->label_get(type->data);
399 if (machine) printf("LABEL: %s\n", str ? str : "");
400 else if (str) printf(INDENT3 "label: \"%s\";\n", str);
401
402 if (!type->description_get) str = NULL;
403 else str = type->description_get(type->data);
404 if (machine) printf("DESCRIPTION: %s\n", str ? str : "");
405 else if (str) printf(INDENT3 "description: \"%s\";\n", str);
406 }
407
408 if (machine) puts("PARAMS-BEGIN");
409 else puts(INDENT3 "params {");
410
411 for (param = type->parameters_info; param->name != NULL; param++)
412 {
413 const char *pt = _param_type_str_get(param);
414 char buf[128];
415
416 if (machine)
417 printf("PARAM-BEGIN\nNAME: %s\nTYPE: %s\n", param->name, pt);
418 else printf(INDENT4 "%s: \"%s\"", pt, param->name);
419
420 if (detail > 0)
421 {
422 const char *str = _param_value_str_get
423 (type, param, buf, sizeof(buf));
424 if (machine) printf("DEFAULT: %s\n", str ? str : "");
425 else if (str) printf(" \"%s\"", str);
426
427 if (detail > 1)
428 {
429 if (!machine) putchar(';');
430 _param_extra_details(type, param);
431 }
432 }
433
434 if (machine) puts("PARAM-END");
435 else if (detail > 1) putchar('\n');
436 else puts(";");
437 }
438
439 if (machine) puts("PARAMS-END\nTYPE-END");
440 else puts(INDENT3 "}\n" INDENT2 "}");
441
442 last_module = type->module;
443 }
444
445 if (in_module)
446 {
447 if (machine) puts("MODULE-END");
448 else puts(INDENT "}\n}");
449 }
450
451 if (!module_found) WRN("no modules match '%s'", module_patterns_str);
452 if (!type_found) WRN("no types match '%s'", type_glob);
453 return (!module_found) || (!type_found);
454}
455
456static int
457_types_names_list(void)
458{
459 Eina_Iterator *itr;
460 Eina_List *types;
461 const Eina_Hash_Tuple *tuple;
462 const Eina_List *l;
463 const char *name;
464 Eina_Bool module_found = EINA_FALSE, type_found = EINA_FALSE;
465
466 EINA_LIST_FOREACH(modules, l, name)
467 {
468 if (!module_matches(name))
469 {
470 DBG("filter out module '%s': does not match '%s'",
471 name, module_patterns_str);
472 continue;
473 }
474
475 if (!edje_module_load(name))
476 {
477 ERR("error loading external '%s'", name);
478 continue;
479 }
480
481 module_found = EINA_TRUE;
482 }
483
484 itr = edje_external_iterator_get();
485 types = NULL;
486 EINA_ITERATOR_FOREACH(itr, tuple)
487 {
488 const Edje_External_Type *type = tuple->data;
489 name = tuple->key;
490
491 if (!type)
492 {
493 ERR("no type value for '%s'", name);
494 continue;
495 }
496 else if (type->abi_version != edje_external_type_abi_version_get())
497 {
498 ERR("type '%s' with incorrect abi_version %u (expected %u)",
499 name, type->abi_version, edje_external_type_abi_version_get());
500 continue;
501 }
502
503 if (!type_matches(name))
504 {
505 DBG("filter out type '%s': does not match '%s'", name, type_glob);
506 continue;
507 }
508
509 types = eina_list_append(types, tuple);
510 type_found = EINA_TRUE;
511 }
512 eina_iterator_free(itr);
513
514 types = eina_list_sort(types, 0, _types_sort);
515 EINA_LIST_FREE(types, tuple)
516 puts(tuple->key);
517
518 if (!module_found) WRN("no modules match '%s'", module_patterns_str);
519 if (!type_found) WRN("no types match '%s'", type_glob);
520 return (!module_found) || (!type_found);
521}
522
523static int
524_modules_names_list(void)
525{
526 const Eina_List *l;
527 const char *name;
528 Eina_Bool found = EINA_FALSE;
529
530 EINA_LIST_FOREACH(modules, l, name)
531 {
532 if (!module_matches(name))
533 {
534 DBG("filter out module '%s': does not match '%s'",
535 name, module_patterns_str);
536 continue;
537 }
538 found = EINA_TRUE;
539 puts(name);
540 }
541
542 if (!found) WRN("no modules match '%s'", module_patterns_str);
543 return !found;
544}
545
546static const char *mode_choices[] = {
547 "info",
548 "modules-names",
549 "types-names",
550 NULL,
551};
552
553static const char *detail_choices[] = {
554 "none",
555 "terse",
556 "all",
557 NULL
558};
559
560const Ecore_Getopt optdesc = {
561 "edje_external_inspector",
562 "%prog [options] [module|module-glob] ... [module|module-glob]",
563 PACKAGE_VERSION,
564 "(C) 2010 - The Enlightenment Project",
565 "BSD",
566 "Edje external module inspector.",
567 0,
568 {
569 ECORE_GETOPT_CHOICE('m', "mode", "Choose which mode to operate.",
570 mode_choices),
571 ECORE_GETOPT_STORE_STR('t', "type", "Limit output to type (or glob)."),
572 ECORE_GETOPT_CHOICE('d', "detail", "Choose detail level (default=terse)",
573 detail_choices),
574 ECORE_GETOPT_STORE_TRUE('M', "machine", "Produce machine readable output."),
575 ECORE_GETOPT_LICENSE('L', "license"),
576 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
577 ECORE_GETOPT_VERSION('V', "version"),
578 ECORE_GETOPT_HELP('h', "help"),
579 ECORE_GETOPT_SENTINEL
580 }
581};
582
583int
584main(int argc, char **argv)
585{
586 Eina_Bool quit_option = EINA_FALSE;
587 char *mode = NULL;
588 char *detail_name = NULL;
589 int arg_index;
590 int ret = 0;
591 Ecore_Getopt_Value values[] = {
592 ECORE_GETOPT_VALUE_STR(mode),
593 ECORE_GETOPT_VALUE_STR(type_glob),
594 ECORE_GETOPT_VALUE_STR(detail_name),
595 ECORE_GETOPT_VALUE_BOOL(machine),
596 ECORE_GETOPT_VALUE_BOOL(quit_option),
597 ECORE_GETOPT_VALUE_BOOL(quit_option),
598 ECORE_GETOPT_VALUE_BOOL(quit_option),
599 ECORE_GETOPT_VALUE_BOOL(quit_option),
600 ECORE_GETOPT_VALUE_NONE
601 };
602
603 setlocale(LC_NUMERIC, "C");
604
605 ecore_init();
606 eina_init();
607 edje_init();
608
609 _log_dom = eina_log_domain_register
610 ("edje_external_inspector", EINA_COLOR_YELLOW);
611 if (_log_dom < 0)
612 {
613 EINA_LOG_CRIT
614 ("could not register log domain 'edje_external_inspector'");
615 ret = 1;
616 goto error_log;
617 }
618
619 arg_index = ecore_getopt_parse(&optdesc, values, argc, argv);
620 if (arg_index < 0)
621 {
622 ERR("could not parse arguments.");
623 ret = 1;
624 goto error_getopt;
625 }
626 else if (quit_option) goto error_getopt;
627
628 if (!mode) mode = (char *)mode_choices[0];
629
630 if (detail_name)
631 {
632 if (!strcmp(detail_name, "none")) detail = 0;
633 else if (!strcmp(detail_name, "terse")) detail = 1;
634 else if (!strcmp(detail_name, "all")) detail = 2;
635 else ERR("Unknown detail level: '%s'", detail_name);
636 }
637
638 if (arg_index < argc) module_patterns = argv + arg_index;
639 else module_patterns = NULL;
640
641 modules = edje_available_modules_get();
642 module_patterns_str = _module_patterns_str_new();
643
644 if (!strcmp(mode, "info")) ret = _info_list();
645 else if (!strcmp(mode, "modules-names")) ret = _modules_names_list();
646 else if (!strcmp(mode, "types-names")) ret = _types_names_list();
647 else
648 {
649 ERR("Unknown mode: %s", mode);
650 ret = 1;
651 }
652
653 free(module_patterns_str);
654
655 error_getopt:
656 eina_log_domain_unregister(_log_dom);
657 error_log:
658 edje_shutdown();
659 ecore_shutdown();
660 eina_shutdown();
661
662 return ret;
663}
diff --git a/libraries/edje/src/bin/edje_inspector.c b/libraries/edje/src/bin/edje_inspector.c
new file mode 100644
index 0000000..ed3baaf
--- /dev/null
+++ b/libraries/edje/src/bin/edje_inspector.c
@@ -0,0 +1,1639 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "Edje.h"
6#define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT 1
7#include "Edje_Edit.h"
8
9#include <Ecore.h>
10#include <Ecore_Evas.h>
11#include <Ecore_Getopt.h>
12#include <locale.h>
13#include <fnmatch.h>
14#include <unistd.h>
15
16static int _log_dom;
17#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
18#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
19#define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__)
20#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
21#define CRIT(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__)
22
23#define INDENT " "
24#define INDENT2 INDENT INDENT
25#define INDENT3 INDENT2 INDENT
26#define INDENT4 INDENT3 INDENT
27#define INDENT5 INDENT4 INDENT
28#define INDENT6 INDENT5 INDENT
29#define INDENT7 INDENT6 INDENT
30
31#define FLOAT_PRECISION 0.0001
32#define FDIFF(a, b) (fabs((a) - (b)) > FLOAT_PRECISION)
33
34#ifdef _WIN32
35# define FMT_UCHAR "%c"
36#else
37# define FMT_UCHAR "%hhu"
38#endif
39
40/* context */
41static Eina_List *groups;
42static Ecore_Evas *ee;
43
44/* options */
45static const char *file;
46static char *group = NULL;
47static char *part = NULL;
48static char *program = NULL;
49static int detail = 1;
50static Eina_Bool api_only = EINA_FALSE;
51static Eina_Bool api_fix = EINA_FALSE;
52static Eina_Bool machine = EINA_FALSE;
53
54static const char *mode_choices[] = {
55 "groups",
56 "parts",
57 "programs",
58 "groups-names",
59 "part-names",
60 "global-data",
61 "images",
62 "fonts",
63 "externals",
64 NULL,
65};
66
67static const char *detail_choices[] = {
68 "none",
69 "terse",
70 "all",
71 NULL
72};
73
74const Ecore_Getopt optdesc = {
75 "edje_inspector",
76 "%prog [options] <file.edj>",
77 PACKAGE_VERSION,
78 "(C) 2010 - The Enlightenment Project",
79 "BSD",
80 "Edje file inspector, let one see groups, parts, programs and other details "
81 "of a compiled (binary) edje file.\n",
82 0,
83 {
84 ECORE_GETOPT_CHOICE('m', "mode", "Choose which mode to operate on file.",
85 mode_choices),
86 ECORE_GETOPT_CHOICE('d', "detail", "Choose detail level (default=terse)",
87 detail_choices),
88 ECORE_GETOPT_STORE_STR('g', "group", "Limit output to group (or glob)."),
89 ECORE_GETOPT_STORE_STR('p', "part", "Limit output to part (or glob)."),
90 ECORE_GETOPT_STORE_STR('r', "program",
91 "Limit output to program (or glob)."),
92 ECORE_GETOPT_STORE_TRUE('a', "api-only", "Limit to just api parts or "
93 "programs."),
94 ECORE_GETOPT_STORE_TRUE('A', "api-fix", "Fix API names to be C compliant."),
95 ECORE_GETOPT_STORE_TRUE('M', "machine", "Produce machine readable output."),
96 ECORE_GETOPT_LICENSE('L', "license"),
97 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
98 ECORE_GETOPT_VERSION('V', "version"),
99 ECORE_GETOPT_HELP('h', "help"),
100 ECORE_GETOPT_SENTINEL
101 }
102};
103
104static inline Eina_Bool
105matches(const char *name, const char *pattern)
106{
107 if (!pattern) return EINA_TRUE;
108 return fnmatch(pattern, name, 0) == 0;
109}
110
111static void
112group_begin(const char *name)
113{
114 if (machine) printf("GROUP-BEGIN\nNAME: %s\n", name);
115 else printf("group { name: '%s';\n", name);
116}
117
118static void
119group_end(void)
120{
121 if (machine) puts("GROUP-END");
122 else puts("}");
123}
124
125static void
126group_details(Evas_Object *ed)
127{
128 int w, h;
129
130 if (detail < 1) return;
131
132 if (machine) puts("GROUP-DETAILS-BEGIN");
133
134 w = edje_edit_group_min_w_get(ed);
135 h = edje_edit_group_min_h_get(ed);
136 if (machine) printf("MIN-W: %d\nMIN-H: %d\n", w, h);
137 else if ((w > 0) || (h > 0)) printf(INDENT "min: %d %d;\n", w, h);
138
139 w = edje_edit_group_max_w_get(ed);
140 h = edje_edit_group_max_h_get(ed);
141 if (machine) printf("MAX-W: %d\nMAX-H: %d\n", w, h);
142 else if ((w > 0) || (h > 0)) printf(INDENT "max: %d %d;\n", w, h);
143
144 if (detail > 1)
145 {
146 Eina_List *dl;
147 dl = edje_edit_group_data_list_get(ed);
148 if (dl)
149 {
150 Eina_List *l;
151 const char *k;
152 if (machine) puts(INDENT "GROUP-DETAILS-DATA-BEGIN");
153 else puts(INDENT "data {");
154
155 EINA_LIST_FOREACH(dl, l, k)
156 {
157 const char *v = edje_edit_group_data_value_get(ed, k);
158 if (machine) printf("ITEM: \"%s\" \"%s\"\n", k, v);
159 else printf(INDENT2 "item: \"%s\" \"%s\";\n", k, v);
160 }
161
162 edje_edit_string_list_free(dl);
163
164 if (machine) puts(INDENT "GROUP-DETAILS-DATA-END");
165 else puts(INDENT "}");
166 }
167 }
168
169 if (machine) puts("GROUP-DETAILS-END");
170}
171
172static void
173parts_begin(void)
174{
175 if (machine) puts("PARTS-BEGIN");
176 else puts(INDENT "parts {");
177}
178
179static void
180parts_end(void)
181{
182 if (machine) puts("PARTS-END");
183 else puts(INDENT "}");
184}
185
186static const char *
187part_type_name_get(Edje_Part_Type t)
188{
189 switch (t)
190 {
191 case EDJE_PART_TYPE_RECTANGLE:
192 return "RECT";
193 case EDJE_PART_TYPE_TEXT:
194 return "TEXT";
195 case EDJE_PART_TYPE_IMAGE:
196 return "IMAGE";
197 case EDJE_PART_TYPE_PROXY:
198 return "PROXY";
199 case EDJE_PART_TYPE_SWALLOW:
200 return "SWALLOW";
201 case EDJE_PART_TYPE_TEXTBLOCK:
202 return "TEXTBLOCK";
203 case EDJE_PART_TYPE_GRADIENT:
204 return "GRADIENT";
205 case EDJE_PART_TYPE_GROUP:
206 return "GROUP";
207 case EDJE_PART_TYPE_BOX:
208 return "BOX";
209 case EDJE_PART_TYPE_TABLE:
210 return "TABLE";
211 case EDJE_PART_TYPE_EXTERNAL:
212 return "EXTERNAL";
213
214 case EDJE_PART_TYPE_NONE:
215 case EDJE_PART_TYPE_LAST:
216 ERR("Invalid part type %d", t);
217 return "???";
218 default:
219 ERR("Unknown part type %d", t);
220 return "???";
221 }
222}
223
224static void
225state_begin(const char *state, double value)
226{
227 if (machine)
228 printf("PART-STATE-BEGIN\nNAME: %s\nVALUE: %2.1f\n", state, value);
229 else
230 {
231 printf(INDENT3 "description { state: \"%s\" %2.1f;", state, value);
232 if (detail > 0) putchar('\n');
233 }
234}
235
236static const char *
237aspect_pref_name_get(int id)
238{
239 switch (id)
240 {
241 case 0: return "NONE";
242 case 1: return "VERTICAL";
243 case 2: return "HORIZONTAL";
244 case 3: return "BOTH";
245 default:
246 ERR("Unknown aspect preference %d", id);
247 return "???";
248 }
249}
250
251static const char *
252border_fill_name_get(int id)
253{
254 switch (id)
255 {
256 case 0: return "NONE";
257 case 1: return "DEFAULT";
258 case 2: return "SOLID";
259 default:
260 ERR("Unknown border fill %d", id);
261 return "???";
262 }
263}
264
265static void
266state_details(Evas_Object *ed, const char *part, const char *state, double value)
267{
268 Edje_Part_Type t = edje_edit_part_type_get(ed, part);
269 double dx, dy;
270 const char *str, *str2;
271 int x, y, r, g, b, a;
272
273 if (detail < 1) return;
274
275 b = edje_edit_state_visible_get(ed, part, state, value);
276 if (machine) printf("VISIBLE: %d\n", b);
277 else if (!b) puts(INDENT4 "visible: 0;");
278
279 edje_edit_state_color_get(ed, part, state, value, &r, &g, &b, &a);
280 if (machine)
281 printf("COLOR-R: %d\nCOLOR-G: %d\nCOLOR-B: %d\nCOLOR-A: %d\n", r, g, b, a);
282 else if ((r != 255) || (g != 255) || (b != 255) || (a != 255))
283 printf(INDENT4 "color: %d %d %d %d;\n", r, g, b, a);
284
285 if (detail > 1)
286 {
287 edje_edit_state_color2_get(ed, part, state, value, &r, &g, &b, &a);
288 if (machine)
289 printf("COLOR2-R: %d\nCOLOR2-G: %d\nCOLOR2-B: %d\nCOLOR2-A: %d\n",
290 r, g, b, a);
291 else if ((r != 255) || (g != 255) || (b != 255) || (a != 255))
292 printf(INDENT4 "color2: %d %d %d %d;\n", r, g, b, a);
293
294 edje_edit_state_color3_get(ed, part, state, value, &r, &g, &b, &a);
295 if (machine)
296 printf("COLOR3-R: %d\nCOLOR3-G: %d\nCOLOR3-B: %d\nCOLOR3-A: %d\n",
297 r, g, b, a);
298 else if ((r != 255) || (g != 255) || (b != 255) || (a != 255))
299 printf(INDENT4 "color3: %d %d %d %d;\n", r, g, b, a);
300 }
301
302 dx = edje_edit_state_align_x_get(ed, part, state, value);
303 dy = edje_edit_state_align_y_get(ed, part, state, value);
304 if (machine) printf("ALIGN-X: %g\nALIGN-Y: %g\n", dx, dy);
305 else if (FDIFF(dx, 0.5) || FDIFF(dy, 0.5))
306 printf(INDENT4 "align: %g %g;\n", dx, dy);
307
308 x = edje_edit_state_min_w_get(ed, part, state, value);
309 y = edje_edit_state_min_h_get(ed, part, state, value);
310 if (machine) printf("MIN-W: %d\nMIN-H: %d\n", x, y);
311 else if ((x) || (y)) printf(INDENT4 "min: %d %d;\n", x, y);
312
313 x = edje_edit_state_max_w_get(ed, part, state, value);
314 y = edje_edit_state_max_h_get(ed, part, state, value);
315 if (machine) printf("MAX-W: %d\nMAX-H: %d\n", x, y);
316 else if ((x != -1) || (y != -1)) printf(INDENT4 "max: %d %d;\n", x, y);
317
318 //TODO Support fixed
319 //TODO Support step
320
321 if (detail > 1)
322 {
323 dx = edje_edit_state_aspect_min_get(ed, part, state, value);
324 dy = edje_edit_state_aspect_max_get(ed, part, state, value);
325 if (machine) printf("ASPECT-MIN: %g\nASPECT-MAX: %g\n", dx, dy);
326 else if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0))
327 printf(INDENT4 "aspect: %g %g;\n", dx, dy);
328
329 x = edje_edit_state_aspect_pref_get(ed, part, state, value);
330 str = aspect_pref_name_get(x);
331 if (machine) printf("ASPECT-PREFERENCE: %s\n", str);
332 else if (x) printf(INDENT4 "aspect_preference: %s;\n", str);
333 /* do not free this str! */
334
335 str = edje_edit_state_color_class_get(ed, part, state, value);
336 if (machine) printf("COLOR_CLASS: %s\n", str ? str : "");
337 else if (str) printf(INDENT4 "color_class: \"%s\";\n", str);
338 edje_edit_string_free(str);
339 }
340
341 dx = edje_edit_state_rel1_relative_x_get(ed, part, state, value);
342 dy = edje_edit_state_rel1_relative_y_get(ed, part, state, value);
343 x = edje_edit_state_rel1_offset_x_get(ed, part, state, value);
344 y = edje_edit_state_rel1_offset_y_get(ed, part, state, value);
345 str = edje_edit_state_rel1_to_x_get(ed, part, state, value);
346 str2 = edje_edit_state_rel1_to_y_get(ed, part, state, value);
347 if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y) || (str) || (str2))
348 {
349 if (machine) puts("REL1-BEGIN");
350 else puts(INDENT4 "rel1 {");
351
352 if (machine) printf("RELATIVE-X: %g\nRELATIVE-Y: %g\n", dx, dy);
353 else if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0))
354 printf(INDENT5 "relative: %g %g;\n", dx, dy);
355
356 if (machine) printf("OFFSET-X: %d\nOFFSET-Y: %d\n", x, y);
357 else if ((x) || (y)) printf(INDENT5 "offset: %d %d;\n", x, y);
358
359 if (machine)
360 printf("TO-X: %s\nTO-Y: %s\n", str ? str : "", str2 ? str2 : "");
361 else if (((str) && (str2)) && (!strcmp(str, str2)))
362 printf(INDENT5 "to: \"%s\";\n", str);
363 else
364 {
365 if (str) printf(INDENT5 "to_x: \"%s\";\n", str);
366 if (str2) printf(INDENT5 "to_y: \"%s\";\n", str2);
367 }
368
369 if (machine) puts("REL1-END");
370 else puts(INDENT4 "}");
371 }
372 edje_edit_string_free(str);
373 edje_edit_string_free(str2);
374
375 dx = edje_edit_state_rel2_relative_x_get(ed, part, state, value);
376 dy = edje_edit_state_rel2_relative_y_get(ed, part, state, value);
377 x = edje_edit_state_rel2_offset_x_get(ed, part, state, value);
378 y = edje_edit_state_rel2_offset_y_get(ed, part, state, value);
379 str = edje_edit_state_rel2_to_x_get(ed, part, state, value);
380 str2 = edje_edit_state_rel2_to_y_get(ed, part, state, value);
381 if (FDIFF(dx, 1.0) || FDIFF(dy, 1.0) || (x != -1) || (y != -1) ||
382 (str) || (str2))
383 {
384 if (machine) puts("REL2-BEGIN");
385 else puts(INDENT4 "rel2 {");
386
387 if (machine) printf("RELATIVE-X: %g\nRELATIVE-Y: %g\n", dx, dy);
388 else if (FDIFF(dx, 1.0) || FDIFF(dy, 1.0))
389 printf(INDENT5 "relative: %g %g;\n", dx, dy);
390
391 if (machine) printf("OFFSET-X: %d\nOFFSET-Y: %d\n", x, y);
392 else if ((x != -1) || (y != -1))
393 printf(INDENT5 "offset: %d %d;\n", x, y);
394
395 if (machine)
396 printf("TO-X: %s\nTO-Y: %s\n", str ? str : "", str2 ? str2 : "");
397 else if (((str) && (str2)) && (!strcmp(str, str2)))
398 printf(INDENT5 "to: \"%s\";\n", str);
399 else
400 {
401 if (str) printf(INDENT5 "to_x: \"%s\";\n", str);
402 if (str2) printf(INDENT5 "to_y: \"%s\";\n", str2);
403 }
404
405 if (machine) puts("REL2-END");
406 else puts(INDENT4 "}");
407 }
408 edje_edit_string_free(str);
409 edje_edit_string_free(str2);
410
411 if (t == EDJE_PART_TYPE_IMAGE)
412 {
413 str = edje_edit_state_image_get(ed, part, state, value);
414
415 if (machine) printf("IMAGE-BEGIN\nNORMAL: %s\n", str ? str : "");
416 else if (detail > 1)
417 {
418 puts(INDENT4 "image {");
419 if (str) printf(INDENT5 "normal: \"%s\";\n", str);
420 }
421 else if (str) printf(INDENT4 "image.normal: \"%s\";\n", str);
422
423 edje_edit_string_free(str);
424
425 if (detail > 1)
426 {
427 Eina_List *tweens, *l;
428 int bl, br, bt, bb, x2, y2;
429 double dx2, dy2;
430 Eina_Bool has_orgin, has_size;
431
432 tweens = edje_edit_state_tweens_list_get(ed, part, state, value);
433 EINA_LIST_FOREACH(tweens, l, str)
434 {
435 if (machine) printf("TWEEN: %s\n", str);
436 else printf(INDENT5 "tween: \"%s\";\n", str);
437 }
438 edje_edit_string_list_free(tweens);
439
440 edje_edit_state_image_border_get
441 (ed, part, state, value, &bl, &br, &bt, &bb);
442 if (machine)
443 printf("BORDER-LEFT: %d\nBORDER-RIGHT: %d\n"
444 "BORDER-TOP: %d\nBORDER-BOTTOM: %d\n", bl, br, bt, bb);
445 else if ((bl) || (br) || (bt) || (bb))
446 printf(INDENT5 "border: %d %d %d %d;\n", bl, br, bt, bb);
447
448 x = edje_edit_state_image_border_fill_get(ed, part, state, value);
449 str = border_fill_name_get(x);
450 if (machine) printf("BORDER-FILL: %s\n", str);
451 else if (x != 1) printf(INDENT5 "middle: %s;\n", str);
452 /* do not free str! */
453
454 // TODO support image.fill.smooth
455
456 dx = edje_edit_state_fill_origin_relative_x_get
457 (ed, part, state, value);
458 dy = edje_edit_state_fill_origin_relative_y_get
459 (ed, part, state, value);
460 x = edje_edit_state_fill_origin_offset_x_get
461 (ed, part, state, value);
462 y = edje_edit_state_fill_origin_offset_y_get
463 (ed, part, state, value);
464
465 dx2 = edje_edit_state_fill_size_relative_x_get
466 (ed, part, state, value);
467 dy2 = edje_edit_state_fill_size_relative_y_get
468 (ed, part, state, value);
469 x2 = edje_edit_state_fill_size_offset_x_get
470 (ed, part, state, value);
471 y2 = edje_edit_state_fill_size_offset_y_get
472 (ed, part, state, value);
473
474 has_orgin = (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y));
475 has_size = (FDIFF(dx2, 1.0) || FDIFF(dy2, 1.0) || (x2) || (y2));
476
477 if ((has_orgin) || (has_size))
478 {
479 if (machine) puts("IMAGE-FILL-BEGIN");
480 else puts(INDENT5 "fill {");
481
482 if (has_orgin)
483 {
484 if (machine)
485 printf("ORIGIN-RELATIVE-X: %g\n"
486 "ORIGIN-RELATIVE-Y: %g\n"
487 "ORIGIN-OFFSET-X: %d\n"
488 "ORIGIN-OFFSET-Y: %d\n",
489 dx, dy, x, y);
490 else
491 printf(INDENT6 "origin {\n"
492 INDENT7 "relative: %g %g;\n"
493 INDENT7 "offset: %d %d;\n"
494 INDENT6 "}\n",
495 dx, dy, x, y);
496 }
497
498 if (has_size)
499 {
500 if (machine)
501 printf("SIZE-RELATIVE-X: %g\n"
502 "SIZE-RELATIVE-Y: %g\n"
503 "SIZE-OFFSET-X: %d\n"
504 "SIZE-OFFSET-Y: %d\n",
505 dx2, dy2, x2, y2);
506 else
507 printf(INDENT6 "size {\n"
508 INDENT7 "relative: %g %g;\n"
509 INDENT7 "offset: %d %d;\n"
510 INDENT6 "}\n",
511 dx2, dy2, x2, y2);
512 }
513
514 if (machine) puts("IMAGE-FILL-END");
515 else puts(INDENT5 "}");
516 }
517 }
518
519 if (machine) puts("IMAGE-END");
520 else if (detail > 1) puts(INDENT4 "}");
521 }
522 else if (t == EDJE_PART_TYPE_PROXY)
523 {
524 int x2, y2;
525 double dx2, dy2;
526 Eina_Bool has_orgin, has_size;
527
528 if (machine) puts("PROXY-BEGIN");
529 else puts(INDENT4 "proxy {");
530 // TODO Support source
531 // TODO support proxy.fill.smooth
532
533 dx = edje_edit_state_fill_origin_relative_x_get
534 (ed, part, state, value);
535 dy = edje_edit_state_fill_origin_relative_y_get
536 (ed, part, state, value);
537 x = edje_edit_state_fill_origin_offset_x_get
538 (ed, part, state, value);
539 y = edje_edit_state_fill_origin_offset_y_get
540 (ed, part, state, value);
541
542 dx2 = edje_edit_state_fill_size_relative_x_get
543 (ed, part, state, value);
544 dy2 = edje_edit_state_fill_size_relative_y_get
545 (ed, part, state, value);
546 x2 = edje_edit_state_fill_size_offset_x_get
547 (ed, part, state, value);
548 y2 = edje_edit_state_fill_size_offset_y_get
549 (ed, part, state, value);
550
551 has_orgin = (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y));
552 has_size = (FDIFF(dx2, 1.0) || FDIFF(dy2, 1.0) || (x2) || (y2));
553
554 if ((has_orgin) || (has_size))
555 {
556 if (machine) puts("PROXY-FILL-BEGIN");
557 else puts(INDENT5 "fill {");
558
559 if (has_orgin)
560 {
561 if (machine)
562 printf("ORIGIN-RELATIVE-X: %g\n"
563 "ORIGIN-RELATIVE-Y: %g\n"
564 "ORIGIN-OFFSET-X: %d\n"
565 "ORIGIN-OFFSET-Y: %d\n",
566 dx, dy, x, y);
567 else
568 printf(INDENT6 "origin {\n"
569 INDENT7 "relative: %g %g;\n"
570 INDENT7 "offset: %d %d;\n"
571 INDENT6 "}\n",
572 dx, dy, x, y);
573 }
574
575 if (has_size)
576 {
577 if (machine)
578 printf("SIZE-RELATIVE-X: %g\n"
579 "SIZE-RELATIVE-Y: %g\n"
580 "SIZE-OFFSET-X: %d\n"
581 "SIZE-OFFSET-Y: %d\n",
582 dx2, dy2, x2, y2);
583 else
584 printf(INDENT6 "size {\n"
585 INDENT7 "relative: %g %g;\n"
586 INDENT7 "offset: %d %d;\n"
587 INDENT6 "}\n",
588 dx2, dy2, x2, y2);
589 }
590
591 if (machine) puts("PROXY-FILL-END");
592 else puts(INDENT5 "}");
593 }
594
595 if (machine) puts("PROXY-END");
596 else puts(INDENT4 "}");
597 }
598 else if ((t == EDJE_PART_TYPE_TEXTBLOCK) || (t == EDJE_PART_TYPE_TEXT))
599 {
600 if (machine) puts("TEXT-BEGIN");
601 else puts(INDENT4 "text {");
602
603 str = edje_edit_state_text_get(ed, part, state, value);
604 if (machine) printf("TEXT: %s\n", str ? str : "");
605 else if (str) printf(INDENT5 "text: \"%s\";\n", str);
606 edje_edit_string_free(str);
607
608 str = edje_edit_state_font_get(ed, part, state, value);
609 if (machine) printf("FONT: %s\n", str ? str : "");
610 else if (str) printf(INDENT5 "font: \"%s\";\n", str);
611 edje_edit_string_free(str);
612
613 x = edje_edit_state_text_size_get(ed, part, state, value);
614 if (machine) printf("SIZE: %d\n", x);
615 else if (x > 0) printf(INDENT5 "size: %d;\n", x);
616
617 // TODO text_class
618
619 dx = edje_edit_state_text_align_x_get(ed, part, state, value);
620 dy = edje_edit_state_text_align_y_get(ed, part, state, value);
621 if (machine) printf("TEXT-ALIGN-X: %g\nTEXT-ALIGN-Y: %g\n", dx, dy);
622 else if (FDIFF(dx, 0.5) || FDIFF(dy, 0.5))
623 printf(INDENT5 "align: %g %g;\n", dx, dy);
624
625 x = edje_edit_state_text_fit_x_get(ed, part, state, value);
626 y = edje_edit_state_text_fit_y_get(ed, part, state, value);
627 if (machine) printf("TEXT-FIT-X: %d\nTEXT-FIT-Y: %d\n", x, y);
628 else if ((x) || (y)) printf(INDENT5 "fit: %d %d;\n", x, y);
629
630 dx = edje_edit_state_text_elipsis_get(ed, part, state, value);
631 if (machine) printf("TEXT-ELIPSIS: %g\n", dx);
632 else if (FDIFF(dx, 0.5)) printf(INDENT5 "elipsis: %g;\n", dx);
633
634 if (machine) puts("TEXT-END");
635 else puts(INDENT4 "}");
636 }
637 else if (t == EDJE_PART_TYPE_EXTERNAL)
638 {
639 const Eina_List *params, *l;
640 const Edje_External_Param *p;
641
642 params = edje_edit_state_external_params_list_get
643 (ed, part, state, value);
644
645 if (params)
646 {
647 if (machine) puts("PARAMS-BEGIN");
648 else puts(INDENT4 "params {");
649
650 EINA_LIST_FOREACH(params, l, p)
651 switch (p->type)
652 {
653 case EDJE_EXTERNAL_PARAM_TYPE_INT:
654 printf(INDENT5 "int: \"%s\" \"%d\";\n", p->name, p->i);
655 break;
656 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
657 printf(INDENT5 "double: \"%s\" \"%g\";\n", p->name, p->d);
658 break;
659 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
660 if (p->s)
661 printf(INDENT5 "string: \"%s\" \"%s\";\n",
662 p->name, p->s);
663 break;
664 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
665 printf(INDENT5 "bool: \"%s\" \"%d\";\n", p->name, p->i);
666 break;
667 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
668 if (p->s)
669 printf(INDENT5 "choice: \"%s\" \"%s\";\n",
670 p->name, p->s);
671 break;
672 default:
673 break;
674 }
675
676 if (machine) puts("PARAMS-END");
677 else puts(INDENT4 "}");
678 }
679 }
680}
681
682static void
683state_end(void)
684{
685 if (machine) puts("PART-STATE-END");
686 else if (detail > 0) puts(INDENT3 "}");
687 else puts(" }");
688}
689
690static void
691part_begin(Evas_Object *ed, const char *name)
692{
693 const char *type = part_type_name_get(edje_edit_part_type_get(ed, name));
694 if (machine) printf("PART-BEGIN\nNAME: %s\nTYPE: %s\n", name, type);
695 else
696 {
697 printf(INDENT2 "part { name: '%s'; type: %s;", name, type);
698 if (detail > 0) putchar('\n');
699 }
700}
701
702static const char *
703text_effect_name_get(Edje_Text_Effect effect)
704{
705 switch (effect)
706 {
707 case EDJE_TEXT_EFFECT_NONE:
708 return "NONE";
709 case EDJE_TEXT_EFFECT_PLAIN:
710 return "PLAIN";
711 case EDJE_TEXT_EFFECT_OUTLINE:
712 return "OUTLINE";
713 case EDJE_TEXT_EFFECT_SOFT_OUTLINE:
714 return "SOFT_OUTLINE";
715 case EDJE_TEXT_EFFECT_SHADOW:
716 return "SHADOW";
717 case EDJE_TEXT_EFFECT_SOFT_SHADOW:
718 return "SOFT_SHADOW";
719 case EDJE_TEXT_EFFECT_OUTLINE_SHADOW:
720 return "OUTLINE_SHADOW";
721 case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW:
722 return "OUTLINE_SOFT_SHADOW";
723 case EDJE_TEXT_EFFECT_FAR_SHADOW:
724 return "FAR_SHADOW";
725 case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW:
726 return "FAR_SOFT_SHADOW";
727 case EDJE_TEXT_EFFECT_GLOW:
728 return "GLOW";
729
730 case EDJE_TEXT_EFFECT_LAST:
731 ERR("Invalid part type %d", effect);
732 return "???";
733 default:
734 ERR("Unknown effect type %d", effect);
735 return "???";
736 }
737}
738
739static inline Eina_Bool
740_c_id_allowed(char c)
741{
742 if ((c >= '0') && (c <= '9')) return EINA_TRUE;
743 if ((c >= 'a') && (c <= 'z')) return EINA_TRUE;
744 if ((c >= 'A') && (c <= 'Z')) return EINA_TRUE;
745 return EINA_FALSE;
746}
747
748static char *
749_api_name_fix(const char *orig)
750{
751 char *d, *d_end, buf[256];
752 const char *s;
753
754 if (!orig) return NULL;
755 if (!api_fix) return strdup(orig);
756
757 s = orig;
758 d = buf;
759 d_end = d + sizeof(buf) - 1;
760 for (; (*s != '\0') && (d < d_end); s++, d++)
761 if (_c_id_allowed(*s)) *d = *s;
762 else *d = '_';
763 *d = '\0';
764
765 return strdup(buf);
766}
767
768static char *
769_part_api_name_get(Evas_Object *ed, const char *part)
770{
771 const char *orig = edje_edit_part_api_name_get(ed, part);
772 char *fix = _api_name_fix(orig);
773 edje_edit_string_free(orig);
774 return fix;
775}
776
777static void
778part_details(Evas_Object *ed, const char *part)
779{
780 Eina_List *states, *l;
781 Eina_Bool b;
782 const char *str, *str2;
783 char *api;
784
785 if (detail < 1) return;
786
787 if (machine) puts("PART-DETAILS-BEGIN");
788
789 str = api =_part_api_name_get(ed, part);
790 str2 = edje_edit_part_api_description_get(ed, part);
791 if (machine)
792 {
793 printf("API-NAME: %s\n", str ? str : "");
794 printf("API-DESCRIPTION: %s\n", str2 ? str2 : "");
795 }
796 else if ((str) || (str2))
797 printf(INDENT3 "api: \"%s\" \"%s\";\n", str ? str : "", str2 ? str2 : "");
798 free(api);
799 edje_edit_string_free(str2);
800
801 b = edje_edit_part_mouse_events_get(ed, part);
802 if (machine) printf("MOUSE_EVENTS: %d\n", b);
803 else if (!b) puts(INDENT3 "mouse_events: 0;");
804
805 if (detail > 1)
806 {
807 b = edje_edit_part_repeat_events_get(ed, part);
808 if (machine) printf("REPEAT_EVENTS: %d\n", b);
809 else if (b) puts(INDENT3 "repeat_events: 1;");
810
811 b = edje_edit_part_scale_get(ed, part);
812 if (machine) printf("SCALE: %d\n", b);
813 else if (b) puts(INDENT3 "scale: 1;");
814 }
815
816 str = edje_edit_part_clip_to_get(ed, part);
817 if (machine) printf("CLIP_TO: %s\n", str ? str : "");
818 else if (str) printf(INDENT3 "clip_to: \"%s\";\n", str);
819 edje_edit_string_free(str);
820
821 str = edje_edit_part_source_get(ed, part);
822 if (machine) printf("SOURCE: %s\n", str ? str : "");
823 else if (str) printf(INDENT3 "source: \"%s\";\n", str);
824 edje_edit_string_free(str);
825
826 if (detail > 1)
827 {
828 if (edje_edit_part_type_get(ed, part) == EDJE_PART_TYPE_TEXT)
829 {
830 str = text_effect_name_get(edje_edit_part_effect_get(ed, part));
831 if (machine) printf("EFFECT: %s\n", str ? str : "");
832 else if (str) printf(INDENT3 "effect: %s;\n", str);
833 /* do not free this str! */
834 }
835
836 if (edje_edit_part_drag_x_get(ed, part) ||
837 edje_edit_part_drag_y_get(ed, part))
838 {
839 int dir, step, count;
840
841 if (machine) puts("DRAGABLE-BEGIN");
842 else puts(INDENT3 "dragable {");
843
844 dir = edje_edit_part_drag_x_get(ed, part);
845 step = edje_edit_part_drag_step_x_get(ed, part);
846 count = edje_edit_part_drag_count_x_get(ed, part);
847 if (machine) printf("DRAG-X: %d %d %d\n", dir, step, count);
848 else printf(INDENT4 "x: %d %d %d;\n", dir, step, count);
849
850 dir = edje_edit_part_drag_y_get(ed, part);
851 step = edje_edit_part_drag_step_y_get(ed, part);
852 count = edje_edit_part_drag_count_y_get(ed, part);
853 if (machine) printf("DRAG-Y: %d %d %d\n", dir, step, count);
854 else printf(INDENT4 "y: %d %d %d;\n", dir, step, count);
855
856 str = edje_edit_part_drag_confine_get(ed, part);
857 if (machine) printf("DRAG-CONFINE: %s\n", str ? str : "");
858 else if (str) printf(INDENT4 "confine: \"%s\";\n", str);
859 edje_edit_string_free(str);
860
861 str = edje_edit_part_drag_event_get(ed, part);
862 if (machine) printf("DRAG-EVENTS: %s\n", str ? str : "");
863 else if (str) printf(INDENT4 "events: \"%s\";\n", str);
864 edje_edit_string_free(str);
865
866 if (machine) puts("DRAGABLE-END");
867 else puts(INDENT3 "}");
868 }
869 }
870
871 states = edje_edit_part_states_list_get(ed, part);
872 EINA_LIST_FOREACH(states, l, str)
873 {
874 char state[512], *delim;
875 double value;
876 eina_strlcpy(state, str, sizeof(state)); /* bad states_list! :-( */
877 delim = strchr(state, ' ');
878 *delim = '\0';
879 delim++;
880 value = strtod(delim, NULL);
881 state_begin(state, value);
882 state_details(ed, part, state, value);
883 state_end();
884 }
885 edje_edit_string_list_free(states);
886
887 if (machine) puts("PART-DETAILS-END");
888}
889
890static void
891part_end(void)
892{
893 if (machine) puts("PART-END");
894 else if (detail > 0) puts(INDENT2 "}");
895 else puts(" }");
896}
897
898static int
899_groups_names_list(void)
900{
901 Eina_List *l;
902 const char *name;
903 Eina_Bool found = EINA_FALSE;
904
905 EINA_LIST_FOREACH(groups, l, name)
906 {
907 if (!matches(name, group))
908 {
909 DBG("filter out group '%s': does not match '%s'", name, group);
910 continue;
911 }
912 found = EINA_TRUE;
913 puts(name);
914 }
915
916 if (!found) WRN("no groups match '%s'", group);
917 return !found;
918}
919
920static int
921_parts_names_list(void)
922{
923 Eina_List *gl, *pl, *parts;
924 const char *gname, *pname;
925 Eina_Bool found_group = EINA_FALSE, found_part = EINA_FALSE;
926
927 EINA_LIST_FOREACH(groups, gl, gname)
928 {
929 Evas_Object *ed;
930
931 if (!matches(gname, group))
932 {
933 DBG("filter out group '%s': does not match '%s'", gname, group);
934 continue;
935 }
936
937 ed = edje_edit_object_add(ecore_evas_get(ee));
938 if (!edje_object_file_set(ed, file, gname))
939 {
940 Edje_Load_Error err = edje_object_load_error_get(ed);
941 const char *errmsg = edje_load_error_str(err);
942 ERR("could not load group '%s' from file '%s': %s",
943 gname, file, errmsg);
944 evas_object_del(ed);
945 continue;
946 }
947
948 found_group = EINA_TRUE;
949 group_begin(gname);
950
951 parts = edje_edit_parts_list_get(ed);
952 EINA_LIST_FOREACH(parts, pl, pname)
953 {
954 if (!matches(pname, part))
955 {
956 DBG("filter out part '%s': does not match '%s'", pname, part);
957 continue;
958 }
959 if (api_only)
960 {
961 if (!edje_edit_part_api_name_get(ed, pname))
962 {
963 DBG("filter out part '%s': not API.", pname);
964 continue;
965 }
966 }
967 if (machine) printf("PART: %s\n", pname);
968 else printf(INDENT "part: %s\n", pname);
969 }
970 edje_edit_string_list_free(parts);
971
972 group_end();
973 evas_object_del(ed);
974 }
975
976 if (!found_group) WRN("no groups match '%s'", group);
977 if (!found_part) WRN("no parts match '%s'", part);
978 return (!found_group) || (!found_part);
979}
980
981static Eina_Bool
982_group_parts_list(Evas_Object *ed)
983{
984 Eina_Bool found = EINA_FALSE;
985 Eina_List *parts, *l;
986 const char *name;
987
988 parts_begin();
989
990 parts = edje_edit_parts_list_get(ed);
991 EINA_LIST_FOREACH(parts, l, name)
992 {
993 if (!matches(name, part))
994 {
995 DBG("filter out part '%s': does not match '%s'", name, part);
996 continue;
997 }
998 if (api_only)
999 {
1000 if (!edje_edit_part_api_name_get(ed, name))
1001 {
1002 DBG("filter out part '%s': not API.", name);
1003 continue;
1004 }
1005 }
1006
1007 found = EINA_TRUE;
1008 part_begin(ed, name);
1009 part_details(ed, name);
1010 part_end();
1011 }
1012
1013 parts_end();
1014 return found;
1015}
1016
1017static void
1018programs_begin(void)
1019{
1020 if (machine) puts("PROGRAMS-BEGIN");
1021 else puts(INDENT "programs {");
1022}
1023
1024static void
1025programs_end(void)
1026{
1027 if (machine) puts("PROGRAMS-END");
1028 else puts(INDENT "}");
1029}
1030
1031static void
1032program_begin(const char *name)
1033{
1034 if (machine) printf("PROGRAM-BEGIN\nNAME: %s\n", name ? name : "");
1035 else
1036 {
1037 printf(INDENT2 "program { name: '%s';\n", name ? name : "");
1038 }
1039}
1040
1041static void
1042program_end(void)
1043{
1044 if (machine) puts("PROGRAM-END");
1045 else puts(INDENT2 "}");
1046}
1047
1048
1049static char *
1050_program_api_name_get(Evas_Object *ed, const char *program)
1051{
1052 const char *orig = edje_edit_program_api_name_get(ed, program);
1053 char *fix = _api_name_fix(orig);
1054 edje_edit_string_free(orig);
1055 return fix;
1056}
1057
1058static const char *
1059_transition_name_get(Edje_Tween_Mode mode)
1060{
1061 switch (mode)
1062 {
1063 case EDJE_TWEEN_MODE_LINEAR: return "LINEAR";
1064 case EDJE_TWEEN_MODE_ACCELERATE: return "ACCELERATE";
1065 case EDJE_TWEEN_MODE_DECELERATE: return "DECELERATE";
1066 case EDJE_TWEEN_MODE_SINUSOIDAL: return "SINUSOIDAL";
1067 default:
1068 ERR("Unknown transition mode %d", mode);
1069 return "???";
1070 }
1071}
1072
1073static void
1074program_details(Evas_Object *ed, const char *program)
1075{
1076 const char *str, *str2;
1077 char *api;
1078
1079 if (detail < 1) return;
1080
1081 if (machine) puts("PROGRAM-DETAILS-BEGIN");
1082
1083 str = api =_program_api_name_get(ed, program);
1084 str2 = edje_edit_program_api_description_get(ed, program);
1085 if (machine)
1086 {
1087 printf("API-NAME: %s\n", str ? str : "");
1088 printf("API-DESCRIPTION: %s\n", str2 ? str2 : "");
1089 }
1090 else if ((str) || (str2))
1091 printf(INDENT3 "api: \"%s\" \"%s\";\n", str ? str : "", str2 ? str2 : "");
1092 free(api);
1093 edje_edit_string_free(str2);
1094
1095 str = edje_edit_program_signal_get(ed, program);
1096 if (machine) printf("SIGNAL: %s\n", str ? str : "");
1097 else if (str) printf(INDENT3 "signal: \"%s\";\n", str);
1098 edje_edit_string_free(str);
1099
1100 str = edje_edit_program_source_get(ed, program);
1101 if (machine) printf("SOURCE: %s\n", str ? str : "");
1102 else if (str) printf(INDENT3 "source: \"%s\";\n", str);
1103 edje_edit_string_free(str);
1104
1105 if (detail >= 1)
1106 {
1107 Eina_List *lst, *l;
1108 Edje_Action_Type type = edje_edit_program_action_get(ed, program);
1109 switch (type)
1110 {
1111 case EDJE_ACTION_TYPE_ACTION_STOP:
1112 if (machine) puts("ACTION: ACTION_STOP");
1113 else puts(INDENT3 "action: ACTION_STOP;");
1114 break;
1115 case EDJE_ACTION_TYPE_STATE_SET:
1116 str = edje_edit_program_state_get(ed, program);
1117 if (machine)
1118 printf("ACTION: STATE_SET\nACTION-STATE: %s %g\n",
1119 str, edje_edit_program_value_get(ed, program));
1120 else
1121 printf(INDENT3 "action: STATE_SET \"%s\" %2.1f;\n",
1122 str, edje_edit_program_value_get(ed, program));
1123 edje_edit_string_free(str);
1124 break;
1125 case EDJE_ACTION_TYPE_SIGNAL_EMIT:
1126 str = edje_edit_program_state_get(ed, program);
1127 str2 = edje_edit_program_state2_get(ed, program);
1128 if (machine)
1129 printf("ACTION: SIGNAL_EMIT\nACTION-SIGNAL: %s\n"
1130 "ACTION-SOURCE: %s\n",
1131 str ? str : "", str2 ? str2 : "");
1132 else if ((str) || (str2))
1133 printf(INDENT3 "action: SIGNAL_EMIT \"%s\" \"%s\";\n",
1134 str ? str : "", str2 ? str2 : "");
1135 edje_edit_string_free(str);
1136 edje_edit_string_free(str2);
1137 break;
1138 //TODO Support Drag
1139 //~ case EDJE_ACTION_TYPE_DRAG_VAL_SET:
1140 //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_SET TODO;\n");
1141 //~ break;
1142 //~ case EDJE_ACTION_TYPE_DRAG_VAL_STEP:
1143 //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_STEP TODO;\n");
1144 //~ break;
1145 //~ case EDJE_ACTION_TYPE_DRAG_VAL_PAGE:
1146 //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_PAGE TODO;\n");
1147 //~ break;
1148 default:
1149 ERR("Unhandled program action type %d", type);
1150 break;
1151 }
1152
1153 if (detail > 1)
1154 {
1155 double from, range;
1156
1157 from = edje_edit_program_transition_time_get(ed, program);
1158 if (from > 0.0)
1159 {
1160 str = _transition_name_get
1161 (edje_edit_program_transition_get(ed, program));
1162 if (machine)
1163 printf("TRANSITION-NAME: %s\nTRANSITION-DURATION: %g\n",
1164 str, from);
1165 else printf(INDENT3 "transition: %s %g;\n", str, from);
1166 /* do not free str! */
1167 }
1168
1169 from = edje_edit_program_in_from_get(ed, program);
1170 range = edje_edit_program_in_range_get(ed, program);
1171 if (FDIFF(from, 0.0) || FDIFF(range, 0.0))
1172 {
1173 if (machine)
1174 printf("IN-FROM: %g\nIN-RANGE: %g\n", from, range);
1175 else printf(INDENT3 "in: %g %g;\n", from, range);
1176 }
1177 }
1178
1179 lst = edje_edit_program_targets_get(ed, program);
1180 EINA_LIST_FOREACH(lst, l, str)
1181 if (machine) printf("TARGET: %s\n", str);
1182 else printf(INDENT3 "target: \"%s\";\n", str);
1183 edje_edit_string_list_free(lst);
1184
1185 lst = edje_edit_program_afters_get(ed, program);
1186 EINA_LIST_FOREACH(lst, l, str)
1187 if (machine) printf("AFTER: %s\n", str);
1188 else printf(INDENT3 "after: \"%s\";\n", str);
1189 edje_edit_string_list_free(lst);
1190
1191 // TODO Support script {}
1192 }
1193
1194 if (machine) puts("PROGRAM-DETAILS-END");
1195}
1196
1197static Eina_Bool
1198_group_programs_list(Evas_Object *ed)
1199{
1200 Eina_Bool found = EINA_FALSE;
1201 Eina_List *programs, *l;
1202 const char *name;
1203
1204 programs_begin();
1205
1206 /* TODO: change programs to operate on their ID instead of names!
1207 * needs huge change in Edje_Edit.h
1208 */
1209 WRN("listing only programs with names!");
1210 programs = edje_edit_programs_list_get(ed);
1211 EINA_LIST_FOREACH(programs, l, name)
1212 {
1213 if (!matches(name, program))
1214 {
1215 DBG("filter out program '%s': does not match '%s'", name, program);
1216 continue;
1217 }
1218 if (api_only)
1219 {
1220 if (!edje_edit_program_api_name_get(ed, name))
1221 {
1222 DBG("filter out program '%s': not API.", name);
1223 continue;
1224 }
1225 }
1226
1227 found = EINA_TRUE;
1228 program_begin(name);
1229 program_details(ed, name);
1230 program_end();
1231 }
1232
1233 programs_end();
1234 return found;
1235}
1236
1237static int
1238_list(const char *mode)
1239{
1240 Eina_List *l;
1241 const char *name;
1242 int ret = 0;
1243 Eina_Bool found_group = EINA_FALSE;
1244 Eina_Bool req_part, found_part, req_prog, found_prog;
1245
1246 if ((!strcmp(mode, "parts")) || (!strcmp(mode, "groups")))
1247 {
1248 req_part = EINA_TRUE;
1249 found_part = EINA_FALSE;
1250 }
1251 else
1252 {
1253 req_part = EINA_FALSE;
1254 found_part = EINA_TRUE;
1255 }
1256
1257 if ((!strcmp(mode, "programs")) || (!strcmp(mode, "groups")))
1258 {
1259 req_prog = EINA_TRUE;
1260 found_prog = EINA_FALSE;
1261 }
1262 else
1263 {
1264 req_prog = EINA_FALSE;
1265 found_prog = EINA_TRUE;
1266 }
1267
1268 EINA_LIST_FOREACH(groups, l, name)
1269 {
1270 Evas_Object *ed;
1271
1272 if (!matches(name, group))
1273 {
1274 DBG("filter out group '%s': does not match '%s'", name, group);
1275 continue;
1276 }
1277
1278 ed = edje_edit_object_add(ecore_evas_get(ee));
1279 if (!edje_object_file_set(ed, file, name))
1280 {
1281 Edje_Load_Error err = edje_object_load_error_get(ed);
1282 const char *errmsg = edje_load_error_str(err);
1283 ERR("could not load group '%s' from file '%s': %s",
1284 name, file, errmsg);
1285 evas_object_del(ed);
1286 continue;
1287 }
1288
1289 found_group = EINA_TRUE;
1290 group_begin(name);
1291 group_details(ed);
1292
1293 if (req_part) found_part |= _group_parts_list(ed);
1294 if (req_prog) found_prog |= _group_programs_list(ed);
1295
1296 group_end();
1297 evas_object_del(ed);
1298 }
1299
1300 /* no hard requirement for parts or programs for group listing */
1301 if (!strcmp(mode, "groups")) req_part = req_prog = EINA_FALSE;
1302
1303 if (!found_group)
1304 {
1305 WRN("no groups match '%s'", group);
1306 ret = 1;
1307 }
1308 if ((req_part) && (!found_part))
1309 {
1310 WRN("no parts match '%s'", part);
1311 ret = 1;
1312 }
1313 if ((req_prog) && (!found_prog))
1314 {
1315 WRN("no programs match '%s'", program);
1316 ret = 1;
1317 }
1318 return ret;
1319}
1320
1321static Evas_Object *
1322_edje_object_any_get(void)
1323{
1324 Evas_Object *ed = edje_edit_object_add(ecore_evas_get(ee));
1325 Eina_List *l;
1326 const char *name;
1327 if (!ed) return NULL;
1328 EINA_LIST_FOREACH(groups, l, name)
1329 if (edje_object_file_set(ed, file, name)) return ed;
1330 evas_object_del(ed);
1331 return NULL;
1332}
1333
1334static Eina_Bool
1335_gdata_list(void)
1336{
1337 Evas_Object *ed = _edje_object_any_get();
1338 Eina_List *l, *data;
1339 const char *key;
1340
1341 if (!ed) return EINA_FALSE;
1342
1343 data = edje_edit_data_list_get(ed);
1344
1345 if (machine) puts("DATA-BEGIN");
1346 else puts("data {");
1347
1348 EINA_LIST_FOREACH(data, l, key)
1349 {
1350 const char *value = edje_edit_data_value_get(ed, key);
1351 if (machine) printf("ITEM: \"%s\" \"%s\"\n", key, value);
1352 else printf(INDENT "item: \"%s\" \"%s\";\n", key, value);
1353 }
1354
1355 if (machine) puts("DATA-END");
1356 else puts("}");
1357
1358 edje_edit_string_list_free(data);
1359 evas_object_del(ed);
1360 return EINA_TRUE;
1361}
1362
1363static const char *
1364_comp_str_get(Evas_Object *ed, const char *img)
1365{
1366 static char buf[128];
1367 Edje_Edit_Image_Comp type = edje_edit_image_compression_type_get(ed, img);
1368 int rate;
1369
1370 switch (type)
1371 {
1372 case EDJE_EDIT_IMAGE_COMP_RAW:
1373 return "RAW";
1374 case EDJE_EDIT_IMAGE_COMP_USER:
1375 return "USER";
1376 case EDJE_EDIT_IMAGE_COMP_COMP:
1377 return "COMP";
1378 case EDJE_EDIT_IMAGE_COMP_LOSSY:
1379 rate = edje_edit_image_compression_rate_get(ed, img);
1380 snprintf(buf, sizeof(buf), "LOSSY %d", rate);
1381 return buf;
1382 default:
1383 ERR("Unknown compression type %d", type);
1384 return "???";
1385 }
1386}
1387
1388static Eina_Bool
1389_images_list(void)
1390{
1391 Evas_Object *ed = _edje_object_any_get();
1392 Eina_List *l, *images;
1393 const char *img;
1394
1395 if (!ed) return EINA_FALSE;
1396
1397 images = edje_edit_images_list_get(ed);
1398
1399 if (machine) puts("IMAGES-BEGIN");
1400 else puts("images {");
1401
1402 EINA_LIST_FOREACH(images, l, img)
1403 {
1404 int id = edje_edit_image_id_get(ed, img);
1405 const char *comp = _comp_str_get(ed, img);
1406
1407 if (detail < 1)
1408 {
1409 if (machine) printf("IMAGE: %s\n", img);
1410 else printf(INDENT "image: \"%s\" %s;\n", img, comp);
1411 }
1412 else if (detail == 1)
1413 {
1414 if (machine) printf("IMAGE: \"%s\" \"%s\"\n", img, comp);
1415 else printf(INDENT "image: \"%s\" %s;\n", img, comp);
1416 }
1417 else
1418 {
1419 if (machine)
1420 printf("IMAGE: \"edje/images/%d\" \"%s\" \"%s\"\n",
1421 id, img, comp);
1422 else
1423 printf(INDENT "image: \"%s\" %s; /* id: \"edje/images/%d\" */\n",
1424 img, comp, id);
1425 }
1426 }
1427
1428 if (machine) puts("IMAGES-END");
1429 else puts("}");
1430
1431 edje_edit_string_list_free(images);
1432 evas_object_del(ed);
1433 return EINA_TRUE;
1434}
1435
1436static Eina_Bool
1437_fonts_list(void)
1438{
1439 Evas_Object *ed = _edje_object_any_get();
1440 Eina_List *l, *fonts;
1441 const char *alias;
1442
1443 if (!ed) return EINA_FALSE;
1444
1445 fonts = edje_edit_fonts_list_get(ed);
1446
1447 if (machine) puts("FONTS-BEGIN");
1448 else puts("fonts {");
1449
1450 EINA_LIST_FOREACH(fonts, l, alias)
1451 {
1452 const char *path = edje_edit_font_path_get(ed, alias);
1453
1454 if (detail < 1)
1455 {
1456 if (machine) printf("FONT: %s\n", alias);
1457 else printf(INDENT "font: \"%s\" \"%s\";\n", path, alias);
1458 }
1459 else if (detail == 1)
1460 {
1461 if (machine) printf("FONT: \"%s\" \"%s\"\n", path, alias);
1462 else printf(INDENT "font: \"%s\" \"%s\";\n", path, alias);
1463 }
1464 else
1465 {
1466 if (machine)
1467 printf("FONT: \"edje/fonts/%s\" \"%s\" \"%s\"\n",
1468 alias, path, alias);
1469 else
1470 printf(INDENT
1471 "font: \"%s\" \"%s\"; /* id: \"edje/fonts/%s\" */\n",
1472 path, alias, alias);
1473 }
1474
1475 edje_edit_string_free(path);
1476 }
1477
1478 if (machine) puts("FONTS-END");
1479 else puts("}");
1480
1481 edje_edit_string_list_free(fonts);
1482 evas_object_del(ed);
1483 return EINA_TRUE;
1484}
1485
1486static Eina_Bool
1487_externals_list(void)
1488{
1489 Evas_Object *ed = _edje_object_any_get();
1490 Eina_List *l, *externals;
1491 const char *key;
1492
1493 if (!ed) return EINA_FALSE;
1494
1495 externals = edje_edit_externals_list_get(ed);
1496
1497 if (machine) puts("EXTERNALS-BEGIN");
1498 else puts("externals {");
1499
1500 EINA_LIST_FOREACH(externals, l, key)
1501 {
1502 if (machine) printf("EXTERNAL: %s\n", key);
1503 else printf(INDENT "external: \"%s\";\n", key);
1504 }
1505
1506 if (machine) puts("EXTERNALS-END");
1507 else puts("}");
1508
1509 edje_edit_string_list_free(externals);
1510 evas_object_del(ed);
1511 return EINA_TRUE;
1512}
1513
1514
1515int
1516main(int argc, char **argv)
1517{
1518 Eina_Bool quit_option = EINA_FALSE;
1519 char *mode = NULL;
1520 char *detail_name = NULL;
1521 int arg_index;
1522 int ret = 0;
1523 Ecore_Getopt_Value values[] = {
1524 ECORE_GETOPT_VALUE_STR(mode),
1525 ECORE_GETOPT_VALUE_STR(detail_name),
1526 ECORE_GETOPT_VALUE_STR(group),
1527 ECORE_GETOPT_VALUE_STR(part),
1528 ECORE_GETOPT_VALUE_STR(program),
1529 ECORE_GETOPT_VALUE_BOOL(api_only),
1530 ECORE_GETOPT_VALUE_BOOL(api_fix),
1531 ECORE_GETOPT_VALUE_BOOL(machine),
1532 ECORE_GETOPT_VALUE_BOOL(quit_option),
1533 ECORE_GETOPT_VALUE_BOOL(quit_option),
1534 ECORE_GETOPT_VALUE_BOOL(quit_option),
1535 ECORE_GETOPT_VALUE_BOOL(quit_option),
1536 ECORE_GETOPT_VALUE_NONE
1537 };
1538
1539 setlocale(LC_NUMERIC, "C");
1540
1541 ecore_init();
1542 ecore_evas_init();
1543 eina_init();
1544 edje_init();
1545
1546 _log_dom = eina_log_domain_register("edje_inspector", EINA_COLOR_YELLOW);
1547 if (_log_dom < 0)
1548 {
1549 EINA_LOG_CRIT("could not register log domain 'edje_inspector'");
1550 ret = 1;
1551 goto error_log;
1552 }
1553
1554 arg_index = ecore_getopt_parse(&optdesc, values, argc, argv);
1555 if (arg_index < 0)
1556 {
1557 ERR("could not parse arguments.");
1558 ret = 1;
1559 goto error_getopt;
1560 }
1561 else if (quit_option) goto error_getopt;
1562 else if (arg_index != argc - 1)
1563 {
1564 ERR("incorrect number of parameters. Requires one single file.");
1565 ret = 1;
1566 goto error_getopt;
1567 }
1568
1569 if (!mode) mode = (char *)mode_choices[0];
1570
1571 if (detail_name)
1572 {
1573 if (!strcmp(detail_name, "none")) detail = 0;
1574 else if (!strcmp(detail_name, "terse")) detail = 1;
1575 else if (!strcmp(detail_name, "all")) detail = 2;
1576 else ERR("Unknown detail level: '%s'", detail_name);
1577 }
1578
1579 file = argv[arg_index];
1580
1581 // check if the file is accessible
1582 if (access(file, R_OK) == -1)
1583 {
1584 int e = errno;
1585 ERR("File '%s' not accessible, error %d (%s).\n",
1586 file, e, strerror(e));
1587 ret = 1;
1588 goto error_getopt;
1589 }
1590
1591 DBG("mode=%s, detail=%d(%s), group=%s, part=%s, program=%s, api-only=" FMT_UCHAR
1592 ", api-fix=" FMT_UCHAR ", machine=" FMT_UCHAR ", file=%s",
1593 mode, detail, detail_name,
1594 group ? group : "",
1595 part ? part : "",
1596 program ? program : "",
1597 api_only, api_fix, machine, file);
1598
1599
1600 groups = edje_file_collection_list(file);
1601 if (!groups)
1602 {
1603 ERR("no groups in edje file '%s'", file);
1604 ret = 1;
1605 goto error_getopt;
1606 }
1607
1608 if (!strcmp(mode, "groups-names")) ret = _groups_names_list();
1609 else
1610 {
1611 ee = ecore_evas_buffer_new(1, 1);
1612 if (!ee)
1613 {
1614 ERR("could not create ecore_evas_buffer");
1615 ret = 1;
1616 }
1617 else
1618 {
1619 if (!strcmp(mode, "parts-names")) ret = _parts_names_list();
1620 else if (!strcmp(mode, "global-data")) ret = _gdata_list();
1621 else if (!strcmp(mode, "images")) ret = _images_list();
1622 else if (!strcmp(mode, "fonts")) ret = _fonts_list();
1623 else if (!strcmp(mode, "externals")) ret = _externals_list();
1624 else ret = _list(mode);
1625 ecore_evas_free(ee);
1626 }
1627 }
1628
1629 edje_file_collection_list_free(groups);
1630 error_getopt:
1631 eina_log_domain_unregister(_log_dom);
1632 error_log:
1633 edje_shutdown();
1634 ecore_evas_shutdown();
1635 ecore_shutdown();
1636 eina_shutdown();
1637
1638 return ret;
1639}
diff --git a/libraries/edje/src/bin/edje_multisense_convert.c b/libraries/edje/src/bin/edje_multisense_convert.c
new file mode 100644
index 0000000..d37d218
--- /dev/null
+++ b/libraries/edje/src/bin/edje_multisense_convert.c
@@ -0,0 +1,329 @@
1#include "edje_multisense_convert.h"
2
3#ifdef HAVE_LIBSNDFILE
4# define READBUF 1024
5# ifdef HAVE_VORBIS
6# include <vorbis/vorbisenc.h>
7# endif
8
9# ifdef HAVE_LIBFLAC
10# include <FLAC/metadata.h>
11# include <FLAC/stream_encoder.h>
12# endif
13
14Edje_Sound_Encode *
15_edje_multisense_encode(const char *filename, Edje_Sound_Sample *sample, double quality)
16{
17 SF_INFO sfinfo;
18 SNDFILE* sfile;
19 Edje_Sound_Encode *enc_info;
20
21 enc_info = calloc(1, sizeof(Edje_Sound_Encode));
22 if (!enc_info)
23 {
24 ERR("Error. while allocating memory to load file ");
25 exit(-1);
26 }
27 memset (&sfinfo, 0, sizeof (SF_INFO));
28
29 enc_info->encoded = EINA_FALSE;
30 enc_info->comp_type = "RAW PCM";
31
32 // Open wav file using sndfile
33 sfile = sf_open (filename, SFM_READ, &sfinfo);
34 if (!sfile)
35 {
36 ERR("Error. Unable to open audio file : %s", filename);
37 exit(-1);
38 }
39
40 if (!sf_format_check(&sfinfo))
41 {
42 ERR("Error. Unknown file, not a valid audio file");
43 exit(-1);
44 }
45
46 if (sample->compression == EDJE_SOUND_SOURCE_TYPE_INLINE_COMP)
47 {
48 sf_close(sfile);
49#ifdef HAVE_LIBFLAC
50 //encode provided wav file to flac
51 enc_info->file = _edje_multisense_encode_to_flac((char *)filename, sfinfo);
52 if (enc_info->file)
53 {
54 enc_info->comp_type = "FLAC";
55 enc_info->encoded = EINA_TRUE;
56 }
57#else
58 WRN("WARNING: Unable to encode sound %s to FLAC compression",
59 sample->name);
60#endif
61 }
62 else if (sample->compression == EDJE_SOUND_SOURCE_TYPE_INLINE_LOSSY)
63 {
64 sf_close(sfile);
65#ifdef HAVE_VORBIS
66 //encode provided wav file to ogg-vorbis
67 enc_info->file = _edje_multisense_encode_to_ogg_vorbis((char *)filename,
68 quality, sfinfo);
69 if (enc_info->file)
70 {
71 enc_info->comp_type = "OGG-VORBIS";
72 enc_info->encoded = EINA_TRUE;
73 }
74#else
75 WRN("WARNING: Unable to encode sound %s to Ogg-Vorbis",
76 sample->name);
77#endif
78 }
79 else
80 eina_stringshare_replace(&enc_info->file, filename);
81 return enc_info;
82}
83
84#ifdef HAVE_LIBFLAC
85const char*
86_edje_multisense_encode_to_flac(char *snd_path, SF_INFO sfinfo)
87{
88 unsigned int total_samples = 0; /* can use a 32-bit number due to WAVE size limitations */
89 FLAC__bool ok = 1;
90 FLAC__StreamEncoder *encoder = 0;
91 FLAC__StreamEncoderInitStatus init_status;
92 FLAC__StreamMetadata *metadata[2];
93 FLAC__StreamMetadata_VorbisComment_Entry entry;
94 SNDFILE *sfile;
95 sf_count_t size;
96 char *tmp;
97
98 sfile = sf_open(snd_path, SFM_READ, &sfinfo);
99 if (!sfile) return NULL;
100 if (!sf_format_check(&sfinfo))
101 {
102 sf_close(sfile);
103 return NULL;
104 }
105 size = sf_seek(sfile, 0, SEEK_END);
106 sf_seek(sfile, 0, SEEK_SET);
107 tmp = malloc(strlen(snd_path) + 1 + 5);
108 if (!tmp)
109 {
110 sf_close(sfile);
111 return NULL;
112 }
113 strcpy(tmp, snd_path);
114 snd_path = tmp;
115 strcat(snd_path, ".flac");
116
117 total_samples = size;
118
119 /* allocate the encoder */
120 if ((encoder = FLAC__stream_encoder_new()) == NULL)
121 {
122 ERR("ERROR: Creating FLAC encoder\n");
123 free(snd_path);
124 sf_close(sfile);
125 return NULL;
126 }
127
128 /* Verify it's own encoded output. This will slow the encoding process. */
129 ok &= FLAC__stream_encoder_set_verify(encoder, 1);
130
131 //Levels range from 0 (fastest, least compression) to 8 (slowest, most compression).
132 //A value larger than 8 will be treated as 8.
133 //5 is used for good compression and moderate compression/decompression speed.
134 ok &= FLAC__stream_encoder_set_compression_level(encoder, 5);
135 ok &= FLAC__stream_encoder_set_channels(encoder, sfinfo.channels);
136 ok &= FLAC__stream_encoder_set_bits_per_sample(encoder, 16);
137 ok &= FLAC__stream_encoder_set_sample_rate(encoder, sfinfo.samplerate);
138 ok &= FLAC__stream_encoder_set_total_samples_estimate(encoder, total_samples);
139
140 /* now add some metadata; we'll add some tags and a padding block */
141 if (ok)
142 {
143 if ((metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) == NULL
144 || (metadata[1] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == NULL
145 || !FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "Encoder", "flac")
146 || !FLAC__metadata_object_vorbiscomment_append_comment(metadata[0], entry, 0))
147 {
148 ERR("ERROR: out of memory error or tag error\n");
149 ok = 0;
150 }
151 metadata[1]->length = 16; /* set the padding length */
152 ok = FLAC__stream_encoder_set_metadata(encoder, metadata, 2);
153 }
154
155 /* initialize encoder */
156 if (ok)
157 {
158 init_status = FLAC__stream_encoder_init_file(encoder, snd_path, NULL,
159 (void *)(long)(total_samples));
160 if (init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
161 {
162 ERR("ERROR: unable to initialize FLAC encoder: %s\n",
163 FLAC__StreamEncoderInitStatusString[init_status]);
164 ok = 0;
165 }
166 }
167
168 /* read blocks of samples from WAVE file and feed to encoder */
169 while (ok)
170 {
171 FLAC__int32 readbuffer[READBUF * 2];
172 sf_count_t count;
173 int i;
174
175 count = sf_readf_int(sfile, readbuffer, READBUF);
176 if (count <= 0) break;
177 for (i = 0; i < (count * sfinfo.channels); i++)
178 readbuffer[i] = readbuffer[i] >> 16;
179 ok = FLAC__stream_encoder_process_interleaved(encoder, readbuffer,
180 count);
181 }
182
183 FLAC__stream_encoder_finish(encoder);
184 /* now that encoding is finished, the metadata can be freed */
185 FLAC__metadata_object_delete(metadata[0]);
186 FLAC__metadata_object_delete(metadata[1]);
187
188 FLAC__stream_encoder_delete(encoder);
189 sf_close(sfile);
190 return (snd_path);
191}
192#endif
193
194#ifdef HAVE_VORBIS
195const char *
196_edje_multisense_encode_to_ogg_vorbis(char *snd_path, double quality, SF_INFO sfinfo)
197{
198 ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */
199 ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
200 ogg_packet op; /* one raw packet of data for decode */
201 vorbis_info vi; /* struct that stores all the static vorbis bitstream settings */
202 vorbis_comment vc; /* struct that stores all the user comments */
203 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
204 vorbis_block vb; /* local working space for packet->PCM decode */
205 int eos = 0, ret;
206 char *tmp;
207 SNDFILE *sfile;
208 FILE *fout;
209
210 sfile = sf_open(snd_path, SFM_READ, &sfinfo);
211 if (!sfile) return NULL;
212 if (!sf_format_check(&sfinfo))
213 {
214 sf_close(sfile);
215 return NULL;
216 }
217 tmp = malloc(strlen(snd_path) + 1 + 4);
218 if (!tmp)
219 {
220 sf_close(sfile);
221 return NULL;
222 }
223 strcpy(tmp, snd_path);
224 snd_path = tmp;
225 strcat(snd_path, ".ogg");
226 fout = fopen(snd_path, "wb");
227 if (!fout)
228 {
229 free(snd_path);
230 sf_close(sfile);
231 return NULL;
232 }
233
234 /********** Encode setup ************/
235 vorbis_info_init(&vi);
236 ret = vorbis_encode_init(&vi, sfinfo.channels, sfinfo.samplerate,
237 -1, (long)(quality * 1000), -1);
238 if (ret == OV_EFAULT) printf("OV_EFAULT\n");
239 if (ret == OV_EINVAL) printf("OV_EINVAL\n");
240 if (ret == OV_EIMPL) printf("OV_EIMPL\n");
241
242 if (ret)
243 {
244 fclose(fout);
245 free(snd_path);
246 sf_close(sfile);
247 return NULL;
248 }
249
250 /* add a comment */
251 vorbis_comment_init(&vc);
252 vorbis_comment_add_tag(&vc, "", "");
253
254 /* set up the analysis state and auxiliary encoding storage */
255 vorbis_analysis_init(&vd, &vi);
256 vorbis_block_init(&vd, &vb);
257
258 srand(time(NULL));
259 ogg_stream_init(&os, rand());
260
261 ogg_packet header;
262 ogg_packet header_comm;
263 ogg_packet header_code;
264
265 vorbis_analysis_headerout(&vd, &vc, &header, &header_comm, &header_code);
266 ogg_stream_packetin(&os, &header); /* automatically placed in its own page */
267 ogg_stream_packetin(&os, &header_comm);
268 ogg_stream_packetin(&os, &header_code);
269
270 while (!eos)
271 {
272 int result = ogg_stream_flush(&os, &og);
273 if (!result) break;
274 fwrite(og.header, 1, og.header_len, fout);
275 fwrite(og.body, 1, og.body_len, fout);
276 }
277
278 while (!eos)
279 {
280 int i, ch;
281 float readbuffer[READBUF * 2];
282 sf_count_t count;
283
284 count = sf_readf_float(sfile, readbuffer, READBUF);
285
286 if (!count)
287 vorbis_analysis_wrote(&vd, 0);
288 else
289 {
290 float **buffer = vorbis_analysis_buffer(&vd, count);
291
292 /* uninterleave samples */
293 for (i = 0; i < count; i++)
294 {
295 for (ch = 0; ch < sfinfo.channels; ch++)
296 buffer[ch][i]= readbuffer[(i * sfinfo.channels) + ch];
297 }
298 vorbis_analysis_wrote(&vd, i);
299 }
300 while (vorbis_analysis_blockout(&vd, &vb) == 1)
301 {
302 vorbis_analysis(&vb, NULL);
303 vorbis_bitrate_addblock(&vb);
304
305 while (vorbis_bitrate_flushpacket(&vd, &op))
306 {
307 ogg_stream_packetin(&os, &op);
308 while (!eos)
309 {
310 int result = ogg_stream_pageout(&os, &og);
311 if (!result) break;
312 fwrite(og.header, 1, og.header_len, fout);
313 fwrite(og.body, 1, og.body_len, fout);
314 if (ogg_page_eos(&og)) eos = 1;
315 }
316 }
317 }
318 }
319 ogg_stream_clear(&os);
320 vorbis_block_clear(&vb);
321 vorbis_dsp_clear(&vd);
322 vorbis_comment_clear(&vc);
323 vorbis_info_clear(&vi);
324 sf_close(sfile);
325 fclose (fout);
326 return snd_path;
327}
328#endif
329#endif
diff --git a/libraries/edje/src/bin/edje_multisense_convert.h b/libraries/edje/src/bin/edje_multisense_convert.h
new file mode 100644
index 0000000..05ee2f7
--- /dev/null
+++ b/libraries/edje/src/bin/edje_multisense_convert.h
@@ -0,0 +1,25 @@
1#ifndef EDJE_SND_CONVERT_H__
2# define EDJE_SND_CONVERT_H__
3#include "edje_private.h"
4
5#ifdef HAVE_LIBSNDFILE
6#include <sndfile.h>
7
8#define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK)
9#define SF_CODEC(x) ((x) & SF_FORMAT_SUBMASK)
10
11typedef struct _Edje_Sound_Encode Edje_Sound_Encode;
12
13struct _Edje_Sound_Encode /*Encoding information*/
14{
15 const char *file; /* the encode sound file path */
16 Eina_Bool encoded; /* True if encoding is successful else False */
17 char *comp_type; /* either LOSSLESS (FLAC) or LOSSY (Ogg/Vorbis) Compression */
18};
19
20Edje_Sound_Encode *_edje_multisense_encode(const char* filename, Edje_Sound_Sample *sample, double quality);
21const char *_edje_multisense_encode_to_flac(char *snd_path, SF_INFO sfinfo);
22const char *_edje_multisense_encode_to_ogg_vorbis(char *snd_path, double quality, SF_INFO sfinfo);
23
24#endif
25#endif
diff --git a/libraries/edje/src/bin/edje_player.c b/libraries/edje/src/bin/edje_player.c
new file mode 100644
index 0000000..4d0c0a3
--- /dev/null
+++ b/libraries/edje/src/bin/edje_player.c
@@ -0,0 +1,795 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <stdio.h>
6#include <string.h>
7#include <stdlib.h>
8#include <errno.h>
9#include <unistd.h>
10#include <fcntl.h>
11#include <ctype.h>
12
13#ifdef HAVE_EVIL
14# include <Evil.h>
15#endif
16
17#include <Evas.h>
18#include <Ecore.h>
19#include <Ecore_Getopt.h>
20#include <Ecore_Evas.h>
21#include <Edje.h>
22
23#ifdef _WIN32
24# define FMT_UCHAR "%c"
25#else
26# define FMT_UCHAR "%hhu"
27#endif
28
29struct opts {
30 char *file;
31 char *group;
32 Eina_Bool list_groups;
33 char *engine;
34 Eina_Rectangle size;
35 unsigned char color[3];
36 Eina_Bool borderless;
37 Eina_Bool sticky;
38 Eina_Bool shaped;
39 Eina_Bool alpha;
40 Eina_Bool print;
41 Eina_Bool slave_mode;
42 double scale;
43 char *title;
44};
45
46static Ecore_Evas *win;
47
48static void
49_win_title_set(const char *group, const char *file)
50{
51 char buf[1024];
52 snprintf(buf, sizeof(buf), "Edje_Player - %s of %s", group, file);
53 ecore_evas_title_set(win, buf);
54}
55
56static char *
57_slave_mode_tok(char **p_arg)
58{
59 char *s, *e;
60 Eina_Bool is_quoted;
61
62 if (!*p_arg) return NULL;
63
64 s = *p_arg;
65 while (isspace(*s))
66 s++;
67
68 if (*s == '\0')
69 {
70 *p_arg = NULL;
71 return NULL;
72 }
73 else if (*s == '"')
74 {
75 is_quoted = EINA_TRUE;
76 s++;
77 *p_arg = s;
78 }
79 else
80 {
81 is_quoted = EINA_FALSE;
82 *p_arg = s;
83 }
84
85 for (e = s; *e != '\0'; e++)
86 {
87 if ((!is_quoted) && (isspace(*e)))
88 break;
89 else if ((is_quoted) && (*e == '"'))
90 break;
91 }
92
93 if (*e == '\0') return NULL;
94
95 *e = '\0';
96 return e + 1;
97}
98
99static void
100_slave_mode_signal(Evas_Object *edje, char *args)
101{
102 char *emission, *source;
103
104 emission = args;
105 source = _slave_mode_tok(&emission);
106 _slave_mode_tok(&source);
107
108 if ((!emission) || (!source))
109 {
110 fputs("ERROR: Invalid command arguments.\n", stderr);
111 return;
112 }
113
114 edje_object_signal_emit(edje, emission, source);
115}
116
117static void
118_slave_mode_info(Evas_Object *edje, char *args)
119{
120 _slave_mode_tok(&args);
121
122 if (!args)
123 {
124 fputs("ERROR: Invalid command arguments.\n", stderr);
125 return;
126 }
127
128 if (!edje_object_part_exists(edje, args))
129 {
130 printf("INFO: \"%s\" does not exist.\n", args);
131 }
132 else
133 {
134 Evas_Coord x, y, w, h;
135 edje_object_part_geometry_get(edje, args, &x, &y, &w, &h);
136 printf("INFO: \"%s\" %d,%d,%d,%d\n", args, x, y, w, h);
137 }
138}
139
140static void
141_slave_mode_quit(Evas_Object *edje __UNUSED__, char *args __UNUSED__)
142{
143 puts("Bye!");
144 ecore_main_loop_quit();
145}
146
147static void
148_slave_mode_help(Evas_Object *edje __UNUSED__, char *args __UNUSED__)
149{
150 puts("Help:\n"
151 "One command per line, arguments separated by space. Strings may have "
152 "spaces if enclosed in quotes (\").\n"
153 "\n"
154 "\t<command> [arguments]\n"
155 "\n"
156 "Available commands:\n"
157 "\tsignal <emission> <source>\n"
158 "\t sends a signal to edje\n"
159 "\tinfo <part>\n"
160 "\t Print part geometry: <x>,<y>,<w>,<h>\n"
161 "\tquit\n"
162 "\t exit edje player.\n"
163 "\thelp\n"
164 "\t shows this message.\n");
165 /*
166 * Extension ideas (are they useful?):
167 * - message: send a message
168 * - data: show data value
169 * - color_class: set color class values (maybe also list?)
170 * - text_class: set text class values (maybe also list?)
171 * - play_set: change play state
172 * - animation_set: change animation state
173 */
174}
175
176struct slave_cmd
177{
178 const char *cmd;
179 void (*func)(Evas_Object *edje, char *args);
180} _slave_mode_commands[] = {
181 {"signal", _slave_mode_signal},
182 {"info", _slave_mode_info},
183 {"quit", _slave_mode_quit},
184 {"help", _slave_mode_help},
185 {NULL, NULL}
186};
187
188static Eina_Bool
189_slave_mode(void *data, Ecore_Fd_Handler *fd_handler)
190{
191 Evas_Object *edje = data;
192 char buf[1024], *p;
193 const struct slave_cmd *itr;
194 size_t len;
195
196 if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
197 {
198 fputs("ERROR: error on stdin! Exit.\n", stderr);
199 ecore_main_loop_quit();
200 return ECORE_CALLBACK_CANCEL;
201 }
202 if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
203 return ECORE_CALLBACK_RENEW;
204
205 if (!fgets(buf, sizeof(buf), stdin))
206 {
207 fputs("ERROR: end of stdin! Exit.\n", stderr);
208 ecore_main_loop_quit();
209 return ECORE_CALLBACK_CANCEL;
210 }
211
212 len = strlen(buf);
213 if (len < 1)
214 {
215 fputs("ERROR: no input! Try: help\n", stderr);
216 return ECORE_CALLBACK_RENEW;
217 }
218 if (buf[len - 1] == '\n')
219 {
220 len--;
221 buf[len] = '\0';
222 }
223
224 p = strchr(buf, ' ');
225 if (p)
226 {
227 *p = '\0';
228 p++;
229
230 while (isspace(*p))
231 p++;
232 if (*p == '\0')
233 p = NULL;
234
235 if (p)
236 {
237 char *q = p + strlen(p) - 1;
238 while (isspace(*q))
239 {
240 *q = '\0';
241 q--;
242 }
243 }
244 }
245
246 for (itr = _slave_mode_commands; itr->cmd; itr++)
247 {
248 if (strcmp(itr->cmd, buf) == 0)
249 {
250 itr->func(edje, p);
251 break;
252 }
253 }
254
255 return ECORE_CALLBACK_RENEW;
256}
257
258static void
259_print_signal(void *data __UNUSED__, Evas_Object *o __UNUSED__, const char *emission, const char *source)
260{
261 printf("SIGNAL: \"%s\" \"%s\"\n", emission, source);
262}
263
264static void
265_print_message(void *data __UNUSED__, Evas_Object *edje __UNUSED__, Edje_Message_Type type, int id, void *msg)
266{
267 const char *typestr;
268 char buf[64];
269
270 switch (type)
271 {
272 case EDJE_MESSAGE_NONE:
273 typestr = "NONE";
274 break;
275 case EDJE_MESSAGE_SIGNAL:
276 typestr = "SIGNAL";
277 break;
278 case EDJE_MESSAGE_STRING:
279 typestr = "STRING";
280 break;
281 case EDJE_MESSAGE_INT:
282 typestr = "INT";
283 break;
284 case EDJE_MESSAGE_FLOAT:
285 typestr = "FLOAT";
286 break;
287 case EDJE_MESSAGE_STRING_SET:
288 typestr = "STRING_SET";
289 break;
290 case EDJE_MESSAGE_INT_SET:
291 typestr = "INT_SET";
292 break;
293 case EDJE_MESSAGE_FLOAT_SET:
294 typestr = "FLOAT_SET";
295 break;
296 case EDJE_MESSAGE_STRING_INT:
297 typestr = "STRING_INT";
298 break;
299 case EDJE_MESSAGE_STRING_FLOAT:
300 typestr = "STRING_FLOAT";
301 break;
302 case EDJE_MESSAGE_STRING_INT_SET:
303 typestr = "INT_SET";
304 break;
305 case EDJE_MESSAGE_STRING_FLOAT_SET:
306 typestr = "FLOAT_SET";
307 break;
308 default:
309 snprintf(buf, sizeof(buf), "UNKNOWN(%d)", type);
310 typestr = buf;
311 }
312
313 printf("MESSAGE: type=%s, id=%d", typestr, id);
314
315 switch (type)
316 {
317 case EDJE_MESSAGE_NONE: break;
318 case EDJE_MESSAGE_SIGNAL: break;
319 case EDJE_MESSAGE_STRING:
320 {
321 Edje_Message_String *m = msg;
322 printf(" \"%s\"", m->str);
323 }
324 break;
325 case EDJE_MESSAGE_INT:
326 {
327 Edje_Message_Int *m = msg;
328 printf(" %d", m->val);
329 }
330 break;
331 case EDJE_MESSAGE_FLOAT:
332 {
333 Edje_Message_Float *m = msg;
334 printf(" %f", m->val);
335 }
336 break;
337 case EDJE_MESSAGE_STRING_SET:
338 {
339 Edje_Message_String_Set *m = msg;
340 int i;
341 for (i = 0; i < m->count; i++)
342 printf(" \"%s\"", m->str[i]);
343 }
344 break;
345 case EDJE_MESSAGE_INT_SET:
346 {
347 Edje_Message_Int_Set *m = msg;
348 int i;
349 for (i = 0; i < m->count; i++)
350 printf(" %d", m->val[i]);
351 }
352 break;
353 case EDJE_MESSAGE_FLOAT_SET:
354 {
355 Edje_Message_Float_Set *m = msg;
356 int i;
357 for (i = 0; i < m->count; i++)
358 printf(" %f", m->val[i]);
359 }
360 break;
361 case EDJE_MESSAGE_STRING_INT:
362 {
363 Edje_Message_String_Int *m = msg;
364 printf(" \"%s\" %d", m->str, m->val);
365 }
366 break;
367 case EDJE_MESSAGE_STRING_FLOAT:
368 {
369 Edje_Message_String_Float *m = msg;
370 printf(" \"%s\" %f", m->str, m->val);
371 }
372 break;
373 case EDJE_MESSAGE_STRING_INT_SET:
374 {
375 Edje_Message_String_Int_Set *m = msg;
376 int i;
377 printf(" \"%s\"", m->str);
378 for (i = 0; i < m->count; i++)
379 printf(" %d", m->val[i]);
380 }
381 break;
382 case EDJE_MESSAGE_STRING_FLOAT_SET:
383 {
384 Edje_Message_String_Float_Set *m = msg;
385 int i;
386 printf(" \"%s\"", m->str);
387 for (i = 0; i < m->count; i++)
388 printf(" %f", m->val[i]);
389 }
390 break;
391 default:
392 break;
393 }
394
395 putchar('\n');
396}
397
398static void
399_reset_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *stack, void *event_info __UNUSED__)
400{
401 Evas_Coord minw, minh;
402 Evas_Object *edje = data;
403
404 edje_object_size_min_get(edje, &minw, &minh);
405 if ((minw <= 0) && (minh <= 0))
406 edje_object_size_min_calc(edje, &minw, &minh);
407
408 evas_object_size_hint_min_set(stack, minw, minh);
409}
410
411static void
412_key_down(void *data, Evas *e __UNUSED__, Evas_Object *stack __UNUSED__, void *event_info)
413{
414 Evas_Event_Key_Down *ev = event_info;
415 struct opts *opts = data;
416
417 if ((!strcmp(ev->keyname, "equal")) ||
418 (!strcmp(ev->keyname, "plus")))
419 opts->scale += 0.1;
420 else if ((!strcmp(ev->keyname, "minus")) ||
421 (!strcmp(ev->keyname, "underscore")))
422 opts->scale -= 0.1;
423 else if ((!strcmp(ev->keyname, "0")))
424 opts->scale = 1.0;
425 if (opts->scale < 0.1) opts->scale = 0.1;
426 else if (opts->scale > 10.0) opts->scale = 1.0;
427 edje_scale_set(opts->scale);
428}
429
430static Evas_Object *
431_create_stack(Evas *evas, const struct opts *opts)
432{
433 Evas_Object *stack = evas_object_box_add(evas);
434 if (!stack)
435 {
436 fputs("ERROR: could not create object stack (box).\n", stderr);
437 return NULL;
438 }
439 evas_object_box_layout_set(stack, evas_object_box_layout_stack, NULL, NULL);
440 evas_object_resize(stack, opts->size.w, opts->size.h);
441 evas_object_size_hint_weight_set(stack, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
442 evas_object_size_hint_align_set(stack, EVAS_HINT_FILL, EVAS_HINT_FILL);
443 evas_object_show(stack);
444 return stack;
445}
446
447static Evas_Object *
448_create_bg(Evas *evas, const struct opts *opts)
449{
450 const unsigned char *color = opts->color;
451 Evas_Object *bg = evas_object_rectangle_add(evas);
452 if (!bg)
453 {
454 fputs("ERROR: could not create background.\n", stderr);
455 return NULL;
456 }
457 evas_object_resize(bg, opts->size.w, opts->size.h);
458 evas_object_color_set(bg, color[0], color[1], color[2], 255);
459 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
460 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
461 evas_object_show(bg);
462 return bg;
463}
464
465static Eina_Bool
466_edje_load_or_show_error(Evas_Object *edje, const char *file, const char *group)
467{
468 const char *errmsg;
469 int err;
470
471 if (edje_object_file_set(edje, file, group))
472 {
473 evas_object_focus_set(edje, EINA_TRUE);
474 return EINA_TRUE;
475 }
476
477 err = edje_object_load_error_get(edje);
478 errmsg = edje_load_error_str(err);
479 fprintf(stderr, "ERROR: could not load edje file '%s', group '%s': %s\n",
480 file, group, errmsg);
481 return EINA_FALSE;
482}
483
484static Evas_Object *
485_create_edje(Evas *evas, const struct opts *opts)
486{
487 Evas_Coord minw, minh, maxw, maxh;
488 Evas_Object *edje = edje_object_add(evas);
489 if (!edje)
490 {
491 fputs("ERROR: could not create edje.\n", stderr);
492 return NULL;
493 }
494
495 if (opts->group)
496 {
497 if (!_edje_load_or_show_error(edje, opts->file, opts->group))
498 {
499 evas_object_del(edje);
500 return NULL;
501 }
502 if (!opts->title) _win_title_set(opts->group, opts->file);
503 }
504 else
505 {
506 if (edje_file_group_exists(opts->file, "main"))
507 {
508 if (!_edje_load_or_show_error(edje, opts->file, "main"))
509 {
510 evas_object_del(edje);
511 return NULL;
512 }
513 if (!opts->title) _win_title_set("main", opts->file);
514 }
515 else
516 {
517 Eina_List *groups = edje_file_collection_list(opts->file);
518 const char *group;
519 if (!groups)
520 {
521 fprintf(stderr, "ERROR: file '%s' has no groups!\n",
522 opts->file);
523 evas_object_del(edje);
524 return NULL;
525 }
526 group = groups->data;
527 if (!_edje_load_or_show_error(edje, opts->file, group))
528 {
529 edje_file_collection_list_free(groups);
530 evas_object_del(edje);
531 return NULL;
532 }
533 if (!opts->title) _win_title_set(group, opts->file);
534 edje_file_collection_list_free(groups);
535 }
536 }
537
538 edje_object_size_max_get(edje, &maxw, &maxh);
539 edje_object_size_min_get(edje, &minw, &minh);
540 if ((minw <= 0) && (minh <= 0))
541 edje_object_size_min_calc(edje, &minw, &minh);
542
543 evas_object_size_hint_max_set(edje, maxw, maxh);
544 evas_object_size_hint_min_set(edje, minw, minh);
545
546 evas_object_size_hint_weight_set(edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
547 evas_object_size_hint_align_set(edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
548 evas_object_show(edje);
549
550 return edje;
551}
552
553static unsigned char _parse_color(__UNUSED__ const Ecore_Getopt *parser, __UNUSED__ const Ecore_Getopt_Desc *desc, const char *str, __UNUSED__ void *data, Ecore_Getopt_Value *storage)
554{
555 unsigned char *color = (unsigned char *)storage->ptrp;
556
557 if (sscanf(str, FMT_UCHAR "," FMT_UCHAR "," FMT_UCHAR, color, color + 1, color + 2) != 3)
558 {
559 fprintf(stderr, "ERROR: incorrect color value '%s'\n", str);
560 return 0;
561 }
562
563 return 1;
564}
565
566static void _cb_delete(__UNUSED__ Ecore_Evas *ee)
567{
568 ecore_main_loop_quit();
569}
570
571const Ecore_Getopt optdesc = {
572 "edje_player",
573 "%prog [options] <filename.edj>",
574 PACKAGE_VERSION,
575 "(C) 2010 Enlightenment",
576 "BSD with advertisement clause",
577 "Simple application to view edje files.",
578 0,
579 {
580 ECORE_GETOPT_STORE_STR
581 ('g', "group", "The edje group to view (defaults to 'main')."),
582 ECORE_GETOPT_STORE_TRUE
583 ('G', "list-groups", "The groups in the given file."),
584 ECORE_GETOPT_STORE_STR
585 ('e', "engine", "The Ecore-Evas engine to use (see --list-engines)"),
586 ECORE_GETOPT_CALLBACK_NOARGS
587 ('E', "list-engines", "list Ecore-Evas engines",
588 ecore_getopt_callback_ecore_evas_list_engines, NULL),
589 ECORE_GETOPT_CALLBACK_ARGS
590 ('Z', "size", "size to use in wxh form.", "WxH",
591 ecore_getopt_callback_size_parse, NULL),
592 ECORE_GETOPT_CALLBACK_ARGS
593 ('c', "bg-color", "Color of the background (if not shaped or alpha)",
594 "RRGGBB", _parse_color, NULL),
595 ECORE_GETOPT_STORE_TRUE
596 ('b', "borderless", "Display window without border."),
597 ECORE_GETOPT_STORE_TRUE
598 ('y', "sticky", "Display window sticky."),
599 ECORE_GETOPT_STORE_TRUE
600 ('s', "shaped", "Display window shaped."),
601 ECORE_GETOPT_STORE_TRUE
602 ('a', "alpha", "Display window with alpha channel "
603 "(needs composite manager!)"),
604 ECORE_GETOPT_STORE_STR
605 ('t', "title", "Define the window title string"),
606 ECORE_GETOPT_STORE_TRUE
607 ('p', "print", "Print signals and messages to stdout"),
608 ECORE_GETOPT_STORE_TRUE
609 ('S', "slave-mode", "Listen for commands on stdin"),
610 ECORE_GETOPT_STORE_DOUBLE
611 ('z', "scale", "Set scale factor"),
612 ECORE_GETOPT_LICENSE('L', "license"),
613 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
614 ECORE_GETOPT_VERSION('V', "version"),
615 ECORE_GETOPT_HELP('h', "help"),
616 ECORE_GETOPT_SENTINEL
617 }
618};
619
620int main(int argc, char **argv)
621{
622 Evas *evas;
623 Evas_Object *stack, *edje;
624 struct opts opts;
625 Eina_Bool quit_option = EINA_FALSE;
626 int args;
627 Ecore_Getopt_Value values[] = {
628 ECORE_GETOPT_VALUE_STR(opts.group),
629 ECORE_GETOPT_VALUE_BOOL(opts.list_groups),
630 ECORE_GETOPT_VALUE_STR(opts.engine),
631 ECORE_GETOPT_VALUE_BOOL(quit_option),
632 ECORE_GETOPT_VALUE_PTR_CAST(opts.size),
633 ECORE_GETOPT_VALUE_PTR_CAST(opts.color),
634 ECORE_GETOPT_VALUE_BOOL(opts.borderless),
635 ECORE_GETOPT_VALUE_BOOL(opts.sticky),
636 ECORE_GETOPT_VALUE_BOOL(opts.shaped),
637 ECORE_GETOPT_VALUE_BOOL(opts.alpha),
638 ECORE_GETOPT_VALUE_STR(opts.title),
639 ECORE_GETOPT_VALUE_BOOL(opts.print),
640 ECORE_GETOPT_VALUE_BOOL(opts.slave_mode),
641 ECORE_GETOPT_VALUE_DOUBLE(opts.scale),
642 ECORE_GETOPT_VALUE_BOOL(quit_option),
643 ECORE_GETOPT_VALUE_BOOL(quit_option),
644 ECORE_GETOPT_VALUE_BOOL(quit_option),
645 ECORE_GETOPT_VALUE_BOOL(quit_option),
646 ECORE_GETOPT_VALUE_NONE
647 };
648
649 memset(&opts, 0, sizeof(opts));
650 opts.scale = 1.0;
651
652 if (!ecore_evas_init())
653 return EXIT_FAILURE;
654 if (!edje_init())
655 goto shutdown_ecore_evas;
656 edje_frametime_set(1.0/60.0);
657
658 args = ecore_getopt_parse(&optdesc, values, argc, argv);
659 if (args < 0)
660 {
661 fputs("Could not parse arguments.\n", stderr);
662 goto shutdown_edje;
663 }
664 else if (quit_option)
665 {
666 goto end;
667 }
668 else if (args >= argc)
669 {
670 fputs("Missing edje file to load.\n", stderr);
671 goto shutdown_edje;
672 }
673
674 ecore_app_args_set(argc, (const char **)argv);
675 edje_scale_set(opts.scale);
676
677 // check if the given edj file is there
678 if (access(argv[args], R_OK) == -1)
679 {
680 int e = errno;
681 fprintf(stderr, "ERROR: file '%s' not accessible, error %d (%s).\n",
682 argv[args], e, strerror(e));
683 goto end;
684 }
685
686 opts.file = argv[args];
687 if (opts.list_groups)
688 {
689 Eina_List *groups, *n;
690 const char *group;
691 groups = edje_file_collection_list(opts.file);
692 printf("%d groups in file '%s':\n", eina_list_count(groups), opts.file);
693 EINA_LIST_FOREACH(groups, n, group)
694 printf("\t'%s'\n", group);
695 edje_file_collection_list_free(groups);
696 goto end;
697 }
698
699 win = ecore_evas_new(opts.engine, 0, 0, opts.size.w, opts.size.h, NULL);
700 if (!win)
701 {
702 fprintf(stderr,
703 "ERROR: could not create window of "
704 "size %dx%d using engine %s.\n",
705 opts.size.w, opts.size.h, opts.engine ? opts.engine : "(auto)");
706 goto shutdown_edje;
707 }
708
709 ecore_evas_callback_delete_request_set(win, _cb_delete);
710 evas = ecore_evas_get(win);
711 stack = _create_stack(evas, &opts);
712 if (!stack)
713 {
714 goto free_ecore_evas;
715 }
716
717 ecore_evas_object_associate(win, stack, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
718
719 if (opts.alpha)
720 ecore_evas_alpha_set(win, EINA_TRUE);
721 else if (opts.shaped)
722 ecore_evas_shaped_set(win, EINA_TRUE);
723 else
724 {
725 Evas_Object *bg = _create_bg(evas, &opts);
726 if (bg) evas_object_box_append(stack, bg);
727 }
728
729 edje = _create_edje(evas, &opts);
730 if (edje)
731 evas_object_box_append(stack, edje);
732 else
733 {
734 goto free_ecore_evas;
735 }
736
737 evas_object_focus_set(stack, EINA_TRUE);
738 evas_object_event_callback_add(stack, EVAS_CALLBACK_KEY_DOWN,
739 _key_down, &opts);
740 evas_object_event_callback_add(stack, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
741 _reset_size_hints, edje);
742
743 if (opts.print)
744 {
745 edje_object_signal_callback_add(edje, "*", "*", _print_signal, NULL);
746 edje_object_message_handler_set(edje, _print_message, NULL);
747 }
748
749 if (opts.slave_mode)
750 {
751#ifndef _WIN32
752 int flags;
753 flags = fcntl(STDIN_FILENO, F_GETFL, 0);
754 flags |= O_NONBLOCK;
755 if (fcntl(STDIN_FILENO, F_SETFL, flags) < 0)
756 {
757 fprintf(stderr, "ERROR: Could not set stdin to non-block: %s\n",
758 strerror(errno));
759 goto free_ecore_evas;
760 }
761 ecore_main_fd_handler_add(STDIN_FILENO, ECORE_FD_READ | ECORE_FD_ERROR,
762 _slave_mode, edje, NULL, NULL);
763#else
764 /* TODO: port the code above to Windows */
765 fprintf (stderr, "ERROR: slave mode not working on Windows\n");
766 goto free_ecore_evas;
767#endif
768 }
769
770 ecore_evas_borderless_set(win, opts.borderless);
771 ecore_evas_sticky_set(win, opts.sticky);
772 if (opts.title)
773 ecore_evas_title_set(win, opts.title);
774
775 if (opts.size.w <= 0) opts.size.w = 320;
776 if (opts.size.h <= 0) opts.size.h = 240;
777 ecore_evas_resize(win, opts.size.w, opts.size.h);
778 ecore_evas_show(win);
779 ecore_main_loop_begin();
780
781 ecore_evas_free(win);
782 end:
783 edje_shutdown();
784 ecore_evas_shutdown();
785
786 return 0;
787
788 free_ecore_evas:
789 ecore_evas_free(win);
790 shutdown_edje:
791 edje_shutdown();
792 shutdown_ecore_evas:
793 ecore_evas_shutdown();
794 return EXIT_FAILURE;
795}
diff --git a/libraries/edje/src/bin/edje_recc b/libraries/edje/src/bin/edje_recc
new file mode 100644
index 0000000..2ae81ad
--- /dev/null
+++ b/libraries/edje/src/bin/edje_recc
@@ -0,0 +1,69 @@
1#!/bin/sh
2
3set -e
4
5usage () {
6 echo "Usage:"
7 echo " edje_recc [OPTIONS] input_file.edj"
8 echo ""
9 echo "Where OPTIONS is one or more of:"
10 echo ""
11 echo "-v Verbose output"
12 echo "-no-lossy Do NOT allow images to be lossy"
13 echo "-no-comp Do NOT allow images to be lossless compression"
14 echo "-no-raw Do NOT allow images to be zero compression"
15 echo "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)"
16 echo "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)"
17 exit -1
18}
19
20if [ $# -lt 1 ]; then
21 usage
22fi
23
24OPT=""
25if [ $# -ge 1 ]; then
26 for I in $@; do
27 case "$I" in
28 -h)
29 usage
30 ;;
31
32 -help)
33 usage
34 ;;
35
36 --help)
37 usage
38 ;;
39
40 *.edj)
41 IN=$I
42 ;;
43
44 *)
45 OPT=$OPT" "$I
46 ;;
47 esac
48 done
49fi
50
51if [ -z "$IN" ]; then
52 echo "ERROR: NO input file.edj provided!"
53 echo ""
54 usage;
55fi
56
57F=`basename $IN`
58B=`basename $F .edj`
59T="./...edje_tmp"
60rm -rf $T
61mkdir -p $T
62cp $IN $T
63cd $T
64edje_decc $F
65cd $B
66./build.sh $OPT
67cd ../..
68mv $T/$B/$F $IN
69rm -rf $T
diff --git a/libraries/edje/src/bin/epp/Makefile.am b/libraries/edje/src/bin/epp/Makefile.am
new file mode 100644
index 0000000..6db5016
--- /dev/null
+++ b/libraries/edje/src/bin/epp/Makefile.am
@@ -0,0 +1,59 @@
1# Makefile for GNU C compiler.
2# Copyright (C) 1987, 88, 90-94, 1995 Free Software Foundation, Inc.
3
4#This file is part of GNU CC.
5
6#GNU CC is free software; you can redistribute it and/or modify
7#it under the terms of the GNU General Public License as published by
8#the Free Software Foundation; either version 2, or (at your option)
9#any later version.
10
11#GNU CC is distributed in the hope that it will be useful,
12#but WITHOUT ANY WARRANTY; without even the implied warranty of
13#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14#GNU General Public License for more details.
15
16#You should have received a copy of the GNU General Public License
17#along with GNU CC; see the file COPYING. If not, write to
18#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20MAINTAINERCLEANFILES = Makefile.in
21
22eppdir = @libdir@/@PACKAGE@/utils
23
24epp_PROGRAMS = epp
25
26epp_SOURCES = \
27cpplib.h \
28cpphash.h \
29cppalloc.c \
30cpperror.c \
31cppexp.c \
32cpphash.c \
33cpplib.c \
34cppmain.c
35
36epp_CPPFLAGS = \
37-I$(top_builddir) \
38$(CWARNFLAGS)
39
40DEFS= \
41-DHAVE_CONFIG_H \
42-DHAVE_STRERROR \
43-DFATAL_EXIT_CODE=1 \
44-DSUCCESS_EXIT_CODE=0 \
45-DGCC_INCLUDE_DIR=\"/usr/include\" \
46-DGPLUSPLUS_INCLUDE_DIR=\"/usr/include\" \
47-DTOOL_INCLUDE_DIR=\"/usr/bin\" \
48-DHOST_BITS_PER_LONG=32 \
49-DBITS_PER_UNIT=8 \
50-DHOST_BITS_PER_INT=32 \
51-DBITS_PER_WORD=16 \
52-DTARGET_BELL=7 \
53-DTARGET_BS=8 \
54-DTARGET_FF=12 \
55-DTARGET_NEWLINE=10 \
56-DTARGET_CR=13 \
57-DTARGET_TAB=9 \
58-DTARGET_VT=11
59
diff --git a/libraries/edje/src/bin/epp/Makefile.in b/libraries/edje/src/bin/epp/Makefile.in
new file mode 100644
index 0000000..2ef2e56
--- /dev/null
+++ b/libraries/edje/src/bin/epp/Makefile.in
@@ -0,0 +1,756 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18# Makefile for GNU C compiler.
19# Copyright (C) 1987, 88, 90-94, 1995 Free Software Foundation, Inc.
20
21#This file is part of GNU CC.
22
23#GNU CC is free software; you can redistribute it and/or modify
24#it under the terms of the GNU General Public License as published by
25#the Free Software Foundation; either version 2, or (at your option)
26#any later version.
27
28#GNU CC is distributed in the hope that it will be useful,
29#but WITHOUT ANY WARRANTY; without even the implied warranty of
30#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31#GNU General Public License for more details.
32
33#You should have received a copy of the GNU General Public License
34#along with GNU CC; see the file COPYING. If not, write to
35#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
36
37VPATH = @srcdir@
38pkgdatadir = $(datadir)/@PACKAGE@
39pkgincludedir = $(includedir)/@PACKAGE@
40pkglibdir = $(libdir)/@PACKAGE@
41pkglibexecdir = $(libexecdir)/@PACKAGE@
42am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
43install_sh_DATA = $(install_sh) -c -m 644
44install_sh_PROGRAM = $(install_sh) -c
45install_sh_SCRIPT = $(install_sh) -c
46INSTALL_HEADER = $(INSTALL_DATA)
47transform = $(program_transform_name)
48NORMAL_INSTALL = :
49PRE_INSTALL = :
50POST_INSTALL = :
51NORMAL_UNINSTALL = :
52PRE_UNINSTALL = :
53POST_UNINSTALL = :
54build_triplet = @build@
55host_triplet = @host@
56epp_PROGRAMS = epp$(EXEEXT)
57subdir = src/bin/epp
58DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
59ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
60am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
61 $(top_srcdir)/m4/efl_binary.m4 \
62 $(top_srcdir)/m4/efl_coverage.m4 \
63 $(top_srcdir)/m4/efl_doxygen.m4 \
64 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
65 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
66 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
67 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
68am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
69 $(ACLOCAL_M4)
70mkinstalldirs = $(install_sh) -d
71CONFIG_HEADER = $(top_builddir)/config.h
72CONFIG_CLEAN_FILES =
73CONFIG_CLEAN_VPATH_FILES =
74am__installdirs = "$(DESTDIR)$(eppdir)"
75PROGRAMS = $(epp_PROGRAMS)
76am_epp_OBJECTS = epp-cppalloc.$(OBJEXT) epp-cpperror.$(OBJEXT) \
77 epp-cppexp.$(OBJEXT) epp-cpphash.$(OBJEXT) \
78 epp-cpplib.$(OBJEXT) epp-cppmain.$(OBJEXT)
79epp_OBJECTS = $(am_epp_OBJECTS)
80epp_LDADD = $(LDADD)
81AM_V_lt = $(am__v_lt_$(V))
82am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
83am__v_lt_0 = --silent
84DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
85depcomp = $(SHELL) $(top_srcdir)/depcomp
86am__depfiles_maybe = depfiles
87am__mv = mv -f
88COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
89 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
90LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
91 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
92 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
93 $(AM_CFLAGS) $(CFLAGS)
94AM_V_CC = $(am__v_CC_$(V))
95am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
96am__v_CC_0 = @echo " CC " $@;
97AM_V_at = $(am__v_at_$(V))
98am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
99am__v_at_0 = @
100CCLD = $(CC)
101LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
102 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
103 $(AM_LDFLAGS) $(LDFLAGS) -o $@
104AM_V_CCLD = $(am__v_CCLD_$(V))
105am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
106am__v_CCLD_0 = @echo " CCLD " $@;
107AM_V_GEN = $(am__v_GEN_$(V))
108am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
109am__v_GEN_0 = @echo " GEN " $@;
110SOURCES = $(epp_SOURCES)
111DIST_SOURCES = $(epp_SOURCES)
112ETAGS = etags
113CTAGS = ctags
114DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
115ACLOCAL = @ACLOCAL@
116ALLOCA = @ALLOCA@
117ALSA_CFLAGS = @ALSA_CFLAGS@
118ALSA_LIBS = @ALSA_LIBS@
119AMTAR = @AMTAR@
120AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
121AR = @AR@
122AS = @AS@
123AUTOCONF = @AUTOCONF@
124AUTOHEADER = @AUTOHEADER@
125AUTOMAKE = @AUTOMAKE@
126AWK = @AWK@
127CC = @CC@
128CCDEPMODE = @CCDEPMODE@
129CFLAGS = @CFLAGS@
130CHECK_CFLAGS = @CHECK_CFLAGS@
131CHECK_LIBS = @CHECK_LIBS@
132CPP = @CPP@
133CPPFLAGS = @CPPFLAGS@
134CYGPATH_W = @CYGPATH_W@
135DEFS = \
136-DHAVE_CONFIG_H \
137-DHAVE_STRERROR \
138-DFATAL_EXIT_CODE=1 \
139-DSUCCESS_EXIT_CODE=0 \
140-DGCC_INCLUDE_DIR=\"/usr/include\" \
141-DGPLUSPLUS_INCLUDE_DIR=\"/usr/include\" \
142-DTOOL_INCLUDE_DIR=\"/usr/bin\" \
143-DHOST_BITS_PER_LONG=32 \
144-DBITS_PER_UNIT=8 \
145-DHOST_BITS_PER_INT=32 \
146-DBITS_PER_WORD=16 \
147-DTARGET_BELL=7 \
148-DTARGET_BS=8 \
149-DTARGET_FF=12 \
150-DTARGET_NEWLINE=10 \
151-DTARGET_CR=13 \
152-DTARGET_TAB=9 \
153-DTARGET_VT=11
154
155DEPDIR = @DEPDIR@
156DLLTOOL = @DLLTOOL@
157DSYMUTIL = @DSYMUTIL@
158DUMPBIN = @DUMPBIN@
159ECHO_C = @ECHO_C@
160ECHO_N = @ECHO_N@
161ECHO_T = @ECHO_T@
162ECORE_IMF_CFLAGS = @ECORE_IMF_CFLAGS@
163ECORE_IMF_LIBS = @ECORE_IMF_LIBS@
164EDJE_CC_CFLAGS = @EDJE_CC_CFLAGS@
165EDJE_CC_LIBS = @EDJE_CC_LIBS@
166EDJE_CC_PRG = @EDJE_CC_PRG@
167EDJE_CFLAGS = @EDJE_CFLAGS@
168EDJE_DECC_CFLAGS = @EDJE_DECC_CFLAGS@
169EDJE_DECC_LIBS = @EDJE_DECC_LIBS@
170EDJE_DECC_PRG = @EDJE_DECC_PRG@
171EDJE_EXTERNAL_INSPECTOR_CFLAGS = @EDJE_EXTERNAL_INSPECTOR_CFLAGS@
172EDJE_EXTERNAL_INSPECTOR_LIBS = @EDJE_EXTERNAL_INSPECTOR_LIBS@
173EDJE_EXTERNAL_INSPECTOR_PRG = @EDJE_EXTERNAL_INSPECTOR_PRG@
174EDJE_INSPECTOR_CFLAGS = @EDJE_INSPECTOR_CFLAGS@
175EDJE_INSPECTOR_LIBS = @EDJE_INSPECTOR_LIBS@
176EDJE_INSPECTOR_PRG = @EDJE_INSPECTOR_PRG@
177EDJE_LIBS = @EDJE_LIBS@
178EDJE_PLAYER_CFLAGS = @EDJE_PLAYER_CFLAGS@
179EDJE_PLAYER_LIBS = @EDJE_PLAYER_LIBS@
180EDJE_PLAYER_PRG = @EDJE_PLAYER_PRG@
181EDJE_RECC_PRG = @EDJE_RECC_PRG@
182EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
183EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
184EFL_EDJE_BUILD = @EFL_EDJE_BUILD@
185EGREP = @EGREP@
186EVIL_CFLAGS = @EVIL_CFLAGS@
187EVIL_LIBS = @EVIL_LIBS@
188EXEEXT = @EXEEXT@
189FGREP = @FGREP@
190FLAC_CFLAGS = @FLAC_CFLAGS@
191FLAC_LIBS = @FLAC_LIBS@
192GREP = @GREP@
193INSTALL = @INSTALL@
194INSTALL_DATA = @INSTALL_DATA@
195INSTALL_PROGRAM = @INSTALL_PROGRAM@
196INSTALL_SCRIPT = @INSTALL_SCRIPT@
197INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
198LD = @LD@
199LDFLAGS = @LDFLAGS@
200LIBOBJS = @LIBOBJS@
201LIBS = @LIBS@
202LIBTOOL = @LIBTOOL@
203LIPO = @LIPO@
204LN_S = @LN_S@
205LTLIBOBJS = @LTLIBOBJS@
206LUA_CFLAGS = @LUA_CFLAGS@
207LUA_LIBS = @LUA_LIBS@
208MAKEINFO = @MAKEINFO@
209MINIMAL_CFLAGS = @MINIMAL_CFLAGS@
210MINIMAL_LIBS = @MINIMAL_LIBS@
211MKDIR_P = @MKDIR_P@
212MODULE_ARCH = @MODULE_ARCH@
213NM = @NM@
214NMEDIT = @NMEDIT@
215OBJDUMP = @OBJDUMP@
216OBJEXT = @OBJEXT@
217OTOOL = @OTOOL@
218OTOOL64 = @OTOOL64@
219PACKAGE = @PACKAGE@
220PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
221PACKAGE_NAME = @PACKAGE_NAME@
222PACKAGE_STRING = @PACKAGE_STRING@
223PACKAGE_TARNAME = @PACKAGE_TARNAME@
224PACKAGE_URL = @PACKAGE_URL@
225PACKAGE_VERSION = @PACKAGE_VERSION@
226PATH_SEPARATOR = @PATH_SEPARATOR@
227PKG_CONFIG = @PKG_CONFIG@
228PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
229PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
230PYTHON = @PYTHON@
231PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
232PYTHON_PLATFORM = @PYTHON_PLATFORM@
233PYTHON_PREFIX = @PYTHON_PREFIX@
234PYTHON_VERSION = @PYTHON_VERSION@
235RANLIB = @RANLIB@
236REMIX_CFLAGS = @REMIX_CFLAGS@
237REMIX_LIBS = @REMIX_LIBS@
238REMIX_PLUGIN_DIR = @REMIX_PLUGIN_DIR@
239SED = @SED@
240SET_MAKE = @SET_MAKE@
241SHELL = @SHELL@
242SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
243SNDFILE_LIBS = @SNDFILE_LIBS@
244STRIP = @STRIP@
245VERSION = @VERSION@
246VMAJ = @VMAJ@
247VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
248VORBISENC_LIBS = @VORBISENC_LIBS@
249abs_builddir = @abs_builddir@
250abs_srcdir = @abs_srcdir@
251abs_top_builddir = @abs_top_builddir@
252abs_top_srcdir = @abs_top_srcdir@
253ac_ct_CC = @ac_ct_CC@
254ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
255am__include = @am__include@
256am__leading_dot = @am__leading_dot@
257am__quote = @am__quote@
258am__tar = @am__tar@
259am__untar = @am__untar@
260bindir = @bindir@
261build = @build@
262build_alias = @build_alias@
263build_cpu = @build_cpu@
264build_os = @build_os@
265build_vendor = @build_vendor@
266builddir = @builddir@
267datadir = @datadir@
268datarootdir = @datarootdir@
269docdir = @docdir@
270dvidir = @dvidir@
271edje_cc = @edje_cc@
272efl_doxygen = @efl_doxygen@
273efl_have_doxygen = @efl_have_doxygen@
274exec_prefix = @exec_prefix@
275have_lcov = @have_lcov@
276host = @host@
277host_alias = @host_alias@
278host_cpu = @host_cpu@
279host_os = @host_os@
280host_vendor = @host_vendor@
281htmldir = @htmldir@
282includedir = @includedir@
283infodir = @infodir@
284install_sh = @install_sh@
285libdir = @libdir@
286libexecdir = @libexecdir@
287localedir = @localedir@
288localstatedir = @localstatedir@
289lt_ECHO = @lt_ECHO@
290lt_enable_auto_import = @lt_enable_auto_import@
291lua_libs = @lua_libs@
292mandir = @mandir@
293mkdir_p = @mkdir_p@
294oldincludedir = @oldincludedir@
295pdfdir = @pdfdir@
296pkgconfig_requires_private = @pkgconfig_requires_private@
297pkgpyexecdir = @pkgpyexecdir@
298pkgpythondir = @pkgpythondir@
299prefix = @prefix@
300program_transform_name = @program_transform_name@
301psdir = @psdir@
302pyexecdir = @pyexecdir@
303pythondir = @pythondir@
304release_info = @release_info@
305requirement_edje = @requirement_edje@
306sbindir = @sbindir@
307sharedstatedir = @sharedstatedir@
308srcdir = @srcdir@
309sysconfdir = @sysconfdir@
310target_alias = @target_alias@
311top_build_prefix = @top_build_prefix@
312top_builddir = @top_builddir@
313top_srcdir = @top_srcdir@
314version_info = @version_info@
315vimdir = @vimdir@
316MAINTAINERCLEANFILES = Makefile.in
317eppdir = @libdir@/@PACKAGE@/utils
318epp_SOURCES = \
319cpplib.h \
320cpphash.h \
321cppalloc.c \
322cpperror.c \
323cppexp.c \
324cpphash.c \
325cpplib.c \
326cppmain.c
327
328epp_CPPFLAGS = \
329-I$(top_builddir) \
330$(CWARNFLAGS)
331
332all: all-am
333
334.SUFFIXES:
335.SUFFIXES: .c .lo .o .obj
336$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
337 @for dep in $?; do \
338 case '$(am__configure_deps)' in \
339 *$$dep*) \
340 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
341 && { if test -f $@; then exit 0; else break; fi; }; \
342 exit 1;; \
343 esac; \
344 done; \
345 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/bin/epp/Makefile'; \
346 $(am__cd) $(top_srcdir) && \
347 $(AUTOMAKE) --gnu src/bin/epp/Makefile
348.PRECIOUS: Makefile
349Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
350 @case '$?' in \
351 *config.status*) \
352 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
353 *) \
354 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
355 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
356 esac;
357
358$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
359 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
360
361$(top_srcdir)/configure: $(am__configure_deps)
362 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
363$(ACLOCAL_M4): $(am__aclocal_m4_deps)
364 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
365$(am__aclocal_m4_deps):
366install-eppPROGRAMS: $(epp_PROGRAMS)
367 @$(NORMAL_INSTALL)
368 test -z "$(eppdir)" || $(MKDIR_P) "$(DESTDIR)$(eppdir)"
369 @list='$(epp_PROGRAMS)'; test -n "$(eppdir)" || list=; \
370 for p in $$list; do echo "$$p $$p"; done | \
371 sed 's/$(EXEEXT)$$//' | \
372 while read p p1; do if test -f $$p || test -f $$p1; \
373 then echo "$$p"; echo "$$p"; else :; fi; \
374 done | \
375 sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
376 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
377 sed 'N;N;N;s,\n, ,g' | \
378 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
379 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
380 if ($$2 == $$4) files[d] = files[d] " " $$1; \
381 else { print "f", $$3 "/" $$4, $$1; } } \
382 END { for (d in files) print "f", d, files[d] }' | \
383 while read type dir files; do \
384 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
385 test -z "$$files" || { \
386 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(eppdir)$$dir'"; \
387 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(eppdir)$$dir" || exit $$?; \
388 } \
389 ; done
390
391uninstall-eppPROGRAMS:
392 @$(NORMAL_UNINSTALL)
393 @list='$(epp_PROGRAMS)'; test -n "$(eppdir)" || list=; \
394 files=`for p in $$list; do echo "$$p"; done | \
395 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
396 -e 's/$$/$(EXEEXT)/' `; \
397 test -n "$$list" || exit 0; \
398 echo " ( cd '$(DESTDIR)$(eppdir)' && rm -f" $$files ")"; \
399 cd "$(DESTDIR)$(eppdir)" && rm -f $$files
400
401clean-eppPROGRAMS:
402 @list='$(epp_PROGRAMS)'; test -n "$$list" || exit 0; \
403 echo " rm -f" $$list; \
404 rm -f $$list || exit $$?; \
405 test -n "$(EXEEXT)" || exit 0; \
406 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
407 echo " rm -f" $$list; \
408 rm -f $$list
409epp$(EXEEXT): $(epp_OBJECTS) $(epp_DEPENDENCIES)
410 @rm -f epp$(EXEEXT)
411 $(AM_V_CCLD)$(LINK) $(epp_OBJECTS) $(epp_LDADD) $(LIBS)
412
413mostlyclean-compile:
414 -rm -f *.$(OBJEXT)
415
416distclean-compile:
417 -rm -f *.tab.c
418
419@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cppalloc.Po@am__quote@
420@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cpperror.Po@am__quote@
421@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cppexp.Po@am__quote@
422@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cpphash.Po@am__quote@
423@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cpplib.Po@am__quote@
424@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cppmain.Po@am__quote@
425
426.c.o:
427@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
428@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
429@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
430@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
431@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
432@am__fastdepCC_FALSE@ $(COMPILE) -c $<
433
434.c.obj:
435@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
436@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
437@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
438@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
439@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
440@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
441
442.c.lo:
443@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
444@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
445@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
446@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
447@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
448@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
449
450epp-cppalloc.o: cppalloc.c
451@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cppalloc.o -MD -MP -MF $(DEPDIR)/epp-cppalloc.Tpo -c -o epp-cppalloc.o `test -f 'cppalloc.c' || echo '$(srcdir)/'`cppalloc.c
452@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppalloc.Tpo $(DEPDIR)/epp-cppalloc.Po
453@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
454@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppalloc.c' object='epp-cppalloc.o' libtool=no @AMDEPBACKSLASH@
455@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
456@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cppalloc.o `test -f 'cppalloc.c' || echo '$(srcdir)/'`cppalloc.c
457
458epp-cppalloc.obj: cppalloc.c
459@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cppalloc.obj -MD -MP -MF $(DEPDIR)/epp-cppalloc.Tpo -c -o epp-cppalloc.obj `if test -f 'cppalloc.c'; then $(CYGPATH_W) 'cppalloc.c'; else $(CYGPATH_W) '$(srcdir)/cppalloc.c'; fi`
460@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppalloc.Tpo $(DEPDIR)/epp-cppalloc.Po
461@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
462@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppalloc.c' object='epp-cppalloc.obj' libtool=no @AMDEPBACKSLASH@
463@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
464@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cppalloc.obj `if test -f 'cppalloc.c'; then $(CYGPATH_W) 'cppalloc.c'; else $(CYGPATH_W) '$(srcdir)/cppalloc.c'; fi`
465
466epp-cpperror.o: cpperror.c
467@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cpperror.o -MD -MP -MF $(DEPDIR)/epp-cpperror.Tpo -c -o epp-cpperror.o `test -f 'cpperror.c' || echo '$(srcdir)/'`cpperror.c
468@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpperror.Tpo $(DEPDIR)/epp-cpperror.Po
469@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
470@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpperror.c' object='epp-cpperror.o' libtool=no @AMDEPBACKSLASH@
471@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
472@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cpperror.o `test -f 'cpperror.c' || echo '$(srcdir)/'`cpperror.c
473
474epp-cpperror.obj: cpperror.c
475@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cpperror.obj -MD -MP -MF $(DEPDIR)/epp-cpperror.Tpo -c -o epp-cpperror.obj `if test -f 'cpperror.c'; then $(CYGPATH_W) 'cpperror.c'; else $(CYGPATH_W) '$(srcdir)/cpperror.c'; fi`
476@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpperror.Tpo $(DEPDIR)/epp-cpperror.Po
477@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
478@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpperror.c' object='epp-cpperror.obj' libtool=no @AMDEPBACKSLASH@
479@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
480@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cpperror.obj `if test -f 'cpperror.c'; then $(CYGPATH_W) 'cpperror.c'; else $(CYGPATH_W) '$(srcdir)/cpperror.c'; fi`
481
482epp-cppexp.o: cppexp.c
483@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cppexp.o -MD -MP -MF $(DEPDIR)/epp-cppexp.Tpo -c -o epp-cppexp.o `test -f 'cppexp.c' || echo '$(srcdir)/'`cppexp.c
484@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppexp.Tpo $(DEPDIR)/epp-cppexp.Po
485@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
486@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppexp.c' object='epp-cppexp.o' libtool=no @AMDEPBACKSLASH@
487@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
488@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cppexp.o `test -f 'cppexp.c' || echo '$(srcdir)/'`cppexp.c
489
490epp-cppexp.obj: cppexp.c
491@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cppexp.obj -MD -MP -MF $(DEPDIR)/epp-cppexp.Tpo -c -o epp-cppexp.obj `if test -f 'cppexp.c'; then $(CYGPATH_W) 'cppexp.c'; else $(CYGPATH_W) '$(srcdir)/cppexp.c'; fi`
492@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppexp.Tpo $(DEPDIR)/epp-cppexp.Po
493@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
494@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppexp.c' object='epp-cppexp.obj' libtool=no @AMDEPBACKSLASH@
495@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
496@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cppexp.obj `if test -f 'cppexp.c'; then $(CYGPATH_W) 'cppexp.c'; else $(CYGPATH_W) '$(srcdir)/cppexp.c'; fi`
497
498epp-cpphash.o: cpphash.c
499@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cpphash.o -MD -MP -MF $(DEPDIR)/epp-cpphash.Tpo -c -o epp-cpphash.o `test -f 'cpphash.c' || echo '$(srcdir)/'`cpphash.c
500@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpphash.Tpo $(DEPDIR)/epp-cpphash.Po
501@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
502@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpphash.c' object='epp-cpphash.o' libtool=no @AMDEPBACKSLASH@
503@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
504@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cpphash.o `test -f 'cpphash.c' || echo '$(srcdir)/'`cpphash.c
505
506epp-cpphash.obj: cpphash.c
507@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cpphash.obj -MD -MP -MF $(DEPDIR)/epp-cpphash.Tpo -c -o epp-cpphash.obj `if test -f 'cpphash.c'; then $(CYGPATH_W) 'cpphash.c'; else $(CYGPATH_W) '$(srcdir)/cpphash.c'; fi`
508@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpphash.Tpo $(DEPDIR)/epp-cpphash.Po
509@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
510@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpphash.c' object='epp-cpphash.obj' libtool=no @AMDEPBACKSLASH@
511@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
512@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cpphash.obj `if test -f 'cpphash.c'; then $(CYGPATH_W) 'cpphash.c'; else $(CYGPATH_W) '$(srcdir)/cpphash.c'; fi`
513
514epp-cpplib.o: cpplib.c
515@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cpplib.o -MD -MP -MF $(DEPDIR)/epp-cpplib.Tpo -c -o epp-cpplib.o `test -f 'cpplib.c' || echo '$(srcdir)/'`cpplib.c
516@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpplib.Tpo $(DEPDIR)/epp-cpplib.Po
517@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
518@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpplib.c' object='epp-cpplib.o' libtool=no @AMDEPBACKSLASH@
519@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
520@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cpplib.o `test -f 'cpplib.c' || echo '$(srcdir)/'`cpplib.c
521
522epp-cpplib.obj: cpplib.c
523@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cpplib.obj -MD -MP -MF $(DEPDIR)/epp-cpplib.Tpo -c -o epp-cpplib.obj `if test -f 'cpplib.c'; then $(CYGPATH_W) 'cpplib.c'; else $(CYGPATH_W) '$(srcdir)/cpplib.c'; fi`
524@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpplib.Tpo $(DEPDIR)/epp-cpplib.Po
525@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
526@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpplib.c' object='epp-cpplib.obj' libtool=no @AMDEPBACKSLASH@
527@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
528@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cpplib.obj `if test -f 'cpplib.c'; then $(CYGPATH_W) 'cpplib.c'; else $(CYGPATH_W) '$(srcdir)/cpplib.c'; fi`
529
530epp-cppmain.o: cppmain.c
531@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cppmain.o -MD -MP -MF $(DEPDIR)/epp-cppmain.Tpo -c -o epp-cppmain.o `test -f 'cppmain.c' || echo '$(srcdir)/'`cppmain.c
532@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppmain.Tpo $(DEPDIR)/epp-cppmain.Po
533@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
534@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppmain.c' object='epp-cppmain.o' libtool=no @AMDEPBACKSLASH@
535@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
536@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cppmain.o `test -f 'cppmain.c' || echo '$(srcdir)/'`cppmain.c
537
538epp-cppmain.obj: cppmain.c
539@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT epp-cppmain.obj -MD -MP -MF $(DEPDIR)/epp-cppmain.Tpo -c -o epp-cppmain.obj `if test -f 'cppmain.c'; then $(CYGPATH_W) 'cppmain.c'; else $(CYGPATH_W) '$(srcdir)/cppmain.c'; fi`
540@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppmain.Tpo $(DEPDIR)/epp-cppmain.Po
541@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
542@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppmain.c' object='epp-cppmain.obj' libtool=no @AMDEPBACKSLASH@
543@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
544@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(epp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o epp-cppmain.obj `if test -f 'cppmain.c'; then $(CYGPATH_W) 'cppmain.c'; else $(CYGPATH_W) '$(srcdir)/cppmain.c'; fi`
545
546mostlyclean-libtool:
547 -rm -f *.lo
548
549clean-libtool:
550 -rm -rf .libs _libs
551
552ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
553 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
554 unique=`for i in $$list; do \
555 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
556 done | \
557 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
558 END { if (nonempty) { for (i in files) print i; }; }'`; \
559 mkid -fID $$unique
560tags: TAGS
561
562TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
563 $(TAGS_FILES) $(LISP)
564 set x; \
565 here=`pwd`; \
566 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
567 unique=`for i in $$list; do \
568 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
569 done | \
570 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
571 END { if (nonempty) { for (i in files) print i; }; }'`; \
572 shift; \
573 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
574 test -n "$$unique" || unique=$$empty_fix; \
575 if test $$# -gt 0; then \
576 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
577 "$$@" $$unique; \
578 else \
579 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
580 $$unique; \
581 fi; \
582 fi
583ctags: CTAGS
584CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
585 $(TAGS_FILES) $(LISP)
586 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
587 unique=`for i in $$list; do \
588 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
589 done | \
590 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
591 END { if (nonempty) { for (i in files) print i; }; }'`; \
592 test -z "$(CTAGS_ARGS)$$unique" \
593 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
594 $$unique
595
596GTAGS:
597 here=`$(am__cd) $(top_builddir) && pwd` \
598 && $(am__cd) $(top_srcdir) \
599 && gtags -i $(GTAGS_ARGS) "$$here"
600
601distclean-tags:
602 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
603
604distdir: $(DISTFILES)
605 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
606 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
607 list='$(DISTFILES)'; \
608 dist_files=`for file in $$list; do echo $$file; done | \
609 sed -e "s|^$$srcdirstrip/||;t" \
610 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
611 case $$dist_files in \
612 */*) $(MKDIR_P) `echo "$$dist_files" | \
613 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
614 sort -u` ;; \
615 esac; \
616 for file in $$dist_files; do \
617 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
618 if test -d $$d/$$file; then \
619 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
620 if test -d "$(distdir)/$$file"; then \
621 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
622 fi; \
623 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
624 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
625 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
626 fi; \
627 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
628 else \
629 test -f "$(distdir)/$$file" \
630 || cp -p $$d/$$file "$(distdir)/$$file" \
631 || exit 1; \
632 fi; \
633 done
634check-am: all-am
635check: check-am
636all-am: Makefile $(PROGRAMS)
637installdirs:
638 for dir in "$(DESTDIR)$(eppdir)"; do \
639 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
640 done
641install: install-am
642install-exec: install-exec-am
643install-data: install-data-am
644uninstall: uninstall-am
645
646install-am: all-am
647 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
648
649installcheck: installcheck-am
650install-strip:
651 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
652 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
653 `test -z '$(STRIP)' || \
654 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
655mostlyclean-generic:
656
657clean-generic:
658
659distclean-generic:
660 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
661 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
662
663maintainer-clean-generic:
664 @echo "This command is intended for maintainers to use"
665 @echo "it deletes files that may require special tools to rebuild."
666 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
667clean: clean-am
668
669clean-am: clean-eppPROGRAMS clean-generic clean-libtool mostlyclean-am
670
671distclean: distclean-am
672 -rm -rf ./$(DEPDIR)
673 -rm -f Makefile
674distclean-am: clean-am distclean-compile distclean-generic \
675 distclean-tags
676
677dvi: dvi-am
678
679dvi-am:
680
681html: html-am
682
683html-am:
684
685info: info-am
686
687info-am:
688
689install-data-am: install-eppPROGRAMS
690
691install-dvi: install-dvi-am
692
693install-dvi-am:
694
695install-exec-am:
696
697install-html: install-html-am
698
699install-html-am:
700
701install-info: install-info-am
702
703install-info-am:
704
705install-man:
706
707install-pdf: install-pdf-am
708
709install-pdf-am:
710
711install-ps: install-ps-am
712
713install-ps-am:
714
715installcheck-am:
716
717maintainer-clean: maintainer-clean-am
718 -rm -rf ./$(DEPDIR)
719 -rm -f Makefile
720maintainer-clean-am: distclean-am maintainer-clean-generic
721
722mostlyclean: mostlyclean-am
723
724mostlyclean-am: mostlyclean-compile mostlyclean-generic \
725 mostlyclean-libtool
726
727pdf: pdf-am
728
729pdf-am:
730
731ps: ps-am
732
733ps-am:
734
735uninstall-am: uninstall-eppPROGRAMS
736
737.MAKE: install-am install-strip
738
739.PHONY: CTAGS GTAGS all all-am check check-am clean clean-eppPROGRAMS \
740 clean-generic clean-libtool ctags distclean distclean-compile \
741 distclean-generic distclean-libtool distclean-tags distdir dvi \
742 dvi-am html html-am info info-am install install-am \
743 install-data install-data-am install-dvi install-dvi-am \
744 install-eppPROGRAMS install-exec install-exec-am install-html \
745 install-html-am install-info install-info-am install-man \
746 install-pdf install-pdf-am install-ps install-ps-am \
747 install-strip installcheck installcheck-am installdirs \
748 maintainer-clean maintainer-clean-generic mostlyclean \
749 mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
750 pdf pdf-am ps ps-am tags uninstall uninstall-am \
751 uninstall-eppPROGRAMS
752
753
754# Tell versions [3.59,3.63) of GNU make to not export all variables.
755# Otherwise a system limit (for SysV at least) may be exceeded.
756.NOEXPORT:
diff --git a/libraries/edje/src/bin/epp/cppalloc.c b/libraries/edje/src/bin/epp/cppalloc.c
new file mode 100644
index 0000000..4ce0dd0
--- /dev/null
+++ b/libraries/edje/src/bin/epp/cppalloc.c
@@ -0,0 +1,70 @@
1/* Part of CPP library. (memory allocation - xmalloc etc)
2 * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
3 * Written by Per Bothner, 1994.
4 * Based on CCCP program by by Paul Rubin, June 1986
5 * Adapted to ANSI C, Richard Stallman, Jan 1987
6 * Copyright (C) 2003-2011 Kim Woelders
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * In other words, you are welcome to use, share and improve this program.
23 * You are forbidden to forbid anyone else to use, share and improve
24 * what you give them. Help stamp out software-hoarding! */
25
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30#include <stdlib.h>
31
32#include "cpplib.h"
33
34static void
35memory_full(void)
36{
37 cpp_fatal("Memory exhausted.");
38}
39
40void *
41xmalloc(unsigned size)
42{
43 char *ptr = (char *)malloc(size);
44
45 if (ptr)
46 return (ptr);
47 memory_full();
48 /*NOTREACHED */
49 return 0;
50}
51
52void *
53xrealloc(void *old, unsigned size)
54{
55 char *ptr = (char *)realloc(old, size);
56
57 if (!ptr)
58 memory_full();
59 return ptr;
60}
61
62void *
63xcalloc(unsigned number, unsigned size)
64{
65 char *ptr = (char *)calloc(number, size);
66
67 if (!ptr)
68 memory_full();
69 return ptr;
70}
diff --git a/libraries/edje/src/bin/epp/cpperror.c b/libraries/edje/src/bin/epp/cpperror.c
new file mode 100644
index 0000000..f4cd5eb
--- /dev/null
+++ b/libraries/edje/src/bin/epp/cpperror.c
@@ -0,0 +1,147 @@
1/* Default error handlers for CPP Library.
2 * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
3 * Written by Per Bothner, 1994.
4 * Based on CCCP program by by Paul Rubin, June 1986
5 * Adapted to ANSI C, Richard Stallman, Jan 1987
6 * Copyright (C) 2003-2011 Kim Woelders
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * In other words, you are welcome to use, share and improve this program.
23 * You are forbidden to forbid anyone else to use, share and improve
24 * what you give them. Help stamp out software-hoarding! */
25
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30#include <stdio.h>
31#include <stdlib.h>
32
33#include "cpplib.h"
34
35/* Print the file names and line numbers of the #include
36 * commands which led to the current file. */
37
38void
39cpp_print_containing_files(cpp_reader * pfile)
40{
41 cpp_buffer *ip;
42 int first = 1;
43
44 /* If stack of files hasn't changed since we last printed
45 * this info, don't repeat it. */
46 if (pfile->input_stack_listing_current)
47 return;
48
49 ip = cpp_file_buffer(pfile);
50
51 /* Give up if we don't find a source file. */
52 if (!ip)
53 return;
54
55 /* Find the other, outer source files. */
56 while ((ip = CPP_PREV_BUFFER(ip)), ip != CPP_NULL_BUFFER(pfile))
57 {
58 long line, col;
59
60 cpp_buf_line_and_col(ip, &line, &col);
61 if (ip->fname)
62 {
63 if (first)
64 {
65 first = 0;
66 fprintf(stderr, "In file included");
67 }
68 else
69 fprintf(stderr, ",\n ");
70 }
71 }
72 if (!first)
73 fprintf(stderr, ":\n");
74
75 /* Record we have printed the status as of this time. */
76 pfile->input_stack_listing_current = 1;
77}
78
79void
80cpp_file_line_for_message(cpp_reader * pfile __UNUSED__, const char *filename,
81 int line, int column)
82{
83 if (column > 0)
84 {
85 fprintf(stderr, "%s:%d:%d: ", filename, line, column);
86 }
87 else
88 {
89 fprintf(stderr, "%s:%d: ", filename, line);
90 }
91}
92
93/* IS_ERROR is 1 for error, 0 for warning */
94void
95cpp_message_v(cpp_reader * pfile, int is_error, const char *msg, va_list args)
96{
97 if (is_error)
98 pfile->errors++;
99 else
100 fprintf(stderr, "warning: ");
101 vfprintf(stderr, msg, args);
102 fprintf(stderr, "\n");
103}
104
105void
106cpp_message(cpp_reader * pfile, int is_error, const char *msg, ...)
107{
108 va_list args;
109
110 va_start(args, msg);
111
112 cpp_message_v(pfile, is_error, msg, args);
113
114 va_end(args);
115}
116
117static void
118cpp_fatal_v(const char *msg, va_list args)
119{
120 fprintf(stderr, "%s: ", progname);
121 vfprintf(stderr, msg, args);
122 fprintf(stderr, "\n");
123 exit(FATAL_EXIT_CODE);
124}
125
126void
127cpp_fatal(const char *msg, ...)
128{
129 va_list args;
130
131 va_start(args, msg);
132
133 cpp_fatal_v(msg, args);
134
135 va_end(args);
136}
137
138void
139cpp_pfatal_with_name(cpp_reader * pfile, const char *name)
140{
141 cpp_perror_with_name(pfile, name);
142#ifdef VMS
143 exit(vaxc$errno);
144#else
145 exit(FATAL_EXIT_CODE);
146#endif
147}
diff --git a/libraries/edje/src/bin/epp/cppexp.c b/libraries/edje/src/bin/epp/cppexp.c
new file mode 100644
index 0000000..5fcb33f
--- /dev/null
+++ b/libraries/edje/src/bin/epp/cppexp.c
@@ -0,0 +1,1090 @@
1/* Parse C expressions for CCCP.
2 * Copyright (C) 1987, 1992, 1994, 1995 Free Software Foundation.
3 * Copyright (C) 2003-2011 Kim Woelders
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2, or (at your option) any
8 * later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 * In other words, you are welcome to use, share and improve this program.
20 * You are forbidden to forbid anyone else to use, share and improve
21 * what you give them. Help stamp out software-hoarding!
22 *
23 * Written by Per Bothner 1994. */
24
25/* Parse a C expression from text in a string */
26
27#ifdef HAVE_CONFIG_H
28# include <config.h>
29#endif
30
31#ifdef __EMX__
32# include <strings.h>
33#endif
34
35#ifdef MULTIBYTE_CHARS
36# include <locale.h>
37#endif
38
39#include <stdlib.h>
40#include <stdio.h>
41#include <string.h>
42
43#include "cpplib.h"
44#include "cpphash.h"
45
46/* This is used for communicating lists of keywords with cccp.c. */
47struct arglist {
48 struct arglist *next;
49 unsigned char *name;
50 int length;
51 int argno;
52};
53
54/* Define a generic NULL if one hasn't already been defined. */
55
56#ifndef NULL
57#define NULL 0
58#endif
59
60#ifndef GENERIC_PTR
61#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
62#define GENERIC_PTR void *
63#else
64#define GENERIC_PTR char *
65#endif
66#endif
67
68#ifndef NULL_PTR
69#define NULL_PTR ((GENERIC_PTR)0)
70#endif
71
72#ifndef CHAR_TYPE_SIZE
73#define CHAR_TYPE_SIZE BITS_PER_UNIT
74#endif
75
76#ifndef INT_TYPE_SIZE
77#define INT_TYPE_SIZE BITS_PER_WORD
78#endif
79
80#ifndef LONG_TYPE_SIZE
81#define LONG_TYPE_SIZE BITS_PER_WORD
82#endif
83
84#ifndef WCHAR_TYPE_SIZE
85#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
86#endif
87
88#ifndef MAX_CHAR_TYPE_SIZE
89#define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
90#endif
91
92#ifndef MAX_INT_TYPE_SIZE
93#define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
94#endif
95
96#ifndef MAX_LONG_TYPE_SIZE
97#define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
98#endif
99
100#ifndef MAX_WCHAR_TYPE_SIZE
101#define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
102#endif
103
104/* Yield nonzero if adding two numbers with A's and B's signs can yield a
105 * number with SUM's sign, where A, B, and SUM are all C integers. */
106#define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0)
107
108#define ERROR 299
109#define OROR 300
110#define ANDAND 301
111#define EQUAL 302
112#define NOTEQUAL 303
113#define LEQ 304
114#define GEQ 305
115#define LSH 306
116#define RSH 307
117#define NAME 308
118#define INT 309
119#define CHAR 310
120
121#define LEFT_OPERAND_REQUIRED 1
122#define RIGHT_OPERAND_REQUIRED 2
123#define HAVE_VALUE 4
124/* SKIP_OPERAND is set for '&&' '||' '?' and ':' when the
125 * following operand should be short-circuited instead of evaluated. */
126#define SKIP_OPERAND 8
127/*#define UNSIGNEDP 16 */
128
129struct operation {
130 short op;
131 char rprio; /* Priority of op (relative to it right operand). */
132 char flags;
133 char unsignedp; /* true if value should be treated as unsigned */
134 HOST_WIDE_INT value; /* The value logically "right" of op. */
135};
136
137/* Take care of parsing a number (anything that starts with a digit).
138 * LEN is the number of characters in it. */
139
140/* maybe needs to actually deal with floating point numbers */
141
142static void
143parse_number(struct operation *op, cpp_reader * pfile, const char *start,
144 int olen)
145{
146 const char *p = start;
147 int c;
148 unsigned long n = 0, nd, ULONG_MAX_over_base;
149 int base = 10;
150 int len = olen;
151 int overflow = 0;
152 int digit, largest_digit = 0;
153 int spec_long = 0;
154
155 op->unsignedp = 0;
156
157 for (c = 0; c < len; c++)
158 if (p[c] == '.')
159 {
160 /* It's a float since it contains a point. */
161 cpp_error(pfile,
162 "floating point numbers not allowed in #if expressions");
163 op->op = ERROR;
164 return;
165 }
166 if (len >= 3 && (!strncmp(p, "0x", 2) || !strncmp(p, "0X", 2)))
167 {
168 p += 2;
169 base = 16;
170 len -= 2;
171 }
172 else if (*p == '0')
173 base = 8;
174
175 /* Some buggy compilers (e.g. MPW C) seem to need both casts. */
176 ULONG_MAX_over_base = ((unsigned long)-1) / ((unsigned long)base);
177
178 for (; len > 0; len--)
179 {
180 c = *p++;
181
182 if (c >= '0' && c <= '9')
183 digit = c - '0';
184 else if (base == 16 && c >= 'a' && c <= 'f')
185 digit = c - 'a' + 10;
186 else if (base == 16 && c >= 'A' && c <= 'F')
187 digit = c - 'A' + 10;
188 else
189 {
190 /* `l' means long, and `u' means unsigned. */
191 while (1)
192 {
193 if (c == 'l' || c == 'L')
194 {
195 if (spec_long)
196 cpp_error(pfile, "two `l's in integer constant");
197 spec_long = 1;
198 }
199 else if (c == 'u' || c == 'U')
200 {
201 if (op->unsignedp)
202 cpp_error(pfile, "two `u's in integer constant");
203 op->unsignedp = 1;
204 }
205 else
206 break;
207
208 if (--len == 0)
209 break;
210 c = *p++;
211 }
212 /* Don't look for any more digits after the suffixes. */
213 break;
214 }
215 if (largest_digit < digit)
216 largest_digit = digit;
217 nd = n * base + digit;
218 overflow |= (ULONG_MAX_over_base < n) | (nd < n);
219 n = nd;
220 }
221
222 if (len != 0)
223 {
224 cpp_error(pfile, "Invalid number in #if expression");
225 op->op = ERROR;
226 return;
227 }
228 if (base <= largest_digit)
229 cpp_warning(pfile, "integer constant contains digits beyond the radix");
230
231 if (overflow)
232 cpp_warning(pfile, "integer constant out of range");
233
234 /* If too big to be signed, consider it unsigned. */
235 if ((long)n < 0 && !op->unsignedp)
236 {
237 if (base == 10)
238 cpp_warning(pfile,
239 "integer constant is so large that it is unsigned");
240 op->unsignedp = 1;
241 }
242 op->value = n;
243 op->op = INT;
244}
245
246struct token {
247 const char *oper;
248 int token;
249};
250
251static struct token tokentab2[] = {
252 {"&&", ANDAND},
253 {"||", OROR},
254 {"<<", LSH},
255 {">>", RSH},
256 {"==", EQUAL},
257 {"!=", NOTEQUAL},
258 {"<=", LEQ},
259 {">=", GEQ},
260 {"++", ERROR},
261 {"--", ERROR},
262 {NULL, ERROR}
263};
264
265/* Read one token. */
266
267static void
268cpp_lex(struct operation *op, cpp_reader * pfile)
269{
270 int c;
271 struct token *toktab;
272 enum cpp_token token;
273 unsigned char *tok_start, *tok_end;
274 int old_written;
275
276 op->value = 0;
277 op->unsignedp = 0;
278
279 retry:
280
281 old_written = CPP_WRITTEN(pfile);
282 cpp_skip_hspace(pfile);
283 c = CPP_BUF_PEEK(CPP_BUFFER(pfile));
284 if (c == '#')
285 {
286 parse_number(op, pfile, cpp_read_check_assertion(pfile) ? "1" : "0", 1);
287 return;
288 }
289
290 if (c == '\n')
291 {
292 op->op = 0;
293 return;
294 }
295 token = cpp_get_token(pfile);
296 tok_start = pfile->token_buffer + old_written;
297 tok_end = CPP_PWRITTEN(pfile);
298 pfile->limit = tok_start;
299 switch (token)
300 {
301 case CPP_EOF: /* Should not happen ... */
302 op->op = 0;
303 break;
304
305 case CPP_VSPACE:
306 case CPP_POP:
307 if (CPP_BUFFER(pfile)->fname)
308 {
309 op->op = 0;
310 break;
311 }
312 goto retry;
313
314 case CPP_HSPACE:
315 case CPP_COMMENT:
316 goto retry;
317
318 case CPP_NUMBER:
319 parse_number(op, pfile, (char *)tok_start, tok_end - tok_start);
320 break;
321
322 case CPP_STRING:
323 cpp_error(pfile, "string constants not allowed in #if expressions");
324 op->op = ERROR;
325 break;
326
327 case CPP_CHAR:
328 /* This code for reading a character constant
329 * handles multicharacter constants and wide characters.
330 * It is mostly copied from c-lex.c. */
331 {
332 int result = 0;
333 int num_chars = 0;
334 unsigned width = MAX_CHAR_TYPE_SIZE;
335 int wide_flag = 0;
336 int max_chars;
337 char *ptr = (char *)tok_start;
338
339#ifdef MULTIBYTE_CHARS
340 char token_buffer[MAX_LONG_TYPE_SIZE /
341 MAX_CHAR_TYPE_SIZE + MB_CUR_MAX];
342#endif
343
344 if (*ptr == 'L')
345 {
346 ptr++;
347 wide_flag = 1;
348 width = MAX_WCHAR_TYPE_SIZE;
349#ifdef MULTIBYTE_CHARS
350 max_chars = MB_CUR_MAX;
351#else
352 max_chars = 1;
353#endif
354 }
355 else
356 max_chars = MAX_LONG_TYPE_SIZE / width;
357
358 while (1)
359 {
360 if (ptr >= (char *)CPP_PWRITTEN(pfile) || (c = *ptr++) == '\'')
361 break;
362
363 if (c == '\\')
364 {
365 c = cpp_parse_escape(pfile, &ptr);
366 if (width < HOST_BITS_PER_INT
367 && (unsigned)c >= (unsigned)(1 << width))
368 cpp_pedwarn(pfile,
369 "escape sequence out of range for character");
370 }
371 num_chars++;
372
373 /* Merge character into result; ignore excess chars. */
374 if (num_chars < max_chars + 1)
375 {
376 if (width < HOST_BITS_PER_INT)
377 result = (result << width) | (c & ((1 << width) - 1));
378 else
379 result = c;
380#ifdef MULTIBYTE_CHARS
381 token_buffer[num_chars - 1] = c;
382#endif
383 }
384 }
385
386#ifdef MULTIBYTE_CHARS
387 token_buffer[num_chars] = 0;
388#endif
389
390 if (c != '\'')
391 cpp_error(pfile, "malformatted character constant");
392 else if (num_chars == 0)
393 cpp_error(pfile, "empty character constant");
394 else if (num_chars > max_chars)
395 {
396 num_chars = max_chars;
397 cpp_error(pfile, "character constant too long");
398 }
399 else if (num_chars != 1 && !CPP_TRADITIONAL(pfile))
400 cpp_warning(pfile, "multi-character character constant");
401
402 /* If char type is signed, sign-extend the constant. */
403 if (!wide_flag)
404 {
405 int num_bits = num_chars * width;
406
407 if (cpp_lookup("__CHAR_UNSIGNED__",
408 sizeof("__CHAR_UNSIGNED__") - 1, -1)
409 || ((result >> (num_bits - 1)) & 1) == 0)
410 op->value =
411 result & ((unsigned long)~0 >>
412 (HOST_BITS_PER_LONG - num_bits));
413 else
414 op->value =
415 result | ~((unsigned long)~0 >>
416 (HOST_BITS_PER_LONG - num_bits));
417 }
418 else
419 {
420#ifdef MULTIBYTE_CHARS
421 /* Set the initial shift state and convert the next sequence. */
422 result = 0;
423 /* In all locales L'\0' is zero and mbtowc will return zero,
424 * so don't use it. */
425 if (num_chars > 1
426 || (num_chars == 1 && token_buffer[0] != '\0'))
427 {
428 wchar_t wc;
429
430 (void)mbtowc(NULL_PTR, NULL_PTR, 0);
431 if (mbtowc(&wc, token_buffer, num_chars) == num_chars)
432 result = wc;
433 else
434 cpp_warning(pfile,
435 "Ignoring invalid multibyte character");
436 }
437#endif
438 op->value = result;
439 }
440 }
441
442 /* This is always a signed type. */
443 op->unsignedp = 0;
444 op->op = CHAR;
445 break;
446
447 case CPP_NAME:
448 parse_number(op, pfile, "0", 0);
449 break;
450
451 case CPP_OTHER:
452 /* See if it is a special token of length 2. */
453 if (tok_start + 2 == tok_end)
454 {
455 for (toktab = tokentab2; toktab->oper; toktab++)
456 if (tok_start[0] == toktab->oper[0]
457 && tok_start[1] == toktab->oper[1])
458 break;
459 if (toktab->token == ERROR)
460 {
461 char *buf = (char *)malloc(40);
462
463 memset(buf, 0, 40);
464
465 sprintf(buf, "`%s' not allowed in operand of `#if'",
466 tok_start);
467 cpp_error(pfile, buf);
468 free(buf);
469 }
470 op->op = toktab->token;
471 break;
472 }
473 /* fall through */
474 default:
475 op->op = *tok_start;
476 break;
477 }
478}
479
480/* Parse a C escape sequence. STRING_PTR points to a variable
481 * containing a pointer to the string to parse. That pointer
482 * is updated past the characters we use. The value of the
483 * escape sequence is returned.
484 *
485 * A negative value means the sequence \ newline was seen,
486 * which is supposed to be equivalent to nothing at all.
487 *
488 * If \ is followed by a null character, we return a negative
489 * value and leave the string pointer pointing at the null character.
490 *
491 * If \ is followed by 000, we return 0 and leave the string pointer
492 * after the zeros. A value of 0 does not mean end of string. */
493
494int
495cpp_parse_escape(cpp_reader * pfile, char **string_ptr)
496{
497 int c = *(*string_ptr)++;
498
499 switch (c)
500 {
501 case 'a':
502 return TARGET_BELL;
503 case 'b':
504 return TARGET_BS;
505 case 'e':
506 case 'E':
507 if (CPP_PEDANTIC(pfile))
508 cpp_pedwarn(pfile, "non-ANSI-standard escape sequence, `\\%c'", c);
509 return 033;
510 case 'f':
511 return TARGET_FF;
512 case 'n':
513 return TARGET_NEWLINE;
514 case 'r':
515 return TARGET_CR;
516 case 't':
517 return TARGET_TAB;
518 case 'v':
519 return TARGET_VT;
520 case '\n':
521 return -2;
522 case 0:
523 (*string_ptr)--;
524 return 0;
525
526 case '0':
527 case '1':
528 case '2':
529 case '3':
530 case '4':
531 case '5':
532 case '6':
533 case '7':
534 {
535 int i = c - '0';
536 int count = 0;
537
538 while (++count < 3)
539 {
540 c = *(*string_ptr)++;
541 if (c >= '0' && c <= '7')
542 i = (i << 3) + c - '0';
543 else
544 {
545 (*string_ptr)--;
546 break;
547 }
548 }
549 if ((i & ~((1 << MAX_CHAR_TYPE_SIZE) - 1)) != 0)
550 {
551 i &= (1 << MAX_CHAR_TYPE_SIZE) - 1;
552 cpp_warning(pfile,
553 "octal character constant does not fit in a byte");
554 }
555 return i;
556 }
557 case 'x':
558 {
559 unsigned i = 0, overflow = 0, digits_found = 0, digit;
560
561 for (;;)
562 {
563 c = *(*string_ptr)++;
564 if (c >= '0' && c <= '9')
565 digit = c - '0';
566 else if (c >= 'a' && c <= 'f')
567 digit = c - 'a' + 10;
568 else if (c >= 'A' && c <= 'F')
569 digit = c - 'A' + 10;
570 else
571 {
572 (*string_ptr)--;
573 break;
574 }
575 overflow |= i ^ (i << 4 >> 4);
576 i = (i << 4) + digit;
577 digits_found = 1;
578 }
579 if (!digits_found)
580 cpp_error(pfile, "\\x used with no following hex digits");
581 if (overflow | (i & ~((1 << BITS_PER_UNIT) - 1)))
582 {
583 i &= (1 << BITS_PER_UNIT) - 1;
584 cpp_warning(pfile,
585 "hex character constant does not fit in a byte");
586 }
587 return i;
588 }
589 default:
590 return c;
591 }
592}
593
594static void
595integer_overflow(cpp_reader * pfile)
596{
597 if (CPP_PEDANTIC(pfile))
598 cpp_pedwarn(pfile, "integer overflow in preprocessor expression");
599}
600
601static long
602left_shift(cpp_reader * pfile, long a, int unsignedp, unsigned long b)
603{
604 if (b >= HOST_BITS_PER_LONG)
605 {
606 if (!unsignedp && a != 0)
607 integer_overflow(pfile);
608 return 0;
609 }
610 else if (unsignedp)
611 return (unsigned long)a << b;
612 else
613 {
614 long l = a << b;
615
616 if (l >> b != a)
617 integer_overflow(pfile);
618 return l;
619 }
620}
621
622static long
623right_shift(cpp_reader * pfile __UNUSED__, long a, int unsignedp,
624 unsigned long b)
625{
626 if (b >= HOST_BITS_PER_LONG)
627 {
628 return unsignedp ? 0 : a >> (HOST_BITS_PER_LONG - 1);
629 }
630 else if (unsignedp)
631 {
632 return (unsigned long)a >> b;
633 }
634 else
635 {
636 return a >> b;
637 }
638}
639
640/* These priorities are all even, so we can handle associatively. */
641#define PAREN_INNER_PRIO 0
642#define COMMA_PRIO 4
643#define COND_PRIO (COMMA_PRIO+2)
644#define OROR_PRIO (COND_PRIO+2)
645#define ANDAND_PRIO (OROR_PRIO+2)
646#define OR_PRIO (ANDAND_PRIO+2)
647#define XOR_PRIO (OR_PRIO+2)
648#define AND_PRIO (XOR_PRIO+2)
649#define EQUAL_PRIO (AND_PRIO+2)
650#define LESS_PRIO (EQUAL_PRIO+2)
651#define SHIFT_PRIO (LESS_PRIO+2)
652#define PLUS_PRIO (SHIFT_PRIO+2)
653#define MUL_PRIO (PLUS_PRIO+2)
654#define UNARY_PRIO (MUL_PRIO+2)
655#define PAREN_OUTER_PRIO (UNARY_PRIO+2)
656
657#define COMPARE(OP) \
658 top->unsignedp = 0;\
659 top->value = (unsigned1 || unsigned2) ? (unsigned long) v1 OP (unsigned long) v2 : (v1 OP v2)
660
661/* Parse and evaluate a C expression, reading from PFILE.
662 * Returns the value of the expression. */
663
664HOST_WIDE_INT
665cpp_parse_expr(cpp_reader * pfile)
666{
667 /* The implementation is an operator precedence parser,
668 * i.e. a bottom-up parser, using a stack for not-yet-reduced tokens.
669 *
670 * The stack base is 'stack', and the current stack pointer is 'top'.
671 * There is a stack element for each operator (only),
672 * and the most recently pushed operator is 'top->op'.
673 * An operand (value) is stored in the 'value' field of the stack
674 * element of the operator that precedes it.
675 * In that case the 'flags' field has the HAVE_VALUE flag set. */
676
677#define INIT_STACK_SIZE 20
678 struct operation init_stack[INIT_STACK_SIZE];
679 struct operation *stack = init_stack;
680 struct operation *limit = stack + INIT_STACK_SIZE;
681 struct operation *top = stack;
682 int lprio = 0, rprio = 0;
683 int skip_evaluation = 0;
684
685 top->rprio = 0;
686 top->flags = 0;
687 for (;;)
688 {
689 struct operation op;
690 char flags = 0;
691
692 /* Read a token */
693 cpp_lex(&op, pfile);
694
695 /* See if the token is an operand, in which case go to set_value.
696 * If the token is an operator, figure out its left and right
697 * priorities, and then goto maybe_reduce. */
698
699 switch (op.op)
700 {
701 case NAME:
702 top->value = 0, top->unsignedp = 0;
703 goto set_value;
704 case INT:
705 case CHAR:
706 top->value = op.value;
707 top->unsignedp = op.unsignedp;
708 goto set_value;
709 case 0:
710 lprio = 0;
711 goto maybe_reduce;
712 case '+':
713 case '-':
714 /* Is this correct if unary ? FIXME */
715 flags = RIGHT_OPERAND_REQUIRED;
716 lprio = PLUS_PRIO;
717 rprio = lprio + 1;
718 goto maybe_reduce;
719 case '!':
720 case '~':
721 flags = RIGHT_OPERAND_REQUIRED;
722 rprio = UNARY_PRIO;
723 lprio = rprio + 1;
724 goto maybe_reduce;
725 case '*':
726 case '/':
727 case '%':
728 lprio = MUL_PRIO;
729 goto binop;
730 case '<':
731 case '>':
732 case LEQ:
733 case GEQ:
734 lprio = LESS_PRIO;
735 goto binop;
736 case EQUAL:
737 case NOTEQUAL:
738 lprio = EQUAL_PRIO;
739 goto binop;
740 case LSH:
741 case RSH:
742 lprio = SHIFT_PRIO;
743 goto binop;
744 case '&':
745 lprio = AND_PRIO;
746 goto binop;
747 case '^':
748 lprio = XOR_PRIO;
749 goto binop;
750 case '|':
751 lprio = OR_PRIO;
752 goto binop;
753 case ANDAND:
754 lprio = ANDAND_PRIO;
755 goto binop;
756 case OROR:
757 lprio = OROR_PRIO;
758 goto binop;
759 case ',':
760 lprio = COMMA_PRIO;
761 goto binop;
762 case '(':
763 lprio = PAREN_OUTER_PRIO;
764 rprio = PAREN_INNER_PRIO;
765 goto maybe_reduce;
766 case ')':
767 lprio = PAREN_INNER_PRIO;
768 rprio = PAREN_OUTER_PRIO;
769 goto maybe_reduce;
770 case ':':
771 lprio = COND_PRIO;
772 rprio = COND_PRIO;
773 goto maybe_reduce;
774 case '?':
775 lprio = COND_PRIO + 1;
776 rprio = COND_PRIO;
777 goto maybe_reduce;
778 binop:
779 flags = LEFT_OPERAND_REQUIRED | RIGHT_OPERAND_REQUIRED;
780 rprio = lprio + 1;
781 goto maybe_reduce;
782 default:
783 cpp_error(pfile, "invalid character in #if");
784 goto syntax_error;
785 }
786
787 set_value:
788 /* Push a value onto the stack. */
789 if (top->flags & HAVE_VALUE)
790 {
791 cpp_error(pfile, "syntax error in #if");
792 goto syntax_error;
793 }
794 top->flags |= HAVE_VALUE;
795 continue;
796
797 maybe_reduce:
798 /* Push an operator, and check if we can reduce now. */
799 while (top->rprio > lprio)
800 {
801 long v1 = top[-1].value, v2 = top[0].value;
802 int unsigned1 = top[-1].unsignedp, unsigned2 =
803 top[0].unsignedp;
804
805 top--;
806 if ((top[1].flags & LEFT_OPERAND_REQUIRED)
807 && !(top[0].flags & HAVE_VALUE))
808 {
809 cpp_error(pfile, "syntax error - missing left operand");
810 goto syntax_error;
811 }
812 if ((top[1].flags & RIGHT_OPERAND_REQUIRED)
813 && !(top[1].flags & HAVE_VALUE))
814 {
815 cpp_error(pfile, "syntax error - missing right operand");
816 goto syntax_error;
817 }
818 /* top[0].value = (top[1].op)(v1, v2); */
819 switch (top[1].op)
820 {
821 case '+':
822 if (!(top->flags & HAVE_VALUE))
823 { /* Unary '+' */
824 top->value = v2;
825 top->unsignedp = unsigned2;
826 top->flags |= HAVE_VALUE;
827 }
828 else
829 {
830 top->value = v1 + v2;
831 top->unsignedp = unsigned1 || unsigned2;
832 if (!top->unsignedp && !skip_evaluation
833 && !possible_sum_sign(v1, v2, top->value))
834 integer_overflow(pfile);
835 }
836 break;
837 case '-':
838 if (skip_evaluation); /* do nothing */
839 else if (!(top->flags & HAVE_VALUE))
840 { /* Unary '-' */
841 top->value = -v2;
842 if ((top->value & v2) < 0 && !unsigned2)
843 integer_overflow(pfile);
844 top->unsignedp = unsigned2;
845 top->flags |= HAVE_VALUE;
846 }
847 else
848 { /* Binary '-' */
849 top->value = v1 - v2;
850 top->unsignedp = unsigned1 || unsigned2;
851 if (!top->unsignedp
852 && !possible_sum_sign(top->value, v2, v1))
853 integer_overflow(pfile);
854 }
855 break;
856 case '*':
857 top->unsignedp = unsigned1 || unsigned2;
858 if (top->unsignedp)
859 top->value = (unsigned long)v1 *v2;
860
861 else if (!skip_evaluation)
862 {
863 top->value = v1 * v2;
864 if (v1
865 && (top->value / v1 != v2
866 || (top->value & v1 & v2) < 0))
867 integer_overflow(pfile);
868 }
869 break;
870 case '/':
871 if (skip_evaluation)
872 break;
873 if (v2 == 0)
874 {
875 cpp_error(pfile, "division by zero in #if");
876 v2 = 1;
877 }
878 top->unsignedp = unsigned1 || unsigned2;
879 if (top->unsignedp)
880 top->value = (unsigned long)v1 / v2;
881 else
882 {
883 top->value = v1 / v2;
884 if ((top->value & v1 & v2) < 0)
885 integer_overflow(pfile);
886 }
887 break;
888 case '%':
889 if (skip_evaluation)
890 break;
891 if (v2 == 0)
892 {
893 cpp_error(pfile, "division by zero in #if");
894 v2 = 1;
895 }
896 top->unsignedp = unsigned1 || unsigned2;
897 if (top->unsignedp)
898 top->value = (unsigned long)v1 % v2;
899 else
900 top->value = v1 % v2;
901 break;
902 case '!':
903 if (top->flags & HAVE_VALUE)
904 {
905 cpp_error(pfile, "syntax error");
906 goto syntax_error;
907 }
908 top->value = !v2;
909 top->unsignedp = 0;
910 top->flags |= HAVE_VALUE;
911 break;
912 case '~':
913 if (top->flags & HAVE_VALUE)
914 {
915 cpp_error(pfile, "syntax error");
916 goto syntax_error;
917 }
918 top->value = ~v2;
919 top->unsignedp = unsigned2;
920 top->flags |= HAVE_VALUE;
921 break;
922 case '<':
923 COMPARE(<);
924 break;
925 case '>':
926 COMPARE(>);
927 break;
928 case LEQ:
929 COMPARE(<=);
930 break;
931 case GEQ:
932 COMPARE(>=);
933 break;
934 case EQUAL:
935 top->value = (v1 == v2);
936 top->unsignedp = 0;
937 break;
938 case NOTEQUAL:
939 top->value = (v1 != v2);
940 top->unsignedp = 0;
941 break;
942 case LSH:
943 if (skip_evaluation)
944 break;
945 top->unsignedp = unsigned1;
946 if (v2 < 0 && !unsigned2)
947 top->value = right_shift(pfile, v1, unsigned1, -v2);
948 else
949 top->value = left_shift(pfile, v1, unsigned1, v2);
950 break;
951 case RSH:
952 if (skip_evaluation)
953 break;
954 top->unsignedp = unsigned1;
955 if (v2 < 0 && !unsigned2)
956 top->value = left_shift(pfile, v1, unsigned1, -v2);
957 else
958 top->value = right_shift(pfile, v1, unsigned1, v2);
959 break;
960#define LOGICAL(OP) \
961 top->value = v1 OP v2;\
962 top->unsignedp = unsigned1 || unsigned2;
963 case '&':
964 LOGICAL(&);
965 break;
966 case '^':
967 LOGICAL(^);
968 break;
969 case '|':
970 LOGICAL(|);
971 break;
972 case ANDAND:
973 top->value = v1 && v2;
974 top->unsignedp = 0;
975 if (!v1)
976 skip_evaluation--;
977 break;
978 case OROR:
979 top->value = v1 || v2;
980 top->unsignedp = 0;
981 if (v1)
982 skip_evaluation--;
983 break;
984 case ',':
985 if (CPP_PEDANTIC(pfile))
986 cpp_pedwarn(pfile, "comma operator in operand of `#if'");
987 top->value = v2;
988 top->unsignedp = unsigned2;
989 break;
990 case '(':
991 case '?':
992 cpp_error(pfile, "syntax error in #if");
993 goto syntax_error;
994 case ':':
995 if (top[0].op != '?')
996 {
997 cpp_error(pfile,
998 "syntax error ':' without preceding '?'");
999 goto syntax_error;
1000 }
1001 else if (!(top[1].flags & HAVE_VALUE)
1002 || !(top[-1].flags & HAVE_VALUE)
1003 || !(top[0].flags & HAVE_VALUE))
1004 {
1005 cpp_error(pfile, "bad syntax for ?: operator");
1006 goto syntax_error;
1007 }
1008 else
1009 {
1010 top--;
1011 if (top->value)
1012 skip_evaluation--;
1013 top->value = top->value ? v1 : v2;
1014 top->unsignedp = unsigned1 || unsigned2;
1015 }
1016 break;
1017 case ')':
1018 if ((top[1].flags & HAVE_VALUE)
1019 || !(top[0].flags & HAVE_VALUE)
1020 || top[0].op != '(' || (top[-1].flags & HAVE_VALUE))
1021 {
1022 cpp_error(pfile, "mismatched parentheses in #if");
1023 goto syntax_error;
1024 }
1025 else
1026 {
1027 top--;
1028 top->value = v1;
1029 top->unsignedp = unsigned1;
1030 top->flags |= HAVE_VALUE;
1031 }
1032 break;
1033 default:
1034 fprintf(stderr,
1035 top[1].op >= ' ' && top[1].op <= '~'
1036 ? "unimplemented operator '%c'\n"
1037 : "unimplemented operator '\\%03o'\n", top[1].op);
1038 }
1039 }
1040 if (op.op == 0)
1041 {
1042 if (top != stack)
1043 cpp_error(pfile, "internal error in #if expression");
1044 if (stack != init_stack)
1045 free(stack);
1046 return top->value;
1047 }
1048 top++;
1049
1050 /* Check for and handle stack overflow. */
1051 if (top == limit)
1052 {
1053 struct operation *new_stack;
1054 int old_size = (char *)limit - (char *)stack;
1055 int new_size = 2 * old_size;
1056
1057 if (stack != init_stack)
1058 new_stack = (struct operation *)xrealloc(stack, new_size);
1059 else
1060 {
1061 new_stack = (struct operation *)xmalloc(new_size);
1062 memcpy((char *)new_stack, (char *)stack, old_size);
1063 }
1064 stack = new_stack;
1065 top = (struct operation *)((char *)new_stack + old_size);
1066 limit = (struct operation *)((char *)new_stack + new_size);
1067 }
1068 top->flags = flags;
1069 top->rprio = rprio;
1070 top->op = op.op;
1071 if ((op.op == OROR && top[-1].value)
1072 || (op.op == ANDAND && !top[-1].value)
1073 || (op.op == '?' && !top[-1].value))
1074 {
1075 skip_evaluation++;
1076 }
1077 else if (op.op == ':')
1078 {
1079 if (top[-2].value) /* Was condition true? */
1080 skip_evaluation++;
1081 else
1082 skip_evaluation--;
1083 }
1084 }
1085 syntax_error:
1086 if (stack != init_stack)
1087 free(stack);
1088 skip_rest_of_line(pfile);
1089 return 0;
1090}
diff --git a/libraries/edje/src/bin/epp/cpphash.c b/libraries/edje/src/bin/epp/cpphash.c
new file mode 100644
index 0000000..e3b68e0
--- /dev/null
+++ b/libraries/edje/src/bin/epp/cpphash.c
@@ -0,0 +1,198 @@
1/* Part of CPP library. (Macro hash table support.)
2 * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
3 * Written by Per Bothner, 1994.
4 * Based on CCCP program by by Paul Rubin, June 1986
5 * Adapted to ANSI C, Richard Stallman, Jan 1987
6 * Copyright (C) 2003-2011 Kim Woelders
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * In other words, you are welcome to use, share and improve this program.
23 * You are forbidden to forbid anyone else to use, share and improve
24 * what you give them. Help stamp out software-hoarding! */
25
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30#include <string.h>
31#include <stdlib.h>
32
33#include "cpplib.h"
34#include "cpphash.h"
35
36static HASHNODE *hashtab[HASHSIZE];
37
38#define IS_IDCHAR(ch) is_idchar[(unsigned char)(ch)]
39
40/*
41 * return hash function on name. must be compatible with the one
42 * computed a step at a time, elsewhere
43 */
44int
45hashf(const char *name, int len, int hashsize)
46{
47 int r = 0;
48
49 while (len--)
50 r = HASHSTEP(r, *name++);
51
52 return MAKE_POS(r) % hashsize;
53}
54
55/*
56 * find the most recent hash node for name name (ending with first
57 * non-identifier char) installed by install
58 *
59 * If LEN is >= 0, it is the length of the name.
60 * Otherwise, compute the length by scanning the entire name.
61 *
62 * If HASH is >= 0, it is the precomputed hash code.
63 * Otherwise, compute the hash code.
64 */
65HASHNODE *
66cpp_lookup(const char *name, int len, int hash)
67{
68 const char *bp;
69 HASHNODE *bucket;
70
71 if (len < 0)
72 {
73 for (bp = name; IS_IDCHAR(*bp); bp++)
74 ;
75 len = bp - name;
76 }
77 if (hash < 0)
78 hash = hashf(name, len, HASHSIZE);
79
80 bucket = hashtab[hash];
81 while (bucket)
82 {
83 if (bucket->length == len
84 && strncmp((const char *)bucket->name, name, len) == 0)
85 return bucket;
86 bucket = bucket->next;
87 }
88 return (HASHNODE *) 0;
89}
90
91/*
92 * Delete a hash node. Some weirdness to free junk from macros.
93 * More such weirdness will have to be added if you define more hash
94 * types that need it.
95 */
96
97/* Note that the DEFINITION of a macro is removed from the hash table
98 * but its storage is not freed. This would be a storage leak
99 * except that it is not reasonable to keep undefining and redefining
100 * large numbers of macros many times.
101 * In any case, this is necessary, because a macro can be #undef'd
102 * in the middle of reading the arguments to a call to it.
103 * If #undef freed the DEFINITION, that would crash. */
104
105void
106delete_macro(HASHNODE * hp)
107{
108
109 if (hp->prev)
110 hp->prev->next = hp->next;
111 if (hp->next)
112 hp->next->prev = hp->prev;
113
114 /* make sure that the bucket chain header that
115 * the deleted guy was on points to the right thing afterwards. */
116 if (hp == *hp->bucket_hdr)
117 *hp->bucket_hdr = hp->next;
118
119 if (hp->type == T_MACRO)
120 {
121 DEFINITION *d = hp->value.defn;
122 struct reflist *ap, *nextap;
123
124 for (ap = d->pattern; ap; ap = nextap)
125 {
126 nextap = ap->next;
127 free(ap);
128 }
129 if (d->nargs >= 0)
130 free(d->args.argnames);
131 free(d);
132 }
133 free(hp);
134}
135/*
136 * install a name in the main hash table, even if it is already there.
137 * name stops with first non alphanumeric, except leading '#'.
138 * caller must check against redefinition if that is desired.
139 * delete_macro () removes things installed by install () in fifo order.
140 * this is important because of the `defined' special symbol used
141 * in #if, and also if pushdef/popdef directives are ever implemented.
142 *
143 * If LEN is >= 0, it is the length of the name.
144 * Otherwise, compute the length by scanning the entire name.
145 *
146 * If HASH is >= 0, it is the precomputed hash code.
147 * Otherwise, compute the hash code.
148 */
149HASHNODE *
150install(const char *name, int len, enum node_type type, int ivalue, char *value,
151 int hash)
152{
153 HASHNODE *hp;
154 int i, bucket;
155 const char *p;
156
157 if (len < 0)
158 {
159 p = name;
160 while (IS_IDCHAR(*p))
161 p++;
162 len = p - name;
163 }
164 if (hash < 0)
165 hash = hashf(name, len, HASHSIZE);
166
167 i = sizeof(HASHNODE) + len + 1;
168 hp = (HASHNODE *) xmalloc(i);
169 bucket = hash;
170 hp->bucket_hdr = &hashtab[bucket];
171 hp->next = hashtab[bucket];
172 hashtab[bucket] = hp;
173 hp->prev = NULL;
174 if (hp->next)
175 hp->next->prev = hp;
176 hp->type = type;
177 hp->length = len;
178 if (hp->type == T_CONST)
179 hp->value.ival = ivalue;
180 else
181 hp->value.cpval = value;
182 hp->name = ((char *)hp) + sizeof(HASHNODE);
183 memcpy(hp->name, name, len);
184 hp->name[len] = 0;
185 return hp;
186}
187
188void
189cpp_hash_cleanup(cpp_reader * pfile __UNUSED__)
190{
191 int i;
192
193 for (i = HASHSIZE; --i >= 0;)
194 {
195 while (hashtab[i])
196 delete_macro(hashtab[i]);
197 }
198}
diff --git a/libraries/edje/src/bin/epp/cpphash.h b/libraries/edje/src/bin/epp/cpphash.h
new file mode 100644
index 0000000..524a850
--- /dev/null
+++ b/libraries/edje/src/bin/epp/cpphash.h
@@ -0,0 +1,41 @@
1enum node_type;
2
3/* different kinds of things that can appear in the value field
4 of a hash node. Actually, this may be useless now. */
5union hashval {
6 int ival;
7 char *cpval;
8 DEFINITION *defn;
9};
10
11struct hashnode {
12 struct hashnode *next; /* double links for easy deletion */
13 struct hashnode *prev;
14 struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash
15 * chain is kept, in case the node is the head
16 * of the chain and gets deleted. */
17 enum node_type type; /* type of special token */
18 int length; /* length of token, for quick comparison */
19 char *name; /* the actual name */
20 union hashval value; /* pointer to expansion, or whatever */
21};
22
23typedef struct hashnode HASHNODE;
24
25/* Some definitions for the hash table. The hash function MUST be
26 computed as shown in hashf () below. That is because the rescan
27 loop computes the hash value `on the fly' for most tokens,
28 in order to avoid the overhead of a lot of procedure calls to
29 the hashf () function. Hashf () only exists for the sake of
30 politeness, for use when speed isn't so important. */
31
32#define HASHSIZE 1403
33#define HASHSTEP(old, c) ((old << 2) + c)
34#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */
35
36extern int hashf(const char *name, int len, int hashsize);
37extern HASHNODE *cpp_lookup(const char *name, int len, int hash);
38extern void delete_macro(HASHNODE * hp);
39extern HASHNODE *install(const char *name, int len, enum node_type type,
40 int ivalue, char *value, int hash);
41extern void cpp_hash_cleanup(cpp_reader * pfile);
diff --git a/libraries/edje/src/bin/epp/cpplib.c b/libraries/edje/src/bin/epp/cpplib.c
new file mode 100644
index 0000000..132d2a9
--- /dev/null
+++ b/libraries/edje/src/bin/epp/cpplib.c
@@ -0,0 +1,7427 @@
1/* CPP Library.
2 * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
3 * Written by Per Bothner, 1994-95.
4 * Based on CCCP program by by Paul Rubin, June 1986
5 * Adapted to ANSI C, Richard Stallman, Jan 1987
6 * Copyright (C) 2003-2011 Kim Woelders
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * In other words, you are welcome to use, share and improve this program.
23 * You are forbidden to forbid anyone else to use, share and improve
24 * what you give them. Help stamp out software-hoarding! */
25
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30#ifdef HAVE_ALLOCA_H
31# include <alloca.h>
32#elif defined __GNUC__
33# define alloca __builtin_alloca
34#elif defined _AIX
35# define alloca __alloca
36#elif defined _MSC_VER
37# include <malloc.h>
38# define alloca _alloca
39#else
40# include <stddef.h>
41void *alloca (size_t);
42#endif
43
44#ifdef __EMX__
45#include <strings.h>
46#endif
47
48#ifndef STANDARD_INCLUDE_DIR
49#define STANDARD_INCLUDE_DIR "/usr/include"
50#endif
51
52#ifndef LOCAL_INCLUDE_DIR
53#define LOCAL_INCLUDE_DIR "/usr/local/include"
54#endif
55
56#include "cpplib.h"
57#include "cpphash.h"
58
59/*
60 * On Windows, if the file is not opened in binary mode,
61 * read does not return the correct size, because of
62 * CR / LF translation.
63 */
64#ifndef O_BINARY
65# define O_BINARY 0
66#endif
67
68const char *version_string = "0.0.0";
69
70#ifndef STDC_VALUE
71#define STDC_VALUE 1
72#endif
73
74/* By default, colon separates directories in a path. */
75#ifndef PATH_SEPARATOR
76#define PATH_SEPARATOR ':'
77#endif
78
79#include <ctype.h>
80#include <stdio.h>
81#include <string.h>
82#include <signal.h>
83#include <stdlib.h>
84#include <unistd.h>
85#include <sys/types.h>
86#include <sys/stat.h>
87#include <fcntl.h>
88#include <stdlib.h>
89
90#ifndef VMS
91#ifndef USG
92#include <time.h>
93#include <sys/time.h> /* for __DATE__ and __TIME__ */
94#ifdef HAVE_SYS_RESOURCE_H
95# include <sys/resource.h>
96#endif
97#else
98#include <sys/param.h> /* CYGNUS LOCAL: shebs -noquiet */
99#include <sys/times.h>
100#include <time.h>
101#include <fcntl.h>
102#endif /* USG */
103#endif /* not VMS */
104
105/* This defines "errno" properly for VMS, and gives us EACCES. */
106#include <errno.h>
107
108#ifndef O_RDONLY
109#define O_RDONLY 0
110#endif
111
112#undef MIN
113#undef MAX
114#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
115#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
116
117#ifndef S_ISREG
118#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
119#endif
120
121#ifndef S_ISDIR
122#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
123#endif
124
125/* Define a generic NULL if one hasn't already been defined. */
126
127#ifndef GENERIC_PTR
128#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
129#define GENERIC_PTR void *
130#else
131#define GENERIC_PTR char *
132#endif
133#endif
134
135#ifndef INCLUDE_LEN_FUDGE
136#define INCLUDE_LEN_FUDGE 0
137#endif
138
139#define USE_FILE_NAME_MAPS 0
140
141/* Symbols to predefine. */
142
143#ifdef CPP_PREDEFINES
144static const char *predefs = CPP_PREDEFINES;
145
146#else
147static const char *predefs = "";
148
149#endif
150
151/* We let tm.h override the types used here, to handle trivial differences
152 * such as the choice of unsigned int or long unsigned int for size_t.
153 * When machines start needing nontrivial differences in the size type,
154 * it would be best to do something here to figure out automatically
155 * from other information what type to use. */
156
157/* The string value for __SIZE_TYPE__. */
158
159#ifndef SIZE_TYPE
160#define SIZE_TYPE "long unsigned int"
161#endif
162
163/* The string value for __PTRDIFF_TYPE__. */
164
165#ifndef PTRDIFF_TYPE
166#define PTRDIFF_TYPE "long int"
167#endif
168
169/* The string value for __WCHAR_TYPE__. */
170
171#ifndef WCHAR_TYPE
172#define WCHAR_TYPE "int"
173#endif
174#define CPP_WCHAR_TYPE(PFILE) \
175 (CPP_OPTIONS (PFILE)->cplusplus ? "__wchar_t" : WCHAR_TYPE)
176
177/* The string value for __USER_LABEL_PREFIX__ */
178
179#ifndef USER_LABEL_PREFIX
180#define USER_LABEL_PREFIX ""
181#endif
182
183/* The string value for __REGISTER_PREFIX__ */
184
185#ifndef REGISTER_PREFIX
186#define REGISTER_PREFIX ""
187#endif
188
189struct directive {
190 int length;
191 int (*func) (cpp_reader * pfile, struct directive * keyword,
192 unsigned char *buf, unsigned char *limit);
193 const char *name;
194 enum node_type type;
195 char command_reads_line;
196 char traditional_comments;
197 char pass_thru;
198};
199
200/* In the definition of a #assert name, this structure forms
201 * a list of the individual values asserted.
202 * Each value is itself a list of "tokens".
203 * These are strings that are compared by name. */
204
205struct tokenlist_list {
206 struct tokenlist_list *next;
207 struct arglist *tokens;
208};
209
210struct assertion_hashnode {
211 struct assertion_hashnode *next; /* double links for easy deletion */
212 struct assertion_hashnode *prev;
213 /* also, a back pointer to this node's hash
214 * chain is kept, in case the node is the head
215 * of the chain and gets deleted. */
216 struct assertion_hashnode **bucket_hdr;
217 int length; /* length of token, for quick comparison */
218 char *name; /* the actual name */
219 /* List of token-sequences. */
220 struct tokenlist_list *value;
221};
222
223#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[(unsigned char)(*p)]) p++; } while (0)
224#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[(unsigned char)(*p)]) p++; } while (0)
225
226#define PEEKN(N) (CPP_BUFFER (pfile)->rlimit - CPP_BUFFER (pfile)->cur >= (N) ? CPP_BUFFER (pfile)->cur[N] : EOF)
227#define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N))
228#define GETC() CPP_BUF_GET (CPP_BUFFER (pfile))
229#define PEEKC() CPP_BUF_PEEK (CPP_BUFFER (pfile))
230/* CPP_IS_MACRO_BUFFER is true if the buffer contains macro expansion.
231 * (Note that it is false while we're expanding marco *arguments*.) */
232#define CPP_IS_MACRO_BUFFER(PBUF) ((PBUF)->cleanup == macro_cleanup)
233
234/* Move all backslash-newline pairs out of embarrassing places.
235 * Exchange all such pairs following BP
236 * with any potentially-embarrassing characters that follow them.
237 * Potentially-embarrassing characters are / and *
238 * (because a backslash-newline inside a comment delimiter
239 * would cause it not to be recognized). */
240
241#define NEWLINE_FIX \
242 do {while (PEEKC() == '\\' && PEEKN(1) == '\n') FORWARD(2); } while(0)
243
244/* Same, but assume we've already read the potential '\\' into C. */
245#define NEWLINE_FIX1(C) do { \
246 while ((C) == '\\' && PEEKC() == '\n') { FORWARD(1); (C) = GETC(); }\
247 } while(0)
248
249/* Name under which this program was invoked. */
250
251char *progname;
252
253struct cpp_pending {
254 struct cpp_pending *next;
255 const char *cmd;
256 const char *arg;
257};
258
259/* Structure returned by create_definition */
260typedef struct {
261 struct definition *defn;
262 char *symnam;
263 int symlen;
264} MACRODEF;
265
266/* Forward declarations. */
267typedef struct file_name_list file_name_list;
268
269static void add_import(cpp_reader * pfile, int fd, char *fname);
270static int finclude(cpp_reader * pfile, int f, const char *fname,
271 int system_header_p, file_name_list * dirptr);
272static void validate_else(cpp_reader * pfile, const char *directive);
273static int comp_def_part(int first, unsigned char *beg1, int len1,
274 unsigned char *beg2, int len2, int last);
275static int lookup_import(cpp_reader * pfile, char *filename,
276 file_name_list * searchptr);
277static int redundant_include_p(cpp_reader * pfile, char *name);
278
279static int is_system_include(cpp_reader * pfile, char *filename);
280
281static int open_include_file(cpp_reader * pfile, char *filename,
282 file_name_list * searchptr);
283static int check_macro_name(cpp_reader * pfile, unsigned char *symname,
284 const char *usage);
285
286static int compare_token_lists(struct arglist *l1, struct arglist *l2);
287static HOST_WIDE_INT eval_if_expression(cpp_reader * pfile, unsigned char *buf,
288 int length);
289
290static int file_size_and_mode(int fd, int *mode_pointer,
291 long int *size_pointer);
292static struct arglist *read_token_list(cpp_reader * pfile, int *error_flag);
293static void free_token_list(struct arglist *tokens);
294static int safe_read(int desc, char *ptr, int len);
295static void push_macro_expansion(cpp_reader * pfile,
296 unsigned char *x,
297 int xbuf_len, HASHNODE * hp);
298
299static struct cpp_pending *nreverse_pending(struct cpp_pending *list);
300static char *savestring(const char *input);
301
302static void conditional_skip(cpp_reader * pfile, int skip,
303 enum node_type type,
304 unsigned char *control_macro);
305static void skip_if_group(cpp_reader * pfile, int any);
306
307static void cpp_error_with_line(cpp_reader * pfile, int line,
308 int column, const char *msg);
309static void cpp_pedwarn_with_line(cpp_reader * pfile, int line,
310 int column, const char *msg);
311static void cpp_pedwarn_with_file_and_line(cpp_reader * pfile,
312 const char *file, int line,
313 const char *msg,
314 const char *arg1,
315 const char *arg2,
316 const char *arg3);
317static void cpp_error_from_errno(cpp_reader * pfile, const char *name);
318
319static cpp_buffer *cpp_push_buffer(cpp_reader * pfile, unsigned char *buffer,
320 long length);
321static cpp_buffer *cpp_pop_buffer(cpp_reader * pfile);
322
323/* Last arg to output_line_command. */
324enum file_change_code {
325 same_file, enter_file, leave_file
326};
327
328/* These functions are declared to return int instead of void since they
329 * are going to be placed in a table and some old compilers have trouble with
330 * pointers to functions returning void. */
331
332static int do_define(cpp_reader * pfile, struct directive *keyword,
333 unsigned char *buf, unsigned char *limit);
334
335static int do_line(cpp_reader * pfile, struct directive *keyword,
336 unsigned char *unused1, unsigned char *unused2);
337
338static int do_include(cpp_reader * pfile, struct directive *keyword,
339 unsigned char *unused1, unsigned char *unused2);
340
341static int do_undef(cpp_reader * pfile, struct directive *keyword,
342 unsigned char *buf, unsigned char *limit);
343
344static int do_error(cpp_reader * pfile, struct directive *keyword,
345 unsigned char *buf, unsigned char *limit);
346
347static int do_pragma(cpp_reader * pfile, struct directive *keyword,
348 unsigned char *buf, unsigned char *limit);
349
350static int do_ident(cpp_reader * pfile, struct directive *keyword,
351 unsigned char *buf, unsigned char *limit);
352
353static int do_if(cpp_reader * pfile, struct directive *keyword,
354 unsigned char *buf, unsigned char *limit);
355
356static int do_xifdef(cpp_reader * pfile, struct directive *keyword,
357 unsigned char *buf, unsigned char *limit);
358
359static int do_else(cpp_reader * pfile, struct directive *keyword,
360 unsigned char *buf, unsigned char *limit);
361
362static int do_elif(cpp_reader * pfile, struct directive *keyword,
363 unsigned char *buf, unsigned char *limit);
364
365static int do_endif(cpp_reader * pfile, struct directive *keyword,
366 unsigned char *buf, unsigned char *limit);
367
368static int do_assert(cpp_reader * pfile, struct directive *keyword,
369 unsigned char *buf, unsigned char *limit);
370
371static int do_unassert(cpp_reader * pfile, struct directive *keyword,
372 unsigned char *buf, unsigned char *limit);
373
374static int do_warning(cpp_reader * pfile, struct directive *keyword,
375 unsigned char *buf, unsigned char *limit);
376
377struct arglist *reverse_token_list(struct arglist *tokens);
378
379static int parse_name(cpp_reader * pfile, int c);
380
381static void parse_set_mark(struct parse_marker *pmark,
382 cpp_reader * pfile);
383static void parse_clear_mark(struct parse_marker *pmark);
384static void parse_goto_mark(struct parse_marker *pmark,
385 cpp_reader * pfile);
386static void parse_move_mark(struct parse_marker *pmark,
387 cpp_reader * pfile);
388
389struct file_name_list {
390 file_name_list *next;
391 char *fname;
392 /* If the following is nonzero, it is a macro name.
393 * Don't include the file again if that macro is defined. */
394 unsigned char *control_macro;
395 /* If the following is nonzero, it is a C-language system include
396 * directory. */
397 int c_system_include_path;
398 /* Mapping of file names for this directory. */
399 struct file_name_map *name_map;
400 /* Non-zero if name_map is valid. */
401 int got_name_map;
402};
403
404/* If a buffer's dir field is SELF_DIR_DUMMY, it means the file was found
405 * via the same directory as the file that #included it. */
406#define SELF_DIR_DUMMY ((file_name_list*)(~0))
407
408/* #include "file" looks in source file dir, then stack. */
409/* #include <file> just looks in the stack. */
410/* -I directories are added to the end, then the defaults are added. */
411/* The */
412static struct default_include {
413 const char *fname; /* The name of the directory. */
414 int cplusplus; /* Only look here if we're compiling C++. */
415 int cxx_aware; /* Includes in this directory don't need to
416 * be wrapped in extern "C" when compiling
417 * C++. */
418} include_defaults_array[]
419#ifdef INCLUDE_DEFAULTS
420 = INCLUDE_DEFAULTS;
421
422#else
423 =
424{
425 /* Pick up GNU C++ specific include files. */
426 {
427 GPLUSPLUS_INCLUDE_DIR, 1, 1}
428 ,
429#ifdef CROSS_COMPILE
430 /* This is the dir for fixincludes. Put it just before
431 * the files that we fix. */
432 {
433 GCC_INCLUDE_DIR, 0, 0}
434 ,
435 /* For cross-compilation, this dir name is generated
436 * automatically in Makefile.in. */
437 {
438 CROSS_INCLUDE_DIR, 0, 0}
439 ,
440 /* This is another place that the target system's headers might be. */
441 {
442 TOOL_INCLUDE_DIR, 0, 1}
443 ,
444#else /* not CROSS_COMPILE */
445 /* This should be /usr/local/include and should come before
446 * the fixincludes-fixed header files. */
447 {
448 LOCAL_INCLUDE_DIR, 0, 1}
449 ,
450 /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here.
451 * Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h. */
452 {
453 TOOL_INCLUDE_DIR, 0, 1}
454 ,
455 /* This is the dir for fixincludes. Put it just before
456 * the files that we fix. */
457 {
458 GCC_INCLUDE_DIR, 0, 0}
459 ,
460 /* Some systems have an extra dir of include files. */
461#ifdef SYSTEM_INCLUDE_DIR
462 {
463 SYSTEM_INCLUDE_DIR, 0, 0}
464 ,
465#endif
466 {
467 STANDARD_INCLUDE_DIR, 0, 0}
468 ,
469#endif /* not CROSS_COMPILE */
470 {
471 0, 0, 0}
472};
473
474#endif /* no INCLUDE_DEFAULTS */
475
476/* Here is the actual list of #-directives, most-often-used first.
477 * The initialize_builtins function assumes #define is the very first. */
478
479static struct directive directive_table[] = {
480 {6, do_define, "define", T_DEFINE, 0, 1, 0},
481 {5, do_xifdef, "ifdef", T_IFDEF, 1, 0, 0},
482 {6, do_xifdef, "ifndef", T_IFNDEF, 1, 0, 0},
483 {7, do_include, "include", T_INCLUDE, 1, 0, 0},
484 {12, do_include, "include_next", T_INCLUDE_NEXT, 1, 0, 0},
485 {6, do_include, "import", T_IMPORT, 1, 0, 0},
486 {5, do_endif, "endif", T_ENDIF, 1, 0, 0},
487 {4, do_else, "else", T_ELSE, 1, 0, 0},
488 {2, do_if, "if", T_IF, 1, 0, 0},
489 {4, do_elif, "elif", T_ELIF, 1, 0, 0},
490 {5, do_undef, "undef", T_UNDEF, 0, 0, 0},
491 {5, do_error, "error", T_ERROR, 0, 0, 0},
492 {7, do_warning, "warning", T_WARNING, 0, 0, 0},
493 {6, do_pragma, "pragma", T_PRAGMA, 0, 0, 1},
494 {4, do_line, "line", T_LINE, 1, 0, 0},
495 {5, do_ident, "ident", T_IDENT, 1, 0, 1},
496#ifdef SCCS_DIRECTIVE
497 {4, do_sccs, "sccs", T_SCCS, 0, 0, 0},
498#endif
499 {6, do_assert, "assert", T_ASSERT, 1, 0, 0},
500 {8, do_unassert, "unassert", T_UNASSERT, 1, 0, 0},
501 {-1, 0, "", T_UNUSED, 0, 0, 0},
502};
503
504/* table to tell if char can be part of a C identifier. */
505unsigned char is_idchar[256];
506
507/* table to tell if char can be first char of a c identifier. */
508unsigned char is_idstart[256];
509
510/* table to tell if c is horizontal space. */
511unsigned char is_hor_space[256];
512
513/* table to tell if c is horizontal or vertical space. */
514static unsigned char is_space[256];
515
516/* Initialize syntactic classifications of characters. */
517
518static void
519initialize_char_syntax(struct cpp_options *opts)
520{
521 int i;
522
523 /*
524 * Set up is_idchar and is_idstart tables. These should be
525 * faster than saying (is_alpha (c) || c == '_'), etc.
526 * Set up these things before calling any routines tthat
527 * refer to them.
528 */
529 for (i = 'a'; i <= 'z'; i++)
530 {
531 is_idchar[i - 'a' + 'A'] = 1;
532 is_idchar[i] = 1;
533 is_idstart[i - 'a' + 'A'] = 1;
534 is_idstart[i] = 1;
535 }
536 for (i = '0'; i <= '9'; i++)
537 is_idchar[i] = 1;
538 is_idchar[(unsigned char)'_'] = 1;
539 is_idstart[(unsigned char)'_'] = 1;
540 is_idchar[(unsigned char)'$'] = opts->dollars_in_ident;
541 is_idstart[(unsigned char)'$'] = opts->dollars_in_ident;
542
543 /* horizontal space table */
544 is_hor_space[(unsigned char)' '] = 1;
545 is_hor_space[(unsigned char)'\t'] = 1;
546 is_hor_space[(unsigned char)'\v'] = 1;
547 is_hor_space[(unsigned char)'\f'] = 1;
548 is_hor_space[(unsigned char)'\r'] = 1;
549
550 is_space[(unsigned char)' '] = 1;
551 is_space[(unsigned char)'\t'] = 1;
552 is_space[(unsigned char)'\v'] = 1;
553 is_space[(unsigned char)'\f'] = 1;
554 is_space[(unsigned char)'\n'] = 1;
555 is_space[(unsigned char)'\r'] = 1;
556}
557
558/* Place into PFILE a quoted string representing the string SRC.
559 * Caller must reserve enough space in pfile->token_buffer. */
560static void
561quote_string(cpp_reader * pfile, const char *src)
562{
563 unsigned char c;
564
565 CPP_PUTC_Q(pfile, '\"');
566 for (;;)
567 switch ((c = *src++))
568 {
569 default:
570 if (isprint(c))
571 CPP_PUTC_Q(pfile, c);
572 else
573 {
574 sprintf((char *)CPP_PWRITTEN(pfile), "\\%03o", c);
575 CPP_ADJUST_WRITTEN(pfile, 4);
576 }
577 break;
578
579 case '\"':
580 case '\\':
581 CPP_PUTC_Q(pfile, '\\');
582 CPP_PUTC_Q(pfile, c);
583 break;
584
585 case '\0':
586 CPP_PUTC_Q(pfile, '\"');
587 CPP_NUL_TERMINATE_Q(pfile);
588 return;
589 }
590}
591
592/* Make sure PFILE->token_buffer will hold at least N more chars. */
593
594void
595cpp_grow_buffer(cpp_reader * pfile, long n)
596{
597 long old_written = CPP_WRITTEN(pfile);
598
599 pfile->token_buffer_size = n + 2 * pfile->token_buffer_size;
600 pfile->token_buffer =
601 (unsigned char *)xrealloc(pfile->token_buffer, pfile->token_buffer_size);
602 CPP_SET_WRITTEN(pfile, old_written);
603}
604
605/*
606 * process a given definition string, for initialization
607 * If STR is just an identifier, define it with value 1.
608 * If STR has anything after the identifier, then it should
609 * be identifier=definition.
610 */
611
612void
613cpp_define(cpp_reader * pfile, unsigned char *str)
614{
615 unsigned char *buf, *p;
616
617 buf = str;
618 p = str;
619 if (!is_idstart[*p])
620 {
621 cpp_error(pfile, "malformed option `-D %s'", str);
622 return;
623 }
624 while (is_idchar[*++p])
625 ;
626 if (*p == 0)
627 {
628 buf = (unsigned char *)alloca(p - buf + 4);
629 strcpy((char *)buf, (const char *)str);
630 strcat((char *)buf, " 1");
631 }
632 else if (*p != '=')
633 {
634 cpp_error(pfile, "malformed option `-D %s'", str);
635 return;
636 }
637 else
638 {
639 unsigned char *q;
640
641 /* Copy the entire option so we can modify it. */
642 buf = (unsigned char *)alloca(2 * strlen((char *)str) + 1);
643 strncpy((char *)buf, (const char *)str, p - str);
644 /* Change the = to a space. */
645 buf[p - str] = ' ';
646 /* Scan for any backslash-newline and remove it. */
647 p++;
648 q = &buf[p - str];
649 while (*p)
650 {
651 if (*p == '\\' && p[1] == '\n')
652 p += 2;
653 else
654 *q++ = *p++;
655 }
656 *q = 0;
657 }
658
659 do_define(pfile, NULL, buf, buf + strlen((char *)buf));
660}
661
662/* Process the string STR as if it appeared as the body of a #assert.
663 * OPTION is the option name for which STR was the argument. */
664
665static void
666make_assertion(cpp_reader * pfile, const char *option, const char *str)
667{
668 unsigned char *buf, *p, *q;
669
670 /* Copy the entire option so we can modify it. */
671 buf = (unsigned char *)alloca(strlen((char *)str) + 1);
672 strcpy((char *)buf, (const char *)str);
673 /* Scan for any backslash-newline and remove it. */
674 p = q = buf;
675 while (*p)
676 {
677 *q++ = *p++;
678 }
679 *q = 0;
680
681 p = buf;
682 if (!is_idstart[*p])
683 {
684 cpp_error(pfile, "malformed option `%s %s'", option, str);
685 return;
686 }
687 while (is_idchar[*++p])
688 ;
689 while (*p == ' ' || *p == '\t')
690 p++;
691 if (!(*p == 0 || *p == '('))
692 {
693 cpp_error(pfile, "malformed option `%s %s'", option, str);
694 return;
695 }
696 cpp_push_buffer(pfile, buf, strlen((char *)buf));
697 do_assert(pfile, NULL, NULL, NULL);
698 cpp_pop_buffer(pfile);
699}
700
701/* Append a chain of `file_name_list's
702 * to the end of the main include chain.
703 * FIRST is the beginning of the chain to append, and LAST is the end. */
704
705static void
706append_include_chain(cpp_reader * pfile, file_name_list * first,
707 file_name_list * last)
708{
709 struct cpp_options *opts = CPP_OPTIONS(pfile);
710 file_name_list *dir;
711
712 if (!first || !last)
713 return;
714
715 if (!opts->include)
716 opts->include = first;
717 else
718 opts->last_include->next = first;
719
720 if (!opts->first_bracket_include)
721 opts->first_bracket_include = first;
722
723 for (dir = first;; dir = dir->next)
724 {
725 int len = strlen(dir->fname) + INCLUDE_LEN_FUDGE;
726
727 if (len > pfile->max_include_len)
728 pfile->max_include_len = len;
729 if (dir == last)
730 break;
731 }
732
733 last->next = NULL;
734 opts->last_include = last;
735}
736
737/* Add output to `deps_buffer' for the -M switch.
738 * STRING points to the text to be output.
739 * SPACER is ':' for targets, ' ' for dependencies, zero for text
740 * to be inserted literally. */
741
742static void
743deps_output(cpp_reader * pfile, const char *string, int spacer)
744{
745 int size = strlen(string);
746
747 if (size == 0)
748 return;
749
750#ifndef MAX_OUTPUT_COLUMNS
751#define MAX_OUTPUT_COLUMNS 72
752#endif
753 if (spacer
754 && pfile->deps_column > 0
755 && (pfile->deps_column + size) > MAX_OUTPUT_COLUMNS)
756 {
757 deps_output(pfile, " \\\n ", 0);
758 pfile->deps_column = 0;
759 }
760 if (pfile->deps_size + size + 8 > pfile->deps_allocated_size)
761 {
762 pfile->deps_allocated_size = (pfile->deps_size + size + 50) * 2;
763 pfile->deps_buffer = (char *)xrealloc(pfile->deps_buffer,
764 pfile->deps_allocated_size);
765 }
766 if (spacer == ' ' && pfile->deps_column > 0)
767 pfile->deps_buffer[pfile->deps_size++] = ' ';
768 memcpy(&pfile->deps_buffer[pfile->deps_size], string, size);
769 pfile->deps_size += size;
770 pfile->deps_column += size;
771 if (spacer == ':')
772 pfile->deps_buffer[pfile->deps_size++] = ':';
773 pfile->deps_buffer[pfile->deps_size] = 0;
774}
775
776/* Given a colon-separated list of file names PATH,
777 * add all the names to the search path for include files. */
778
779static void
780path_include(cpp_reader * pfile, char *path)
781{
782 char *p;
783
784 p = path;
785
786 if (*p)
787 while (1)
788 {
789 char *q = p;
790 char *name;
791 file_name_list *dirtmp;
792
793 /* Find the end of this name. */
794 while (*q != 0 && *q != PATH_SEPARATOR)
795 q++;
796 if (p == q)
797 {
798 /* An empty name in the path stands for the current directory. */
799 name = (char *)xmalloc(2);
800 name[0] = '.';
801 name[1] = 0;
802 }
803 else
804 {
805 /* Otherwise use the directory that is named. */
806 name = (char *)xmalloc(q - p + 1);
807 memcpy(name, p, q - p);
808 name[q - p] = 0;
809 }
810
811 dirtmp = (file_name_list *) xmalloc(sizeof(file_name_list));
812
813 dirtmp->next = 0; /* New one goes on the end */
814 dirtmp->control_macro = 0;
815 dirtmp->c_system_include_path = 0;
816 dirtmp->fname = name;
817 dirtmp->got_name_map = 0;
818 append_include_chain(pfile, dirtmp, dirtmp);
819
820 /* Advance past this name. */
821 p = q;
822 if (*p == 0)
823 break;
824 /* Skip the colon. */
825 p++;
826 }
827}
828
829void
830init_parse_options(struct cpp_options *opts)
831{
832 memset((char *)opts, 0, sizeof *opts);
833 opts->in_fname = NULL;
834 opts->out_fname = NULL;
835
836 /* Initialize is_idchar to allow $. */
837 opts->dollars_in_ident = 1;
838 initialize_char_syntax(opts);
839 opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 0;
840
841 opts->no_line_commands = 0;
842 opts->no_trigraphs = 1;
843 opts->put_out_comments = 0;
844 opts->print_include_names = 0;
845 opts->dump_macros = dump_none;
846 opts->no_output = 0;
847 opts->cplusplus = 0;
848 opts->cplusplus_comments = 1;
849
850 opts->verbose = 0;
851 opts->objc = 0;
852 opts->lang_asm = 0;
853 opts->for_lint = 0;
854 opts->chill = 0;
855 opts->pedantic_errors = 0;
856 opts->inhibit_warnings = 0;
857 opts->warn_comments = 0;
858 opts->warn_import = 1;
859 opts->warnings_are_errors = 0;
860}
861
862static enum cpp_token
863null_underflow(cpp_reader * pfile __UNUSED__)
864{
865 return CPP_EOF;
866}
867
868static int
869null_cleanup(cpp_buffer * pbuf __UNUSED__, cpp_reader * pfile __UNUSED__)
870{
871 return 0;
872}
873
874static int
875macro_cleanup(cpp_buffer * pbuf, cpp_reader * pfile __UNUSED__)
876{
877 HASHNODE *macro = (HASHNODE *) pbuf->data;
878
879 if (macro->type == T_DISABLED)
880 macro->type = T_MACRO;
881 if (macro->type != T_MACRO || pbuf->buf != macro->value.defn->expansion)
882 free(pbuf->buf);
883 return 0;
884}
885
886static int
887file_cleanup(cpp_buffer * pbuf, cpp_reader * pfile __UNUSED__)
888{
889 if (pbuf->buf)
890 {
891 free(pbuf->buf);
892 pbuf->buf = 0;
893 }
894 return 0;
895}
896
897/* Assuming we have read '/'.
898 * If this is the start of a comment (followed by '*' or '/'),
899 * skip to the end of the comment, and return ' '.
900 * Return EOF if we reached the end of file before the end of the comment.
901 * If not the start of a comment, return '/'. */
902
903static int
904skip_comment(cpp_reader * pfile, long *linep)
905{
906 int c = 0;
907
908 while (PEEKC() == '\\' && PEEKN(1) == '\n')
909 {
910 if (linep)
911 (*linep)++;
912 FORWARD(2);
913 }
914 if (PEEKC() == '*')
915 {
916 FORWARD(1);
917 for (;;)
918 {
919 int prev_c = c;
920
921 c = GETC();
922 if (c == EOF)
923 return EOF;
924 while (c == '\\' && PEEKC() == '\n')
925 {
926 if (linep)
927 (*linep)++;
928 FORWARD(1), c = GETC();
929 }
930 if (prev_c == '*' && c == '/')
931 return ' ';
932 if (c == '\n' && linep)
933 (*linep)++;
934 }
935 }
936 else if (PEEKC() == '/' && CPP_OPTIONS(pfile)->cplusplus_comments)
937 {
938 FORWARD(1);
939 for (;;)
940 {
941 c = GETC();
942 if (c == EOF)
943 return ' '; /* Allow // to be terminated by EOF. */
944 while (c == '\\' && PEEKC() == '\n')
945 {
946 FORWARD(1);
947 c = GETC();
948 if (linep)
949 (*linep)++;
950 }
951 if (c == '\n')
952 {
953 /* Don't consider final '\n' to be part of comment. */
954 FORWARD(-1);
955 return ' ';
956 }
957 }
958 }
959 else
960 return '/';
961}
962
963/* Skip whitespace \-newline and comments. Does not macro-expand. */
964void
965cpp_skip_hspace(cpp_reader * pfile)
966{
967 while (1)
968 {
969 int c = PEEKC();
970
971 if (c == EOF)
972 return; /* FIXME */
973 if (is_hor_space[c])
974 {
975 if ((c == '\f' || c == '\v') && CPP_PEDANTIC(pfile))
976 cpp_pedwarn(pfile, "%s in preprocessing directive",
977 c == '\f' ? "formfeed" : "vertical tab");
978 FORWARD(1);
979 }
980 else if (c == '/')
981 {
982 FORWARD(1);
983 c = skip_comment(pfile, NULL);
984 if (c == '/')
985 FORWARD(-1);
986 if (c == EOF || c == '/')
987 return;
988 }
989 else if (c == '\\' && PEEKN(1) == '\n')
990 {
991 FORWARD(2);
992 }
993 else if (c == '@' && CPP_BUFFER(pfile)->has_escapes
994 && is_hor_space[PEEKN(1)])
995 {
996 FORWARD(1);
997 }
998 else
999 return;
1000 }
1001}
1002
1003/* Read the rest of the current line.
1004 * The line is appended to PFILE's output buffer. */
1005
1006static void
1007copy_rest_of_line(cpp_reader * pfile)
1008{
1009 struct cpp_options *opts = CPP_OPTIONS(pfile);
1010
1011 for (;;)
1012 {
1013 int c = GETC();
1014 int nextc;
1015
1016 switch (c)
1017 {
1018 case EOF:
1019 goto end_directive;
1020 case '\\':
1021 if (PEEKC() == '\n')
1022 {
1023 FORWARD(1);
1024 continue;
1025 }
1026 case '\'':
1027 case '\"':
1028 goto scan_directive_token;
1029 break;
1030 case '/':
1031 nextc = PEEKC();
1032 if (nextc == '*' || (opts->cplusplus_comments && nextc == '*'))
1033 goto scan_directive_token;
1034 break;
1035 case '\f':
1036 case '\v':
1037 if (CPP_PEDANTIC(pfile))
1038 cpp_pedwarn(pfile, "%s in preprocessing directive",
1039 c == '\f' ? "formfeed" : "vertical tab");
1040 break;
1041
1042 case '\n':
1043 FORWARD(-1);
1044 goto end_directive;
1045 scan_directive_token:
1046 FORWARD(-1);
1047 cpp_get_token(pfile);
1048 continue;
1049 }
1050 CPP_PUTC(pfile, c);
1051 }
1052 end_directive:;
1053 CPP_NUL_TERMINATE(pfile);
1054}
1055
1056void
1057skip_rest_of_line(cpp_reader * pfile)
1058{
1059 long old = CPP_WRITTEN(pfile);
1060
1061 copy_rest_of_line(pfile);
1062 CPP_SET_WRITTEN(pfile, old);
1063}
1064
1065/* Handle a possible # directive.
1066 * '#' has already been read. */
1067
1068static int
1069handle_directive(cpp_reader * pfile)
1070{
1071 int c;
1072 struct directive *kt;
1073 int ident_length;
1074 long after_ident = 0;
1075 unsigned char *ident, *line_end;
1076 long old_written = CPP_WRITTEN(pfile);
1077
1078 cpp_skip_hspace(pfile);
1079
1080 c = PEEKC();
1081 if (c >= '0' && c <= '9')
1082 {
1083 /* Handle # followed by a line number. */
1084 if (CPP_PEDANTIC(pfile))
1085 cpp_pedwarn(pfile, "`#' followed by integer");
1086 do_line(pfile, NULL, NULL, NULL);
1087 goto done_a_directive;
1088 }
1089 /* Now find the directive name. */
1090 CPP_PUTC(pfile, '#');
1091 parse_name(pfile, GETC());
1092 ident = pfile->token_buffer + old_written + 1;
1093 ident_length = CPP_PWRITTEN(pfile) - ident;
1094 if (ident_length == 0 && PEEKC() == '\n')
1095 {
1096 /* A line of just `#' becomes blank. */
1097 goto done_a_directive;
1098 }
1099 /*
1100 * Decode the keyword and call the appropriate expansion
1101 * routine, after moving the input pointer up to the next line.
1102 */
1103 for (kt = directive_table;; kt++)
1104 {
1105 if (kt->length <= 0)
1106 goto not_a_directive;
1107 if (kt->length == ident_length
1108 && !strncmp(kt->name, (const char *)ident, ident_length))
1109 break;
1110 }
1111
1112 if (!kt->command_reads_line)
1113 {
1114 /* Nonzero means do not delete comments within the directive.
1115 * #define needs this when -traditional. */
1116 int comments = 0;
1117 int save_put_out_comments =
1118 CPP_OPTIONS(pfile)->put_out_comments;
1119
1120 CPP_OPTIONS(pfile)->put_out_comments = comments;
1121 after_ident = CPP_WRITTEN(pfile);
1122 copy_rest_of_line(pfile);
1123 CPP_OPTIONS(pfile)->put_out_comments = save_put_out_comments;
1124 }
1125 /* For #pragma and #define, we may want to pass through the directive.
1126 * Other directives may create output, but we don't want the directive
1127 * itself out, so we pop it now. For example #include may write a #line
1128 * command (see comment in do_include), and conditionals may emit
1129 * #failed ... #endfailed stuff. But note that popping the buffer
1130 * means the parameters to kt->func may point after pfile->limit
1131 * so these parameters are invalid as soon as something gets appended
1132 * to the token_buffer. */
1133
1134 line_end = CPP_PWRITTEN(pfile);
1135 if (!kt->pass_thru && kt->type != T_DEFINE)
1136 CPP_SET_WRITTEN(pfile, old_written);
1137
1138 (*kt->func) (pfile, kt, pfile->token_buffer + after_ident, line_end);
1139 if (kt->pass_thru
1140 || (kt->type == T_DEFINE
1141 && CPP_OPTIONS(pfile)->dump_macros == dump_definitions))
1142 {
1143 /* Just leave the entire #define in the output stack. */
1144 }
1145 else if (kt->type == T_DEFINE
1146 && CPP_OPTIONS(pfile)->dump_macros == dump_names)
1147 {
1148 unsigned char *p = pfile->token_buffer + old_written + 7; /* Skip "#define". */
1149
1150 SKIP_WHITE_SPACE(p);
1151 while (is_idchar[*p])
1152 p++;
1153 pfile->limit = p;
1154 CPP_PUTC(pfile, '\n');
1155 }
1156 else if (kt->type == T_DEFINE)
1157 CPP_SET_WRITTEN(pfile, old_written);
1158 done_a_directive:
1159 return 1;
1160
1161 not_a_directive:
1162 return 0;
1163}
1164
1165/* Pass a directive through to the output file.
1166 * BUF points to the contents of the directive, as a contiguous string.
1167 * LIMIT points to the first character past the end of the directive.
1168 * KEYWORD is the keyword-table entry for the directive. */
1169
1170static void
1171pass_thru_directive(char *buf, char *limit, cpp_reader * pfile,
1172 struct directive *keyword)
1173{
1174 unsigned keyword_length = keyword->length;
1175
1176 CPP_RESERVE(pfile, 1 + keyword_length + (limit - buf));
1177 CPP_PUTC_Q(pfile, '#');
1178 CPP_PUTS_Q(pfile, keyword->name, keyword_length);
1179 if (limit != buf && buf[0] != ' ')
1180 CPP_PUTC_Q(pfile, ' ');
1181 CPP_PUTS_Q(pfile, buf, limit - buf);
1182}
1183
1184/* The arglist structure is built by do_define to tell
1185 * collect_definition where the argument names begin. That
1186 * is, for a define like "#define f(x,y,z) foo+x-bar*y", the arglist
1187 * would contain pointers to the strings x, y, and z.
1188 * Collect_definition would then build a DEFINITION node,
1189 * with reflist nodes pointing to the places x, y, and z had
1190 * appeared. So the arglist is just convenience data passed
1191 * between these two routines. It is not kept around after
1192 * the current #define has been processed and entered into the
1193 * hash table. */
1194
1195struct arglist {
1196 struct arglist *next;
1197 char *name;
1198 int length;
1199 int argno;
1200 char rest_args;
1201};
1202
1203/* Read a replacement list for a macro with parameters.
1204 * Build the DEFINITION structure.
1205 * Reads characters of text starting at BUF until END.
1206 * ARGLIST specifies the formal parameters to look for
1207 * in the text of the definition; NARGS is the number of args
1208 * in that list, or -1 for a macro name that wants no argument list.
1209 * MACRONAME is the macro name itself (so we can avoid recursive expansion)
1210 * and NAMELEN is its length in characters.
1211 *
1212 * Note that comments, backslash-newlines, and leading white space
1213 * have already been deleted from the argument. */
1214
1215static DEFINITION *
1216collect_expansion(cpp_reader * pfile, unsigned char *buf, unsigned char *limit,
1217 int nargs, struct arglist *arglist)
1218{
1219 DEFINITION *defn;
1220 unsigned char *p, *lastp, *exp_p;
1221 reflist *endpat = NULL;
1222
1223 /* Pointer to first nonspace after last ## seen. */
1224 unsigned char *concat = 0;
1225
1226 /* Pointer to first nonspace after last single-# seen. */
1227 unsigned char *stringify = 0;
1228 int maxsize;
1229 int expected_delimiter = '\0';
1230
1231 /* Scan thru the replacement list, ignoring comments and quoted
1232 * strings, picking up on the macro calls. It does a linear search
1233 * thru the arg list on every potential symbol. Profiling might say
1234 * that something smarter should happen. */
1235
1236 if (limit < buf)
1237 abort();
1238
1239 /* Find the beginning of the trailing whitespace. */
1240 p = buf;
1241 while (p < limit && is_space[limit[-1]])
1242 limit--;
1243
1244 /* Allocate space for the text in the macro definition.
1245 * Leading and trailing whitespace chars need 2 bytes each.
1246 * Each other input char may or may not need 1 byte,
1247 * so this is an upper bound. The extra 5 are for invented
1248 * leading and trailing newline-marker and final null. */
1249 maxsize = (sizeof(DEFINITION) + (limit - p) + 5);
1250 /* Occurrences of '@' get doubled, so allocate extra space for them. */
1251 while (p < limit)
1252 if (*p++ == '@')
1253 maxsize++;
1254 defn = (DEFINITION *) xcalloc(1, maxsize);
1255
1256 defn->nargs = nargs;
1257 exp_p = defn->expansion = (unsigned char *)defn + sizeof(DEFINITION);
1258 lastp = exp_p;
1259
1260 p = buf;
1261
1262 /* Add one initial space escape-marker to prevent accidental
1263 * token-pasting (often removed by macroexpand). */
1264 *exp_p++ = '@';
1265 *exp_p++ = ' ';
1266
1267 if (limit - p >= 2 && p[0] == '#' && p[1] == '#')
1268 {
1269 cpp_error(pfile, "`##' at start of macro definition");
1270 p += 2;
1271 }
1272 /* Process the main body of the definition. */
1273 while (p < limit)
1274 {
1275 int skipped_arg = 0;
1276 unsigned char c = *p++;
1277
1278 *exp_p++ = c;
1279
1280 switch (c)
1281 {
1282 case '\'':
1283 case '\"':
1284 if (expected_delimiter != '\0')
1285 {
1286 if (c == expected_delimiter)
1287 expected_delimiter = '\0';
1288 }
1289 else
1290 expected_delimiter = c;
1291 break;
1292
1293 case '\\':
1294 if (p < limit && expected_delimiter)
1295 {
1296 /* In a string, backslash goes through
1297 * and makes next char ordinary. */
1298 *exp_p++ = *p++;
1299 }
1300 break;
1301
1302 case '@':
1303 /* An '@' in a string or character constant stands for itself,
1304 * and does not need to be escaped. */
1305 if (!expected_delimiter)
1306 *exp_p++ = c;
1307 break;
1308
1309 case '#':
1310 /* # is ordinary inside a string. */
1311 if (expected_delimiter)
1312 break;
1313 if (p < limit && *p == '#')
1314 {
1315 /* ##: concatenate preceding and following tokens. */
1316 /* Take out the first #, discard preceding whitespace. */
1317 exp_p--;
1318 while (exp_p > lastp && is_hor_space[exp_p[-1]])
1319 --exp_p;
1320 /* Skip the second #. */
1321 p++;
1322 /* Discard following whitespace. */
1323 SKIP_WHITE_SPACE(p);
1324 concat = p;
1325 if (p == limit)
1326 cpp_error(pfile, "`##' at end of macro definition");
1327 }
1328 else if (nargs >= 0)
1329 {
1330 /* Single #: stringify following argument ref.
1331 * Don't leave the # in the expansion. */
1332 exp_p--;
1333 SKIP_WHITE_SPACE(p);
1334 if (p == limit || !is_idstart[*p])
1335 cpp_error(pfile,
1336 "`#' operator is not followed by a macro argument name");
1337 else
1338 stringify = p;
1339 }
1340 break;
1341 }
1342
1343 /* Handle the start of a symbol. */
1344 if (is_idchar[c] && nargs > 0)
1345 {
1346 unsigned char *id_beg = p - 1;
1347 int id_len;
1348
1349 --exp_p;
1350 while (p != limit && is_idchar[*p])
1351 p++;
1352 id_len = p - id_beg;
1353
1354 if (is_idstart[c])
1355 {
1356 struct arglist *arg;
1357
1358 for (arg = arglist; arg; arg = arg->next)
1359 {
1360 reflist *tpat;
1361
1362 if (arg->name[0] == c
1363 && arg->length == id_len
1364 && strncmp((const char *)arg->name,
1365 (const char *)id_beg, id_len) == 0)
1366 {
1367 if (expected_delimiter
1368 && CPP_OPTIONS(pfile)->warn_stringify)
1369 {
1370 cpp_warning(pfile,
1371 "macro arg `%.*s' would be stringified with -traditional.",
1372 id_len, arg->name);
1373 }
1374 /* If ANSI, don't actually substitute inside a string. */
1375 if (expected_delimiter)
1376 break;
1377 /* make a pat node for this arg and append it to the end of
1378 * the pat list */
1379 tpat = (reflist *) xmalloc(sizeof(reflist));
1380
1381 tpat->next = NULL;
1382 tpat->raw_before = concat == id_beg;
1383 tpat->raw_after = 0;
1384 tpat->rest_args = arg->rest_args;
1385 tpat->stringify = (stringify == id_beg);
1386
1387 if (!endpat)
1388 defn->pattern = tpat;
1389 else
1390 endpat->next = tpat;
1391 endpat = tpat;
1392
1393 tpat->argno = arg->argno;
1394 tpat->nchars = exp_p - lastp;
1395 {
1396 unsigned char *p1 = p;
1397
1398 SKIP_WHITE_SPACE(p1);
1399 if (p1 + 2 <= limit && p1[0] == '#'
1400 && p1[1] == '#')
1401 tpat->raw_after = 1;
1402 }
1403 lastp = exp_p; /* place to start copying from next time */
1404 skipped_arg = 1;
1405 break;
1406 }
1407 }
1408 }
1409 /* If this was not a macro arg, copy it into the expansion. */
1410 if (!skipped_arg)
1411 {
1412 unsigned char *lim1 = p;
1413
1414 p = id_beg;
1415 while (p != lim1)
1416 *exp_p++ = *p++;
1417 if (stringify == id_beg)
1418 cpp_error(pfile,
1419 "`#' operator should be followed by a macro argument name");
1420 }
1421 }
1422 }
1423
1424 if (expected_delimiter == 0)
1425 {
1426 /* If ANSI, put in a "@ " marker to prevent token pasting.
1427 * But not if "inside a string" (which in ANSI mode
1428 * happens only for -D option). */
1429 *exp_p++ = '@';
1430 *exp_p++ = ' ';
1431 }
1432 *exp_p = '\0';
1433
1434 defn->length = exp_p - defn->expansion;
1435
1436 /* Crash now if we overrun the allocated size. */
1437 if (defn->length + 1 > maxsize)
1438 abort();
1439
1440 return defn;
1441}
1442
1443/*
1444 * special extension string that can be added to the last macro argument to
1445 * allow it to absorb the "rest" of the arguments when expanded. Ex:
1446 * #define wow(a, b...) process (b, a, b)
1447 * { wow (1, 2, 3); } -> { process (2, 3, 1, 2, 3); }
1448 * { wow (one, two); } -> { process (two, one, two); }
1449 * if this "rest_arg" is used with the concat token '##' and if it is not
1450 * supplied then the token attached to with ## will not be outputted. Ex:
1451 * #define wow (a, b...) process (b ## , a, ## b)
1452 * { wow (1, 2); } -> { process (2, 1, 2); }
1453 * { wow (one); } -> { process (one); {
1454 */
1455static char rest_extension[] = "...";
1456
1457#define REST_EXTENSION_LENGTH (sizeof (rest_extension) - 1)
1458
1459/* Create a DEFINITION node from a #define directive. Arguments are
1460 * as for do_define. */
1461static void
1462create_definition(MACRODEF * mdef, unsigned char *buf, unsigned char *limit,
1463 cpp_reader * pfile, int predefinition)
1464{
1465 unsigned char *bp; /* temp ptr into input buffer */
1466 unsigned char *symname; /* remember where symbol name starts */
1467 int sym_length; /* and how long it is */
1468 int rest_args = 0;
1469 long line, col;
1470 const char *file =
1471 CPP_BUFFER(pfile) ? CPP_BUFFER(pfile)->nominal_fname : "";
1472 DEFINITION *defn;
1473 int arglengths = 0; /* Accumulate lengths of arg names
1474 * plus number of args. */
1475
1476 cpp_buf_line_and_col(CPP_BUFFER(pfile), &line, &col);
1477
1478 bp = buf;
1479
1480 while (is_hor_space[*bp])
1481 bp++;
1482
1483 symname = bp; /* remember where it starts */
1484
1485 sym_length = check_macro_name(pfile, bp, "macro");
1486 bp += sym_length;
1487
1488 /* Lossage will occur if identifiers or control keywords are broken
1489 * across lines using backslash. This is not the right place to take
1490 * care of that. */
1491
1492 if (*bp == '(')
1493 {
1494 struct arglist *arg_ptrs = NULL;
1495 int argno = 0;
1496
1497 bp++; /* skip '(' */
1498 SKIP_WHITE_SPACE(bp);
1499
1500 /* Loop over macro argument names. */
1501 while (*bp != ')')
1502 {
1503 struct arglist *temp;
1504
1505 temp = (struct arglist *)alloca(sizeof(struct arglist));
1506
1507 temp->name = (char *)bp;
1508 temp->next = arg_ptrs;
1509 temp->argno = argno++;
1510 temp->rest_args = 0;
1511 arg_ptrs = temp;
1512
1513 if (rest_args)
1514 cpp_pedwarn(pfile, "another parameter follows `%s'",
1515 rest_extension);
1516
1517 if (!is_idstart[*bp])
1518 cpp_pedwarn(pfile, "invalid character in macro parameter name");
1519
1520 /* Find the end of the arg name. */
1521 while (is_idchar[*bp])
1522 {
1523 bp++;
1524 /* do we have a "special" rest-args extension here? */
1525 if ((unsigned)(limit - bp) > REST_EXTENSION_LENGTH &&
1526 strncmp(rest_extension, (const char *)bp,
1527 REST_EXTENSION_LENGTH) == 0)
1528 {
1529 rest_args = 1;
1530 temp->rest_args = 1;
1531 break;
1532 }
1533 }
1534 temp->length = (char *)bp - temp->name;
1535 if (rest_args == 1)
1536 bp += REST_EXTENSION_LENGTH;
1537 arglengths += temp->length + 2;
1538 SKIP_WHITE_SPACE(bp);
1539 if (temp->length == 0 || (*bp != ',' && *bp != ')'))
1540 {
1541 cpp_error(pfile,
1542 "badly punctuated parameter list in `#define'");
1543 goto nope;
1544 }
1545 if (*bp == ',')
1546 {
1547 bp++;
1548 SKIP_WHITE_SPACE(bp);
1549 }
1550 if (bp >= limit)
1551 {
1552 cpp_error(pfile, "unterminated parameter list in `#define'");
1553 goto nope;
1554 }
1555 {
1556 struct arglist *otemp;
1557
1558 for (otemp = temp->next; otemp; otemp = otemp->next)
1559 if (temp->length == otemp->length &&
1560 strncmp((const char *)temp->name,
1561 (const char *)otemp->name, temp->length) == 0)
1562 {
1563 char *name;
1564
1565 name = (char *)alloca(temp->length + 1);
1566 strncpy(name, (const char *)temp->name, temp->length);
1567 name[temp->length] = '\0';
1568 cpp_error(pfile,
1569 "duplicate argument name `%s' in `#define'",
1570 name);
1571 goto nope;
1572 }
1573 }
1574 }
1575
1576 ++bp; /* skip paren */
1577 SKIP_WHITE_SPACE(bp);
1578 /* now everything from bp before limit is the definition. */
1579 defn = collect_expansion(pfile, bp, limit, argno, arg_ptrs);
1580 defn->rest_args = rest_args;
1581
1582 /* Now set defn->args.argnames to the result of concatenating
1583 * the argument names in reverse order
1584 * with comma-space between them. */
1585 defn->args.argnames = (unsigned char *)xmalloc(arglengths + 1);
1586 {
1587 struct arglist *temp;
1588 int i = 0;
1589
1590 for (temp = arg_ptrs; temp; temp = temp->next)
1591 {
1592 memcpy(&defn->args.argnames[i], temp->name, temp->length);
1593 i += temp->length;
1594 if (temp->next)
1595 {
1596 defn->args.argnames[i++] = ',';
1597 defn->args.argnames[i++] = ' ';
1598 }
1599 }
1600 defn->args.argnames[i] = 0;
1601 }
1602 }
1603 else
1604 {
1605 /* Simple expansion or empty definition. */
1606
1607 if (bp < limit)
1608 {
1609 if (is_hor_space[*bp])
1610 {
1611 bp++;
1612 SKIP_WHITE_SPACE(bp);
1613 }
1614 else
1615 {
1616 switch (*bp)
1617 {
1618 case '!':
1619 case '"':
1620 case '#':
1621 case '%':
1622 case '&':
1623 case '\'':
1624 case ')':
1625 case '*':
1626 case '+':
1627 case ',':
1628 case '-':
1629 case '.':
1630 case '/':
1631 case ':':
1632 case ';':
1633 case '<':
1634 case '=':
1635 case '>':
1636 case '?':
1637 case '[':
1638 case '\\':
1639 case ']':
1640 case '^':
1641 case '{':
1642 case '|':
1643 case '}':
1644 case '~':
1645 cpp_warning(pfile,
1646 "missing white space after `#define %.*s'",
1647 sym_length, symname);
1648 break;
1649
1650 default:
1651 cpp_pedwarn(pfile,
1652 "missing white space after `#define %.*s'",
1653 sym_length, symname);
1654 break;
1655 }
1656 }
1657 }
1658 /* now everything from bp before limit is the definition. */
1659 defn = collect_expansion(pfile, bp, limit, -1, NULL);
1660 defn->args.argnames = (unsigned char *)"";
1661 }
1662
1663 defn->line = line;
1664 defn->file = file;
1665
1666 /* OP is null if this is a predefinition */
1667 defn->predefined = predefinition;
1668 mdef->defn = defn;
1669 mdef->symnam = (char *)symname;
1670 mdef->symlen = sym_length;
1671
1672 return;
1673
1674 nope:
1675 mdef->defn = 0;
1676}
1677
1678/* Check a purported macro name SYMNAME, and yield its length.
1679 * USAGE is the kind of name this is intended for. */
1680
1681static int
1682check_macro_name(cpp_reader * pfile, unsigned char *symname, const char *usage)
1683{
1684 unsigned char *p;
1685 int sym_length;
1686
1687 for (p = symname; is_idchar[*p]; p++)
1688 ;
1689 sym_length = p - symname;
1690 if (sym_length == 0)
1691 {
1692 cpp_error(pfile, "invalid %s name", usage);
1693 }
1694 else if (!is_idstart[*symname])
1695 {
1696 unsigned char *msg; /* what pain... */
1697
1698 msg = (unsigned char *)alloca(sym_length + 1);
1699 memcpy(msg, symname, sym_length);
1700 msg[sym_length] = 0;
1701 cpp_error(pfile, "invalid %s name `%s'", usage, msg);
1702 }
1703 else
1704 {
1705 if (!strncmp((const char *)symname, "defined", 7) && sym_length == 7)
1706 cpp_error(pfile, "invalid %s name `defined'", usage);
1707 }
1708 return sym_length;
1709}
1710
1711/*
1712 * return zero if two DEFINITIONs are isomorphic
1713 */
1714static int
1715compare_defs(DEFINITION * d1, DEFINITION * d2)
1716{
1717 reflist *a1, *a2;
1718 unsigned char *p1 = d1->expansion;
1719 unsigned char *p2 = d2->expansion;
1720 int first = 1;
1721
1722 if (d1->nargs != d2->nargs)
1723 return 1;
1724 if (strcmp((char *)d1->args.argnames, (char *)d2->args.argnames))
1725 return 1;
1726 for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2;
1727 a1 = a1->next, a2 = a2->next)
1728 {
1729 if (!
1730 ((a1->nchars == a2->nchars
1731 && !strncmp((const char *)p1, (const char *)p2, a1->nchars))
1732 || !comp_def_part(first, p1, a1->nchars, p2, a2->nchars, 0))
1733 || a1->argno != a2->argno || a1->stringify != a2->stringify
1734 || a1->raw_before != a2->raw_before
1735 || a1->raw_after != a2->raw_after)
1736 return 1;
1737 first = 0;
1738 p1 += a1->nchars;
1739 p2 += a2->nchars;
1740 }
1741 if (a1 != a2)
1742 return 1;
1743 if (comp_def_part(first, p1, d1->length - (p1 - d1->expansion),
1744 p2, d2->length - (p2 - d2->expansion), 1))
1745 return 1;
1746 return 0;
1747}
1748
1749/* Return 1 if two parts of two macro definitions are effectively different.
1750 * One of the parts starts at BEG1 and has LEN1 chars;
1751 * the other has LEN2 chars at BEG2.
1752 * Any sequence of whitespace matches any other sequence of whitespace.
1753 * FIRST means these parts are the first of a macro definition;
1754 * so ignore leading whitespace entirely.
1755 * LAST means these parts are the last of a macro definition;
1756 * so ignore trailing whitespace entirely. */
1757
1758static int
1759comp_def_part(int first, unsigned char *beg1, int len1,
1760 unsigned char *beg2, int len2, int last)
1761{
1762 unsigned char *end1 = beg1 + len1;
1763 unsigned char *end2 = beg2 + len2;
1764
1765 if (first)
1766 {
1767 while (beg1 != end1 && is_space[*beg1])
1768 beg1++;
1769 while (beg2 != end2 && is_space[*beg2])
1770 beg2++;
1771 }
1772 if (last)
1773 {
1774 while (beg1 != end1 && is_space[end1[-1]])
1775 end1--;
1776 while (beg2 != end2 && is_space[end2[-1]])
1777 end2--;
1778 }
1779 while (beg1 != end1 && beg2 != end2)
1780 {
1781 if (is_space[*beg1] && is_space[*beg2])
1782 {
1783 while (beg1 != end1 && is_space[*beg1])
1784 beg1++;
1785 while (beg2 != end2 && is_space[*beg2])
1786 beg2++;
1787 }
1788 else if (*beg1 == *beg2)
1789 {
1790 beg1++;
1791 beg2++;
1792 }
1793 else
1794 break;
1795 }
1796 return (beg1 != end1) || (beg2 != end2);
1797}
1798
1799/* Process a #define command.
1800 * BUF points to the contents of the #define command, as a contiguous string.
1801 * LIMIT points to the first character past the end of the definition.
1802 * KEYWORD is the keyword-table entry for #define,
1803 * or NULL for a "predefined" macro. */
1804
1805static int
1806do_define(cpp_reader * pfile, struct directive *keyword,
1807 unsigned char *buf, unsigned char *limit)
1808{
1809 int hashcode;
1810 MACRODEF mdef;
1811 HASHNODE *hp;
1812
1813 create_definition(&mdef, buf, limit, pfile, !keyword);
1814 if (!mdef.defn)
1815 return 1;
1816
1817 hashcode = hashf(mdef.symnam, mdef.symlen, HASHSIZE);
1818
1819 if ((hp = cpp_lookup(mdef.symnam, mdef.symlen, hashcode)))
1820 {
1821 int ok = 0;
1822
1823 /* Redefining a precompiled key is ok. */
1824 if (hp->type == T_PCSTRING)
1825 ok = 1;
1826 /* Redefining a macro is ok if the definitions are the same. */
1827 else if (hp->type == T_MACRO)
1828 ok = !compare_defs(mdef.defn, hp->value.defn);
1829 /* Redefining a constant is ok with -D. */
1830 else if (hp->type == T_CONST)
1831 ok = !CPP_OPTIONS(pfile)->done_initializing;
1832 /* Print the warning if it's not ok. */
1833 if (!ok)
1834 {
1835 char *msg; /* what pain... */
1836
1837 /* If we are passing through #define and #undef directives, do
1838 * that for this re-definition now. */
1839 if (CPP_OPTIONS(pfile)->debug_output && keyword)
1840 pass_thru_directive((char *)buf, (char *)limit, pfile, keyword);
1841
1842 msg = (char *)alloca(mdef.symlen + 22);
1843 *msg = '`';
1844 memcpy(msg + 1, mdef.symnam, mdef.symlen);
1845 strcpy((msg + mdef.symlen + 1), "' redefined");
1846 cpp_pedwarn(pfile, msg);
1847 if (hp->type == T_MACRO)
1848 cpp_pedwarn_with_file_and_line(pfile, hp->value.defn->file,
1849 hp->value.defn->line,
1850 "this is the location of the previous definition",
1851 NULL, NULL, NULL);
1852 }
1853 /* Replace the old definition. */
1854 hp->type = T_MACRO;
1855 hp->value.defn = mdef.defn;
1856 }
1857 else
1858 {
1859 /* If we are passing through #define and #undef directives, do
1860 * that for this new definition now. */
1861 if (CPP_OPTIONS(pfile)->debug_output && keyword)
1862 pass_thru_directive((char *)buf, (char *)limit, pfile, keyword);
1863 install(mdef.symnam, mdef.symlen, T_MACRO, 0,
1864 (char *)mdef.defn, hashcode);
1865 }
1866
1867 return 0;
1868}
1869
1870/* This structure represents one parsed argument in a macro call.
1871 * `raw' points to the argument text as written (`raw_length' is its length).
1872 * `expanded' points to the argument's macro-expansion
1873 * (its length is `expand_length').
1874 * `stringified_length' is the length the argument would have
1875 * if stringified.
1876 * `use_count' is the number of times this macro arg is substituted
1877 * into the macro. If the actual use count exceeds 10,
1878 * the value stored is 10. */
1879
1880/* raw and expanded are relative to ARG_BASE */
1881#define ARG_BASE ((pfile)->token_buffer)
1882
1883struct argdata {
1884 /* Strings relative to pfile->token_buffer */
1885 long raw, expanded, stringified;
1886 int raw_length, expand_length;
1887 int stringified_length;
1888 char newlines;
1889 char use_count;
1890};
1891
1892cpp_buffer *
1893cpp_push_buffer(cpp_reader * pfile, unsigned char *buffer, long length)
1894{
1895#ifdef STATIC_BUFFERS
1896 cpp_buffer *buf = CPP_BUFFER(pfile);
1897
1898 if (buf == pfile->buffer_stack)
1899 cpp_fatal("macro or `#include' recursion too deep");
1900 buf--;
1901 memset((char *)buf, 0, sizeof(cpp_buffer));
1902 CPP_BUFFER(pfile) = buf;
1903#else
1904 cpp_buffer *buf = (cpp_buffer *) xmalloc(sizeof(cpp_buffer));
1905
1906 memset((char *)buf, 0, sizeof(cpp_buffer));
1907 CPP_PREV_BUFFER(buf) = CPP_BUFFER(pfile);
1908 CPP_BUFFER(pfile) = buf;
1909#endif
1910 buf->if_stack = pfile->if_stack;
1911 buf->cleanup = null_cleanup;
1912 buf->underflow = null_underflow;
1913 buf->buf = buf->cur = buffer;
1914 buf->alimit = buf->rlimit = buffer + length;
1915
1916 return buf;
1917}
1918
1919static cpp_buffer *
1920cpp_pop_buffer(cpp_reader * pfile)
1921{
1922 cpp_buffer *buf = CPP_BUFFER(pfile);
1923
1924#ifdef STATIC_BUFFERS
1925 (*buf->cleanup) (buf, pfile);
1926 return ++CPP_BUFFER(pfile);
1927#else
1928 cpp_buffer *next_buf = CPP_PREV_BUFFER(buf);
1929
1930 (*buf->cleanup) (buf, pfile);
1931 CPP_BUFFER(pfile) = next_buf;
1932 free(buf);
1933 return next_buf;
1934#endif
1935}
1936
1937/* Scan until CPP_BUFFER (PFILE) is exhausted into PFILE->token_buffer.
1938 * Pop the buffer when done. */
1939
1940static void
1941cpp_scan_buffer(cpp_reader * pfile)
1942{
1943 cpp_buffer *buffer = CPP_BUFFER(pfile);
1944
1945 for (;;)
1946 {
1947 enum cpp_token token = cpp_get_token(pfile);
1948
1949 if (token == CPP_EOF) /* Should not happen ... */
1950 break;
1951 if (token == CPP_POP && CPP_BUFFER(pfile) == buffer)
1952 {
1953 cpp_pop_buffer(pfile);
1954 break;
1955 }
1956 }
1957}
1958
1959/*
1960 * Rescan a string (which may have escape marks) into pfile's buffer.
1961 * Place the result in pfile->token_buffer.
1962 *
1963 * The input is copied before it is scanned, so it is safe to pass
1964 * it something from the token_buffer that will get overwritten
1965 * (because it follows CPP_WRITTEN). This is used by do_include.
1966 */
1967
1968static void
1969cpp_expand_to_buffer(cpp_reader * pfile, unsigned char *buf, int length)
1970{
1971 cpp_buffer *ip;
1972 unsigned char *limit = buf + length;
1973 unsigned char *buf1;
1974
1975 if (length < 0)
1976 abort();
1977
1978 /* Set up the input on the input stack. */
1979
1980 buf1 = (unsigned char *)alloca(length + 1);
1981 {
1982 unsigned char *p1 = buf;
1983 unsigned char *p2 = buf1;
1984 int in_string = 0;
1985
1986#if 0 /* old behavior */
1987 while (p1 != limit) *p2++ = *p1++;
1988#else /* new one - handle \ escapes if not in string */
1989 while (p1 != limit)
1990 {
1991 if (!in_string)
1992 {
1993 if (*p1 == '"') in_string = 1;
1994 if (*p1 == '\\')
1995 {
1996 p1++;
1997 if (p1 != limit) *p2++ = *p1++;
1998 }
1999 else
2000 *p2++ = *p1++;
2001 }
2002 else
2003 {
2004 if ((*p1 == '"') && (p1 > buf) && (p1[-1] != '\\'))
2005 in_string = 0;
2006 *p2++ = *p1++;
2007 }
2008 }
2009#endif
2010 *p2 = 0;
2011 length = p2 - buf1;
2012 }
2013
2014 ip = cpp_push_buffer(pfile, buf1, length);
2015 ip->has_escapes = 1;
2016
2017 /* Scan the input, create the output. */
2018 cpp_scan_buffer(pfile);
2019
2020 CPP_NUL_TERMINATE(pfile);
2021}
2022
2023static void
2024adjust_position(unsigned char *buf, unsigned char *limit, long *linep,
2025 long *colp)
2026{
2027 while (buf < limit)
2028 {
2029 unsigned char ch = *buf++;
2030
2031 if (ch == '\n')
2032 (*linep)++, (*colp) = 1;
2033 else
2034 (*colp)++;
2035 }
2036}
2037
2038/* Move line_base forward, updating lineno and colno. */
2039
2040static void
2041update_position(cpp_buffer * pbuf)
2042{
2043 unsigned char *old_pos = pbuf->buf + pbuf->line_base;
2044 unsigned char *new_pos = pbuf->cur;
2045 struct parse_marker *mark;
2046
2047 for (mark = pbuf->marks; mark; mark = mark->next)
2048 {
2049 if (pbuf->buf + mark->position < new_pos)
2050 new_pos = pbuf->buf + mark->position;
2051 }
2052 pbuf->line_base += new_pos - old_pos;
2053 adjust_position(old_pos, new_pos, &pbuf->lineno, &pbuf->colno);
2054}
2055
2056void
2057cpp_buf_line_and_col(cpp_buffer * pbuf, long *linep, long *colp)
2058{
2059 long dummy;
2060
2061 if (!colp)
2062 colp = &dummy;
2063 if (pbuf)
2064 {
2065 *linep = pbuf->lineno;
2066 *colp = pbuf->colno;
2067 adjust_position(pbuf->buf + pbuf->line_base, pbuf->cur, linep, colp);
2068 }
2069 else
2070 {
2071 *linep = 0;
2072 *colp = 0;
2073 }
2074}
2075
2076/* Return the cpp_buffer that corresponds to a file (not a macro). */
2077
2078cpp_buffer *
2079cpp_file_buffer(cpp_reader * pfile)
2080{
2081 cpp_buffer *ip = CPP_BUFFER(pfile);
2082
2083 for (; ip != CPP_NULL_BUFFER(pfile); ip = CPP_PREV_BUFFER(ip))
2084 if (ip->fname)
2085 return ip;
2086 return NULL;
2087}
2088
2089static long
2090count_newlines(unsigned char *buf, unsigned char *limit)
2091{
2092 long count = 0;
2093
2094 while (buf < limit)
2095 {
2096 unsigned char ch = *buf++;
2097
2098 if (ch == '\n')
2099 count++;
2100 }
2101 return count;
2102}
2103
2104/*
2105 * write out a #line command, for instance, after an #include file.
2106 * If CONDITIONAL is nonzero, we can omit the #line if it would
2107 * appear to be a no-op, and we can output a few newlines instead
2108 * if we want to increase the line number by a small amount.
2109 * FILE_CHANGE says whether we are entering a file, leaving, or neither.
2110 */
2111
2112static void
2113output_line_command(cpp_reader * pfile, int conditional,
2114 enum file_change_code file_change)
2115{
2116 long line, col;
2117 cpp_buffer *ip = CPP_BUFFER(pfile);
2118
2119 if (CPP_OPTIONS(pfile)->no_line_commands
2120 || !ip->fname || CPP_OPTIONS(pfile)->no_output)
2121 {
2122 return;
2123 }
2124 update_position(ip);
2125 line = CPP_BUFFER(pfile)->lineno;
2126 col = CPP_BUFFER(pfile)->colno;
2127 adjust_position(CPP_LINE_BASE(ip), ip->cur, &line, &col);
2128
2129 if (conditional)
2130 {
2131 if (line == pfile->lineno)
2132 return;
2133
2134 /* If the inherited line number is a little too small,
2135 * output some newlines instead of a #line command. */
2136 if (line > pfile->lineno && line < pfile->lineno + 8)
2137 {
2138 CPP_RESERVE(pfile, 20);
2139 while (line > pfile->lineno)
2140 {
2141 CPP_PUTC_Q(pfile, '\n');
2142 pfile->lineno++;
2143 }
2144 return;
2145 }
2146 }
2147
2148 CPP_RESERVE(pfile, 4 * strlen(ip->nominal_fname) + 50);
2149 {
2150 static char sharp_line[] = "#line ";
2151
2152 CPP_PUTS_Q(pfile, sharp_line, sizeof(sharp_line) - 1);
2153 }
2154
2155 sprintf((char *)CPP_PWRITTEN(pfile), "%d ", (int)line);
2156 CPP_ADJUST_WRITTEN(pfile, strlen((char *)CPP_PWRITTEN(pfile)));
2157
2158 quote_string(pfile, ip->nominal_fname);
2159 if (file_change != same_file)
2160 {
2161 CPP_PUTC_Q(pfile, ' ');
2162 CPP_PUTC_Q(pfile, file_change == enter_file ? '1' : '2');
2163 }
2164 /* Tell cc1 if following text comes from a system header file. */
2165 if (ip->system_header_p)
2166 {
2167 CPP_PUTC_Q(pfile, ' ');
2168 CPP_PUTC_Q(pfile, '3');
2169 }
2170#ifndef NO_IMPLICIT_EXTERN_C
2171 /* Tell cc1plus if following text should be treated as C. */
2172 if (ip->system_header_p == 2 && CPP_OPTIONS(pfile)->cplusplus)
2173 {
2174 CPP_PUTC_Q(pfile, ' ');
2175 CPP_PUTC_Q(pfile, '4');
2176 }
2177#endif
2178 CPP_PUTC_Q(pfile, '\n');
2179 pfile->lineno = line;
2180}
2181
2182/*
2183 * Parse a macro argument and append the info on PFILE's token_buffer.
2184 * REST_ARGS means to absorb the rest of the args.
2185 * Return nonzero to indicate a syntax error.
2186 */
2187
2188static enum cpp_token
2189macarg(cpp_reader * pfile, int rest_args)
2190{
2191 int paren = 0;
2192 enum cpp_token token;
2193 char save_put_out_comments =
2194 CPP_OPTIONS(pfile)->put_out_comments;
2195
2196 CPP_OPTIONS(pfile)->put_out_comments = 0;
2197
2198 token = CPP_OTHER;
2199 /* Try to parse as much of the argument as exists at this
2200 * input stack level. */
2201 pfile->no_macro_expand++;
2202 for (;;)
2203 {
2204 token = cpp_get_token(pfile);
2205 switch (token)
2206 {
2207 case CPP_EOF:
2208 goto done;
2209 case CPP_POP:
2210 /* If we've hit end of file, it's an error (reported by caller).
2211 * Ditto if it's the end of cpp_expand_to_buffer text.
2212 * If we've hit end of macro, just continue. */
2213 if (!CPP_IS_MACRO_BUFFER(CPP_BUFFER(pfile)))
2214 goto done;
2215 break;
2216 case CPP_LPAREN:
2217 paren++;
2218 break;
2219 case CPP_RPAREN:
2220 if (--paren < 0)
2221 goto found;
2222 break;
2223 case CPP_COMMA:
2224 /* if we've returned to lowest level and
2225 * we aren't absorbing all args */
2226 if (paren == 0 && rest_args == 0)
2227 goto found;
2228 break;
2229 found:
2230 /* Remove ',' or ')' from argument buffer. */
2231 CPP_ADJUST_WRITTEN(pfile, -1);
2232 goto done;
2233 default:;
2234 }
2235 }
2236
2237 done:
2238 CPP_OPTIONS(pfile)->put_out_comments = save_put_out_comments;
2239 pfile->no_macro_expand--;
2240
2241 return token;
2242}
2243
2244/* Turn newlines to spaces in the string of length LENGTH at START,
2245 * except inside of string constants.
2246 * The string is copied into itself with its beginning staying fixed. */
2247
2248static int
2249change_newlines(unsigned char *start, int length)
2250{
2251 unsigned char *ibp;
2252 unsigned char *obp;
2253 unsigned char *limit;
2254 int c;
2255
2256 ibp = start;
2257 limit = start + length;
2258 obp = start;
2259
2260 while (ibp < limit)
2261 {
2262 *obp++ = c = *ibp++;
2263 switch (c)
2264 {
2265
2266 case '\'':
2267 case '\"':
2268 /* Notice and skip strings, so that we don't delete newlines in them. */
2269 {
2270 int quotec = c;
2271
2272 while (ibp < limit)
2273 {
2274 *obp++ = c = *ibp++;
2275 if (c == quotec)
2276 break;
2277 if (c == '\n' && quotec == '\'')
2278 break;
2279 }
2280 }
2281 break;
2282 }
2283 }
2284
2285 return obp - start;
2286}
2287
2288static struct tm *
2289timestamp(cpp_reader * pfile)
2290{
2291 if (!pfile->timebuf)
2292 {
2293 time_t t = time((time_t *) 0);
2294
2295 pfile->timebuf = localtime(&t);
2296 }
2297 return pfile->timebuf;
2298}
2299
2300static const char *monthnames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
2301 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
2302};
2303
2304/*
2305 * expand things like __FILE__. Place the expansion into the output
2306 * buffer *without* rescanning.
2307 */
2308
2309static void
2310special_symbol(HASHNODE * hp, cpp_reader * pfile)
2311{
2312 const char *buf;
2313 char *bufx;
2314 int len;
2315 int true_indepth;
2316 cpp_buffer *ip = NULL;
2317 struct tm *timebuf;
2318
2319 int paren = 0; /* For special `defined' keyword */
2320
2321 for (ip = CPP_BUFFER(pfile);; ip = CPP_PREV_BUFFER(ip))
2322 {
2323 if (!ip)
2324 {
2325 cpp_error(pfile, "cccp error: not in any file?!");
2326 return; /* the show must go on */
2327 }
2328 if (ip->fname)
2329 break;
2330 }
2331
2332 switch (hp->type)
2333 {
2334 case T_FILE:
2335 case T_BASE_FILE:
2336 {
2337 const char *string;
2338
2339 if (hp->type == T_BASE_FILE)
2340 {
2341 while (CPP_PREV_BUFFER(ip))
2342 ip = CPP_PREV_BUFFER(ip);
2343 }
2344 string = ip->nominal_fname;
2345
2346 if (!string)
2347 string = "";
2348 CPP_RESERVE(pfile, 3 + 4 * strlen(string));
2349 quote_string(pfile, string);
2350 return;
2351 }
2352
2353 case T_INCLUDE_LEVEL:
2354 true_indepth = 0;
2355 for (ip = CPP_BUFFER(pfile); ip; ip = CPP_PREV_BUFFER(ip))
2356 if (ip->fname)
2357 true_indepth++;
2358
2359 bufx = (char *)alloca(8); /* Eight bytes ought to be more than enough */
2360 sprintf(bufx, "%d", true_indepth - 1);
2361 buf = bufx;
2362 break;
2363
2364 case T_VERSION:
2365 bufx = (char *)alloca(3 + strlen(version_string));
2366 sprintf(bufx, "\"%s\"", version_string);
2367 buf = bufx;
2368 break;
2369
2370#ifndef NO_BUILTIN_SIZE_TYPE
2371 case T_SIZE_TYPE:
2372 buf = SIZE_TYPE;
2373 break;
2374#endif
2375
2376#ifndef NO_BUILTIN_PTRDIFF_TYPE
2377 case T_PTRDIFF_TYPE:
2378 buf = PTRDIFF_TYPE;
2379 break;
2380#endif
2381
2382 case T_WCHAR_TYPE:
2383 buf = CPP_WCHAR_TYPE(pfile);
2384 break;
2385
2386 case T_USER_LABEL_PREFIX_TYPE:
2387 buf = USER_LABEL_PREFIX;
2388 break;
2389
2390 case T_REGISTER_PREFIX_TYPE:
2391 buf = REGISTER_PREFIX;
2392 break;
2393
2394 case T_CONST:
2395 bufx = (char *)alloca(4 * sizeof(int));
2396 sprintf(bufx, "%d", hp->value.ival);
2397 buf = bufx;
2398 break;
2399
2400 case T_SPECLINE:
2401 {
2402 long line = ip->lineno;
2403 long col = ip->colno;
2404
2405 adjust_position(CPP_LINE_BASE(ip), ip->cur, &line, &col);
2406
2407 bufx = (char *)alloca(10);
2408 sprintf(bufx, "%d", (int)line);
2409 buf = bufx;
2410 }
2411 break;
2412
2413 case T_DATE:
2414 case T_TIME:
2415 bufx = (char *)alloca(20);
2416 timebuf = timestamp(pfile);
2417 if (hp->type == T_DATE)
2418 sprintf(bufx, "\"%s %2d %4d\"", monthnames[timebuf->tm_mon],
2419 timebuf->tm_mday, timebuf->tm_year + 1900);
2420 else
2421 sprintf(bufx, "\"%02d:%02d:%02d\"", timebuf->tm_hour,
2422 timebuf->tm_min, timebuf->tm_sec);
2423 buf = bufx;
2424 break;
2425
2426 case T_SPEC_DEFINED:
2427 buf = " 0 "; /* Assume symbol is not defined */
2428 ip = CPP_BUFFER(pfile);
2429 SKIP_WHITE_SPACE(ip->cur);
2430 if (*ip->cur == '(')
2431 {
2432 paren++;
2433 ip->cur++; /* Skip over the paren */
2434 SKIP_WHITE_SPACE(ip->cur);
2435 }
2436 if (!is_idstart[*ip->cur])
2437 goto oops;
2438 if ((hp = cpp_lookup((const char *)ip->cur, -1, -1)))
2439 {
2440 buf = " 1 ";
2441 }
2442 while (is_idchar[*ip->cur])
2443 ++ip->cur;
2444 SKIP_WHITE_SPACE(ip->cur);
2445 if (paren)
2446 {
2447 if (*ip->cur != ')')
2448 goto oops;
2449 ++ip->cur;
2450 }
2451 break;
2452
2453 oops:
2454
2455 cpp_error(pfile, "`defined' without an identifier");
2456 break;
2457
2458 default:
2459 cpp_error(pfile, "cccp error: invalid special hash type"); /* time for gdb */
2460 abort();
2461 }
2462 len = strlen(buf);
2463 CPP_RESERVE(pfile, len + 1);
2464 CPP_PUTS_Q(pfile, buf, len);
2465 CPP_NUL_TERMINATE_Q(pfile);
2466
2467 return;
2468}
2469
2470/* Initialize the built-in macros. */
2471
2472static void
2473initialize_builtins(cpp_reader * pfile)
2474{
2475 install("__LINE__", -1, T_SPECLINE, 0, 0, -1);
2476 install("__DATE__", -1, T_DATE, 0, 0, -1);
2477 install("__FILE__", -1, T_FILE, 0, 0, -1);
2478 install("__BASE_FILE__", -1, T_BASE_FILE, 0, 0, -1);
2479 install("__INCLUDE_LEVEL__", -1, T_INCLUDE_LEVEL, 0, 0, -1);
2480 install("__VERSION__", -1, T_VERSION, 0, 0, -1);
2481#ifndef NO_BUILTIN_SIZE_TYPE
2482 install("__SIZE_TYPE__", -1, T_SIZE_TYPE, 0, 0, -1);
2483#endif
2484#ifndef NO_BUILTIN_PTRDIFF_TYPE
2485 install("__PTRDIFF_TYPE__ ", -1, T_PTRDIFF_TYPE, 0, 0, -1);
2486#endif
2487 install("__WCHAR_TYPE__", -1, T_WCHAR_TYPE, 0, 0, -1);
2488 install("__USER_LABEL_PREFIX__", -1, T_USER_LABEL_PREFIX_TYPE, 0, 0, -1);
2489 install("__REGISTER_PREFIX__", -1, T_REGISTER_PREFIX_TYPE, 0, 0, -1);
2490 install("__TIME__", -1, T_TIME, 0, 0, -1);
2491 install("__STDC__", -1, T_CONST, STDC_VALUE, 0, -1);
2492 if (CPP_OPTIONS(pfile)->objc)
2493 install("__OBJC__", -1, T_CONST, 1, 0, -1);
2494/* This is supplied using a -D by the compiler driver
2495 * so that it is present only when truly compiling with GNU C. */
2496/* install ("__GNUC__", -1, T_CONST, 2, 0, -1); */
2497
2498 if (CPP_OPTIONS(pfile)->debug_output)
2499 {
2500 char directive[2048];
2501 struct directive *dp = &directive_table[0];
2502 struct tm *timebuf = timestamp(pfile);
2503 cpp_buffer *pbuffer = CPP_BUFFER(pfile);
2504
2505 while (CPP_PREV_BUFFER(pbuffer))
2506 pbuffer = CPP_PREV_BUFFER(pbuffer);
2507 sprintf(directive, " __BASE_FILE__ \"%s\"\n", pbuffer->nominal_fname);
2508 output_line_command(pfile, 0, same_file);
2509 pass_thru_directive(directive, &directive[strlen(directive)], pfile,
2510 dp);
2511
2512 sprintf(directive, " __VERSION__ \"%s\"\n", version_string);
2513 output_line_command(pfile, 0, same_file);
2514 pass_thru_directive(directive, &directive[strlen(directive)], pfile,
2515 dp);
2516
2517#ifndef NO_BUILTIN_SIZE_TYPE
2518 sprintf(directive, " __SIZE_TYPE__ %s\n", SIZE_TYPE);
2519 output_line_command(pfile, 0, same_file);
2520 pass_thru_directive(directive, &directive[strlen(directive)], pfile,
2521 dp);
2522#endif
2523
2524#ifndef NO_BUILTIN_PTRDIFF_TYPE
2525 sprintf(directive, " __PTRDIFF_TYPE__ %s\n", PTRDIFF_TYPE);
2526 output_line_command(pfile, 0, same_file);
2527 pass_thru_directive(directive, &directive[strlen(directive)], pfile,
2528 dp);
2529#endif
2530
2531 sprintf(directive, " __WCHAR_TYPE__ %s\n", CPP_WCHAR_TYPE(pfile));
2532 output_line_command(pfile, 0, same_file);
2533 pass_thru_directive(directive, &directive[strlen(directive)], pfile,
2534 dp);
2535
2536 sprintf(directive, " __DATE__ \"%s %2d %4d\"\n",
2537 monthnames[timebuf->tm_mon],
2538 timebuf->tm_mday, timebuf->tm_year + 1900);
2539 output_line_command(pfile, 0, same_file);
2540 pass_thru_directive(directive, &directive[strlen(directive)], pfile,
2541 dp);
2542
2543 sprintf(directive, " __TIME__ \"%02d:%02d:%02d\"\n",
2544 timebuf->tm_hour, timebuf->tm_min, timebuf->tm_sec);
2545 output_line_command(pfile, 0, same_file);
2546 pass_thru_directive(directive, &directive[strlen(directive)], pfile,
2547 dp);
2548
2549 sprintf(directive, " __STDC__ 1");
2550 output_line_command(pfile, 0, same_file);
2551 pass_thru_directive(directive, &directive[strlen(directive)],
2552 pfile, dp);
2553 }
2554}
2555
2556/* Return 1 iff a token ending in C1 followed directly by a token C2
2557 * could cause mis-tokenization. */
2558
2559static int
2560unsafe_chars(int c1, int c2)
2561{
2562// printf("unsafe %c %c ...", c1, c2);
2563 switch (c1)
2564 {
2565 case '+':
2566 case '-':
2567 case '.':
2568// printf(" no0\n");
2569 return 0;
2570 case '0':
2571 case '1':
2572 case '2':
2573 case '3':
2574 case '4':
2575 case '5':
2576 case '6':
2577 case '7':
2578 case '8':
2579 case '9':
2580 case 'e':
2581 case 'E':
2582 if (c2 == '-' || c2 == '+')
2583 {
2584// printf(" yes2\n");
2585 return 1; /* could extend a pre-processing number */
2586 }
2587 goto letter;
2588 case 'L':
2589 if (c2 == '\'' || c2 == '\"')
2590 {
2591// printf(" yes3\n");
2592 return 1; /* Could turn into L"xxx" or L'xxx'. */
2593 }
2594 goto letter;
2595 letter:
2596 case '_':
2597 case 'a':
2598 case 'b':
2599 case 'c':
2600 case 'd':
2601 case 'f':
2602 case 'g':
2603 case 'h':
2604 case 'i':
2605 case 'j':
2606 case 'k':
2607 case 'l':
2608 case 'm':
2609 case 'n':
2610 case 'o':
2611 case 'p':
2612 case 'q':
2613 case 'r':
2614 case 's':
2615 case 't':
2616 case 'u':
2617 case 'v':
2618 case 'w':
2619 case 'x':
2620 case 'y':
2621 case 'z':
2622 case 'A':
2623 case 'B':
2624 case 'C':
2625 case 'D':
2626 case 'F':
2627 case 'G':
2628 case 'H':
2629 case 'I':
2630 case 'J':
2631 case 'K':
2632 case 'M':
2633 case 'N':
2634 case 'O':
2635 case 'P':
2636 case 'Q':
2637 case 'R':
2638 case 'S':
2639 case 'T':
2640 case 'U':
2641 case 'V':
2642 case 'W':
2643 case 'X':
2644 case 'Y':
2645 case 'Z':
2646 /* We're in the middle of either a name or a pre-processing number. */
2647 if (is_idchar[c2] || c2 == '.')
2648 {
2649// printf(" yes4 %i %i\n", is_idchar[c2], c2 == '.');
2650 return 1;
2651 }
2652 else
2653 {
2654// printf(" no5\n");
2655 return 0;
2656 }
2657 case '<':
2658 case '>':
2659 case '!':
2660 case '%':
2661 case '#':
2662 case ':':
2663 case '^':
2664 case '&':
2665 case '|':
2666 case '*':
2667 case '/':
2668 case '=':
2669 if (c2 == c1 || c2 == '=')
2670 {
2671// printf(" yes6\n");
2672 return 1;
2673 }
2674 else
2675 {
2676// printf(" no7\n");
2677 return 0;
2678 }
2679 }
2680// printf(" no8\n");
2681 return 0;
2682}
2683
2684/* Expand a macro call.
2685 * HP points to the symbol that is the macro being called.
2686 * Put the result of expansion onto the input stack
2687 * so that subsequent input by our caller will use it.
2688 *
2689 * If macro wants arguments, caller has already verified that
2690 * an argument list follows; arguments come from the input stack. */
2691
2692static void
2693macroexpand(cpp_reader * pfile, HASHNODE * hp)
2694{
2695 int nargs;
2696 DEFINITION *defn = hp->value.defn;
2697 unsigned char *xbuf;
2698 long start_line, start_column;
2699 int xbuf_len;
2700 struct argdata *args;
2701 long old_written = CPP_WRITTEN(pfile);
2702
2703 int rest_args, rest_zero;
2704 int i;
2705
2706 pfile->output_escapes++;
2707 cpp_buf_line_and_col(cpp_file_buffer(pfile), &start_line, &start_column);
2708
2709 rest_zero = 0;
2710 args = NULL;
2711 nargs = defn->nargs;
2712
2713 if (nargs >= 0)
2714 {
2715 enum cpp_token token;
2716
2717 token = CPP_OTHER;
2718
2719 args = (struct argdata *)alloca((nargs + 1) * sizeof(struct argdata));
2720
2721 for (i = 0; i < nargs; i++)
2722 {
2723 args[i].raw = args[i].expanded = 0;
2724 args[i].raw_length = 0;
2725 args[i].expand_length = args[i].stringified_length = -1;
2726 args[i].use_count = 0;
2727 }
2728
2729 /* Parse all the macro args that are supplied. I counts them.
2730 * The first NARGS args are stored in ARGS.
2731 * The rest are discarded. If rest_args is set then we assume
2732 * macarg absorbed the rest of the args. */
2733 i = 0;
2734 rest_args = 0;
2735 rest_args = 0;
2736 FORWARD(1); /* Discard the open-parenthesis before the first arg. */
2737 do
2738 {
2739 if (rest_args)
2740 continue;
2741 if (i < nargs || (nargs == 0 && i == 0))
2742 {
2743 unsigned char *bp;
2744
2745 /* if we are working on last arg which absorbs rest of args... */
2746 if (i == nargs - 1 && defn->rest_args)
2747 rest_args = 1;
2748 args[i].raw = CPP_WRITTEN(pfile);
2749 token = macarg(pfile, rest_args);
2750 args[i].raw_length = CPP_WRITTEN(pfile) - args[i].raw;
2751 args[i].newlines = 0; /* FIXME */
2752 bp = ARG_BASE + args[i].raw;
2753 while (is_space[(unsigned char)(*bp)]) { bp++; }
2754 args[i].raw_length -= bp - (ARG_BASE + args[i].raw);
2755 args[i].raw = bp - ARG_BASE;
2756 if (args[i].raw_length > 0)
2757 {
2758 bp = ARG_BASE + args[i].raw + args[i].raw_length - 1;
2759 while (is_space[(unsigned char)(*bp)])
2760 {
2761 bp--;
2762 args[i].raw_length--;
2763 if (args[i].raw_length < 1) break;
2764 }
2765 }
2766 }
2767 else
2768 token = macarg(pfile, 0);
2769 if (token == CPP_EOF || token == CPP_POP)
2770 {
2771 cpp_error_with_line(pfile, start_line, start_column,
2772 "unterminated macro call");
2773 return;
2774 }
2775 i++;
2776 }
2777 while (token == CPP_COMMA);
2778
2779 /* If we got one arg but it was just whitespace, call that 0 args. */
2780 if (i == 1)
2781 {
2782 unsigned char *bp = ARG_BASE + args[0].raw;
2783 unsigned char *lim = bp + args[0].raw_length;
2784
2785 /* cpp.texi says for foo ( ) we provide one argument.
2786 * However, if foo wants just 0 arguments, treat this as 0. */
2787 if (nargs == 0)
2788 while (bp != lim && is_space[*bp])
2789 bp++;
2790 if (bp == lim)
2791 i = 0;
2792 }
2793 /* Don't output an error message if we have already output one for
2794 * a parse error above. */
2795 if (nargs == 0 && i > 0)
2796 {
2797 cpp_error(pfile, "arguments given to macro `%s'", hp->name);
2798 }
2799 else if (i < nargs)
2800 {
2801 if (i == nargs - 1 && defn->rest_args)
2802 rest_zero = 1;
2803 else if (i == 0)
2804 cpp_error(pfile, "macro `%s' used without args", hp->name);
2805 else if (i == 1)
2806 cpp_error(pfile, "macro `%s' used with just one arg", hp->name);
2807 else
2808 cpp_error(pfile, "macro `%s' used with only %d args",
2809 hp->name, i);
2810 }
2811 else if (i > nargs)
2812 {
2813 cpp_error(pfile,
2814 "macro `%s' used with too many (%d) args", hp->name, i);
2815 }
2816 }
2817 /* If macro wants zero args, we parsed the arglist for checking only.
2818 * Read directly from the macro definition. */
2819 if (nargs <= 0)
2820 {
2821 xbuf = defn->expansion;
2822 xbuf_len = defn->length;
2823 }
2824 else
2825 {
2826 unsigned char *exp = defn->expansion;
2827 int offset; /* offset in expansion,
2828 * copied a piece at a time */
2829 int totlen; /* total amount of exp buffer filled so far */
2830 reflist *ap, *last_ap;
2831
2832 /* Macro really takes args. Compute the expansion of this call. */
2833
2834 /* Compute length in characters of the macro's expansion.
2835 * Also count number of times each arg is used. */
2836 xbuf_len = defn->length;
2837 for (ap = defn->pattern; ap; ap = ap->next)
2838 {
2839 if (ap->stringify)
2840 {
2841 struct argdata *arg = &args[ap->argno];
2842
2843 /* Stringify it it hasn't already been */
2844 if (arg->stringified_length < 0)
2845 {
2846 int arglen = arg->raw_length;
2847 int escaped = 0;
2848 int in_string = 0;
2849 int c;
2850
2851 /* Initially need_space is -1. Otherwise, 1 means the
2852 * previous character was a space, but we suppressed it;
2853 * 0 means the previous character was a non-space. */
2854 int need_space = -1;
2855
2856 i = 0;
2857 arg->stringified = CPP_WRITTEN(pfile);
2858 CPP_PUTC(pfile, '\"'); /* insert beginning quote */
2859 for (; i < arglen; i++)
2860 {
2861 c = (ARG_BASE + arg->raw)[i];
2862
2863 if (!in_string)
2864 {
2865 /* Internal sequences of whitespace are replaced by
2866 * one space except within an string or char token. */
2867 if (is_space[c])
2868 {
2869 if (CPP_WRITTEN(pfile) > arg->stringified
2870 && (CPP_PWRITTEN(pfile))[-1] == '@')
2871 {
2872 /* "@ " escape markers are removed */
2873 CPP_ADJUST_WRITTEN(pfile, -1);
2874 continue;
2875 }
2876 if (need_space == 0)
2877 need_space = 1;
2878 continue;
2879 }
2880 else if (need_space > 0)
2881 CPP_PUTC(pfile, ' ');
2882 need_space = 0;
2883 }
2884 if (escaped)
2885 escaped = 0;
2886 else
2887 {
2888 if (c == '\\')
2889 escaped = 1;
2890 if (in_string)
2891 {
2892 if (c == in_string)
2893 in_string = 0;
2894 }
2895 else if (c == '\"' || c == '\'')
2896 in_string = c;
2897 }
2898
2899 /* Escape these chars */
2900 if (c == '\"' || (in_string && c == '\\'))
2901 CPP_PUTC(pfile, '\\');
2902 if (isprint(c))
2903 CPP_PUTC(pfile, c);
2904 else
2905 {
2906 CPP_RESERVE(pfile, 4);
2907 sprintf((char *)CPP_PWRITTEN(pfile), "\\%03o",
2908 (unsigned int)c);
2909 CPP_ADJUST_WRITTEN(pfile, 4);
2910 }
2911 }
2912 CPP_PUTC(pfile, '\"'); /* insert ending quote */
2913 arg->stringified_length
2914 = CPP_WRITTEN(pfile) - arg->stringified;
2915 }
2916 xbuf_len += args[ap->argno].stringified_length;
2917 }
2918 else if (ap->raw_before || ap->raw_after)
2919 {
2920 /* Add 4 for two newline-space markers to prevent
2921 * token concatenation. */
2922 xbuf_len += args[ap->argno].raw_length + 4;
2923 }
2924 else
2925 {
2926 /* We have an ordinary (expanded) occurrence of the arg.
2927 * So compute its expansion, if we have not already. */
2928 if (args[ap->argno].expand_length < 0)
2929 {
2930 args[ap->argno].expanded = CPP_WRITTEN(pfile);
2931 cpp_expand_to_buffer(pfile,
2932 ARG_BASE + args[ap->argno].raw,
2933 args[ap->argno].raw_length);
2934
2935 args[ap->argno].expand_length
2936 = CPP_WRITTEN(pfile) - args[ap->argno].expanded;
2937 }
2938 /* Add 4 for two newline-space markers to prevent
2939 * token concatenation. */
2940 xbuf_len += args[ap->argno].expand_length + 4;
2941 }
2942 if (args[ap->argno].use_count < 10)
2943 args[ap->argno].use_count++;
2944 }
2945
2946 xbuf = (unsigned char *)xmalloc(xbuf_len + 1);
2947
2948 /* Generate in XBUF the complete expansion
2949 * with arguments substituted in.
2950 * TOTLEN is the total size generated so far.
2951 * OFFSET is the index in the definition
2952 * of where we are copying from. */
2953 offset = totlen = 0;
2954 for (last_ap = NULL, ap = defn->pattern; ap;
2955 last_ap = ap, ap = ap->next)
2956 {
2957 struct argdata *arg = &args[ap->argno];
2958 int count_before = totlen;
2959
2960 /* Add chars to XBUF. */
2961 for (i = 0; i < ap->nchars; i++, offset++)
2962 xbuf[totlen++] = exp[offset];
2963
2964 /* If followed by an empty rest arg with concatenation,
2965 * delete the last run of nonwhite chars. */
2966 if (rest_zero && totlen > count_before
2967 && ((ap->rest_args && ap->raw_before)
2968 || (last_ap && last_ap->rest_args && last_ap->raw_after)))
2969 {
2970 /* Delete final whitespace. */
2971 while (totlen > count_before && is_space[xbuf[totlen - 1]])
2972 totlen--;
2973
2974 /* Delete the nonwhites before them. */
2975 while (totlen > count_before && !is_space[xbuf[totlen - 1]])
2976 totlen--;
2977 }
2978 if (ap->stringify != 0)
2979 {
2980 memcpy(xbuf + totlen, ARG_BASE + arg->stringified,
2981 arg->stringified_length);
2982 totlen += arg->stringified_length;
2983 }
2984 else if (ap->raw_before || ap->raw_after)
2985 {
2986 unsigned char *p1 = ARG_BASE + arg->raw;
2987 unsigned char *l1 = p1 + arg->raw_length;
2988
2989 if (ap->raw_before)
2990 {
2991 while (p1 != l1 && is_space[*p1])
2992 p1++;
2993 while (p1 != l1 && is_idchar[*p1])
2994 xbuf[totlen++] = *p1++;
2995 }
2996 if (ap->raw_after)
2997 {
2998 /* Arg is concatenated after: delete trailing whitespace,
2999 * whitespace markers, and no-reexpansion markers. */
3000 while (p1 != l1)
3001 {
3002 if (is_space[l1[-1]])
3003 l1--;
3004 else if (l1[-1] == '-')
3005 {
3006 unsigned char *p2 = l1 - 1;
3007
3008 /* If a `-' is preceded by an odd number of newlines then it
3009 * and the last newline are a no-reexpansion marker. */
3010 while (p2 != p1 && p2[-1] == '\n')
3011 p2--;
3012 if ((l1 - 1 - p2) & 1)
3013 {
3014 l1 -= 2;
3015 }
3016 else
3017 break;
3018 }
3019 else
3020 break;
3021 }
3022 }
3023 memcpy(xbuf + totlen, p1, l1 - p1);
3024 totlen += l1 - p1;
3025 }
3026 else
3027 {
3028 unsigned char *expanded = ARG_BASE + arg->expanded;
3029
3030 if (!ap->raw_before && totlen > 0 && arg->expand_length
3031 && unsafe_chars(xbuf[totlen - 1], expanded[0]))
3032 {
3033 xbuf[totlen++] = '@';
3034 xbuf[totlen++] = ' ';
3035 }
3036 memcpy(xbuf + totlen, expanded, arg->expand_length);
3037 totlen += arg->expand_length;
3038
3039 if (!ap->raw_after && totlen > 0 && offset < defn->length
3040 && unsafe_chars(xbuf[totlen - 1], exp[offset]))
3041 {
3042 xbuf[totlen++] = '@';
3043 xbuf[totlen++] = ' ';
3044 }
3045 /* If a macro argument with newlines is used multiple times,
3046 * then only expand the newlines once. This avoids creating
3047 * output lines which don't correspond to any input line,
3048 * which confuses gdb and gcov. */
3049 if (arg->use_count > 1 && arg->newlines > 0)
3050 {
3051 /* Don't bother doing change_newlines for subsequent
3052 * uses of arg. */
3053 arg->use_count = 1;
3054 arg->expand_length
3055 = change_newlines(expanded, arg->expand_length);
3056 }
3057 }
3058
3059 if (totlen > xbuf_len)
3060 abort();
3061 }
3062 /* if there is anything left of the definition
3063 * after handling the arg list, copy that in too. */
3064
3065 for (i = offset; i < defn->length; i++)
3066 {
3067 /* if we've reached the end of the macro */
3068 if (exp[i] == ')')
3069 rest_zero = 0;
3070 if (!(rest_zero && last_ap && last_ap->rest_args
3071 && last_ap->raw_after))
3072 xbuf[totlen++] = exp[i];
3073 }
3074
3075 xbuf[totlen] = 0;
3076 xbuf_len = totlen;
3077 }
3078
3079 pfile->output_escapes--;
3080
3081 /* Now put the expansion on the input stack
3082 * so our caller will commence reading from it. */
3083 push_macro_expansion(pfile, xbuf, xbuf_len, hp);
3084 CPP_BUFFER(pfile)->has_escapes = 1;
3085
3086 /* Pop the space we've used in the token_buffer for argument expansion. */
3087 CPP_SET_WRITTEN(pfile, old_written);
3088
3089 /* Recursive macro use sometimes works traditionally.
3090 * #define foo(x,y) bar (x (y,0), y)
3091 * foo (foo, baz) */
3092
3093 hp->type = T_DISABLED;
3094}
3095
3096static void
3097push_macro_expansion(cpp_reader * pfile, unsigned char *xbuf, int xbuf_len,
3098 HASHNODE * hp)
3099{
3100 cpp_buffer *mbuf = cpp_push_buffer(pfile, xbuf, xbuf_len);
3101
3102 mbuf->cleanup = macro_cleanup;
3103 mbuf->data = hp;
3104
3105 /* The first chars of the expansion should be a "@ " added by
3106 * collect_expansion. This is to prevent accidental token-pasting
3107 * between the text preceding the macro invocation, and the macro
3108 * expansion text.
3109 *
3110 * We would like to avoid adding unneeded spaces (for the sake of
3111 * tools that use cpp, such as imake). In some common cases we can
3112 * tell that it is safe to omit the space.
3113 *
3114 * The character before the macro invocation cannot have been an
3115 * idchar (or else it would have been pasted with the idchars of
3116 * the macro name). Therefore, if the first non-space character
3117 * of the expansion is an idchar, we do not need the extra space
3118 * to prevent token pasting.
3119 *
3120 * Also, we don't need the extra space if the first char is '(',
3121 * or some other (less common) characters. */
3122
3123 if (xbuf[0] == '@' && xbuf[1] == ' '
3124 && (is_idchar[xbuf[2]] || xbuf[2] == '(' || xbuf[2] == '\''
3125 || xbuf[2] == '\"'))
3126 mbuf->cur += 2;
3127}
3128
3129/* Like cpp_get_token, except that it does not read past end-of-line.
3130 * Also, horizontal space is skipped, and macros are popped. */
3131
3132static enum cpp_token
3133get_directive_token(cpp_reader * pfile)
3134{
3135 for (;;)
3136 {
3137 long old_written = CPP_WRITTEN(pfile);
3138 enum cpp_token token;
3139
3140 cpp_skip_hspace(pfile);
3141 if (PEEKC() == '\n')
3142 return CPP_VSPACE;
3143 token = cpp_get_token(pfile);
3144 switch (token)
3145 {
3146 case CPP_POP:
3147 if (!CPP_IS_MACRO_BUFFER(CPP_BUFFER(pfile)))
3148 return token;
3149 /* ... else fall though ... */
3150 case CPP_HSPACE:
3151 case CPP_COMMENT:
3152 CPP_SET_WRITTEN(pfile, old_written);
3153 break;
3154 default:
3155 return token;
3156 }
3157 }
3158}
3159
3160/* Handle #include and #import.
3161 * This function expects to see "fname" or <fname> on the input.
3162 *
3163 * The input is normally in part of the output_buffer following
3164 * CPP_WRITTEN, and will get overwritten by output_line_command.
3165 * I.e. in input file specification has been popped by handle_directive.
3166 * This is safe. */
3167
3168static int
3169do_include(cpp_reader * pfile, struct directive *keyword,
3170 unsigned char *unused1 __UNUSED__, unsigned char *unused2 __UNUSED__)
3171{
3172 int importing = (keyword->type == T_IMPORT);
3173 int skip_dirs = (keyword->type == T_INCLUDE_NEXT);
3174 char *fname; /* Dynamically allocated fname buffer */
3175 unsigned char *fbeg, *fend; /* Beginning and end of fname */
3176 enum cpp_token token;
3177
3178 /* Chain of dirs to search */
3179 file_name_list *search_start = CPP_OPTIONS(pfile)->include;
3180 file_name_list dsp[1]; /* First in chain, if #include "..." */
3181 file_name_list *searchptr = 0;
3182 long old_written = CPP_WRITTEN(pfile);
3183 int flen;
3184 int f; /* file number */
3185 int angle_brackets = 0; /* 0 for "...", 1 for <...> */
3186
3187 f = -1; /* JF we iz paranoid! */
3188
3189 if (importing && CPP_OPTIONS(pfile)->warn_import
3190 && !CPP_OPTIONS(pfile)->inhibit_warnings
3191 && !CPP_BUFFER(pfile)->system_header_p && !pfile->import_warning)
3192 {
3193 pfile->import_warning = 1;
3194 cpp_warning(pfile, "using `#import' is not recommended");
3195 fprintf(stderr,
3196 "The fact that a certain header file need not be processed more than once\n");
3197 fprintf(stderr,
3198 "should be indicated in the header file, not where it is used.\n");
3199 fprintf(stderr,
3200 "The best way to do this is with a conditional of this form:\n\n");
3201 fprintf(stderr, " #ifndef _FOO_H_INCLUDED\n");
3202 fprintf(stderr, " #define _FOO_H_INCLUDED\n");
3203 fprintf(stderr, " ... <real contents of file> ...\n");
3204 fprintf(stderr, " #endif /* Not _FOO_H_INCLUDED */\n\n");
3205 fprintf(stderr, "Then users can use `#include' any number of times.\n");
3206 fprintf(stderr,
3207 "GNU C automatically avoids processing the file more than once\n");
3208 fprintf(stderr, "when it is equipped with such a conditional.\n");
3209 }
3210 pfile->parsing_include_directive++;
3211 token = get_directive_token(pfile);
3212 pfile->parsing_include_directive--;
3213
3214 if (token == CPP_STRING)
3215 {
3216 /* FIXME - check no trailing garbage */
3217 fbeg = pfile->token_buffer + old_written + 1;
3218 fend = CPP_PWRITTEN(pfile) - 1;
3219 if (fbeg[-1] == '<')
3220 {
3221 angle_brackets = 1;
3222 /* If -I-, start with the first -I dir after the -I-. */
3223 if (CPP_OPTIONS(pfile)->first_bracket_include)
3224 search_start = CPP_OPTIONS(pfile)->first_bracket_include;
3225 }
3226 /* If -I- was specified, don't search current dir, only spec'd ones. */
3227 else if (!CPP_OPTIONS(pfile)->ignore_srcdir)
3228 {
3229 cpp_buffer *fp;
3230
3231 /* We have "filename". Figure out directory this source
3232 * file is coming from and put it on the front of the list. */
3233
3234 for (fp = CPP_BUFFER(pfile); fp; fp = CPP_PREV_BUFFER(fp))
3235 {
3236 int n;
3237 const char *ep, *nam;
3238
3239 if ((nam = fp->nominal_fname))
3240 {
3241 /* Found a named file. Figure out dir of the file,
3242 * and put it in front of the search list. */
3243 dsp[0].next = search_start;
3244 search_start = dsp;
3245#ifndef VMS
3246 ep = strrchr(nam, '/');
3247#else /* VMS */
3248 ep = strrchr(nam, ']');
3249 if (!ep)
3250 ep = strrchr(nam, '>');
3251 if (!ep)
3252 ep = strrchr(nam, ':');
3253 if (ep)
3254 ep++;
3255#endif /* VMS */
3256 if (ep)
3257 {
3258 n = ep - nam;
3259 dsp[0].fname = (char *)alloca(n + 1);
3260 strncpy(dsp[0].fname, nam, n);
3261 dsp[0].fname[n] = '\0';
3262 if (n + INCLUDE_LEN_FUDGE > pfile->max_include_len)
3263 pfile->max_include_len = n + INCLUDE_LEN_FUDGE;
3264 }
3265 else
3266 {
3267 dsp[0].fname = 0; /* Current directory */
3268 }
3269 dsp[0].got_name_map = 0;
3270 break;
3271 }
3272 }
3273 }
3274 }
3275 else
3276 {
3277 cpp_error(pfile,
3278 "`#%s' expects \"FILENAME\" or <FILENAME>", keyword->name);
3279 CPP_SET_WRITTEN(pfile, old_written);
3280 skip_rest_of_line(pfile);
3281 return 0;
3282 }
3283
3284 *fend = 0;
3285
3286 token = get_directive_token(pfile);
3287 if (token != CPP_VSPACE)
3288 {
3289 cpp_error(pfile, "junk at end of `#include'");
3290 while (token != CPP_VSPACE && token != CPP_EOF && token != CPP_POP)
3291 token = get_directive_token(pfile);
3292 }
3293 /* For #include_next, skip in the search path
3294 * past the dir in which the containing file was found. */
3295 if (skip_dirs)
3296 {
3297 cpp_buffer *fp;
3298
3299 for (fp = CPP_BUFFER(pfile); fp; fp = CPP_PREV_BUFFER(fp))
3300 if (fp->fname)
3301 {
3302 /* fp->dir is null if the containing file was specified with
3303 * an absolute file name. In that case, don't skip anything. */
3304 if (fp->dir == SELF_DIR_DUMMY)
3305 search_start = CPP_OPTIONS(pfile)->include;
3306 else if (fp->dir)
3307 search_start = fp->dir->next;
3308 break;
3309 }
3310 }
3311 CPP_SET_WRITTEN(pfile, old_written);
3312
3313 flen = fend - fbeg;
3314
3315 if (flen == 0)
3316 {
3317 cpp_error(pfile, "empty file name in `#%s'", keyword->name);
3318 return 0;
3319 }
3320 /* Allocate this permanently, because it gets stored in the definitions
3321 * of macros. */
3322 fname = (char *)xmalloc(pfile->max_include_len + flen + 4);
3323 /* + 2 above for slash and terminating null. */
3324 /* + 2 added for '.h' on VMS (to support '#include filename') */
3325
3326 /* If specified file name is absolute, just open it. */
3327
3328#ifndef __EMX__
3329 if (*fbeg == '/')
3330#else
3331 if (_fnisabs(fbeg))
3332#endif
3333 {
3334 strncpy(fname, (const char *)fbeg, flen);
3335 fname[flen] = 0;
3336 if (redundant_include_p(pfile, fname))
3337 return 0;
3338 if (importing)
3339 f = lookup_import(pfile, fname, NULL);
3340 else
3341 f = open_include_file(pfile, fname, NULL);
3342 if (f == -2)
3343 return 0; /* Already included this file */
3344 }
3345 else
3346 {
3347 /* Search directory path, trying to open the file.
3348 * Copy each filename tried into FNAME. */
3349
3350 for (searchptr = search_start; searchptr; searchptr = searchptr->next)
3351 {
3352 if (searchptr->fname)
3353 {
3354 /* The empty string in a search path is ignored.
3355 * This makes it possible to turn off entirely
3356 * a standard piece of the list. */
3357 if (searchptr->fname[0] == 0)
3358 continue;
3359 strcpy(fname, searchptr->fname);
3360 strcat(fname, "/");
3361 fname[strlen(fname) + flen] = 0;
3362 }
3363 else
3364 {
3365 fname[0] = 0;
3366 }
3367 strncat(fname, (const char *)fbeg, flen);
3368#ifdef VMS
3369 /* Change this 1/2 Unix 1/2 VMS file specification into a
3370 * full VMS file specification */
3371 if (searchptr->fname && (searchptr->fname[0] != 0))
3372 {
3373 /* Fix up the filename */
3374 hack_vms_include_specification(fname);
3375 }
3376 else
3377 {
3378 /* This is a normal VMS filespec, so use it unchanged. */
3379 strncpy(fname, fbeg, flen);
3380 fname[flen] = 0;
3381 /* if it's '#include filename', add the missing .h */
3382 if (!strchr(fname, '.'))
3383 {
3384 strcat(fname, ".h");
3385 }
3386 }
3387#endif /* VMS */
3388 /* ??? There are currently 3 separate mechanisms for avoiding processing
3389 * of redundant include files: #import, #pragma once, and
3390 * redundant_include_p. It would be nice if they were unified. */
3391 if (redundant_include_p(pfile, fname))
3392 return 0;
3393 if (importing)
3394 f = lookup_import(pfile, fname, searchptr);
3395 else
3396 f = open_include_file(pfile, fname, searchptr);
3397 if (f == -2)
3398 return 0; /* Already included this file */
3399#ifdef EACCES
3400 else if (f == -1 && errno == EACCES)
3401 cpp_warning(pfile, "Header file %s exists, but is not readable",
3402 fname);
3403#endif
3404 if (f >= 0)
3405 break;
3406 }
3407 }
3408
3409 if (f < 0)
3410 {
3411 /* A file that was not found. */
3412 strncpy(fname, (const char *)fbeg, flen);
3413 fname[flen] = 0;
3414 /* If generating dependencies and -MG was specified, we assume missing
3415 * files are leaf files, living in the same directory as the source file
3416 * or other similar place; these missing files may be generated from
3417 * other files and may not exist yet (eg: y.tab.h). */
3418
3419 if (CPP_OPTIONS(pfile)->print_deps_missing_files
3420 && CPP_PRINT_DEPS(pfile)
3421 > (angle_brackets || (pfile->system_include_depth > 0)))
3422 {
3423 /* If it was requested as a system header file,
3424 * then assume it belongs in the first place to look for such. */
3425 if (angle_brackets)
3426 {
3427 for (searchptr = search_start; searchptr;
3428 searchptr = searchptr->next)
3429 {
3430 if (searchptr->fname)
3431 {
3432 char *p;
3433
3434 if (searchptr->fname[0] == 0)
3435 continue;
3436 p = (char *)alloca(strlen(searchptr->fname)
3437 + strlen(fname) + 2);
3438 strcpy(p, searchptr->fname);
3439 strcat(p, "/");
3440 strcat(p, fname);
3441 deps_output(pfile, p, ' ');
3442 break;
3443 }
3444 }
3445 }
3446 else
3447 {
3448 /* Otherwise, omit the directory, as if the file existed
3449 * in the directory with the source. */
3450 deps_output(pfile, fname, ' ');
3451 }
3452 }
3453 /* If -M was specified, and this header file won't be added to the
3454 * dependency list, then don't count this as an error, because we can
3455 * still produce correct output. Otherwise, we can't produce correct
3456 * output, because there may be dependencies we need inside the missing
3457 * file, and we don't know what directory this missing file exists in. */
3458 else if (CPP_PRINT_DEPS(pfile)
3459 && (CPP_PRINT_DEPS(pfile)
3460 <= (angle_brackets || (pfile->system_include_depth > 0))))
3461 cpp_warning(pfile, "No include path in which to find %s", fname);
3462 else if (search_start)
3463 cpp_error_from_errno(pfile, fname);
3464 else
3465 cpp_error(pfile, "No include path in which to find %s", fname);
3466 }
3467 else
3468 {
3469 /* Check to see if this include file is a once-only include file.
3470 * If so, give up. */
3471
3472 file_name_list *ptr;
3473
3474 for (ptr = pfile->dont_repeat_files; ptr; ptr = ptr->next)
3475 {
3476 if (!strcmp(ptr->fname, fname))
3477 {
3478 close(f);
3479 return 0; /* This file was once'd. */
3480 }
3481 }
3482
3483 for (ptr = pfile->all_include_files; ptr; ptr = ptr->next)
3484 {
3485 if (!strcmp(ptr->fname, fname))
3486 break; /* This file was included before. */
3487 }
3488
3489 if (!ptr)
3490 {
3491 /* This is the first time for this file. */
3492 /* Add it to list of files included. */
3493
3494 ptr = (file_name_list *) xmalloc(sizeof(file_name_list));
3495
3496 ptr->control_macro = 0;
3497 ptr->c_system_include_path = 0;
3498 ptr->next = pfile->all_include_files;
3499 pfile->all_include_files = ptr;
3500 ptr->fname = savestring(fname);
3501 ptr->got_name_map = 0;
3502
3503 /* For -M, add this file to the dependencies. */
3504 if (CPP_PRINT_DEPS(pfile)
3505 > (angle_brackets || (pfile->system_include_depth > 0)))
3506 deps_output(pfile, fname, ' ');
3507 }
3508 /* Handle -H option. */
3509 if (CPP_OPTIONS(pfile)->print_include_names)
3510 {
3511 cpp_buffer *buf = CPP_BUFFER(pfile);
3512
3513 while ((buf = CPP_PREV_BUFFER(buf)))
3514 putc('.', stderr);
3515 fprintf(stderr, "%s\n", fname);
3516 }
3517 if (angle_brackets)
3518 pfile->system_include_depth++;
3519
3520 /* Actually process the file. */
3521
3522 /* Record file on "seen" list for #import. */
3523 add_import(pfile, f, fname);
3524
3525 /* Actually process the file */
3526 cpp_push_buffer(pfile, NULL, 0);
3527 if (finclude(pfile, f, fname, is_system_include(pfile, fname),
3528 searchptr != dsp ? searchptr : SELF_DIR_DUMMY))
3529 {
3530 output_line_command(pfile, 0, enter_file);
3531 pfile->only_seen_white = 2;
3532 }
3533 if (angle_brackets)
3534 pfile->system_include_depth--;
3535 }
3536 return 0;
3537}
3538
3539/* Return nonzero if there is no need to include file NAME
3540 * because it has already been included and it contains a conditional
3541 * to make a repeated include do nothing. */
3542
3543static int
3544redundant_include_p(cpp_reader * pfile, char *name)
3545{
3546 file_name_list *l = pfile->all_include_files;
3547
3548 for (; l; l = l->next)
3549 if (!strcmp(name, l->fname)
3550 && l->control_macro
3551 && cpp_lookup((const char *)l->control_macro, -1, -1))
3552 return 1;
3553 return 0;
3554}
3555
3556/* Return nonzero if the given FILENAME is an absolute pathname which
3557 * designates a file within one of the known "system" include file
3558 * directories. We assume here that if the given FILENAME looks like
3559 * it is the name of a file which resides either directly in a "system"
3560 * include file directory, or within any subdirectory thereof, then the
3561 * given file must be a "system" include file. This function tells us
3562 * if we should suppress pedantic errors/warnings for the given FILENAME.
3563 *
3564 * The value is 2 if the file is a C-language system header file
3565 * for which C++ should (on most systems) assume `extern "C"'. */
3566
3567static int
3568is_system_include(cpp_reader * pfile, char *filename)
3569{
3570 file_name_list *searchptr;
3571
3572 for (searchptr = CPP_OPTIONS(pfile)->first_system_include; searchptr;
3573 searchptr = searchptr->next)
3574 if (searchptr->fname)
3575 {
3576 char *sys_dir = searchptr->fname;
3577 unsigned length = strlen(sys_dir);
3578
3579 if (!strncmp(sys_dir, filename, length) && filename[length] == '/')
3580 {
3581 if (searchptr->c_system_include_path)
3582 return 2;
3583 else
3584 return 1;
3585 }
3586 }
3587 return 0;
3588}
3589
3590/*
3591 * Install a name in the assertion hash table.
3592 *
3593 * If LEN is >= 0, it is the length of the name.
3594 * Otherwise, compute the length by scanning the entire name.
3595 *
3596 * If HASH is >= 0, it is the precomputed hash code.
3597 * Otherwise, compute the hash code.
3598 */
3599static ASSERTION_HASHNODE *
3600assertion_install(cpp_reader * pfile, const char *name, int len, int hash)
3601{
3602 ASSERTION_HASHNODE *hp;
3603 int i, bucket;
3604
3605 i = sizeof(ASSERTION_HASHNODE) + len + 1;
3606 hp = (ASSERTION_HASHNODE *) xmalloc(i);
3607 bucket = hash;
3608 hp->bucket_hdr = &pfile->assertion_hashtab[bucket];
3609 hp->next = pfile->assertion_hashtab[bucket];
3610 pfile->assertion_hashtab[bucket] = hp;
3611 hp->prev = NULL;
3612 if (hp->next)
3613 hp->next->prev = hp;
3614 hp->length = len;
3615 hp->value = 0;
3616 hp->name = ((char *)hp) + sizeof(ASSERTION_HASHNODE);
3617 memcpy(hp->name, name, len);
3618 hp->name[len] = 0;
3619 return hp;
3620}
3621/*
3622 * find the most recent hash node for name name (ending with first
3623 * non-identifier char) installed by install
3624 *
3625 * If LEN is >= 0, it is the length of the name.
3626 * Otherwise, compute the length by scanning the entire name.
3627 *
3628 * If HASH is >= 0, it is the precomputed hash code.
3629 * Otherwise, compute the hash code.
3630 */
3631
3632static ASSERTION_HASHNODE *
3633assertion_lookup(cpp_reader * pfile, const char *name, int len, int hash)
3634{
3635 ASSERTION_HASHNODE *bucket;
3636
3637 bucket = pfile->assertion_hashtab[hash];
3638 while (bucket)
3639 {
3640 if (bucket->length == len && strncmp(bucket->name, name, len) == 0)
3641 return bucket;
3642 bucket = bucket->next;
3643 }
3644 return NULL;
3645}
3646
3647static void
3648delete_assertion(ASSERTION_HASHNODE * hp)
3649{
3650 struct tokenlist_list *tail;
3651
3652 if (hp->prev)
3653 hp->prev->next = hp->next;
3654 if (hp->next)
3655 hp->next->prev = hp->prev;
3656
3657 for (tail = hp->value; tail;)
3658 {
3659 struct tokenlist_list *next = tail->next;
3660
3661 free_token_list(tail->tokens);
3662 free(tail);
3663 tail = next;
3664 }
3665
3666 /* make sure that the bucket chain header that
3667 * the deleted guy was on points to the right thing afterwards. */
3668 if (hp == *hp->bucket_hdr)
3669 *hp->bucket_hdr = hp->next;
3670
3671 free(hp);
3672}
3673
3674/* Convert a character string literal into a nul-terminated string.
3675 * The input string is [IN ... LIMIT).
3676 * The result is placed in RESULT. RESULT can be the same as IN.
3677 * The value returned in the end of the string written to RESULT,
3678 * or NULL on error. */
3679
3680static char *
3681convert_string(cpp_reader * pfile, char *result, char *in, char *limit,
3682 int handle_escapes)
3683{
3684 unsigned char c;
3685
3686 c = *in++;
3687 if (c != '\"')
3688 return NULL;
3689 while (in < limit)
3690 {
3691 c = *in++;
3692
3693 switch (c)
3694 {
3695 case '\0':
3696 return NULL;
3697 case '\"':
3698 limit = in;
3699 break;
3700 case '\\':
3701 if (handle_escapes)
3702 {
3703 char *bpc = in;
3704 int i =
3705 (unsigned char)cpp_parse_escape(pfile, &bpc);
3706
3707 in = bpc;
3708 if (i >= 0)
3709 *result++ = (unsigned char)c;
3710 break;
3711 }
3712 /* else fall through */
3713 default:
3714 *result++ = c;
3715 }
3716 }
3717 *result = 0;
3718 return result;
3719}
3720
3721/*
3722 * interpret #line command. Remembers previously seen fnames
3723 * in its very own hash table.
3724 */
3725#define FNAME_HASHSIZE 37
3726
3727static int
3728do_line(cpp_reader * pfile, struct directive *keyword __UNUSED__,
3729 unsigned char *unused1 __UNUSED__, unsigned char *unused2 __UNUSED__)
3730{
3731 cpp_buffer *ip = CPP_BUFFER(pfile);
3732 int new_lineno;
3733 long old_written = CPP_WRITTEN(pfile);
3734 enum file_change_code file_change = same_file;
3735 enum cpp_token token;
3736
3737 token = get_directive_token(pfile);
3738
3739 if (token != CPP_NUMBER || !isdigit(pfile->token_buffer[old_written]))
3740 {
3741 cpp_error(pfile, "invalid format `#line' command");
3742 goto bad_line_directive;
3743 }
3744 /* The Newline at the end of this line remains to be processed.
3745 * To put the next line at the specified line number,
3746 * we must store a line number now that is one less. */
3747 new_lineno = atoi((char *)(pfile->token_buffer + old_written)) - 1;
3748 CPP_SET_WRITTEN(pfile, old_written);
3749
3750 /* NEW_LINENO is one less than the actual line number here. */
3751 if (CPP_PEDANTIC(pfile) && new_lineno < 0)
3752 cpp_pedwarn(pfile, "line number out of range in `#line' command");
3753
3754 token = get_directive_token(pfile);
3755
3756 if (token == CPP_STRING)
3757 {
3758 char *fname = (char *)pfile->token_buffer + old_written;
3759 char *end_name;
3760 static HASHNODE *fname_table[FNAME_HASHSIZE];
3761 HASHNODE *hp, **hash_bucket;
3762 unsigned char *p;
3763 long num_start;
3764 int fname_length;
3765
3766 /* Turn the file name, which is a character string literal,
3767 * into a null-terminated string. Do this in place. */
3768 end_name =
3769 convert_string(pfile, fname, fname, (char *)CPP_PWRITTEN(pfile), 1);
3770 if (!end_name)
3771 {
3772 cpp_error(pfile, "invalid format `#line' command");
3773 goto bad_line_directive;
3774 }
3775 fname_length = end_name - fname;
3776
3777 num_start = CPP_WRITTEN(pfile);
3778 token = get_directive_token(pfile);
3779 if (token != CPP_VSPACE && token != CPP_EOF && token != CPP_POP)
3780 {
3781 p = pfile->token_buffer + num_start;
3782 if (CPP_PEDANTIC(pfile))
3783 cpp_pedwarn(pfile, "garbage at end of `#line' command");
3784
3785 if (token != CPP_NUMBER || *p < '0' || *p > '4' || p[1] != '\0')
3786 {
3787 cpp_error(pfile, "invalid format `#line' command");
3788 goto bad_line_directive;
3789 }
3790 if (*p == '1')
3791 file_change = enter_file;
3792 else if (*p == 2)
3793 file_change = leave_file;
3794 else if (*p == 3)
3795 ip->system_header_p = 1;
3796 else /* if (*p == 4) */
3797 ip->system_header_p = 2;
3798
3799 CPP_SET_WRITTEN(pfile, num_start);
3800 token = get_directive_token(pfile);
3801 p = pfile->token_buffer + num_start;
3802 if (token == CPP_NUMBER && p[1] == '\0'
3803 && (*p == '3' || *p == '4'))
3804 {
3805 ip->system_header_p = *p == 3 ? 1 : 2;
3806 token = get_directive_token(pfile);
3807 }
3808 if (token != CPP_VSPACE)
3809 {
3810 cpp_error(pfile, "invalid format `#line' command");
3811 goto bad_line_directive;
3812 }
3813 }
3814 hash_bucket = &fname_table[hashf(fname, fname_length, FNAME_HASHSIZE)];
3815 for (hp = *hash_bucket; hp; hp = hp->next)
3816 if (hp->length == fname_length &&
3817 strncmp(hp->value.cpval, fname, fname_length) == 0)
3818 {
3819 ip->nominal_fname = hp->value.cpval;
3820 break;
3821 }
3822 if (!hp)
3823 {
3824 /* Didn't find it; cons up a new one. */
3825 hp = (HASHNODE *) xcalloc(1, sizeof(HASHNODE) + fname_length + 1);
3826 hp->next = *hash_bucket;
3827 *hash_bucket = hp;
3828
3829 hp->length = fname_length;
3830 ip->nominal_fname = hp->value.cpval =
3831 ((char *)hp) + sizeof(HASHNODE);
3832 memcpy(hp->value.cpval, fname, fname_length);
3833 }
3834 }
3835 else if (token != CPP_VSPACE && token != CPP_EOF)
3836 {
3837 cpp_error(pfile, "invalid format `#line' command");
3838 goto bad_line_directive;
3839 }
3840 ip->lineno = new_lineno;
3841 bad_line_directive:
3842 skip_rest_of_line(pfile);
3843 CPP_SET_WRITTEN(pfile, old_written);
3844 output_line_command(pfile, 0, file_change);
3845 return 0;
3846}
3847
3848/*
3849 * remove the definition of a symbol from the symbol table.
3850 * according to un*x /lib/cpp, it is not an error to undef
3851 * something that has no definitions, so it isn't one here either.
3852 */
3853
3854static int
3855do_undef(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
3856 unsigned char *limit)
3857{
3858 int sym_length;
3859 HASHNODE *hp;
3860 unsigned char *orig_buf = buf;
3861
3862 SKIP_WHITE_SPACE(buf);
3863 sym_length = check_macro_name(pfile, buf, "macro");
3864
3865 while ((hp = cpp_lookup((const char *)buf, sym_length, -1)))
3866 {
3867 /* If we are generating additional info for debugging (with -g) we
3868 * need to pass through all effective #undef commands. */
3869 if (CPP_OPTIONS(pfile)->debug_output && keyword)
3870 pass_thru_directive((char *)orig_buf, (char *)limit, pfile, keyword);
3871 if (hp->type != T_MACRO)
3872 cpp_warning(pfile, "undefining `%s'", hp->name);
3873 delete_macro(hp);
3874 }
3875
3876 if (CPP_PEDANTIC(pfile))
3877 {
3878 buf += sym_length;
3879 SKIP_WHITE_SPACE(buf);
3880 if (buf != limit)
3881 cpp_pedwarn(pfile, "garbage after `#undef' directive");
3882 }
3883 return 0;
3884}
3885
3886/*
3887 * Report an error detected by the program we are processing.
3888 * Use the text of the line in the error message.
3889 * (We use error because it prints the filename & line#.)
3890 */
3891
3892static int
3893do_error(cpp_reader * pfile, struct directive *keyword __UNUSED__,
3894 unsigned char *buf, unsigned char *limit)
3895{
3896 int length = limit - buf;
3897 unsigned char *copy = (unsigned char *)xmalloc(length + 1);
3898
3899 memcpy(copy, buf, length);
3900 copy[length] = 0;
3901 SKIP_WHITE_SPACE(copy);
3902 cpp_error(pfile, "#error %s", copy);
3903 return 0;
3904}
3905
3906/*
3907 * Report a warning detected by the program we are processing.
3908 * Use the text of the line in the warning message, then continue.
3909 * (We use error because it prints the filename & line#.)
3910 */
3911
3912static int
3913do_warning(cpp_reader * pfile, struct directive *keyword __UNUSED__,
3914 unsigned char *buf, unsigned char *limit)
3915{
3916 int length = limit - buf;
3917 unsigned char *copy = (unsigned char *)xmalloc(length + 1);
3918
3919 memcpy(copy, buf, length);
3920 copy[length] = 0;
3921 SKIP_WHITE_SPACE(copy);
3922 cpp_warning(pfile, "#warning %s", copy);
3923 return 0;
3924}
3925
3926/* Remember the name of the current file being read from so that we can
3927 * avoid ever including it again. */
3928
3929static int
3930do_once(cpp_reader * pfile)
3931{
3932 cpp_buffer *ip = NULL;
3933 file_name_list *new_;
3934
3935 for (ip = CPP_BUFFER(pfile);; ip = CPP_PREV_BUFFER(ip))
3936 {
3937 if (!ip)
3938 return 0;
3939 if (ip->fname)
3940 break;
3941 }
3942
3943 new_ = (file_name_list *) xmalloc(sizeof(file_name_list));
3944
3945 new_->next = pfile->dont_repeat_files;
3946 pfile->dont_repeat_files = new_;
3947 new_->fname = savestring(ip->fname);
3948 new_->control_macro = 0;
3949 new_->got_name_map = 0;
3950 new_->c_system_include_path = 0;
3951
3952 return 0;
3953}
3954
3955/* #ident has already been copied to the output file, so just ignore it. */
3956
3957static int
3958do_ident(cpp_reader * pfile, struct directive *keyword __UNUSED__,
3959 unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__)
3960{
3961/* long old_written = CPP_WRITTEN (pfile); */
3962
3963 /* Allow #ident in system headers, since that's not user's fault. */
3964 if (CPP_PEDANTIC(pfile) && !CPP_BUFFER(pfile)->system_header_p)
3965 cpp_pedwarn(pfile, "ANSI C does not allow `#ident'");
3966
3967 /* Leave rest of line to be read by later calls to cpp_get_token. */
3968
3969 return 0;
3970}
3971
3972/* #pragma and its argument line have already been copied to the output file.
3973 * Just check for some recognized pragmas that need validation here. */
3974
3975static int
3976do_pragma(cpp_reader * pfile, struct directive *keyword __UNUSED__,
3977 unsigned char *buf, unsigned char *limit __UNUSED__)
3978{
3979 while (*buf == ' ' || *buf == '\t')
3980 buf++;
3981
3982 if (!strncmp((const char *)buf, "once", 4))
3983 {
3984 /* Allow #pragma once in system headers, since that's not the user's
3985 * fault. */
3986 if (!CPP_BUFFER(pfile)->system_header_p)
3987 cpp_warning(pfile, "`#pragma once' is obsolete");
3988 do_once(pfile);
3989 }
3990 if (!strncmp((const char *)buf, "implementation", 14))
3991 {
3992 /* Be quiet about `#pragma implementation' for a file only if it hasn't
3993 * been included yet. */
3994 file_name_list *ptr;
3995 char *p = (char *)buf + 14, *fname, *inc_fname;
3996 int fname_len;
3997
3998 SKIP_WHITE_SPACE(p);
3999 if (*p == '\n' || *p != '\"')
4000 return 0;
4001
4002 fname = p + 1;
4003 p = strchr(fname, '\"');
4004 fname_len = (p) ? (int)(p - fname) : (int)strlen(fname);
4005
4006 for (ptr = pfile->all_include_files; ptr; ptr = ptr->next)
4007 {
4008 inc_fname = strrchr(ptr->fname, '/');
4009 inc_fname = inc_fname ? inc_fname + 1 : (char *)ptr->fname;
4010 if (inc_fname && !strncmp(inc_fname, fname, fname_len))
4011 cpp_warning(pfile,
4012 "`#pragma implementation' for `%s' appears after file is included",
4013 fname);
4014 }
4015 }
4016 return 0;
4017}
4018
4019/* Just ignore #sccs, on systems where we define it at all. */
4020
4021/*
4022 * handle #if command by
4023 * 1) inserting special `defined' keyword into the hash table
4024 * that gets turned into 0 or 1 by special_symbol (thus,
4025 * if the luser has a symbol called `defined' already, it won't
4026 * work inside the #if command)
4027 * 2) rescan the input into a temporary output buffer
4028 * 3) pass the output buffer to the yacc parser and collect a value
4029 * 4) clean up the mess left from steps 1 and 2.
4030 * 5) call conditional_skip to skip til the next #endif (etc.),
4031 * or not, depending on the value from step 3.
4032 */
4033
4034static int
4035do_if(cpp_reader * pfile, struct directive *keyword __UNUSED__,
4036 unsigned char *buf, unsigned char *limit)
4037{
4038 HOST_WIDE_INT value = eval_if_expression(pfile, buf, limit - buf);
4039
4040 conditional_skip(pfile, value == 0, T_IF, NULL);
4041 return 0;
4042}
4043
4044/*
4045 * handle a #elif directive by not changing if_stack either.
4046 * see the comment above do_else.
4047 */
4048
4049static int
4050do_elif(cpp_reader * pfile, struct directive *keyword __UNUSED__,
4051 unsigned char *buf, unsigned char *limit)
4052{
4053 if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack)
4054 {
4055 cpp_error(pfile, "`#elif' not within a conditional");
4056 return 0;
4057 }
4058 else
4059 {
4060 if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF)
4061 {
4062 cpp_error(pfile, "`#elif' after `#else'");
4063 if (pfile->if_stack->fname
4064 && CPP_BUFFER(pfile)->fname
4065 && strcmp(pfile->if_stack->fname,
4066 CPP_BUFFER(pfile)->nominal_fname) != 0)
4067 fprintf(stderr, ", file %s", pfile->if_stack->fname);
4068 fprintf(stderr, ")\n");
4069 }
4070 pfile->if_stack->type = T_ELIF;
4071 }
4072
4073 if (pfile->if_stack->if_succeeded)
4074 skip_if_group(pfile, 0);
4075 else
4076 {
4077 HOST_WIDE_INT value = eval_if_expression(pfile, buf, limit - buf);
4078
4079 if (value == 0)
4080 skip_if_group(pfile, 0);
4081 else
4082 {
4083 ++pfile->if_stack->if_succeeded; /* continue processing input */
4084 output_line_command(pfile, 1, same_file);
4085 }
4086 }
4087 return 0;
4088}
4089
4090/*
4091 * evaluate a #if expression in BUF, of length LENGTH,
4092 * then parse the result as a C expression and return the value as an int.
4093 */
4094static HOST_WIDE_INT
4095eval_if_expression(cpp_reader * pfile, unsigned char *buf __UNUSED__,
4096 int length __UNUSED__)
4097{
4098 HASHNODE *save_defined;
4099 HOST_WIDE_INT value;
4100 long old_written = CPP_WRITTEN(pfile);
4101
4102 save_defined = install("defined", -1, T_SPEC_DEFINED, 0, 0, -1);
4103 pfile->pcp_inside_if = 1;
4104
4105 value = cpp_parse_expr(pfile);
4106 pfile->pcp_inside_if = 0;
4107 delete_macro(save_defined); /* clean up special symbol */
4108
4109 CPP_SET_WRITTEN(pfile, old_written); /* Pop */
4110
4111 return value;
4112}
4113
4114/*
4115 * routine to handle ifdef/ifndef. Try to look up the symbol,
4116 * then do or don't skip to the #endif/#else/#elif depending
4117 * on what directive is actually being processed.
4118 */
4119
4120static int
4121do_xifdef(cpp_reader * pfile, struct directive *keyword,
4122 unsigned char *unused1 __UNUSED__, unsigned char *unused2 __UNUSED__)
4123{
4124 int skip;
4125 cpp_buffer *ip = CPP_BUFFER(pfile);
4126 char *ident;
4127 int ident_length;
4128 enum cpp_token token;
4129 int start_of_file = 0;
4130 unsigned char *control_macro = 0;
4131 int old_written = CPP_WRITTEN(pfile);
4132 int c;
4133
4134 /* Detect a #ifndef at start of file (not counting comments). */
4135 if (ip->fname != 0 && keyword->type == T_IFNDEF)
4136 start_of_file = pfile->only_seen_white == 2;
4137
4138 pfile->no_macro_expand++;
4139 token = get_directive_token(pfile);
4140 pfile->no_macro_expand--;
4141
4142 ident = (char *)pfile->token_buffer + old_written;
4143 ident_length = CPP_WRITTEN(pfile) - old_written;
4144 CPP_SET_WRITTEN(pfile, old_written); /* Pop */
4145
4146 if (token == CPP_VSPACE || token == CPP_POP || token == CPP_EOF)
4147 {
4148 skip = (keyword->type == T_IFDEF);
4149 cpp_pedwarn(pfile, "`#%s' with no argument", keyword->name);
4150 }
4151 else if (token == CPP_NAME)
4152 {
4153 HASHNODE *hp = cpp_lookup(ident, ident_length, -1);
4154
4155 skip = (!hp) ^ (keyword->type == T_IFNDEF);
4156 if (start_of_file && !skip)
4157 {
4158 control_macro = (unsigned char *)xmalloc(ident_length + 1);
4159 memcpy(control_macro, ident, ident_length + 1);
4160 }
4161 }
4162 else
4163 {
4164 skip = (keyword->type == T_IFDEF);
4165 cpp_error(pfile, "`#%s' with invalid argument", keyword->name);
4166 }
4167
4168 cpp_skip_hspace(pfile);
4169 c = PEEKC();
4170 if (c != EOF && c != '\n')
4171 cpp_pedwarn(pfile, "garbage at end of `#%s' argument",
4172 keyword->name);
4173 skip_rest_of_line(pfile);
4174
4175 conditional_skip(pfile, skip, T_IF, control_macro);
4176 return 0;
4177}
4178
4179/* Push TYPE on stack; then, if SKIP is nonzero, skip ahead.
4180 * If this is a #ifndef starting at the beginning of a file,
4181 * CONTROL_MACRO is the macro name tested by the #ifndef.
4182 * Otherwise, CONTROL_MACRO is 0. */
4183
4184static void
4185conditional_skip(cpp_reader * pfile, int skip, enum node_type type,
4186 unsigned char *control_macro)
4187{
4188 IF_STACK_FRAME *temp;
4189
4190 temp = (IF_STACK_FRAME *) xcalloc(1, sizeof(IF_STACK_FRAME));
4191 temp->fname = CPP_BUFFER(pfile)->nominal_fname;
4192 temp->next = pfile->if_stack;
4193 temp->control_macro = control_macro;
4194 pfile->if_stack = temp;
4195
4196 pfile->if_stack->type = type;
4197
4198 if (skip != 0)
4199 {
4200 skip_if_group(pfile, 0);
4201 return;
4202 }
4203 else
4204 {
4205 ++pfile->if_stack->if_succeeded;
4206 output_line_command(pfile, 1, same_file);
4207 }
4208}
4209
4210/*
4211 * skip to #endif, #else, or #elif. adjust line numbers, etc.
4212 * leaves input ptr at the sharp sign found.
4213 * If ANY is nonzero, return at next directive of any sort.
4214 */
4215
4216static void
4217skip_if_group(cpp_reader * pfile, int any)
4218{
4219 int c;
4220 struct directive *kt;
4221 IF_STACK_FRAME *save_if_stack = pfile->if_stack; /* don't pop past here */
4222
4223 int ident_length;
4224 char *ident;
4225 struct parse_marker line_start_mark;
4226
4227 parse_set_mark(&line_start_mark, pfile);
4228
4229 if (CPP_OPTIONS(pfile)->output_conditionals)
4230 {
4231 static char failed[] = "#failed\n";
4232
4233 CPP_PUTS(pfile, failed, sizeof(failed) - 1);
4234 pfile->lineno++;
4235 output_line_command(pfile, 1, same_file);
4236 }
4237 beg_of_line:
4238 if (CPP_OPTIONS(pfile)->output_conditionals)
4239 {
4240 cpp_buffer *pbuf = CPP_BUFFER(pfile);
4241 unsigned char *start_line = pbuf->buf + line_start_mark.position;
4242
4243 CPP_PUTS(pfile, start_line, pbuf->cur - start_line);
4244 }
4245 parse_move_mark(&line_start_mark, pfile);
4246 cpp_skip_hspace(pfile);
4247 c = GETC();
4248 if (c == '#')
4249 {
4250 int old_written = CPP_WRITTEN(pfile);
4251
4252 cpp_skip_hspace(pfile);
4253
4254 parse_name(pfile, GETC());
4255 ident_length = CPP_WRITTEN(pfile) - old_written;
4256 ident = (char *)pfile->token_buffer + old_written;
4257 pfile->limit = (unsigned char *)ident;
4258
4259 for (kt = directive_table; kt->length >= 0; kt++)
4260 {
4261 IF_STACK_FRAME *temp;
4262
4263 if (ident_length == kt->length
4264 && strncmp(ident, kt->name, kt->length) == 0)
4265 {
4266 /* If we are asked to return on next directive, do so now. */
4267 if (any)
4268 goto done;
4269
4270 switch (kt->type)
4271 {
4272 case T_IF:
4273 case T_IFDEF:
4274 case T_IFNDEF:
4275 temp
4276 =
4277 (IF_STACK_FRAME *) xcalloc(1, sizeof(IF_STACK_FRAME));
4278 temp->next = pfile->if_stack;
4279 pfile->if_stack = temp;
4280 temp->fname = CPP_BUFFER(pfile)->nominal_fname;
4281 temp->type = kt->type;
4282 break;
4283 case T_ELSE:
4284 case T_ENDIF:
4285 if (CPP_PEDANTIC(pfile)
4286 && pfile->if_stack != save_if_stack)
4287 validate_else(pfile,
4288 kt->type ==
4289 T_ELSE ? "#else" : "#endif");
4290 case T_ELIF:
4291 if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack)
4292 {
4293 cpp_error(pfile,
4294 "`#%s' not within a conditional",
4295 kt->name);
4296 break;
4297 }
4298 else if (pfile->if_stack == save_if_stack)
4299 goto done; /* found what we came for */
4300
4301 if (kt->type != T_ENDIF)
4302 {
4303 if (pfile->if_stack->type == T_ELSE)
4304 cpp_error(pfile,
4305 "`#else' or `#elif' after `#else'");
4306 pfile->if_stack->type = kt->type;
4307 break;
4308 }
4309 temp = pfile->if_stack;
4310 pfile->if_stack = temp->next;
4311 free(temp);
4312 break;
4313 default:;
4314 }
4315 break;
4316 }
4317 /* Don't let erroneous code go by. */
4318 if (kt->length < 0 && !CPP_OPTIONS(pfile)->lang_asm
4319 && CPP_PEDANTIC(pfile))
4320 cpp_pedwarn(pfile, "invalid preprocessor directive name");
4321 }
4322 c = GETC();
4323 }
4324 /* We're in the middle of a line. Skip the rest of it. */
4325 for (;;)
4326 {
4327 switch (c)
4328 {
4329 long old;
4330
4331 case EOF:
4332 goto done;
4333 case '/': /* possible comment */
4334 c = skip_comment(pfile, NULL);
4335 if (c == EOF)
4336 goto done;
4337 break;
4338 case '\"':
4339 case '\'':
4340 FORWARD(-1);
4341 old = CPP_WRITTEN(pfile);
4342 cpp_get_token(pfile);
4343 CPP_SET_WRITTEN(pfile, old);
4344 break;
4345 case '\\':
4346 /* Char after backslash loses its special meaning. */
4347 if (PEEKC() == '\n')
4348 FORWARD(1);
4349 break;
4350 case '\n':
4351 goto beg_of_line;
4352 break;
4353 }
4354 c = GETC();
4355 }
4356 done:
4357 if (CPP_OPTIONS(pfile)->output_conditionals)
4358 {
4359 static char end_failed[] = "#endfailed\n";
4360
4361 CPP_PUTS(pfile, end_failed, sizeof(end_failed) - 1);
4362 pfile->lineno++;
4363 }
4364 pfile->only_seen_white = 1;
4365 parse_goto_mark(&line_start_mark, pfile);
4366 parse_clear_mark(&line_start_mark);
4367}
4368
4369/*
4370 * handle a #else directive. Do this by just continuing processing
4371 * without changing if_stack ; this is so that the error message
4372 * for missing #endif's etc. will point to the original #if. It
4373 * is possible that something different would be better.
4374 */
4375
4376static int
4377do_else(cpp_reader * pfile, struct directive *keyword __UNUSED__,
4378 unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__)
4379{
4380 cpp_buffer *ip = CPP_BUFFER(pfile);
4381
4382 if (CPP_PEDANTIC(pfile))
4383 validate_else(pfile, "#else");
4384 skip_rest_of_line(pfile);
4385
4386 if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack)
4387 {
4388 cpp_error(pfile, "`#else' not within a conditional");
4389 return 0;
4390 }
4391 else
4392 {
4393 /* #ifndef can't have its special treatment for containing the whole file
4394 * if it has a #else clause. */
4395 pfile->if_stack->control_macro = 0;
4396
4397 if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF)
4398 {
4399 cpp_error(pfile, "`#else' after `#else'");
4400 fprintf(stderr, " (matches line %d", pfile->if_stack->lineno);
4401 if (strcmp(pfile->if_stack->fname, ip->nominal_fname) != 0)
4402 fprintf(stderr, ", file %s", pfile->if_stack->fname);
4403 fprintf(stderr, ")\n");
4404 }
4405 pfile->if_stack->type = T_ELSE;
4406 }
4407
4408 if (pfile->if_stack->if_succeeded)
4409 skip_if_group(pfile, 0);
4410 else
4411 {
4412 ++pfile->if_stack->if_succeeded; /* continue processing input */
4413 output_line_command(pfile, 1, same_file);
4414 }
4415 return 0;
4416}
4417
4418/*
4419 * unstack after #endif command
4420 */
4421
4422static int
4423do_endif(cpp_reader * pfile, struct directive *keyword __UNUSED__,
4424 unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__)
4425{
4426 if (CPP_PEDANTIC(pfile))
4427 validate_else(pfile, "#endif");
4428 skip_rest_of_line(pfile);
4429
4430 if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack)
4431 {
4432 cpp_error(pfile, "unbalanced `#endif'");
4433 }
4434 else
4435 {
4436 IF_STACK_FRAME *temp = pfile->if_stack;
4437
4438 pfile->if_stack = temp->next;
4439 if (temp->control_macro)
4440 {
4441 /* This #endif matched a #ifndef at the start of the file.
4442 * See if it is at the end of the file. */
4443 struct parse_marker start_mark;
4444 int c;
4445
4446 parse_set_mark(&start_mark, pfile);
4447
4448 for (;;)
4449 {
4450 cpp_skip_hspace(pfile);
4451 c = GETC();
4452 if (c != '\n')
4453 break;
4454 }
4455 parse_goto_mark(&start_mark, pfile);
4456 parse_clear_mark(&start_mark);
4457
4458 if (c == EOF)
4459 {
4460 /* If we get here, this #endif ends a #ifndef
4461 * that contains all of the file (aside from whitespace).
4462 * Arrange not to include the file again
4463 * if the macro that was tested is defined.
4464 *
4465 * Do not do this for the top-level file in a -include or any
4466 * file in a -imacros. */
4467 {
4468 file_name_list *ifile = pfile->all_include_files;
4469
4470 for (; ifile; ifile = ifile->next)
4471 {
4472 if (!strcmp(ifile->fname, CPP_BUFFER(pfile)->fname))
4473 {
4474 ifile->control_macro = temp->control_macro;
4475 break;
4476 }
4477 }
4478 }
4479 }
4480 }
4481 free(temp);
4482 output_line_command(pfile, 1, same_file);
4483 }
4484 return 0;
4485}
4486
4487/* When an #else or #endif is found while skipping failed conditional,
4488 * if -pedantic was specified, this is called to warn about text after
4489 * the command name. P points to the first char after the command name. */
4490
4491static void
4492validate_else(cpp_reader * pfile, const char *directive)
4493{
4494 int c;
4495
4496 cpp_skip_hspace(pfile);
4497 c = PEEKC();
4498 if (c != EOF && c != '\n')
4499 cpp_pedwarn(pfile,
4500 "text following `%s' violates ANSI standard", directive);
4501}
4502
4503/* Get the next token, and add it to the text in pfile->token_buffer.
4504 * Return the kind of token we got. */
4505
4506enum cpp_token
4507cpp_get_token(cpp_reader * pfile)
4508{
4509 int c, c2, c3;
4510 long old_written = 0;
4511 long start_line = 0, start_column = 0;
4512 enum cpp_token token;
4513 struct cpp_options *opts = CPP_OPTIONS(pfile);
4514
4515 CPP_BUFFER(pfile)->prev = CPP_BUFFER(pfile)->cur;
4516 get_next:
4517 c = GETC();
4518 if (c == EOF)
4519 {
4520 handle_eof:
4521 if (CPP_BUFFER(pfile)->seen_eof)
4522 {
4523 if (cpp_pop_buffer(pfile) != CPP_NULL_BUFFER(pfile))
4524 goto get_next;
4525 else
4526 return CPP_EOF;
4527 }
4528 else
4529 {
4530 cpp_buffer *next_buf = CPP_PREV_BUFFER(CPP_BUFFER(pfile));
4531
4532 CPP_BUFFER(pfile)->seen_eof = 1;
4533 if (CPP_BUFFER(pfile)->nominal_fname && next_buf)
4534 {
4535 /* We're about to return from an #include file.
4536 * Emit #line information now (as part of the CPP_POP) result.
4537 * But the #line refers to the file we will pop to. */
4538 cpp_buffer *cur_buffer = CPP_BUFFER(pfile);
4539
4540 CPP_BUFFER(pfile) = next_buf;
4541 pfile->input_stack_listing_current = 0;
4542 output_line_command(pfile, 0, leave_file);
4543 CPP_BUFFER(pfile) = cur_buffer;
4544 }
4545 return CPP_POP;
4546 }
4547 }
4548 else
4549 {
4550 switch (c)
4551 {
4552 long newlines;
4553 struct parse_marker start_mark;
4554
4555 case '/':
4556 if (PEEKC() == '=')
4557 goto op2;
4558 if (opts->put_out_comments)
4559 parse_set_mark(&start_mark, pfile);
4560 newlines = 0;
4561 cpp_buf_line_and_col(cpp_file_buffer(pfile),
4562 &start_line, &start_column);
4563 c = skip_comment(pfile, &newlines);
4564 if (opts->put_out_comments && (c == '/' || c == EOF))
4565 parse_clear_mark(&start_mark);
4566 if (c == '/')
4567 goto randomchar;
4568 if (c == EOF)
4569 {
4570 cpp_error_with_line(pfile, start_line, start_column,
4571 "unterminated comment");
4572 goto handle_eof;
4573 }
4574 c = '/'; /* Initial letter of comment. */
4575 return_comment:
4576 /* Comments are equivalent to spaces.
4577 * For -traditional, a comment is equivalent to nothing. */
4578 if (opts->put_out_comments)
4579 {
4580 cpp_buffer *pbuf = CPP_BUFFER(pfile);
4581 unsigned char *start = pbuf->buf + start_mark.position;
4582 int len = pbuf->cur - start;
4583
4584 CPP_RESERVE(pfile, 1 + len);
4585 CPP_PUTC_Q(pfile, c);
4586 CPP_PUTS_Q(pfile, start, len);
4587 pfile->lineno += newlines;
4588 parse_clear_mark(&start_mark);
4589 return CPP_COMMENT;
4590 }
4591 else if (newlines > 0)
4592 {
4593 output_line_command(pfile, 0, same_file);
4594 CPP_RESERVE(pfile, 1);
4595 CPP_PUTC_Q(pfile, ' ');
4596 return CPP_VSPACE;
4597 }
4598 else
4599 {
4600 CPP_RESERVE(pfile, 1);
4601 CPP_PUTC_Q(pfile, ' ');
4602 return CPP_HSPACE;
4603 }
4604
4605 case '#':
4606 if (!pfile->only_seen_white)
4607 goto randomchar;
4608 if (handle_directive(pfile))
4609 return CPP_DIRECTIVE;
4610 pfile->only_seen_white = 0;
4611 return CPP_OTHER;
4612
4613 case '\"':
4614 case '\'':
4615 /* A single quoted string is treated like a double -- some
4616 * programs (e.g., troff) are perverse this way */
4617 cpp_buf_line_and_col(cpp_file_buffer(pfile),
4618 &start_line, &start_column);
4619 old_written = CPP_WRITTEN(pfile);
4620 string:
4621 CPP_PUTC(pfile, c);
4622 while (1)
4623 {
4624 int cc = GETC();
4625
4626 if (cc == EOF)
4627 {
4628 if (CPP_IS_MACRO_BUFFER(CPP_BUFFER(pfile)))
4629 {
4630 /* try harder: this string crosses a macro expansion
4631 * boundary. This can happen naturally if -traditional.
4632 * Otherwise, only -D can make a macro with an unmatched
4633 * quote. */
4634 cpp_buffer *next_buf
4635 = CPP_PREV_BUFFER(CPP_BUFFER(pfile));
4636
4637 (*CPP_BUFFER(pfile)->cleanup)
4638 (CPP_BUFFER(pfile), pfile);
4639 CPP_BUFFER(pfile) = next_buf;
4640 continue;
4641 }
4642 cpp_error_with_line(pfile, start_line, start_column,
4643 "unterminated string or character constant");
4644 if (pfile->multiline_string_line != start_line
4645 && pfile->multiline_string_line != 0)
4646 cpp_error_with_line(pfile,
4647 pfile->multiline_string_line,
4648 -1,
4649 "possible real start of unterminated constant");
4650 pfile->multiline_string_line = 0;
4651 break;
4652 }
4653 CPP_PUTC(pfile, cc);
4654 switch (cc)
4655 {
4656 case '\n':
4657 /* Traditionally, end of line ends a string constant with
4658 * no error. So exit the loop and record the new line. */
4659 if (c == '\'')
4660 {
4661 cpp_error_with_line(pfile, start_line, start_column,
4662 "unterminated character constant");
4663 goto while2end;
4664 }
4665 if (CPP_PEDANTIC(pfile)
4666 && pfile->multiline_string_line == 0)
4667 {
4668 cpp_pedwarn_with_line(pfile, start_line,
4669 start_column,
4670 "string constant runs past end of line");
4671 }
4672 if (pfile->multiline_string_line == 0)
4673 pfile->multiline_string_line = start_line;
4674 break;
4675
4676 case '\\':
4677 cc = GETC();
4678 if (cc == '\n')
4679 {
4680 /* Backslash newline is replaced by nothing at all. */
4681 CPP_ADJUST_WRITTEN(pfile, -1);
4682 pfile->lineno++;
4683 }
4684 else
4685 {
4686 /* ANSI stupidly requires that in \\ the second \
4687 * is *not* prevented from combining with a newline. */
4688 NEWLINE_FIX1(cc);
4689 if (cc != EOF)
4690 CPP_PUTC(pfile, cc);
4691 }
4692 break;
4693
4694 case '\"':
4695 case '\'':
4696 if (cc == c)
4697 goto while2end;
4698 break;
4699 }
4700 }
4701 while2end:
4702 pfile->lineno += count_newlines(pfile->token_buffer + old_written,
4703 CPP_PWRITTEN(pfile));
4704 pfile->only_seen_white = 0;
4705 return c == '\'' ? CPP_CHAR : CPP_STRING;
4706
4707 case '$':
4708 if (!opts->dollars_in_ident)
4709 goto randomchar;
4710 goto letter;
4711
4712 case ':':
4713 if (opts->cplusplus && PEEKC() == ':')
4714 goto op2;
4715 goto randomchar;
4716
4717 case '&':
4718 case '+':
4719 case '|':
4720 NEWLINE_FIX;
4721 c2 = PEEKC();
4722 if (c2 == c || c2 == '=')
4723 goto op2;
4724 goto randomchar;
4725
4726 case '*':
4727 case '!':
4728 case '%':
4729 case '=':
4730 case '^':
4731 NEWLINE_FIX;
4732 if (PEEKC() == '=')
4733 goto op2;
4734 goto randomchar;
4735
4736 case '-':
4737 NEWLINE_FIX;
4738 c2 = PEEKC();
4739 if (c2 == '-' && opts->chill)
4740 {
4741 /* Chill style comment */
4742 if (opts->put_out_comments)
4743 parse_set_mark(&start_mark, pfile);
4744 FORWARD(1); /* Skip second '-'. */
4745 for (;;)
4746 {
4747 c = GETC();
4748 if (c == EOF)
4749 break;
4750 if (c == '\n')
4751 {
4752 /* Don't consider final '\n' to be part of comment. */
4753 FORWARD(-1);
4754 break;
4755 }
4756 }
4757 c = '-';
4758 goto return_comment;
4759 }
4760 if (c2 == '-' || c2 == '=' || c2 == '>')
4761 goto op2;
4762 goto randomchar;
4763
4764 case '<':
4765 if (pfile->parsing_include_directive)
4766 {
4767 for (;;)
4768 {
4769 CPP_PUTC(pfile, c);
4770 if (c == '>')
4771 break;
4772 c = GETC();
4773 NEWLINE_FIX1(c);
4774 if (c == '\n' || c == EOF)
4775 {
4776 cpp_error(pfile,
4777 "missing '>' in `#include <FILENAME>'");
4778 break;
4779 }
4780 }
4781 return CPP_STRING;
4782 }
4783 /* else fall through */
4784 case '>':
4785 NEWLINE_FIX;
4786 c2 = PEEKC();
4787 if (c2 == '=')
4788 goto op2;
4789 if (c2 != c)
4790 goto randomchar;
4791 FORWARD(1);
4792 CPP_RESERVE(pfile, 4);
4793 CPP_PUTC(pfile, c);
4794 CPP_PUTC(pfile, c2);
4795 NEWLINE_FIX;
4796 c3 = PEEKC();
4797 if (c3 == '=')
4798 CPP_PUTC_Q(pfile, GETC());
4799 CPP_NUL_TERMINATE_Q(pfile);
4800 pfile->only_seen_white = 0;
4801 return CPP_OTHER;
4802
4803 case '@':
4804 if (CPP_BUFFER(pfile)->has_escapes)
4805 {
4806 c = GETC();
4807 // fix macro expansions starting with - losing the -
4808 if (c == '-')
4809 {
4810 CPP_PUTS(pfile, "-", 1);
4811 return CPP_OTHER;
4812 }
4813 // fix macro expansions starting with - losing the +
4814 else if (c == '+')
4815 {
4816 CPP_PUTS(pfile, "+", 1);
4817 return CPP_OTHER;
4818 }
4819 // fix macro expansions starting with - losing the .
4820 else if (c == '.')
4821 {
4822 CPP_PUTS(pfile, ".", 1);
4823 return CPP_OTHER;
4824 }
4825 else if (is_space[c])
4826 {
4827 CPP_RESERVE(pfile, 1);
4828 if (pfile->output_escapes)
4829 CPP_PUTC_Q(pfile, '@');
4830 return CPP_HSPACE;
4831 }
4832 }
4833 if (pfile->output_escapes)
4834 {
4835 CPP_PUTS(pfile, "@@", 2);
4836 return CPP_OTHER;
4837 }
4838 goto randomchar;
4839
4840 case '.':
4841 NEWLINE_FIX;
4842 c2 = PEEKC();
4843 if (isdigit(c2))
4844 {
4845 CPP_RESERVE(pfile, 2);
4846 CPP_PUTC_Q(pfile, '.');
4847 c = GETC();
4848 goto number;
4849 }
4850 /* FIXME - misses the case "..\\\n." */
4851 if (c2 == '.' && PEEKN(1) == '.')
4852 {
4853 CPP_RESERVE(pfile, 4);
4854 CPP_PUTC_Q(pfile, '.');
4855 CPP_PUTC_Q(pfile, '.');
4856 CPP_PUTC_Q(pfile, '.');
4857 FORWARD(2);
4858 CPP_NUL_TERMINATE_Q(pfile);
4859 pfile->only_seen_white = 0;
4860 return CPP_3DOTS;
4861 }
4862 goto randomchar;
4863
4864 op2:
4865 token = CPP_OTHER;
4866 pfile->only_seen_white = 0;
4867 op2any:
4868 CPP_RESERVE(pfile, 3);
4869 CPP_PUTC_Q(pfile, c);
4870 CPP_PUTC_Q(pfile, GETC());
4871 CPP_NUL_TERMINATE_Q(pfile);
4872 return token;
4873
4874 case 'L':
4875 NEWLINE_FIX;
4876 c2 = PEEKC();
4877 if ((c2 == '\'' || c2 == '\"'))
4878 {
4879 CPP_PUTC(pfile, c);
4880 c = GETC();
4881 goto string;
4882 }
4883 goto letter;
4884
4885 case '0':
4886 case '1':
4887 case '2':
4888 case '3':
4889 case '4':
4890 case '5':
4891 case '6':
4892 case '7':
4893 case '8':
4894 case '9':
4895 number:
4896 c2 = '.';
4897 for (;;)
4898 {
4899 CPP_RESERVE(pfile, 2);
4900 CPP_PUTC_Q(pfile, c);
4901 NEWLINE_FIX;
4902 c = PEEKC();
4903 if (c == EOF)
4904 break;
4905 if (!is_idchar[c] && c != '.'
4906 && ((c2 != 'e' && c2 != 'E') || (c != '+' && c != '-')))
4907 break;
4908 FORWARD(1);
4909 c2 = c;
4910 }
4911 CPP_NUL_TERMINATE_Q(pfile);
4912 pfile->only_seen_white = 0;
4913 return CPP_NUMBER;
4914 case 'b':
4915 case 'c':
4916 case 'd':
4917 case 'h':
4918 case 'o':
4919 case 'B':
4920 case 'C':
4921 case 'D':
4922 case 'H':
4923 case 'O':
4924 if (opts->chill && PEEKC() == '\'')
4925 {
4926 pfile->only_seen_white = 0;
4927 CPP_RESERVE(pfile, 2);
4928 CPP_PUTC_Q(pfile, c);
4929 CPP_PUTC_Q(pfile, '\'');
4930 FORWARD(1);
4931 for (;;)
4932 {
4933 c = GETC();
4934 if (c == EOF)
4935 goto chill_number_eof;
4936 if (!is_idchar[c])
4937 {
4938 if (c == '\\' && PEEKC() == '\n')
4939 {
4940 FORWARD(2);
4941 continue;
4942 }
4943 break;
4944 }
4945 CPP_PUTC(pfile, c);
4946 }
4947 if (c == '\'')
4948 {
4949 CPP_RESERVE(pfile, 2);
4950 CPP_PUTC_Q(pfile, c);
4951 CPP_NUL_TERMINATE_Q(pfile);
4952 return CPP_STRING;
4953 }
4954 else
4955 {
4956 FORWARD(-1);
4957 chill_number_eof:
4958 CPP_NUL_TERMINATE(pfile);
4959 return CPP_NUMBER;
4960 }
4961 }
4962 else
4963 goto letter;
4964 case '_':
4965 case 'a':
4966 case 'e':
4967 case 'f':
4968 case 'g':
4969 case 'i':
4970 case 'j':
4971 case 'k':
4972 case 'l':
4973 case 'm':
4974 case 'n':
4975 case 'p':
4976 case 'q':
4977 case 'r':
4978 case 's':
4979 case 't':
4980 case 'u':
4981 case 'v':
4982 case 'w':
4983 case 'x':
4984 case 'y':
4985 case 'z':
4986 case 'A':
4987 case 'E':
4988 case 'F':
4989 case 'G':
4990 case 'I':
4991 case 'J':
4992 case 'K':
4993 case 'M':
4994 case 'N':
4995 case 'P':
4996 case 'Q':
4997 case 'R':
4998 case 'S':
4999 case 'T':
5000 case 'U':
5001 case 'V':
5002 case 'W':
5003 case 'X':
5004 case 'Y':
5005 case 'Z':
5006 letter:
5007 {
5008 HASHNODE *hp;
5009 char *ident;
5010 int before_name_written = CPP_WRITTEN(pfile);
5011 int ident_len;
5012
5013 parse_name(pfile, c);
5014 pfile->only_seen_white = 0;
5015 if (pfile->no_macro_expand)
5016 return CPP_NAME;
5017 ident = (char *)pfile->token_buffer + before_name_written;
5018 ident_len = CPP_PWRITTEN(pfile) - (unsigned char *)ident;
5019 hp = cpp_lookup(ident, ident_len, -1);
5020 if (!hp)
5021 return CPP_NAME;
5022 if (hp->type == T_DISABLED)
5023 {
5024 if (pfile->output_escapes)
5025 { /* Return "@-IDENT", followed by '\0'. */
5026 int i;
5027
5028 CPP_RESERVE(pfile, 3);
5029 ident =
5030 (char *)pfile->token_buffer + before_name_written;
5031 CPP_ADJUST_WRITTEN(pfile, 2);
5032 for (i = ident_len; i >= 0; i--)
5033 ident[i + 2] = ident[i];
5034 ident[0] = '@';
5035 ident[1] = '-';
5036 }
5037 return CPP_NAME;
5038 }
5039 /* If macro wants an arglist, verify that a '(' follows.
5040 * first skip all whitespace, copying it to the output
5041 * after the macro name. Then, if there is no '(',
5042 * decide this is not a macro call and leave things that way. */
5043 if (hp->type == T_MACRO && hp->value.defn->nargs >= 0)
5044 {
5045 struct parse_marker macro_mark;
5046 int is_macro_call;
5047
5048 while (CPP_IS_MACRO_BUFFER(CPP_BUFFER(pfile)))
5049 {
5050 cpp_buffer *next_buf;
5051
5052 cpp_skip_hspace(pfile);
5053 if (PEEKC() != EOF)
5054 break;
5055 next_buf = CPP_PREV_BUFFER(CPP_BUFFER(pfile));
5056 (*CPP_BUFFER(pfile)->cleanup) (CPP_BUFFER(pfile),
5057 pfile);
5058 CPP_BUFFER(pfile) = next_buf;
5059 }
5060 parse_set_mark(&macro_mark, pfile);
5061 for (;;)
5062 {
5063 cpp_skip_hspace(pfile);
5064 c = PEEKC();
5065 is_macro_call = c == '(';
5066 if (c != '\n')
5067 break;
5068 FORWARD(1);
5069 }
5070 if (!is_macro_call)
5071 parse_goto_mark(&macro_mark, pfile);
5072 parse_clear_mark(&macro_mark);
5073 if (!is_macro_call)
5074 return CPP_NAME;
5075 }
5076 /* This is now known to be a macro call. */
5077
5078 /* it might not actually be a macro. */
5079 if (hp->type != T_MACRO)
5080 {
5081 int xbuf_len;
5082 unsigned char *xbuf;
5083
5084 CPP_SET_WRITTEN(pfile, before_name_written);
5085 special_symbol(hp, pfile);
5086 xbuf_len = CPP_WRITTEN(pfile) - before_name_written;
5087 xbuf = (unsigned char *)xmalloc(xbuf_len + 1);
5088 CPP_SET_WRITTEN(pfile, before_name_written);
5089 memcpy(xbuf, CPP_PWRITTEN(pfile), xbuf_len + 1);
5090 push_macro_expansion(pfile, xbuf, xbuf_len, hp);
5091 }
5092 else
5093 {
5094 /* Expand the macro, reading arguments as needed,
5095 * and push the expansion on the input stack. */
5096 macroexpand(pfile, hp);
5097 CPP_SET_WRITTEN(pfile, before_name_written);
5098 }
5099
5100 /* An extra "@ " is added to the end of a macro expansion
5101 * to prevent accidental token pasting. We prefer to avoid
5102 * unneeded extra spaces (for the sake of cpp-using tools like
5103 * imake). Here we remove the space if it is safe to do so. */
5104 if (pfile->buffer->rlimit - pfile->buffer->cur >= 3
5105 && pfile->buffer->rlimit[-2] == '@'
5106 && pfile->buffer->rlimit[-1] == ' ')
5107 {
5108 int c1 = pfile->buffer->rlimit[-3];
5109
5110 c2 = CPP_BUF_PEEK(CPP_PREV_BUFFER(CPP_BUFFER(pfile)));
5111
5112 if (c2 == EOF || !unsafe_chars(c1, c2))
5113 pfile->buffer->rlimit -= 2;
5114 }
5115 }
5116 goto get_next;
5117
5118 case ' ':
5119 case '\t':
5120 case '\v':
5121 case '\r':
5122 for (;;)
5123 {
5124 CPP_PUTC(pfile, c);
5125 c = PEEKC();
5126 if (c == EOF || !is_hor_space[c])
5127 break;
5128 FORWARD(1);
5129 }
5130 return CPP_HSPACE;
5131
5132 case '\\':
5133 c2 = PEEKC();
5134 if (c2 != '\n')
5135 goto randomchar;
5136 token = CPP_HSPACE;
5137 goto op2any;
5138
5139 case '\n':
5140 CPP_PUTC(pfile, c);
5141 if (pfile->only_seen_white == 0)
5142 pfile->only_seen_white = 1;
5143 pfile->lineno++;
5144 output_line_command(pfile, 1, same_file);
5145 return CPP_VSPACE;
5146
5147 case '(':
5148 token = CPP_LPAREN;
5149 goto char1;
5150 case ')':
5151 token = CPP_RPAREN;
5152 goto char1;
5153 case '{':
5154 token = CPP_LBRACE;
5155 goto char1;
5156 case '}':
5157 token = CPP_RBRACE;
5158 goto char1;
5159 case ',':
5160 token = CPP_COMMA;
5161 goto char1;
5162 case ';':
5163 token = CPP_SEMICOLON;
5164 goto char1;
5165
5166 randomchar:
5167 default:
5168 token = CPP_OTHER;
5169 char1:
5170 pfile->only_seen_white = 0;
5171 CPP_PUTC(pfile, c);
5172 return token;
5173 }
5174 }
5175}
5176
5177#if 0 /* Unused */
5178/* Like cpp_get_token, but skip spaces and comments. */
5179enum cpp_token
5180cpp_get_non_space_token(cpp_reader * pfile)
5181{
5182 int old_written = CPP_WRITTEN(pfile);
5183
5184 for (;;)
5185 {
5186 enum cpp_token token = cpp_get_token(pfile);
5187
5188 if (token != CPP_COMMENT && token != CPP_POP
5189 && token != CPP_HSPACE && token != CPP_VSPACE)
5190 return token;
5191 CPP_SET_WRITTEN(pfile, old_written);
5192 }
5193}
5194#endif
5195
5196/* Parse an identifier starting with C. */
5197
5198int
5199parse_name(cpp_reader * pfile, int c)
5200{
5201 for (;;)
5202 {
5203 if (!is_idchar[c])
5204 {
5205 if (c == '\\' && PEEKC() == '\n')
5206 {
5207 FORWARD(2);
5208 continue;
5209 }
5210 FORWARD(-1);
5211 break;
5212 }
5213 CPP_RESERVE(pfile, 2); /* One more for final NUL. */
5214 CPP_PUTC_Q(pfile, c);
5215 c = GETC();
5216 if (c == EOF)
5217 break;
5218 }
5219 CPP_NUL_TERMINATE_Q(pfile);
5220 return 1;
5221}
5222
5223/* Maintain and search list of included files, for #import. */
5224
5225/* Hash a file name for import_hash_table. */
5226
5227static int
5228import_hash(char *f)
5229{
5230 int val = 0;
5231
5232 while (*f)
5233 val += *f++;
5234 return (val % IMPORT_HASH_SIZE);
5235}
5236
5237/* Search for file FILENAME in import_hash_table.
5238 * Return -2 if found, either a matching name or a matching inode.
5239 * Otherwise, open the file and return a file descriptor if successful
5240 * or -1 if unsuccessful. */
5241
5242static int
5243lookup_import(cpp_reader * pfile, char *filename, file_name_list * searchptr)
5244{
5245 struct import_file *i;
5246 int h;
5247 int hashval;
5248 struct stat sb;
5249 int fd;
5250
5251 hashval = import_hash(filename);
5252
5253 /* Attempt to find file in list of already included files */
5254 i = pfile->import_hash_table[hashval];
5255
5256 while (i)
5257 {
5258 if (!strcmp(filename, i->name))
5259 return -2; /* return found */
5260 i = i->next;
5261 }
5262 /* Open it and try a match on inode/dev */
5263 fd = open_include_file(pfile, filename, searchptr);
5264 if (fd < 0)
5265 return fd;
5266 fstat(fd, &sb);
5267 for (h = 0; h < IMPORT_HASH_SIZE; h++)
5268 {
5269 i = pfile->import_hash_table[h];
5270 while (i)
5271 {
5272 /* Compare the inode and the device.
5273 * Supposedly on some systems the inode is not a scalar. */
5274 if (!memcmp
5275 ((char *)&i->inode, (char *)&sb.st_ino, sizeof(sb.st_ino))
5276 && i->dev == sb.st_dev)
5277 {
5278 close(fd);
5279 return -2; /* return found */
5280 }
5281 i = i->next;
5282 }
5283 }
5284 return fd; /* Not found, return open file */
5285}
5286
5287/* Add the file FNAME, open on descriptor FD, to import_hash_table. */
5288
5289static void
5290add_import(cpp_reader * pfile, int fd, char *fname)
5291{
5292 struct import_file *i;
5293 int hashval;
5294 struct stat sb;
5295
5296 hashval = import_hash(fname);
5297 fstat(fd, &sb);
5298 i = (struct import_file *)xmalloc(sizeof(struct import_file));
5299
5300 i->name = (char *)xmalloc(strlen(fname) + 1);
5301 strcpy(i->name, fname);
5302 memcpy((char *)&i->inode, (char *)&sb.st_ino, sizeof(sb.st_ino));
5303 i->dev = sb.st_dev;
5304 i->next = pfile->import_hash_table[hashval];
5305 pfile->import_hash_table[hashval] = i;
5306}
5307
5308/* The file_name_map structure holds a mapping of file names for a
5309 * particular directory. This mapping is read from the file named
5310 * FILE_NAME_MAP_FILE in that directory. Such a file can be used to
5311 * map filenames on a file system with severe filename restrictions,
5312 * such as DOS. The format of the file name map file is just a series
5313 * of lines with two tokens on each line. The first token is the name
5314 * to map, and the second token is the actual name to use. */
5315
5316struct file_name_map {
5317 struct file_name_map *map_next;
5318 char *map_from;
5319 char *map_to;
5320};
5321
5322#if USE_FILE_NAME_MAPS
5323
5324#define FILE_NAME_MAP_FILE "header.gcc"
5325
5326/* Read a space delimited string of unlimited length from a stdio
5327 * file. */
5328
5329static char *
5330read_filename_string(int ch, FILE * f)
5331{
5332 char *alloc, *set;
5333 int len;
5334
5335 len = 20;
5336 set = alloc = (char *)xmalloc(len + 1);
5337 if (!is_space[ch])
5338 {
5339 *set++ = ch;
5340 while ((ch = getc(f)) != EOF && !is_space[ch])
5341 {
5342 if (set - alloc == len)
5343 {
5344 len *= 2;
5345 alloc = (char *)xrealloc(alloc, len + 1);
5346 set = alloc + len / 2;
5347 }
5348 *set++ = ch;
5349 }
5350 }
5351 *set = '\0';
5352 ungetc(ch, f);
5353 return alloc;
5354}
5355
5356/* This structure holds a linked list of file name maps, one per directory. */
5357struct file_name_map_list {
5358 struct file_name_map_list *map_list_next;
5359 char *map_list_name;
5360 struct file_name_map *map_list_map;
5361};
5362
5363/* Read the file name map file for DIRNAME. */
5364
5365static struct file_name_map *
5366read_name_map(cpp_reader * pfile, const char *dirname)
5367{
5368 struct file_name_map_list *map_list_ptr;
5369 char *name;
5370 FILE *f;
5371
5372 for (map_list_ptr = CPP_OPTIONS(pfile)->map_list; map_list_ptr;
5373 map_list_ptr = map_list_ptr->map_list_next)
5374 if (!strcmp(map_list_ptr->map_list_name, dirname))
5375 return map_list_ptr->map_list_map;
5376
5377 map_list_ptr =
5378 ((struct file_name_map_list *)xmalloc(sizeof(struct file_name_map_list)));
5379
5380 map_list_ptr->map_list_name = savestring(dirname);
5381 map_list_ptr->map_list_map = NULL;
5382
5383 name = (char *)alloca(strlen(dirname) + strlen(FILE_NAME_MAP_FILE) + 2);
5384 strcpy(name, dirname);
5385 if (*dirname)
5386 strcat(name, "/");
5387 strcat(name, FILE_NAME_MAP_FILE);
5388#ifndef __EMX__
5389 f = fopen(name, "rb");
5390#else
5391 f = fopen(name, "rtb");
5392#endif
5393 if (!f)
5394 map_list_ptr->map_list_map = NULL;
5395 else
5396 {
5397 int ch;
5398 int dirlen = strlen(dirname);
5399
5400 while ((ch = getc(f)) != EOF)
5401 {
5402 char *from, *to;
5403 struct file_name_map *ptr;
5404
5405 if (is_space[ch])
5406 continue;
5407 from = read_filename_string(ch, f);
5408 while ((ch = getc(f)) != EOF && is_hor_space[ch]);
5409 to = read_filename_string(ch, f);
5410
5411 ptr =
5412 ((struct file_name_map *)xmalloc(sizeof(struct file_name_map)));
5413
5414 ptr->map_from = from;
5415
5416 /* Make the real filename absolute. */
5417 if (*to == '/')
5418 ptr->map_to = to;
5419 else
5420 {
5421 ptr->map_to = (char *)xmalloc(dirlen + strlen(to) + 2);
5422 strcpy(ptr->map_to, dirname);
5423 ptr->map_to[dirlen] = '/';
5424 strcpy(ptr->map_to + dirlen + 1, to);
5425 free(to);
5426 }
5427
5428 ptr->map_next = map_list_ptr->map_list_map;
5429 map_list_ptr->map_list_map = ptr;
5430
5431 while ((ch = getc(f)) != '\n')
5432 if (ch == EOF)
5433 break;
5434 }
5435 fclose(f);
5436 }
5437
5438 map_list_ptr->map_list_next = CPP_OPTIONS(pfile)->map_list;
5439 CPP_OPTIONS(pfile)->map_list = map_list_ptr;
5440
5441 return map_list_ptr->map_list_map;
5442}
5443
5444/* Try to open include file FILENAME. SEARCHPTR is the directory
5445 * being tried from the include file search path. This function maps
5446 * filenames on file systems based on information read by
5447 * read_name_map. */
5448
5449static int
5450open_include_file(cpp_reader * pfile, char *filename,
5451 file_name_list * searchptr)
5452{
5453 struct file_name_map *map;
5454 const char *from;
5455 const char *p, *dir;
5456
5457 if (searchptr && !searchptr->got_name_map)
5458 {
5459 searchptr->name_map = read_name_map(pfile,
5460 searchptr->fname
5461 ? searchptr->fname : ".");
5462 searchptr->got_name_map = 1;
5463 }
5464 /* First check the mapping for the directory we are using. */
5465 if (searchptr && searchptr->name_map)
5466 {
5467 from = filename;
5468 if (searchptr->fname)
5469 from += strlen(searchptr->fname) + 1;
5470 for (map = searchptr->name_map; map; map = map->map_next)
5471 {
5472 if (!strcmp(map->map_from, from))
5473 {
5474 /* Found a match. */
5475 return open(map->map_to, O_RDONLY | O_BINARY, 0666);
5476 }
5477 }
5478 }
5479 /* Try to find a mapping file for the particular directory we are
5480 * looking in. Thus #include <sys/types.h> will look up sys/types.h
5481 * in /usr/include/header.gcc and look up types.h in
5482 * /usr/include/sys/header.gcc. */
5483 p = strrchr(filename, '/');
5484 if (!p)
5485 p = filename;
5486 if (searchptr
5487 && searchptr->fname
5488 && strlen(searchptr->fname) == (unsigned)(p - filename)
5489 && !strncmp(searchptr->fname, filename, p - filename))
5490 {
5491 /* FILENAME is in SEARCHPTR, which we've already checked. */
5492 return open(filename, O_RDONLY | O_BINARY, 0666);
5493 }
5494 if (p == filename)
5495 {
5496 dir = ".";
5497 from = filename;
5498 }
5499 else
5500 {
5501 char *s;
5502
5503 s = (char *)alloca(p - filename + 1);
5504 memcpy(s, filename, p - filename);
5505 s[p - filename] = '\0';
5506 from = p + 1;
5507 dir = s;
5508 }
5509 for (map = read_name_map(pfile, dir); map; map = map->map_next)
5510 if (!strcmp(map->map_from, from))
5511 return open(map->map_to, O_RDONLY | O_BINARY, 0666);
5512
5513 return open(filename, O_RDONLY | O_BINARY, 0666);
5514}
5515
5516#else
5517
5518static int
5519open_include_file(cpp_reader * pfile __UNUSED__, char *filename,
5520 file_name_list * searchptr __UNUSED__)
5521{
5522 return open(filename, O_RDONLY | O_BINARY, 0666);
5523}
5524
5525#endif /* USE_FILE_NAME_MAPS */
5526
5527static int
5528dos2unix(cpp_buffer *fp, int length)
5529{
5530 unsigned char *tbuf;
5531 int nlen = 0, i;
5532
5533 tbuf = xmalloc(length + 4);
5534 if (!tbuf) return length;
5535 for (i = 0; i < length; i++)
5536 {
5537 if ((fp->buf[i] == '\r') &&
5538 (fp->buf[i + 1] == '\n'))
5539 {
5540 // skip \r in \r\n
5541 continue;
5542 }
5543 tbuf[nlen] = fp->buf[i];
5544 nlen++;
5545 }
5546 tbuf[nlen] = 0;
5547
5548 free(fp->buf);
5549 fp->buf = tbuf;
5550 return nlen;
5551}
5552
5553/* Process the contents of include file FNAME, already open on descriptor F,
5554 * with output to OP.
5555 * SYSTEM_HEADER_P is 1 if this file resides in any one of the known
5556 * "system" include directories (as decided by the `is_system_include'
5557 * function above).
5558 * DIRPTR is the link in the dir path through which this file was found,
5559 * or 0 if the file name was absolute or via the current directory.
5560 * Return 1 on success, 0 on failure.
5561 *
5562 * The caller is responsible for the cpp_push_buffer. */
5563
5564static int
5565finclude(cpp_reader * pfile, int f, const char *fname, int system_header_p,
5566 file_name_list * dirptr)
5567{
5568 int st_mode;
5569 long st_size;
5570 long i;
5571 int length;
5572 cpp_buffer *fp; /* For input stack frame */
5573
5574 if (file_size_and_mode(f, &st_mode, &st_size) < 0)
5575 {
5576 cpp_perror_with_name(pfile, fname);
5577 close(f);
5578 cpp_pop_buffer(pfile);
5579 return 0;
5580 }
5581 fp = CPP_BUFFER(pfile);
5582 fp->nominal_fname = fp->fname = fname;
5583 fp->dir = dirptr;
5584 fp->system_header_p = system_header_p;
5585 fp->lineno = 1;
5586 fp->colno = 1;
5587 fp->cleanup = file_cleanup;
5588
5589 if (S_ISREG(st_mode))
5590 {
5591 fp->buf = (unsigned char *)xmalloc(st_size + 2);
5592 /* Read the file contents, knowing that st_size is an upper bound
5593 * on the number of bytes we can read. */
5594 length = safe_read(f, (char *)fp->buf, st_size);
5595 length = dos2unix(fp, length);
5596
5597 fp->alimit = fp->buf + st_size + 2;
5598 fp->cur = fp->buf;
5599 fp->rlimit = fp->buf + length;
5600 if (length < 0)
5601 goto nope;
5602 }
5603 else if (S_ISDIR(st_mode))
5604 {
5605 cpp_error(pfile, "directory `%s' specified in #include", fname);
5606 close(f);
5607 return 0;
5608 }
5609 else
5610 {
5611 /* Cannot count its file size before reading.
5612 * First read the entire file into heap and
5613 * copy them into buffer on stack. */
5614
5615 int bsize = 2000;
5616
5617 st_size = 0;
5618 fp->buf = (unsigned char *)xmalloc(bsize + 2);
5619
5620 for (;;)
5621 {
5622 i = safe_read(f, (char *)(fp->buf + st_size), bsize - st_size);
5623 if (i < 0)
5624 goto nope; /* error! */
5625 st_size += i;
5626 if (st_size != bsize)
5627 break; /* End of file */
5628 bsize *= 2;
5629 fp->buf = (unsigned char *)xrealloc(fp->buf, bsize + 2);
5630 }
5631 length = st_size;
5632 length = dos2unix(fp, length);
5633 }
5634
5635 if ((length > 0 && fp->buf[length - 1] != '\n')
5636 /* Backslash-newline at end is not good enough. */
5637 || (length > 1 && fp->buf[length - 2] == '\\'))
5638 {
5639 fp->buf[length++] = '\n';
5640 }
5641 fp->buf[length] = '\0';
5642
5643 fp->rlimit = fp->buf + length;
5644
5645 /* Close descriptor now, so nesting does not use lots of descriptors. */
5646 close(f);
5647
5648 /* Must do this before calling trigraph_pcp, so that the correct file name
5649 * will be printed in warning messages. */
5650
5651 pfile->input_stack_listing_current = 0;
5652
5653 return 1;
5654
5655 nope:
5656
5657 cpp_perror_with_name(pfile, fname);
5658 close(f);
5659 free(fp->buf);
5660 return 1;
5661}
5662
5663int
5664push_parse_file(cpp_reader * pfile, const char *fname)
5665{
5666 struct cpp_options *opts = CPP_OPTIONS(pfile);
5667 struct cpp_pending *pend;
5668 char *p;
5669 int f;
5670 cpp_buffer *fp;
5671
5672 /* The code looks at the defaults through this pointer, rather than through
5673 * the constant structure above. This pointer gets changed if an environment
5674 * variable specifies other defaults. */
5675 struct default_include *include_defaults = include_defaults_array;
5676
5677 /* Add dirs from CPATH after dirs from -I. */
5678 /* There seems to be confusion about what CPATH should do,
5679 * so for the moment it is not documented. */
5680 /* Some people say that CPATH should replace the standard include dirs,
5681 * but that seems pointless: it comes before them, so it overrides them
5682 * anyway. */
5683 p = (char *)getenv("CPATH");
5684 if (p && !opts->no_standard_includes)
5685 path_include(pfile, p);
5686
5687 /* Now that dollars_in_ident is known, initialize is_idchar. */
5688 initialize_char_syntax(opts);
5689
5690 /* Do partial setup of input buffer for the sake of generating
5691 * early #line directives (when -g is in effect). */
5692 fp = cpp_push_buffer(pfile, NULL, 0);
5693 if (!opts->in_fname)
5694 opts->in_fname = "";
5695 fp->nominal_fname = fp->fname = opts->in_fname;
5696 fp->lineno = 0;
5697
5698 /* Install __LINE__, etc. Must follow initialize_char_syntax
5699 * and option processing. */
5700 initialize_builtins(pfile);
5701
5702 /* Do standard #defines and assertions
5703 * that identify system and machine type. */
5704
5705 if (!opts->inhibit_predefs)
5706 {
5707 p = (char *)alloca(strlen(predefs) + 1);
5708
5709 strcpy(p, predefs);
5710 while (*p)
5711 {
5712 char *q;
5713
5714 while (*p == ' ' || *p == '\t')
5715 p++;
5716 /* Handle -D options. */
5717 if (p[0] == '-' && p[1] == 'D')
5718 {
5719 q = &p[2];
5720 while (*p && *p != ' ' && *p != '\t')
5721 p++;
5722 if (*p != 0)
5723 *p++ = 0;
5724 if (opts->debug_output)
5725 output_line_command(pfile, 0, same_file);
5726 cpp_define(pfile, (unsigned char *)q);
5727 while (*p == ' ' || *p == '\t')
5728 p++;
5729 }
5730 else if (p[0] == '-' && p[1] == 'A')
5731 {
5732 /* Handle -A options (assertions). */
5733 char *assertion;
5734 char *past_name;
5735 char *value;
5736 char *past_value;
5737 char *termination;
5738 int save_char;
5739
5740 assertion = &p[2];
5741 past_name = assertion;
5742 /* Locate end of name. */
5743 while (*past_name && *past_name != ' '
5744 && *past_name != '\t' && *past_name != '(')
5745 past_name++;
5746 /* Locate `(' at start of value. */
5747 value = past_name;
5748 while (*value && (*value == ' ' || *value == '\t'))
5749 value++;
5750 if (*value++ != '(')
5751 abort();
5752 while (*value && (*value == ' ' || *value == '\t'))
5753 value++;
5754 past_value = value;
5755 /* Locate end of value. */
5756 while (*past_value && *past_value != ' '
5757 && *past_value != '\t' && *past_value != ')')
5758 past_value++;
5759 termination = past_value;
5760 while (*termination
5761 && (*termination == ' ' || *termination == '\t'))
5762 termination++;
5763 if (*termination++ != ')')
5764 abort();
5765 if (*termination && *termination != ' '
5766 && *termination != '\t')
5767 abort();
5768 /* Temporarily null-terminate the value. */
5769 save_char = *termination;
5770 *termination = '\0';
5771 /* Install the assertion. */
5772 make_assertion(pfile, "-A", assertion);
5773 *termination = (char)save_char;
5774 p = termination;
5775 while (*p == ' ' || *p == '\t')
5776 p++;
5777 }
5778 else
5779 {
5780 abort();
5781 }
5782 }
5783 }
5784 /* Now handle the command line options. */
5785
5786 /* Do -U's, -D's and -A's in the order they were seen. */
5787 /* First reverse the list. */
5788 opts->pending = nreverse_pending(opts->pending);
5789
5790 for (pend = opts->pending; pend; pend = pend->next)
5791 {
5792 if (pend->cmd && pend->cmd[0] == '-')
5793 {
5794 switch (pend->cmd[1])
5795 {
5796 case 'U':
5797 if (opts->debug_output)
5798 output_line_command(pfile, 0, same_file);
5799 do_undef(pfile, NULL, (unsigned char *)pend->arg,
5800 (unsigned char *)pend->arg + strlen(pend->arg));
5801 break;
5802 case 'D':
5803 if (opts->debug_output)
5804 output_line_command(pfile, 0, same_file);
5805 cpp_define(pfile, (unsigned char *)pend->arg);
5806 break;
5807 case 'A':
5808 make_assertion(pfile, "-A", pend->arg);
5809 break;
5810 }
5811 }
5812 }
5813
5814 opts->done_initializing = 1;
5815
5816 { /* read the appropriate environment variable and if it exists
5817 * replace include_defaults with the listed path. */
5818 char *epath = 0;
5819
5820 switch ((opts->objc << 1) + opts->cplusplus)
5821 {
5822 case 0:
5823 epath = getenv("C_INCLUDE_PATH");
5824 break;
5825 case 1:
5826 epath = getenv("CPLUS_INCLUDE_PATH");
5827 break;
5828 case 2:
5829 epath = getenv("OBJC_INCLUDE_PATH");
5830 break;
5831 case 3:
5832 epath = getenv("OBJCPLUS_INCLUDE_PATH");
5833 break;
5834 }
5835 /* If the environment var for this language is set,
5836 * add to the default list of include directories. */
5837 if (epath)
5838 {
5839 char *nstore = (char *)alloca(strlen(epath) + 2);
5840 int num_dirs;
5841 char *startp, *endp;
5842
5843 for (num_dirs = 1, startp = epath; *startp; startp++)
5844 if (*startp == PATH_SEPARATOR)
5845 num_dirs++;
5846 include_defaults
5847 = (struct default_include *)xmalloc((num_dirs
5848 *
5849 sizeof(struct
5850 default_include)) +
5851 sizeof
5852 (include_defaults_array));
5853
5854 startp = endp = epath;
5855 num_dirs = 0;
5856 while (1)
5857 {
5858 /* Handle cases like c:/usr/lib:d:/gcc/lib */
5859 if ((*endp == PATH_SEPARATOR) || *endp == 0)
5860 {
5861 strncpy(nstore, startp, endp - startp);
5862 if (endp == startp)
5863 strcpy(nstore, ".");
5864 else
5865 nstore[endp - startp] = '\0';
5866
5867 include_defaults[num_dirs].fname = savestring(nstore);
5868 include_defaults[num_dirs].cplusplus = opts->cplusplus;
5869 include_defaults[num_dirs].cxx_aware = 1;
5870 num_dirs++;
5871 if (*endp == '\0')
5872 break;
5873 endp = startp = endp + 1;
5874 }
5875 else
5876 endp++;
5877 }
5878 /* Put the usual defaults back in at the end. */
5879 memcpy((char *)&include_defaults[num_dirs],
5880 (char *)include_defaults_array,
5881 sizeof(include_defaults_array));
5882 }
5883 }
5884
5885 append_include_chain(pfile, opts->before_system, opts->last_before_system);
5886 opts->first_system_include = opts->before_system;
5887
5888 /* Unless -fnostdinc,
5889 * tack on the standard include file dirs to the specified list */
5890 if (!opts->no_standard_includes)
5891 {
5892 struct default_include *di = include_defaults;
5893 char *specd_prefix = opts->include_prefix;
5894 char *default_prefix = savestring(GCC_INCLUDE_DIR);
5895 int default_len = 0;
5896
5897 /* Remove the `include' from /usr/local/lib/gcc.../include. */
5898 if (!strcmp(default_prefix + strlen(default_prefix) - 8, "/include"))
5899 {
5900 default_len = strlen(default_prefix) - 7;
5901 default_prefix[default_len] = 0;
5902 }
5903 /* Search "translated" versions of GNU directories.
5904 * These have /usr/local/lib/gcc... replaced by specd_prefix. */
5905 if (specd_prefix && default_len != 0)
5906 for (di = include_defaults; di->fname; di++)
5907 {
5908 /* Some standard dirs are only for C++. */
5909 if (!di->cplusplus
5910 || (opts->cplusplus
5911 && !opts->no_standard_cplusplus_includes))
5912 {
5913 /* Does this dir start with the prefix? */
5914 if (!strncmp(di->fname, default_prefix, default_len))
5915 {
5916 /* Yes; change prefix and add to search list. */
5917 file_name_list *new_
5918 =
5919 (file_name_list *) xmalloc(sizeof(file_name_list));
5920 int this_len =
5921 strlen(specd_prefix) + strlen(di->fname) -
5922 default_len;
5923 char *str =
5924 (char *)xmalloc(this_len + 1);
5925
5926 strcpy(str, specd_prefix);
5927 strcat(str, di->fname + default_len);
5928 new_->fname = str;
5929 new_->control_macro = 0;
5930 new_->c_system_include_path = !di->cxx_aware;
5931 new_->got_name_map = 0;
5932 append_include_chain(pfile, new_, new_);
5933 if (!opts->first_system_include)
5934 opts->first_system_include = new_;
5935 }
5936 }
5937 }
5938 /* Search ordinary names for GNU include directories. */
5939 for (di = include_defaults; di->fname; di++)
5940 {
5941 /* Some standard dirs are only for C++. */
5942 if (!di->cplusplus
5943 || (opts->cplusplus && !opts->no_standard_cplusplus_includes))
5944 {
5945 file_name_list *new_
5946 = (file_name_list *) xmalloc(sizeof(file_name_list));
5947
5948 new_->control_macro = 0;
5949 new_->c_system_include_path = !di->cxx_aware;
5950 new_->fname = (char *)di->fname;
5951 new_->got_name_map = 0;
5952 append_include_chain(pfile, new_, new_);
5953 if (!opts->first_system_include)
5954 opts->first_system_include = new_;
5955 }
5956 }
5957 }
5958 /* Tack the after_include chain at the end of the include chain. */
5959 append_include_chain(pfile, opts->after_include, opts->last_after_include);
5960 if (!opts->first_system_include)
5961 opts->first_system_include = opts->after_include;
5962
5963 /* With -v, print the list of dirs to search. */
5964 if (opts->verbose)
5965 {
5966 file_name_list *fl;
5967
5968 fprintf(stderr, "#include \"...\" search starts here:\n");
5969 for (fl = opts->include; fl; fl = fl->next)
5970 {
5971 if (fl == opts->first_bracket_include)
5972 fprintf(stderr, "#include <...> search starts here:\n");
5973 fprintf(stderr, " %s\n", fl->fname);
5974 }
5975 fprintf(stderr, "End of search list.\n");
5976 }
5977 /* Scan the -imacros files before the main input.
5978 * Much like #including them, but with no_output set
5979 * so that only their macro definitions matter. */
5980
5981 opts->no_output++;
5982 pfile->no_record_file++;
5983 for (pend = opts->pending; pend; pend = pend->next)
5984 {
5985 if (pend->cmd && strcmp(pend->cmd, "-imacros") == 0)
5986 {
5987 int fd = open(pend->arg, O_RDONLY | O_BINARY, 0666);
5988
5989 if (fd < 0)
5990 {
5991 cpp_perror_with_name(pfile, pend->arg);
5992 return FATAL_EXIT_CODE;
5993 }
5994 cpp_push_buffer(pfile, NULL, 0);
5995 finclude(pfile, fd, pend->arg, 0, NULL);
5996 cpp_scan_buffer(pfile);
5997 }
5998 }
5999 opts->no_output--;
6000 pfile->no_record_file--;
6001
6002 /* Copy the entire contents of the main input file into
6003 * the stacked input buffer previously allocated for it. */
6004 if (!fname || *fname == 0)
6005 {
6006 fname = "";
6007 f = 0;
6008 }
6009 else if ((f = open(fname, O_RDONLY | O_BINARY, 0666)) < 0)
6010 cpp_pfatal_with_name(pfile, fname);
6011
6012 /* -MG doesn't select the form of output and must be specified with one of
6013 * -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't
6014 * inhibit compilation. */
6015 if (opts->print_deps_missing_files
6016 && (opts->print_deps == 0 || !opts->no_output))
6017 cpp_fatal("-MG must be specified with one of -M or -MM");
6018
6019 /* Either of two environment variables can specify output of deps.
6020 * Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
6021 * where OUTPUT_FILE is the file to write deps info to
6022 * and DEPS_TARGET is the target to mention in the deps. */
6023
6024 if (opts->print_deps == 0
6025 && (getenv("SUNPRO_DEPENDENCIES") != 0
6026 || getenv("DEPENDENCIES_OUTPUT") != 0))
6027 {
6028 char *spec = getenv("DEPENDENCIES_OUTPUT");
6029 char *s;
6030 char *output_file;
6031
6032 if (!spec)
6033 {
6034 spec = getenv("SUNPRO_DEPENDENCIES");
6035 opts->print_deps = 2;
6036 }
6037 else
6038 opts->print_deps = 1;
6039
6040 s = spec;
6041 /* Find the space before the DEPS_TARGET, if there is one. */
6042 /* This should use index. (mrs) */
6043 while (*s != 0 && *s != ' ')
6044 s++;
6045 if (*s != 0)
6046 {
6047 opts->deps_target = s + 1;
6048 output_file = (char *)xmalloc(s - spec + 1);
6049 memcpy(output_file, spec, s - spec);
6050 output_file[s - spec] = 0;
6051 }
6052 else
6053 {
6054 opts->deps_target = 0;
6055 output_file = spec;
6056 }
6057
6058 opts->deps_file = output_file;
6059 opts->print_deps_append = 1;
6060 }
6061 /* For -M, print the expected object file name
6062 * as the target of this Make-rule. */
6063 if (opts->print_deps)
6064 {
6065 pfile->deps_allocated_size = 200;
6066 pfile->deps_buffer = (char *)xmalloc(pfile->deps_allocated_size);
6067 pfile->deps_buffer[0] = 0;
6068 pfile->deps_size = 0;
6069 pfile->deps_column = 0;
6070
6071 if (opts->deps_target)
6072 deps_output(pfile, opts->deps_target, ':');
6073 else if (*opts->in_fname == 0)
6074 deps_output(pfile, "-", ':');
6075 else
6076 {
6077 char *q;
6078 int len;
6079
6080 /* Discard all directory prefixes from filename. */
6081 if ((q = (char *)strrchr(opts->in_fname, '/'))
6082#ifdef DIR_SEPARATOR
6083 && (q = strrchr(opts->in_fname, DIR_SEPARATOR))
6084#endif
6085 )
6086 ++q;
6087 else
6088 q = (char *)opts->in_fname;
6089
6090 /* Copy remainder to mungable area. */
6091 p = (char *)alloca(strlen(q) + 8);
6092 strcpy(p, q);
6093
6094 /* Output P, but remove known suffixes. */
6095 len = strlen(p);
6096 q = p + len;
6097 if (len >= 2 && p[len - 2] == '.' && strchr("cCsSm", p[len - 1]))
6098 q = p + (len - 2);
6099 else if (len >= 3
6100 && p[len - 3] == '.'
6101 && p[len - 2] == 'c' && p[len - 1] == 'c')
6102 q = p + (len - 3);
6103 else if (len >= 4
6104 && p[len - 4] == '.'
6105 && p[len - 3] == 'c'
6106 && p[len - 2] == 'x' && p[len - 1] == 'x')
6107 q = p + (len - 4);
6108 else if (len >= 4
6109 && p[len - 4] == '.'
6110 && p[len - 3] == 'c'
6111 && p[len - 2] == 'p' && p[len - 1] == 'p')
6112 q = p + (len - 4);
6113
6114 /* Supply our own suffix. */
6115 strcpy(q, ".o");
6116
6117 deps_output(pfile, p, ':');
6118 deps_output(pfile, opts->in_fname, ' ');
6119 }
6120 }
6121
6122 /* Scan the -include files before the main input.
6123 * We push these in reverse order, so that the first one is handled first. */
6124
6125 pfile->no_record_file++;
6126 opts->pending = nreverse_pending(opts->pending);
6127 for (pend = opts->pending; pend; pend = pend->next)
6128 {
6129 if (pend->cmd && strcmp(pend->cmd, "-include") == 0)
6130 {
6131 int fd = open(pend->arg, O_RDONLY | O_BINARY, 0666);
6132
6133 if (fd < 0)
6134 {
6135 cpp_perror_with_name(pfile, pend->arg);
6136 return FATAL_EXIT_CODE;
6137 }
6138 cpp_push_buffer(pfile, NULL, 0);
6139 finclude(pfile, fd, pend->arg, 0, NULL);
6140 }
6141 }
6142 pfile->no_record_file--;
6143
6144 /* Free the pending list. */
6145 for (pend = opts->pending; pend;)
6146 {
6147 struct cpp_pending *next = pend->next;
6148
6149 free(pend);
6150 pend = next;
6151 }
6152 opts->pending = NULL;
6153
6154 if (finclude(pfile, f, fname, 0, NULL))
6155 output_line_command(pfile, 0, same_file);
6156 return SUCCESS_EXIT_CODE;
6157}
6158
6159void
6160init_parse_file(cpp_reader * pfile)
6161{
6162 memset((char *)pfile, 0, sizeof(cpp_reader));
6163 pfile->get_token = cpp_get_token;
6164
6165 pfile->token_buffer_size = 200;
6166 pfile->token_buffer = (unsigned char *)xmalloc(pfile->token_buffer_size);
6167 CPP_SET_WRITTEN(pfile, 0);
6168
6169 pfile->system_include_depth = 0;
6170 pfile->dont_repeat_files = 0;
6171 pfile->all_include_files = 0;
6172 pfile->max_include_len = 0;
6173 pfile->timebuf = NULL;
6174 pfile->only_seen_white = 1;
6175 pfile->buffer = CPP_NULL_BUFFER(pfile);
6176}
6177
6178static struct cpp_pending *
6179nreverse_pending(struct cpp_pending *list)
6180{
6181 struct cpp_pending *prev = 0, *next, *pend;
6182
6183 for (pend = list; pend; pend = next)
6184 {
6185 next = pend->next;
6186 pend->next = prev;
6187 prev = pend;
6188 }
6189 return prev;
6190}
6191
6192static void
6193push_pending(cpp_reader * pfile, const char *cmd, const char *arg)
6194{
6195 struct cpp_pending *pend
6196 = (struct cpp_pending *)xmalloc(sizeof(struct cpp_pending));
6197
6198 pend->cmd = cmd;
6199 pend->arg = arg;
6200 pend->next = CPP_OPTIONS(pfile)->pending;
6201 CPP_OPTIONS(pfile)->pending = pend;
6202}
6203
6204/* Handle command-line options in (argc, argv).
6205 * Can be called multiple times, to handle multiple sets of options.
6206 * Returns if an unrecognized option is seen.
6207 * Returns number of handled arguments. */
6208
6209int
6210cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
6211{
6212 int i;
6213 struct cpp_options *opts = CPP_OPTIONS(pfile);
6214
6215 for (i = 0; i < argc; i++)
6216 {
6217 if (argv[i][0] != '-')
6218 {
6219 if (opts->out_fname)
6220 cpp_fatal("Usage: %s [switches] input output", argv[0]);
6221 else if (opts->in_fname)
6222 opts->out_fname = argv[i];
6223 else
6224 opts->in_fname = argv[i];
6225 }
6226 else
6227 {
6228 switch (argv[i][1])
6229 {
6230
6231 case 'i':
6232 if (!strcmp(argv[i], "-include")
6233 || !strcmp(argv[i], "-imacros"))
6234 {
6235 if (i + 1 == argc)
6236 cpp_fatal("Filename missing after `%s' option",
6237 argv[i]);
6238 else
6239 push_pending(pfile, argv[i], argv[i + 1]), i++;
6240 }
6241 if (!strcmp(argv[i], "-iprefix"))
6242 {
6243 if (i + 1 == argc)
6244 cpp_fatal("Filename missing after `-iprefix' option");
6245 else
6246 opts->include_prefix = argv[++i];
6247 }
6248 if (!strcmp(argv[i], "-ifoutput"))
6249 {
6250 opts->output_conditionals = 1;
6251 }
6252 if (!strcmp(argv[i], "-isystem"))
6253 {
6254 file_name_list *dirtmp;
6255
6256 if (i + 1 == argc)
6257 cpp_fatal("Filename missing after `-isystem' option");
6258
6259 dirtmp =
6260 (file_name_list *) xmalloc(sizeof(file_name_list));
6261
6262 dirtmp->next = 0;
6263 dirtmp->control_macro = 0;
6264 dirtmp->c_system_include_path = 1;
6265 dirtmp->fname = (char *)xmalloc(strlen(argv[i + 1]) + 1);
6266 strcpy(dirtmp->fname, argv[++i]);
6267 dirtmp->got_name_map = 0;
6268
6269 if (!opts->before_system)
6270 opts->before_system = dirtmp;
6271 else
6272 opts->last_before_system->next = dirtmp;
6273 opts->last_before_system = dirtmp; /* Tail follows the last one */
6274 }
6275 /* Add directory to end of path for includes,
6276 * with the default prefix at the front of its name. */
6277 if (!strcmp(argv[i], "-iwithprefix"))
6278 {
6279 file_name_list *dirtmp;
6280 char *prefix;
6281
6282 if (opts->include_prefix)
6283 prefix = opts->include_prefix;
6284 else
6285 {
6286 prefix = savestring(GCC_INCLUDE_DIR);
6287 /* Remove the `include' from /usr/local/lib/gcc.../include. */
6288 if (!strcmp
6289 (prefix + strlen(prefix) - 8, "/include"))
6290 prefix[strlen(prefix) - 7] = 0;
6291 }
6292
6293 dirtmp =
6294 (file_name_list *) xmalloc(sizeof(file_name_list));
6295
6296 dirtmp->next = 0; /* New one goes on the end */
6297 dirtmp->control_macro = 0;
6298 dirtmp->c_system_include_path = 0;
6299 if (i + 1 == argc)
6300 cpp_fatal
6301 ("Directory name missing after `-iwithprefix' option");
6302
6303 dirtmp->fname = (char *)xmalloc(strlen(argv[i + 1])
6304 + strlen(prefix) + 1);
6305 strcpy(dirtmp->fname, prefix);
6306 strcat(dirtmp->fname, argv[++i]);
6307 dirtmp->got_name_map = 0;
6308
6309 if (!opts->after_include)
6310 opts->after_include = dirtmp;
6311 else
6312 opts->last_after_include->next = dirtmp;
6313 opts->last_after_include = dirtmp; /* Tail follows the last one */
6314 }
6315 /* Add directory to main path for includes,
6316 * with the default prefix at the front of its name. */
6317 if (!strcmp(argv[i], "-iwithprefixbefore"))
6318 {
6319 file_name_list *dirtmp;
6320 char *prefix;
6321
6322 if (opts->include_prefix)
6323 prefix = opts->include_prefix;
6324 else
6325 {
6326 prefix = savestring(GCC_INCLUDE_DIR);
6327 /* Remove the `include' from /usr/local/lib/gcc.../include. */
6328 if (!strcmp
6329 (prefix + strlen(prefix) - 8, "/include"))
6330 prefix[strlen(prefix) - 7] = 0;
6331 }
6332
6333 dirtmp =
6334 (file_name_list *) xmalloc(sizeof(file_name_list));
6335
6336 dirtmp->next = 0; /* New one goes on the end */
6337 dirtmp->control_macro = 0;
6338 dirtmp->c_system_include_path = 0;
6339 if (i + 1 == argc)
6340 cpp_fatal
6341 ("Directory name missing after `-iwithprefixbefore' option");
6342
6343 dirtmp->fname = (char *)xmalloc(strlen(argv[i + 1])
6344 + strlen(prefix) + 1);
6345 strcpy(dirtmp->fname, prefix);
6346 strcat(dirtmp->fname, argv[++i]);
6347 dirtmp->got_name_map = 0;
6348
6349 append_include_chain(pfile, dirtmp, dirtmp);
6350 }
6351 /* Add directory to end of path for includes. */
6352 if (!strcmp(argv[i], "-idirafter"))
6353 {
6354 file_name_list *dirtmp;
6355
6356 dirtmp =
6357 (file_name_list *) xmalloc(sizeof(file_name_list));
6358
6359 dirtmp->next = 0; /* New one goes on the end */
6360 dirtmp->control_macro = 0;
6361 dirtmp->c_system_include_path = 0;
6362 if (i + 1 == argc)
6363 cpp_fatal
6364 ("Directory name missing after `-idirafter' option");
6365 else
6366 dirtmp->fname = argv[++i];
6367 dirtmp->got_name_map = 0;
6368
6369 if (!opts->after_include)
6370 opts->after_include = dirtmp;
6371 else
6372 opts->last_after_include->next = dirtmp;
6373 opts->last_after_include = dirtmp; /* Tail follows the last one */
6374 }
6375 break;
6376
6377 case 'o':
6378 if (opts->out_fname)
6379 cpp_fatal("Output filename specified twice");
6380 if (i + 1 == argc)
6381 cpp_fatal("Filename missing after -o option");
6382 opts->out_fname = argv[++i];
6383 if (!strcmp(opts->out_fname, "-"))
6384 opts->out_fname = "";
6385 break;
6386
6387 case 'p':
6388 if (!strcmp(argv[i], "-pedantic"))
6389 CPP_PEDANTIC(pfile) = 1;
6390 else if (!strcmp(argv[i], "-pedantic-errors"))
6391 {
6392 CPP_PEDANTIC(pfile) = 1;
6393 opts->pedantic_errors = 1;
6394 }
6395 break;
6396
6397 case 't':
6398 if (!strcmp(argv[i], "-trigraphs"))
6399 {
6400 if (!opts->chill)
6401 opts->no_trigraphs = 0;
6402 }
6403 break;
6404
6405 case 'l':
6406 if (!strcmp(argv[i], "-lang-c"))
6407 opts->cplusplus = 0, opts->cplusplus_comments =
6408 0, opts->objc = 0;
6409 if (!strcmp(argv[i], "-lang-c++"))
6410 opts->cplusplus = 1, opts->cplusplus_comments =
6411 1, opts->objc = 0;
6412 if (!strcmp(argv[i], "-lang-c-c++-comments"))
6413 opts->cplusplus = 0, opts->cplusplus_comments =
6414 1, opts->objc = 0;
6415 if (!strcmp(argv[i], "-lang-objc"))
6416 opts->objc = 1, opts->cplusplus =
6417 0, opts->cplusplus_comments = 1;
6418 if (!strcmp(argv[i], "-lang-objc++"))
6419 opts->objc = 1, opts->cplusplus =
6420 1, opts->cplusplus_comments = 1;
6421 if (!strcmp(argv[i], "-lang-asm"))
6422 opts->lang_asm = 1;
6423 if (!strcmp(argv[i], "-lint"))
6424 opts->for_lint = 1;
6425 if (!strcmp(argv[i], "-lang-chill"))
6426 opts->objc = 0, opts->cplusplus = 0, opts->chill = 1,
6427 opts->traditional = 1, opts->no_trigraphs = 1;
6428 break;
6429
6430 case '+':
6431 opts->cplusplus = 1, opts->cplusplus_comments = 1;
6432 break;
6433
6434 case 'w':
6435 opts->inhibit_warnings = 1;
6436 break;
6437
6438 case 'W':
6439 if (!strcmp(argv[i], "-Wtrigraphs"))
6440 opts->warn_trigraphs = 1;
6441 else if (!strcmp(argv[i], "-Wno-trigraphs"))
6442 opts->warn_trigraphs = 0;
6443 else if (!strcmp(argv[i], "-Wcomment"))
6444 opts->warn_comments = 1;
6445 else if (!strcmp(argv[i], "-Wno-comment"))
6446 opts->warn_comments = 0;
6447 else if (!strcmp(argv[i], "-Wcomments"))
6448 opts->warn_comments = 1;
6449 else if (!strcmp(argv[i], "-Wno-comments"))
6450 opts->warn_comments = 0;
6451 else if (!strcmp(argv[i], "-Wtraditional"))
6452 opts->warn_stringify = 1;
6453 else if (!strcmp(argv[i], "-Wno-traditional"))
6454 opts->warn_stringify = 0;
6455 else if (!strcmp(argv[i], "-Wimport"))
6456 opts->warn_import = 1;
6457 else if (!strcmp(argv[i], "-Wno-import"))
6458 opts->warn_import = 0;
6459 else if (!strcmp(argv[i], "-Werror"))
6460 opts->warnings_are_errors = 1;
6461 else if (!strcmp(argv[i], "-Wno-error"))
6462 opts->warnings_are_errors = 0;
6463 else if (!strcmp(argv[i], "-Wall"))
6464 {
6465 opts->warn_trigraphs = 1;
6466 opts->warn_comments = 1;
6467 }
6468 break;
6469
6470 case 'M':
6471 /* The style of the choices here is a bit mixed.
6472 * The chosen scheme is a hybrid of keeping all options in one string
6473 * and specifying each option in a separate argument:
6474 * -M|-MM|-MD file|-MMD file [-MG]. An alternative is:
6475 * -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
6476 * -M[M][G][D file]. This is awkward to handle in specs, and is not
6477 * as extensible. */
6478 /* ??? -MG must be specified in addition to one of -M or -MM.
6479 * This can be relaxed in the future without breaking anything.
6480 * The converse isn't true. */
6481
6482 /* -MG isn't valid with -MD or -MMD. This is checked for later. */
6483 if (!strcmp(argv[i], "-MG"))
6484 {
6485 opts->print_deps_missing_files = 1;
6486 break;
6487 }
6488 if (!strcmp(argv[i], "-M"))
6489 opts->print_deps = 2;
6490 else if (!strcmp(argv[i], "-MM"))
6491 opts->print_deps = 1;
6492 else if (!strcmp(argv[i], "-MD"))
6493 opts->print_deps = 2;
6494 else if (!strcmp(argv[i], "-MMD"))
6495 opts->print_deps = 1;
6496 /* For -MD and -MMD options, write deps on file named by next arg. */
6497 if (!strcmp(argv[i], "-MD") || !strcmp(argv[i], "-MMD"))
6498 {
6499 if (i + 1 == argc)
6500 cpp_fatal("Filename missing after %s option",
6501 argv[i]);
6502 opts->deps_file = argv[++i];
6503 }
6504 else
6505 {
6506 /* For -M and -MM, write deps on standard output
6507 * and suppress the usual output. */
6508 opts->no_output = 1;
6509 }
6510 break;
6511
6512 case 'd':
6513 {
6514 char *p = argv[i] + 2;
6515 char c;
6516
6517 while ((c = *p++) != 0)
6518 {
6519 /* Arg to -d specifies what parts of macros to dump */
6520 switch (c)
6521 {
6522 case 'M':
6523 opts->dump_macros = dump_only;
6524 opts->no_output = 1;
6525 break;
6526 case 'N':
6527 opts->dump_macros = dump_names;
6528 break;
6529 case 'D':
6530 opts->dump_macros = dump_definitions;
6531 break;
6532 }
6533 }
6534 }
6535 break;
6536
6537 case 'g':
6538 if (argv[i][2] == '3')
6539 opts->debug_output = 1;
6540 break;
6541
6542 case 'v':
6543 fprintf(stderr, "GNU CPP version %s", version_string);
6544#ifdef TARGET_VERSION
6545 TARGET_VERSION;
6546#endif
6547 fprintf(stderr, "\n");
6548 opts->verbose = 1;
6549 break;
6550
6551 case 'H':
6552 opts->print_include_names = 1;
6553 break;
6554
6555 case 'D':
6556 if (argv[i][2] != 0)
6557 push_pending(pfile, "-D", argv[i] + 2);
6558 else if (i + 1 == argc)
6559 cpp_fatal("Macro name missing after -D option");
6560 else
6561 i++, push_pending(pfile, "-D", argv[i]);
6562 break;
6563
6564 case 'A':
6565 {
6566 char *p = NULL;
6567
6568 if (argv[i][2] != 0)
6569 p = argv[i] + 2;
6570 else if (i + 1 == argc)
6571 cpp_fatal("Assertion missing after -A option");
6572 else
6573 p = argv[++i];
6574
6575 if (!strcmp(p, "-"))
6576 {
6577 struct cpp_pending **ptr;
6578
6579 /* -A- eliminates all predefined macros and assertions.
6580 * Let's include also any that were specified earlier
6581 * on the command line. That way we can get rid of any
6582 * that were passed automatically in from GCC. */
6583
6584 opts->inhibit_predefs = 1;
6585 for (ptr = &opts->pending; *ptr;)
6586 {
6587 struct cpp_pending *pend = *ptr;
6588
6589 if (pend->cmd && pend->cmd[0] == '-'
6590 && (pend->cmd[1] == 'D'
6591 || pend->cmd[1] == 'A'))
6592 {
6593 *ptr = pend->next;
6594 free(pend);
6595 }
6596 else
6597 ptr = &pend->next;
6598 }
6599 }
6600 else
6601 {
6602 push_pending(pfile, "-A", p);
6603 }
6604 }
6605 break;
6606
6607 case 'U': /* JF #undef something */
6608 if (argv[i][2] != 0)
6609 push_pending(pfile, "-U", argv[i] + 2);
6610 else if (i + 1 == argc)
6611 cpp_fatal("Macro name missing after -U option");
6612 else
6613 push_pending(pfile, "-U", argv[i + 1]), i++;
6614 break;
6615
6616 case 'C':
6617 opts->put_out_comments = 1;
6618 break;
6619
6620 case 'E': /* -E comes from cc -E; ignore it. */
6621 break;
6622
6623 case 'P':
6624 opts->no_line_commands = 1;
6625 break;
6626
6627 case '$': /* Don't include $ in identifiers. */
6628 opts->dollars_in_ident = 0;
6629 break;
6630
6631 case 'I': /* Add directory to path for includes. */
6632 {
6633 file_name_list *dirtmp;
6634
6635 if (!CPP_OPTIONS(pfile)->ignore_srcdir
6636 && !strcmp(argv[i] + 2, "-"))
6637 {
6638 CPP_OPTIONS(pfile)->ignore_srcdir = 1;
6639 /* Don't use any preceding -I directories for #include <...>. */
6640 CPP_OPTIONS(pfile)->first_bracket_include = 0;
6641 }
6642 else
6643 {
6644 dirtmp =
6645 (file_name_list *) xmalloc(sizeof(file_name_list));
6646
6647 dirtmp->next = 0; /* New one goes on the end */
6648 dirtmp->control_macro = 0;
6649 dirtmp->c_system_include_path = 0;
6650 if (argv[i][2] != 0)
6651 dirtmp->fname = argv[i] + 2;
6652 else if (i + 1 == argc)
6653 cpp_fatal
6654 ("Directory name missing after -I option");
6655 else
6656 dirtmp->fname = argv[++i];
6657 dirtmp->got_name_map = 0;
6658 append_include_chain(pfile, dirtmp, dirtmp);
6659 }
6660 }
6661 break;
6662
6663 case 'n':
6664 if (!strcmp(argv[i], "-nostdinc"))
6665 /* -nostdinc causes no default include directories.
6666 * You must specify all include-file directories with -I. */
6667 opts->no_standard_includes = 1;
6668 else if (!strcmp(argv[i], "-nostdinc++"))
6669 /* -nostdinc++ causes no default C++-specific include directories. */
6670 opts->no_standard_cplusplus_includes = 1;
6671 break;
6672
6673 case 'u':
6674 /* Sun compiler passes undocumented switch "-undef".
6675 * Let's assume it means to inhibit the predefined symbols. */
6676 opts->inhibit_predefs = 1;
6677 break;
6678
6679 case '\0': /* JF handle '-' as file name meaning stdin or stdout */
6680 if (!opts->in_fname)
6681 {
6682 opts->in_fname = "";
6683 break;
6684 }
6685 else if (!opts->out_fname)
6686 {
6687 opts->out_fname = "";
6688 break;
6689 } /* else fall through into error */
6690 default:
6691 return i;
6692 }
6693 }
6694 }
6695 return i;
6696}
6697
6698void
6699cpp_finish(cpp_reader * pfile)
6700{
6701 struct cpp_options *opts = CPP_OPTIONS(pfile);
6702
6703 if (opts->print_deps)
6704 {
6705 /* Stream on which to print the dependency information. */
6706 FILE *deps_stream;
6707
6708 /* Don't actually write the deps file if compilation has failed. */
6709 if (pfile->errors == 0)
6710 {
6711 const char *deps_mode =
6712 opts->print_deps_append ? "ab" : "wb";
6713
6714 if (!opts->deps_file)
6715 deps_stream = stdout;
6716 else if (!(deps_stream = fopen(opts->deps_file, deps_mode)))
6717 cpp_pfatal_with_name(pfile, opts->deps_file);
6718 fputs(pfile->deps_buffer, deps_stream);
6719 putc('\n', deps_stream);
6720 if (opts->deps_file)
6721 {
6722 if (ferror(deps_stream) || fclose(deps_stream) != 0)
6723 cpp_fatal("I/O error on output");
6724 }
6725 }
6726 }
6727}
6728
6729static int
6730do_assert(cpp_reader * pfile, struct directive *keyword __UNUSED__,
6731 unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__)
6732{
6733 long symstart; /* remember where symbol name starts */
6734 int c;
6735 int sym_length; /* and how long it is */
6736 struct arglist *tokens = NULL;
6737
6738 if (CPP_PEDANTIC(pfile) && CPP_OPTIONS(pfile)->done_initializing
6739 && !CPP_BUFFER(pfile)->system_header_p)
6740 cpp_pedwarn(pfile, "ANSI C does not allow `#assert'");
6741
6742 cpp_skip_hspace(pfile);
6743 symstart = CPP_WRITTEN(pfile); /* remember where it starts */
6744 parse_name(pfile, GETC());
6745 sym_length = check_macro_name(pfile, pfile->token_buffer + symstart,
6746 "assertion");
6747
6748 cpp_skip_hspace(pfile);
6749 if (PEEKC() != '(')
6750 {
6751 cpp_error(pfile, "missing token-sequence in `#assert'");
6752 goto error;
6753 }
6754 {
6755 int error_flag = 0;
6756
6757 tokens = read_token_list(pfile, &error_flag);
6758 if (error_flag)
6759 goto error;
6760 if (!tokens)
6761 {
6762 cpp_error(pfile, "empty token-sequence in `#assert'");
6763 goto error;
6764 }
6765 cpp_skip_hspace(pfile);
6766 c = PEEKC();
6767 if (c != EOF && c != '\n')
6768 cpp_pedwarn(pfile, "junk at end of `#assert'");
6769 skip_rest_of_line(pfile);
6770 }
6771
6772 /* If this name isn't already an assertion name, make it one.
6773 * Error if it was already in use in some other way. */
6774
6775 {
6776 ASSERTION_HASHNODE *hp;
6777 const char *symname = (char *)pfile->token_buffer + symstart;
6778 int hashcode =
6779 hashf(symname, sym_length, ASSERTION_HASHSIZE);
6780 struct tokenlist_list *value =
6781 (struct tokenlist_list *)xmalloc(sizeof(struct tokenlist_list));
6782
6783 hp = assertion_lookup(pfile, symname, sym_length, hashcode);
6784 if (!hp)
6785 {
6786 if (sym_length == 7 && !strncmp(symname, "defined", sym_length))
6787 cpp_error(pfile, "`defined' redefined as assertion");
6788 hp = assertion_install(pfile, symname, sym_length, hashcode);
6789 }
6790 /* Add the spec'd token-sequence to the list of such. */
6791 value->tokens = tokens;
6792 value->next = hp->value;
6793 hp->value = value;
6794 }
6795 CPP_SET_WRITTEN(pfile, symstart); /* Pop */
6796 return 0;
6797 error:
6798 CPP_SET_WRITTEN(pfile, symstart); /* Pop */
6799 skip_rest_of_line(pfile);
6800 return 1;
6801}
6802
6803static int
6804do_unassert(cpp_reader * pfile, struct directive *keyword __UNUSED__,
6805 unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__)
6806{
6807 long symstart; /* remember where symbol name starts */
6808 int sym_length; /* and how long it is */
6809 int c;
6810
6811 struct arglist *tokens = NULL;
6812 int tokens_specified = 0;
6813
6814 if (CPP_PEDANTIC(pfile) && CPP_OPTIONS(pfile)->done_initializing
6815 && !CPP_BUFFER(pfile)->system_header_p)
6816 cpp_pedwarn(pfile, "ANSI C does not allow `#unassert'");
6817
6818 cpp_skip_hspace(pfile);
6819
6820 symstart = CPP_WRITTEN(pfile); /* remember where it starts */
6821 parse_name(pfile, GETC());
6822 sym_length = check_macro_name(pfile, pfile->token_buffer + symstart,
6823 "assertion");
6824
6825 cpp_skip_hspace(pfile);
6826 if (PEEKC() == '(')
6827 {
6828 int error_flag = 0;
6829
6830 tokens = read_token_list(pfile, &error_flag);
6831 if (error_flag)
6832 goto error;
6833 if (!tokens)
6834 {
6835 cpp_error(pfile, "empty token list in `#unassert'");
6836 goto error;
6837 }
6838 tokens_specified = 1;
6839 }
6840 cpp_skip_hspace(pfile);
6841 c = PEEKC();
6842 if (c != EOF && c != '\n')
6843 cpp_error(pfile, "junk at end of `#unassert'");
6844 skip_rest_of_line(pfile);
6845
6846 {
6847 ASSERTION_HASHNODE *hp;
6848 const char *symname = (char *)pfile->token_buffer + symstart;
6849 int hashcode =
6850 hashf(symname, sym_length, ASSERTION_HASHSIZE);
6851 struct tokenlist_list *tail, *prev;
6852
6853 hp = assertion_lookup(pfile, symname, sym_length, hashcode);
6854 if (!hp)
6855 return 1;
6856
6857 /* If no token list was specified, then eliminate this assertion
6858 * entirely. */
6859 if (!tokens_specified)
6860 delete_assertion(hp);
6861 else
6862 {
6863 /* If a list of tokens was given, then delete any matching list. */
6864
6865 tail = hp->value;
6866 prev = 0;
6867 while (tail)
6868 {
6869 struct tokenlist_list *next = tail->next;
6870
6871 if (compare_token_lists(tail->tokens, tokens))
6872 {
6873 if (prev)
6874 prev->next = next;
6875 else
6876 hp->value = tail->next;
6877 free_token_list(tail->tokens);
6878 free(tail);
6879 }
6880 else
6881 {
6882 prev = tail;
6883 }
6884 tail = next;
6885 }
6886 }
6887 }
6888
6889 CPP_SET_WRITTEN(pfile, symstart); /* Pop */
6890 return 0;
6891 error:
6892 CPP_SET_WRITTEN(pfile, symstart); /* Pop */
6893 skip_rest_of_line(pfile);
6894 return 1;
6895}
6896
6897/* Test whether there is an assertion named NAME
6898 * and optionally whether it has an asserted token list TOKENS.
6899 * NAME is not null terminated; its length is SYM_LENGTH.
6900 * If TOKENS_SPECIFIED is 0, then don't check for any token list. */
6901
6902static int
6903check_assertion(cpp_reader * pfile, const char *name, int sym_length,
6904 int tokens_specified, struct arglist *tokens)
6905{
6906 ASSERTION_HASHNODE *hp;
6907 int hashcode = hashf(name, sym_length, ASSERTION_HASHSIZE);
6908
6909 if (CPP_PEDANTIC(pfile) && !CPP_BUFFER(pfile)->system_header_p)
6910 cpp_pedwarn(pfile, "ANSI C does not allow testing assertions");
6911
6912 hp = assertion_lookup(pfile, name, sym_length, hashcode);
6913 if (!hp)
6914 /* It is not an assertion; just return false. */
6915 return 0;
6916
6917 /* If no token list was specified, then value is 1. */
6918 if (!tokens_specified)
6919 return 1;
6920
6921 {
6922 struct tokenlist_list *tail;
6923
6924 tail = hp->value;
6925
6926 /* If a list of tokens was given,
6927 * then succeed if the assertion records a matching list. */
6928
6929 while (tail)
6930 {
6931 if (compare_token_lists(tail->tokens, tokens))
6932 return 1;
6933 tail = tail->next;
6934 }
6935
6936 /* Fail if the assertion has no matching list. */
6937 return 0;
6938 }
6939}
6940
6941/* Compare two lists of tokens for equality including order of tokens. */
6942
6943static int
6944compare_token_lists(struct arglist *l1, struct arglist *l2)
6945{
6946 while (l1 && l2)
6947 {
6948 if (l1->length != l2->length)
6949 return 0;
6950 if (strncmp(l1->name, l2->name, l1->length))
6951 return 0;
6952 l1 = l1->next;
6953 l2 = l2->next;
6954 }
6955
6956 /* Succeed if both lists end at the same time. */
6957 return l1 == l2;
6958}
6959
6960struct arglist *
6961reverse_token_list(struct arglist *tokens)
6962{
6963 struct arglist *prev = 0, *cur, *next;
6964
6965 for (cur = tokens; cur; cur = next)
6966 {
6967 next = cur->next;
6968 cur->next = prev;
6969 prev = cur;
6970 }
6971 return prev;
6972}
6973
6974/* Read a space-separated list of tokens ending in a close parenthesis.
6975 * Return a list of strings, in the order they were written.
6976 * (In case of error, return 0 and store -1 in *ERROR_FLAG.) */
6977
6978static struct arglist *
6979read_token_list(cpp_reader * pfile, int *error_flag)
6980{
6981 struct arglist *token_ptrs = 0;
6982 int depth = 1;
6983 int length;
6984
6985 *error_flag = 0;
6986 FORWARD(1); /* Skip '(' */
6987
6988 /* Loop over the assertion value tokens. */
6989 while (depth > 0)
6990 {
6991 struct arglist *temp;
6992 long name_written = CPP_WRITTEN(pfile);
6993 int c;
6994
6995 cpp_skip_hspace(pfile);
6996
6997 c = GETC();
6998
6999 /* Find the end of the token. */
7000 if (c == '(')
7001 {
7002 CPP_PUTC(pfile, c);
7003 depth++;
7004 }
7005 else if (c == ')')
7006 {
7007 depth--;
7008 if (depth == 0)
7009 break;
7010 CPP_PUTC(pfile, c);
7011 }
7012 else if (c == '"' || c == '\'')
7013 {
7014 FORWARD(-1);
7015 cpp_get_token(pfile);
7016 }
7017 else if (c == '\n')
7018 break;
7019 else
7020 {
7021 while (c != EOF && !is_space[c] && c != '(' && c != ')'
7022 && c != '"' && c != '\'')
7023 {
7024 CPP_PUTC(pfile, c);
7025 c = GETC();
7026 }
7027 if (c != EOF)
7028 FORWARD(-1);
7029 }
7030
7031 length = CPP_WRITTEN(pfile) - name_written;
7032 temp = (struct arglist *)xmalloc(sizeof(struct arglist) + length + 1);
7033
7034 temp->name = (char *)(temp + 1);
7035 memcpy(temp->name, (char *)(pfile->token_buffer + name_written),
7036 length);
7037 temp->name[length] = 0;
7038 temp->next = token_ptrs;
7039 token_ptrs = temp;
7040 temp->length = length;
7041
7042 CPP_ADJUST_WRITTEN(pfile, -length); /* pop */
7043
7044 if (c == EOF || c == '\n')
7045 { /* FIXME */
7046 cpp_error(pfile,
7047 "unterminated token sequence following `#' operator");
7048 return 0;
7049 }
7050 }
7051
7052 /* We accumulated the names in reverse order.
7053 * Now reverse them to get the proper order. */
7054 return reverse_token_list(token_ptrs);
7055}
7056
7057static void
7058free_token_list(struct arglist *tokens)
7059{
7060 while (tokens)
7061 {
7062 struct arglist *next = tokens->next;
7063
7064 free(tokens->name);
7065 free(tokens);
7066 tokens = next;
7067 }
7068}
7069
7070/* Get the file-mode and data size of the file open on FD
7071 * and store them in *MODE_POINTER and *SIZE_POINTER. */
7072
7073static int
7074file_size_and_mode(int fd, int *mode_pointer, long int *size_pointer)
7075{
7076 struct stat sbuf;
7077
7078 if (fstat(fd, &sbuf) < 0)
7079 return (-1);
7080 if (mode_pointer)
7081 *mode_pointer = sbuf.st_mode;
7082 if (size_pointer)
7083 *size_pointer = sbuf.st_size;
7084 return 0;
7085}
7086
7087/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,
7088 * retrying if necessary. Return a negative value if an error occurs,
7089 * otherwise return the actual number of bytes read,
7090 * which must be LEN unless end-of-file was reached. */
7091
7092static int
7093safe_read(int desc, char *ptr, int len)
7094{
7095 int left = len;
7096
7097 while (left > 0)
7098 {
7099 int nchars = read(desc, ptr, left);
7100
7101 if (nchars < 0)
7102 {
7103#ifdef EINTR
7104 if (errno == EINTR)
7105 continue;
7106#endif
7107 return nchars;
7108 }
7109 if (nchars == 0)
7110 break;
7111 ptr += nchars;
7112 left -= nchars;
7113 }
7114 return len - left;
7115}
7116
7117static char *
7118savestring(const char *input)
7119{
7120 unsigned size = strlen(input);
7121 char *output = (char *)xmalloc(size + 1);
7122
7123 strcpy(output, input);
7124 return output;
7125}
7126
7127/* Initialize PMARK to remember the current position of PFILE. */
7128void
7129parse_set_mark(struct parse_marker *pmark, cpp_reader * pfile)
7130{
7131 cpp_buffer *pbuf = CPP_BUFFER(pfile);
7132
7133 pmark->next = pbuf->marks;
7134 pbuf->marks = pmark;
7135 pmark->buf = pbuf;
7136 pmark->position = pbuf->cur - pbuf->buf;
7137}
7138
7139/* Cleanup PMARK - we no longer need it. */
7140static void
7141parse_clear_mark(struct parse_marker *pmark)
7142{
7143 struct parse_marker **pp = &pmark->buf->marks;
7144
7145 for (;; pp = &(*pp)->next)
7146 {
7147 if (!*pp)
7148 cpp_fatal("internal error", "in parse_set_mark");
7149 if (*pp == pmark)
7150 break;
7151 }
7152 *pp = pmark->next;
7153}
7154
7155/* Backup the current position of PFILE to that saved in PMARK. */
7156
7157static void
7158parse_goto_mark(struct parse_marker *pmark, cpp_reader * pfile)
7159{
7160 cpp_buffer *pbuf = CPP_BUFFER(pfile);
7161
7162 if (pbuf != pmark->buf)
7163 cpp_fatal("internal error %s", "parse_goto_mark");
7164 pbuf->cur = pbuf->buf + pmark->position;
7165}
7166
7167/* Reset PMARK to point to the current position of PFILE. (Same
7168 * as parse_clear_mark (PMARK), parse_set_mark (PMARK, PFILE) but faster. */
7169
7170static void
7171parse_move_mark(struct parse_marker *pmark, cpp_reader * pfile)
7172{
7173 cpp_buffer *pbuf = CPP_BUFFER(pfile);
7174
7175 if (pbuf != pmark->buf)
7176 cpp_fatal("internal error %s", "parse_move_mark");
7177 pmark->position = pbuf->cur - pbuf->buf;
7178}
7179
7180int
7181cpp_read_check_assertion(cpp_reader * pfile)
7182{
7183 int name_start = CPP_WRITTEN(pfile);
7184 int name_length, name_written;
7185 int result;
7186
7187 FORWARD(1); /* Skip '#' */
7188 cpp_skip_hspace(pfile);
7189 parse_name(pfile, GETC());
7190 name_written = CPP_WRITTEN(pfile);
7191 name_length = name_written - name_start;
7192 cpp_skip_hspace(pfile);
7193 if (CPP_BUF_PEEK(CPP_BUFFER(pfile)) == '(')
7194 {
7195 int error_flag;
7196 struct arglist *token_ptrs = read_token_list(pfile, &error_flag);
7197
7198 result = check_assertion(pfile,
7199 (char *)pfile->token_buffer + name_start,
7200 name_length, 1, token_ptrs);
7201 }
7202 else
7203 result = check_assertion(pfile,
7204 (char *)pfile->token_buffer + name_start,
7205 name_length, 0, NULL);
7206 CPP_ADJUST_WRITTEN(pfile, -name_length); /* pop */
7207 return result;
7208}
7209
7210static void
7211cpp_print_file_and_line(cpp_reader * pfile)
7212{
7213 cpp_buffer *ip = cpp_file_buffer(pfile);
7214
7215 if (ip)
7216 {
7217 long line, col;
7218
7219 cpp_buf_line_and_col(ip, &line, &col);
7220 cpp_file_line_for_message(pfile, ip->nominal_fname,
7221 line, pfile->show_column ? col : -1);
7222 }
7223}
7224
7225static void
7226cpp_error_v(cpp_reader * pfile, const char *msg, va_list args)
7227{
7228 cpp_print_containing_files(pfile);
7229 cpp_print_file_and_line(pfile);
7230 cpp_message_v(pfile, 1, msg, args);
7231}
7232
7233void
7234cpp_error(cpp_reader * pfile, const char *msg, ...)
7235{
7236 va_list args;
7237
7238 va_start(args, msg);
7239
7240 cpp_error_v(pfile, msg, args);
7241
7242 va_end(args);
7243}
7244
7245/* Print error message but don't count it. */
7246
7247static void
7248cpp_warning_v(cpp_reader * pfile, const char *msg, va_list args)
7249{
7250 if (CPP_OPTIONS(pfile)->inhibit_warnings)
7251 return;
7252
7253 if (CPP_OPTIONS(pfile)->warnings_are_errors)
7254 pfile->errors++;
7255
7256 cpp_print_containing_files(pfile);
7257 cpp_print_file_and_line(pfile);
7258 cpp_message_v(pfile, 0, msg, args);
7259}
7260
7261void
7262cpp_warning(cpp_reader * pfile, const char *msg, ...)
7263{
7264 va_list args;
7265
7266 va_start(args, msg);
7267
7268 cpp_warning_v(pfile, msg, args);
7269
7270 va_end(args);
7271}
7272
7273/* Print an error message and maybe count it. */
7274
7275void
7276cpp_pedwarn(cpp_reader * pfile, const char *msg, ...)
7277{
7278 va_list args;
7279
7280 va_start(args, msg);
7281
7282 if (CPP_OPTIONS(pfile)->pedantic_errors)
7283 cpp_error_v(pfile, msg, args);
7284 else
7285 cpp_warning_v(pfile, msg, args);
7286
7287 va_end(args);
7288}
7289
7290static void
7291cpp_error_with_line(cpp_reader * pfile, int line, int column, const char *msg)
7292{
7293 cpp_buffer *ip = cpp_file_buffer(pfile);
7294
7295 cpp_print_containing_files(pfile);
7296
7297 if (ip)
7298 cpp_file_line_for_message(pfile, ip->nominal_fname, line, column);
7299
7300 cpp_message(pfile, 1, msg, NULL, NULL, NULL);
7301}
7302
7303static void
7304cpp_warning_with_line(cpp_reader * pfile, int line, int column, const char *msg)
7305{
7306 cpp_buffer *ip;
7307
7308 if (CPP_OPTIONS(pfile)->inhibit_warnings)
7309 return;
7310
7311 if (CPP_OPTIONS(pfile)->warnings_are_errors)
7312 pfile->errors++;
7313
7314 cpp_print_containing_files(pfile);
7315
7316 ip = cpp_file_buffer(pfile);
7317
7318 if (ip)
7319 cpp_file_line_for_message(pfile, ip->nominal_fname, line, column);
7320
7321 cpp_message(pfile, 0, msg, NULL, NULL, NULL);
7322}
7323
7324static void
7325cpp_pedwarn_with_line(cpp_reader * pfile, int line, int column, const char *msg)
7326{
7327 if (CPP_OPTIONS(pfile)->pedantic_errors)
7328 cpp_error_with_line(pfile, column, line, msg);
7329 else
7330 cpp_warning_with_line(pfile, line, column, msg);
7331}
7332
7333/* Report a warning (or an error if pedantic_errors)
7334 * giving specified file name and line number, not current. */
7335
7336void
7337cpp_pedwarn_with_file_and_line(cpp_reader * pfile,
7338 const char *file, int line,
7339 const char *msg, const char *arg1,
7340 const char *arg2, const char *arg3)
7341{
7342 if (!CPP_OPTIONS(pfile)->pedantic_errors
7343 && CPP_OPTIONS(pfile)->inhibit_warnings)
7344 return;
7345 if (file)
7346 cpp_file_line_for_message(pfile, file, line, -1);
7347 cpp_message(pfile, CPP_OPTIONS(pfile)->pedantic_errors,
7348 msg, arg1, arg2, arg3);
7349}
7350
7351/* This defines "errno" properly for VMS, and gives us EACCES. */
7352#include <errno.h>
7353#ifndef errno
7354extern int errno;
7355
7356#endif
7357
7358#ifndef HAVE_STRERROR
7359extern int sys_nerr;
7360
7361#if defined(bsd4_4)
7362extern const char *const sys_errlist[];
7363
7364#else
7365extern char *sys_errlist[];
7366
7367#endif
7368#endif /* HAVE_STRERROR */
7369
7370/*
7371 * my_strerror - return the descriptive text associated with an `errno' code.
7372 */
7373
7374static const char *
7375my_strerror(int errnum)
7376{
7377 const char *result;
7378
7379#ifndef HAVE_STRERROR
7380 result = ((errnum < sys_nerr) ? sys_errlist[errnum] : 0);
7381#else
7382 result = strerror(errnum);
7383#endif
7384
7385 if (!result)
7386 result = "undocumented I/O error";
7387
7388 return result;
7389}
7390
7391/* Error including a message from `errno'. */
7392
7393static void
7394cpp_error_from_errno(cpp_reader * pfile, const char *name)
7395{
7396 cpp_buffer *ip = cpp_file_buffer(pfile);
7397
7398 cpp_print_containing_files(pfile);
7399
7400 if (ip)
7401 cpp_file_line_for_message(pfile, ip->nominal_fname, ip->lineno, -1);
7402
7403 cpp_message(pfile, 1, "%s: %s", name, my_strerror(errno), NULL);
7404}
7405
7406void
7407cpp_perror_with_name(cpp_reader * pfile, const char *name)
7408{
7409 cpp_message(pfile, 1, "%s: %s: %s", progname, name, my_strerror(errno));
7410}
7411
7412/* TODO:
7413 * No pre-compiled header file support.
7414 *
7415 * Possibly different enum token codes for each C/C++ token.
7416 *
7417 * Should clean up remaining directives to that do_XXX functions
7418 * only take two arguments and all have command_reads_line.
7419 *
7420 * Find and cleanup remaining uses of static variables,
7421 *
7422 * Support for trigraphs.
7423 *
7424 * Support -dM flag (dump_all_macros).
7425 *
7426 * Support for_lint flag.
7427 */
diff --git a/libraries/edje/src/bin/epp/cpplib.h b/libraries/edje/src/bin/epp/cpplib.h
new file mode 100644
index 0000000..5653dd2
--- /dev/null
+++ b/libraries/edje/src/bin/epp/cpplib.h
@@ -0,0 +1,641 @@
1/* Definitions for CPP library.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Written by Per Bothner, 1994-95.
4
5This program is free software; you can redistribute it and/or modify it
6under the terms of the GNU General Public License as published by the
7Free Software Foundation; either version 2, or (at your option) any
8later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 In other words, you are welcome to use, share and improve this program.
20 You are forbidden to forbid anyone else to use, share and improve
21 what you give them. Help stamp out software-hoarding! */
22
23#include <stdarg.h>
24#include <sys/types.h>
25#include <sys/stat.h>
26
27#ifndef HOST_BITS_PER_WIDE_INT
28
29#if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
30#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
31#define HOST_WIDE_INT long
32#else
33#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
34#define HOST_WIDE_INT int
35#endif
36
37#endif
38
39#define STATIC_BUFFERS
40
41typedef struct cpp_reader cpp_reader;
42typedef struct cpp_buffer cpp_buffer;
43typedef struct cpp_options cpp_options;
44
45enum cpp_token {
46 CPP_EOF = -1,
47 CPP_OTHER = 0,
48 CPP_COMMENT = 1,
49 CPP_HSPACE,
50 CPP_VSPACE, /* newlines and #line directives */
51 CPP_NAME,
52 CPP_NUMBER,
53 CPP_CHAR,
54 CPP_STRING,
55 CPP_DIRECTIVE,
56 CPP_LPAREN, /* "(" */
57 CPP_RPAREN, /* ")" */
58 CPP_LBRACE, /* "{" */
59 CPP_RBRACE, /* "}" */
60 CPP_COMMA, /* "," */
61 CPP_SEMICOLON, /* ";" */
62 CPP_3DOTS, /* "..." */
63 /* POP_TOKEN is returned when we've popped a cpp_buffer. */
64 CPP_POP
65};
66
67typedef enum cpp_token (*parse_underflow_t) (cpp_reader *);
68typedef int (*parse_cleanup_t) (cpp_buffer *, cpp_reader *);
69
70/* A parse_marker indicates a previous position,
71 which we can backtrack to. */
72
73struct parse_marker {
74 cpp_buffer *buf;
75 struct parse_marker *next;
76 int position;
77};
78
79extern int cpp_handle_options(cpp_reader * pfile, int, char **);
80extern enum cpp_token cpp_get_token(cpp_reader * pfile);
81extern void cpp_skip_hspace(cpp_reader * pfile);
82
83/* Maintain and search list of included files, for #import. */
84
85#define IMPORT_HASH_SIZE 31
86
87struct import_file {
88 char *name;
89 ino_t inode;
90 dev_t dev;
91 struct import_file *next;
92};
93
94/* If we have a huge buffer, may need to cache more recent counts */
95#define CPP_LINE_BASE(BUF) ((BUF)->buf + (BUF)->line_base)
96
97enum dump_type {
98 dump_none = 0, dump_only, dump_names, dump_definitions
99};
100
101struct cpp_buffer {
102 unsigned char *buf;
103 unsigned char *cur;
104 unsigned char *rlimit; /* end of valid data */
105 unsigned char *alimit; /* end of allocated buffer */
106 unsigned char *prev; /* start of current token */
107
108 const char *fname;
109 /* Filename specified with #line command. */
110 const char *nominal_fname;
111
112 /* Record where in the search path this file was found.
113 * For #include_next. */
114 struct file_name_list *dir;
115
116 long line_base;
117 long lineno; /* Line number at CPP_LINE_BASE. */
118 long colno; /* Column number at CPP_LINE_BASE. */
119#ifndef STATIC_BUFFERS
120 cpp_buffer *chain;
121#endif
122 parse_underflow_t underflow;
123 parse_cleanup_t cleanup;
124 void *data;
125 struct parse_marker *marks;
126 /* Value of if_stack at start of this file.
127 * Used to prohibit unmatched #endif (etc) in an include file. */
128 struct if_stack *if_stack;
129
130 /* True if this is a header file included using <FILENAME>. */
131 char system_header_p;
132 char seen_eof;
133
134 /* True if buffer contains escape sequences.
135 * Currently there are are only two kind:
136 * "@-" means following identifier should not be macro-expanded.
137 * "@ " means a token-separator. This turns into " " in final output
138 * if not stringizing and needed to separate tokens; otherwise nothing.
139 * "@@" means a normal '@'.
140 * (An '@' inside a string stands for itself and is never an escape.) */
141 char has_escapes;
142};
143
144struct cpp_pending; /* Forward declaration - for C++. */
145struct file_name_map_list;
146
147typedef struct assertion_hashnode ASSERTION_HASHNODE;
148
149#define ASSERTION_HASHSIZE 37
150
151#ifdef STATIC_BUFFERS
152/* Maximum nesting of cpp_buffers. We use a static limit, partly for
153 efficiency, and partly to limit runaway recursion. */
154#define CPP_STACK_MAX 200
155#endif
156
157struct cpp_reader {
158 unsigned char *limit;
159 parse_underflow_t get_token;
160 cpp_buffer *buffer;
161#ifdef STATIC_BUFFERS
162 cpp_buffer buffer_stack[CPP_STACK_MAX];
163#endif
164
165 int errors; /* Error counter for exit code */
166 void *data;
167
168 unsigned char *token_buffer;
169 int token_buffer_size;
170
171 /* Line where a newline was first seen in a string constant. */
172 int multiline_string_line;
173
174 /* Current depth in #include directives that use <...>. */
175 int system_include_depth;
176
177 /* List of included files that contained #pragma once. */
178 struct file_name_list *dont_repeat_files;
179
180 /* List of other included files.
181 * If ->control_macro if nonzero, the file had a #ifndef
182 * around the entire contents, and ->control_macro gives the macro name. */
183 struct file_name_list *all_include_files;
184
185 /* Current maximum length of directory names in the search path
186 * for include files. (Altered as we get more of them.) */
187 int max_include_len;
188
189 /* Hash table of files already included with #include or #import. */
190 struct import_file *import_hash_table[IMPORT_HASH_SIZE];
191
192 struct if_stack *if_stack;
193
194 /* Nonzero means we are inside an IF during a -pcp run. In this mode
195 * macro expansion is done, and preconditions are output for all macro
196 * uses requiring them. */
197 char pcp_inside_if;
198
199 /* Nonzero means we have printed (while error reporting) a list of
200 * containing files that matches the current status. */
201 char input_stack_listing_current;
202
203 /* If non-zero, macros are not expanded. */
204 char no_macro_expand;
205
206 /* Print column number in error messages. */
207 char show_column;
208
209 /* We're printed a warning recommending against using #import. */
210 char import_warning;
211
212 /* If true, character between '<' and '>' are a single (string) token. */
213 char parsing_include_directive;
214
215 /* True if escape sequences (as described for has_escapes in
216 * parse_buffer) should be emitted. */
217 char output_escapes;
218
219 /* 0: Have seen non-white-space on this line.
220 * 1: Only seen white space so far on this line.
221 * 2: Only seen white space so far in this file. */
222 char only_seen_white;
223
224 /* Nonzero means this file was included with a -imacros or -include
225 * command line and should not be recorded as an include file. */
226
227 int no_record_file;
228
229 long lineno;
230
231 struct tm *timebuf;
232
233 ASSERTION_HASHNODE *assertion_hashtab[ASSERTION_HASHSIZE];
234
235 /* Buffer of -M output. */
236 char *deps_buffer;
237
238 /* Number of bytes allocated in above. */
239 int deps_allocated_size;
240
241 /* Number of bytes used. */
242 int deps_size;
243
244 /* Number of bytes since the last newline. */
245 int deps_column;
246};
247
248#define CPP_BUF_PEEK(BUFFER) \
249 ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur : EOF)
250#define CPP_BUF_GET(BUFFER) \
251 ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur++ : EOF)
252#define CPP_FORWARD(BUFFER, N) ((BUFFER)->cur += (N))
253
254/* Number of characters currently in PFILE's output buffer. */
255#define CPP_WRITTEN(PFILE) ((PFILE)->limit - (PFILE)->token_buffer)
256#define CPP_PWRITTEN(PFILE) ((PFILE)->limit)
257
258/* Make sure PFILE->token_buffer has space for at least N more characters. */
259#define CPP_RESERVE(PFILE, N) \
260 ((unsigned int)(CPP_WRITTEN (PFILE) + N) > (unsigned int) (PFILE)->token_buffer_size \
261 && (cpp_grow_buffer (PFILE, N), 0))
262
263/* Append string STR (of length N) to PFILE's output buffer.
264 Assume there is enough space. */
265#define CPP_PUTS_Q(PFILE, STR, N) \
266 do { memcpy ((PFILE)->limit, STR, (N)); (PFILE)->limit += (N); } while(0)
267/* Append string STR (of length N) to PFILE's output buffer. Make space. */
268#define CPP_PUTS(PFILE, STR, N) \
269 do { CPP_RESERVE(PFILE, N); CPP_PUTS_Q(PFILE, STR,N); } while(0)
270/* Append character CH to PFILE's output buffer. Assume sufficient space. */
271#define CPP_PUTC_Q(PFILE, CH) (*(PFILE)->limit++ = (CH))
272/* Append character CH to PFILE's output buffer. Make space if need be. */
273#define CPP_PUTC(PFILE, CH) \
274 do { CPP_RESERVE (PFILE, 1); CPP_PUTC_Q (PFILE, CH); } while(0)
275/* Make sure PFILE->limit is followed by '\0'. */
276#define CPP_NUL_TERMINATE_Q(PFILE) (*(PFILE)->limit = 0)
277#define CPP_NUL_TERMINATE(PFILE) \
278 do { CPP_RESERVE(PFILE, 1); *(PFILE)->limit = 0; } while(0)
279#define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA))
280#define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N))
281
282#define CPP_OPTIONS(PFILE) ((cpp_options*)(PFILE)->data)
283#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
284#ifdef STATIC_BUFFERS
285#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1)
286#define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX])
287#else
288#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->chain)
289#define CPP_NULL_BUFFER(PFILE) ((cpp_buffer*)0)
290#endif
291
292/* Pointed to by parse_file::data. */
293struct cpp_options {
294 const char *in_fname;
295
296 /* Name of output file, for error messages. */
297 const char *out_fname;
298
299 struct file_name_map_list *map_list;
300
301 /* Non-0 means -v, so print the full set of include dirs. */
302 char verbose;
303
304 /* Nonzero means use extra default include directories for C++. */
305
306 char cplusplus;
307
308 /* Nonzero means handle cplusplus style comments */
309
310 char cplusplus_comments;
311
312 /* Nonzero means handle #import, for objective C. */
313
314 char objc;
315
316 /* Nonzero means this is an assembly file, and allow
317 * unknown directives, which could be comments. */
318
319 int lang_asm;
320
321 /* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */
322
323 char for_lint;
324
325 /* Nonzero means handle CHILL comment syntax
326 * and output CHILL string delimiter for __DATE___ etc. */
327
328 char chill;
329
330 /* Nonzero means copy comments into the output file. */
331
332 char put_out_comments;
333
334 /* Nonzero means don't process the ANSI trigraph sequences. */
335
336 char no_trigraphs;
337
338 /* Nonzero means print the names of included files rather than
339 * the preprocessed output. 1 means just the #include "...",
340 * 2 means #include <...> as well. */
341
342 char print_deps;
343
344 /* Nonzero if missing .h files in -M output are assumed to be generated
345 * files and not errors. */
346
347 char print_deps_missing_files;
348
349 /* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
350 char print_deps_append;
351
352 /* Nonzero means print names of header files (-H). */
353
354 char print_include_names;
355
356 /* Nonzero means try to make failure to fit ANSI C an error. */
357
358 char pedantic_errors;
359
360 /* Nonzero means don't print warning messages. -w. */
361
362 char inhibit_warnings;
363
364 /* Nonzero means warn if slash-star appears in a comment. */
365
366 char warn_comments;
367
368 /* Nonzero means warn if there are any trigraphs. */
369
370 char warn_trigraphs;
371
372 /* Nonzero means warn if #import is used. */
373
374 char warn_import;
375
376 /* Nonzero means warn if a macro argument is (or would be)
377 * stringified with -traditional. */
378
379 char warn_stringify;
380
381 /* Nonzero means turn warnings into errors. */
382
383 char warnings_are_errors;
384
385 /* Nonzero causes output not to be done,
386 * but directives such as #define that have side effects
387 * are still obeyed. */
388
389 char no_output;
390
391 /* Nonzero means don't output line number information. */
392
393 char no_line_commands;
394
395/* Nonzero means output the text in failing conditionals,
396 inside #failed ... #endfailed. */
397
398 char output_conditionals;
399
400 /* Nonzero means -I- has been seen,
401 * so don't look for #include "foo" the source-file directory. */
402 char ignore_srcdir;
403
404/* Zero means dollar signs are punctuation.
405 -$ stores 0; -traditional may store 1. Default is 1 for VMS, 0 otherwise.
406 This must be 0 for correct processing of this ANSI C program:
407 #define foo(a) #a
408 #define lose(b) foo (b)
409 #define test$
410 lose (test) */
411 char dollars_in_ident;
412#ifndef DOLLARS_IN_IDENTIFIERS
413#define DOLLARS_IN_IDENTIFIERS 1
414#endif
415
416 /* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */
417 char traditional;
418
419 /* Nonzero means give all the error messages the ANSI standard requires. */
420 char pedantic;
421
422 char done_initializing;
423
424 struct file_name_list *include; /* First dir to search */
425 /* First dir to search for <file> */
426 /* This is the first element to use for #include <...>.
427 * If it is 0, use the entire chain for such includes. */
428 struct file_name_list *first_bracket_include;
429 /* This is the first element in the chain that corresponds to
430 * a directory of system header files. */
431 struct file_name_list *first_system_include;
432 struct file_name_list *last_include; /* Last in chain */
433
434 /* Chain of include directories to put at the end of the other chain. */
435 struct file_name_list *after_include;
436 struct file_name_list *last_after_include; /* Last in chain */
437
438 /* Chain to put at the start of the system include files. */
439 struct file_name_list *before_system;
440 struct file_name_list *last_before_system; /* Last in chain */
441
442 /* Directory prefix that should replace `/usr' in the standard
443 * include file directories. */
444 char *include_prefix;
445
446 char inhibit_predefs;
447 char no_standard_includes;
448 char no_standard_cplusplus_includes;
449
450/* dump_only means inhibit output of the preprocessed text
451 and instead output the definitions of all user-defined
452 macros in a form suitable for use as input to cccp.
453 dump_names means pass #define and the macro name through to output.
454 dump_definitions means pass the whole definition (plus #define) through
455*/
456
457 enum dump_type dump_macros;
458
459/* Nonzero means pass all #define and #undef directives which we actually
460 process through to the output stream. This feature is used primarily
461 to allow cc1 to record the #defines and #undefs for the sake of
462 debuggers which understand about preprocessor macros, but it may
463 also be useful with -E to figure out how symbols are defined, and
464 where they are defined. */
465 int debug_output;
466
467 /* Pending -D, -U and -A options, in reverse order. */
468 struct cpp_pending *pending;
469
470 /* File name which deps are being written to.
471 * This is 0 if deps are being written to stdout. */
472 char *deps_file;
473
474 /* Target-name to write with the dependency information. */
475 char *deps_target;
476};
477
478#define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional)
479#define CPP_PEDANTIC(PFILE) (CPP_OPTIONS (PFILE)->pedantic)
480#define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps)
481
482/* Name under which this program was invoked. */
483
484extern char *progname;
485
486/* The structure of a node in the hash table. The hash table
487 has entries for all tokens defined by #define commands (type T_MACRO),
488 plus some special tokens like __LINE__ (these each have their own
489 type, and the appropriate code is run when that type of node is seen.
490 It does not contain control words like "#define", which are recognized
491 by a separate piece of code. */
492
493/* different flavors of hash nodes --- also used in keyword table */
494enum node_type {
495 T_DEFINE = 1, /* the `#define' keyword */
496 T_INCLUDE, /* the `#include' keyword */
497 T_INCLUDE_NEXT, /* the `#include_next' keyword */
498 T_IMPORT, /* the `#import' keyword */
499 T_IFDEF, /* the `#ifdef' keyword */
500 T_IFNDEF, /* the `#ifndef' keyword */
501 T_IF, /* the `#if' keyword */
502 T_ELSE, /* `#else' */
503 T_PRAGMA, /* `#pragma' */
504 T_ELIF, /* `#elif' */
505 T_UNDEF, /* `#undef' */
506 T_LINE, /* `#line' */
507 T_ERROR, /* `#error' */
508 T_WARNING, /* `#warning' */
509 T_ENDIF, /* `#endif' */
510 T_SCCS, /* `#sccs', used on system V. */
511 T_IDENT, /* `#ident', used on system V. */
512 T_ASSERT, /* `#assert', taken from system V. */
513 T_UNASSERT, /* `#unassert', taken from system V. */
514 T_SPECLINE, /* special symbol `__LINE__' */
515 T_DATE, /* `__DATE__' */
516 T_FILE, /* `__FILE__' */
517 T_BASE_FILE, /* `__BASE_FILE__' */
518 T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
519 T_VERSION, /* `__VERSION__' */
520 T_SIZE_TYPE, /* `__SIZE_TYPE__' */
521 T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */
522 T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */
523 T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */
524 T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */
525 T_TIME, /* `__TIME__' */
526 T_CONST, /* Constant value, used by `__STDC__' */
527 T_MACRO, /* macro defined by `#define' */
528 T_DISABLED, /* macro temporarily turned off for rescan */
529 T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */
530 T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */
531 T_UNUSED /* Used for something not defined. */
532};
533
534/* Structure allocated for every #define. For a simple replacement
535 such as
536 #define foo bar ,
537 nargs = -1, the `pattern' list is null, and the expansion is just
538 the replacement text. Nargs = 0 means a functionlike macro with no args,
539 e.g.,
540 #define getchar() getc (stdin) .
541 When there are args, the expansion is the replacement text with the
542 args squashed out, and the reflist is a list describing how to
543 build the output from the input: e.g., "3 chars, then the 1st arg,
544 then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg".
545 The chars here come from the expansion. Whatever is left of the
546 expansion after the last arg-occurrence is copied after that arg.
547 Note that the reflist can be arbitrarily long---
548 its length depends on the number of times the arguments appear in
549 the replacement text, not how many args there are. Example:
550 #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and
551 pattern list
552 { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL }
553 where (x, y) means (nchars, argno). */
554
555typedef struct reflist reflist;
556struct reflist {
557 reflist *next;
558 char stringify; /* nonzero if this arg was preceded by a
559 * # operator. */
560 char raw_before; /* Nonzero if a ## operator before arg. */
561 char raw_after; /* Nonzero if a ## operator after arg. */
562 char rest_args; /* Nonzero if this arg. absorbs the rest */
563 int nchars; /* Number of literal chars to copy before
564 * this arg occurrence. */
565 int argno; /* Number of arg to substitute (origin-0) */
566};
567
568typedef struct definition DEFINITION;
569struct definition {
570 int nargs;
571 int length; /* length of expansion string */
572 int predefined; /* True if the macro was builtin or */
573 /* came from the command line */
574 unsigned char *expansion;
575 int line; /* Line number of definition */
576 const char *file; /* File of definition */
577 char rest_args; /* Nonzero if last arg. absorbs the rest */
578 reflist *pattern;
579 union {
580 /* Names of macro args, concatenated in reverse order
581 * with comma-space between them.
582 * The only use of this is that we warn on redefinition
583 * if this differs between the old and new definitions. */
584 unsigned char *argnames;
585 } args;
586};
587
588extern unsigned char is_idchar[256];
589
590/* Stack of conditionals currently in progress
591 (including both successful and failing conditionals). */
592
593struct if_stack {
594 struct if_stack *next; /* for chaining to the next stack frame */
595 const char *fname; /* copied from input when frame is made */
596 int lineno; /* similarly */
597 int if_succeeded; /* true if a leg of this if-group
598 * has been passed through rescan */
599 unsigned char *control_macro; /* For #ifndef at start of file,
600 * this is the macro name tested. */
601 enum node_type type; /* type of last directive seen in this group */
602};
603typedef struct if_stack IF_STACK_FRAME;
604
605extern void cpp_buf_line_and_col(cpp_buffer *, long *, long *);
606extern cpp_buffer *cpp_file_buffer(cpp_reader *);
607extern void cpp_define(cpp_reader *, unsigned char *);
608
609extern void cpp_error(cpp_reader * pfile, const char *msg, ...);
610extern void cpp_warning(cpp_reader * pfile, const char *msg, ...);
611extern void cpp_pedwarn(cpp_reader * pfile, const char *msg, ...);
612extern void cpp_fatal(const char *msg, ...);
613extern void cpp_file_line_for_message(cpp_reader * pfile,
614 const char *filename, int line,
615 int column);
616extern void cpp_perror_with_name(cpp_reader * pfile, const char *name);
617extern void cpp_pfatal_with_name(cpp_reader * pfile, const char *name);
618extern void cpp_message(cpp_reader * pfile, int is_error,
619 const char *msg, ...);
620extern void cpp_message_v(cpp_reader * pfile, int is_error,
621 const char *msg, va_list args);
622
623extern void cpp_grow_buffer(cpp_reader * pfile, long n);
624extern int cpp_parse_escape(cpp_reader * pfile, char **string_ptr);
625
626void cpp_print_containing_files(cpp_reader * pfile);
627HOST_WIDE_INT cpp_parse_expr(cpp_reader * pfile);
628void skip_rest_of_line(cpp_reader * pfile);
629void init_parse_file(cpp_reader * pfile);
630void init_parse_options(struct cpp_options *opts);
631int push_parse_file(cpp_reader * pfile, const char *fname);
632void cpp_finish(cpp_reader * pfile);
633int cpp_read_check_assertion(cpp_reader * pfile);
634
635void *xmalloc(unsigned size);
636void *xrealloc(void *old, unsigned size);
637void *xcalloc(unsigned number, unsigned size);
638
639#ifdef __EMX__
640#define PATH_SEPARATOR ';'
641#endif
diff --git a/libraries/edje/src/bin/epp/cppmain.c b/libraries/edje/src/bin/epp/cppmain.c
new file mode 100644
index 0000000..45b67b5
--- /dev/null
+++ b/libraries/edje/src/bin/epp/cppmain.c
@@ -0,0 +1,142 @@
1/* CPP main program, using CPP Library.
2 * Copyright (C) 1995 Free Software Foundation, Inc.
3 * Written by Per Bothner, 1994-95.
4 * Copyright (C) 2003-2011 Kim Woelders
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * In other words, you are welcome to use, share and improve this program.
21 * You are forbidden to forbid anyone else to use, share and improve
22 * what you give them. Help stamp out software-hoarding! */
23
24#ifdef HAVE_CONFIG_H
25# include <config.h>
26#endif
27
28#include <stdio.h>
29#include <string.h>
30#include <stdlib.h>
31
32#include "cpplib.h"
33
34#define EPP_DEBUG 0
35
36cpp_reader parse_in;
37cpp_options options;
38
39int
40main(int argc, char **argv)
41{
42 char *p;
43 int i;
44 int argi = 1; /* Next argument to handle. */
45 struct cpp_options *opts = &options;
46 enum cpp_token kind;
47 int got_text;
48
49 p = argv[0] + strlen(argv[0]);
50#ifndef __EMX__
51 while (p != argv[0] && p[-1] != '/')
52#else
53 while (p != argv[0] && p[-1] != '/' && p[-1] != '\\')
54#endif
55 --p;
56 progname = p;
57
58 init_parse_file(&parse_in);
59 parse_in.data = opts;
60
61 init_parse_options(opts);
62
63 argi += cpp_handle_options(&parse_in, argc - argi, argv + argi);
64 if (argi < argc)
65 cpp_fatal("Invalid option `%s'", argv[argi]);
66 parse_in.show_column = 1;
67
68 i = push_parse_file(&parse_in, opts->in_fname);
69 if (i != SUCCESS_EXIT_CODE)
70 return i;
71
72 /* Now that we know the input file is valid, open the output. */
73
74 if (!opts->out_fname || !strcmp(opts->out_fname, ""))
75 opts->out_fname = "stdout";
76 else if (!freopen(opts->out_fname, "w", stdout))
77 cpp_pfatal_with_name(&parse_in, opts->out_fname);
78
79 got_text = 0;
80 for (i = 0;; i++)
81 {
82 kind = cpp_get_token(&parse_in);
83#if EPP_DEBUG
84 fprintf(stderr, "%03d: kind=%d len=%d out=%d text=%d\n", i,
85 kind, CPP_WRITTEN(&parse_in), !opts->no_output, got_text);
86#endif
87 switch (kind)
88 {
89 case CPP_EOF:
90 goto done;
91
92 case CPP_HSPACE:
93 continue;
94
95 case CPP_VSPACE:
96 break;
97
98 default:
99 case CPP_OTHER:
100 case CPP_NAME:
101 case CPP_NUMBER:
102 case CPP_CHAR:
103 case CPP_STRING:
104 case CPP_LPAREN:
105 case CPP_RPAREN:
106 case CPP_LBRACE:
107 case CPP_RBRACE:
108 case CPP_COMMA:
109 case CPP_SEMICOLON:
110 case CPP_3DOTS:
111 got_text = 1;
112 continue;
113
114 case CPP_COMMENT:
115 case CPP_DIRECTIVE:
116 case CPP_POP:
117 continue;
118 }
119#if EPP_DEBUG
120 fprintf(stderr, "'");
121 fwrite(parse_in.token_buffer, 1, CPP_WRITTEN(&parse_in), stderr);
122 fprintf(stderr, "'\n");
123#endif
124 if (!opts->no_output)
125 {
126 size_t n;
127
128 n = CPP_WRITTEN(&parse_in);
129 if (fwrite(parse_in.token_buffer, 1, n, stdout) != n)
130 exit(FATAL_EXIT_CODE);
131 }
132 parse_in.limit = parse_in.token_buffer;
133 got_text = 0;
134 }
135
136 done:
137 cpp_finish(&parse_in);
138
139 if (parse_in.errors)
140 exit(FATAL_EXIT_CODE);
141 exit(SUCCESS_EXIT_CODE);
142}