From dd7595a3475407a7fa96a97393bae8c5220e8762 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Wed, 4 Jan 2012 18:41:13 +1000 Subject: 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. --- libraries/edje/src/bin/Makefile.am | 72 + libraries/edje/src/bin/Makefile.in | 1149 ++++ libraries/edje/src/bin/edje_cc.c | 250 + libraries/edje/src/bin/edje_cc.h | 226 + libraries/edje/src/bin/edje_cc_handlers.c | 7763 ++++++++++++++++++++++ libraries/edje/src/bin/edje_cc_mem.c | 40 + libraries/edje/src/bin/edje_cc_out.c | 1995 ++++++ libraries/edje/src/bin/edje_cc_parse.c | 1552 +++++ libraries/edje/src/bin/edje_cc_sources.c | 259 + libraries/edje/src/bin/edje_convert.c | 459 ++ libraries/edje/src/bin/edje_convert.h | 154 + libraries/edje/src/bin/edje_data_convert.c | 451 ++ libraries/edje/src/bin/edje_decc.c | 472 ++ libraries/edje/src/bin/edje_decc.h | 61 + libraries/edje/src/bin/edje_external_inspector.c | 663 ++ libraries/edje/src/bin/edje_inspector.c | 1639 +++++ libraries/edje/src/bin/edje_multisense_convert.c | 329 + libraries/edje/src/bin/edje_multisense_convert.h | 25 + libraries/edje/src/bin/edje_player.c | 795 +++ libraries/edje/src/bin/edje_recc | 69 + libraries/edje/src/bin/epp/Makefile.am | 59 + libraries/edje/src/bin/epp/Makefile.in | 756 +++ libraries/edje/src/bin/epp/cppalloc.c | 70 + libraries/edje/src/bin/epp/cpperror.c | 147 + libraries/edje/src/bin/epp/cppexp.c | 1090 +++ libraries/edje/src/bin/epp/cpphash.c | 198 + libraries/edje/src/bin/epp/cpphash.h | 41 + libraries/edje/src/bin/epp/cpplib.c | 7427 +++++++++++++++++++++ libraries/edje/src/bin/epp/cpplib.h | 641 ++ libraries/edje/src/bin/epp/cppmain.c | 142 + 30 files changed, 28994 insertions(+) create mode 100644 libraries/edje/src/bin/Makefile.am create mode 100644 libraries/edje/src/bin/Makefile.in create mode 100644 libraries/edje/src/bin/edje_cc.c create mode 100644 libraries/edje/src/bin/edje_cc.h create mode 100644 libraries/edje/src/bin/edje_cc_handlers.c create mode 100644 libraries/edje/src/bin/edje_cc_mem.c create mode 100644 libraries/edje/src/bin/edje_cc_out.c create mode 100644 libraries/edje/src/bin/edje_cc_parse.c create mode 100644 libraries/edje/src/bin/edje_cc_sources.c create mode 100644 libraries/edje/src/bin/edje_convert.c create mode 100644 libraries/edje/src/bin/edje_convert.h create mode 100644 libraries/edje/src/bin/edje_data_convert.c create mode 100644 libraries/edje/src/bin/edje_decc.c create mode 100644 libraries/edje/src/bin/edje_decc.h create mode 100644 libraries/edje/src/bin/edje_external_inspector.c create mode 100644 libraries/edje/src/bin/edje_inspector.c create mode 100644 libraries/edje/src/bin/edje_multisense_convert.c create mode 100644 libraries/edje/src/bin/edje_multisense_convert.h create mode 100644 libraries/edje/src/bin/edje_player.c create mode 100644 libraries/edje/src/bin/edje_recc create mode 100644 libraries/edje/src/bin/epp/Makefile.am create mode 100644 libraries/edje/src/bin/epp/Makefile.in create mode 100644 libraries/edje/src/bin/epp/cppalloc.c create mode 100644 libraries/edje/src/bin/epp/cpperror.c create mode 100644 libraries/edje/src/bin/epp/cppexp.c create mode 100644 libraries/edje/src/bin/epp/cpphash.c create mode 100644 libraries/edje/src/bin/epp/cpphash.h create mode 100644 libraries/edje/src/bin/epp/cpplib.c create mode 100644 libraries/edje/src/bin/epp/cpplib.h create mode 100644 libraries/edje/src/bin/epp/cppmain.c (limited to 'libraries/edje/src/bin') 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 @@ +MAINTAINERCLEANFILES = Makefile.in + +if BUILD_EPP + SUBDIRS = epp +endif + +bin_SCRIPTS = @EDJE_RECC_PRG@ + +bin_PROGRAMS = @EDJE_CC_PRG@ @EDJE_DECC_PRG@ @EDJE_PLAYER_PRG@ @EDJE_INSPECTOR_PRG@ @EDJE_EXTERNAL_INSPECTOR_PRG@ + +EXTRA_PROGRAMS = edje_cc edje_decc edje_player edje_inspector edje_external_inspector + +edje_cc_SOURCES = \ +edje_cc.c \ +edje_cc_out.c \ +edje_cc_parse.c \ +edje_cc_mem.c \ +edje_cc_handlers.c \ +edje_cc_sources.c \ +edje_multisense_convert.c + +edje_cc_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +-DPACKAGE_BIN_DIR=\"$(bindir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +-DEPP_DIR=\"$(libdir)/$(PACKAGE)/utils\" \ +@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EVIL_CFLAGS@ @SNDFILE_CFLAGS@ +edje_cc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_CC_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ -lm +edje_cc_LDFLAGS = @lt_enable_auto_import@ + + +edje_decc_SOURCES = \ +edje_decc.c \ +edje_decc.h \ +edje_cc_mem.c \ +edje_cc_sources.c + +edje_decc_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +@EDJE_CFLAGS@ @EDJE_DECC_CFLAGS@ @EVIL_CFLAGS@ +edje_decc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_DECC_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +edje_decc_LDFLAGS = @lt_enable_auto_import@ + +edje_player_SOURCES = edje_player.c +edje_player_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +@EDJE_PLAYER_CFLAGS@ @EVIL_CFLAGS@ +edje_player_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_PLAYER_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +edje_player_LDFLAGS = @lt_enable_auto_import@ + +edje_inspector_SOURCES = edje_inspector.c +edje_inspector_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +@EDJE_INSPECTOR_CFLAGS@ +edje_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ +edje_inspector_LDFLAGS = @lt_enable_auto_import@ + +edje_external_inspector_SOURCES = edje_external_inspector.c +edje_external_inspector_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +@EDJE_EXTERNAL_INSPECTOR_CFLAGS@ +edje_external_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_EXTERNAL_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +edje_external_inspector_LDFLAGS = @lt_enable_auto_import@ + +EXTRA_DIST = @EDJE_RECC_PRG@ edje_cc.h edje_convert.h edje_convert.c edje_multisense_convert.h edje_data_convert.c +EXTRA_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 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +EXTRA_PROGRAMS = edje_cc$(EXEEXT) edje_decc$(EXEEXT) \ + edje_player$(EXEEXT) edje_inspector$(EXEEXT) \ + edje_external_inspector$(EXEEXT) +subdir = src/bin +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \ + $(top_srcdir)/m4/efl_binary.m4 \ + $(top_srcdir)/m4/efl_coverage.m4 \ + $(top_srcdir)/m4/efl_doxygen.m4 \ + $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_edje_cc_OBJECTS = edje_cc-edje_cc.$(OBJEXT) \ + edje_cc-edje_cc_out.$(OBJEXT) edje_cc-edje_cc_parse.$(OBJEXT) \ + edje_cc-edje_cc_mem.$(OBJEXT) \ + edje_cc-edje_cc_handlers.$(OBJEXT) \ + edje_cc-edje_cc_sources.$(OBJEXT) \ + edje_cc-edje_multisense_convert.$(OBJEXT) +edje_cc_OBJECTS = $(am_edje_cc_OBJECTS) +edje_cc_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +edje_cc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(edje_cc_LDFLAGS) $(LDFLAGS) -o $@ +am_edje_decc_OBJECTS = edje_decc-edje_decc.$(OBJEXT) \ + edje_decc-edje_cc_mem.$(OBJEXT) \ + edje_decc-edje_cc_sources.$(OBJEXT) +edje_decc_OBJECTS = $(am_edje_decc_OBJECTS) +edje_decc_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la +edje_decc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(edje_decc_LDFLAGS) $(LDFLAGS) -o $@ +am_edje_external_inspector_OBJECTS = \ + edje_external_inspector-edje_external_inspector.$(OBJEXT) +edje_external_inspector_OBJECTS = \ + $(am_edje_external_inspector_OBJECTS) +edje_external_inspector_DEPENDENCIES = \ + $(top_builddir)/src/lib/libedje.la +edje_external_inspector_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(edje_external_inspector_LDFLAGS) \ + $(LDFLAGS) -o $@ +am_edje_inspector_OBJECTS = edje_inspector-edje_inspector.$(OBJEXT) +edje_inspector_OBJECTS = $(am_edje_inspector_OBJECTS) +edje_inspector_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la +edje_inspector_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(edje_inspector_LDFLAGS) $(LDFLAGS) -o \ + $@ +am_edje_player_OBJECTS = edje_player-edje_player.$(OBJEXT) +edje_player_OBJECTS = $(am_edje_player_OBJECTS) +edje_player_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la +edje_player_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(edje_player_LDFLAGS) $(LDFLAGS) -o $@ +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +SCRIPTS = $(bin_SCRIPTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(edje_cc_SOURCES) $(edje_decc_SOURCES) \ + $(edje_external_inspector_SOURCES) $(edje_inspector_SOURCES) \ + $(edje_player_SOURCES) +DIST_SOURCES = $(edje_cc_SOURCES) $(edje_decc_SOURCES) \ + $(edje_external_inspector_SOURCES) $(edje_inspector_SOURCES) \ + $(edje_player_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = epp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ECORE_IMF_CFLAGS = @ECORE_IMF_CFLAGS@ +ECORE_IMF_LIBS = @ECORE_IMF_LIBS@ +EDJE_CC_CFLAGS = @EDJE_CC_CFLAGS@ +EDJE_CC_LIBS = @EDJE_CC_LIBS@ +EDJE_CC_PRG = @EDJE_CC_PRG@ +EDJE_CFLAGS = @EDJE_CFLAGS@ +EDJE_DECC_CFLAGS = @EDJE_DECC_CFLAGS@ +EDJE_DECC_LIBS = @EDJE_DECC_LIBS@ +EDJE_DECC_PRG = @EDJE_DECC_PRG@ +EDJE_EXTERNAL_INSPECTOR_CFLAGS = @EDJE_EXTERNAL_INSPECTOR_CFLAGS@ +EDJE_EXTERNAL_INSPECTOR_LIBS = @EDJE_EXTERNAL_INSPECTOR_LIBS@ +EDJE_EXTERNAL_INSPECTOR_PRG = @EDJE_EXTERNAL_INSPECTOR_PRG@ +EDJE_INSPECTOR_CFLAGS = @EDJE_INSPECTOR_CFLAGS@ +EDJE_INSPECTOR_LIBS = @EDJE_INSPECTOR_LIBS@ +EDJE_INSPECTOR_PRG = @EDJE_INSPECTOR_PRG@ +EDJE_LIBS = @EDJE_LIBS@ +EDJE_PLAYER_CFLAGS = @EDJE_PLAYER_CFLAGS@ +EDJE_PLAYER_LIBS = @EDJE_PLAYER_LIBS@ +EDJE_PLAYER_PRG = @EDJE_PLAYER_PRG@ +EDJE_RECC_PRG = @EDJE_RECC_PRG@ +EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@ +EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@ +EFL_EDJE_BUILD = @EFL_EDJE_BUILD@ +EGREP = @EGREP@ +EVIL_CFLAGS = @EVIL_CFLAGS@ +EVIL_LIBS = @EVIL_LIBS@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FLAC_CFLAGS = @FLAC_CFLAGS@ +FLAC_LIBS = @FLAC_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LUA_CFLAGS = @LUA_CFLAGS@ +LUA_LIBS = @LUA_LIBS@ +MAKEINFO = @MAKEINFO@ +MINIMAL_CFLAGS = @MINIMAL_CFLAGS@ +MINIMAL_LIBS = @MINIMAL_LIBS@ +MKDIR_P = @MKDIR_P@ +MODULE_ARCH = @MODULE_ARCH@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +REMIX_CFLAGS = @REMIX_CFLAGS@ +REMIX_LIBS = @REMIX_LIBS@ +REMIX_PLUGIN_DIR = @REMIX_PLUGIN_DIR@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ +SNDFILE_LIBS = @SNDFILE_LIBS@ +STRIP = @STRIP@ +VERSION = @VERSION@ +VMAJ = @VMAJ@ +VORBISENC_CFLAGS = @VORBISENC_CFLAGS@ +VORBISENC_LIBS = @VORBISENC_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +edje_cc = @edje_cc@ +efl_doxygen = @efl_doxygen@ +efl_have_doxygen = @efl_have_doxygen@ +exec_prefix = @exec_prefix@ +have_lcov = @have_lcov@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +lt_enable_auto_import = @lt_enable_auto_import@ +lua_libs = @lua_libs@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfig_requires_private = @pkgconfig_requires_private@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +release_info = @release_info@ +requirement_edje = @requirement_edje@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +version_info = @version_info@ +vimdir = @vimdir@ +MAINTAINERCLEANFILES = Makefile.in +@BUILD_EPP_TRUE@SUBDIRS = epp +bin_SCRIPTS = @EDJE_RECC_PRG@ +bin_PROGRAMS = @EDJE_CC_PRG@ @EDJE_DECC_PRG@ @EDJE_PLAYER_PRG@ @EDJE_INSPECTOR_PRG@ @EDJE_EXTERNAL_INSPECTOR_PRG@ +edje_cc_SOURCES = \ +edje_cc.c \ +edje_cc_out.c \ +edje_cc_parse.c \ +edje_cc_mem.c \ +edje_cc_handlers.c \ +edje_cc_sources.c \ +edje_multisense_convert.c + +edje_cc_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +-DPACKAGE_BIN_DIR=\"$(bindir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +-DEPP_DIR=\"$(libdir)/$(PACKAGE)/utils\" \ +@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EVIL_CFLAGS@ @SNDFILE_CFLAGS@ + +edje_cc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_CC_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ -lm +edje_cc_LDFLAGS = @lt_enable_auto_import@ +edje_decc_SOURCES = \ +edje_decc.c \ +edje_decc.h \ +edje_cc_mem.c \ +edje_cc_sources.c + +edje_decc_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +@EDJE_CFLAGS@ @EDJE_DECC_CFLAGS@ @EVIL_CFLAGS@ + +edje_decc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_DECC_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +edje_decc_LDFLAGS = @lt_enable_auto_import@ +edje_player_SOURCES = edje_player.c +edje_player_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +@EDJE_PLAYER_CFLAGS@ @EVIL_CFLAGS@ + +edje_player_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_PLAYER_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +edje_player_LDFLAGS = @lt_enable_auto_import@ +edje_inspector_SOURCES = edje_inspector.c +edje_inspector_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +@EDJE_INSPECTOR_CFLAGS@ + +edje_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ +edje_inspector_LDFLAGS = @lt_enable_auto_import@ +edje_external_inspector_SOURCES = edje_external_inspector.c +edje_external_inspector_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +@EDJE_EXTERNAL_INSPECTOR_CFLAGS@ + +edje_external_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_EXTERNAL_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +edje_external_inspector_LDFLAGS = @lt_enable_auto_import@ +EXTRA_DIST = @EDJE_RECC_PRG@ edje_cc.h edje_convert.h edje_convert.c edje_multisense_convert.h edje_data_convert.c +EXTRA_SCRIPTS = edje_recc +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/bin/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/bin/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +edje_cc$(EXEEXT): $(edje_cc_OBJECTS) $(edje_cc_DEPENDENCIES) + @rm -f edje_cc$(EXEEXT) + $(AM_V_CCLD)$(edje_cc_LINK) $(edje_cc_OBJECTS) $(edje_cc_LDADD) $(LIBS) +edje_decc$(EXEEXT): $(edje_decc_OBJECTS) $(edje_decc_DEPENDENCIES) + @rm -f edje_decc$(EXEEXT) + $(AM_V_CCLD)$(edje_decc_LINK) $(edje_decc_OBJECTS) $(edje_decc_LDADD) $(LIBS) +edje_external_inspector$(EXEEXT): $(edje_external_inspector_OBJECTS) $(edje_external_inspector_DEPENDENCIES) + @rm -f edje_external_inspector$(EXEEXT) + $(AM_V_CCLD)$(edje_external_inspector_LINK) $(edje_external_inspector_OBJECTS) $(edje_external_inspector_LDADD) $(LIBS) +edje_inspector$(EXEEXT): $(edje_inspector_OBJECTS) $(edje_inspector_DEPENDENCIES) + @rm -f edje_inspector$(EXEEXT) + $(AM_V_CCLD)$(edje_inspector_LINK) $(edje_inspector_OBJECTS) $(edje_inspector_LDADD) $(LIBS) +edje_player$(EXEEXT): $(edje_player_OBJECTS) $(edje_player_DEPENDENCIES) + @rm -f edje_player$(EXEEXT) + $(AM_V_CCLD)$(edje_player_LINK) $(edje_player_OBJECTS) $(edje_player_LDADD) $(LIBS) +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_handlers.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_mem.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_out.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_parse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_cc_sources.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cc-edje_multisense_convert.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_decc-edje_cc_mem.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_decc-edje_cc_sources.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_decc-edje_decc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_external_inspector-edje_external_inspector.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_inspector-edje_inspector.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_player-edje_player.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +edje_cc-edje_cc.o: edje_cc.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc.Tpo $(DEPDIR)/edje_cc-edje_cc.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc.c' object='edje_cc-edje_cc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_cc-edje_cc.obj: edje_cc.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc.Tpo $(DEPDIR)/edje_cc-edje_cc.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc.c' object='edje_cc-edje_cc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_cc-edje_cc_out.o: edje_cc_out.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_out.Tpo $(DEPDIR)/edje_cc-edje_cc_out.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_out.c' object='edje_cc-edje_cc_out.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_cc-edje_cc_out.obj: edje_cc_out.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_out.Tpo $(DEPDIR)/edje_cc-edje_cc_out.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_out.c' object='edje_cc-edje_cc_out.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_cc-edje_cc_parse.o: edje_cc_parse.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_parse.Tpo $(DEPDIR)/edje_cc-edje_cc_parse.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_parse.c' object='edje_cc-edje_cc_parse.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_cc-edje_cc_parse.obj: edje_cc_parse.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_parse.Tpo $(DEPDIR)/edje_cc-edje_cc_parse.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_parse.c' object='edje_cc-edje_cc_parse.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_cc-edje_cc_mem.o: edje_cc_mem.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_mem.Tpo $(DEPDIR)/edje_cc-edje_cc_mem.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_mem.c' object='edje_cc-edje_cc_mem.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_cc-edje_cc_mem.obj: edje_cc_mem.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_mem.Tpo $(DEPDIR)/edje_cc-edje_cc_mem.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_mem.c' object='edje_cc-edje_cc_mem.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_cc-edje_cc_handlers.o: edje_cc_handlers.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_handlers.Tpo $(DEPDIR)/edje_cc-edje_cc_handlers.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_handlers.c' object='edje_cc-edje_cc_handlers.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_cc-edje_cc_handlers.obj: edje_cc_handlers.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_handlers.Tpo $(DEPDIR)/edje_cc-edje_cc_handlers.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_handlers.c' object='edje_cc-edje_cc_handlers.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_cc-edje_cc_sources.o: edje_cc_sources.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_sources.Tpo $(DEPDIR)/edje_cc-edje_cc_sources.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_sources.c' object='edje_cc-edje_cc_sources.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_cc-edje_cc_sources.obj: edje_cc_sources.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_cc_sources.Tpo $(DEPDIR)/edje_cc-edje_cc_sources.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_sources.c' object='edje_cc-edje_cc_sources.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_cc-edje_multisense_convert.o: edje_multisense_convert.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_multisense_convert.Tpo $(DEPDIR)/edje_cc-edje_multisense_convert.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_multisense_convert.c' object='edje_cc-edje_multisense_convert.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_cc-edje_multisense_convert.obj: edje_multisense_convert.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_cc-edje_multisense_convert.Tpo $(DEPDIR)/edje_cc-edje_multisense_convert.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_multisense_convert.c' object='edje_cc-edje_multisense_convert.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_decc-edje_decc.o: edje_decc.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_decc.Tpo $(DEPDIR)/edje_decc-edje_decc.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_decc.c' object='edje_decc-edje_decc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_decc-edje_decc.obj: edje_decc.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_decc.Tpo $(DEPDIR)/edje_decc-edje_decc.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_decc.c' object='edje_decc-edje_decc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_decc-edje_cc_mem.o: edje_cc_mem.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_cc_mem.Tpo $(DEPDIR)/edje_decc-edje_cc_mem.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_mem.c' object='edje_decc-edje_cc_mem.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_decc-edje_cc_mem.obj: edje_cc_mem.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_cc_mem.Tpo $(DEPDIR)/edje_decc-edje_cc_mem.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_mem.c' object='edje_decc-edje_cc_mem.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_decc-edje_cc_sources.o: edje_cc_sources.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_cc_sources.Tpo $(DEPDIR)/edje_decc-edje_cc_sources.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_sources.c' object='edje_decc-edje_cc_sources.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_decc-edje_cc_sources.obj: edje_cc_sources.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_decc-edje_cc_sources.Tpo $(DEPDIR)/edje_decc-edje_cc_sources.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_cc_sources.c' object='edje_decc-edje_cc_sources.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_external_inspector-edje_external_inspector.o: edje_external_inspector.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_external_inspector-edje_external_inspector.Tpo $(DEPDIR)/edje_external_inspector-edje_external_inspector.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_external_inspector.c' object='edje_external_inspector-edje_external_inspector.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_external_inspector-edje_external_inspector.obj: edje_external_inspector.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_external_inspector-edje_external_inspector.Tpo $(DEPDIR)/edje_external_inspector-edje_external_inspector.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_external_inspector.c' object='edje_external_inspector-edje_external_inspector.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_inspector-edje_inspector.o: edje_inspector.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_inspector-edje_inspector.Tpo $(DEPDIR)/edje_inspector-edje_inspector.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_inspector.c' object='edje_inspector-edje_inspector.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_inspector-edje_inspector.obj: edje_inspector.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_inspector-edje_inspector.Tpo $(DEPDIR)/edje_inspector-edje_inspector.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_inspector.c' object='edje_inspector-edje_inspector.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +edje_player-edje_player.o: edje_player.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_player-edje_player.Tpo $(DEPDIR)/edje_player-edje_player.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_player.c' object='edje_player-edje_player.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +edje_player-edje_player.obj: edje_player.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/edje_player-edje_player.Tpo $(DEPDIR)/edje_player-edje_player.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edje_player.c' object='edje_player-edje_player.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) $(SCRIPTS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-binSCRIPTS + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ + install-am install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-binSCRIPTS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-binSCRIPTS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.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 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include + +#include "edje_cc.h" +int _edje_cc_log_dom = -1; +static void main_help(void); + +Eina_Prefix *pfx = NULL; +Eina_List *snd_dirs = NULL; +Eina_List *img_dirs = NULL; +Eina_List *fnt_dirs = NULL; +Eina_List *defines = NULL; +char *file_in = NULL; +char *tmp_dir = NULL; +char *file_out = NULL; +char *progname = NULL; +int verbose = 0; + +int no_lossy = 0; +int no_comp = 0; +int no_raw = 0; +int no_save = 0; +int min_quality = 0; +int max_quality = 100; + +static void +main_help(void) +{ + printf + ("Usage:\n" + "\t%s [OPTIONS] input_file.edc [output_file.edj]\n" + "\n" + "Where OPTIONS is one or more of:\n" + "\n" + "-id image/directory Add a directory to look in for relative path images\n" + "-fd font/directory Add a directory to look in for relative path fonts\n" + "-sd sound/directory Add a directory to look in for relative path sounds samples\n" + "-td temp/directory Directory to store temporary files\n" + "-v Verbose output\n" + "-no-lossy Do NOT allow images to be lossy\n" + "-no-comp Do NOT allow images to be stored with lossless compression\n" + "-no-raw Do NOT allow images to be stored with zero compression (raw)\n" + "-no-save Do NOT store the input EDC file in the EDJ file\n" + "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n" + "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n" + "-Ddefine_val=to CPP style define to define input macro definitions to the .edc source\n" + ,progname); +} + +int +main(int argc, char **argv) +{ + int i; + struct stat st; + char rpath[PATH_MAX], rpath2[PATH_MAX]; + + setlocale(LC_NUMERIC, "C"); + + if (!eina_init()) + return -1; + + _edje_cc_log_dom = eina_log_domain_register + ("edje_cc", EDJE_CC_DEFAULT_LOG_COLOR); + if (_edje_cc_log_dom < 0) + { + EINA_LOG_ERR("Enable to create a log domain."); + exit(-1); + } + tmp_dir = getenv("TMPDIR"); + + img_dirs = eina_list_append(img_dirs, "."); + + progname = argv[0]; + for (i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "-h")) + { + main_help(); + exit(0); + } + else if (!strcmp(argv[i], "-v")) + { + verbose = 1; + } + else if (!strcmp(argv[i], "-no-lossy")) + { + no_lossy = 1; + } + else if (!strcmp(argv[i], "-no-comp")) + { + no_comp = 1; + } + else if (!strcmp(argv[i], "-no-raw")) + { + no_raw = 1; + } + else if (!strcmp(argv[i], "-no-save")) + { + no_save = 1; + } + else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1))) + { + i++; + img_dirs = eina_list_append(img_dirs, argv[i]); + } + else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1))) + { + i++; + fnt_dirs = eina_list_append(fnt_dirs, argv[i]); + } + else if ((!strcmp(argv[i], "-sd") || !strcmp(argv[i], "--sound_dir")) && (i < (argc - 1))) + { + i++; + snd_dirs = eina_list_append(snd_dirs, argv[i]); + } + else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1))) + { + i++; + if (!tmp_dir) + tmp_dir = argv[i]; + } + else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1))) + { + i++; + min_quality = atoi(argv[i]); + if (min_quality < 0) min_quality = 0; + if (min_quality > 100) min_quality = 100; + } + else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1))) + { + i++; + max_quality = atoi(argv[i]); + if (max_quality < 0) max_quality = 0; + if (max_quality > 100) max_quality = 100; + } + else if (!strncmp(argv[i], "-D", 2)) + { + defines = eina_list_append(defines, mem_strdup(argv[i])); + } + else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1))) + { + i++; + file_out = argv[i]; + } + else if (!file_in) + file_in = argv[i]; + else if (!file_out) + file_out = argv[i]; + } + if (!file_in) + { + fprintf(stderr, "%s: Error: no input file specified.\n", progname); + main_help(); + exit(-1); + } + + pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */ + main, /* an optional symbol to check path of */ + "EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */ + "edje", /* dir to add after "share" (PREFIX/share/DIRNAME) */ + "include/edje.inc", /* a magic file to check for in PREFIX/share/DIRNAME for success */ + PACKAGE_BIN_DIR, /* package bin dir @ compile time */ + PACKAGE_LIB_DIR, /* package lib dir @ compile time */ + PACKAGE_DATA_DIR, /* package data dir @ compile time */ + PACKAGE_DATA_DIR /* if locale needed use LOCALE_DIR */ + ); + + /* check whether file_in exists */ +#ifdef HAVE_REALPATH + if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode)) +#else + if (stat(file_in, &st) || !S_ISREG(st.st_mode)) +#endif + { + fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in); + main_help(); + exit(-1); + } + + if (!file_out) + { + char *suffix; + + if ((suffix = strstr(file_in,".edc")) && (suffix[4] == 0)) + { + file_out = strdup(file_in); + if (file_out) + { + suffix = strstr(file_out,".edc"); + strcpy(suffix,".edj"); + } + } + } + if (!file_out) + { + fprintf(stderr, "%s: Error: no output file specified.\n", progname); + main_help(); + exit(-1); + } + +#ifdef HAVE_REALPATH + if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2)) +#else + if (!strcmp (file_in, file_out)) +#endif + { + fprintf(stderr, "%s: Error: input file equals output file.\n", progname); + main_help(); + exit(-1); + } + + if (!edje_init()) + exit(-1); + + edje_file = mem_alloc(SZ(Edje_File)); + edje_file->compiler = strdup("edje_cc"); + edje_file->version = EDJE_FILE_VERSION; + edje_file->minor = EDJE_FILE_MINOR; + edje_file->feature_ver = 1; /* increment this every time we add a field + * or feature to the edje file format that + * does not load nicely as a NULL or 0 value + * and needs a special fallback initialization + */ + + source_edd(); + source_fetch(); + + data_setup(); + compile(); + reorder_parts(); + data_process_scripts(); + data_process_lookups(); + data_process_script_lookups(); + data_write(); + + eina_prefix_free(pfx); + pfx = NULL; + + edje_shutdown(); + eina_log_domain_unregister(_edje_cc_log_dom); + eina_shutdown(); + + return 0; +} 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 @@ +#ifndef EDJE_CC_H +#define EDJE_CC_H + +#include + +extern Eina_Prefix *pfx; + +/* + * On Windows, if the file is not opened in binary mode, + * read does not return the correct size, because of + * CR / LF translation. + */ +#ifndef O_BINARY +# define O_BINARY 0 +#endif + +/* logging variables */ +extern int _edje_cc_log_dom ; +#define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN +#ifdef ERR +# undef ERR +#endif +#define ERR(...) EINA_LOG_DOM_ERR(_edje_cc_log_dom, __VA_ARGS__) +#ifdef INF +# undef INF +#endif +#define INF(...) EINA_LOG_DOM_INFO(_edje_cc_log_dom, __VA_ARGS__) +#ifdef WRN +# undef WRN +#endif +#define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__) + + +/* types */ +typedef struct _New_Object_Handler New_Object_Handler; +typedef struct _New_Statement_Handler New_Statement_Handler; +typedef struct _External_List External_List; +typedef struct _External External; +typedef struct _Font_List Font_List; +typedef struct _Font Font; +typedef struct _Code Code; +typedef struct _Code_Program Code_Program; +typedef struct _SrcFile SrcFile; +typedef struct _SrcFile_List SrcFile_List; + +typedef struct _Edje_Program_Parser Edje_Program_Parser; +typedef struct _Edje_Pack_Element_Parser Edje_Pack_Element_Parser; +typedef struct _Edje_Part_Parser Edje_Part_Parser; + +struct _New_Object_Handler +{ + const char *type; + void (*func)(void); +}; + +struct _New_Statement_Handler +{ + const char *type; + void (*func)(void); +}; + +struct _External_List +{ + Eina_List *list; +}; + +struct _External +{ + char *name; +}; + +struct _Font_List +{ + Eina_List *list; +}; + +struct _Font +{ + char *name; + char *file; +}; + +struct _Code +{ + int l1, l2; + char *shared; + char *original; + Eina_List *programs; + int is_lua; +}; + +struct _Code_Program +{ + int l1, l2; + int id; + char *script; + char *original; +}; + +struct _SrcFile +{ + char *name; + char *file; +}; + +struct _SrcFile_List +{ + Eina_List *list; +}; + +struct _Edje_Program_Parser +{ + Edje_Program common; + Eina_Bool can_override; +}; + +struct _Edje_Pack_Element_Parser +{ + Edje_Pack_Element common; + Eina_Bool can_override; +}; + +struct _Edje_Part_Parser +{ + Edje_Part common; + struct { + Eina_Bool done; + const char *insert_before; /* the part name for insertion in front of */ + const char *insert_after; /* the part name for insertion behind of */ + Edje_Part_Parser *before; + Edje_Part_Parser *after; + int linked_prev; /* the number linked previous part for reorder */ + int linked_next; /* the number linked next part for reorder */ + } reorder; + Eina_Bool can_override; +}; + +/* global fn calls */ +void data_setup(void); +void data_write(void); +void data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest); +void data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest); +void data_queue_program_lookup(Edje_Part_Collection *pc, const char *name, int *dest); +void data_queue_copied_program_lookup(Edje_Part_Collection *pc, int *src, int *dest); +void data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest); +void data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest); +void data_queue_image_lookup(char *name, int *dest, Eina_Bool *set); +void data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set); +void data_queue_part_slave_lookup(int *master, int *slave); +void data_queue_image_slave_lookup(int *master, int *slave); +void data_queue_spectrum_lookup(char *name, int *dest); +void data_queue_spectrum_slave_lookup(int *master, int *slave); +void data_process_lookups(void); +void data_process_scripts(void); +void data_process_script_lookups(void); + + +int is_verbatim(void); +void track_verbatim(int on); +void set_verbatim(char *s, int l1, int l2); +char *get_verbatim(void); +int get_verbatim_line1(void); +int get_verbatim_line2(void); +void compile(void); +int is_param(int n); +int is_num(int n); +char *parse_str(int n); +int parse_enum(int n, ...); +int parse_flags(int n, ...); +int parse_int(int n); +int parse_int_range(int n, int f, int t); +int parse_bool(int n); +double parse_float(int n); +double parse_float_range(int n, double f, double t); +int get_arg_count(void); +void check_arg_count(int n); +void check_min_arg_count(int n); + +int object_handler_num(void); +int statement_handler_num(void); + +void reorder_parts(void); +void source_edd(void); +void source_fetch(void); +int source_append(Eet_File *ef); +SrcFile_List *source_load(Eet_File *ef); +int source_fontmap_save(Eet_File *ef, Eina_List *fonts); +Font_List *source_fontmap_load(Eet_File *ef); + +void *mem_alloc(size_t size); +char *mem_strdup(const char *s); +#define SZ sizeof + +void error_and_abort(Eet_File *ef, const char *fmt, ...); + +/* global vars */ +extern Eina_List *ext_dirs; +extern Eina_List *img_dirs; +extern Eina_List *fnt_dirs; +extern Eina_List *snd_dirs; +extern char *file_in; +extern char *tmp_dir; +extern char *file_out; +extern char *progname; +extern int verbose; +extern int no_lossy; +extern int no_comp; +extern int no_raw; +extern int no_save; +extern int min_quality; +extern int max_quality; +extern int line; +extern Eina_List *stack; +extern Eina_List *params; +extern Edje_File *edje_file; +extern Eina_List *edje_collections; +extern Eina_List *externals; +extern Eina_List *fonts; +extern Eina_List *codes; +extern Eina_List *defines; +extern Eina_List *aliases; +extern New_Object_Handler object_handlers[]; +extern New_Statement_Handler statement_handlers[]; + + +#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 @@ +/* + Concerning the EDC reference: + + The formatting for blocks and properties has been implemented as a table + which is filled using ALIASES. + For maximum flexibility I implemented them in the \@code/\@encode style, + this means that missing one or changing the order most certainly cause + formatting errors. + + \@block + block name + \@context + code sample of the block + \@description + the block's description + \@endblock + + \@property + property name + \@parameters + property's parameter list + \@effect + the property description (lol) + \@endproperty +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + +#include "edje_cc.h" + +/** + * @page edcref Edje Data Collection reference + * An Edje Data Collection, it's a plain text file (normally identified with the + * .edc extension),consisting of instructions for the Edje Compiler. + * + * The syntax for the edje data collection files follows a simple structure of + * "blocks { .. }" that can contain "properties: ..", more blocks, or both. + * + * @anchor sec_quickaccess Quick access to block descriptions: + *
    + *
  • @ref sec_toplevel "Top-Level"
  • + *
  • @ref sec_group "Group"
  • + *
  • @ref sec_description "State description"
  • + *
      + *
    • @ref sec_description_image "Image"
    • + *
    • @ref sec_description_text "Text"
    • + *
    • @ref sec_description_box "Box"
    • + *
    • @ref sec_description_table "Table"
    • + *
    • @ref sec_description_map "Map (3d/transformations)"
    • + *
    + *
  • @ref sec_program "Program block"
  • + *
+ * + * @author Andres Blanc (dresb) andresblanc@gmail.com + * + * + */ + +static Edje_Part_Collection_Directory_Entry *current_de = NULL; +static Edje_Part *current_part = NULL; +static Edje_Pack_Element *current_item = NULL; +static Edje_Part_Description_Common *current_desc = NULL; +static Edje_Part_Description_Common *parent_desc = NULL; +static Edje_Program *current_program = NULL; + +static void st_externals_external(void); + +static void st_images_image(void); +static void ob_images_set(void); +static void st_images_set_name(void); +static void ob_images_set_image(void); +static void st_images_set_image_image(void); +static void st_images_set_image_size(void); + +static void st_fonts_font(void); + +static void st_data_item(void); +static void st_data_file(void); + +static void ob_styles_style(void); +static void st_styles_style_name(void); +static void st_styles_style_base(void); +static void st_styles_style_tag(void); + +static void ob_color_class(void); +static void st_color_class_name(void); +static void st_color_class_color(void); +static void st_color_class_color2(void); +static void st_color_class_color3(void); + +static void ob_collections(void); + +static void ob_collections_group(void); +static void st_collections_group_name(void); +static void st_collections_group_inherit(void); +static void st_collections_group_script_only(void); +static void st_collections_group_alias(void); +static void st_collections_group_min(void); +static void st_collections_group_max(void); +static void st_collections_group_data_item(void); +static void st_collections_group_orientation(void); + +static void st_collections_group_limits_vertical(void); +static void st_collections_group_limits_horizontal(void); + +static void ob_collections_group_script(void); +static void ob_collections_group_lua_script(void); + +static void st_collections_group_parts_alias(void); + +static void ob_collections_group_parts_part(void); +static void st_collections_group_parts_part_name(void); +static void st_collections_group_parts_part_type(void); +static void st_collections_group_parts_part_insert_before(void); +static void st_collections_group_parts_part_insert_after(void); +static void st_collections_group_parts_part_effect(void); +static void st_collections_group_parts_part_mouse_events(void); +static void st_collections_group_parts_part_repeat_events(void); +static void st_collections_group_parts_part_ignore_flags(void); +static void st_collections_group_parts_part_scale(void); +static void st_collections_group_parts_part_pointer_mode(void); +static void st_collections_group_parts_part_precise_is_inside(void); +static void st_collections_group_parts_part_use_alternate_font_metrics(void); +static void st_collections_group_parts_part_clip_to_id(void); +static void st_collections_group_parts_part_source(void); +static void st_collections_group_parts_part_source2(void); +static void st_collections_group_parts_part_source3(void); +static void st_collections_group_parts_part_source4(void); +static void st_collections_group_parts_part_source5(void); +static void st_collections_group_parts_part_source6(void); +static void st_collections_group_parts_part_entry_mode(void); +static void st_collections_group_parts_part_select_mode(void); +static void st_collections_group_parts_part_cursor_mode(void); +static void st_collections_group_parts_part_multiline(void); +static void st_collections_group_parts_part_dragable_x(void); +static void st_collections_group_parts_part_dragable_y(void); +static void st_collections_group_parts_part_dragable_confine(void); +static void st_collections_group_parts_part_dragable_events(void); + +/* box and table items share these */ +static void ob_collections_group_parts_part_box_items_item(void); +static void st_collections_group_parts_part_box_items_item_type(void); +static void st_collections_group_parts_part_box_items_item_name(void); +static void st_collections_group_parts_part_box_items_item_source(void); +static void st_collections_group_parts_part_box_items_item_min(void); +static void st_collections_group_parts_part_box_items_item_prefer(void); +static void st_collections_group_parts_part_box_items_item_max(void); +static void st_collections_group_parts_part_box_items_item_padding(void); +static void st_collections_group_parts_part_box_items_item_align(void); +static void st_collections_group_parts_part_box_items_item_weight(void); +static void st_collections_group_parts_part_box_items_item_aspect(void); +static void st_collections_group_parts_part_box_items_item_aspect_mode(void); +static void st_collections_group_parts_part_box_items_item_options(void); +/* but these are only for table */ +static void st_collections_group_parts_part_table_items_item_position(void); +static void st_collections_group_parts_part_table_items_item_span(void); + +static void ob_collections_group_parts_part_description(void); +static void st_collections_group_parts_part_description_inherit(void); +static void st_collections_group_parts_part_description_source(void); +static void st_collections_group_parts_part_description_state(void); +static void st_collections_group_parts_part_description_visible(void); +static void st_collections_group_parts_part_description_align(void); +static void st_collections_group_parts_part_description_fixed(void); +static void st_collections_group_parts_part_description_min(void); +static void st_collections_group_parts_part_description_max(void); +static void st_collections_group_parts_part_description_step(void); +static void st_collections_group_parts_part_description_aspect(void); +static void st_collections_group_parts_part_description_aspect_preference(void); +static void st_collections_group_parts_part_description_rel1_relative(void); +static void st_collections_group_parts_part_description_rel1_offset(void); +static void st_collections_group_parts_part_description_rel1_to(void); +static void st_collections_group_parts_part_description_rel1_to_x(void); +static void st_collections_group_parts_part_description_rel1_to_y(void); +static void st_collections_group_parts_part_description_rel2_relative(void); +static void st_collections_group_parts_part_description_rel2_offset(void); +static void st_collections_group_parts_part_description_rel2_to(void); +static void st_collections_group_parts_part_description_rel2_to_x(void); +static void st_collections_group_parts_part_description_rel2_to_y(void); +static void st_collections_group_parts_part_description_image_normal(void); +static void st_collections_group_parts_part_description_image_tween(void); +static void st_collections_group_parts_part_description_image_border(void); +static void st_collections_group_parts_part_description_image_middle(void); +static void st_collections_group_parts_part_description_image_border_scale(void); +static void st_collections_group_parts_part_description_image_border_scale_by(void); +static void st_collections_group_parts_part_description_image_scale_hint(void); +static void st_collections_group_parts_part_description_fill_smooth(void); +static void st_collections_group_parts_part_description_fill_origin_relative(void); +static void st_collections_group_parts_part_description_fill_origin_offset(void); +static void st_collections_group_parts_part_description_fill_size_relative(void); +static void st_collections_group_parts_part_description_fill_size_offset(void); +static void st_collections_group_parts_part_description_fill_spread(void); +static void st_collections_group_parts_part_description_fill_type(void); +static void st_collections_group_parts_part_description_color_class(void); +static void st_collections_group_parts_part_description_color(void); +static void st_collections_group_parts_part_description_color2(void); +static void st_collections_group_parts_part_description_color3(void); +static void st_collections_group_parts_part_description_text_text(void); +static void st_collections_group_parts_part_description_text_text_class(void); +static void st_collections_group_parts_part_description_text_font(void); +static void st_collections_group_parts_part_description_text_style(void); +static void st_collections_group_parts_part_description_text_repch(void); +static void st_collections_group_parts_part_description_text_size(void); +static void st_collections_group_parts_part_description_text_size_range(void); +static void st_collections_group_parts_part_description_text_fit(void); +static void st_collections_group_parts_part_description_text_min(void); +static void st_collections_group_parts_part_description_text_max(void); +static void st_collections_group_parts_part_description_text_align(void); +static void st_collections_group_parts_part_description_text_source(void); +static void st_collections_group_parts_part_description_text_text_source(void); +static void st_collections_group_parts_part_description_text_elipsis(void); +static void st_collections_group_parts_part_description_box_layout(void); +static void st_collections_group_parts_part_description_box_align(void); +static void st_collections_group_parts_part_description_box_padding(void); +static void st_collections_group_parts_part_description_box_min(void); +static void st_collections_group_parts_part_description_table_homogeneous(void); +static void st_collections_group_parts_part_description_table_align(void); +static void st_collections_group_parts_part_description_table_padding(void); +static void st_collections_group_parts_part_description_table_min(void); +static void st_collections_group_parts_part_description_map_perspective(void); +static void st_collections_group_parts_part_description_map_light(void); +static void st_collections_group_parts_part_description_map_rotation_center(void); +static void st_collections_group_parts_part_description_map_rotation_x(void); +static void st_collections_group_parts_part_description_map_rotation_y(void); +static void st_collections_group_parts_part_description_map_rotation_z(void); +static void st_collections_group_parts_part_description_map_on(void); +static void st_collections_group_parts_part_description_map_smooth(void); +static void st_collections_group_parts_part_description_map_alpha(void); +static void st_collections_group_parts_part_description_map_backface_cull(void); +static void st_collections_group_parts_part_description_map_perspective_on(void); +static void st_collections_group_parts_part_description_perspective_zplane(void); +static void st_collections_group_parts_part_description_perspective_focal(void); +static void st_collections_group_parts_part_api(void); + +/* external part parameters */ +static void st_collections_group_parts_part_description_params_int(void); +static void ob_collections_group_programs_program(void); +static void st_collections_group_parts_part_description_params_double(void); + +static void st_collections_group_programs_program_name(void); +static void st_collections_group_parts_part_description_params_string(void); +static void st_collections_group_parts_part_description_params_bool(void); +static void st_collections_group_parts_part_description_params_choice(void); +static void st_collections_group_programs_program_signal(void); +static void st_collections_group_programs_program_source(void); +static void st_collections_group_programs_program_filter(void); +static void st_collections_group_programs_program_in(void); +static void st_collections_group_programs_program_action(void); +static void st_collections_group_programs_program_transition(void); +static void st_collections_group_programs_program_target(void); +static void st_collections_group_programs_program_after(void); +static void st_collections_group_programs_program_api(void); + +static void ob_collections_group_programs_program_script(void); + +#ifdef ENABLE_MULTISENSE +static void st_collections_group_sound_sample_name(void); +static void st_collections_group_sound_sample_source(void); +static void st_collections_group_sound_tone(void); +#endif + +/*****/ + +New_Statement_Handler statement_handlers[] = +{ + {"externals.external", st_externals_external}, + {"images.image", st_images_image}, + {"images.set.name", st_images_set_name}, + {"images.set.image.image", st_images_set_image_image}, + {"images.set.image.size", st_images_set_image_size}, + {"fonts.font", st_fonts_font}, + {"data.item", st_data_item}, + {"data.file", st_data_file}, + {"styles.style.name", st_styles_style_name}, + {"styles.style.base", st_styles_style_base}, + {"styles.style.tag", st_styles_style_tag}, + {"color_classes.color_class.name", st_color_class_name}, + {"color_classes.color_class.color", st_color_class_color}, + {"color_classes.color_class.color2", st_color_class_color2}, + {"color_classes.color_class.color3", st_color_class_color3}, + {"collections.externals.external", st_externals_external}, /* dup */ + {"collections.image", st_images_image}, /* dup */ + {"collections.set.name", st_images_set_name}, /* dup */ + {"collections.set.image.image", st_images_set_image_image}, /* dup */ + {"collections.set.image.size", st_images_set_image_size}, /* dup */ + {"collections.images.image", st_images_image}, /* dup */ + {"collections.images.set.name", st_images_set_name}, /* dup */ + {"collections.images.set.image.image", st_images_set_image_image}, /* dup */ + {"collections.images.set.image.size", st_images_set_image_size}, /* dup */ + {"collections.font", st_fonts_font}, /* dup */ + {"collections.fonts.font", st_fonts_font}, /* dup */ + {"collections.styles.style.name", st_styles_style_name}, /* dup */ + {"collections.styles.style.base", st_styles_style_base}, /* dup */ + {"collections.styles.style.tag", st_styles_style_tag}, /* dup */ + {"collections.color_classes.color_class.name", st_color_class_name}, /* dup */ + {"collections.color_classes.color_class.color", st_color_class_color}, /* dup */ + {"collections.color_classes.color_class.color2", st_color_class_color2}, /* dup */ + {"collections.color_classes.color_class.color3", st_color_class_color3}, /* dup */ +#ifdef ENABLE_MULTISENSE + {"collections.sounds.sample.name", st_collections_group_sound_sample_name}, + {"collections.sounds.sample.source", st_collections_group_sound_sample_source}, + {"collections.group.sounds.sample.name", st_collections_group_sound_sample_name}, /* dup */ + {"collections.group.sounds.sample.source", st_collections_group_sound_sample_source}, /* dup */ + {"collections.sounds.tone", st_collections_group_sound_tone}, + {"collections.group.sounds.tone", st_collections_group_sound_tone}, /* dup */ +#endif + {"collections.group.name", st_collections_group_name}, + {"collections.group.inherit", st_collections_group_inherit}, + {"collections.group.script_only", st_collections_group_script_only}, + {"collections.group.lua_script_only", st_collections_group_script_only}, + {"collections.group.alias", st_collections_group_alias}, + {"collections.group.min", st_collections_group_min}, + {"collections.group.max", st_collections_group_max}, + {"collections.group.orientation", st_collections_group_orientation}, + {"collections.group.data.item", st_collections_group_data_item}, + {"collections.group.limits.horizontal", st_collections_group_limits_horizontal}, + {"collections.group.limits.vertical", st_collections_group_limits_vertical}, + {"collections.group.externals.external", st_externals_external}, /* dup */ + {"collections.group.image", st_images_image}, /* dup */ + {"collections.group.set.name", st_images_set_name}, + {"collections.group.set.image.image", st_images_set_image_image}, + {"collections.group.set.image.size", st_images_set_image_size}, + {"collections.group.images.image", st_images_image}, /* dup */ + {"collections.group.images.set.name", st_images_set_name}, + {"collections.group.images.set.image.image", st_images_set_image_image}, + {"collections.group.images.set.image.size", st_images_set_image_size}, + {"collections.group.font", st_fonts_font}, /* dup */ + {"collections.group.fonts.font", st_fonts_font}, /* dup */ + {"collections.group.styles.style.name", st_styles_style_name}, /* dup */ + {"collections.group.styles.style.base", st_styles_style_base}, /* dup */ + {"collections.group.styles.style.tag", st_styles_style_tag}, /* dup */ + {"collections.group.color_classes.color_class.name", st_color_class_name}, /* dup */ + {"collections.group.color_classes.color_class.color", st_color_class_color}, /* dup */ + {"collections.group.color_classes.color_class.color2", st_color_class_color2}, /* dup */ + {"collections.group.color_classes.color_class.color3", st_color_class_color3}, /* dup */ + {"collections.group.parts.alias", st_collections_group_parts_alias }, + {"collections.group.parts.image", st_images_image}, /* dup */ + {"collections.group.parts.set.name", st_images_set_name}, + {"collections.group.parts.set.image.image", st_images_set_image_image}, + {"collections.group.parts.set.image.size", st_images_set_image_size}, + {"collections.group.parts.images.image", st_images_image}, /* dup */ + {"collections.group.parts.images.set.name", st_images_set_name}, + {"collections.group.parts.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.images.set.image.size", st_images_set_image_size}, + {"collections.group.parts.font", st_fonts_font}, /* dup */ + {"collections.group.parts.fonts.font", st_fonts_font}, /* dup */ + {"collections.group.parts.styles.style.name", st_styles_style_name}, /* dup */ + {"collections.group.parts.styles.style.base", st_styles_style_base}, /* dup */ + {"collections.group.parts.styles.style.tag", st_styles_style_tag}, /* dup */ + {"collections.group.parts.color_classes.color_class.name", st_color_class_name}, /* dup */ + {"collections.group.parts.color_classes.color_class.color", st_color_class_color}, /* dup */ + {"collections.group.parts.color_classes.color_class.color2", st_color_class_color2}, /* dup */ + {"collections.group.parts.color_classes.color_class.color3", st_color_class_color3}, /* dup */ + {"collections.group.parts.part.name", st_collections_group_parts_part_name}, + {"collections.group.parts.part.api", st_collections_group_parts_part_api}, + {"collections.group.parts.part.type", st_collections_group_parts_part_type}, + {"collections.group.parts.part.insert_before", st_collections_group_parts_part_insert_before}, + {"collections.group.parts.part.insert_after", st_collections_group_parts_part_insert_after}, + {"collections.group.parts.part.effect", st_collections_group_parts_part_effect}, + {"collections.group.parts.part.mouse_events", st_collections_group_parts_part_mouse_events}, + {"collections.group.parts.part.repeat_events", st_collections_group_parts_part_repeat_events}, + {"collections.group.parts.part.ignore_flags", st_collections_group_parts_part_ignore_flags}, + {"collections.group.parts.part.scale", st_collections_group_parts_part_scale}, + {"collections.group.parts.part.pointer_mode", st_collections_group_parts_part_pointer_mode}, + {"collections.group.parts.part.precise_is_inside", st_collections_group_parts_part_precise_is_inside}, + {"collections.group.parts.part.use_alternate_font_metrics", st_collections_group_parts_part_use_alternate_font_metrics}, + {"collections.group.parts.part.clip_to", st_collections_group_parts_part_clip_to_id}, + {"collections.group.parts.part.source", st_collections_group_parts_part_source}, + {"collections.group.parts.part.source2", st_collections_group_parts_part_source2}, + {"collections.group.parts.part.source3", st_collections_group_parts_part_source3}, + {"collections.group.parts.part.source4", st_collections_group_parts_part_source4}, + {"collections.group.parts.part.source5", st_collections_group_parts_part_source5}, + {"collections.group.parts.part.source6", st_collections_group_parts_part_source6}, + {"collections.group.parts.part.dragable.x", st_collections_group_parts_part_dragable_x}, + {"collections.group.parts.part.dragable.y", st_collections_group_parts_part_dragable_y}, + {"collections.group.parts.part.dragable.confine", st_collections_group_parts_part_dragable_confine}, + {"collections.group.parts.part.dragable.events", st_collections_group_parts_part_dragable_events}, + {"collections.group.parts.part.entry_mode", st_collections_group_parts_part_entry_mode}, + {"collections.group.parts.part.select_mode", st_collections_group_parts_part_select_mode}, + {"collections.group.parts.part.cursor_mode", st_collections_group_parts_part_cursor_mode}, + {"collections.group.parts.part.multiline", st_collections_group_parts_part_multiline}, + {"collections.group.parts.part.image", st_images_image}, /* dup */ + {"collections.group.parts.part.set.name", st_images_set_name}, + {"collections.group.parts.part.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.images.set.name", st_images_set_name}, + {"collections.group.parts.part.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.images.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.fonts.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.styles.style.name", st_styles_style_name}, /* dup */ + {"collections.group.parts.part.styles.style.base", st_styles_style_base}, /* dup */ + {"collections.group.parts.part.styles.style.tag", st_styles_style_tag}, /* dup */ + {"collections.group.parts.part.color_classes.color_class.name", st_color_class_name}, /* dup */ + {"collections.group.parts.part.color_classes.color_class.color", st_color_class_color}, /* dup */ + {"collections.group.parts.part.color_classes.color_class.color2", st_color_class_color2}, /* dup */ + {"collections.group.parts.part.color_classes.color_class.color3", st_color_class_color3}, /* dup */ + {"collections.group.parts.part.box.items.item.type", st_collections_group_parts_part_box_items_item_type}, + {"collections.group.parts.part.box.items.item.name", st_collections_group_parts_part_box_items_item_name}, + {"collections.group.parts.part.box.items.item.source", st_collections_group_parts_part_box_items_item_source}, + {"collections.group.parts.part.box.items.item.min", st_collections_group_parts_part_box_items_item_min}, + {"collections.group.parts.part.box.items.item.prefer", st_collections_group_parts_part_box_items_item_prefer}, + {"collections.group.parts.part.box.items.item.max", st_collections_group_parts_part_box_items_item_max}, + {"collections.group.parts.part.box.items.item.padding", st_collections_group_parts_part_box_items_item_padding}, + {"collections.group.parts.part.box.items.item.align", st_collections_group_parts_part_box_items_item_align}, + {"collections.group.parts.part.box.items.item.weight", st_collections_group_parts_part_box_items_item_weight}, + {"collections.group.parts.part.box.items.item.aspect", st_collections_group_parts_part_box_items_item_aspect}, + {"collections.group.parts.part.box.items.item.aspect_mode", st_collections_group_parts_part_box_items_item_aspect_mode}, + {"collections.group.parts.part.box.items.item.options", st_collections_group_parts_part_box_items_item_options}, + {"collections.group.parts.part.table.items.item.type", st_collections_group_parts_part_box_items_item_type}, /* dup */ + {"collections.group.parts.part.table.items.item.name", st_collections_group_parts_part_box_items_item_name}, /* dup */ + {"collections.group.parts.part.table.items.item.source", st_collections_group_parts_part_box_items_item_source}, /* dup */ + {"collections.group.parts.part.table.items.item.min", st_collections_group_parts_part_box_items_item_min}, /* dup */ + {"collections.group.parts.part.table.items.item.prefer", st_collections_group_parts_part_box_items_item_prefer}, /* dup */ + {"collections.group.parts.part.table.items.item.max", st_collections_group_parts_part_box_items_item_max}, /* dup */ + {"collections.group.parts.part.table.items.item.padding", st_collections_group_parts_part_box_items_item_padding}, /* dup */ + {"collections.group.parts.part.table.items.item.align", st_collections_group_parts_part_box_items_item_align}, /* dup */ + {"collections.group.parts.part.table.items.item.weight", st_collections_group_parts_part_box_items_item_weight}, /* dup */ + {"collections.group.parts.part.table.items.item.aspect", st_collections_group_parts_part_box_items_item_aspect}, /* dup */ + {"collections.group.parts.part.table.items.item.aspect_mode", st_collections_group_parts_part_box_items_item_aspect_mode}, /* dup */ + {"collections.group.parts.part.table.items.item.options", st_collections_group_parts_part_box_items_item_options}, /* dup */ + {"collections.group.parts.part.table.items.item.position", st_collections_group_parts_part_table_items_item_position}, + {"collections.group.parts.part.table.items.item.span", st_collections_group_parts_part_table_items_item_span}, + {"collections.group.parts.part.description.inherit", st_collections_group_parts_part_description_inherit}, + {"collections.group.parts.part.description.source", st_collections_group_parts_part_description_source}, + {"collections.group.parts.part.description.state", st_collections_group_parts_part_description_state}, + {"collections.group.parts.part.description.visible", st_collections_group_parts_part_description_visible}, + {"collections.group.parts.part.description.align", st_collections_group_parts_part_description_align}, + {"collections.group.parts.part.description.fixed", st_collections_group_parts_part_description_fixed}, + {"collections.group.parts.part.description.min", st_collections_group_parts_part_description_min}, + {"collections.group.parts.part.description.max", st_collections_group_parts_part_description_max}, + {"collections.group.parts.part.description.step", st_collections_group_parts_part_description_step}, + {"collections.group.parts.part.description.aspect", st_collections_group_parts_part_description_aspect}, + {"collections.group.parts.part.description.aspect_preference", st_collections_group_parts_part_description_aspect_preference}, + {"collections.group.parts.part.description.rel1.relative", st_collections_group_parts_part_description_rel1_relative}, + {"collections.group.parts.part.description.rel1.offset", st_collections_group_parts_part_description_rel1_offset}, + {"collections.group.parts.part.description.rel1.to", st_collections_group_parts_part_description_rel1_to}, + {"collections.group.parts.part.description.rel1.to_x", st_collections_group_parts_part_description_rel1_to_x}, + {"collections.group.parts.part.description.rel1.to_y", st_collections_group_parts_part_description_rel1_to_y}, + {"collections.group.parts.part.description.rel2.relative", st_collections_group_parts_part_description_rel2_relative}, + {"collections.group.parts.part.description.rel2.offset", st_collections_group_parts_part_description_rel2_offset}, + {"collections.group.parts.part.description.rel2.to", st_collections_group_parts_part_description_rel2_to}, + {"collections.group.parts.part.description.rel2.to_x", st_collections_group_parts_part_description_rel2_to_x}, + {"collections.group.parts.part.description.rel2.to_y", st_collections_group_parts_part_description_rel2_to_y}, + {"collections.group.parts.part.description.image.normal", st_collections_group_parts_part_description_image_normal}, + {"collections.group.parts.part.description.image.tween", st_collections_group_parts_part_description_image_tween}, + {"collections.group.parts.part.description.image.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.image.set.name", st_images_set_name}, + {"collections.group.parts.part.description.image.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.image.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.description.image.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.image.images.set.name", st_images_set_name}, + {"collections.group.parts.part.description.image.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.image.images.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.description.image.border", st_collections_group_parts_part_description_image_border}, + {"collections.group.parts.part.description.image.middle", st_collections_group_parts_part_description_image_middle}, + {"collections.group.parts.part.description.image.border_scale", st_collections_group_parts_part_description_image_border_scale}, + {"collections.group.parts.part.description.image.border_scale_by", st_collections_group_parts_part_description_image_border_scale_by}, + {"collections.group.parts.part.description.image.scale_hint", st_collections_group_parts_part_description_image_scale_hint}, + {"collections.group.parts.part.description.fill.smooth", st_collections_group_parts_part_description_fill_smooth}, + {"collections.group.parts.part.description.fill.origin.relative", st_collections_group_parts_part_description_fill_origin_relative}, + {"collections.group.parts.part.description.fill.origin.offset", st_collections_group_parts_part_description_fill_origin_offset}, + {"collections.group.parts.part.description.fill.size.relative", st_collections_group_parts_part_description_fill_size_relative}, + {"collections.group.parts.part.description.fill.size.offset", st_collections_group_parts_part_description_fill_size_offset}, + {"collections.group.parts.part.description.fill.spread", st_collections_group_parts_part_description_fill_spread}, + {"collections.group.parts.part.description.fill.type", st_collections_group_parts_part_description_fill_type}, + {"collections.group.parts.part.description.color_class", st_collections_group_parts_part_description_color_class}, + {"collections.group.parts.part.description.color", st_collections_group_parts_part_description_color}, + {"collections.group.parts.part.description.color2", st_collections_group_parts_part_description_color2}, + {"collections.group.parts.part.description.color3", st_collections_group_parts_part_description_color3}, + {"collections.group.parts.part.description.text.text", st_collections_group_parts_part_description_text_text}, + {"collections.group.parts.part.description.text.text_class", st_collections_group_parts_part_description_text_text_class}, + {"collections.group.parts.part.description.text.font", st_collections_group_parts_part_description_text_font}, + {"collections.group.parts.part.description.text.style", st_collections_group_parts_part_description_text_style}, + {"collections.group.parts.part.description.text.repch", st_collections_group_parts_part_description_text_repch}, + {"collections.group.parts.part.description.text.size", st_collections_group_parts_part_description_text_size}, + {"collections.group.parts.part.description.text.size_range", st_collections_group_parts_part_description_text_size_range}, + {"collections.group.parts.part.description.text.fit", st_collections_group_parts_part_description_text_fit}, + {"collections.group.parts.part.description.text.min", st_collections_group_parts_part_description_text_min}, + {"collections.group.parts.part.description.text.max", st_collections_group_parts_part_description_text_max}, + {"collections.group.parts.part.description.text.align", st_collections_group_parts_part_description_text_align}, + {"collections.group.parts.part.description.text.source", st_collections_group_parts_part_description_text_source}, + {"collections.group.parts.part.description.text.text_source", st_collections_group_parts_part_description_text_text_source}, + {"collections.group.parts.part.description.text.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.description.text.fonts.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.description.text.elipsis", st_collections_group_parts_part_description_text_elipsis}, + {"collections.group.parts.part.description.text.ellipsis", st_collections_group_parts_part_description_text_elipsis}, + {"collections.group.parts.part.description.box.layout", st_collections_group_parts_part_description_box_layout}, + {"collections.group.parts.part.description.box.align", st_collections_group_parts_part_description_box_align}, + {"collections.group.parts.part.description.box.padding", st_collections_group_parts_part_description_box_padding}, + {"collections.group.parts.part.description.box.min", st_collections_group_parts_part_description_box_min}, + {"collections.group.parts.part.description.table.homogeneous", st_collections_group_parts_part_description_table_homogeneous}, + {"collections.group.parts.part.description.table.align", st_collections_group_parts_part_description_table_align}, + {"collections.group.parts.part.description.table.padding", st_collections_group_parts_part_description_table_padding}, + {"collections.group.parts.part.description.table.min", st_collections_group_parts_part_description_table_min}, + {"collections.group.parts.part.description.map.perspective", st_collections_group_parts_part_description_map_perspective}, + {"collections.group.parts.part.description.map.light", st_collections_group_parts_part_description_map_light}, + {"collections.group.parts.part.description.map.rotation.center", st_collections_group_parts_part_description_map_rotation_center}, + {"collections.group.parts.part.description.map.rotation.x", st_collections_group_parts_part_description_map_rotation_x}, + {"collections.group.parts.part.description.map.rotation.y", st_collections_group_parts_part_description_map_rotation_y}, + {"collections.group.parts.part.description.map.rotation.z", st_collections_group_parts_part_description_map_rotation_z}, + {"collections.group.parts.part.description.map.on", st_collections_group_parts_part_description_map_on}, + {"collections.group.parts.part.description.map.smooth", st_collections_group_parts_part_description_map_smooth}, + {"collections.group.parts.part.description.map.alpha", st_collections_group_parts_part_description_map_alpha}, + {"collections.group.parts.part.description.map.backface_cull", st_collections_group_parts_part_description_map_backface_cull}, + {"collections.group.parts.part.description.map.perspective_on", st_collections_group_parts_part_description_map_perspective_on}, + {"collections.group.parts.part.description.perspective.zplane", st_collections_group_parts_part_description_perspective_zplane}, + {"collections.group.parts.part.description.perspective.focal", st_collections_group_parts_part_description_perspective_focal}, + {"collections.group.parts.part.description.params.int", st_collections_group_parts_part_description_params_int}, + {"collections.group.parts.part.description.params.double", st_collections_group_parts_part_description_params_double}, + {"collections.group.parts.part.description.params.string", st_collections_group_parts_part_description_params_string}, + {"collections.group.parts.part.description.params.bool", st_collections_group_parts_part_description_params_bool}, + {"collections.group.parts.part.description.params.choice", st_collections_group_parts_part_description_params_choice}, + {"collections.group.parts.part.description.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.images.set.name", st_images_set_name}, + {"collections.group.parts.part.description.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.images.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.description.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.description.fonts.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.description.styles.style.name", st_styles_style_name}, /* dup */ + {"collections.group.parts.part.description.styles.style.base", st_styles_style_base}, /* dup */ + {"collections.group.parts.part.description.styles.style.tag", st_styles_style_tag}, /* dup */ + {"collections.group.parts.part.description.color_classes.color_class.name", st_color_class_name}, /* dup */ + {"collections.group.parts.part.description.color_classes.color_class.color", st_color_class_color}, /* dup */ + {"collections.group.parts.part.description.color_classes.color_class.color2", st_color_class_color2}, /* dup */ + {"collections.group.parts.part.description.color_classes.color_class.color3", st_color_class_color3}, /* dup */ + {"collections.group.parts.part.description.programs.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.programs.set.name", st_images_set_name}, + {"collections.group.parts.part.description.programs.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.programs.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.description.programs.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.programs.images.set.name", st_images_set_name}, + {"collections.group.parts.part.description.programs.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.programs.images.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.description.programs.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.description.programs.fonts.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.description.programs.program.name", st_collections_group_programs_program_name}, /* dup */ + {"collections.group.parts.part.description.programs.program.signal", st_collections_group_programs_program_signal}, /* dup */ + {"collections.group.parts.part.description.programs.program.source", st_collections_group_programs_program_source}, /* dup */ + {"collections.group.parts.part.description.programs.program.in", st_collections_group_programs_program_in}, /* dup */ + {"collections.group.parts.part.description.programs.program.action", st_collections_group_programs_program_action}, /* dup */ + {"collections.group.parts.part.description.programs.program.transition", st_collections_group_programs_program_transition}, /* dup */ + {"collections.group.parts.part.description.programs.program.target", st_collections_group_programs_program_target}, /* dup */ + {"collections.group.parts.part.description.programs.program.after", st_collections_group_programs_program_after}, /* dup */ + {"collections.group.parts.part.description.programs.program.api", st_collections_group_programs_program_api}, /* dup */ + {"collections.group.parts.part.description.program.name", st_collections_group_programs_program_name}, /* dup */ + {"collections.group.parts.part.description.program.signal", st_collections_group_programs_program_signal}, /* dup */ + {"collections.group.parts.part.description.program.source", st_collections_group_programs_program_source}, /* dup */ + {"collections.group.parts.part.description.program.in", st_collections_group_programs_program_in}, /* dup */ + {"collections.group.parts.part.description.program.action", st_collections_group_programs_program_action}, /* dup */ + {"collections.group.parts.part.description.program.transition", st_collections_group_programs_program_transition}, /* dup */ + {"collections.group.parts.part.description.program.target", st_collections_group_programs_program_target}, /* dup */ + {"collections.group.parts.part.description.program.after", st_collections_group_programs_program_after}, /* dup */ + {"collections.group.parts.part.description.program.api", st_collections_group_programs_program_api}, /* dup */ + {"collections.group.parts.part.programs.image", st_images_image}, /* dup */ + {"collections.group.parts.part.programs.set.name", st_images_set_name}, + {"collections.group.parts.part.programs.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.programs.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.programs.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.programs.images.set.name", st_images_set_name}, + {"collections.group.parts.part.programs.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.programs.images.set.image.size", st_images_set_image_size}, + {"collections.group.parts.part.programs.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.programs.fonts.font", st_fonts_font}, /* dup */ + {"collections.group.parts.part.programs.program.name", st_collections_group_programs_program_name}, /* dup */ + {"collections.group.parts.part.programs.program.signal", st_collections_group_programs_program_signal}, /* dup */ + {"collections.group.parts.part.programs.program.source", st_collections_group_programs_program_source}, /* dup */ + {"collections.group.parts.part.programs.program.in", st_collections_group_programs_program_in}, /* dup */ + {"collections.group.parts.part.programs.program.action", st_collections_group_programs_program_action}, /* dup */ + {"collections.group.parts.part.programs.program.transition", st_collections_group_programs_program_transition}, /* dup */ + {"collections.group.parts.part.programs.program.target", st_collections_group_programs_program_target}, /* dup */ + {"collections.group.parts.part.programs.program.after", st_collections_group_programs_program_after}, /* dup */ + {"collections.group.parts.part.programs.program.api", st_collections_group_programs_program_api}, /* dup */ + {"collections.group.parts.part.program.name", st_collections_group_programs_program_name}, /* dup */ + {"collections.group.parts.part.program.signal", st_collections_group_programs_program_signal}, /* dup */ + {"collections.group.parts.part.program.source", st_collections_group_programs_program_source}, /* dup */ + {"collections.group.parts.part.program.in", st_collections_group_programs_program_in}, /* dup */ + {"collections.group.parts.part.program.action", st_collections_group_programs_program_action}, /* dup */ + {"collections.group.parts.part.program.transition", st_collections_group_programs_program_transition}, /* dup */ + {"collections.group.parts.part.program.target", st_collections_group_programs_program_target}, /* dup */ + {"collections.group.parts.part.program.after", st_collections_group_programs_program_after}, /* dup */ + {"collections.group.parts.part.program.api", st_collections_group_programs_program_api}, /* dup */ + {"collections.group.parts.programs.image", st_images_image}, /* dup */ + {"collections.group.parts.programs.set.name", st_images_set_name}, + {"collections.group.parts.programs.set.image.image", st_images_set_image_image}, + {"collections.group.parts.programs.set.image.size", st_images_set_image_size}, + {"collections.group.parts.programs.images.image", st_images_image}, /* dup */ + {"collections.group.parts.programs.images.set.name", st_images_set_name}, + {"collections.group.parts.programs.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.programs.images.set.image.size", st_images_set_image_size}, + {"collections.group.parts.programs.font", st_fonts_font}, /* dup */ + {"collections.group.parts.programs.fonts.font", st_fonts_font}, /* dup */ + {"collections.group.parts.programs.program.name", st_collections_group_programs_program_name}, /* dup */ + {"collections.group.parts.programs.program.signal", st_collections_group_programs_program_signal}, /* dup */ + {"collections.group.parts.programs.program.source", st_collections_group_programs_program_source}, /* dup */ + {"collections.group.parts.programs.program.filter", st_collections_group_programs_program_filter}, /* dup */ + {"collections.group.parts.programs.program.in", st_collections_group_programs_program_in}, /* dup */ + {"collections.group.parts.programs.program.action", st_collections_group_programs_program_action}, /* dup */ + {"collections.group.parts.programs.program.transition", st_collections_group_programs_program_transition}, /* dup */ + {"collections.group.parts.programs.program.target", st_collections_group_programs_program_target}, /* dup */ + {"collections.group.parts.programs.program.after", st_collections_group_programs_program_after}, + {"collections.group.parts.programs.program.api", st_collections_group_programs_program_api}, + {"collections.group.parts.program.name", st_collections_group_programs_program_name}, /* dup */ + {"collections.group.parts.program.signal", st_collections_group_programs_program_signal}, /* dup */ + {"collections.group.parts.program.source", st_collections_group_programs_program_source}, /* dup */ + {"collections.group.parts.program.filter", st_collections_group_programs_program_filter}, /* dup */ + {"collections.group.parts.program.in", st_collections_group_programs_program_in}, /* dup */ + {"collections.group.parts.program.action", st_collections_group_programs_program_action}, /* dup */ + {"collections.group.parts.program.transition", st_collections_group_programs_program_transition}, /* dup */ + {"collections.group.parts.program.target", st_collections_group_programs_program_target}, /* dup */ + {"collections.group.parts.program.after", st_collections_group_programs_program_after}, /* dup */ + {"collections.group.parts.program.api", st_collections_group_programs_program_api}, /* dup */ + {"collections.group.program.name", st_collections_group_programs_program_name}, /* dup */ + {"collections.group.program.signal", st_collections_group_programs_program_signal}, /* dup */ + {"collections.group.program.source", st_collections_group_programs_program_source}, /* dup */ + {"collections.group.program.filter", st_collections_group_programs_program_filter}, /* dup */ + {"collections.group.program.in", st_collections_group_programs_program_in}, /* dup */ + {"collections.group.program.action", st_collections_group_programs_program_action}, /* dup */ + {"collections.group.program.transition", st_collections_group_programs_program_transition}, /* dup */ + {"collections.group.program.target", st_collections_group_programs_program_target}, /* dup */ + {"collections.group.program.after", st_collections_group_programs_program_after}, /* dup */ + {"collections.group.program.api", st_collections_group_programs_program_api}, /* dup */ + {"collections.group.programs.program.name", st_collections_group_programs_program_name}, + {"collections.group.programs.program.signal", st_collections_group_programs_program_signal}, + {"collections.group.programs.program.source", st_collections_group_programs_program_source}, + {"collections.group.programs.program.filter", st_collections_group_programs_program_filter}, /* dup */ + {"collections.group.programs.program.in", st_collections_group_programs_program_in}, + {"collections.group.programs.program.action", st_collections_group_programs_program_action}, + {"collections.group.programs.program.transition", st_collections_group_programs_program_transition}, + {"collections.group.programs.program.target", st_collections_group_programs_program_target}, + {"collections.group.programs.program.after", st_collections_group_programs_program_after}, + {"collections.group.programs.program.api", st_collections_group_programs_program_api}, + {"collections.group.programs.image", st_images_image}, /* dup */ + {"collections.group.programs.set.name", st_images_set_name}, + {"collections.group.programs.set.image.image", st_images_set_image_image}, + {"collections.group.programs.set.image.size", st_images_set_image_size}, + {"collections.group.programs.images.image", st_images_image}, /* dup */ + {"collections.group.programs.images.set.name", st_images_set_name}, + {"collections.group.programs.images.set.image.image", st_images_set_image_image}, + {"collections.group.programs.images.set.image.size", st_images_set_image_size}, + {"collections.group.programs.font", st_fonts_font}, /* dup */ + {"collections.group.programs.fonts.font", st_fonts_font} /* dup */ +}; + +New_Object_Handler object_handlers[] = +{ + {"externals", NULL}, + {"images", NULL}, + {"images.set", ob_images_set}, + {"images.set.image", ob_images_set_image}, + {"fonts", NULL}, + {"data", NULL}, + {"styles", NULL}, + {"styles.style", ob_styles_style}, + {"color_classes", NULL}, + {"color_classes.color_class", ob_color_class}, + {"spectra", NULL}, + {"collections", ob_collections}, + {"collections.externals", NULL}, /* dup */ + {"collections.set", ob_images_set}, /* dup */ + {"collections.set.image", ob_images_set_image}, /* dup */ + {"collections.images", NULL}, /* dup */ + {"collections.images.set", ob_images_set}, /* dup */ + {"collections.images.set.image", ob_images_set_image}, /* dup */ + {"collections.fonts", NULL}, /* dup */ + {"collections.styles", NULL}, /* dup */ + {"collections.styles.style", ob_styles_style}, /* dup */ + {"collections.color_classes", NULL}, /* dup */ + {"collections.color_classes.color_class", ob_color_class}, /* dup */ +#ifdef ENABLE_MULTISENSE + {"collections.sounds", NULL}, + {"collections.group.sounds", NULL}, /* dup */ + {"collections.sounds.sample", NULL}, + {"collections.group.sounds.sample", NULL}, /* dup */ +#endif + {"collections.group", ob_collections_group}, + {"collections.group.data", NULL}, + {"collections.group.script", ob_collections_group_script}, + {"collections.group.lua_script", ob_collections_group_lua_script}, + {"collections.group.externals", NULL}, /* dup */ + {"collections.group.set", ob_images_set}, /* dup */ + {"collections.group.set.image", ob_images_set_image}, /* dup */ + {"collections.group.images", NULL}, /* dup */ + {"collections.group.images.set", ob_images_set}, /* dup */ + {"collections.group.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.fonts", NULL}, /* dup */ + {"collections.group.styles", NULL}, /* dup */ + {"collections.group.styles.style", ob_styles_style}, /* dup */ + {"collections.group.color_classes", NULL}, /* dup */ + {"collections.group.color_classes.color_class", ob_color_class}, /* dup */ + {"collections.group.parts", NULL}, + {"collections.group.parts.set", ob_images_set}, /* dup */ + {"collections.group.parts.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.images", NULL}, /* dup */ + {"collections.group.parts.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.fonts", NULL}, /* dup */ + {"collections.group.parts.styles", NULL}, /* dup */ + {"collections.group.parts.styles.style", ob_styles_style}, /* dup */ + {"collections.group.parts.color_classes", NULL}, /* dup */ + {"collections.group.parts.color_classes.color_class", ob_color_class}, /* dup */ + {"collections.group.parts.part", ob_collections_group_parts_part}, + {"collections.group.parts.part.dragable", NULL}, + {"collections.group.parts.part.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.images", NULL}, /* dup */ + {"collections.group.parts.part.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.fonts", NULL}, /* dup */ + {"collections.group.parts.part.styles", NULL}, /* dup */ + {"collections.group.parts.part.styles.style", ob_styles_style}, /* dup */ + {"collections.group.parts.part.color_classes", NULL}, /* dup */ + {"collections.group.parts.part.color_classes.color_class", ob_color_class}, /* dup */ + {"collections.group.parts.part.box", NULL}, + {"collections.group.parts.part.box.items", NULL}, + {"collections.group.parts.part.box.items.item", ob_collections_group_parts_part_box_items_item}, + {"collections.group.parts.part.table", NULL}, + {"collections.group.parts.part.table.items", NULL}, + {"collections.group.parts.part.table.items.item", ob_collections_group_parts_part_box_items_item}, /* dup */ + {"collections.group.parts.part.description", ob_collections_group_parts_part_description}, + {"collections.group.parts.part.description.rel1", NULL}, + {"collections.group.parts.part.description.rel2", NULL}, + {"collections.group.parts.part.description.image", NULL}, /* dup */ + {"collections.group.parts.part.description.image.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.description.image.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.description.image.images", NULL}, /* dup */ + {"collections.group.parts.part.description.image.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.description.image.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.description.fill", NULL}, + {"collections.group.parts.part.description.fill.origin", NULL}, + {"collections.group.parts.part.description.fill.size", NULL}, + {"collections.group.parts.part.description.text", NULL}, + {"collections.group.parts.part.description.text.fonts", NULL}, /* dup */ + {"collections.group.parts.part.description.images", NULL}, /* dup */ + {"collections.group.parts.part.description.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.description.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.description.fonts", NULL}, /* dup */ + {"collections.group.parts.part.description.styles", NULL}, /* dup */ + {"collections.group.parts.part.description.styles.style", ob_styles_style}, /* dup */ + {"collections.group.parts.part.description.box", NULL}, + {"collections.group.parts.part.description.table", NULL}, + {"collections.group.parts.part.description.map", NULL}, + {"collections.group.parts.part.description.map.rotation", NULL}, + {"collections.group.parts.part.description.perspective", NULL}, + {"collections.group.parts.part.description.params", NULL}, + {"collections.group.parts.part.description.color_classes", NULL}, /* dup */ + {"collections.group.parts.part.description.color_classes.color_class", ob_color_class}, /* dup */ + {"collections.group.parts.part.description.program", ob_collections_group_programs_program}, /* dup */ + {"collections.group.parts.part.description.program.script", ob_collections_group_programs_program_script}, /* dup */ + {"collections.group.parts.part.description.programs", NULL}, /* dup */ + {"collections.group.parts.part.description.programs.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.description.programs.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.description.programs.images", NULL}, /* dup */ + {"collections.group.parts.part.description.programs.images.set", ob_images_set}, + {"collections.group.parts.part.description.programs.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.description.programs.fonts", NULL}, /* dup */ + {"collections.group.parts.part.description.programs.program", ob_collections_group_programs_program}, /* dup */ + {"collections.group.parts.part.description.programs.program.script", ob_collections_group_programs_program_script}, /* dup */ + {"collections.group.parts.part.description.script", ob_collections_group_script}, /* dup */ + {"collections.group.parts.part.program", ob_collections_group_programs_program}, /* dup */ + {"collections.group.parts.part.program.script", ob_collections_group_programs_program_script}, /* dup */ + {"collections.group.parts.part.programs", NULL}, /* dup */ + {"collections.group.parts.part.programs.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.programs.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.programs.images", NULL}, /* dup */ + {"collections.group.parts.part.programs.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.programs.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.part.programs.fonts", NULL}, /* dup */ + {"collections.group.parts.part.programs.program", ob_collections_group_programs_program}, /* dup */ + {"collections.group.parts.part.programs.program.script", ob_collections_group_programs_program_script}, /* dup */ + {"collections.group.parts.part.script", ob_collections_group_script}, /* dup */ + {"collections.group.parts.program", ob_collections_group_programs_program}, /* dup */ + {"collections.group.parts.program.script", ob_collections_group_programs_program_script}, /* dup */ + {"collections.group.parts.programs", NULL}, /* dup */ + {"collections.group.parts.programs.set", ob_images_set}, /* dup */ + {"collections.group.parts.programs.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.programs.images", NULL}, /* dup */ + {"collections.group.parts.programs.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.programs.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.parts.programs.fonts", NULL}, /* dup */ + {"collections.group.parts.programs.program", ob_collections_group_programs_program}, /* dup */ + {"collections.group.parts.programs.program.script", ob_collections_group_programs_program_script}, /* dup */ + {"collections.group.parts.script", ob_collections_group_script}, /* dup */ + {"collections.group.program", ob_collections_group_programs_program}, /* dup */ + {"collections.group.program.script", ob_collections_group_programs_program_script}, /* dup */ + {"collections.group.programs", NULL}, + {"collections.group.programs.set", ob_images_set}, /* dup */ + {"collections.group.programs.set.image", ob_images_set_image}, /* dup */ + {"collections.group.programs.images", NULL}, /* dup */ + {"collections.group.programs.images.set", ob_images_set}, /* dup */ + {"collections.group.programs.images.set.image", ob_images_set_image}, /* dup */ + {"collections.group.programs.fonts", NULL}, /* dup */ + {"collections.group.programs.program", ob_collections_group_programs_program}, + {"collections.group.programs.program.script", ob_collections_group_programs_program_script}, + {"collections.group.programs.script", ob_collections_group_script} /* dup */ +}; + +/*****/ + +int +object_handler_num(void) +{ + return sizeof(object_handlers) / sizeof (New_Object_Handler); +} + +int +statement_handler_num(void) +{ + return sizeof(statement_handlers) / sizeof (New_Object_Handler); +} + +static void +_edje_part_description_fill(Edje_Part_Description_Spec_Fill *fill) +{ + fill->smooth = 1; + fill->pos_rel_x = FROM_DOUBLE(0.0); + fill->pos_abs_x = 0; + fill->rel_x = FROM_DOUBLE(1.0); + fill->abs_x = 0; + fill->pos_rel_y = FROM_DOUBLE(0.0); + fill->pos_abs_y = 0; + fill->rel_y = FROM_DOUBLE(1.0); + fill->abs_y = 0; + fill->angle = 0; + fill->spread = 0; + fill->type = EDJE_FILL_TYPE_SCALE; +} + +static Edje_Part_Description_Common * +_edje_part_description_alloc(unsigned char type, const char *collection, const char *part) +{ + Edje_Part_Description_Common *result = NULL; + + switch (type) + { + case EDJE_PART_TYPE_RECTANGLE: + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_GROUP: + result = mem_alloc(SZ(Edje_Part_Description_Common)); + break; + case EDJE_PART_TYPE_TEXT: + case EDJE_PART_TYPE_TEXTBLOCK: + { + Edje_Part_Description_Text *ed; + + ed = mem_alloc(SZ(Edje_Part_Description_Text)); + + ed->text.color3.r = 0; + ed->text.color3.g = 0; + ed->text.color3.b = 0; + ed->text.color3.a = 128; + ed->text.align.x = FROM_DOUBLE(0.5); + ed->text.align.y = FROM_DOUBLE(0.5); + ed->text.id_source = -1; + ed->text.id_text_source = -1; + + result = &ed->common; + break; + } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; + + ed = mem_alloc(SZ(Edje_Part_Description_Image)); + + ed->image.id = -1; + + _edje_part_description_fill(&ed->image.fill); + + result = &ed->common; + break; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = mem_alloc(SZ(Edje_Part_Description_Proxy)); + + ed->proxy.id = -1; + + _edje_part_description_fill(&ed->proxy.fill); + + result = &ed->common; + break; + } + case EDJE_PART_TYPE_BOX: + { + Edje_Part_Description_Box *ed; + + ed = mem_alloc(SZ(Edje_Part_Description_Box)); + + ed->box.layout = NULL; + ed->box.alt_layout = NULL; + ed->box.align.x = FROM_DOUBLE(0.5); + ed->box.align.y = FROM_DOUBLE(0.5); + ed->box.padding.x = 0; + ed->box.padding.y = 0; + + result = &ed->common; + break; + } + case EDJE_PART_TYPE_TABLE: + { + Edje_Part_Description_Table *ed; + + ed = mem_alloc(SZ(Edje_Part_Description_Table)); + + ed->table.homogeneous = EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE; + ed->table.align.x = FROM_DOUBLE(0.5); + ed->table.align.y = FROM_DOUBLE(0.5); + ed->table.padding.x = 0; + ed->table.padding.y = 0; + + result = &ed->common; + break; + } + case EDJE_PART_TYPE_EXTERNAL: + { + Edje_Part_Description_External *ed; + + ed = mem_alloc(SZ(Edje_Part_Description_External)); + + ed->external_params = NULL; + + result = &ed->common; + break; + } + } + + if (!result) + { + ERR("%s: Error. Unknown type %i of part %s in collection %s.", progname, type, part, collection); + exit(-1); + } + + return result; +} + +static void +_edje_program_check(const char *name, Edje_Program *me, Edje_Program **pgrms, unsigned int count) +{ + Edje_Part_Collection *pc; + unsigned int i; + Edje_Program_Parser *epp; + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + for (i = 0; i < count; ++i) + if (pgrms[i]->name) + if (pgrms[i] != me && (!strcmp(name, pgrms[i]->name))) + { + epp = (Edje_Program_Parser *)pgrms[i]; + if (!epp->can_override) + { + ERR("%s: Error. parse error %s:%i. There is already a program of the name %s\n", + progname, file_in, line - 1, name); + exit(-1); + } + else + { + _edje_program_remove(pc, me); + current_program = pgrms[i]; + epp->can_override = EINA_FALSE; + return; + } + } +} + +static void +_edje_program_copy(Edje_Program *ep, Edje_Program *ep2) +{ + Edje_Part_Collection *pc; + Edje_Program_Target *et, *et2; + Edje_Program_After *pa, *pa2; + Edje_Program_Parser *epp; + Eina_List *l; + char *name; + char *copy; + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + #define STRDUP(x) x ? strdup(x) : NULL + ep->name = STRDUP(ep2->name); + + _edje_program_remove(pc, current_program); + ep->signal = STRDUP(ep2->signal); + ep->source = STRDUP(ep2->source); + _edje_program_insert(pc, current_program); + + ep->filter.part = STRDUP(ep2->filter.part); + ep->filter.state = STRDUP(ep2->filter.state); + ep->in.from = ep2->in.from; + ep->in.range = ep2->in.range; + ep->action = ep2->action; + ep->state = STRDUP(ep2->state); + ep->state2 = STRDUP(ep2->state2); + ep->value = ep2->value; + ep->value2 = ep2->value2; + ep->tween.mode = ep2->tween.mode; + ep->tween.time = ep2->tween.time; + ep->tween.v1 = ep2->tween.v1; + ep->tween.v2 = ep2->tween.v2; + + EINA_LIST_FOREACH(ep2->targets, l, et2) + { + name = (char*) (et2 + 1); + et = mem_alloc(SZ(Edje_Program_Target) + strlen(name) + 1); + ep->targets = eina_list_append(ep->targets, et); + copy = (char*) (et + 1); + + memcpy(copy, name, strlen(name) + 1); + + if (ep2->action == EDJE_ACTION_TYPE_STATE_SET) + data_queue_copied_part_lookup(pc, &(et2->id), &(et->id)); + else if (ep2->action == EDJE_ACTION_TYPE_ACTION_STOP) + data_queue_copied_program_lookup(pc, &(et2->id), &(et->id)); + else if (ep2->action == EDJE_ACTION_TYPE_DRAG_VAL_SET) + data_queue_copied_part_lookup(pc, &(et2->id), &(et->id)); + else if (ep2->action == EDJE_ACTION_TYPE_DRAG_VAL_STEP) + data_queue_copied_part_lookup(pc, &(et2->id), &(et->id)); + else if (ep2->action == EDJE_ACTION_TYPE_DRAG_VAL_PAGE) + data_queue_copied_part_lookup(pc, &(et2->id), &(et->id)); + else if (ep2->action == EDJE_ACTION_TYPE_FOCUS_SET) + + data_queue_copied_part_lookup(pc, &(et2->id), &(et->id)); + else if (ep2->action == EDJE_ACTION_TYPE_FOCUS_OBJECT) + data_queue_copied_part_lookup(pc, &(et2->id), &(et->id)); + else + { + ERR("%s: Error. parse error %s:%i. " + "target may only be used after action", + progname, file_in, line - 1); + exit(-1); + } + } + + EINA_LIST_FOREACH(ep2->after, l, pa2) + { + pa = mem_alloc(SZ(Edje_Program_After)); + ep->after = eina_list_append(ep->after, pa); + + data_queue_copied_program_lookup(pc, &(pa2->id), &(pa->id)); + } + + ep->api.name = STRDUP(ep2->api.name); + ep->api.description = STRDUP(ep2->api.description); + data_queue_copied_part_lookup(pc, &(ep2->param.src), &(ep->param.src)); + data_queue_copied_part_lookup(pc, &(ep2->param.dst), &(ep->param.dst)); + + epp = (Edje_Program_Parser *)ep; + epp->can_override = EINA_TRUE; + + #undef STRDUP +} + +/*****/ + +/** + @edcsection{toplevel,Top-Level blocks} + */ + +/** + @page edcref + + @block + externals + @context + externals { + external: "name"; + } + @description + The "externals" block is used to list each external module file that will be used in others + programs. + @endblock + + @property + external + @parameters + [external filename] + @effect + Used to add a file to the externals list. + @endproperty + */ +static void +st_externals_external(void) +{ + External *ex; + + check_arg_count(1); + + if (!edje_file->external_dir) + edje_file->external_dir = mem_alloc(SZ(Edje_External_Directory)); + + ex = mem_alloc(SZ(External)); + ex->name = parse_str(0); + { + Eina_List *l; + External *lex; + + EINA_LIST_FOREACH(externals, l, lex) + { + if (!strcmp(lex->name, ex->name)) + { + free(ex->name); + free(ex); + return; + } + } + } + externals = eina_list_append(externals, ex); + + if (edje_file->external_dir) + { + edje_file->external_dir->entries_count++; + edje_file->external_dir->entries = realloc(edje_file->external_dir->entries, + sizeof (Edje_External_Directory) * edje_file->external_dir->entries_count); + memset(edje_file->external_dir->entries + edje_file->external_dir->entries_count - 1, + 0, sizeof (Edje_External_Directory)); + if (!edje_file->external_dir->entries) + { + ERR("%s: Error. not enough memory", progname); + exit(-1); + } + + edje_file->external_dir->entries[edje_file->external_dir->entries_count - 1].entry = mem_strdup(ex->name); + } +} + +/** + @page edcref + + @block + images + @context + images { + image: "filename1.ext" COMP; + image: "filename2.ext" LOSSY 99; + set { + name: "image_name_used"; + image { + image: "filename3.ext" LOSSY 90; + size: 201 201 500 500; + } + image { + image: "filename4.ext" COMP; + size: 51 51 200 200; + } + image { + image: "filename5.ext" COMP; + size: 11 11 50 50; + } + image { + image: "filename6.ext" RAW; + size: 0 0 10 10; + } + } + .. + } + @description + The "images" block is used to list each image file that will be used in + the theme along with its compression method (if any). + Besides the document's root, additional "images" blocks can be + included inside other blocks, normally "collections", "group" and + "part", easing maintenance of the file list when the theme is split + among multiple files. + @endblock + + @property + image + @parameters + [image file] [compression method] (compression level) + @effect + Used to include each image file. The full path to the directory holding + the images can be defined later with edje_cc's "-id" option. + Compression methods: + @li RAW: Uncompressed. + @li COMP: Lossless compression. + @li LOSSY [0-100]: Lossy comression with quality from 0 to 100. + @li USER: Do not embed the file, refer to the external file instead. + @endproperty + */ +static void +st_images_image(void) +{ + Edje_Image_Directory_Entry *img; + const char *tmp; + unsigned int i; + int v; + + if (!edje_file->image_dir) + edje_file->image_dir = mem_alloc(SZ(Edje_Image_Directory)); + + tmp = parse_str(0); + + for (i = 0; i < edje_file->image_dir->entries_count; ++i) + if (!strcmp(edje_file->image_dir->entries[i].entry, tmp)) + { + free((char*) tmp); + return; + } + + edje_file->image_dir->entries_count++; + edje_file->image_dir->entries = realloc(edje_file->image_dir->entries, + sizeof (Edje_Image_Directory_Entry) * edje_file->image_dir->entries_count); + memset(edje_file->image_dir->entries + edje_file->image_dir->entries_count - 1, + 0, sizeof (Edje_Image_Directory_Entry)); + if (!edje_file->image_dir->entries) + { + ERR("%s: Error. No enough memory.", progname); + exit(-1); + } + + img = edje_file->image_dir->entries + edje_file->image_dir->entries_count - 1; + + img->entry = tmp; + img->id = edje_file->image_dir->entries_count - 1; + v = parse_enum(1, + "RAW", 0, + "COMP", 1, + "LOSSY", 2, + "USER", 3, + NULL); + if (v == 0) + { + img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT; + img->source_param = 0; + } + else if (v == 1) + { + img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT; + img->source_param = 1; + } + else if (v == 2) + { + img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY; + img->source_param = 0; + } + else if (v == 3) + { + img->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL; + img->source_param = 0; + } + if (img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY) + check_arg_count(2); + else + { + img->source_param = parse_int_range(2, 0, 100); + check_arg_count(3); + } +} + +/** + @page edcref + + @block + set + @context + set { + name: "image_name_used"; + image { + image: "filename3.ext" LOSSY 90; + size: 201 201 500 500; + } + image { + image: "filename4.ext" COMP; + size: 51 51 200 200; + } + image { + image: "filename5.ext" COMP; + size: 11 11 50 50; + } + image { + image: "filename6.ext" RAW; + size: 0 0 10 10; + } + } + @description + The "set" block is used to define an image with different content depending on their size. + Besides the document's root, additional "set" blocks can be + included inside other blocks, normally "collections", "group" and + "part", easing maintenance of the file list when the theme is split + among multiple files. + @endblock + */ +static void +ob_images_set(void) +{ + if (!edje_file->image_dir) + edje_file->image_dir = mem_alloc(SZ(Edje_Image_Directory)); + + edje_file->image_dir->sets_count++; + edje_file->image_dir->sets = realloc(edje_file->image_dir->sets, + sizeof (Edje_Image_Directory_Set) * edje_file->image_dir->sets_count); + memset(edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1, + 0, sizeof (Edje_Image_Directory_Set)); + if (!edje_file->image_dir->sets) + { + ERR("%s: Error. Not enough memory.", progname); + exit(-1); + } + edje_file->image_dir->sets[edje_file->image_dir->sets_count - 1].id = edje_file->image_dir->sets_count - 1; +} + +/** + @page edcref + + @property + name + @parameters + [image name] + @effect + Define the name that refer to this image description. + @endproperty +*/ +static void +st_images_set_name(void) +{ + check_arg_count(1); + + edje_file->image_dir->sets[edje_file->image_dir->sets_count - 1].name = parse_str(0); +} + +static void +ob_images_set_image(void) +{ + Edje_Image_Directory_Set_Entry *entry; + Edje_Image_Directory_Set *set; + + set = edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1; + + entry = mem_alloc(SZ(Edje_Image_Directory_Set_Entry)); + + set->entries = eina_list_append(set->entries, entry); +} + +static void +st_images_set_image_image(void) +{ + Edje_Image_Directory_Set_Entry *entry; + Edje_Image_Directory_Set *set; + unsigned int i; + + set = edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1; + entry = eina_list_data_get(eina_list_last(set->entries)); + + /* Add the image to the global pool with the same syntax. */ + st_images_image(); + + entry->name = parse_str(0); + + for (i = 0; i < edje_file->image_dir->entries_count; ++i) + if (!strcmp(edje_file->image_dir->entries[i].entry, entry->name)) + { + entry->id = i; + return; + } +} + +/** + @page edcref + + @property + size + @parameters + [minw minh maxw mawh] + @effect + Define the minimal and maximal size that will select the specified image. + @endproperty +*/ +static void +st_images_set_image_size(void) +{ + Edje_Image_Directory_Set_Entry *entry; + Edje_Image_Directory_Set *set; + + set = edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1; + entry = eina_list_data_get(eina_list_last(set->entries)); + + entry->size.min.w = parse_int(0); + entry->size.min.h = parse_int(1); + entry->size.max.w = parse_int(2); + entry->size.max.h = parse_int(3); + + if (entry->size.min.w > entry->size.max.w + || entry->size.min.h > entry->size.max.h) + { + ERR("%s: Error. parse error %s:%i. Image min and max size are not in the right order ([%i, %i] < [%i, %i])", + progname, file_in, line - 1, + entry->size.min.w, entry->size.min.h, + entry->size.max.w, entry->size.max.h); + exit(-1); + } +} + +/** + @page edcref + + @block + fonts + @context + fonts { + font: "filename1.ext" "fontname"; + font: "filename2.ext" "otherfontname"; + .. + } + @description + The "fonts" block is used to list each font file with an alias used later + in the theme. As with the "images" block, additional "fonts" blocks can + be included inside other blocks. + @endblock + + @property + font + @parameters + [font filename] [font alias] + @effect + Defines each font "file" and "alias", the full path to the directory + holding the font files can be defined with edje_cc's "-fd" option. + @endproperty + */ +static void +st_fonts_font(void) +{ + Font *fn; + + check_arg_count(2); + + if (!edje_file->fonts) + edje_file->fonts = eina_hash_string_small_new(free); + + fn = mem_alloc(SZ(Font)); + fn->file = parse_str(0); + fn->name = parse_str(1); + + if (eina_hash_find(edje_file->fonts, fn->name)) + { + free(fn->file); + free(fn->name); + free(fn); + return; + } + + eina_hash_direct_add(edje_file->fonts, fn->name, fn); +} + +/** + @page edcref + @block + data + @context + data { + item: "key" "value"; + file: "otherkey" "filename.ext"; + .. + } + @description + The "data" block is used to pass arbitrary parameters from the theme to + the application. Unlike the "images" and "fonts" blocks, additional + "data" blocks can only be included inside the "group" block. + @endblock + + @property + item + @parameters + [parameter name] [parameter value] + @effect + Defines a new parameter, the value will be the string specified next to + it. + @endproperty + */ +static void +st_data_item(void) +{ + Edje_String *es; + char *key; + + check_arg_count(2); + + key = parse_str(0); + + es = mem_alloc(SZ(Edje_String)); + es->str = parse_str(1); + + if (!edje_file->data) + edje_file->data = eina_hash_string_small_new(free); + + /* FIXME: check if data already exist */ + eina_hash_direct_add(edje_file->data, key, es); +} + +/** + @page edcref + @property + file + @parameters + [parameter name] [parameter filename] + @effect + Defines a new parameter , the value will be the contents of the + specified file formated as a single string of text. This property only + works with plain text files. + @endproperty + */ +static void +st_data_file(void) +{ + const char *data; + const char *over; + Edje_String *es; + char *filename; + char *value; + char *key; + int fd; + int i; + struct stat buf; + + check_arg_count(2); + + key = parse_str(0); + + es = mem_alloc(SZ(Edje_String)); + filename = parse_str(1); + + fd = open(filename, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); + if (fd < 0) + { + ERR("%s: Error. %s:%i when opening file \"%s\": \"%s\"", + progname, file_in, line, filename, strerror(errno)); + exit(-1); + } + + if (fstat(fd, &buf)) + { + ERR("%s: Error. %s:%i when stating file \"%s\": \"%s\"", + progname, file_in, line, filename, strerror(errno)); + exit(-1); + } + + data = mmap(NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (data == MAP_FAILED) + { + ERR("%s: Error. %s:%i when mapping file \"%s\": \"%s\"", + progname, file_in, line, filename, strerror(errno)); + exit(-1); + } + + over = data; + for (i = 0; i < buf.st_size; ++i, ++over) + if (*over == '\0') + { + ERR("%s: Error. %s:%i file \"%s\" is a binary file.", + progname, file_in, line, filename); + exit(-1); + } + + value = malloc(sizeof (char) * buf.st_size + 1); + snprintf(value, buf.st_size + 1, "%s", data); + + munmap((void*)data, buf.st_size); + close(fd); + + es->str = value; + + eina_hash_direct_add(edje_file->data, key, es); + + free(filename); +} + +/** + @page edcref + @block + color_classes + @context + color_classes { + color_class { + name: "colorclassname"; + color: [0-255] [0-255] [0-255] [0-255]; + color2: [0-255] [0-255] [0-255] [0-255]; + color3: [0-255] [0-255] [0-255] [0-255] + } + .. + } + @description + The "color_classes" block contains a list of one or more "color_class" + blocks. Each "color_class" allows the designer to name an arbitrary + group of colors to be used in the theme, the application can use that + name to alter the color values at runtime. + @endblock +*/ +static void +ob_color_class(void) +{ + Edje_Color_Class *cc; + + cc = mem_alloc(SZ(Edje_Color_Class)); + edje_file->color_classes = eina_list_append(edje_file->color_classes, cc); + + cc->r = 0; + cc->g = 0; + cc->b = 0; + cc->a = 0; + cc->r2 = 0; + cc->g2 = 0; + cc->b2 = 0; + cc->a2 = 0; + cc->r3 = 0; + cc->g3 = 0; + cc->b3 = 0; + cc->a3 = 0; +} + +/** + @page edcref + + @property + name + @parameters + [color class name] + @effect + Sets the name for the color class, used as reference by both the theme + and the application. + @endproperty +*/ +static void +st_color_class_name(void) +{ + Edje_Color_Class *cc, *tcc; + Eina_List *l; + + cc = eina_list_data_get(eina_list_last(edje_file->color_classes)); + cc->name = parse_str(0); + EINA_LIST_FOREACH(edje_file->color_classes, l, tcc) + { + if ((cc != tcc) && (!strcmp(cc->name, tcc->name))) + { + fprintf(stderr, "%s: Error. parse error %s:%i. There is already a color class named \"%s\"\n", + progname, file_in, line - 1, cc->name); + exit(-1); + } + } +} + +/** + @page edcref + @property + color + @parameters + [red] [green] [blue] [alpha] + @effect + The main color. + @endproperty +*/ +static void +st_color_class_color(void) +{ + Edje_Color_Class *cc; + + check_arg_count(4); + + cc = eina_list_data_get(eina_list_last(edje_file->color_classes)); + cc->r = parse_int_range(0, 0, 255); + cc->g = parse_int_range(1, 0, 255); + cc->b = parse_int_range(2, 0, 255); + cc->a = parse_int_range(3, 0, 255); +} + +/** + @page edcref + @property + color2 + @parameters + [red] [green] [blue] [alpha] + @effect + Used as shadow in text and textblock parts. + @endproperty +*/ +static void +st_color_class_color2(void) +{ + Edje_Color_Class *cc; + + check_arg_count(4); + + cc = eina_list_data_get(eina_list_last(edje_file->color_classes)); + cc->r2 = parse_int_range(0, 0, 255); + cc->g2 = parse_int_range(1, 0, 255); + cc->b2 = parse_int_range(2, 0, 255); + cc->a2 = parse_int_range(3, 0, 255); +} + +/** + @page edcref + @property + color3 + @parameters + [red] [green] [blue] [alpha] + @effect + Used as outline in text and textblock parts. + @endproperty +*/ +static void +st_color_class_color3(void) +{ + Edje_Color_Class *cc; + + check_arg_count(4); + + cc = eina_list_data_get(eina_list_last(edje_file->color_classes)); + cc->r3 = parse_int_range(0, 0, 255); + cc->g3 = parse_int_range(1, 0, 255); + cc->b3 = parse_int_range(2, 0, 255); + cc->a3 = parse_int_range(3, 0, 255); +} + +/** + @page edcref + @block + styles + @context + styles { + style { + name: "stylename"; + base: "..default style properties.."; + + tag: "tagname" "..style properties.."; + .. + } + .. + } + @description + The "styles" block contains a list of one or more "style" blocks. A + "style" block is used to create style \ for advanced TEXTBLOCK + formatting. + @endblock +*/ +static void +ob_styles_style(void) +{ + Edje_Style *stl; + + stl = mem_alloc(SZ(Edje_Style)); + edje_file->styles = eina_list_append(edje_file->styles, stl); +} + +/** + @page edcref + @property + name + @parameters + [style name] + @effect + The name of the style to be used as reference later in the theme. + @endproperty +*/ +static void +st_styles_style_name(void) +{ + Edje_Style *stl, *tstl; + Eina_List *l; + + stl = eina_list_data_get(eina_list_last(edje_file->styles)); + stl->name = parse_str(0); + EINA_LIST_FOREACH(edje_file->styles, l, tstl) + { + if (stl->name && tstl->name && (stl != tstl) && (!strcmp(stl->name, tstl->name))) + { + ERR("%s: Error. parse error %s:%i. There is already a style named \"%s\"", + progname, file_in, line - 1, stl->name); + exit(-1); + } + } +} + +/** + @page edcref + @property + base + @parameters + [style properties string] + @effect + The default style properties that will be applied to the complete + text. + @endproperty +*/ +static void +st_styles_style_base(void) +{ + Edje_Style *stl; + Edje_Style_Tag *tag; + + stl = eina_list_data_get(eina_list_last(edje_file->styles)); + if (stl->tags) + { + ERR("%s: Error. parse error %s:%i. There is already a basic format for the style", + progname, file_in, line - 1); + exit(-1); + } + tag = mem_alloc(SZ(Edje_Style_Tag)); + tag->key = mem_strdup("DEFAULT"); + tag->value = parse_str(0); + stl->tags = eina_list_append(stl->tags, tag); +} + +/** + @page edcref + @property + tag + @parameters + [tag name] [style properties string] + @effect + Style to be applied only to text between style \..\. + When creating "paired" tags, like \\, A '+' should be added at the start of the style properties of the first part (\). + If the second part (\) is also defined, a '-' should be prepended to it's style properties. + This only applies to paired tags; Single tags, like \, must not include a starting '+'. + @endproperty +*/ +static void +st_styles_style_tag(void) +{ + Edje_Style *stl; + Edje_Style_Tag *tag; + + stl = eina_list_data_get(eina_list_last(edje_file->styles)); + tag = mem_alloc(SZ(Edje_Style_Tag)); + tag->key = parse_str(0); + tag->value = parse_str(1); + stl->tags = eina_list_append(stl->tags, tag); +} + +#ifdef ENABLE_MULTISENSE +/* add to below doc +sounds { } + */ +#endif + +/** + @page edcref + @block + collections + @context + collections { + .. + group { } + group { } + .. + } + @description + The "collections" block is used to list the groups that compose the + theme. Additional "collections" blocks do not prevent overriding group + names. The "sounds" block comprises of all sound definitions. + @endblock +*/ +static void +ob_collections(void) +{ + if (!edje_file->collection) + edje_file->collection = eina_hash_string_small_new(NULL); +} + +#ifdef ENABLE_MULTISENSE +/* * delete space before * + @page edcref + @block + sounds + @context + sounds { + sample { + name: "sound_file1" COMP; + source: "sound_file1.wav"; + } + sample { + name: "sound_file2" LOSSY 0.4; + source: "sound_file2.wav"; + } + tone: "tone-1" 2300; + } + + @description + The "sounds" block contains a list of one or more sound sample and tones items. + @endblock + @block + sample + @context + sample { + name: "sound_file1" RAW; + source: "sound_file1.wav"; + } + sample { + name: "sound_file2" LOSSY 0.5; + source: "sound_file2.wav"; + } + sample { + name: "sound_file3" COMP; + source: "sound_file3.wav"; + } + sample { + name: "sound_file4" AS-IS; + source: "sound_file1.wav"; + } + @description + The sample block defines the sound sample. + @endblock + @property + name + @parameters + [sample name] [compression type] [if lossy, then quality] + @effect + Used to include each sound file. The full path to the directory holding + the sounds can be defined later with edje_cc's "-sd" option. + @li RAW: Uncompressed. + @li COMP: Lossless compression. + @li LOSSY [-0.1 - 1.0]: Lossy comression with quality from 0 to 1.0. + @li AS_IS: Check for re-encoding, no compression/encoding, just write the file information as it is. + @endproperty + @since 1.1.0 + */ +static void +st_collections_group_sound_sample_name(void) +{ + Edje_Sound_Sample *sample; + const char *tmp; + unsigned int i; + + if (!edje_file->sound_dir) + edje_file->sound_dir = mem_alloc(SZ(Edje_Sound_Directory)); + + tmp = parse_str(0); + + for (i = 0; i < edje_file->sound_dir->samples_count; i++) + { + if (!strcmp(edje_file->sound_dir->samples[i].name, tmp)) + { + free((char *)tmp); + return; + } + } + + edje_file->sound_dir->samples_count++; + edje_file->sound_dir->samples = + realloc(edje_file->sound_dir->samples, + sizeof(Edje_Sound_Sample) * + edje_file->sound_dir->samples_count); + + if (!edje_file->sound_dir->samples) + { + ERR("%s: Error. No enough memory.", progname); + exit(-1); + } + + sample = + edje_file->sound_dir->samples + + edje_file->sound_dir->samples_count - 1; + memset(sample, 0, sizeof (Edje_Sound_Sample)); + + sample->name = tmp; + sample->id = edje_file->sound_dir->samples_count - 1; + sample->compression = parse_enum(1, + "RAW", EDJE_SOUND_SOURCE_TYPE_INLINE_RAW, + "COMP", EDJE_SOUND_SOURCE_TYPE_INLINE_COMP, + "LOSSY", EDJE_SOUND_SOURCE_TYPE_INLINE_LOSSY, + "AS_IS", EDJE_SOUND_SOURCE_TYPE_INLINE_AS_IS, + NULL); + + if (sample->compression == EDJE_SOUND_SOURCE_TYPE_INLINE_LOSSY) + { + sample->quality = parse_float_range(2, 45.0, 1000.0); + check_arg_count(3); + } + else + check_arg_count(2); + +} + +/* * delete space before * + @page edcref + @property + source + @parameters + [sound file name] + @effect + The Sound source file name (Source can be mono/stereo WAV file. + Only files with 44.1 KHz sample rate supported now) + @endproperty + @since 1.1.0 + */ +static void +st_collections_group_sound_sample_source(void) +{ + Edje_Sound_Sample *sample; + + if (!edje_file->sound_dir->samples) + { + ERR("%s: Error. Invalid sound sample source definition.", progname); + exit(-1); + } + + sample = + edje_file->sound_dir->samples + + edje_file->sound_dir->samples_count - 1; + + if (!sample) + { + ERR("%s: Error. Invalid sound sample source definition.", progname); + exit(-1); + } + sample->snd_src = parse_str(0); + check_arg_count(1); +} + +/* * delete space before * + @page edcref + @property + tone + @parameters + [tone name] [frequency] + @effect + sound of specific frequency + @endproperty + @since 1.1.0 + */ +static void +st_collections_group_sound_tone(void) +{ + Edje_Sound_Tone *tone; + const char *tmp; + unsigned int i; + int value; + + check_arg_count(2); + + if (!edje_file->sound_dir) + edje_file->sound_dir = mem_alloc(SZ(Edje_Sound_Directory)); + + tmp = parse_str(0); + /* Audible range 20 to 20KHz */ + value = parse_int_range(1, 20, 20000); + + /* Check for Tone duplication */ + for (i = 0; i < edje_file->sound_dir->tones_count; i++) + { + if (!strcmp(edje_file->sound_dir->tones[i].name, tmp)) + { + ERR("%s: Error. Tone name: %s already exist.", progname, tmp); + free((char *)tmp); + exit(-1); + } + if (edje_file->sound_dir->tones[i].value == value) + { + ERR("%s: Error. Tone name %s with same frequency %d exist.", + progname, edje_file->sound_dir->tones[i].name, value); + exit(-1); + } + } + edje_file->sound_dir->tones_count++; + edje_file->sound_dir->tones = + realloc(edje_file->sound_dir->tones, + sizeof (Edje_Sound_Tone) * + edje_file->sound_dir->tones_count); + + if (!edje_file->sound_dir->tones) + { + ERR("%s: Error. No enough memory.", progname); + exit(-1); + } + + tone = edje_file->sound_dir->tones + edje_file->sound_dir->tones_count - 1; + memset(tone, 0, sizeof (Edje_Sound_Tone)); + + tone->name = tmp; + tone->value = value; + tone->id = edje_file->sound_dir->tones_count - 1; +} +#endif + +/** + @edcsection{group,Group sub blocks} + */ + +/** + @page edcref + @block + group + @context + collections { + .. + group { + name: "nameusedbytheapplication"; + alias: "anothername"; + min: width height; + max: width height; + + data { } + script { } + parts { } + programs { } + } + .. + } + @description + A "group" block contains the list of parts and programs that compose a + given Edje Object. + @endblock +*/ +static void +ob_collections_group(void) +{ + Edje_Part_Collection *pc; + Code *cd; + + if (current_de && !current_de->entry) + { + ERR("%p: Error. A collection without a name was detected, that's not allowed.", progname); + exit(-1); + } + + current_de = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry)); + current_de->id = eina_list_count(edje_collections); + + pc = mem_alloc(SZ(Edje_Part_Collection)); + edje_collections = eina_list_append(edje_collections, pc); + pc->id = current_de->id; + + cd = mem_alloc(SZ(Code)); + codes = eina_list_append(codes, cd); +} + +/** + @page edcref + @property + name + @parameters + [group name] + @effect + The name that will be used by the application to load the resulting + Edje object and to identify the group to swallow in a GROUP part. If a + group with the same name exists already it will be completely overriden + by the new group. + @endproperty +*/ +static void +st_collections_group_name(void) +{ + Edje_Part_Collection_Directory_Entry *older; + Edje_Part_Collection *current_pc; + + check_arg_count(1); + + current_pc = eina_list_data_get(eina_list_last(edje_collections)); + + current_de->entry = parse_str(0); + current_pc->part = current_de->entry; + + older = eina_hash_find(edje_file->collection, current_de->entry); + + if (older) + { + Edje_Part_Collection *pc; + Eina_List *l; + Code *cd; + int i = 0; + + pc = eina_list_nth(edje_collections, older->id); + cd = eina_list_nth(codes, older->id); + + eina_hash_del(edje_file->collection, current_de->entry, older); + edje_collections = eina_list_remove(edje_collections, pc); + codes = eina_list_remove(codes, cd); + + EINA_LIST_FOREACH(edje_collections, l, pc) + { + older = eina_hash_find(edje_file->collection, pc->part); + + pc->id = i++; + if (older) older->id = pc->id; + } + } + + eina_hash_direct_add(edje_file->collection, current_de->entry, current_de); +} + +typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data; +struct _Edje_List_Foreach_Data +{ + Eina_List *list; +}; + +static Eina_Bool +_edje_data_item_list_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata) +{ + Edje_List_Foreach_Data *fd; + + fd = fdata; + fd->list = eina_list_append(fd->list, strdup(key)); + + return EINA_TRUE; +} + +/** + @page edcref + @property + inherit + @parameters + [parent group name] + @effect + Parent group name for inheritance. + Group "inherit" is used to inherit any predefined group and change + some property which belongs to "part", "description", "items" or "program". + The child group has the same property as parent group. If you specify the + type again in an inherited part, it will cause an error (unless you plan + to fix that). + @endproperty + @since 1.1.0 +*/ +static void +st_collections_group_inherit(void) +{ + Edje_Part_Collection *pc, *pc2; + Edje_Part *ep, *ep2; + Edje_Part_Parser *epp, *epp2; + Edje_Pack_Element *item, *item2; + Edje_Pack_Element_Parser *pitem; + Edje_Part_Description_Common *ed, *ed2; + Edje_List_Foreach_Data fdata; + Edje_String *es; + Eina_List *l; + char *parent_name; + unsigned int i, j; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + parent_name = parse_str(0); + + EINA_LIST_FOREACH(edje_collections, l, pc2) + { + if (!strcmp(parent_name, pc2->part)) + break; + } + if (!pc2) + { + ERR("%s: Error. parse error %s:%i. There isn't a group with the name %s", + progname, file_in, line - 1, parent_name); + exit(-1); + } + + if (pc2->data) + { + char *key; + + memset(&fdata, 0, sizeof(Edje_List_Foreach_Data)); + eina_hash_foreach(pc2->data, + _edje_data_item_list_foreach, &fdata); + + if (!pc->data) + pc->data = eina_hash_string_small_new(free); + + + EINA_LIST_FREE(fdata.list, key) + { + es = mem_alloc(SZ(Edje_String)); + es = (Edje_String *)eina_hash_find(pc2->data, key); + eina_hash_direct_add(pc->data, key, es); + } + } + + pc->prop.min.w = pc2->prop.min.w; + pc->prop.min.h = pc2->prop.min.h; + pc->prop.orientation = pc2->prop.orientation; + + pc->lua_script_only = pc2->lua_script_only; + + #define STRDUP(x) x ? strdup(x) : NULL + for (i = 0 ; i < pc2->parts_count ; i++) + { + // copy the part + ob_collections_group_parts_part(); + ep = pc->parts[i]; + ep2 = pc2->parts[i]; + ep->name = STRDUP(ep2->name); + ep->source = STRDUP(ep2->source); + ep->source2 = STRDUP(ep2->source2); + ep->source3 = STRDUP(ep2->source3); + ep->source4 = STRDUP(ep2->source4); + ep->source5 = STRDUP(ep2->source5); + ep->source6 = STRDUP(ep2->source6); + + data_queue_copied_part_lookup(pc, &(ep2->clip_to_id), &(ep->clip_to_id)); + + ep->type = ep2->type; + ep->mouse_events = ep2->mouse_events; + ep->repeat_events = ep2->repeat_events; + ep->ignore_flags = ep2->ignore_flags; + ep->scale = ep2->scale; + ep->pointer_mode = ep2->pointer_mode; + ep->precise_is_inside = ep2->precise_is_inside; + ep->use_alternate_font_metrics = ep2->use_alternate_font_metrics; + ep->effect = ep2->effect; + ep->entry_mode = ep2->entry_mode; + ep->select_mode = ep2->select_mode; + ep->cursor_mode = ep2->cursor_mode; + ep->multiline = ep2->multiline; + ep->dragable.x = ep2->dragable.x; + ep->dragable.step_x = ep2->dragable.step_x; + ep->dragable.count_x = ep2->dragable.count_x; + ep->dragable.y = ep2->dragable.y; + ep->dragable.step_y = ep2->dragable.step_y; + ep->dragable.count_y = ep2->dragable.count_y; + + data_queue_copied_part_lookup(pc, &(ep2->dragable.confine_id), &(ep->dragable.confine_id)); + data_queue_copied_part_lookup(pc, &(ep2->dragable.event_id), &(ep->dragable.event_id)); + + epp = (Edje_Part_Parser *)ep; + epp2 = (Edje_Part_Parser *)ep2; + epp->reorder.insert_before = STRDUP(epp2->reorder.insert_before); + epp->reorder.insert_after = STRDUP(epp2->reorder.insert_after); + epp->can_override = EINA_TRUE; + + for (j = 0 ; j < ep2->items_count ; j++) + { + ob_collections_group_parts_part_box_items_item(); + item = ep->items[j]; + item2 = ep2->items[j]; + item->type = item2->type; + item->name = STRDUP(item2->name); + item->source = STRDUP(item2->source); + item->min.w = item2->min.w; + item->min.h = item2->min.h; + item->prefer.w = item2->prefer.w; + item->prefer.h = item2->prefer.h; + item->max.w = item2->max.w; + item->max.h = item2->max.h; + item->padding.l = item2->padding.l; + item->padding.r = item2->padding.r; + item->padding.t = item2->padding.t; + item->padding.b = item2->padding.b; + item->align.x = item2->align.x; + item->align.y = item2->align.y; + item->weight.x = item2->weight.x; + item->weight.y = item2->weight.y; + item->aspect.w = item2->aspect.w; + item->aspect.h = item2->aspect.h; + item->aspect.mode = item2->aspect.mode; + item->options = STRDUP(item2->options); + item->col = item2->col; + item->row = item2->row; + item->colspan = item2->colspan; + item->rowspan = item2->rowspan; + + pitem = (Edje_Pack_Element_Parser *)item; + pitem->can_override = EINA_TRUE; + } + + ep->api.name = STRDUP(ep2->api.name); + if (ep2->api.description) ep->api.description = STRDUP(ep2->api.description); + + // copy default description + ob_collections_group_parts_part_description(); + ed = ep->default_desc; + parent_desc = ed2 = ep2->default_desc; + ed->state.name = STRDUP(ed2->state.name); + ed->state.value = ed2->state.value; + st_collections_group_parts_part_description_inherit(); + parent_desc = NULL; + + // copy other description + for (j = 0 ; j < ep2->other.desc_count ; j++) + { + ob_collections_group_parts_part_description(); + ed = ep->other.desc[j]; + parent_desc = ed2 = ep2->other.desc[j]; + ed->state.name = STRDUP(ed2->state.name); + ed->state.value = ed2->state.value; + st_collections_group_parts_part_description_inherit(); + parent_desc = NULL; + } + } + + //copy programs + for (j = 0 ; j < pc2->programs.fnmatch_count ; j++) + { + ob_collections_group_programs_program(); + _edje_program_copy(current_program, pc2->programs.fnmatch[j]); + } + for (j = 0 ; j < pc2->programs.strcmp_count ; j++) + { + ob_collections_group_programs_program(); + _edje_program_copy(current_program, pc2->programs.strcmp[j]); + } + for (j = 0 ; j < pc2->programs.strncmp_count ; j++) + { + ob_collections_group_programs_program(); + _edje_program_copy(current_program, pc2->programs.strncmp[j]); + } + for (j = 0 ; j < pc2->programs.strrncmp_count ; j++) + { + ob_collections_group_programs_program(); + _edje_program_copy(current_program, pc2->programs.strrncmp[j]); + } + for (j = 0 ; j < pc2->programs.nocmp_count ; j++) + { + ob_collections_group_programs_program(); + _edje_program_copy(current_program, pc2->programs.nocmp[j]); + } + + Code *cd, *cd2; + Code_Program *cp, *cp2; + Edje_Part_Collection_Directory_Entry *de; + + de = eina_hash_find(edje_file->collection, pc2->part); + cd2 = eina_list_nth(codes, de->id); + cd = eina_list_data_get(eina_list_last(codes)); + + EINA_LIST_FOREACH(cd2->programs, l, cp2) + { + cp = mem_alloc(SZ(Code_Program)); + + cp->l1 = cp2->l1; + cp->l2 = cp2->l2; + cp->script = STRDUP(cp2->script); + cd->is_lua = cd2->is_lua; + cd->programs = eina_list_append(cd->programs, cp); + data_queue_copied_anonymous_lookup(pc, &(cp2->id), &(cp->id)); + } + + free(parent_name); + #undef STRDUP +} + +/** + @page edcref + @property + script_only + @parameters + [on/off] + @effect + The flag (on/off) as to if this group is defined ONLY by script + callbacks such as init(), resize() and shutdown() + @endproperty +*/ +static void +st_collections_group_script_only(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + pc->lua_script_only = parse_bool(0); +} + +/** + @page edcref + @property + alias + @parameters + [aditional group name] + @effect + Additional name to serve as identifier. Defining multiple aliases is + supported. + @endproperty +*/ +static void +st_collections_group_alias(void) +{ + Edje_Part_Collection_Directory_Entry *alias; + + check_arg_count(1); + + alias = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry)); + alias->id = current_de->id; + alias->entry = parse_str(0); + + aliases = eina_list_append(aliases, alias); +} + +/** + @page edcref + @property + min + @parameters + [width] [height] + @effect + The minimum size for the container defined by the composition of the + parts. It is not enforced. + @endproperty +*/ +static void +st_collections_group_min(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(2); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + pc->prop.min.w = parse_int_range(0, 0, 0x7fffffff); + pc->prop.min.h = parse_int_range(1, 0, 0x7fffffff); +} + +/** + @page edcref + @property + max + @parameters + [width] [height] + @effect + The maximum size for the container defined by the totality of the + parts. It is not enforced. + @endproperty +*/ +static void +st_collections_group_max(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(2); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + pc->prop.max.w = parse_int_range(0, 0, 0x7fffffff); + pc->prop.max.h = parse_int_range(1, 0, 0x7fffffff); +} + +/** + @page edcref + @block + script + @context + .. + group { + script { + //embryo script + } + .. + program { + script { + //embryo script + } + } + .. + } + .. + @description + This block is used to "inject" embryo scripts to a given Edje theme and + it functions in two modalities. When it's included inside a "program" + block, the script will be executed every time the program is run, on + the other hand, when included directly into a "group", "part" or + "description" block, it will be executed once at load time, in the + load order. + @endblock +*/ +static void +ob_collections_group_script(void) +{ + Code *cd; + + cd = eina_list_data_get(eina_list_last(codes)); + + if (!is_verbatim()) track_verbatim(1); + else + { + char *s; + + s = get_verbatim(); + if (s) + { + cd->l1 = get_verbatim_line1(); + cd->l2 = get_verbatim_line2(); + if (cd->shared) + { + ERR("%s: Error. parse error %s:%i. There is already an existing script section for the group", + progname, file_in, line - 1); + exit(-1); + } + cd->shared = s; + cd->original = strdup(s); + cd->is_lua = 0; + set_verbatim(NULL, 0, 0); + } + } +} + +static void +ob_collections_group_lua_script(void) +{ + Code *cd; + + cd = eina_list_data_get(eina_list_last(codes)); + + if (!is_verbatim()) track_verbatim(1); + else + { + char *s; + + s = get_verbatim(); + if (s) + { + cd->l1 = get_verbatim_line1(); + cd->l2 = get_verbatim_line2(); + if (cd->shared) + { + ERR("%s: Error. parse error %s:%i. There is already an existing script section for the group", + progname, file_in, line - 1); + exit(-1); + } + cd->shared = s; + cd->is_lua = 1; + set_verbatim(NULL, 0, 0); + } + } +} + +static void +st_collections_group_data_item(void) +{ + Edje_Part_Collection *pc; + Edje_String *es; + char *key; + + check_arg_count(2); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + if (!pc->data) + pc->data = eina_hash_string_small_new(free); + + key = parse_str(0); + + es = mem_alloc(SZ(Edje_String)); + es->str = parse_str(1); + + if (eina_hash_find(pc->data, key)) + eina_hash_modify(pc->data, key, es); + else + eina_hash_direct_add(pc->data, key, es); +} + +/** + @page edcref + @property + orientation + @parameters + enum AUTO, LTR, RTL + @effect + This defines GROUP orientation. + This is useful if you want match interface orientation with language. + AUTO - Follow system defs. + LTR - suitable for Left To Right Languages (latin) + RTL - suitable for Right To Left Languages (Hebrew, Arabic interface) + @endproperty +*/ +static void +st_collections_group_orientation(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + pc->prop.orientation = parse_enum(0, + "AUTO", EDJE_ORIENTATION_AUTO, + "LTR", EDJE_ORIENTATION_LTR, + "RTL", EDJE_ORIENTATION_RTL, + NULL); +} + +/** + @page edcref + @block + limits + @context + group { + limits { + vertical: "limit_name" height_barrier; + horizontal: "limit_name" width_barrier; + .. + } + .. + } + .. + @description + This block is used to trigger some signal when the Edje object is resized. + @endblock + + @edcref + @property + vertical + @parameters + [name] [height barrier] + @effect + It will send a signal: "limit,name,over" when the object is resized and pass + the limit by growing over it. And it will send: "limit,name,below" when + it pass below that limit. + This limit will be applied on the y absis. + @endproperty +*/ +static void +st_collections_group_limits_vertical(void) +{ + Edje_Part_Collection *pc; + Edje_Limit *el; + + check_arg_count(2); + + el = mem_alloc(SZ(Edje_Limit)); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + pc->limits.vertical_count++; + pc->limits.vertical = realloc(pc->limits.vertical, pc->limits.vertical_count * sizeof (Edje_Limit *)); + if (!pc->limits.vertical || !el) + { + ERR("%s: Error. Not enough memory.", progname); + exit(-1); + } + + pc->limits.vertical[pc->limits.vertical_count - 1] = el; + + el->name = parse_str(0); + el->value = parse_int_range(1, 1, 0xffff); +} + +/** + @page edcref + @property + horizontal + @parameters + [name] [width barrier] + @effect + It will send a signal: "limit,name,over" when the object is resized and pass + the limit by growing over it. And it will send: "limit,name,below" when + it pass below that limit. + This limit will be applied on the x absis. + @endproperty +*/ +static void +st_collections_group_limits_horizontal(void) +{ + Edje_Part_Collection *pc; + Edje_Limit *el; + + check_arg_count(2); + + el = mem_alloc(SZ(Edje_Limit)); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + pc->limits.horizontal_count++; + pc->limits.horizontal = realloc(pc->limits.horizontal, pc->limits.horizontal_count * sizeof (Edje_Limit *)); + if (!pc->limits.horizontal || !el) + { + ERR("%s: Error. Not enough memory.", progname); + exit(-1); + } + + pc->limits.horizontal[pc->limits.horizontal_count - 1] = el; + + el->name = parse_str(0); + el->value = parse_int_range(1, 1, 0xffff); +} + +/** + @page edcref + @block + parts + @context + group { + parts { + alias: "theme_part_path" "real_part_path"; + .. + } + } + @description + Alias of part give a chance to let the designer put the real one + in a box or reuse one from a GROUP or inside a BOX. + @endblock +*/ +static void +st_collections_group_parts_alias(void) +{ + Edje_Part_Collection *pc; + const char *alias; + const char *aliased; + + check_arg_count(2); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + alias = parse_str(0); + aliased = parse_str(1); + + if (!pc->alias) pc->alias = eina_hash_string_small_new(NULL); + eina_hash_add(pc->alias, alias, aliased); + + if (!pc->aliased) pc->aliased = eina_hash_string_small_new(NULL); + eina_hash_add(pc->aliased, aliased, alias); +} + + +/** + @page edcref + @block + part + @context + group { + parts { + .. + part { + name: "partname"; + type: IMAGE; + mouse_events: 1; + repeat_events: 0; + ignore_flags: NONE; + clip_to: "anotherpart"; + source: "groupname"; + pointer_mode: AUTOGRAB; + use_alternate_font_metrics: 0; + + description { } + dragable { } + items { } + } + .. + } + } + @description + Parts are used to represent the most basic design elements of the + theme, for example, a part can represent a line in a border or a label + on a button. + @endblock +*/ +static void +ob_collections_group_parts_part(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Parser *epp; + + ep = mem_alloc(SZ(Edje_Part_Parser)); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + pc->parts_count++; + pc->parts = realloc(pc->parts, pc->parts_count * sizeof (Edje_Part *)); + if (!pc->parts) + { + ERR("%s: Error. Not enough memory.", progname); + exit(-1); + } + current_part = pc->parts[pc->parts_count - 1] = ep; + + ep->id = pc->parts_count - 1; + ep->type = EDJE_PART_TYPE_IMAGE; + ep->mouse_events = 1; + ep->repeat_events = 0; + ep->ignore_flags = EVAS_EVENT_FLAG_NONE; + ep->scale = 0; + ep->pointer_mode = EVAS_OBJECT_POINTER_MODE_AUTOGRAB; + ep->precise_is_inside = 0; + ep->use_alternate_font_metrics = 0; + ep->clip_to_id = -1; + ep->dragable.confine_id = -1; + ep->dragable.event_id = -1; + ep->items = NULL; + + epp = (Edje_Part_Parser *)ep; + epp->reorder.insert_before = NULL; + epp->reorder.insert_after = NULL; + epp->reorder.before = NULL; + epp->reorder.after = NULL; + epp->reorder.linked_prev = 0; + epp->reorder.linked_next = 0; + epp->reorder.done = EINA_FALSE; + epp->can_override = EINA_FALSE; +} + +/** + @page edcref + @property + name + @parameters + [part name] + @effect + The part's name will be used as reference in the theme's relative + positioning system, by programs and in some cases by the application. + It must be unique within the group. + @endproperty +*/ +static void +st_collections_group_parts_part_name(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Parser *epp; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = current_part; + ep->name = parse_str(0); + + if (ep->name) + { + unsigned int i; + + for (i = 0; i < (pc->parts_count - 1); i++) + { + if (pc->parts[i]->name && (!strcmp(pc->parts[i]->name, ep->name))) + { + epp = (Edje_Part_Parser *)pc->parts[i]; + if (!epp->can_override) + { + ERR("%s: Error. parse error %s:%i. There is already a part of the name %s", + progname, file_in, line - 1, ep->name); + exit(-1); + } + else + { + free(ep); + pc->parts_count--; + pc->parts = realloc(pc->parts, pc->parts_count * sizeof (Edje_Part *)); + ep = current_part = pc->parts[i]; + epp->can_override = EINA_FALSE; + break; + } + } + } + } +} + +/** + @page edcref + @property + type + @parameters + [TYPE] + @effect + Set the type (all caps) from among the available types, it's set to + IMAGE by default. Valid types: + @li RECT + @li TEXT + @li IMAGE + @li SWALLOW + @li TEXTBLOCK + @li GROUP + @li BOX + @li TABLE + @li EXTERNAL + @li PROXY + @endproperty +*/ +static void +st_collections_group_parts_part_type(void) +{ + check_arg_count(1); + + current_part->type = parse_enum(0, + "NONE", EDJE_PART_TYPE_NONE, + "RECT", EDJE_PART_TYPE_RECTANGLE, + "TEXT", EDJE_PART_TYPE_TEXT, + "IMAGE", EDJE_PART_TYPE_IMAGE, + "SWALLOW", EDJE_PART_TYPE_SWALLOW, + "TEXTBLOCK", EDJE_PART_TYPE_TEXTBLOCK, + "GROUP", EDJE_PART_TYPE_GROUP, + "BOX", EDJE_PART_TYPE_BOX, + "TABLE", EDJE_PART_TYPE_TABLE, + "EXTERNAL", EDJE_PART_TYPE_EXTERNAL, + "PROXY", EDJE_PART_TYPE_PROXY, + NULL); +} + +/** + @page edcref + @property + insert_before + @parameters + [another part's name] + @effect + The part's name which this part is inserted before. One part cannot + have both insert_before and insert_after. One part cannot refer + more than one by insert_before. + @endproperty + @since 1.1.0 +*/ +static void +st_collections_group_parts_part_insert_before(void) +{ + Edje_Part_Parser *epp; + check_arg_count(1); + + epp = (Edje_Part_Parser *)current_part; + epp->reorder.insert_before = parse_str(0); +} + +/** + @page edcref + @property + insert_after + @parameters + [another part's name] + @effect + The part's name which this part is inserted after. One part cannot + have both insert_before and insert_after. One part cannot refer + more than one by insert_after. + @endproperty + @since 1.1.0 +*/ +static void +st_collections_group_parts_part_insert_after(void) +{ + Edje_Part_Parser *epp; + check_arg_count(1); + + epp = (Edje_Part_Parser *)current_part; + epp->reorder.insert_after = parse_str(0); +} + +/** + @page edcref + @property + mouse_events + @parameters + [1 or 0] + @effect + Specifies whether the part will emit signals, although it is named + "mouse_events", disabling it (0) will prevent the part from emitting + any type of signal at all. It's set to 1 by default. + @endproperty +*/ +static void +st_collections_group_parts_part_mouse_events(void) +{ + check_arg_count(1); + + current_part->mouse_events = parse_bool(0); +} + +/** + @page edcref + @property + repeat_events + @parameters + [1 or 0] + @effect + Specifies whether a part echoes a mouse event to other parts below the + pointer (1), or not (0). It's set to 0 by default. + @endproperty +*/ +static void +st_collections_group_parts_part_repeat_events(void) +{ + check_arg_count(1); + + current_part->repeat_events = parse_bool(0); +} + +/** + @page edcref + @property + ignore_flags + @parameters + [FLAG] ... + @effect + Specifies whether events with the given flags should be ignored, + i.e., will not have the signals emitted to the parts. Multiple flags + must be separated by spaces, the effect will be ignoring all events + with one of the flags specified. Possible flags: + @li NONE (default value, no event will be ignored) + @li ON_HOLD + @endproperty +*/ +static void +st_collections_group_parts_part_ignore_flags(void) +{ + check_min_arg_count(1); + + current_part->ignore_flags = parse_flags(0, + "NONE", EVAS_EVENT_FLAG_NONE, + "ON_HOLD", EVAS_EVENT_FLAG_ON_HOLD, + NULL); +} + +/** + @page edcref + @property + scale + @parameters + [1 or 0] + @effect + Specifies whether the part will scale its size with an edje scaling + factor. By default scale is off (0) and the default scale factor is + 1.0 - that means no scaling. This would be used to scale properties + such as font size, min/max size of the part, and possibly can be used + to scale based on DPI of the target device. The reason to be selective + is that some things work well being scaled, others do not, so the + designer gets to choose what works best. + @endproperty +*/ +static void +st_collections_group_parts_part_scale(void) +{ + check_arg_count(1); + + current_part->scale = parse_bool(0); +} + +/** + @page edcref + @property + pointer_mode + @parameters + [MODE] + @effect + Sets the mouse pointer behavior for a given part. The default value is + AUTOGRAB. Aviable modes: + @li AUTOGRAB, when the part is clicked and the button remains + pressed, the part will be the source of all future mouse + signals emitted, even outside the object, until the button is + released. + @li NOGRAB, the effect will be limited to the part's container. + @endproperty +*/ +static void +st_collections_group_parts_part_pointer_mode(void) +{ + check_arg_count(1); + + current_part->pointer_mode = parse_enum(0, + "AUTOGRAB", EVAS_OBJECT_POINTER_MODE_AUTOGRAB, + "NOGRAB", EVAS_OBJECT_POINTER_MODE_NOGRAB, + NULL); +} + +/** + @page edcref + @property + precise_is_inside + @parameters + [1 or 0] + @effect + Enables precise point collision detection for the part, which is more + resource intensive. Disabled by default. + @endproperty +*/ +static void +st_collections_group_parts_part_precise_is_inside(void) +{ + check_arg_count(1); + + current_part->precise_is_inside = parse_bool(0); +} + +/** + @page edcref + @property + use_alternate_font_metrics + @parameters + [1 or 0] + @effect + Only affects text and textblock parts, when enabled Edje will use + different size measurement functions. Disabled by default. (note from + the author: I don't know what this is exactlu useful for?) + @endproperty +*/ +static void +st_collections_group_parts_part_use_alternate_font_metrics(void) +{ + check_arg_count(1); + + current_part->use_alternate_font_metrics = parse_bool(0); +} + +/** + @page edcref + @property + clip_to + @parameters + [another part's name] + @effect + Only renders the area of part that coincides with another part's + container. Overflowing content will not be displayed. + @endproperty +*/ +static void +st_collections_group_parts_part_clip_to_id(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_part->clip_to_id)); + free(name); + } +} + +/** + @page edcref + @property + source + @parameters + [another group's name] + @effect + Only available to GROUP or TEXTBLOCK parts. Swallows the specified + group into the part's container if a GROUP. If TEXTBLOCK it is used + for the group to be loaded and used for selection display UNDER the + selected text. source2 is used for on top of the selected text, if + source2 is specified. + @endproperty +*/ +static void +st_collections_group_parts_part_source(void) +{ + check_arg_count(1); + + //FIXME: validate this somehow (need to decide on the format also) + current_part->source = parse_str(0); +} + +/** + @page edcref + @property + source2 + @parameters + [another group's name] + @effect + Only available to TEXTBLOCK parts. It is used for the group to be + loaded and used for selection display OVER the selected text. source + is used for under of the selected text, if source is specified. + @endproperty +*/ +static void +st_collections_group_parts_part_source2(void) +{ + check_arg_count(1); + + //FIXME: validate this somehow (need to decide on the format also) + current_part->source2 = parse_str(0); +} + +/** + @page edcref + @property + source3 + @parameters + [another group's name] + @effect + Only available to TEXTBLOCK parts. It is used for the group to be + loaded and used for cursor display UNDER the cursor position. source4 + is used for over the cursor text, if source4 is specified. + @endproperty +*/ +static void +st_collections_group_parts_part_source3(void) +{ + check_arg_count(1); + + //FIXME: validate this somehow (need to decide on the format also) + current_part->source3 = parse_str(0); +} + +/** + @page edcref + @property + source4 + @parameters + [another group's name] + @effect + Only available to TEXTBLOCK parts. It is used for the group to be + loaded and used for cursor display OVER the cursor position. source3 + is used for under the cursor text, if source4 is specified. + @endproperty +*/ +static void +st_collections_group_parts_part_source4(void) +{ + check_arg_count(1); + + //FIXME: validate this somehow (need to decide on the format also) + current_part->source4 = parse_str(0); +} + +/** + @page edcref + @property + source5 + @parameters + [another group's name] + @effect + Only available to TEXTBLOCK parts. It is used for the group to be + loaded and used for anchors display UNDER the anchor position. source6 + is used for over the anchors text, if source6 is specified. + @endproperty +*/ +static void +st_collections_group_parts_part_source5(void) +{ + check_arg_count(1); + + //FIXME: validate this somehow (need to decide on the format also) + current_part->source5 = parse_str(0); +} + +/** + @page edcref + @property + source6 + @parameters + [another group's name] + @effect + Only available to TEXTBLOCK parts. It is used for the group to be + loaded and used for anchor display OVER the anchor position. source5 + is used for under the anchor text, if source6 is specified. + @endproperty +*/ +static void +st_collections_group_parts_part_source6(void) +{ + check_arg_count(1); + + //FIXME: validate this somehow (need to decide on the format also) + current_part->source6 = parse_str(0); +} + +/** + @page edcref + + @property + effect + @parameters + [EFFECT] + (optional) [SHADOW DIRECTION] + @effect + Causes Edje to draw the selected effect among: + @li PLAIN + @li OUTLINE + @li SOFT_OUTLINE + @li SHADOW + @li SOFT_SHADOW + @li OUTLINE_SHADOW + @li OUTLINE_SOFT_SHADOW + @li FAR_SHADOW + @li FAR_SOFT_SHADOW + @li GLOW + + Shadow directions (default if not given is BOTTOM_RIGHT): + @li BOTTOM_RIGHT + @li BOTTOM + @li BOTTOM_LEFT + @li LEFT + @li TOP_LEFT + @li TOP + @li TOP_RIGHT + @li RIGHT + @endproperty +*/ +static void +st_collections_group_parts_part_effect(void) +{ + check_min_arg_count(1); + + current_part->effect = parse_enum(0, + "NONE", EDJE_TEXT_EFFECT_NONE, + "PLAIN", EDJE_TEXT_EFFECT_PLAIN, + "OUTLINE", EDJE_TEXT_EFFECT_OUTLINE, + "SOFT_OUTLINE", EDJE_TEXT_EFFECT_SOFT_OUTLINE, + "SHADOW", EDJE_TEXT_EFFECT_SHADOW, + "SOFT_SHADOW", EDJE_TEXT_EFFECT_SOFT_SHADOW, + "OUTLINE_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SHADOW, + "OUTLINE_SOFT_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW, + "FAR_SHADOW", EDJE_TEXT_EFFECT_FAR_SHADOW, + "FAR_SOFT_SHADOW", EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW, + "GLOW", EDJE_TEXT_EFFECT_GLOW, + NULL); + if (get_arg_count() >= 2) + { + unsigned char shadow; + + shadow = parse_enum(1, + "BOTTOM_RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT, + "BOTTOM", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM, + "BOTTOM_LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT, + "LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT, + "TOP_LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT, + "TOP", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP, + "TOP_RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT, + "RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT, + NULL); + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_SET(current_part->effect, shadow); + } +} + +/** + @page edcref + @property + entry_mode + @parameters + [MODE] + @effect + Sets the edit mode for a textblock part to one of: + @li NONE + @li PLAIN + @li EDITABLE + @li PASSWORD + It causes the part be editable if the edje object has the keyboard + focus AND the part has the edje focus (or selectable always + regardless of focus) and in the event of password mode, not + selectable and all text chars replaced with *'s but editable and + pastable. + @endproperty +*/ +static void +st_collections_group_parts_part_entry_mode(void) +{ + check_arg_count(1); + + current_part->entry_mode = parse_enum(0, + "NONE", EDJE_ENTRY_EDIT_MODE_NONE, + "PLAIN", EDJE_ENTRY_EDIT_MODE_SELECTABLE, + "EDITABLE", EDJE_ENTRY_EDIT_MODE_EDITABLE, + "PASSWORD", EDJE_ENTRY_EDIT_MODE_PASSWORD, + NULL); +} + +/** + @page edcref + @property + select_mode + @parameters + [MODE] + @effect + Sets the selection mode for a textblock part to one of: + @li DEFAULT + @li EXPLICIT + DEFAULT selection mode is what you would expect on any desktop. Press + mouse, drag and release to end. EXPLICIT mode requires the application + controlling the edje object has to explicitly begin and end selection + modes, and the selection itself is dragable at both ends. + @endproperty +*/ +static void +st_collections_group_parts_part_select_mode(void) +{ + check_arg_count(1); + + current_part->select_mode = parse_enum(0, + "DEFAULT", EDJE_ENTRY_SELECTION_MODE_DEFAULT, + "EXPLICIT", EDJE_ENTRY_SELECTION_MODE_EXPLICIT, + NULL); +} + +/** + @page edcref + @property + cursor_mode + @parameters + [MODE] + @effect + Sets the cursor mode for a textblock part to one of: + @li UNDER + @li BEFORE + UNDER cursor mode means the cursor will draw below the character pointed + at. That's the default. + BEFORE cursor mode means the cursor is drawn as a vertical line before + the current character, just like many other GUI toolkits handle it. + @endproperty +*/ +static void +st_collections_group_parts_part_cursor_mode(void) +{ + check_arg_count(1); + + current_part->cursor_mode = parse_enum(0, + "UNDER", EDJE_ENTRY_CURSOR_MODE_UNDER, + "BEFORE", EDJE_ENTRY_CURSOR_MODE_BEFORE, + NULL); +} + +/** + @page edcref + @property + multiline + @parameters + [1 or 0] + @effect + It causes a textblock that is editable to allow multiple lines for + editing. + @endproperty +*/ +static void +st_collections_group_parts_part_multiline(void) +{ + check_arg_count(1); + + current_part->multiline = parse_bool(0); +} + +/** + @page edcref + @block + dragable + @context + part { + .. + dragable { + confine: "another part"; + events: "another dragable part"; + x: 0 0 0; + y: 0 0 0; + } + .. + } + @description + When this block is used the resulting part can be dragged around the + interface, do not confuse with external drag & drop. By default Edje + (and most applications) will attempt to use the minimal size possible + for a dragable part. If the min property is not set in the description + the part will be (most likely) set to 0px width and 0px height, thus + invisible. + @endblock + + @property + x + @parameters + [enable/disable] [step] [count] + @effect + Used to setup dragging events for the X axis. The first parameter is + used to enable (1 or -1) and disable (0) dragging along the axis. When + enabled, 1 will set the starting point at 0.0 and -1 at 1.0. The second + parameter takes any integer and will limit movement to values + divisible by it, causing the part to jump from position to position. + The third parameter, (question from the author: What is count for?). + @endproperty +*/ +static void +st_collections_group_parts_part_dragable_x(void) +{ + check_arg_count(3); + + current_part->dragable.x = parse_int_range(0, -1, 1); + current_part->dragable.step_x = parse_int_range(1, 0, 0x7fffffff); + current_part->dragable.count_x = parse_int_range(2, 0, 0x7fffffff); +} + +/** + @page edcref + @property + y + @parameters + [enable/disable] [step] [count] + @effect + Used to setup dragging events for the Y axis. The first parameter is + used to enable (1 or -1) and disable (0) dragging along the axis. When + enabled, 1 will set the starting point at 0.0 and -1 at 1.0. The second + parameter takes any integer and will limit movement to values + divisibles by it, causing the part to jump from position to position. + The third parameter, (question from the author: What is count for?). + @endproperty +*/ +static void +st_collections_group_parts_part_dragable_y(void) +{ + check_arg_count(3); + + current_part->dragable.y = parse_int_range(0, -1, 1); + current_part->dragable.step_y = parse_int_range(1, 0, 0x7fffffff); + current_part->dragable.count_y = parse_int_range(2, 0, 0x7fffffff); +} + +/** + @page edcref + @property + confine + @parameters + [another part's name] + @effect + When set, limits the movement of the dragged part to another part's + container. When you use confine don't forget to set a min size for the + part, or the draggie will not show up. + @endproperty +*/ +static void +st_collections_group_parts_part_dragable_confine(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_part->dragable.confine_id)); + free(name); + } +} + +/** + @page edcref + @property + events + @parameters + [another dragable part's name] + @effect + It causes the part to forward the drag events to another part, thus + ignoring them for itself. + @endproperty +*/ +static void +st_collections_group_parts_part_dragable_events(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_part->dragable.event_id)); + free(name); + } +} + +/** + @page edcref + @block + items + @context + part { + .. + box { + items { + item { + type: TYPE; + source: "some source"; + min: 1 1; + max: 100 100; + padding: 1 1 2 2; + } + item { + type: TYPE; + source: "some other source"; + name: "some name"; + align: 1.0 0.5; + } + .. + } + } + .. + } + @description + On a part of type BOX, this block can be used to set other groups + as elements of the box. These can be mixed with external objects set + by the application through the edje_object_part_box_* API. + @endblock +*/ +static void ob_collections_group_parts_part_box_items_item(void) +{ + Edje_Part *ep; + Edje_Pack_Element *item; + Edje_Pack_Element_Parser *pitem; + + ep = current_part; + + if ((ep->type != EDJE_PART_TYPE_BOX) && (ep->type != EDJE_PART_TYPE_TABLE)) + { + ERR("%s: Error. parse error %s:%i. " + "box attributes in non-BOX or TABLE part.", + progname, file_in, line - 1); + exit(-1); + } + + ep->items_count++; + ep->items = realloc(ep->items, sizeof (Edje_Pack_Element*) * ep->items_count); + if (!ep->items) + { + ERR("%s: Error. Not enough memory.", progname); + exit(-1); + } + + item = mem_alloc(SZ(Edje_Pack_Element_Parser)); + current_item = ep->items[ep->items_count - 1] = item; + item->type = EDJE_PART_TYPE_GROUP; + item->name = NULL; + item->source = NULL; + item->min.w = 0; + item->min.h = 0; + item->prefer.w = 0; + item->prefer.h = 0; + item->max.w = -1; + item->max.h = -1; + item->padding.l = 0; + item->padding.r = 0; + item->padding.t = 0; + item->padding.b = 0; + item->align.x = FROM_DOUBLE(0.5); + item->align.y = FROM_DOUBLE(0.5); + item->weight.x = FROM_DOUBLE(0.0); + item->weight.y = FROM_DOUBLE(0.0); + item->aspect.w = 0; + item->aspect.h = 0; + item->aspect.mode = EDJE_ASPECT_CONTROL_NONE; + item->options = NULL; + item->col = -1; + item->row = -1; + item->colspan = 1; + item->rowspan = 1; + pitem = (Edje_Pack_Element_Parser *)item; + pitem->can_override = EINA_FALSE; +} + +/** + @page edcref + @property + type + @parameters + Only GROUP for now (defaults to it) + @effect + Sets the type of the object this item will hold. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_type(void) +{ + check_arg_count(1); + + { + char *s; + + s = parse_str(0); + if (strcmp(s, "GROUP")) + { + ERR("%s: Error. parse error %s:%i. " + "token %s not one of: GROUP.", + progname, file_in, line - 1, s); + exit(-1); + } + /* FIXME: handle the enum, once everything else is supported */ + current_item->type = EDJE_PART_TYPE_GROUP; + } +} + +/** + @page edcref + @property + name + @parameters + [name for the object] + @effect + Sets the name of the object via evas_object_name_set(). + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_name(void) +{ + Edje_Part *ep; + Edje_Pack_Element *item; + Edje_Pack_Element_Parser *pitem; + + check_arg_count(1); + + ep = current_part; + item = ep->items[ep->items_count - 1]; + + item->name = parse_str(0); + + { + unsigned int i; + + for (i = 0; i < ep->items_count - 1; ++i) + { + if (ep->items[i]->name && (!strcmp(ep->items[i]->name, item->name))) + { + pitem = (Edje_Pack_Element_Parser *)ep->items[i]; + if (!pitem->can_override) + { + ERR("%s: Error. parse error %s:%i. There is already a item of the name %s", + progname, file_in, line - 1, item->name); + exit(-1); + } + else + { + free(item); + ep->items_count--; + ep->items = realloc(ep->items, ep->items_count * sizeof (Edje_Pack_Element *)); + current_item = ep->items[i]; + pitem->can_override = EINA_FALSE; + } + } + } + } +} + +/** + @page edcref + @property + source + @parameters + [another group's name] + @effect + Sets the group this object will be made from. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_source(void) +{ + check_arg_count(1); + + current_item->source = parse_str(0); +} + +/** + @page edcref + @property + min + @parameters + [width] [height] + @effect + Sets the minimum size hints for this object. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_min(void) +{ + check_arg_count(2); + + current_item->min.w = parse_int_range(0, 0, 0x7ffffff); + current_item->min.h = parse_int_range(1, 0, 0x7ffffff); +} + +/** + @page edcref + @property + prefer + @parameters + [width] [height] + @effect + Sets the preferred size hints for this object. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_prefer(void) +{ + check_arg_count(2); + + current_item->prefer.w = parse_int_range(0, 0, 0x7ffffff); + current_item->prefer.h = parse_int_range(1, 0, 0x7ffffff); +} +/** + @page edcref + @property + max + @parameters + [width] [height] + @effect + Sets the maximum size hints for this object. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_max(void) +{ + check_arg_count(2); + + current_item->max.w = parse_int_range(0, 0, 0x7ffffff); + current_item->max.h = parse_int_range(1, 0, 0x7ffffff); +} + +/** + @page edcref + @property + padding + @parameters + [left] [right] [top] [bottom] + @effect + Sets the padding hints for this object. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_padding(void) +{ + check_arg_count(4); + + current_item->padding.l = parse_int_range(0, 0, 0x7ffffff); + current_item->padding.r = parse_int_range(1, 0, 0x7ffffff); + current_item->padding.t = parse_int_range(2, 0, 0x7ffffff); + current_item->padding.b = parse_int_range(3, 0, 0x7ffffff); +} + +/** + @page edcref + @property + align + @parameters + [x] [y] + @effect + Sets the alignment hints for this object. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_align(void) +{ + check_arg_count(2); + + current_item->align.x = FROM_DOUBLE(parse_float_range(0, -1.0, 1.0)); + current_item->align.y = FROM_DOUBLE(parse_float_range(1, -1.0, 1.0)); +} + +/** + @page edcref + @property + weight + @parameters + [x] [y] + @effect + Sets the weight hints for this object. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_weight(void) +{ + check_arg_count(2); + + current_item->weight.x = FROM_DOUBLE(parse_float_range(0, 0.0, 99999.99)); + current_item->weight.y = FROM_DOUBLE(parse_float_range(1, 0.0, 99999.99)); +} + +/** + @page edcref + @property + aspect + @parameters + [w] [h] + @effect + Sets the aspect width and height hints for this object. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_aspect(void) +{ + check_arg_count(2); + + current_item->aspect.w = parse_int_range(0, 0, 0x7fffffff); + current_item->aspect.h = parse_int_range(1, 0, 0x7fffffff); +} + +/** + @page edcref + @property + aspect_mode + @parameters + NONE, NEITHER, HORIZONTAL, VERTICAL, BOTH + @effect + Sets the aspect control hints for this object. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_aspect_mode(void) +{ + check_arg_count(1); + + current_item->aspect.mode = parse_enum(0, + "NONE", EDJE_ASPECT_CONTROL_NONE, + "NEITHER", EDJE_ASPECT_CONTROL_NEITHER, + "HORIZONTAL", EDJE_ASPECT_CONTROL_HORIZONTAL, + "VERTICAL", EDJE_ASPECT_CONTROL_VERTICAL, + "BOTH", EDJE_ASPECT_CONTROL_BOTH, + NULL); +} + +/** + @page edcref + @property + options + @parameters + [extra options] + @effect + Sets extra options for the object. Unused for now. + @endproperty +*/ +static void st_collections_group_parts_part_box_items_item_options(void) +{ + check_arg_count(1); + + current_item->options = parse_str(0); +} + +/** + @page edcref + @property + position + @parameters + [col] [row] + @effect + Sets the position this item will have in the table. + This is required for parts of type TABLE. + @endproperty +*/ +static void st_collections_group_parts_part_table_items_item_position(void) +{ + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_TABLE) + { + ERR("%s: Error. parse error %s:%i. " + "table attributes in non-TABLE part.", + progname, file_in, line - 1); + exit(-1); + } + + current_item->col = parse_int_range(0, 0, 0xffff); + current_item->row = parse_int_range(1, 0, 0xffff); +} + +/** + @page edcref + @property + span + @parameters + [col] [row] + @effect + Sets how many columns/rows this item will use. + Defaults to 1 1. + @endproperty +*/ +static void st_collections_group_parts_part_table_items_item_span(void) +{ + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_TABLE) + { + ERR("%s: Error. parse error %s:%i. " + "table attributes in non-TABLE part.", + progname, file_in, line - 1); + exit(-1); + } + + current_item->colspan = parse_int_range(0, 1, 0xffff); + current_item->rowspan = parse_int_range(1, 1, 0xffff); +} + +/** + @edcsection{description,State description sub blocks} + */ + +/** + @page edcref + @block + description + @context + description { + inherit: "another_description" INDEX; + state: "description_name" INDEX; + visible: 1; + min: 0 0; + max: -1 -1; + align: 0.5 0.5; + fixed: 0 0; + step: 0 0; + aspect: 1 1; + + rel1 { + .. + } + + rel2 { + .. + } + } + @description + Every part can have one or more description blocks. Each description is + used to define style and layout properties of a part in a given + "state". + @endblock +*/ +static void +ob_collections_group_parts_part_description(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description_Common *ed; + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = current_part; + + ed = _edje_part_description_alloc(ep->type, pc->part, ep->name); + + if (!ep->default_desc) + { + current_desc = ep->default_desc = ed; + } + else + { + ep->other.desc_count++; + ep->other.desc = realloc(ep->other.desc, + sizeof (Edje_Part_Description_Common*) * ep->other.desc_count); + current_desc = ep->other.desc[ep->other.desc_count - 1] = ed; + } + + ed->visible = 1; + ed->align.x = FROM_DOUBLE(0.5); + ed->align.y = FROM_DOUBLE(0.5); + ed->min.w = 0; + ed->min.h = 0; + ed->fixed.w = 0; + ed->fixed.h = 0; + ed->max.w = -1; + ed->max.h = -1; + ed->rel1.relative_x = FROM_DOUBLE(0.0); + ed->rel1.relative_y = FROM_DOUBLE(0.0); + ed->rel1.offset_x = 0; + ed->rel1.offset_y = 0; + ed->rel1.id_x = -1; + ed->rel1.id_y = -1; + ed->rel2.relative_x = FROM_DOUBLE(1.0); + ed->rel2.relative_y = FROM_DOUBLE(1.0); + ed->rel2.offset_x = -1; + ed->rel2.offset_y = -1; + ed->rel2.id_x = -1; + ed->rel2.id_y = -1; + ed->color_class = NULL; + ed->color.r = 255; + ed->color.g = 255; + ed->color.b = 255; + ed->color.a = 255; + ed->color2.r = 0; + ed->color2.g = 0; + ed->color2.b = 0; + ed->color2.a = 255; + ed->map.id_persp = -1; + ed->map.id_light = -1; + ed->map.rot.id_center = -1; + ed->map.rot.x = FROM_DOUBLE(0.0); + ed->map.rot.y = FROM_DOUBLE(0.0); + ed->map.rot.z = FROM_DOUBLE(0.0); + ed->map.on = 0; + ed->map.smooth = 1; + ed->map.alpha = 1; + ed->map.backcull = 0; + ed->map.persp_on = 0; + ed->persp.zplane = 0; + ed->persp.focal = 1000; +} + +/** + @page edcref + @property + inherit + @parameters + [another description's name] [another description's index] + @effect + When set, the description will inherit all the properties from the + named description. The properties defined in this part will override + the inherited properties, reducing the amount of necessary code for + simple state changes. Note: inheritance in Edje is single level only. + @endproperty +*/ +static void +st_collections_group_parts_part_description_inherit(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description_Common *ed, *parent = NULL; + Edje_Part_Image_Id *iid; + char *parent_name; + const char *state_name; + double parent_val, state_val; + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = current_part; + ed = current_desc; + + if (!ed->state.name) + { + ERR("%s: Error. parse error %s:%i. " + "inherit may only be used after state", + progname, file_in, line - 1); + exit(-1); + } + + parent = parent_desc; + if (!parent) + { + check_arg_count(2); + + /* inherit may not be used in the default description */ + if (!ep->other.desc_count) + { + ERR("%s: Error. parse error %s:%i. " + "inherit may not be used in the default description", + progname, file_in, line - 1); + exit(-1); + } + + /* find the description that we inherit from */ + parent_name = parse_str(0); + parent_val = parse_float_range(1, 0.0, 1.0); + + if (!strcmp (parent_name, "default") && parent_val == 0.0) + parent = ep->default_desc; + else + { + Edje_Part_Description_Common *d; + double min_dst = 999.0; + unsigned int i; + + if (!strcmp(parent_name, "default")) + { + parent = ep->default_desc; + min_dst = ABS(ep->default_desc->state.value - parent_val); + } + + for (i = 0; i < ep->other.desc_count; ++i) + { + d = ep->other.desc[i]; + + if (!strcmp (d->state.name, parent_name)) + { + + double dst; + + dst = ABS(d->state.value - parent_val); + if (dst < min_dst) + { + parent = d; + min_dst = dst; + } + } + } + } + + if (!parent) + { + ERR("%s: Error. parse error %s:%i. " + "cannot find referenced part state %s %lf", + ep->name, file_in, line - 1, parent_name, parent_val); + exit(-1); + } + + free(parent_name); + } + /* now do a full copy, only state info will be kept */ + state_name = ed->state.name; + state_val = ed->state.value; + + *ed = *parent; + + ed->state.name = state_name; + ed->state.value = state_val; + + data_queue_copied_part_lookup(pc, &parent->rel1.id_x, &ed->rel1.id_x); + data_queue_copied_part_lookup(pc, &parent->rel1.id_y, &ed->rel1.id_y); + data_queue_copied_part_lookup(pc, &parent->rel2.id_x, &ed->rel2.id_x); + data_queue_copied_part_lookup(pc, &parent->rel2.id_y, &ed->rel2.id_y); + + data_queue_copied_part_lookup(pc, &parent->map.id_persp, &ed->map.id_persp); + data_queue_copied_part_lookup(pc, &parent->map.id_light, &ed->map.id_light); + data_queue_copied_part_lookup(pc, &parent->map.rot.id_center, &ed->map.rot.id_center); + + /* make sure all the allocated memory is getting copied, not just + * referenced + */ +#define STRDUP(x) x ? strdup(x) : NULL + + ed->color_class = STRDUP(ed->color_class); + switch (ep->type) + { + case EDJE_PART_TYPE_RECTANGLE: + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_GROUP: + /* Nothing todo, this part only have a common description. */ + break; + case EDJE_PART_TYPE_TEXT: + case EDJE_PART_TYPE_TEXTBLOCK: + { + Edje_Part_Description_Text *ted = (Edje_Part_Description_Text*) ed; + Edje_Part_Description_Text *tparent = (Edje_Part_Description_Text*) parent; + + ted->text = tparent->text; + + ted->text.text.str = STRDUP(ted->text.text.str); + ted->text.text_class = STRDUP(ted->text.text_class); + ted->text.font.str = STRDUP(ted->text.font.str); + + data_queue_copied_part_lookup(pc, &(tparent->text.id_source), &(ted->text.id_source)); + data_queue_copied_part_lookup(pc, &(tparent->text.id_text_source), &(ted->text.id_text_source)); + + break; + } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ied = (Edje_Part_Description_Image *) ed; + Edje_Part_Description_Image *iparent = (Edje_Part_Description_Image *) parent; + unsigned int i; + + ied->image = iparent->image; + + data_queue_copied_image_lookup(&iparent->image.id, &ied->image.id, &ied->image.set); + + ied->image.tweens = calloc(iparent->image.tweens_count, + sizeof (Edje_Part_Image_Id*)); + for (i = 0; i < iparent->image.tweens_count; i++) + { + Edje_Part_Image_Id *iid_new; + + iid = iparent->image.tweens[i]; + + iid_new = mem_alloc(SZ(Edje_Part_Image_Id)); + data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set)); + ied->image.tweens[i] = iid_new; + } + + break; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ped = (Edje_Part_Description_Proxy*) ed; + Edje_Part_Description_Proxy *pparent = (Edje_Part_Description_Proxy*) parent; + + data_queue_copied_part_lookup(pc, &(pparent->proxy.id), &(ped->proxy.id)); + + break; + } + case EDJE_PART_TYPE_BOX: + { + Edje_Part_Description_Box *bed = (Edje_Part_Description_Box *) ed; + Edje_Part_Description_Box *bparent = (Edje_Part_Description_Box *) parent; + + bed->box = bparent->box; + + break; + } + case EDJE_PART_TYPE_TABLE: + { + Edje_Part_Description_Table *ted = (Edje_Part_Description_Table *) ed; + Edje_Part_Description_Table *tparent = (Edje_Part_Description_Table *) parent; + + ted->table = tparent->table; + + break; + } + case EDJE_PART_TYPE_EXTERNAL: + { + Edje_Part_Description_External *eed = (Edje_Part_Description_External *) ed; + Edje_Part_Description_External *eparent = (Edje_Part_Description_External *) parent; + + if (eparent->external_params) + { + Eina_List *l; + Edje_External_Param *param, *new_param; + + eed->external_params = NULL; + EINA_LIST_FOREACH(eparent->external_params, l, param) + { + new_param = mem_alloc(SZ(Edje_External_Param)); + *new_param = *param; + eed->external_params = eina_list_append(eed->external_params, new_param); + } + } + break; + } + } + +#undef STRDUP +} + +/** + @page edcref + + @property + source + @parameters + [another part's name] + @effect + Causes the part to use another part content as the content of this part. + Only work with PROXY part. + @endproperty +*/ +static void +st_collections_group_parts_part_description_source(void) +{ + Edje_Part_Collection *pc; + Edje_Part_Description_Proxy *ed; + char *name; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + if (current_part->type != EDJE_PART_TYPE_PROXY) + { + ERR("%s: Error. parse error %s:%i. " + "source attributes in non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Proxy*) current_desc; + + name = parse_str(0); + + data_queue_part_lookup(pc, name, &(ed->proxy.id)); + free(name); +} + +/** + @page edcref + @property + state + @parameters + [a name for the description] [an index] + @effect + Sets a name used to identify a description inside a given part. + Multiple descriptions are used to declare different states of the same + part, like "clicked" or "invisible". All states declarations are also + coupled with an index number between 0.0 and 1.0. All parts must have + at least one description named "default 0.0". + @endproperty +*/ +static void +st_collections_group_parts_part_description_state(void) +{ + Edje_Part *ep; + Edje_Part_Description_Common *ed; + char *s; + + check_arg_count(2); + + ep = current_part; + + ed = ep->default_desc; + if (ep->other.desc_count) ed = ep->other.desc[ep->other.desc_count - 1]; + + s = parse_str(0); + if (!strcmp (s, "custom")) + { + ERR("%s: Error. parse error %s:%i. " + "invalid state name: '%s'.", + progname, file_in, line - 1, s); + exit(-1); + } + + ed->state.name = s; + ed->state.value = parse_float_range(1, 0.0, 1.0); + + if (ed != ep->default_desc) + { + if ((ep->default_desc->state.name && !strcmp(s, ep->default_desc->state.name) && ed->state.value == ep->default_desc->state.value) || + (!ep->default_desc->state.name && !strcmp(s, "default") && ed->state.value == ep->default_desc->state.value)) + { + free(ed); + ep->other.desc_count--; + ep->other.desc = realloc(ep->other.desc, + sizeof (Edje_Part_Description_Common*) * ep->other.desc_count); + current_desc = ep->default_desc; + } + else if (ep->other.desc_count) + { + unsigned int i; + for (i = 0; i < ep->other.desc_count - 1; ++i) + { + if (!strcmp(s, ep->other.desc[i]->state.name) && ed->state.value == ep->other.desc[i]->state.value) + { + free(ed); + ep->other.desc_count--; + ep->other.desc = realloc(ep->other.desc, + sizeof (Edje_Part_Description_Common*) * ep->other.desc_count); + current_desc = ep->other.desc[i]; + break; + } + } + } + } +} + +/** + @page edcref + @property + visible + @parameters + [0 or 1] + @effect + Takes a boolean value specifying whether part is visible (1) or not + (0). Non-visible parts do not emit signals. The default value is 1. + @endproperty +*/ +static void +st_collections_group_parts_part_description_visible(void) +{ + check_arg_count(1); + + current_desc->visible = parse_bool(0); +} + +/** + @page edcref + @property + align + @parameters + [X axis] [Y axis] + @effect + When the displayed object's size is smaller than its container, this + property moves it relatively along both axis inside its container. The + default value is "0.5 0.5". + @endproperty +*/ +static void +st_collections_group_parts_part_description_align(void) +{ + check_arg_count(2); + + current_desc->align.x = FROM_DOUBLE(parse_float_range(0, 0.0, 1.0)); + current_desc->align.y = FROM_DOUBLE(parse_float_range(1, 0.0, 1.0)); +} + +/** + @page edcref + @property + fixed + @parameters + [width, 0 or 1] [height, 0 or 1] + @effect + This affects the minimum size calculation. See + edje_object_size_min_calc() and edje_object_size_min_restricted_calc(). + This tells the min size calculation routine that this part does not + change size in width or height (1 for it doesn't, 0 for it does), so + the routine should not try and expand or contract the part. + @endproperty +*/ +static void +st_collections_group_parts_part_description_fixed(void) +{ + check_arg_count(2); + + current_desc->fixed.w = parse_float_range(0, 0, 1); + current_desc->fixed.h = parse_float_range(1, 0, 1); +} + +/** + @page edcref + @property + min + @parameters + [width] [height] + @effect + The minimum size of the state. + @endproperty +*/ +static void +st_collections_group_parts_part_description_min(void) +{ + check_arg_count(2); + + current_desc->min.w = parse_float_range(0, 0, 0x7fffffff); + current_desc->min.h = parse_float_range(1, 0, 0x7fffffff); +} + +/** + @page edcref + @property + max + @parameters + [width] [height] + @effect + The maximum size of the state. A size of -1.0 means that it will be ignored in one direction. + @endproperty +*/ +static void +st_collections_group_parts_part_description_max(void) +{ + check_arg_count(2); + + current_desc->max.w = parse_float_range(0, -1.0, 0x7fffffff); + current_desc->max.h = parse_float_range(1, -1.0, 0x7fffffff); +} + +/** + @page edcref + @property + step + @parameters + [width] [height] + @effect + Restricts resizing of each dimension to values divisibles by its value. + This causes the part to jump from value to value while resizing. The + default value is "0 0" disabling stepping. + @endproperty +*/ +static void +st_collections_group_parts_part_description_step(void) +{ + check_arg_count(2); + + current_desc->step.x = parse_float_range(0, 0, 0x7fffffff); + current_desc->step.y = parse_float_range(1, 0, 0x7fffffff); +} + +/** + @page edcref + @property + aspect + @parameters + [min] [max] + @effect + Normally width and height can be resized to any values independently. + The aspect property forces the width to height ratio to be kept between + the minimum and maximum set. For example, "1.0 1.0" will increase the + width a pixel for every pixel added to heigh. The default value is + "0.0 0.0" disabling aspect. + @endproperty +*/ +static void +st_collections_group_parts_part_description_aspect(void) +{ + check_arg_count(2); + + current_desc->aspect.min = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0)); + current_desc->aspect.max = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0)); +} + +/** + @page edcref + @property + aspect_preference + @parameters + [DIMENSION] + @effect + Sets the scope of the "aspect" property to a given dimension. Available + options are BOTH, VERTICAL, HORIZONTAL and NONE + @endproperty +*/ +static void +st_collections_group_parts_part_description_aspect_preference(void) +{ + check_arg_count(1); + + current_desc->aspect.prefer = parse_enum(0, + "NONE", EDJE_ASPECT_PREFER_NONE, + "VERTICAL", EDJE_ASPECT_PREFER_VERTICAL, + "HORIZONTAL", EDJE_ASPECT_PREFER_HORIZONTAL, + "BOTH", EDJE_ASPECT_PREFER_BOTH, + NULL); +} + +/** + @page edcref + @property + color_class + @parameters + [color class name] + @effect + The part will use the color values of the named color_class, these + values can be overrided by the "color", "color2" and "color3" + properties set below. + @endproperty +*/ +static void +st_collections_group_parts_part_description_color_class(void) +{ + check_arg_count(1); + + current_desc->color_class = parse_str(0); +} + +/** + @page edcref + @property + color + @parameters + [red] [green] [blue] [alpha] + @effect + Sets the main color to the specified values (between 0 and 255). + @endproperty +*/ +static void +st_collections_group_parts_part_description_color(void) +{ + check_arg_count(4); + + current_desc->color.r = parse_int_range(0, 0, 255); + current_desc->color.g = parse_int_range(1, 0, 255); + current_desc->color.b = parse_int_range(2, 0, 255); + current_desc->color.a = parse_int_range(3, 0, 255); +} + +/** + @page edcref + @property + color2 + @parameters + [red] [green] [blue] [alpha] + @effect + Sets the text shadow color to the specified values (0 to 255). + @endproperty +*/ +static void +st_collections_group_parts_part_description_color2(void) +{ + check_arg_count(4); + + current_desc->color2.r = parse_int_range(0, 0, 255); + current_desc->color2.g = parse_int_range(1, 0, 255); + current_desc->color2.b = parse_int_range(2, 0, 255); + current_desc->color2.a = parse_int_range(3, 0, 255); +} + +/** + @page edcref + @property + color3 + @parameters + [red] [green] [blue] [alpha] + @effect + Sets the text outline color to the specified values (0 to 255). + @endproperty +*/ +static void +st_collections_group_parts_part_description_color3(void) +{ + Edje_Part_Collection *pc; + Edje_Part_Description_Text *ed; + + check_arg_count(4); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + if (current_part->type != EDJE_PART_TYPE_TEXT + && current_part->type != EDJE_PART_TYPE_TEXTBLOCK) + { + ERR("%s: Error. Setting color3 in part %s from %s not of type TEXT or TEXTBLOCK.", progname, current_part->name, pc->part); + exit(-1); + } + + ed = (Edje_Part_Description_Text*)current_desc; + + ed->text.color3.r = parse_int_range(0, 0, 255); + ed->text.color3.g = parse_int_range(1, 0, 255); + ed->text.color3.b = parse_int_range(2, 0, 255); + ed->text.color3.a = parse_int_range(3, 0, 255); +} + +/** + @page edcref + @block + rel1/rel2 + @context + description { + .. + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + .. + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + .. + } + @description + The rel1 and rel2 blocks are used to define the position of each corner + of the part's container. With rel1 being the left-up corner and rel2 + being the right-down corner. + @endblock + + @property + relative + @parameters + [X axis] [Y axis] + @effect + Moves a corner to a relative position inside the container of the + relative "to" part. Values from 0.0 (0%, beginning) to 1.0 (100%, end) + of each axis. + @endproperty +*/ +static void +st_collections_group_parts_part_description_rel1_relative(void) +{ + check_arg_count(2); + + current_desc->rel1.relative_x = FROM_DOUBLE(parse_float(0)); + current_desc->rel1.relative_y = FROM_DOUBLE(parse_float(1)); +} + +/** + @page edcref + @property + offset + @parameters + [X axis] [Y axis] + @effect + Affects the corner position a fixed number of pixels along each axis. + @endproperty +*/ +static void +st_collections_group_parts_part_description_rel1_offset(void) +{ + check_arg_count(2); + + current_desc->rel1.offset_x = parse_int(0); + current_desc->rel1.offset_y = parse_int(1); +} + +/** + @page edcref + @property + to + @parameters + [another part's name] + @effect + Causes a corner to be positioned relatively to another part's + container. Setting to "" will un-set this value for inherited + parts. + @endproperty +*/ +static void +st_collections_group_parts_part_description_rel1_to(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->rel1.id_x)); + data_queue_part_lookup(pc, name, &(current_desc->rel1.id_y)); + free(name); + } +} + +/** + @page edcref + @property + to_x + @parameters + [another part's name] + @effect + Causes a corner to be positioned relatively to the X axis of another + part's container. Simply put affects the first parameter of "relative". + Setting to "" will un-set this value for inherited parts. + @endproperty +*/ +static void +st_collections_group_parts_part_description_rel1_to_x(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->rel1.id_x)); + free(name); + } +} + +/** + @page edcref + @property + to_y + @parameters + [another part's name] + @effect + Causes a corner to be positioned relatively to the Y axis of another + part's container. Simply put, affects the second parameter of + "relative". Setting to "" will un-set this value for inherited parts. + @endproperty +*/ +static void +st_collections_group_parts_part_description_rel1_to_y(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->rel1.id_y)); + free(name); + } +} + +static void +st_collections_group_parts_part_description_rel2_relative(void) +{ + check_arg_count(2); + + current_desc->rel2.relative_x = FROM_DOUBLE(parse_float(0)); + current_desc->rel2.relative_y = FROM_DOUBLE(parse_float(1)); +} + +static void +st_collections_group_parts_part_description_rel2_offset(void) +{ + check_arg_count(2); + + current_desc->rel2.offset_x = parse_int(0); + current_desc->rel2.offset_y = parse_int(1); +} + +static void +st_collections_group_parts_part_description_rel2_to(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->rel2.id_x)); + data_queue_part_lookup(pc, name, &(current_desc->rel2.id_y)); + free(name); + } +} + +static void +st_collections_group_parts_part_description_rel2_to_x(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->rel2.id_x)); + free(name); + } +} + +static void +st_collections_group_parts_part_description_rel2_to_y(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->rel2.id_y)); + free(name); + } +} + +/** + @edcsection{description_image,Image state description sub blocks} + */ + +/** + @page edcref + @block + image + @context + description { + .. + image { + normal: "filename.ext"; + tween: "filename2.ext"; + .. + tween: "filenameN.ext"; + border: left right top bottom; + middle: 0/1/NONE/DEFAULT/SOLID; + } + .. + } + @description + @endblock + + @property + normal + @parameters + [image's filename] + @effect + Name of image to be used as previously declared in the images block. + In an animation, this is the first and last image displayed. It's + required in any image part + @endproperty +*/ +static void +st_collections_group_parts_part_description_image_normal(void) +{ + Edje_Part_Description_Image *ed; + + check_arg_count(1); + + if (current_part->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Image*) current_desc; + + { + char *name; + + name = parse_str(0); + data_queue_image_lookup(name, &(ed->image.id), &(ed->image.set)); + free(name); + } +} + +/** + @page edcref + @property + tween + @parameters + [image's filename] + @effect + Name of an image to be used in an animation loop, an image block can + have none, one or multiple tween declarations. Images are displayed in + the order they are listed. + @endproperty +*/ +static void +st_collections_group_parts_part_description_image_tween(void) +{ + Edje_Part_Description_Image *ed; + + check_arg_count(1); + + if (current_part->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Image*) current_desc; + + { + char *name; + Edje_Part_Image_Id *iid; + + iid = mem_alloc(SZ(Edje_Part_Image_Id)); + ed->image.tweens_count++; + ed->image.tweens = realloc(ed->image.tweens, + sizeof (Edje_Part_Image_Id*) * ed->image.tweens_count); + ed->image.tweens[ed->image.tweens_count - 1] = iid; + name = parse_str(0); + data_queue_image_lookup(name, &(iid->id), &(iid->set)); + free(name); + } +} + +/** + @page edcref + @property + border + @parameters + [left] [right] [top] [bottom] + @effect + If set, the area (in pixels) of each side of the image will be + displayed as a fixed size border, from the side -> inwards, preventing + the corners from being changed on a resize. + @endproperty +*/ +static void +st_collections_group_parts_part_description_image_border(void) +{ + Edje_Part_Description_Image *ed; + + check_arg_count(4); + + if (current_part->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Image*) current_desc; + + ed->image.border.l = parse_int_range(0, 0, 0x7fffffff); + ed->image.border.r = parse_int_range(1, 0, 0x7fffffff); + ed->image.border.t = parse_int_range(2, 0, 0x7fffffff); + ed->image.border.b = parse_int_range(3, 0, 0x7fffffff); +} + +/** + @page edcref + @property + middle + @parameters + 0, 1, NONE, DEFAULT, SOLID + @effect + If border is set, this value tells Edje if the rest of the + image (not covered by the defined border) will be displayed or not + or be assumed to be solid (without alpha). The default is 1/DEFAULT. + @endproperty +*/ +static void +st_collections_group_parts_part_description_image_middle(void) +{ + Edje_Part_Description_Image *ed; + + check_arg_count(1); + + if (current_part->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Image*) current_desc; + + ed->image.border.no_fill = parse_enum(0, + "1", 0, + "DEFAULT", 0, + "0", 1, + "NONE", 1, + "SOLID", 2, + NULL); +} + +/** + @page edcref + @property + border_scale_by + @parameters + 0.0 or bigger (0.0 or 1.0 to turn it off) + @effect + If border scaling is enabled then normally the OUTPUT border sizes + (e.g. if 3 pixels on the left edge are set as a border, then normally + at scale 1.0, those 3 columns will always be the exact 3 columns of + output, or at scale 2.0 they will be 6 columns, or 0.33 they will merge + into a single column). This property multiplies the input scale + factor by this multiplier, allowing the creation of "supersampled" + borders to make much higher resolution outputs possible by always using + the highest resolution artwork and then runtime scaling it down. + @endproperty +*/ +static void +st_collections_group_parts_part_description_image_border_scale_by(void) +{ + Edje_Part_Description_Image *ed; + + check_arg_count(1); + + if (current_part->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Image*) current_desc; + + ed->image.border.scale_by = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0)); +} + +/** + @page edcref + @property + border_scale + @parameters + 0, 1 + @effect + If border is set, this value tells Edje if the border should be scaled + by the object/global edje scale factors + @endproperty +*/ +static void +st_collections_group_parts_part_description_image_border_scale(void) +{ + Edje_Part_Description_Image *ed; + + check_arg_count(1); + + if (current_part->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Image*) current_desc; + + ed->image.border.scale = parse_enum(0, + "0", 0, + "1", 1, + NULL); +} + +/** + @page edcref + @property + scale_hint + @parameters + 0, NONE, DYNAMIC, STATIC + @effect + Sets the evas image scale hint letting the engine more effectively save + cached copies of the scaled image if it makes sense + @endproperty +*/ +static void +st_collections_group_parts_part_description_image_scale_hint(void) +{ + Edje_Part_Description_Image *ed; + + check_arg_count(1); + + if (current_part->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Image*) current_desc; + + ed->image.scale_hint = parse_enum(0, + "NONE", EVAS_IMAGE_SCALE_HINT_NONE, + "DYNAMIC", EVAS_IMAGE_SCALE_HINT_DYNAMIC, + "STATIC", EVAS_IMAGE_SCALE_HINT_STATIC, + "0", EVAS_IMAGE_SCALE_HINT_NONE, + NULL); +} + +/** + @page edcref + @block + fill + @context + description { + .. + fill { + smooth: 0-1; + origin { + relative: X-axis Y-axis; + offset: X-axis Y-axis; + } + size { + relative: width height; + offset: width height; + } + } + .. + } + @description + The fill method is an optional block that defines the way an IMAGE part + is going to be displayed inside its container. + @endblock + + @property + smooth + @parameters + [0 or 1] + @effect + The smooth property takes a boolean value to decide if the image will + be smoothed on scaling (1) or not (0). The default value is 1. + @endproperty +*/ +static void +st_collections_group_parts_part_description_fill_smooth(void) +{ + Edje_Part_Description_Spec_Fill *fill; + + check_arg_count(1); + + switch (current_part->type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; + + ed = (Edje_Part_Description_Image*) current_desc; + + fill = &ed->image.fill; + break; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) current_desc; + + fill = &ed->proxy.fill; + break; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY `%s` part (%i).", + progname, file_in, line - 1, current_part->name, current_part->type); + exit(-1); + } + } + + fill->smooth = parse_bool(0); +} + +/** + @page edcref + + @property + spread + @parameters + TODO + @effect + TODO + @endproperty +*/ +static void +st_collections_group_parts_part_description_fill_spread(void) +{ +#if 0 + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description_Image *ed; +#endif + + check_arg_count(1); + + /* XXX this will need to include IMAGES when spread support is added to evas images */ + { + ERR("%s: Error. parse error %s:%i. " + "fill.spread not supported yet.", + progname, file_in, line - 1); + exit(-1); + } + +#if 0 + pc = eina_list_data_get(eina_list_last(edje_collections)); + + ep = pc->parts[pc->parts_count - 1]; + + if (ep->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Image*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + + ed->image.fill.spread = parse_int_range(0, 0, 1); +#endif +} + +/** + @page edcref + + @property + type + @parameters + TODO + @effect + TODO + @endproperty +*/ +static void +st_collections_group_parts_part_description_fill_type(void) +{ + Edje_Part_Description_Spec_Fill *fill; + + check_arg_count(1); + + switch (current_part->type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; + + ed = (Edje_Part_Description_Image*) current_desc; + + fill = &ed->image.fill; + break; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) current_desc; + + fill = &ed->proxy.fill; + break; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } + + fill->type = parse_enum(0, + "SCALE", EDJE_FILL_TYPE_SCALE, + "TILE", EDJE_FILL_TYPE_TILE, + NULL); +} + +/** + @page edcref + @block + origin + @context + description { + .. + fill { + .. + origin { + relative: 0.0 0.0; + offset: 0 0; + } + .. + } + .. + } + @description + The origin block is used to place the starting point, inside the + displayed element, that will be used to render the tile. By default, + the origin is set at the element's left-up corner. + @endblock + + @property + relative + @parameters + [X axis] [Y axis] + @effect + Sets the starting point relatively to displayed element's content. + @endproperty +*/ +static void +st_collections_group_parts_part_description_fill_origin_relative(void) +{ + Edje_Part_Description_Spec_Fill *fill; + + check_arg_count(2); + + switch (current_part->type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; + + ed = (Edje_Part_Description_Image*) current_desc; + + fill = &ed->image.fill; + break; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) current_desc; + + fill = &ed->proxy.fill; + break; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } + + fill->pos_rel_x = FROM_DOUBLE(parse_float_range(0, -999999999.0, 999999999.0)); + fill->pos_rel_y = FROM_DOUBLE(parse_float_range(1, -999999999.0, 999999999.0)); +} + +/** + @page edcref + @property + offset + @parameters + [X axis] [Y axis] + @effect + Affects the starting point a fixed number of pixels along each axis. + @endproperty +*/ +static void +st_collections_group_parts_part_description_fill_origin_offset(void) +{ + Edje_Part_Description_Spec_Fill *fill; + + check_arg_count(2); + + switch (current_part->type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; + + ed = (Edje_Part_Description_Image*) current_desc; + + fill = &ed->image.fill; + break; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) current_desc; + + fill = &ed->proxy.fill; + break; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } + + fill->pos_abs_x = parse_int(0); + fill->pos_abs_y = parse_int(1); +} + +/** + @page edcref + @block + size + @context + description { + .. + fill { + .. + size { + relative: 1.0 1.0; + offset: -1 -1; + } + .. + } + .. + } + @description + The size block defines the tile size of the content that will be + displayed. + @endblock + + @property + relative + @parameters + [width] [height] + @effect + Takes a pair of decimal values that represent the a percentual value + of the original size of the element. For example, "0.5 0.5" represents + half the size, while "2.0 2.0" represents the double. The default + value is "1.0 1.0". + @endproperty +*/ +static void +st_collections_group_parts_part_description_fill_size_relative(void) +{ + Edje_Part_Description_Spec_Fill *fill; + + check_arg_count(2); + + switch (current_part->type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; + + ed = (Edje_Part_Description_Image*) current_desc; + + fill = &ed->image.fill; + break; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) current_desc; + + fill = &ed->proxy.fill; + break; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } + + fill->rel_x = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0)); + fill->rel_y = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0)); +} + +/** + @page edcref + @property + offset + @parameters + [X axis] [Y axis] + @effect + Affects the size of the tile a fixed number of pixels along each axis. + @endproperty +*/ +static void +st_collections_group_parts_part_description_fill_size_offset(void) +{ + Edje_Part_Description_Spec_Fill *fill; + + check_arg_count(2); + + switch (current_part->type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; + + ed = (Edje_Part_Description_Image*) current_desc; + + fill = &ed->image.fill; + break; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) current_desc; + + fill = &ed->proxy.fill; + break; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } + + fill->abs_x = parse_int(0); + fill->abs_y = parse_int(1); +} + + +/** + @edcsection{description_text,Text state description sub blocks} + */ + +/** + @page edcref + + @block + text + @context + part { + description { + .. + text { + text: "some string of text to display"; + font: "font_name"; + size: SIZE; + text_class: "class_name"; + fit: horizontal vertical; + min: horizontal vertical; + max: horizontal vertical; + align: X-axis Y-axis; + source: "part_name"; + text_source: "text_part_name"; + ellipsis: 0.0-1.0; + style: "stylename"; + } + .. + } + } + @description + @endblock + + @property + text + @parameters + [a string of text, or nothing] + @effect + Sets the default content of a text part, normally the application is + the one changing its value. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_text(void) +{ + Edje_Part_Description_Text *ed; + char *str = NULL; + int i; + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + for (i = 0; ;i++) + { + char *s; + + if (!is_param(i)) break; + s = parse_str(i); + if (!str) str = s; + else + { + str = realloc(str, strlen(str) + strlen(s) + 1); + strcat(str, s); + free(s); + } + } + ed->text.text.str = str; +} + +/** + @page edcref + + @property + text_class + @parameters + [text class name] + @effect + Similar to color_class, this is the name used by the application + to alter the font family and size at runtime. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_text_class(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(1); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.text_class = parse_str(0); +} + +/** + @page edcref + + @property + font + @parameters + [font alias] + @effect + This sets the font family to one of the aliases set up in the "fonts" + block. Can be overrided by the application. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_font(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(1); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.font.str = parse_str(0); +} + +/** + @page edcref + + @property + style + @parameters + [the style name] + @effect + Causes the part to use the default style and tags defined in the + "style" block with the specified name. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_style(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(1); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.style.str = parse_str(0); +} + +/** + @page edcref + + @property + repch + @parameters + [the replacement character string] + @effect + If this is a textblock and is in PASSWORD mode this string is used + to replace every character to hide the details of the entry. Normally + you would use a "*", but you can use anything you like. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_repch(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(1); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.repch.str = parse_str(0); +} + +/** + @page edcref + + @property + size + @parameters + [font size in points (pt)] + @effect + Sets the default font size for the text part. Can be overrided by the + application. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_size(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(1); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*)current_desc; + + ed->text.size = parse_int_range(0, 0, 255); +} + +/** + @page edcref + + @property + size_range + @parameters + [font min size in points (pt)] [font max size in points (pt)] + @effect + Sets the allowed font size for the text part. Setting min and max to 0 + means we won't restrict the sizing (default). + @endproperty + @since 1.1.0 +*/ +static void +st_collections_group_parts_part_description_text_size_range(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(2); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.size_range_min = parse_int_range(0, 0, 255); + ed->text.size_range_max = parse_int_range(1, 0, 255); + if (ed->text.size_range_min > ed->text.size_range_max) + { + ERR("%s: Error. parse error %s:%i. " + "min size is bigger than max size.", + progname, file_in, line - 1); + exit(-1); + } +} + +/** + @page edcref + + @property + fit + @parameters + [horizontal] [vertical] + @effect + When any of the parameters is set to 1 edje will resize the text for it + to fit in it's container. Both are disabled by default. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_fit(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(2); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.fit_x = parse_bool(0); + ed->text.fit_y = parse_bool(1); +} + +/** + @page edcref + + @property + min + @parameters + [horizontal] [vertical] + @effect + When any of the parameters is enabled (1) it forces the minimum size of + the container to be equal to the minimum size of the text. The default + value is "0 0". + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_min(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(2); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*)current_desc; + + ed->text.min_x = parse_bool(0); + ed->text.min_y = parse_bool(1); +} + +/** + @page edcref + + @property + max + @parameters + [horizontal] [vertical] + @effect + When any of the parameters is enabled (1) it forces the maximum size of + the container to be equal to the maximum size of the text. The default + value is "0 0". + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_max(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(2); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.max_x = parse_bool(0); + ed->text.max_y = parse_bool(1); +} + +/** + @page edcref + + @property + align + @parameters + [horizontal] [vertical] + @effect + Change the position of the point of balance inside the container. The + default value is 0.5 0.5. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_align(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(2); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.align.x = FROM_DOUBLE(parse_float_range(0, -1.0, 1.0)); + ed->text.align.y = FROM_DOUBLE(parse_float_range(1, 0.0, 1.0)); +} + +/** + @page edcref + + @property + source + @parameters + [another TEXT part's name] + @effect + Causes the part to use the text properties (like font and size) of + another part and update them as they change. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_source(void) +{ + Edje_Part_Collection *pc; + Edje_Part_Description_Text *ed; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(ed->text.id_source)); + free(name); + } +} + +/** + @page edcref + + @property + text_source + @parameters + [another TEXT part's name] + @effect + Causes the part to display the text content of another part and update + them as they change. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_text_source(void) +{ + Edje_Part_Collection *pc; + Edje_Part_Description_Text *ed; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(ed->text.id_text_source)); + free(name); + } +} + +/** + @page edcref + + @property + ellipsis + @parameters + [point of balance] + @effect + Used to balance the text in a relative point from 0.0 to 1.0, this + point is the last section of the string to be cut out in case of a + resize that is smaller than the text itself. The default value is 0.0. + @endproperty +*/ +static void +st_collections_group_parts_part_description_text_elipsis(void) +{ + Edje_Part_Description_Text *ed; + + check_arg_count(1); + + if ((current_part->type != EDJE_PART_TYPE_TEXT) && + (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + ERR("%s: Error. parse error %s:%i. " + "text attributes in non-TEXT part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Text*) current_desc; + + ed->text.elipsis = parse_float_range(0, 0.0, 1.0); +} + + +/** + @edcsection{description_box,Box state description sub blocks} + */ + +/** + @page edcref + + @block + box + @context + part { + description { + .. + box { + layout: "vertical"; + padding: 0 2; + align: 0.5 0.5; + min: 0 0; + } + .. + } + } + @description + A box block can contain other objects and display them in different + layouts, any of the predefined set, or a custom one, set by the + application. + @endblock + + @property + layout + @parameters + [primary layout] [fallback layout] + @effect + Sets the layout for the box: + @li horizontal (default) + @li vertical + @li horizontal_homogeneous + @li vertical_homogeneous + @li horizontal_max (homogeneous to the max sized child) + @li vertical_max + @li horizontal_flow + @li vertical_flow + @li stack + @li some_other_custom_layout_set_by_the_application + You could set a custom layout as fallback, it makes very + very little sense though, and if that one fails, it will + default to horizontal. + @endproperty + + @property + align + @parameters + [horizontal] [vertical] + @effect + Change the position of the point of balance inside the container. The + default value is 0.5 0.5. + @endproperty + + @property + padding + @parameters + [horizontal] [vertical] + @effect + Sets the space between cells in pixels. Defaults to 0 0. + @endproperty + + @property + min + @parameters + [horizontal] [vertical] + @effect + When any of the parameters is enabled (1) it forces the minimum size of + the box to be equal to the minimum size of the items. The default + value is "0 0". + @endproperty +*/ +static void st_collections_group_parts_part_description_box_layout(void) +{ + Edje_Part_Description_Box *ed; + + check_min_arg_count(1); + + if (current_part->type != EDJE_PART_TYPE_BOX) + { + ERR("%s: Error. parse error %s:%i. " + "box attributes in non-BOX part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Box*) current_desc; + + ed->box.layout = parse_str(0); + if (is_param(1)) + ed->box.alt_layout = parse_str(1); +} + +static void st_collections_group_parts_part_description_box_align(void) +{ + Edje_Part_Description_Box *ed; + + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_BOX) + { + ERR("%s: Error. parse error %s:%i. " + "box attributes in non-BOX part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Box*) current_desc; + + ed->box.align.x = FROM_DOUBLE(parse_float_range(0, -1.0, 1.0)); + ed->box.align.y = FROM_DOUBLE(parse_float_range(1, -1.0, 1.0)); +} + +static void st_collections_group_parts_part_description_box_padding(void) +{ + Edje_Part_Description_Box *ed; + + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_BOX) + { + ERR("%s: Error. parse error %s:%i. " + "box attributes in non-BOX part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Box*) current_desc; + + ed->box.padding.x = parse_int_range(0, 0, 0x7fffffff); + ed->box.padding.y = parse_int_range(1, 0, 0x7fffffff); +} + +static void +st_collections_group_parts_part_description_box_min(void) +{ + Edje_Part_Description_Box *ed; + + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_BOX) + { + ERR("%s: Error. parse error %s:%i. " + "box attributes in non-BOX part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Box*) current_desc; + + ed->box.min.h = parse_bool(0); + ed->box.min.v = parse_bool(1); +} + + +/** + @edcsection{description_table,Table state description sub blocks} + */ + +/** + @page edcref + + @block + table + @context + part { + description { + .. + table { + homogeneous: TABLE; + padding: 0 2; + align: 0.5 0.5; + min: 0 0; + } + .. + } + } + @description + A table block can contain other objects packed in multiple columns + and rows, and each item can span across more than one column and/or + row. + @endblock + + @property + homogeneous + @parameters + [homogeneous mode] + @effect + Sets the homogeneous mode for the table: + @li NONE (default) + @li TABLE + @li ITEM + @endproperty + + @property + align + @parameters + [horizontal] [vertical] + @effect + Change the position of the point of balance inside the container. The + default value is 0.5 0.5. + @endproperty + + @property + padding + @parameters + [horizontal] [vertical] + @effect + Sets the space between cells in pixels. Defaults to 0 0. + @endproperty + + @property + min + @parameters + [horizontal] [vertical] + @effect + When any of the parameters is enabled (1) it forces the minimum size of + the table to be equal to the minimum size of the items. The default + value is "0 0". + @endproperty +*/ +static void st_collections_group_parts_part_description_table_homogeneous(void) +{ + Edje_Part_Description_Table *ed; + + check_min_arg_count(1); + + if (current_part->type != EDJE_PART_TYPE_TABLE) + { + ERR("%s: Error. parse error %s:%i. " + "table attributes in non-TABLE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Table*) current_desc; + + ed->table.homogeneous = parse_enum(0, + "NONE", EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE, + "TABLE", EDJE_OBJECT_TABLE_HOMOGENEOUS_TABLE, + "ITEM", EDJE_OBJECT_TABLE_HOMOGENEOUS_ITEM, + NULL); +} + +static void st_collections_group_parts_part_description_table_align(void) +{ + Edje_Part_Description_Table *ed; + + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_TABLE) + { + ERR("%s: Error. parse error %s:%i. " + "table attributes in non-TABLE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Table*) current_desc; + + ed->table.align.x = FROM_DOUBLE(parse_float_range(0, -1.0, 1.0)); + ed->table.align.y = FROM_DOUBLE(parse_float_range(1, -1.0, 1.0)); +} + +static void st_collections_group_parts_part_description_table_padding(void) +{ + Edje_Part_Description_Table *ed; + + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_TABLE) + { + ERR("%s: Error. parse error %s:%i. " + "table attributes in non-TABLE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Table*) current_desc; + + ed->table.padding.x = parse_int_range(0, 0, 0x7fffffff); + ed->table.padding.y = parse_int_range(1, 0, 0x7fffffff); +} + +static void +st_collections_group_parts_part_description_table_min(void) +{ + Edje_Part_Description_Table *ed; + + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_TABLE) + { + ERR("%s: Error. parse error %s:%i. " + "box attributes in non-TABLE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Table*) current_desc; + + ed->table.min.h = parse_bool(0); + ed->table.min.v = parse_bool(1); +} + +/** + @edcsection{description_map,Map state description sub blocks} + */ + +/** + @page edcref + @block + map + @context + description { + .. + map { + perspective: "name"; + light: "name"; + on: 1; + smooth: 1; + perspective_on: 1; + backface_cull: 1; + alpha: 1; + + rotation { + .. + } + } + .. + } + + @description + @endblock + + @property + perspective + @parameters + [another part's name] + @effect + This sets the part that is used as the "perspective point" for giving + a part a "3d look". The perspective point should have a perspective + section that provides zplane and focal properties. The center of this + part will be used as the focal point, so size, color and visibility + etc. are not relevant just center point, zplane and focal are used. + This also implicitly enables perspective transforms (see the on + parameter for the map section). + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_perspective(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->map.id_persp)); + free(name); + } + + current_desc->map.persp_on = 1; +} + +/** + @page edcref + @property + light + @parameters + [another part's name] + @effect + This sets the part that is used as the "light" for calculating the + brightness (based on how directly the part's surface is facing the + light source point). Like the perspective point part, the center point + is used and zplane is used for the z position (0 being the zero-plane + where all 2D objects normally live) and positive values being further + away into the distance. The light part color is used as the light + color (alpha not used for light color). The color2 color is used for + the ambient lighting when calculating brightness (alpha also not + used). + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_light(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->map.id_light)); + free(name); + } +} + +/** + @page edcref + @property + on + @parameters + [1 or 0] + @effect + This enables mapping for the part. Default is 0. + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_on(void) +{ + check_arg_count(1); + + current_desc->map.on = parse_bool(0); +} + +/** + @page edcref + @property + smooth + @parameters + [1 or 0] + @effect + This enable smooth map rendering. This may be linear interpolation, + anisotropic filtering or anything the engine decides is "smooth". + This is a best-effort hint and may not produce precisely the same + results in all engines and situations. Default is 1 + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_smooth(void) +{ + check_arg_count(1); + + current_desc->map.smooth = parse_bool(0); +} + +/** + @page edcref + @property + alpha + @parameters + [1 or 0] + @effect + This enable alpha channel when map rendering. Default is 1. + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_alpha(void) +{ + check_arg_count(1); + + current_desc->map.alpha = parse_bool(0); +} + +/** + @page edcref + @property + backface_cull + @parameters + [1 or 0] + @effect + This enables backface culling (when the rotated part that normally + faces the camera is facing away after being rotated etc.). This means + that the object will be hidden when "backface culled". + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_backface_cull(void) +{ + check_arg_count(1); + + current_desc->map.backcull = parse_bool(0); +} + +/** + @page edcref + @property + perspective_on + @parameters + [1 or 0] + @effect + Enable perspective when rotating even without a perspective point object. + This would use perspective set for the object itself or for the + canvas as a whole as the global perspective with + edje_perspective_set() and edje_perspective_global_set(). + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_perspective_on(void) +{ + check_arg_count(1); + + current_desc->map.persp_on = parse_bool(0); +} +/** + @page edcref + @block + rotation + @context + map { + .. + rotation { + center: "name"; + x: 45.0; + y: 45.0; + z: 45.0; + } + .. + } + @description + Rotates the part, optionally with the center on another part. + @endblock + + @property + center + @parameters + [another part's name] + @effect + This sets the part that is used as the center of rotation when + rotating the part with this description. The part's center point + is used as the rotation center when applying rotation around the + x, y and z axes. If no center is given, the parts original center + itself is used for the rotation center. + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_rotation_center(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + { + char *name; + + name = parse_str(0); + data_queue_part_lookup(pc, name, &(current_desc->map.rot.id_center)); + free(name); + } +} + +/** + @page edcref + @property + x + @parameters + [X degrees] + @effect + This sets the rotation around the x axis of the part considering + the center set. In degrees. + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_rotation_x(void) +{ + check_arg_count(1); + + current_desc->map.rot.x = FROM_DOUBLE(parse_float(0)); +} + +/** + @page edcref + @property + y + @parameters + [Y degrees] + @effect + This sets the rotation around the u axis of the part considering + the center set. In degrees. + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_rotation_y(void) +{ + check_arg_count(1); + + current_desc->map.rot.y = FROM_DOUBLE(parse_float(0)); +} + +/** + @page edcref + @property + z + @parameters + [Z degrees] + @effect + This sets the rotation around the z axis of the part considering + the center set. In degrees. + @endproperty +*/ +static void +st_collections_group_parts_part_description_map_rotation_z(void) +{ + check_arg_count(1); + + current_desc->map.rot.z = FROM_DOUBLE(parse_float(0)); +} + +/** + @page edcref + @block + perspective + @context + description { + .. + perspective { + zplane: 0; + focal: 1000; + } + .. + } + @description + Adds focal and plane perspective to the part. Active if perspective_on is true. + Must be provided if the part is being used by other part as it's perspective target. + @endblock + + @property + zplane + @parameters + [unscaled Z value] + @effect + This sets the z value that will not be scaled. Normally this is 0 as + that is the z distance that all objects are at normally. + @endproperty +*/ +static void +st_collections_group_parts_part_description_perspective_zplane(void) +{ + check_arg_count(1); + + current_desc->persp.zplane = parse_int(0); +} + + +/** + @page edcref + @property + focal + @parameters + [distance] + @effect + This sets the distance from the focal z plane (zplane) and the + camera - i.e. very much equating to focal length of the camera + @endproperty +*/ +static void +st_collections_group_parts_part_description_perspective_focal(void) +{ + check_arg_count(1); + + current_desc->persp.focal = parse_int_range(0, 1, 0x7fffffff); +} + + +/** + @edcsection{description_params,Params state description sub blocks} + */ + +/** + @page edcref + @block + params + @context + description { + .. + params { + int: "name" 0; + double: "other_name" 0.0; + string: "another_name" "some text"; + bool: "name" 1; + choice: "some_name" "value"; + } + .. + } + @description + Set parameters for EXTERNAL parts. The value overwrites previous + definitions with the same name. + @endblock +*/ +static void +_st_collections_group_parts_part_description_params(Edje_External_Param_Type type) +{ + Edje_Part_Description_External *ed; + Edje_External_Param *param; + Eina_List *l; + const char *name; + int found = 0; + + check_arg_count(2); + + if (current_part->type != EDJE_PART_TYPE_EXTERNAL) + { + ERR("%s: Error. parse error %s:%i. " + "params in non-EXTERNAL part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_External*) current_desc; + + name = parse_str(0); + + /* if a param with this name already exists, overwrite it */ + EINA_LIST_FOREACH(ed->external_params, l, param) + { + if (!strcmp(param->name, name)) + { + found = 1; + break; + } + } + + if (!found) + { + param = mem_alloc(SZ(Edje_External_Param)); + param->name = name; + } + + param->type = type; + param->i = 0; + param->d = 0; + param->s = NULL; + + switch (type) + { + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + case EDJE_EXTERNAL_PARAM_TYPE_INT: + param->i = parse_int(1); + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + param->d = parse_float(1); + break; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + param->s = parse_str(1); + break; + default: + ERR("%s: Error. parse error %s:%i. Invalid param type.\n", + progname, file_in, line - 1); + break; + } + + if (!found) + ed->external_params = eina_list_append(ed->external_params, param); +} + +/** + @page edcref + @property + int + @parameters + [param_name] [int_value] + @effect + Adds an integer parameter for an external object + @endproperty +*/ +static void +st_collections_group_parts_part_description_params_int(void) +{ + _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_INT); +} + +/** + @page edcref + @property + double + @parameters + [param_name] [double_value] + @effect + Adds a double parameter for an external object + @endproperty +*/ +static void +st_collections_group_parts_part_description_params_double(void) +{ + _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_DOUBLE); +} + +/** + @page edcref + @property + string + @parameters + [param_name] [string_value] + @effect + Adds a string parameter for an external object + @endproperty +*/ +static void +st_collections_group_parts_part_description_params_string(void) +{ + _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_STRING); +} + +/** + @page edcref + @property + bool + @parameters + [param_name] [bool_value] + @effect + Adds an boolean parameter for an external object. Value must be 0 or 1. + @endproperty +*/ +static void +st_collections_group_parts_part_description_params_bool(void) +{ + _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_BOOL); +} + +/** + @page edcref + @property + choice + @parameters + [param_name] [choice_string] + @effect + Adds a choice parameter for an external object. The possible + choice values are defined by external type at their register time + and will be validated at runtime. + @endproperty +*/ +static void +st_collections_group_parts_part_description_params_choice(void) +{ + _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_CHOICE); +} + + +/** + @edcsection{program, Program block} + */ + +/** + @page edcref + @block + program + @context + group { + programs { + .. + program { + name: "programname"; + signal: "signalname"; + source: "partname"; + filter: "partname" "statename"; + in: 0.3 0.0; + action: STATE_SET "statename" state_value; + transition: LINEAR 0.5; + target: "partname"; + target: "anotherpart"; + after: "programname"; + after: "anotherprogram"; + } + .. + } + } + @description + Programs define how your interface reacts to events. + Programs can change the state of parts, react to events or trigger + other events. + @endblock +*/ +static void +ob_collections_group_programs_program(void) +{ + Edje_Part_Collection *pc; + Edje_Program *ep; + Edje_Program_Parser *epp; + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + ep = mem_alloc(SZ(Edje_Program_Parser)); + ep->id = -1; + ep->tween.mode = EDJE_TWEEN_MODE_LINEAR; + ep->after = NULL; + epp = (Edje_Program_Parser *)ep; + epp->can_override = EINA_FALSE; + + _edje_program_insert(pc, ep); + + current_program = ep; +} + +/** + @page edcref + @property + name + @parameters + [program name] + @effect + Symbolic name of program as a unique identifier. + @endproperty +*/ +static void +st_collections_group_programs_program_name(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + current_program->name = parse_str(0); + + _edje_program_check(current_program->name, current_program, pc->programs.fnmatch, pc->programs.fnmatch_count); + _edje_program_check(current_program->name, current_program, pc->programs.strcmp, pc->programs.strcmp_count); + _edje_program_check(current_program->name, current_program, pc->programs.strncmp, pc->programs.strncmp_count); + _edje_program_check(current_program->name, current_program, pc->programs.strrncmp, pc->programs.strrncmp_count); + _edje_program_check(current_program->name, current_program, pc->programs.nocmp, pc->programs.nocmp_count); +} + +/** + @page edcref + @property + signal + @parameters + [signal name] + @effect + Specifies signal(s) that should cause the program to run. The signal + received must match the specified source to run. + Signals may be globbed, but only one signal keyword per program + may be used. ex: signal: "mouse,clicked,*"; (clicking any mouse button + that matches source starts program). + @endproperty +*/ +static void +st_collections_group_programs_program_signal(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + _edje_program_remove(pc, current_program); + current_program->signal = parse_str(0); + _edje_program_insert(pc, current_program); +} + +/** + @page edcref + @property + source + @parameters + [source name] + @effect + Source of accepted signal. Sources may be globbed, but only one source + keyword per program may be used. ex:source: "button-*"; (Signals from + any part or program named "button-*" are accepted). + @endproperty +*/ +static void +st_collections_group_programs_program_source(void) +{ + Edje_Part_Collection *pc; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + + _edje_program_remove(pc, current_program); + current_program->source = parse_str(0); + _edje_program_insert(pc, current_program); +} + +/** + @page edcref + @property + filter + @parameters + [part] [state] + @effect + Filter signals to be only accepted if the part [part] is in state named [state]. + Only one filter per program can be used. If [state] is not given, the source of + the event will be used instead. + @endproperty +*/ +static void +st_collections_group_programs_program_filter(void) +{ + check_min_arg_count(1); + + if(is_param(1)) { + current_program->filter.part = parse_str(0); + current_program->filter.state = parse_str(1); + } else { + current_program->filter.state = parse_str(0); + } +} + +/** + @page edcref + @property + in + @parameters + [from] [range] + @effect + Wait 'from' seconds before executing the program. And add a random + number of seconds (from 0 to 'range') to the total waiting time. + @endproperty +*/ +static void +st_collections_group_programs_program_in(void) +{ + check_arg_count(2); + + current_program->in.from = parse_float_range(0, 0.0, 999999999.0); + current_program->in.range = parse_float_range(1, 0.0, 999999999.0); +} + +#ifdef ENABLE_MULTISENSE +/* add to docs below +, PLAY_SAMPLE, PLAY_TONE + + action: PLAY_SAMPLE "sample name";\n + action: PLAY_TONE "tone name" duration in seconds ( Range 0.1 to 10.0 );\n +*/ +#endif + +/** + @page edcref + @property + action + @parameters + [type] [param1] [param2] + @effect + Action to be performed by the program. Valid actions are: STATE_SET, + ACTION_STOP, SIGNAL_EMIT, DRAG_VAL_SET, DRAG_VAL_STEP, DRAG_VAL_PAGE, + FOCUS_SET, PARAM_COPY, PARAM_SET + Only one action can be specified per program. Examples:\n + action: STATE_SET "statename" 0.5;\n + action: ACTION_STOP;\n + action: SIGNAL_EMIT "signalname" "emitter";\n + action: DRAG_VAL_SET 0.5 0.0;\n + action: DRAG_VAL_STEP 1.0 0.0;\n + action: DRAG_VAL_PAGE 0.0 0.0;\n + action: FOCUS_SET;\n + action: FOCUS_OBJECT;\n + action: PARAM_COPY "src_part" "src_param" "dst_part" "dst_param";\n + action: PARAM_SET "part" "param" "value";\n + @endproperty +*/ +static void +st_collections_group_programs_program_action(void) +{ + Edje_Part_Collection *pc; + Edje_Program *ep; + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = current_program; + ep->action = parse_enum(0, + "STATE_SET", EDJE_ACTION_TYPE_STATE_SET, + "ACTION_STOP", EDJE_ACTION_TYPE_ACTION_STOP, + "SIGNAL_EMIT", EDJE_ACTION_TYPE_SIGNAL_EMIT, + "DRAG_VAL_SET", EDJE_ACTION_TYPE_DRAG_VAL_SET, + "DRAG_VAL_STEP", EDJE_ACTION_TYPE_DRAG_VAL_STEP, + "DRAG_VAL_PAGE", EDJE_ACTION_TYPE_DRAG_VAL_PAGE, + "SCRIPT", EDJE_ACTION_TYPE_SCRIPT, + "FOCUS_SET", EDJE_ACTION_TYPE_FOCUS_SET, + "FOCUS_OBJECT", EDJE_ACTION_TYPE_FOCUS_OBJECT, + "PARAM_COPY", EDJE_ACTION_TYPE_PARAM_COPY, + "PARAM_SET", EDJE_ACTION_TYPE_PARAM_SET, +#ifdef ENABLE_MULTISENSE + "PLAY_SAMPLE", EDJE_ACTION_TYPE_SOUND_SAMPLE, + "PLAY_TONE", EDJE_ACTION_TYPE_SOUND_TONE, +#endif + NULL); + if (ep->action == EDJE_ACTION_TYPE_STATE_SET) + { + ep->state = parse_str(1); + ep->value = parse_float_range(2, 0.0, 1.0); + } + else if (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT) + { + ep->state = parse_str(1); + ep->state2 = parse_str(2); + } +#ifdef ENABLE_MULTISENSE + else if (ep->action == EDJE_ACTION_TYPE_SOUND_SAMPLE) + { + int i; + + ep->sample_name = parse_str(1); + for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++) + { + if (!strcmp(edje_file->sound_dir->samples[i].name, ep->sample_name)) + break; + if (i == (int)(edje_file->sound_dir->samples_count - 1)) + { + ERR("%s: Error. No Sample name %s exist.", progname, + ep->sample_name); + exit(-1); + } + } + ep->speed = parse_float_range(2, 0.0, 10.0); + } + else if (ep->action == EDJE_ACTION_TYPE_SOUND_TONE) + { + int i; + + ep->tone_name = parse_str(1); + for (i = 0; i < (int)edje_file->sound_dir->tones_count; i++) + { + if (!strcmp(edje_file->sound_dir->tones[i].name, ep->tone_name)) + break; + if (i == (int)(edje_file->sound_dir->tones_count - 1)) + { + ERR("%s: Error. No Tone name %s exist.", progname, + ep->tone_name); + exit(-1); + } + } + ep->duration = parse_float_range(2, 0.1, 10.0); + } +#endif + else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_SET) + { + ep->value = parse_float(1); + ep->value2 = parse_float(2); + } + else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_STEP) + { + ep->value = parse_float(1); + ep->value2 = parse_float(2); + } + else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_PAGE) + { + ep->value = parse_float(1); + ep->value2 = parse_float(2); + } + else if (ep->action == EDJE_ACTION_TYPE_PARAM_COPY) + { + char *src_part, *dst_part; + + src_part = parse_str(1); + ep->state = parse_str(2); + dst_part = parse_str(3); + ep->state2 = parse_str(4); + + data_queue_part_lookup(pc, src_part, &(ep->param.src)); + data_queue_part_lookup(pc, dst_part, &(ep->param.dst)); + + free(src_part); + free(dst_part); + } + else if (ep->action == EDJE_ACTION_TYPE_PARAM_SET) + { + char *part; + + part = parse_str(1); + ep->state = parse_str(2); + ep->state2 = parse_str(3); + + data_queue_part_lookup(pc, part, &(ep->param.dst)); + free(part); + } + + switch (ep->action) + { + case EDJE_ACTION_TYPE_ACTION_STOP: + check_arg_count(1); + break; + case EDJE_ACTION_TYPE_SCRIPT: + /* this is implicitly set by script {} so this is here just for + * completeness */ + break; + case EDJE_ACTION_TYPE_FOCUS_OBJECT: + case EDJE_ACTION_TYPE_FOCUS_SET: + check_arg_count(1); + break; + case EDJE_ACTION_TYPE_PARAM_COPY: + check_arg_count(5); + break; + case EDJE_ACTION_TYPE_PARAM_SET: + check_arg_count(4); + break; +#ifdef ENABLE_MULTISENSE + case EDJE_ACTION_TYPE_SOUND_SAMPLE: + check_arg_count(3); + break; + case EDJE_ACTION_TYPE_SOUND_TONE: + check_arg_count(3); + break; +#endif + default: + check_arg_count(3); + } +} + +/** + @page edcref + @property + transition + @parameters + [type] [length] [[interp val 1]] [[interp val 2]] [[option]] + @effect + Defines how transitions occur using STATE_SET action.\n + Where 'type' is the style of the transition and 'length' is a double + specifying the number of seconds in which to preform the transition.\n + Valid types are: LIN or LINEAR, SIN or SINUSOIDAL, + ACCEL or ACCELERATE, DECEL or DECELERATE, + ACCEL_FAC or ACCELERATE_FACTOR, DECEL_FAC or DECELERATE_FACTOR, + SIN_FAC or SINUSOIDAL_FACTOR, DIVIS or DIVISOR_INTERP, + BOUNCE, SPRING. + + ACCEL_FAC, DECEL_FAC and SIN_FAC need the extra optional + "interp val 1" to determine the "factor" of curviness. 1.0 is the same + as their non-factor counterparts, where 0.0 is equal to linear. + numbers higher than one make the curve angles steeper with a more + prnounced curve point. + + DIVIS, BOUNCE and SPRING also require "interp val 2" in addition + to "interp val 1". + + DIVIS uses val 1 as the initial graident start + (0.0 is horizontal, 1.0 is diagonal (linear), 2.0 is twice the + gradient of linear etc.). val 2 is interpreted as an integer factor + defining how much the value swings "outside" the gradient only to come + back to the final resting spot at the end. 0.0 for val 2 is equivalent + to linear interpolation. Note that DIVIS can exceed 1.0 + + BOUNCE uses val 2 as the number of bounces (so its rounded down to + the nearest integer value), with val 2 determining how much the + bounce decays, with 0.0 giving linear decay per bounce, and higher + values giving much more decay. + + SPRING is similar to bounce, where val 2 specifies the number of + spring "swings" and val 1 specifies the decay, but it can exceed 1.0 + on the outer swings. + + Valid option is CURRENT. + + CURRENT is the option which causes the edje object to move from its current position. + It can be used as the last parameter of any transition type. (@since 1.1.0) + + @endproperty +*/ +static void +st_collections_group_programs_program_transition(void) +{ + check_min_arg_count(2); + + current_program->tween.mode = parse_enum(0, + // short names + "LIN", EDJE_TWEEN_MODE_LINEAR, + "SIN", EDJE_TWEEN_MODE_SINUSOIDAL, + "ACCEL", EDJE_TWEEN_MODE_ACCELERATE, + "DECEL", EDJE_TWEEN_MODE_DECELERATE, + "ACCEL_FAC", EDJE_TWEEN_MODE_ACCELERATE_FACTOR, + "DECEL_FAC", EDJE_TWEEN_MODE_DECELERATE_FACTOR, + "SIN_FAC", EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR, + "DIVIS", EDJE_TWEEN_MODE_DIVISOR_INTERP, + + // long/full names + "LINEAR", EDJE_TWEEN_MODE_LINEAR, + "SINUSOIDAL", EDJE_TWEEN_MODE_SINUSOIDAL, + "ACCELERATE", EDJE_TWEEN_MODE_ACCELERATE, + "DECELERATE", EDJE_TWEEN_MODE_DECELERATE, + "ACCELERATE_FACTOR", EDJE_TWEEN_MODE_ACCELERATE_FACTOR, + "DECELERATE_FACTOR", EDJE_TWEEN_MODE_DECELERATE_FACTOR, + "SINUSOIDAL_FACTOR", EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR, + "DIVISOR_INTERP", EDJE_TWEEN_MODE_DIVISOR_INTERP, + + // long/full is short enough + "BOUNCE", EDJE_TWEEN_MODE_BOUNCE, + "SPRING", EDJE_TWEEN_MODE_SPRING, + NULL); + current_program->tween.time = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0)); + if ((current_program->tween.mode >= EDJE_TWEEN_MODE_LINEAR) && + (current_program->tween.mode <= EDJE_TWEEN_MODE_DECELERATE)) + { + if ((get_arg_count() == 3) && (!strcmp(parse_str(2), "CURRENT"))) + current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; + else if (get_arg_count() != 2) + { + ERR("%s: Error. parse error %s:%i. " + "Need 2rd parameter to set time", + progname, file_in, line - 1); + exit(-1); + } + } + // the following need v1 + // EDJE_TWEEN_MODE_ACCELERATE_FACTOR + // EDJE_TWEEN_MODE_DECELERATE_FACTOR + // EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR + // current_program->tween.v1 + else if ((current_program->tween.mode >= EDJE_TWEEN_MODE_ACCELERATE_FACTOR) && + (current_program->tween.mode <= EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR)) + { + if ((get_arg_count() == 4) && (!strcmp(parse_str(3), "CURRENT"))) + current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; + else if (get_arg_count() != 3) + { + ERR("%s: Error. parse error %s:%i. " + "Need 3rd parameter to set factor", + progname, file_in, line - 1); + exit(-1); + } + current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0)); + } + // the followjng also need v2 + // EDJE_TWEEN_MODE_DIVISOR_INTERP + // EDJE_TWEEN_MODE_BOUNCE + // EDJE_TWEEN_MODE_SPRING + // current_program->tween.v2 + else if ((current_program->tween.mode >= EDJE_TWEEN_MODE_DIVISOR_INTERP) && + (current_program->tween.mode <= EDJE_TWEEN_MODE_SPRING)) + { + if ((get_arg_count() == 5) && (!strcmp(parse_str(4), "CURRENT"))) + current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; + else if (get_arg_count() != 4) + { + ERR("%s: Error. parse error %s:%i. " + "Need 3rd and 4th parameters to set factor and counts", + progname, file_in, line - 1); + exit(-1); + } + current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0)); + current_program->tween.v2 = FROM_DOUBLE(parse_float_range(3, 0.0, 999999999.0)); + } +} + +/** + @page edcref + @property + target + @parameters + [target] + @effect + Program or part on which the specified action acts. Multiple target + keywords may be specified, one per target. SIGNAL_EMITs do not have + targets. + @endproperty +*/ +static void +st_collections_group_programs_program_target(void) +{ + Edje_Part_Collection *pc; + Edje_Program *ep; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = current_program; + { + Edje_Program_Target *et; + Edje_Program_Target *etw; + Eina_List *l; + char *name; + char *copy; + + name = parse_str(0); + + EINA_LIST_FOREACH(ep->targets, l, etw) + { + if (!strcmp(name, (char*) (etw + 1))) + { + free(name); + return; + } + } + + et = mem_alloc(SZ(Edje_Program_Target) + strlen(name) + 1); + ep->targets = eina_list_append(ep->targets, et); + copy = (char*) (et + 1); + + memcpy(copy, name, strlen(name) + 1); + + if (ep->action == EDJE_ACTION_TYPE_STATE_SET) + data_queue_part_lookup(pc, name, &(et->id)); + else if (ep->action == EDJE_ACTION_TYPE_ACTION_STOP) + data_queue_program_lookup(pc, name, &(et->id)); + else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_SET) + data_queue_part_lookup(pc, name, &(et->id)); + else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_STEP) + data_queue_part_lookup(pc, name, &(et->id)); + else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_PAGE) + data_queue_part_lookup(pc, name, &(et->id)); + else if (ep->action == EDJE_ACTION_TYPE_FOCUS_SET) + data_queue_part_lookup(pc, name, &(et->id)); + else if (ep->action == EDJE_ACTION_TYPE_FOCUS_OBJECT) + data_queue_part_lookup(pc, name, &(et->id)); + else + { + ERR("%s: Error. parse error %s:%i. " + "target may only be used after action", + progname, file_in, line - 1); + exit(-1); + } + free(name); + } +} + +/** + @page edcref + @property + after + @parameters + [after] + @effect + Specifies a program to run after the current program completes. The + source and signal parameters of a program run as an "after" are ignored. + Multiple "after" statements can be specified per program. + @endproperty +*/ +static void +st_collections_group_programs_program_after(void) +{ + Edje_Part_Collection *pc; + Edje_Program *ep; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = current_program; + { + Edje_Program_After *pa; + char *name; + + name = parse_str(0); + + pa = mem_alloc(SZ(Edje_Program_After)); + pa->id = -1; + ep->after = eina_list_append(ep->after, pa); + + data_queue_program_lookup(pc, name, &(pa->id)); + free(name); + } +} + +/** + @page edcref + @property + api + @parameters + [name] [description] + @effect + Specifies a hint to let applications (or IDE's) know how to bind + things. The parameter name should contain the name of the function that + the application should use, and description describes how it should + be used. + @endproperty +*/ +static void +st_collections_group_programs_program_api(void) +{ + check_min_arg_count(1); + + current_program->api.name = parse_str(0); + + if (is_param(1)) + { + check_arg_count(2); + current_program->api.description = parse_str(1); + } +} + +static void +st_collections_group_parts_part_api(void) +{ + check_min_arg_count(1); + + current_part->api.name = parse_str(0); + if (is_param(1)) + { + check_arg_count(2); + current_part->api.description = parse_str(1); + } +} + +static void +ob_collections_group_programs_program_script(void) +{ + Edje_Part_Collection *pc; + Code *cd; + + pc = eina_list_data_get(eina_list_last(edje_collections)); + cd = eina_list_data_get(eina_list_last(codes)); + + if (!is_verbatim()) track_verbatim(1); + else + { + Eina_Bool empty = EINA_TRUE; + char *s; + int i, len; + + s = get_verbatim(); + if (s) + { + Code_Program *cp; + + /* FIXME: Need to store the script somewhere to be restored when using edje_edit API */ + cp = mem_alloc(SZ(Code_Program)); + cp->l1 = get_verbatim_line1(); + cp->l2 = get_verbatim_line2(); + cp->script = s; + cp->original = strdup(s); + if (cd->shared && cd->is_lua) + { + ERR("%s: Error. parse error %s:%i. You're trying to mix Embryo and Lua scripting in the same group", + progname, file_in, line - 1); + exit(-1); + } + cd->is_lua = 0; + + len = strlen(cp->script); + for (i = 0; i < len; i++) + { + if (((cp->script[i] > 'a') && (cp->script[i] < 'z')) || + ((cp->script[i] > 'A') && (cp->script[i] < 'Z')) || + ((cp->script[i] > '0') && (cp->script[i] < '9'))) + empty = EINA_FALSE; + } + + if (!empty) + { + cd->programs = eina_list_append(cd->programs, cp); + data_queue_anonymous_lookup(pc, current_program, &(cp->id)); + current_program->action = EDJE_ACTION_TYPE_SCRIPT; + } + else + { + data_queue_anonymous_lookup(pc, current_program, NULL); + free(cp); + cp = NULL; + } + + set_verbatim(NULL, 0, 0); + } + } +} +/** + @page edcref +
+*/ 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 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "edje_cc.h" + +#ifdef _WIN32 +# define FMT_SIZE_T "%Iu" +#else +# define FMT_SIZE_T "%zu" +#endif + +void * +mem_alloc(size_t size) +{ + void *mem; + + mem = calloc(1, size); + if (mem) return mem; + ERR("%s: Error. %s:%i memory allocation of " FMT_SIZE_T " bytes failed. %s", + progname, file_in, line, size, strerror(errno)); + exit(-1); + return NULL; +} + +char * +mem_strdup(const char *s) +{ + void *str; + + str = strdup(s); + if (str) return str; + ERR("%s: Error. %s:%i memory allocation of " FMT_SIZE_T " bytes failed. %s. string being duplicated: \"%s\"", + progname, file_in, line, strlen(s) + 1, strerror(errno), s); + exit(-1); + return NULL; +} 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 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_ALLOCA_H +# include +#elif defined __GNUC__ +# define alloca __builtin_alloca +#elif defined _AIX +# define alloca __alloca +#elif defined _MSC_VER +# include +# define alloca _alloca +#else +# include +# ifdef __cplusplus +extern "C" +# endif +void *alloca (size_t); +#endif + +#include +#include +#include +#include + +#include + +#include "edje_cc.h" +#include "edje_convert.h" +#include "edje_multisense_convert.h" + +#include +#include + +typedef struct _External_Lookup External_Lookup; +typedef struct _Part_Lookup Part_Lookup; +typedef struct _Program_Lookup Program_Lookup; +typedef struct _Group_Lookup Group_Lookup; +typedef struct _Image_Lookup Image_Lookup; +typedef struct _Slave_Lookup Slave_Lookup; +typedef struct _Code_Lookup Code_Lookup; + + +struct _External_Lookup +{ + char *name; +}; + +struct _Part_Lookup +{ + Edje_Part_Collection *pc; + char *name; + int *dest; +}; + +struct _Program_Lookup +{ + Edje_Part_Collection *pc; + + union + { + char *name; + Edje_Program *ep; + } u; + + int *dest; + + Eina_Bool anonymous : 1; +}; + +struct _Group_Lookup +{ + char *name; +}; + +struct _String_Lookup +{ + char *name; + int *dest; +}; + +struct _Image_Lookup +{ + char *name; + int *dest; + Eina_Bool *set; +}; + +struct _Slave_Lookup +{ + int *master; + int *slave; +}; + +struct _Code_Lookup +{ + char *ptr; + int len; + int val; + Eina_Bool set; +}; + +static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char *ptr, int len)); + +Edje_File *edje_file = NULL; +Eina_List *edje_collections = NULL; +Eina_List *externals = NULL; +Eina_List *fonts = NULL; +Eina_List *codes = NULL; +Eina_List *code_lookups = NULL; +Eina_List *aliases = NULL; + +static Eet_Data_Descriptor *edd_edje_file = NULL; +static Eet_Data_Descriptor *edd_edje_part_collection = NULL; + +static Eina_List *part_lookups = NULL; +static Eina_List *program_lookups = NULL; +static Eina_List *group_lookups = NULL; +static Eina_List *image_lookups = NULL; +static Eina_List *part_slave_lookups = NULL; +static Eina_List *image_slave_lookups= NULL; + +#define ABORT_WRITE(eet_file, file) \ + eet_close(eet_file); \ + unlink(file); \ + exit(-1); + +void +error_and_abort(Eet_File *ef, const char *fmt, ...) +{ + va_list ap; + + fprintf(stderr, "%s: Error. ", progname); + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + ABORT_WRITE(ef, file_out); +} + +void +data_setup(void) +{ + edd_edje_file = _edje_edd_edje_file; + edd_edje_part_collection = _edje_edd_edje_part_collection; +} + +static void +check_image_part_desc (Edje_Part_Collection *pc, Edje_Part *ep, + Edje_Part_Description_Image *epd, Eet_File *ef) +{ + unsigned int i; + +#if 0 /* FIXME: This check sounds like not a useful one */ + if (epd->image.id == -1) + ERR(ef, "Collection %s(%i): image attributes missing for " + "part \"%s\", description \"%s\" %f\n", + pc->part, pc->id, ep->name, epd->common.state.name, epd->common.state.value); +#endif + + for (i = 0; i < epd->image.tweens_count; ++i) + { + if (epd->image.tweens[i]->id == -1) + error_and_abort(ef, "Collection %i: tween image id missing for " + "part \"%s\", description \"%s\" %f\n", + pc->id, ep->name, epd->common.state.name, epd->common.state.value); + } +} + +static void +check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) +{ + unsigned int i; + + for (i = 0; i < ep->items_count; ++i) + { + if (ep->items[i]->type == EDJE_PART_TYPE_GROUP && !ep->items[i]->source) + error_and_abort(ef, "Collection %i: missing source on packed item " + "of type GROUP in part \"%s\"\n", + pc->id, ep->name); + if (ep->type == EDJE_PART_TYPE_TABLE && (ep->items[i]->col < 0 || ep->items[i]->row < 0)) + error_and_abort(ef, "Collection %i: missing col/row on packed item " + "for part \"%s\" of type TABLE\n", + pc->id, ep->name); + } +} + +static void +check_nameless_state(Edje_Part_Collection *pc, Edje_Part *ep, Edje_Part_Description_Common *ed, Eet_File *ef) +{ + if (!ed->state.name) + error_and_abort(ef, "Collection %i: description with state missing on part \"%s\"\n", + pc->id, ep->name); +} + +static void +check_part (Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) +{ + unsigned int i; + /* FIXME: check image set and sort them. */ + if (!ep->default_desc) + error_and_abort(ef, "Collection %i: default description missing " + "for part \"%s\"\n", pc->id, ep->name); + + for (i = 0; i < ep->other.desc_count; ++i) + check_nameless_state(pc, ep, ep->other.desc[i], ef); + + if (ep->type == EDJE_PART_TYPE_IMAGE) + { + check_image_part_desc(pc, ep, (Edje_Part_Description_Image*) ep->default_desc, ef); + + for (i = 0; i < ep->other.desc_count; ++i) + check_image_part_desc (pc, ep, (Edje_Part_Description_Image*) ep->other.desc[i], ef); + } + else if ((ep->type == EDJE_PART_TYPE_BOX) || + (ep->type == EDJE_PART_TYPE_TABLE)) + check_packed_items(pc, ep, ef); +} + +static void +check_program (Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef) +{ + switch (ep->action) + { + case EDJE_ACTION_TYPE_STATE_SET: + case EDJE_ACTION_TYPE_ACTION_STOP: + case EDJE_ACTION_TYPE_DRAG_VAL_SET: + case EDJE_ACTION_TYPE_DRAG_VAL_STEP: + case EDJE_ACTION_TYPE_DRAG_VAL_PAGE: + if (!ep->targets) + error_and_abort(ef, "Collection %i: target missing in program " + "\"%s\"\n", pc->id, ep->name); + break; + default: + break; + } +} + +static int +data_write_header(Eet_File *ef) +{ + int bytes = 0; + + if (edje_file) + { + if (edje_file->collection) + { + Edje_Part_Collection_Directory_Entry *ce; + + /* copy aliases into collection directory */ + EINA_LIST_FREE(aliases, ce) + { + Edje_Part_Collection_Directory_Entry *sce; + Eina_Iterator *it; + + if (!ce->entry) + error_and_abort(ef, "Collection %i: name missing.\n", ce->id); + + it = eina_hash_iterator_data_new(edje_file->collection); + + EINA_ITERATOR_FOREACH(it, sce) + if (ce->id == sce->id) + { + memcpy(&ce->count, &sce->count, sizeof (ce->count)); + break; + } + + if (!sce) + error_and_abort(ef, "Collection %s (%i) can't find an correct alias.\n", ce->entry, ce->id); + + eina_iterator_free(it); + + eina_hash_direct_add(edje_file->collection, ce->entry, ce); + } + } + bytes = eet_data_write(ef, edd_edje_file, "edje/file", edje_file, 1); + if (bytes <= 0) + error_and_abort(ef, "Unable to write \"edje_file\" entry to \"%s\" \n", + file_out); + } + + if (verbose) + { + printf("%s: Wrote %9i bytes (%4iKb) for \"edje_file\" header\n", + progname, bytes, (bytes + 512) / 1024); + } + + return bytes; +} + +static int +data_write_fonts(Eet_File *ef, int *font_num, int *input_bytes, int *input_raw_bytes) +{ + Eina_Iterator *it; + int bytes = 0; + int total_bytes = 0; + Font *fn; + + if (!edje_file->fonts) + return 0; + + it = eina_hash_iterator_data_new(edje_file->fonts); + EINA_ITERATOR_FOREACH(it, fn) + { + void *fdata = NULL; + int fsize = 0; + Eina_List *ll; + FILE *f; + + f = fopen(fn->file, "rb"); + if (f) + { + long pos; + + fseek(f, 0, SEEK_END); + pos = ftell(f); + rewind(f); + fdata = malloc(pos); + if (fdata) + { + if (fread(fdata, pos, 1, f) != 1) + error_and_abort(ef, "Unable to read all of font " + "file \"%s\"\n", fn->file); + fsize = pos; + } + fclose(f); + } + else + { + char *data; + + EINA_LIST_FOREACH(fnt_dirs, ll, data) + { + char buf[4096]; + + snprintf(buf, sizeof(buf), "%s/%s", data, fn->file); + f = fopen(buf, "rb"); + if (f) + { + long pos; + + fseek(f, 0, SEEK_END); + pos = ftell(f); + rewind(f); + fdata = malloc(pos); + if (fdata) + { + if (fread(fdata, pos, 1, f) != 1) + error_and_abort(ef, "Unable to read all of font " + "file \"%s\"\n", buf); + fsize = pos; + } + fclose(f); + if (fdata) break; + } + } + } + if (!fdata) + { + error_and_abort(ef, "Unable to load font part \"%s\" entry " + "to %s \n", fn->file, file_out); + } + else + { + char buf[4096]; + + snprintf(buf, sizeof(buf), "edje/fonts/%s", fn->name); + bytes = eet_write(ef, buf, fdata, fsize, 1); + if (bytes <= 0) + error_and_abort(ef, "Unable to write font part \"%s\" as \"%s\" " + "part entry to %s \n", fn->file, buf, file_out); + + *font_num += 1; + total_bytes += bytes; + *input_bytes += fsize; + *input_raw_bytes += fsize; + + if (verbose) + { + printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" font entry \"%s\" compress: [real: %2.1f%%]\n", + progname, bytes, (bytes + 512) / 1024, buf, fn->file, + 100 - (100 * (double)bytes) / ((double)(fsize)) + ); + } + free(fdata); + } + } + eina_iterator_free(it); + + return total_bytes; +} + +static void +error_and_abort_image_load_error(Eet_File *ef, const char *file, int error) +{ + const char *errmsg = evas_load_error_str(error); + char hint[1024] = ""; + + if (error == EVAS_LOAD_ERROR_DOES_NOT_EXIST) + { + snprintf + (hint, sizeof(hint), + " Check if path to file \"%s\" is correct " + "(both directory and file name).", + file); + } + else if (error == EVAS_LOAD_ERROR_CORRUPT_FILE) + { + snprintf + (hint, sizeof(hint), + " Check if file \"%s\" is consistent.", + file); + } + else if (error == EVAS_LOAD_ERROR_UNKNOWN_FORMAT) + { + const char *ext = strrchr(file, '.'); + const char **itr, *known_loaders[] = { + /* list from evas_image_load.c */ + "png", + "jpg", + "jpeg", + "jfif", + "eet", + "edj", + "eap", + "edb", + "xpm", + "tiff", + "tif", + "svg", + "svgz", + "gif", + "pbm", + "pgm", + "ppm", + "pnm", + NULL + }; + + if (!ext) + { + snprintf + (hint, sizeof(hint), + " File \"%s\" does not have an extension, " + "maybe it should?", + file); + goto show_err; + } + + ext++; + for (itr = known_loaders; *itr; itr++) + { + if (strcasecmp(ext, *itr) == 0) + { + snprintf + (hint, sizeof(hint), + " Check if Evas was compiled with %s module enabled and " + "all required dependencies exist.", + ext); + goto show_err; + } + } + + snprintf(hint, sizeof(hint), + " Check if Evas supports loading files of type \"%s\" (%s) " + "and this module was compiled and all its dependencies exist.", + ext, file); + } + show_err: + error_and_abort + (ef, "Unable to load image \"%s\" used by file \"%s\": %s.%s\n", + file, file_out, errmsg, hint); +} + +static int +data_write_images(Eet_File *ef, int *image_num, int *input_bytes, int *input_raw_bytes) +{ + unsigned int i; + int bytes = 0; + int total_bytes = 0; + + if ((edje_file) && (edje_file->image_dir)) + { + Ecore_Evas *ee; + Evas *evas; + Edje_Image_Directory_Entry *img; + + ecore_init(); + ecore_evas_init(); + + ee = ecore_evas_buffer_new(1, 1); + if (!ee) + error_and_abort(ef, "Cannot create buffer engine canvas for image " + "load.\n"); + + evas = ecore_evas_get(ee); + for (i = 0; i < edje_file->image_dir->entries_count; i++) + { + img = &edje_file->image_dir->entries[i]; + + if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) + { + } + else + { + Evas_Object *im; + Eina_List *ll; + char *data; + int load_err = EVAS_LOAD_ERROR_NONE; + + im = NULL; + EINA_LIST_FOREACH(img_dirs, ll, data) + { + char buf[4096]; + + snprintf(buf, sizeof(buf), "%s/%s", + data, img->entry); + im = evas_object_image_add(evas); + if (im) + { + evas_object_image_file_set(im, buf, NULL); + load_err = evas_object_image_load_error_get(im); + if (load_err == EVAS_LOAD_ERROR_NONE) + break; + evas_object_del(im); + im = NULL; + if (load_err != EVAS_LOAD_ERROR_DOES_NOT_EXIST) + break; + } + } + if ((!im) && (load_err == EVAS_LOAD_ERROR_DOES_NOT_EXIST)) + { + im = evas_object_image_add(evas); + if (im) + { + evas_object_image_file_set(im, img->entry, NULL); + load_err = evas_object_image_load_error_get(im); + if (load_err != EVAS_LOAD_ERROR_NONE) + { + evas_object_del(im); + im = NULL; + } + } + } + if (im) + { + void *im_data; + int im_w, im_h; + int im_alpha; + char buf[256]; + + evas_object_image_size_get(im, &im_w, &im_h); + im_alpha = evas_object_image_alpha_get(im); + im_data = evas_object_image_data_get(im, 0); + if ((im_data) && (im_w > 0) && (im_h > 0)) + { + int mode, qual; + + snprintf(buf, sizeof(buf), "edje/images/%i", img->id); + qual = 80; + if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && + (img->source_param == 0)) + mode = 0; /* RAW */ + else if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && + (img->source_param == 1)) + mode = 1; /* COMPRESS */ + else + mode = 2; /* LOSSY */ + if ((mode == 0) && (no_raw)) + { + mode = 1; /* promote compression */ + img->source_param = 95; + } + if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */ + if ((mode == 1) && (no_comp)) + { + if (no_lossy) mode = 0; /* demote compression */ + else if (no_raw) + { + img->source_param = 90; + mode = 2; /* no choice. lossy */ + } + } + if (mode == 2) + { + qual = img->source_param; + if (qual < min_quality) qual = min_quality; + if (qual > max_quality) qual = max_quality; + } + if (mode == 0) + bytes = eet_data_image_write(ef, buf, + im_data, im_w, im_h, + im_alpha, + 0, 0, 0); + else if (mode == 1) + bytes = eet_data_image_write(ef, buf, + im_data, im_w, im_h, + im_alpha, + 1, 0, 0); + else if (mode == 2) + bytes = eet_data_image_write(ef, buf, + im_data, im_w, im_h, + im_alpha, + 0, qual, 1); + if (bytes <= 0) + error_and_abort(ef, "Unable to write image part " + "\"%s\" as \"%s\" part entry to " + "%s\n", img->entry, buf, + file_out); + + *image_num += 1; + total_bytes += bytes; + } + else + { + error_and_abort_image_load_error + (ef, img->entry, load_err); + } + + if (verbose) + { + struct stat st; + const char *file = NULL; + + evas_object_image_file_get(im, &file, NULL); + if (!file || (stat(file, &st) != 0)) + st.st_size = 0; + *input_bytes += st.st_size; + *input_raw_bytes += im_w * im_h * 4; + printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\" compress: [raw: %2.1f%%] [real: %2.1f%%]\n", + progname, bytes, (bytes + 512) / 1024, buf, img->entry, + 100 - (100 * (double)bytes) / ((double)(im_w * im_h * 4)), + 100 - (100 * (double)bytes) / ((double)(st.st_size)) + ); + } + evas_object_del(im); + } + else + { + error_and_abort_image_load_error + (ef, img->entry, load_err); + } + } + } + ecore_evas_free(ee); + ecore_evas_shutdown(); + ecore_shutdown(); + } + + return total_bytes; +} + +static int +data_write_sounds(Eet_File * ef, int *sound_num, int *input_bytes, int *input_raw_bytes) +{ + int bytes = 0; + int total_bytes = 0; + + if ((edje_file) && (edje_file->sound_dir)) + { + Eina_List *ll; + Edje_Sound_Sample *sample; +#ifdef HAVE_LIBSNDFILE + Edje_Sound_Encode *enc_info; +#endif + char *dir_path = NULL; + char snd_path[PATH_MAX]; + char sndid_str[15]; + void *fdata; + FILE *fp = NULL; + struct stat st; + int size = 0; + int i; + + for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++) + { + sample = &edje_file->sound_dir->samples[i]; + memset(&st, 0, sizeof(struct stat)); + + // Search the Sound file in all the -sd ( sound directory ) + EINA_LIST_FOREACH(snd_dirs, ll, dir_path) + { + snprintf((char *)snd_path, sizeof(snd_path), "%s/%s", dir_path, + sample->snd_src); + stat(snd_path, &st); + if (st.st_size) break; + } + if (!st.st_size) + { + snprintf((char *)snd_path, sizeof(snd_path), "%s", + sample->snd_src); + stat(snd_path, &st); + } + size = st.st_size; + if (!size) + { + ERR("%s: Error. Unable to load sound source file : %s", + progname, sample->snd_src); + exit(-1); + } +#ifdef HAVE_LIBSNDFILE + enc_info = _edje_multisense_encode(snd_path, sample, sample->quality); + + stat(enc_info->file, &st); + size = st.st_size; + fp = fopen(enc_info->file, "rb"); +#else + fp = fopen(snd_path, "rb"); +#endif + if (!fp) + { + ERR("%s: Error: Unable to load sound data of: %s", + progname, sample->name); + exit(-1); + } + + snprintf(sndid_str, sizeof(sndid_str), "edje/sounds/%i", sample->id); + fdata = malloc(size); + if (!fdata) + { + ERR("%s: Error. %s:%i while allocating memory to load file \"%s\"", + progname, file_in, line, snd_path); + exit(-1); + } + if (fread(fdata, size, 1, fp)) + bytes = eet_write(ef, sndid_str, fdata, size, EINA_FALSE); + free(fdata); + fclose(fp); + +#ifdef HAVE_LIBSNDFILE + //If encoded temporary file, delete it. + if (enc_info->encoded) unlink(enc_info->file); +#endif + *sound_num += 1; + total_bytes += bytes; + *input_bytes += size; + *input_raw_bytes += size; + + if (verbose) + { +#ifdef HAVE_LIBSNDFILE + printf ("%s: Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry" + "\"%s\" \n", progname, bytes, (bytes + 512) / 1024, + sndid_str, enc_info->comp_type, sample->name); +#else + printf ("%s: Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry" + "\"%s\" \n", progname, bytes, (bytes + 512) / 1024, + sndid_str, "RAW PCM", sample->name); +#endif + } +#ifdef HAVE_LIBSNDFILE + if ((enc_info->file) && (!enc_info->encoded)) eina_stringshare_del(enc_info->file); + if (enc_info) free(enc_info); + enc_info = NULL; +#endif + } + } + return total_bytes; +} + +static void +check_groups(Eet_File *ef) +{ + Edje_Part_Collection *pc; + Eina_List *l; + + /* sanity checks for parts and programs */ + EINA_LIST_FOREACH(edje_collections, l, pc) + { + unsigned int i; + + for (i = 0; i < pc->parts_count; ++i) + check_part(pc, pc->parts[i], ef); + +#define CHECK_PROGRAM(Type, Pc, It) \ + for (It = 0; It < Pc->programs.Type ## _count; ++It) \ + check_program(Pc, Pc->programs.Type[i], ef); \ + + CHECK_PROGRAM(fnmatch, pc, i); + CHECK_PROGRAM(strcmp, pc, i); + CHECK_PROGRAM(strncmp, pc, i); + CHECK_PROGRAM(strrncmp, pc, i); + CHECK_PROGRAM(nocmp, pc, i); + } +} + +static int +data_write_groups(Eet_File *ef, int *collection_num) +{ + Eina_List *l; + Edje_Part_Collection *pc; + int bytes = 0; + int total_bytes = 0; + + EINA_LIST_FOREACH(edje_collections, l, pc) + { + char buf[4096]; + + snprintf(buf, sizeof(buf), "edje/collections/%i", pc->id); + bytes = eet_data_write(ef, edd_edje_part_collection, buf, pc, 1); + if (bytes <= 0) + error_and_abort(ef, "Error. Unable to write \"%s\" part entry " + "to %s\n", buf, file_out); + + *collection_num += 1; + total_bytes += bytes; + + if (verbose) + { + printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" collection entry\n", + progname, bytes, (bytes + 512) / 1024, buf); + } + } + + return total_bytes; +} + +static void +create_script_file(Eet_File *ef, const char *filename, const Code *cd, int fd) +{ + FILE *f = fdopen(fd, "wb"); + if (!f) + error_and_abort(ef, "Unable to open temp file \"%s\" for script " + "compilation.\n", filename); + + Eina_List *ll; + Code_Program *cp; + + fprintf(f, "#include \n"); + int ln = 2; + + if (cd->shared) + { + while (ln < (cd->l1 - 1)) + { + fprintf(f, " \n"); + ln++; + } + { + char *sp; + int hash = 0; + int newlined = 0; + + for (sp = cd->shared; *sp; sp++) + { + if ((sp[0] == '#') && (newlined)) + { + hash = 1; + } + newlined = 0; + if (sp[0] == '\n') newlined = 1; + if (!hash) fputc(sp[0], f); + else if (sp[0] == '\n') hash = 0; + } + fputc('\n', f); + } + ln += cd->l2 - cd->l1 + 1; + } + EINA_LIST_FOREACH(cd->programs, ll, cp) + { + if (cp->script) + { + while (ln < (cp->l1 - 1)) + { + fprintf(f, " \n"); + ln++; + } + /* FIXME: this prototype needs to be */ + /* formalised and set in stone */ + fprintf(f, "public _p%i(sig[], src[]) {", cp->id); + { + char *sp; + int hash = 0; + int newlined = 0; + + for (sp = cp->script; *sp; sp++) + { + if ((sp[0] == '#') && (newlined)) + { + hash = 1; + } + newlined = 0; + if (sp[0] == '\n') newlined = 1; + if (!hash) fputc(sp[0], f); + else if (sp[0] == '\n') hash = 0; + } + } + fprintf(f, "}\n"); + ln += cp->l2 - cp->l1 + 1; + } + } + + fclose(f); +} + +static void +compile_script_file(Eet_File *ef, const char *source, const char *output, + int script_num, int fd) +{ + FILE *f; + char buf[4096]; + int ret; + + snprintf(buf, sizeof(buf), + "embryo_cc -i %s/include -o %s %s", + eina_prefix_data_get(pfx), output, source); + ret = system(buf); + + /* accept warnings in the embryo code */ + if (ret < 0 || ret > 1) + error_and_abort(ef, "Compiling script code not clean.\n"); + + f = fdopen(fd, "rb"); + if (!f) + error_and_abort(ef, "Unable to open script object \"%s\" for reading.\n", + output); + + fseek(f, 0, SEEK_END); + int size = ftell(f); + rewind(f); + + if (size > 0) + { + void *data = malloc(size); + + if (data) + { + if (fread(data, size, 1, f) != 1) + error_and_abort(ef, "Unable to read all of script object " + "\"%s\"\n", output); + + snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", script_num); + eet_write(ef, buf, data, size, 1); + free(data); + } + } + + fclose(f); +} + +static void +data_write_scripts(Eet_File *ef) +{ + Eina_List *l; + int i; + + if (!tmp_dir) +#ifdef HAVE_EVIL + tmp_dir = (char *)evil_tmpdir_get(); +#else + tmp_dir = "/tmp"; +#endif + + for (i = 0, l = codes; l; l = eina_list_next(l), i++) + { + char tmpn[PATH_MAX]; + char tmpo[PATH_MAX]; + int fd; + Code *cd = eina_list_data_get(l); + + if (cd->is_lua) + continue; + if ((!cd->shared) && (!cd->programs)) + continue; + + snprintf(tmpn, PATH_MAX, "%s/edje_cc.sma-tmp-XXXXXX", tmp_dir); + fd = mkstemp(tmpn); + if (fd < 0) + error_and_abort(ef, "Unable to open temp file \"%s\" for script " + "compilation.\n", tmpn); + + create_script_file(ef, tmpn, cd, fd); + + snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir); + fd = mkstemp(tmpo); + if (fd < 0) + { + unlink(tmpn); + error_and_abort(ef, "Unable to open temp file \"%s\" for script " + "compilation.\n", tmpn); + } + compile_script_file(ef, tmpn, tmpo, i, fd); + + unlink(tmpn); + unlink(tmpo); + + if (!no_save) + { + char buf[PATH_MAX]; + Eina_List *ll; + Code_Program *cp; + + if (cd->original) + { + snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i", i); + eet_write(ef, buf, cd->original, strlen(cd->original) + 1, 1); + } + EINA_LIST_FOREACH(cd->programs, ll, cp) + { + if (!cp->original) + continue; + snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i/%i", i, + cp->id); + eet_write(ef, buf, cp->original, strlen(cp->original) + 1, 1); + } + } + } +} + +typedef struct _Edje_Lua_Script_Writer_Struct Edje_Lua_Script_Writer_Struct; + +struct _Edje_Lua_Script_Writer_Struct +{ + char *buf; + int size; +}; + +#ifdef LUA_BINARY +static int +_edje_lua_script_writer(lua_State *L __UNUSED__, const void *chunk_buf, size_t chunk_size, void *_data) +{ + Edje_Lua_Script_Writer_Struct *data; + void *old; + + data = (Edje_Lua_Script_Writer_Struct *)_data; + old = data->buf; + data->buf = malloc (data->size + chunk_size); + memcpy (data->buf, old, data->size); + memcpy (&((data->buf)[data->size]), chunk_buf, chunk_size); + if (old) + free (old); + data->size += chunk_size; + + return 0; +} +#endif + +void +_edje_lua_error_and_abort(lua_State * L, int err_code, Eet_File *ef) +{ + char *err_type; + + switch (err_code) + { + case LUA_ERRRUN: + err_type = "runtime"; + break; + case LUA_ERRSYNTAX: + err_type = "syntax"; + break; + case LUA_ERRMEM: + err_type = "memory allocation"; + break; + case LUA_ERRERR: + err_type = "error handler"; + break; + default: + err_type = "unknown"; + break; + } + error_and_abort(ef, "Lua %s error: %s\n", err_type, lua_tostring(L, -1)); +} + + +static void +data_write_lua_scripts(Eet_File *ef) +{ + Eina_List *l; + Eina_List *ll; + Code_Program *cp; + int i; + + for (i = 0, l = codes; l; l = eina_list_next(l), i++) + { + char buf[4096]; + Code *cd; + lua_State *L; + int ln = 1; + luaL_Buffer b; + Edje_Lua_Script_Writer_Struct data; +#ifdef LUA_BINARY + int err_code; +#endif + + cd = (Code *)eina_list_data_get(l); + if (!cd->is_lua) + continue; + if ((!cd->shared) && (!cd->programs)) + continue; + + L = luaL_newstate(); + if (!L) + error_and_abort(ef, "Lua error: Lua state could not be initialized\n"); + + luaL_buffinit(L, &b); + + data.buf = NULL; + data.size = 0; + if (cd->shared) + { + while (ln < (cd->l1 - 1)) + { + luaL_addchar(&b, '\n'); + ln++; + } + luaL_addstring(&b, cd->shared); + ln += cd->l2 - cd->l1; + } + + EINA_LIST_FOREACH(cd->programs, ll, cp) + { + if (cp->script) + { + while (ln < (cp->l1 - 1)) + { + luaL_addchar(&b, '\n'); + ln++; + } + luaL_addstring(&b, "_G["); + lua_pushnumber(L, cp->id); + luaL_addvalue(&b); + luaL_addstring(&b, "] = function (ed, signal, source)"); + luaL_addstring(&b, cp->script); + luaL_addstring(&b, "end\n"); + ln += cp->l2 - cp->l1 + 1; + } + } + luaL_pushresult(&b); +#ifdef LUA_BINARY + if (err_code = luaL_loadstring(L, lua_tostring (L, -1))) + _edje_lua_error_and_abort(L, err_code, ef); + lua_dump(L, _edje_lua_script_writer, &data); +#else // LUA_PLAIN_TEXT + data.buf = (char *)lua_tostring(L, -1); + data.size = strlen(data.buf); +#endif + //printf("lua chunk size: %d\n", data.size); + + /* + * TODO load and test Lua chunk + */ + + /* + if (luaL_loadbuffer(L, globbuf, globbufsize, "edje_lua_script")) + printf("lua load error: %s\n", lua_tostring (L, -1)); + if (lua_pcall(L, 0, 0, 0)) + printf("lua call error: %s\n", lua_tostring (L, -1)); + */ + + snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", i); + eet_write(ef, buf, data.buf, data.size, 1); +#ifdef LUA_BINARY + free(data.buf); +#endif + lua_close(L); + } +} + +void +data_write(void) +{ + Eet_File *ef; + int input_bytes = 0; + int total_bytes = 0; + int src_bytes = 0; + int fmap_bytes = 0; + int input_raw_bytes = 0; + int image_num = 0; + int sound_num = 0; + int font_num = 0; + int collection_num = 0; + + if (!edje_file) + { + ERR("%s: Error. No data to put in \"%s\"", + progname, file_out); + exit(-1); + } + + ef = eet_open(file_out, EET_FILE_MODE_WRITE); + if (!ef) + { + ERR("%s: Error. Unable to open \"%s\" for writing output", + progname, file_out); + exit(-1); + } + + check_groups(ef); + + total_bytes += data_write_header(ef); + total_bytes += data_write_fonts(ef, &font_num, &input_bytes, + &input_raw_bytes); + total_bytes += data_write_images(ef, &image_num, &input_bytes, + &input_raw_bytes); + total_bytes += data_write_sounds(ef, &sound_num, &input_bytes, + &input_raw_bytes); + + total_bytes += data_write_groups(ef, &collection_num); + data_write_scripts(ef); + data_write_lua_scripts(ef); + + src_bytes = source_append(ef); + total_bytes += src_bytes; + fmap_bytes = source_fontmap_save(ef, fonts); + total_bytes += fmap_bytes; + + eet_close(ef); + + if (verbose) + { + struct stat st; + + if (stat(file_in, &st) != 0) + st.st_size = 0; + input_bytes += st.st_size; + input_raw_bytes += st.st_size; + printf("Summary:\n" + " Wrote %i collections\n" + " Wrote %i images\n" + " Wrote %i sounds\n" + " Wrote %i fonts\n" + " Wrote %i bytes (%iKb) of original source data\n" + " Wrote %i bytes (%iKb) of original source font map\n" + "Conservative compression summary:\n" + " Wrote total %i bytes (%iKb) from %i (%iKb) input data\n" + " Output file is %3.1f%% the size of the input data\n" + " Saved %i bytes (%iKb)\n" + "Raw compression summary:\n" + " Wrote total %i bytes (%iKb) from %i (%iKb) raw input data\n" + " Output file is %3.1f%% the size of the raw input data\n" + " Saved %i bytes (%iKb)\n" + , + collection_num, + image_num, + sound_num, + font_num, + src_bytes, (src_bytes + 512) / 1024, + fmap_bytes, (fmap_bytes + 512) / 1024, + total_bytes, (total_bytes + 512) / 1024, + input_bytes, (input_bytes + 512) / 1024, + (100.0 * (double)total_bytes) / (double)input_bytes, + input_bytes - total_bytes, + (input_bytes - total_bytes + 512) / 1024, + total_bytes, (total_bytes + 512) / 1024, + input_raw_bytes, (input_raw_bytes + 512) / 1024, + (100.0 * (double)total_bytes) / (double)input_raw_bytes, + input_raw_bytes - total_bytes, + (input_raw_bytes - total_bytes + 512) / 1024); + } +} + +void +reorder_parts(void) +{ + Edje_Part_Collection *pc; + Edje_Part **parts; + Edje_Part_Parser *ep, *ep2; + Eina_List *l; + + /* sanity checks for parts and programs */ + EINA_LIST_FOREACH(edje_collections, l, pc) + { + unsigned int i, j, k; + Eina_Bool found = EINA_FALSE; + + for (i = 0; i < pc->parts_count; i++) + { + ep = (Edje_Part_Parser *)pc->parts[i]; + if (ep->reorder.insert_before && ep->reorder.insert_after) + ERR("%s: Error. Unable to use together insert_before and insert_after in part \"%s\".", progname, pc->parts[i]->name); + + if (ep->reorder.done) + { + continue; + } + if (ep->reorder.insert_before || ep->reorder.insert_after) + { + found = EINA_FALSE; + for (j = 0; j < pc->parts_count; j++) + { + if (ep->reorder.insert_before && + !strcmp(ep->reorder.insert_before, pc->parts[j]->name)) + { + ep2 = (Edje_Part_Parser *)pc->parts[j]; + if (ep2->reorder.after) + ERR("%s: Error. The part \"%s\" is ambiguous ordered part.", progname, pc->parts[i]->name); + if (ep2->reorder.linked_prev) + ERR("%s: Error. Unable to insert two or more parts in same part \"%s\".", progname, pc->parts[j]->name); + k = j - 1; + found = EINA_TRUE; + ep2->reorder.linked_prev += ep->reorder.linked_prev + 1; + ep->reorder.before = (Edje_Part_Parser *)pc->parts[j]; + while (ep2->reorder.before) + { + ep2->reorder.before->reorder.linked_prev = ep2->reorder.linked_prev + 1; + ep2 = ep2->reorder.before; + } + break; + } + else if (ep->reorder.insert_after && + !strcmp(ep->reorder.insert_after, pc->parts[j]->name)) + { + ep2 = (Edje_Part_Parser *)pc->parts[j]; + if (ep2->reorder.before) + ERR("%s: Error. The part \"%s\" is ambiguous ordered part.", progname, pc->parts[i]->name); + if (ep2->reorder.linked_next) + ERR("%s: Error. Unable to insert two or more parts in same part \"%s\".", progname, pc->parts[j]->name); + k = j; + found = EINA_TRUE; + ep2->reorder.linked_next += ep->reorder.linked_next + 1; + ep->reorder.after = (Edje_Part_Parser *)pc->parts[j]; + while (ep2->reorder.after) + { + ep2->reorder.after->reorder.linked_next = ep2->reorder.linked_next + 1; + ep2 = ep2->reorder.after; + } + break; + } + } + if (found) + { + unsigned int amount, linked; + + if (((i > k) && ((i - ep->reorder.linked_prev) <= k)) + || ((i < k) && ((i + ep->reorder.linked_next) >= k))) + ERR("%s: Error. The part order is wrong. It has circular dependency.", + progname); + + amount = ep->reorder.linked_prev + ep->reorder.linked_next + 1; + linked = i - ep->reorder.linked_prev; + parts = malloc(amount * sizeof(Edje_Part)); + for (j = 0 ; j < amount ; j++) + { + parts[j] = pc->parts[linked]; + linked++; + } + if (i > k) + { + for (j = i - ep->reorder.linked_prev - 1 ; j >= k ; j--) + { + pc->parts[j + amount] = pc->parts[j]; + pc->parts[j + amount]->id = j + amount; + } + for (j = 0 ; j < amount ; j++) + { + pc->parts[j + k] = parts[j]; + pc->parts[j + k]->id = j + k; + } + } + else if (i < k) + { + for (j = i + ep->reorder.linked_next + 1 ; j <= k ; j++) + { + pc->parts[j - amount] = pc->parts[j]; + pc->parts[j - amount]->id = j - amount; + } + for (j = 0 ; j < amount ; j++) + { + pc->parts[j + k - amount + 1] = parts[j]; + pc->parts[j + k - amount + 1]->id = j + k - amount + 1; + } + i -= amount; + } + ep->reorder.done = EINA_TRUE; + free(parts); + } + } + } + } +} + +void +data_queue_group_lookup(char *name) +{ + Group_Lookup *gl; + + gl = mem_alloc(SZ(Group_Lookup)); + group_lookups = eina_list_append(group_lookups, gl); + gl->name = mem_strdup(name); +} + +void +data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest) +{ + Eina_List *l; + Part_Lookup *pl; + + EINA_LIST_FOREACH(part_lookups, l, pl) + { + if ((pl->pc == pc) && (pl->dest == dest)) + { + free(pl->name); + if (name[0]) + pl->name = mem_strdup(name); + else + { + part_lookups = eina_list_remove(part_lookups, pl); + free(pl); + } + return; + } + } + if (!name[0]) return; + + pl = mem_alloc(SZ(Part_Lookup)); + part_lookups = eina_list_append(part_lookups, pl); + pl->pc = pc; + pl->name = mem_strdup(name); + pl->dest = dest; +} + +void +data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest) +{ + Eina_List *l; + Part_Lookup *pl; + + EINA_LIST_FOREACH(part_lookups, l, pl) + { + if (pl->dest == src) + data_queue_part_lookup(pc, pl->name, dest); + } +} + +void +data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest) +{ + Eina_List *l, *l2; + Program_Lookup *pl; + + if (!ep) return ; /* FIXME: should we stop compiling ? */ + + EINA_LIST_FOREACH(program_lookups, l, pl) + { + if (pl->u.ep == ep) + { + Code *cd; + Code_Program *cp; + + cd = eina_list_data_get(eina_list_last(codes)); + + EINA_LIST_FOREACH(cd->programs, l2, cp) + { + if (&(cp->id) == pl->dest) + { + cd->programs = eina_list_remove(cd->programs, cp); + free(cp); + cp = NULL; + } + } + program_lookups = eina_list_remove(program_lookups, pl); + free(pl); + } + } + + if (dest) + { + pl = mem_alloc(SZ(Program_Lookup)); + program_lookups = eina_list_append(program_lookups, pl); + pl->pc = pc; + pl->u.ep = ep; + pl->dest = dest; + pl->anonymous = EINA_TRUE; + } +} + +void +data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest) +{ + Eina_List *l; + Program_Lookup *pl; + unsigned int i; + + EINA_LIST_FOREACH(program_lookups, l, pl) + { + if (pl->dest == src) + { + for (i = 0 ; i < pc->programs.fnmatch_count ; i++) + { + if (!strcmp(pl->u.ep->name, pc->programs.fnmatch[i]->name)) + data_queue_anonymous_lookup(pc, pc->programs.fnmatch[i], dest); + } + for (i = 0 ; i < pc->programs.strcmp_count ; i++) + { + if (!strcmp(pl->u.ep->name, pc->programs.strcmp[i]->name)) + data_queue_anonymous_lookup(pc, pc->programs.strcmp[i], dest); + } + for (i = 0 ; i < pc->programs.strncmp_count ; i++) + { + if (!strcmp(pl->u.ep->name, pc->programs.strncmp[i]->name)) + data_queue_anonymous_lookup(pc, pc->programs.strncmp[i], dest); + } + for (i = 0 ; i < pc->programs.strrncmp_count ; i++) + { + if (!strcmp(pl->u.ep->name, pc->programs.strrncmp[i]->name)) + data_queue_anonymous_lookup(pc, pc->programs.strrncmp[i], dest); + } + for (i = 0 ; i < pc->programs.nocmp_count ; i++) + { + if (!strcmp(pl->u.ep->name, pc->programs.nocmp[i]->name)) + data_queue_anonymous_lookup(pc, pc->programs.nocmp[i], dest); + } + } + } +} + +void +data_queue_program_lookup(Edje_Part_Collection *pc, const char *name, int *dest) +{ + Program_Lookup *pl; + + if (!name) return ; /* FIXME: should we stop compiling ? */ + + pl = mem_alloc(SZ(Program_Lookup)); + program_lookups = eina_list_append(program_lookups, pl); + pl->pc = pc; + pl->u.name = mem_strdup(name); + pl->dest = dest; + pl->anonymous = EINA_FALSE; +} + +void +data_queue_copied_program_lookup(Edje_Part_Collection *pc, int *src, int *dest) +{ + Eina_List *l; + Program_Lookup *pl; + + EINA_LIST_FOREACH(program_lookups, l, pl) + { + if (pl->dest == src) + data_queue_program_lookup(pc, pl->u.name, dest); + } +} + +void +data_queue_image_lookup(char *name, int *dest, Eina_Bool *set) +{ + Image_Lookup *il; + + il = mem_alloc(SZ(Image_Lookup)); + image_lookups = eina_list_append(image_lookups, il); + il->name = mem_strdup(name); + il->dest = dest; + il->set = set; +} + +void +data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set) +{ + Eina_List *l; + Image_Lookup *il; + + EINA_LIST_FOREACH(image_lookups, l, il) + { + if (il->dest == src) + data_queue_image_lookup(il->name, dest, set); + } +} +void +data_queue_part_slave_lookup(int *master, int *slave) +{ + Slave_Lookup *sl; + + sl = mem_alloc(SZ(Slave_Lookup)); + part_slave_lookups = eina_list_append(part_slave_lookups, sl); + sl->master = master; + sl->slave = slave; +} + +void +data_queue_image_slave_lookup(int *master, int *slave) +{ + Slave_Lookup *sl; + + sl = mem_alloc(SZ(Slave_Lookup)); + image_slave_lookups = eina_list_append(image_slave_lookups, sl); + sl->master = master; + sl->slave = slave; +} + +void +handle_slave_lookup(Eina_List *list, int *master, int value) +{ + Eina_List *l; + Slave_Lookup *sl; + + EINA_LIST_FOREACH(list, l, sl) + if (sl->master == master) + *sl->slave = value; +} + +void +data_process_lookups(void) +{ + Edje_Part_Collection *pc; + Part_Lookup *part; + Program_Lookup *program; + Group_Lookup *group; + Image_Lookup *image; + Eina_List *l; + void *data; + + EINA_LIST_FOREACH(edje_collections, l, pc) + { + unsigned int count = 0; + unsigned int i; + +#define PROGRAM_ID_SET(Type, Pc, It, Count) \ + for (It = 0; It < Pc->programs.Type ## _count; ++It) \ + { \ + Pc->programs.Type[It]->id = Count++; \ + } + + PROGRAM_ID_SET(fnmatch, pc, i, count); + PROGRAM_ID_SET(strcmp, pc, i, count); + PROGRAM_ID_SET(strncmp, pc, i, count); + PROGRAM_ID_SET(strrncmp, pc, i, count); + PROGRAM_ID_SET(nocmp, pc, i, count); + +#undef PROGRAM_ID_SET + } + + EINA_LIST_FREE(part_lookups, part) + { + Edje_Part *ep; + unsigned int i; + + for (i = 0; i < part->pc->parts_count; ++i) + { + ep = part->pc->parts[i]; + + if ((ep->name) && (!strcmp(ep->name, part->name))) + { + handle_slave_lookup(part_slave_lookups, part->dest, ep->id); + *(part->dest) = ep->id; + break; + } + } + + if (i == part->pc->parts_count) + { + ERR("%s: Error. Unable to find part name \"%s\".", + progname, part->name); + exit(-1); + } + + free(part->name); + free(part); + } + + EINA_LIST_FREE(program_lookups, program) + { + unsigned int i; + Eina_Bool find = EINA_FALSE; + +#define PROGRAM_MATCH(Type, Pl, It) \ + for (It = 0; It < Pl->pc->programs.Type ## _count; ++It) \ + { \ + Edje_Program *ep; \ + \ + ep = Pl->pc->programs.Type[It]; \ + \ + if ((Pl->anonymous && ep == Pl->u.ep) || \ + ((!Pl->anonymous) && (ep->name) && (!strcmp(ep->name, Pl->u.name)))) \ + { \ + *(Pl->dest) = ep->id; \ + find = EINA_TRUE; \ + break; \ + } \ + } + + PROGRAM_MATCH(fnmatch, program, i); + PROGRAM_MATCH(strcmp, program, i); + PROGRAM_MATCH(strncmp, program, i); + PROGRAM_MATCH(strrncmp, program, i); + PROGRAM_MATCH(nocmp, program, i); + +#undef PROGRAM_MATCH + + if (!find) + { + if (!program->anonymous) + ERR("%s: Error. Unable to find program name \"%s\".", + progname, program->u.name); + else + ERR("%s: Error. Unable to find anonymous program.", + progname); + exit(-1); + } + + if (!program->anonymous) + free(program->u.name); + free(program); + } + + EINA_LIST_FREE(group_lookups, group) + { + Edje_Part_Collection_Directory_Entry *de; + + de = eina_hash_find(edje_file->collection, group->name); + + if (!de) + { + ERR("%s: Error. Unable to find group name \"%s\".", + progname, group->name); + exit(-1); + } + + free(group->name); + free(group); + } + + EINA_LIST_FREE(image_lookups, image) + { + Edje_Image_Directory_Entry *de; + Eina_Bool find = EINA_FALSE; + + if (edje_file->image_dir) + { + unsigned int i; + + for (i = 0; i < edje_file->image_dir->entries_count; ++i) + { + de = edje_file->image_dir->entries + i; + + if ((de->entry) && (!strcmp(de->entry, image->name))) + { + handle_slave_lookup(image_slave_lookups, image->dest, de->id); + if (de->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) + *(image->dest) = -de->id - 1; + else + *(image->dest) = de->id; + *(image->set) = EINA_FALSE; + find = EINA_TRUE; + break; + } + } + + if (!find) + { + Edje_Image_Directory_Set *set; + + for (i = 0; i < edje_file->image_dir->sets_count; ++i) + { + set = edje_file->image_dir->sets + i; + + if ((set->name) && (!strcmp(set->name, image->name))) + { + handle_slave_lookup(image_slave_lookups, image->dest, set->id); + *(image->dest) = set->id; + *(image->set) = EINA_TRUE; + find = EINA_TRUE; + break; + } + } + } + } + + if (!find) + { + ERR("%s: Error. Unable to find image name \"%s\".", + progname, image->name); + exit(-1); + } + + free(image->name); + free(image); + } + + EINA_LIST_FREE(part_slave_lookups, data) + free(data); + + EINA_LIST_FREE(image_slave_lookups, data) + free(data); +} + +static void +data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len)) +{ + char *p; + char *key; + int keyl; + int quote, escape; + + key = alloca(strlen(prefix) + 2 + 1); + if (!key) return; + strcpy(key, prefix); + strcat(key, ":\""); + keyl = strlen(key); + quote = 0; + escape = 0; + for (p = s; (p) && (*p); p++) + { + if (!quote) + { + if (*p == '\"') + { + quote = 1; + p++; + } + } + if (!quote) + { + if (!strncmp(p, key, keyl)) + { + char *ptr; + int len; + int inesc = 0; + char *name; + + ptr = p; + p += keyl; + while ((*p)) + { + if (!inesc) + { + if (*p == '\\') inesc = 1; + else if (*p == '\"') + { + /* string concatenation, see below */ + if (*(p + 1) != '\"') + break; + else + p++; + } + } + else + inesc = 0; + p++; + } + len = p - ptr + 1; + name = alloca(len); + if (name) + { + char *pp; + int i; + + name[0] = 0; + pp = ptr + keyl; + inesc = 0; + i = 0; + while (*pp) + { + if (!inesc) + { + if (*pp == '\\') inesc = 1; + else if (*pp == '\"') + { + /* concat strings like "foo""bar" to "foobar" */ + if (*(pp + 1) == '\"') + pp++; + else + { + name[i] = 0; + break; + } + } + else + { + name[i] = *pp; + name[i + 1] = 0; + i++; + } + } + else + inesc = 0; + pp++; + } + func(pc, name, ptr, len); + } + } + } + else + { + if (!escape) + { + if (*p == '\"') quote = 0; + else if (*p == '\\') escape = 1; + } + else if (escape) + { + escape = 0; + } + } + } +} + +static void +_data_queue_part_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len) +{ + Code_Lookup *cl; + cl = mem_alloc(SZ(Code_Lookup)); + cl->ptr = ptr; + cl->len = len; + + data_queue_part_lookup(pc, name, &(cl->val)); + + code_lookups = eina_list_append(code_lookups, cl); +} +static void +_data_queue_program_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len) +{ + Code_Lookup *cl; + + cl = mem_alloc(SZ(Code_Lookup)); + cl->ptr = ptr; + cl->len = len; + + data_queue_program_lookup(pc, name, &(cl->val)); + + code_lookups = eina_list_append(code_lookups, cl); +} +static void +_data_queue_group_lookup(Edje_Part_Collection *pc __UNUSED__, char *name, char *ptr __UNUSED__, int len __UNUSED__) +{ + data_queue_group_lookup(name); +} +static void +_data_queue_image_pc_lookup(Edje_Part_Collection *pc __UNUSED__, char *name, char *ptr, int len) +{ + Code_Lookup *cl; + + cl = mem_alloc(SZ(Code_Lookup)); + cl->ptr = ptr; + cl->len = len; + + data_queue_image_lookup(name, &(cl->val), &(cl->set)); + + code_lookups = eina_list_append(code_lookups, cl); +} + +void +data_process_scripts(void) +{ + Eina_List *l, *l2; + + for (l = codes, l2 = edje_collections; (l) && (l2); l = eina_list_next(l), l2 = eina_list_next(l2)) + { + Edje_Part_Collection *pc; + Code *cd; + + cd = eina_list_data_get(l); + pc = eina_list_data_get(l2); + + if ((cd->shared) && (!cd->is_lua)) + { + data_process_string(pc, "PART", cd->shared, _data_queue_part_lookup); + data_process_string(pc, "PROGRAM", cd->shared, _data_queue_program_lookup); + data_process_string(pc, "IMAGE", cd->shared, _data_queue_image_pc_lookup); + data_process_string(pc, "GROUP", cd->shared, _data_queue_group_lookup); + } + + if (cd->programs) + { + Code_Program *cp; + Eina_List *ll; + + EINA_LIST_FOREACH(cd->programs, ll, cp) + { + if (cp->script) + { + data_process_string(pc, "PART", cp->script, _data_queue_part_lookup); + data_process_string(pc, "PROGRAM", cp->script, _data_queue_program_lookup); + data_process_string(pc, "IMAGE", cp->script, _data_queue_image_pc_lookup); + data_process_string(pc, "GROUP", cp->script, _data_queue_group_lookup); + } + } + } + } +} + +void +data_process_script_lookups(void) +{ + Eina_List *l; + Code_Lookup *cl; + + EINA_LIST_FOREACH(code_lookups, l, cl) + { + char buf[12]; + int n; + + /* FIXME !! Handle set in program */ + n = eina_convert_itoa(cl->val, buf); + if (n > cl->len) + { + ERR("%s: Error. The unexpected happened. A numeric replacement string was larger than the original!", + progname); + exit(-1); + } + memset(cl->ptr, ' ', cl->len); + strncpy(cl->ptr, buf, n); + } +} 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 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_ALLOCA_H +# include +#elif defined __GNUC__ +# define alloca __builtin_alloca +#elif defined _AIX +# define alloca __alloca +#elif defined _MSC_VER +# include +# define alloca _alloca +#else +# include +# ifdef __cplusplus +extern "C" +# endif +void *alloca (size_t); +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "edje_cc.h" +#include +#include + +#ifdef _WIN32 +# define EPP_EXT ".exe" +#else +# define EPP_EXT +#endif + +static void new_object(void); +static void new_statement(void); +static char *perform_math (char *input); +static int isdelim(char c); +static char *next_token(char *p, char *end, char **new_p, int *delim); +static char *stack_id(void); +static void stack_chop_top(void); +static void parse(char *data, off_t size); + +/* simple expression parsing protos */ +static int my_atoi(const char * s); +static char * _alphai(char *s, int * val); +static char * _betai(char *s, int * val); +static char * _gammai(char *s, int * val); +static char * _deltai(char *s, int * val); +static char * _get_numi(char *s, int * val); +static int _is_numi(char c); +static int _is_op1i(char c); +static int _is_op2i(char c); +static int _calci(char op, int a, int b); + +static double my_atof(const char * s); +static char * _alphaf(char *s, double * val); +static char * _betaf(char *s, double * val); +static char * _gammaf(char *s, double * val); +static char * _deltaf(char *s, double * val); +static char * _get_numf(char *s, double * val); +static int _is_numf(char c); +static int _is_op1f(char c); +static int _is_op2f(char c); +static double _calcf(char op, double a, double b); +static int strstrip(const char *in, char *out, size_t size); + + +int line = 0; +Eina_List *stack = NULL; +Eina_List *params = NULL; + +static char file_buf[4096]; +static int verbatim = 0; +static int verbatim_line1 = 0; +static int verbatim_line2 = 0; +static char *verbatim_str = NULL; + +static void +err_show_stack(void) +{ + char *s; + + s = stack_id(); + if (s) + { + printf("PARSE STACK:\n%s\n", s); + free(s); + } + else + printf("NO PARSE STACK\n"); +} + +static void +err_show_params(void) +{ + Eina_List *l; + char *p; + + printf("PARAMS:"); + EINA_LIST_FOREACH(params, l, p) + { + printf(" %s", p); + } + printf("\n"); +} + +static void +err_show(void) +{ + err_show_stack(); + err_show_params(); +} + +static void +new_object(void) +{ + char *id; + int i; + int handled = 0; + + id = stack_id(); + for (i = 0; i < object_handler_num(); i++) + { + if (!strcmp(object_handlers[i].type, id)) + { + handled = 1; + if (object_handlers[i].func) + { + object_handlers[i].func(); + } + break; + } + } + if (!handled) + { + for (i = 0; i < statement_handler_num(); i++) + { + if (!strcmp(statement_handlers[i].type, id)) + { + free(id); + return; + } + } + } + if (!handled) + { + ERR("%s: Error. %s:%i unhandled keyword %s", + progname, file_in, line - 1, + (char *)eina_list_data_get(eina_list_last(stack))); + err_show(); + exit(-1); + } + free(id); +} + +static void +new_statement(void) +{ + char *id; + int i; + int handled = 0; + + id = stack_id(); + for (i = 0; i < statement_handler_num(); i++) + { + if (!strcmp(statement_handlers[i].type, id)) + { + handled = 1; + if (statement_handlers[i].func) + { + statement_handlers[i].func(); + } + break; + } + } + if (!handled) + { + ERR("%s: Error. %s:%i unhandled keyword %s", + progname, file_in, line - 1, + (char *)eina_list_data_get(eina_list_last(stack))); + err_show(); + exit(-1); + } + free(id); +} + +static char * +perform_math (char *input) +{ + char buf[256]; + double res; + + /* FIXME + * Always apply floating-point arithmetic. + * Does this cause problems for integer parameters? (yes it will) + * + * What we should do is, loop over the string and figure out whether + * there are floating point operands, too and then switch to + * floating point math. + */ + res = my_atof(input); + snprintf(buf, sizeof (buf), "%lf", res); + return strdup(buf); +} + +static int +isdelim(char c) +{ + const char *delims = "{},;:"; + char *d; + + d = (char *)delims; + while (*d) + { + if (c == *d) return 1; + d++; + } + return 0; +} + +static char * +next_token(char *p, char *end, char **new_p, int *delim) +{ + char *tok_start = NULL, *tok_end = NULL, *tok = NULL, *sa_start = NULL; + int in_tok = 0; + int in_quote = 0; + int in_parens = 0; + int in_comment_ss = 0; + int in_comment_cpp = 0; + int in_comment_sa = 0; + int had_quote = 0; + int is_escaped = 0; + char *cpp_token_line = NULL; + char *cpp_token_file = NULL; + + *delim = 0; + if (p >= end) return NULL; + while (p < end) + { + if (*p == '\n') + { + in_comment_ss = 0; + in_comment_cpp = 0; + cpp_token_line = NULL; + cpp_token_file = NULL; + line++; + } + if ((!in_comment_ss) && (!in_comment_sa)) + { + if ((!in_quote) && (*p == '/') && (p < (end - 1)) && (*(p + 1) == '/')) + in_comment_ss = 1; + if ((!in_quote) && (*p == '#')) + in_comment_cpp = 1; + if ((!in_quote) && (*p == '/') && (p < (end - 1)) && (*(p + 1) == '*')) + { + in_comment_sa = 1; + sa_start = p; + } + } + if ((in_comment_cpp) && (*p == '#')) + { + char *pp, fl[4096]; + char *tmpstr = NULL; + int l, nm; + + /* handle cpp comments */ + /* their line format is + * #line [??] + */ + cpp_token_line = NULL; + cpp_token_file = NULL; + + pp = p; + while ((pp < end) && (*pp != '\n')) + { + pp++; + } + l = pp - p; + tmpstr = alloca(l + 1); + if (!tmpstr) + { + ERR("%s: Error. %s:%i malloc %i bytes failed", + progname, file_in, line - 1, l + 1); + exit(-1); + } + strncpy(tmpstr, p, l); + tmpstr[l] = 0; + l = sscanf(tmpstr, "%*s %i \"%[^\"]\"", &nm, fl); + if (l == 2) + { + strcpy(file_buf, fl); + line = nm; + file_in = file_buf; + } + } + else if ((!in_comment_ss) && (!in_comment_sa) && (!in_comment_cpp)) + { + if (!in_tok) + { + if (!in_quote) + { + if (!isspace(*p)) + { + if (*p == '"') + { + in_quote = 1; + had_quote = 1; + } + else if (*p == '(') + in_parens++; + + in_tok = 1; + tok_start = p; + if (isdelim(*p)) *delim = 1; + } + } + } + else + { + if (in_quote) + { + if ((*p) == '\\') + is_escaped = !is_escaped; + else if (((*p) == '"') && (!is_escaped)) + { + in_quote = 0; + had_quote = 1; + } + else if (is_escaped) + is_escaped = 0; + } + else if (in_parens) + { + if (((*p) == ')') && (!is_escaped)) + in_parens--; + } + else + { + if (*p == '"') + { + in_quote = 1; + had_quote = 1; + } + else if (*p == '(') + in_parens++; + + /* check for end-of-token */ + if ( + (isspace(*p)) || + ((*delim) && (!isdelim(*p))) || + (isdelim(*p)) + ) + {/*the line below this is never used because it skips to + * the 'done' label which is after the return call for + * in_tok being 0. is this intentional? + */ + in_tok = 0; + + tok_end = p - 1; + if (*p == '\n') line--; + goto done; + } + } + } + } + if (in_comment_sa) + { + if ((*p == '/') && (*(p - 1) == '*') && ((p - sa_start) > 2)) + in_comment_sa = 0; + } + p++; + } + if (!in_tok) return NULL; + tok_end = p - 1; + + done: + *new_p = p; + + tok = mem_alloc(tok_end - tok_start + 2); + strncpy(tok, tok_start, tok_end - tok_start + 1); + tok[tok_end - tok_start + 1] = 0; + + if (had_quote) + { + is_escaped = 0; + p = tok; + + while (*p) + { + if ((*p == '\"') && (!is_escaped)) + { + memmove(p, p + 1, strlen(p)); + } + else if ((*p == '\\') && (*(p + 1) == 'n')) + { + memmove(p, p + 1, strlen(p)); + *p = '\n'; + } + else if ((*p == '\\') && (*(p + 1) == 't')) + { + memmove(p, p + 1, strlen(p)); + *p = '\t'; + } + else if (*p == '\\') + { + memmove(p, p + 1, strlen(p)); + if (*p == '\\') p++; + else is_escaped = 1; + } + else + { + if (is_escaped) is_escaped = 0; + p++; + } + } + } + else if ((tok) && (*tok == '(')) + { + char *tmp; + tmp = tok; + tok = perform_math(tok); + free(tmp); + } + + return tok; +} + +static char * +stack_id(void) +{ + char *id; + int len; + Eina_List *l; + char *data; + + len = 0; + EINA_LIST_FOREACH(stack, l, data) + len += strlen(data) + 1; + id = mem_alloc(len); + id[0] = 0; + EINA_LIST_FOREACH(stack, l, data) + { + strcat(id, data); + if (eina_list_next(l)) strcat(id, "."); + } + return id; +} + +static void +stack_chop_top(void) +{ + char *top; + + /* remove top from stack */ + top = eina_list_data_get(eina_list_last(stack)); + if (top) + { + free(top); + stack = eina_list_remove(stack, top); + } + else + { + ERR("%s: Error. parse error %s:%i. } marker without matching { marker", + progname, file_in, line - 1); + err_show(); + exit(-1); + } +} + +static void +parse(char *data, off_t size) +{ + char *p, *end, *token; + int delim = 0; + int do_params = 0; + + if (verbose) + { + INF("%s: Parsing input file", + progname); + } + p = data; + end = data + size; + line = 1; + while ((token = next_token(p, end, &p, &delim))) + { + /* if we are in param mode, the only delimiter + * we'll accept is the semicolon + */ + if (do_params && delim && *token != ';') + { + ERR("%s: Error. parse error %s:%i. %c marker before ; marker", + progname, file_in, line - 1, *token); + err_show(); + exit(-1); + } + else if (delim) + { + if (*token == ',' || *token == ':') do_params = 1; + else if (*token == '}') + { + if (do_params) + { + ERR("%s: Error. parse error %s:%i. } marker before ; marker", + progname, file_in, line - 1); + err_show(); + exit(-1); + } + else + stack_chop_top(); + } + else if (*token == ';') + { + if (do_params) + { + do_params = 0; + new_statement(); + /* clear out params */ + while (params) + { + free(eina_list_data_get(params)); + params = eina_list_remove(params, eina_list_data_get(params)); + } + /* remove top from stack */ + stack_chop_top(); + } + } + else if (*token == '{') + { + if (do_params) + { + ERR("%s: Error. parse error %s:%i. { marker before ; marker", + progname, file_in, line - 1); + err_show(); + exit(-1); + } + } + free(token); + } + else + { + if (do_params) + params = eina_list_append(params, token); + else + { + stack = eina_list_append(stack, token); + new_object(); + if ((verbatim == 1) && (p < (end - 2))) + { + int escaped = 0; + int inquotes = 0; + int insquotes = 0; + int squigglie = 1; + int l1 = 0, l2 = 0; + char *verbatim_1; + char *verbatim_2; + + l1 = line; + while ((p[0] != '{') && (p < end)) + { + if (*p == '\n') line++; + p++; + } + p++; + verbatim_1 = p; + verbatim_2 = NULL; + for (; p < end; p++) + { + if (*p == '\n') line++; + if (escaped) escaped = 0; + if (!escaped) + { + if (p[0] == '\\') escaped = 1; + else if (p[0] == '\"') + { + if (!insquotes) + { + if (inquotes) inquotes = 0; + else inquotes = 1; + } + } + else if (p[0] == '\'') + { + if (!inquotes) + { + if (insquotes) insquotes = 0; + else insquotes = 1; + } + } + else if ((!inquotes) && (!insquotes)) + { + if (p[0] == '{') squigglie++; + else if (p[0] == '}') squigglie--; + if (squigglie == 0) + { + verbatim_2 = p - 1; + l2 = line; + break; + } + } + } + } + if (verbatim_2 > verbatim_1) + { + int l; + char *v; + + l = verbatim_2 - verbatim_1 + 1; + v = malloc(l + 1); + strncpy(v, verbatim_1, l); + v[l] = 0; + set_verbatim(v, l1, l2); + } + else + { + ERR("%s: Error. parse error %s:%i. { marker does not have matching } marker", + progname, file_in, line - 1); + err_show(); + exit(-1); + } + new_object(); + verbatim = 0; + } + } + } + } + if (verbose) + { + INF("%s: Parsing done", + progname); + } +} + +static char *clean_file = NULL; +static void +clean_tmp_file(void) +{ + if (clean_file) unlink(clean_file); +} + +int +is_verbatim(void) +{ + return verbatim; +} + +void +track_verbatim(int on) +{ + verbatim = on; +} + +void +set_verbatim(char *s, int l1, int l2) +{ + verbatim_line1 = l1; + verbatim_line2 = l2; + verbatim_str = s; +} + +char * +get_verbatim(void) +{ + return verbatim_str; +} + +int +get_verbatim_line1(void) +{ + return verbatim_line1; +} + +int +get_verbatim_line2(void) +{ + return verbatim_line2; +} + +void +compile(void) +{ + char buf[4096], buf2[4096]; + char inc[4096]; + static char tmpn[4096]; + int fd; + off_t size; + char *data, *p; + Eina_List *l; + Edje_Style *stl; + + if (!tmp_dir) +#ifdef HAVE_EVIL + tmp_dir = (char *)evil_tmpdir_get(); +#else + tmp_dir = "/tmp"; +#endif + + strncpy(inc, file_in, 4000); + inc[4001] = 0; + p = strrchr(inc, '/'); + if (!p) strcpy(inc, "./"); + else *p = 0; + snprintf(tmpn, PATH_MAX, "%s/edje_cc.edc-tmp-XXXXXX", tmp_dir); + fd = mkstemp(tmpn); + if (fd >= 0) + { + int ret; + char *def; + + clean_file = tmpn; + close(fd); + atexit(clean_tmp_file); + if (!defines) + def = mem_strdup(""); + else + { + int len; + char *define; + + len = 0; + EINA_LIST_FOREACH(defines, l, define) + len += strlen(define) + 1; + def = mem_alloc(len + 1); + def[0] = 0; + EINA_LIST_FOREACH(defines, l, define) + { + strcat(def, define); + strcat(def, " "); + } + } + + /* + * Run the input through the C pre-processor. + */ + ret = -1; + snprintf(buf2, sizeof(buf2), "%s/edje/utils/epp" EPP_EXT, + eina_prefix_lib_get(pfx)); + if (ecore_file_exists(buf2)) + { + snprintf(buf, sizeof(buf), "%s %s -I%s %s -o %s", + buf2, file_in, inc, def, tmpn); + ret = system(buf); + } + else + { + ERR("Error. Cannot run epp: %s", buf2); + exit(-1); + } + if (ret == EXIT_SUCCESS) + file_in = tmpn; + else + { + ERR("Error. Exit code of epp not clean: %i", ret); + exit(-1); + } + free(def); + } + fd = open(file_in, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); + if (fd < 0) + { + ERR("%s: Error. cannot open file \"%s\" for input. %s", + progname, file_in, strerror(errno)); + exit(-1); + } + if (verbose) + { + INF("%s: Opening \"%s\" for input", progname, file_in); + } + + size = lseek(fd, 0, SEEK_END); + lseek(fd, 0, SEEK_SET); + data = malloc(size); + if (data && (read(fd, data, size) == size)) + parse(data, size); + else + { + ERR("%s: Error. cannot read file \"%s\". %s", + progname, file_in, strerror(errno)); + exit(-1); + } + free(data); + close(fd); + + EINA_LIST_FOREACH(edje_file->styles, l, stl) + { + if (!stl->name) + { + ERR("%s: Error. style must have a name.", progname); + exit(-1); + } + } +} + +int +is_param(int n) +{ + char *str; + + str = eina_list_nth(params, n); + if (str) return 1; + return 0; +} + +int +is_num(int n) +{ + char *str; + char *end; + long int ret; + + str = eina_list_nth(params, n); + if (!str) + { + ERR("%s: Error. %s:%i no parameter supplied as argument %i", + progname, file_in, line - 1, n + 1); + err_show(); + exit(-1); + } + if (str[0] == 0) return 0; + end = str; + ret = strtol(str, &end, 0); + if ((ret == LONG_MIN) || (ret == LONG_MAX)) + { + n = 0; // do nothing. shut gcc warnings up + } + if ((end != str) && (end[0] == 0)) return 1; + return 0; +} + +char * +parse_str(int n) +{ + char *str; + char *s; + + str = eina_list_nth(params, n); + if (!str) + { + ERR("%s: Error. %s:%i no parameter supplied as argument %i", + progname, file_in, line - 1, n + 1); + err_show(); + exit(-1); + } + s = mem_strdup(str); + return s; +} + +static int +_parse_enum(char *str, va_list va) +{ + va_list va2; + va_copy(va2, va); /* iterator for the error message */ + + for (;;) + { + char *s; + int v; + + s = va_arg(va, char *); + + /* End of the list, nothing matched. */ + if (!s) + { + fprintf(stderr, "%s: Error. %s:%i token %s not one of:", + progname, file_in, line - 1, str); + s = va_arg(va2, char *); + while (s) + { + va_arg(va2, int); + fprintf(stderr, " %s", s); + s = va_arg(va2, char *); + if (!s) break; + } + fprintf(stderr, "\n"); + va_end(va2); + va_end(va); + err_show(); + exit(-1); + } + + v = va_arg(va, int); + if (!strcmp(s, str)) + { + va_end(va2); + va_end(va); + return v; + } + } + va_end(va2); + va_end(va); + return 0; +} + +int +parse_enum(int n, ...) +{ + char *str; + int result; + va_list va; + + str = eina_list_nth(params, n); + if (!str) + { + ERR("%s: Error. %s:%i no parameter supplied as argument %i", + progname, file_in, line - 1, n + 1); + err_show(); + exit(-1); + } + + va_start(va, n); + result = _parse_enum(str, va); + va_end(va); + + return result; +} + +int +parse_flags(int n, ...) +{ + Eina_List *lst; + int result = 0; + va_list va; + char *data; + + va_start(va, n); + EINA_LIST_FOREACH(eina_list_nth_list(params, n), lst, data) + result |= _parse_enum(data, va); + va_end(va); + + return result; +} + +int +parse_int(int n) +{ + char *str; + int i; + + str = eina_list_nth(params, n); + if (!str) + { + ERR("%s: Error. %s:%i no parameter supplied as argument %i", + progname, file_in, line - 1, n + 1); + err_show(); + exit(-1); + } + i = my_atoi(str); + return i; +} + +int +parse_int_range(int n, int f, int t) +{ + char *str; + int i; + + str = eina_list_nth(params, n); + if (!str) + { + ERR("%s: Error. %s:%i no parameter supplied as argument %i", + progname, file_in, line - 1, n + 1); + err_show(); + exit(-1); + } + i = my_atoi(str); + if ((i < f) || (i > t)) + { + ERR("%s: Error. %s:%i integer %i out of range of %i to %i inclusive", + progname, file_in, line - 1, i, f, t); + err_show(); + exit(-1); + } + return i; +} + +int +parse_bool(int n) +{ + char *str, buf[4096]; + int i; + + str = eina_list_nth(params, n); + if (!str) + { + ERR("%s: Error. %s:%i no parameter supplied as argument %i", + progname, file_in, line - 1, n + 1); + err_show(); + exit(-1); + } + + if (!strstrip(str, buf, sizeof (buf))) + { + ERR("%s: Error. %s:%i expression is too long", + progname, file_in, line - 1); + return 0; + } + + if (!strcasecmp(buf, "false") || !strcasecmp(buf, "off")) + return 0; + if (!strcasecmp(buf, "true") || !strcasecmp(buf, "on")) + return 1; + + i = my_atoi(str); + if ((i < 0) || (i > 1)) + { + ERR("%s: Error. %s:%i integer %i out of range of 0 to 1 inclusive", + progname, file_in, line - 1, i); + err_show(); + exit(-1); + } + return i; +} + +double +parse_float(int n) +{ + char *str; + double i; + + str = eina_list_nth(params, n); + if (!str) + { + ERR("%s: Error. %s:%i no parameter supplied as argument %i", + progname, file_in, line - 1, n + 1); + err_show(); + exit(-1); + } + i = my_atof(str); + return i; +} + +double +parse_float_range(int n, double f, double t) +{ + char *str; + double i; + + str = eina_list_nth(params, n); + if (!str) + { + ERR("%s: Error. %s:%i no parameter supplied as argument %i", + progname, file_in, line - 1, n + 1); + err_show(); + exit(-1); + } + i = my_atof(str); + if ((i < f) || (i > t)) + { + ERR("%s: Error. %s:%i float %3.3f out of range of %3.3f to %3.3f inclusive", + progname, file_in, line - 1, i, f, t); + err_show(); + exit(-1); + } + return i; +} + +int +get_arg_count(void) +{ + return eina_list_count (params); +} + +void +check_arg_count(int required_args) +{ + int num_args = eina_list_count (params); + + if (num_args != required_args) + { + ERR("%s: Error. %s:%i got %i arguments, but expected %i", + progname, file_in, line - 1, num_args, required_args); + err_show(); + exit(-1); + } +} + +void +check_min_arg_count(int min_required_args) +{ + int num_args = eina_list_count (params); + + if (num_args < min_required_args) + { + ERR("%s: Error. %s:%i got %i arguments, " + "but expected at least %i", + progname, file_in, line - 1, num_args, min_required_args); + err_show(); + exit(-1); + } +} + +/* simple expression parsing stuff */ + +/* + * alpha ::= beta + beta || beta + * beta ::= gamma + gamma || gamma + * gamma ::= num || delta + * delta ::= '(' alpha ')' + * + */ + +/* int set of function */ + +static int +my_atoi(const char *s) +{ + int res = 0; + char buf[4096]; + + if (!s) return 0; + if (!strstrip(s, buf, sizeof(buf))) + { + ERR("%s: Error. %s:%i expression is too long\n", + progname, file_in, line - 1); + return 0; + } + _alphai(buf, &res); + return res; +} + +static char * +_deltai(char *s, int *val) +{ + if (!val) return NULL; + if ('(' != s[0]) + { + ERR("%s: Error. %s:%i unexpected character at %s\n", + progname, file_in, line - 1, s); + return s; + } + else + { + s++; + s = _alphai(s, val); + s++; + return s; + } + return s; +} + +static char * +_funci(char *s, int *val) +{ + if (!strncmp(s, "floor(", 6)) + { + s += 5; + s = _deltai(s, val); + *val = *val; + } + else if (!strncmp(s, "ceil(", 5)) + { + s += 4; + s = _deltai(s, val); + *val = *val; + } + else + { + ERR("%s: Error. %s:%i unexpected character at %s\n", + progname, file_in, line - 1, s); + } + return s; +} + +static char * +_gammai(char *s, int *val) +{ + if (!val) return NULL; + if (_is_numi(s[0])) + { + s = _get_numi(s, val); + return s; + } + else if ('(' == s[0]) + { + s = _deltai(s, val); + return s; + } + else + { + s = _funci(s, val); +// ERR("%s: Error. %s:%i unexpected character at %s\n", +// progname, file_in, line - 1, s); + } + return s; +} + +static char * +_betai(char *s, int *val) +{ + int a1, a2; + char op; + + if (!val) return NULL; + s = _gammai(s, &a1); + while (_is_op1i(s[0])) + { + op = s[0]; + s++; + s = _gammai(s, &a2); + a1 = _calci(op, a1, a2); + } + (*val) = a1; + return s; +} + +static char * +_alphai(char *s, int *val) +{ + int a1, a2; + char op; + + if (!val) return NULL; + s = _betai(s, &a1); + while (_is_op2i(s[0])) + { + op = s[0]; + s++; + s = _betai(s, &a2); + a1 = _calci(op, a1, a2); + } + (*val) = a1; + return s; +} + +char * +_get_numi(char *s, int *val) +{ + char buf[4096]; + int pos = 0; + + if (!val) return s; + while ((('0' <= s[pos]) && ('9' >= s[pos])) || + ((0 == pos) && ('-' == s[pos]))) + { + buf[pos] = s[pos]; + pos++; + } + buf[pos] = '\0'; + (*val) = atoi(buf); + return (s + pos); +} + +int +_is_numi(char c) +{ + if (((c >= '0') && (c <= '9')) || ('-' == c) || ('+' == c)) + return 1; + else + return 0; +} + +int +_is_op1i(char c) +{ + switch (c) + { + case '*':; + case '%':; + case '/': return 1; + default: break; + } + return 0; +} + +int +_is_op2i(char c) +{ + switch (c) + { + case '+':; + case '-': return 1; + default: break; + } + return 0; +} + +int +_calci(char op, int a, int b) +{ + switch(op) + { + case '+': + a += b; + return a; + case '-': + a -= b; + return a; + case '/': + if (0 != b) a /= b; + else + ERR("%s: Error. %s:%i divide by zero\n", + progname, file_in, line - 1); + return a; + case '*': + a *= b; + return a; + case '%': + if (0 != b) a = a % b; + else + ERR("%s: Error. %s:%i modula by zero\n", + progname, file_in, line - 1); + return a; + default: + ERR("%s: Error. %s:%i unexpected character '%c'\n", + progname, file_in, line - 1, op); + } + return a; +} + +/* float set of functoins */ + +double +my_atof(const char *s) +{ + double res = 0; + char buf[4096]; + + if (!s) return 0; + + if (!strstrip(s, buf, sizeof (buf))) + { + ERR("%s: Error. %s:%i expression is too long", + progname, file_in, line - 1); + return 0; + } + _alphaf(buf, &res); + return res; +} + +static char * +_deltaf(char *s, double *val) +{ + if (!val) return NULL; + if ('(' != s[0]) + { + ERR("%s: Error. %s:%i unexpected character at %s", + progname, file_in, line - 1, s); + return s; + } + else + { + s++; + s = _alphaf(s, val); + s++; + } + return s; +} + +static char * +_funcf(char *s, double *val) +{ + if (!strncmp(s, "floor(", 6)) + { + s += 5; + s = _deltaf(s, val); + *val = floor(*val); + } + else if (!strncmp(s, "ceil(", 5)) + { + s += 4; + s = _deltaf(s, val); + *val = ceil(*val); + } + else + { + ERR("%s: Error. %s:%i unexpected character at %s\n", + progname, file_in, line - 1, s); + } + return s; +} + +static char * +_gammaf(char *s, double *val) +{ + if (!val) return NULL; + + if (_is_numf(s[0])) + { + s = _get_numf(s, val); + return s; + } + else if ('(' == s[0]) + { + s = _deltaf(s, val); + return s; + } + else + { + s = _funcf(s, val); +// ERR("%s: Error. %s:%i unexpected character at %s\n", +// progname, file_in, line - 1, s); + } + return s; +} + +static char * +_betaf(char *s, double *val) +{ + double a1=0, a2=0; + char op; + + if (!val) return NULL; + s = _gammaf(s, &a1); + while (_is_op1f(s[0])) + { + op = s[0]; + s++; + s = _gammaf(s, &a2); + a1 = _calcf(op, a1, a2); + } + (*val) = a1; + return s; +} + +static char * +_alphaf(char *s, double *val) +{ + double a1=0, a2=0; + char op; + + if (!val) return NULL; + s = _betaf(s, &a1); + while (_is_op2f(s[0])) + { + op = s[0]; + s++; + s = _betaf(s, &a2); + a1 = _calcf(op, a1, a2); + } + (*val) = a1; + return s; +} + +static char * +_get_numf(char *s, double *val) +{ + char buf[4096]; + int pos = 0; + + if (!val) return s; + + while ((('0' <= s[pos]) && ('9' >= s[pos])) || + ('.' == s[pos]) || + ((0 == pos) && ('-' == s[pos]))) + { + buf[pos] = s[pos]; + pos++; + } + buf[pos] = '\0'; + (*val) = atof(buf); + return (s+pos); +} + +static int +_is_numf(char c) +{ + if (((c >= '0') && (c <= '9')) + || ('-' == c) + || ('.' == c) + || ('+' == c)) + return 1; + return 0; +} + +static int +_is_op1f(char c) +{ + switch(c) + { + case '*':; + case '%':; + case '/': return 1; + default: break; + } + return 0; +} + +static int +_is_op2f(char c) +{ + switch(c) + { + case '+':; + case '-': return 1; + default: break; + } + return 0; +} + +static double +_calcf(char op, double a, double b) +{ + switch(op) + { + case '+': + a += b; + return a; + case '-': + a -= b; + return a; + case '/': + if (b != 0) a /= b; + else + ERR("%s: Error. %s:%i divide by zero\n", + progname, file_in, line - 1); + return a; + case '*': + a *= b; + return a; + case '%': + if (0 != b) a = (double)((int)a % (int)b); + else + ERR("%s: Error. %s:%i modula by zero\n", + progname, file_in, line - 1); + return a; + default: + ERR("%s: Error. %s:%i unexpected character '%c'\n", + progname, file_in, line - 1, op); + } + return a; +} + +static int +strstrip(const char *in, char *out, size_t size) +{ + if ((size -1 ) < strlen(in)) + { + ERR("%s: Error. %s:%i expression is too long", + progname, file_in, line - 1); + return 0; + } + /* remove spaces and tabs */ + while (*in) + { + if ((0x20 != *in) && (0x09 != *in)) + { + *out = *in; + out++; + } + in++; + } + *out = '\0'; + return 1; +} 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 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +#include "edje_cc.h" + +static Eet_Data_Descriptor *_srcfile_edd = NULL; +static Eet_Data_Descriptor *_srcfile_list_edd = NULL; + +static Eet_Data_Descriptor *_external_edd = NULL; +static Eet_Data_Descriptor *_external_list_edd = NULL; + +static Eet_Data_Descriptor *_font_edd = NULL; +static Eet_Data_Descriptor *_font_list_edd = NULL; + +static SrcFile_List srcfiles = {NULL}; + +void +source_edd(void) +{ + Eet_Data_Descriptor_Class eddc; + + eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "srcfile", sizeof (SrcFile)); + _srcfile_edd = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "name", name, EET_T_INLINED_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "file", file, EET_T_INLINED_STRING); + + eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "srcfile_list", sizeof (SrcFile_List)); + _srcfile_list_edd = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(_srcfile_list_edd, SrcFile_List, "list", list, _srcfile_edd); + + eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "external", sizeof (External)); + _external_edd = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_external_edd, External, "name", name, EET_T_INLINED_STRING); + + eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "external_list", sizeof (External_List)); + _external_list_edd = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(_external_list_edd, External_List, "list", list, _external_edd); + + eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "font", sizeof (Font)); + _font_edd = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_font_edd, Font, "file", file, EET_T_INLINED_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_font_edd, Font, "name", name, EET_T_INLINED_STRING); + + eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "font_list", sizeof (Font_List)); + _font_list_edd = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(_font_list_edd, Font_List, "list", list, _font_edd); +} + +static void source_fetch_file(const char *fil, const char *filname); + +static void +source_fetch_file(const char *fil, const char *filname) +{ + FILE *f; + char buf[16 * 1024], *dir = NULL; + long sz; + size_t tmp; + ssize_t dir_len = 0; + SrcFile *sf; + + f = fopen(fil, "rb"); + if (!f) + { + ERR("%s: Warning. Cannot open file '%s'", + progname, fil); + exit(-1); + } + + fseek(f, 0, SEEK_END); + sz = ftell(f); + fseek(f, 0, SEEK_SET); + sf = mem_alloc(SZ(SrcFile)); + sf->name = mem_strdup(filname); + sf->file = mem_alloc(sz + 1); + if (sz > 0) + { + tmp = fread(sf->file, sz, 1, f); + if (tmp != 1) + { + ERR("%s: Warning file length for (%s) doesn't match !", + progname, filname); + exit(-1); + } + } + + sf->file[sz] = '\0'; + fseek(f, 0, SEEK_SET); + srcfiles.list = eina_list_append(srcfiles.list, sf); + + while (fgets(buf, sizeof(buf), f)) + { + char *p, *pp; + int got_hash = 0; + int forgetit = 0; + int haveinclude = 0; + char *file = NULL, *fname = NULL; + + p = buf; + while ((!forgetit) && (*p)) + { + if (!got_hash) + { + if (!isspace(*p)) + { + if (*p == '#') + got_hash = 1; + else + forgetit = 1; + } + p++; + } + + if (!haveinclude) + { + if (!isspace(*p)) + { + if (!strncmp(p, "include", 7)) + { + haveinclude = 1; + p += 7; + } + /* HACK! the logic above should be fixed so + * preprocessor statements don't have to begin + * in column 0. + * otoh, edje_cc should print a warning in that case, + * since according to the standard, preprocessor + * statements need to be put in column 0. + */ + else if (!strncmp(p, "#include", 8)) + { + haveinclude = 1; + p += 8; + } + else + forgetit = 1; + } + } + else + { + if (!isspace(*p)) + { + char end = '\0'; + + if (*p == '"') end = '"'; + else if (*p == '<') end = '>'; + + if (end) + { + pp = strchr(p + 1, end); + if (!pp) + forgetit = 1; + else + { + char *slash; + ssize_t l = 0; + + /* get the directory of the current file + * if we haven't already done so + */ + if ((!dir) && (strrchr(fil, '/'))) + { + dir = mem_strdup(fil); + slash = strrchr(dir, '/'); + *slash = '\0'; + dir_len = strlen(dir); + } + + l = pp - p + dir_len + 1; + file = mem_alloc(l); + + if (!dir_len) + { + snprintf(file, l - 1, "%s", p + 1); + file[l - 2] = 0; + } + else + { + snprintf(file, l, "%s/%s", dir, p + 1); + file[l - 1] = 0; + } + + + fname = strdup(p + 1); + pp = strrchr(fname, end); + if (pp) *pp = 0; + forgetit = 1; + } + } + else + forgetit = 1; + } + else + p++; + } + + got_hash = 0; + } + if ((file) && (fname)) + { + source_fetch_file(file, fname); + free(file); + free(fname); + } + } + free(dir); + fclose(f); +} + +void +source_fetch(void) +{ + char buf[PATH_MAX] = {0}, *ptr; + + ptr = strrchr(file_in, '/'); + if (ptr) + { + snprintf(buf, sizeof (buf), "%s", ptr + 1); + } + + source_fetch_file(file_in, buf[0] ? buf : file_in); +} + +int +source_append(Eet_File *ef) +{ + return eet_data_write(ef, _srcfile_list_edd, "edje_sources", &srcfiles, 1); +} + +SrcFile_List * +source_load(Eet_File *ef) +{ + SrcFile_List *s; + + s = eet_data_read(ef, _srcfile_list_edd, "edje_sources"); + return s; +} + +int +source_fontmap_save(Eet_File *ef, Eina_List *font_list) +{ + Font_List fl; + + fl.list = font_list; + return eet_data_write(ef, _font_list_edd, "edje_source_fontmap", &fl, 1); +} + +Font_List * +source_fontmap_load(Eet_File *ef) +{ + Font_List *fl; + + fl = eet_data_read(ef, _font_list_edd, "edje_source_fontmap"); + return fl; +} 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 @@ +#include "edje_private.h" + +#include "edje_cc.h" +#include "edje_convert.h" + +static const Edje_File *_current_edje_file = NULL; + +const Edje_File * +_edje_file_get(void) +{ + return _current_edje_file; +} + +void +_edje_file_set(const Edje_File *edf) +{ + _current_edje_file = edf; +} + +static Eina_Bool +_edje_file_convert_external(Edje_File *edf, Old_Edje_File *oedf) +{ + Edje_External_Directory_Entry *ede; + unsigned int max; + unsigned int i = 0; + + edf->external_dir = calloc(1, sizeof (Edje_External_Directory)); + if (!edf->external_dir) return EINA_FALSE; + if (!oedf->external_dir) return EINA_TRUE; + + max = eina_list_count(oedf->external_dir->entries); + edf->external_dir->entries = calloc(1, sizeof (Edje_External_Directory_Entry) * max); + edf->external_dir->entries_count = max; + + if (!edf->external_dir->entries && max) + return EINA_FALSE; + + EINA_LIST_FREE(oedf->external_dir->entries, ede) + { + edf->external_dir->entries[i++].entry = ede->entry; + free(ede); + } + + free(oedf->external_dir); + oedf->external_dir = NULL; + + return EINA_TRUE; +} + +static Eina_Bool +_edje_file_convert_images(Edje_File *edf, Old_Edje_File *oedf) +{ + Edje_Image_Directory_Entry *de; + Edje_Image_Directory_Set *ds; + Eina_List *l; + int max; + + edf->image_dir = calloc(1, sizeof (Edje_Image_Directory)); + if (!edf->image_dir) return EINA_FALSE; + if (!oedf->image_dir) return EINA_TRUE; + + max = -1; + EINA_LIST_FOREACH(oedf->image_dir->entries, l, de) + if (max < de->id) + max = de->id; + + edf->image_dir->entries = calloc(1, sizeof (Edje_Image_Directory_Entry) * (max + 1)); + edf->image_dir->entries_count = max + 1; + + if (!edf->image_dir->entries && edf->image_dir->entries_count) + return EINA_FALSE; + + EINA_LIST_FREE(oedf->image_dir->entries, de) + { + memcpy(edf->image_dir->entries + de->id, + de, + sizeof (Edje_Image_Directory_Entry)); + free(de); + } + + max = -1; + EINA_LIST_FOREACH(oedf->image_dir->sets, l, ds) + if (max < ds->id) + max = ds->id; + + edf->image_dir->sets = calloc(1, sizeof (Edje_Image_Directory_Set) * (max + 1)); + edf->image_dir->sets_count = max + 1; + + if (!edf->image_dir->sets && edf->image_dir->sets_count) + { + free(edf->image_dir->entries); + edf->image_dir->entries = NULL; + return EINA_FALSE; + } + + EINA_LIST_FREE(oedf->image_dir->sets, ds) + { + memcpy(edf->image_dir->sets + ds->id, + ds, + sizeof (Edje_Image_Directory_Set)); + free(ds); + } + + return EINA_TRUE; +} + +Edje_File * +_edje_file_convert(Eet_File *ef, Old_Edje_File *oedf) +{ + Edje_Part_Collection_Directory_Entry *ce; + Edje_Font_Directory_Entry *fnt; + Edje_File *edf; + Eina_List *l; + Old_Edje_Data *ed; + + if (oedf->version < 2) return NULL; + + edf = calloc(1, sizeof (Edje_File)); + if (!edf) return NULL; + + edf->free_strings = 0; + + edf->fonts = eina_hash_string_small_new(free); + edf->collection = eina_hash_string_small_new(free); + edf->data = eina_hash_string_small_new(free); + + if (!edf->fonts || !edf->collection || !edf->data) + goto on_error; + + EINA_LIST_FREE(oedf->data, ed) + { + Edje_String *es; + + es = calloc(1, sizeof (Edje_String)); + if (!es) continue; + + es->str = ed->value; + + eina_hash_direct_add(edf->data, ed->key, es); + free(ed); + } + + EINA_LIST_FOREACH(oedf->collection_dir->entries, l, ce) + if (ce->entry) + eina_hash_direct_add(edf->collection, ce->entry, ce); + else + error_and_abort(ef, "Collection %i: name missing.\n", ce->id); + + if (oedf->font_dir) + EINA_LIST_FOREACH(oedf->font_dir->entries, l, fnt) + eina_hash_direct_add(edf->fonts, fnt->entry, fnt); + + if (!_edje_file_convert_images(edf, oedf)) + goto on_error; + + if (!_edje_file_convert_external(edf, oedf)) + goto on_error; + + edf->styles = oedf->styles; + edf->color_classes = oedf->color_classes; + edf->version = EDJE_FILE_VERSION; + edf->feature_ver = oedf->feature_ver; + edf->compiler = oedf->compiler; + + edf->dangling = EINA_FALSE; + edf->warning = EINA_FALSE; + + /* Below you will find all memory structure that could be cleaned when under + memory pressure */ + edf->collection_cache = NULL; + edf->collection_patterns = NULL; + + return edf; + + on_error: + eina_hash_free(edf->fonts); + eina_hash_free(edf->collection); + eina_hash_free(edf->data); + free(edf->image_dir); + free(edf->external_dir); + free(edf); + return NULL; +} + +static void +_edje_collection_program_add(Edje_Program ***array, + unsigned int *count, + Edje_Program *add) +{ + Edje_Program **tmp; + + tmp = realloc(*array, sizeof (Edje_Program*) * (*count + 1)); + if (!tmp) return ; + + tmp[(*count)++] = add; + *array = tmp; +} + +Edje_Part_Collection * +_edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, Old_Edje_Part_Collection *oedc) +{ + Edje_Part_Collection *edc; + Old_Edje_Part *part; + Edje_Program *pg; + Old_Edje_Data *di; + Eina_List *l; + char *buffer; + unsigned int k; + + oedc->part = ce->entry; + + /* Count each type part and their respective state */ + EINA_LIST_FOREACH(oedc->parts, l, part) + { + int *count; + int dummy = 0; + + + switch (part->type) + { +#define CSP(Tp, Ce) \ + case EDJE_PART_TYPE_##Tp : \ + count = &Ce->count.Tp; \ + break; + + CSP(RECTANGLE, ce); + CSP(TEXT, ce); + CSP(IMAGE, ce); + CSP(SWALLOW, ce); + CSP(TEXTBLOCK, ce); + CSP(GROUP, ce); + CSP(BOX, ce); + CSP(TABLE, ce); + CSP(EXTERNAL, ce); + default: + count = &dummy; + break; + } + + *count += eina_list_count(part->other_desc) + 1; + } + ce->count.part = eina_list_count(oedc->parts); + +#define CONVERT_EMN(Tp, Sz, Ce) \ + buffer = alloca(strlen(ce->entry) + strlen(#Tp) + 2); \ + sprintf(buffer, "%s/%s", ce->entry, #Tp); \ + Ce->mp.Tp = eina_mempool_add("one_big", buffer, NULL, sizeof (Sz), Ce->count.Tp); + + CONVERT_EMN(RECTANGLE, Edje_Part_Description_Common, ce); + CONVERT_EMN(TEXT, Edje_Part_Description_Text, ce); + CONVERT_EMN(IMAGE, Edje_Part_Description_Image, ce); + CONVERT_EMN(SWALLOW, Edje_Part_Description_Common, ce); + CONVERT_EMN(TEXTBLOCK, Edje_Part_Description_Text, ce); + CONVERT_EMN(GROUP, Edje_Part_Description_Common, ce); + CONVERT_EMN(BOX, Edje_Part_Description_Box, ce); + CONVERT_EMN(TABLE, Edje_Part_Description_Table, ce); + CONVERT_EMN(EXTERNAL, Edje_Part_Description_External, ce); + CONVERT_EMN(part, Edje_Part, ce); + + /* Change structure layout */ + edc = calloc(1, sizeof (Edje_Part_Collection)); + if (!edc) error_and_abort(ef, "Not enough memory\n"); + ce->ref = edc; + + EINA_LIST_FREE(oedc->programs, pg) + { + if (!pg->signal && !pg->source) + _edje_collection_program_add(&edc->programs.nocmp, + &edc->programs.nocmp_count, + pg); + else if (pg->signal && !strpbrk(pg->signal, "*?[\\") + && pg->source && !strpbrk(pg->source, "*?[\\")) + _edje_collection_program_add(&edc->programs.strcmp, + &edc->programs.strcmp_count, + pg); + else if (pg->signal && edje_program_is_strncmp(pg->signal) + && pg->source && edje_program_is_strncmp(pg->source)) + _edje_collection_program_add(&edc->programs.strncmp, + &edc->programs.strncmp_count, + pg); + else if (pg->signal && edje_program_is_strrncmp(pg->signal) + && pg->source && edje_program_is_strrncmp(pg->source)) + _edje_collection_program_add(&edc->programs.strrncmp, + &edc->programs.strrncmp_count, + pg); + else + _edje_collection_program_add(&edc->programs.fnmatch, + &edc->programs.fnmatch_count, + pg); + } + + edc->data = eina_hash_string_small_new(NULL); + EINA_LIST_FREE(oedc->data, di) + { + Edje_String *es; + + es = calloc(1, sizeof (Edje_String)); + if (!es) continue ; + + es->str = di->value; + + eina_hash_direct_add(edc->data, di->key, es); + free(di); + } + + edc->parts_count = eina_list_count(oedc->parts); + edc->parts = calloc(edc->parts_count, sizeof (Edje_Part *)); + if (edc->parts_count && !edc->parts) + error_and_abort(ef, "Not enough memory\n"); + k = 0; + + EINA_LIST_FREE(oedc->parts, part) + { + Old_Edje_Part_Description *oepd; + Edje_Pack_Element *elm; + Edje_Part *replacement; + unsigned int i; + + replacement = eina_mempool_malloc(ce->mp.part, sizeof (Edje_Part)); + if (!replacement) + error_and_abort(ef, "Not enough memory\n"); + + replacement->name = part->name; + replacement->default_desc = _edje_description_convert(part->type, ce, part->default_desc); + + replacement->other.desc_count = eina_list_count(part->other_desc); + replacement->other.desc = calloc(replacement->other.desc_count, sizeof (Edje_Part_Description_Common*)); + + i = 0; + EINA_LIST_FREE(part->other_desc, oepd) + replacement->other.desc[i++] = _edje_description_convert(part->type, ce, oepd); + + replacement->source = part->source; + replacement->source2 = part->source2; + replacement->source3 = part->source3; + replacement->source4 = part->source4; + replacement->source5 = part->source5; + replacement->source6 = part->source6; + replacement->id = part->id; + replacement->clip_to_id = part->clip_to_id; + replacement->dragable = part->dragable; + replacement->items_count = eina_list_count(part->items); + replacement->items = calloc(replacement->items_count, sizeof (Edje_Pack_Element*)); + + i = 0; + EINA_LIST_FREE(part->items, elm) + replacement->items[i++] = elm; + + replacement->type = part->type; + replacement->effect = part->effect; + replacement->mouse_events = part->mouse_events; + replacement->repeat_events = part->repeat_events; + replacement->ignore_flags = part->ignore_flags; + replacement->scale = part->scale; + replacement->precise_is_inside = part->precise_is_inside; + replacement->use_alternate_font_metrics = part->use_alternate_font_metrics; + replacement->pointer_mode = part->pointer_mode; + replacement->entry_mode = part->entry_mode; + replacement->select_mode = part->select_mode; + replacement->multiline = part->multiline; + replacement->api = part->api; + + edc->parts[k++] = replacement; + + free(part); + } + + edc->id = oedc->id; + edc->alias = oedc->alias; + edc->prop.min = oedc->prop.min; + edc->prop.max = oedc->prop.max; + edc->script = oedc->script; + edc->part = oedc->part; + edc->script_only = oedc->script_only; + edc->lua_script_only = oedc->lua_script_only; + edc->checked = oedc->checked; + + free(oedc); + + return edc; +} + +Edje_Part_Description_Common* +_edje_description_convert(int type, + Edje_Part_Collection_Directory_Entry *ce, + Old_Edje_Part_Description *oed) +{ + Edje_Part_Description_Common *result = NULL; + + switch (type) + { + case EDJE_PART_TYPE_RECTANGLE: + result = eina_mempool_malloc(ce->mp.RECTANGLE, + sizeof (Edje_Part_Description_Common)); + break; + case EDJE_PART_TYPE_SWALLOW: + result = eina_mempool_malloc(ce->mp.SWALLOW, + sizeof (Edje_Part_Description_Common)); + break; + case EDJE_PART_TYPE_GROUP: + result = eina_mempool_malloc(ce->mp.GROUP, + sizeof (Edje_Part_Description_Common)); + break; + + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *img; + Edje_Part_Image_Id *id; + unsigned int i = 0; + + img = eina_mempool_malloc(ce->mp.IMAGE, sizeof (Edje_Part_Description_Image)); + + img->image.tweens_count = eina_list_count(oed->image.tween_list); + img->image.tweens = calloc(img->image.tweens_count, + sizeof (Edje_Part_Image_Id*)); + if (img->image.tweens_count > 0 && !img->image.tweens) + { + eina_mempool_free(ce->mp.IMAGE, img); + return NULL; + } + + EINA_LIST_FREE(oed->image.tween_list, id) + img->image.tweens[i++] = id; + + img->image.id = oed->image.id; + img->image.scale_hint = oed->image.scale_hint; + img->image.set = oed->image.set; + + img->image.border = oed->image.border; + img->image.fill = oed->image.fill; + + result = &img->common; + break; + } + +#define CONVERT_ALLOC_POOL(Short, Type, Name) \ + case EDJE_PART_TYPE_##Short: \ + { \ + Edje_Part_Description_##Type *Name; \ + \ + Name = eina_mempool_malloc(ce->mp.Short, sizeof (Edje_Part_Description_##Type)); \ + Name->Name = oed->Name; \ + result = &Name->common; \ + break; \ + } + + CONVERT_ALLOC_POOL(TEXT, Text, text); + CONVERT_ALLOC_POOL(TEXTBLOCK, Text, text); + CONVERT_ALLOC_POOL(BOX, Box, box); + CONVERT_ALLOC_POOL(TABLE, Table, table); + CONVERT_ALLOC_POOL(EXTERNAL, External, external_params); + } + + if (result) + *result = oed->common; + + free(oed); + return result; +} 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 @@ +#ifndef EDJE_CONVERT_H__ +# define EDJE_CONVERT_H__ + + +typedef struct _Old_Edje_File Old_Edje_File; +typedef struct _Old_Edje_Image_Directory Old_Edje_Image_Directory; +typedef struct _Old_Edje_Font_Directory Old_Edje_Font_Directory; +typedef struct _Old_Edje_External_Directory Old_Edje_External_Directory; +typedef struct _Old_Edje_Part Old_Edje_Part; +typedef struct _Old_Edje_Part_Collection Old_Edje_Part_Collection; +typedef struct _Old_Edje_Part_Collection_Directory Old_Edje_Part_Collection_Directory; +typedef struct _Old_Edje_Part_Description Old_Edje_Part_Description; +typedef struct _Old_Edje_Part_Description_Spec_Image Old_Edje_Part_Description_Spec_Image; +typedef struct _Old_Edje_Data Old_Edje_Data; + +struct _Old_Edje_Data +{ + const char *key; + char *value; +}; + +/*----------*/ + +struct _Old_Edje_Font_Directory +{ + Eina_List *entries; /* a list of Edje_Font_Directory_Entry */ +}; + +struct _Old_Edje_Image_Directory +{ + Eina_List *entries; /* a list of Edje_Image_Directory_Entry */ + Eina_List *sets; /* a list of Edje_Image_Directory_Set */ +}; + +struct _Old_Edje_External_Directory +{ + Eina_List *entries; /* a list of Edje_External_Directory_Entry */ +}; + +struct _Old_Edje_File +{ + const char *path; + time_t mtime; + + Old_Edje_External_Directory *external_dir; + Old_Edje_Font_Directory *font_dir; + Old_Edje_Image_Directory *image_dir; + Old_Edje_Part_Collection_Directory *collection_dir; + Eina_List *data; + Eina_List *styles; + Eina_List *color_classes; + + const char *compiler; + int version; + int feature_ver; +}; + +struct _Old_Edje_Part_Collection +{ + Eina_List *programs; /* a list of Edje_Program */ + Eina_List *parts; /* a list of Edje_Part */ + Eina_List *data; + + int id; /* the collection id */ + + Eina_Hash *alias; /* aliasing part*/ + + struct { + Edje_Size min, max; + } prop; + + int references; +#ifdef EDJE_PROGRAM_CACHE + struct { + Eina_Hash *no_matches; + Eina_Hash *matches; + } prog_cache; +#endif + + Embryo_Program *script; /* all the embryo script code for this group */ + const char *part; + + unsigned char script_only; + + unsigned char lua_script_only; + + unsigned char checked : 1; +}; + +struct _Old_Edje_Part +{ + const char *name; /* the name if any of the part */ + Old_Edje_Part_Description *default_desc; /* the part descriptor for default */ + Eina_List *other_desc; /* other possible descriptors */ + const char *source, *source2, *source3, *source4, *source5, *source6; + int id; /* its id number */ + int clip_to_id; /* the part id to clip this one to */ + Edje_Part_Dragable dragable; + Eina_List *items; /* packed items for box and table */ + unsigned char type; /* what type (image, rect, text) */ + unsigned char effect; /* 0 = plain... */ + unsigned char mouse_events; /* it will affect/respond to mouse events */ + unsigned char repeat_events; /* it will repeat events to objects below */ + Evas_Event_Flags ignore_flags; + unsigned char scale; /* should certain properties scale with edje scale factor? */ + unsigned char precise_is_inside; + unsigned char use_alternate_font_metrics; + unsigned char pointer_mode; + unsigned char entry_mode; + unsigned char select_mode; + unsigned char multiline; + Edje_Part_Api api; +}; + +struct _Old_Edje_Part_Description_Spec_Image +{ + Eina_List *tween_list; /* list of Edje_Part_Image_Id */ + int id; /* the image id to use */ + int scale_hint; /* evas scale hint */ + Eina_Bool set; /* if image condition it's content */ + + Edje_Part_Description_Spec_Border border; + Edje_Part_Description_Spec_Fill fill; +}; + +struct _Old_Edje_Part_Description +{ + Edje_Part_Description_Common common; + Old_Edje_Part_Description_Spec_Image image; + Edje_Part_Description_Spec_Text text; + Edje_Part_Description_Spec_Box box; + Edje_Part_Description_Spec_Table table; + + Eina_List *external_params; /* parameters for external objects */ +}; + +struct _Old_Edje_Part_Collection_Directory +{ + Eina_List *entries; /* a list of Edje_Part_Collection_Directory_Entry */ + + int references; +}; + +Edje_File *_edje_file_convert(Eet_File *ef, Old_Edje_File *oedf); +Edje_Part_Collection *_edje_collection_convert(Eet_File *ef, + Edje_Part_Collection_Directory_Entry *ce, + Old_Edje_Part_Collection *oedc); +Edje_Part_Description_Common *_edje_description_convert(int type, + Edje_Part_Collection_Directory_Entry *ce, + Old_Edje_Part_Description *oed); +const Edje_File *_edje_file_get(void); +void _edje_file_set(const Edje_File *edf); + +#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 @@ +#include "edje_private.h" +#include "edje_convert.h" + +Eet_Data_Descriptor *_edje_edd_old_edje_file = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_style = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_style_tag = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_color_class = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_data = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_external_directory = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_external_directory_entry = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_font_directory = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_font_directory_entry = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_image_directory = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_image_directory_entry = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_image_directory_set = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_image_directory_set_entry = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_program = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_program_target = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_program_after = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_part_collection_directory = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_part_collection_directory_entry = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_pack_element = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_part_collection = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_part = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_part_description = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_part_image_id = NULL; +Eet_Data_Descriptor *_edje_edd_old_edje_external_param = NULL; + +#define FREED(eed) \ + if (eed) \ + { \ + eet_data_descriptor_free((eed)); \ + (eed) = NULL; \ + } + +void +_edje_edd_old_shutdown(void) +{ + FREED(_edje_edd_old_edje_file); + FREED(_edje_edd_old_edje_style); + FREED(_edje_edd_old_edje_style_tag); + FREED(_edje_edd_old_edje_color_class); + FREED(_edje_edd_old_edje_data); + FREED(_edje_edd_old_edje_external_directory); + FREED(_edje_edd_old_edje_external_directory_entry); + FREED(_edje_edd_old_edje_font_directory); + FREED(_edje_edd_old_edje_font_directory_entry); + FREED(_edje_edd_old_edje_image_directory); + FREED(_edje_edd_old_edje_image_directory_entry); + FREED(_edje_edd_old_edje_program); + FREED(_edje_edd_old_edje_program_target); + FREED(_edje_edd_old_edje_program_after); + FREED(_edje_edd_old_edje_part_collection_directory); + FREED(_edje_edd_old_edje_part_collection_directory_entry); + FREED(_edje_edd_old_edje_pack_element); + FREED(_edje_edd_old_edje_part_collection); + FREED(_edje_edd_old_edje_part); + FREED(_edje_edd_old_edje_part_description); + FREED(_edje_edd_old_edje_part_image_id); + FREED(_edje_edd_old_edje_external_param); + FREED(_edje_edd_old_edje_image_directory_set); + FREED(_edje_edd_old_edje_image_directory_set_entry); +} + +void +_edje_edd_old_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + /* external directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Directory_Entry); + _edje_edd_old_edje_external_directory_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_directory_entry, Edje_External_Directory_Entry, "entry", entry, EET_T_STRING); + + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), + "Edje_External_Directory", + sizeof (Old_Edje_External_Directory)); + _edje_edd_old_edje_external_directory = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_external_directory, Edje_External_Directory, "entries", entries, _edje_edd_old_edje_external_directory_entry); + + /* font directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Font_Directory_Entry); + _edje_edd_old_edje_font_directory_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_font_directory_entry, Edje_Font_Directory_Entry, "entry", entry, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_font_directory_entry, Edje_Font_Directory_Entry, "file", file, EET_T_STRING); + + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), + "Edje_Font_Directory", + sizeof (Old_Edje_Font_Directory)); + _edje_edd_old_edje_font_directory = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_font_directory, Old_Edje_Font_Directory, "entries", entries, _edje_edd_old_edje_font_directory_entry); + + /* image directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Entry); + _edje_edd_old_edje_image_directory_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_entry, Edje_Image_Directory_Entry, "entry", entry, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_type", source_type, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_param", source_param, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_entry, Edje_Image_Directory_Entry, "id", id, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set_Entry); + _edje_edd_old_edje_image_directory_set_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "id", id, EET_T_INT); + 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); + 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); + 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); + 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); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set); + _edje_edd_old_edje_image_directory_set = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "id", id, EET_T_INT); + 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); + + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), + "Edje_Image_Directory", + sizeof (Old_Edje_Image_Directory)); + _edje_edd_old_edje_image_directory = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_image_directory, Old_Edje_Image_Directory, "entries", entries, _edje_edd_old_edje_image_directory_entry); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_image_directory, Old_Edje_Image_Directory, "sets", sets, _edje_edd_old_edje_image_directory_set); + + /* collection directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Collection_Directory_Entry); + _edje_edd_old_edje_part_collection_directory_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "entry", entry, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "id", id, EET_T_INT); + + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), + "Edje_Part_Collection_Directory", + sizeof (Old_Edje_Part_Collection_Directory)); + _edje_edd_old_edje_part_collection_directory = + eet_data_descriptor_file_new(&eddc); + 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); + + /* generic data attachment */ + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), + "Edje_Data", sizeof (Old_Edje_Data)); + _edje_edd_old_edje_data = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_data, Old_Edje_Data, "key", key, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_data, Old_Edje_Data, "value", value, EET_T_STRING); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style_Tag); + _edje_edd_old_edje_style_tag = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_style_tag, Edje_Style_Tag, "key", key, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_style_tag, Edje_Style_Tag, "value", value, EET_T_STRING); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style); + _edje_edd_old_edje_style = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_style, Edje_Style, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_style, Edje_Style, "tags", tags, _edje_edd_old_edje_style_tag); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Color_Class); + _edje_edd_old_edje_color_class = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "r", r, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "g", g, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "b", b, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "a", a, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "r2", r2, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "g2", g2, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "b2", b2, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "a2", a2, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "r3", r3, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "g3", g3, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "b3", b3, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_color_class, Edje_Color_Class, "a3", a3, EET_T_UCHAR); + + /* the main file directory */ + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), + "Edje_File", sizeof (Old_Edje_File)); + _edje_edd_old_edje_file = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_file, Old_Edje_File, "compiler", compiler, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_file, Old_Edje_File, "version", version, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_file, Old_Edje_File, "feature_ver", feature_ver, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_file, Old_Edje_File, "external_dir", external_dir, _edje_edd_old_edje_external_directory); + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_file, Old_Edje_File, "font_dir", font_dir, _edje_edd_old_edje_font_directory); + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_file, Old_Edje_File, "image_dir", image_dir, _edje_edd_old_edje_image_directory); + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_file, Old_Edje_File, "collection_dir", collection_dir, _edje_edd_old_edje_part_collection_directory); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, "data", data, _edje_edd_old_edje_data); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, "styles", styles, _edje_edd_old_edje_style); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, "color_classes", color_classes, _edje_edd_old_edje_color_class); + + /* parts & programs - loaded induvidually */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_Target); + _edje_edd_old_edje_program_target = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program_target, Edje_Program_Target, "id", id, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_After); + _edje_edd_old_edje_program_after = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program_after, + Edje_Program_After, "id", id, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program); + _edje_edd_old_edje_program = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "signal", signal, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "source", source, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "filter_part", filter.part, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "filter_state", filter.state, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "in.from", in.from, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "in.range", in.range, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "action", action, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "state", state, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "state2", state2, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "value", value, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "value2", value2, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "tween.mode", tween.mode, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "tween.time", tween.time, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_program, Edje_Program, "targets", targets, _edje_edd_old_edje_program_target); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_program, Edje_Program, "after", after, _edje_edd_old_edje_program_after); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "api.name", api.name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "api.description", api.description, EET_T_STRING); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "param.src", param.src, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_program, Edje_Program, "param.dst", param.dst, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Image_Id); + _edje_edd_old_edje_part_image_id = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_image_id, Edje_Part_Image_Id, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_image_id, Edje_Part_Image_Id, "set", set, EET_T_UCHAR); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Param); + _edje_edd_old_edje_external_param = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "type", type, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "i", i, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "d", d, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_param, Edje_External_Param, "s", s, EET_T_STRING); + + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Edje_Part_Description", sizeof (Old_Edje_Part_Description)); + _edje_edd_old_edje_part_description = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "state.name", common.state.name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "state.value", common.state.value, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "visible", common.visible, EET_T_CHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "align.x", common.align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "align.y", common.align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fixed.w", common.fixed.w, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fixed.h", common.fixed.h, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "min.w", common.min.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "min.h", common.min.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "max.w", common.max.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "max.h", common.max.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "step.x", common.step.x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "step.y", common.step.y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "aspect.min", common.aspect.min, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "aspect.max", common.aspect.max, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "aspect.prefer", common.aspect.prefer, EET_T_CHAR); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "image.id", image.id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "image.set", image.set, EET_T_UCHAR); + 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); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.l", image.border.l, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.r", image.border.r, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.t", image.border.t, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.b", image.border.b, EET_T_INT); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "border.scale", image.border.scale, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.smooth", image.fill.smooth, EET_T_CHAR); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.angle", image.fill.angle, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.spread", image.fill.spread, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "fill.type", image.fill.type, EET_T_CHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color_class", common.color_class, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color.r", common.color.r, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color.g", common.color.g, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color.b", common.color.b, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color.a", common.color.a, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color2.r", common.color2.r, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color2.g", common.color2.g, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color2.b", common.color2.b, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color2.a", common.color2.a, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color3.r", text.color3.r, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color3.g", text.color3.g, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color3.b", text.color3.b, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "color3.a", text.color3.a, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.text", text.text.str, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.text_class", text.text_class, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.style", text.style.str, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.font", text.font.str, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.repch", text.repch.str, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.size", text.size, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.fit_x", text.fit_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.fit_y", text.fit_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.min_x", text.min_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.min_y", text.min_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.max_x", text.max_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.max_y", text.max_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.align.x", text.align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.align.y", text.align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.id_source", text.id_source, EET_T_INT); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "text.elipsis", text.elipsis, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.layout", box.layout, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.alt_layout", box.alt_layout, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.align.x", box.align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.align.y", box.align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.padding.x", box.padding.x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.padding.y", box.padding.y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.min.h", box.min.h, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "box.min.v", box.min.v, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.homogeneous", table.homogeneous, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.align.x", table.align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.align.y", table.align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.padding.x", table.padding.x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "table.padding.y", table.padding.y, EET_T_INT); + 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); + 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); + 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); + 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); + 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); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.on", common.map.on, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.smooth", common.map.smooth, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.alpha", common.map.alpha, EET_T_UCHAR); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "map.backcull", common.map.backcull, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "persp.zplane", common.persp.zplane, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_description, Old_Edje_Part_Description, "persp.focal", common.persp.focal, EET_T_INT); + 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); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Pack_Element); + _edje_edd_old_edje_pack_element = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "type", type, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "source", source, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "min.w", min.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "min.h", min.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "prefer.w", prefer.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "prefer.h", prefer.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "max.w", max.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "max.h", max.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "padding.l", padding.l, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "padding.r", padding.r, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "padding.t", padding.t, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "padding.b", padding.b, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "align.x", align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "align.y", align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "weight.x", weight.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "weight.y", weight.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "aspect.w", aspect.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "aspect.h", aspect.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "aspect.mode", aspect.mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "options", options, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "col", col, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "row", row, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "colspan", colspan, EET_T_USHORT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "rowspan", rowspan, EET_T_USHORT); + + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Edje_Part", sizeof (Old_Edje_Part)); + _edje_edd_old_edje_part = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "type", type, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "effect", effect, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "mouse_events", mouse_events, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "repeat_events", repeat_events, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "ignore_flags", ignore_flags, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "scale", scale, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "pointer_mode", pointer_mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "precise_is_inside", precise_is_inside, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "clip_to_id", clip_to_id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "use_alternate_font_metrics", use_alternate_font_metrics, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_old_edje_part, Old_Edje_Part, "default_desc", default_desc, _edje_edd_old_edje_part_description); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part, Old_Edje_Part, "other_desc", other_desc, _edje_edd_old_edje_part_description); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.x", dragable.x, EET_T_CHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.step_x", dragable.step_x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.count_x", dragable.count_x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.y", dragable.y, EET_T_CHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.step_y", dragable.step_y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.count_y", dragable.count_y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.counfine_id", dragable.confine_id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "dragable.events_id", dragable.event_id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "entry_mode", entry_mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "select_mode", select_mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "multiline", multiline, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source", source, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source2", source2, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source3", source3, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source4", source4, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source5", source5, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "source6", source6, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part, Old_Edje_Part, "items", items, _edje_edd_old_edje_pack_element); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "api.name", api.name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "api.description", api.description, EET_T_STRING); + + eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Edje_Part_Collection", sizeof (Old_Edje_Part_Collection)); + _edje_edd_old_edje_part_collection = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "programs", programs, _edje_edd_old_edje_program); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "parts", parts, _edje_edd_old_edje_part); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "data", data, _edje_edd_old_edje_data); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "prop.min.w", prop.min.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "prop.min.h", prop.min.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "prop.max.h", prop.max.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "script_only", script_only, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "lua_script_only", lua_script_only, EET_T_UCHAR); + + { + Old_Edje_Part_Collection epc; + + eet_data_descriptor_element_add(_edje_edd_old_edje_part_collection, + "alias", EET_T_STRING, EET_G_HASH, + (char *)(&(epc.alias)) - (char *)(&(epc)), + 0, /* 0, */NULL, NULL); + } +} 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 @@ +/* ugly ugly. avert your eyes. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include + + +#include +#include + +#include "edje_decc.h" + +int _edje_cc_log_dom = -1; +char *progname = NULL; +char *file_in = NULL; +char *file_out = NULL; + +Edje_File *edje_file = NULL; +SrcFile_List *srcfiles = NULL; +Font_List *fontlist = NULL; + +int line = 0; +int build_sh = 1; +int new_dir = 1; + +int decomp(void); +void output(void); +static int compiler_cmd_is_sane(); +static int root_filename_is_sane(); + +static void +main_help(void) +{ + printf + ("Usage:\n" + "\t%s input_file.edj [-main-out file.edc] [-no-build-sh] [-current-dir]\n" + "\n" + " -main-out\tCreate a symbolic link to the main edc \n" + " -no-build-sh\tDon't output build.sh \n" + " -current-dir\tOutput to current directory \n" + "\n" + ,progname); +} + +Eet_File *ef; +Eet_Dictionary *ed; + +int +main(int argc, char **argv) +{ + int i; + + setlocale(LC_NUMERIC, "C"); + if (!eina_init()) + exit(-1); + _edje_cc_log_dom = eina_log_domain_register + ("edje_decc", EDJE_CC_DEFAULT_LOG_COLOR); + if (_edje_cc_log_dom < 0) + { + EINA_LOG_ERR("Impossible to create a log domain."); + eina_shutdown(); + exit(-1); + } + eina_log_level_set(EINA_LOG_LEVEL_INFO); + progname = argv[0]; + for (i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "-h")) + { + main_help(); + exit(0); + } + if (!file_in) + file_in = argv[i]; + else if ((!strcmp(argv[i], "-main-out")) && (i < (argc - 1))) + { + i++; + file_out = argv[i]; + } + else if (!strcmp(argv[i], "-no-build-sh")) + build_sh = 0; + else if (!strcmp(argv[i], "-current-dir")) + new_dir = 0; + } + if (!file_in) + { + ERR("%s: Error: no input file specified.", progname); + main_help(); + exit(-1); + } + + if (!edje_init()) + exit(-1); + source_edd(); + + if (!decomp()) return -1; + output(); + + printf("WARNING! If any Image or audio data was encoded in a LOSSY way, then\n" + "re-encoding will drop quality even more. You need access to the original\n" + "data to ensure no loss of quality.\n"); + eet_close(ef); + edje_shutdown(); + eina_log_domain_unregister(_edje_cc_log_dom); + _edje_cc_log_dom = -1; + eina_shutdown(); + return 0; +} + +int +decomp(void) +{ + ef = eet_open(file_in, EET_FILE_MODE_READ); + if (!ef) + { + ERR("ERROR: cannot open %s", file_in); + return 0; + } + + srcfiles = source_load(ef); + if (!srcfiles || !srcfiles->list) + { + ERR("ERROR: %s has no decompile information", file_in); + eet_close(ef); + return 0; + } + if (!eina_list_data_get(srcfiles->list) || !root_filename_is_sane()) + { + ERR("ERROR: Invalid root filename: '%s'", (char *) eina_list_data_get(srcfiles->list)); + eet_close(ef); + return 0; + } + edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje/file"); + if (!edje_file) + { + ERR("ERROR: %s does not appear to be an edje file", file_in); + eet_close(ef); + return 0; + } + /* force compiler to be edje_cc */ + edje_file->compiler = strdup("edje_cc"); + if (!edje_file->compiler) + { + edje_file->compiler = strdup("edje_cc"); + } + else if (!compiler_cmd_is_sane()) + { + ERR("ERROR: invalid compiler executable: '%s'", edje_file->compiler); + eet_close(ef); + return 0; + } + fontlist = source_fontmap_load(ef); + return 1; +} + +void +output(void) +{ + Eina_List *l; + Eet_File *tef; + SrcFile *sf; + char *outdir, *p; + + if (!new_dir) + outdir = strdup("."); + else + { + p = strrchr(file_in, '/'); + if (p) + outdir = strdup(p + 1); + else + outdir = strdup(file_in); + p = strrchr(outdir, '.'); + if (p) *p = 0; + ecore_file_mkpath(outdir); + } + + + tef = eet_open(file_in, EET_FILE_MODE_READ); + + if (edje_file->image_dir) + { + Edje_Image_Directory_Entry *ei; + unsigned int i; + + for (i = 0; i < edje_file->image_dir->entries_count; ++i) + { + ei = &edje_file->image_dir->entries[i]; + + if ((ei->source_type > EDJE_IMAGE_SOURCE_TYPE_NONE) && + (ei->source_type < EDJE_IMAGE_SOURCE_TYPE_LAST) && + (ei->source_type != EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) && + (ei->entry)) + { + Ecore_Evas *ee; + Evas *evas; + Evas_Object *im; + char buf[4096]; + char out[4096]; + char *pp; + + ecore_init(); + ecore_evas_init(); + ee = ecore_evas_buffer_new(1, 1); + if (!ee) + { + ERR("Cannot create buffer engine canvas for image save."); + exit(-1); + } + evas = ecore_evas_get(ee); + im = evas_object_image_add(evas); + if (!im) + { + ERR("Cannot create image object for save."); + exit(-1); + } + snprintf(buf, sizeof(buf), "edje/images/%i", ei->id); + evas_object_image_file_set(im, file_in, buf); + snprintf(out, sizeof(out), "%s/%s", outdir, ei->entry); + printf("Output Image: %s\n", out); + pp = strdup(out); + p = strrchr(pp, '/'); + *p = 0; + if (strstr(pp, "../")) + { + ERR("Potential security violation. attempt to write in parent dir."); + exit(-1); + } + ecore_file_mkpath(pp); + free(pp); + if (!evas_object_image_save(im, out, NULL, "quality=100 compress=9")) + { + ERR("Cannot write file %s. Perhaps missing JPEG or PNG saver modules for Evas.", out); + exit(-1); + } + evas_object_del(im); + ecore_evas_free(ee); + ecore_evas_shutdown(); + ecore_shutdown(); + } + } + } + + EINA_LIST_FOREACH(srcfiles->list, l, sf) + { + char out[4096]; + FILE *f; + char *pp; + + snprintf(out, sizeof(out), "%s/%s", outdir, sf->name); + INF("Output Source File: %s\n", out); + pp = strdup(out); + p = strrchr(pp, '/'); + *p = 0; + if (strstr(pp, "../")) + { + ERR("Potential security violation. attempt to write in parent dir."); + exit (-1); + } + ecore_file_mkpath(pp); + free(pp); + if (strstr(out, "../")) + { + ERR("Potential security violation. attempt to write in parent dir."); + exit (-1); + } + f = fopen(out, "wb"); + if (!f) + { + ERR("Unable to write file (%s).", out); + exit (-1); + } + + /* if the file is empty, sf->file will be NULL. + * note that that's not an error + */ + if (sf->file) fputs(sf->file, f); + fclose(f); + } + if (edje_file->fonts) + { + Edje_Font_Directory_Entry *fn; + Eina_Iterator *it; + + it = eina_hash_iterator_data_new(edje_file->fonts); + EINA_ITERATOR_FOREACH(it, fn) + { + void *font; + int fontsize; + char out[4096]; + /* FIXME!!!! */ + /* should be fn->entry -v */ + snprintf(out, sizeof(out), "edje/fonts/%s", fn->file); + font = eet_read(tef, out, &fontsize); + if (font) + { + FILE *f; + char *pp; + + /* should be fn->file -v */ + snprintf(out, sizeof(out), "%s/%s", outdir, fn->entry); + INF("Output Font: %s", out); + pp = strdup(out); + p = strrchr(pp, '/'); + *p = 0; + if (strstr(pp, "../")) + { + ERR("Potential security violation. attempt to write in parent dir."); + exit (-1); + } + ecore_file_mkpath(pp); + free(pp); + if (strstr(out, "../")) + { + ERR("Potential security violation. attempt to write in parent dir."); + exit (-1); + } + if (!(f = fopen(out, "wb"))) + { + ERR("Could not open file: %s", out); + exit (-1); + } + if (fwrite(font, fontsize, 1, f) != 1) + ERR("Could not write font: %s", strerror(errno)); + if (f) fclose(f); + free(font); + } + } + eina_iterator_free(it); + } + { + char out[4096]; + FILE *f; + sf = eina_list_data_get(srcfiles->list); + + + if (build_sh) + { + snprintf(out, sizeof(out), "%s/build.sh", outdir); + printf("Output Build Script: %s\n", out); + if (strstr(out, "../")) + { + ERR("potential security violation. attempt to write in parent dir.\n"); + exit (-1); + } + f = fopen(out, "wb"); + fprintf(f, "#!/bin/sh\n"); + fprintf(f, "%s $@ -id . -fd . %s -o %s.edj\n", edje_file->compiler, sf->name, outdir); + fclose(f); + + WRN("\n*** CAUTION ***\n" + "Please check the build script for anything malicious " + "before running it!\n\n"); + } + + if (file_out) + { + snprintf(out, sizeof(out), "%s/%s", outdir, file_out); + if (ecore_file_symlink(sf->name, out) != EINA_TRUE) + { + ERR("symlink %s -> %s failed\n", sf->name, out); + } + } + + chmod(out, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP); + + } + + if (edje_file->sound_dir) + { + Edje_Sound_Sample *sample; + void *sound_data; + char out[PATH_MAX]; + char out1[PATH_MAX]; + char *pp; + int sound_data_size; + FILE *f; + int i; + + for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++) + { + sample = &edje_file->sound_dir->samples[i]; + if ((!sample) || (!sample->name)) continue; + snprintf(out, sizeof(out), "edje/sounds/%i", sample->id); + sound_data = (void *)eet_read_direct(tef, out, &sound_data_size); + if (sound_data) + { + snprintf(out1, sizeof(out1), "%s/%s", outdir, sample->name); + pp = strdup(out1); + p = strrchr(pp, '/'); + *p = 0; + if (strstr(pp, "../")) + { + ERR("Potential security violation. attempt to write in parent dir."); + exit(-1); + } + ecore_file_mkpath(pp); + free(pp); + if (strstr(out, "../")) + { + ERR("Potential security violation. attempt to write in parent dir."); + exit(-1); + } + f = fopen(out1, "wb"); + if (fwrite(sound_data, sound_data_size, 1, f) != 1) + ERR("Could not write sound: %s", strerror(errno)); + fclose(f); + free(sound_data); + } + } + + } + eet_close(tef); +} + +static int +compiler_cmd_is_sane() +{ + const char *c = edje_file->compiler, *ptr; + + if ((!c) || (!*c)) + { + return 0; + } + + for (ptr = c; ptr && *ptr; ptr++) + { + /* only allow [a-z][A-Z][0-9]_- */ + if ((!isalnum(*ptr)) && (*ptr != '_') && (*ptr != '-')) + { + return 0; + } + } + + return 1; +} + +static int +root_filename_is_sane() +{ + SrcFile *sf = eina_list_data_get(srcfiles->list); + char *f = sf->name, *ptr; + + if (!f || !*f) + { + return 0; + } + + for (ptr = f; ptr && *ptr; ptr++) + { + /* only allow [a-z][A-Z][0-9]_-./ */ + switch (*ptr) + { + case '_': case '-': case '.': case '/': + break; + default: + if (!isalnum(*ptr)) + { + return 0; + } + } + } + return 1; +} 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 @@ +#ifndef EDJE_DECC_H +#define EDJE_DECC_H + +#include + +/* logging variables */ +extern int _edje_cc_log_dom ; +#define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN +#ifdef ERR +# undef ERR +#endif +#define ERR(...) EINA_LOG_DOM_ERR(_edje_cc_log_dom, __VA_ARGS__) +#ifdef INF +# undef INF +#endif +#define INF(...) EINA_LOG_DOM_INFO(_edje_cc_log_dom, __VA_ARGS__) +#ifdef WRN +# undef WRN +#endif +#define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__) + +/* types */ +typedef struct _Font Font; +typedef struct _Font_List Font_List; +typedef struct _SrcFile SrcFile; +typedef struct _SrcFile_List SrcFile_List; + +struct _Font +{ + char *file; + char *name; +}; + +struct _Font_List +{ + Eina_List *list; +}; + +struct _SrcFile +{ + char *name; + char *file; +}; + +struct _SrcFile_List +{ + Eina_List *list; +}; + +void source_edd(void); +void source_fetch(void); +int source_append(Eet_File *ef); +SrcFile_List *source_load(Eet_File *ef); +int source_fontmap_save(Eet_File *ef, Eina_List *fonts); +Font_List *source_fontmap_load(Eet_File *ef); + +void *mem_alloc(size_t size); +char *mem_strdup(const char *s); +#define SZ sizeof + +#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 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include +#include + +#include "Edje.h" + +static int _log_dom; +#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__) +#define CRIT(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__) + +#define INDENT " " +#define INDENT2 INDENT INDENT +#define INDENT3 INDENT2 INDENT +#define INDENT4 INDENT3 INDENT + +static char *module_patterns_str = NULL; + +static int detail = 1; +static Eina_Bool machine = EINA_FALSE; +static char *type_glob = NULL; +static char * const *module_patterns; +static const Eina_List *modules; + + +static char * +_module_patterns_str_new(void) +{ + Eina_Strbuf *buf; + char * const *itr; + char *ret; + if (!module_patterns) return strdup("*"); + + buf = eina_strbuf_new(); + for (itr = module_patterns; *itr != NULL; itr++) + { + eina_strbuf_append(buf, *itr); + if (itr[1]) eina_strbuf_append(buf, ", "); + } + ret = eina_strbuf_string_steal(buf); + eina_strbuf_free(buf); + return ret; +} + +static Eina_Bool +module_matches(const char *name) +{ + char * const *itr; + if (!module_patterns) return EINA_TRUE; + + for (itr = module_patterns; *itr != NULL; itr++) + if (fnmatch(*itr, name, 0) == 0) return EINA_TRUE; + + return EINA_FALSE; +} + +static inline Eina_Bool +type_matches(const char *name) +{ + if (!type_glob) return EINA_TRUE; + return fnmatch(type_glob, name, 0) == 0; +} + +static int +_types_sort(const void *pa, const void *pb) +{ + const Eina_Hash_Tuple *ha = pa, *hb = pb; + const Edje_External_Type *ta = ha->data, *tb = hb->data; + const char *na = ha->key, *nb = hb->key; + int r; + + if (!ta->module) return -1; + if (!tb->module) return 1; + r = strcmp(ta->module, tb->module); + if (r != 0) return r; + + if (!na) return -1; + if (!nb) return 1; + return strcmp(na, nb); +} + +static const char * +_param_type_str_get(const Edje_External_Param_Info *param) +{ + switch (param->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: return "int"; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: return "double"; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: return "string"; + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: return "bool"; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: return "choice"; + default: + ERR("Unknown parameter type %d", param->type); + return "???"; + } +} + +static const char * +_param_value_str_get(const Edje_External_Type *type, const Edje_External_Param_Info *param, char *buf, size_t buflen) +{ + switch (param->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + if (param->info.i.def == EDJE_EXTERNAL_INT_UNSET) return NULL; + snprintf(buf, buflen, "%d", param->info.i.def); + return buf; + + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + if (param->info.d.def == EDJE_EXTERNAL_DOUBLE_UNSET) return NULL; + snprintf(buf, buflen, "%g", param->info.d.def); + return buf; + + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + return param->info.s.def; + + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + if (param->info.b.def == 0) return "0"; + else if (param->info.b.def == 1) return "1"; + return NULL; + + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + { + char *def; + if (param->info.c.def) return param->info.c.def; + if (!param->info.c.def_get) return NULL; + def = param->info.c.def_get(type->data, param); + if (!def) return NULL; + eina_strlcpy(buf, def, buflen); + free(def); + return buf; + } + + default: + ERR("Unknown parameter type %d", param->type); + return NULL; + } +} + +static const char * +_param_flags_str_get(const Edje_External_Param_Info *param) +{ + static char buf[] = "GET|SET|STATE|CONSTRUCTOR"; + + if (param->flags == EDJE_EXTERNAL_PARAM_FLAGS_NONE) return "NONE"; + if (param->flags == EDJE_EXTERNAL_PARAM_FLAGS_REGULAR) return "REGULAR"; + + buf[0] = '\0'; + + if (param->flags & EDJE_EXTERNAL_PARAM_FLAGS_GET) + strcat(buf, "GET"); + + if (param->flags & EDJE_EXTERNAL_PARAM_FLAGS_SET) + { + if (buf[0] != '\0') strcat(buf, "|"); + strcat(buf, "SET"); + } + + if (param->flags & EDJE_EXTERNAL_PARAM_FLAGS_STATE) + { + if (buf[0] != '\0') strcat(buf, "|"); + strcat(buf, "STATE"); + } + + if (param->flags & EDJE_EXTERNAL_PARAM_FLAGS_CONSTRUCTOR) + { + if (buf[0] != '\0') strcat(buf, "|"); + strcat(buf, "CONSTRUCTOR"); + } + + return buf; +} + +static void +_param_choices_print(const char * const *choices) +{ + if (machine) puts("CHOICES-BEGIN"); + else fputs(", choices:", stdout); + for (; *choices != NULL; choices++) + { + if (machine) puts(*choices); + else printf(" \"%s\"", *choices); + } + if (machine) puts("CHOICES-END"); +} + +static void +_param_extra_details(const Edje_External_Type *type, const Edje_External_Param_Info *param) +{ + const char *str = _param_flags_str_get(param); + if (machine) printf("FLAGS: %s\n", str); + else printf(" /* flags: %s", str); + + switch (param->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + if (param->info.i.min != EDJE_EXTERNAL_INT_UNSET) + { + if (machine) printf("MIN: %d\n", param->info.i.min); + else printf(", min: %d", param->info.i.min); + } + if (param->info.i.max != EDJE_EXTERNAL_INT_UNSET) + { + if (machine) printf("MAX: %d\n", param->info.i.max); + else printf(", max: %d", param->info.i.max); + } + if (param->info.i.step != EDJE_EXTERNAL_INT_UNSET) + { + if (machine) printf("STEP: %d\n", param->info.i.step); + else printf(", step: %d", param->info.i.step); + } + break; + + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + if (param->info.d.min != EDJE_EXTERNAL_DOUBLE_UNSET) + { + if (machine) printf("MIN: %g\n", param->info.d.min); + else printf(", min: %g", param->info.d.min); + } + if (param->info.d.max != EDJE_EXTERNAL_DOUBLE_UNSET) + { + if (machine) printf("MAX: %g\n", param->info.d.max); + else printf(", max: %g", param->info.d.max); + } + if (param->info.d.step != EDJE_EXTERNAL_DOUBLE_UNSET) + { + if (machine) printf("STEP: %g\n", param->info.d.step); + else printf(", step: %g", param->info.d.step); + } + break; + + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + if (param->info.s.accept_fmt) + { + if (machine) printf("ACCEPT_FMT: %s\n", param->info.s.accept_fmt); + else printf(", accept_fmt: \"%s\"", param->info.s.accept_fmt); + } + if (param->info.s.deny_fmt) + { + if (machine) printf("DENY_FMT: %s\n", param->info.s.deny_fmt); + else printf(", deny_fmt: \"%s\"", param->info.s.deny_fmt); + } + break; + + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + if (param->info.b.false_str) + { + if (machine) printf("FALSE_STR: %s\n", param->info.b.false_str); + else printf(", false_str: \"%s\"", param->info.b.false_str); + } + if (param->info.b.true_str) + { + if (machine) printf("TRUE_STR: %s\n", param->info.b.true_str); + else printf(", true_str: \"%s\"", param->info.b.true_str); + } + break; + + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + { + if (param->info.c.choices) + _param_choices_print(param->info.c.choices); + else if (param->info.c.query) + { + char **choices = param->info.c.query(type->data, param); + if (choices) + { + char **itr; + _param_choices_print((const char * const*)choices); + for (itr = choices; *itr; itr++) free(*itr); + free(choices); + } + } + } + break; + + default: + ERR("Unknown parameter type %d", param->type); + } + + if (!machine) fputs(" */", stdout); /* \n not desired */ +} + +static int +_info_list(void) +{ + Eina_Iterator *itr; + Eina_List *types; + const Eina_Hash_Tuple *tuple; + const Eina_List *l; + const char *name, *last_module; + Eina_Bool module_found = EINA_FALSE, type_found = EINA_FALSE; + Eina_Bool in_module = EINA_FALSE; + + EINA_LIST_FOREACH(modules, l, name) + { + if (!module_matches(name)) + { + DBG("filter out module '%s': does not match '%s'", + name, module_patterns_str); + continue; + } + + if (!edje_module_load(name)) + { + ERR("error loading external '%s'", name); + continue; + } + + module_found = EINA_TRUE; + } + + itr = edje_external_iterator_get(); + types = NULL; + EINA_ITERATOR_FOREACH(itr, tuple) + { + const Edje_External_Type *type = tuple->data; + name = tuple->key; + + if (!type) + { + ERR("no type value for '%s'", name); + continue; + } + else if (type->abi_version != edje_external_type_abi_version_get()) + { + ERR("type '%s' with incorrect abi_version %u (expected %u)", + name, type->abi_version, edje_external_type_abi_version_get()); + continue; + } + + if (!type_matches(name)) + { + DBG("filter out type '%s': does not match '%s'", name, type_glob); + continue; + } + + types = eina_list_append(types, tuple); + type_found = EINA_TRUE; + } + eina_iterator_free(itr); + + last_module = NULL; + types = eina_list_sort(types, 0, _types_sort); + EINA_LIST_FREE(types, tuple) + { + Eina_Bool changed_module = EINA_FALSE; + const Edje_External_Type *type = tuple->data; + const Edje_External_Param_Info *param; + name = tuple->key; + + if ((last_module) && (type->module)) + { + changed_module = ((last_module != type->module) && + (!strcmp(last_module, type->module))); + } + else if ((!last_module) && (type->module)) + changed_module = EINA_TRUE; + + if (changed_module) + { + if (in_module) + { + if (machine) puts("TYPES-END\nMODULE-END"); + else puts(INDENT "}\n}"); + } + + if (machine) + printf("MODULE-BEGIN\n" + "NAME: %s\n" + "FRIENDLY-NAME: %s\n" + "TYPES-BEGIN\n", + type->module, type->module_name); + else + printf("module {\n" + INDENT "name: \"%s\";\n" + INDENT "friendly_name: \"%s\";\n" + INDENT "types {\n", + type->module, type->module_name); + + in_module = EINA_TRUE; + } + + if (machine) printf("TYPE-BEGIN\nNAME: %s\n", name); + else printf(INDENT2 "type {\n" INDENT3 "name: \"%s\";\n", name); + + if (detail > 1) + { + const char *str; + + if (!type->label_get) str = NULL; + else str = type->label_get(type->data); + if (machine) printf("LABEL: %s\n", str ? str : ""); + else if (str) printf(INDENT3 "label: \"%s\";\n", str); + + if (!type->description_get) str = NULL; + else str = type->description_get(type->data); + if (machine) printf("DESCRIPTION: %s\n", str ? str : ""); + else if (str) printf(INDENT3 "description: \"%s\";\n", str); + } + + if (machine) puts("PARAMS-BEGIN"); + else puts(INDENT3 "params {"); + + for (param = type->parameters_info; param->name != NULL; param++) + { + const char *pt = _param_type_str_get(param); + char buf[128]; + + if (machine) + printf("PARAM-BEGIN\nNAME: %s\nTYPE: %s\n", param->name, pt); + else printf(INDENT4 "%s: \"%s\"", pt, param->name); + + if (detail > 0) + { + const char *str = _param_value_str_get + (type, param, buf, sizeof(buf)); + if (machine) printf("DEFAULT: %s\n", str ? str : ""); + else if (str) printf(" \"%s\"", str); + + if (detail > 1) + { + if (!machine) putchar(';'); + _param_extra_details(type, param); + } + } + + if (machine) puts("PARAM-END"); + else if (detail > 1) putchar('\n'); + else puts(";"); + } + + if (machine) puts("PARAMS-END\nTYPE-END"); + else puts(INDENT3 "}\n" INDENT2 "}"); + + last_module = type->module; + } + + if (in_module) + { + if (machine) puts("MODULE-END"); + else puts(INDENT "}\n}"); + } + + if (!module_found) WRN("no modules match '%s'", module_patterns_str); + if (!type_found) WRN("no types match '%s'", type_glob); + return (!module_found) || (!type_found); +} + +static int +_types_names_list(void) +{ + Eina_Iterator *itr; + Eina_List *types; + const Eina_Hash_Tuple *tuple; + const Eina_List *l; + const char *name; + Eina_Bool module_found = EINA_FALSE, type_found = EINA_FALSE; + + EINA_LIST_FOREACH(modules, l, name) + { + if (!module_matches(name)) + { + DBG("filter out module '%s': does not match '%s'", + name, module_patterns_str); + continue; + } + + if (!edje_module_load(name)) + { + ERR("error loading external '%s'", name); + continue; + } + + module_found = EINA_TRUE; + } + + itr = edje_external_iterator_get(); + types = NULL; + EINA_ITERATOR_FOREACH(itr, tuple) + { + const Edje_External_Type *type = tuple->data; + name = tuple->key; + + if (!type) + { + ERR("no type value for '%s'", name); + continue; + } + else if (type->abi_version != edje_external_type_abi_version_get()) + { + ERR("type '%s' with incorrect abi_version %u (expected %u)", + name, type->abi_version, edje_external_type_abi_version_get()); + continue; + } + + if (!type_matches(name)) + { + DBG("filter out type '%s': does not match '%s'", name, type_glob); + continue; + } + + types = eina_list_append(types, tuple); + type_found = EINA_TRUE; + } + eina_iterator_free(itr); + + types = eina_list_sort(types, 0, _types_sort); + EINA_LIST_FREE(types, tuple) + puts(tuple->key); + + if (!module_found) WRN("no modules match '%s'", module_patterns_str); + if (!type_found) WRN("no types match '%s'", type_glob); + return (!module_found) || (!type_found); +} + +static int +_modules_names_list(void) +{ + const Eina_List *l; + const char *name; + Eina_Bool found = EINA_FALSE; + + EINA_LIST_FOREACH(modules, l, name) + { + if (!module_matches(name)) + { + DBG("filter out module '%s': does not match '%s'", + name, module_patterns_str); + continue; + } + found = EINA_TRUE; + puts(name); + } + + if (!found) WRN("no modules match '%s'", module_patterns_str); + return !found; +} + +static const char *mode_choices[] = { + "info", + "modules-names", + "types-names", + NULL, +}; + +static const char *detail_choices[] = { + "none", + "terse", + "all", + NULL +}; + +const Ecore_Getopt optdesc = { + "edje_external_inspector", + "%prog [options] [module|module-glob] ... [module|module-glob]", + PACKAGE_VERSION, + "(C) 2010 - The Enlightenment Project", + "BSD", + "Edje external module inspector.", + 0, + { + ECORE_GETOPT_CHOICE('m', "mode", "Choose which mode to operate.", + mode_choices), + ECORE_GETOPT_STORE_STR('t', "type", "Limit output to type (or glob)."), + ECORE_GETOPT_CHOICE('d', "detail", "Choose detail level (default=terse)", + detail_choices), + ECORE_GETOPT_STORE_TRUE('M', "machine", "Produce machine readable output."), + ECORE_GETOPT_LICENSE('L', "license"), + ECORE_GETOPT_COPYRIGHT('C', "copyright"), + ECORE_GETOPT_VERSION('V', "version"), + ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_SENTINEL + } +}; + +int +main(int argc, char **argv) +{ + Eina_Bool quit_option = EINA_FALSE; + char *mode = NULL; + char *detail_name = NULL; + int arg_index; + int ret = 0; + Ecore_Getopt_Value values[] = { + ECORE_GETOPT_VALUE_STR(mode), + ECORE_GETOPT_VALUE_STR(type_glob), + ECORE_GETOPT_VALUE_STR(detail_name), + ECORE_GETOPT_VALUE_BOOL(machine), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_NONE + }; + + setlocale(LC_NUMERIC, "C"); + + ecore_init(); + eina_init(); + edje_init(); + + _log_dom = eina_log_domain_register + ("edje_external_inspector", EINA_COLOR_YELLOW); + if (_log_dom < 0) + { + EINA_LOG_CRIT + ("could not register log domain 'edje_external_inspector'"); + ret = 1; + goto error_log; + } + + arg_index = ecore_getopt_parse(&optdesc, values, argc, argv); + if (arg_index < 0) + { + ERR("could not parse arguments."); + ret = 1; + goto error_getopt; + } + else if (quit_option) goto error_getopt; + + if (!mode) mode = (char *)mode_choices[0]; + + if (detail_name) + { + if (!strcmp(detail_name, "none")) detail = 0; + else if (!strcmp(detail_name, "terse")) detail = 1; + else if (!strcmp(detail_name, "all")) detail = 2; + else ERR("Unknown detail level: '%s'", detail_name); + } + + if (arg_index < argc) module_patterns = argv + arg_index; + else module_patterns = NULL; + + modules = edje_available_modules_get(); + module_patterns_str = _module_patterns_str_new(); + + if (!strcmp(mode, "info")) ret = _info_list(); + else if (!strcmp(mode, "modules-names")) ret = _modules_names_list(); + else if (!strcmp(mode, "types-names")) ret = _types_names_list(); + else + { + ERR("Unknown mode: %s", mode); + ret = 1; + } + + free(module_patterns_str); + + error_getopt: + eina_log_domain_unregister(_log_dom); + error_log: + edje_shutdown(); + ecore_shutdown(); + eina_shutdown(); + + return ret; +} 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 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "Edje.h" +#define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT 1 +#include "Edje_Edit.h" + +#include +#include +#include +#include +#include +#include + +static int _log_dom; +#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__) +#define CRIT(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__) + +#define INDENT " " +#define INDENT2 INDENT INDENT +#define INDENT3 INDENT2 INDENT +#define INDENT4 INDENT3 INDENT +#define INDENT5 INDENT4 INDENT +#define INDENT6 INDENT5 INDENT +#define INDENT7 INDENT6 INDENT + +#define FLOAT_PRECISION 0.0001 +#define FDIFF(a, b) (fabs((a) - (b)) > FLOAT_PRECISION) + +#ifdef _WIN32 +# define FMT_UCHAR "%c" +#else +# define FMT_UCHAR "%hhu" +#endif + +/* context */ +static Eina_List *groups; +static Ecore_Evas *ee; + +/* options */ +static const char *file; +static char *group = NULL; +static char *part = NULL; +static char *program = NULL; +static int detail = 1; +static Eina_Bool api_only = EINA_FALSE; +static Eina_Bool api_fix = EINA_FALSE; +static Eina_Bool machine = EINA_FALSE; + +static const char *mode_choices[] = { + "groups", + "parts", + "programs", + "groups-names", + "part-names", + "global-data", + "images", + "fonts", + "externals", + NULL, +}; + +static const char *detail_choices[] = { + "none", + "terse", + "all", + NULL +}; + +const Ecore_Getopt optdesc = { + "edje_inspector", + "%prog [options] ", + PACKAGE_VERSION, + "(C) 2010 - The Enlightenment Project", + "BSD", + "Edje file inspector, let one see groups, parts, programs and other details " + "of a compiled (binary) edje file.\n", + 0, + { + ECORE_GETOPT_CHOICE('m', "mode", "Choose which mode to operate on file.", + mode_choices), + ECORE_GETOPT_CHOICE('d', "detail", "Choose detail level (default=terse)", + detail_choices), + ECORE_GETOPT_STORE_STR('g', "group", "Limit output to group (or glob)."), + ECORE_GETOPT_STORE_STR('p', "part", "Limit output to part (or glob)."), + ECORE_GETOPT_STORE_STR('r', "program", + "Limit output to program (or glob)."), + ECORE_GETOPT_STORE_TRUE('a', "api-only", "Limit to just api parts or " + "programs."), + ECORE_GETOPT_STORE_TRUE('A', "api-fix", "Fix API names to be C compliant."), + ECORE_GETOPT_STORE_TRUE('M', "machine", "Produce machine readable output."), + ECORE_GETOPT_LICENSE('L', "license"), + ECORE_GETOPT_COPYRIGHT('C', "copyright"), + ECORE_GETOPT_VERSION('V', "version"), + ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_SENTINEL + } +}; + +static inline Eina_Bool +matches(const char *name, const char *pattern) +{ + if (!pattern) return EINA_TRUE; + return fnmatch(pattern, name, 0) == 0; +} + +static void +group_begin(const char *name) +{ + if (machine) printf("GROUP-BEGIN\nNAME: %s\n", name); + else printf("group { name: '%s';\n", name); +} + +static void +group_end(void) +{ + if (machine) puts("GROUP-END"); + else puts("}"); +} + +static void +group_details(Evas_Object *ed) +{ + int w, h; + + if (detail < 1) return; + + if (machine) puts("GROUP-DETAILS-BEGIN"); + + w = edje_edit_group_min_w_get(ed); + h = edje_edit_group_min_h_get(ed); + if (machine) printf("MIN-W: %d\nMIN-H: %d\n", w, h); + else if ((w > 0) || (h > 0)) printf(INDENT "min: %d %d;\n", w, h); + + w = edje_edit_group_max_w_get(ed); + h = edje_edit_group_max_h_get(ed); + if (machine) printf("MAX-W: %d\nMAX-H: %d\n", w, h); + else if ((w > 0) || (h > 0)) printf(INDENT "max: %d %d;\n", w, h); + + if (detail > 1) + { + Eina_List *dl; + dl = edje_edit_group_data_list_get(ed); + if (dl) + { + Eina_List *l; + const char *k; + if (machine) puts(INDENT "GROUP-DETAILS-DATA-BEGIN"); + else puts(INDENT "data {"); + + EINA_LIST_FOREACH(dl, l, k) + { + const char *v = edje_edit_group_data_value_get(ed, k); + if (machine) printf("ITEM: \"%s\" \"%s\"\n", k, v); + else printf(INDENT2 "item: \"%s\" \"%s\";\n", k, v); + } + + edje_edit_string_list_free(dl); + + if (machine) puts(INDENT "GROUP-DETAILS-DATA-END"); + else puts(INDENT "}"); + } + } + + if (machine) puts("GROUP-DETAILS-END"); +} + +static void +parts_begin(void) +{ + if (machine) puts("PARTS-BEGIN"); + else puts(INDENT "parts {"); +} + +static void +parts_end(void) +{ + if (machine) puts("PARTS-END"); + else puts(INDENT "}"); +} + +static const char * +part_type_name_get(Edje_Part_Type t) +{ + switch (t) + { + case EDJE_PART_TYPE_RECTANGLE: + return "RECT"; + case EDJE_PART_TYPE_TEXT: + return "TEXT"; + case EDJE_PART_TYPE_IMAGE: + return "IMAGE"; + case EDJE_PART_TYPE_PROXY: + return "PROXY"; + case EDJE_PART_TYPE_SWALLOW: + return "SWALLOW"; + case EDJE_PART_TYPE_TEXTBLOCK: + return "TEXTBLOCK"; + case EDJE_PART_TYPE_GRADIENT: + return "GRADIENT"; + case EDJE_PART_TYPE_GROUP: + return "GROUP"; + case EDJE_PART_TYPE_BOX: + return "BOX"; + case EDJE_PART_TYPE_TABLE: + return "TABLE"; + case EDJE_PART_TYPE_EXTERNAL: + return "EXTERNAL"; + + case EDJE_PART_TYPE_NONE: + case EDJE_PART_TYPE_LAST: + ERR("Invalid part type %d", t); + return "???"; + default: + ERR("Unknown part type %d", t); + return "???"; + } +} + +static void +state_begin(const char *state, double value) +{ + if (machine) + printf("PART-STATE-BEGIN\nNAME: %s\nVALUE: %2.1f\n", state, value); + else + { + printf(INDENT3 "description { state: \"%s\" %2.1f;", state, value); + if (detail > 0) putchar('\n'); + } +} + +static const char * +aspect_pref_name_get(int id) +{ + switch (id) + { + case 0: return "NONE"; + case 1: return "VERTICAL"; + case 2: return "HORIZONTAL"; + case 3: return "BOTH"; + default: + ERR("Unknown aspect preference %d", id); + return "???"; + } +} + +static const char * +border_fill_name_get(int id) +{ + switch (id) + { + case 0: return "NONE"; + case 1: return "DEFAULT"; + case 2: return "SOLID"; + default: + ERR("Unknown border fill %d", id); + return "???"; + } +} + +static void +state_details(Evas_Object *ed, const char *part, const char *state, double value) +{ + Edje_Part_Type t = edje_edit_part_type_get(ed, part); + double dx, dy; + const char *str, *str2; + int x, y, r, g, b, a; + + if (detail < 1) return; + + b = edje_edit_state_visible_get(ed, part, state, value); + if (machine) printf("VISIBLE: %d\n", b); + else if (!b) puts(INDENT4 "visible: 0;"); + + edje_edit_state_color_get(ed, part, state, value, &r, &g, &b, &a); + if (machine) + printf("COLOR-R: %d\nCOLOR-G: %d\nCOLOR-B: %d\nCOLOR-A: %d\n", r, g, b, a); + else if ((r != 255) || (g != 255) || (b != 255) || (a != 255)) + printf(INDENT4 "color: %d %d %d %d;\n", r, g, b, a); + + if (detail > 1) + { + edje_edit_state_color2_get(ed, part, state, value, &r, &g, &b, &a); + if (machine) + printf("COLOR2-R: %d\nCOLOR2-G: %d\nCOLOR2-B: %d\nCOLOR2-A: %d\n", + r, g, b, a); + else if ((r != 255) || (g != 255) || (b != 255) || (a != 255)) + printf(INDENT4 "color2: %d %d %d %d;\n", r, g, b, a); + + edje_edit_state_color3_get(ed, part, state, value, &r, &g, &b, &a); + if (machine) + printf("COLOR3-R: %d\nCOLOR3-G: %d\nCOLOR3-B: %d\nCOLOR3-A: %d\n", + r, g, b, a); + else if ((r != 255) || (g != 255) || (b != 255) || (a != 255)) + printf(INDENT4 "color3: %d %d %d %d;\n", r, g, b, a); + } + + dx = edje_edit_state_align_x_get(ed, part, state, value); + dy = edje_edit_state_align_y_get(ed, part, state, value); + if (machine) printf("ALIGN-X: %g\nALIGN-Y: %g\n", dx, dy); + else if (FDIFF(dx, 0.5) || FDIFF(dy, 0.5)) + printf(INDENT4 "align: %g %g;\n", dx, dy); + + x = edje_edit_state_min_w_get(ed, part, state, value); + y = edje_edit_state_min_h_get(ed, part, state, value); + if (machine) printf("MIN-W: %d\nMIN-H: %d\n", x, y); + else if ((x) || (y)) printf(INDENT4 "min: %d %d;\n", x, y); + + x = edje_edit_state_max_w_get(ed, part, state, value); + y = edje_edit_state_max_h_get(ed, part, state, value); + if (machine) printf("MAX-W: %d\nMAX-H: %d\n", x, y); + else if ((x != -1) || (y != -1)) printf(INDENT4 "max: %d %d;\n", x, y); + + //TODO Support fixed + //TODO Support step + + if (detail > 1) + { + dx = edje_edit_state_aspect_min_get(ed, part, state, value); + dy = edje_edit_state_aspect_max_get(ed, part, state, value); + if (machine) printf("ASPECT-MIN: %g\nASPECT-MAX: %g\n", dx, dy); + else if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0)) + printf(INDENT4 "aspect: %g %g;\n", dx, dy); + + x = edje_edit_state_aspect_pref_get(ed, part, state, value); + str = aspect_pref_name_get(x); + if (machine) printf("ASPECT-PREFERENCE: %s\n", str); + else if (x) printf(INDENT4 "aspect_preference: %s;\n", str); + /* do not free this str! */ + + str = edje_edit_state_color_class_get(ed, part, state, value); + if (machine) printf("COLOR_CLASS: %s\n", str ? str : ""); + else if (str) printf(INDENT4 "color_class: \"%s\";\n", str); + edje_edit_string_free(str); + } + + dx = edje_edit_state_rel1_relative_x_get(ed, part, state, value); + dy = edje_edit_state_rel1_relative_y_get(ed, part, state, value); + x = edje_edit_state_rel1_offset_x_get(ed, part, state, value); + y = edje_edit_state_rel1_offset_y_get(ed, part, state, value); + str = edje_edit_state_rel1_to_x_get(ed, part, state, value); + str2 = edje_edit_state_rel1_to_y_get(ed, part, state, value); + if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y) || (str) || (str2)) + { + if (machine) puts("REL1-BEGIN"); + else puts(INDENT4 "rel1 {"); + + if (machine) printf("RELATIVE-X: %g\nRELATIVE-Y: %g\n", dx, dy); + else if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0)) + printf(INDENT5 "relative: %g %g;\n", dx, dy); + + if (machine) printf("OFFSET-X: %d\nOFFSET-Y: %d\n", x, y); + else if ((x) || (y)) printf(INDENT5 "offset: %d %d;\n", x, y); + + if (machine) + printf("TO-X: %s\nTO-Y: %s\n", str ? str : "", str2 ? str2 : ""); + else if (((str) && (str2)) && (!strcmp(str, str2))) + printf(INDENT5 "to: \"%s\";\n", str); + else + { + if (str) printf(INDENT5 "to_x: \"%s\";\n", str); + if (str2) printf(INDENT5 "to_y: \"%s\";\n", str2); + } + + if (machine) puts("REL1-END"); + else puts(INDENT4 "}"); + } + edje_edit_string_free(str); + edje_edit_string_free(str2); + + dx = edje_edit_state_rel2_relative_x_get(ed, part, state, value); + dy = edje_edit_state_rel2_relative_y_get(ed, part, state, value); + x = edje_edit_state_rel2_offset_x_get(ed, part, state, value); + y = edje_edit_state_rel2_offset_y_get(ed, part, state, value); + str = edje_edit_state_rel2_to_x_get(ed, part, state, value); + str2 = edje_edit_state_rel2_to_y_get(ed, part, state, value); + if (FDIFF(dx, 1.0) || FDIFF(dy, 1.0) || (x != -1) || (y != -1) || + (str) || (str2)) + { + if (machine) puts("REL2-BEGIN"); + else puts(INDENT4 "rel2 {"); + + if (machine) printf("RELATIVE-X: %g\nRELATIVE-Y: %g\n", dx, dy); + else if (FDIFF(dx, 1.0) || FDIFF(dy, 1.0)) + printf(INDENT5 "relative: %g %g;\n", dx, dy); + + if (machine) printf("OFFSET-X: %d\nOFFSET-Y: %d\n", x, y); + else if ((x != -1) || (y != -1)) + printf(INDENT5 "offset: %d %d;\n", x, y); + + if (machine) + printf("TO-X: %s\nTO-Y: %s\n", str ? str : "", str2 ? str2 : ""); + else if (((str) && (str2)) && (!strcmp(str, str2))) + printf(INDENT5 "to: \"%s\";\n", str); + else + { + if (str) printf(INDENT5 "to_x: \"%s\";\n", str); + if (str2) printf(INDENT5 "to_y: \"%s\";\n", str2); + } + + if (machine) puts("REL2-END"); + else puts(INDENT4 "}"); + } + edje_edit_string_free(str); + edje_edit_string_free(str2); + + if (t == EDJE_PART_TYPE_IMAGE) + { + str = edje_edit_state_image_get(ed, part, state, value); + + if (machine) printf("IMAGE-BEGIN\nNORMAL: %s\n", str ? str : ""); + else if (detail > 1) + { + puts(INDENT4 "image {"); + if (str) printf(INDENT5 "normal: \"%s\";\n", str); + } + else if (str) printf(INDENT4 "image.normal: \"%s\";\n", str); + + edje_edit_string_free(str); + + if (detail > 1) + { + Eina_List *tweens, *l; + int bl, br, bt, bb, x2, y2; + double dx2, dy2; + Eina_Bool has_orgin, has_size; + + tweens = edje_edit_state_tweens_list_get(ed, part, state, value); + EINA_LIST_FOREACH(tweens, l, str) + { + if (machine) printf("TWEEN: %s\n", str); + else printf(INDENT5 "tween: \"%s\";\n", str); + } + edje_edit_string_list_free(tweens); + + edje_edit_state_image_border_get + (ed, part, state, value, &bl, &br, &bt, &bb); + if (machine) + printf("BORDER-LEFT: %d\nBORDER-RIGHT: %d\n" + "BORDER-TOP: %d\nBORDER-BOTTOM: %d\n", bl, br, bt, bb); + else if ((bl) || (br) || (bt) || (bb)) + printf(INDENT5 "border: %d %d %d %d;\n", bl, br, bt, bb); + + x = edje_edit_state_image_border_fill_get(ed, part, state, value); + str = border_fill_name_get(x); + if (machine) printf("BORDER-FILL: %s\n", str); + else if (x != 1) printf(INDENT5 "middle: %s;\n", str); + /* do not free str! */ + + // TODO support image.fill.smooth + + dx = edje_edit_state_fill_origin_relative_x_get + (ed, part, state, value); + dy = edje_edit_state_fill_origin_relative_y_get + (ed, part, state, value); + x = edje_edit_state_fill_origin_offset_x_get + (ed, part, state, value); + y = edje_edit_state_fill_origin_offset_y_get + (ed, part, state, value); + + dx2 = edje_edit_state_fill_size_relative_x_get + (ed, part, state, value); + dy2 = edje_edit_state_fill_size_relative_y_get + (ed, part, state, value); + x2 = edje_edit_state_fill_size_offset_x_get + (ed, part, state, value); + y2 = edje_edit_state_fill_size_offset_y_get + (ed, part, state, value); + + has_orgin = (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y)); + has_size = (FDIFF(dx2, 1.0) || FDIFF(dy2, 1.0) || (x2) || (y2)); + + if ((has_orgin) || (has_size)) + { + if (machine) puts("IMAGE-FILL-BEGIN"); + else puts(INDENT5 "fill {"); + + if (has_orgin) + { + if (machine) + printf("ORIGIN-RELATIVE-X: %g\n" + "ORIGIN-RELATIVE-Y: %g\n" + "ORIGIN-OFFSET-X: %d\n" + "ORIGIN-OFFSET-Y: %d\n", + dx, dy, x, y); + else + printf(INDENT6 "origin {\n" + INDENT7 "relative: %g %g;\n" + INDENT7 "offset: %d %d;\n" + INDENT6 "}\n", + dx, dy, x, y); + } + + if (has_size) + { + if (machine) + printf("SIZE-RELATIVE-X: %g\n" + "SIZE-RELATIVE-Y: %g\n" + "SIZE-OFFSET-X: %d\n" + "SIZE-OFFSET-Y: %d\n", + dx2, dy2, x2, y2); + else + printf(INDENT6 "size {\n" + INDENT7 "relative: %g %g;\n" + INDENT7 "offset: %d %d;\n" + INDENT6 "}\n", + dx2, dy2, x2, y2); + } + + if (machine) puts("IMAGE-FILL-END"); + else puts(INDENT5 "}"); + } + } + + if (machine) puts("IMAGE-END"); + else if (detail > 1) puts(INDENT4 "}"); + } + else if (t == EDJE_PART_TYPE_PROXY) + { + int x2, y2; + double dx2, dy2; + Eina_Bool has_orgin, has_size; + + if (machine) puts("PROXY-BEGIN"); + else puts(INDENT4 "proxy {"); + // TODO Support source + // TODO support proxy.fill.smooth + + dx = edje_edit_state_fill_origin_relative_x_get + (ed, part, state, value); + dy = edje_edit_state_fill_origin_relative_y_get + (ed, part, state, value); + x = edje_edit_state_fill_origin_offset_x_get + (ed, part, state, value); + y = edje_edit_state_fill_origin_offset_y_get + (ed, part, state, value); + + dx2 = edje_edit_state_fill_size_relative_x_get + (ed, part, state, value); + dy2 = edje_edit_state_fill_size_relative_y_get + (ed, part, state, value); + x2 = edje_edit_state_fill_size_offset_x_get + (ed, part, state, value); + y2 = edje_edit_state_fill_size_offset_y_get + (ed, part, state, value); + + has_orgin = (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y)); + has_size = (FDIFF(dx2, 1.0) || FDIFF(dy2, 1.0) || (x2) || (y2)); + + if ((has_orgin) || (has_size)) + { + if (machine) puts("PROXY-FILL-BEGIN"); + else puts(INDENT5 "fill {"); + + if (has_orgin) + { + if (machine) + printf("ORIGIN-RELATIVE-X: %g\n" + "ORIGIN-RELATIVE-Y: %g\n" + "ORIGIN-OFFSET-X: %d\n" + "ORIGIN-OFFSET-Y: %d\n", + dx, dy, x, y); + else + printf(INDENT6 "origin {\n" + INDENT7 "relative: %g %g;\n" + INDENT7 "offset: %d %d;\n" + INDENT6 "}\n", + dx, dy, x, y); + } + + if (has_size) + { + if (machine) + printf("SIZE-RELATIVE-X: %g\n" + "SIZE-RELATIVE-Y: %g\n" + "SIZE-OFFSET-X: %d\n" + "SIZE-OFFSET-Y: %d\n", + dx2, dy2, x2, y2); + else + printf(INDENT6 "size {\n" + INDENT7 "relative: %g %g;\n" + INDENT7 "offset: %d %d;\n" + INDENT6 "}\n", + dx2, dy2, x2, y2); + } + + if (machine) puts("PROXY-FILL-END"); + else puts(INDENT5 "}"); + } + + if (machine) puts("PROXY-END"); + else puts(INDENT4 "}"); + } + else if ((t == EDJE_PART_TYPE_TEXTBLOCK) || (t == EDJE_PART_TYPE_TEXT)) + { + if (machine) puts("TEXT-BEGIN"); + else puts(INDENT4 "text {"); + + str = edje_edit_state_text_get(ed, part, state, value); + if (machine) printf("TEXT: %s\n", str ? str : ""); + else if (str) printf(INDENT5 "text: \"%s\";\n", str); + edje_edit_string_free(str); + + str = edje_edit_state_font_get(ed, part, state, value); + if (machine) printf("FONT: %s\n", str ? str : ""); + else if (str) printf(INDENT5 "font: \"%s\";\n", str); + edje_edit_string_free(str); + + x = edje_edit_state_text_size_get(ed, part, state, value); + if (machine) printf("SIZE: %d\n", x); + else if (x > 0) printf(INDENT5 "size: %d;\n", x); + + // TODO text_class + + dx = edje_edit_state_text_align_x_get(ed, part, state, value); + dy = edje_edit_state_text_align_y_get(ed, part, state, value); + if (machine) printf("TEXT-ALIGN-X: %g\nTEXT-ALIGN-Y: %g\n", dx, dy); + else if (FDIFF(dx, 0.5) || FDIFF(dy, 0.5)) + printf(INDENT5 "align: %g %g;\n", dx, dy); + + x = edje_edit_state_text_fit_x_get(ed, part, state, value); + y = edje_edit_state_text_fit_y_get(ed, part, state, value); + if (machine) printf("TEXT-FIT-X: %d\nTEXT-FIT-Y: %d\n", x, y); + else if ((x) || (y)) printf(INDENT5 "fit: %d %d;\n", x, y); + + dx = edje_edit_state_text_elipsis_get(ed, part, state, value); + if (machine) printf("TEXT-ELIPSIS: %g\n", dx); + else if (FDIFF(dx, 0.5)) printf(INDENT5 "elipsis: %g;\n", dx); + + if (machine) puts("TEXT-END"); + else puts(INDENT4 "}"); + } + else if (t == EDJE_PART_TYPE_EXTERNAL) + { + const Eina_List *params, *l; + const Edje_External_Param *p; + + params = edje_edit_state_external_params_list_get + (ed, part, state, value); + + if (params) + { + if (machine) puts("PARAMS-BEGIN"); + else puts(INDENT4 "params {"); + + EINA_LIST_FOREACH(params, l, p) + switch (p->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + printf(INDENT5 "int: \"%s\" \"%d\";\n", p->name, p->i); + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + printf(INDENT5 "double: \"%s\" \"%g\";\n", p->name, p->d); + break; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + if (p->s) + printf(INDENT5 "string: \"%s\" \"%s\";\n", + p->name, p->s); + break; + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + printf(INDENT5 "bool: \"%s\" \"%d\";\n", p->name, p->i); + break; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + if (p->s) + printf(INDENT5 "choice: \"%s\" \"%s\";\n", + p->name, p->s); + break; + default: + break; + } + + if (machine) puts("PARAMS-END"); + else puts(INDENT4 "}"); + } + } +} + +static void +state_end(void) +{ + if (machine) puts("PART-STATE-END"); + else if (detail > 0) puts(INDENT3 "}"); + else puts(" }"); +} + +static void +part_begin(Evas_Object *ed, const char *name) +{ + const char *type = part_type_name_get(edje_edit_part_type_get(ed, name)); + if (machine) printf("PART-BEGIN\nNAME: %s\nTYPE: %s\n", name, type); + else + { + printf(INDENT2 "part { name: '%s'; type: %s;", name, type); + if (detail > 0) putchar('\n'); + } +} + +static const char * +text_effect_name_get(Edje_Text_Effect effect) +{ + switch (effect) + { + case EDJE_TEXT_EFFECT_NONE: + return "NONE"; + case EDJE_TEXT_EFFECT_PLAIN: + return "PLAIN"; + case EDJE_TEXT_EFFECT_OUTLINE: + return "OUTLINE"; + case EDJE_TEXT_EFFECT_SOFT_OUTLINE: + return "SOFT_OUTLINE"; + case EDJE_TEXT_EFFECT_SHADOW: + return "SHADOW"; + case EDJE_TEXT_EFFECT_SOFT_SHADOW: + return "SOFT_SHADOW"; + case EDJE_TEXT_EFFECT_OUTLINE_SHADOW: + return "OUTLINE_SHADOW"; + case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW: + return "OUTLINE_SOFT_SHADOW"; + case EDJE_TEXT_EFFECT_FAR_SHADOW: + return "FAR_SHADOW"; + case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW: + return "FAR_SOFT_SHADOW"; + case EDJE_TEXT_EFFECT_GLOW: + return "GLOW"; + + case EDJE_TEXT_EFFECT_LAST: + ERR("Invalid part type %d", effect); + return "???"; + default: + ERR("Unknown effect type %d", effect); + return "???"; + } +} + +static inline Eina_Bool +_c_id_allowed(char c) +{ + if ((c >= '0') && (c <= '9')) return EINA_TRUE; + if ((c >= 'a') && (c <= 'z')) return EINA_TRUE; + if ((c >= 'A') && (c <= 'Z')) return EINA_TRUE; + return EINA_FALSE; +} + +static char * +_api_name_fix(const char *orig) +{ + char *d, *d_end, buf[256]; + const char *s; + + if (!orig) return NULL; + if (!api_fix) return strdup(orig); + + s = orig; + d = buf; + d_end = d + sizeof(buf) - 1; + for (; (*s != '\0') && (d < d_end); s++, d++) + if (_c_id_allowed(*s)) *d = *s; + else *d = '_'; + *d = '\0'; + + return strdup(buf); +} + +static char * +_part_api_name_get(Evas_Object *ed, const char *part) +{ + const char *orig = edje_edit_part_api_name_get(ed, part); + char *fix = _api_name_fix(orig); + edje_edit_string_free(orig); + return fix; +} + +static void +part_details(Evas_Object *ed, const char *part) +{ + Eina_List *states, *l; + Eina_Bool b; + const char *str, *str2; + char *api; + + if (detail < 1) return; + + if (machine) puts("PART-DETAILS-BEGIN"); + + str = api =_part_api_name_get(ed, part); + str2 = edje_edit_part_api_description_get(ed, part); + if (machine) + { + printf("API-NAME: %s\n", str ? str : ""); + printf("API-DESCRIPTION: %s\n", str2 ? str2 : ""); + } + else if ((str) || (str2)) + printf(INDENT3 "api: \"%s\" \"%s\";\n", str ? str : "", str2 ? str2 : ""); + free(api); + edje_edit_string_free(str2); + + b = edje_edit_part_mouse_events_get(ed, part); + if (machine) printf("MOUSE_EVENTS: %d\n", b); + else if (!b) puts(INDENT3 "mouse_events: 0;"); + + if (detail > 1) + { + b = edje_edit_part_repeat_events_get(ed, part); + if (machine) printf("REPEAT_EVENTS: %d\n", b); + else if (b) puts(INDENT3 "repeat_events: 1;"); + + b = edje_edit_part_scale_get(ed, part); + if (machine) printf("SCALE: %d\n", b); + else if (b) puts(INDENT3 "scale: 1;"); + } + + str = edje_edit_part_clip_to_get(ed, part); + if (machine) printf("CLIP_TO: %s\n", str ? str : ""); + else if (str) printf(INDENT3 "clip_to: \"%s\";\n", str); + edje_edit_string_free(str); + + str = edje_edit_part_source_get(ed, part); + if (machine) printf("SOURCE: %s\n", str ? str : ""); + else if (str) printf(INDENT3 "source: \"%s\";\n", str); + edje_edit_string_free(str); + + if (detail > 1) + { + if (edje_edit_part_type_get(ed, part) == EDJE_PART_TYPE_TEXT) + { + str = text_effect_name_get(edje_edit_part_effect_get(ed, part)); + if (machine) printf("EFFECT: %s\n", str ? str : ""); + else if (str) printf(INDENT3 "effect: %s;\n", str); + /* do not free this str! */ + } + + if (edje_edit_part_drag_x_get(ed, part) || + edje_edit_part_drag_y_get(ed, part)) + { + int dir, step, count; + + if (machine) puts("DRAGABLE-BEGIN"); + else puts(INDENT3 "dragable {"); + + dir = edje_edit_part_drag_x_get(ed, part); + step = edje_edit_part_drag_step_x_get(ed, part); + count = edje_edit_part_drag_count_x_get(ed, part); + if (machine) printf("DRAG-X: %d %d %d\n", dir, step, count); + else printf(INDENT4 "x: %d %d %d;\n", dir, step, count); + + dir = edje_edit_part_drag_y_get(ed, part); + step = edje_edit_part_drag_step_y_get(ed, part); + count = edje_edit_part_drag_count_y_get(ed, part); + if (machine) printf("DRAG-Y: %d %d %d\n", dir, step, count); + else printf(INDENT4 "y: %d %d %d;\n", dir, step, count); + + str = edje_edit_part_drag_confine_get(ed, part); + if (machine) printf("DRAG-CONFINE: %s\n", str ? str : ""); + else if (str) printf(INDENT4 "confine: \"%s\";\n", str); + edje_edit_string_free(str); + + str = edje_edit_part_drag_event_get(ed, part); + if (machine) printf("DRAG-EVENTS: %s\n", str ? str : ""); + else if (str) printf(INDENT4 "events: \"%s\";\n", str); + edje_edit_string_free(str); + + if (machine) puts("DRAGABLE-END"); + else puts(INDENT3 "}"); + } + } + + states = edje_edit_part_states_list_get(ed, part); + EINA_LIST_FOREACH(states, l, str) + { + char state[512], *delim; + double value; + eina_strlcpy(state, str, sizeof(state)); /* bad states_list! :-( */ + delim = strchr(state, ' '); + *delim = '\0'; + delim++; + value = strtod(delim, NULL); + state_begin(state, value); + state_details(ed, part, state, value); + state_end(); + } + edje_edit_string_list_free(states); + + if (machine) puts("PART-DETAILS-END"); +} + +static void +part_end(void) +{ + if (machine) puts("PART-END"); + else if (detail > 0) puts(INDENT2 "}"); + else puts(" }"); +} + +static int +_groups_names_list(void) +{ + Eina_List *l; + const char *name; + Eina_Bool found = EINA_FALSE; + + EINA_LIST_FOREACH(groups, l, name) + { + if (!matches(name, group)) + { + DBG("filter out group '%s': does not match '%s'", name, group); + continue; + } + found = EINA_TRUE; + puts(name); + } + + if (!found) WRN("no groups match '%s'", group); + return !found; +} + +static int +_parts_names_list(void) +{ + Eina_List *gl, *pl, *parts; + const char *gname, *pname; + Eina_Bool found_group = EINA_FALSE, found_part = EINA_FALSE; + + EINA_LIST_FOREACH(groups, gl, gname) + { + Evas_Object *ed; + + if (!matches(gname, group)) + { + DBG("filter out group '%s': does not match '%s'", gname, group); + continue; + } + + ed = edje_edit_object_add(ecore_evas_get(ee)); + if (!edje_object_file_set(ed, file, gname)) + { + Edje_Load_Error err = edje_object_load_error_get(ed); + const char *errmsg = edje_load_error_str(err); + ERR("could not load group '%s' from file '%s': %s", + gname, file, errmsg); + evas_object_del(ed); + continue; + } + + found_group = EINA_TRUE; + group_begin(gname); + + parts = edje_edit_parts_list_get(ed); + EINA_LIST_FOREACH(parts, pl, pname) + { + if (!matches(pname, part)) + { + DBG("filter out part '%s': does not match '%s'", pname, part); + continue; + } + if (api_only) + { + if (!edje_edit_part_api_name_get(ed, pname)) + { + DBG("filter out part '%s': not API.", pname); + continue; + } + } + if (machine) printf("PART: %s\n", pname); + else printf(INDENT "part: %s\n", pname); + } + edje_edit_string_list_free(parts); + + group_end(); + evas_object_del(ed); + } + + if (!found_group) WRN("no groups match '%s'", group); + if (!found_part) WRN("no parts match '%s'", part); + return (!found_group) || (!found_part); +} + +static Eina_Bool +_group_parts_list(Evas_Object *ed) +{ + Eina_Bool found = EINA_FALSE; + Eina_List *parts, *l; + const char *name; + + parts_begin(); + + parts = edje_edit_parts_list_get(ed); + EINA_LIST_FOREACH(parts, l, name) + { + if (!matches(name, part)) + { + DBG("filter out part '%s': does not match '%s'", name, part); + continue; + } + if (api_only) + { + if (!edje_edit_part_api_name_get(ed, name)) + { + DBG("filter out part '%s': not API.", name); + continue; + } + } + + found = EINA_TRUE; + part_begin(ed, name); + part_details(ed, name); + part_end(); + } + + parts_end(); + return found; +} + +static void +programs_begin(void) +{ + if (machine) puts("PROGRAMS-BEGIN"); + else puts(INDENT "programs {"); +} + +static void +programs_end(void) +{ + if (machine) puts("PROGRAMS-END"); + else puts(INDENT "}"); +} + +static void +program_begin(const char *name) +{ + if (machine) printf("PROGRAM-BEGIN\nNAME: %s\n", name ? name : ""); + else + { + printf(INDENT2 "program { name: '%s';\n", name ? name : ""); + } +} + +static void +program_end(void) +{ + if (machine) puts("PROGRAM-END"); + else puts(INDENT2 "}"); +} + + +static char * +_program_api_name_get(Evas_Object *ed, const char *program) +{ + const char *orig = edje_edit_program_api_name_get(ed, program); + char *fix = _api_name_fix(orig); + edje_edit_string_free(orig); + return fix; +} + +static const char * +_transition_name_get(Edje_Tween_Mode mode) +{ + switch (mode) + { + case EDJE_TWEEN_MODE_LINEAR: return "LINEAR"; + case EDJE_TWEEN_MODE_ACCELERATE: return "ACCELERATE"; + case EDJE_TWEEN_MODE_DECELERATE: return "DECELERATE"; + case EDJE_TWEEN_MODE_SINUSOIDAL: return "SINUSOIDAL"; + default: + ERR("Unknown transition mode %d", mode); + return "???"; + } +} + +static void +program_details(Evas_Object *ed, const char *program) +{ + const char *str, *str2; + char *api; + + if (detail < 1) return; + + if (machine) puts("PROGRAM-DETAILS-BEGIN"); + + str = api =_program_api_name_get(ed, program); + str2 = edje_edit_program_api_description_get(ed, program); + if (machine) + { + printf("API-NAME: %s\n", str ? str : ""); + printf("API-DESCRIPTION: %s\n", str2 ? str2 : ""); + } + else if ((str) || (str2)) + printf(INDENT3 "api: \"%s\" \"%s\";\n", str ? str : "", str2 ? str2 : ""); + free(api); + edje_edit_string_free(str2); + + str = edje_edit_program_signal_get(ed, program); + if (machine) printf("SIGNAL: %s\n", str ? str : ""); + else if (str) printf(INDENT3 "signal: \"%s\";\n", str); + edje_edit_string_free(str); + + str = edje_edit_program_source_get(ed, program); + if (machine) printf("SOURCE: %s\n", str ? str : ""); + else if (str) printf(INDENT3 "source: \"%s\";\n", str); + edje_edit_string_free(str); + + if (detail >= 1) + { + Eina_List *lst, *l; + Edje_Action_Type type = edje_edit_program_action_get(ed, program); + switch (type) + { + case EDJE_ACTION_TYPE_ACTION_STOP: + if (machine) puts("ACTION: ACTION_STOP"); + else puts(INDENT3 "action: ACTION_STOP;"); + break; + case EDJE_ACTION_TYPE_STATE_SET: + str = edje_edit_program_state_get(ed, program); + if (machine) + printf("ACTION: STATE_SET\nACTION-STATE: %s %g\n", + str, edje_edit_program_value_get(ed, program)); + else + printf(INDENT3 "action: STATE_SET \"%s\" %2.1f;\n", + str, edje_edit_program_value_get(ed, program)); + edje_edit_string_free(str); + break; + case EDJE_ACTION_TYPE_SIGNAL_EMIT: + str = edje_edit_program_state_get(ed, program); + str2 = edje_edit_program_state2_get(ed, program); + if (machine) + printf("ACTION: SIGNAL_EMIT\nACTION-SIGNAL: %s\n" + "ACTION-SOURCE: %s\n", + str ? str : "", str2 ? str2 : ""); + else if ((str) || (str2)) + printf(INDENT3 "action: SIGNAL_EMIT \"%s\" \"%s\";\n", + str ? str : "", str2 ? str2 : ""); + edje_edit_string_free(str); + edje_edit_string_free(str2); + break; + //TODO Support Drag + //~ case EDJE_ACTION_TYPE_DRAG_VAL_SET: + //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_SET TODO;\n"); + //~ break; + //~ case EDJE_ACTION_TYPE_DRAG_VAL_STEP: + //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_STEP TODO;\n"); + //~ break; + //~ case EDJE_ACTION_TYPE_DRAG_VAL_PAGE: + //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_PAGE TODO;\n"); + //~ break; + default: + ERR("Unhandled program action type %d", type); + break; + } + + if (detail > 1) + { + double from, range; + + from = edje_edit_program_transition_time_get(ed, program); + if (from > 0.0) + { + str = _transition_name_get + (edje_edit_program_transition_get(ed, program)); + if (machine) + printf("TRANSITION-NAME: %s\nTRANSITION-DURATION: %g\n", + str, from); + else printf(INDENT3 "transition: %s %g;\n", str, from); + /* do not free str! */ + } + + from = edje_edit_program_in_from_get(ed, program); + range = edje_edit_program_in_range_get(ed, program); + if (FDIFF(from, 0.0) || FDIFF(range, 0.0)) + { + if (machine) + printf("IN-FROM: %g\nIN-RANGE: %g\n", from, range); + else printf(INDENT3 "in: %g %g;\n", from, range); + } + } + + lst = edje_edit_program_targets_get(ed, program); + EINA_LIST_FOREACH(lst, l, str) + if (machine) printf("TARGET: %s\n", str); + else printf(INDENT3 "target: \"%s\";\n", str); + edje_edit_string_list_free(lst); + + lst = edje_edit_program_afters_get(ed, program); + EINA_LIST_FOREACH(lst, l, str) + if (machine) printf("AFTER: %s\n", str); + else printf(INDENT3 "after: \"%s\";\n", str); + edje_edit_string_list_free(lst); + + // TODO Support script {} + } + + if (machine) puts("PROGRAM-DETAILS-END"); +} + +static Eina_Bool +_group_programs_list(Evas_Object *ed) +{ + Eina_Bool found = EINA_FALSE; + Eina_List *programs, *l; + const char *name; + + programs_begin(); + + /* TODO: change programs to operate on their ID instead of names! + * needs huge change in Edje_Edit.h + */ + WRN("listing only programs with names!"); + programs = edje_edit_programs_list_get(ed); + EINA_LIST_FOREACH(programs, l, name) + { + if (!matches(name, program)) + { + DBG("filter out program '%s': does not match '%s'", name, program); + continue; + } + if (api_only) + { + if (!edje_edit_program_api_name_get(ed, name)) + { + DBG("filter out program '%s': not API.", name); + continue; + } + } + + found = EINA_TRUE; + program_begin(name); + program_details(ed, name); + program_end(); + } + + programs_end(); + return found; +} + +static int +_list(const char *mode) +{ + Eina_List *l; + const char *name; + int ret = 0; + Eina_Bool found_group = EINA_FALSE; + Eina_Bool req_part, found_part, req_prog, found_prog; + + if ((!strcmp(mode, "parts")) || (!strcmp(mode, "groups"))) + { + req_part = EINA_TRUE; + found_part = EINA_FALSE; + } + else + { + req_part = EINA_FALSE; + found_part = EINA_TRUE; + } + + if ((!strcmp(mode, "programs")) || (!strcmp(mode, "groups"))) + { + req_prog = EINA_TRUE; + found_prog = EINA_FALSE; + } + else + { + req_prog = EINA_FALSE; + found_prog = EINA_TRUE; + } + + EINA_LIST_FOREACH(groups, l, name) + { + Evas_Object *ed; + + if (!matches(name, group)) + { + DBG("filter out group '%s': does not match '%s'", name, group); + continue; + } + + ed = edje_edit_object_add(ecore_evas_get(ee)); + if (!edje_object_file_set(ed, file, name)) + { + Edje_Load_Error err = edje_object_load_error_get(ed); + const char *errmsg = edje_load_error_str(err); + ERR("could not load group '%s' from file '%s': %s", + name, file, errmsg); + evas_object_del(ed); + continue; + } + + found_group = EINA_TRUE; + group_begin(name); + group_details(ed); + + if (req_part) found_part |= _group_parts_list(ed); + if (req_prog) found_prog |= _group_programs_list(ed); + + group_end(); + evas_object_del(ed); + } + + /* no hard requirement for parts or programs for group listing */ + if (!strcmp(mode, "groups")) req_part = req_prog = EINA_FALSE; + + if (!found_group) + { + WRN("no groups match '%s'", group); + ret = 1; + } + if ((req_part) && (!found_part)) + { + WRN("no parts match '%s'", part); + ret = 1; + } + if ((req_prog) && (!found_prog)) + { + WRN("no programs match '%s'", program); + ret = 1; + } + return ret; +} + +static Evas_Object * +_edje_object_any_get(void) +{ + Evas_Object *ed = edje_edit_object_add(ecore_evas_get(ee)); + Eina_List *l; + const char *name; + if (!ed) return NULL; + EINA_LIST_FOREACH(groups, l, name) + if (edje_object_file_set(ed, file, name)) return ed; + evas_object_del(ed); + return NULL; +} + +static Eina_Bool +_gdata_list(void) +{ + Evas_Object *ed = _edje_object_any_get(); + Eina_List *l, *data; + const char *key; + + if (!ed) return EINA_FALSE; + + data = edje_edit_data_list_get(ed); + + if (machine) puts("DATA-BEGIN"); + else puts("data {"); + + EINA_LIST_FOREACH(data, l, key) + { + const char *value = edje_edit_data_value_get(ed, key); + if (machine) printf("ITEM: \"%s\" \"%s\"\n", key, value); + else printf(INDENT "item: \"%s\" \"%s\";\n", key, value); + } + + if (machine) puts("DATA-END"); + else puts("}"); + + edje_edit_string_list_free(data); + evas_object_del(ed); + return EINA_TRUE; +} + +static const char * +_comp_str_get(Evas_Object *ed, const char *img) +{ + static char buf[128]; + Edje_Edit_Image_Comp type = edje_edit_image_compression_type_get(ed, img); + int rate; + + switch (type) + { + case EDJE_EDIT_IMAGE_COMP_RAW: + return "RAW"; + case EDJE_EDIT_IMAGE_COMP_USER: + return "USER"; + case EDJE_EDIT_IMAGE_COMP_COMP: + return "COMP"; + case EDJE_EDIT_IMAGE_COMP_LOSSY: + rate = edje_edit_image_compression_rate_get(ed, img); + snprintf(buf, sizeof(buf), "LOSSY %d", rate); + return buf; + default: + ERR("Unknown compression type %d", type); + return "???"; + } +} + +static Eina_Bool +_images_list(void) +{ + Evas_Object *ed = _edje_object_any_get(); + Eina_List *l, *images; + const char *img; + + if (!ed) return EINA_FALSE; + + images = edje_edit_images_list_get(ed); + + if (machine) puts("IMAGES-BEGIN"); + else puts("images {"); + + EINA_LIST_FOREACH(images, l, img) + { + int id = edje_edit_image_id_get(ed, img); + const char *comp = _comp_str_get(ed, img); + + if (detail < 1) + { + if (machine) printf("IMAGE: %s\n", img); + else printf(INDENT "image: \"%s\" %s;\n", img, comp); + } + else if (detail == 1) + { + if (machine) printf("IMAGE: \"%s\" \"%s\"\n", img, comp); + else printf(INDENT "image: \"%s\" %s;\n", img, comp); + } + else + { + if (machine) + printf("IMAGE: \"edje/images/%d\" \"%s\" \"%s\"\n", + id, img, comp); + else + printf(INDENT "image: \"%s\" %s; /* id: \"edje/images/%d\" */\n", + img, comp, id); + } + } + + if (machine) puts("IMAGES-END"); + else puts("}"); + + edje_edit_string_list_free(images); + evas_object_del(ed); + return EINA_TRUE; +} + +static Eina_Bool +_fonts_list(void) +{ + Evas_Object *ed = _edje_object_any_get(); + Eina_List *l, *fonts; + const char *alias; + + if (!ed) return EINA_FALSE; + + fonts = edje_edit_fonts_list_get(ed); + + if (machine) puts("FONTS-BEGIN"); + else puts("fonts {"); + + EINA_LIST_FOREACH(fonts, l, alias) + { + const char *path = edje_edit_font_path_get(ed, alias); + + if (detail < 1) + { + if (machine) printf("FONT: %s\n", alias); + else printf(INDENT "font: \"%s\" \"%s\";\n", path, alias); + } + else if (detail == 1) + { + if (machine) printf("FONT: \"%s\" \"%s\"\n", path, alias); + else printf(INDENT "font: \"%s\" \"%s\";\n", path, alias); + } + else + { + if (machine) + printf("FONT: \"edje/fonts/%s\" \"%s\" \"%s\"\n", + alias, path, alias); + else + printf(INDENT + "font: \"%s\" \"%s\"; /* id: \"edje/fonts/%s\" */\n", + path, alias, alias); + } + + edje_edit_string_free(path); + } + + if (machine) puts("FONTS-END"); + else puts("}"); + + edje_edit_string_list_free(fonts); + evas_object_del(ed); + return EINA_TRUE; +} + +static Eina_Bool +_externals_list(void) +{ + Evas_Object *ed = _edje_object_any_get(); + Eina_List *l, *externals; + const char *key; + + if (!ed) return EINA_FALSE; + + externals = edje_edit_externals_list_get(ed); + + if (machine) puts("EXTERNALS-BEGIN"); + else puts("externals {"); + + EINA_LIST_FOREACH(externals, l, key) + { + if (machine) printf("EXTERNAL: %s\n", key); + else printf(INDENT "external: \"%s\";\n", key); + } + + if (machine) puts("EXTERNALS-END"); + else puts("}"); + + edje_edit_string_list_free(externals); + evas_object_del(ed); + return EINA_TRUE; +} + + +int +main(int argc, char **argv) +{ + Eina_Bool quit_option = EINA_FALSE; + char *mode = NULL; + char *detail_name = NULL; + int arg_index; + int ret = 0; + Ecore_Getopt_Value values[] = { + ECORE_GETOPT_VALUE_STR(mode), + ECORE_GETOPT_VALUE_STR(detail_name), + ECORE_GETOPT_VALUE_STR(group), + ECORE_GETOPT_VALUE_STR(part), + ECORE_GETOPT_VALUE_STR(program), + ECORE_GETOPT_VALUE_BOOL(api_only), + ECORE_GETOPT_VALUE_BOOL(api_fix), + ECORE_GETOPT_VALUE_BOOL(machine), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_NONE + }; + + setlocale(LC_NUMERIC, "C"); + + ecore_init(); + ecore_evas_init(); + eina_init(); + edje_init(); + + _log_dom = eina_log_domain_register("edje_inspector", EINA_COLOR_YELLOW); + if (_log_dom < 0) + { + EINA_LOG_CRIT("could not register log domain 'edje_inspector'"); + ret = 1; + goto error_log; + } + + arg_index = ecore_getopt_parse(&optdesc, values, argc, argv); + if (arg_index < 0) + { + ERR("could not parse arguments."); + ret = 1; + goto error_getopt; + } + else if (quit_option) goto error_getopt; + else if (arg_index != argc - 1) + { + ERR("incorrect number of parameters. Requires one single file."); + ret = 1; + goto error_getopt; + } + + if (!mode) mode = (char *)mode_choices[0]; + + if (detail_name) + { + if (!strcmp(detail_name, "none")) detail = 0; + else if (!strcmp(detail_name, "terse")) detail = 1; + else if (!strcmp(detail_name, "all")) detail = 2; + else ERR("Unknown detail level: '%s'", detail_name); + } + + file = argv[arg_index]; + + // check if the file is accessible + if (access(file, R_OK) == -1) + { + int e = errno; + ERR("File '%s' not accessible, error %d (%s).\n", + file, e, strerror(e)); + ret = 1; + goto error_getopt; + } + + DBG("mode=%s, detail=%d(%s), group=%s, part=%s, program=%s, api-only=" FMT_UCHAR + ", api-fix=" FMT_UCHAR ", machine=" FMT_UCHAR ", file=%s", + mode, detail, detail_name, + group ? group : "", + part ? part : "", + program ? program : "", + api_only, api_fix, machine, file); + + + groups = edje_file_collection_list(file); + if (!groups) + { + ERR("no groups in edje file '%s'", file); + ret = 1; + goto error_getopt; + } + + if (!strcmp(mode, "groups-names")) ret = _groups_names_list(); + else + { + ee = ecore_evas_buffer_new(1, 1); + if (!ee) + { + ERR("could not create ecore_evas_buffer"); + ret = 1; + } + else + { + if (!strcmp(mode, "parts-names")) ret = _parts_names_list(); + else if (!strcmp(mode, "global-data")) ret = _gdata_list(); + else if (!strcmp(mode, "images")) ret = _images_list(); + else if (!strcmp(mode, "fonts")) ret = _fonts_list(); + else if (!strcmp(mode, "externals")) ret = _externals_list(); + else ret = _list(mode); + ecore_evas_free(ee); + } + } + + edje_file_collection_list_free(groups); + error_getopt: + eina_log_domain_unregister(_log_dom); + error_log: + edje_shutdown(); + ecore_evas_shutdown(); + ecore_shutdown(); + eina_shutdown(); + + return ret; +} 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 @@ +#include "edje_multisense_convert.h" + +#ifdef HAVE_LIBSNDFILE +# define READBUF 1024 +# ifdef HAVE_VORBIS +# include +# endif + +# ifdef HAVE_LIBFLAC +# include +# include +# endif + +Edje_Sound_Encode * +_edje_multisense_encode(const char *filename, Edje_Sound_Sample *sample, double quality) +{ + SF_INFO sfinfo; + SNDFILE* sfile; + Edje_Sound_Encode *enc_info; + + enc_info = calloc(1, sizeof(Edje_Sound_Encode)); + if (!enc_info) + { + ERR("Error. while allocating memory to load file "); + exit(-1); + } + memset (&sfinfo, 0, sizeof (SF_INFO)); + + enc_info->encoded = EINA_FALSE; + enc_info->comp_type = "RAW PCM"; + + // Open wav file using sndfile + sfile = sf_open (filename, SFM_READ, &sfinfo); + if (!sfile) + { + ERR("Error. Unable to open audio file : %s", filename); + exit(-1); + } + + if (!sf_format_check(&sfinfo)) + { + ERR("Error. Unknown file, not a valid audio file"); + exit(-1); + } + + if (sample->compression == EDJE_SOUND_SOURCE_TYPE_INLINE_COMP) + { + sf_close(sfile); +#ifdef HAVE_LIBFLAC + //encode provided wav file to flac + enc_info->file = _edje_multisense_encode_to_flac((char *)filename, sfinfo); + if (enc_info->file) + { + enc_info->comp_type = "FLAC"; + enc_info->encoded = EINA_TRUE; + } +#else + WRN("WARNING: Unable to encode sound %s to FLAC compression", + sample->name); +#endif + } + else if (sample->compression == EDJE_SOUND_SOURCE_TYPE_INLINE_LOSSY) + { + sf_close(sfile); +#ifdef HAVE_VORBIS + //encode provided wav file to ogg-vorbis + enc_info->file = _edje_multisense_encode_to_ogg_vorbis((char *)filename, + quality, sfinfo); + if (enc_info->file) + { + enc_info->comp_type = "OGG-VORBIS"; + enc_info->encoded = EINA_TRUE; + } +#else + WRN("WARNING: Unable to encode sound %s to Ogg-Vorbis", + sample->name); +#endif + } + else + eina_stringshare_replace(&enc_info->file, filename); + return enc_info; +} + +#ifdef HAVE_LIBFLAC +const char* +_edje_multisense_encode_to_flac(char *snd_path, SF_INFO sfinfo) +{ + unsigned int total_samples = 0; /* can use a 32-bit number due to WAVE size limitations */ + FLAC__bool ok = 1; + FLAC__StreamEncoder *encoder = 0; + FLAC__StreamEncoderInitStatus init_status; + FLAC__StreamMetadata *metadata[2]; + FLAC__StreamMetadata_VorbisComment_Entry entry; + SNDFILE *sfile; + sf_count_t size; + char *tmp; + + sfile = sf_open(snd_path, SFM_READ, &sfinfo); + if (!sfile) return NULL; + if (!sf_format_check(&sfinfo)) + { + sf_close(sfile); + return NULL; + } + size = sf_seek(sfile, 0, SEEK_END); + sf_seek(sfile, 0, SEEK_SET); + tmp = malloc(strlen(snd_path) + 1 + 5); + if (!tmp) + { + sf_close(sfile); + return NULL; + } + strcpy(tmp, snd_path); + snd_path = tmp; + strcat(snd_path, ".flac"); + + total_samples = size; + + /* allocate the encoder */ + if ((encoder = FLAC__stream_encoder_new()) == NULL) + { + ERR("ERROR: Creating FLAC encoder\n"); + free(snd_path); + sf_close(sfile); + return NULL; + } + + /* Verify it's own encoded output. This will slow the encoding process. */ + ok &= FLAC__stream_encoder_set_verify(encoder, 1); + + //Levels range from 0 (fastest, least compression) to 8 (slowest, most compression). + //A value larger than 8 will be treated as 8. + //5 is used for good compression and moderate compression/decompression speed. + ok &= FLAC__stream_encoder_set_compression_level(encoder, 5); + ok &= FLAC__stream_encoder_set_channels(encoder, sfinfo.channels); + ok &= FLAC__stream_encoder_set_bits_per_sample(encoder, 16); + ok &= FLAC__stream_encoder_set_sample_rate(encoder, sfinfo.samplerate); + ok &= FLAC__stream_encoder_set_total_samples_estimate(encoder, total_samples); + + /* now add some metadata; we'll add some tags and a padding block */ + if (ok) + { + if ((metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) == NULL + || (metadata[1] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == NULL + || !FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "Encoder", "flac") + || !FLAC__metadata_object_vorbiscomment_append_comment(metadata[0], entry, 0)) + { + ERR("ERROR: out of memory error or tag error\n"); + ok = 0; + } + metadata[1]->length = 16; /* set the padding length */ + ok = FLAC__stream_encoder_set_metadata(encoder, metadata, 2); + } + + /* initialize encoder */ + if (ok) + { + init_status = FLAC__stream_encoder_init_file(encoder, snd_path, NULL, + (void *)(long)(total_samples)); + if (init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) + { + ERR("ERROR: unable to initialize FLAC encoder: %s\n", + FLAC__StreamEncoderInitStatusString[init_status]); + ok = 0; + } + } + + /* read blocks of samples from WAVE file and feed to encoder */ + while (ok) + { + FLAC__int32 readbuffer[READBUF * 2]; + sf_count_t count; + int i; + + count = sf_readf_int(sfile, readbuffer, READBUF); + if (count <= 0) break; + for (i = 0; i < (count * sfinfo.channels); i++) + readbuffer[i] = readbuffer[i] >> 16; + ok = FLAC__stream_encoder_process_interleaved(encoder, readbuffer, + count); + } + + FLAC__stream_encoder_finish(encoder); + /* now that encoding is finished, the metadata can be freed */ + FLAC__metadata_object_delete(metadata[0]); + FLAC__metadata_object_delete(metadata[1]); + + FLAC__stream_encoder_delete(encoder); + sf_close(sfile); + return (snd_path); +} +#endif + +#ifdef HAVE_VORBIS +const char * +_edje_multisense_encode_to_ogg_vorbis(char *snd_path, double quality, SF_INFO sfinfo) +{ + ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */ + ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ + ogg_packet op; /* one raw packet of data for decode */ + vorbis_info vi; /* struct that stores all the static vorbis bitstream settings */ + vorbis_comment vc; /* struct that stores all the user comments */ + vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ + vorbis_block vb; /* local working space for packet->PCM decode */ + int eos = 0, ret; + char *tmp; + SNDFILE *sfile; + FILE *fout; + + sfile = sf_open(snd_path, SFM_READ, &sfinfo); + if (!sfile) return NULL; + if (!sf_format_check(&sfinfo)) + { + sf_close(sfile); + return NULL; + } + tmp = malloc(strlen(snd_path) + 1 + 4); + if (!tmp) + { + sf_close(sfile); + return NULL; + } + strcpy(tmp, snd_path); + snd_path = tmp; + strcat(snd_path, ".ogg"); + fout = fopen(snd_path, "wb"); + if (!fout) + { + free(snd_path); + sf_close(sfile); + return NULL; + } + + /********** Encode setup ************/ + vorbis_info_init(&vi); + ret = vorbis_encode_init(&vi, sfinfo.channels, sfinfo.samplerate, + -1, (long)(quality * 1000), -1); + if (ret == OV_EFAULT) printf("OV_EFAULT\n"); + if (ret == OV_EINVAL) printf("OV_EINVAL\n"); + if (ret == OV_EIMPL) printf("OV_EIMPL\n"); + + if (ret) + { + fclose(fout); + free(snd_path); + sf_close(sfile); + return NULL; + } + + /* add a comment */ + vorbis_comment_init(&vc); + vorbis_comment_add_tag(&vc, "", ""); + + /* set up the analysis state and auxiliary encoding storage */ + vorbis_analysis_init(&vd, &vi); + vorbis_block_init(&vd, &vb); + + srand(time(NULL)); + ogg_stream_init(&os, rand()); + + ogg_packet header; + ogg_packet header_comm; + ogg_packet header_code; + + vorbis_analysis_headerout(&vd, &vc, &header, &header_comm, &header_code); + ogg_stream_packetin(&os, &header); /* automatically placed in its own page */ + ogg_stream_packetin(&os, &header_comm); + ogg_stream_packetin(&os, &header_code); + + while (!eos) + { + int result = ogg_stream_flush(&os, &og); + if (!result) break; + fwrite(og.header, 1, og.header_len, fout); + fwrite(og.body, 1, og.body_len, fout); + } + + while (!eos) + { + int i, ch; + float readbuffer[READBUF * 2]; + sf_count_t count; + + count = sf_readf_float(sfile, readbuffer, READBUF); + + if (!count) + vorbis_analysis_wrote(&vd, 0); + else + { + float **buffer = vorbis_analysis_buffer(&vd, count); + + /* uninterleave samples */ + for (i = 0; i < count; i++) + { + for (ch = 0; ch < sfinfo.channels; ch++) + buffer[ch][i]= readbuffer[(i * sfinfo.channels) + ch]; + } + vorbis_analysis_wrote(&vd, i); + } + while (vorbis_analysis_blockout(&vd, &vb) == 1) + { + vorbis_analysis(&vb, NULL); + vorbis_bitrate_addblock(&vb); + + while (vorbis_bitrate_flushpacket(&vd, &op)) + { + ogg_stream_packetin(&os, &op); + while (!eos) + { + int result = ogg_stream_pageout(&os, &og); + if (!result) break; + fwrite(og.header, 1, og.header_len, fout); + fwrite(og.body, 1, og.body_len, fout); + if (ogg_page_eos(&og)) eos = 1; + } + } + } + } + ogg_stream_clear(&os); + vorbis_block_clear(&vb); + vorbis_dsp_clear(&vd); + vorbis_comment_clear(&vc); + vorbis_info_clear(&vi); + sf_close(sfile); + fclose (fout); + return snd_path; +} +#endif +#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 @@ +#ifndef EDJE_SND_CONVERT_H__ +# define EDJE_SND_CONVERT_H__ +#include "edje_private.h" + +#ifdef HAVE_LIBSNDFILE +#include + +#define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK) +#define SF_CODEC(x) ((x) & SF_FORMAT_SUBMASK) + +typedef struct _Edje_Sound_Encode Edje_Sound_Encode; + +struct _Edje_Sound_Encode /*Encoding information*/ +{ + const char *file; /* the encode sound file path */ + Eina_Bool encoded; /* True if encoding is successful else False */ + char *comp_type; /* either LOSSLESS (FLAC) or LOSSY (Ogg/Vorbis) Compression */ +}; + +Edje_Sound_Encode *_edje_multisense_encode(const char* filename, Edje_Sound_Sample *sample, double quality); +const char *_edje_multisense_encode_to_flac(char *snd_path, SF_INFO sfinfo); +const char *_edje_multisense_encode_to_ogg_vorbis(char *snd_path, double quality, SF_INFO sfinfo); + +#endif +#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 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_EVIL +# include +#endif + +#include +#include +#include +#include +#include + +#ifdef _WIN32 +# define FMT_UCHAR "%c" +#else +# define FMT_UCHAR "%hhu" +#endif + +struct opts { + char *file; + char *group; + Eina_Bool list_groups; + char *engine; + Eina_Rectangle size; + unsigned char color[3]; + Eina_Bool borderless; + Eina_Bool sticky; + Eina_Bool shaped; + Eina_Bool alpha; + Eina_Bool print; + Eina_Bool slave_mode; + double scale; + char *title; +}; + +static Ecore_Evas *win; + +static void +_win_title_set(const char *group, const char *file) +{ + char buf[1024]; + snprintf(buf, sizeof(buf), "Edje_Player - %s of %s", group, file); + ecore_evas_title_set(win, buf); +} + +static char * +_slave_mode_tok(char **p_arg) +{ + char *s, *e; + Eina_Bool is_quoted; + + if (!*p_arg) return NULL; + + s = *p_arg; + while (isspace(*s)) + s++; + + if (*s == '\0') + { + *p_arg = NULL; + return NULL; + } + else if (*s == '"') + { + is_quoted = EINA_TRUE; + s++; + *p_arg = s; + } + else + { + is_quoted = EINA_FALSE; + *p_arg = s; + } + + for (e = s; *e != '\0'; e++) + { + if ((!is_quoted) && (isspace(*e))) + break; + else if ((is_quoted) && (*e == '"')) + break; + } + + if (*e == '\0') return NULL; + + *e = '\0'; + return e + 1; +} + +static void +_slave_mode_signal(Evas_Object *edje, char *args) +{ + char *emission, *source; + + emission = args; + source = _slave_mode_tok(&emission); + _slave_mode_tok(&source); + + if ((!emission) || (!source)) + { + fputs("ERROR: Invalid command arguments.\n", stderr); + return; + } + + edje_object_signal_emit(edje, emission, source); +} + +static void +_slave_mode_info(Evas_Object *edje, char *args) +{ + _slave_mode_tok(&args); + + if (!args) + { + fputs("ERROR: Invalid command arguments.\n", stderr); + return; + } + + if (!edje_object_part_exists(edje, args)) + { + printf("INFO: \"%s\" does not exist.\n", args); + } + else + { + Evas_Coord x, y, w, h; + edje_object_part_geometry_get(edje, args, &x, &y, &w, &h); + printf("INFO: \"%s\" %d,%d,%d,%d\n", args, x, y, w, h); + } +} + +static void +_slave_mode_quit(Evas_Object *edje __UNUSED__, char *args __UNUSED__) +{ + puts("Bye!"); + ecore_main_loop_quit(); +} + +static void +_slave_mode_help(Evas_Object *edje __UNUSED__, char *args __UNUSED__) +{ + puts("Help:\n" + "One command per line, arguments separated by space. Strings may have " + "spaces if enclosed in quotes (\").\n" + "\n" + "\t [arguments]\n" + "\n" + "Available commands:\n" + "\tsignal \n" + "\t sends a signal to edje\n" + "\tinfo \n" + "\t Print part geometry: ,,,\n" + "\tquit\n" + "\t exit edje player.\n" + "\thelp\n" + "\t shows this message.\n"); + /* + * Extension ideas (are they useful?): + * - message: send a message + * - data: show data value + * - color_class: set color class values (maybe also list?) + * - text_class: set text class values (maybe also list?) + * - play_set: change play state + * - animation_set: change animation state + */ +} + +struct slave_cmd +{ + const char *cmd; + void (*func)(Evas_Object *edje, char *args); +} _slave_mode_commands[] = { + {"signal", _slave_mode_signal}, + {"info", _slave_mode_info}, + {"quit", _slave_mode_quit}, + {"help", _slave_mode_help}, + {NULL, NULL} +}; + +static Eina_Bool +_slave_mode(void *data, Ecore_Fd_Handler *fd_handler) +{ + Evas_Object *edje = data; + char buf[1024], *p; + const struct slave_cmd *itr; + size_t len; + + if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) + { + fputs("ERROR: error on stdin! Exit.\n", stderr); + ecore_main_loop_quit(); + return ECORE_CALLBACK_CANCEL; + } + if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) + return ECORE_CALLBACK_RENEW; + + if (!fgets(buf, sizeof(buf), stdin)) + { + fputs("ERROR: end of stdin! Exit.\n", stderr); + ecore_main_loop_quit(); + return ECORE_CALLBACK_CANCEL; + } + + len = strlen(buf); + if (len < 1) + { + fputs("ERROR: no input! Try: help\n", stderr); + return ECORE_CALLBACK_RENEW; + } + if (buf[len - 1] == '\n') + { + len--; + buf[len] = '\0'; + } + + p = strchr(buf, ' '); + if (p) + { + *p = '\0'; + p++; + + while (isspace(*p)) + p++; + if (*p == '\0') + p = NULL; + + if (p) + { + char *q = p + strlen(p) - 1; + while (isspace(*q)) + { + *q = '\0'; + q--; + } + } + } + + for (itr = _slave_mode_commands; itr->cmd; itr++) + { + if (strcmp(itr->cmd, buf) == 0) + { + itr->func(edje, p); + break; + } + } + + return ECORE_CALLBACK_RENEW; +} + +static void +_print_signal(void *data __UNUSED__, Evas_Object *o __UNUSED__, const char *emission, const char *source) +{ + printf("SIGNAL: \"%s\" \"%s\"\n", emission, source); +} + +static void +_print_message(void *data __UNUSED__, Evas_Object *edje __UNUSED__, Edje_Message_Type type, int id, void *msg) +{ + const char *typestr; + char buf[64]; + + switch (type) + { + case EDJE_MESSAGE_NONE: + typestr = "NONE"; + break; + case EDJE_MESSAGE_SIGNAL: + typestr = "SIGNAL"; + break; + case EDJE_MESSAGE_STRING: + typestr = "STRING"; + break; + case EDJE_MESSAGE_INT: + typestr = "INT"; + break; + case EDJE_MESSAGE_FLOAT: + typestr = "FLOAT"; + break; + case EDJE_MESSAGE_STRING_SET: + typestr = "STRING_SET"; + break; + case EDJE_MESSAGE_INT_SET: + typestr = "INT_SET"; + break; + case EDJE_MESSAGE_FLOAT_SET: + typestr = "FLOAT_SET"; + break; + case EDJE_MESSAGE_STRING_INT: + typestr = "STRING_INT"; + break; + case EDJE_MESSAGE_STRING_FLOAT: + typestr = "STRING_FLOAT"; + break; + case EDJE_MESSAGE_STRING_INT_SET: + typestr = "INT_SET"; + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + typestr = "FLOAT_SET"; + break; + default: + snprintf(buf, sizeof(buf), "UNKNOWN(%d)", type); + typestr = buf; + } + + printf("MESSAGE: type=%s, id=%d", typestr, id); + + switch (type) + { + case EDJE_MESSAGE_NONE: break; + case EDJE_MESSAGE_SIGNAL: break; + case EDJE_MESSAGE_STRING: + { + Edje_Message_String *m = msg; + printf(" \"%s\"", m->str); + } + break; + case EDJE_MESSAGE_INT: + { + Edje_Message_Int *m = msg; + printf(" %d", m->val); + } + break; + case EDJE_MESSAGE_FLOAT: + { + Edje_Message_Float *m = msg; + printf(" %f", m->val); + } + break; + case EDJE_MESSAGE_STRING_SET: + { + Edje_Message_String_Set *m = msg; + int i; + for (i = 0; i < m->count; i++) + printf(" \"%s\"", m->str[i]); + } + break; + case EDJE_MESSAGE_INT_SET: + { + Edje_Message_Int_Set *m = msg; + int i; + for (i = 0; i < m->count; i++) + printf(" %d", m->val[i]); + } + break; + case EDJE_MESSAGE_FLOAT_SET: + { + Edje_Message_Float_Set *m = msg; + int i; + for (i = 0; i < m->count; i++) + printf(" %f", m->val[i]); + } + break; + case EDJE_MESSAGE_STRING_INT: + { + Edje_Message_String_Int *m = msg; + printf(" \"%s\" %d", m->str, m->val); + } + break; + case EDJE_MESSAGE_STRING_FLOAT: + { + Edje_Message_String_Float *m = msg; + printf(" \"%s\" %f", m->str, m->val); + } + break; + case EDJE_MESSAGE_STRING_INT_SET: + { + Edje_Message_String_Int_Set *m = msg; + int i; + printf(" \"%s\"", m->str); + for (i = 0; i < m->count; i++) + printf(" %d", m->val[i]); + } + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + { + Edje_Message_String_Float_Set *m = msg; + int i; + printf(" \"%s\"", m->str); + for (i = 0; i < m->count; i++) + printf(" %f", m->val[i]); + } + break; + default: + break; + } + + putchar('\n'); +} + +static void +_reset_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *stack, void *event_info __UNUSED__) +{ + Evas_Coord minw, minh; + Evas_Object *edje = data; + + edje_object_size_min_get(edje, &minw, &minh); + if ((minw <= 0) && (minh <= 0)) + edje_object_size_min_calc(edje, &minw, &minh); + + evas_object_size_hint_min_set(stack, minw, minh); +} + +static void +_key_down(void *data, Evas *e __UNUSED__, Evas_Object *stack __UNUSED__, void *event_info) +{ + Evas_Event_Key_Down *ev = event_info; + struct opts *opts = data; + + if ((!strcmp(ev->keyname, "equal")) || + (!strcmp(ev->keyname, "plus"))) + opts->scale += 0.1; + else if ((!strcmp(ev->keyname, "minus")) || + (!strcmp(ev->keyname, "underscore"))) + opts->scale -= 0.1; + else if ((!strcmp(ev->keyname, "0"))) + opts->scale = 1.0; + if (opts->scale < 0.1) opts->scale = 0.1; + else if (opts->scale > 10.0) opts->scale = 1.0; + edje_scale_set(opts->scale); +} + +static Evas_Object * +_create_stack(Evas *evas, const struct opts *opts) +{ + Evas_Object *stack = evas_object_box_add(evas); + if (!stack) + { + fputs("ERROR: could not create object stack (box).\n", stderr); + return NULL; + } + evas_object_box_layout_set(stack, evas_object_box_layout_stack, NULL, NULL); + evas_object_resize(stack, opts->size.w, opts->size.h); + evas_object_size_hint_weight_set(stack, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(stack, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(stack); + return stack; +} + +static Evas_Object * +_create_bg(Evas *evas, const struct opts *opts) +{ + const unsigned char *color = opts->color; + Evas_Object *bg = evas_object_rectangle_add(evas); + if (!bg) + { + fputs("ERROR: could not create background.\n", stderr); + return NULL; + } + evas_object_resize(bg, opts->size.w, opts->size.h); + evas_object_color_set(bg, color[0], color[1], color[2], 255); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(bg); + return bg; +} + +static Eina_Bool +_edje_load_or_show_error(Evas_Object *edje, const char *file, const char *group) +{ + const char *errmsg; + int err; + + if (edje_object_file_set(edje, file, group)) + { + evas_object_focus_set(edje, EINA_TRUE); + return EINA_TRUE; + } + + err = edje_object_load_error_get(edje); + errmsg = edje_load_error_str(err); + fprintf(stderr, "ERROR: could not load edje file '%s', group '%s': %s\n", + file, group, errmsg); + return EINA_FALSE; +} + +static Evas_Object * +_create_edje(Evas *evas, const struct opts *opts) +{ + Evas_Coord minw, minh, maxw, maxh; + Evas_Object *edje = edje_object_add(evas); + if (!edje) + { + fputs("ERROR: could not create edje.\n", stderr); + return NULL; + } + + if (opts->group) + { + if (!_edje_load_or_show_error(edje, opts->file, opts->group)) + { + evas_object_del(edje); + return NULL; + } + if (!opts->title) _win_title_set(opts->group, opts->file); + } + else + { + if (edje_file_group_exists(opts->file, "main")) + { + if (!_edje_load_or_show_error(edje, opts->file, "main")) + { + evas_object_del(edje); + return NULL; + } + if (!opts->title) _win_title_set("main", opts->file); + } + else + { + Eina_List *groups = edje_file_collection_list(opts->file); + const char *group; + if (!groups) + { + fprintf(stderr, "ERROR: file '%s' has no groups!\n", + opts->file); + evas_object_del(edje); + return NULL; + } + group = groups->data; + if (!_edje_load_or_show_error(edje, opts->file, group)) + { + edje_file_collection_list_free(groups); + evas_object_del(edje); + return NULL; + } + if (!opts->title) _win_title_set(group, opts->file); + edje_file_collection_list_free(groups); + } + } + + edje_object_size_max_get(edje, &maxw, &maxh); + edje_object_size_min_get(edje, &minw, &minh); + if ((minw <= 0) && (minh <= 0)) + edje_object_size_min_calc(edje, &minw, &minh); + + evas_object_size_hint_max_set(edje, maxw, maxh); + evas_object_size_hint_min_set(edje, minw, minh); + + evas_object_size_hint_weight_set(edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(edje, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(edje); + + return edje; +} + +static 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) +{ + unsigned char *color = (unsigned char *)storage->ptrp; + + if (sscanf(str, FMT_UCHAR "," FMT_UCHAR "," FMT_UCHAR, color, color + 1, color + 2) != 3) + { + fprintf(stderr, "ERROR: incorrect color value '%s'\n", str); + return 0; + } + + return 1; +} + +static void _cb_delete(__UNUSED__ Ecore_Evas *ee) +{ + ecore_main_loop_quit(); +} + +const Ecore_Getopt optdesc = { + "edje_player", + "%prog [options] ", + PACKAGE_VERSION, + "(C) 2010 Enlightenment", + "BSD with advertisement clause", + "Simple application to view edje files.", + 0, + { + ECORE_GETOPT_STORE_STR + ('g', "group", "The edje group to view (defaults to 'main')."), + ECORE_GETOPT_STORE_TRUE + ('G', "list-groups", "The groups in the given file."), + ECORE_GETOPT_STORE_STR + ('e', "engine", "The Ecore-Evas engine to use (see --list-engines)"), + ECORE_GETOPT_CALLBACK_NOARGS + ('E', "list-engines", "list Ecore-Evas engines", + ecore_getopt_callback_ecore_evas_list_engines, NULL), + ECORE_GETOPT_CALLBACK_ARGS + ('Z', "size", "size to use in wxh form.", "WxH", + ecore_getopt_callback_size_parse, NULL), + ECORE_GETOPT_CALLBACK_ARGS + ('c', "bg-color", "Color of the background (if not shaped or alpha)", + "RRGGBB", _parse_color, NULL), + ECORE_GETOPT_STORE_TRUE + ('b', "borderless", "Display window without border."), + ECORE_GETOPT_STORE_TRUE + ('y', "sticky", "Display window sticky."), + ECORE_GETOPT_STORE_TRUE + ('s', "shaped", "Display window shaped."), + ECORE_GETOPT_STORE_TRUE + ('a', "alpha", "Display window with alpha channel " + "(needs composite manager!)"), + ECORE_GETOPT_STORE_STR + ('t', "title", "Define the window title string"), + ECORE_GETOPT_STORE_TRUE + ('p', "print", "Print signals and messages to stdout"), + ECORE_GETOPT_STORE_TRUE + ('S', "slave-mode", "Listen for commands on stdin"), + ECORE_GETOPT_STORE_DOUBLE + ('z', "scale", "Set scale factor"), + ECORE_GETOPT_LICENSE('L', "license"), + ECORE_GETOPT_COPYRIGHT('C', "copyright"), + ECORE_GETOPT_VERSION('V', "version"), + ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_SENTINEL + } +}; + +int main(int argc, char **argv) +{ + Evas *evas; + Evas_Object *stack, *edje; + struct opts opts; + Eina_Bool quit_option = EINA_FALSE; + int args; + Ecore_Getopt_Value values[] = { + ECORE_GETOPT_VALUE_STR(opts.group), + ECORE_GETOPT_VALUE_BOOL(opts.list_groups), + ECORE_GETOPT_VALUE_STR(opts.engine), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_PTR_CAST(opts.size), + ECORE_GETOPT_VALUE_PTR_CAST(opts.color), + ECORE_GETOPT_VALUE_BOOL(opts.borderless), + ECORE_GETOPT_VALUE_BOOL(opts.sticky), + ECORE_GETOPT_VALUE_BOOL(opts.shaped), + ECORE_GETOPT_VALUE_BOOL(opts.alpha), + ECORE_GETOPT_VALUE_STR(opts.title), + ECORE_GETOPT_VALUE_BOOL(opts.print), + ECORE_GETOPT_VALUE_BOOL(opts.slave_mode), + ECORE_GETOPT_VALUE_DOUBLE(opts.scale), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_NONE + }; + + memset(&opts, 0, sizeof(opts)); + opts.scale = 1.0; + + if (!ecore_evas_init()) + return EXIT_FAILURE; + if (!edje_init()) + goto shutdown_ecore_evas; + edje_frametime_set(1.0/60.0); + + args = ecore_getopt_parse(&optdesc, values, argc, argv); + if (args < 0) + { + fputs("Could not parse arguments.\n", stderr); + goto shutdown_edje; + } + else if (quit_option) + { + goto end; + } + else if (args >= argc) + { + fputs("Missing edje file to load.\n", stderr); + goto shutdown_edje; + } + + ecore_app_args_set(argc, (const char **)argv); + edje_scale_set(opts.scale); + + // check if the given edj file is there + if (access(argv[args], R_OK) == -1) + { + int e = errno; + fprintf(stderr, "ERROR: file '%s' not accessible, error %d (%s).\n", + argv[args], e, strerror(e)); + goto end; + } + + opts.file = argv[args]; + if (opts.list_groups) + { + Eina_List *groups, *n; + const char *group; + groups = edje_file_collection_list(opts.file); + printf("%d groups in file '%s':\n", eina_list_count(groups), opts.file); + EINA_LIST_FOREACH(groups, n, group) + printf("\t'%s'\n", group); + edje_file_collection_list_free(groups); + goto end; + } + + win = ecore_evas_new(opts.engine, 0, 0, opts.size.w, opts.size.h, NULL); + if (!win) + { + fprintf(stderr, + "ERROR: could not create window of " + "size %dx%d using engine %s.\n", + opts.size.w, opts.size.h, opts.engine ? opts.engine : "(auto)"); + goto shutdown_edje; + } + + ecore_evas_callback_delete_request_set(win, _cb_delete); + evas = ecore_evas_get(win); + stack = _create_stack(evas, &opts); + if (!stack) + { + goto free_ecore_evas; + } + + ecore_evas_object_associate(win, stack, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); + + if (opts.alpha) + ecore_evas_alpha_set(win, EINA_TRUE); + else if (opts.shaped) + ecore_evas_shaped_set(win, EINA_TRUE); + else + { + Evas_Object *bg = _create_bg(evas, &opts); + if (bg) evas_object_box_append(stack, bg); + } + + edje = _create_edje(evas, &opts); + if (edje) + evas_object_box_append(stack, edje); + else + { + goto free_ecore_evas; + } + + evas_object_focus_set(stack, EINA_TRUE); + evas_object_event_callback_add(stack, EVAS_CALLBACK_KEY_DOWN, + _key_down, &opts); + evas_object_event_callback_add(stack, EVAS_CALLBACK_CHANGED_SIZE_HINTS, + _reset_size_hints, edje); + + if (opts.print) + { + edje_object_signal_callback_add(edje, "*", "*", _print_signal, NULL); + edje_object_message_handler_set(edje, _print_message, NULL); + } + + if (opts.slave_mode) + { +#ifndef _WIN32 + int flags; + flags = fcntl(STDIN_FILENO, F_GETFL, 0); + flags |= O_NONBLOCK; + if (fcntl(STDIN_FILENO, F_SETFL, flags) < 0) + { + fprintf(stderr, "ERROR: Could not set stdin to non-block: %s\n", + strerror(errno)); + goto free_ecore_evas; + } + ecore_main_fd_handler_add(STDIN_FILENO, ECORE_FD_READ | ECORE_FD_ERROR, + _slave_mode, edje, NULL, NULL); +#else + /* TODO: port the code above to Windows */ + fprintf (stderr, "ERROR: slave mode not working on Windows\n"); + goto free_ecore_evas; +#endif + } + + ecore_evas_borderless_set(win, opts.borderless); + ecore_evas_sticky_set(win, opts.sticky); + if (opts.title) + ecore_evas_title_set(win, opts.title); + + if (opts.size.w <= 0) opts.size.w = 320; + if (opts.size.h <= 0) opts.size.h = 240; + ecore_evas_resize(win, opts.size.w, opts.size.h); + ecore_evas_show(win); + ecore_main_loop_begin(); + + ecore_evas_free(win); + end: + edje_shutdown(); + ecore_evas_shutdown(); + + return 0; + + free_ecore_evas: + ecore_evas_free(win); + shutdown_edje: + edje_shutdown(); + shutdown_ecore_evas: + ecore_evas_shutdown(); + return EXIT_FAILURE; +} 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 @@ +#!/bin/sh + +set -e + +usage () { + echo "Usage:" + echo " edje_recc [OPTIONS] input_file.edj" + echo "" + echo "Where OPTIONS is one or more of:" + echo "" + echo "-v Verbose output" + echo "-no-lossy Do NOT allow images to be lossy" + echo "-no-comp Do NOT allow images to be lossless compression" + echo "-no-raw Do NOT allow images to be zero compression" + echo "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)" + echo "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)" + exit -1 +} + +if [ $# -lt 1 ]; then + usage +fi + +OPT="" +if [ $# -ge 1 ]; then + for I in $@; do + case "$I" in + -h) + usage + ;; + + -help) + usage + ;; + + --help) + usage + ;; + + *.edj) + IN=$I + ;; + + *) + OPT=$OPT" "$I + ;; + esac + done +fi + +if [ -z "$IN" ]; then + echo "ERROR: NO input file.edj provided!" + echo "" + usage; +fi + +F=`basename $IN` +B=`basename $F .edj` +T="./...edje_tmp" +rm -rf $T +mkdir -p $T +cp $IN $T +cd $T +edje_decc $F +cd $B +./build.sh $OPT +cd ../.. +mv $T/$B/$F $IN +rm -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 @@ +# Makefile for GNU C compiler. +# Copyright (C) 1987, 88, 90-94, 1995 Free Software Foundation, Inc. + +#This file is part of GNU CC. + +#GNU CC is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 2, or (at your option) +#any later version. + +#GNU CC is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. + +#You should have received a copy of the GNU General Public License +#along with GNU CC; see the file COPYING. If not, write to +#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +MAINTAINERCLEANFILES = Makefile.in + +eppdir = @libdir@/@PACKAGE@/utils + +epp_PROGRAMS = epp + +epp_SOURCES = \ +cpplib.h \ +cpphash.h \ +cppalloc.c \ +cpperror.c \ +cppexp.c \ +cpphash.c \ +cpplib.c \ +cppmain.c + +epp_CPPFLAGS = \ +-I$(top_builddir) \ +$(CWARNFLAGS) + +DEFS= \ +-DHAVE_CONFIG_H \ +-DHAVE_STRERROR \ +-DFATAL_EXIT_CODE=1 \ +-DSUCCESS_EXIT_CODE=0 \ +-DGCC_INCLUDE_DIR=\"/usr/include\" \ +-DGPLUSPLUS_INCLUDE_DIR=\"/usr/include\" \ +-DTOOL_INCLUDE_DIR=\"/usr/bin\" \ +-DHOST_BITS_PER_LONG=32 \ +-DBITS_PER_UNIT=8 \ +-DHOST_BITS_PER_INT=32 \ +-DBITS_PER_WORD=16 \ +-DTARGET_BELL=7 \ +-DTARGET_BS=8 \ +-DTARGET_FF=12 \ +-DTARGET_NEWLINE=10 \ +-DTARGET_CR=13 \ +-DTARGET_TAB=9 \ +-DTARGET_VT=11 + 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 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Makefile for GNU C compiler. +# Copyright (C) 1987, 88, 90-94, 1995 Free Software Foundation, Inc. + +#This file is part of GNU CC. + +#GNU CC is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 2, or (at your option) +#any later version. + +#GNU CC is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. + +#You should have received a copy of the GNU General Public License +#along with GNU CC; see the file COPYING. If not, write to +#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +epp_PROGRAMS = epp$(EXEEXT) +subdir = src/bin/epp +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \ + $(top_srcdir)/m4/efl_binary.m4 \ + $(top_srcdir)/m4/efl_coverage.m4 \ + $(top_srcdir)/m4/efl_doxygen.m4 \ + $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(eppdir)" +PROGRAMS = $(epp_PROGRAMS) +am_epp_OBJECTS = epp-cppalloc.$(OBJEXT) epp-cpperror.$(OBJEXT) \ + epp-cppexp.$(OBJEXT) epp-cpphash.$(OBJEXT) \ + epp-cpplib.$(OBJEXT) epp-cppmain.$(OBJEXT) +epp_OBJECTS = $(am_epp_OBJECTS) +epp_LDADD = $(LDADD) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(epp_SOURCES) +DIST_SOURCES = $(epp_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = \ +-DHAVE_CONFIG_H \ +-DHAVE_STRERROR \ +-DFATAL_EXIT_CODE=1 \ +-DSUCCESS_EXIT_CODE=0 \ +-DGCC_INCLUDE_DIR=\"/usr/include\" \ +-DGPLUSPLUS_INCLUDE_DIR=\"/usr/include\" \ +-DTOOL_INCLUDE_DIR=\"/usr/bin\" \ +-DHOST_BITS_PER_LONG=32 \ +-DBITS_PER_UNIT=8 \ +-DHOST_BITS_PER_INT=32 \ +-DBITS_PER_WORD=16 \ +-DTARGET_BELL=7 \ +-DTARGET_BS=8 \ +-DTARGET_FF=12 \ +-DTARGET_NEWLINE=10 \ +-DTARGET_CR=13 \ +-DTARGET_TAB=9 \ +-DTARGET_VT=11 + +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ECORE_IMF_CFLAGS = @ECORE_IMF_CFLAGS@ +ECORE_IMF_LIBS = @ECORE_IMF_LIBS@ +EDJE_CC_CFLAGS = @EDJE_CC_CFLAGS@ +EDJE_CC_LIBS = @EDJE_CC_LIBS@ +EDJE_CC_PRG = @EDJE_CC_PRG@ +EDJE_CFLAGS = @EDJE_CFLAGS@ +EDJE_DECC_CFLAGS = @EDJE_DECC_CFLAGS@ +EDJE_DECC_LIBS = @EDJE_DECC_LIBS@ +EDJE_DECC_PRG = @EDJE_DECC_PRG@ +EDJE_EXTERNAL_INSPECTOR_CFLAGS = @EDJE_EXTERNAL_INSPECTOR_CFLAGS@ +EDJE_EXTERNAL_INSPECTOR_LIBS = @EDJE_EXTERNAL_INSPECTOR_LIBS@ +EDJE_EXTERNAL_INSPECTOR_PRG = @EDJE_EXTERNAL_INSPECTOR_PRG@ +EDJE_INSPECTOR_CFLAGS = @EDJE_INSPECTOR_CFLAGS@ +EDJE_INSPECTOR_LIBS = @EDJE_INSPECTOR_LIBS@ +EDJE_INSPECTOR_PRG = @EDJE_INSPECTOR_PRG@ +EDJE_LIBS = @EDJE_LIBS@ +EDJE_PLAYER_CFLAGS = @EDJE_PLAYER_CFLAGS@ +EDJE_PLAYER_LIBS = @EDJE_PLAYER_LIBS@ +EDJE_PLAYER_PRG = @EDJE_PLAYER_PRG@ +EDJE_RECC_PRG = @EDJE_RECC_PRG@ +EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@ +EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@ +EFL_EDJE_BUILD = @EFL_EDJE_BUILD@ +EGREP = @EGREP@ +EVIL_CFLAGS = @EVIL_CFLAGS@ +EVIL_LIBS = @EVIL_LIBS@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FLAC_CFLAGS = @FLAC_CFLAGS@ +FLAC_LIBS = @FLAC_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LUA_CFLAGS = @LUA_CFLAGS@ +LUA_LIBS = @LUA_LIBS@ +MAKEINFO = @MAKEINFO@ +MINIMAL_CFLAGS = @MINIMAL_CFLAGS@ +MINIMAL_LIBS = @MINIMAL_LIBS@ +MKDIR_P = @MKDIR_P@ +MODULE_ARCH = @MODULE_ARCH@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +REMIX_CFLAGS = @REMIX_CFLAGS@ +REMIX_LIBS = @REMIX_LIBS@ +REMIX_PLUGIN_DIR = @REMIX_PLUGIN_DIR@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ +SNDFILE_LIBS = @SNDFILE_LIBS@ +STRIP = @STRIP@ +VERSION = @VERSION@ +VMAJ = @VMAJ@ +VORBISENC_CFLAGS = @VORBISENC_CFLAGS@ +VORBISENC_LIBS = @VORBISENC_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +edje_cc = @edje_cc@ +efl_doxygen = @efl_doxygen@ +efl_have_doxygen = @efl_have_doxygen@ +exec_prefix = @exec_prefix@ +have_lcov = @have_lcov@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +lt_enable_auto_import = @lt_enable_auto_import@ +lua_libs = @lua_libs@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfig_requires_private = @pkgconfig_requires_private@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +release_info = @release_info@ +requirement_edje = @requirement_edje@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +version_info = @version_info@ +vimdir = @vimdir@ +MAINTAINERCLEANFILES = Makefile.in +eppdir = @libdir@/@PACKAGE@/utils +epp_SOURCES = \ +cpplib.h \ +cpphash.h \ +cppalloc.c \ +cpperror.c \ +cppexp.c \ +cpphash.c \ +cpplib.c \ +cppmain.c + +epp_CPPFLAGS = \ +-I$(top_builddir) \ +$(CWARNFLAGS) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/bin/epp/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/bin/epp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-eppPROGRAMS: $(epp_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(eppdir)" || $(MKDIR_P) "$(DESTDIR)$(eppdir)" + @list='$(epp_PROGRAMS)'; test -n "$(eppdir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(eppdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(eppdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-eppPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(epp_PROGRAMS)'; test -n "$(eppdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(eppdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(eppdir)" && rm -f $$files + +clean-eppPROGRAMS: + @list='$(epp_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +epp$(EXEEXT): $(epp_OBJECTS) $(epp_DEPENDENCIES) + @rm -f epp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(epp_OBJECTS) $(epp_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cppalloc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cpperror.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cppexp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cpphash.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cpplib.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epp-cppmain.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +epp-cppalloc.o: cppalloc.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppalloc.Tpo $(DEPDIR)/epp-cppalloc.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppalloc.c' object='epp-cppalloc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +epp-cppalloc.obj: cppalloc.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppalloc.Tpo $(DEPDIR)/epp-cppalloc.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppalloc.c' object='epp-cppalloc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +epp-cpperror.o: cpperror.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpperror.Tpo $(DEPDIR)/epp-cpperror.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpperror.c' object='epp-cpperror.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +epp-cpperror.obj: cpperror.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpperror.Tpo $(DEPDIR)/epp-cpperror.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpperror.c' object='epp-cpperror.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +epp-cppexp.o: cppexp.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppexp.Tpo $(DEPDIR)/epp-cppexp.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppexp.c' object='epp-cppexp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +epp-cppexp.obj: cppexp.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppexp.Tpo $(DEPDIR)/epp-cppexp.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppexp.c' object='epp-cppexp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +epp-cpphash.o: cpphash.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpphash.Tpo $(DEPDIR)/epp-cpphash.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpphash.c' object='epp-cpphash.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +epp-cpphash.obj: cpphash.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpphash.Tpo $(DEPDIR)/epp-cpphash.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpphash.c' object='epp-cpphash.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +epp-cpplib.o: cpplib.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpplib.Tpo $(DEPDIR)/epp-cpplib.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpplib.c' object='epp-cpplib.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +epp-cpplib.obj: cpplib.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cpplib.Tpo $(DEPDIR)/epp-cpplib.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cpplib.c' object='epp-cpplib.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +epp-cppmain.o: cppmain.c +@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 +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppmain.Tpo $(DEPDIR)/epp-cppmain.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppmain.c' object='epp-cppmain.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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 + +epp-cppmain.obj: cppmain.c +@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` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/epp-cppmain.Tpo $(DEPDIR)/epp-cppmain.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cppmain.c' object='epp-cppmain.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@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` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(eppdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-eppPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-eppPROGRAMS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-eppPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-eppPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-eppPROGRAMS install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-eppPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.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 @@ +/* Part of CPP library. (memory allocation - xmalloc etc) + * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + * Written by Per Bothner, 1994. + * Based on CCCP program by by Paul Rubin, June 1986 + * Adapted to ANSI C, Richard Stallman, Jan 1987 + * Copyright (C) 2003-2011 Kim Woelders + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * In other words, you are welcome to use, share and improve this program. + * You are forbidden to forbid anyone else to use, share and improve + * what you give them. Help stamp out software-hoarding! */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "cpplib.h" + +static void +memory_full(void) +{ + cpp_fatal("Memory exhausted."); +} + +void * +xmalloc(unsigned size) +{ + char *ptr = (char *)malloc(size); + + if (ptr) + return (ptr); + memory_full(); + /*NOTREACHED */ + return 0; +} + +void * +xrealloc(void *old, unsigned size) +{ + char *ptr = (char *)realloc(old, size); + + if (!ptr) + memory_full(); + return ptr; +} + +void * +xcalloc(unsigned number, unsigned size) +{ + char *ptr = (char *)calloc(number, size); + + if (!ptr) + memory_full(); + return ptr; +} 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 @@ +/* Default error handlers for CPP Library. + * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + * Written by Per Bothner, 1994. + * Based on CCCP program by by Paul Rubin, June 1986 + * Adapted to ANSI C, Richard Stallman, Jan 1987 + * Copyright (C) 2003-2011 Kim Woelders + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * In other words, you are welcome to use, share and improve this program. + * You are forbidden to forbid anyone else to use, share and improve + * what you give them. Help stamp out software-hoarding! */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include "cpplib.h" + +/* Print the file names and line numbers of the #include + * commands which led to the current file. */ + +void +cpp_print_containing_files(cpp_reader * pfile) +{ + cpp_buffer *ip; + int first = 1; + + /* If stack of files hasn't changed since we last printed + * this info, don't repeat it. */ + if (pfile->input_stack_listing_current) + return; + + ip = cpp_file_buffer(pfile); + + /* Give up if we don't find a source file. */ + if (!ip) + return; + + /* Find the other, outer source files. */ + while ((ip = CPP_PREV_BUFFER(ip)), ip != CPP_NULL_BUFFER(pfile)) + { + long line, col; + + cpp_buf_line_and_col(ip, &line, &col); + if (ip->fname) + { + if (first) + { + first = 0; + fprintf(stderr, "In file included"); + } + else + fprintf(stderr, ",\n "); + } + } + if (!first) + fprintf(stderr, ":\n"); + + /* Record we have printed the status as of this time. */ + pfile->input_stack_listing_current = 1; +} + +void +cpp_file_line_for_message(cpp_reader * pfile __UNUSED__, const char *filename, + int line, int column) +{ + if (column > 0) + { + fprintf(stderr, "%s:%d:%d: ", filename, line, column); + } + else + { + fprintf(stderr, "%s:%d: ", filename, line); + } +} + +/* IS_ERROR is 1 for error, 0 for warning */ +void +cpp_message_v(cpp_reader * pfile, int is_error, const char *msg, va_list args) +{ + if (is_error) + pfile->errors++; + else + fprintf(stderr, "warning: "); + vfprintf(stderr, msg, args); + fprintf(stderr, "\n"); +} + +void +cpp_message(cpp_reader * pfile, int is_error, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + + cpp_message_v(pfile, is_error, msg, args); + + va_end(args); +} + +static void +cpp_fatal_v(const char *msg, va_list args) +{ + fprintf(stderr, "%s: ", progname); + vfprintf(stderr, msg, args); + fprintf(stderr, "\n"); + exit(FATAL_EXIT_CODE); +} + +void +cpp_fatal(const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + + cpp_fatal_v(msg, args); + + va_end(args); +} + +void +cpp_pfatal_with_name(cpp_reader * pfile, const char *name) +{ + cpp_perror_with_name(pfile, name); +#ifdef VMS + exit(vaxc$errno); +#else + exit(FATAL_EXIT_CODE); +#endif +} 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 @@ +/* Parse C expressions for CCCP. + * Copyright (C) 1987, 1992, 1994, 1995 Free Software Foundation. + * Copyright (C) 2003-2011 Kim Woelders + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * In other words, you are welcome to use, share and improve this program. + * You are forbidden to forbid anyone else to use, share and improve + * what you give them. Help stamp out software-hoarding! + * + * Written by Per Bothner 1994. */ + +/* Parse a C expression from text in a string */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef __EMX__ +# include +#endif + +#ifdef MULTIBYTE_CHARS +# include +#endif + +#include +#include +#include + +#include "cpplib.h" +#include "cpphash.h" + +/* This is used for communicating lists of keywords with cccp.c. */ +struct arglist { + struct arglist *next; + unsigned char *name; + int length; + int argno; +}; + +/* Define a generic NULL if one hasn't already been defined. */ + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef GENERIC_PTR +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +#define GENERIC_PTR void * +#else +#define GENERIC_PTR char * +#endif +#endif + +#ifndef NULL_PTR +#define NULL_PTR ((GENERIC_PTR)0) +#endif + +#ifndef CHAR_TYPE_SIZE +#define CHAR_TYPE_SIZE BITS_PER_UNIT +#endif + +#ifndef INT_TYPE_SIZE +#define INT_TYPE_SIZE BITS_PER_WORD +#endif + +#ifndef LONG_TYPE_SIZE +#define LONG_TYPE_SIZE BITS_PER_WORD +#endif + +#ifndef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE INT_TYPE_SIZE +#endif + +#ifndef MAX_CHAR_TYPE_SIZE +#define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE +#endif + +#ifndef MAX_INT_TYPE_SIZE +#define MAX_INT_TYPE_SIZE INT_TYPE_SIZE +#endif + +#ifndef MAX_LONG_TYPE_SIZE +#define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE +#endif + +#ifndef MAX_WCHAR_TYPE_SIZE +#define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE +#endif + +/* Yield nonzero if adding two numbers with A's and B's signs can yield a + * number with SUM's sign, where A, B, and SUM are all C integers. */ +#define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0) + +#define ERROR 299 +#define OROR 300 +#define ANDAND 301 +#define EQUAL 302 +#define NOTEQUAL 303 +#define LEQ 304 +#define GEQ 305 +#define LSH 306 +#define RSH 307 +#define NAME 308 +#define INT 309 +#define CHAR 310 + +#define LEFT_OPERAND_REQUIRED 1 +#define RIGHT_OPERAND_REQUIRED 2 +#define HAVE_VALUE 4 +/* SKIP_OPERAND is set for '&&' '||' '?' and ':' when the + * following operand should be short-circuited instead of evaluated. */ +#define SKIP_OPERAND 8 +/*#define UNSIGNEDP 16 */ + +struct operation { + short op; + char rprio; /* Priority of op (relative to it right operand). */ + char flags; + char unsignedp; /* true if value should be treated as unsigned */ + HOST_WIDE_INT value; /* The value logically "right" of op. */ +}; + +/* Take care of parsing a number (anything that starts with a digit). + * LEN is the number of characters in it. */ + +/* maybe needs to actually deal with floating point numbers */ + +static void +parse_number(struct operation *op, cpp_reader * pfile, const char *start, + int olen) +{ + const char *p = start; + int c; + unsigned long n = 0, nd, ULONG_MAX_over_base; + int base = 10; + int len = olen; + int overflow = 0; + int digit, largest_digit = 0; + int spec_long = 0; + + op->unsignedp = 0; + + for (c = 0; c < len; c++) + if (p[c] == '.') + { + /* It's a float since it contains a point. */ + cpp_error(pfile, + "floating point numbers not allowed in #if expressions"); + op->op = ERROR; + return; + } + if (len >= 3 && (!strncmp(p, "0x", 2) || !strncmp(p, "0X", 2))) + { + p += 2; + base = 16; + len -= 2; + } + else if (*p == '0') + base = 8; + + /* Some buggy compilers (e.g. MPW C) seem to need both casts. */ + ULONG_MAX_over_base = ((unsigned long)-1) / ((unsigned long)base); + + for (; len > 0; len--) + { + c = *p++; + + if (c >= '0' && c <= '9') + digit = c - '0'; + else if (base == 16 && c >= 'a' && c <= 'f') + digit = c - 'a' + 10; + else if (base == 16 && c >= 'A' && c <= 'F') + digit = c - 'A' + 10; + else + { + /* `l' means long, and `u' means unsigned. */ + while (1) + { + if (c == 'l' || c == 'L') + { + if (spec_long) + cpp_error(pfile, "two `l's in integer constant"); + spec_long = 1; + } + else if (c == 'u' || c == 'U') + { + if (op->unsignedp) + cpp_error(pfile, "two `u's in integer constant"); + op->unsignedp = 1; + } + else + break; + + if (--len == 0) + break; + c = *p++; + } + /* Don't look for any more digits after the suffixes. */ + break; + } + if (largest_digit < digit) + largest_digit = digit; + nd = n * base + digit; + overflow |= (ULONG_MAX_over_base < n) | (nd < n); + n = nd; + } + + if (len != 0) + { + cpp_error(pfile, "Invalid number in #if expression"); + op->op = ERROR; + return; + } + if (base <= largest_digit) + cpp_warning(pfile, "integer constant contains digits beyond the radix"); + + if (overflow) + cpp_warning(pfile, "integer constant out of range"); + + /* If too big to be signed, consider it unsigned. */ + if ((long)n < 0 && !op->unsignedp) + { + if (base == 10) + cpp_warning(pfile, + "integer constant is so large that it is unsigned"); + op->unsignedp = 1; + } + op->value = n; + op->op = INT; +} + +struct token { + const char *oper; + int token; +}; + +static struct token tokentab2[] = { + {"&&", ANDAND}, + {"||", OROR}, + {"<<", LSH}, + {">>", RSH}, + {"==", EQUAL}, + {"!=", NOTEQUAL}, + {"<=", LEQ}, + {">=", GEQ}, + {"++", ERROR}, + {"--", ERROR}, + {NULL, ERROR} +}; + +/* Read one token. */ + +static void +cpp_lex(struct operation *op, cpp_reader * pfile) +{ + int c; + struct token *toktab; + enum cpp_token token; + unsigned char *tok_start, *tok_end; + int old_written; + + op->value = 0; + op->unsignedp = 0; + + retry: + + old_written = CPP_WRITTEN(pfile); + cpp_skip_hspace(pfile); + c = CPP_BUF_PEEK(CPP_BUFFER(pfile)); + if (c == '#') + { + parse_number(op, pfile, cpp_read_check_assertion(pfile) ? "1" : "0", 1); + return; + } + + if (c == '\n') + { + op->op = 0; + return; + } + token = cpp_get_token(pfile); + tok_start = pfile->token_buffer + old_written; + tok_end = CPP_PWRITTEN(pfile); + pfile->limit = tok_start; + switch (token) + { + case CPP_EOF: /* Should not happen ... */ + op->op = 0; + break; + + case CPP_VSPACE: + case CPP_POP: + if (CPP_BUFFER(pfile)->fname) + { + op->op = 0; + break; + } + goto retry; + + case CPP_HSPACE: + case CPP_COMMENT: + goto retry; + + case CPP_NUMBER: + parse_number(op, pfile, (char *)tok_start, tok_end - tok_start); + break; + + case CPP_STRING: + cpp_error(pfile, "string constants not allowed in #if expressions"); + op->op = ERROR; + break; + + case CPP_CHAR: + /* This code for reading a character constant + * handles multicharacter constants and wide characters. + * It is mostly copied from c-lex.c. */ + { + int result = 0; + int num_chars = 0; + unsigned width = MAX_CHAR_TYPE_SIZE; + int wide_flag = 0; + int max_chars; + char *ptr = (char *)tok_start; + +#ifdef MULTIBYTE_CHARS + char token_buffer[MAX_LONG_TYPE_SIZE / + MAX_CHAR_TYPE_SIZE + MB_CUR_MAX]; +#endif + + if (*ptr == 'L') + { + ptr++; + wide_flag = 1; + width = MAX_WCHAR_TYPE_SIZE; +#ifdef MULTIBYTE_CHARS + max_chars = MB_CUR_MAX; +#else + max_chars = 1; +#endif + } + else + max_chars = MAX_LONG_TYPE_SIZE / width; + + while (1) + { + if (ptr >= (char *)CPP_PWRITTEN(pfile) || (c = *ptr++) == '\'') + break; + + if (c == '\\') + { + c = cpp_parse_escape(pfile, &ptr); + if (width < HOST_BITS_PER_INT + && (unsigned)c >= (unsigned)(1 << width)) + cpp_pedwarn(pfile, + "escape sequence out of range for character"); + } + num_chars++; + + /* Merge character into result; ignore excess chars. */ + if (num_chars < max_chars + 1) + { + if (width < HOST_BITS_PER_INT) + result = (result << width) | (c & ((1 << width) - 1)); + else + result = c; +#ifdef MULTIBYTE_CHARS + token_buffer[num_chars - 1] = c; +#endif + } + } + +#ifdef MULTIBYTE_CHARS + token_buffer[num_chars] = 0; +#endif + + if (c != '\'') + cpp_error(pfile, "malformatted character constant"); + else if (num_chars == 0) + cpp_error(pfile, "empty character constant"); + else if (num_chars > max_chars) + { + num_chars = max_chars; + cpp_error(pfile, "character constant too long"); + } + else if (num_chars != 1 && !CPP_TRADITIONAL(pfile)) + cpp_warning(pfile, "multi-character character constant"); + + /* If char type is signed, sign-extend the constant. */ + if (!wide_flag) + { + int num_bits = num_chars * width; + + if (cpp_lookup("__CHAR_UNSIGNED__", + sizeof("__CHAR_UNSIGNED__") - 1, -1) + || ((result >> (num_bits - 1)) & 1) == 0) + op->value = + result & ((unsigned long)~0 >> + (HOST_BITS_PER_LONG - num_bits)); + else + op->value = + result | ~((unsigned long)~0 >> + (HOST_BITS_PER_LONG - num_bits)); + } + else + { +#ifdef MULTIBYTE_CHARS + /* Set the initial shift state and convert the next sequence. */ + result = 0; + /* In all locales L'\0' is zero and mbtowc will return zero, + * so don't use it. */ + if (num_chars > 1 + || (num_chars == 1 && token_buffer[0] != '\0')) + { + wchar_t wc; + + (void)mbtowc(NULL_PTR, NULL_PTR, 0); + if (mbtowc(&wc, token_buffer, num_chars) == num_chars) + result = wc; + else + cpp_warning(pfile, + "Ignoring invalid multibyte character"); + } +#endif + op->value = result; + } + } + + /* This is always a signed type. */ + op->unsignedp = 0; + op->op = CHAR; + break; + + case CPP_NAME: + parse_number(op, pfile, "0", 0); + break; + + case CPP_OTHER: + /* See if it is a special token of length 2. */ + if (tok_start + 2 == tok_end) + { + for (toktab = tokentab2; toktab->oper; toktab++) + if (tok_start[0] == toktab->oper[0] + && tok_start[1] == toktab->oper[1]) + break; + if (toktab->token == ERROR) + { + char *buf = (char *)malloc(40); + + memset(buf, 0, 40); + + sprintf(buf, "`%s' not allowed in operand of `#if'", + tok_start); + cpp_error(pfile, buf); + free(buf); + } + op->op = toktab->token; + break; + } + /* fall through */ + default: + op->op = *tok_start; + break; + } +} + +/* Parse a C escape sequence. STRING_PTR points to a variable + * containing a pointer to the string to parse. That pointer + * is updated past the characters we use. The value of the + * escape sequence is returned. + * + * A negative value means the sequence \ newline was seen, + * which is supposed to be equivalent to nothing at all. + * + * If \ is followed by a null character, we return a negative + * value and leave the string pointer pointing at the null character. + * + * If \ is followed by 000, we return 0 and leave the string pointer + * after the zeros. A value of 0 does not mean end of string. */ + +int +cpp_parse_escape(cpp_reader * pfile, char **string_ptr) +{ + int c = *(*string_ptr)++; + + switch (c) + { + case 'a': + return TARGET_BELL; + case 'b': + return TARGET_BS; + case 'e': + case 'E': + if (CPP_PEDANTIC(pfile)) + cpp_pedwarn(pfile, "non-ANSI-standard escape sequence, `\\%c'", c); + return 033; + case 'f': + return TARGET_FF; + case 'n': + return TARGET_NEWLINE; + case 'r': + return TARGET_CR; + case 't': + return TARGET_TAB; + case 'v': + return TARGET_VT; + case '\n': + return -2; + case 0: + (*string_ptr)--; + return 0; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + int i = c - '0'; + int count = 0; + + while (++count < 3) + { + c = *(*string_ptr)++; + if (c >= '0' && c <= '7') + i = (i << 3) + c - '0'; + else + { + (*string_ptr)--; + break; + } + } + if ((i & ~((1 << MAX_CHAR_TYPE_SIZE) - 1)) != 0) + { + i &= (1 << MAX_CHAR_TYPE_SIZE) - 1; + cpp_warning(pfile, + "octal character constant does not fit in a byte"); + } + return i; + } + case 'x': + { + unsigned i = 0, overflow = 0, digits_found = 0, digit; + + for (;;) + { + c = *(*string_ptr)++; + if (c >= '0' && c <= '9') + digit = c - '0'; + else if (c >= 'a' && c <= 'f') + digit = c - 'a' + 10; + else if (c >= 'A' && c <= 'F') + digit = c - 'A' + 10; + else + { + (*string_ptr)--; + break; + } + overflow |= i ^ (i << 4 >> 4); + i = (i << 4) + digit; + digits_found = 1; + } + if (!digits_found) + cpp_error(pfile, "\\x used with no following hex digits"); + if (overflow | (i & ~((1 << BITS_PER_UNIT) - 1))) + { + i &= (1 << BITS_PER_UNIT) - 1; + cpp_warning(pfile, + "hex character constant does not fit in a byte"); + } + return i; + } + default: + return c; + } +} + +static void +integer_overflow(cpp_reader * pfile) +{ + if (CPP_PEDANTIC(pfile)) + cpp_pedwarn(pfile, "integer overflow in preprocessor expression"); +} + +static long +left_shift(cpp_reader * pfile, long a, int unsignedp, unsigned long b) +{ + if (b >= HOST_BITS_PER_LONG) + { + if (!unsignedp && a != 0) + integer_overflow(pfile); + return 0; + } + else if (unsignedp) + return (unsigned long)a << b; + else + { + long l = a << b; + + if (l >> b != a) + integer_overflow(pfile); + return l; + } +} + +static long +right_shift(cpp_reader * pfile __UNUSED__, long a, int unsignedp, + unsigned long b) +{ + if (b >= HOST_BITS_PER_LONG) + { + return unsignedp ? 0 : a >> (HOST_BITS_PER_LONG - 1); + } + else if (unsignedp) + { + return (unsigned long)a >> b; + } + else + { + return a >> b; + } +} + +/* These priorities are all even, so we can handle associatively. */ +#define PAREN_INNER_PRIO 0 +#define COMMA_PRIO 4 +#define COND_PRIO (COMMA_PRIO+2) +#define OROR_PRIO (COND_PRIO+2) +#define ANDAND_PRIO (OROR_PRIO+2) +#define OR_PRIO (ANDAND_PRIO+2) +#define XOR_PRIO (OR_PRIO+2) +#define AND_PRIO (XOR_PRIO+2) +#define EQUAL_PRIO (AND_PRIO+2) +#define LESS_PRIO (EQUAL_PRIO+2) +#define SHIFT_PRIO (LESS_PRIO+2) +#define PLUS_PRIO (SHIFT_PRIO+2) +#define MUL_PRIO (PLUS_PRIO+2) +#define UNARY_PRIO (MUL_PRIO+2) +#define PAREN_OUTER_PRIO (UNARY_PRIO+2) + +#define COMPARE(OP) \ + top->unsignedp = 0;\ + top->value = (unsigned1 || unsigned2) ? (unsigned long) v1 OP (unsigned long) v2 : (v1 OP v2) + +/* Parse and evaluate a C expression, reading from PFILE. + * Returns the value of the expression. */ + +HOST_WIDE_INT +cpp_parse_expr(cpp_reader * pfile) +{ + /* The implementation is an operator precedence parser, + * i.e. a bottom-up parser, using a stack for not-yet-reduced tokens. + * + * The stack base is 'stack', and the current stack pointer is 'top'. + * There is a stack element for each operator (only), + * and the most recently pushed operator is 'top->op'. + * An operand (value) is stored in the 'value' field of the stack + * element of the operator that precedes it. + * In that case the 'flags' field has the HAVE_VALUE flag set. */ + +#define INIT_STACK_SIZE 20 + struct operation init_stack[INIT_STACK_SIZE]; + struct operation *stack = init_stack; + struct operation *limit = stack + INIT_STACK_SIZE; + struct operation *top = stack; + int lprio = 0, rprio = 0; + int skip_evaluation = 0; + + top->rprio = 0; + top->flags = 0; + for (;;) + { + struct operation op; + char flags = 0; + + /* Read a token */ + cpp_lex(&op, pfile); + + /* See if the token is an operand, in which case go to set_value. + * If the token is an operator, figure out its left and right + * priorities, and then goto maybe_reduce. */ + + switch (op.op) + { + case NAME: + top->value = 0, top->unsignedp = 0; + goto set_value; + case INT: + case CHAR: + top->value = op.value; + top->unsignedp = op.unsignedp; + goto set_value; + case 0: + lprio = 0; + goto maybe_reduce; + case '+': + case '-': + /* Is this correct if unary ? FIXME */ + flags = RIGHT_OPERAND_REQUIRED; + lprio = PLUS_PRIO; + rprio = lprio + 1; + goto maybe_reduce; + case '!': + case '~': + flags = RIGHT_OPERAND_REQUIRED; + rprio = UNARY_PRIO; + lprio = rprio + 1; + goto maybe_reduce; + case '*': + case '/': + case '%': + lprio = MUL_PRIO; + goto binop; + case '<': + case '>': + case LEQ: + case GEQ: + lprio = LESS_PRIO; + goto binop; + case EQUAL: + case NOTEQUAL: + lprio = EQUAL_PRIO; + goto binop; + case LSH: + case RSH: + lprio = SHIFT_PRIO; + goto binop; + case '&': + lprio = AND_PRIO; + goto binop; + case '^': + lprio = XOR_PRIO; + goto binop; + case '|': + lprio = OR_PRIO; + goto binop; + case ANDAND: + lprio = ANDAND_PRIO; + goto binop; + case OROR: + lprio = OROR_PRIO; + goto binop; + case ',': + lprio = COMMA_PRIO; + goto binop; + case '(': + lprio = PAREN_OUTER_PRIO; + rprio = PAREN_INNER_PRIO; + goto maybe_reduce; + case ')': + lprio = PAREN_INNER_PRIO; + rprio = PAREN_OUTER_PRIO; + goto maybe_reduce; + case ':': + lprio = COND_PRIO; + rprio = COND_PRIO; + goto maybe_reduce; + case '?': + lprio = COND_PRIO + 1; + rprio = COND_PRIO; + goto maybe_reduce; + binop: + flags = LEFT_OPERAND_REQUIRED | RIGHT_OPERAND_REQUIRED; + rprio = lprio + 1; + goto maybe_reduce; + default: + cpp_error(pfile, "invalid character in #if"); + goto syntax_error; + } + + set_value: + /* Push a value onto the stack. */ + if (top->flags & HAVE_VALUE) + { + cpp_error(pfile, "syntax error in #if"); + goto syntax_error; + } + top->flags |= HAVE_VALUE; + continue; + + maybe_reduce: + /* Push an operator, and check if we can reduce now. */ + while (top->rprio > lprio) + { + long v1 = top[-1].value, v2 = top[0].value; + int unsigned1 = top[-1].unsignedp, unsigned2 = + top[0].unsignedp; + + top--; + if ((top[1].flags & LEFT_OPERAND_REQUIRED) + && !(top[0].flags & HAVE_VALUE)) + { + cpp_error(pfile, "syntax error - missing left operand"); + goto syntax_error; + } + if ((top[1].flags & RIGHT_OPERAND_REQUIRED) + && !(top[1].flags & HAVE_VALUE)) + { + cpp_error(pfile, "syntax error - missing right operand"); + goto syntax_error; + } + /* top[0].value = (top[1].op)(v1, v2); */ + switch (top[1].op) + { + case '+': + if (!(top->flags & HAVE_VALUE)) + { /* Unary '+' */ + top->value = v2; + top->unsignedp = unsigned2; + top->flags |= HAVE_VALUE; + } + else + { + top->value = v1 + v2; + top->unsignedp = unsigned1 || unsigned2; + if (!top->unsignedp && !skip_evaluation + && !possible_sum_sign(v1, v2, top->value)) + integer_overflow(pfile); + } + break; + case '-': + if (skip_evaluation); /* do nothing */ + else if (!(top->flags & HAVE_VALUE)) + { /* Unary '-' */ + top->value = -v2; + if ((top->value & v2) < 0 && !unsigned2) + integer_overflow(pfile); + top->unsignedp = unsigned2; + top->flags |= HAVE_VALUE; + } + else + { /* Binary '-' */ + top->value = v1 - v2; + top->unsignedp = unsigned1 || unsigned2; + if (!top->unsignedp + && !possible_sum_sign(top->value, v2, v1)) + integer_overflow(pfile); + } + break; + case '*': + top->unsignedp = unsigned1 || unsigned2; + if (top->unsignedp) + top->value = (unsigned long)v1 *v2; + + else if (!skip_evaluation) + { + top->value = v1 * v2; + if (v1 + && (top->value / v1 != v2 + || (top->value & v1 & v2) < 0)) + integer_overflow(pfile); + } + break; + case '/': + if (skip_evaluation) + break; + if (v2 == 0) + { + cpp_error(pfile, "division by zero in #if"); + v2 = 1; + } + top->unsignedp = unsigned1 || unsigned2; + if (top->unsignedp) + top->value = (unsigned long)v1 / v2; + else + { + top->value = v1 / v2; + if ((top->value & v1 & v2) < 0) + integer_overflow(pfile); + } + break; + case '%': + if (skip_evaluation) + break; + if (v2 == 0) + { + cpp_error(pfile, "division by zero in #if"); + v2 = 1; + } + top->unsignedp = unsigned1 || unsigned2; + if (top->unsignedp) + top->value = (unsigned long)v1 % v2; + else + top->value = v1 % v2; + break; + case '!': + if (top->flags & HAVE_VALUE) + { + cpp_error(pfile, "syntax error"); + goto syntax_error; + } + top->value = !v2; + top->unsignedp = 0; + top->flags |= HAVE_VALUE; + break; + case '~': + if (top->flags & HAVE_VALUE) + { + cpp_error(pfile, "syntax error"); + goto syntax_error; + } + top->value = ~v2; + top->unsignedp = unsigned2; + top->flags |= HAVE_VALUE; + break; + case '<': + COMPARE(<); + break; + case '>': + COMPARE(>); + break; + case LEQ: + COMPARE(<=); + break; + case GEQ: + COMPARE(>=); + break; + case EQUAL: + top->value = (v1 == v2); + top->unsignedp = 0; + break; + case NOTEQUAL: + top->value = (v1 != v2); + top->unsignedp = 0; + break; + case LSH: + if (skip_evaluation) + break; + top->unsignedp = unsigned1; + if (v2 < 0 && !unsigned2) + top->value = right_shift(pfile, v1, unsigned1, -v2); + else + top->value = left_shift(pfile, v1, unsigned1, v2); + break; + case RSH: + if (skip_evaluation) + break; + top->unsignedp = unsigned1; + if (v2 < 0 && !unsigned2) + top->value = left_shift(pfile, v1, unsigned1, -v2); + else + top->value = right_shift(pfile, v1, unsigned1, v2); + break; +#define LOGICAL(OP) \ + top->value = v1 OP v2;\ + top->unsignedp = unsigned1 || unsigned2; + case '&': + LOGICAL(&); + break; + case '^': + LOGICAL(^); + break; + case '|': + LOGICAL(|); + break; + case ANDAND: + top->value = v1 && v2; + top->unsignedp = 0; + if (!v1) + skip_evaluation--; + break; + case OROR: + top->value = v1 || v2; + top->unsignedp = 0; + if (v1) + skip_evaluation--; + break; + case ',': + if (CPP_PEDANTIC(pfile)) + cpp_pedwarn(pfile, "comma operator in operand of `#if'"); + top->value = v2; + top->unsignedp = unsigned2; + break; + case '(': + case '?': + cpp_error(pfile, "syntax error in #if"); + goto syntax_error; + case ':': + if (top[0].op != '?') + { + cpp_error(pfile, + "syntax error ':' without preceding '?'"); + goto syntax_error; + } + else if (!(top[1].flags & HAVE_VALUE) + || !(top[-1].flags & HAVE_VALUE) + || !(top[0].flags & HAVE_VALUE)) + { + cpp_error(pfile, "bad syntax for ?: operator"); + goto syntax_error; + } + else + { + top--; + if (top->value) + skip_evaluation--; + top->value = top->value ? v1 : v2; + top->unsignedp = unsigned1 || unsigned2; + } + break; + case ')': + if ((top[1].flags & HAVE_VALUE) + || !(top[0].flags & HAVE_VALUE) + || top[0].op != '(' || (top[-1].flags & HAVE_VALUE)) + { + cpp_error(pfile, "mismatched parentheses in #if"); + goto syntax_error; + } + else + { + top--; + top->value = v1; + top->unsignedp = unsigned1; + top->flags |= HAVE_VALUE; + } + break; + default: + fprintf(stderr, + top[1].op >= ' ' && top[1].op <= '~' + ? "unimplemented operator '%c'\n" + : "unimplemented operator '\\%03o'\n", top[1].op); + } + } + if (op.op == 0) + { + if (top != stack) + cpp_error(pfile, "internal error in #if expression"); + if (stack != init_stack) + free(stack); + return top->value; + } + top++; + + /* Check for and handle stack overflow. */ + if (top == limit) + { + struct operation *new_stack; + int old_size = (char *)limit - (char *)stack; + int new_size = 2 * old_size; + + if (stack != init_stack) + new_stack = (struct operation *)xrealloc(stack, new_size); + else + { + new_stack = (struct operation *)xmalloc(new_size); + memcpy((char *)new_stack, (char *)stack, old_size); + } + stack = new_stack; + top = (struct operation *)((char *)new_stack + old_size); + limit = (struct operation *)((char *)new_stack + new_size); + } + top->flags = flags; + top->rprio = rprio; + top->op = op.op; + if ((op.op == OROR && top[-1].value) + || (op.op == ANDAND && !top[-1].value) + || (op.op == '?' && !top[-1].value)) + { + skip_evaluation++; + } + else if (op.op == ':') + { + if (top[-2].value) /* Was condition true? */ + skip_evaluation++; + else + skip_evaluation--; + } + } + syntax_error: + if (stack != init_stack) + free(stack); + skip_rest_of_line(pfile); + return 0; +} 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 @@ +/* Part of CPP library. (Macro hash table support.) + * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + * Written by Per Bothner, 1994. + * Based on CCCP program by by Paul Rubin, June 1986 + * Adapted to ANSI C, Richard Stallman, Jan 1987 + * Copyright (C) 2003-2011 Kim Woelders + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * In other words, you are welcome to use, share and improve this program. + * You are forbidden to forbid anyone else to use, share and improve + * what you give them. Help stamp out software-hoarding! */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include "cpplib.h" +#include "cpphash.h" + +static HASHNODE *hashtab[HASHSIZE]; + +#define IS_IDCHAR(ch) is_idchar[(unsigned char)(ch)] + +/* + * return hash function on name. must be compatible with the one + * computed a step at a time, elsewhere + */ +int +hashf(const char *name, int len, int hashsize) +{ + int r = 0; + + while (len--) + r = HASHSTEP(r, *name++); + + return MAKE_POS(r) % hashsize; +} + +/* + * find the most recent hash node for name name (ending with first + * non-identifier char) installed by install + * + * If LEN is >= 0, it is the length of the name. + * Otherwise, compute the length by scanning the entire name. + * + * If HASH is >= 0, it is the precomputed hash code. + * Otherwise, compute the hash code. + */ +HASHNODE * +cpp_lookup(const char *name, int len, int hash) +{ + const char *bp; + HASHNODE *bucket; + + if (len < 0) + { + for (bp = name; IS_IDCHAR(*bp); bp++) + ; + len = bp - name; + } + if (hash < 0) + hash = hashf(name, len, HASHSIZE); + + bucket = hashtab[hash]; + while (bucket) + { + if (bucket->length == len + && strncmp((const char *)bucket->name, name, len) == 0) + return bucket; + bucket = bucket->next; + } + return (HASHNODE *) 0; +} + +/* + * Delete a hash node. Some weirdness to free junk from macros. + * More such weirdness will have to be added if you define more hash + * types that need it. + */ + +/* Note that the DEFINITION of a macro is removed from the hash table + * but its storage is not freed. This would be a storage leak + * except that it is not reasonable to keep undefining and redefining + * large numbers of macros many times. + * In any case, this is necessary, because a macro can be #undef'd + * in the middle of reading the arguments to a call to it. + * If #undef freed the DEFINITION, that would crash. */ + +void +delete_macro(HASHNODE * hp) +{ + + if (hp->prev) + hp->prev->next = hp->next; + if (hp->next) + hp->next->prev = hp->prev; + + /* make sure that the bucket chain header that + * the deleted guy was on points to the right thing afterwards. */ + if (hp == *hp->bucket_hdr) + *hp->bucket_hdr = hp->next; + + if (hp->type == T_MACRO) + { + DEFINITION *d = hp->value.defn; + struct reflist *ap, *nextap; + + for (ap = d->pattern; ap; ap = nextap) + { + nextap = ap->next; + free(ap); + } + if (d->nargs >= 0) + free(d->args.argnames); + free(d); + } + free(hp); +} +/* + * install a name in the main hash table, even if it is already there. + * name stops with first non alphanumeric, except leading '#'. + * caller must check against redefinition if that is desired. + * delete_macro () removes things installed by install () in fifo order. + * this is important because of the `defined' special symbol used + * in #if, and also if pushdef/popdef directives are ever implemented. + * + * If LEN is >= 0, it is the length of the name. + * Otherwise, compute the length by scanning the entire name. + * + * If HASH is >= 0, it is the precomputed hash code. + * Otherwise, compute the hash code. + */ +HASHNODE * +install(const char *name, int len, enum node_type type, int ivalue, char *value, + int hash) +{ + HASHNODE *hp; + int i, bucket; + const char *p; + + if (len < 0) + { + p = name; + while (IS_IDCHAR(*p)) + p++; + len = p - name; + } + if (hash < 0) + hash = hashf(name, len, HASHSIZE); + + i = sizeof(HASHNODE) + len + 1; + hp = (HASHNODE *) xmalloc(i); + bucket = hash; + hp->bucket_hdr = &hashtab[bucket]; + hp->next = hashtab[bucket]; + hashtab[bucket] = hp; + hp->prev = NULL; + if (hp->next) + hp->next->prev = hp; + hp->type = type; + hp->length = len; + if (hp->type == T_CONST) + hp->value.ival = ivalue; + else + hp->value.cpval = value; + hp->name = ((char *)hp) + sizeof(HASHNODE); + memcpy(hp->name, name, len); + hp->name[len] = 0; + return hp; +} + +void +cpp_hash_cleanup(cpp_reader * pfile __UNUSED__) +{ + int i; + + for (i = HASHSIZE; --i >= 0;) + { + while (hashtab[i]) + delete_macro(hashtab[i]); + } +} 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 @@ +enum node_type; + +/* different kinds of things that can appear in the value field + of a hash node. Actually, this may be useless now. */ +union hashval { + int ival; + char *cpval; + DEFINITION *defn; +}; + +struct hashnode { + struct hashnode *next; /* double links for easy deletion */ + struct hashnode *prev; + struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash + * chain is kept, in case the node is the head + * of the chain and gets deleted. */ + enum node_type type; /* type of special token */ + int length; /* length of token, for quick comparison */ + char *name; /* the actual name */ + union hashval value; /* pointer to expansion, or whatever */ +}; + +typedef struct hashnode HASHNODE; + +/* Some definitions for the hash table. The hash function MUST be + computed as shown in hashf () below. That is because the rescan + loop computes the hash value `on the fly' for most tokens, + in order to avoid the overhead of a lot of procedure calls to + the hashf () function. Hashf () only exists for the sake of + politeness, for use when speed isn't so important. */ + +#define HASHSIZE 1403 +#define HASHSTEP(old, c) ((old << 2) + c) +#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */ + +extern int hashf(const char *name, int len, int hashsize); +extern HASHNODE *cpp_lookup(const char *name, int len, int hash); +extern void delete_macro(HASHNODE * hp); +extern HASHNODE *install(const char *name, int len, enum node_type type, + int ivalue, char *value, int hash); +extern 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 @@ +/* CPP Library. + * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + * Written by Per Bothner, 1994-95. + * Based on CCCP program by by Paul Rubin, June 1986 + * Adapted to ANSI C, Richard Stallman, Jan 1987 + * Copyright (C) 2003-2011 Kim Woelders + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * In other words, you are welcome to use, share and improve this program. + * You are forbidden to forbid anyone else to use, share and improve + * what you give them. Help stamp out software-hoarding! */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_ALLOCA_H +# include +#elif defined __GNUC__ +# define alloca __builtin_alloca +#elif defined _AIX +# define alloca __alloca +#elif defined _MSC_VER +# include +# define alloca _alloca +#else +# include +void *alloca (size_t); +#endif + +#ifdef __EMX__ +#include +#endif + +#ifndef STANDARD_INCLUDE_DIR +#define STANDARD_INCLUDE_DIR "/usr/include" +#endif + +#ifndef LOCAL_INCLUDE_DIR +#define LOCAL_INCLUDE_DIR "/usr/local/include" +#endif + +#include "cpplib.h" +#include "cpphash.h" + +/* + * On Windows, if the file is not opened in binary mode, + * read does not return the correct size, because of + * CR / LF translation. + */ +#ifndef O_BINARY +# define O_BINARY 0 +#endif + +const char *version_string = "0.0.0"; + +#ifndef STDC_VALUE +#define STDC_VALUE 1 +#endif + +/* By default, colon separates directories in a path. */ +#ifndef PATH_SEPARATOR +#define PATH_SEPARATOR ':' +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef VMS +#ifndef USG +#include +#include /* for __DATE__ and __TIME__ */ +#ifdef HAVE_SYS_RESOURCE_H +# include +#endif +#else +#include /* CYGNUS LOCAL: shebs -noquiet */ +#include +#include +#include +#endif /* USG */ +#endif /* not VMS */ + +/* This defines "errno" properly for VMS, and gives us EACCES. */ +#include + +#ifndef O_RDONLY +#define O_RDONLY 0 +#endif + +#undef MIN +#undef MAX +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) + +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +/* Define a generic NULL if one hasn't already been defined. */ + +#ifndef GENERIC_PTR +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +#define GENERIC_PTR void * +#else +#define GENERIC_PTR char * +#endif +#endif + +#ifndef INCLUDE_LEN_FUDGE +#define INCLUDE_LEN_FUDGE 0 +#endif + +#define USE_FILE_NAME_MAPS 0 + +/* Symbols to predefine. */ + +#ifdef CPP_PREDEFINES +static const char *predefs = CPP_PREDEFINES; + +#else +static const char *predefs = ""; + +#endif + +/* We let tm.h override the types used here, to handle trivial differences + * such as the choice of unsigned int or long unsigned int for size_t. + * When machines start needing nontrivial differences in the size type, + * it would be best to do something here to figure out automatically + * from other information what type to use. */ + +/* The string value for __SIZE_TYPE__. */ + +#ifndef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" +#endif + +/* The string value for __PTRDIFF_TYPE__. */ + +#ifndef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" +#endif + +/* The string value for __WCHAR_TYPE__. */ + +#ifndef WCHAR_TYPE +#define WCHAR_TYPE "int" +#endif +#define CPP_WCHAR_TYPE(PFILE) \ + (CPP_OPTIONS (PFILE)->cplusplus ? "__wchar_t" : WCHAR_TYPE) + +/* The string value for __USER_LABEL_PREFIX__ */ + +#ifndef USER_LABEL_PREFIX +#define USER_LABEL_PREFIX "" +#endif + +/* The string value for __REGISTER_PREFIX__ */ + +#ifndef REGISTER_PREFIX +#define REGISTER_PREFIX "" +#endif + +struct directive { + int length; + int (*func) (cpp_reader * pfile, struct directive * keyword, + unsigned char *buf, unsigned char *limit); + const char *name; + enum node_type type; + char command_reads_line; + char traditional_comments; + char pass_thru; +}; + +/* In the definition of a #assert name, this structure forms + * a list of the individual values asserted. + * Each value is itself a list of "tokens". + * These are strings that are compared by name. */ + +struct tokenlist_list { + struct tokenlist_list *next; + struct arglist *tokens; +}; + +struct assertion_hashnode { + struct assertion_hashnode *next; /* double links for easy deletion */ + struct assertion_hashnode *prev; + /* also, a back pointer to this node's hash + * chain is kept, in case the node is the head + * of the chain and gets deleted. */ + struct assertion_hashnode **bucket_hdr; + int length; /* length of token, for quick comparison */ + char *name; /* the actual name */ + /* List of token-sequences. */ + struct tokenlist_list *value; +}; + +#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[(unsigned char)(*p)]) p++; } while (0) +#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[(unsigned char)(*p)]) p++; } while (0) + +#define PEEKN(N) (CPP_BUFFER (pfile)->rlimit - CPP_BUFFER (pfile)->cur >= (N) ? CPP_BUFFER (pfile)->cur[N] : EOF) +#define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N)) +#define GETC() CPP_BUF_GET (CPP_BUFFER (pfile)) +#define PEEKC() CPP_BUF_PEEK (CPP_BUFFER (pfile)) +/* CPP_IS_MACRO_BUFFER is true if the buffer contains macro expansion. + * (Note that it is false while we're expanding marco *arguments*.) */ +#define CPP_IS_MACRO_BUFFER(PBUF) ((PBUF)->cleanup == macro_cleanup) + +/* Move all backslash-newline pairs out of embarrassing places. + * Exchange all such pairs following BP + * with any potentially-embarrassing characters that follow them. + * Potentially-embarrassing characters are / and * + * (because a backslash-newline inside a comment delimiter + * would cause it not to be recognized). */ + +#define NEWLINE_FIX \ + do {while (PEEKC() == '\\' && PEEKN(1) == '\n') FORWARD(2); } while(0) + +/* Same, but assume we've already read the potential '\\' into C. */ +#define NEWLINE_FIX1(C) do { \ + while ((C) == '\\' && PEEKC() == '\n') { FORWARD(1); (C) = GETC(); }\ + } while(0) + +/* Name under which this program was invoked. */ + +char *progname; + +struct cpp_pending { + struct cpp_pending *next; + const char *cmd; + const char *arg; +}; + +/* Structure returned by create_definition */ +typedef struct { + struct definition *defn; + char *symnam; + int symlen; +} MACRODEF; + +/* Forward declarations. */ +typedef struct file_name_list file_name_list; + +static void add_import(cpp_reader * pfile, int fd, char *fname); +static int finclude(cpp_reader * pfile, int f, const char *fname, + int system_header_p, file_name_list * dirptr); +static void validate_else(cpp_reader * pfile, const char *directive); +static int comp_def_part(int first, unsigned char *beg1, int len1, + unsigned char *beg2, int len2, int last); +static int lookup_import(cpp_reader * pfile, char *filename, + file_name_list * searchptr); +static int redundant_include_p(cpp_reader * pfile, char *name); + +static int is_system_include(cpp_reader * pfile, char *filename); + +static int open_include_file(cpp_reader * pfile, char *filename, + file_name_list * searchptr); +static int check_macro_name(cpp_reader * pfile, unsigned char *symname, + const char *usage); + +static int compare_token_lists(struct arglist *l1, struct arglist *l2); +static HOST_WIDE_INT eval_if_expression(cpp_reader * pfile, unsigned char *buf, + int length); + +static int file_size_and_mode(int fd, int *mode_pointer, + long int *size_pointer); +static struct arglist *read_token_list(cpp_reader * pfile, int *error_flag); +static void free_token_list(struct arglist *tokens); +static int safe_read(int desc, char *ptr, int len); +static void push_macro_expansion(cpp_reader * pfile, + unsigned char *x, + int xbuf_len, HASHNODE * hp); + +static struct cpp_pending *nreverse_pending(struct cpp_pending *list); +static char *savestring(const char *input); + +static void conditional_skip(cpp_reader * pfile, int skip, + enum node_type type, + unsigned char *control_macro); +static void skip_if_group(cpp_reader * pfile, int any); + +static void cpp_error_with_line(cpp_reader * pfile, int line, + int column, const char *msg); +static void cpp_pedwarn_with_line(cpp_reader * pfile, int line, + int column, const char *msg); +static void cpp_pedwarn_with_file_and_line(cpp_reader * pfile, + const char *file, int line, + const char *msg, + const char *arg1, + const char *arg2, + const char *arg3); +static void cpp_error_from_errno(cpp_reader * pfile, const char *name); + +static cpp_buffer *cpp_push_buffer(cpp_reader * pfile, unsigned char *buffer, + long length); +static cpp_buffer *cpp_pop_buffer(cpp_reader * pfile); + +/* Last arg to output_line_command. */ +enum file_change_code { + same_file, enter_file, leave_file +}; + +/* These functions are declared to return int instead of void since they + * are going to be placed in a table and some old compilers have trouble with + * pointers to functions returning void. */ + +static int do_define(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_line(cpp_reader * pfile, struct directive *keyword, + unsigned char *unused1, unsigned char *unused2); + +static int do_include(cpp_reader * pfile, struct directive *keyword, + unsigned char *unused1, unsigned char *unused2); + +static int do_undef(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_error(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_pragma(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_ident(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_if(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_xifdef(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_else(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_elif(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_endif(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_assert(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_unassert(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +static int do_warning(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit); + +struct arglist *reverse_token_list(struct arglist *tokens); + +static int parse_name(cpp_reader * pfile, int c); + +static void parse_set_mark(struct parse_marker *pmark, + cpp_reader * pfile); +static void parse_clear_mark(struct parse_marker *pmark); +static void parse_goto_mark(struct parse_marker *pmark, + cpp_reader * pfile); +static void parse_move_mark(struct parse_marker *pmark, + cpp_reader * pfile); + +struct file_name_list { + file_name_list *next; + char *fname; + /* If the following is nonzero, it is a macro name. + * Don't include the file again if that macro is defined. */ + unsigned char *control_macro; + /* If the following is nonzero, it is a C-language system include + * directory. */ + int c_system_include_path; + /* Mapping of file names for this directory. */ + struct file_name_map *name_map; + /* Non-zero if name_map is valid. */ + int got_name_map; +}; + +/* If a buffer's dir field is SELF_DIR_DUMMY, it means the file was found + * via the same directory as the file that #included it. */ +#define SELF_DIR_DUMMY ((file_name_list*)(~0)) + +/* #include "file" looks in source file dir, then stack. */ +/* #include just looks in the stack. */ +/* -I directories are added to the end, then the defaults are added. */ +/* The */ +static struct default_include { + const char *fname; /* The name of the directory. */ + int cplusplus; /* Only look here if we're compiling C++. */ + int cxx_aware; /* Includes in this directory don't need to + * be wrapped in extern "C" when compiling + * C++. */ +} include_defaults_array[] +#ifdef INCLUDE_DEFAULTS + = INCLUDE_DEFAULTS; + +#else + = +{ + /* Pick up GNU C++ specific include files. */ + { + GPLUSPLUS_INCLUDE_DIR, 1, 1} + , +#ifdef CROSS_COMPILE + /* This is the dir for fixincludes. Put it just before + * the files that we fix. */ + { + GCC_INCLUDE_DIR, 0, 0} + , + /* For cross-compilation, this dir name is generated + * automatically in Makefile.in. */ + { + CROSS_INCLUDE_DIR, 0, 0} + , + /* This is another place that the target system's headers might be. */ + { + TOOL_INCLUDE_DIR, 0, 1} + , +#else /* not CROSS_COMPILE */ + /* This should be /usr/local/include and should come before + * the fixincludes-fixed header files. */ + { + LOCAL_INCLUDE_DIR, 0, 1} + , + /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here. + * Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h. */ + { + TOOL_INCLUDE_DIR, 0, 1} + , + /* This is the dir for fixincludes. Put it just before + * the files that we fix. */ + { + GCC_INCLUDE_DIR, 0, 0} + , + /* Some systems have an extra dir of include files. */ +#ifdef SYSTEM_INCLUDE_DIR + { + SYSTEM_INCLUDE_DIR, 0, 0} + , +#endif + { + STANDARD_INCLUDE_DIR, 0, 0} + , +#endif /* not CROSS_COMPILE */ + { + 0, 0, 0} +}; + +#endif /* no INCLUDE_DEFAULTS */ + +/* Here is the actual list of #-directives, most-often-used first. + * The initialize_builtins function assumes #define is the very first. */ + +static struct directive directive_table[] = { + {6, do_define, "define", T_DEFINE, 0, 1, 0}, + {5, do_xifdef, "ifdef", T_IFDEF, 1, 0, 0}, + {6, do_xifdef, "ifndef", T_IFNDEF, 1, 0, 0}, + {7, do_include, "include", T_INCLUDE, 1, 0, 0}, + {12, do_include, "include_next", T_INCLUDE_NEXT, 1, 0, 0}, + {6, do_include, "import", T_IMPORT, 1, 0, 0}, + {5, do_endif, "endif", T_ENDIF, 1, 0, 0}, + {4, do_else, "else", T_ELSE, 1, 0, 0}, + {2, do_if, "if", T_IF, 1, 0, 0}, + {4, do_elif, "elif", T_ELIF, 1, 0, 0}, + {5, do_undef, "undef", T_UNDEF, 0, 0, 0}, + {5, do_error, "error", T_ERROR, 0, 0, 0}, + {7, do_warning, "warning", T_WARNING, 0, 0, 0}, + {6, do_pragma, "pragma", T_PRAGMA, 0, 0, 1}, + {4, do_line, "line", T_LINE, 1, 0, 0}, + {5, do_ident, "ident", T_IDENT, 1, 0, 1}, +#ifdef SCCS_DIRECTIVE + {4, do_sccs, "sccs", T_SCCS, 0, 0, 0}, +#endif + {6, do_assert, "assert", T_ASSERT, 1, 0, 0}, + {8, do_unassert, "unassert", T_UNASSERT, 1, 0, 0}, + {-1, 0, "", T_UNUSED, 0, 0, 0}, +}; + +/* table to tell if char can be part of a C identifier. */ +unsigned char is_idchar[256]; + +/* table to tell if char can be first char of a c identifier. */ +unsigned char is_idstart[256]; + +/* table to tell if c is horizontal space. */ +unsigned char is_hor_space[256]; + +/* table to tell if c is horizontal or vertical space. */ +static unsigned char is_space[256]; + +/* Initialize syntactic classifications of characters. */ + +static void +initialize_char_syntax(struct cpp_options *opts) +{ + int i; + + /* + * Set up is_idchar and is_idstart tables. These should be + * faster than saying (is_alpha (c) || c == '_'), etc. + * Set up these things before calling any routines tthat + * refer to them. + */ + for (i = 'a'; i <= 'z'; i++) + { + is_idchar[i - 'a' + 'A'] = 1; + is_idchar[i] = 1; + is_idstart[i - 'a' + 'A'] = 1; + is_idstart[i] = 1; + } + for (i = '0'; i <= '9'; i++) + is_idchar[i] = 1; + is_idchar[(unsigned char)'_'] = 1; + is_idstart[(unsigned char)'_'] = 1; + is_idchar[(unsigned char)'$'] = opts->dollars_in_ident; + is_idstart[(unsigned char)'$'] = opts->dollars_in_ident; + + /* horizontal space table */ + is_hor_space[(unsigned char)' '] = 1; + is_hor_space[(unsigned char)'\t'] = 1; + is_hor_space[(unsigned char)'\v'] = 1; + is_hor_space[(unsigned char)'\f'] = 1; + is_hor_space[(unsigned char)'\r'] = 1; + + is_space[(unsigned char)' '] = 1; + is_space[(unsigned char)'\t'] = 1; + is_space[(unsigned char)'\v'] = 1; + is_space[(unsigned char)'\f'] = 1; + is_space[(unsigned char)'\n'] = 1; + is_space[(unsigned char)'\r'] = 1; +} + +/* Place into PFILE a quoted string representing the string SRC. + * Caller must reserve enough space in pfile->token_buffer. */ +static void +quote_string(cpp_reader * pfile, const char *src) +{ + unsigned char c; + + CPP_PUTC_Q(pfile, '\"'); + for (;;) + switch ((c = *src++)) + { + default: + if (isprint(c)) + CPP_PUTC_Q(pfile, c); + else + { + sprintf((char *)CPP_PWRITTEN(pfile), "\\%03o", c); + CPP_ADJUST_WRITTEN(pfile, 4); + } + break; + + case '\"': + case '\\': + CPP_PUTC_Q(pfile, '\\'); + CPP_PUTC_Q(pfile, c); + break; + + case '\0': + CPP_PUTC_Q(pfile, '\"'); + CPP_NUL_TERMINATE_Q(pfile); + return; + } +} + +/* Make sure PFILE->token_buffer will hold at least N more chars. */ + +void +cpp_grow_buffer(cpp_reader * pfile, long n) +{ + long old_written = CPP_WRITTEN(pfile); + + pfile->token_buffer_size = n + 2 * pfile->token_buffer_size; + pfile->token_buffer = + (unsigned char *)xrealloc(pfile->token_buffer, pfile->token_buffer_size); + CPP_SET_WRITTEN(pfile, old_written); +} + +/* + * process a given definition string, for initialization + * If STR is just an identifier, define it with value 1. + * If STR has anything after the identifier, then it should + * be identifier=definition. + */ + +void +cpp_define(cpp_reader * pfile, unsigned char *str) +{ + unsigned char *buf, *p; + + buf = str; + p = str; + if (!is_idstart[*p]) + { + cpp_error(pfile, "malformed option `-D %s'", str); + return; + } + while (is_idchar[*++p]) + ; + if (*p == 0) + { + buf = (unsigned char *)alloca(p - buf + 4); + strcpy((char *)buf, (const char *)str); + strcat((char *)buf, " 1"); + } + else if (*p != '=') + { + cpp_error(pfile, "malformed option `-D %s'", str); + return; + } + else + { + unsigned char *q; + + /* Copy the entire option so we can modify it. */ + buf = (unsigned char *)alloca(2 * strlen((char *)str) + 1); + strncpy((char *)buf, (const char *)str, p - str); + /* Change the = to a space. */ + buf[p - str] = ' '; + /* Scan for any backslash-newline and remove it. */ + p++; + q = &buf[p - str]; + while (*p) + { + if (*p == '\\' && p[1] == '\n') + p += 2; + else + *q++ = *p++; + } + *q = 0; + } + + do_define(pfile, NULL, buf, buf + strlen((char *)buf)); +} + +/* Process the string STR as if it appeared as the body of a #assert. + * OPTION is the option name for which STR was the argument. */ + +static void +make_assertion(cpp_reader * pfile, const char *option, const char *str) +{ + unsigned char *buf, *p, *q; + + /* Copy the entire option so we can modify it. */ + buf = (unsigned char *)alloca(strlen((char *)str) + 1); + strcpy((char *)buf, (const char *)str); + /* Scan for any backslash-newline and remove it. */ + p = q = buf; + while (*p) + { + *q++ = *p++; + } + *q = 0; + + p = buf; + if (!is_idstart[*p]) + { + cpp_error(pfile, "malformed option `%s %s'", option, str); + return; + } + while (is_idchar[*++p]) + ; + while (*p == ' ' || *p == '\t') + p++; + if (!(*p == 0 || *p == '(')) + { + cpp_error(pfile, "malformed option `%s %s'", option, str); + return; + } + cpp_push_buffer(pfile, buf, strlen((char *)buf)); + do_assert(pfile, NULL, NULL, NULL); + cpp_pop_buffer(pfile); +} + +/* Append a chain of `file_name_list's + * to the end of the main include chain. + * FIRST is the beginning of the chain to append, and LAST is the end. */ + +static void +append_include_chain(cpp_reader * pfile, file_name_list * first, + file_name_list * last) +{ + struct cpp_options *opts = CPP_OPTIONS(pfile); + file_name_list *dir; + + if (!first || !last) + return; + + if (!opts->include) + opts->include = first; + else + opts->last_include->next = first; + + if (!opts->first_bracket_include) + opts->first_bracket_include = first; + + for (dir = first;; dir = dir->next) + { + int len = strlen(dir->fname) + INCLUDE_LEN_FUDGE; + + if (len > pfile->max_include_len) + pfile->max_include_len = len; + if (dir == last) + break; + } + + last->next = NULL; + opts->last_include = last; +} + +/* Add output to `deps_buffer' for the -M switch. + * STRING points to the text to be output. + * SPACER is ':' for targets, ' ' for dependencies, zero for text + * to be inserted literally. */ + +static void +deps_output(cpp_reader * pfile, const char *string, int spacer) +{ + int size = strlen(string); + + if (size == 0) + return; + +#ifndef MAX_OUTPUT_COLUMNS +#define MAX_OUTPUT_COLUMNS 72 +#endif + if (spacer + && pfile->deps_column > 0 + && (pfile->deps_column + size) > MAX_OUTPUT_COLUMNS) + { + deps_output(pfile, " \\\n ", 0); + pfile->deps_column = 0; + } + if (pfile->deps_size + size + 8 > pfile->deps_allocated_size) + { + pfile->deps_allocated_size = (pfile->deps_size + size + 50) * 2; + pfile->deps_buffer = (char *)xrealloc(pfile->deps_buffer, + pfile->deps_allocated_size); + } + if (spacer == ' ' && pfile->deps_column > 0) + pfile->deps_buffer[pfile->deps_size++] = ' '; + memcpy(&pfile->deps_buffer[pfile->deps_size], string, size); + pfile->deps_size += size; + pfile->deps_column += size; + if (spacer == ':') + pfile->deps_buffer[pfile->deps_size++] = ':'; + pfile->deps_buffer[pfile->deps_size] = 0; +} + +/* Given a colon-separated list of file names PATH, + * add all the names to the search path for include files. */ + +static void +path_include(cpp_reader * pfile, char *path) +{ + char *p; + + p = path; + + if (*p) + while (1) + { + char *q = p; + char *name; + file_name_list *dirtmp; + + /* Find the end of this name. */ + while (*q != 0 && *q != PATH_SEPARATOR) + q++; + if (p == q) + { + /* An empty name in the path stands for the current directory. */ + name = (char *)xmalloc(2); + name[0] = '.'; + name[1] = 0; + } + else + { + /* Otherwise use the directory that is named. */ + name = (char *)xmalloc(q - p + 1); + memcpy(name, p, q - p); + name[q - p] = 0; + } + + dirtmp = (file_name_list *) xmalloc(sizeof(file_name_list)); + + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + dirtmp->fname = name; + dirtmp->got_name_map = 0; + append_include_chain(pfile, dirtmp, dirtmp); + + /* Advance past this name. */ + p = q; + if (*p == 0) + break; + /* Skip the colon. */ + p++; + } +} + +void +init_parse_options(struct cpp_options *opts) +{ + memset((char *)opts, 0, sizeof *opts); + opts->in_fname = NULL; + opts->out_fname = NULL; + + /* Initialize is_idchar to allow $. */ + opts->dollars_in_ident = 1; + initialize_char_syntax(opts); + opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 0; + + opts->no_line_commands = 0; + opts->no_trigraphs = 1; + opts->put_out_comments = 0; + opts->print_include_names = 0; + opts->dump_macros = dump_none; + opts->no_output = 0; + opts->cplusplus = 0; + opts->cplusplus_comments = 1; + + opts->verbose = 0; + opts->objc = 0; + opts->lang_asm = 0; + opts->for_lint = 0; + opts->chill = 0; + opts->pedantic_errors = 0; + opts->inhibit_warnings = 0; + opts->warn_comments = 0; + opts->warn_import = 1; + opts->warnings_are_errors = 0; +} + +static enum cpp_token +null_underflow(cpp_reader * pfile __UNUSED__) +{ + return CPP_EOF; +} + +static int +null_cleanup(cpp_buffer * pbuf __UNUSED__, cpp_reader * pfile __UNUSED__) +{ + return 0; +} + +static int +macro_cleanup(cpp_buffer * pbuf, cpp_reader * pfile __UNUSED__) +{ + HASHNODE *macro = (HASHNODE *) pbuf->data; + + if (macro->type == T_DISABLED) + macro->type = T_MACRO; + if (macro->type != T_MACRO || pbuf->buf != macro->value.defn->expansion) + free(pbuf->buf); + return 0; +} + +static int +file_cleanup(cpp_buffer * pbuf, cpp_reader * pfile __UNUSED__) +{ + if (pbuf->buf) + { + free(pbuf->buf); + pbuf->buf = 0; + } + return 0; +} + +/* Assuming we have read '/'. + * If this is the start of a comment (followed by '*' or '/'), + * skip to the end of the comment, and return ' '. + * Return EOF if we reached the end of file before the end of the comment. + * If not the start of a comment, return '/'. */ + +static int +skip_comment(cpp_reader * pfile, long *linep) +{ + int c = 0; + + while (PEEKC() == '\\' && PEEKN(1) == '\n') + { + if (linep) + (*linep)++; + FORWARD(2); + } + if (PEEKC() == '*') + { + FORWARD(1); + for (;;) + { + int prev_c = c; + + c = GETC(); + if (c == EOF) + return EOF; + while (c == '\\' && PEEKC() == '\n') + { + if (linep) + (*linep)++; + FORWARD(1), c = GETC(); + } + if (prev_c == '*' && c == '/') + return ' '; + if (c == '\n' && linep) + (*linep)++; + } + } + else if (PEEKC() == '/' && CPP_OPTIONS(pfile)->cplusplus_comments) + { + FORWARD(1); + for (;;) + { + c = GETC(); + if (c == EOF) + return ' '; /* Allow // to be terminated by EOF. */ + while (c == '\\' && PEEKC() == '\n') + { + FORWARD(1); + c = GETC(); + if (linep) + (*linep)++; + } + if (c == '\n') + { + /* Don't consider final '\n' to be part of comment. */ + FORWARD(-1); + return ' '; + } + } + } + else + return '/'; +} + +/* Skip whitespace \-newline and comments. Does not macro-expand. */ +void +cpp_skip_hspace(cpp_reader * pfile) +{ + while (1) + { + int c = PEEKC(); + + if (c == EOF) + return; /* FIXME */ + if (is_hor_space[c]) + { + if ((c == '\f' || c == '\v') && CPP_PEDANTIC(pfile)) + cpp_pedwarn(pfile, "%s in preprocessing directive", + c == '\f' ? "formfeed" : "vertical tab"); + FORWARD(1); + } + else if (c == '/') + { + FORWARD(1); + c = skip_comment(pfile, NULL); + if (c == '/') + FORWARD(-1); + if (c == EOF || c == '/') + return; + } + else if (c == '\\' && PEEKN(1) == '\n') + { + FORWARD(2); + } + else if (c == '@' && CPP_BUFFER(pfile)->has_escapes + && is_hor_space[PEEKN(1)]) + { + FORWARD(1); + } + else + return; + } +} + +/* Read the rest of the current line. + * The line is appended to PFILE's output buffer. */ + +static void +copy_rest_of_line(cpp_reader * pfile) +{ + struct cpp_options *opts = CPP_OPTIONS(pfile); + + for (;;) + { + int c = GETC(); + int nextc; + + switch (c) + { + case EOF: + goto end_directive; + case '\\': + if (PEEKC() == '\n') + { + FORWARD(1); + continue; + } + case '\'': + case '\"': + goto scan_directive_token; + break; + case '/': + nextc = PEEKC(); + if (nextc == '*' || (opts->cplusplus_comments && nextc == '*')) + goto scan_directive_token; + break; + case '\f': + case '\v': + if (CPP_PEDANTIC(pfile)) + cpp_pedwarn(pfile, "%s in preprocessing directive", + c == '\f' ? "formfeed" : "vertical tab"); + break; + + case '\n': + FORWARD(-1); + goto end_directive; + scan_directive_token: + FORWARD(-1); + cpp_get_token(pfile); + continue; + } + CPP_PUTC(pfile, c); + } + end_directive:; + CPP_NUL_TERMINATE(pfile); +} + +void +skip_rest_of_line(cpp_reader * pfile) +{ + long old = CPP_WRITTEN(pfile); + + copy_rest_of_line(pfile); + CPP_SET_WRITTEN(pfile, old); +} + +/* Handle a possible # directive. + * '#' has already been read. */ + +static int +handle_directive(cpp_reader * pfile) +{ + int c; + struct directive *kt; + int ident_length; + long after_ident = 0; + unsigned char *ident, *line_end; + long old_written = CPP_WRITTEN(pfile); + + cpp_skip_hspace(pfile); + + c = PEEKC(); + if (c >= '0' && c <= '9') + { + /* Handle # followed by a line number. */ + if (CPP_PEDANTIC(pfile)) + cpp_pedwarn(pfile, "`#' followed by integer"); + do_line(pfile, NULL, NULL, NULL); + goto done_a_directive; + } + /* Now find the directive name. */ + CPP_PUTC(pfile, '#'); + parse_name(pfile, GETC()); + ident = pfile->token_buffer + old_written + 1; + ident_length = CPP_PWRITTEN(pfile) - ident; + if (ident_length == 0 && PEEKC() == '\n') + { + /* A line of just `#' becomes blank. */ + goto done_a_directive; + } + /* + * Decode the keyword and call the appropriate expansion + * routine, after moving the input pointer up to the next line. + */ + for (kt = directive_table;; kt++) + { + if (kt->length <= 0) + goto not_a_directive; + if (kt->length == ident_length + && !strncmp(kt->name, (const char *)ident, ident_length)) + break; + } + + if (!kt->command_reads_line) + { + /* Nonzero means do not delete comments within the directive. + * #define needs this when -traditional. */ + int comments = 0; + int save_put_out_comments = + CPP_OPTIONS(pfile)->put_out_comments; + + CPP_OPTIONS(pfile)->put_out_comments = comments; + after_ident = CPP_WRITTEN(pfile); + copy_rest_of_line(pfile); + CPP_OPTIONS(pfile)->put_out_comments = save_put_out_comments; + } + /* For #pragma and #define, we may want to pass through the directive. + * Other directives may create output, but we don't want the directive + * itself out, so we pop it now. For example #include may write a #line + * command (see comment in do_include), and conditionals may emit + * #failed ... #endfailed stuff. But note that popping the buffer + * means the parameters to kt->func may point after pfile->limit + * so these parameters are invalid as soon as something gets appended + * to the token_buffer. */ + + line_end = CPP_PWRITTEN(pfile); + if (!kt->pass_thru && kt->type != T_DEFINE) + CPP_SET_WRITTEN(pfile, old_written); + + (*kt->func) (pfile, kt, pfile->token_buffer + after_ident, line_end); + if (kt->pass_thru + || (kt->type == T_DEFINE + && CPP_OPTIONS(pfile)->dump_macros == dump_definitions)) + { + /* Just leave the entire #define in the output stack. */ + } + else if (kt->type == T_DEFINE + && CPP_OPTIONS(pfile)->dump_macros == dump_names) + { + unsigned char *p = pfile->token_buffer + old_written + 7; /* Skip "#define". */ + + SKIP_WHITE_SPACE(p); + while (is_idchar[*p]) + p++; + pfile->limit = p; + CPP_PUTC(pfile, '\n'); + } + else if (kt->type == T_DEFINE) + CPP_SET_WRITTEN(pfile, old_written); + done_a_directive: + return 1; + + not_a_directive: + return 0; +} + +/* Pass a directive through to the output file. + * BUF points to the contents of the directive, as a contiguous string. + * LIMIT points to the first character past the end of the directive. + * KEYWORD is the keyword-table entry for the directive. */ + +static void +pass_thru_directive(char *buf, char *limit, cpp_reader * pfile, + struct directive *keyword) +{ + unsigned keyword_length = keyword->length; + + CPP_RESERVE(pfile, 1 + keyword_length + (limit - buf)); + CPP_PUTC_Q(pfile, '#'); + CPP_PUTS_Q(pfile, keyword->name, keyword_length); + if (limit != buf && buf[0] != ' ') + CPP_PUTC_Q(pfile, ' '); + CPP_PUTS_Q(pfile, buf, limit - buf); +} + +/* The arglist structure is built by do_define to tell + * collect_definition where the argument names begin. That + * is, for a define like "#define f(x,y,z) foo+x-bar*y", the arglist + * would contain pointers to the strings x, y, and z. + * Collect_definition would then build a DEFINITION node, + * with reflist nodes pointing to the places x, y, and z had + * appeared. So the arglist is just convenience data passed + * between these two routines. It is not kept around after + * the current #define has been processed and entered into the + * hash table. */ + +struct arglist { + struct arglist *next; + char *name; + int length; + int argno; + char rest_args; +}; + +/* Read a replacement list for a macro with parameters. + * Build the DEFINITION structure. + * Reads characters of text starting at BUF until END. + * ARGLIST specifies the formal parameters to look for + * in the text of the definition; NARGS is the number of args + * in that list, or -1 for a macro name that wants no argument list. + * MACRONAME is the macro name itself (so we can avoid recursive expansion) + * and NAMELEN is its length in characters. + * + * Note that comments, backslash-newlines, and leading white space + * have already been deleted from the argument. */ + +static DEFINITION * +collect_expansion(cpp_reader * pfile, unsigned char *buf, unsigned char *limit, + int nargs, struct arglist *arglist) +{ + DEFINITION *defn; + unsigned char *p, *lastp, *exp_p; + reflist *endpat = NULL; + + /* Pointer to first nonspace after last ## seen. */ + unsigned char *concat = 0; + + /* Pointer to first nonspace after last single-# seen. */ + unsigned char *stringify = 0; + int maxsize; + int expected_delimiter = '\0'; + + /* Scan thru the replacement list, ignoring comments and quoted + * strings, picking up on the macro calls. It does a linear search + * thru the arg list on every potential symbol. Profiling might say + * that something smarter should happen. */ + + if (limit < buf) + abort(); + + /* Find the beginning of the trailing whitespace. */ + p = buf; + while (p < limit && is_space[limit[-1]]) + limit--; + + /* Allocate space for the text in the macro definition. + * Leading and trailing whitespace chars need 2 bytes each. + * Each other input char may or may not need 1 byte, + * so this is an upper bound. The extra 5 are for invented + * leading and trailing newline-marker and final null. */ + maxsize = (sizeof(DEFINITION) + (limit - p) + 5); + /* Occurrences of '@' get doubled, so allocate extra space for them. */ + while (p < limit) + if (*p++ == '@') + maxsize++; + defn = (DEFINITION *) xcalloc(1, maxsize); + + defn->nargs = nargs; + exp_p = defn->expansion = (unsigned char *)defn + sizeof(DEFINITION); + lastp = exp_p; + + p = buf; + + /* Add one initial space escape-marker to prevent accidental + * token-pasting (often removed by macroexpand). */ + *exp_p++ = '@'; + *exp_p++ = ' '; + + if (limit - p >= 2 && p[0] == '#' && p[1] == '#') + { + cpp_error(pfile, "`##' at start of macro definition"); + p += 2; + } + /* Process the main body of the definition. */ + while (p < limit) + { + int skipped_arg = 0; + unsigned char c = *p++; + + *exp_p++ = c; + + switch (c) + { + case '\'': + case '\"': + if (expected_delimiter != '\0') + { + if (c == expected_delimiter) + expected_delimiter = '\0'; + } + else + expected_delimiter = c; + break; + + case '\\': + if (p < limit && expected_delimiter) + { + /* In a string, backslash goes through + * and makes next char ordinary. */ + *exp_p++ = *p++; + } + break; + + case '@': + /* An '@' in a string or character constant stands for itself, + * and does not need to be escaped. */ + if (!expected_delimiter) + *exp_p++ = c; + break; + + case '#': + /* # is ordinary inside a string. */ + if (expected_delimiter) + break; + if (p < limit && *p == '#') + { + /* ##: concatenate preceding and following tokens. */ + /* Take out the first #, discard preceding whitespace. */ + exp_p--; + while (exp_p > lastp && is_hor_space[exp_p[-1]]) + --exp_p; + /* Skip the second #. */ + p++; + /* Discard following whitespace. */ + SKIP_WHITE_SPACE(p); + concat = p; + if (p == limit) + cpp_error(pfile, "`##' at end of macro definition"); + } + else if (nargs >= 0) + { + /* Single #: stringify following argument ref. + * Don't leave the # in the expansion. */ + exp_p--; + SKIP_WHITE_SPACE(p); + if (p == limit || !is_idstart[*p]) + cpp_error(pfile, + "`#' operator is not followed by a macro argument name"); + else + stringify = p; + } + break; + } + + /* Handle the start of a symbol. */ + if (is_idchar[c] && nargs > 0) + { + unsigned char *id_beg = p - 1; + int id_len; + + --exp_p; + while (p != limit && is_idchar[*p]) + p++; + id_len = p - id_beg; + + if (is_idstart[c]) + { + struct arglist *arg; + + for (arg = arglist; arg; arg = arg->next) + { + reflist *tpat; + + if (arg->name[0] == c + && arg->length == id_len + && strncmp((const char *)arg->name, + (const char *)id_beg, id_len) == 0) + { + if (expected_delimiter + && CPP_OPTIONS(pfile)->warn_stringify) + { + cpp_warning(pfile, + "macro arg `%.*s' would be stringified with -traditional.", + id_len, arg->name); + } + /* If ANSI, don't actually substitute inside a string. */ + if (expected_delimiter) + break; + /* make a pat node for this arg and append it to the end of + * the pat list */ + tpat = (reflist *) xmalloc(sizeof(reflist)); + + tpat->next = NULL; + tpat->raw_before = concat == id_beg; + tpat->raw_after = 0; + tpat->rest_args = arg->rest_args; + tpat->stringify = (stringify == id_beg); + + if (!endpat) + defn->pattern = tpat; + else + endpat->next = tpat; + endpat = tpat; + + tpat->argno = arg->argno; + tpat->nchars = exp_p - lastp; + { + unsigned char *p1 = p; + + SKIP_WHITE_SPACE(p1); + if (p1 + 2 <= limit && p1[0] == '#' + && p1[1] == '#') + tpat->raw_after = 1; + } + lastp = exp_p; /* place to start copying from next time */ + skipped_arg = 1; + break; + } + } + } + /* If this was not a macro arg, copy it into the expansion. */ + if (!skipped_arg) + { + unsigned char *lim1 = p; + + p = id_beg; + while (p != lim1) + *exp_p++ = *p++; + if (stringify == id_beg) + cpp_error(pfile, + "`#' operator should be followed by a macro argument name"); + } + } + } + + if (expected_delimiter == 0) + { + /* If ANSI, put in a "@ " marker to prevent token pasting. + * But not if "inside a string" (which in ANSI mode + * happens only for -D option). */ + *exp_p++ = '@'; + *exp_p++ = ' '; + } + *exp_p = '\0'; + + defn->length = exp_p - defn->expansion; + + /* Crash now if we overrun the allocated size. */ + if (defn->length + 1 > maxsize) + abort(); + + return defn; +} + +/* + * special extension string that can be added to the last macro argument to + * allow it to absorb the "rest" of the arguments when expanded. Ex: + * #define wow(a, b...) process (b, a, b) + * { wow (1, 2, 3); } -> { process (2, 3, 1, 2, 3); } + * { wow (one, two); } -> { process (two, one, two); } + * if this "rest_arg" is used with the concat token '##' and if it is not + * supplied then the token attached to with ## will not be outputted. Ex: + * #define wow (a, b...) process (b ## , a, ## b) + * { wow (1, 2); } -> { process (2, 1, 2); } + * { wow (one); } -> { process (one); { + */ +static char rest_extension[] = "..."; + +#define REST_EXTENSION_LENGTH (sizeof (rest_extension) - 1) + +/* Create a DEFINITION node from a #define directive. Arguments are + * as for do_define. */ +static void +create_definition(MACRODEF * mdef, unsigned char *buf, unsigned char *limit, + cpp_reader * pfile, int predefinition) +{ + unsigned char *bp; /* temp ptr into input buffer */ + unsigned char *symname; /* remember where symbol name starts */ + int sym_length; /* and how long it is */ + int rest_args = 0; + long line, col; + const char *file = + CPP_BUFFER(pfile) ? CPP_BUFFER(pfile)->nominal_fname : ""; + DEFINITION *defn; + int arglengths = 0; /* Accumulate lengths of arg names + * plus number of args. */ + + cpp_buf_line_and_col(CPP_BUFFER(pfile), &line, &col); + + bp = buf; + + while (is_hor_space[*bp]) + bp++; + + symname = bp; /* remember where it starts */ + + sym_length = check_macro_name(pfile, bp, "macro"); + bp += sym_length; + + /* Lossage will occur if identifiers or control keywords are broken + * across lines using backslash. This is not the right place to take + * care of that. */ + + if (*bp == '(') + { + struct arglist *arg_ptrs = NULL; + int argno = 0; + + bp++; /* skip '(' */ + SKIP_WHITE_SPACE(bp); + + /* Loop over macro argument names. */ + while (*bp != ')') + { + struct arglist *temp; + + temp = (struct arglist *)alloca(sizeof(struct arglist)); + + temp->name = (char *)bp; + temp->next = arg_ptrs; + temp->argno = argno++; + temp->rest_args = 0; + arg_ptrs = temp; + + if (rest_args) + cpp_pedwarn(pfile, "another parameter follows `%s'", + rest_extension); + + if (!is_idstart[*bp]) + cpp_pedwarn(pfile, "invalid character in macro parameter name"); + + /* Find the end of the arg name. */ + while (is_idchar[*bp]) + { + bp++; + /* do we have a "special" rest-args extension here? */ + if ((unsigned)(limit - bp) > REST_EXTENSION_LENGTH && + strncmp(rest_extension, (const char *)bp, + REST_EXTENSION_LENGTH) == 0) + { + rest_args = 1; + temp->rest_args = 1; + break; + } + } + temp->length = (char *)bp - temp->name; + if (rest_args == 1) + bp += REST_EXTENSION_LENGTH; + arglengths += temp->length + 2; + SKIP_WHITE_SPACE(bp); + if (temp->length == 0 || (*bp != ',' && *bp != ')')) + { + cpp_error(pfile, + "badly punctuated parameter list in `#define'"); + goto nope; + } + if (*bp == ',') + { + bp++; + SKIP_WHITE_SPACE(bp); + } + if (bp >= limit) + { + cpp_error(pfile, "unterminated parameter list in `#define'"); + goto nope; + } + { + struct arglist *otemp; + + for (otemp = temp->next; otemp; otemp = otemp->next) + if (temp->length == otemp->length && + strncmp((const char *)temp->name, + (const char *)otemp->name, temp->length) == 0) + { + char *name; + + name = (char *)alloca(temp->length + 1); + strncpy(name, (const char *)temp->name, temp->length); + name[temp->length] = '\0'; + cpp_error(pfile, + "duplicate argument name `%s' in `#define'", + name); + goto nope; + } + } + } + + ++bp; /* skip paren */ + SKIP_WHITE_SPACE(bp); + /* now everything from bp before limit is the definition. */ + defn = collect_expansion(pfile, bp, limit, argno, arg_ptrs); + defn->rest_args = rest_args; + + /* Now set defn->args.argnames to the result of concatenating + * the argument names in reverse order + * with comma-space between them. */ + defn->args.argnames = (unsigned char *)xmalloc(arglengths + 1); + { + struct arglist *temp; + int i = 0; + + for (temp = arg_ptrs; temp; temp = temp->next) + { + memcpy(&defn->args.argnames[i], temp->name, temp->length); + i += temp->length; + if (temp->next) + { + defn->args.argnames[i++] = ','; + defn->args.argnames[i++] = ' '; + } + } + defn->args.argnames[i] = 0; + } + } + else + { + /* Simple expansion or empty definition. */ + + if (bp < limit) + { + if (is_hor_space[*bp]) + { + bp++; + SKIP_WHITE_SPACE(bp); + } + else + { + switch (*bp) + { + case '!': + case '"': + case '#': + case '%': + case '&': + case '\'': + case ')': + case '*': + case '+': + case ',': + case '-': + case '.': + case '/': + case ':': + case ';': + case '<': + case '=': + case '>': + case '?': + case '[': + case '\\': + case ']': + case '^': + case '{': + case '|': + case '}': + case '~': + cpp_warning(pfile, + "missing white space after `#define %.*s'", + sym_length, symname); + break; + + default: + cpp_pedwarn(pfile, + "missing white space after `#define %.*s'", + sym_length, symname); + break; + } + } + } + /* now everything from bp before limit is the definition. */ + defn = collect_expansion(pfile, bp, limit, -1, NULL); + defn->args.argnames = (unsigned char *)""; + } + + defn->line = line; + defn->file = file; + + /* OP is null if this is a predefinition */ + defn->predefined = predefinition; + mdef->defn = defn; + mdef->symnam = (char *)symname; + mdef->symlen = sym_length; + + return; + + nope: + mdef->defn = 0; +} + +/* Check a purported macro name SYMNAME, and yield its length. + * USAGE is the kind of name this is intended for. */ + +static int +check_macro_name(cpp_reader * pfile, unsigned char *symname, const char *usage) +{ + unsigned char *p; + int sym_length; + + for (p = symname; is_idchar[*p]; p++) + ; + sym_length = p - symname; + if (sym_length == 0) + { + cpp_error(pfile, "invalid %s name", usage); + } + else if (!is_idstart[*symname]) + { + unsigned char *msg; /* what pain... */ + + msg = (unsigned char *)alloca(sym_length + 1); + memcpy(msg, symname, sym_length); + msg[sym_length] = 0; + cpp_error(pfile, "invalid %s name `%s'", usage, msg); + } + else + { + if (!strncmp((const char *)symname, "defined", 7) && sym_length == 7) + cpp_error(pfile, "invalid %s name `defined'", usage); + } + return sym_length; +} + +/* + * return zero if two DEFINITIONs are isomorphic + */ +static int +compare_defs(DEFINITION * d1, DEFINITION * d2) +{ + reflist *a1, *a2; + unsigned char *p1 = d1->expansion; + unsigned char *p2 = d2->expansion; + int first = 1; + + if (d1->nargs != d2->nargs) + return 1; + if (strcmp((char *)d1->args.argnames, (char *)d2->args.argnames)) + return 1; + for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2; + a1 = a1->next, a2 = a2->next) + { + if (! + ((a1->nchars == a2->nchars + && !strncmp((const char *)p1, (const char *)p2, a1->nchars)) + || !comp_def_part(first, p1, a1->nchars, p2, a2->nchars, 0)) + || a1->argno != a2->argno || a1->stringify != a2->stringify + || a1->raw_before != a2->raw_before + || a1->raw_after != a2->raw_after) + return 1; + first = 0; + p1 += a1->nchars; + p2 += a2->nchars; + } + if (a1 != a2) + return 1; + if (comp_def_part(first, p1, d1->length - (p1 - d1->expansion), + p2, d2->length - (p2 - d2->expansion), 1)) + return 1; + return 0; +} + +/* Return 1 if two parts of two macro definitions are effectively different. + * One of the parts starts at BEG1 and has LEN1 chars; + * the other has LEN2 chars at BEG2. + * Any sequence of whitespace matches any other sequence of whitespace. + * FIRST means these parts are the first of a macro definition; + * so ignore leading whitespace entirely. + * LAST means these parts are the last of a macro definition; + * so ignore trailing whitespace entirely. */ + +static int +comp_def_part(int first, unsigned char *beg1, int len1, + unsigned char *beg2, int len2, int last) +{ + unsigned char *end1 = beg1 + len1; + unsigned char *end2 = beg2 + len2; + + if (first) + { + while (beg1 != end1 && is_space[*beg1]) + beg1++; + while (beg2 != end2 && is_space[*beg2]) + beg2++; + } + if (last) + { + while (beg1 != end1 && is_space[end1[-1]]) + end1--; + while (beg2 != end2 && is_space[end2[-1]]) + end2--; + } + while (beg1 != end1 && beg2 != end2) + { + if (is_space[*beg1] && is_space[*beg2]) + { + while (beg1 != end1 && is_space[*beg1]) + beg1++; + while (beg2 != end2 && is_space[*beg2]) + beg2++; + } + else if (*beg1 == *beg2) + { + beg1++; + beg2++; + } + else + break; + } + return (beg1 != end1) || (beg2 != end2); +} + +/* Process a #define command. + * BUF points to the contents of the #define command, as a contiguous string. + * LIMIT points to the first character past the end of the definition. + * KEYWORD is the keyword-table entry for #define, + * or NULL for a "predefined" macro. */ + +static int +do_define(cpp_reader * pfile, struct directive *keyword, + unsigned char *buf, unsigned char *limit) +{ + int hashcode; + MACRODEF mdef; + HASHNODE *hp; + + create_definition(&mdef, buf, limit, pfile, !keyword); + if (!mdef.defn) + return 1; + + hashcode = hashf(mdef.symnam, mdef.symlen, HASHSIZE); + + if ((hp = cpp_lookup(mdef.symnam, mdef.symlen, hashcode))) + { + int ok = 0; + + /* Redefining a precompiled key is ok. */ + if (hp->type == T_PCSTRING) + ok = 1; + /* Redefining a macro is ok if the definitions are the same. */ + else if (hp->type == T_MACRO) + ok = !compare_defs(mdef.defn, hp->value.defn); + /* Redefining a constant is ok with -D. */ + else if (hp->type == T_CONST) + ok = !CPP_OPTIONS(pfile)->done_initializing; + /* Print the warning if it's not ok. */ + if (!ok) + { + char *msg; /* what pain... */ + + /* If we are passing through #define and #undef directives, do + * that for this re-definition now. */ + if (CPP_OPTIONS(pfile)->debug_output && keyword) + pass_thru_directive((char *)buf, (char *)limit, pfile, keyword); + + msg = (char *)alloca(mdef.symlen + 22); + *msg = '`'; + memcpy(msg + 1, mdef.symnam, mdef.symlen); + strcpy((msg + mdef.symlen + 1), "' redefined"); + cpp_pedwarn(pfile, msg); + if (hp->type == T_MACRO) + cpp_pedwarn_with_file_and_line(pfile, hp->value.defn->file, + hp->value.defn->line, + "this is the location of the previous definition", + NULL, NULL, NULL); + } + /* Replace the old definition. */ + hp->type = T_MACRO; + hp->value.defn = mdef.defn; + } + else + { + /* If we are passing through #define and #undef directives, do + * that for this new definition now. */ + if (CPP_OPTIONS(pfile)->debug_output && keyword) + pass_thru_directive((char *)buf, (char *)limit, pfile, keyword); + install(mdef.symnam, mdef.symlen, T_MACRO, 0, + (char *)mdef.defn, hashcode); + } + + return 0; +} + +/* This structure represents one parsed argument in a macro call. + * `raw' points to the argument text as written (`raw_length' is its length). + * `expanded' points to the argument's macro-expansion + * (its length is `expand_length'). + * `stringified_length' is the length the argument would have + * if stringified. + * `use_count' is the number of times this macro arg is substituted + * into the macro. If the actual use count exceeds 10, + * the value stored is 10. */ + +/* raw and expanded are relative to ARG_BASE */ +#define ARG_BASE ((pfile)->token_buffer) + +struct argdata { + /* Strings relative to pfile->token_buffer */ + long raw, expanded, stringified; + int raw_length, expand_length; + int stringified_length; + char newlines; + char use_count; +}; + +cpp_buffer * +cpp_push_buffer(cpp_reader * pfile, unsigned char *buffer, long length) +{ +#ifdef STATIC_BUFFERS + cpp_buffer *buf = CPP_BUFFER(pfile); + + if (buf == pfile->buffer_stack) + cpp_fatal("macro or `#include' recursion too deep"); + buf--; + memset((char *)buf, 0, sizeof(cpp_buffer)); + CPP_BUFFER(pfile) = buf; +#else + cpp_buffer *buf = (cpp_buffer *) xmalloc(sizeof(cpp_buffer)); + + memset((char *)buf, 0, sizeof(cpp_buffer)); + CPP_PREV_BUFFER(buf) = CPP_BUFFER(pfile); + CPP_BUFFER(pfile) = buf; +#endif + buf->if_stack = pfile->if_stack; + buf->cleanup = null_cleanup; + buf->underflow = null_underflow; + buf->buf = buf->cur = buffer; + buf->alimit = buf->rlimit = buffer + length; + + return buf; +} + +static cpp_buffer * +cpp_pop_buffer(cpp_reader * pfile) +{ + cpp_buffer *buf = CPP_BUFFER(pfile); + +#ifdef STATIC_BUFFERS + (*buf->cleanup) (buf, pfile); + return ++CPP_BUFFER(pfile); +#else + cpp_buffer *next_buf = CPP_PREV_BUFFER(buf); + + (*buf->cleanup) (buf, pfile); + CPP_BUFFER(pfile) = next_buf; + free(buf); + return next_buf; +#endif +} + +/* Scan until CPP_BUFFER (PFILE) is exhausted into PFILE->token_buffer. + * Pop the buffer when done. */ + +static void +cpp_scan_buffer(cpp_reader * pfile) +{ + cpp_buffer *buffer = CPP_BUFFER(pfile); + + for (;;) + { + enum cpp_token token = cpp_get_token(pfile); + + if (token == CPP_EOF) /* Should not happen ... */ + break; + if (token == CPP_POP && CPP_BUFFER(pfile) == buffer) + { + cpp_pop_buffer(pfile); + break; + } + } +} + +/* + * Rescan a string (which may have escape marks) into pfile's buffer. + * Place the result in pfile->token_buffer. + * + * The input is copied before it is scanned, so it is safe to pass + * it something from the token_buffer that will get overwritten + * (because it follows CPP_WRITTEN). This is used by do_include. + */ + +static void +cpp_expand_to_buffer(cpp_reader * pfile, unsigned char *buf, int length) +{ + cpp_buffer *ip; + unsigned char *limit = buf + length; + unsigned char *buf1; + + if (length < 0) + abort(); + + /* Set up the input on the input stack. */ + + buf1 = (unsigned char *)alloca(length + 1); + { + unsigned char *p1 = buf; + unsigned char *p2 = buf1; + int in_string = 0; + +#if 0 /* old behavior */ + while (p1 != limit) *p2++ = *p1++; +#else /* new one - handle \ escapes if not in string */ + while (p1 != limit) + { + if (!in_string) + { + if (*p1 == '"') in_string = 1; + if (*p1 == '\\') + { + p1++; + if (p1 != limit) *p2++ = *p1++; + } + else + *p2++ = *p1++; + } + else + { + if ((*p1 == '"') && (p1 > buf) && (p1[-1] != '\\')) + in_string = 0; + *p2++ = *p1++; + } + } +#endif + *p2 = 0; + length = p2 - buf1; + } + + ip = cpp_push_buffer(pfile, buf1, length); + ip->has_escapes = 1; + + /* Scan the input, create the output. */ + cpp_scan_buffer(pfile); + + CPP_NUL_TERMINATE(pfile); +} + +static void +adjust_position(unsigned char *buf, unsigned char *limit, long *linep, + long *colp) +{ + while (buf < limit) + { + unsigned char ch = *buf++; + + if (ch == '\n') + (*linep)++, (*colp) = 1; + else + (*colp)++; + } +} + +/* Move line_base forward, updating lineno and colno. */ + +static void +update_position(cpp_buffer * pbuf) +{ + unsigned char *old_pos = pbuf->buf + pbuf->line_base; + unsigned char *new_pos = pbuf->cur; + struct parse_marker *mark; + + for (mark = pbuf->marks; mark; mark = mark->next) + { + if (pbuf->buf + mark->position < new_pos) + new_pos = pbuf->buf + mark->position; + } + pbuf->line_base += new_pos - old_pos; + adjust_position(old_pos, new_pos, &pbuf->lineno, &pbuf->colno); +} + +void +cpp_buf_line_and_col(cpp_buffer * pbuf, long *linep, long *colp) +{ + long dummy; + + if (!colp) + colp = &dummy; + if (pbuf) + { + *linep = pbuf->lineno; + *colp = pbuf->colno; + adjust_position(pbuf->buf + pbuf->line_base, pbuf->cur, linep, colp); + } + else + { + *linep = 0; + *colp = 0; + } +} + +/* Return the cpp_buffer that corresponds to a file (not a macro). */ + +cpp_buffer * +cpp_file_buffer(cpp_reader * pfile) +{ + cpp_buffer *ip = CPP_BUFFER(pfile); + + for (; ip != CPP_NULL_BUFFER(pfile); ip = CPP_PREV_BUFFER(ip)) + if (ip->fname) + return ip; + return NULL; +} + +static long +count_newlines(unsigned char *buf, unsigned char *limit) +{ + long count = 0; + + while (buf < limit) + { + unsigned char ch = *buf++; + + if (ch == '\n') + count++; + } + return count; +} + +/* + * write out a #line command, for instance, after an #include file. + * If CONDITIONAL is nonzero, we can omit the #line if it would + * appear to be a no-op, and we can output a few newlines instead + * if we want to increase the line number by a small amount. + * FILE_CHANGE says whether we are entering a file, leaving, or neither. + */ + +static void +output_line_command(cpp_reader * pfile, int conditional, + enum file_change_code file_change) +{ + long line, col; + cpp_buffer *ip = CPP_BUFFER(pfile); + + if (CPP_OPTIONS(pfile)->no_line_commands + || !ip->fname || CPP_OPTIONS(pfile)->no_output) + { + return; + } + update_position(ip); + line = CPP_BUFFER(pfile)->lineno; + col = CPP_BUFFER(pfile)->colno; + adjust_position(CPP_LINE_BASE(ip), ip->cur, &line, &col); + + if (conditional) + { + if (line == pfile->lineno) + return; + + /* If the inherited line number is a little too small, + * output some newlines instead of a #line command. */ + if (line > pfile->lineno && line < pfile->lineno + 8) + { + CPP_RESERVE(pfile, 20); + while (line > pfile->lineno) + { + CPP_PUTC_Q(pfile, '\n'); + pfile->lineno++; + } + return; + } + } + + CPP_RESERVE(pfile, 4 * strlen(ip->nominal_fname) + 50); + { + static char sharp_line[] = "#line "; + + CPP_PUTS_Q(pfile, sharp_line, sizeof(sharp_line) - 1); + } + + sprintf((char *)CPP_PWRITTEN(pfile), "%d ", (int)line); + CPP_ADJUST_WRITTEN(pfile, strlen((char *)CPP_PWRITTEN(pfile))); + + quote_string(pfile, ip->nominal_fname); + if (file_change != same_file) + { + CPP_PUTC_Q(pfile, ' '); + CPP_PUTC_Q(pfile, file_change == enter_file ? '1' : '2'); + } + /* Tell cc1 if following text comes from a system header file. */ + if (ip->system_header_p) + { + CPP_PUTC_Q(pfile, ' '); + CPP_PUTC_Q(pfile, '3'); + } +#ifndef NO_IMPLICIT_EXTERN_C + /* Tell cc1plus if following text should be treated as C. */ + if (ip->system_header_p == 2 && CPP_OPTIONS(pfile)->cplusplus) + { + CPP_PUTC_Q(pfile, ' '); + CPP_PUTC_Q(pfile, '4'); + } +#endif + CPP_PUTC_Q(pfile, '\n'); + pfile->lineno = line; +} + +/* + * Parse a macro argument and append the info on PFILE's token_buffer. + * REST_ARGS means to absorb the rest of the args. + * Return nonzero to indicate a syntax error. + */ + +static enum cpp_token +macarg(cpp_reader * pfile, int rest_args) +{ + int paren = 0; + enum cpp_token token; + char save_put_out_comments = + CPP_OPTIONS(pfile)->put_out_comments; + + CPP_OPTIONS(pfile)->put_out_comments = 0; + + token = CPP_OTHER; + /* Try to parse as much of the argument as exists at this + * input stack level. */ + pfile->no_macro_expand++; + for (;;) + { + token = cpp_get_token(pfile); + switch (token) + { + case CPP_EOF: + goto done; + case CPP_POP: + /* If we've hit end of file, it's an error (reported by caller). + * Ditto if it's the end of cpp_expand_to_buffer text. + * If we've hit end of macro, just continue. */ + if (!CPP_IS_MACRO_BUFFER(CPP_BUFFER(pfile))) + goto done; + break; + case CPP_LPAREN: + paren++; + break; + case CPP_RPAREN: + if (--paren < 0) + goto found; + break; + case CPP_COMMA: + /* if we've returned to lowest level and + * we aren't absorbing all args */ + if (paren == 0 && rest_args == 0) + goto found; + break; + found: + /* Remove ',' or ')' from argument buffer. */ + CPP_ADJUST_WRITTEN(pfile, -1); + goto done; + default:; + } + } + + done: + CPP_OPTIONS(pfile)->put_out_comments = save_put_out_comments; + pfile->no_macro_expand--; + + return token; +} + +/* Turn newlines to spaces in the string of length LENGTH at START, + * except inside of string constants. + * The string is copied into itself with its beginning staying fixed. */ + +static int +change_newlines(unsigned char *start, int length) +{ + unsigned char *ibp; + unsigned char *obp; + unsigned char *limit; + int c; + + ibp = start; + limit = start + length; + obp = start; + + while (ibp < limit) + { + *obp++ = c = *ibp++; + switch (c) + { + + case '\'': + case '\"': + /* Notice and skip strings, so that we don't delete newlines in them. */ + { + int quotec = c; + + while (ibp < limit) + { + *obp++ = c = *ibp++; + if (c == quotec) + break; + if (c == '\n' && quotec == '\'') + break; + } + } + break; + } + } + + return obp - start; +} + +static struct tm * +timestamp(cpp_reader * pfile) +{ + if (!pfile->timebuf) + { + time_t t = time((time_t *) 0); + + pfile->timebuf = localtime(&t); + } + return pfile->timebuf; +} + +static const char *monthnames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", +}; + +/* + * expand things like __FILE__. Place the expansion into the output + * buffer *without* rescanning. + */ + +static void +special_symbol(HASHNODE * hp, cpp_reader * pfile) +{ + const char *buf; + char *bufx; + int len; + int true_indepth; + cpp_buffer *ip = NULL; + struct tm *timebuf; + + int paren = 0; /* For special `defined' keyword */ + + for (ip = CPP_BUFFER(pfile);; ip = CPP_PREV_BUFFER(ip)) + { + if (!ip) + { + cpp_error(pfile, "cccp error: not in any file?!"); + return; /* the show must go on */ + } + if (ip->fname) + break; + } + + switch (hp->type) + { + case T_FILE: + case T_BASE_FILE: + { + const char *string; + + if (hp->type == T_BASE_FILE) + { + while (CPP_PREV_BUFFER(ip)) + ip = CPP_PREV_BUFFER(ip); + } + string = ip->nominal_fname; + + if (!string) + string = ""; + CPP_RESERVE(pfile, 3 + 4 * strlen(string)); + quote_string(pfile, string); + return; + } + + case T_INCLUDE_LEVEL: + true_indepth = 0; + for (ip = CPP_BUFFER(pfile); ip; ip = CPP_PREV_BUFFER(ip)) + if (ip->fname) + true_indepth++; + + bufx = (char *)alloca(8); /* Eight bytes ought to be more than enough */ + sprintf(bufx, "%d", true_indepth - 1); + buf = bufx; + break; + + case T_VERSION: + bufx = (char *)alloca(3 + strlen(version_string)); + sprintf(bufx, "\"%s\"", version_string); + buf = bufx; + break; + +#ifndef NO_BUILTIN_SIZE_TYPE + case T_SIZE_TYPE: + buf = SIZE_TYPE; + break; +#endif + +#ifndef NO_BUILTIN_PTRDIFF_TYPE + case T_PTRDIFF_TYPE: + buf = PTRDIFF_TYPE; + break; +#endif + + case T_WCHAR_TYPE: + buf = CPP_WCHAR_TYPE(pfile); + break; + + case T_USER_LABEL_PREFIX_TYPE: + buf = USER_LABEL_PREFIX; + break; + + case T_REGISTER_PREFIX_TYPE: + buf = REGISTER_PREFIX; + break; + + case T_CONST: + bufx = (char *)alloca(4 * sizeof(int)); + sprintf(bufx, "%d", hp->value.ival); + buf = bufx; + break; + + case T_SPECLINE: + { + long line = ip->lineno; + long col = ip->colno; + + adjust_position(CPP_LINE_BASE(ip), ip->cur, &line, &col); + + bufx = (char *)alloca(10); + sprintf(bufx, "%d", (int)line); + buf = bufx; + } + break; + + case T_DATE: + case T_TIME: + bufx = (char *)alloca(20); + timebuf = timestamp(pfile); + if (hp->type == T_DATE) + sprintf(bufx, "\"%s %2d %4d\"", monthnames[timebuf->tm_mon], + timebuf->tm_mday, timebuf->tm_year + 1900); + else + sprintf(bufx, "\"%02d:%02d:%02d\"", timebuf->tm_hour, + timebuf->tm_min, timebuf->tm_sec); + buf = bufx; + break; + + case T_SPEC_DEFINED: + buf = " 0 "; /* Assume symbol is not defined */ + ip = CPP_BUFFER(pfile); + SKIP_WHITE_SPACE(ip->cur); + if (*ip->cur == '(') + { + paren++; + ip->cur++; /* Skip over the paren */ + SKIP_WHITE_SPACE(ip->cur); + } + if (!is_idstart[*ip->cur]) + goto oops; + if ((hp = cpp_lookup((const char *)ip->cur, -1, -1))) + { + buf = " 1 "; + } + while (is_idchar[*ip->cur]) + ++ip->cur; + SKIP_WHITE_SPACE(ip->cur); + if (paren) + { + if (*ip->cur != ')') + goto oops; + ++ip->cur; + } + break; + + oops: + + cpp_error(pfile, "`defined' without an identifier"); + break; + + default: + cpp_error(pfile, "cccp error: invalid special hash type"); /* time for gdb */ + abort(); + } + len = strlen(buf); + CPP_RESERVE(pfile, len + 1); + CPP_PUTS_Q(pfile, buf, len); + CPP_NUL_TERMINATE_Q(pfile); + + return; +} + +/* Initialize the built-in macros. */ + +static void +initialize_builtins(cpp_reader * pfile) +{ + install("__LINE__", -1, T_SPECLINE, 0, 0, -1); + install("__DATE__", -1, T_DATE, 0, 0, -1); + install("__FILE__", -1, T_FILE, 0, 0, -1); + install("__BASE_FILE__", -1, T_BASE_FILE, 0, 0, -1); + install("__INCLUDE_LEVEL__", -1, T_INCLUDE_LEVEL, 0, 0, -1); + install("__VERSION__", -1, T_VERSION, 0, 0, -1); +#ifndef NO_BUILTIN_SIZE_TYPE + install("__SIZE_TYPE__", -1, T_SIZE_TYPE, 0, 0, -1); +#endif +#ifndef NO_BUILTIN_PTRDIFF_TYPE + install("__PTRDIFF_TYPE__ ", -1, T_PTRDIFF_TYPE, 0, 0, -1); +#endif + install("__WCHAR_TYPE__", -1, T_WCHAR_TYPE, 0, 0, -1); + install("__USER_LABEL_PREFIX__", -1, T_USER_LABEL_PREFIX_TYPE, 0, 0, -1); + install("__REGISTER_PREFIX__", -1, T_REGISTER_PREFIX_TYPE, 0, 0, -1); + install("__TIME__", -1, T_TIME, 0, 0, -1); + install("__STDC__", -1, T_CONST, STDC_VALUE, 0, -1); + if (CPP_OPTIONS(pfile)->objc) + install("__OBJC__", -1, T_CONST, 1, 0, -1); +/* This is supplied using a -D by the compiler driver + * so that it is present only when truly compiling with GNU C. */ +/* install ("__GNUC__", -1, T_CONST, 2, 0, -1); */ + + if (CPP_OPTIONS(pfile)->debug_output) + { + char directive[2048]; + struct directive *dp = &directive_table[0]; + struct tm *timebuf = timestamp(pfile); + cpp_buffer *pbuffer = CPP_BUFFER(pfile); + + while (CPP_PREV_BUFFER(pbuffer)) + pbuffer = CPP_PREV_BUFFER(pbuffer); + sprintf(directive, " __BASE_FILE__ \"%s\"\n", pbuffer->nominal_fname); + output_line_command(pfile, 0, same_file); + pass_thru_directive(directive, &directive[strlen(directive)], pfile, + dp); + + sprintf(directive, " __VERSION__ \"%s\"\n", version_string); + output_line_command(pfile, 0, same_file); + pass_thru_directive(directive, &directive[strlen(directive)], pfile, + dp); + +#ifndef NO_BUILTIN_SIZE_TYPE + sprintf(directive, " __SIZE_TYPE__ %s\n", SIZE_TYPE); + output_line_command(pfile, 0, same_file); + pass_thru_directive(directive, &directive[strlen(directive)], pfile, + dp); +#endif + +#ifndef NO_BUILTIN_PTRDIFF_TYPE + sprintf(directive, " __PTRDIFF_TYPE__ %s\n", PTRDIFF_TYPE); + output_line_command(pfile, 0, same_file); + pass_thru_directive(directive, &directive[strlen(directive)], pfile, + dp); +#endif + + sprintf(directive, " __WCHAR_TYPE__ %s\n", CPP_WCHAR_TYPE(pfile)); + output_line_command(pfile, 0, same_file); + pass_thru_directive(directive, &directive[strlen(directive)], pfile, + dp); + + sprintf(directive, " __DATE__ \"%s %2d %4d\"\n", + monthnames[timebuf->tm_mon], + timebuf->tm_mday, timebuf->tm_year + 1900); + output_line_command(pfile, 0, same_file); + pass_thru_directive(directive, &directive[strlen(directive)], pfile, + dp); + + sprintf(directive, " __TIME__ \"%02d:%02d:%02d\"\n", + timebuf->tm_hour, timebuf->tm_min, timebuf->tm_sec); + output_line_command(pfile, 0, same_file); + pass_thru_directive(directive, &directive[strlen(directive)], pfile, + dp); + + sprintf(directive, " __STDC__ 1"); + output_line_command(pfile, 0, same_file); + pass_thru_directive(directive, &directive[strlen(directive)], + pfile, dp); + } +} + +/* Return 1 iff a token ending in C1 followed directly by a token C2 + * could cause mis-tokenization. */ + +static int +unsafe_chars(int c1, int c2) +{ +// printf("unsafe %c %c ...", c1, c2); + switch (c1) + { + case '+': + case '-': + case '.': +// printf(" no0\n"); + return 0; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'e': + case 'E': + if (c2 == '-' || c2 == '+') + { +// printf(" yes2\n"); + return 1; /* could extend a pre-processing number */ + } + goto letter; + case 'L': + if (c2 == '\'' || c2 == '\"') + { +// printf(" yes3\n"); + return 1; /* Could turn into L"xxx" or L'xxx'. */ + } + goto letter; + letter: + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': + case 'A': + case 'B': + case 'C': + case 'D': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + /* We're in the middle of either a name or a pre-processing number. */ + if (is_idchar[c2] || c2 == '.') + { +// printf(" yes4 %i %i\n", is_idchar[c2], c2 == '.'); + return 1; + } + else + { +// printf(" no5\n"); + return 0; + } + case '<': + case '>': + case '!': + case '%': + case '#': + case ':': + case '^': + case '&': + case '|': + case '*': + case '/': + case '=': + if (c2 == c1 || c2 == '=') + { +// printf(" yes6\n"); + return 1; + } + else + { +// printf(" no7\n"); + return 0; + } + } +// printf(" no8\n"); + return 0; +} + +/* Expand a macro call. + * HP points to the symbol that is the macro being called. + * Put the result of expansion onto the input stack + * so that subsequent input by our caller will use it. + * + * If macro wants arguments, caller has already verified that + * an argument list follows; arguments come from the input stack. */ + +static void +macroexpand(cpp_reader * pfile, HASHNODE * hp) +{ + int nargs; + DEFINITION *defn = hp->value.defn; + unsigned char *xbuf; + long start_line, start_column; + int xbuf_len; + struct argdata *args; + long old_written = CPP_WRITTEN(pfile); + + int rest_args, rest_zero; + int i; + + pfile->output_escapes++; + cpp_buf_line_and_col(cpp_file_buffer(pfile), &start_line, &start_column); + + rest_zero = 0; + args = NULL; + nargs = defn->nargs; + + if (nargs >= 0) + { + enum cpp_token token; + + token = CPP_OTHER; + + args = (struct argdata *)alloca((nargs + 1) * sizeof(struct argdata)); + + for (i = 0; i < nargs; i++) + { + args[i].raw = args[i].expanded = 0; + args[i].raw_length = 0; + args[i].expand_length = args[i].stringified_length = -1; + args[i].use_count = 0; + } + + /* Parse all the macro args that are supplied. I counts them. + * The first NARGS args are stored in ARGS. + * The rest are discarded. If rest_args is set then we assume + * macarg absorbed the rest of the args. */ + i = 0; + rest_args = 0; + rest_args = 0; + FORWARD(1); /* Discard the open-parenthesis before the first arg. */ + do + { + if (rest_args) + continue; + if (i < nargs || (nargs == 0 && i == 0)) + { + unsigned char *bp; + + /* if we are working on last arg which absorbs rest of args... */ + if (i == nargs - 1 && defn->rest_args) + rest_args = 1; + args[i].raw = CPP_WRITTEN(pfile); + token = macarg(pfile, rest_args); + args[i].raw_length = CPP_WRITTEN(pfile) - args[i].raw; + args[i].newlines = 0; /* FIXME */ + bp = ARG_BASE + args[i].raw; + while (is_space[(unsigned char)(*bp)]) { bp++; } + args[i].raw_length -= bp - (ARG_BASE + args[i].raw); + args[i].raw = bp - ARG_BASE; + if (args[i].raw_length > 0) + { + bp = ARG_BASE + args[i].raw + args[i].raw_length - 1; + while (is_space[(unsigned char)(*bp)]) + { + bp--; + args[i].raw_length--; + if (args[i].raw_length < 1) break; + } + } + } + else + token = macarg(pfile, 0); + if (token == CPP_EOF || token == CPP_POP) + { + cpp_error_with_line(pfile, start_line, start_column, + "unterminated macro call"); + return; + } + i++; + } + while (token == CPP_COMMA); + + /* If we got one arg but it was just whitespace, call that 0 args. */ + if (i == 1) + { + unsigned char *bp = ARG_BASE + args[0].raw; + unsigned char *lim = bp + args[0].raw_length; + + /* cpp.texi says for foo ( ) we provide one argument. + * However, if foo wants just 0 arguments, treat this as 0. */ + if (nargs == 0) + while (bp != lim && is_space[*bp]) + bp++; + if (bp == lim) + i = 0; + } + /* Don't output an error message if we have already output one for + * a parse error above. */ + if (nargs == 0 && i > 0) + { + cpp_error(pfile, "arguments given to macro `%s'", hp->name); + } + else if (i < nargs) + { + if (i == nargs - 1 && defn->rest_args) + rest_zero = 1; + else if (i == 0) + cpp_error(pfile, "macro `%s' used without args", hp->name); + else if (i == 1) + cpp_error(pfile, "macro `%s' used with just one arg", hp->name); + else + cpp_error(pfile, "macro `%s' used with only %d args", + hp->name, i); + } + else if (i > nargs) + { + cpp_error(pfile, + "macro `%s' used with too many (%d) args", hp->name, i); + } + } + /* If macro wants zero args, we parsed the arglist for checking only. + * Read directly from the macro definition. */ + if (nargs <= 0) + { + xbuf = defn->expansion; + xbuf_len = defn->length; + } + else + { + unsigned char *exp = defn->expansion; + int offset; /* offset in expansion, + * copied a piece at a time */ + int totlen; /* total amount of exp buffer filled so far */ + reflist *ap, *last_ap; + + /* Macro really takes args. Compute the expansion of this call. */ + + /* Compute length in characters of the macro's expansion. + * Also count number of times each arg is used. */ + xbuf_len = defn->length; + for (ap = defn->pattern; ap; ap = ap->next) + { + if (ap->stringify) + { + struct argdata *arg = &args[ap->argno]; + + /* Stringify it it hasn't already been */ + if (arg->stringified_length < 0) + { + int arglen = arg->raw_length; + int escaped = 0; + int in_string = 0; + int c; + + /* Initially need_space is -1. Otherwise, 1 means the + * previous character was a space, but we suppressed it; + * 0 means the previous character was a non-space. */ + int need_space = -1; + + i = 0; + arg->stringified = CPP_WRITTEN(pfile); + CPP_PUTC(pfile, '\"'); /* insert beginning quote */ + for (; i < arglen; i++) + { + c = (ARG_BASE + arg->raw)[i]; + + if (!in_string) + { + /* Internal sequences of whitespace are replaced by + * one space except within an string or char token. */ + if (is_space[c]) + { + if (CPP_WRITTEN(pfile) > arg->stringified + && (CPP_PWRITTEN(pfile))[-1] == '@') + { + /* "@ " escape markers are removed */ + CPP_ADJUST_WRITTEN(pfile, -1); + continue; + } + if (need_space == 0) + need_space = 1; + continue; + } + else if (need_space > 0) + CPP_PUTC(pfile, ' '); + need_space = 0; + } + if (escaped) + escaped = 0; + else + { + if (c == '\\') + escaped = 1; + if (in_string) + { + if (c == in_string) + in_string = 0; + } + else if (c == '\"' || c == '\'') + in_string = c; + } + + /* Escape these chars */ + if (c == '\"' || (in_string && c == '\\')) + CPP_PUTC(pfile, '\\'); + if (isprint(c)) + CPP_PUTC(pfile, c); + else + { + CPP_RESERVE(pfile, 4); + sprintf((char *)CPP_PWRITTEN(pfile), "\\%03o", + (unsigned int)c); + CPP_ADJUST_WRITTEN(pfile, 4); + } + } + CPP_PUTC(pfile, '\"'); /* insert ending quote */ + arg->stringified_length + = CPP_WRITTEN(pfile) - arg->stringified; + } + xbuf_len += args[ap->argno].stringified_length; + } + else if (ap->raw_before || ap->raw_after) + { + /* Add 4 for two newline-space markers to prevent + * token concatenation. */ + xbuf_len += args[ap->argno].raw_length + 4; + } + else + { + /* We have an ordinary (expanded) occurrence of the arg. + * So compute its expansion, if we have not already. */ + if (args[ap->argno].expand_length < 0) + { + args[ap->argno].expanded = CPP_WRITTEN(pfile); + cpp_expand_to_buffer(pfile, + ARG_BASE + args[ap->argno].raw, + args[ap->argno].raw_length); + + args[ap->argno].expand_length + = CPP_WRITTEN(pfile) - args[ap->argno].expanded; + } + /* Add 4 for two newline-space markers to prevent + * token concatenation. */ + xbuf_len += args[ap->argno].expand_length + 4; + } + if (args[ap->argno].use_count < 10) + args[ap->argno].use_count++; + } + + xbuf = (unsigned char *)xmalloc(xbuf_len + 1); + + /* Generate in XBUF the complete expansion + * with arguments substituted in. + * TOTLEN is the total size generated so far. + * OFFSET is the index in the definition + * of where we are copying from. */ + offset = totlen = 0; + for (last_ap = NULL, ap = defn->pattern; ap; + last_ap = ap, ap = ap->next) + { + struct argdata *arg = &args[ap->argno]; + int count_before = totlen; + + /* Add chars to XBUF. */ + for (i = 0; i < ap->nchars; i++, offset++) + xbuf[totlen++] = exp[offset]; + + /* If followed by an empty rest arg with concatenation, + * delete the last run of nonwhite chars. */ + if (rest_zero && totlen > count_before + && ((ap->rest_args && ap->raw_before) + || (last_ap && last_ap->rest_args && last_ap->raw_after))) + { + /* Delete final whitespace. */ + while (totlen > count_before && is_space[xbuf[totlen - 1]]) + totlen--; + + /* Delete the nonwhites before them. */ + while (totlen > count_before && !is_space[xbuf[totlen - 1]]) + totlen--; + } + if (ap->stringify != 0) + { + memcpy(xbuf + totlen, ARG_BASE + arg->stringified, + arg->stringified_length); + totlen += arg->stringified_length; + } + else if (ap->raw_before || ap->raw_after) + { + unsigned char *p1 = ARG_BASE + arg->raw; + unsigned char *l1 = p1 + arg->raw_length; + + if (ap->raw_before) + { + while (p1 != l1 && is_space[*p1]) + p1++; + while (p1 != l1 && is_idchar[*p1]) + xbuf[totlen++] = *p1++; + } + if (ap->raw_after) + { + /* Arg is concatenated after: delete trailing whitespace, + * whitespace markers, and no-reexpansion markers. */ + while (p1 != l1) + { + if (is_space[l1[-1]]) + l1--; + else if (l1[-1] == '-') + { + unsigned char *p2 = l1 - 1; + + /* If a `-' is preceded by an odd number of newlines then it + * and the last newline are a no-reexpansion marker. */ + while (p2 != p1 && p2[-1] == '\n') + p2--; + if ((l1 - 1 - p2) & 1) + { + l1 -= 2; + } + else + break; + } + else + break; + } + } + memcpy(xbuf + totlen, p1, l1 - p1); + totlen += l1 - p1; + } + else + { + unsigned char *expanded = ARG_BASE + arg->expanded; + + if (!ap->raw_before && totlen > 0 && arg->expand_length + && unsafe_chars(xbuf[totlen - 1], expanded[0])) + { + xbuf[totlen++] = '@'; + xbuf[totlen++] = ' '; + } + memcpy(xbuf + totlen, expanded, arg->expand_length); + totlen += arg->expand_length; + + if (!ap->raw_after && totlen > 0 && offset < defn->length + && unsafe_chars(xbuf[totlen - 1], exp[offset])) + { + xbuf[totlen++] = '@'; + xbuf[totlen++] = ' '; + } + /* If a macro argument with newlines is used multiple times, + * then only expand the newlines once. This avoids creating + * output lines which don't correspond to any input line, + * which confuses gdb and gcov. */ + if (arg->use_count > 1 && arg->newlines > 0) + { + /* Don't bother doing change_newlines for subsequent + * uses of arg. */ + arg->use_count = 1; + arg->expand_length + = change_newlines(expanded, arg->expand_length); + } + } + + if (totlen > xbuf_len) + abort(); + } + /* if there is anything left of the definition + * after handling the arg list, copy that in too. */ + + for (i = offset; i < defn->length; i++) + { + /* if we've reached the end of the macro */ + if (exp[i] == ')') + rest_zero = 0; + if (!(rest_zero && last_ap && last_ap->rest_args + && last_ap->raw_after)) + xbuf[totlen++] = exp[i]; + } + + xbuf[totlen] = 0; + xbuf_len = totlen; + } + + pfile->output_escapes--; + + /* Now put the expansion on the input stack + * so our caller will commence reading from it. */ + push_macro_expansion(pfile, xbuf, xbuf_len, hp); + CPP_BUFFER(pfile)->has_escapes = 1; + + /* Pop the space we've used in the token_buffer for argument expansion. */ + CPP_SET_WRITTEN(pfile, old_written); + + /* Recursive macro use sometimes works traditionally. + * #define foo(x,y) bar (x (y,0), y) + * foo (foo, baz) */ + + hp->type = T_DISABLED; +} + +static void +push_macro_expansion(cpp_reader * pfile, unsigned char *xbuf, int xbuf_len, + HASHNODE * hp) +{ + cpp_buffer *mbuf = cpp_push_buffer(pfile, xbuf, xbuf_len); + + mbuf->cleanup = macro_cleanup; + mbuf->data = hp; + + /* The first chars of the expansion should be a "@ " added by + * collect_expansion. This is to prevent accidental token-pasting + * between the text preceding the macro invocation, and the macro + * expansion text. + * + * We would like to avoid adding unneeded spaces (for the sake of + * tools that use cpp, such as imake). In some common cases we can + * tell that it is safe to omit the space. + * + * The character before the macro invocation cannot have been an + * idchar (or else it would have been pasted with the idchars of + * the macro name). Therefore, if the first non-space character + * of the expansion is an idchar, we do not need the extra space + * to prevent token pasting. + * + * Also, we don't need the extra space if the first char is '(', + * or some other (less common) characters. */ + + if (xbuf[0] == '@' && xbuf[1] == ' ' + && (is_idchar[xbuf[2]] || xbuf[2] == '(' || xbuf[2] == '\'' + || xbuf[2] == '\"')) + mbuf->cur += 2; +} + +/* Like cpp_get_token, except that it does not read past end-of-line. + * Also, horizontal space is skipped, and macros are popped. */ + +static enum cpp_token +get_directive_token(cpp_reader * pfile) +{ + for (;;) + { + long old_written = CPP_WRITTEN(pfile); + enum cpp_token token; + + cpp_skip_hspace(pfile); + if (PEEKC() == '\n') + return CPP_VSPACE; + token = cpp_get_token(pfile); + switch (token) + { + case CPP_POP: + if (!CPP_IS_MACRO_BUFFER(CPP_BUFFER(pfile))) + return token; + /* ... else fall though ... */ + case CPP_HSPACE: + case CPP_COMMENT: + CPP_SET_WRITTEN(pfile, old_written); + break; + default: + return token; + } + } +} + +/* Handle #include and #import. + * This function expects to see "fname" or on the input. + * + * The input is normally in part of the output_buffer following + * CPP_WRITTEN, and will get overwritten by output_line_command. + * I.e. in input file specification has been popped by handle_directive. + * This is safe. */ + +static int +do_include(cpp_reader * pfile, struct directive *keyword, + unsigned char *unused1 __UNUSED__, unsigned char *unused2 __UNUSED__) +{ + int importing = (keyword->type == T_IMPORT); + int skip_dirs = (keyword->type == T_INCLUDE_NEXT); + char *fname; /* Dynamically allocated fname buffer */ + unsigned char *fbeg, *fend; /* Beginning and end of fname */ + enum cpp_token token; + + /* Chain of dirs to search */ + file_name_list *search_start = CPP_OPTIONS(pfile)->include; + file_name_list dsp[1]; /* First in chain, if #include "..." */ + file_name_list *searchptr = 0; + long old_written = CPP_WRITTEN(pfile); + int flen; + int f; /* file number */ + int angle_brackets = 0; /* 0 for "...", 1 for <...> */ + + f = -1; /* JF we iz paranoid! */ + + if (importing && CPP_OPTIONS(pfile)->warn_import + && !CPP_OPTIONS(pfile)->inhibit_warnings + && !CPP_BUFFER(pfile)->system_header_p && !pfile->import_warning) + { + pfile->import_warning = 1; + cpp_warning(pfile, "using `#import' is not recommended"); + fprintf(stderr, + "The fact that a certain header file need not be processed more than once\n"); + fprintf(stderr, + "should be indicated in the header file, not where it is used.\n"); + fprintf(stderr, + "The best way to do this is with a conditional of this form:\n\n"); + fprintf(stderr, " #ifndef _FOO_H_INCLUDED\n"); + fprintf(stderr, " #define _FOO_H_INCLUDED\n"); + fprintf(stderr, " ... ...\n"); + fprintf(stderr, " #endif /* Not _FOO_H_INCLUDED */\n\n"); + fprintf(stderr, "Then users can use `#include' any number of times.\n"); + fprintf(stderr, + "GNU C automatically avoids processing the file more than once\n"); + fprintf(stderr, "when it is equipped with such a conditional.\n"); + } + pfile->parsing_include_directive++; + token = get_directive_token(pfile); + pfile->parsing_include_directive--; + + if (token == CPP_STRING) + { + /* FIXME - check no trailing garbage */ + fbeg = pfile->token_buffer + old_written + 1; + fend = CPP_PWRITTEN(pfile) - 1; + if (fbeg[-1] == '<') + { + angle_brackets = 1; + /* If -I-, start with the first -I dir after the -I-. */ + if (CPP_OPTIONS(pfile)->first_bracket_include) + search_start = CPP_OPTIONS(pfile)->first_bracket_include; + } + /* If -I- was specified, don't search current dir, only spec'd ones. */ + else if (!CPP_OPTIONS(pfile)->ignore_srcdir) + { + cpp_buffer *fp; + + /* We have "filename". Figure out directory this source + * file is coming from and put it on the front of the list. */ + + for (fp = CPP_BUFFER(pfile); fp; fp = CPP_PREV_BUFFER(fp)) + { + int n; + const char *ep, *nam; + + if ((nam = fp->nominal_fname)) + { + /* Found a named file. Figure out dir of the file, + * and put it in front of the search list. */ + dsp[0].next = search_start; + search_start = dsp; +#ifndef VMS + ep = strrchr(nam, '/'); +#else /* VMS */ + ep = strrchr(nam, ']'); + if (!ep) + ep = strrchr(nam, '>'); + if (!ep) + ep = strrchr(nam, ':'); + if (ep) + ep++; +#endif /* VMS */ + if (ep) + { + n = ep - nam; + dsp[0].fname = (char *)alloca(n + 1); + strncpy(dsp[0].fname, nam, n); + dsp[0].fname[n] = '\0'; + if (n + INCLUDE_LEN_FUDGE > pfile->max_include_len) + pfile->max_include_len = n + INCLUDE_LEN_FUDGE; + } + else + { + dsp[0].fname = 0; /* Current directory */ + } + dsp[0].got_name_map = 0; + break; + } + } + } + } + else + { + cpp_error(pfile, + "`#%s' expects \"FILENAME\" or ", keyword->name); + CPP_SET_WRITTEN(pfile, old_written); + skip_rest_of_line(pfile); + return 0; + } + + *fend = 0; + + token = get_directive_token(pfile); + if (token != CPP_VSPACE) + { + cpp_error(pfile, "junk at end of `#include'"); + while (token != CPP_VSPACE && token != CPP_EOF && token != CPP_POP) + token = get_directive_token(pfile); + } + /* For #include_next, skip in the search path + * past the dir in which the containing file was found. */ + if (skip_dirs) + { + cpp_buffer *fp; + + for (fp = CPP_BUFFER(pfile); fp; fp = CPP_PREV_BUFFER(fp)) + if (fp->fname) + { + /* fp->dir is null if the containing file was specified with + * an absolute file name. In that case, don't skip anything. */ + if (fp->dir == SELF_DIR_DUMMY) + search_start = CPP_OPTIONS(pfile)->include; + else if (fp->dir) + search_start = fp->dir->next; + break; + } + } + CPP_SET_WRITTEN(pfile, old_written); + + flen = fend - fbeg; + + if (flen == 0) + { + cpp_error(pfile, "empty file name in `#%s'", keyword->name); + return 0; + } + /* Allocate this permanently, because it gets stored in the definitions + * of macros. */ + fname = (char *)xmalloc(pfile->max_include_len + flen + 4); + /* + 2 above for slash and terminating null. */ + /* + 2 added for '.h' on VMS (to support '#include filename') */ + + /* If specified file name is absolute, just open it. */ + +#ifndef __EMX__ + if (*fbeg == '/') +#else + if (_fnisabs(fbeg)) +#endif + { + strncpy(fname, (const char *)fbeg, flen); + fname[flen] = 0; + if (redundant_include_p(pfile, fname)) + return 0; + if (importing) + f = lookup_import(pfile, fname, NULL); + else + f = open_include_file(pfile, fname, NULL); + if (f == -2) + return 0; /* Already included this file */ + } + else + { + /* Search directory path, trying to open the file. + * Copy each filename tried into FNAME. */ + + for (searchptr = search_start; searchptr; searchptr = searchptr->next) + { + if (searchptr->fname) + { + /* The empty string in a search path is ignored. + * This makes it possible to turn off entirely + * a standard piece of the list. */ + if (searchptr->fname[0] == 0) + continue; + strcpy(fname, searchptr->fname); + strcat(fname, "/"); + fname[strlen(fname) + flen] = 0; + } + else + { + fname[0] = 0; + } + strncat(fname, (const char *)fbeg, flen); +#ifdef VMS + /* Change this 1/2 Unix 1/2 VMS file specification into a + * full VMS file specification */ + if (searchptr->fname && (searchptr->fname[0] != 0)) + { + /* Fix up the filename */ + hack_vms_include_specification(fname); + } + else + { + /* This is a normal VMS filespec, so use it unchanged. */ + strncpy(fname, fbeg, flen); + fname[flen] = 0; + /* if it's '#include filename', add the missing .h */ + if (!strchr(fname, '.')) + { + strcat(fname, ".h"); + } + } +#endif /* VMS */ + /* ??? There are currently 3 separate mechanisms for avoiding processing + * of redundant include files: #import, #pragma once, and + * redundant_include_p. It would be nice if they were unified. */ + if (redundant_include_p(pfile, fname)) + return 0; + if (importing) + f = lookup_import(pfile, fname, searchptr); + else + f = open_include_file(pfile, fname, searchptr); + if (f == -2) + return 0; /* Already included this file */ +#ifdef EACCES + else if (f == -1 && errno == EACCES) + cpp_warning(pfile, "Header file %s exists, but is not readable", + fname); +#endif + if (f >= 0) + break; + } + } + + if (f < 0) + { + /* A file that was not found. */ + strncpy(fname, (const char *)fbeg, flen); + fname[flen] = 0; + /* If generating dependencies and -MG was specified, we assume missing + * files are leaf files, living in the same directory as the source file + * or other similar place; these missing files may be generated from + * other files and may not exist yet (eg: y.tab.h). */ + + if (CPP_OPTIONS(pfile)->print_deps_missing_files + && CPP_PRINT_DEPS(pfile) + > (angle_brackets || (pfile->system_include_depth > 0))) + { + /* If it was requested as a system header file, + * then assume it belongs in the first place to look for such. */ + if (angle_brackets) + { + for (searchptr = search_start; searchptr; + searchptr = searchptr->next) + { + if (searchptr->fname) + { + char *p; + + if (searchptr->fname[0] == 0) + continue; + p = (char *)alloca(strlen(searchptr->fname) + + strlen(fname) + 2); + strcpy(p, searchptr->fname); + strcat(p, "/"); + strcat(p, fname); + deps_output(pfile, p, ' '); + break; + } + } + } + else + { + /* Otherwise, omit the directory, as if the file existed + * in the directory with the source. */ + deps_output(pfile, fname, ' '); + } + } + /* If -M was specified, and this header file won't be added to the + * dependency list, then don't count this as an error, because we can + * still produce correct output. Otherwise, we can't produce correct + * output, because there may be dependencies we need inside the missing + * file, and we don't know what directory this missing file exists in. */ + else if (CPP_PRINT_DEPS(pfile) + && (CPP_PRINT_DEPS(pfile) + <= (angle_brackets || (pfile->system_include_depth > 0)))) + cpp_warning(pfile, "No include path in which to find %s", fname); + else if (search_start) + cpp_error_from_errno(pfile, fname); + else + cpp_error(pfile, "No include path in which to find %s", fname); + } + else + { + /* Check to see if this include file is a once-only include file. + * If so, give up. */ + + file_name_list *ptr; + + for (ptr = pfile->dont_repeat_files; ptr; ptr = ptr->next) + { + if (!strcmp(ptr->fname, fname)) + { + close(f); + return 0; /* This file was once'd. */ + } + } + + for (ptr = pfile->all_include_files; ptr; ptr = ptr->next) + { + if (!strcmp(ptr->fname, fname)) + break; /* This file was included before. */ + } + + if (!ptr) + { + /* This is the first time for this file. */ + /* Add it to list of files included. */ + + ptr = (file_name_list *) xmalloc(sizeof(file_name_list)); + + ptr->control_macro = 0; + ptr->c_system_include_path = 0; + ptr->next = pfile->all_include_files; + pfile->all_include_files = ptr; + ptr->fname = savestring(fname); + ptr->got_name_map = 0; + + /* For -M, add this file to the dependencies. */ + if (CPP_PRINT_DEPS(pfile) + > (angle_brackets || (pfile->system_include_depth > 0))) + deps_output(pfile, fname, ' '); + } + /* Handle -H option. */ + if (CPP_OPTIONS(pfile)->print_include_names) + { + cpp_buffer *buf = CPP_BUFFER(pfile); + + while ((buf = CPP_PREV_BUFFER(buf))) + putc('.', stderr); + fprintf(stderr, "%s\n", fname); + } + if (angle_brackets) + pfile->system_include_depth++; + + /* Actually process the file. */ + + /* Record file on "seen" list for #import. */ + add_import(pfile, f, fname); + + /* Actually process the file */ + cpp_push_buffer(pfile, NULL, 0); + if (finclude(pfile, f, fname, is_system_include(pfile, fname), + searchptr != dsp ? searchptr : SELF_DIR_DUMMY)) + { + output_line_command(pfile, 0, enter_file); + pfile->only_seen_white = 2; + } + if (angle_brackets) + pfile->system_include_depth--; + } + return 0; +} + +/* Return nonzero if there is no need to include file NAME + * because it has already been included and it contains a conditional + * to make a repeated include do nothing. */ + +static int +redundant_include_p(cpp_reader * pfile, char *name) +{ + file_name_list *l = pfile->all_include_files; + + for (; l; l = l->next) + if (!strcmp(name, l->fname) + && l->control_macro + && cpp_lookup((const char *)l->control_macro, -1, -1)) + return 1; + return 0; +} + +/* Return nonzero if the given FILENAME is an absolute pathname which + * designates a file within one of the known "system" include file + * directories. We assume here that if the given FILENAME looks like + * it is the name of a file which resides either directly in a "system" + * include file directory, or within any subdirectory thereof, then the + * given file must be a "system" include file. This function tells us + * if we should suppress pedantic errors/warnings for the given FILENAME. + * + * The value is 2 if the file is a C-language system header file + * for which C++ should (on most systems) assume `extern "C"'. */ + +static int +is_system_include(cpp_reader * pfile, char *filename) +{ + file_name_list *searchptr; + + for (searchptr = CPP_OPTIONS(pfile)->first_system_include; searchptr; + searchptr = searchptr->next) + if (searchptr->fname) + { + char *sys_dir = searchptr->fname; + unsigned length = strlen(sys_dir); + + if (!strncmp(sys_dir, filename, length) && filename[length] == '/') + { + if (searchptr->c_system_include_path) + return 2; + else + return 1; + } + } + return 0; +} + +/* + * Install a name in the assertion hash table. + * + * If LEN is >= 0, it is the length of the name. + * Otherwise, compute the length by scanning the entire name. + * + * If HASH is >= 0, it is the precomputed hash code. + * Otherwise, compute the hash code. + */ +static ASSERTION_HASHNODE * +assertion_install(cpp_reader * pfile, const char *name, int len, int hash) +{ + ASSERTION_HASHNODE *hp; + int i, bucket; + + i = sizeof(ASSERTION_HASHNODE) + len + 1; + hp = (ASSERTION_HASHNODE *) xmalloc(i); + bucket = hash; + hp->bucket_hdr = &pfile->assertion_hashtab[bucket]; + hp->next = pfile->assertion_hashtab[bucket]; + pfile->assertion_hashtab[bucket] = hp; + hp->prev = NULL; + if (hp->next) + hp->next->prev = hp; + hp->length = len; + hp->value = 0; + hp->name = ((char *)hp) + sizeof(ASSERTION_HASHNODE); + memcpy(hp->name, name, len); + hp->name[len] = 0; + return hp; +} +/* + * find the most recent hash node for name name (ending with first + * non-identifier char) installed by install + * + * If LEN is >= 0, it is the length of the name. + * Otherwise, compute the length by scanning the entire name. + * + * If HASH is >= 0, it is the precomputed hash code. + * Otherwise, compute the hash code. + */ + +static ASSERTION_HASHNODE * +assertion_lookup(cpp_reader * pfile, const char *name, int len, int hash) +{ + ASSERTION_HASHNODE *bucket; + + bucket = pfile->assertion_hashtab[hash]; + while (bucket) + { + if (bucket->length == len && strncmp(bucket->name, name, len) == 0) + return bucket; + bucket = bucket->next; + } + return NULL; +} + +static void +delete_assertion(ASSERTION_HASHNODE * hp) +{ + struct tokenlist_list *tail; + + if (hp->prev) + hp->prev->next = hp->next; + if (hp->next) + hp->next->prev = hp->prev; + + for (tail = hp->value; tail;) + { + struct tokenlist_list *next = tail->next; + + free_token_list(tail->tokens); + free(tail); + tail = next; + } + + /* make sure that the bucket chain header that + * the deleted guy was on points to the right thing afterwards. */ + if (hp == *hp->bucket_hdr) + *hp->bucket_hdr = hp->next; + + free(hp); +} + +/* Convert a character string literal into a nul-terminated string. + * The input string is [IN ... LIMIT). + * The result is placed in RESULT. RESULT can be the same as IN. + * The value returned in the end of the string written to RESULT, + * or NULL on error. */ + +static char * +convert_string(cpp_reader * pfile, char *result, char *in, char *limit, + int handle_escapes) +{ + unsigned char c; + + c = *in++; + if (c != '\"') + return NULL; + while (in < limit) + { + c = *in++; + + switch (c) + { + case '\0': + return NULL; + case '\"': + limit = in; + break; + case '\\': + if (handle_escapes) + { + char *bpc = in; + int i = + (unsigned char)cpp_parse_escape(pfile, &bpc); + + in = bpc; + if (i >= 0) + *result++ = (unsigned char)c; + break; + } + /* else fall through */ + default: + *result++ = c; + } + } + *result = 0; + return result; +} + +/* + * interpret #line command. Remembers previously seen fnames + * in its very own hash table. + */ +#define FNAME_HASHSIZE 37 + +static int +do_line(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *unused1 __UNUSED__, unsigned char *unused2 __UNUSED__) +{ + cpp_buffer *ip = CPP_BUFFER(pfile); + int new_lineno; + long old_written = CPP_WRITTEN(pfile); + enum file_change_code file_change = same_file; + enum cpp_token token; + + token = get_directive_token(pfile); + + if (token != CPP_NUMBER || !isdigit(pfile->token_buffer[old_written])) + { + cpp_error(pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + /* The Newline at the end of this line remains to be processed. + * To put the next line at the specified line number, + * we must store a line number now that is one less. */ + new_lineno = atoi((char *)(pfile->token_buffer + old_written)) - 1; + CPP_SET_WRITTEN(pfile, old_written); + + /* NEW_LINENO is one less than the actual line number here. */ + if (CPP_PEDANTIC(pfile) && new_lineno < 0) + cpp_pedwarn(pfile, "line number out of range in `#line' command"); + + token = get_directive_token(pfile); + + if (token == CPP_STRING) + { + char *fname = (char *)pfile->token_buffer + old_written; + char *end_name; + static HASHNODE *fname_table[FNAME_HASHSIZE]; + HASHNODE *hp, **hash_bucket; + unsigned char *p; + long num_start; + int fname_length; + + /* Turn the file name, which is a character string literal, + * into a null-terminated string. Do this in place. */ + end_name = + convert_string(pfile, fname, fname, (char *)CPP_PWRITTEN(pfile), 1); + if (!end_name) + { + cpp_error(pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + fname_length = end_name - fname; + + num_start = CPP_WRITTEN(pfile); + token = get_directive_token(pfile); + if (token != CPP_VSPACE && token != CPP_EOF && token != CPP_POP) + { + p = pfile->token_buffer + num_start; + if (CPP_PEDANTIC(pfile)) + cpp_pedwarn(pfile, "garbage at end of `#line' command"); + + if (token != CPP_NUMBER || *p < '0' || *p > '4' || p[1] != '\0') + { + cpp_error(pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + if (*p == '1') + file_change = enter_file; + else if (*p == 2) + file_change = leave_file; + else if (*p == 3) + ip->system_header_p = 1; + else /* if (*p == 4) */ + ip->system_header_p = 2; + + CPP_SET_WRITTEN(pfile, num_start); + token = get_directive_token(pfile); + p = pfile->token_buffer + num_start; + if (token == CPP_NUMBER && p[1] == '\0' + && (*p == '3' || *p == '4')) + { + ip->system_header_p = *p == 3 ? 1 : 2; + token = get_directive_token(pfile); + } + if (token != CPP_VSPACE) + { + cpp_error(pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + } + hash_bucket = &fname_table[hashf(fname, fname_length, FNAME_HASHSIZE)]; + for (hp = *hash_bucket; hp; hp = hp->next) + if (hp->length == fname_length && + strncmp(hp->value.cpval, fname, fname_length) == 0) + { + ip->nominal_fname = hp->value.cpval; + break; + } + if (!hp) + { + /* Didn't find it; cons up a new one. */ + hp = (HASHNODE *) xcalloc(1, sizeof(HASHNODE) + fname_length + 1); + hp->next = *hash_bucket; + *hash_bucket = hp; + + hp->length = fname_length; + ip->nominal_fname = hp->value.cpval = + ((char *)hp) + sizeof(HASHNODE); + memcpy(hp->value.cpval, fname, fname_length); + } + } + else if (token != CPP_VSPACE && token != CPP_EOF) + { + cpp_error(pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + ip->lineno = new_lineno; + bad_line_directive: + skip_rest_of_line(pfile); + CPP_SET_WRITTEN(pfile, old_written); + output_line_command(pfile, 0, file_change); + return 0; +} + +/* + * remove the definition of a symbol from the symbol table. + * according to un*x /lib/cpp, it is not an error to undef + * something that has no definitions, so it isn't one here either. + */ + +static int +do_undef(cpp_reader * pfile, struct directive *keyword, unsigned char *buf, + unsigned char *limit) +{ + int sym_length; + HASHNODE *hp; + unsigned char *orig_buf = buf; + + SKIP_WHITE_SPACE(buf); + sym_length = check_macro_name(pfile, buf, "macro"); + + while ((hp = cpp_lookup((const char *)buf, sym_length, -1))) + { + /* If we are generating additional info for debugging (with -g) we + * need to pass through all effective #undef commands. */ + if (CPP_OPTIONS(pfile)->debug_output && keyword) + pass_thru_directive((char *)orig_buf, (char *)limit, pfile, keyword); + if (hp->type != T_MACRO) + cpp_warning(pfile, "undefining `%s'", hp->name); + delete_macro(hp); + } + + if (CPP_PEDANTIC(pfile)) + { + buf += sym_length; + SKIP_WHITE_SPACE(buf); + if (buf != limit) + cpp_pedwarn(pfile, "garbage after `#undef' directive"); + } + return 0; +} + +/* + * Report an error detected by the program we are processing. + * Use the text of the line in the error message. + * (We use error because it prints the filename & line#.) + */ + +static int +do_error(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf, unsigned char *limit) +{ + int length = limit - buf; + unsigned char *copy = (unsigned char *)xmalloc(length + 1); + + memcpy(copy, buf, length); + copy[length] = 0; + SKIP_WHITE_SPACE(copy); + cpp_error(pfile, "#error %s", copy); + return 0; +} + +/* + * Report a warning detected by the program we are processing. + * Use the text of the line in the warning message, then continue. + * (We use error because it prints the filename & line#.) + */ + +static int +do_warning(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf, unsigned char *limit) +{ + int length = limit - buf; + unsigned char *copy = (unsigned char *)xmalloc(length + 1); + + memcpy(copy, buf, length); + copy[length] = 0; + SKIP_WHITE_SPACE(copy); + cpp_warning(pfile, "#warning %s", copy); + return 0; +} + +/* Remember the name of the current file being read from so that we can + * avoid ever including it again. */ + +static int +do_once(cpp_reader * pfile) +{ + cpp_buffer *ip = NULL; + file_name_list *new_; + + for (ip = CPP_BUFFER(pfile);; ip = CPP_PREV_BUFFER(ip)) + { + if (!ip) + return 0; + if (ip->fname) + break; + } + + new_ = (file_name_list *) xmalloc(sizeof(file_name_list)); + + new_->next = pfile->dont_repeat_files; + pfile->dont_repeat_files = new_; + new_->fname = savestring(ip->fname); + new_->control_macro = 0; + new_->got_name_map = 0; + new_->c_system_include_path = 0; + + return 0; +} + +/* #ident has already been copied to the output file, so just ignore it. */ + +static int +do_ident(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__) +{ +/* long old_written = CPP_WRITTEN (pfile); */ + + /* Allow #ident in system headers, since that's not user's fault. */ + if (CPP_PEDANTIC(pfile) && !CPP_BUFFER(pfile)->system_header_p) + cpp_pedwarn(pfile, "ANSI C does not allow `#ident'"); + + /* Leave rest of line to be read by later calls to cpp_get_token. */ + + return 0; +} + +/* #pragma and its argument line have already been copied to the output file. + * Just check for some recognized pragmas that need validation here. */ + +static int +do_pragma(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf, unsigned char *limit __UNUSED__) +{ + while (*buf == ' ' || *buf == '\t') + buf++; + + if (!strncmp((const char *)buf, "once", 4)) + { + /* Allow #pragma once in system headers, since that's not the user's + * fault. */ + if (!CPP_BUFFER(pfile)->system_header_p) + cpp_warning(pfile, "`#pragma once' is obsolete"); + do_once(pfile); + } + if (!strncmp((const char *)buf, "implementation", 14)) + { + /* Be quiet about `#pragma implementation' for a file only if it hasn't + * been included yet. */ + file_name_list *ptr; + char *p = (char *)buf + 14, *fname, *inc_fname; + int fname_len; + + SKIP_WHITE_SPACE(p); + if (*p == '\n' || *p != '\"') + return 0; + + fname = p + 1; + p = strchr(fname, '\"'); + fname_len = (p) ? (int)(p - fname) : (int)strlen(fname); + + for (ptr = pfile->all_include_files; ptr; ptr = ptr->next) + { + inc_fname = strrchr(ptr->fname, '/'); + inc_fname = inc_fname ? inc_fname + 1 : (char *)ptr->fname; + if (inc_fname && !strncmp(inc_fname, fname, fname_len)) + cpp_warning(pfile, + "`#pragma implementation' for `%s' appears after file is included", + fname); + } + } + return 0; +} + +/* Just ignore #sccs, on systems where we define it at all. */ + +/* + * handle #if command by + * 1) inserting special `defined' keyword into the hash table + * that gets turned into 0 or 1 by special_symbol (thus, + * if the luser has a symbol called `defined' already, it won't + * work inside the #if command) + * 2) rescan the input into a temporary output buffer + * 3) pass the output buffer to the yacc parser and collect a value + * 4) clean up the mess left from steps 1 and 2. + * 5) call conditional_skip to skip til the next #endif (etc.), + * or not, depending on the value from step 3. + */ + +static int +do_if(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf, unsigned char *limit) +{ + HOST_WIDE_INT value = eval_if_expression(pfile, buf, limit - buf); + + conditional_skip(pfile, value == 0, T_IF, NULL); + return 0; +} + +/* + * handle a #elif directive by not changing if_stack either. + * see the comment above do_else. + */ + +static int +do_elif(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf, unsigned char *limit) +{ + if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack) + { + cpp_error(pfile, "`#elif' not within a conditional"); + return 0; + } + else + { + if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF) + { + cpp_error(pfile, "`#elif' after `#else'"); + if (pfile->if_stack->fname + && CPP_BUFFER(pfile)->fname + && strcmp(pfile->if_stack->fname, + CPP_BUFFER(pfile)->nominal_fname) != 0) + fprintf(stderr, ", file %s", pfile->if_stack->fname); + fprintf(stderr, ")\n"); + } + pfile->if_stack->type = T_ELIF; + } + + if (pfile->if_stack->if_succeeded) + skip_if_group(pfile, 0); + else + { + HOST_WIDE_INT value = eval_if_expression(pfile, buf, limit - buf); + + if (value == 0) + skip_if_group(pfile, 0); + else + { + ++pfile->if_stack->if_succeeded; /* continue processing input */ + output_line_command(pfile, 1, same_file); + } + } + return 0; +} + +/* + * evaluate a #if expression in BUF, of length LENGTH, + * then parse the result as a C expression and return the value as an int. + */ +static HOST_WIDE_INT +eval_if_expression(cpp_reader * pfile, unsigned char *buf __UNUSED__, + int length __UNUSED__) +{ + HASHNODE *save_defined; + HOST_WIDE_INT value; + long old_written = CPP_WRITTEN(pfile); + + save_defined = install("defined", -1, T_SPEC_DEFINED, 0, 0, -1); + pfile->pcp_inside_if = 1; + + value = cpp_parse_expr(pfile); + pfile->pcp_inside_if = 0; + delete_macro(save_defined); /* clean up special symbol */ + + CPP_SET_WRITTEN(pfile, old_written); /* Pop */ + + return value; +} + +/* + * routine to handle ifdef/ifndef. Try to look up the symbol, + * then do or don't skip to the #endif/#else/#elif depending + * on what directive is actually being processed. + */ + +static int +do_xifdef(cpp_reader * pfile, struct directive *keyword, + unsigned char *unused1 __UNUSED__, unsigned char *unused2 __UNUSED__) +{ + int skip; + cpp_buffer *ip = CPP_BUFFER(pfile); + char *ident; + int ident_length; + enum cpp_token token; + int start_of_file = 0; + unsigned char *control_macro = 0; + int old_written = CPP_WRITTEN(pfile); + int c; + + /* Detect a #ifndef at start of file (not counting comments). */ + if (ip->fname != 0 && keyword->type == T_IFNDEF) + start_of_file = pfile->only_seen_white == 2; + + pfile->no_macro_expand++; + token = get_directive_token(pfile); + pfile->no_macro_expand--; + + ident = (char *)pfile->token_buffer + old_written; + ident_length = CPP_WRITTEN(pfile) - old_written; + CPP_SET_WRITTEN(pfile, old_written); /* Pop */ + + if (token == CPP_VSPACE || token == CPP_POP || token == CPP_EOF) + { + skip = (keyword->type == T_IFDEF); + cpp_pedwarn(pfile, "`#%s' with no argument", keyword->name); + } + else if (token == CPP_NAME) + { + HASHNODE *hp = cpp_lookup(ident, ident_length, -1); + + skip = (!hp) ^ (keyword->type == T_IFNDEF); + if (start_of_file && !skip) + { + control_macro = (unsigned char *)xmalloc(ident_length + 1); + memcpy(control_macro, ident, ident_length + 1); + } + } + else + { + skip = (keyword->type == T_IFDEF); + cpp_error(pfile, "`#%s' with invalid argument", keyword->name); + } + + cpp_skip_hspace(pfile); + c = PEEKC(); + if (c != EOF && c != '\n') + cpp_pedwarn(pfile, "garbage at end of `#%s' argument", + keyword->name); + skip_rest_of_line(pfile); + + conditional_skip(pfile, skip, T_IF, control_macro); + return 0; +} + +/* Push TYPE on stack; then, if SKIP is nonzero, skip ahead. + * If this is a #ifndef starting at the beginning of a file, + * CONTROL_MACRO is the macro name tested by the #ifndef. + * Otherwise, CONTROL_MACRO is 0. */ + +static void +conditional_skip(cpp_reader * pfile, int skip, enum node_type type, + unsigned char *control_macro) +{ + IF_STACK_FRAME *temp; + + temp = (IF_STACK_FRAME *) xcalloc(1, sizeof(IF_STACK_FRAME)); + temp->fname = CPP_BUFFER(pfile)->nominal_fname; + temp->next = pfile->if_stack; + temp->control_macro = control_macro; + pfile->if_stack = temp; + + pfile->if_stack->type = type; + + if (skip != 0) + { + skip_if_group(pfile, 0); + return; + } + else + { + ++pfile->if_stack->if_succeeded; + output_line_command(pfile, 1, same_file); + } +} + +/* + * skip to #endif, #else, or #elif. adjust line numbers, etc. + * leaves input ptr at the sharp sign found. + * If ANY is nonzero, return at next directive of any sort. + */ + +static void +skip_if_group(cpp_reader * pfile, int any) +{ + int c; + struct directive *kt; + IF_STACK_FRAME *save_if_stack = pfile->if_stack; /* don't pop past here */ + + int ident_length; + char *ident; + struct parse_marker line_start_mark; + + parse_set_mark(&line_start_mark, pfile); + + if (CPP_OPTIONS(pfile)->output_conditionals) + { + static char failed[] = "#failed\n"; + + CPP_PUTS(pfile, failed, sizeof(failed) - 1); + pfile->lineno++; + output_line_command(pfile, 1, same_file); + } + beg_of_line: + if (CPP_OPTIONS(pfile)->output_conditionals) + { + cpp_buffer *pbuf = CPP_BUFFER(pfile); + unsigned char *start_line = pbuf->buf + line_start_mark.position; + + CPP_PUTS(pfile, start_line, pbuf->cur - start_line); + } + parse_move_mark(&line_start_mark, pfile); + cpp_skip_hspace(pfile); + c = GETC(); + if (c == '#') + { + int old_written = CPP_WRITTEN(pfile); + + cpp_skip_hspace(pfile); + + parse_name(pfile, GETC()); + ident_length = CPP_WRITTEN(pfile) - old_written; + ident = (char *)pfile->token_buffer + old_written; + pfile->limit = (unsigned char *)ident; + + for (kt = directive_table; kt->length >= 0; kt++) + { + IF_STACK_FRAME *temp; + + if (ident_length == kt->length + && strncmp(ident, kt->name, kt->length) == 0) + { + /* If we are asked to return on next directive, do so now. */ + if (any) + goto done; + + switch (kt->type) + { + case T_IF: + case T_IFDEF: + case T_IFNDEF: + temp + = + (IF_STACK_FRAME *) xcalloc(1, sizeof(IF_STACK_FRAME)); + temp->next = pfile->if_stack; + pfile->if_stack = temp; + temp->fname = CPP_BUFFER(pfile)->nominal_fname; + temp->type = kt->type; + break; + case T_ELSE: + case T_ENDIF: + if (CPP_PEDANTIC(pfile) + && pfile->if_stack != save_if_stack) + validate_else(pfile, + kt->type == + T_ELSE ? "#else" : "#endif"); + case T_ELIF: + if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack) + { + cpp_error(pfile, + "`#%s' not within a conditional", + kt->name); + break; + } + else if (pfile->if_stack == save_if_stack) + goto done; /* found what we came for */ + + if (kt->type != T_ENDIF) + { + if (pfile->if_stack->type == T_ELSE) + cpp_error(pfile, + "`#else' or `#elif' after `#else'"); + pfile->if_stack->type = kt->type; + break; + } + temp = pfile->if_stack; + pfile->if_stack = temp->next; + free(temp); + break; + default:; + } + break; + } + /* Don't let erroneous code go by. */ + if (kt->length < 0 && !CPP_OPTIONS(pfile)->lang_asm + && CPP_PEDANTIC(pfile)) + cpp_pedwarn(pfile, "invalid preprocessor directive name"); + } + c = GETC(); + } + /* We're in the middle of a line. Skip the rest of it. */ + for (;;) + { + switch (c) + { + long old; + + case EOF: + goto done; + case '/': /* possible comment */ + c = skip_comment(pfile, NULL); + if (c == EOF) + goto done; + break; + case '\"': + case '\'': + FORWARD(-1); + old = CPP_WRITTEN(pfile); + cpp_get_token(pfile); + CPP_SET_WRITTEN(pfile, old); + break; + case '\\': + /* Char after backslash loses its special meaning. */ + if (PEEKC() == '\n') + FORWARD(1); + break; + case '\n': + goto beg_of_line; + break; + } + c = GETC(); + } + done: + if (CPP_OPTIONS(pfile)->output_conditionals) + { + static char end_failed[] = "#endfailed\n"; + + CPP_PUTS(pfile, end_failed, sizeof(end_failed) - 1); + pfile->lineno++; + } + pfile->only_seen_white = 1; + parse_goto_mark(&line_start_mark, pfile); + parse_clear_mark(&line_start_mark); +} + +/* + * handle a #else directive. Do this by just continuing processing + * without changing if_stack ; this is so that the error message + * for missing #endif's etc. will point to the original #if. It + * is possible that something different would be better. + */ + +static int +do_else(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__) +{ + cpp_buffer *ip = CPP_BUFFER(pfile); + + if (CPP_PEDANTIC(pfile)) + validate_else(pfile, "#else"); + skip_rest_of_line(pfile); + + if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack) + { + cpp_error(pfile, "`#else' not within a conditional"); + return 0; + } + else + { + /* #ifndef can't have its special treatment for containing the whole file + * if it has a #else clause. */ + pfile->if_stack->control_macro = 0; + + if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF) + { + cpp_error(pfile, "`#else' after `#else'"); + fprintf(stderr, " (matches line %d", pfile->if_stack->lineno); + if (strcmp(pfile->if_stack->fname, ip->nominal_fname) != 0) + fprintf(stderr, ", file %s", pfile->if_stack->fname); + fprintf(stderr, ")\n"); + } + pfile->if_stack->type = T_ELSE; + } + + if (pfile->if_stack->if_succeeded) + skip_if_group(pfile, 0); + else + { + ++pfile->if_stack->if_succeeded; /* continue processing input */ + output_line_command(pfile, 1, same_file); + } + return 0; +} + +/* + * unstack after #endif command + */ + +static int +do_endif(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__) +{ + if (CPP_PEDANTIC(pfile)) + validate_else(pfile, "#endif"); + skip_rest_of_line(pfile); + + if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack) + { + cpp_error(pfile, "unbalanced `#endif'"); + } + else + { + IF_STACK_FRAME *temp = pfile->if_stack; + + pfile->if_stack = temp->next; + if (temp->control_macro) + { + /* This #endif matched a #ifndef at the start of the file. + * See if it is at the end of the file. */ + struct parse_marker start_mark; + int c; + + parse_set_mark(&start_mark, pfile); + + for (;;) + { + cpp_skip_hspace(pfile); + c = GETC(); + if (c != '\n') + break; + } + parse_goto_mark(&start_mark, pfile); + parse_clear_mark(&start_mark); + + if (c == EOF) + { + /* If we get here, this #endif ends a #ifndef + * that contains all of the file (aside from whitespace). + * Arrange not to include the file again + * if the macro that was tested is defined. + * + * Do not do this for the top-level file in a -include or any + * file in a -imacros. */ + { + file_name_list *ifile = pfile->all_include_files; + + for (; ifile; ifile = ifile->next) + { + if (!strcmp(ifile->fname, CPP_BUFFER(pfile)->fname)) + { + ifile->control_macro = temp->control_macro; + break; + } + } + } + } + } + free(temp); + output_line_command(pfile, 1, same_file); + } + return 0; +} + +/* When an #else or #endif is found while skipping failed conditional, + * if -pedantic was specified, this is called to warn about text after + * the command name. P points to the first char after the command name. */ + +static void +validate_else(cpp_reader * pfile, const char *directive) +{ + int c; + + cpp_skip_hspace(pfile); + c = PEEKC(); + if (c != EOF && c != '\n') + cpp_pedwarn(pfile, + "text following `%s' violates ANSI standard", directive); +} + +/* Get the next token, and add it to the text in pfile->token_buffer. + * Return the kind of token we got. */ + +enum cpp_token +cpp_get_token(cpp_reader * pfile) +{ + int c, c2, c3; + long old_written = 0; + long start_line = 0, start_column = 0; + enum cpp_token token; + struct cpp_options *opts = CPP_OPTIONS(pfile); + + CPP_BUFFER(pfile)->prev = CPP_BUFFER(pfile)->cur; + get_next: + c = GETC(); + if (c == EOF) + { + handle_eof: + if (CPP_BUFFER(pfile)->seen_eof) + { + if (cpp_pop_buffer(pfile) != CPP_NULL_BUFFER(pfile)) + goto get_next; + else + return CPP_EOF; + } + else + { + cpp_buffer *next_buf = CPP_PREV_BUFFER(CPP_BUFFER(pfile)); + + CPP_BUFFER(pfile)->seen_eof = 1; + if (CPP_BUFFER(pfile)->nominal_fname && next_buf) + { + /* We're about to return from an #include file. + * Emit #line information now (as part of the CPP_POP) result. + * But the #line refers to the file we will pop to. */ + cpp_buffer *cur_buffer = CPP_BUFFER(pfile); + + CPP_BUFFER(pfile) = next_buf; + pfile->input_stack_listing_current = 0; + output_line_command(pfile, 0, leave_file); + CPP_BUFFER(pfile) = cur_buffer; + } + return CPP_POP; + } + } + else + { + switch (c) + { + long newlines; + struct parse_marker start_mark; + + case '/': + if (PEEKC() == '=') + goto op2; + if (opts->put_out_comments) + parse_set_mark(&start_mark, pfile); + newlines = 0; + cpp_buf_line_and_col(cpp_file_buffer(pfile), + &start_line, &start_column); + c = skip_comment(pfile, &newlines); + if (opts->put_out_comments && (c == '/' || c == EOF)) + parse_clear_mark(&start_mark); + if (c == '/') + goto randomchar; + if (c == EOF) + { + cpp_error_with_line(pfile, start_line, start_column, + "unterminated comment"); + goto handle_eof; + } + c = '/'; /* Initial letter of comment. */ + return_comment: + /* Comments are equivalent to spaces. + * For -traditional, a comment is equivalent to nothing. */ + if (opts->put_out_comments) + { + cpp_buffer *pbuf = CPP_BUFFER(pfile); + unsigned char *start = pbuf->buf + start_mark.position; + int len = pbuf->cur - start; + + CPP_RESERVE(pfile, 1 + len); + CPP_PUTC_Q(pfile, c); + CPP_PUTS_Q(pfile, start, len); + pfile->lineno += newlines; + parse_clear_mark(&start_mark); + return CPP_COMMENT; + } + else if (newlines > 0) + { + output_line_command(pfile, 0, same_file); + CPP_RESERVE(pfile, 1); + CPP_PUTC_Q(pfile, ' '); + return CPP_VSPACE; + } + else + { + CPP_RESERVE(pfile, 1); + CPP_PUTC_Q(pfile, ' '); + return CPP_HSPACE; + } + + case '#': + if (!pfile->only_seen_white) + goto randomchar; + if (handle_directive(pfile)) + return CPP_DIRECTIVE; + pfile->only_seen_white = 0; + return CPP_OTHER; + + case '\"': + case '\'': + /* A single quoted string is treated like a double -- some + * programs (e.g., troff) are perverse this way */ + cpp_buf_line_and_col(cpp_file_buffer(pfile), + &start_line, &start_column); + old_written = CPP_WRITTEN(pfile); + string: + CPP_PUTC(pfile, c); + while (1) + { + int cc = GETC(); + + if (cc == EOF) + { + if (CPP_IS_MACRO_BUFFER(CPP_BUFFER(pfile))) + { + /* try harder: this string crosses a macro expansion + * boundary. This can happen naturally if -traditional. + * Otherwise, only -D can make a macro with an unmatched + * quote. */ + cpp_buffer *next_buf + = CPP_PREV_BUFFER(CPP_BUFFER(pfile)); + + (*CPP_BUFFER(pfile)->cleanup) + (CPP_BUFFER(pfile), pfile); + CPP_BUFFER(pfile) = next_buf; + continue; + } + cpp_error_with_line(pfile, start_line, start_column, + "unterminated string or character constant"); + if (pfile->multiline_string_line != start_line + && pfile->multiline_string_line != 0) + cpp_error_with_line(pfile, + pfile->multiline_string_line, + -1, + "possible real start of unterminated constant"); + pfile->multiline_string_line = 0; + break; + } + CPP_PUTC(pfile, cc); + switch (cc) + { + case '\n': + /* Traditionally, end of line ends a string constant with + * no error. So exit the loop and record the new line. */ + if (c == '\'') + { + cpp_error_with_line(pfile, start_line, start_column, + "unterminated character constant"); + goto while2end; + } + if (CPP_PEDANTIC(pfile) + && pfile->multiline_string_line == 0) + { + cpp_pedwarn_with_line(pfile, start_line, + start_column, + "string constant runs past end of line"); + } + if (pfile->multiline_string_line == 0) + pfile->multiline_string_line = start_line; + break; + + case '\\': + cc = GETC(); + if (cc == '\n') + { + /* Backslash newline is replaced by nothing at all. */ + CPP_ADJUST_WRITTEN(pfile, -1); + pfile->lineno++; + } + else + { + /* ANSI stupidly requires that in \\ the second \ + * is *not* prevented from combining with a newline. */ + NEWLINE_FIX1(cc); + if (cc != EOF) + CPP_PUTC(pfile, cc); + } + break; + + case '\"': + case '\'': + if (cc == c) + goto while2end; + break; + } + } + while2end: + pfile->lineno += count_newlines(pfile->token_buffer + old_written, + CPP_PWRITTEN(pfile)); + pfile->only_seen_white = 0; + return c == '\'' ? CPP_CHAR : CPP_STRING; + + case '$': + if (!opts->dollars_in_ident) + goto randomchar; + goto letter; + + case ':': + if (opts->cplusplus && PEEKC() == ':') + goto op2; + goto randomchar; + + case '&': + case '+': + case '|': + NEWLINE_FIX; + c2 = PEEKC(); + if (c2 == c || c2 == '=') + goto op2; + goto randomchar; + + case '*': + case '!': + case '%': + case '=': + case '^': + NEWLINE_FIX; + if (PEEKC() == '=') + goto op2; + goto randomchar; + + case '-': + NEWLINE_FIX; + c2 = PEEKC(); + if (c2 == '-' && opts->chill) + { + /* Chill style comment */ + if (opts->put_out_comments) + parse_set_mark(&start_mark, pfile); + FORWARD(1); /* Skip second '-'. */ + for (;;) + { + c = GETC(); + if (c == EOF) + break; + if (c == '\n') + { + /* Don't consider final '\n' to be part of comment. */ + FORWARD(-1); + break; + } + } + c = '-'; + goto return_comment; + } + if (c2 == '-' || c2 == '=' || c2 == '>') + goto op2; + goto randomchar; + + case '<': + if (pfile->parsing_include_directive) + { + for (;;) + { + CPP_PUTC(pfile, c); + if (c == '>') + break; + c = GETC(); + NEWLINE_FIX1(c); + if (c == '\n' || c == EOF) + { + cpp_error(pfile, + "missing '>' in `#include '"); + break; + } + } + return CPP_STRING; + } + /* else fall through */ + case '>': + NEWLINE_FIX; + c2 = PEEKC(); + if (c2 == '=') + goto op2; + if (c2 != c) + goto randomchar; + FORWARD(1); + CPP_RESERVE(pfile, 4); + CPP_PUTC(pfile, c); + CPP_PUTC(pfile, c2); + NEWLINE_FIX; + c3 = PEEKC(); + if (c3 == '=') + CPP_PUTC_Q(pfile, GETC()); + CPP_NUL_TERMINATE_Q(pfile); + pfile->only_seen_white = 0; + return CPP_OTHER; + + case '@': + if (CPP_BUFFER(pfile)->has_escapes) + { + c = GETC(); + // fix macro expansions starting with - losing the - + if (c == '-') + { + CPP_PUTS(pfile, "-", 1); + return CPP_OTHER; + } + // fix macro expansions starting with - losing the + + else if (c == '+') + { + CPP_PUTS(pfile, "+", 1); + return CPP_OTHER; + } + // fix macro expansions starting with - losing the . + else if (c == '.') + { + CPP_PUTS(pfile, ".", 1); + return CPP_OTHER; + } + else if (is_space[c]) + { + CPP_RESERVE(pfile, 1); + if (pfile->output_escapes) + CPP_PUTC_Q(pfile, '@'); + return CPP_HSPACE; + } + } + if (pfile->output_escapes) + { + CPP_PUTS(pfile, "@@", 2); + return CPP_OTHER; + } + goto randomchar; + + case '.': + NEWLINE_FIX; + c2 = PEEKC(); + if (isdigit(c2)) + { + CPP_RESERVE(pfile, 2); + CPP_PUTC_Q(pfile, '.'); + c = GETC(); + goto number; + } + /* FIXME - misses the case "..\\\n." */ + if (c2 == '.' && PEEKN(1) == '.') + { + CPP_RESERVE(pfile, 4); + CPP_PUTC_Q(pfile, '.'); + CPP_PUTC_Q(pfile, '.'); + CPP_PUTC_Q(pfile, '.'); + FORWARD(2); + CPP_NUL_TERMINATE_Q(pfile); + pfile->only_seen_white = 0; + return CPP_3DOTS; + } + goto randomchar; + + op2: + token = CPP_OTHER; + pfile->only_seen_white = 0; + op2any: + CPP_RESERVE(pfile, 3); + CPP_PUTC_Q(pfile, c); + CPP_PUTC_Q(pfile, GETC()); + CPP_NUL_TERMINATE_Q(pfile); + return token; + + case 'L': + NEWLINE_FIX; + c2 = PEEKC(); + if ((c2 == '\'' || c2 == '\"')) + { + CPP_PUTC(pfile, c); + c = GETC(); + goto string; + } + goto letter; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + number: + c2 = '.'; + for (;;) + { + CPP_RESERVE(pfile, 2); + CPP_PUTC_Q(pfile, c); + NEWLINE_FIX; + c = PEEKC(); + if (c == EOF) + break; + if (!is_idchar[c] && c != '.' + && ((c2 != 'e' && c2 != 'E') || (c != '+' && c != '-'))) + break; + FORWARD(1); + c2 = c; + } + CPP_NUL_TERMINATE_Q(pfile); + pfile->only_seen_white = 0; + return CPP_NUMBER; + case 'b': + case 'c': + case 'd': + case 'h': + case 'o': + case 'B': + case 'C': + case 'D': + case 'H': + case 'O': + if (opts->chill && PEEKC() == '\'') + { + pfile->only_seen_white = 0; + CPP_RESERVE(pfile, 2); + CPP_PUTC_Q(pfile, c); + CPP_PUTC_Q(pfile, '\''); + FORWARD(1); + for (;;) + { + c = GETC(); + if (c == EOF) + goto chill_number_eof; + if (!is_idchar[c]) + { + if (c == '\\' && PEEKC() == '\n') + { + FORWARD(2); + continue; + } + break; + } + CPP_PUTC(pfile, c); + } + if (c == '\'') + { + CPP_RESERVE(pfile, 2); + CPP_PUTC_Q(pfile, c); + CPP_NUL_TERMINATE_Q(pfile); + return CPP_STRING; + } + else + { + FORWARD(-1); + chill_number_eof: + CPP_NUL_TERMINATE(pfile); + return CPP_NUMBER; + } + } + else + goto letter; + case '_': + case 'a': + case 'e': + case 'f': + case 'g': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': + case 'A': + case 'E': + case 'F': + case 'G': + case 'I': + case 'J': + case 'K': + case 'M': + case 'N': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + letter: + { + HASHNODE *hp; + char *ident; + int before_name_written = CPP_WRITTEN(pfile); + int ident_len; + + parse_name(pfile, c); + pfile->only_seen_white = 0; + if (pfile->no_macro_expand) + return CPP_NAME; + ident = (char *)pfile->token_buffer + before_name_written; + ident_len = CPP_PWRITTEN(pfile) - (unsigned char *)ident; + hp = cpp_lookup(ident, ident_len, -1); + if (!hp) + return CPP_NAME; + if (hp->type == T_DISABLED) + { + if (pfile->output_escapes) + { /* Return "@-IDENT", followed by '\0'. */ + int i; + + CPP_RESERVE(pfile, 3); + ident = + (char *)pfile->token_buffer + before_name_written; + CPP_ADJUST_WRITTEN(pfile, 2); + for (i = ident_len; i >= 0; i--) + ident[i + 2] = ident[i]; + ident[0] = '@'; + ident[1] = '-'; + } + return CPP_NAME; + } + /* If macro wants an arglist, verify that a '(' follows. + * first skip all whitespace, copying it to the output + * after the macro name. Then, if there is no '(', + * decide this is not a macro call and leave things that way. */ + if (hp->type == T_MACRO && hp->value.defn->nargs >= 0) + { + struct parse_marker macro_mark; + int is_macro_call; + + while (CPP_IS_MACRO_BUFFER(CPP_BUFFER(pfile))) + { + cpp_buffer *next_buf; + + cpp_skip_hspace(pfile); + if (PEEKC() != EOF) + break; + next_buf = CPP_PREV_BUFFER(CPP_BUFFER(pfile)); + (*CPP_BUFFER(pfile)->cleanup) (CPP_BUFFER(pfile), + pfile); + CPP_BUFFER(pfile) = next_buf; + } + parse_set_mark(¯o_mark, pfile); + for (;;) + { + cpp_skip_hspace(pfile); + c = PEEKC(); + is_macro_call = c == '('; + if (c != '\n') + break; + FORWARD(1); + } + if (!is_macro_call) + parse_goto_mark(¯o_mark, pfile); + parse_clear_mark(¯o_mark); + if (!is_macro_call) + return CPP_NAME; + } + /* This is now known to be a macro call. */ + + /* it might not actually be a macro. */ + if (hp->type != T_MACRO) + { + int xbuf_len; + unsigned char *xbuf; + + CPP_SET_WRITTEN(pfile, before_name_written); + special_symbol(hp, pfile); + xbuf_len = CPP_WRITTEN(pfile) - before_name_written; + xbuf = (unsigned char *)xmalloc(xbuf_len + 1); + CPP_SET_WRITTEN(pfile, before_name_written); + memcpy(xbuf, CPP_PWRITTEN(pfile), xbuf_len + 1); + push_macro_expansion(pfile, xbuf, xbuf_len, hp); + } + else + { + /* Expand the macro, reading arguments as needed, + * and push the expansion on the input stack. */ + macroexpand(pfile, hp); + CPP_SET_WRITTEN(pfile, before_name_written); + } + + /* An extra "@ " is added to the end of a macro expansion + * to prevent accidental token pasting. We prefer to avoid + * unneeded extra spaces (for the sake of cpp-using tools like + * imake). Here we remove the space if it is safe to do so. */ + if (pfile->buffer->rlimit - pfile->buffer->cur >= 3 + && pfile->buffer->rlimit[-2] == '@' + && pfile->buffer->rlimit[-1] == ' ') + { + int c1 = pfile->buffer->rlimit[-3]; + + c2 = CPP_BUF_PEEK(CPP_PREV_BUFFER(CPP_BUFFER(pfile))); + + if (c2 == EOF || !unsafe_chars(c1, c2)) + pfile->buffer->rlimit -= 2; + } + } + goto get_next; + + case ' ': + case '\t': + case '\v': + case '\r': + for (;;) + { + CPP_PUTC(pfile, c); + c = PEEKC(); + if (c == EOF || !is_hor_space[c]) + break; + FORWARD(1); + } + return CPP_HSPACE; + + case '\\': + c2 = PEEKC(); + if (c2 != '\n') + goto randomchar; + token = CPP_HSPACE; + goto op2any; + + case '\n': + CPP_PUTC(pfile, c); + if (pfile->only_seen_white == 0) + pfile->only_seen_white = 1; + pfile->lineno++; + output_line_command(pfile, 1, same_file); + return CPP_VSPACE; + + case '(': + token = CPP_LPAREN; + goto char1; + case ')': + token = CPP_RPAREN; + goto char1; + case '{': + token = CPP_LBRACE; + goto char1; + case '}': + token = CPP_RBRACE; + goto char1; + case ',': + token = CPP_COMMA; + goto char1; + case ';': + token = CPP_SEMICOLON; + goto char1; + + randomchar: + default: + token = CPP_OTHER; + char1: + pfile->only_seen_white = 0; + CPP_PUTC(pfile, c); + return token; + } + } +} + +#if 0 /* Unused */ +/* Like cpp_get_token, but skip spaces and comments. */ +enum cpp_token +cpp_get_non_space_token(cpp_reader * pfile) +{ + int old_written = CPP_WRITTEN(pfile); + + for (;;) + { + enum cpp_token token = cpp_get_token(pfile); + + if (token != CPP_COMMENT && token != CPP_POP + && token != CPP_HSPACE && token != CPP_VSPACE) + return token; + CPP_SET_WRITTEN(pfile, old_written); + } +} +#endif + +/* Parse an identifier starting with C. */ + +int +parse_name(cpp_reader * pfile, int c) +{ + for (;;) + { + if (!is_idchar[c]) + { + if (c == '\\' && PEEKC() == '\n') + { + FORWARD(2); + continue; + } + FORWARD(-1); + break; + } + CPP_RESERVE(pfile, 2); /* One more for final NUL. */ + CPP_PUTC_Q(pfile, c); + c = GETC(); + if (c == EOF) + break; + } + CPP_NUL_TERMINATE_Q(pfile); + return 1; +} + +/* Maintain and search list of included files, for #import. */ + +/* Hash a file name for import_hash_table. */ + +static int +import_hash(char *f) +{ + int val = 0; + + while (*f) + val += *f++; + return (val % IMPORT_HASH_SIZE); +} + +/* Search for file FILENAME in import_hash_table. + * Return -2 if found, either a matching name or a matching inode. + * Otherwise, open the file and return a file descriptor if successful + * or -1 if unsuccessful. */ + +static int +lookup_import(cpp_reader * pfile, char *filename, file_name_list * searchptr) +{ + struct import_file *i; + int h; + int hashval; + struct stat sb; + int fd; + + hashval = import_hash(filename); + + /* Attempt to find file in list of already included files */ + i = pfile->import_hash_table[hashval]; + + while (i) + { + if (!strcmp(filename, i->name)) + return -2; /* return found */ + i = i->next; + } + /* Open it and try a match on inode/dev */ + fd = open_include_file(pfile, filename, searchptr); + if (fd < 0) + return fd; + fstat(fd, &sb); + for (h = 0; h < IMPORT_HASH_SIZE; h++) + { + i = pfile->import_hash_table[h]; + while (i) + { + /* Compare the inode and the device. + * Supposedly on some systems the inode is not a scalar. */ + if (!memcmp + ((char *)&i->inode, (char *)&sb.st_ino, sizeof(sb.st_ino)) + && i->dev == sb.st_dev) + { + close(fd); + return -2; /* return found */ + } + i = i->next; + } + } + return fd; /* Not found, return open file */ +} + +/* Add the file FNAME, open on descriptor FD, to import_hash_table. */ + +static void +add_import(cpp_reader * pfile, int fd, char *fname) +{ + struct import_file *i; + int hashval; + struct stat sb; + + hashval = import_hash(fname); + fstat(fd, &sb); + i = (struct import_file *)xmalloc(sizeof(struct import_file)); + + i->name = (char *)xmalloc(strlen(fname) + 1); + strcpy(i->name, fname); + memcpy((char *)&i->inode, (char *)&sb.st_ino, sizeof(sb.st_ino)); + i->dev = sb.st_dev; + i->next = pfile->import_hash_table[hashval]; + pfile->import_hash_table[hashval] = i; +} + +/* The file_name_map structure holds a mapping of file names for a + * particular directory. This mapping is read from the file named + * FILE_NAME_MAP_FILE in that directory. Such a file can be used to + * map filenames on a file system with severe filename restrictions, + * such as DOS. The format of the file name map file is just a series + * of lines with two tokens on each line. The first token is the name + * to map, and the second token is the actual name to use. */ + +struct file_name_map { + struct file_name_map *map_next; + char *map_from; + char *map_to; +}; + +#if USE_FILE_NAME_MAPS + +#define FILE_NAME_MAP_FILE "header.gcc" + +/* Read a space delimited string of unlimited length from a stdio + * file. */ + +static char * +read_filename_string(int ch, FILE * f) +{ + char *alloc, *set; + int len; + + len = 20; + set = alloc = (char *)xmalloc(len + 1); + if (!is_space[ch]) + { + *set++ = ch; + while ((ch = getc(f)) != EOF && !is_space[ch]) + { + if (set - alloc == len) + { + len *= 2; + alloc = (char *)xrealloc(alloc, len + 1); + set = alloc + len / 2; + } + *set++ = ch; + } + } + *set = '\0'; + ungetc(ch, f); + return alloc; +} + +/* This structure holds a linked list of file name maps, one per directory. */ +struct file_name_map_list { + struct file_name_map_list *map_list_next; + char *map_list_name; + struct file_name_map *map_list_map; +}; + +/* Read the file name map file for DIRNAME. */ + +static struct file_name_map * +read_name_map(cpp_reader * pfile, const char *dirname) +{ + struct file_name_map_list *map_list_ptr; + char *name; + FILE *f; + + for (map_list_ptr = CPP_OPTIONS(pfile)->map_list; map_list_ptr; + map_list_ptr = map_list_ptr->map_list_next) + if (!strcmp(map_list_ptr->map_list_name, dirname)) + return map_list_ptr->map_list_map; + + map_list_ptr = + ((struct file_name_map_list *)xmalloc(sizeof(struct file_name_map_list))); + + map_list_ptr->map_list_name = savestring(dirname); + map_list_ptr->map_list_map = NULL; + + name = (char *)alloca(strlen(dirname) + strlen(FILE_NAME_MAP_FILE) + 2); + strcpy(name, dirname); + if (*dirname) + strcat(name, "/"); + strcat(name, FILE_NAME_MAP_FILE); +#ifndef __EMX__ + f = fopen(name, "rb"); +#else + f = fopen(name, "rtb"); +#endif + if (!f) + map_list_ptr->map_list_map = NULL; + else + { + int ch; + int dirlen = strlen(dirname); + + while ((ch = getc(f)) != EOF) + { + char *from, *to; + struct file_name_map *ptr; + + if (is_space[ch]) + continue; + from = read_filename_string(ch, f); + while ((ch = getc(f)) != EOF && is_hor_space[ch]); + to = read_filename_string(ch, f); + + ptr = + ((struct file_name_map *)xmalloc(sizeof(struct file_name_map))); + + ptr->map_from = from; + + /* Make the real filename absolute. */ + if (*to == '/') + ptr->map_to = to; + else + { + ptr->map_to = (char *)xmalloc(dirlen + strlen(to) + 2); + strcpy(ptr->map_to, dirname); + ptr->map_to[dirlen] = '/'; + strcpy(ptr->map_to + dirlen + 1, to); + free(to); + } + + ptr->map_next = map_list_ptr->map_list_map; + map_list_ptr->map_list_map = ptr; + + while ((ch = getc(f)) != '\n') + if (ch == EOF) + break; + } + fclose(f); + } + + map_list_ptr->map_list_next = CPP_OPTIONS(pfile)->map_list; + CPP_OPTIONS(pfile)->map_list = map_list_ptr; + + return map_list_ptr->map_list_map; +} + +/* Try to open include file FILENAME. SEARCHPTR is the directory + * being tried from the include file search path. This function maps + * filenames on file systems based on information read by + * read_name_map. */ + +static int +open_include_file(cpp_reader * pfile, char *filename, + file_name_list * searchptr) +{ + struct file_name_map *map; + const char *from; + const char *p, *dir; + + if (searchptr && !searchptr->got_name_map) + { + searchptr->name_map = read_name_map(pfile, + searchptr->fname + ? searchptr->fname : "."); + searchptr->got_name_map = 1; + } + /* First check the mapping for the directory we are using. */ + if (searchptr && searchptr->name_map) + { + from = filename; + if (searchptr->fname) + from += strlen(searchptr->fname) + 1; + for (map = searchptr->name_map; map; map = map->map_next) + { + if (!strcmp(map->map_from, from)) + { + /* Found a match. */ + return open(map->map_to, O_RDONLY | O_BINARY, 0666); + } + } + } + /* Try to find a mapping file for the particular directory we are + * looking in. Thus #include will look up sys/types.h + * in /usr/include/header.gcc and look up types.h in + * /usr/include/sys/header.gcc. */ + p = strrchr(filename, '/'); + if (!p) + p = filename; + if (searchptr + && searchptr->fname + && strlen(searchptr->fname) == (unsigned)(p - filename) + && !strncmp(searchptr->fname, filename, p - filename)) + { + /* FILENAME is in SEARCHPTR, which we've already checked. */ + return open(filename, O_RDONLY | O_BINARY, 0666); + } + if (p == filename) + { + dir = "."; + from = filename; + } + else + { + char *s; + + s = (char *)alloca(p - filename + 1); + memcpy(s, filename, p - filename); + s[p - filename] = '\0'; + from = p + 1; + dir = s; + } + for (map = read_name_map(pfile, dir); map; map = map->map_next) + if (!strcmp(map->map_from, from)) + return open(map->map_to, O_RDONLY | O_BINARY, 0666); + + return open(filename, O_RDONLY | O_BINARY, 0666); +} + +#else + +static int +open_include_file(cpp_reader * pfile __UNUSED__, char *filename, + file_name_list * searchptr __UNUSED__) +{ + return open(filename, O_RDONLY | O_BINARY, 0666); +} + +#endif /* USE_FILE_NAME_MAPS */ + +static int +dos2unix(cpp_buffer *fp, int length) +{ + unsigned char *tbuf; + int nlen = 0, i; + + tbuf = xmalloc(length + 4); + if (!tbuf) return length; + for (i = 0; i < length; i++) + { + if ((fp->buf[i] == '\r') && + (fp->buf[i + 1] == '\n')) + { + // skip \r in \r\n + continue; + } + tbuf[nlen] = fp->buf[i]; + nlen++; + } + tbuf[nlen] = 0; + + free(fp->buf); + fp->buf = tbuf; + return nlen; +} + +/* Process the contents of include file FNAME, already open on descriptor F, + * with output to OP. + * SYSTEM_HEADER_P is 1 if this file resides in any one of the known + * "system" include directories (as decided by the `is_system_include' + * function above). + * DIRPTR is the link in the dir path through which this file was found, + * or 0 if the file name was absolute or via the current directory. + * Return 1 on success, 0 on failure. + * + * The caller is responsible for the cpp_push_buffer. */ + +static int +finclude(cpp_reader * pfile, int f, const char *fname, int system_header_p, + file_name_list * dirptr) +{ + int st_mode; + long st_size; + long i; + int length; + cpp_buffer *fp; /* For input stack frame */ + + if (file_size_and_mode(f, &st_mode, &st_size) < 0) + { + cpp_perror_with_name(pfile, fname); + close(f); + cpp_pop_buffer(pfile); + return 0; + } + fp = CPP_BUFFER(pfile); + fp->nominal_fname = fp->fname = fname; + fp->dir = dirptr; + fp->system_header_p = system_header_p; + fp->lineno = 1; + fp->colno = 1; + fp->cleanup = file_cleanup; + + if (S_ISREG(st_mode)) + { + fp->buf = (unsigned char *)xmalloc(st_size + 2); + /* Read the file contents, knowing that st_size is an upper bound + * on the number of bytes we can read. */ + length = safe_read(f, (char *)fp->buf, st_size); + length = dos2unix(fp, length); + + fp->alimit = fp->buf + st_size + 2; + fp->cur = fp->buf; + fp->rlimit = fp->buf + length; + if (length < 0) + goto nope; + } + else if (S_ISDIR(st_mode)) + { + cpp_error(pfile, "directory `%s' specified in #include", fname); + close(f); + return 0; + } + else + { + /* Cannot count its file size before reading. + * First read the entire file into heap and + * copy them into buffer on stack. */ + + int bsize = 2000; + + st_size = 0; + fp->buf = (unsigned char *)xmalloc(bsize + 2); + + for (;;) + { + i = safe_read(f, (char *)(fp->buf + st_size), bsize - st_size); + if (i < 0) + goto nope; /* error! */ + st_size += i; + if (st_size != bsize) + break; /* End of file */ + bsize *= 2; + fp->buf = (unsigned char *)xrealloc(fp->buf, bsize + 2); + } + length = st_size; + length = dos2unix(fp, length); + } + + if ((length > 0 && fp->buf[length - 1] != '\n') + /* Backslash-newline at end is not good enough. */ + || (length > 1 && fp->buf[length - 2] == '\\')) + { + fp->buf[length++] = '\n'; + } + fp->buf[length] = '\0'; + + fp->rlimit = fp->buf + length; + + /* Close descriptor now, so nesting does not use lots of descriptors. */ + close(f); + + /* Must do this before calling trigraph_pcp, so that the correct file name + * will be printed in warning messages. */ + + pfile->input_stack_listing_current = 0; + + return 1; + + nope: + + cpp_perror_with_name(pfile, fname); + close(f); + free(fp->buf); + return 1; +} + +int +push_parse_file(cpp_reader * pfile, const char *fname) +{ + struct cpp_options *opts = CPP_OPTIONS(pfile); + struct cpp_pending *pend; + char *p; + int f; + cpp_buffer *fp; + + /* The code looks at the defaults through this pointer, rather than through + * the constant structure above. This pointer gets changed if an environment + * variable specifies other defaults. */ + struct default_include *include_defaults = include_defaults_array; + + /* Add dirs from CPATH after dirs from -I. */ + /* There seems to be confusion about what CPATH should do, + * so for the moment it is not documented. */ + /* Some people say that CPATH should replace the standard include dirs, + * but that seems pointless: it comes before them, so it overrides them + * anyway. */ + p = (char *)getenv("CPATH"); + if (p && !opts->no_standard_includes) + path_include(pfile, p); + + /* Now that dollars_in_ident is known, initialize is_idchar. */ + initialize_char_syntax(opts); + + /* Do partial setup of input buffer for the sake of generating + * early #line directives (when -g is in effect). */ + fp = cpp_push_buffer(pfile, NULL, 0); + if (!opts->in_fname) + opts->in_fname = ""; + fp->nominal_fname = fp->fname = opts->in_fname; + fp->lineno = 0; + + /* Install __LINE__, etc. Must follow initialize_char_syntax + * and option processing. */ + initialize_builtins(pfile); + + /* Do standard #defines and assertions + * that identify system and machine type. */ + + if (!opts->inhibit_predefs) + { + p = (char *)alloca(strlen(predefs) + 1); + + strcpy(p, predefs); + while (*p) + { + char *q; + + while (*p == ' ' || *p == '\t') + p++; + /* Handle -D options. */ + if (p[0] == '-' && p[1] == 'D') + { + q = &p[2]; + while (*p && *p != ' ' && *p != '\t') + p++; + if (*p != 0) + *p++ = 0; + if (opts->debug_output) + output_line_command(pfile, 0, same_file); + cpp_define(pfile, (unsigned char *)q); + while (*p == ' ' || *p == '\t') + p++; + } + else if (p[0] == '-' && p[1] == 'A') + { + /* Handle -A options (assertions). */ + char *assertion; + char *past_name; + char *value; + char *past_value; + char *termination; + int save_char; + + assertion = &p[2]; + past_name = assertion; + /* Locate end of name. */ + while (*past_name && *past_name != ' ' + && *past_name != '\t' && *past_name != '(') + past_name++; + /* Locate `(' at start of value. */ + value = past_name; + while (*value && (*value == ' ' || *value == '\t')) + value++; + if (*value++ != '(') + abort(); + while (*value && (*value == ' ' || *value == '\t')) + value++; + past_value = value; + /* Locate end of value. */ + while (*past_value && *past_value != ' ' + && *past_value != '\t' && *past_value != ')') + past_value++; + termination = past_value; + while (*termination + && (*termination == ' ' || *termination == '\t')) + termination++; + if (*termination++ != ')') + abort(); + if (*termination && *termination != ' ' + && *termination != '\t') + abort(); + /* Temporarily null-terminate the value. */ + save_char = *termination; + *termination = '\0'; + /* Install the assertion. */ + make_assertion(pfile, "-A", assertion); + *termination = (char)save_char; + p = termination; + while (*p == ' ' || *p == '\t') + p++; + } + else + { + abort(); + } + } + } + /* Now handle the command line options. */ + + /* Do -U's, -D's and -A's in the order they were seen. */ + /* First reverse the list. */ + opts->pending = nreverse_pending(opts->pending); + + for (pend = opts->pending; pend; pend = pend->next) + { + if (pend->cmd && pend->cmd[0] == '-') + { + switch (pend->cmd[1]) + { + case 'U': + if (opts->debug_output) + output_line_command(pfile, 0, same_file); + do_undef(pfile, NULL, (unsigned char *)pend->arg, + (unsigned char *)pend->arg + strlen(pend->arg)); + break; + case 'D': + if (opts->debug_output) + output_line_command(pfile, 0, same_file); + cpp_define(pfile, (unsigned char *)pend->arg); + break; + case 'A': + make_assertion(pfile, "-A", pend->arg); + break; + } + } + } + + opts->done_initializing = 1; + + { /* read the appropriate environment variable and if it exists + * replace include_defaults with the listed path. */ + char *epath = 0; + + switch ((opts->objc << 1) + opts->cplusplus) + { + case 0: + epath = getenv("C_INCLUDE_PATH"); + break; + case 1: + epath = getenv("CPLUS_INCLUDE_PATH"); + break; + case 2: + epath = getenv("OBJC_INCLUDE_PATH"); + break; + case 3: + epath = getenv("OBJCPLUS_INCLUDE_PATH"); + break; + } + /* If the environment var for this language is set, + * add to the default list of include directories. */ + if (epath) + { + char *nstore = (char *)alloca(strlen(epath) + 2); + int num_dirs; + char *startp, *endp; + + for (num_dirs = 1, startp = epath; *startp; startp++) + if (*startp == PATH_SEPARATOR) + num_dirs++; + include_defaults + = (struct default_include *)xmalloc((num_dirs + * + sizeof(struct + default_include)) + + sizeof + (include_defaults_array)); + + startp = endp = epath; + num_dirs = 0; + while (1) + { + /* Handle cases like c:/usr/lib:d:/gcc/lib */ + if ((*endp == PATH_SEPARATOR) || *endp == 0) + { + strncpy(nstore, startp, endp - startp); + if (endp == startp) + strcpy(nstore, "."); + else + nstore[endp - startp] = '\0'; + + include_defaults[num_dirs].fname = savestring(nstore); + include_defaults[num_dirs].cplusplus = opts->cplusplus; + include_defaults[num_dirs].cxx_aware = 1; + num_dirs++; + if (*endp == '\0') + break; + endp = startp = endp + 1; + } + else + endp++; + } + /* Put the usual defaults back in at the end. */ + memcpy((char *)&include_defaults[num_dirs], + (char *)include_defaults_array, + sizeof(include_defaults_array)); + } + } + + append_include_chain(pfile, opts->before_system, opts->last_before_system); + opts->first_system_include = opts->before_system; + + /* Unless -fnostdinc, + * tack on the standard include file dirs to the specified list */ + if (!opts->no_standard_includes) + { + struct default_include *di = include_defaults; + char *specd_prefix = opts->include_prefix; + char *default_prefix = savestring(GCC_INCLUDE_DIR); + int default_len = 0; + + /* Remove the `include' from /usr/local/lib/gcc.../include. */ + if (!strcmp(default_prefix + strlen(default_prefix) - 8, "/include")) + { + default_len = strlen(default_prefix) - 7; + default_prefix[default_len] = 0; + } + /* Search "translated" versions of GNU directories. + * These have /usr/local/lib/gcc... replaced by specd_prefix. */ + if (specd_prefix && default_len != 0) + for (di = include_defaults; di->fname; di++) + { + /* Some standard dirs are only for C++. */ + if (!di->cplusplus + || (opts->cplusplus + && !opts->no_standard_cplusplus_includes)) + { + /* Does this dir start with the prefix? */ + if (!strncmp(di->fname, default_prefix, default_len)) + { + /* Yes; change prefix and add to search list. */ + file_name_list *new_ + = + (file_name_list *) xmalloc(sizeof(file_name_list)); + int this_len = + strlen(specd_prefix) + strlen(di->fname) - + default_len; + char *str = + (char *)xmalloc(this_len + 1); + + strcpy(str, specd_prefix); + strcat(str, di->fname + default_len); + new_->fname = str; + new_->control_macro = 0; + new_->c_system_include_path = !di->cxx_aware; + new_->got_name_map = 0; + append_include_chain(pfile, new_, new_); + if (!opts->first_system_include) + opts->first_system_include = new_; + } + } + } + /* Search ordinary names for GNU include directories. */ + for (di = include_defaults; di->fname; di++) + { + /* Some standard dirs are only for C++. */ + if (!di->cplusplus + || (opts->cplusplus && !opts->no_standard_cplusplus_includes)) + { + file_name_list *new_ + = (file_name_list *) xmalloc(sizeof(file_name_list)); + + new_->control_macro = 0; + new_->c_system_include_path = !di->cxx_aware; + new_->fname = (char *)di->fname; + new_->got_name_map = 0; + append_include_chain(pfile, new_, new_); + if (!opts->first_system_include) + opts->first_system_include = new_; + } + } + } + /* Tack the after_include chain at the end of the include chain. */ + append_include_chain(pfile, opts->after_include, opts->last_after_include); + if (!opts->first_system_include) + opts->first_system_include = opts->after_include; + + /* With -v, print the list of dirs to search. */ + if (opts->verbose) + { + file_name_list *fl; + + fprintf(stderr, "#include \"...\" search starts here:\n"); + for (fl = opts->include; fl; fl = fl->next) + { + if (fl == opts->first_bracket_include) + fprintf(stderr, "#include <...> search starts here:\n"); + fprintf(stderr, " %s\n", fl->fname); + } + fprintf(stderr, "End of search list.\n"); + } + /* Scan the -imacros files before the main input. + * Much like #including them, but with no_output set + * so that only their macro definitions matter. */ + + opts->no_output++; + pfile->no_record_file++; + for (pend = opts->pending; pend; pend = pend->next) + { + if (pend->cmd && strcmp(pend->cmd, "-imacros") == 0) + { + int fd = open(pend->arg, O_RDONLY | O_BINARY, 0666); + + if (fd < 0) + { + cpp_perror_with_name(pfile, pend->arg); + return FATAL_EXIT_CODE; + } + cpp_push_buffer(pfile, NULL, 0); + finclude(pfile, fd, pend->arg, 0, NULL); + cpp_scan_buffer(pfile); + } + } + opts->no_output--; + pfile->no_record_file--; + + /* Copy the entire contents of the main input file into + * the stacked input buffer previously allocated for it. */ + if (!fname || *fname == 0) + { + fname = ""; + f = 0; + } + else if ((f = open(fname, O_RDONLY | O_BINARY, 0666)) < 0) + cpp_pfatal_with_name(pfile, fname); + + /* -MG doesn't select the form of output and must be specified with one of + * -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't + * inhibit compilation. */ + if (opts->print_deps_missing_files + && (opts->print_deps == 0 || !opts->no_output)) + cpp_fatal("-MG must be specified with one of -M or -MM"); + + /* Either of two environment variables can specify output of deps. + * Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET", + * where OUTPUT_FILE is the file to write deps info to + * and DEPS_TARGET is the target to mention in the deps. */ + + if (opts->print_deps == 0 + && (getenv("SUNPRO_DEPENDENCIES") != 0 + || getenv("DEPENDENCIES_OUTPUT") != 0)) + { + char *spec = getenv("DEPENDENCIES_OUTPUT"); + char *s; + char *output_file; + + if (!spec) + { + spec = getenv("SUNPRO_DEPENDENCIES"); + opts->print_deps = 2; + } + else + opts->print_deps = 1; + + s = spec; + /* Find the space before the DEPS_TARGET, if there is one. */ + /* This should use index. (mrs) */ + while (*s != 0 && *s != ' ') + s++; + if (*s != 0) + { + opts->deps_target = s + 1; + output_file = (char *)xmalloc(s - spec + 1); + memcpy(output_file, spec, s - spec); + output_file[s - spec] = 0; + } + else + { + opts->deps_target = 0; + output_file = spec; + } + + opts->deps_file = output_file; + opts->print_deps_append = 1; + } + /* For -M, print the expected object file name + * as the target of this Make-rule. */ + if (opts->print_deps) + { + pfile->deps_allocated_size = 200; + pfile->deps_buffer = (char *)xmalloc(pfile->deps_allocated_size); + pfile->deps_buffer[0] = 0; + pfile->deps_size = 0; + pfile->deps_column = 0; + + if (opts->deps_target) + deps_output(pfile, opts->deps_target, ':'); + else if (*opts->in_fname == 0) + deps_output(pfile, "-", ':'); + else + { + char *q; + int len; + + /* Discard all directory prefixes from filename. */ + if ((q = (char *)strrchr(opts->in_fname, '/')) +#ifdef DIR_SEPARATOR + && (q = strrchr(opts->in_fname, DIR_SEPARATOR)) +#endif + ) + ++q; + else + q = (char *)opts->in_fname; + + /* Copy remainder to mungable area. */ + p = (char *)alloca(strlen(q) + 8); + strcpy(p, q); + + /* Output P, but remove known suffixes. */ + len = strlen(p); + q = p + len; + if (len >= 2 && p[len - 2] == '.' && strchr("cCsSm", p[len - 1])) + q = p + (len - 2); + else if (len >= 3 + && p[len - 3] == '.' + && p[len - 2] == 'c' && p[len - 1] == 'c') + q = p + (len - 3); + else if (len >= 4 + && p[len - 4] == '.' + && p[len - 3] == 'c' + && p[len - 2] == 'x' && p[len - 1] == 'x') + q = p + (len - 4); + else if (len >= 4 + && p[len - 4] == '.' + && p[len - 3] == 'c' + && p[len - 2] == 'p' && p[len - 1] == 'p') + q = p + (len - 4); + + /* Supply our own suffix. */ + strcpy(q, ".o"); + + deps_output(pfile, p, ':'); + deps_output(pfile, opts->in_fname, ' '); + } + } + + /* Scan the -include files before the main input. + * We push these in reverse order, so that the first one is handled first. */ + + pfile->no_record_file++; + opts->pending = nreverse_pending(opts->pending); + for (pend = opts->pending; pend; pend = pend->next) + { + if (pend->cmd && strcmp(pend->cmd, "-include") == 0) + { + int fd = open(pend->arg, O_RDONLY | O_BINARY, 0666); + + if (fd < 0) + { + cpp_perror_with_name(pfile, pend->arg); + return FATAL_EXIT_CODE; + } + cpp_push_buffer(pfile, NULL, 0); + finclude(pfile, fd, pend->arg, 0, NULL); + } + } + pfile->no_record_file--; + + /* Free the pending list. */ + for (pend = opts->pending; pend;) + { + struct cpp_pending *next = pend->next; + + free(pend); + pend = next; + } + opts->pending = NULL; + + if (finclude(pfile, f, fname, 0, NULL)) + output_line_command(pfile, 0, same_file); + return SUCCESS_EXIT_CODE; +} + +void +init_parse_file(cpp_reader * pfile) +{ + memset((char *)pfile, 0, sizeof(cpp_reader)); + pfile->get_token = cpp_get_token; + + pfile->token_buffer_size = 200; + pfile->token_buffer = (unsigned char *)xmalloc(pfile->token_buffer_size); + CPP_SET_WRITTEN(pfile, 0); + + pfile->system_include_depth = 0; + pfile->dont_repeat_files = 0; + pfile->all_include_files = 0; + pfile->max_include_len = 0; + pfile->timebuf = NULL; + pfile->only_seen_white = 1; + pfile->buffer = CPP_NULL_BUFFER(pfile); +} + +static struct cpp_pending * +nreverse_pending(struct cpp_pending *list) +{ + struct cpp_pending *prev = 0, *next, *pend; + + for (pend = list; pend; pend = next) + { + next = pend->next; + pend->next = prev; + prev = pend; + } + return prev; +} + +static void +push_pending(cpp_reader * pfile, const char *cmd, const char *arg) +{ + struct cpp_pending *pend + = (struct cpp_pending *)xmalloc(sizeof(struct cpp_pending)); + + pend->cmd = cmd; + pend->arg = arg; + pend->next = CPP_OPTIONS(pfile)->pending; + CPP_OPTIONS(pfile)->pending = pend; +} + +/* Handle command-line options in (argc, argv). + * Can be called multiple times, to handle multiple sets of options. + * Returns if an unrecognized option is seen. + * Returns number of handled arguments. */ + +int +cpp_handle_options(cpp_reader * pfile, int argc, char **argv) +{ + int i; + struct cpp_options *opts = CPP_OPTIONS(pfile); + + for (i = 0; i < argc; i++) + { + if (argv[i][0] != '-') + { + if (opts->out_fname) + cpp_fatal("Usage: %s [switches] input output", argv[0]); + else if (opts->in_fname) + opts->out_fname = argv[i]; + else + opts->in_fname = argv[i]; + } + else + { + switch (argv[i][1]) + { + + case 'i': + if (!strcmp(argv[i], "-include") + || !strcmp(argv[i], "-imacros")) + { + if (i + 1 == argc) + cpp_fatal("Filename missing after `%s' option", + argv[i]); + else + push_pending(pfile, argv[i], argv[i + 1]), i++; + } + if (!strcmp(argv[i], "-iprefix")) + { + if (i + 1 == argc) + cpp_fatal("Filename missing after `-iprefix' option"); + else + opts->include_prefix = argv[++i]; + } + if (!strcmp(argv[i], "-ifoutput")) + { + opts->output_conditionals = 1; + } + if (!strcmp(argv[i], "-isystem")) + { + file_name_list *dirtmp; + + if (i + 1 == argc) + cpp_fatal("Filename missing after `-isystem' option"); + + dirtmp = + (file_name_list *) xmalloc(sizeof(file_name_list)); + + dirtmp->next = 0; + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 1; + dirtmp->fname = (char *)xmalloc(strlen(argv[i + 1]) + 1); + strcpy(dirtmp->fname, argv[++i]); + dirtmp->got_name_map = 0; + + if (!opts->before_system) + opts->before_system = dirtmp; + else + opts->last_before_system->next = dirtmp; + opts->last_before_system = dirtmp; /* Tail follows the last one */ + } + /* Add directory to end of path for includes, + * with the default prefix at the front of its name. */ + if (!strcmp(argv[i], "-iwithprefix")) + { + file_name_list *dirtmp; + char *prefix; + + if (opts->include_prefix) + prefix = opts->include_prefix; + else + { + prefix = savestring(GCC_INCLUDE_DIR); + /* Remove the `include' from /usr/local/lib/gcc.../include. */ + if (!strcmp + (prefix + strlen(prefix) - 8, "/include")) + prefix[strlen(prefix) - 7] = 0; + } + + dirtmp = + (file_name_list *) xmalloc(sizeof(file_name_list)); + + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + if (i + 1 == argc) + cpp_fatal + ("Directory name missing after `-iwithprefix' option"); + + dirtmp->fname = (char *)xmalloc(strlen(argv[i + 1]) + + strlen(prefix) + 1); + strcpy(dirtmp->fname, prefix); + strcat(dirtmp->fname, argv[++i]); + dirtmp->got_name_map = 0; + + if (!opts->after_include) + opts->after_include = dirtmp; + else + opts->last_after_include->next = dirtmp; + opts->last_after_include = dirtmp; /* Tail follows the last one */ + } + /* Add directory to main path for includes, + * with the default prefix at the front of its name. */ + if (!strcmp(argv[i], "-iwithprefixbefore")) + { + file_name_list *dirtmp; + char *prefix; + + if (opts->include_prefix) + prefix = opts->include_prefix; + else + { + prefix = savestring(GCC_INCLUDE_DIR); + /* Remove the `include' from /usr/local/lib/gcc.../include. */ + if (!strcmp + (prefix + strlen(prefix) - 8, "/include")) + prefix[strlen(prefix) - 7] = 0; + } + + dirtmp = + (file_name_list *) xmalloc(sizeof(file_name_list)); + + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + if (i + 1 == argc) + cpp_fatal + ("Directory name missing after `-iwithprefixbefore' option"); + + dirtmp->fname = (char *)xmalloc(strlen(argv[i + 1]) + + strlen(prefix) + 1); + strcpy(dirtmp->fname, prefix); + strcat(dirtmp->fname, argv[++i]); + dirtmp->got_name_map = 0; + + append_include_chain(pfile, dirtmp, dirtmp); + } + /* Add directory to end of path for includes. */ + if (!strcmp(argv[i], "-idirafter")) + { + file_name_list *dirtmp; + + dirtmp = + (file_name_list *) xmalloc(sizeof(file_name_list)); + + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + if (i + 1 == argc) + cpp_fatal + ("Directory name missing after `-idirafter' option"); + else + dirtmp->fname = argv[++i]; + dirtmp->got_name_map = 0; + + if (!opts->after_include) + opts->after_include = dirtmp; + else + opts->last_after_include->next = dirtmp; + opts->last_after_include = dirtmp; /* Tail follows the last one */ + } + break; + + case 'o': + if (opts->out_fname) + cpp_fatal("Output filename specified twice"); + if (i + 1 == argc) + cpp_fatal("Filename missing after -o option"); + opts->out_fname = argv[++i]; + if (!strcmp(opts->out_fname, "-")) + opts->out_fname = ""; + break; + + case 'p': + if (!strcmp(argv[i], "-pedantic")) + CPP_PEDANTIC(pfile) = 1; + else if (!strcmp(argv[i], "-pedantic-errors")) + { + CPP_PEDANTIC(pfile) = 1; + opts->pedantic_errors = 1; + } + break; + + case 't': + if (!strcmp(argv[i], "-trigraphs")) + { + if (!opts->chill) + opts->no_trigraphs = 0; + } + break; + + case 'l': + if (!strcmp(argv[i], "-lang-c")) + opts->cplusplus = 0, opts->cplusplus_comments = + 0, opts->objc = 0; + if (!strcmp(argv[i], "-lang-c++")) + opts->cplusplus = 1, opts->cplusplus_comments = + 1, opts->objc = 0; + if (!strcmp(argv[i], "-lang-c-c++-comments")) + opts->cplusplus = 0, opts->cplusplus_comments = + 1, opts->objc = 0; + if (!strcmp(argv[i], "-lang-objc")) + opts->objc = 1, opts->cplusplus = + 0, opts->cplusplus_comments = 1; + if (!strcmp(argv[i], "-lang-objc++")) + opts->objc = 1, opts->cplusplus = + 1, opts->cplusplus_comments = 1; + if (!strcmp(argv[i], "-lang-asm")) + opts->lang_asm = 1; + if (!strcmp(argv[i], "-lint")) + opts->for_lint = 1; + if (!strcmp(argv[i], "-lang-chill")) + opts->objc = 0, opts->cplusplus = 0, opts->chill = 1, + opts->traditional = 1, opts->no_trigraphs = 1; + break; + + case '+': + opts->cplusplus = 1, opts->cplusplus_comments = 1; + break; + + case 'w': + opts->inhibit_warnings = 1; + break; + + case 'W': + if (!strcmp(argv[i], "-Wtrigraphs")) + opts->warn_trigraphs = 1; + else if (!strcmp(argv[i], "-Wno-trigraphs")) + opts->warn_trigraphs = 0; + else if (!strcmp(argv[i], "-Wcomment")) + opts->warn_comments = 1; + else if (!strcmp(argv[i], "-Wno-comment")) + opts->warn_comments = 0; + else if (!strcmp(argv[i], "-Wcomments")) + opts->warn_comments = 1; + else if (!strcmp(argv[i], "-Wno-comments")) + opts->warn_comments = 0; + else if (!strcmp(argv[i], "-Wtraditional")) + opts->warn_stringify = 1; + else if (!strcmp(argv[i], "-Wno-traditional")) + opts->warn_stringify = 0; + else if (!strcmp(argv[i], "-Wimport")) + opts->warn_import = 1; + else if (!strcmp(argv[i], "-Wno-import")) + opts->warn_import = 0; + else if (!strcmp(argv[i], "-Werror")) + opts->warnings_are_errors = 1; + else if (!strcmp(argv[i], "-Wno-error")) + opts->warnings_are_errors = 0; + else if (!strcmp(argv[i], "-Wall")) + { + opts->warn_trigraphs = 1; + opts->warn_comments = 1; + } + break; + + case 'M': + /* The style of the choices here is a bit mixed. + * The chosen scheme is a hybrid of keeping all options in one string + * and specifying each option in a separate argument: + * -M|-MM|-MD file|-MMD file [-MG]. An alternative is: + * -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely: + * -M[M][G][D file]. This is awkward to handle in specs, and is not + * as extensible. */ + /* ??? -MG must be specified in addition to one of -M or -MM. + * This can be relaxed in the future without breaking anything. + * The converse isn't true. */ + + /* -MG isn't valid with -MD or -MMD. This is checked for later. */ + if (!strcmp(argv[i], "-MG")) + { + opts->print_deps_missing_files = 1; + break; + } + if (!strcmp(argv[i], "-M")) + opts->print_deps = 2; + else if (!strcmp(argv[i], "-MM")) + opts->print_deps = 1; + else if (!strcmp(argv[i], "-MD")) + opts->print_deps = 2; + else if (!strcmp(argv[i], "-MMD")) + opts->print_deps = 1; + /* For -MD and -MMD options, write deps on file named by next arg. */ + if (!strcmp(argv[i], "-MD") || !strcmp(argv[i], "-MMD")) + { + if (i + 1 == argc) + cpp_fatal("Filename missing after %s option", + argv[i]); + opts->deps_file = argv[++i]; + } + else + { + /* For -M and -MM, write deps on standard output + * and suppress the usual output. */ + opts->no_output = 1; + } + break; + + case 'd': + { + char *p = argv[i] + 2; + char c; + + while ((c = *p++) != 0) + { + /* Arg to -d specifies what parts of macros to dump */ + switch (c) + { + case 'M': + opts->dump_macros = dump_only; + opts->no_output = 1; + break; + case 'N': + opts->dump_macros = dump_names; + break; + case 'D': + opts->dump_macros = dump_definitions; + break; + } + } + } + break; + + case 'g': + if (argv[i][2] == '3') + opts->debug_output = 1; + break; + + case 'v': + fprintf(stderr, "GNU CPP version %s", version_string); +#ifdef TARGET_VERSION + TARGET_VERSION; +#endif + fprintf(stderr, "\n"); + opts->verbose = 1; + break; + + case 'H': + opts->print_include_names = 1; + break; + + case 'D': + if (argv[i][2] != 0) + push_pending(pfile, "-D", argv[i] + 2); + else if (i + 1 == argc) + cpp_fatal("Macro name missing after -D option"); + else + i++, push_pending(pfile, "-D", argv[i]); + break; + + case 'A': + { + char *p = NULL; + + if (argv[i][2] != 0) + p = argv[i] + 2; + else if (i + 1 == argc) + cpp_fatal("Assertion missing after -A option"); + else + p = argv[++i]; + + if (!strcmp(p, "-")) + { + struct cpp_pending **ptr; + + /* -A- eliminates all predefined macros and assertions. + * Let's include also any that were specified earlier + * on the command line. That way we can get rid of any + * that were passed automatically in from GCC. */ + + opts->inhibit_predefs = 1; + for (ptr = &opts->pending; *ptr;) + { + struct cpp_pending *pend = *ptr; + + if (pend->cmd && pend->cmd[0] == '-' + && (pend->cmd[1] == 'D' + || pend->cmd[1] == 'A')) + { + *ptr = pend->next; + free(pend); + } + else + ptr = &pend->next; + } + } + else + { + push_pending(pfile, "-A", p); + } + } + break; + + case 'U': /* JF #undef something */ + if (argv[i][2] != 0) + push_pending(pfile, "-U", argv[i] + 2); + else if (i + 1 == argc) + cpp_fatal("Macro name missing after -U option"); + else + push_pending(pfile, "-U", argv[i + 1]), i++; + break; + + case 'C': + opts->put_out_comments = 1; + break; + + case 'E': /* -E comes from cc -E; ignore it. */ + break; + + case 'P': + opts->no_line_commands = 1; + break; + + case '$': /* Don't include $ in identifiers. */ + opts->dollars_in_ident = 0; + break; + + case 'I': /* Add directory to path for includes. */ + { + file_name_list *dirtmp; + + if (!CPP_OPTIONS(pfile)->ignore_srcdir + && !strcmp(argv[i] + 2, "-")) + { + CPP_OPTIONS(pfile)->ignore_srcdir = 1; + /* Don't use any preceding -I directories for #include <...>. */ + CPP_OPTIONS(pfile)->first_bracket_include = 0; + } + else + { + dirtmp = + (file_name_list *) xmalloc(sizeof(file_name_list)); + + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + if (argv[i][2] != 0) + dirtmp->fname = argv[i] + 2; + else if (i + 1 == argc) + cpp_fatal + ("Directory name missing after -I option"); + else + dirtmp->fname = argv[++i]; + dirtmp->got_name_map = 0; + append_include_chain(pfile, dirtmp, dirtmp); + } + } + break; + + case 'n': + if (!strcmp(argv[i], "-nostdinc")) + /* -nostdinc causes no default include directories. + * You must specify all include-file directories with -I. */ + opts->no_standard_includes = 1; + else if (!strcmp(argv[i], "-nostdinc++")) + /* -nostdinc++ causes no default C++-specific include directories. */ + opts->no_standard_cplusplus_includes = 1; + break; + + case 'u': + /* Sun compiler passes undocumented switch "-undef". + * Let's assume it means to inhibit the predefined symbols. */ + opts->inhibit_predefs = 1; + break; + + case '\0': /* JF handle '-' as file name meaning stdin or stdout */ + if (!opts->in_fname) + { + opts->in_fname = ""; + break; + } + else if (!opts->out_fname) + { + opts->out_fname = ""; + break; + } /* else fall through into error */ + default: + return i; + } + } + } + return i; +} + +void +cpp_finish(cpp_reader * pfile) +{ + struct cpp_options *opts = CPP_OPTIONS(pfile); + + if (opts->print_deps) + { + /* Stream on which to print the dependency information. */ + FILE *deps_stream; + + /* Don't actually write the deps file if compilation has failed. */ + if (pfile->errors == 0) + { + const char *deps_mode = + opts->print_deps_append ? "ab" : "wb"; + + if (!opts->deps_file) + deps_stream = stdout; + else if (!(deps_stream = fopen(opts->deps_file, deps_mode))) + cpp_pfatal_with_name(pfile, opts->deps_file); + fputs(pfile->deps_buffer, deps_stream); + putc('\n', deps_stream); + if (opts->deps_file) + { + if (ferror(deps_stream) || fclose(deps_stream) != 0) + cpp_fatal("I/O error on output"); + } + } + } +} + +static int +do_assert(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__) +{ + long symstart; /* remember where symbol name starts */ + int c; + int sym_length; /* and how long it is */ + struct arglist *tokens = NULL; + + if (CPP_PEDANTIC(pfile) && CPP_OPTIONS(pfile)->done_initializing + && !CPP_BUFFER(pfile)->system_header_p) + cpp_pedwarn(pfile, "ANSI C does not allow `#assert'"); + + cpp_skip_hspace(pfile); + symstart = CPP_WRITTEN(pfile); /* remember where it starts */ + parse_name(pfile, GETC()); + sym_length = check_macro_name(pfile, pfile->token_buffer + symstart, + "assertion"); + + cpp_skip_hspace(pfile); + if (PEEKC() != '(') + { + cpp_error(pfile, "missing token-sequence in `#assert'"); + goto error; + } + { + int error_flag = 0; + + tokens = read_token_list(pfile, &error_flag); + if (error_flag) + goto error; + if (!tokens) + { + cpp_error(pfile, "empty token-sequence in `#assert'"); + goto error; + } + cpp_skip_hspace(pfile); + c = PEEKC(); + if (c != EOF && c != '\n') + cpp_pedwarn(pfile, "junk at end of `#assert'"); + skip_rest_of_line(pfile); + } + + /* If this name isn't already an assertion name, make it one. + * Error if it was already in use in some other way. */ + + { + ASSERTION_HASHNODE *hp; + const char *symname = (char *)pfile->token_buffer + symstart; + int hashcode = + hashf(symname, sym_length, ASSERTION_HASHSIZE); + struct tokenlist_list *value = + (struct tokenlist_list *)xmalloc(sizeof(struct tokenlist_list)); + + hp = assertion_lookup(pfile, symname, sym_length, hashcode); + if (!hp) + { + if (sym_length == 7 && !strncmp(symname, "defined", sym_length)) + cpp_error(pfile, "`defined' redefined as assertion"); + hp = assertion_install(pfile, symname, sym_length, hashcode); + } + /* Add the spec'd token-sequence to the list of such. */ + value->tokens = tokens; + value->next = hp->value; + hp->value = value; + } + CPP_SET_WRITTEN(pfile, symstart); /* Pop */ + return 0; + error: + CPP_SET_WRITTEN(pfile, symstart); /* Pop */ + skip_rest_of_line(pfile); + return 1; +} + +static int +do_unassert(cpp_reader * pfile, struct directive *keyword __UNUSED__, + unsigned char *buf __UNUSED__, unsigned char *limit __UNUSED__) +{ + long symstart; /* remember where symbol name starts */ + int sym_length; /* and how long it is */ + int c; + + struct arglist *tokens = NULL; + int tokens_specified = 0; + + if (CPP_PEDANTIC(pfile) && CPP_OPTIONS(pfile)->done_initializing + && !CPP_BUFFER(pfile)->system_header_p) + cpp_pedwarn(pfile, "ANSI C does not allow `#unassert'"); + + cpp_skip_hspace(pfile); + + symstart = CPP_WRITTEN(pfile); /* remember where it starts */ + parse_name(pfile, GETC()); + sym_length = check_macro_name(pfile, pfile->token_buffer + symstart, + "assertion"); + + cpp_skip_hspace(pfile); + if (PEEKC() == '(') + { + int error_flag = 0; + + tokens = read_token_list(pfile, &error_flag); + if (error_flag) + goto error; + if (!tokens) + { + cpp_error(pfile, "empty token list in `#unassert'"); + goto error; + } + tokens_specified = 1; + } + cpp_skip_hspace(pfile); + c = PEEKC(); + if (c != EOF && c != '\n') + cpp_error(pfile, "junk at end of `#unassert'"); + skip_rest_of_line(pfile); + + { + ASSERTION_HASHNODE *hp; + const char *symname = (char *)pfile->token_buffer + symstart; + int hashcode = + hashf(symname, sym_length, ASSERTION_HASHSIZE); + struct tokenlist_list *tail, *prev; + + hp = assertion_lookup(pfile, symname, sym_length, hashcode); + if (!hp) + return 1; + + /* If no token list was specified, then eliminate this assertion + * entirely. */ + if (!tokens_specified) + delete_assertion(hp); + else + { + /* If a list of tokens was given, then delete any matching list. */ + + tail = hp->value; + prev = 0; + while (tail) + { + struct tokenlist_list *next = tail->next; + + if (compare_token_lists(tail->tokens, tokens)) + { + if (prev) + prev->next = next; + else + hp->value = tail->next; + free_token_list(tail->tokens); + free(tail); + } + else + { + prev = tail; + } + tail = next; + } + } + } + + CPP_SET_WRITTEN(pfile, symstart); /* Pop */ + return 0; + error: + CPP_SET_WRITTEN(pfile, symstart); /* Pop */ + skip_rest_of_line(pfile); + return 1; +} + +/* Test whether there is an assertion named NAME + * and optionally whether it has an asserted token list TOKENS. + * NAME is not null terminated; its length is SYM_LENGTH. + * If TOKENS_SPECIFIED is 0, then don't check for any token list. */ + +static int +check_assertion(cpp_reader * pfile, const char *name, int sym_length, + int tokens_specified, struct arglist *tokens) +{ + ASSERTION_HASHNODE *hp; + int hashcode = hashf(name, sym_length, ASSERTION_HASHSIZE); + + if (CPP_PEDANTIC(pfile) && !CPP_BUFFER(pfile)->system_header_p) + cpp_pedwarn(pfile, "ANSI C does not allow testing assertions"); + + hp = assertion_lookup(pfile, name, sym_length, hashcode); + if (!hp) + /* It is not an assertion; just return false. */ + return 0; + + /* If no token list was specified, then value is 1. */ + if (!tokens_specified) + return 1; + + { + struct tokenlist_list *tail; + + tail = hp->value; + + /* If a list of tokens was given, + * then succeed if the assertion records a matching list. */ + + while (tail) + { + if (compare_token_lists(tail->tokens, tokens)) + return 1; + tail = tail->next; + } + + /* Fail if the assertion has no matching list. */ + return 0; + } +} + +/* Compare two lists of tokens for equality including order of tokens. */ + +static int +compare_token_lists(struct arglist *l1, struct arglist *l2) +{ + while (l1 && l2) + { + if (l1->length != l2->length) + return 0; + if (strncmp(l1->name, l2->name, l1->length)) + return 0; + l1 = l1->next; + l2 = l2->next; + } + + /* Succeed if both lists end at the same time. */ + return l1 == l2; +} + +struct arglist * +reverse_token_list(struct arglist *tokens) +{ + struct arglist *prev = 0, *cur, *next; + + for (cur = tokens; cur; cur = next) + { + next = cur->next; + cur->next = prev; + prev = cur; + } + return prev; +} + +/* Read a space-separated list of tokens ending in a close parenthesis. + * Return a list of strings, in the order they were written. + * (In case of error, return 0 and store -1 in *ERROR_FLAG.) */ + +static struct arglist * +read_token_list(cpp_reader * pfile, int *error_flag) +{ + struct arglist *token_ptrs = 0; + int depth = 1; + int length; + + *error_flag = 0; + FORWARD(1); /* Skip '(' */ + + /* Loop over the assertion value tokens. */ + while (depth > 0) + { + struct arglist *temp; + long name_written = CPP_WRITTEN(pfile); + int c; + + cpp_skip_hspace(pfile); + + c = GETC(); + + /* Find the end of the token. */ + if (c == '(') + { + CPP_PUTC(pfile, c); + depth++; + } + else if (c == ')') + { + depth--; + if (depth == 0) + break; + CPP_PUTC(pfile, c); + } + else if (c == '"' || c == '\'') + { + FORWARD(-1); + cpp_get_token(pfile); + } + else if (c == '\n') + break; + else + { + while (c != EOF && !is_space[c] && c != '(' && c != ')' + && c != '"' && c != '\'') + { + CPP_PUTC(pfile, c); + c = GETC(); + } + if (c != EOF) + FORWARD(-1); + } + + length = CPP_WRITTEN(pfile) - name_written; + temp = (struct arglist *)xmalloc(sizeof(struct arglist) + length + 1); + + temp->name = (char *)(temp + 1); + memcpy(temp->name, (char *)(pfile->token_buffer + name_written), + length); + temp->name[length] = 0; + temp->next = token_ptrs; + token_ptrs = temp; + temp->length = length; + + CPP_ADJUST_WRITTEN(pfile, -length); /* pop */ + + if (c == EOF || c == '\n') + { /* FIXME */ + cpp_error(pfile, + "unterminated token sequence following `#' operator"); + return 0; + } + } + + /* We accumulated the names in reverse order. + * Now reverse them to get the proper order. */ + return reverse_token_list(token_ptrs); +} + +static void +free_token_list(struct arglist *tokens) +{ + while (tokens) + { + struct arglist *next = tokens->next; + + free(tokens->name); + free(tokens); + tokens = next; + } +} + +/* Get the file-mode and data size of the file open on FD + * and store them in *MODE_POINTER and *SIZE_POINTER. */ + +static int +file_size_and_mode(int fd, int *mode_pointer, long int *size_pointer) +{ + struct stat sbuf; + + if (fstat(fd, &sbuf) < 0) + return (-1); + if (mode_pointer) + *mode_pointer = sbuf.st_mode; + if (size_pointer) + *size_pointer = sbuf.st_size; + return 0; +} + +/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME, + * retrying if necessary. Return a negative value if an error occurs, + * otherwise return the actual number of bytes read, + * which must be LEN unless end-of-file was reached. */ + +static int +safe_read(int desc, char *ptr, int len) +{ + int left = len; + + while (left > 0) + { + int nchars = read(desc, ptr, left); + + if (nchars < 0) + { +#ifdef EINTR + if (errno == EINTR) + continue; +#endif + return nchars; + } + if (nchars == 0) + break; + ptr += nchars; + left -= nchars; + } + return len - left; +} + +static char * +savestring(const char *input) +{ + unsigned size = strlen(input); + char *output = (char *)xmalloc(size + 1); + + strcpy(output, input); + return output; +} + +/* Initialize PMARK to remember the current position of PFILE. */ +void +parse_set_mark(struct parse_marker *pmark, cpp_reader * pfile) +{ + cpp_buffer *pbuf = CPP_BUFFER(pfile); + + pmark->next = pbuf->marks; + pbuf->marks = pmark; + pmark->buf = pbuf; + pmark->position = pbuf->cur - pbuf->buf; +} + +/* Cleanup PMARK - we no longer need it. */ +static void +parse_clear_mark(struct parse_marker *pmark) +{ + struct parse_marker **pp = &pmark->buf->marks; + + for (;; pp = &(*pp)->next) + { + if (!*pp) + cpp_fatal("internal error", "in parse_set_mark"); + if (*pp == pmark) + break; + } + *pp = pmark->next; +} + +/* Backup the current position of PFILE to that saved in PMARK. */ + +static void +parse_goto_mark(struct parse_marker *pmark, cpp_reader * pfile) +{ + cpp_buffer *pbuf = CPP_BUFFER(pfile); + + if (pbuf != pmark->buf) + cpp_fatal("internal error %s", "parse_goto_mark"); + pbuf->cur = pbuf->buf + pmark->position; +} + +/* Reset PMARK to point to the current position of PFILE. (Same + * as parse_clear_mark (PMARK), parse_set_mark (PMARK, PFILE) but faster. */ + +static void +parse_move_mark(struct parse_marker *pmark, cpp_reader * pfile) +{ + cpp_buffer *pbuf = CPP_BUFFER(pfile); + + if (pbuf != pmark->buf) + cpp_fatal("internal error %s", "parse_move_mark"); + pmark->position = pbuf->cur - pbuf->buf; +} + +int +cpp_read_check_assertion(cpp_reader * pfile) +{ + int name_start = CPP_WRITTEN(pfile); + int name_length, name_written; + int result; + + FORWARD(1); /* Skip '#' */ + cpp_skip_hspace(pfile); + parse_name(pfile, GETC()); + name_written = CPP_WRITTEN(pfile); + name_length = name_written - name_start; + cpp_skip_hspace(pfile); + if (CPP_BUF_PEEK(CPP_BUFFER(pfile)) == '(') + { + int error_flag; + struct arglist *token_ptrs = read_token_list(pfile, &error_flag); + + result = check_assertion(pfile, + (char *)pfile->token_buffer + name_start, + name_length, 1, token_ptrs); + } + else + result = check_assertion(pfile, + (char *)pfile->token_buffer + name_start, + name_length, 0, NULL); + CPP_ADJUST_WRITTEN(pfile, -name_length); /* pop */ + return result; +} + +static void +cpp_print_file_and_line(cpp_reader * pfile) +{ + cpp_buffer *ip = cpp_file_buffer(pfile); + + if (ip) + { + long line, col; + + cpp_buf_line_and_col(ip, &line, &col); + cpp_file_line_for_message(pfile, ip->nominal_fname, + line, pfile->show_column ? col : -1); + } +} + +static void +cpp_error_v(cpp_reader * pfile, const char *msg, va_list args) +{ + cpp_print_containing_files(pfile); + cpp_print_file_and_line(pfile); + cpp_message_v(pfile, 1, msg, args); +} + +void +cpp_error(cpp_reader * pfile, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + + cpp_error_v(pfile, msg, args); + + va_end(args); +} + +/* Print error message but don't count it. */ + +static void +cpp_warning_v(cpp_reader * pfile, const char *msg, va_list args) +{ + if (CPP_OPTIONS(pfile)->inhibit_warnings) + return; + + if (CPP_OPTIONS(pfile)->warnings_are_errors) + pfile->errors++; + + cpp_print_containing_files(pfile); + cpp_print_file_and_line(pfile); + cpp_message_v(pfile, 0, msg, args); +} + +void +cpp_warning(cpp_reader * pfile, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + + cpp_warning_v(pfile, msg, args); + + va_end(args); +} + +/* Print an error message and maybe count it. */ + +void +cpp_pedwarn(cpp_reader * pfile, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + + if (CPP_OPTIONS(pfile)->pedantic_errors) + cpp_error_v(pfile, msg, args); + else + cpp_warning_v(pfile, msg, args); + + va_end(args); +} + +static void +cpp_error_with_line(cpp_reader * pfile, int line, int column, const char *msg) +{ + cpp_buffer *ip = cpp_file_buffer(pfile); + + cpp_print_containing_files(pfile); + + if (ip) + cpp_file_line_for_message(pfile, ip->nominal_fname, line, column); + + cpp_message(pfile, 1, msg, NULL, NULL, NULL); +} + +static void +cpp_warning_with_line(cpp_reader * pfile, int line, int column, const char *msg) +{ + cpp_buffer *ip; + + if (CPP_OPTIONS(pfile)->inhibit_warnings) + return; + + if (CPP_OPTIONS(pfile)->warnings_are_errors) + pfile->errors++; + + cpp_print_containing_files(pfile); + + ip = cpp_file_buffer(pfile); + + if (ip) + cpp_file_line_for_message(pfile, ip->nominal_fname, line, column); + + cpp_message(pfile, 0, msg, NULL, NULL, NULL); +} + +static void +cpp_pedwarn_with_line(cpp_reader * pfile, int line, int column, const char *msg) +{ + if (CPP_OPTIONS(pfile)->pedantic_errors) + cpp_error_with_line(pfile, column, line, msg); + else + cpp_warning_with_line(pfile, line, column, msg); +} + +/* Report a warning (or an error if pedantic_errors) + * giving specified file name and line number, not current. */ + +void +cpp_pedwarn_with_file_and_line(cpp_reader * pfile, + const char *file, int line, + const char *msg, const char *arg1, + const char *arg2, const char *arg3) +{ + if (!CPP_OPTIONS(pfile)->pedantic_errors + && CPP_OPTIONS(pfile)->inhibit_warnings) + return; + if (file) + cpp_file_line_for_message(pfile, file, line, -1); + cpp_message(pfile, CPP_OPTIONS(pfile)->pedantic_errors, + msg, arg1, arg2, arg3); +} + +/* This defines "errno" properly for VMS, and gives us EACCES. */ +#include +#ifndef errno +extern int errno; + +#endif + +#ifndef HAVE_STRERROR +extern int sys_nerr; + +#if defined(bsd4_4) +extern const char *const sys_errlist[]; + +#else +extern char *sys_errlist[]; + +#endif +#endif /* HAVE_STRERROR */ + +/* + * my_strerror - return the descriptive text associated with an `errno' code. + */ + +static const char * +my_strerror(int errnum) +{ + const char *result; + +#ifndef HAVE_STRERROR + result = ((errnum < sys_nerr) ? sys_errlist[errnum] : 0); +#else + result = strerror(errnum); +#endif + + if (!result) + result = "undocumented I/O error"; + + return result; +} + +/* Error including a message from `errno'. */ + +static void +cpp_error_from_errno(cpp_reader * pfile, const char *name) +{ + cpp_buffer *ip = cpp_file_buffer(pfile); + + cpp_print_containing_files(pfile); + + if (ip) + cpp_file_line_for_message(pfile, ip->nominal_fname, ip->lineno, -1); + + cpp_message(pfile, 1, "%s: %s", name, my_strerror(errno), NULL); +} + +void +cpp_perror_with_name(cpp_reader * pfile, const char *name) +{ + cpp_message(pfile, 1, "%s: %s: %s", progname, name, my_strerror(errno)); +} + +/* TODO: + * No pre-compiled header file support. + * + * Possibly different enum token codes for each C/C++ token. + * + * Should clean up remaining directives to that do_XXX functions + * only take two arguments and all have command_reads_line. + * + * Find and cleanup remaining uses of static variables, + * + * Support for trigraphs. + * + * Support -dM flag (dump_all_macros). + * + * Support for_lint flag. + */ 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 @@ +/* Definitions for CPP library. + Copyright (C) 1995 Free Software Foundation, Inc. + Written by Per Bothner, 1994-95. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! */ + +#include +#include +#include + +#ifndef HOST_BITS_PER_WIDE_INT + +#if HOST_BITS_PER_LONG > HOST_BITS_PER_INT +#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG +#define HOST_WIDE_INT long +#else +#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT +#define HOST_WIDE_INT int +#endif + +#endif + +#define STATIC_BUFFERS + +typedef struct cpp_reader cpp_reader; +typedef struct cpp_buffer cpp_buffer; +typedef struct cpp_options cpp_options; + +enum cpp_token { + CPP_EOF = -1, + CPP_OTHER = 0, + CPP_COMMENT = 1, + CPP_HSPACE, + CPP_VSPACE, /* newlines and #line directives */ + CPP_NAME, + CPP_NUMBER, + CPP_CHAR, + CPP_STRING, + CPP_DIRECTIVE, + CPP_LPAREN, /* "(" */ + CPP_RPAREN, /* ")" */ + CPP_LBRACE, /* "{" */ + CPP_RBRACE, /* "}" */ + CPP_COMMA, /* "," */ + CPP_SEMICOLON, /* ";" */ + CPP_3DOTS, /* "..." */ + /* POP_TOKEN is returned when we've popped a cpp_buffer. */ + CPP_POP +}; + +typedef enum cpp_token (*parse_underflow_t) (cpp_reader *); +typedef int (*parse_cleanup_t) (cpp_buffer *, cpp_reader *); + +/* A parse_marker indicates a previous position, + which we can backtrack to. */ + +struct parse_marker { + cpp_buffer *buf; + struct parse_marker *next; + int position; +}; + +extern int cpp_handle_options(cpp_reader * pfile, int, char **); +extern enum cpp_token cpp_get_token(cpp_reader * pfile); +extern void cpp_skip_hspace(cpp_reader * pfile); + +/* Maintain and search list of included files, for #import. */ + +#define IMPORT_HASH_SIZE 31 + +struct import_file { + char *name; + ino_t inode; + dev_t dev; + struct import_file *next; +}; + +/* If we have a huge buffer, may need to cache more recent counts */ +#define CPP_LINE_BASE(BUF) ((BUF)->buf + (BUF)->line_base) + +enum dump_type { + dump_none = 0, dump_only, dump_names, dump_definitions +}; + +struct cpp_buffer { + unsigned char *buf; + unsigned char *cur; + unsigned char *rlimit; /* end of valid data */ + unsigned char *alimit; /* end of allocated buffer */ + unsigned char *prev; /* start of current token */ + + const char *fname; + /* Filename specified with #line command. */ + const char *nominal_fname; + + /* Record where in the search path this file was found. + * For #include_next. */ + struct file_name_list *dir; + + long line_base; + long lineno; /* Line number at CPP_LINE_BASE. */ + long colno; /* Column number at CPP_LINE_BASE. */ +#ifndef STATIC_BUFFERS + cpp_buffer *chain; +#endif + parse_underflow_t underflow; + parse_cleanup_t cleanup; + void *data; + struct parse_marker *marks; + /* Value of if_stack at start of this file. + * Used to prohibit unmatched #endif (etc) in an include file. */ + struct if_stack *if_stack; + + /* True if this is a header file included using . */ + char system_header_p; + char seen_eof; + + /* True if buffer contains escape sequences. + * Currently there are are only two kind: + * "@-" means following identifier should not be macro-expanded. + * "@ " means a token-separator. This turns into " " in final output + * if not stringizing and needed to separate tokens; otherwise nothing. + * "@@" means a normal '@'. + * (An '@' inside a string stands for itself and is never an escape.) */ + char has_escapes; +}; + +struct cpp_pending; /* Forward declaration - for C++. */ +struct file_name_map_list; + +typedef struct assertion_hashnode ASSERTION_HASHNODE; + +#define ASSERTION_HASHSIZE 37 + +#ifdef STATIC_BUFFERS +/* Maximum nesting of cpp_buffers. We use a static limit, partly for + efficiency, and partly to limit runaway recursion. */ +#define CPP_STACK_MAX 200 +#endif + +struct cpp_reader { + unsigned char *limit; + parse_underflow_t get_token; + cpp_buffer *buffer; +#ifdef STATIC_BUFFERS + cpp_buffer buffer_stack[CPP_STACK_MAX]; +#endif + + int errors; /* Error counter for exit code */ + void *data; + + unsigned char *token_buffer; + int token_buffer_size; + + /* Line where a newline was first seen in a string constant. */ + int multiline_string_line; + + /* Current depth in #include directives that use <...>. */ + int system_include_depth; + + /* List of included files that contained #pragma once. */ + struct file_name_list *dont_repeat_files; + + /* List of other included files. + * If ->control_macro if nonzero, the file had a #ifndef + * around the entire contents, and ->control_macro gives the macro name. */ + struct file_name_list *all_include_files; + + /* Current maximum length of directory names in the search path + * for include files. (Altered as we get more of them.) */ + int max_include_len; + + /* Hash table of files already included with #include or #import. */ + struct import_file *import_hash_table[IMPORT_HASH_SIZE]; + + struct if_stack *if_stack; + + /* Nonzero means we are inside an IF during a -pcp run. In this mode + * macro expansion is done, and preconditions are output for all macro + * uses requiring them. */ + char pcp_inside_if; + + /* Nonzero means we have printed (while error reporting) a list of + * containing files that matches the current status. */ + char input_stack_listing_current; + + /* If non-zero, macros are not expanded. */ + char no_macro_expand; + + /* Print column number in error messages. */ + char show_column; + + /* We're printed a warning recommending against using #import. */ + char import_warning; + + /* If true, character between '<' and '>' are a single (string) token. */ + char parsing_include_directive; + + /* True if escape sequences (as described for has_escapes in + * parse_buffer) should be emitted. */ + char output_escapes; + + /* 0: Have seen non-white-space on this line. + * 1: Only seen white space so far on this line. + * 2: Only seen white space so far in this file. */ + char only_seen_white; + + /* Nonzero means this file was included with a -imacros or -include + * command line and should not be recorded as an include file. */ + + int no_record_file; + + long lineno; + + struct tm *timebuf; + + ASSERTION_HASHNODE *assertion_hashtab[ASSERTION_HASHSIZE]; + + /* Buffer of -M output. */ + char *deps_buffer; + + /* Number of bytes allocated in above. */ + int deps_allocated_size; + + /* Number of bytes used. */ + int deps_size; + + /* Number of bytes since the last newline. */ + int deps_column; +}; + +#define CPP_BUF_PEEK(BUFFER) \ + ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur : EOF) +#define CPP_BUF_GET(BUFFER) \ + ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur++ : EOF) +#define CPP_FORWARD(BUFFER, N) ((BUFFER)->cur += (N)) + +/* Number of characters currently in PFILE's output buffer. */ +#define CPP_WRITTEN(PFILE) ((PFILE)->limit - (PFILE)->token_buffer) +#define CPP_PWRITTEN(PFILE) ((PFILE)->limit) + +/* Make sure PFILE->token_buffer has space for at least N more characters. */ +#define CPP_RESERVE(PFILE, N) \ + ((unsigned int)(CPP_WRITTEN (PFILE) + N) > (unsigned int) (PFILE)->token_buffer_size \ + && (cpp_grow_buffer (PFILE, N), 0)) + +/* Append string STR (of length N) to PFILE's output buffer. + Assume there is enough space. */ +#define CPP_PUTS_Q(PFILE, STR, N) \ + do { memcpy ((PFILE)->limit, STR, (N)); (PFILE)->limit += (N); } while(0) +/* Append string STR (of length N) to PFILE's output buffer. Make space. */ +#define CPP_PUTS(PFILE, STR, N) \ + do { CPP_RESERVE(PFILE, N); CPP_PUTS_Q(PFILE, STR,N); } while(0) +/* Append character CH to PFILE's output buffer. Assume sufficient space. */ +#define CPP_PUTC_Q(PFILE, CH) (*(PFILE)->limit++ = (CH)) +/* Append character CH to PFILE's output buffer. Make space if need be. */ +#define CPP_PUTC(PFILE, CH) \ + do { CPP_RESERVE (PFILE, 1); CPP_PUTC_Q (PFILE, CH); } while(0) +/* Make sure PFILE->limit is followed by '\0'. */ +#define CPP_NUL_TERMINATE_Q(PFILE) (*(PFILE)->limit = 0) +#define CPP_NUL_TERMINATE(PFILE) \ + do { CPP_RESERVE(PFILE, 1); *(PFILE)->limit = 0; } while(0) +#define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA)) +#define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N)) + +#define CPP_OPTIONS(PFILE) ((cpp_options*)(PFILE)->data) +#define CPP_BUFFER(PFILE) ((PFILE)->buffer) +#ifdef STATIC_BUFFERS +#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1) +#define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX]) +#else +#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->chain) +#define CPP_NULL_BUFFER(PFILE) ((cpp_buffer*)0) +#endif + +/* Pointed to by parse_file::data. */ +struct cpp_options { + const char *in_fname; + + /* Name of output file, for error messages. */ + const char *out_fname; + + struct file_name_map_list *map_list; + + /* Non-0 means -v, so print the full set of include dirs. */ + char verbose; + + /* Nonzero means use extra default include directories for C++. */ + + char cplusplus; + + /* Nonzero means handle cplusplus style comments */ + + char cplusplus_comments; + + /* Nonzero means handle #import, for objective C. */ + + char objc; + + /* Nonzero means this is an assembly file, and allow + * unknown directives, which could be comments. */ + + int lang_asm; + + /* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */ + + char for_lint; + + /* Nonzero means handle CHILL comment syntax + * and output CHILL string delimiter for __DATE___ etc. */ + + char chill; + + /* Nonzero means copy comments into the output file. */ + + char put_out_comments; + + /* Nonzero means don't process the ANSI trigraph sequences. */ + + char no_trigraphs; + + /* Nonzero means print the names of included files rather than + * the preprocessed output. 1 means just the #include "...", + * 2 means #include <...> as well. */ + + char print_deps; + + /* Nonzero if missing .h files in -M output are assumed to be generated + * files and not errors. */ + + char print_deps_missing_files; + + /* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */ + char print_deps_append; + + /* Nonzero means print names of header files (-H). */ + + char print_include_names; + + /* Nonzero means try to make failure to fit ANSI C an error. */ + + char pedantic_errors; + + /* Nonzero means don't print warning messages. -w. */ + + char inhibit_warnings; + + /* Nonzero means warn if slash-star appears in a comment. */ + + char warn_comments; + + /* Nonzero means warn if there are any trigraphs. */ + + char warn_trigraphs; + + /* Nonzero means warn if #import is used. */ + + char warn_import; + + /* Nonzero means warn if a macro argument is (or would be) + * stringified with -traditional. */ + + char warn_stringify; + + /* Nonzero means turn warnings into errors. */ + + char warnings_are_errors; + + /* Nonzero causes output not to be done, + * but directives such as #define that have side effects + * are still obeyed. */ + + char no_output; + + /* Nonzero means don't output line number information. */ + + char no_line_commands; + +/* Nonzero means output the text in failing conditionals, + inside #failed ... #endfailed. */ + + char output_conditionals; + + /* Nonzero means -I- has been seen, + * so don't look for #include "foo" the source-file directory. */ + char ignore_srcdir; + +/* Zero means dollar signs are punctuation. + -$ stores 0; -traditional may store 1. Default is 1 for VMS, 0 otherwise. + This must be 0 for correct processing of this ANSI C program: + #define foo(a) #a + #define lose(b) foo (b) + #define test$ + lose (test) */ + char dollars_in_ident; +#ifndef DOLLARS_IN_IDENTIFIERS +#define DOLLARS_IN_IDENTIFIERS 1 +#endif + + /* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */ + char traditional; + + /* Nonzero means give all the error messages the ANSI standard requires. */ + char pedantic; + + char done_initializing; + + struct file_name_list *include; /* First dir to search */ + /* First dir to search for */ + /* This is the first element to use for #include <...>. + * If it is 0, use the entire chain for such includes. */ + struct file_name_list *first_bracket_include; + /* This is the first element in the chain that corresponds to + * a directory of system header files. */ + struct file_name_list *first_system_include; + struct file_name_list *last_include; /* Last in chain */ + + /* Chain of include directories to put at the end of the other chain. */ + struct file_name_list *after_include; + struct file_name_list *last_after_include; /* Last in chain */ + + /* Chain to put at the start of the system include files. */ + struct file_name_list *before_system; + struct file_name_list *last_before_system; /* Last in chain */ + + /* Directory prefix that should replace `/usr' in the standard + * include file directories. */ + char *include_prefix; + + char inhibit_predefs; + char no_standard_includes; + char no_standard_cplusplus_includes; + +/* dump_only means inhibit output of the preprocessed text + and instead output the definitions of all user-defined + macros in a form suitable for use as input to cccp. + dump_names means pass #define and the macro name through to output. + dump_definitions means pass the whole definition (plus #define) through +*/ + + enum dump_type dump_macros; + +/* Nonzero means pass all #define and #undef directives which we actually + process through to the output stream. This feature is used primarily + to allow cc1 to record the #defines and #undefs for the sake of + debuggers which understand about preprocessor macros, but it may + also be useful with -E to figure out how symbols are defined, and + where they are defined. */ + int debug_output; + + /* Pending -D, -U and -A options, in reverse order. */ + struct cpp_pending *pending; + + /* File name which deps are being written to. + * This is 0 if deps are being written to stdout. */ + char *deps_file; + + /* Target-name to write with the dependency information. */ + char *deps_target; +}; + +#define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional) +#define CPP_PEDANTIC(PFILE) (CPP_OPTIONS (PFILE)->pedantic) +#define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps) + +/* Name under which this program was invoked. */ + +extern char *progname; + +/* The structure of a node in the hash table. The hash table + has entries for all tokens defined by #define commands (type T_MACRO), + plus some special tokens like __LINE__ (these each have their own + type, and the appropriate code is run when that type of node is seen. + It does not contain control words like "#define", which are recognized + by a separate piece of code. */ + +/* different flavors of hash nodes --- also used in keyword table */ +enum node_type { + T_DEFINE = 1, /* the `#define' keyword */ + T_INCLUDE, /* the `#include' keyword */ + T_INCLUDE_NEXT, /* the `#include_next' keyword */ + T_IMPORT, /* the `#import' keyword */ + T_IFDEF, /* the `#ifdef' keyword */ + T_IFNDEF, /* the `#ifndef' keyword */ + T_IF, /* the `#if' keyword */ + T_ELSE, /* `#else' */ + T_PRAGMA, /* `#pragma' */ + T_ELIF, /* `#elif' */ + T_UNDEF, /* `#undef' */ + T_LINE, /* `#line' */ + T_ERROR, /* `#error' */ + T_WARNING, /* `#warning' */ + T_ENDIF, /* `#endif' */ + T_SCCS, /* `#sccs', used on system V. */ + T_IDENT, /* `#ident', used on system V. */ + T_ASSERT, /* `#assert', taken from system V. */ + T_UNASSERT, /* `#unassert', taken from system V. */ + T_SPECLINE, /* special symbol `__LINE__' */ + T_DATE, /* `__DATE__' */ + T_FILE, /* `__FILE__' */ + T_BASE_FILE, /* `__BASE_FILE__' */ + T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */ + T_VERSION, /* `__VERSION__' */ + T_SIZE_TYPE, /* `__SIZE_TYPE__' */ + T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */ + T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */ + T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */ + T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */ + T_TIME, /* `__TIME__' */ + T_CONST, /* Constant value, used by `__STDC__' */ + T_MACRO, /* macro defined by `#define' */ + T_DISABLED, /* macro temporarily turned off for rescan */ + T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */ + T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */ + T_UNUSED /* Used for something not defined. */ +}; + +/* Structure allocated for every #define. For a simple replacement + such as + #define foo bar , + nargs = -1, the `pattern' list is null, and the expansion is just + the replacement text. Nargs = 0 means a functionlike macro with no args, + e.g., + #define getchar() getc (stdin) . + When there are args, the expansion is the replacement text with the + args squashed out, and the reflist is a list describing how to + build the output from the input: e.g., "3 chars, then the 1st arg, + then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg". + The chars here come from the expansion. Whatever is left of the + expansion after the last arg-occurrence is copied after that arg. + Note that the reflist can be arbitrarily long--- + its length depends on the number of times the arguments appear in + the replacement text, not how many args there are. Example: + #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and + pattern list + { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL } + where (x, y) means (nchars, argno). */ + +typedef struct reflist reflist; +struct reflist { + reflist *next; + char stringify; /* nonzero if this arg was preceded by a + * # operator. */ + char raw_before; /* Nonzero if a ## operator before arg. */ + char raw_after; /* Nonzero if a ## operator after arg. */ + char rest_args; /* Nonzero if this arg. absorbs the rest */ + int nchars; /* Number of literal chars to copy before + * this arg occurrence. */ + int argno; /* Number of arg to substitute (origin-0) */ +}; + +typedef struct definition DEFINITION; +struct definition { + int nargs; + int length; /* length of expansion string */ + int predefined; /* True if the macro was builtin or */ + /* came from the command line */ + unsigned char *expansion; + int line; /* Line number of definition */ + const char *file; /* File of definition */ + char rest_args; /* Nonzero if last arg. absorbs the rest */ + reflist *pattern; + union { + /* Names of macro args, concatenated in reverse order + * with comma-space between them. + * The only use of this is that we warn on redefinition + * if this differs between the old and new definitions. */ + unsigned char *argnames; + } args; +}; + +extern unsigned char is_idchar[256]; + +/* Stack of conditionals currently in progress + (including both successful and failing conditionals). */ + +struct if_stack { + struct if_stack *next; /* for chaining to the next stack frame */ + const char *fname; /* copied from input when frame is made */ + int lineno; /* similarly */ + int if_succeeded; /* true if a leg of this if-group + * has been passed through rescan */ + unsigned char *control_macro; /* For #ifndef at start of file, + * this is the macro name tested. */ + enum node_type type; /* type of last directive seen in this group */ +}; +typedef struct if_stack IF_STACK_FRAME; + +extern void cpp_buf_line_and_col(cpp_buffer *, long *, long *); +extern cpp_buffer *cpp_file_buffer(cpp_reader *); +extern void cpp_define(cpp_reader *, unsigned char *); + +extern void cpp_error(cpp_reader * pfile, const char *msg, ...); +extern void cpp_warning(cpp_reader * pfile, const char *msg, ...); +extern void cpp_pedwarn(cpp_reader * pfile, const char *msg, ...); +extern void cpp_fatal(const char *msg, ...); +extern void cpp_file_line_for_message(cpp_reader * pfile, + const char *filename, int line, + int column); +extern void cpp_perror_with_name(cpp_reader * pfile, const char *name); +extern void cpp_pfatal_with_name(cpp_reader * pfile, const char *name); +extern void cpp_message(cpp_reader * pfile, int is_error, + const char *msg, ...); +extern void cpp_message_v(cpp_reader * pfile, int is_error, + const char *msg, va_list args); + +extern void cpp_grow_buffer(cpp_reader * pfile, long n); +extern int cpp_parse_escape(cpp_reader * pfile, char **string_ptr); + +void cpp_print_containing_files(cpp_reader * pfile); +HOST_WIDE_INT cpp_parse_expr(cpp_reader * pfile); +void skip_rest_of_line(cpp_reader * pfile); +void init_parse_file(cpp_reader * pfile); +void init_parse_options(struct cpp_options *opts); +int push_parse_file(cpp_reader * pfile, const char *fname); +void cpp_finish(cpp_reader * pfile); +int cpp_read_check_assertion(cpp_reader * pfile); + +void *xmalloc(unsigned size); +void *xrealloc(void *old, unsigned size); +void *xcalloc(unsigned number, unsigned size); + +#ifdef __EMX__ +#define PATH_SEPARATOR ';' +#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 @@ +/* CPP main program, using CPP Library. + * Copyright (C) 1995 Free Software Foundation, Inc. + * Written by Per Bothner, 1994-95. + * Copyright (C) 2003-2011 Kim Woelders + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * In other words, you are welcome to use, share and improve this program. + * You are forbidden to forbid anyone else to use, share and improve + * what you give them. Help stamp out software-hoarding! */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include + +#include "cpplib.h" + +#define EPP_DEBUG 0 + +cpp_reader parse_in; +cpp_options options; + +int +main(int argc, char **argv) +{ + char *p; + int i; + int argi = 1; /* Next argument to handle. */ + struct cpp_options *opts = &options; + enum cpp_token kind; + int got_text; + + p = argv[0] + strlen(argv[0]); +#ifndef __EMX__ + while (p != argv[0] && p[-1] != '/') +#else + while (p != argv[0] && p[-1] != '/' && p[-1] != '\\') +#endif + --p; + progname = p; + + init_parse_file(&parse_in); + parse_in.data = opts; + + init_parse_options(opts); + + argi += cpp_handle_options(&parse_in, argc - argi, argv + argi); + if (argi < argc) + cpp_fatal("Invalid option `%s'", argv[argi]); + parse_in.show_column = 1; + + i = push_parse_file(&parse_in, opts->in_fname); + if (i != SUCCESS_EXIT_CODE) + return i; + + /* Now that we know the input file is valid, open the output. */ + + if (!opts->out_fname || !strcmp(opts->out_fname, "")) + opts->out_fname = "stdout"; + else if (!freopen(opts->out_fname, "w", stdout)) + cpp_pfatal_with_name(&parse_in, opts->out_fname); + + got_text = 0; + for (i = 0;; i++) + { + kind = cpp_get_token(&parse_in); +#if EPP_DEBUG + fprintf(stderr, "%03d: kind=%d len=%d out=%d text=%d\n", i, + kind, CPP_WRITTEN(&parse_in), !opts->no_output, got_text); +#endif + switch (kind) + { + case CPP_EOF: + goto done; + + case CPP_HSPACE: + continue; + + case CPP_VSPACE: + break; + + default: + case CPP_OTHER: + case CPP_NAME: + case CPP_NUMBER: + case CPP_CHAR: + case CPP_STRING: + case CPP_LPAREN: + case CPP_RPAREN: + case CPP_LBRACE: + case CPP_RBRACE: + case CPP_COMMA: + case CPP_SEMICOLON: + case CPP_3DOTS: + got_text = 1; + continue; + + case CPP_COMMENT: + case CPP_DIRECTIVE: + case CPP_POP: + continue; + } +#if EPP_DEBUG + fprintf(stderr, "'"); + fwrite(parse_in.token_buffer, 1, CPP_WRITTEN(&parse_in), stderr); + fprintf(stderr, "'\n"); +#endif + if (!opts->no_output) + { + size_t n; + + n = CPP_WRITTEN(&parse_in); + if (fwrite(parse_in.token_buffer, 1, n, stdout) != n) + exit(FATAL_EXIT_CODE); + } + parse_in.limit = parse_in.token_buffer; + got_text = 0; + } + + done: + cpp_finish(&parse_in); + + if (parse_in.errors) + exit(FATAL_EXIT_CODE); + exit(SUCCESS_EXIT_CODE); +} -- cgit v1.1