diff -Nru gpick-0.2.4/SConscript gpick-0.2.5/SConscript --- gpick-0.2.4/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/SConscript 2013-04-06 04:15:00.000000000 +0000 @@ -7,43 +7,44 @@ from tools.gpick import * env = GpickEnvironment(ENV=os.environ, BUILDERS = {'WriteNsisVersion' : Builder(action = WriteNsisVersion, suffix = ".nsi")}) -env.AddCustomBuilders() vars = Variables(os.path.join(env.GetLaunchDir(), 'user-config.py')) -vars.Add('DESTDIR', 'Directory to install under', '/usr/local') +vars.Add('DESTDIR', 'Directory to install under', '/usr/') +vars.Add('LOCALEDIR', 'Path to locale directory', '') vars.Add('DEBARCH', 'Debian package architecture', 'i386') -vars.Add('WITH_UNIQUE', 'Use libunique instead of pure DBus', False) -vars.Add('WITH_DBUSGLIB', 'Compile with DBus support', True) -vars.Add('DEBUG', 'Compile with debug information', False) +vars.Add(BoolVariable('ENABLE_NLS', 'Compile with gettext support', True)) +vars.Add(BoolVariable('DEBUG', 'Compile with debug information', False)) vars.Add('BUILD_TARGET', 'Build target', '') -vars.Add('INTERNAL_EXPAT', 'Use internal Expat library', True) -vars.Add('INTERNAL_LUA', 'Use internal Lua library', True) -vars.Add('PREBUILD_GRAMMAR', 'Use prebuild grammar files', False) +vars.Add('TOOLCHAIN', 'Toolchain', 'gcc') +vars.Add(BoolVariable('EXPERIMENTAL_CSS_PARSER', 'Compile with experimental CSS parser', False)) +vars.Add(BoolVariable('DOWNLOAD_RESENE_COLOR_LIST', 'Download Resene color list file at program startup', False)) +vars.Add('MSVS_VERSION', 'Visual Studio version', '11.0') +vars.Add(BoolVariable('PREBUILD_GRAMMAR', 'Use prebuild grammar files', False)) vars.Update(env) +if env['LOCALEDIR'] == '': + env['LOCALEDIR'] = env['DESTDIR'] + '/share/locale' + v = Variables(os.path.join(env.GetLaunchDir(), 'version.py')) v.Add('GPICK_BUILD_VERSION', '', '0.0') v.Update(env) -if os.environ.has_key('CC'): - env['CC'] = os.environ['CC'] -if os.environ.has_key('CFLAGS'): - env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) -if os.environ.has_key('CXX'): - env['CXX'] = os.environ['CXX'] -if os.environ.has_key('CXXFLAGS'): - env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) -if os.environ.has_key('LDFLAGS'): - env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) - - if not env['BUILD_TARGET']: env['BUILD_TARGET'] = sys.platform if env['BUILD_TARGET'] == 'win32': - if sys.platform != 'win32': - env.Tool('crossmingw', toolpath = ['tools']) + if env['TOOLCHAIN'] == 'msvc': + env['TARGET_ARCH'] = 'x86' + env['MSVS'] = {'VERSION': env['MSVS_VERSION']} + env['MSVC_VERSION'] = env['MSVS_VERSION'] + Tool('msvc')(env) + else: + if sys.platform != 'win32': + env.Tool('crossmingw', toolpath = ['tools']) + else: + env.Tool('mingw') +env.AddCustomBuilders() env.GetVersionInfo() try: @@ -55,54 +56,83 @@ if not env.GetOption('clean'): conf = Configure(env) - libs = { - 'GTK_PC': {'checks':{'gtk+-2.0':'>= 2.12.0'}}, - } - - if not env['INTERNAL_LUA']: - libs['LUA_PC'] = {'checks':{'lua':'>= 5.1', 'lua5.1':'>= 5.1'}}, - if env['WITH_UNIQUE']==True: - libs['UNIQUE_PC'] = {'checks':{'unique-1.0':'>= 1.0.8'}} - elif env['WITH_DBUSGLIB']==True: - libs['DBUSGLIB_PC'] = {'checks':{'dbus-glib-1':'>= 0.76'}} + programs = {} + if env['ENABLE_NLS']: + programs['GETTEXT'] = {'checks':{'msgfmt':'GETTEXT'}} + programs['XGETTEXT'] = {'checks':{'xgettext':'XGETTEXT'}, 'required':False} + programs['MSGMERGE'] = {'checks':{'msgmerge':'MSGMERGE'}, 'required':False} + programs['MSGCAT'] = {'checks':{'msgcat':'MSGCAT'}, 'required':False} + if env['EXPERIMENTAL_CSS_PARSER'] and not env['PREBUILD_GRAMMAR']: + programs['LEMON'] = {'checks':{'lemon':'LEMON'}} + programs['FLEX'] = {'checks':{'flex':'FLEX'}} + env.ConfirmPrograms(conf, programs) + + libs = {} + + if not env['TOOLCHAIN'] == 'msvc': + libs['GTK_PC'] = {'checks':{'gtk+-2.0':'>= 2.24.0'}} + libs['GIO_PC'] = {'checks':{'gio-unix-2.0':'>= 2.26.0', 'gio-2.0':'>= 2.26.0'}} + libs['LUA_PC'] = {'checks':{'lua':'>= 5.2', 'lua5.2':'>= 5.2'}} + + if env['DOWNLOAD_RESENE_COLOR_LIST']: + libs['CURL_PC'] = {'checks':{'libcurl':'>= 7'}} env.ConfirmLibs(conf, libs) env = conf.Finish() - +if os.environ.has_key('CC'): + env['CC'] = os.environ['CC'] +if os.environ.has_key('CFLAGS'): + env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) +if os.environ.has_key('CXX'): + env['CXX'] = os.environ['CXX'] +if os.environ.has_key('CXXFLAGS'): + env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) +if os.environ.has_key('LDFLAGS'): + env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) + Decider('MD5-timestamp') -env.Replace( - SHCCCOMSTR = "Compiling ==> $TARGET", - SHCXXCOMSTR = "Compiling ==> $TARGET", - CCCOMSTR = "Compiling ==> $TARGET", - CXXCOMSTR = "Compiling ==> $TARGET", - SHLINKCOMSTR = "Linking shared ==> $TARGET", - LINKCOMSTR = "Linking ==> $TARGET", - LDMODULECOMSTR = "Linking module ==> $TARGET", - ARCOMSTR = "Linking static ==> $TARGET", - TARCOMSTR = "Archiving ==> $TARGET" - ) - -if not (os.environ.has_key('CFLAGS') or os.environ.has_key('CXXFLAGS') or os.environ.has_key('LDFLAGS')): +if not env['TOOLCHAIN'] == 'msvc': + if not (os.environ.has_key('CFLAGS') or os.environ.has_key('CXXFLAGS') or os.environ.has_key('LDFLAGS')): + if env['DEBUG']: + env.Append( + CPPFLAGS = ['-Wall', '-g3', '-O0'], + CFLAGS = ['-Wall', '-g3', '-O0'], + LINKFLAGS = ['-Wl,-as-needed'], + ) + else: + env.Append( + CPPDEFINES = ['NDEBUG'], + CDEFINES = ['NDEBUG'], + CPPFLAGS = ['-Wall', '-O3'], + CFLAGS = ['-Wall', '-O3'], + LINKFLAGS = ['-Wl,-as-needed', '-s'], + ) + + if env['BUILD_TARGET'] == 'win32': + env.Append( + LINKFLAGS = ['-Wl,--enable-auto-import', '-static-libgcc', '-static-libstdc++'], + CPPDEFINES = ['_WIN32_WINNT=0x0501'], + ) +else: + env['LINKCOM'] = [env['LINKCOM'], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1'] if env['DEBUG']: env.Append( - CPPFLAGS = ['-Wall', '-g3', '-O0'], - CFLAGS = ['-Wall', '-g3', '-O0'], - LINKFLAGS = ['-Wl,-as-needed'], + CPPFLAGS = ['/Od', '/EHsc', '/MD', '/Gy', '/Zi', '/TP', '/wd4819'], + CPPDEFINES = ['WIN32', '_DEBUG'], + LINKFLAGS = ['/MANIFEST', '/DEBUG'], ) else: env.Append( - CPPDEFINES = ['NDEBUG'], - CDEFINES = ['NDEBUG'], - CPPFLAGS = ['-Wall', '-O3'], - CFLAGS = ['-Wall', '-O3'], - LINKFLAGS = ['-Wl,-as-needed', '-s'], + CPPFLAGS = ['/O2', '/Oi', '/GL', '/EHsc', '/MD', '/Gy', '/Zi', '/TP', '/wd4819'], + CPPDEFINES = ['WIN32', 'NDEBUG'], + LINKFLAGS = ['/MANIFEST', '/LTCG'], ) extern_libs = SConscript(['extern/SConscript'], exports='env') -executable, parser_files = SConscript(['source/SConscript'], exports='env') +executable, parser_files = SConscript(['source/SConscript'], exports='env') env.Alias(target="build", source=[ executable @@ -111,6 +141,24 @@ if 'debian' in COMMAND_LINE_TARGETS: SConscript("deb/SConscript", exports='env') + +if env['ENABLE_NLS']: + locales = env.Gettext(env.Glob('share/locale/*/LC_MESSAGES/gpick.po')) + Depends(executable, locales) + + env.Alias(target="locales", source=[ + locales + ]) + + template_c = env.Xgettext("template_c.pot", env.Glob('source/*.cpp') + env.Glob('source/tools/*.cpp') + env.Glob('source/transformation/*.cpp'), XGETTEXT_FLAGS = ['--keyword=N_', '--from-code=UTF-8', '--package-version="$GPICK_BUILD_VERSION"']) + template_lua = env.Xgettext("template_lua.pot", env.Glob('share/gpick/*.lua'), XGETTEXT_FLAGS = ['--language=C++', '--keyword=N_', '--from-code=UTF-8', '--package-version="$GPICK_BUILD_VERSION"']) + + template = env.Msgcat("template.pot", [template_c, template_lua], MSGCAT_FLAGS = ['--use-first']) + + env.Alias(target="template", source=[ + template + ]) + env.Alias(target="install", source=[ env.InstallProgram(dir=env['DESTDIR'] +'/bin', source=[executable]), env.InstallData(dir=env['DESTDIR'] +'/share/applications', source=['share/applications/gpick.desktop']), @@ -119,23 +167,24 @@ env.InstallData(dir=env['DESTDIR'] +'/share/man/man1', source=['share/man/man1/gpick.1']), env.InstallData(dir=env['DESTDIR'] +'/share/icons/hicolor/48x48/apps/', source=[env.Glob('share/icons/hicolor/48x48/apps/*.png')]), env.InstallData(dir=env['DESTDIR'] +'/share/icons/hicolor/scalable/apps/', source=[env.Glob('share/icons/hicolor/scalable/apps/*.svg')]), + env.InstallDataAutoDir(dir=env['DESTDIR'] + '/share/locale/', relative_dir='share/locale/', source=[env.Glob('share/locale/*/LC_MESSAGES/gpick.mo')]), ]) env.Alias(target="nsis", source=[ env.WriteNsisVersion("version.py") ]) -tarFiles = env.GetSourceFiles( "("+RegexEscape(os.sep)+r"\.)|("+RegexEscape(os.sep)+r"\.svn$)|(^"+RegexEscape(os.sep)+r"build$)", r"(^\.)|(\.pyc$)|(\.orig$)|(~$)|(\.log$)|(^gpick-.*\.tar\.gz$)|(^user-config\.py$)") +tarFiles = env.GetSourceFiles( "("+RegexEscape(os.sep)+r"\.)|("+RegexEscape(os.sep)+r"\.svn$)|(^"+RegexEscape(os.sep)+r"build$)", r"(^\.)|(\.pyc$)|(\.orig$)|(~$)|(\.log$)|(\.diff)|(\.mo$)|(^gpick-.*\.tar\.gz$)|(^user-config\.py$)") for item in parser_files: tarFiles.append(str(item)) -env.Alias(target="tar", source=[ - env.Append(TARFLAGS = ['-z']), - env.Prepend(TARFLAGS = ['--transform', '"s,(^(build/)?),gpick_'+str(env['GPICK_BUILD_VERSION'])+'/,x"']), - env.Tar('gpick_'+str(env['GPICK_BUILD_VERSION'])+'.tar.gz', tarFiles) -]) - +if 'TAR' in env: + env.Alias(target="tar", source=[ + env.Append(TARFLAGS = ['-z']), + env.Prepend(TARFLAGS = ['--transform', '"s,(^(build/)?),gpick_'+str(env['GPICK_BUILD_VERSION'])+'/,x"']), + env.Tar('gpick_'+str(env['GPICK_BUILD_VERSION'])+'.tar.gz', tarFiles) + ]) env.Default(executable) diff -Nru gpick-0.2.4/deb/SConscript gpick-0.2.5/deb/SConscript --- gpick-0.2.4/deb/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/deb/SConscript 2013-01-01 16:10:51.000000000 +0000 @@ -15,7 +15,7 @@ DEBVERSION = str(env['GPICK_BUILD_VERSION'])+"-1" DEBMAINT = "Albertas Vyšniauskas " DEBARCH = env['DEBARCH'] -DEBDEPENDS = "libgtk2.0-0 (>= 2.12), libc6 (>= 2.7), liblua5.1-0 (>= 5.1), libcairo2 (>=1.6), libglib2.0-0 (>=2.16)" +DEBDEPENDS = "libgtk2.0-0 (>= 2.24), libc6 (>= 2.13), liblua5.2-0 (>= 5.2), libcairo2 (>=1.8), libglib2.0-0 (>=2.24)" DEBPRIORITY = "optional" DEBSECTION = "graphics" DEBDESC = "Advanced color picker" @@ -26,11 +26,6 @@ or simply copy them to the clipboard """ -if env['WITH_UNIQUE']==True: - DEBDEPENDS += ', libunique-1.0-0 (>=1.0)' -elif env['WITH_DBUSGLIB']==True: - DEBDEPENDS += ', libdbus-glib-1-2 (>=0.76-1)' - DEBPACKAGEFILE = '%s_%s_%s.deb' % (DEBNAME, DEBVERSION, DEBARCH) CONTROL_TEMPLATE = """Package: %s diff -Nru gpick-0.2.4/debian/README.Debian gpick-0.2.5/debian/README.Debian --- gpick-0.2.4/debian/README.Debian 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/README.Debian 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,6 @@ +gpick for Debian +---------------- + + + + -- Dariusz Duma Tue, 02 Apr 2013 15:30:49 +0200 diff -Nru gpick-0.2.4/debian/README.source gpick-0.2.5/debian/README.source --- gpick-0.2.4/debian/README.source 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/README.source 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,9 @@ +gpick for Debian +---------------- + + + + + + diff -Nru gpick-0.2.4/debian/changelog gpick-0.2.5/debian/changelog --- gpick-0.2.4/debian/changelog 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/changelog 2013-04-06 04:27:23.000000000 +0000 @@ -1,19 +1,5 @@ -gpick (0.2.4-1) unstable; urgency=low +gpick (0.2.5-1dhor~raring) raring; urgency=low - * New upstream release. - * Updated Standards-Version to 3.9.2 - * Bump debhelper compat to 8 - * Upstream fixed wrong color (Closes: #622964) - * Updated debian/copyright under DEP-5 format. - * Added '-Wl,--as-needed' flag into debian/rules. - * 01_expat_dependency.patch: Updated. - * 02_dsolink_expat.patch: Updated. + * 0.2.5 - -- Elías Alejandro Año Mendoza Tue, 14 Jun 2011 13:44:26 -0500 - -gpick (0.2.3-1) unstable; urgency=low - - * Initial release (Closes: #579617) - * Switched to share expat library and avoid its internal library. - - -- Elías Alejandro Año Mendoza Thu, 11 Nov 2010 18:03:50 -0500 + -- Dariusz Duma Tue, 02 Apr 2013 15:30:49 +0200 diff -Nru gpick-0.2.4/debian/control gpick-0.2.5/debian/control --- gpick-0.2.4/debian/control 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/control 2013-04-06 04:25:49.000000000 +0000 @@ -1,20 +1,18 @@ Source: gpick Section: graphics -Priority: optional -Maintainer: Elías Alejandro Año Mendoza -Build-Depends: debhelper (>= 8.0.0), scons, libcairo2 (>=1.6), - libglib2.0-0 (>=2.16), libdbus-glib-1-dev (>=0.76), libgtk2.0-dev (>= 2.12), - liblua5.1-0-dev (>= 5.1), libboost-dev, libexpat1-dev, lemon, flex +Priority: extra +Maintainer: Dariusz Duma +Build-Depends: debhelper (>= 8.0.0), scons, libgtk2.0-dev (>= 2.24), libc6-dev (>= 2.13), liblua5.2-dev (>= 5.2), libcairo2-dev (>=1.8), libglib2.0-dev (>=2.24), libboost-dev Standards-Version: 3.9.2 -Homepage: http://code.google.com/p/gpick/ -Vcs-Git: git://git.debian.org/collab-maint/gpick.git -Vcs-Browser: http://git.debian.org/?p=collab-maint/gpick.git;a=summary +#Vcs-Git: git://git.debian.org/collab-maint/gpick.git +#Vcs-Browser: http://git.debian.org/?p=collab-maint/gpick.git;a=summary Package: gpick Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Description: advanced GTK+ color picker - gpick is an advanced color picker used to pick colors from anywhere - on the screen, mix them to get new colors, generate shades and tints, - and export palettes to common file formats or simply copy them - to the clipboard. +Description: Advanced GTK+ color picker + gpick is a program used to pick colors + from anythere on the screen, mix them to + get new colors, generate shades and tints + and export palettes to common file formats + or simply copy them to the clipboard diff -Nru gpick-0.2.4/debian/copyright gpick-0.2.5/debian/copyright --- gpick-0.2.4/debian/copyright 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/copyright 2013-04-02 13:30:51.000000000 +0000 @@ -1,108 +1,36 @@ Format: http://dep.debian.net/deps/dep5 Upstream-Name: gpick -Upstream-Contact: Albertas Vyšniauskas -Source: http://code.google.com/p/gpick/ +Source: Files: * -Copyright: 2009-2011 Albertas Vyšniauskas -License: BSD-3 - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: +Copyright: + +License: + + . - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the software author nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - . - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - -Files: extern/expat/* -Copyright: 2001, 2002, 2003, 2004, 2005, 2006, Expat maintainers - 1998, 1999, 2000, Thai Open Source Software Center Ltd and Clark Cooper -License: MIT - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - . - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Files: share/gpick/colors.txt -Copyright: 2001, Resene Paints Ltd. -License: - Permission to copy this dictionary, to modify it, to redistribute it, - to distribute modified versions, and to use it for any purpose is - granted, subject to the following restrictions and understandings. - . - 1. Any text copy made of this dictionary must include this copyright - notice in full. - . - 2. Any redistribution in binary form must reproduce this copyright - notice in the documentation or other materials provided with the - distribution. - . - 3. Resene Paints Ltd makes no warranty or representation that this - dictionary is error-free, and is under no obligation to provide any - services, by way of maintenance, update, or otherwise. - . - 4. There shall be no use of the name of Resene or Resene Paints Ltd - in any advertising, promotional, or sales literature without prior - written consent in each case. - . - 5. These RGB colour formulations may not be used to the detriment of - Resene Paints Ltd. + +# If you want to use GPL v2 or later for the /debian/* files use +# the following clauses, or change it to suit. Delete these two lines Files: debian/* -Copyright: 2011, Elías Alejandro Año Mendoza -License: BSD-3 -Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: +Copyright: 2013 Dariusz Duma +License: GPL-2+ + This package 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 of the License, or + (at your option) any later version. + . + This package 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. . - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the software author nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + You should have received a copy of the GNU General Public License + along with this program. If not, see . - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff -Nru gpick-0.2.4/debian/emacsen-install.ex gpick-0.2.5/debian/emacsen-install.ex --- gpick-0.2.4/debian/emacsen-install.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/emacsen-install.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,45 @@ +#! /bin/sh -e +# /usr/lib/emacsen-common/packages/install/gpick + +# Written by Jim Van Zandt , borrowing heavily +# from the install scripts for gettext by Santiago Vila +# and octave by Dirk Eddelbuettel . + +FLAVOR=$1 +PACKAGE=gpick + +if [ ${FLAVOR} = emacs ]; then exit 0; fi + +echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR} + +#FLAVORTEST=`echo $FLAVOR | cut -c-6` +#if [ ${FLAVORTEST} = xemacs ] ; then +# SITEFLAG="-no-site-file" +#else +# SITEFLAG="--no-site-file" +#fi +FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile" + +ELDIR=/usr/share/emacs/site-lisp/${PACKAGE} +ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE} + +# Install-info-altdir does not actually exist. +# Maybe somebody will write it. +if test -x /usr/sbin/install-info-altdir; then + echo install/${PACKAGE}: install Info links for ${FLAVOR} + install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/share/info/${PACKAGE}.info.gz +fi + +install -m 755 -d ${ELCDIR} +cd ${ELDIR} +FILES=`echo *.el` +cp ${FILES} ${ELCDIR} +cd ${ELCDIR} + +cat << EOF > path.el +(setq load-path (cons "." load-path) byte-compile-warnings nil) +EOF +${FLAVOR} ${FLAGS} ${FILES} +rm -f *.el path.el + +exit 0 diff -Nru gpick-0.2.4/debian/emacsen-remove.ex gpick-0.2.5/debian/emacsen-remove.ex --- gpick-0.2.4/debian/emacsen-remove.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/emacsen-remove.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,15 @@ +#!/bin/sh -e +# /usr/lib/emacsen-common/packages/remove/gpick + +FLAVOR=$1 +PACKAGE=gpick + +if [ ${FLAVOR} != emacs ]; then + if test -x /usr/sbin/install-info-altdir; then + echo remove/${PACKAGE}: removing Info links for ${FLAVOR} + install-info-altdir --quiet --remove --dirname=${FLAVOR} /usr/share/info/gpick.info.gz + fi + + echo remove/${PACKAGE}: purging byte-compiled files for ${FLAVOR} + rm -rf /usr/share/${FLAVOR}/site-lisp/${PACKAGE} +fi diff -Nru gpick-0.2.4/debian/emacsen-startup.ex gpick-0.2.5/debian/emacsen-startup.ex --- gpick-0.2.4/debian/emacsen-startup.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/emacsen-startup.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,25 @@ +;; -*-emacs-lisp-*- +;; +;; Emacs startup file, e.g. /etc/emacs/site-start.d/50gpick.el +;; for the Debian gpick package +;; +;; Originally contributed by Nils Naumann +;; Modified by Dirk Eddelbuettel +;; Adapted for dh-make by Jim Van Zandt + +;; The gpick package follows the Debian/GNU Linux 'emacsen' policy and +;; byte-compiles its elisp files for each 'emacs flavor' (emacs19, +;; xemacs19, emacs20, xemacs20...). The compiled code is then +;; installed in a subdirectory of the respective site-lisp directory. +;; We have to add this to the load-path: +(let ((package-dir (concat "/usr/share/" + (symbol-name flavor) + "/site-lisp/gpick"))) +;; If package-dir does not exist, the gpick package must have +;; removed but not purged, and we should skip the setup. + (when (file-directory-p package-dir) + (setq load-path (cons package-dir load-path)) + (autoload 'gpick-mode "gpick-mode" + "Major mode for editing gpick files." t) + (add-to-list 'auto-mode-alist '("\\.gpick$" . gpick-mode)))) + diff -Nru gpick-0.2.4/debian/gpick.1 gpick-0.2.5/debian/gpick.1 --- gpick-0.2.4/debian/gpick.1 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/gpick.1 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -.TH GPICK 1 "November 11, 2010" -.SH NAME -gpick \- advanced color picker written in C++ using GTK+ toolkit -.SH SYNOPSIS -.B gpick -[OPTION...] [FILE...] -.SH DESCRIPTION -\fBgpick\fP starts an application and opens FILE if it is specified -.SH HELP OPTIONS -.TP -.B \-h, \-\-help -Show help options. -.TP -.B \-\-help-all -Show all help options. -.TP -.B \-\-help-gtk -Show GTK+ Options -.SH APPLICATION OPTIONS -.TP -.B \-g\, \-\-geometry=GEOMETRY -Window geometry -.TP -.B \-\-display=DISPLAY -X display to use -.br -.SH AUTHOR -gpick was written by Albertas Vyšniauskas -.PP -This manual page was written by Elías Alejandro Año Mendoza , -for the Debian project (and may be used by others). diff -Nru gpick-0.2.4/debian/gpick.cron.d.ex gpick-0.2.5/debian/gpick.cron.d.ex --- gpick-0.2.4/debian/gpick.cron.d.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/gpick.cron.d.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,4 @@ +# +# Regular cron jobs for the gpick package +# +0 4 * * * root [ -x /usr/bin/gpick_maintenance ] && /usr/bin/gpick_maintenance diff -Nru gpick-0.2.4/debian/gpick.default.ex gpick-0.2.5/debian/gpick.default.ex --- gpick-0.2.4/debian/gpick.default.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/gpick.default.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,10 @@ +# Defaults for gpick initscript +# sourced by /etc/init.d/gpick +# installed at /etc/default/gpick by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +# Additional options that are passed to the Daemon. +DAEMON_OPTS="" diff -Nru gpick-0.2.4/debian/gpick.doc-base.EX gpick-0.2.5/debian/gpick.doc-base.EX --- gpick-0.2.4/debian/gpick.doc-base.EX 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/gpick.doc-base.EX 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,20 @@ +Document: gpick +Title: Debian gpick Manual +Author: +Abstract: This manual describes what gpick is + and how it can be used to + manage online manuals on Debian systems. +Section: unknown + +Format: debiandoc-sgml +Files: /usr/share/doc/gpick/gpick.sgml.gz + +Format: postscript +Files: /usr/share/doc/gpick/gpick.ps.gz + +Format: text +Files: /usr/share/doc/gpick/gpick.text.gz + +Format: HTML +Index: /usr/share/doc/gpick/html/index.html +Files: /usr/share/doc/gpick/html/*.html diff -Nru gpick-0.2.4/debian/gpick.manpages gpick-0.2.5/debian/gpick.manpages --- gpick-0.2.4/debian/gpick.manpages 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/gpick.manpages 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -debian/gpick.1 diff -Nru gpick-0.2.4/debian/init.d.ex gpick-0.2.5/debian/init.d.ex --- gpick-0.2.4/debian/init.d.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/init.d.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,154 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: gpick +# Required-Start: $network $local_fs +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: +# Description: +# <...> +# <...> +### END INIT INFO + +# Author: Dariusz Duma + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC=gpick # Introduce a short description here +NAME=gpick # Introduce the short server's name here +DAEMON=/usr/sbin/gpick # Introduce the server's location here +DAEMON_ARGS="" # Arguments to run the daemon with +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x $DAEMON ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 + # Add code here, if necessary, that waits for the process to be ready + # to handle requests from services started subsequently which depend + # on this one. As a last resort, sleep for some time. +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + #reload|force-reload) + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + #log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #log_end_msg $? + #;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff -Nru gpick-0.2.4/debian/manpage.1.ex gpick-0.2.5/debian/manpage.1.ex --- gpick-0.2.4/debian/manpage.1.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/manpage.1.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,59 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH GPICK SECTION "April 2, 2013" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +gpick \- program to do something +.SH SYNOPSIS +.B gpick +.RI [ options ] " files" ... +.br +.B bar +.RI [ options ] " files" ... +.SH DESCRIPTION +This manual page documents briefly the +.B gpick +and +.B bar +commands. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBgpick\fP is a program that... +.SH OPTIONS +These programs follow the usual GNU command line syntax, with long +options starting with two dashes (`-'). +A summary of options is included below. +For a complete description, see the Info files. +.TP +.B \-h, \-\-help +Show summary of options. +.TP +.B \-v, \-\-version +Show version of program. +.SH SEE ALSO +.BR bar (1), +.BR baz (1). +.br +The programs are documented fully by +.IR "The Rise and Fall of a Fooish Bar" , +available via the Info system. +.SH AUTHOR +gpick was written by . +.PP +This manual page was written by Dariusz Duma , +for the Debian project (and may be used by others). diff -Nru gpick-0.2.4/debian/manpage.sgml.ex gpick-0.2.5/debian/manpage.sgml.ex --- gpick-0.2.4/debian/manpage.sgml.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/manpage.sgml.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,154 @@ + manpage.1'. You may view + the manual page with: `docbook-to-man manpage.sgml | nroff -man | + less'. A typical entry in a Makefile or Makefile.am is: + +manpage.1: manpage.sgml + docbook-to-man $< > $@ + + + The docbook-to-man binary is found in the docbook-to-man package. + Please remember that if you create the nroff version in one of the + debian/rules file targets (such as build), you will need to include + docbook-to-man in your Build-Depends control field. + + --> + + + FIRSTNAME"> + SURNAME"> + + April 2, 2013"> + + SECTION"> + dhor@toxic.net.pl"> + + GPICK"> + + + Debian"> + GNU"> + GPL"> +]> + + + +
+ &dhemail; +
+ + &dhfirstname; + &dhsurname; + + + 2003 + &dhusername; + + &dhdate; +
+ + &dhucpackage; + + &dhsection; + + + &dhpackage; + + program to do something + + + + &dhpackage; + + + + + + + + DESCRIPTION + + This manual page documents briefly the + &dhpackage; and bar + commands. + + This manual page was written for the &debian; distribution + because the original program does not have a manual page. + Instead, it has documentation in the &gnu; + Info format; see below. + + &dhpackage; is a program that... + + + + OPTIONS + + These programs follow the usual &gnu; command line syntax, + with long options starting with two dashes (`-'). A summary of + options is included below. For a complete description, see the + Info files. + + + + + + + + Show summary of options. + + + + + + + + Show version of program. + + + + + + SEE ALSO + + bar (1), baz (1). + + The programs are documented fully by The Rise and + Fall of a Fooish Bar available via the + Info system. + + + AUTHOR + + This manual page was written by &dhusername; &dhemail; for + the &debian; system (and may be used by others). Permission is + granted to copy, distribute and/or modify this document under + the terms of the &gnu; General Public License, Version 2 any + later version published by the Free Software Foundation. + + + On Debian systems, the complete text of the GNU General Public + License can be found in /usr/share/common-licenses/GPL. + + + +
+ + diff -Nru gpick-0.2.4/debian/manpage.xml.ex gpick-0.2.5/debian/manpage.xml.ex --- gpick-0.2.4/debian/manpage.xml.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/manpage.xml.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,291 @@ + +.
will be generated. You may view the +manual page with: nroff -man .
| less'. A typical entry +in a Makefile or Makefile.am is: + +DB2MAN = /usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/manpages/docbook.xsl +XP = xsltproc -''-nonet -''-param man.charmap.use.subset "0" + +manpage.1: manpage.xml + $(XP) $(DB2MAN) $< + +The xsltproc binary is found in the xsltproc package. The XSL files are in +docbook-xsl. A description of the parameters you can use can be found in the +docbook-xsl-doc-* packages. Please remember that if you create the nroff +version in one of the debian/rules file targets (such as build), you will need +to include xsltproc and docbook-xsl in your Build-Depends control field. +Alternatively use the xmlto command/package. That will also automatically +pull in xsltproc and docbook-xsl. + +Notes for using docbook2x: docbook2x-man does not automatically create the +AUTHOR(S) and COPYRIGHT sections. In this case, please add them manually as + ... . + +To disable the automatic creation of the AUTHOR(S) and COPYRIGHT sections +read /usr/share/doc/docbook-xsl/doc/manpages/authors.html. This file can be +found in the docbook-xsl-doc-html package. + +Validation can be done using: `xmllint -''-noout -''-valid manpage.xml` + +General documentation about man-pages and man-page-formatting: +man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ + +--> + + + + + + + + + + + + + +]> + + + + &dhtitle; + &dhpackage; + + + &dhfirstname; + &dhsurname; + Wrote this manpage for the Debian system. +
+ &dhemail; +
+
+
+ + 2007 + &dhusername; + + + This manual page was written for the Debian system + (and may be used by others). + Permission is granted to copy, distribute and/or modify this + document under the terms of the GNU General Public License, + Version 2 or (at your option) any later version published by + the Free Software Foundation. + On Debian systems, the complete text of the GNU General Public + License can be found in + /usr/share/common-licenses/GPL. + +
+ + &dhucpackage; + &dhsection; + + + &dhpackage; + program to do something + + + + &dhpackage; + + + + + + + + + this + + + + + + + + this + that + + + + + &dhpackage; + + + + + + + + + + + + + + + + + + + DESCRIPTION + This manual page documents briefly the + &dhpackage; and bar + commands. + This manual page was written for the Debian distribution + because the original program does not have a manual page. + Instead, it has documentation in the GNU + info + 1 + format; see below. + &dhpackage; is a program that... + + + OPTIONS + The program follows the usual GNU command line syntax, + with long options starting with two dashes (`-'). A summary of + options is included below. For a complete description, see the + + info + 1 + files. + + + + + + + Does this and that. + + + + + + + Show summary of options. + + + + + + + Show version of program. + + + + + + FILES + + + /etc/foo.conf + + The system-wide configuration file to control the + behaviour of &dhpackage;. See + + foo.conf + 5 + for further details. + + + + ${HOME}/.foo.conf + + The per-user configuration file to control the + behaviour of &dhpackage;. See + + foo.conf + 5 + for further details. + + + + + + ENVIONMENT + + + FOO_CONF + + If used, the defined file is used as configuration + file (see also ). + + + + + + DIAGNOSTICS + The following diagnostics may be issued + on stderr: + + + Bad configuration file. Exiting. + + The configuration file seems to contain a broken configuration + line. Use the option, to get more info. + + + + + &dhpackage; provides some return codes, that can + be used in scripts: + + Code + Diagnostic + + 0 + Program exited successfully. + + + 1 + The configuration file seems to be broken. + + + + + + BUGS + The program is currently limited to only work + with the foobar library. + The upstreams BTS can be found + at . + + + SEE ALSO + + + bar + 1 + , + baz + 1 + , + foo.conf + 5 + + The programs are documented fully by The Rise and + Fall of a Fooish Bar available via the + info + 1 + system. + +
+ diff -Nru gpick-0.2.4/debian/menu.ex gpick-0.2.5/debian/menu.ex --- gpick-0.2.4/debian/menu.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/menu.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,2 @@ +?package(gpick):needs="X11|text|vc|wm" section="Applications/see-menu-manual"\ + title="gpick" command="/usr/bin/gpick" diff -Nru gpick-0.2.4/debian/patches/01_expat_dependency.patch gpick-0.2.5/debian/patches/01_expat_dependency.patch --- gpick-0.2.4/debian/patches/01_expat_dependency.patch 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/patches/01_expat_dependency.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -Description: gpick by default works with a internal expat library - This patch allow works with the shared library. - -Author: Elías Alejandro Año Mendoza -Forwarded: yes -Last-Update: 2011-06-14 - ---- gpick.orig/source/SConscript 2011-06-14 13:25:49.000000000 -0500 -+++ gpick/source/SConscript 2011-06-14 13:26:10.000000000 -0500 -@@ -41,8 +41,8 @@ - 'gpick', - source = [sources, objects]) - --if env['INTERNAL_EXPAT']: -- Depends(executable, local_env.UseLibrary('expat')) -+#if env['INTERNAL_EXPAT']: -+# Depends(executable, local_env.UseLibrary('expat')) - if env['INTERNAL_LUA']: - Depends(executable, local_env.UseLibrary('lua')) - diff -Nru gpick-0.2.4/debian/patches/02_dsolink_expat.patch gpick-0.2.5/debian/patches/02_dsolink_expat.patch --- gpick-0.2.4/debian/patches/02_dsolink_expat.patch 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/patches/02_dsolink_expat.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -Description: gpick has troubles with the new linker-related changes - This patch allow works properly with DSO Linking changes for wheezy. - -Author: Yuri D'Elia -Forwarded: yes -Last-Update: 2011-06-14 - ---- gpick.orig/source/SConscript 2011-06-14 13:27:08.000000000 -0500 -+++ gpick/source/SConscript 2011-06-14 13:27:36.000000000 -0500 -@@ -32,7 +32,7 @@ - local_env.Append(LINKFLAGS = '-mwindows') - objects.append(SConscript(['winres/SConscript'], exports='env')) - elif local_env['BUILD_TARGET'] == 'linux2': -- local_env.Append(LIBS=['rt']) -+ local_env.Append(LIBS=['rt', 'expat']) - - if not env['INTERNAL_EXPAT']: - local_env.Append(LIBS=['expat']) diff -Nru gpick-0.2.4/debian/patches/series gpick-0.2.5/debian/patches/series --- gpick-0.2.4/debian/patches/series 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -01_expat_dependency.patch -02_dsolink_expat.patch diff -Nru gpick-0.2.4/debian/postinst.ex gpick-0.2.5/debian/postinst.ex --- gpick-0.2.4/debian/postinst.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/postinst.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,39 @@ +#!/bin/sh +# postinst script for gpick +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru gpick-0.2.4/debian/postrm.ex gpick-0.2.5/debian/postrm.ex --- gpick-0.2.4/debian/postrm.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/postrm.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,37 @@ +#!/bin/sh +# postrm script for gpick +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru gpick-0.2.4/debian/preinst.ex gpick-0.2.5/debian/preinst.ex --- gpick-0.2.4/debian/preinst.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/preinst.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,35 @@ +#!/bin/sh +# preinst script for gpick +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru gpick-0.2.4/debian/prerm.ex gpick-0.2.5/debian/prerm.ex --- gpick-0.2.4/debian/prerm.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/prerm.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,38 @@ +#!/bin/sh +# prerm script for gpick +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru gpick-0.2.4/debian/rules gpick-0.2.5/debian/rules --- gpick-0.2.4/debian/rules 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/rules 2013-04-06 04:17:10.000000000 +0000 @@ -1,4 +1,12 @@ #!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 LDFLAGS+=-Wl,--as-needed @@ -8,16 +16,22 @@ %: dh $@ -override_dh_clean: - dh_testdir - dh_testroot - scons -c -C src - find -name "*.pyc" -delete - rm -f build-stamp configure-stamp - rm -rf .sconsign.dblite config.log .sconf_temp/ build/ - dh_clean + +#override_dh_auto_build: +# scons +#override_dh_auto_install: +# scons install + +#override_dh_clean: +# dh_testdir +# dh_testroot +# scons -c -C src +# find -name "*.pyc" -delete +# rm -f build-stamp configure-stamp +# rm -rf .sconsign.dblite config.log .sconf_temp/ build/ +# dh_clean override_dh_install: scons install DESTDIR=$(debian_destdir) rm -f $(debian_destdir)/share/doc/copyright - rm -f $(debian_destdir)/share/man/man1/gpick.1 + rm -f $(debian_destdir)/share/man/man1/gpick.1 \ No newline at end of file diff -Nru gpick-0.2.4/debian/watch gpick-0.2.5/debian/watch --- gpick-0.2.4/debian/watch 2011-06-16 16:33:04.000000000 +0000 +++ gpick-0.2.5/debian/watch 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -version=3 - -http://googlecode.debian.net/p/gpick/gpick_(\d+.*)\.tar\.gz diff -Nru gpick-0.2.4/debian/watch.ex gpick-0.2.5/debian/watch.ex --- gpick-0.2.4/debian/watch.ex 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/debian/watch.ex 2013-04-02 13:30:51.000000000 +0000 @@ -0,0 +1,23 @@ +# Example watch control file for uscan +# Rename this file to "watch" and then you can run the "uscan" command +# to check for upstream updates and more. +# See uscan(1) for format + +# Compulsory line, this is a version 3 file +version=3 + +# Uncomment to examine a Webpage +# +#http://www.example.com/downloads.php gpick-(.*)\.tar\.gz + +# Uncomment to examine a Webserver directory +#http://www.example.com/pub/gpick-(.*)\.tar\.gz + +# Uncommment to examine a FTP server +#ftp://ftp.example.com/pub/gpick-(.*)\.tar\.gz debian uupdate + +# Uncomment to find new files on sourceforge, for devscripts >= 2.9 +# http://sf.net/gpick/gpick-(.*)\.tar\.gz + +# Uncomment to find new files on GooglePages +# http://example.googlepages.com/foo.html gpick-(.*)\.tar\.gz diff -Nru gpick-0.2.4/doc/Doxyfile gpick-0.2.5/doc/Doxyfile --- gpick-0.2.4/doc/Doxyfile 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/doc/Doxyfile 2013-01-01 16:10:51.000000000 +0000 @@ -767,7 +767,7 @@ # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. -GENERATE_HTML = NO +GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be @@ -820,7 +820,7 @@ # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). -HTML_DYNAMIC_SECTIONS = NO +HTML_DYNAMIC_SECTIONS = YES # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 @@ -1367,7 +1367,7 @@ # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. -CLASS_DIAGRAMS = YES +CLASS_DIAGRAMS = NO # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see diff -Nru gpick-0.2.4/extern/SConscript gpick-0.2.5/extern/SConscript --- gpick-0.2.4/extern/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/SConscript 2013-01-01 16:10:51.000000000 +0000 @@ -1,8 +1,6 @@ #!/usr/bin/env python Import('*') - objects = [] -objects.append(SConscript(['expat/SConscript'], exports='env')) -objects.append(SConscript(['lua/SConscript'], exports='env')) Return('objects') + diff -Nru gpick-0.2.4/extern/expat/COPYING gpick-0.2.5/extern/expat/COPYING --- gpick-0.2.4/extern/expat/COPYING 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/COPYING 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - and Clark Cooper -Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff -Nru gpick-0.2.4/extern/expat/Changes gpick-0.2.5/extern/expat/Changes --- gpick-0.2.4/extern/expat/Changes 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/Changes 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -Release 2.0.1 Tue June 5 2007 - - Fixed bugs #1515266, #1515600: The character data handler's calling - of XML_StopParser() was not handled properly; if the parser was - stopped and the handler set to NULL, the parser would segfault. - - Fixed bug #1690883: Expat failed on EBCDIC systems as it assumed - some character constants to be ASCII encoded. - - Minor cleanups of the test harness. - - Fixed xmlwf bug #1513566: "out of memory" error on file size zero. - - Fixed outline.c bug #1543233: missing a final XML_ParserFree() call. - - Fixes and improvements for Windows platform: - bugs #1409451, #1476160, #1548182, #1602769, #1717322. - - Build fixes for various platforms: - HP-UX, Tru64, Solaris 9: patch #1437840, bug #1196180. - All Unix: #1554618 (refreshed config.sub/config.guess). - #1490371, #1613457: support both, DESTDIR and INSTALL_ROOT, - without relying on GNU-Make specific features. - #1647805: Patched configure.in to work better with Intel compiler. - - Fixes to Makefile.in to have make check work correctly: - bugs #1408143, #1535603, #1536684. - - Added Open Watcom support: patch #1523242. - -Release 2.0.0 Wed Jan 11 2006 - - We no longer use the "check" library for C unit testing; we - always use the (partial) internal implementation of the API. - - Report XML_NS setting via XML_GetFeatureList(). - - Fixed headers for use from C++. - - XML_GetCurrentLineNumber() and XML_GetCurrentColumnNumber() - now return unsigned integers. - - Added XML_LARGE_SIZE switch to enable 64-bit integers for - byte indexes and line/column numbers. - - Updated to use libtool 1.5.22 (the most recent). - - Added support for AmigaOS. - - Some mostly minor bug fixes. SF issues include: #1006708, - #1021776, #1023646, #1114960, #1156398, #1221160, #1271642. - -Release 1.95.8 Fri Jul 23 2004 - - Major new feature: suspend/resume. Handlers can now request - that a parse be suspended for later resumption or aborted - altogether. See "Temporarily Stopping Parsing" in the - documentation for more details. - - Some mostly minor bug fixes, but compilation should no - longer generate warnings on most platforms. SF issues - include: #827319, #840173, #846309, #888329, #896188, #923913, - #928113, #961698, #985192. - -Release 1.95.7 Mon Oct 20 2003 - - Fixed enum XML_Status issue (reported on SourceForge many - times), so compilers that are properly picky will be happy. - - Introduced an XMLCALL macro to control the calling - convention used by the Expat API; this macro should be used - to annotate prototypes and definitions of callback - implementations in code compiled with a calling convention - other than the default convention for the host platform. - - Improved ability to build without the configure-generated - expat_config.h header. This is useful for applications - which embed Expat rather than linking in the library. - - Fixed a variety of bugs: see SF issues #458907, #609603, - #676844, #679754, #692878, #692964, #695401, #699323, #699487, - #820946. - - Improved hash table lookups. - - Added more regression tests and improved documentation. - -Release 1.95.6 Tue Jan 28 2003 - - Added XML_FreeContentModel(). - - Added XML_MemMalloc(), XML_MemRealloc(), XML_MemFree(). - - Fixed a variety of bugs: see SF issues #615606, #616863, - #618199, #653180, #673791. - - Enhanced the regression test suite. - - Man page improvements: includes SF issue #632146. - -Release 1.95.5 Fri Sep 6 2002 - - Added XML_UseForeignDTD() for improved SAX2 support. - - Added XML_GetFeatureList(). - - Defined XML_Bool type and the values XML_TRUE and XML_FALSE. - - Use an incomplete struct instead of a void* for the parser - (may not retain). - - Fixed UTF-8 decoding bug that caused legal UTF-8 to be rejected. - - Finally fixed bug where default handler would report DTD - events that were already handled by another handler. - Initial patch contributed by Darryl Miles. - - Removed unnecessary DllMain() function that caused static - linking into a DLL to be difficult. - - Added VC++ projects for building static libraries. - - Reduced line-length for all source code and headers to be - no longer than 80 characters, to help with AS/400 support. - - Reduced memory copying during parsing (SF patch #600964). - - Fixed a variety of bugs: see SF issues #580793, #434664, - #483514, #580503, #581069, #584041, #584183, #584832, #585537, - #596555, #596678, #598352, #598944, #599715, #600479, #600971. - -Release 1.95.4 Fri Jul 12 2002 - - Added support for VMS, contributed by Craig Berry. See - vms/README.vms for more information. - - Added Mac OS (classic) support, with a makefile for MPW, - contributed by Thomas Wegner and Daryle Walker. - - Added Borland C++ Builder 5 / BCC 5.5 support, contributed - by Patrick McConnell (SF patch #538032). - - Fixed a variety of bugs: see SF issues #441449, #563184, - #564342, #566334, #566901, #569461, #570263, #575168, #579196. - - Made skippedEntityHandler conform to SAX2 (see source comment) - - Re-implemented WFC: Entity Declared from XML 1.0 spec and - added a new error "entity declared in parameter entity": - see SF bug report #569461 and SF patch #578161 - - Re-implemented section 5.1 from XML 1.0 spec: - see SF bug report #570263 and SF patch #578161 - -Release 1.95.3 Mon Jun 3 2002 - - Added a project to the MSVC workspace to create a wchar_t - version of the library; the DLLs are named libexpatw.dll. - - Changed the name of the Windows DLLs from expat.dll to - libexpat.dll; this fixes SF bug #432456. - - Added the XML_ParserReset() API function. - - Fixed XML_SetReturnNSTriplet() to work for element names. - - Made the XML_UNICODE builds usable (thanks, Karl!). - - Allow xmlwf to read from standard input. - - Install a man page for xmlwf on Unix systems. - - Fixed many bugs; see SF bug reports #231864, #461380, #464837, - #466885, #469226, #477667, #484419, #487840, #494749, #496505, - #547350. Other bugs which we can't test as easily may also - have been fixed, especially in the area of build support. - -Release 1.95.2 Fri Jul 27 2001 - - More changes to make MSVC happy with the build; add a single - workspace to support both the library and xmlwf application. - - Added a Windows installer for Windows users; includes - xmlwf.exe. - - Added compile-time constants that can be used to determine the - Expat version - - Removed a lot of GNU-specific dependencies to aide portability - among the various Unix flavors. - - Fix the UTF-8 BOM bug. - - Cleaned up warning messages for several compilers. - - Added the -Wall, -Wstrict-prototypes options for GCC. - -Release 1.95.1 Sun Oct 22 15:11:36 EDT 2000 - - Changes to get expat to build under Microsoft compiler - - Removed all aborts and instead return an UNEXPECTED_STATE error. - - Fixed a bug where a stray '%' in an entity value would cause an - abort. - - Defined XML_SetEndNamespaceDeclHandler. Thanks to Darryl Miles for - finding this oversight. - - Changed default patterns in lib/Makefile.in to fit non-GNU makes - Thanks to robin@unrated.net for reporting and providing an - account to test on. - - The reference had the wrong label for XML_SetStartNamespaceDecl. - Reported by an anonymous user. - -Release 1.95.0 Fri Sep 29 2000 - - XML_ParserCreate_MM - Allows you to set a memory management suite to replace the - standard malloc,realloc, and free. - - XML_SetReturnNSTriplet - If you turn this feature on when namespace processing is in - effect, then qualified, prefixed element and attribute names - are returned as "uri|name|prefix" where '|' is whatever - separator character is used in namespace processing. - - Merged in features from perl-expat - o XML_SetElementDeclHandler - o XML_SetAttlistDeclHandler - o XML_SetXmlDeclHandler - o XML_SetEntityDeclHandler - o StartDoctypeDeclHandler takes 3 additional parameters: - sysid, pubid, has_internal_subset - o Many paired handler setters (like XML_SetElementHandler) - now have corresponding individual handler setters - o XML_GetInputContext for getting the input context of - the current parse position. - - Added reference material - - Packaged into a distribution that builds a sharable library diff -Nru gpick-0.2.4/extern/expat/README gpick-0.2.5/extern/expat/README --- gpick-0.2.4/extern/expat/README 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ - - Expat, Release 2.0.1 - -This is Expat, a C library for parsing XML, written by James Clark. -Expat is a stream-oriented XML parser. This means that you register -handlers with the parser before starting the parse. These handlers -are called when the parser discovers the associated structures in the -document being parsed. A start tag is an example of the kind of -structures for which you may register handlers. - -Windows users should use the expat_win32bin package, which includes -both precompiled libraries and executables, and source code for -developers. - -Expat is free software. You may copy, distribute, and modify it under -the terms of the License contained in the file COPYING distributed -with this package. This license is the same as the MIT/X Consortium -license. - -Versions of Expat that have an odd minor version (the middle number in -the release above), are development releases and should be considered -as beta software. Releases with even minor version numbers are -intended to be production grade software. - -If you are building Expat from a check-out from the CVS repository, -you need to run a script that generates the configure script using the -GNU autoconf and libtool tools. To do this, you need to have -autoconf 2.52 or newer and libtool 1.4 or newer (1.5 or newer preferred). -Run the script like this: - - ./buildconf.sh - -Once this has been done, follow the same instructions as for building -from a source distribution. - -To build Expat from a source distribution, you first run the -configuration shell script in the top level distribution directory: - - ./configure - -There are many options which you may provide to configure (which you -can discover by running configure with the --help option). But the -one of most interest is the one that sets the installation directory. -By default, the configure script will set things up to install -libexpat into /usr/local/lib, expat.h into /usr/local/include, and -xmlwf into /usr/local/bin. If, for example, you'd prefer to install -into /home/me/mystuff/lib, /home/me/mystuff/include, and -/home/me/mystuff/bin, you can tell configure about that with: - - ./configure --prefix=/home/me/mystuff - -Another interesting option is to enable 64-bit integer support for -line and column numbers and the over-all byte index: - - ./configure CPPFLAGS=-DXML_LARGE_SIZE - -However, such a modification would be a breaking change to the ABI -and is therefore not recommended for general use - e.g. as part of -a Linux distribution - but rather for builds with special requirements. - -After running the configure script, the "make" command will build -things and "make install" will install things into their proper -location. Have a look at the "Makefile" to learn about additional -"make" options. Note that you need to have write permission into -the directories into which things will be installed. - -If you are interested in building Expat to provide document -information in UTF-16 rather than the default UTF-8, follow these -instructions (after having run "make distclean"): - - 1. For UTF-16 output as unsigned short (and version/error - strings as char), run: - - ./configure CPPFLAGS=-DXML_UNICODE - - For UTF-16 output as wchar_t (incl. version/error strings), - run: - - ./configure CFLAGS="-g -O2 -fshort-wchar" \ - CPPFLAGS=-DXML_UNICODE_WCHAR_T - - 2. Edit the MakeFile, changing: - - LIBRARY = libexpat.la - - to: - - LIBRARY = libexpatw.la - - (Note the additional "w" in the library name.) - - 3. Run "make buildlib" (which builds the library only). - Or, to save step 2, run "make buildlib LIBRARY=libexpatw.la". - - 4. Run "make installlib" (which installs the library only). - Or, if step 2 was omitted, run "make installlib LIBRARY=libexpatw.la". - -Using DESTDIR or INSTALL_ROOT is enabled, with INSTALL_ROOT being the default -value for DESTDIR, and the rest of the make file using only DESTDIR. -It works as follows: - $ make install DESTDIR=/path/to/image -overrides the in-makefile set DESTDIR, while both - $ INSTALL_ROOT=/path/to/image make install - $ make install INSTALL_ROOT=/path/to/image -use DESTDIR=$(INSTALL_ROOT), even if DESTDIR eventually is defined in the -environment, because variable-setting priority is -1) commandline -2) in-makefile -3) environment - -Note for Solaris users: The "ar" command is usually located in -"/usr/ccs/bin", which is not in the default PATH. You will need to -add this to your path for the "make" command, and probably also switch -to GNU make (the "make" found in /usr/ccs/bin does not seem to work -properly -- appearantly it does not understand .PHONY directives). If -you're using ksh or bash, use this command to build: - - PATH=/usr/ccs/bin:$PATH make - -When using Expat with a project using autoconf for configuration, you -can use the probing macro in conftools/expat.m4 to determine how to -include Expat. See the comments at the top of that file for more -information. - -A reference manual is available in the file doc/reference.html in this -distribution. - -The homepage for this project is http://www.libexpat.org/. There -are links there to connect you to the bug reports page. If you need -to report a bug when you don't have access to a browser, you may also -send a bug report by email to expat-bugs@mail.libexpat.org. - -Discussion related to the direction of future expat development takes -place on expat-discuss@mail.libexpat.org. Archives of this list and -other Expat-related lists may be found at: - - http://mail.libexpat.org/mailman/listinfo/ diff -Nru gpick-0.2.4/extern/expat/SConscript gpick-0.2.5/extern/expat/SConscript --- gpick-0.2.4/extern/expat/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/SConscript 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -from tools.gpick import * - -Import('*') -local_env = env.Clone() - -local_env.Append ( - CPPDEFINES = ['HAVE_EXPAT_CONFIG_H'], - CPPPATH = ['.'] - ) - -sources = local_env.Glob('lib/*.c') - -executable = local_env.StaticLibrary( - 'expat', - source = [sources]) - -library = GpickLibrary(executable); -library.include_dirs = ['#extern/expat/lib'] -env.DefineLibrary('expat', library) - -Return('executable') diff -Nru gpick-0.2.4/extern/expat/expat_config.h gpick-0.2.5/extern/expat/expat_config.h --- gpick-0.2.4/extern/expat/expat_config.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/expat_config.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -/* expat_config.h. Generated by configure. */ -/* expat_config.h.in. Generated from configure.in by autoheader. */ - -/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ -#define BYTEORDER 1234 - -/* Define to 1 if you have the `bcopy' function. */ -#define HAVE_BCOPY 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "expat-bugs@libexpat.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "expat" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "expat 2.0.1" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "expat" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "2.0.1" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* whether byteorder is bigendian */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to specify how much context to retain around the current parse - point. */ -#define XML_CONTEXT_BYTES 1024 - -/* Define to make parameter entity parsing functionality available. */ -#define XML_DTD 0 - -/* Define to make XML Namespaces functionality available. */ -#define XML_NS 0 - -/* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */ -/* #undef __func__ */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `long' if does not define. */ -/* #undef off_t */ - -/* Define to `unsigned' if does not define. */ -/* #undef size_t */ diff -Nru gpick-0.2.4/extern/expat/expat_config.h.in gpick-0.2.5/extern/expat/expat_config.h.in --- gpick-0.2.4/extern/expat/expat_config.h.in 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/expat_config.h.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -/* expat_config.h.in. Generated from configure.in by autoheader. */ - -/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ -#undef BYTEORDER - -/* Define to 1 if you have the `bcopy' function. */ -#undef HAVE_BCOPY - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `getpagesize' function. */ -#undef HAVE_GETPAGESIZE - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `memmove' function. */ -#undef HAVE_MEMMOVE - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* whether byteorder is bigendian */ -#undef WORDS_BIGENDIAN - -/* Define to specify how much context to retain around the current parse - point. */ -#undef XML_CONTEXT_BYTES - -/* Define to make parameter entity parsing functionality available. */ -#undef XML_DTD - -/* Define to make XML Namespaces functionality available. */ -#undef XML_NS - -/* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */ -#undef __func__ - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `long' if does not define. */ -#undef off_t - -/* Define to `unsigned' if does not define. */ -#undef size_t diff -Nru gpick-0.2.4/extern/expat/lib/amigaconfig.h gpick-0.2.5/extern/expat/lib/amigaconfig.h --- gpick-0.2.4/extern/expat/lib/amigaconfig.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/amigaconfig.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -#ifndef AMIGACONFIG_H -#define AMIGACONFIG_H - -/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ -#define BYTEORDER 4321 - -/* Define to 1 if you have the `bcopy' function. */ -#define HAVE_BCOPY 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_CHECK_H - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* whether byteorder is bigendian */ -#define WORDS_BIGENDIAN - -/* Define to specify how much context to retain around the current parse - point. */ -#define XML_CONTEXT_BYTES 1024 - -/* Define to make parameter entity parsing functionality available. */ -#define XML_DTD - -/* Define to make XML Namespaces functionality available. */ -#define XML_NS - -#endif /* AMIGACONFIG_H */ diff -Nru gpick-0.2.4/extern/expat/lib/ascii.h gpick-0.2.5/extern/expat/lib/ascii.h --- gpick-0.2.4/extern/expat/lib/ascii.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/ascii.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#define ASCII_A 0x41 -#define ASCII_B 0x42 -#define ASCII_C 0x43 -#define ASCII_D 0x44 -#define ASCII_E 0x45 -#define ASCII_F 0x46 -#define ASCII_G 0x47 -#define ASCII_H 0x48 -#define ASCII_I 0x49 -#define ASCII_J 0x4A -#define ASCII_K 0x4B -#define ASCII_L 0x4C -#define ASCII_M 0x4D -#define ASCII_N 0x4E -#define ASCII_O 0x4F -#define ASCII_P 0x50 -#define ASCII_Q 0x51 -#define ASCII_R 0x52 -#define ASCII_S 0x53 -#define ASCII_T 0x54 -#define ASCII_U 0x55 -#define ASCII_V 0x56 -#define ASCII_W 0x57 -#define ASCII_X 0x58 -#define ASCII_Y 0x59 -#define ASCII_Z 0x5A - -#define ASCII_a 0x61 -#define ASCII_b 0x62 -#define ASCII_c 0x63 -#define ASCII_d 0x64 -#define ASCII_e 0x65 -#define ASCII_f 0x66 -#define ASCII_g 0x67 -#define ASCII_h 0x68 -#define ASCII_i 0x69 -#define ASCII_j 0x6A -#define ASCII_k 0x6B -#define ASCII_l 0x6C -#define ASCII_m 0x6D -#define ASCII_n 0x6E -#define ASCII_o 0x6F -#define ASCII_p 0x70 -#define ASCII_q 0x71 -#define ASCII_r 0x72 -#define ASCII_s 0x73 -#define ASCII_t 0x74 -#define ASCII_u 0x75 -#define ASCII_v 0x76 -#define ASCII_w 0x77 -#define ASCII_x 0x78 -#define ASCII_y 0x79 -#define ASCII_z 0x7A - -#define ASCII_0 0x30 -#define ASCII_1 0x31 -#define ASCII_2 0x32 -#define ASCII_3 0x33 -#define ASCII_4 0x34 -#define ASCII_5 0x35 -#define ASCII_6 0x36 -#define ASCII_7 0x37 -#define ASCII_8 0x38 -#define ASCII_9 0x39 - -#define ASCII_TAB 0x09 -#define ASCII_SPACE 0x20 -#define ASCII_EXCL 0x21 -#define ASCII_QUOT 0x22 -#define ASCII_AMP 0x26 -#define ASCII_APOS 0x27 -#define ASCII_MINUS 0x2D -#define ASCII_PERIOD 0x2E -#define ASCII_COLON 0x3A -#define ASCII_SEMI 0x3B -#define ASCII_LT 0x3C -#define ASCII_EQUALS 0x3D -#define ASCII_GT 0x3E -#define ASCII_LSQB 0x5B -#define ASCII_RSQB 0x5D -#define ASCII_UNDERSCORE 0x5F -#define ASCII_LPAREN 0x28 -#define ASCII_RPAREN 0x29 -#define ASCII_FF 0x0C -#define ASCII_SLASH 0x2F -#define ASCII_HASH 0x23 -#define ASCII_PIPE 0x7C -#define ASCII_COMMA 0x2C diff -Nru gpick-0.2.4/extern/expat/lib/asciitab.h gpick-0.2.5/extern/expat/lib/asciitab.h --- gpick-0.2.4/extern/expat/lib/asciitab.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/asciitab.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, -/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML, -/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, -/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, -/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, -/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, -/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, -/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, -/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, -/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, -/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, diff -Nru gpick-0.2.4/extern/expat/lib/expat.h gpick-0.2.5/extern/expat/lib/expat.h --- gpick-0.2.4/extern/expat/lib/expat.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/expat.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,1014 +0,0 @@ -/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifndef Expat_INCLUDED -#define Expat_INCLUDED 1 - -#ifdef __VMS -/* 0 1 2 3 0 1 2 3 - 1234567890123456789012345678901 1234567890123456789012345678901 */ -#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler -#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler -#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler -#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg -#endif - -#include -#include "expat_external.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct XML_ParserStruct; -typedef struct XML_ParserStruct *XML_Parser; - -/* Should this be defined using stdbool.h when C99 is available? */ -typedef unsigned char XML_Bool; -#define XML_TRUE ((XML_Bool) 1) -#define XML_FALSE ((XML_Bool) 0) - -/* The XML_Status enum gives the possible return values for several - API functions. The preprocessor #defines are included so this - stanza can be added to code that still needs to support older - versions of Expat 1.95.x: - - #ifndef XML_STATUS_OK - #define XML_STATUS_OK 1 - #define XML_STATUS_ERROR 0 - #endif - - Otherwise, the #define hackery is quite ugly and would have been - dropped. -*/ -enum XML_Status { - XML_STATUS_ERROR = 0, -#define XML_STATUS_ERROR XML_STATUS_ERROR - XML_STATUS_OK = 1, -#define XML_STATUS_OK XML_STATUS_OK - XML_STATUS_SUSPENDED = 2 -#define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED -}; - -enum XML_Error { - XML_ERROR_NONE, - XML_ERROR_NO_MEMORY, - XML_ERROR_SYNTAX, - XML_ERROR_NO_ELEMENTS, - XML_ERROR_INVALID_TOKEN, - XML_ERROR_UNCLOSED_TOKEN, - XML_ERROR_PARTIAL_CHAR, - XML_ERROR_TAG_MISMATCH, - XML_ERROR_DUPLICATE_ATTRIBUTE, - XML_ERROR_JUNK_AFTER_DOC_ELEMENT, - XML_ERROR_PARAM_ENTITY_REF, - XML_ERROR_UNDEFINED_ENTITY, - XML_ERROR_RECURSIVE_ENTITY_REF, - XML_ERROR_ASYNC_ENTITY, - XML_ERROR_BAD_CHAR_REF, - XML_ERROR_BINARY_ENTITY_REF, - XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, - XML_ERROR_MISPLACED_XML_PI, - XML_ERROR_UNKNOWN_ENCODING, - XML_ERROR_INCORRECT_ENCODING, - XML_ERROR_UNCLOSED_CDATA_SECTION, - XML_ERROR_EXTERNAL_ENTITY_HANDLING, - XML_ERROR_NOT_STANDALONE, - XML_ERROR_UNEXPECTED_STATE, - XML_ERROR_ENTITY_DECLARED_IN_PE, - XML_ERROR_FEATURE_REQUIRES_XML_DTD, - XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, - /* Added in 1.95.7. */ - XML_ERROR_UNBOUND_PREFIX, - /* Added in 1.95.8. */ - XML_ERROR_UNDECLARING_PREFIX, - XML_ERROR_INCOMPLETE_PE, - XML_ERROR_XML_DECL, - XML_ERROR_TEXT_DECL, - XML_ERROR_PUBLICID, - XML_ERROR_SUSPENDED, - XML_ERROR_NOT_SUSPENDED, - XML_ERROR_ABORTED, - XML_ERROR_FINISHED, - XML_ERROR_SUSPEND_PE, - /* Added in 2.0. */ - XML_ERROR_RESERVED_PREFIX_XML, - XML_ERROR_RESERVED_PREFIX_XMLNS, - XML_ERROR_RESERVED_NAMESPACE_URI -}; - -enum XML_Content_Type { - XML_CTYPE_EMPTY = 1, - XML_CTYPE_ANY, - XML_CTYPE_MIXED, - XML_CTYPE_NAME, - XML_CTYPE_CHOICE, - XML_CTYPE_SEQ -}; - -enum XML_Content_Quant { - XML_CQUANT_NONE, - XML_CQUANT_OPT, - XML_CQUANT_REP, - XML_CQUANT_PLUS -}; - -/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be - XML_CQUANT_NONE, and the other fields will be zero or NULL. - If type == XML_CTYPE_MIXED, then quant will be NONE or REP and - numchildren will contain number of elements that may be mixed in - and children point to an array of XML_Content cells that will be - all of XML_CTYPE_NAME type with no quantification. - - If type == XML_CTYPE_NAME, then the name points to the name, and - the numchildren field will be zero and children will be NULL. The - quant fields indicates any quantifiers placed on the name. - - CHOICE and SEQ will have name NULL, the number of children in - numchildren and children will point, recursively, to an array - of XML_Content cells. - - The EMPTY, ANY, and MIXED types will only occur at top level. -*/ - -typedef struct XML_cp XML_Content; - -struct XML_cp { - enum XML_Content_Type type; - enum XML_Content_Quant quant; - XML_Char * name; - unsigned int numchildren; - XML_Content * children; -}; - - -/* This is called for an element declaration. See above for - description of the model argument. It's the caller's responsibility - to free model when finished with it. -*/ -typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData, - const XML_Char *name, - XML_Content *model); - -XMLPARSEAPI(void) -XML_SetElementDeclHandler(XML_Parser parser, - XML_ElementDeclHandler eldecl); - -/* The Attlist declaration handler is called for *each* attribute. So - a single Attlist declaration with multiple attributes declared will - generate multiple calls to this handler. The "default" parameter - may be NULL in the case of the "#IMPLIED" or "#REQUIRED" - keyword. The "isrequired" parameter will be true and the default - value will be NULL in the case of "#REQUIRED". If "isrequired" is - true and default is non-NULL, then this is a "#FIXED" default. -*/ -typedef void (XMLCALL *XML_AttlistDeclHandler) ( - void *userData, - const XML_Char *elname, - const XML_Char *attname, - const XML_Char *att_type, - const XML_Char *dflt, - int isrequired); - -XMLPARSEAPI(void) -XML_SetAttlistDeclHandler(XML_Parser parser, - XML_AttlistDeclHandler attdecl); - -/* The XML declaration handler is called for *both* XML declarations - and text declarations. The way to distinguish is that the version - parameter will be NULL for text declarations. The encoding - parameter may be NULL for XML declarations. The standalone - parameter will be -1, 0, or 1 indicating respectively that there - was no standalone parameter in the declaration, that it was given - as no, or that it was given as yes. -*/ -typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData, - const XML_Char *version, - const XML_Char *encoding, - int standalone); - -XMLPARSEAPI(void) -XML_SetXmlDeclHandler(XML_Parser parser, - XML_XmlDeclHandler xmldecl); - - -typedef struct { - void *(*malloc_fcn)(size_t size); - void *(*realloc_fcn)(void *ptr, size_t size); - void (*free_fcn)(void *ptr); -} XML_Memory_Handling_Suite; - -/* Constructs a new parser; encoding is the encoding specified by the - external protocol or NULL if there is none specified. -*/ -XMLPARSEAPI(XML_Parser) -XML_ParserCreate(const XML_Char *encoding); - -/* Constructs a new parser and namespace processor. Element type - names and attribute names that belong to a namespace will be - expanded; unprefixed attribute names are never expanded; unprefixed - element type names are expanded only if there is a default - namespace. The expanded name is the concatenation of the namespace - URI, the namespace separator character, and the local part of the - name. If the namespace separator is '\0' then the namespace URI - and the local part will be concatenated without any separator. - It is a programming error to use the separator '\0' with namespace - triplets (see XML_SetReturnNSTriplet). -*/ -XMLPARSEAPI(XML_Parser) -XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); - - -/* Constructs a new parser using the memory management suite referred to - by memsuite. If memsuite is NULL, then use the standard library memory - suite. If namespaceSeparator is non-NULL it creates a parser with - namespace processing as described above. The character pointed at - will serve as the namespace separator. - - All further memory operations used for the created parser will come from - the given suite. -*/ -XMLPARSEAPI(XML_Parser) -XML_ParserCreate_MM(const XML_Char *encoding, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *namespaceSeparator); - -/* Prepare a parser object to be re-used. This is particularly - valuable when memory allocation overhead is disproportionatly high, - such as when a large number of small documnents need to be parsed. - All handlers are cleared from the parser, except for the - unknownEncodingHandler. The parser's external state is re-initialized - except for the values of ns and ns_triplets. - - Added in Expat 1.95.3. -*/ -XMLPARSEAPI(XML_Bool) -XML_ParserReset(XML_Parser parser, const XML_Char *encoding); - -/* atts is array of name/value pairs, terminated by 0; - names and values are 0 terminated. -*/ -typedef void (XMLCALL *XML_StartElementHandler) (void *userData, - const XML_Char *name, - const XML_Char **atts); - -typedef void (XMLCALL *XML_EndElementHandler) (void *userData, - const XML_Char *name); - - -/* s is not 0 terminated. */ -typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData, - const XML_Char *s, - int len); - -/* target and data are 0 terminated */ -typedef void (XMLCALL *XML_ProcessingInstructionHandler) ( - void *userData, - const XML_Char *target, - const XML_Char *data); - -/* data is 0 terminated */ -typedef void (XMLCALL *XML_CommentHandler) (void *userData, - const XML_Char *data); - -typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData); -typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData); - -/* This is called for any characters in the XML document for which - there is no applicable handler. This includes both characters that - are part of markup which is of a kind that is not reported - (comments, markup declarations), or characters that are part of a - construct which could be reported but for which no handler has been - supplied. The characters are passed exactly as they were in the XML - document except that they will be encoded in UTF-8 or UTF-16. - Line boundaries are not normalized. Note that a byte order mark - character is not passed to the default handler. There are no - guarantees about how characters are divided between calls to the - default handler: for example, a comment might be split between - multiple calls. -*/ -typedef void (XMLCALL *XML_DefaultHandler) (void *userData, - const XML_Char *s, - int len); - -/* This is called for the start of the DOCTYPE declaration, before - any DTD or internal subset is parsed. -*/ -typedef void (XMLCALL *XML_StartDoctypeDeclHandler) ( - void *userData, - const XML_Char *doctypeName, - const XML_Char *sysid, - const XML_Char *pubid, - int has_internal_subset); - -/* This is called for the start of the DOCTYPE declaration when the - closing > is encountered, but after processing any external - subset. -*/ -typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); - -/* This is called for entity declarations. The is_parameter_entity - argument will be non-zero if the entity is a parameter entity, zero - otherwise. - - For internal entities (), value will - be non-NULL and systemId, publicID, and notationName will be NULL. - The value string is NOT nul-terminated; the length is provided in - the value_length argument. Since it is legal to have zero-length - values, do not use this argument to test for internal entities. - - For external entities, value will be NULL and systemId will be - non-NULL. The publicId argument will be NULL unless a public - identifier was provided. The notationName argument will have a - non-NULL value only for unparsed entity declarations. - - Note that is_parameter_entity can't be changed to XML_Bool, since - that would break binary compatibility. -*/ -typedef void (XMLCALL *XML_EntityDeclHandler) ( - void *userData, - const XML_Char *entityName, - int is_parameter_entity, - const XML_Char *value, - int value_length, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); - -XMLPARSEAPI(void) -XML_SetEntityDeclHandler(XML_Parser parser, - XML_EntityDeclHandler handler); - -/* OBSOLETE -- OBSOLETE -- OBSOLETE - This handler has been superceded by the EntityDeclHandler above. - It is provided here for backward compatibility. - - This is called for a declaration of an unparsed (NDATA) entity. - The base argument is whatever was set by XML_SetBase. The - entityName, systemId and notationName arguments will never be - NULL. The other arguments may be. -*/ -typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) ( - void *userData, - const XML_Char *entityName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); - -/* This is called for a declaration of notation. The base argument is - whatever was set by XML_SetBase. The notationName will never be - NULL. The other arguments can be. -*/ -typedef void (XMLCALL *XML_NotationDeclHandler) ( - void *userData, - const XML_Char *notationName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); - -/* When namespace processing is enabled, these are called once for - each namespace declaration. The call to the start and end element - handlers occur between the calls to the start and end namespace - declaration handlers. For an xmlns attribute, prefix will be - NULL. For an xmlns="" attribute, uri will be NULL. -*/ -typedef void (XMLCALL *XML_StartNamespaceDeclHandler) ( - void *userData, - const XML_Char *prefix, - const XML_Char *uri); - -typedef void (XMLCALL *XML_EndNamespaceDeclHandler) ( - void *userData, - const XML_Char *prefix); - -/* This is called if the document is not standalone, that is, it has an - external subset or a reference to a parameter entity, but does not - have standalone="yes". If this handler returns XML_STATUS_ERROR, - then processing will not continue, and the parser will return a - XML_ERROR_NOT_STANDALONE error. - If parameter entity parsing is enabled, then in addition to the - conditions above this handler will only be called if the referenced - entity was actually read. -*/ -typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData); - -/* This is called for a reference to an external parsed general - entity. The referenced entity is not automatically parsed. The - application can parse it immediately or later using - XML_ExternalEntityParserCreate. - - The parser argument is the parser parsing the entity containing the - reference; it can be passed as the parser argument to - XML_ExternalEntityParserCreate. The systemId argument is the - system identifier as specified in the entity declaration; it will - not be NULL. - - The base argument is the system identifier that should be used as - the base for resolving systemId if systemId was relative; this is - set by XML_SetBase; it may be NULL. - - The publicId argument is the public identifier as specified in the - entity declaration, or NULL if none was specified; the whitespace - in the public identifier will have been normalized as required by - the XML spec. - - The context argument specifies the parsing context in the format - expected by the context argument to XML_ExternalEntityParserCreate; - context is valid only until the handler returns, so if the - referenced entity is to be parsed later, it must be copied. - context is NULL only when the entity is a parameter entity. - - The handler should return XML_STATUS_ERROR if processing should not - continue because of a fatal error in the handling of the external - entity. In this case the calling parser will return an - XML_ERROR_EXTERNAL_ENTITY_HANDLING error. - - Note that unlike other handlers the first argument is the parser, - not userData. -*/ -typedef int (XMLCALL *XML_ExternalEntityRefHandler) ( - XML_Parser parser, - const XML_Char *context, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); - -/* This is called in two situations: - 1) An entity reference is encountered for which no declaration - has been read *and* this is not an error. - 2) An internal entity reference is read, but not expanded, because - XML_SetDefaultHandler has been called. - Note: skipped parameter entities in declarations and skipped general - entities in attribute values cannot be reported, because - the event would be out of sync with the reporting of the - declarations or attribute values -*/ -typedef void (XMLCALL *XML_SkippedEntityHandler) ( - void *userData, - const XML_Char *entityName, - int is_parameter_entity); - -/* This structure is filled in by the XML_UnknownEncodingHandler to - provide information to the parser about encodings that are unknown - to the parser. - - The map[b] member gives information about byte sequences whose - first byte is b. - - If map[b] is c where c is >= 0, then b by itself encodes the - Unicode scalar value c. - - If map[b] is -1, then the byte sequence is malformed. - - If map[b] is -n, where n >= 2, then b is the first byte of an - n-byte sequence that encodes a single Unicode scalar value. - - The data member will be passed as the first argument to the convert - function. - - The convert function is used to convert multibyte sequences; s will - point to a n-byte sequence where map[(unsigned char)*s] == -n. The - convert function must return the Unicode scalar value represented - by this byte sequence or -1 if the byte sequence is malformed. - - The convert function may be NULL if the encoding is a single-byte - encoding, that is if map[b] >= -1 for all bytes b. - - When the parser is finished with the encoding, then if release is - not NULL, it will call release passing it the data member; once - release has been called, the convert function will not be called - again. - - Expat places certain restrictions on the encodings that are supported - using this mechanism. - - 1. Every ASCII character that can appear in a well-formed XML document, - other than the characters - - $@\^`{}~ - - must be represented by a single byte, and that byte must be the - same byte that represents that character in ASCII. - - 2. No character may require more than 4 bytes to encode. - - 3. All characters encoded must have Unicode scalar values <= - 0xFFFF, (i.e., characters that would be encoded by surrogates in - UTF-16 are not allowed). Note that this restriction doesn't - apply to the built-in support for UTF-8 and UTF-16. - - 4. No Unicode character may be encoded by more than one distinct - sequence of bytes. -*/ -typedef struct { - int map[256]; - void *data; - int (XMLCALL *convert)(void *data, const char *s); - void (XMLCALL *release)(void *data); -} XML_Encoding; - -/* This is called for an encoding that is unknown to the parser. - - The encodingHandlerData argument is that which was passed as the - second argument to XML_SetUnknownEncodingHandler. - - The name argument gives the name of the encoding as specified in - the encoding declaration. - - If the callback can provide information about the encoding, it must - fill in the XML_Encoding structure, and return XML_STATUS_OK. - Otherwise it must return XML_STATUS_ERROR. - - If info does not describe a suitable encoding, then the parser will - return an XML_UNKNOWN_ENCODING error. -*/ -typedef int (XMLCALL *XML_UnknownEncodingHandler) ( - void *encodingHandlerData, - const XML_Char *name, - XML_Encoding *info); - -XMLPARSEAPI(void) -XML_SetElementHandler(XML_Parser parser, - XML_StartElementHandler start, - XML_EndElementHandler end); - -XMLPARSEAPI(void) -XML_SetStartElementHandler(XML_Parser parser, - XML_StartElementHandler handler); - -XMLPARSEAPI(void) -XML_SetEndElementHandler(XML_Parser parser, - XML_EndElementHandler handler); - -XMLPARSEAPI(void) -XML_SetCharacterDataHandler(XML_Parser parser, - XML_CharacterDataHandler handler); - -XMLPARSEAPI(void) -XML_SetProcessingInstructionHandler(XML_Parser parser, - XML_ProcessingInstructionHandler handler); -XMLPARSEAPI(void) -XML_SetCommentHandler(XML_Parser parser, - XML_CommentHandler handler); - -XMLPARSEAPI(void) -XML_SetCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start, - XML_EndCdataSectionHandler end); - -XMLPARSEAPI(void) -XML_SetStartCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start); - -XMLPARSEAPI(void) -XML_SetEndCdataSectionHandler(XML_Parser parser, - XML_EndCdataSectionHandler end); - -/* This sets the default handler and also inhibits expansion of - internal entities. These entity references will be passed to the - default handler, or to the skipped entity handler, if one is set. -*/ -XMLPARSEAPI(void) -XML_SetDefaultHandler(XML_Parser parser, - XML_DefaultHandler handler); - -/* This sets the default handler but does not inhibit expansion of - internal entities. The entity reference will not be passed to the - default handler. -*/ -XMLPARSEAPI(void) -XML_SetDefaultHandlerExpand(XML_Parser parser, - XML_DefaultHandler handler); - -XMLPARSEAPI(void) -XML_SetDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start, - XML_EndDoctypeDeclHandler end); - -XMLPARSEAPI(void) -XML_SetStartDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start); - -XMLPARSEAPI(void) -XML_SetEndDoctypeDeclHandler(XML_Parser parser, - XML_EndDoctypeDeclHandler end); - -XMLPARSEAPI(void) -XML_SetUnparsedEntityDeclHandler(XML_Parser parser, - XML_UnparsedEntityDeclHandler handler); - -XMLPARSEAPI(void) -XML_SetNotationDeclHandler(XML_Parser parser, - XML_NotationDeclHandler handler); - -XMLPARSEAPI(void) -XML_SetNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start, - XML_EndNamespaceDeclHandler end); - -XMLPARSEAPI(void) -XML_SetStartNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start); - -XMLPARSEAPI(void) -XML_SetEndNamespaceDeclHandler(XML_Parser parser, - XML_EndNamespaceDeclHandler end); - -XMLPARSEAPI(void) -XML_SetNotStandaloneHandler(XML_Parser parser, - XML_NotStandaloneHandler handler); - -XMLPARSEAPI(void) -XML_SetExternalEntityRefHandler(XML_Parser parser, - XML_ExternalEntityRefHandler handler); - -/* If a non-NULL value for arg is specified here, then it will be - passed as the first argument to the external entity ref handler - instead of the parser object. -*/ -XMLPARSEAPI(void) -XML_SetExternalEntityRefHandlerArg(XML_Parser parser, - void *arg); - -XMLPARSEAPI(void) -XML_SetSkippedEntityHandler(XML_Parser parser, - XML_SkippedEntityHandler handler); - -XMLPARSEAPI(void) -XML_SetUnknownEncodingHandler(XML_Parser parser, - XML_UnknownEncodingHandler handler, - void *encodingHandlerData); - -/* This can be called within a handler for a start element, end - element, processing instruction or character data. It causes the - corresponding markup to be passed to the default handler. -*/ -XMLPARSEAPI(void) -XML_DefaultCurrent(XML_Parser parser); - -/* If do_nst is non-zero, and namespace processing is in effect, and - a name has a prefix (i.e. an explicit namespace qualifier) then - that name is returned as a triplet in a single string separated by - the separator character specified when the parser was created: URI - + sep + local_name + sep + prefix. - - If do_nst is zero, then namespace information is returned in the - default manner (URI + sep + local_name) whether or not the name - has a prefix. - - Note: Calling XML_SetReturnNSTriplet after XML_Parse or - XML_ParseBuffer has no effect. -*/ - -XMLPARSEAPI(void) -XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); - -/* This value is passed as the userData argument to callbacks. */ -XMLPARSEAPI(void) -XML_SetUserData(XML_Parser parser, void *userData); - -/* Returns the last value set by XML_SetUserData or NULL. */ -#define XML_GetUserData(parser) (*(void **)(parser)) - -/* This is equivalent to supplying an encoding argument to - XML_ParserCreate. On success XML_SetEncoding returns non-zero, - zero otherwise. - Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer - has no effect and returns XML_STATUS_ERROR. -*/ -XMLPARSEAPI(enum XML_Status) -XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); - -/* If this function is called, then the parser will be passed as the - first argument to callbacks instead of userData. The userData will - still be accessible using XML_GetUserData. -*/ -XMLPARSEAPI(void) -XML_UseParserAsHandlerArg(XML_Parser parser); - -/* If useDTD == XML_TRUE is passed to this function, then the parser - will assume that there is an external subset, even if none is - specified in the document. In such a case the parser will call the - externalEntityRefHandler with a value of NULL for the systemId - argument (the publicId and context arguments will be NULL as well). - Note: For the purpose of checking WFC: Entity Declared, passing - useDTD == XML_TRUE will make the parser behave as if the document - had a DTD with an external subset. - Note: If this function is called, then this must be done before - the first call to XML_Parse or XML_ParseBuffer, since it will - have no effect after that. Returns - XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING. - Note: If the document does not have a DOCTYPE declaration at all, - then startDoctypeDeclHandler and endDoctypeDeclHandler will not - be called, despite an external subset being parsed. - Note: If XML_DTD is not defined when Expat is compiled, returns - XML_ERROR_FEATURE_REQUIRES_XML_DTD. -*/ -XMLPARSEAPI(enum XML_Error) -XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); - - -/* Sets the base to be used for resolving relative URIs in system - identifiers in declarations. Resolving relative identifiers is - left to the application: this value will be passed through as the - base argument to the XML_ExternalEntityRefHandler, - XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base - argument will be copied. Returns XML_STATUS_ERROR if out of memory, - XML_STATUS_OK otherwise. -*/ -XMLPARSEAPI(enum XML_Status) -XML_SetBase(XML_Parser parser, const XML_Char *base); - -XMLPARSEAPI(const XML_Char *) -XML_GetBase(XML_Parser parser); - -/* Returns the number of the attribute/value pairs passed in last call - to the XML_StartElementHandler that were specified in the start-tag - rather than defaulted. Each attribute/value pair counts as 2; thus - this correspondds to an index into the atts array passed to the - XML_StartElementHandler. -*/ -XMLPARSEAPI(int) -XML_GetSpecifiedAttributeCount(XML_Parser parser); - -/* Returns the index of the ID attribute passed in the last call to - XML_StartElementHandler, or -1 if there is no ID attribute. Each - attribute/value pair counts as 2; thus this correspondds to an - index into the atts array passed to the XML_StartElementHandler. -*/ -XMLPARSEAPI(int) -XML_GetIdAttributeIndex(XML_Parser parser); - -/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is - detected. The last call to XML_Parse must have isFinal true; len - may be zero for this call (or any other). - - Though the return values for these functions has always been - described as a Boolean value, the implementation, at least for the - 1.95.x series, has always returned exactly one of the XML_Status - values. -*/ -XMLPARSEAPI(enum XML_Status) -XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); - -XMLPARSEAPI(void *) -XML_GetBuffer(XML_Parser parser, int len); - -XMLPARSEAPI(enum XML_Status) -XML_ParseBuffer(XML_Parser parser, int len, int isFinal); - -/* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. - Must be called from within a call-back handler, except when aborting - (resumable = 0) an already suspended parser. Some call-backs may - still follow because they would otherwise get lost. Examples: - - endElementHandler() for empty elements when stopped in - startElementHandler(), - - endNameSpaceDeclHandler() when stopped in endElementHandler(), - and possibly others. - - Can be called from most handlers, including DTD related call-backs, - except when parsing an external parameter entity and resumable != 0. - Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. - Possible error codes: - - XML_ERROR_SUSPENDED: when suspending an already suspended parser. - - XML_ERROR_FINISHED: when the parser has already finished. - - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. - - When resumable != 0 (true) then parsing is suspended, that is, - XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. - Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer() - return XML_STATUS_ERROR with error code XML_ERROR_ABORTED. - - *Note*: - This will be applied to the current parser instance only, that is, if - there is a parent parser then it will continue parsing when the - externalEntityRefHandler() returns. It is up to the implementation of - the externalEntityRefHandler() to call XML_StopParser() on the parent - parser (recursively), if one wants to stop parsing altogether. - - When suspended, parsing can be resumed by calling XML_ResumeParser(). -*/ -XMLPARSEAPI(enum XML_Status) -XML_StopParser(XML_Parser parser, XML_Bool resumable); - -/* Resumes parsing after it has been suspended with XML_StopParser(). - Must not be called from within a handler call-back. Returns same - status codes as XML_Parse() or XML_ParseBuffer(). - Additional error code XML_ERROR_NOT_SUSPENDED possible. - - *Note*: - This must be called on the most deeply nested child parser instance - first, and on its parent parser only after the child parser has finished, - to be applied recursively until the document entity's parser is restarted. - That is, the parent parser will not resume by itself and it is up to the - application to call XML_ResumeParser() on it at the appropriate moment. -*/ -XMLPARSEAPI(enum XML_Status) -XML_ResumeParser(XML_Parser parser); - -enum XML_Parsing { - XML_INITIALIZED, - XML_PARSING, - XML_FINISHED, - XML_SUSPENDED -}; - -typedef struct { - enum XML_Parsing parsing; - XML_Bool finalBuffer; -} XML_ParsingStatus; - -/* Returns status of parser with respect to being initialized, parsing, - finished, or suspended and processing the final buffer. - XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus, - XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED -*/ -XMLPARSEAPI(void) -XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status); - -/* Creates an XML_Parser object that can parse an external general - entity; context is a '\0'-terminated string specifying the parse - context; encoding is a '\0'-terminated string giving the name of - the externally specified encoding, or NULL if there is no - externally specified encoding. The context string consists of a - sequence of tokens separated by formfeeds (\f); a token consisting - of a name specifies that the general entity of the name is open; a - token of the form prefix=uri specifies the namespace for a - particular prefix; a token of the form =uri specifies the default - namespace. This can be called at any point after the first call to - an ExternalEntityRefHandler so longer as the parser has not yet - been freed. The new parser is completely independent and may - safely be used in a separate thread. The handlers and userData are - initialized from the parser argument. Returns NULL if out of memory. - Otherwise returns a new XML_Parser object. -*/ -XMLPARSEAPI(XML_Parser) -XML_ExternalEntityParserCreate(XML_Parser parser, - const XML_Char *context, - const XML_Char *encoding); - -enum XML_ParamEntityParsing { - XML_PARAM_ENTITY_PARSING_NEVER, - XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, - XML_PARAM_ENTITY_PARSING_ALWAYS -}; - -/* Controls parsing of parameter entities (including the external DTD - subset). If parsing of parameter entities is enabled, then - references to external parameter entities (including the external - DTD subset) will be passed to the handler set with - XML_SetExternalEntityRefHandler. The context passed will be 0. - - Unlike external general entities, external parameter entities can - only be parsed synchronously. If the external parameter entity is - to be parsed, it must be parsed during the call to the external - entity ref handler: the complete sequence of - XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and - XML_ParserFree calls must be made during this call. After - XML_ExternalEntityParserCreate has been called to create the parser - for the external parameter entity (context must be 0 for this - call), it is illegal to make any calls on the old parser until - XML_ParserFree has been called on the newly created parser. - If the library has been compiled without support for parameter - entity parsing (ie without XML_DTD being defined), then - XML_SetParamEntityParsing will return 0 if parsing of parameter - entities is requested; otherwise it will return non-zero. - Note: If XML_SetParamEntityParsing is called after XML_Parse or - XML_ParseBuffer, then it has no effect and will always return 0. -*/ -XMLPARSEAPI(int) -XML_SetParamEntityParsing(XML_Parser parser, - enum XML_ParamEntityParsing parsing); - -/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then - XML_GetErrorCode returns information about the error. -*/ -XMLPARSEAPI(enum XML_Error) -XML_GetErrorCode(XML_Parser parser); - -/* These functions return information about the current parse - location. They may be called from any callback called to report - some parse event; in this case the location is the location of the - first of the sequence of characters that generated the event. When - called from callbacks generated by declarations in the document - prologue, the location identified isn't as neatly defined, but will - be within the relevant markup. When called outside of the callback - functions, the position indicated will be just past the last parse - event (regardless of whether there was an associated callback). - - They may also be called after returning from a call to XML_Parse - or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then - the location is the location of the character at which the error - was detected; otherwise the location is the location of the last - parse event, as described above. -*/ -XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); -XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); -XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser); - -/* Return the number of bytes in the current event. - Returns 0 if the event is in an internal entity. -*/ -XMLPARSEAPI(int) -XML_GetCurrentByteCount(XML_Parser parser); - -/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets - the integer pointed to by offset to the offset within this buffer - of the current parse position, and sets the integer pointed to by size - to the size of this buffer (the number of input bytes). Otherwise - returns a NULL pointer. Also returns a NULL pointer if a parse isn't - active. - - NOTE: The character pointer returned should not be used outside - the handler that makes the call. -*/ -XMLPARSEAPI(const char *) -XML_GetInputContext(XML_Parser parser, - int *offset, - int *size); - -/* For backwards compatibility with previous versions. */ -#define XML_GetErrorLineNumber XML_GetCurrentLineNumber -#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber -#define XML_GetErrorByteIndex XML_GetCurrentByteIndex - -/* Frees the content model passed to the element declaration handler */ -XMLPARSEAPI(void) -XML_FreeContentModel(XML_Parser parser, XML_Content *model); - -/* Exposing the memory handling functions used in Expat */ -XMLPARSEAPI(void *) -XML_MemMalloc(XML_Parser parser, size_t size); - -XMLPARSEAPI(void *) -XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); - -XMLPARSEAPI(void) -XML_MemFree(XML_Parser parser, void *ptr); - -/* Frees memory used by the parser. */ -XMLPARSEAPI(void) -XML_ParserFree(XML_Parser parser); - -/* Returns a string describing the error. */ -XMLPARSEAPI(const XML_LChar *) -XML_ErrorString(enum XML_Error code); - -/* Return a string containing the version number of this expat */ -XMLPARSEAPI(const XML_LChar *) -XML_ExpatVersion(void); - -typedef struct { - int major; - int minor; - int micro; -} XML_Expat_Version; - -/* Return an XML_Expat_Version structure containing numeric version - number information for this version of expat. -*/ -XMLPARSEAPI(XML_Expat_Version) -XML_ExpatVersionInfo(void); - -/* Added in Expat 1.95.5. */ -enum XML_FeatureEnum { - XML_FEATURE_END = 0, - XML_FEATURE_UNICODE, - XML_FEATURE_UNICODE_WCHAR_T, - XML_FEATURE_DTD, - XML_FEATURE_CONTEXT_BYTES, - XML_FEATURE_MIN_SIZE, - XML_FEATURE_SIZEOF_XML_CHAR, - XML_FEATURE_SIZEOF_XML_LCHAR, - XML_FEATURE_NS, - XML_FEATURE_LARGE_SIZE - /* Additional features must be added to the end of this enum. */ -}; - -typedef struct { - enum XML_FeatureEnum feature; - const XML_LChar *name; - long int value; -} XML_Feature; - -XMLPARSEAPI(const XML_Feature *) -XML_GetFeatureList(void); - - -/* Expat follows the GNU/Linux convention of odd number minor version for - beta/development releases and even number minor version for stable - releases. Micro is bumped with each release, and set to 0 with each - change to major or minor version. -*/ -#define XML_MAJOR_VERSION 2 -#define XML_MINOR_VERSION 0 -#define XML_MICRO_VERSION 1 - -#ifdef __cplusplus -} -#endif - -#endif /* not Expat_INCLUDED */ diff -Nru gpick-0.2.4/extern/expat/lib/expat_external.h gpick-0.2.5/extern/expat/lib/expat_external.h --- gpick-0.2.4/extern/expat/lib/expat_external.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/expat_external.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifndef Expat_External_INCLUDED -#define Expat_External_INCLUDED 1 - -/* External API definitions */ - -#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) -#define XML_USE_MSC_EXTENSIONS 1 -#endif - -/* Expat tries very hard to make the API boundary very specifically - defined. There are two macros defined to control this boundary; - each of these can be defined before including this header to - achieve some different behavior, but doing so it not recommended or - tested frequently. - - XMLCALL - The calling convention to use for all calls across the - "library boundary." This will default to cdecl, and - try really hard to tell the compiler that's what we - want. - - XMLIMPORT - Whatever magic is needed to note that a function is - to be imported from a dynamically loaded library - (.dll, .so, or .sl, depending on your platform). - - The XMLCALL macro was added in Expat 1.95.7. The only one which is - expected to be directly useful in client code is XMLCALL. - - Note that on at least some Unix versions, the Expat library must be - compiled with the cdecl calling convention as the default since - system headers may assume the cdecl convention. -*/ -#ifndef XMLCALL -#if defined(_MSC_VER) -#define XMLCALL __cdecl -#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER) -#define XMLCALL __attribute__((cdecl)) -#else -/* For any platform which uses this definition and supports more than - one calling convention, we need to extend this definition to - declare the convention used on that platform, if it's possible to - do so. - - If this is the case for your platform, please file a bug report - with information on how to identify your platform via the C - pre-processor and how to specify the same calling convention as the - platform's malloc() implementation. -*/ -#define XMLCALL -#endif -#endif /* not defined XMLCALL */ - - -#if !defined(XML_STATIC) && !defined(XMLIMPORT) -#ifndef XML_BUILDING_EXPAT -/* using Expat from an application */ - -#ifdef XML_USE_MSC_EXTENSIONS -#define XMLIMPORT __declspec(dllimport) -#endif - -#endif -#endif /* not defined XML_STATIC */ - - -/* If we didn't define it above, define it away: */ -#ifndef XMLIMPORT -#define XMLIMPORT -#endif - - -#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef XML_UNICODE_WCHAR_T -#define XML_UNICODE -#endif - -#ifdef XML_UNICODE /* Information is UTF-16 encoded. */ -#ifdef XML_UNICODE_WCHAR_T -typedef wchar_t XML_Char; -typedef wchar_t XML_LChar; -#else -typedef unsigned short XML_Char; -typedef char XML_LChar; -#endif /* XML_UNICODE_WCHAR_T */ -#else /* Information is UTF-8 encoded. */ -typedef char XML_Char; -typedef char XML_LChar; -#endif /* XML_UNICODE */ - -#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ -#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 -typedef __int64 XML_Index; -typedef unsigned __int64 XML_Size; -#else -typedef long long XML_Index; -typedef unsigned long long XML_Size; -#endif -#else -typedef long XML_Index; -typedef unsigned long XML_Size; -#endif /* XML_LARGE_SIZE */ - -#ifdef __cplusplus -} -#endif - -#endif /* not Expat_External_INCLUDED */ diff -Nru gpick-0.2.4/extern/expat/lib/iasciitab.h gpick-0.2.5/extern/expat/lib/iasciitab.h --- gpick-0.2.4/extern/expat/lib/iasciitab.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/iasciitab.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ -/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, -/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML, -/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, -/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, -/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, -/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, -/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, -/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, -/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, -/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, -/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, diff -Nru gpick-0.2.4/extern/expat/lib/internal.h gpick-0.2.5/extern/expat/lib/internal.h --- gpick-0.2.4/extern/expat/lib/internal.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/internal.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -/* internal.h - - Internal definitions used by Expat. This is not needed to compile - client code. - - The following calling convention macros are defined for frequently - called functions: - - FASTCALL - Used for those internal functions that have a simple - body and a low number of arguments and local variables. - - PTRCALL - Used for functions called though function pointers. - - PTRFASTCALL - Like PTRCALL, but for low number of arguments. - - inline - Used for selected internal functions for which inlining - may improve performance on some platforms. - - Note: Use of these macros is based on judgement, not hard rules, - and therefore subject to change. -*/ - -#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__) -/* We'll use this version by default only where we know it helps. - - regparm() generates warnings on Solaris boxes. See SF bug #692878. - - Instability reported with egcs on a RedHat Linux 7.3. - Let's comment out: - #define FASTCALL __attribute__((stdcall, regparm(3))) - and let's try this: -*/ -#define FASTCALL __attribute__((regparm(3))) -#define PTRFASTCALL __attribute__((regparm(3))) -#endif - -/* Using __fastcall seems to have an unexpected negative effect under - MS VC++, especially for function pointers, so we won't use it for - now on that platform. It may be reconsidered for a future release - if it can be made more effective. - Likely reason: __fastcall on Windows is like stdcall, therefore - the compiler cannot perform stack optimizations for call clusters. -*/ - -/* Make sure all of these are defined if they aren't already. */ - -#ifndef FASTCALL -#define FASTCALL -#endif - -#ifndef PTRCALL -#define PTRCALL -#endif - -#ifndef PTRFASTCALL -#define PTRFASTCALL -#endif - -#ifndef XML_MIN_SIZE -#if !defined(__cplusplus) && !defined(inline) -#ifdef __GNUC__ -#define inline __inline -#endif /* __GNUC__ */ -#endif -#endif /* XML_MIN_SIZE */ - -#ifdef __cplusplus -#define inline inline -#else -#ifndef inline -#define inline -#endif -#endif diff -Nru gpick-0.2.4/extern/expat/lib/latin1tab.h gpick-0.2.5/extern/expat/lib/latin1tab.h --- gpick-0.2.4/extern/expat/lib/latin1tab.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/latin1tab.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, -/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME, -/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, -/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, diff -Nru gpick-0.2.4/extern/expat/lib/macconfig.h gpick-0.2.5/extern/expat/lib/macconfig.h --- gpick-0.2.4/extern/expat/lib/macconfig.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/macconfig.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/*================================================================ -** Copyright 2000, Clark Cooper -** All rights reserved. -** -** This is free software. You are permitted to copy, distribute, or modify -** it under the terms of the MIT/X license (contained in the COPYING file -** with this distribution.) -** -*/ - -#ifndef MACCONFIG_H -#define MACCONFIG_H - - -/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ -#define BYTEORDER 4321 - -/* Define to 1 if you have the `bcopy' function. */ -#undef HAVE_BCOPY - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE - -/* Define to 1 if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* whether byteorder is bigendian */ -#define WORDS_BIGENDIAN - -/* Define to specify how much context to retain around the current parse - point. */ -#undef XML_CONTEXT_BYTES - -/* Define to make parameter entity parsing functionality available. */ -#define XML_DTD - -/* Define to make XML Namespaces functionality available. */ -#define XML_NS - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `long' if does not define. */ -#define off_t long - -/* Define to `unsigned' if does not define. */ -#undef size_t - - -#endif /* ifndef MACCONFIG_H */ diff -Nru gpick-0.2.4/extern/expat/lib/nametab.h gpick-0.2.5/extern/expat/lib/nametab.h --- gpick-0.2.4/extern/expat/lib/nametab.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/nametab.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -static const unsigned namingBitmap[] = { -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE, -0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF, -0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF, -0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, -0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, -0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, -0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, -0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, -0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, -0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000, -0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060, -0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, -0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003, -0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000, -0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, -0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003, -0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000, -0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, -0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003, -0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000, -0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000, -0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, -0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB, -0x40000000, 0xF580C900, 0x00000007, 0x02010800, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF, -0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF, -0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, -0x00000000, 0x00004C40, 0x00000000, 0x00000000, -0x00000007, 0x00000000, 0x00000000, 0x00000000, -0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, -0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF, -0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000, -0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE, -0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, -0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, -0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, -0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, -0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, -0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, -0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, -0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF, -0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, -0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF, -0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF, -0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, -0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0, -0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1, -0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, -0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80, -0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3, -0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, -0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, -0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000, -0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF, -0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x1FFF0000, 0x00000002, -0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, -0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF, -}; -static const unsigned char nmstrtPages[] = { -0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, -0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, -0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, -0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -static const unsigned char namePages[] = { -0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, -0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, -0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, -0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; diff -Nru gpick-0.2.4/extern/expat/lib/utf8tab.h gpick-0.2.5/extern/expat/lib/utf8tab.h --- gpick-0.2.4/extern/expat/lib/utf8tab.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/utf8tab.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - - -/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4, -/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM, diff -Nru gpick-0.2.4/extern/expat/lib/watcomconfig.h gpick-0.2.5/extern/expat/lib/watcomconfig.h --- gpick-0.2.4/extern/expat/lib/watcomconfig.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/watcomconfig.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* expat_config.h for use with Open Watcom 1.5 and above. */ - -#ifndef WATCOMCONFIG_H -#define WATCOMCONFIG_H - -#ifdef __NT__ -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN -#endif - -/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ -#define BYTEORDER 1234 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "expat-bugs@mail.libexpat.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "expat" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "expat 2.0.0" - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "2.0.0" - -/* Define to specify how much context to retain around the current parse - point. */ -#define XML_CONTEXT_BYTES 1024 - -/* Define to make parameter entity parsing functionality available. */ -#define XML_DTD 1 - -/* Define to make XML Namespaces functionality available. */ -#define XML_NS 1 - -#endif - diff -Nru gpick-0.2.4/extern/expat/lib/winconfig.h gpick-0.2.5/extern/expat/lib/winconfig.h --- gpick-0.2.4/extern/expat/lib/winconfig.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/winconfig.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/*================================================================ -** Copyright 2000, Clark Cooper -** All rights reserved. -** -** This is free software. You are permitted to copy, distribute, or modify -** it under the terms of the MIT/X license (contained in the COPYING file -** with this distribution.) -*/ - -#ifndef WINCONFIG_H -#define WINCONFIG_H - -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN - -#include -#include - -#define XML_NS 1 -#define XML_DTD 1 -#define XML_CONTEXT_BYTES 1024 - -/* we will assume all Windows platforms are little endian */ -#define BYTEORDER 1234 - -/* Windows has memmove() available. */ -#define HAVE_MEMMOVE - -#endif /* ndef WINCONFIG_H */ diff -Nru gpick-0.2.4/extern/expat/lib/xmlparse.c gpick-0.2.5/extern/expat/lib/xmlparse.c --- gpick-0.2.4/extern/expat/lib/xmlparse.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/xmlparse.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,6290 +0,0 @@ -/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#include -#include /* memset(), memcpy() */ -#include - -#define XML_BUILDING_EXPAT 1 - -#ifdef COMPILED_FROM_DSP -#include "winconfig.h" -#elif defined(MACOS_CLASSIC) -#include "macconfig.h" -#elif defined(__amigaos__) -#include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" -#elif defined(HAVE_EXPAT_CONFIG_H) -#include -#endif /* ndef COMPILED_FROM_DSP */ - -#include "ascii.h" -#include "expat.h" - -#ifdef XML_UNICODE -#define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX -#define XmlConvert XmlUtf16Convert -#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding -#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS -#define XmlEncode XmlUtf16Encode -/* Using pointer subtraction to convert to integer type. */ -#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1)) -typedef unsigned short ICHAR; -#else -#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX -#define XmlConvert XmlUtf8Convert -#define XmlGetInternalEncoding XmlGetUtf8InternalEncoding -#define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS -#define XmlEncode XmlUtf8Encode -#define MUST_CONVERT(enc, s) (!(enc)->isUtf8) -typedef char ICHAR; -#endif - - -#ifndef XML_NS - -#define XmlInitEncodingNS XmlInitEncoding -#define XmlInitUnknownEncodingNS XmlInitUnknownEncoding -#undef XmlGetInternalEncodingNS -#define XmlGetInternalEncodingNS XmlGetInternalEncoding -#define XmlParseXmlDeclNS XmlParseXmlDecl - -#endif - -#ifdef XML_UNICODE - -#ifdef XML_UNICODE_WCHAR_T -#define XML_T(x) (const wchar_t)x -#define XML_L(x) L ## x -#else -#define XML_T(x) (const unsigned short)x -#define XML_L(x) x -#endif - -#else - -#define XML_T(x) x -#define XML_L(x) x - -#endif - -/* Round up n to be a multiple of sz, where sz is a power of 2. */ -#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) - -/* Handle the case where memmove() doesn't exist. */ -#ifndef HAVE_MEMMOVE -#ifdef HAVE_BCOPY -#define memmove(d,s,l) bcopy((s),(d),(l)) -#else -#error memmove does not exist on this platform, nor is a substitute available -#endif /* HAVE_BCOPY */ -#endif /* HAVE_MEMMOVE */ - -#include "internal.h" -#include "xmltok.h" -#include "xmlrole.h" - -typedef const XML_Char *KEY; - -typedef struct { - KEY name; -} NAMED; - -typedef struct { - NAMED **v; - unsigned char power; - size_t size; - size_t used; - const XML_Memory_Handling_Suite *mem; -} HASH_TABLE; - -/* Basic character hash algorithm, taken from Python's string hash: - h = h * 1000003 ^ character, the constant being a prime number. - -*/ -#ifdef XML_UNICODE -#define CHAR_HASH(h, c) \ - (((h) * 0xF4243) ^ (unsigned short)(c)) -#else -#define CHAR_HASH(h, c) \ - (((h) * 0xF4243) ^ (unsigned char)(c)) -#endif - -/* For probing (after a collision) we need a step size relative prime - to the hash table size, which is a power of 2. We use double-hashing, - since we can calculate a second hash value cheaply by taking those bits - of the first hash value that were discarded (masked out) when the table - index was calculated: index = hash & mask, where mask = table->size - 1. - We limit the maximum step size to table->size / 4 (mask >> 2) and make - it odd, since odd numbers are always relative prime to a power of 2. -*/ -#define SECOND_HASH(hash, mask, power) \ - ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2)) -#define PROBE_STEP(hash, mask, power) \ - ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1)) - -typedef struct { - NAMED **p; - NAMED **end; -} HASH_TABLE_ITER; - -#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ -#define INIT_DATA_BUF_SIZE 1024 -#define INIT_ATTS_SIZE 16 -#define INIT_ATTS_VERSION 0xFFFFFFFF -#define INIT_BLOCK_SIZE 1024 -#define INIT_BUFFER_SIZE 1024 - -#define EXPAND_SPARE 24 - -typedef struct binding { - struct prefix *prefix; - struct binding *nextTagBinding; - struct binding *prevPrefixBinding; - const struct attribute_id *attId; - XML_Char *uri; - int uriLen; - int uriAlloc; -} BINDING; - -typedef struct prefix { - const XML_Char *name; - BINDING *binding; -} PREFIX; - -typedef struct { - const XML_Char *str; - const XML_Char *localPart; - const XML_Char *prefix; - int strLen; - int uriLen; - int prefixLen; -} TAG_NAME; - -/* TAG represents an open element. - The name of the element is stored in both the document and API - encodings. The memory buffer 'buf' is a separately-allocated - memory area which stores the name. During the XML_Parse()/ - XMLParseBuffer() when the element is open, the memory for the 'raw' - version of the name (in the document encoding) is shared with the - document buffer. If the element is open across calls to - XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to - contain the 'raw' name as well. - - A parser re-uses these structures, maintaining a list of allocated - TAG objects in a free list. -*/ -typedef struct tag { - struct tag *parent; /* parent of this element */ - const char *rawName; /* tagName in the original encoding */ - int rawNameLength; - TAG_NAME name; /* tagName in the API encoding */ - char *buf; /* buffer for name components */ - char *bufEnd; /* end of the buffer */ - BINDING *bindings; -} TAG; - -typedef struct { - const XML_Char *name; - const XML_Char *textPtr; - int textLen; /* length in XML_Chars */ - int processed; /* # of processed bytes - when suspended */ - const XML_Char *systemId; - const XML_Char *base; - const XML_Char *publicId; - const XML_Char *notation; - XML_Bool open; - XML_Bool is_param; - XML_Bool is_internal; /* true if declared in internal subset outside PE */ -} ENTITY; - -typedef struct { - enum XML_Content_Type type; - enum XML_Content_Quant quant; - const XML_Char * name; - int firstchild; - int lastchild; - int childcnt; - int nextsib; -} CONTENT_SCAFFOLD; - -#define INIT_SCAFFOLD_ELEMENTS 32 - -typedef struct block { - struct block *next; - int size; - XML_Char s[1]; -} BLOCK; - -typedef struct { - BLOCK *blocks; - BLOCK *freeBlocks; - const XML_Char *end; - XML_Char *ptr; - XML_Char *start; - const XML_Memory_Handling_Suite *mem; -} STRING_POOL; - -/* The XML_Char before the name is used to determine whether - an attribute has been specified. */ -typedef struct attribute_id { - XML_Char *name; - PREFIX *prefix; - XML_Bool maybeTokenized; - XML_Bool xmlns; -} ATTRIBUTE_ID; - -typedef struct { - const ATTRIBUTE_ID *id; - XML_Bool isCdata; - const XML_Char *value; -} DEFAULT_ATTRIBUTE; - -typedef struct { - unsigned long version; - unsigned long hash; - const XML_Char *uriName; -} NS_ATT; - -typedef struct { - const XML_Char *name; - PREFIX *prefix; - const ATTRIBUTE_ID *idAtt; - int nDefaultAtts; - int allocDefaultAtts; - DEFAULT_ATTRIBUTE *defaultAtts; -} ELEMENT_TYPE; - -typedef struct { - HASH_TABLE generalEntities; - HASH_TABLE elementTypes; - HASH_TABLE attributeIds; - HASH_TABLE prefixes; - STRING_POOL pool; - STRING_POOL entityValuePool; - /* false once a parameter entity reference has been skipped */ - XML_Bool keepProcessing; - /* true once an internal or external PE reference has been encountered; - this includes the reference to an external subset */ - XML_Bool hasParamEntityRefs; - XML_Bool standalone; -#ifdef XML_DTD - /* indicates if external PE has been read */ - XML_Bool paramEntityRead; - HASH_TABLE paramEntities; -#endif /* XML_DTD */ - PREFIX defaultPrefix; - /* === scaffolding for building content model === */ - XML_Bool in_eldecl; - CONTENT_SCAFFOLD *scaffold; - unsigned contentStringLen; - unsigned scaffSize; - unsigned scaffCount; - int scaffLevel; - int *scaffIndex; -} DTD; - -typedef struct open_internal_entity { - const char *internalEventPtr; - const char *internalEventEndPtr; - struct open_internal_entity *next; - ENTITY *entity; - int startTagLevel; - XML_Bool betweenDecl; /* WFC: PE Between Declarations */ -} OPEN_INTERNAL_ENTITY; - -typedef enum XML_Error PTRCALL Processor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr); - -static Processor prologProcessor; -static Processor prologInitProcessor; -static Processor contentProcessor; -static Processor cdataSectionProcessor; -#ifdef XML_DTD -static Processor ignoreSectionProcessor; -static Processor externalParEntProcessor; -static Processor externalParEntInitProcessor; -static Processor entityValueProcessor; -static Processor entityValueInitProcessor; -#endif /* XML_DTD */ -static Processor epilogProcessor; -static Processor errorProcessor; -static Processor externalEntityInitProcessor; -static Processor externalEntityInitProcessor2; -static Processor externalEntityInitProcessor3; -static Processor externalEntityContentProcessor; -static Processor internalEntityProcessor; - -static enum XML_Error -handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName); -static enum XML_Error -processXmlDecl(XML_Parser parser, int isGeneralTextEntity, - const char *s, const char *next); -static enum XML_Error -initializeEncoding(XML_Parser parser); -static enum XML_Error -doProlog(XML_Parser parser, const ENCODING *enc, const char *s, - const char *end, int tok, const char *next, const char **nextPtr, - XML_Bool haveMore); -static enum XML_Error -processInternalEntity(XML_Parser parser, ENTITY *entity, - XML_Bool betweenDecl); -static enum XML_Error -doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, - const char *start, const char *end, const char **endPtr, - XML_Bool haveMore); -static enum XML_Error -doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, - const char *end, const char **nextPtr, XML_Bool haveMore); -#ifdef XML_DTD -static enum XML_Error -doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, - const char *end, const char **nextPtr, XML_Bool haveMore); -#endif /* XML_DTD */ - -static enum XML_Error -storeAtts(XML_Parser parser, const ENCODING *, const char *s, - TAG_NAME *tagNamePtr, BINDING **bindingsPtr); -static enum XML_Error -addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, - const XML_Char *uri, BINDING **bindingsPtr); -static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, - XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser); -static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, - const char *, const char *, STRING_POOL *); -static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, - const char *, const char *, STRING_POOL *); -static ATTRIBUTE_ID * -getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, - const char *end); -static int -setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); -static enum XML_Error -storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start, - const char *end); -static int -reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, - const char *start, const char *end); -static int -reportComment(XML_Parser parser, const ENCODING *enc, const char *start, - const char *end); -static void -reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, - const char *end); - -static const XML_Char * getContext(XML_Parser parser); -static XML_Bool -setContext(XML_Parser parser, const XML_Char *context); - -static void FASTCALL normalizePublicId(XML_Char *s); - -static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms); -/* do not call if parentParser != NULL */ -static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); -static void -dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); -static int -dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); -static int -copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); - -static NAMED * -lookup(HASH_TABLE *table, KEY name, size_t createSize); -static void FASTCALL -hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms); -static void FASTCALL hashTableClear(HASH_TABLE *); -static void FASTCALL hashTableDestroy(HASH_TABLE *); -static void FASTCALL -hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); -static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *); - -static void FASTCALL -poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms); -static void FASTCALL poolClear(STRING_POOL *); -static void FASTCALL poolDestroy(STRING_POOL *); -static XML_Char * -poolAppend(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end); -static XML_Char * -poolStoreString(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end); -static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); -static const XML_Char * FASTCALL -poolCopyString(STRING_POOL *pool, const XML_Char *s); -static const XML_Char * -poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n); -static const XML_Char * FASTCALL -poolAppendString(STRING_POOL *pool, const XML_Char *s); - -static int FASTCALL nextScaffoldPart(XML_Parser parser); -static XML_Content * build_model(XML_Parser parser); -static ELEMENT_TYPE * -getElementType(XML_Parser parser, const ENCODING *enc, - const char *ptr, const char *end); - -static XML_Parser -parserCreate(const XML_Char *encodingName, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *nameSep, - DTD *dtd); -static void -parserInit(XML_Parser parser, const XML_Char *encodingName); - -#define poolStart(pool) ((pool)->start) -#define poolEnd(pool) ((pool)->ptr) -#define poolLength(pool) ((pool)->ptr - (pool)->start) -#define poolChop(pool) ((void)--(pool->ptr)) -#define poolLastChar(pool) (((pool)->ptr)[-1]) -#define poolDiscard(pool) ((pool)->ptr = (pool)->start) -#define poolFinish(pool) ((pool)->start = (pool)->ptr) -#define poolAppendChar(pool, c) \ - (((pool)->ptr == (pool)->end && !poolGrow(pool)) \ - ? 0 \ - : ((*((pool)->ptr)++ = c), 1)) - -struct XML_ParserStruct { - /* The first member must be userData so that the XML_GetUserData - macro works. */ - void *m_userData; - void *m_handlerArg; - char *m_buffer; - const XML_Memory_Handling_Suite m_mem; - /* first character to be parsed */ - const char *m_bufferPtr; - /* past last character to be parsed */ - char *m_bufferEnd; - /* allocated end of buffer */ - const char *m_bufferLim; - XML_Index m_parseEndByteIndex; - const char *m_parseEndPtr; - XML_Char *m_dataBuf; - XML_Char *m_dataBufEnd; - XML_StartElementHandler m_startElementHandler; - XML_EndElementHandler m_endElementHandler; - XML_CharacterDataHandler m_characterDataHandler; - XML_ProcessingInstructionHandler m_processingInstructionHandler; - XML_CommentHandler m_commentHandler; - XML_StartCdataSectionHandler m_startCdataSectionHandler; - XML_EndCdataSectionHandler m_endCdataSectionHandler; - XML_DefaultHandler m_defaultHandler; - XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler; - XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler; - XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler; - XML_NotationDeclHandler m_notationDeclHandler; - XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler; - XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler; - XML_NotStandaloneHandler m_notStandaloneHandler; - XML_ExternalEntityRefHandler m_externalEntityRefHandler; - XML_Parser m_externalEntityRefHandlerArg; - XML_SkippedEntityHandler m_skippedEntityHandler; - XML_UnknownEncodingHandler m_unknownEncodingHandler; - XML_ElementDeclHandler m_elementDeclHandler; - XML_AttlistDeclHandler m_attlistDeclHandler; - XML_EntityDeclHandler m_entityDeclHandler; - XML_XmlDeclHandler m_xmlDeclHandler; - const ENCODING *m_encoding; - INIT_ENCODING m_initEncoding; - const ENCODING *m_internalEncoding; - const XML_Char *m_protocolEncodingName; - XML_Bool m_ns; - XML_Bool m_ns_triplets; - void *m_unknownEncodingMem; - void *m_unknownEncodingData; - void *m_unknownEncodingHandlerData; - void (XMLCALL *m_unknownEncodingRelease)(void *); - PROLOG_STATE m_prologState; - Processor *m_processor; - enum XML_Error m_errorCode; - const char *m_eventPtr; - const char *m_eventEndPtr; - const char *m_positionPtr; - OPEN_INTERNAL_ENTITY *m_openInternalEntities; - OPEN_INTERNAL_ENTITY *m_freeInternalEntities; - XML_Bool m_defaultExpandInternalEntities; - int m_tagLevel; - ENTITY *m_declEntity; - const XML_Char *m_doctypeName; - const XML_Char *m_doctypeSysid; - const XML_Char *m_doctypePubid; - const XML_Char *m_declAttributeType; - const XML_Char *m_declNotationName; - const XML_Char *m_declNotationPublicId; - ELEMENT_TYPE *m_declElementType; - ATTRIBUTE_ID *m_declAttributeId; - XML_Bool m_declAttributeIsCdata; - XML_Bool m_declAttributeIsId; - DTD *m_dtd; - const XML_Char *m_curBase; - TAG *m_tagStack; - TAG *m_freeTagList; - BINDING *m_inheritedBindings; - BINDING *m_freeBindingList; - int m_attsSize; - int m_nSpecifiedAtts; - int m_idAttIndex; - ATTRIBUTE *m_atts; - NS_ATT *m_nsAtts; - unsigned long m_nsAttsVersion; - unsigned char m_nsAttsPower; - POSITION m_position; - STRING_POOL m_tempPool; - STRING_POOL m_temp2Pool; - char *m_groupConnector; - unsigned int m_groupSize; - XML_Char m_namespaceSeparator; - XML_Parser m_parentParser; - XML_ParsingStatus m_parsingStatus; -#ifdef XML_DTD - XML_Bool m_isParamEntity; - XML_Bool m_useForeignDTD; - enum XML_ParamEntityParsing m_paramEntityParsing; -#endif -}; - -#define MALLOC(s) (parser->m_mem.malloc_fcn((s))) -#define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s))) -#define FREE(p) (parser->m_mem.free_fcn((p))) - -#define userData (parser->m_userData) -#define handlerArg (parser->m_handlerArg) -#define startElementHandler (parser->m_startElementHandler) -#define endElementHandler (parser->m_endElementHandler) -#define characterDataHandler (parser->m_characterDataHandler) -#define processingInstructionHandler \ - (parser->m_processingInstructionHandler) -#define commentHandler (parser->m_commentHandler) -#define startCdataSectionHandler \ - (parser->m_startCdataSectionHandler) -#define endCdataSectionHandler (parser->m_endCdataSectionHandler) -#define defaultHandler (parser->m_defaultHandler) -#define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler) -#define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler) -#define unparsedEntityDeclHandler \ - (parser->m_unparsedEntityDeclHandler) -#define notationDeclHandler (parser->m_notationDeclHandler) -#define startNamespaceDeclHandler \ - (parser->m_startNamespaceDeclHandler) -#define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler) -#define notStandaloneHandler (parser->m_notStandaloneHandler) -#define externalEntityRefHandler \ - (parser->m_externalEntityRefHandler) -#define externalEntityRefHandlerArg \ - (parser->m_externalEntityRefHandlerArg) -#define internalEntityRefHandler \ - (parser->m_internalEntityRefHandler) -#define skippedEntityHandler (parser->m_skippedEntityHandler) -#define unknownEncodingHandler (parser->m_unknownEncodingHandler) -#define elementDeclHandler (parser->m_elementDeclHandler) -#define attlistDeclHandler (parser->m_attlistDeclHandler) -#define entityDeclHandler (parser->m_entityDeclHandler) -#define xmlDeclHandler (parser->m_xmlDeclHandler) -#define encoding (parser->m_encoding) -#define initEncoding (parser->m_initEncoding) -#define internalEncoding (parser->m_internalEncoding) -#define unknownEncodingMem (parser->m_unknownEncodingMem) -#define unknownEncodingData (parser->m_unknownEncodingData) -#define unknownEncodingHandlerData \ - (parser->m_unknownEncodingHandlerData) -#define unknownEncodingRelease (parser->m_unknownEncodingRelease) -#define protocolEncodingName (parser->m_protocolEncodingName) -#define ns (parser->m_ns) -#define ns_triplets (parser->m_ns_triplets) -#define prologState (parser->m_prologState) -#define processor (parser->m_processor) -#define errorCode (parser->m_errorCode) -#define eventPtr (parser->m_eventPtr) -#define eventEndPtr (parser->m_eventEndPtr) -#define positionPtr (parser->m_positionPtr) -#define position (parser->m_position) -#define openInternalEntities (parser->m_openInternalEntities) -#define freeInternalEntities (parser->m_freeInternalEntities) -#define defaultExpandInternalEntities \ - (parser->m_defaultExpandInternalEntities) -#define tagLevel (parser->m_tagLevel) -#define buffer (parser->m_buffer) -#define bufferPtr (parser->m_bufferPtr) -#define bufferEnd (parser->m_bufferEnd) -#define parseEndByteIndex (parser->m_parseEndByteIndex) -#define parseEndPtr (parser->m_parseEndPtr) -#define bufferLim (parser->m_bufferLim) -#define dataBuf (parser->m_dataBuf) -#define dataBufEnd (parser->m_dataBufEnd) -#define _dtd (parser->m_dtd) -#define curBase (parser->m_curBase) -#define declEntity (parser->m_declEntity) -#define doctypeName (parser->m_doctypeName) -#define doctypeSysid (parser->m_doctypeSysid) -#define doctypePubid (parser->m_doctypePubid) -#define declAttributeType (parser->m_declAttributeType) -#define declNotationName (parser->m_declNotationName) -#define declNotationPublicId (parser->m_declNotationPublicId) -#define declElementType (parser->m_declElementType) -#define declAttributeId (parser->m_declAttributeId) -#define declAttributeIsCdata (parser->m_declAttributeIsCdata) -#define declAttributeIsId (parser->m_declAttributeIsId) -#define freeTagList (parser->m_freeTagList) -#define freeBindingList (parser->m_freeBindingList) -#define inheritedBindings (parser->m_inheritedBindings) -#define tagStack (parser->m_tagStack) -#define atts (parser->m_atts) -#define attsSize (parser->m_attsSize) -#define nSpecifiedAtts (parser->m_nSpecifiedAtts) -#define idAttIndex (parser->m_idAttIndex) -#define nsAtts (parser->m_nsAtts) -#define nsAttsVersion (parser->m_nsAttsVersion) -#define nsAttsPower (parser->m_nsAttsPower) -#define tempPool (parser->m_tempPool) -#define temp2Pool (parser->m_temp2Pool) -#define groupConnector (parser->m_groupConnector) -#define groupSize (parser->m_groupSize) -#define namespaceSeparator (parser->m_namespaceSeparator) -#define parentParser (parser->m_parentParser) -#define ps_parsing (parser->m_parsingStatus.parsing) -#define ps_finalBuffer (parser->m_parsingStatus.finalBuffer) -#ifdef XML_DTD -#define isParamEntity (parser->m_isParamEntity) -#define useForeignDTD (parser->m_useForeignDTD) -#define paramEntityParsing (parser->m_paramEntityParsing) -#endif /* XML_DTD */ - -XML_Parser XMLCALL -XML_ParserCreate(const XML_Char *encodingName) -{ - return XML_ParserCreate_MM(encodingName, NULL, NULL); -} - -XML_Parser XMLCALL -XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) -{ - XML_Char tmp[2]; - *tmp = nsSep; - return XML_ParserCreate_MM(encodingName, NULL, tmp); -} - -static const XML_Char implicitContext[] = { - ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p, - ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, - ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, - ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, - ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e, - ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0' -}; - -XML_Parser XMLCALL -XML_ParserCreate_MM(const XML_Char *encodingName, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *nameSep) -{ - XML_Parser parser = parserCreate(encodingName, memsuite, nameSep, NULL); - if (parser != NULL && ns) { - /* implicit context only set for root parser, since child - parsers (i.e. external entity parsers) will inherit it - */ - if (!setContext(parser, implicitContext)) { - XML_ParserFree(parser); - return NULL; - } - } - return parser; -} - -static XML_Parser -parserCreate(const XML_Char *encodingName, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *nameSep, - DTD *dtd) -{ - XML_Parser parser; - - if (memsuite) { - XML_Memory_Handling_Suite *mtemp; - parser = (XML_Parser) - memsuite->malloc_fcn(sizeof(struct XML_ParserStruct)); - if (parser != NULL) { - mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); - mtemp->malloc_fcn = memsuite->malloc_fcn; - mtemp->realloc_fcn = memsuite->realloc_fcn; - mtemp->free_fcn = memsuite->free_fcn; - } - } - else { - XML_Memory_Handling_Suite *mtemp; - parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct)); - if (parser != NULL) { - mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); - mtemp->malloc_fcn = malloc; - mtemp->realloc_fcn = realloc; - mtemp->free_fcn = free; - } - } - - if (!parser) - return parser; - - buffer = NULL; - bufferLim = NULL; - - attsSize = INIT_ATTS_SIZE; - atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE)); - if (atts == NULL) { - FREE(parser); - return NULL; - } - dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); - if (dataBuf == NULL) { - FREE(atts); - FREE(parser); - return NULL; - } - dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; - - if (dtd) - _dtd = dtd; - else { - _dtd = dtdCreate(&parser->m_mem); - if (_dtd == NULL) { - FREE(dataBuf); - FREE(atts); - FREE(parser); - return NULL; - } - } - - freeBindingList = NULL; - freeTagList = NULL; - freeInternalEntities = NULL; - - groupSize = 0; - groupConnector = NULL; - - unknownEncodingHandler = NULL; - unknownEncodingHandlerData = NULL; - - namespaceSeparator = ASCII_EXCL; - ns = XML_FALSE; - ns_triplets = XML_FALSE; - - nsAtts = NULL; - nsAttsVersion = 0; - nsAttsPower = 0; - - poolInit(&tempPool, &(parser->m_mem)); - poolInit(&temp2Pool, &(parser->m_mem)); - parserInit(parser, encodingName); - - if (encodingName && !protocolEncodingName) { - XML_ParserFree(parser); - return NULL; - } - - if (nameSep) { - ns = XML_TRUE; - internalEncoding = XmlGetInternalEncodingNS(); - namespaceSeparator = *nameSep; - } - else { - internalEncoding = XmlGetInternalEncoding(); - } - - return parser; -} - -static void -parserInit(XML_Parser parser, const XML_Char *encodingName) -{ - processor = prologInitProcessor; - XmlPrologStateInit(&prologState); - protocolEncodingName = (encodingName != NULL - ? poolCopyString(&tempPool, encodingName) - : NULL); - curBase = NULL; - XmlInitEncoding(&initEncoding, &encoding, 0); - userData = NULL; - handlerArg = NULL; - startElementHandler = NULL; - endElementHandler = NULL; - characterDataHandler = NULL; - processingInstructionHandler = NULL; - commentHandler = NULL; - startCdataSectionHandler = NULL; - endCdataSectionHandler = NULL; - defaultHandler = NULL; - startDoctypeDeclHandler = NULL; - endDoctypeDeclHandler = NULL; - unparsedEntityDeclHandler = NULL; - notationDeclHandler = NULL; - startNamespaceDeclHandler = NULL; - endNamespaceDeclHandler = NULL; - notStandaloneHandler = NULL; - externalEntityRefHandler = NULL; - externalEntityRefHandlerArg = parser; - skippedEntityHandler = NULL; - elementDeclHandler = NULL; - attlistDeclHandler = NULL; - entityDeclHandler = NULL; - xmlDeclHandler = NULL; - bufferPtr = buffer; - bufferEnd = buffer; - parseEndByteIndex = 0; - parseEndPtr = NULL; - declElementType = NULL; - declAttributeId = NULL; - declEntity = NULL; - doctypeName = NULL; - doctypeSysid = NULL; - doctypePubid = NULL; - declAttributeType = NULL; - declNotationName = NULL; - declNotationPublicId = NULL; - declAttributeIsCdata = XML_FALSE; - declAttributeIsId = XML_FALSE; - memset(&position, 0, sizeof(POSITION)); - errorCode = XML_ERROR_NONE; - eventPtr = NULL; - eventEndPtr = NULL; - positionPtr = NULL; - openInternalEntities = NULL; - defaultExpandInternalEntities = XML_TRUE; - tagLevel = 0; - tagStack = NULL; - inheritedBindings = NULL; - nSpecifiedAtts = 0; - unknownEncodingMem = NULL; - unknownEncodingRelease = NULL; - unknownEncodingData = NULL; - parentParser = NULL; - ps_parsing = XML_INITIALIZED; -#ifdef XML_DTD - isParamEntity = XML_FALSE; - useForeignDTD = XML_FALSE; - paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; -#endif -} - -/* moves list of bindings to freeBindingList */ -static void FASTCALL -moveToFreeBindingList(XML_Parser parser, BINDING *bindings) -{ - while (bindings) { - BINDING *b = bindings; - bindings = bindings->nextTagBinding; - b->nextTagBinding = freeBindingList; - freeBindingList = b; - } -} - -XML_Bool XMLCALL -XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) -{ - TAG *tStk; - OPEN_INTERNAL_ENTITY *openEntityList; - if (parentParser) - return XML_FALSE; - /* move tagStack to freeTagList */ - tStk = tagStack; - while (tStk) { - TAG *tag = tStk; - tStk = tStk->parent; - tag->parent = freeTagList; - moveToFreeBindingList(parser, tag->bindings); - tag->bindings = NULL; - freeTagList = tag; - } - /* move openInternalEntities to freeInternalEntities */ - openEntityList = openInternalEntities; - while (openEntityList) { - OPEN_INTERNAL_ENTITY *openEntity = openEntityList; - openEntityList = openEntity->next; - openEntity->next = freeInternalEntities; - freeInternalEntities = openEntity; - } - moveToFreeBindingList(parser, inheritedBindings); - FREE(unknownEncodingMem); - if (unknownEncodingRelease) - unknownEncodingRelease(unknownEncodingData); - poolClear(&tempPool); - poolClear(&temp2Pool); - parserInit(parser, encodingName); - dtdReset(_dtd, &parser->m_mem); - return setContext(parser, implicitContext); -} - -enum XML_Status XMLCALL -XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) -{ - /* Block after XML_Parse()/XML_ParseBuffer() has been called. - XXX There's no way for the caller to determine which of the - XXX possible error cases caused the XML_STATUS_ERROR return. - */ - if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) - return XML_STATUS_ERROR; - if (encodingName == NULL) - protocolEncodingName = NULL; - else { - protocolEncodingName = poolCopyString(&tempPool, encodingName); - if (!protocolEncodingName) - return XML_STATUS_ERROR; - } - return XML_STATUS_OK; -} - -XML_Parser XMLCALL -XML_ExternalEntityParserCreate(XML_Parser oldParser, - const XML_Char *context, - const XML_Char *encodingName) -{ - XML_Parser parser = oldParser; - DTD *newDtd = NULL; - DTD *oldDtd = _dtd; - XML_StartElementHandler oldStartElementHandler = startElementHandler; - XML_EndElementHandler oldEndElementHandler = endElementHandler; - XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler; - XML_ProcessingInstructionHandler oldProcessingInstructionHandler - = processingInstructionHandler; - XML_CommentHandler oldCommentHandler = commentHandler; - XML_StartCdataSectionHandler oldStartCdataSectionHandler - = startCdataSectionHandler; - XML_EndCdataSectionHandler oldEndCdataSectionHandler - = endCdataSectionHandler; - XML_DefaultHandler oldDefaultHandler = defaultHandler; - XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler - = unparsedEntityDeclHandler; - XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler; - XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler - = startNamespaceDeclHandler; - XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler - = endNamespaceDeclHandler; - XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler; - XML_ExternalEntityRefHandler oldExternalEntityRefHandler - = externalEntityRefHandler; - XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler; - XML_UnknownEncodingHandler oldUnknownEncodingHandler - = unknownEncodingHandler; - XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler; - XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler; - XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler; - XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler; - ELEMENT_TYPE * oldDeclElementType = declElementType; - - void *oldUserData = userData; - void *oldHandlerArg = handlerArg; - XML_Bool oldDefaultExpandInternalEntities = defaultExpandInternalEntities; - XML_Parser oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; -#ifdef XML_DTD - enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing; - int oldInEntityValue = prologState.inEntityValue; -#endif - XML_Bool oldns_triplets = ns_triplets; - -#ifdef XML_DTD - if (!context) - newDtd = oldDtd; -#endif /* XML_DTD */ - - /* Note that the magical uses of the pre-processor to make field - access look more like C++ require that `parser' be overwritten - here. This makes this function more painful to follow than it - would be otherwise. - */ - if (ns) { - XML_Char tmp[2]; - *tmp = namespaceSeparator; - parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); - } - else { - parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); - } - - if (!parser) - return NULL; - - startElementHandler = oldStartElementHandler; - endElementHandler = oldEndElementHandler; - characterDataHandler = oldCharacterDataHandler; - processingInstructionHandler = oldProcessingInstructionHandler; - commentHandler = oldCommentHandler; - startCdataSectionHandler = oldStartCdataSectionHandler; - endCdataSectionHandler = oldEndCdataSectionHandler; - defaultHandler = oldDefaultHandler; - unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; - notationDeclHandler = oldNotationDeclHandler; - startNamespaceDeclHandler = oldStartNamespaceDeclHandler; - endNamespaceDeclHandler = oldEndNamespaceDeclHandler; - notStandaloneHandler = oldNotStandaloneHandler; - externalEntityRefHandler = oldExternalEntityRefHandler; - skippedEntityHandler = oldSkippedEntityHandler; - unknownEncodingHandler = oldUnknownEncodingHandler; - elementDeclHandler = oldElementDeclHandler; - attlistDeclHandler = oldAttlistDeclHandler; - entityDeclHandler = oldEntityDeclHandler; - xmlDeclHandler = oldXmlDeclHandler; - declElementType = oldDeclElementType; - userData = oldUserData; - if (oldUserData == oldHandlerArg) - handlerArg = userData; - else - handlerArg = parser; - if (oldExternalEntityRefHandlerArg != oldParser) - externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; - defaultExpandInternalEntities = oldDefaultExpandInternalEntities; - ns_triplets = oldns_triplets; - parentParser = oldParser; -#ifdef XML_DTD - paramEntityParsing = oldParamEntityParsing; - prologState.inEntityValue = oldInEntityValue; - if (context) { -#endif /* XML_DTD */ - if (!dtdCopy(_dtd, oldDtd, &parser->m_mem) - || !setContext(parser, context)) { - XML_ParserFree(parser); - return NULL; - } - processor = externalEntityInitProcessor; -#ifdef XML_DTD - } - else { - /* The DTD instance referenced by _dtd is shared between the document's - root parser and external PE parsers, therefore one does not need to - call setContext. In addition, one also *must* not call setContext, - because this would overwrite existing prefix->binding pointers in - _dtd with ones that get destroyed with the external PE parser. - This would leave those prefixes with dangling pointers. - */ - isParamEntity = XML_TRUE; - XmlPrologStateInitExternalEntity(&prologState); - processor = externalParEntInitProcessor; - } -#endif /* XML_DTD */ - return parser; -} - -static void FASTCALL -destroyBindings(BINDING *bindings, XML_Parser parser) -{ - for (;;) { - BINDING *b = bindings; - if (!b) - break; - bindings = b->nextTagBinding; - FREE(b->uri); - FREE(b); - } -} - -void XMLCALL -XML_ParserFree(XML_Parser parser) -{ - TAG *tagList; - OPEN_INTERNAL_ENTITY *entityList; - if (parser == NULL) - return; - /* free tagStack and freeTagList */ - tagList = tagStack; - for (;;) { - TAG *p; - if (tagList == NULL) { - if (freeTagList == NULL) - break; - tagList = freeTagList; - freeTagList = NULL; - } - p = tagList; - tagList = tagList->parent; - FREE(p->buf); - destroyBindings(p->bindings, parser); - FREE(p); - } - /* free openInternalEntities and freeInternalEntities */ - entityList = openInternalEntities; - for (;;) { - OPEN_INTERNAL_ENTITY *openEntity; - if (entityList == NULL) { - if (freeInternalEntities == NULL) - break; - entityList = freeInternalEntities; - freeInternalEntities = NULL; - } - openEntity = entityList; - entityList = entityList->next; - FREE(openEntity); - } - - destroyBindings(freeBindingList, parser); - destroyBindings(inheritedBindings, parser); - poolDestroy(&tempPool); - poolDestroy(&temp2Pool); -#ifdef XML_DTD - /* external parameter entity parsers share the DTD structure - parser->m_dtd with the root parser, so we must not destroy it - */ - if (!isParamEntity && _dtd) -#else - if (_dtd) -#endif /* XML_DTD */ - dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); - FREE((void *)atts); - FREE(groupConnector); - FREE(buffer); - FREE(dataBuf); - FREE(nsAtts); - FREE(unknownEncodingMem); - if (unknownEncodingRelease) - unknownEncodingRelease(unknownEncodingData); - FREE(parser); -} - -void XMLCALL -XML_UseParserAsHandlerArg(XML_Parser parser) -{ - handlerArg = parser; -} - -enum XML_Error XMLCALL -XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) -{ -#ifdef XML_DTD - /* block after XML_Parse()/XML_ParseBuffer() has been called */ - if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) - return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING; - useForeignDTD = useDTD; - return XML_ERROR_NONE; -#else - return XML_ERROR_FEATURE_REQUIRES_XML_DTD; -#endif -} - -void XMLCALL -XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) -{ - /* block after XML_Parse()/XML_ParseBuffer() has been called */ - if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) - return; - ns_triplets = do_nst ? XML_TRUE : XML_FALSE; -} - -void XMLCALL -XML_SetUserData(XML_Parser parser, void *p) -{ - if (handlerArg == userData) - handlerArg = userData = p; - else - userData = p; -} - -enum XML_Status XMLCALL -XML_SetBase(XML_Parser parser, const XML_Char *p) -{ - if (p) { - p = poolCopyString(&_dtd->pool, p); - if (!p) - return XML_STATUS_ERROR; - curBase = p; - } - else - curBase = NULL; - return XML_STATUS_OK; -} - -const XML_Char * XMLCALL -XML_GetBase(XML_Parser parser) -{ - return curBase; -} - -int XMLCALL -XML_GetSpecifiedAttributeCount(XML_Parser parser) -{ - return nSpecifiedAtts; -} - -int XMLCALL -XML_GetIdAttributeIndex(XML_Parser parser) -{ - return idAttIndex; -} - -void XMLCALL -XML_SetElementHandler(XML_Parser parser, - XML_StartElementHandler start, - XML_EndElementHandler end) -{ - startElementHandler = start; - endElementHandler = end; -} - -void XMLCALL -XML_SetStartElementHandler(XML_Parser parser, - XML_StartElementHandler start) { - startElementHandler = start; -} - -void XMLCALL -XML_SetEndElementHandler(XML_Parser parser, - XML_EndElementHandler end) { - endElementHandler = end; -} - -void XMLCALL -XML_SetCharacterDataHandler(XML_Parser parser, - XML_CharacterDataHandler handler) -{ - characterDataHandler = handler; -} - -void XMLCALL -XML_SetProcessingInstructionHandler(XML_Parser parser, - XML_ProcessingInstructionHandler handler) -{ - processingInstructionHandler = handler; -} - -void XMLCALL -XML_SetCommentHandler(XML_Parser parser, - XML_CommentHandler handler) -{ - commentHandler = handler; -} - -void XMLCALL -XML_SetCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start, - XML_EndCdataSectionHandler end) -{ - startCdataSectionHandler = start; - endCdataSectionHandler = end; -} - -void XMLCALL -XML_SetStartCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start) { - startCdataSectionHandler = start; -} - -void XMLCALL -XML_SetEndCdataSectionHandler(XML_Parser parser, - XML_EndCdataSectionHandler end) { - endCdataSectionHandler = end; -} - -void XMLCALL -XML_SetDefaultHandler(XML_Parser parser, - XML_DefaultHandler handler) -{ - defaultHandler = handler; - defaultExpandInternalEntities = XML_FALSE; -} - -void XMLCALL -XML_SetDefaultHandlerExpand(XML_Parser parser, - XML_DefaultHandler handler) -{ - defaultHandler = handler; - defaultExpandInternalEntities = XML_TRUE; -} - -void XMLCALL -XML_SetDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start, - XML_EndDoctypeDeclHandler end) -{ - startDoctypeDeclHandler = start; - endDoctypeDeclHandler = end; -} - -void XMLCALL -XML_SetStartDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start) { - startDoctypeDeclHandler = start; -} - -void XMLCALL -XML_SetEndDoctypeDeclHandler(XML_Parser parser, - XML_EndDoctypeDeclHandler end) { - endDoctypeDeclHandler = end; -} - -void XMLCALL -XML_SetUnparsedEntityDeclHandler(XML_Parser parser, - XML_UnparsedEntityDeclHandler handler) -{ - unparsedEntityDeclHandler = handler; -} - -void XMLCALL -XML_SetNotationDeclHandler(XML_Parser parser, - XML_NotationDeclHandler handler) -{ - notationDeclHandler = handler; -} - -void XMLCALL -XML_SetNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start, - XML_EndNamespaceDeclHandler end) -{ - startNamespaceDeclHandler = start; - endNamespaceDeclHandler = end; -} - -void XMLCALL -XML_SetStartNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start) { - startNamespaceDeclHandler = start; -} - -void XMLCALL -XML_SetEndNamespaceDeclHandler(XML_Parser parser, - XML_EndNamespaceDeclHandler end) { - endNamespaceDeclHandler = end; -} - -void XMLCALL -XML_SetNotStandaloneHandler(XML_Parser parser, - XML_NotStandaloneHandler handler) -{ - notStandaloneHandler = handler; -} - -void XMLCALL -XML_SetExternalEntityRefHandler(XML_Parser parser, - XML_ExternalEntityRefHandler handler) -{ - externalEntityRefHandler = handler; -} - -void XMLCALL -XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) -{ - if (arg) - externalEntityRefHandlerArg = (XML_Parser)arg; - else - externalEntityRefHandlerArg = parser; -} - -void XMLCALL -XML_SetSkippedEntityHandler(XML_Parser parser, - XML_SkippedEntityHandler handler) -{ - skippedEntityHandler = handler; -} - -void XMLCALL -XML_SetUnknownEncodingHandler(XML_Parser parser, - XML_UnknownEncodingHandler handler, - void *data) -{ - unknownEncodingHandler = handler; - unknownEncodingHandlerData = data; -} - -void XMLCALL -XML_SetElementDeclHandler(XML_Parser parser, - XML_ElementDeclHandler eldecl) -{ - elementDeclHandler = eldecl; -} - -void XMLCALL -XML_SetAttlistDeclHandler(XML_Parser parser, - XML_AttlistDeclHandler attdecl) -{ - attlistDeclHandler = attdecl; -} - -void XMLCALL -XML_SetEntityDeclHandler(XML_Parser parser, - XML_EntityDeclHandler handler) -{ - entityDeclHandler = handler; -} - -void XMLCALL -XML_SetXmlDeclHandler(XML_Parser parser, - XML_XmlDeclHandler handler) { - xmlDeclHandler = handler; -} - -int XMLCALL -XML_SetParamEntityParsing(XML_Parser parser, - enum XML_ParamEntityParsing peParsing) -{ - /* block after XML_Parse()/XML_ParseBuffer() has been called */ - if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) - return 0; -#ifdef XML_DTD - paramEntityParsing = peParsing; - return 1; -#else - return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; -#endif -} - -enum XML_Status XMLCALL -XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) -{ - switch (ps_parsing) { - case XML_SUSPENDED: - errorCode = XML_ERROR_SUSPENDED; - return XML_STATUS_ERROR; - case XML_FINISHED: - errorCode = XML_ERROR_FINISHED; - return XML_STATUS_ERROR; - default: - ps_parsing = XML_PARSING; - } - - if (len == 0) { - ps_finalBuffer = (XML_Bool)isFinal; - if (!isFinal) - return XML_STATUS_OK; - positionPtr = bufferPtr; - parseEndPtr = bufferEnd; - - /* If data are left over from last buffer, and we now know that these - data are the final chunk of input, then we have to check them again - to detect errors based on that fact. - */ - errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); - - if (errorCode == XML_ERROR_NONE) { - switch (ps_parsing) { - case XML_SUSPENDED: - XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); - positionPtr = bufferPtr; - return XML_STATUS_SUSPENDED; - case XML_INITIALIZED: - case XML_PARSING: - ps_parsing = XML_FINISHED; - /* fall through */ - default: - return XML_STATUS_OK; - } - } - eventEndPtr = eventPtr; - processor = errorProcessor; - return XML_STATUS_ERROR; - } -#ifndef XML_CONTEXT_BYTES - else if (bufferPtr == bufferEnd) { - const char *end; - int nLeftOver; - enum XML_Error result; - parseEndByteIndex += len; - positionPtr = s; - ps_finalBuffer = (XML_Bool)isFinal; - - errorCode = processor(parser, s, parseEndPtr = s + len, &end); - - if (errorCode != XML_ERROR_NONE) { - eventEndPtr = eventPtr; - processor = errorProcessor; - return XML_STATUS_ERROR; - } - else { - switch (ps_parsing) { - case XML_SUSPENDED: - result = XML_STATUS_SUSPENDED; - break; - case XML_INITIALIZED: - case XML_PARSING: - result = XML_STATUS_OK; - if (isFinal) { - ps_parsing = XML_FINISHED; - return result; - } - } - } - - XmlUpdatePosition(encoding, positionPtr, end, &position); - nLeftOver = s + len - end; - if (nLeftOver) { - if (buffer == NULL || nLeftOver > bufferLim - buffer) { - /* FIXME avoid integer overflow */ - char *temp; - temp = (buffer == NULL - ? (char *)MALLOC(len * 2) - : (char *)REALLOC(buffer, len * 2)); - if (temp == NULL) { - errorCode = XML_ERROR_NO_MEMORY; - eventPtr = eventEndPtr = NULL; - processor = errorProcessor; - return XML_STATUS_ERROR; - } - buffer = temp; - bufferLim = buffer + len * 2; - } - memcpy(buffer, end, nLeftOver); - } - bufferPtr = buffer; - bufferEnd = buffer + nLeftOver; - positionPtr = bufferPtr; - parseEndPtr = bufferEnd; - eventPtr = bufferPtr; - eventEndPtr = bufferPtr; - return result; - } -#endif /* not defined XML_CONTEXT_BYTES */ - else { - void *buff = XML_GetBuffer(parser, len); - if (buff == NULL) - return XML_STATUS_ERROR; - else { - memcpy(buff, s, len); - return XML_ParseBuffer(parser, len, isFinal); - } - } -} - -enum XML_Status XMLCALL -XML_ParseBuffer(XML_Parser parser, int len, int isFinal) -{ - const char *start; - enum XML_Status result = XML_STATUS_OK; - - switch (ps_parsing) { - case XML_SUSPENDED: - errorCode = XML_ERROR_SUSPENDED; - return XML_STATUS_ERROR; - case XML_FINISHED: - errorCode = XML_ERROR_FINISHED; - return XML_STATUS_ERROR; - default: - ps_parsing = XML_PARSING; - } - - start = bufferPtr; - positionPtr = start; - bufferEnd += len; - parseEndPtr = bufferEnd; - parseEndByteIndex += len; - ps_finalBuffer = (XML_Bool)isFinal; - - errorCode = processor(parser, start, parseEndPtr, &bufferPtr); - - if (errorCode != XML_ERROR_NONE) { - eventEndPtr = eventPtr; - processor = errorProcessor; - return XML_STATUS_ERROR; - } - else { - switch (ps_parsing) { - case XML_SUSPENDED: - result = XML_STATUS_SUSPENDED; - break; - case XML_INITIALIZED: - case XML_PARSING: - if (isFinal) { - ps_parsing = XML_FINISHED; - return result; - } - default: ; /* should not happen */ - } - } - - XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); - positionPtr = bufferPtr; - return result; -} - -void * XMLCALL -XML_GetBuffer(XML_Parser parser, int len) -{ - switch (ps_parsing) { - case XML_SUSPENDED: - errorCode = XML_ERROR_SUSPENDED; - return NULL; - case XML_FINISHED: - errorCode = XML_ERROR_FINISHED; - return NULL; - default: ; - } - - if (len > bufferLim - bufferEnd) { - /* FIXME avoid integer overflow */ - int neededSize = len + (int)(bufferEnd - bufferPtr); -#ifdef XML_CONTEXT_BYTES - int keep = (int)(bufferPtr - buffer); - - if (keep > XML_CONTEXT_BYTES) - keep = XML_CONTEXT_BYTES; - neededSize += keep; -#endif /* defined XML_CONTEXT_BYTES */ - if (neededSize <= bufferLim - buffer) { -#ifdef XML_CONTEXT_BYTES - if (keep < bufferPtr - buffer) { - int offset = (int)(bufferPtr - buffer) - keep; - memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep); - bufferEnd -= offset; - bufferPtr -= offset; - } -#else - memmove(buffer, bufferPtr, bufferEnd - bufferPtr); - bufferEnd = buffer + (bufferEnd - bufferPtr); - bufferPtr = buffer; -#endif /* not defined XML_CONTEXT_BYTES */ - } - else { - char *newBuf; - int bufferSize = (int)(bufferLim - bufferPtr); - if (bufferSize == 0) - bufferSize = INIT_BUFFER_SIZE; - do { - bufferSize *= 2; - } while (bufferSize < neededSize); - newBuf = (char *)MALLOC(bufferSize); - if (newBuf == 0) { - errorCode = XML_ERROR_NO_MEMORY; - return NULL; - } - bufferLim = newBuf + bufferSize; -#ifdef XML_CONTEXT_BYTES - if (bufferPtr) { - int keep = (int)(bufferPtr - buffer); - if (keep > XML_CONTEXT_BYTES) - keep = XML_CONTEXT_BYTES; - memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep); - FREE(buffer); - buffer = newBuf; - bufferEnd = buffer + (bufferEnd - bufferPtr) + keep; - bufferPtr = buffer + keep; - } - else { - bufferEnd = newBuf + (bufferEnd - bufferPtr); - bufferPtr = buffer = newBuf; - } -#else - if (bufferPtr) { - memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); - FREE(buffer); - } - bufferEnd = newBuf + (bufferEnd - bufferPtr); - bufferPtr = buffer = newBuf; -#endif /* not defined XML_CONTEXT_BYTES */ - } - eventPtr = eventEndPtr = NULL; - positionPtr = NULL; - } - return bufferEnd; -} - -enum XML_Status XMLCALL -XML_StopParser(XML_Parser parser, XML_Bool resumable) -{ - switch (ps_parsing) { - case XML_SUSPENDED: - if (resumable) { - errorCode = XML_ERROR_SUSPENDED; - return XML_STATUS_ERROR; - } - ps_parsing = XML_FINISHED; - break; - case XML_FINISHED: - errorCode = XML_ERROR_FINISHED; - return XML_STATUS_ERROR; - default: - if (resumable) { -#ifdef XML_DTD - if (isParamEntity) { - errorCode = XML_ERROR_SUSPEND_PE; - return XML_STATUS_ERROR; - } -#endif - ps_parsing = XML_SUSPENDED; - } - else - ps_parsing = XML_FINISHED; - } - return XML_STATUS_OK; -} - -enum XML_Status XMLCALL -XML_ResumeParser(XML_Parser parser) -{ - enum XML_Status result = XML_STATUS_OK; - - if (ps_parsing != XML_SUSPENDED) { - errorCode = XML_ERROR_NOT_SUSPENDED; - return XML_STATUS_ERROR; - } - ps_parsing = XML_PARSING; - - errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); - - if (errorCode != XML_ERROR_NONE) { - eventEndPtr = eventPtr; - processor = errorProcessor; - return XML_STATUS_ERROR; - } - else { - switch (ps_parsing) { - case XML_SUSPENDED: - result = XML_STATUS_SUSPENDED; - break; - case XML_INITIALIZED: - case XML_PARSING: - if (ps_finalBuffer) { - ps_parsing = XML_FINISHED; - return result; - } - default: ; - } - } - - XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); - positionPtr = bufferPtr; - return result; -} - -void XMLCALL -XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status) -{ - assert(status != NULL); - *status = parser->m_parsingStatus; -} - -enum XML_Error XMLCALL -XML_GetErrorCode(XML_Parser parser) -{ - return errorCode; -} - -XML_Index XMLCALL -XML_GetCurrentByteIndex(XML_Parser parser) -{ - if (eventPtr) - return parseEndByteIndex - (parseEndPtr - eventPtr); - return -1; -} - -int XMLCALL -XML_GetCurrentByteCount(XML_Parser parser) -{ - if (eventEndPtr && eventPtr) - return (int)(eventEndPtr - eventPtr); - return 0; -} - -const char * XMLCALL -XML_GetInputContext(XML_Parser parser, int *offset, int *size) -{ -#ifdef XML_CONTEXT_BYTES - if (eventPtr && buffer) { - *offset = (int)(eventPtr - buffer); - *size = (int)(bufferEnd - buffer); - return buffer; - } -#endif /* defined XML_CONTEXT_BYTES */ - return (char *) 0; -} - -XML_Size XMLCALL -XML_GetCurrentLineNumber(XML_Parser parser) -{ - if (eventPtr && eventPtr >= positionPtr) { - XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); - positionPtr = eventPtr; - } - return position.lineNumber + 1; -} - -XML_Size XMLCALL -XML_GetCurrentColumnNumber(XML_Parser parser) -{ - if (eventPtr && eventPtr >= positionPtr) { - XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); - positionPtr = eventPtr; - } - return position.columnNumber; -} - -void XMLCALL -XML_FreeContentModel(XML_Parser parser, XML_Content *model) -{ - FREE(model); -} - -void * XMLCALL -XML_MemMalloc(XML_Parser parser, size_t size) -{ - return MALLOC(size); -} - -void * XMLCALL -XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) -{ - return REALLOC(ptr, size); -} - -void XMLCALL -XML_MemFree(XML_Parser parser, void *ptr) -{ - FREE(ptr); -} - -void XMLCALL -XML_DefaultCurrent(XML_Parser parser) -{ - if (defaultHandler) { - if (openInternalEntities) - reportDefault(parser, - internalEncoding, - openInternalEntities->internalEventPtr, - openInternalEntities->internalEventEndPtr); - else - reportDefault(parser, encoding, eventPtr, eventEndPtr); - } -} - -const XML_LChar * XMLCALL -XML_ErrorString(enum XML_Error code) -{ - static const XML_LChar* const message[] = { - 0, - XML_L("out of memory"), - XML_L("syntax error"), - XML_L("no element found"), - XML_L("not well-formed (invalid token)"), - XML_L("unclosed token"), - XML_L("partial character"), - XML_L("mismatched tag"), - XML_L("duplicate attribute"), - XML_L("junk after document element"), - XML_L("illegal parameter entity reference"), - XML_L("undefined entity"), - XML_L("recursive entity reference"), - XML_L("asynchronous entity"), - XML_L("reference to invalid character number"), - XML_L("reference to binary entity"), - XML_L("reference to external entity in attribute"), - XML_L("XML or text declaration not at start of entity"), - XML_L("unknown encoding"), - XML_L("encoding specified in XML declaration is incorrect"), - XML_L("unclosed CDATA section"), - XML_L("error in processing external entity reference"), - XML_L("document is not standalone"), - XML_L("unexpected parser state - please send a bug report"), - XML_L("entity declared in parameter entity"), - XML_L("requested feature requires XML_DTD support in Expat"), - XML_L("cannot change setting once parsing has begun"), - XML_L("unbound prefix"), - XML_L("must not undeclare prefix"), - XML_L("incomplete markup in parameter entity"), - XML_L("XML declaration not well-formed"), - XML_L("text declaration not well-formed"), - XML_L("illegal character(s) in public id"), - XML_L("parser suspended"), - XML_L("parser not suspended"), - XML_L("parsing aborted"), - XML_L("parsing finished"), - XML_L("cannot suspend in external parameter entity"), - XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"), - XML_L("reserved prefix (xmlns) must not be declared or undeclared"), - XML_L("prefix must not be bound to one of the reserved namespace names") - }; - if (code > 0 && code < sizeof(message)/sizeof(message[0])) - return message[code]; - return NULL; -} - -const XML_LChar * XMLCALL -XML_ExpatVersion(void) { - - /* V1 is used to string-ize the version number. However, it would - string-ize the actual version macro *names* unless we get them - substituted before being passed to V1. CPP is defined to expand - a macro, then rescan for more expansions. Thus, we use V2 to expand - the version macros, then CPP will expand the resulting V1() macro - with the correct numerals. */ - /* ### I'm assuming cpp is portable in this respect... */ - -#define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c) -#define V2(a,b,c) XML_L("expat_")V1(a,b,c) - - return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION); - -#undef V1 -#undef V2 -} - -XML_Expat_Version XMLCALL -XML_ExpatVersionInfo(void) -{ - XML_Expat_Version version; - - version.major = XML_MAJOR_VERSION; - version.minor = XML_MINOR_VERSION; - version.micro = XML_MICRO_VERSION; - - return version; -} - -const XML_Feature * XMLCALL -XML_GetFeatureList(void) -{ - static const XML_Feature features[] = { - {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"), - sizeof(XML_Char)}, - {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"), - sizeof(XML_LChar)}, -#ifdef XML_UNICODE - {XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0}, -#endif -#ifdef XML_UNICODE_WCHAR_T - {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0}, -#endif -#ifdef XML_DTD - {XML_FEATURE_DTD, XML_L("XML_DTD"), 0}, -#endif -#ifdef XML_CONTEXT_BYTES - {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), - XML_CONTEXT_BYTES}, -#endif -#ifdef XML_MIN_SIZE - {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0}, -#endif -#ifdef XML_NS - {XML_FEATURE_NS, XML_L("XML_NS"), 0}, -#endif -#ifdef XML_LARGE_SIZE - {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0}, -#endif - {XML_FEATURE_END, NULL, 0} - }; - - return features; -} - -/* Initially tag->rawName always points into the parse buffer; - for those TAG instances opened while the current parse buffer was - processed, and not yet closed, we need to store tag->rawName in a more - permanent location, since the parse buffer is about to be discarded. -*/ -static XML_Bool -storeRawNames(XML_Parser parser) -{ - TAG *tag = tagStack; - while (tag) { - int bufSize; - int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); - char *rawNameBuf = tag->buf + nameLen; - /* Stop if already stored. Since tagStack is a stack, we can stop - at the first entry that has already been copied; everything - below it in the stack is already been accounted for in a - previous call to this function. - */ - if (tag->rawName == rawNameBuf) - break; - /* For re-use purposes we need to ensure that the - size of tag->buf is a multiple of sizeof(XML_Char). - */ - bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); - if (bufSize > tag->bufEnd - tag->buf) { - char *temp = (char *)REALLOC(tag->buf, bufSize); - if (temp == NULL) - return XML_FALSE; - /* if tag->name.str points to tag->buf (only when namespace - processing is off) then we have to update it - */ - if (tag->name.str == (XML_Char *)tag->buf) - tag->name.str = (XML_Char *)temp; - /* if tag->name.localPart is set (when namespace processing is on) - then update it as well, since it will always point into tag->buf - */ - if (tag->name.localPart) - tag->name.localPart = (XML_Char *)temp + (tag->name.localPart - - (XML_Char *)tag->buf); - tag->buf = temp; - tag->bufEnd = temp + bufSize; - rawNameBuf = temp + nameLen; - } - memcpy(rawNameBuf, tag->rawName, tag->rawNameLength); - tag->rawName = rawNameBuf; - tag = tag->parent; - } - return XML_TRUE; -} - -static enum XML_Error PTRCALL -contentProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = doContent(parser, 0, encoding, start, end, - endPtr, (XML_Bool)!ps_finalBuffer); - if (result == XML_ERROR_NONE) { - if (!storeRawNames(parser)) - return XML_ERROR_NO_MEMORY; - } - return result; -} - -static enum XML_Error PTRCALL -externalEntityInitProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = initializeEncoding(parser); - if (result != XML_ERROR_NONE) - return result; - processor = externalEntityInitProcessor2; - return externalEntityInitProcessor2(parser, start, end, endPtr); -} - -static enum XML_Error PTRCALL -externalEntityInitProcessor2(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - const char *next = start; /* XmlContentTok doesn't always set the last arg */ - int tok = XmlContentTok(encoding, start, end, &next); - switch (tok) { - case XML_TOK_BOM: - /* If we are at the end of the buffer, this would cause the next stage, - i.e. externalEntityInitProcessor3, to pass control directly to - doContent (by detecting XML_TOK_NONE) without processing any xml text - declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent. - */ - if (next == end && !ps_finalBuffer) { - *endPtr = next; - return XML_ERROR_NONE; - } - start = next; - break; - case XML_TOK_PARTIAL: - if (!ps_finalBuffer) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (!ps_finalBuffer) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_PARTIAL_CHAR; - } - processor = externalEntityInitProcessor3; - return externalEntityInitProcessor3(parser, start, end, endPtr); -} - -static enum XML_Error PTRCALL -externalEntityInitProcessor3(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - int tok; - const char *next = start; /* XmlContentTok doesn't always set the last arg */ - eventPtr = start; - tok = XmlContentTok(encoding, start, end, &next); - eventEndPtr = next; - - switch (tok) { - case XML_TOK_XML_DECL: - { - enum XML_Error result; - result = processXmlDecl(parser, 1, start, next); - if (result != XML_ERROR_NONE) - return result; - switch (ps_parsing) { - case XML_SUSPENDED: - *endPtr = next; - return XML_ERROR_NONE; - case XML_FINISHED: - return XML_ERROR_ABORTED; - default: - start = next; - } - } - break; - case XML_TOK_PARTIAL: - if (!ps_finalBuffer) { - *endPtr = start; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (!ps_finalBuffer) { - *endPtr = start; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - } - processor = externalEntityContentProcessor; - tagLevel = 1; - return externalEntityContentProcessor(parser, start, end, endPtr); -} - -static enum XML_Error PTRCALL -externalEntityContentProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = doContent(parser, 1, encoding, start, end, - endPtr, (XML_Bool)!ps_finalBuffer); - if (result == XML_ERROR_NONE) { - if (!storeRawNames(parser)) - return XML_ERROR_NO_MEMORY; - } - return result; -} - -static enum XML_Error -doContent(XML_Parser parser, - int startTagLevel, - const ENCODING *enc, - const char *s, - const char *end, - const char **nextPtr, - XML_Bool haveMore) -{ - /* save one level of indirection */ - DTD * const dtd = _dtd; - - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - - for (;;) { - const char *next = s; /* XmlContentTok doesn't always set the last arg */ - int tok = XmlContentTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_TRAILING_CR: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - *eventEndPP = end; - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, end); - /* We are at the end of the final buffer, should we check for - XML_SUSPENDED, XML_FINISHED? - */ - if (startTagLevel == 0) - return XML_ERROR_NO_ELEMENTS; - if (tagLevel != startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - *nextPtr = end; - return XML_ERROR_NONE; - case XML_TOK_NONE: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - if (startTagLevel > 0) { - if (tagLevel != startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_NO_ELEMENTS; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_ENTITY_REF: - { - const XML_Char *name; - ENTITY *entity; - XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (ch) { - if (characterDataHandler) - characterDataHandler(handlerArg, &ch, 1); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - name = poolStoreString(&dtd->pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); - poolDiscard(&dtd->pool); - /* First, determine if a check for an existing declaration is needed; - if yes, check that the entity exists, and that it is internal, - otherwise call the skipped entity or default handler. - */ - if (!dtd->hasParamEntityRefs || dtd->standalone) { - if (!entity) - return XML_ERROR_UNDEFINED_ENTITY; - else if (!entity->is_internal) - return XML_ERROR_ENTITY_DECLARED_IN_PE; - } - else if (!entity) { - if (skippedEntityHandler) - skippedEntityHandler(handlerArg, name, 0); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - if (entity->open) - return XML_ERROR_RECURSIVE_ENTITY_REF; - if (entity->notation) - return XML_ERROR_BINARY_ENTITY_REF; - if (entity->textPtr) { - enum XML_Error result; - if (!defaultExpandInternalEntities) { - if (skippedEntityHandler) - skippedEntityHandler(handlerArg, entity->name, 0); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - result = processInternalEntity(parser, entity, XML_FALSE); - if (result != XML_ERROR_NONE) - return result; - } - else if (externalEntityRefHandler) { - const XML_Char *context; - entity->open = XML_TRUE; - context = getContext(parser); - entity->open = XML_FALSE; - if (!context) - return XML_ERROR_NO_MEMORY; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - context, - entity->base, - entity->systemId, - entity->publicId)) - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - poolDiscard(&tempPool); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - case XML_TOK_START_TAG_NO_ATTS: - /* fall through */ - case XML_TOK_START_TAG_WITH_ATTS: - { - TAG *tag; - enum XML_Error result; - XML_Char *toPtr; - if (freeTagList) { - tag = freeTagList; - freeTagList = freeTagList->parent; - } - else { - tag = (TAG *)MALLOC(sizeof(TAG)); - if (!tag) - return XML_ERROR_NO_MEMORY; - tag->buf = (char *)MALLOC(INIT_TAG_BUF_SIZE); - if (!tag->buf) { - FREE(tag); - return XML_ERROR_NO_MEMORY; - } - tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; - } - tag->bindings = NULL; - tag->parent = tagStack; - tagStack = tag; - tag->name.localPart = NULL; - tag->name.prefix = NULL; - tag->rawName = s + enc->minBytesPerChar; - tag->rawNameLength = XmlNameLength(enc, tag->rawName); - ++tagLevel; - { - const char *rawNameEnd = tag->rawName + tag->rawNameLength; - const char *fromPtr = tag->rawName; - toPtr = (XML_Char *)tag->buf; - for (;;) { - int bufSize; - int convLen; - XmlConvert(enc, - &fromPtr, rawNameEnd, - (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); - convLen = (int)(toPtr - (XML_Char *)tag->buf); - if (fromPtr == rawNameEnd) { - tag->name.strLen = convLen; - break; - } - bufSize = (int)(tag->bufEnd - tag->buf) << 1; - { - char *temp = (char *)REALLOC(tag->buf, bufSize); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - tag->buf = temp; - tag->bufEnd = temp + bufSize; - toPtr = (XML_Char *)temp + convLen; - } - } - } - tag->name.str = (XML_Char *)tag->buf; - *toPtr = XML_T('\0'); - result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); - if (result) - return result; - if (startElementHandler) - startElementHandler(handlerArg, tag->name.str, - (const XML_Char **)atts); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - poolClear(&tempPool); - break; - } - case XML_TOK_EMPTY_ELEMENT_NO_ATTS: - /* fall through */ - case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: - { - const char *rawName = s + enc->minBytesPerChar; - enum XML_Error result; - BINDING *bindings = NULL; - XML_Bool noElmHandlers = XML_TRUE; - TAG_NAME name; - name.str = poolStoreString(&tempPool, enc, rawName, - rawName + XmlNameLength(enc, rawName)); - if (!name.str) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - result = storeAtts(parser, enc, s, &name, &bindings); - if (result) - return result; - poolFinish(&tempPool); - if (startElementHandler) { - startElementHandler(handlerArg, name.str, (const XML_Char **)atts); - noElmHandlers = XML_FALSE; - } - if (endElementHandler) { - if (startElementHandler) - *eventPP = *eventEndPP; - endElementHandler(handlerArg, name.str); - noElmHandlers = XML_FALSE; - } - if (noElmHandlers && defaultHandler) - reportDefault(parser, enc, s, next); - poolClear(&tempPool); - while (bindings) { - BINDING *b = bindings; - if (endNamespaceDeclHandler) - endNamespaceDeclHandler(handlerArg, b->prefix->name); - bindings = bindings->nextTagBinding; - b->nextTagBinding = freeBindingList; - freeBindingList = b; - b->prefix->binding = b->prevPrefixBinding; - } - } - if (tagLevel == 0) - return epilogProcessor(parser, next, end, nextPtr); - break; - case XML_TOK_END_TAG: - if (tagLevel == startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - else { - int len; - const char *rawName; - TAG *tag = tagStack; - tagStack = tag->parent; - tag->parent = freeTagList; - freeTagList = tag; - rawName = s + enc->minBytesPerChar*2; - len = XmlNameLength(enc, rawName); - if (len != tag->rawNameLength - || memcmp(tag->rawName, rawName, len) != 0) { - *eventPP = rawName; - return XML_ERROR_TAG_MISMATCH; - } - --tagLevel; - if (endElementHandler) { - const XML_Char *localPart; - const XML_Char *prefix; - XML_Char *uri; - localPart = tag->name.localPart; - if (ns && localPart) { - /* localPart and prefix may have been overwritten in - tag->name.str, since this points to the binding->uri - buffer which gets re-used; so we have to add them again - */ - uri = (XML_Char *)tag->name.str + tag->name.uriLen; - /* don't need to check for space - already done in storeAtts() */ - while (*localPart) *uri++ = *localPart++; - prefix = (XML_Char *)tag->name.prefix; - if (ns_triplets && prefix) { - *uri++ = namespaceSeparator; - while (*prefix) *uri++ = *prefix++; - } - *uri = XML_T('\0'); - } - endElementHandler(handlerArg, tag->name.str); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - while (tag->bindings) { - BINDING *b = tag->bindings; - if (endNamespaceDeclHandler) - endNamespaceDeclHandler(handlerArg, b->prefix->name); - tag->bindings = tag->bindings->nextTagBinding; - b->nextTagBinding = freeBindingList; - freeBindingList = b; - b->prefix->binding = b->prevPrefixBinding; - } - if (tagLevel == 0) - return epilogProcessor(parser, next, end, nextPtr); - } - break; - case XML_TOK_CHAR_REF: - { - int n = XmlCharRefNumber(enc, s); - if (n < 0) - return XML_ERROR_BAD_CHAR_REF; - if (characterDataHandler) { - XML_Char buf[XML_ENCODE_MAX]; - characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf)); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - } - break; - case XML_TOK_XML_DECL: - return XML_ERROR_MISPLACED_XML_PI; - case XML_TOK_DATA_NEWLINE: - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_CDATA_SECT_OPEN: - { - enum XML_Error result; - if (startCdataSectionHandler) - startCdataSectionHandler(handlerArg); -#if 0 - /* Suppose you doing a transformation on a document that involves - changing only the character data. You set up a defaultHandler - and a characterDataHandler. The defaultHandler simply copies - characters through. The characterDataHandler does the - transformation and writes the characters out escaping them as - necessary. This case will fail to work if we leave out the - following two lines (because & and < inside CDATA sections will - be incorrectly escaped). - - However, now we have a start/endCdataSectionHandler, so it seems - easier to let the user deal with this. - */ - else if (characterDataHandler) - characterDataHandler(handlerArg, dataBuf, 0); -#endif - else if (defaultHandler) - reportDefault(parser, enc, s, next); - result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore); - if (result != XML_ERROR_NONE) - return result; - else if (!next) { - processor = cdataSectionProcessor; - return result; - } - } - break; - case XML_TOK_TRAILING_RSQB: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - if (characterDataHandler) { - if (MUST_CONVERT(enc, s)) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); - characterDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - } - else - characterDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)end - (XML_Char *)s)); - } - else if (defaultHandler) - reportDefault(parser, enc, s, end); - /* We are at the end of the final buffer, should we check for - XML_SUSPENDED, XML_FINISHED? - */ - if (startTagLevel == 0) { - *eventPP = end; - return XML_ERROR_NO_ELEMENTS; - } - if (tagLevel != startTagLevel) { - *eventPP = end; - return XML_ERROR_ASYNC_ENTITY; - } - *nextPtr = end; - return XML_ERROR_NONE; - case XML_TOK_DATA_CHARS: - { - XML_CharacterDataHandler charDataHandler = characterDataHandler; - if (charDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - charDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - if (s == next) - break; - *eventPP = s; - } - } - else - charDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)next - (XML_Char *)s)); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - } - break; - case XML_TOK_PI: - if (!reportProcessingInstruction(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_COMMENT: - if (!reportComment(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - default: - if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - *eventPP = s = next; - switch (ps_parsing) { - case XML_SUSPENDED: - *nextPtr = next; - return XML_ERROR_NONE; - case XML_FINISHED: - return XML_ERROR_ABORTED; - default: ; - } - } - /* not reached */ -} - -/* Precondition: all arguments must be non-NULL; - Purpose: - - normalize attributes - - check attributes for well-formedness - - generate namespace aware attribute names (URI, prefix) - - build list of attributes for startElementHandler - - default attributes - - process namespace declarations (check and report them) - - generate namespace aware element name (URI, prefix) -*/ -static enum XML_Error -storeAtts(XML_Parser parser, const ENCODING *enc, - const char *attStr, TAG_NAME *tagNamePtr, - BINDING **bindingsPtr) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - ELEMENT_TYPE *elementType; - int nDefaultAtts; - const XML_Char **appAtts; /* the attribute list for the application */ - int attIndex = 0; - int prefixLen; - int i; - int n; - XML_Char *uri; - int nPrefixes = 0; - BINDING *binding; - const XML_Char *localPart; - - /* lookup the element type name */ - elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, tagNamePtr->str,0); - if (!elementType) { - const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str); - if (!name) - return XML_ERROR_NO_MEMORY; - elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, name, - sizeof(ELEMENT_TYPE)); - if (!elementType) - return XML_ERROR_NO_MEMORY; - if (ns && !setElementTypePrefix(parser, elementType)) - return XML_ERROR_NO_MEMORY; - } - nDefaultAtts = elementType->nDefaultAtts; - - /* get the attributes from the tokenizer */ - n = XmlGetAttributes(enc, attStr, attsSize, atts); - if (n + nDefaultAtts > attsSize) { - int oldAttsSize = attsSize; - ATTRIBUTE *temp; - attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; - temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - atts = temp; - if (n > oldAttsSize) - XmlGetAttributes(enc, attStr, n, atts); - } - - appAtts = (const XML_Char **)atts; - for (i = 0; i < n; i++) { - /* add the name and value to the attribute list */ - ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name, - atts[i].name - + XmlNameLength(enc, atts[i].name)); - if (!attId) - return XML_ERROR_NO_MEMORY; - /* Detect duplicate attributes by their QNames. This does not work when - namespace processing is turned on and different prefixes for the same - namespace are used. For this case we have a check further down. - */ - if ((attId->name)[-1]) { - if (enc == encoding) - eventPtr = atts[i].name; - return XML_ERROR_DUPLICATE_ATTRIBUTE; - } - (attId->name)[-1] = 1; - appAtts[attIndex++] = attId->name; - if (!atts[i].normalized) { - enum XML_Error result; - XML_Bool isCdata = XML_TRUE; - - /* figure out whether declared as other than CDATA */ - if (attId->maybeTokenized) { - int j; - for (j = 0; j < nDefaultAtts; j++) { - if (attId == elementType->defaultAtts[j].id) { - isCdata = elementType->defaultAtts[j].isCdata; - break; - } - } - } - - /* normalize the attribute value */ - result = storeAttributeValue(parser, enc, isCdata, - atts[i].valuePtr, atts[i].valueEnd, - &tempPool); - if (result) - return result; - appAtts[attIndex] = poolStart(&tempPool); - poolFinish(&tempPool); - } - else { - /* the value did not need normalizing */ - appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, - atts[i].valueEnd); - if (appAtts[attIndex] == 0) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - } - /* handle prefixed attribute names */ - if (attId->prefix) { - if (attId->xmlns) { - /* deal with namespace declarations here */ - enum XML_Error result = addBinding(parser, attId->prefix, attId, - appAtts[attIndex], bindingsPtr); - if (result) - return result; - --attIndex; - } - else { - /* deal with other prefixed names later */ - attIndex++; - nPrefixes++; - (attId->name)[-1] = 2; - } - } - else - attIndex++; - } - - /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ - nSpecifiedAtts = attIndex; - if (elementType->idAtt && (elementType->idAtt->name)[-1]) { - for (i = 0; i < attIndex; i += 2) - if (appAtts[i] == elementType->idAtt->name) { - idAttIndex = i; - break; - } - } - else - idAttIndex = -1; - - /* do attribute defaulting */ - for (i = 0; i < nDefaultAtts; i++) { - const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i; - if (!(da->id->name)[-1] && da->value) { - if (da->id->prefix) { - if (da->id->xmlns) { - enum XML_Error result = addBinding(parser, da->id->prefix, da->id, - da->value, bindingsPtr); - if (result) - return result; - } - else { - (da->id->name)[-1] = 2; - nPrefixes++; - appAtts[attIndex++] = da->id->name; - appAtts[attIndex++] = da->value; - } - } - else { - (da->id->name)[-1] = 1; - appAtts[attIndex++] = da->id->name; - appAtts[attIndex++] = da->value; - } - } - } - appAtts[attIndex] = 0; - - /* expand prefixed attribute names, check for duplicates, - and clear flags that say whether attributes were specified */ - i = 0; - if (nPrefixes) { - int j; /* hash table index */ - unsigned long version = nsAttsVersion; - int nsAttsSize = (int)1 << nsAttsPower; - /* size of hash table must be at least 2 * (# of prefixed attributes) */ - if ((nPrefixes << 1) >> nsAttsPower) { /* true for nsAttsPower = 0 */ - NS_ATT *temp; - /* hash table size must also be a power of 2 and >= 8 */ - while (nPrefixes >> nsAttsPower++); - if (nsAttsPower < 3) - nsAttsPower = 3; - nsAttsSize = (int)1 << nsAttsPower; - temp = (NS_ATT *)REALLOC(nsAtts, nsAttsSize * sizeof(NS_ATT)); - if (!temp) - return XML_ERROR_NO_MEMORY; - nsAtts = temp; - version = 0; /* force re-initialization of nsAtts hash table */ - } - /* using a version flag saves us from initializing nsAtts every time */ - if (!version) { /* initialize version flags when version wraps around */ - version = INIT_ATTS_VERSION; - for (j = nsAttsSize; j != 0; ) - nsAtts[--j].version = version; - } - nsAttsVersion = --version; - - /* expand prefixed names and check for duplicates */ - for (; i < attIndex; i += 2) { - const XML_Char *s = appAtts[i]; - if (s[-1] == 2) { /* prefixed */ - ATTRIBUTE_ID *id; - const BINDING *b; - unsigned long uriHash = 0; - ((XML_Char *)s)[-1] = 0; /* clear flag */ - id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0); - b = id->prefix->binding; - if (!b) - return XML_ERROR_UNBOUND_PREFIX; - - /* as we expand the name we also calculate its hash value */ - for (j = 0; j < b->uriLen; j++) { - const XML_Char c = b->uri[j]; - if (!poolAppendChar(&tempPool, c)) - return XML_ERROR_NO_MEMORY; - uriHash = CHAR_HASH(uriHash, c); - } - while (*s++ != XML_T(ASCII_COLON)) - ; - do { /* copies null terminator */ - const XML_Char c = *s; - if (!poolAppendChar(&tempPool, *s)) - return XML_ERROR_NO_MEMORY; - uriHash = CHAR_HASH(uriHash, c); - } while (*s++); - - { /* Check hash table for duplicate of expanded name (uriName). - Derived from code in lookup(HASH_TABLE *table, ...). - */ - unsigned char step = 0; - unsigned long mask = nsAttsSize - 1; - j = uriHash & mask; /* index into hash table */ - while (nsAtts[j].version == version) { - /* for speed we compare stored hash values first */ - if (uriHash == nsAtts[j].hash) { - const XML_Char *s1 = poolStart(&tempPool); - const XML_Char *s2 = nsAtts[j].uriName; - /* s1 is null terminated, but not s2 */ - for (; *s1 == *s2 && *s1 != 0; s1++, s2++); - if (*s1 == 0) - return XML_ERROR_DUPLICATE_ATTRIBUTE; - } - if (!step) - step = PROBE_STEP(uriHash, mask, nsAttsPower); - j < step ? (j += nsAttsSize - step) : (j -= step); - } - } - - if (ns_triplets) { /* append namespace separator and prefix */ - tempPool.ptr[-1] = namespaceSeparator; - s = b->prefix->name; - do { - if (!poolAppendChar(&tempPool, *s)) - return XML_ERROR_NO_MEMORY; - } while (*s++); - } - - /* store expanded name in attribute list */ - s = poolStart(&tempPool); - poolFinish(&tempPool); - appAtts[i] = s; - - /* fill empty slot with new version, uriName and hash value */ - nsAtts[j].version = version; - nsAtts[j].hash = uriHash; - nsAtts[j].uriName = s; - - if (!--nPrefixes) { - i += 2; - break; - } - } - else /* not prefixed */ - ((XML_Char *)s)[-1] = 0; /* clear flag */ - } - } - /* clear flags for the remaining attributes */ - for (; i < attIndex; i += 2) - ((XML_Char *)(appAtts[i]))[-1] = 0; - for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) - binding->attId->name[-1] = 0; - - if (!ns) - return XML_ERROR_NONE; - - /* expand the element type name */ - if (elementType->prefix) { - binding = elementType->prefix->binding; - if (!binding) - return XML_ERROR_UNBOUND_PREFIX; - localPart = tagNamePtr->str; - while (*localPart++ != XML_T(ASCII_COLON)) - ; - } - else if (dtd->defaultPrefix.binding) { - binding = dtd->defaultPrefix.binding; - localPart = tagNamePtr->str; - } - else - return XML_ERROR_NONE; - prefixLen = 0; - if (ns_triplets && binding->prefix->name) { - for (; binding->prefix->name[prefixLen++];) - ; /* prefixLen includes null terminator */ - } - tagNamePtr->localPart = localPart; - tagNamePtr->uriLen = binding->uriLen; - tagNamePtr->prefix = binding->prefix->name; - tagNamePtr->prefixLen = prefixLen; - for (i = 0; localPart[i++];) - ; /* i includes null terminator */ - n = i + binding->uriLen + prefixLen; - if (n > binding->uriAlloc) { - TAG *p; - uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); - if (!uri) - return XML_ERROR_NO_MEMORY; - binding->uriAlloc = n + EXPAND_SPARE; - memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); - for (p = tagStack; p; p = p->parent) - if (p->name.str == binding->uri) - p->name.str = uri; - FREE(binding->uri); - binding->uri = uri; - } - /* if namespaceSeparator != '\0' then uri includes it already */ - uri = binding->uri + binding->uriLen; - memcpy(uri, localPart, i * sizeof(XML_Char)); - /* we always have a namespace separator between localPart and prefix */ - if (prefixLen) { - uri += i - 1; - *uri = namespaceSeparator; /* replace null terminator */ - memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char)); - } - tagNamePtr->str = binding->uri; - return XML_ERROR_NONE; -} - -/* addBinding() overwrites the value of prefix->binding without checking. - Therefore one must keep track of the old value outside of addBinding(). -*/ -static enum XML_Error -addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, - const XML_Char *uri, BINDING **bindingsPtr) -{ - static const XML_Char xmlNamespace[] = { - ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, - ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, - ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, - ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH, - ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, - ASCII_e, '\0' - }; - static const int xmlLen = - (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; - static const XML_Char xmlnsNamespace[] = { - ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, - ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, - ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, - ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, - ASCII_SLASH, '\0' - }; - static const int xmlnsLen = - (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; - - XML_Bool mustBeXML = XML_FALSE; - XML_Bool isXML = XML_TRUE; - XML_Bool isXMLNS = XML_TRUE; - - BINDING *b; - int len; - - /* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) */ - if (*uri == XML_T('\0') && prefix->name) - return XML_ERROR_UNDECLARING_PREFIX; - - if (prefix->name - && prefix->name[0] == XML_T(ASCII_x) - && prefix->name[1] == XML_T(ASCII_m) - && prefix->name[2] == XML_T(ASCII_l)) { - - /* Not allowed to bind xmlns */ - if (prefix->name[3] == XML_T(ASCII_n) - && prefix->name[4] == XML_T(ASCII_s) - && prefix->name[5] == XML_T('\0')) - return XML_ERROR_RESERVED_PREFIX_XMLNS; - - if (prefix->name[3] == XML_T('\0')) - mustBeXML = XML_TRUE; - } - - for (len = 0; uri[len]; len++) { - if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) - isXML = XML_FALSE; - - if (!mustBeXML && isXMLNS - && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) - isXMLNS = XML_FALSE; - } - isXML = isXML && len == xmlLen; - isXMLNS = isXMLNS && len == xmlnsLen; - - if (mustBeXML != isXML) - return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML - : XML_ERROR_RESERVED_NAMESPACE_URI; - - if (isXMLNS) - return XML_ERROR_RESERVED_NAMESPACE_URI; - - if (namespaceSeparator) - len++; - if (freeBindingList) { - b = freeBindingList; - if (len > b->uriAlloc) { - XML_Char *temp = (XML_Char *)REALLOC(b->uri, - sizeof(XML_Char) * (len + EXPAND_SPARE)); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - b->uri = temp; - b->uriAlloc = len + EXPAND_SPARE; - } - freeBindingList = b->nextTagBinding; - } - else { - b = (BINDING *)MALLOC(sizeof(BINDING)); - if (!b) - return XML_ERROR_NO_MEMORY; - b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); - if (!b->uri) { - FREE(b); - return XML_ERROR_NO_MEMORY; - } - b->uriAlloc = len + EXPAND_SPARE; - } - b->uriLen = len; - memcpy(b->uri, uri, len * sizeof(XML_Char)); - if (namespaceSeparator) - b->uri[len - 1] = namespaceSeparator; - b->prefix = prefix; - b->attId = attId; - b->prevPrefixBinding = prefix->binding; - /* NULL binding when default namespace undeclared */ - if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix) - prefix->binding = NULL; - else - prefix->binding = b; - b->nextTagBinding = *bindingsPtr; - *bindingsPtr = b; - /* if attId == NULL then we are not starting a namespace scope */ - if (attId && startNamespaceDeclHandler) - startNamespaceDeclHandler(handlerArg, prefix->name, - prefix->binding ? uri : 0); - return XML_ERROR_NONE; -} - -/* The idea here is to avoid using stack for each CDATA section when - the whole file is parsed with one call. -*/ -static enum XML_Error PTRCALL -cdataSectionProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = doCdataSection(parser, encoding, &start, end, - endPtr, (XML_Bool)!ps_finalBuffer); - if (result != XML_ERROR_NONE) - return result; - if (start) { - if (parentParser) { /* we are parsing an external entity */ - processor = externalEntityContentProcessor; - return externalEntityContentProcessor(parser, start, end, endPtr); - } - else { - processor = contentProcessor; - return contentProcessor(parser, start, end, endPtr); - } - } - return result; -} - -/* startPtr gets set to non-null if the section is closed, and to null if - the section is not yet closed. -*/ -static enum XML_Error -doCdataSection(XML_Parser parser, - const ENCODING *enc, - const char **startPtr, - const char *end, - const char **nextPtr, - XML_Bool haveMore) -{ - const char *s = *startPtr; - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - *eventPP = s; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - *startPtr = NULL; - - for (;;) { - const char *next; - int tok = XmlCdataSectionTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_CDATA_SECT_CLOSE: - if (endCdataSectionHandler) - endCdataSectionHandler(handlerArg); -#if 0 - /* see comment under XML_TOK_CDATA_SECT_OPEN */ - else if (characterDataHandler) - characterDataHandler(handlerArg, dataBuf, 0); -#endif - else if (defaultHandler) - reportDefault(parser, enc, s, next); - *startPtr = next; - *nextPtr = next; - if (ps_parsing == XML_FINISHED) - return XML_ERROR_ABORTED; - else - return XML_ERROR_NONE; - case XML_TOK_DATA_NEWLINE: - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_DATA_CHARS: - { - XML_CharacterDataHandler charDataHandler = characterDataHandler; - if (charDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = next; - charDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - if (s == next) - break; - *eventPP = s; - } - } - else - charDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)next - (XML_Char *)s)); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - } - break; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_PARTIAL: - case XML_TOK_NONE: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_CDATA_SECTION; - default: - *eventPP = next; - return XML_ERROR_UNEXPECTED_STATE; - } - - *eventPP = s = next; - switch (ps_parsing) { - case XML_SUSPENDED: - *nextPtr = next; - return XML_ERROR_NONE; - case XML_FINISHED: - return XML_ERROR_ABORTED; - default: ; - } - } - /* not reached */ -} - -#ifdef XML_DTD - -/* The idea here is to avoid using stack for each IGNORE section when - the whole file is parsed with one call. -*/ -static enum XML_Error PTRCALL -ignoreSectionProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, - endPtr, (XML_Bool)!ps_finalBuffer); - if (result != XML_ERROR_NONE) - return result; - if (start) { - processor = prologProcessor; - return prologProcessor(parser, start, end, endPtr); - } - return result; -} - -/* startPtr gets set to non-null is the section is closed, and to null - if the section is not yet closed. -*/ -static enum XML_Error -doIgnoreSection(XML_Parser parser, - const ENCODING *enc, - const char **startPtr, - const char *end, - const char **nextPtr, - XML_Bool haveMore) -{ - const char *next; - int tok; - const char *s = *startPtr; - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - *eventPP = s; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - *startPtr = NULL; - tok = XmlIgnoreSectionTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_IGNORE_SECT: - if (defaultHandler) - reportDefault(parser, enc, s, next); - *startPtr = next; - *nextPtr = next; - if (ps_parsing == XML_FINISHED) - return XML_ERROR_ABORTED; - else - return XML_ERROR_NONE; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_PARTIAL: - case XML_TOK_NONE: - if (haveMore) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ - default: - *eventPP = next; - return XML_ERROR_UNEXPECTED_STATE; - } - /* not reached */ -} - -#endif /* XML_DTD */ - -static enum XML_Error -initializeEncoding(XML_Parser parser) -{ - const char *s; -#ifdef XML_UNICODE - char encodingBuf[128]; - if (!protocolEncodingName) - s = NULL; - else { - int i; - for (i = 0; protocolEncodingName[i]; i++) { - if (i == sizeof(encodingBuf) - 1 - || (protocolEncodingName[i] & ~0x7f) != 0) { - encodingBuf[0] = '\0'; - break; - } - encodingBuf[i] = (char)protocolEncodingName[i]; - } - encodingBuf[i] = '\0'; - s = encodingBuf; - } -#else - s = protocolEncodingName; -#endif - if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s)) - return XML_ERROR_NONE; - return handleUnknownEncoding(parser, protocolEncodingName); -} - -static enum XML_Error -processXmlDecl(XML_Parser parser, int isGeneralTextEntity, - const char *s, const char *next) -{ - const char *encodingName = NULL; - const XML_Char *storedEncName = NULL; - const ENCODING *newEncoding = NULL; - const char *version = NULL; - const char *versionend; - const XML_Char *storedversion = NULL; - int standalone = -1; - if (!(ns - ? XmlParseXmlDeclNS - : XmlParseXmlDecl)(isGeneralTextEntity, - encoding, - s, - next, - &eventPtr, - &version, - &versionend, - &encodingName, - &newEncoding, - &standalone)) { - if (isGeneralTextEntity) - return XML_ERROR_TEXT_DECL; - else - return XML_ERROR_XML_DECL; - } - if (!isGeneralTextEntity && standalone == 1) { - _dtd->standalone = XML_TRUE; -#ifdef XML_DTD - if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) - paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; -#endif /* XML_DTD */ - } - if (xmlDeclHandler) { - if (encodingName != NULL) { - storedEncName = poolStoreString(&temp2Pool, - encoding, - encodingName, - encodingName - + XmlNameLength(encoding, encodingName)); - if (!storedEncName) - return XML_ERROR_NO_MEMORY; - poolFinish(&temp2Pool); - } - if (version) { - storedversion = poolStoreString(&temp2Pool, - encoding, - version, - versionend - encoding->minBytesPerChar); - if (!storedversion) - return XML_ERROR_NO_MEMORY; - } - xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone); - } - else if (defaultHandler) - reportDefault(parser, encoding, s, next); - if (protocolEncodingName == NULL) { - if (newEncoding) { - if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) { - eventPtr = encodingName; - return XML_ERROR_INCORRECT_ENCODING; - } - encoding = newEncoding; - } - else if (encodingName) { - enum XML_Error result; - if (!storedEncName) { - storedEncName = poolStoreString( - &temp2Pool, encoding, encodingName, - encodingName + XmlNameLength(encoding, encodingName)); - if (!storedEncName) - return XML_ERROR_NO_MEMORY; - } - result = handleUnknownEncoding(parser, storedEncName); - poolClear(&temp2Pool); - if (result == XML_ERROR_UNKNOWN_ENCODING) - eventPtr = encodingName; - return result; - } - } - - if (storedEncName || storedversion) - poolClear(&temp2Pool); - - return XML_ERROR_NONE; -} - -static enum XML_Error -handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) -{ - if (unknownEncodingHandler) { - XML_Encoding info; - int i; - for (i = 0; i < 256; i++) - info.map[i] = -1; - info.convert = NULL; - info.data = NULL; - info.release = NULL; - if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, - &info)) { - ENCODING *enc; - unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding()); - if (!unknownEncodingMem) { - if (info.release) - info.release(info.data); - return XML_ERROR_NO_MEMORY; - } - enc = (ns - ? XmlInitUnknownEncodingNS - : XmlInitUnknownEncoding)(unknownEncodingMem, - info.map, - info.convert, - info.data); - if (enc) { - unknownEncodingData = info.data; - unknownEncodingRelease = info.release; - encoding = enc; - return XML_ERROR_NONE; - } - } - if (info.release != NULL) - info.release(info.data); - } - return XML_ERROR_UNKNOWN_ENCODING; -} - -static enum XML_Error PTRCALL -prologInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - enum XML_Error result = initializeEncoding(parser); - if (result != XML_ERROR_NONE) - return result; - processor = prologProcessor; - return prologProcessor(parser, s, end, nextPtr); -} - -#ifdef XML_DTD - -static enum XML_Error PTRCALL -externalParEntInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - enum XML_Error result = initializeEncoding(parser); - if (result != XML_ERROR_NONE) - return result; - - /* we know now that XML_Parse(Buffer) has been called, - so we consider the external parameter entity read */ - _dtd->paramEntityRead = XML_TRUE; - - if (prologState.inEntityValue) { - processor = entityValueInitProcessor; - return entityValueInitProcessor(parser, s, end, nextPtr); - } - else { - processor = externalParEntProcessor; - return externalParEntProcessor(parser, s, end, nextPtr); - } -} - -static enum XML_Error PTRCALL -entityValueInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - int tok; - const char *start = s; - const char *next = start; - eventPtr = start; - - for (;;) { - tok = XmlPrologTok(encoding, start, end, &next); - eventEndPtr = next; - if (tok <= 0) { - if (!ps_finalBuffer && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_NONE: /* start == end */ - default: - break; - } - /* found end of entity value - can store it now */ - return storeEntityValue(parser, encoding, s, end); - } - else if (tok == XML_TOK_XML_DECL) { - enum XML_Error result; - result = processXmlDecl(parser, 0, start, next); - if (result != XML_ERROR_NONE) - return result; - switch (ps_parsing) { - case XML_SUSPENDED: - *nextPtr = next; - return XML_ERROR_NONE; - case XML_FINISHED: - return XML_ERROR_ABORTED; - default: - *nextPtr = next; - } - /* stop scanning for text declaration - we found one */ - processor = entityValueProcessor; - return entityValueProcessor(parser, next, end, nextPtr); - } - /* If we are at the end of the buffer, this would cause XmlPrologTok to - return XML_TOK_NONE on the next call, which would then cause the - function to exit with *nextPtr set to s - that is what we want for other - tokens, but not for the BOM - we would rather like to skip it; - then, when this routine is entered the next time, XmlPrologTok will - return XML_TOK_INVALID, since the BOM is still in the buffer - */ - else if (tok == XML_TOK_BOM && next == end && !ps_finalBuffer) { - *nextPtr = next; - return XML_ERROR_NONE; - } - start = next; - eventPtr = start; - } -} - -static enum XML_Error PTRCALL -externalParEntProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - const char *next = s; - int tok; - - tok = XmlPrologTok(encoding, s, end, &next); - if (tok <= 0) { - if (!ps_finalBuffer && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_NONE: /* start == end */ - default: - break; - } - } - /* This would cause the next stage, i.e. doProlog to be passed XML_TOK_BOM. - However, when parsing an external subset, doProlog will not accept a BOM - as valid, and report a syntax error, so we have to skip the BOM - */ - else if (tok == XML_TOK_BOM) { - s = next; - tok = XmlPrologTok(encoding, s, end, &next); - } - - processor = prologProcessor; - return doProlog(parser, encoding, s, end, tok, next, - nextPtr, (XML_Bool)!ps_finalBuffer); -} - -static enum XML_Error PTRCALL -entityValueProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - const char *start = s; - const char *next = s; - const ENCODING *enc = encoding; - int tok; - - for (;;) { - tok = XmlPrologTok(enc, start, end, &next); - if (tok <= 0) { - if (!ps_finalBuffer && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_NONE: /* start == end */ - default: - break; - } - /* found end of entity value - can store it now */ - return storeEntityValue(parser, enc, s, end); - } - start = next; - } -} - -#endif /* XML_DTD */ - -static enum XML_Error PTRCALL -prologProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - const char *next = s; - int tok = XmlPrologTok(encoding, s, end, &next); - return doProlog(parser, encoding, s, end, tok, next, - nextPtr, (XML_Bool)!ps_finalBuffer); -} - -static enum XML_Error -doProlog(XML_Parser parser, - const ENCODING *enc, - const char *s, - const char *end, - int tok, - const char *next, - const char **nextPtr, - XML_Bool haveMore) -{ -#ifdef XML_DTD - static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' }; -#endif /* XML_DTD */ - static const XML_Char atypeCDATA[] = - { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; - static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' }; - static const XML_Char atypeIDREF[] = - { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; - static const XML_Char atypeIDREFS[] = - { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; - static const XML_Char atypeENTITY[] = - { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; - static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N, - ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' }; - static const XML_Char atypeNMTOKEN[] = { - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; - static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, - ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' }; - static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T, - ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' }; - static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' }; - static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' }; - - /* save one level of indirection */ - DTD * const dtd = _dtd; - - const char **eventPP; - const char **eventEndPP; - enum XML_Content_Quant quant; - - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - - for (;;) { - int role; - XML_Bool handleDefault = XML_TRUE; - *eventPP = s; - *eventEndPP = next; - if (tok <= 0) { - if (haveMore && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case -XML_TOK_PROLOG_S: - tok = -tok; - break; - case XML_TOK_NONE: -#ifdef XML_DTD - /* for internal PE NOT referenced between declarations */ - if (enc != encoding && !openInternalEntities->betweenDecl) { - *nextPtr = s; - return XML_ERROR_NONE; - } - /* WFC: PE Between Declarations - must check that PE contains - complete markup, not only for external PEs, but also for - internal PEs if the reference occurs between declarations. - */ - if (isParamEntity || enc != encoding) { - if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc) - == XML_ROLE_ERROR) - return XML_ERROR_INCOMPLETE_PE; - *nextPtr = s; - return XML_ERROR_NONE; - } -#endif /* XML_DTD */ - return XML_ERROR_NO_ELEMENTS; - default: - tok = -tok; - next = end; - break; - } - } - role = XmlTokenRole(&prologState, tok, s, next, enc); - switch (role) { - case XML_ROLE_XML_DECL: - { - enum XML_Error result = processXmlDecl(parser, 0, s, next); - if (result != XML_ERROR_NONE) - return result; - enc = encoding; - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_DOCTYPE_NAME: - if (startDoctypeDeclHandler) { - doctypeName = poolStoreString(&tempPool, enc, s, next); - if (!doctypeName) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - doctypePubid = NULL; - handleDefault = XML_FALSE; - } - doctypeSysid = NULL; /* always initialize to NULL */ - break; - case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: - if (startDoctypeDeclHandler) { - startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, - doctypePubid, 1); - doctypeName = NULL; - poolClear(&tempPool); - handleDefault = XML_FALSE; - } - break; -#ifdef XML_DTD - case XML_ROLE_TEXT_DECL: - { - enum XML_Error result = processXmlDecl(parser, 1, s, next); - if (result != XML_ERROR_NONE) - return result; - enc = encoding; - handleDefault = XML_FALSE; - } - break; -#endif /* XML_DTD */ - case XML_ROLE_DOCTYPE_PUBLIC_ID: -#ifdef XML_DTD - useForeignDTD = XML_FALSE; - declEntity = (ENTITY *)lookup(&dtd->paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; -#endif /* XML_DTD */ - dtd->hasParamEntityRefs = XML_TRUE; - if (startDoctypeDeclHandler) { - XML_Char *pubId; - if (!XmlIsPublicId(enc, s, next, eventPP)) - return XML_ERROR_PUBLICID; - pubId = poolStoreString(&tempPool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!pubId) - return XML_ERROR_NO_MEMORY; - normalizePublicId(pubId); - poolFinish(&tempPool); - doctypePubid = pubId; - handleDefault = XML_FALSE; - goto alreadyChecked; - } - /* fall through */ - case XML_ROLE_ENTITY_PUBLIC_ID: - if (!XmlIsPublicId(enc, s, next, eventPP)) - return XML_ERROR_PUBLICID; - alreadyChecked: - if (dtd->keepProcessing && declEntity) { - XML_Char *tem = poolStoreString(&dtd->pool, - enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!tem) - return XML_ERROR_NO_MEMORY; - normalizePublicId(tem); - declEntity->publicId = tem; - poolFinish(&dtd->pool); - if (entityDeclHandler) - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_DOCTYPE_CLOSE: - if (doctypeName) { - startDoctypeDeclHandler(handlerArg, doctypeName, - doctypeSysid, doctypePubid, 0); - poolClear(&tempPool); - handleDefault = XML_FALSE; - } - /* doctypeSysid will be non-NULL in the case of a previous - XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler - was not set, indicating an external subset - */ -#ifdef XML_DTD - if (doctypeSysid || useForeignDTD) { - XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; - dtd->hasParamEntityRefs = XML_TRUE; - if (paramEntityParsing && externalEntityRefHandler) { - ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!entity) - return XML_ERROR_NO_MEMORY; - if (useForeignDTD) - entity->base = curBase; - dtd->paramEntityRead = XML_FALSE; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - if (dtd->paramEntityRead) { - if (!dtd->standalone && - notStandaloneHandler && - !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - } - /* if we didn't read the foreign DTD then this means that there - is no external subset and we must reset dtd->hasParamEntityRefs - */ - else if (!doctypeSysid) - dtd->hasParamEntityRefs = hadParamEntityRefs; - /* end of DTD - no need to update dtd->keepProcessing */ - } - useForeignDTD = XML_FALSE; - } -#endif /* XML_DTD */ - if (endDoctypeDeclHandler) { - endDoctypeDeclHandler(handlerArg); - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_INSTANCE_START: -#ifdef XML_DTD - /* if there is no DOCTYPE declaration then now is the - last chance to read the foreign DTD - */ - if (useForeignDTD) { - XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; - dtd->hasParamEntityRefs = XML_TRUE; - if (paramEntityParsing && externalEntityRefHandler) { - ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!entity) - return XML_ERROR_NO_MEMORY; - entity->base = curBase; - dtd->paramEntityRead = XML_FALSE; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - if (dtd->paramEntityRead) { - if (!dtd->standalone && - notStandaloneHandler && - !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - } - /* if we didn't read the foreign DTD then this means that there - is no external subset and we must reset dtd->hasParamEntityRefs - */ - else - dtd->hasParamEntityRefs = hadParamEntityRefs; - /* end of DTD - no need to update dtd->keepProcessing */ - } - } -#endif /* XML_DTD */ - processor = contentProcessor; - return contentProcessor(parser, s, end, nextPtr); - case XML_ROLE_ATTLIST_ELEMENT_NAME: - declElementType = getElementType(parser, enc, s, next); - if (!declElementType) - return XML_ERROR_NO_MEMORY; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_NAME: - declAttributeId = getAttributeId(parser, enc, s, next); - if (!declAttributeId) - return XML_ERROR_NO_MEMORY; - declAttributeIsCdata = XML_FALSE; - declAttributeType = NULL; - declAttributeIsId = XML_FALSE; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_CDATA: - declAttributeIsCdata = XML_TRUE; - declAttributeType = atypeCDATA; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_ID: - declAttributeIsId = XML_TRUE; - declAttributeType = atypeID; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_IDREF: - declAttributeType = atypeIDREF; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: - declAttributeType = atypeIDREFS; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: - declAttributeType = atypeENTITY; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: - declAttributeType = atypeENTITIES; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: - declAttributeType = atypeNMTOKEN; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: - declAttributeType = atypeNMTOKENS; - checkAttListDeclHandler: - if (dtd->keepProcessing && attlistDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_ATTRIBUTE_ENUM_VALUE: - case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: - if (dtd->keepProcessing && attlistDeclHandler) { - const XML_Char *prefix; - if (declAttributeType) { - prefix = enumValueSep; - } - else { - prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE - ? notationPrefix - : enumValueStart); - } - if (!poolAppendString(&tempPool, prefix)) - return XML_ERROR_NO_MEMORY; - if (!poolAppend(&tempPool, enc, s, next)) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: - case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: - if (dtd->keepProcessing) { - if (!defineAttribute(declElementType, declAttributeId, - declAttributeIsCdata, declAttributeIsId, - 0, parser)) - return XML_ERROR_NO_MEMORY; - if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == XML_T(ASCII_LPAREN) - || (*declAttributeType == XML_T(ASCII_N) - && declAttributeType[1] == XML_T(ASCII_O))) { - /* Enumerated or Notation type */ - if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) - || !poolAppendChar(&tempPool, XML_T('\0'))) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - poolFinish(&tempPool); - } - *eventEndPP = s; - attlistDeclHandler(handlerArg, declElementType->name, - declAttributeId->name, declAttributeType, - 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); - poolClear(&tempPool); - handleDefault = XML_FALSE; - } - } - break; - case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: - case XML_ROLE_FIXED_ATTRIBUTE_VALUE: - if (dtd->keepProcessing) { - const XML_Char *attVal; - enum XML_Error result = - storeAttributeValue(parser, enc, declAttributeIsCdata, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar, - &dtd->pool); - if (result) - return result; - attVal = poolStart(&dtd->pool); - poolFinish(&dtd->pool); - /* ID attributes aren't allowed to have a default */ - if (!defineAttribute(declElementType, declAttributeId, - declAttributeIsCdata, XML_FALSE, attVal, parser)) - return XML_ERROR_NO_MEMORY; - if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == XML_T(ASCII_LPAREN) - || (*declAttributeType == XML_T(ASCII_N) - && declAttributeType[1] == XML_T(ASCII_O))) { - /* Enumerated or Notation type */ - if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) - || !poolAppendChar(&tempPool, XML_T('\0'))) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - poolFinish(&tempPool); - } - *eventEndPP = s; - attlistDeclHandler(handlerArg, declElementType->name, - declAttributeId->name, declAttributeType, - attVal, - role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); - poolClear(&tempPool); - handleDefault = XML_FALSE; - } - } - break; - case XML_ROLE_ENTITY_VALUE: - if (dtd->keepProcessing) { - enum XML_Error result = storeEntityValue(parser, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (declEntity) { - declEntity->textPtr = poolStart(&dtd->entityValuePool); - declEntity->textLen = (int)(poolLength(&dtd->entityValuePool)); - poolFinish(&dtd->entityValuePool); - if (entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - declEntity->is_param, - declEntity->textPtr, - declEntity->textLen, - curBase, 0, 0, 0); - handleDefault = XML_FALSE; - } - } - else - poolDiscard(&dtd->entityValuePool); - if (result != XML_ERROR_NONE) - return result; - } - break; - case XML_ROLE_DOCTYPE_SYSTEM_ID: -#ifdef XML_DTD - useForeignDTD = XML_FALSE; -#endif /* XML_DTD */ - dtd->hasParamEntityRefs = XML_TRUE; - if (startDoctypeDeclHandler) { - doctypeSysid = poolStoreString(&tempPool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (doctypeSysid == NULL) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - handleDefault = XML_FALSE; - } -#ifdef XML_DTD - else - /* use externalSubsetName to make doctypeSysid non-NULL - for the case where no startDoctypeDeclHandler is set */ - doctypeSysid = externalSubsetName; -#endif /* XML_DTD */ - if (!dtd->standalone -#ifdef XML_DTD - && !paramEntityParsing -#endif /* XML_DTD */ - && notStandaloneHandler - && !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; -#ifndef XML_DTD - break; -#else /* XML_DTD */ - if (!declEntity) { - declEntity = (ENTITY *)lookup(&dtd->paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; - declEntity->publicId = NULL; - } - /* fall through */ -#endif /* XML_DTD */ - case XML_ROLE_ENTITY_SYSTEM_ID: - if (dtd->keepProcessing && declEntity) { - declEntity->systemId = poolStoreString(&dtd->pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!declEntity->systemId) - return XML_ERROR_NO_MEMORY; - declEntity->base = curBase; - poolFinish(&dtd->pool); - if (entityDeclHandler) - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_ENTITY_COMPLETE: - if (dtd->keepProcessing && declEntity && entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - declEntity->is_param, - 0,0, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - 0); - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_ENTITY_NOTATION_NAME: - if (dtd->keepProcessing && declEntity) { - declEntity->notation = poolStoreString(&dtd->pool, enc, s, next); - if (!declEntity->notation) - return XML_ERROR_NO_MEMORY; - poolFinish(&dtd->pool); - if (unparsedEntityDeclHandler) { - *eventEndPP = s; - unparsedEntityDeclHandler(handlerArg, - declEntity->name, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - declEntity->notation); - handleDefault = XML_FALSE; - } - else if (entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - 0,0,0, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - declEntity->notation); - handleDefault = XML_FALSE; - } - } - break; - case XML_ROLE_GENERAL_ENTITY_NAME: - { - if (XmlPredefinedEntityName(enc, s, next)) { - declEntity = NULL; - break; - } - if (dtd->keepProcessing) { - const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); - if (!name) - return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(&dtd->generalEntities, name, - sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; - if (declEntity->name != name) { - poolDiscard(&dtd->pool); - declEntity = NULL; - } - else { - poolFinish(&dtd->pool); - declEntity->publicId = NULL; - declEntity->is_param = XML_FALSE; - /* if we have a parent parser or are reading an internal parameter - entity, then the entity declaration is not considered "internal" - */ - declEntity->is_internal = !(parentParser || openInternalEntities); - if (entityDeclHandler) - handleDefault = XML_FALSE; - } - } - else { - poolDiscard(&dtd->pool); - declEntity = NULL; - } - } - break; - case XML_ROLE_PARAM_ENTITY_NAME: -#ifdef XML_DTD - if (dtd->keepProcessing) { - const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); - if (!name) - return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(&dtd->paramEntities, - name, sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; - if (declEntity->name != name) { - poolDiscard(&dtd->pool); - declEntity = NULL; - } - else { - poolFinish(&dtd->pool); - declEntity->publicId = NULL; - declEntity->is_param = XML_TRUE; - /* if we have a parent parser or are reading an internal parameter - entity, then the entity declaration is not considered "internal" - */ - declEntity->is_internal = !(parentParser || openInternalEntities); - if (entityDeclHandler) - handleDefault = XML_FALSE; - } - } - else { - poolDiscard(&dtd->pool); - declEntity = NULL; - } -#else /* not XML_DTD */ - declEntity = NULL; -#endif /* XML_DTD */ - break; - case XML_ROLE_NOTATION_NAME: - declNotationPublicId = NULL; - declNotationName = NULL; - if (notationDeclHandler) { - declNotationName = poolStoreString(&tempPool, enc, s, next); - if (!declNotationName) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_NOTATION_PUBLIC_ID: - if (!XmlIsPublicId(enc, s, next, eventPP)) - return XML_ERROR_PUBLICID; - if (declNotationName) { /* means notationDeclHandler != NULL */ - XML_Char *tem = poolStoreString(&tempPool, - enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!tem) - return XML_ERROR_NO_MEMORY; - normalizePublicId(tem); - declNotationPublicId = tem; - poolFinish(&tempPool); - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_NOTATION_SYSTEM_ID: - if (declNotationName && notationDeclHandler) { - const XML_Char *systemId - = poolStoreString(&tempPool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!systemId) - return XML_ERROR_NO_MEMORY; - *eventEndPP = s; - notationDeclHandler(handlerArg, - declNotationName, - curBase, - systemId, - declNotationPublicId); - handleDefault = XML_FALSE; - } - poolClear(&tempPool); - break; - case XML_ROLE_NOTATION_NO_SYSTEM_ID: - if (declNotationPublicId && notationDeclHandler) { - *eventEndPP = s; - notationDeclHandler(handlerArg, - declNotationName, - curBase, - 0, - declNotationPublicId); - handleDefault = XML_FALSE; - } - poolClear(&tempPool); - break; - case XML_ROLE_ERROR: - switch (tok) { - case XML_TOK_PARAM_ENTITY_REF: - /* PE references in internal subset are - not allowed within declarations. */ - return XML_ERROR_PARAM_ENTITY_REF; - case XML_TOK_XML_DECL: - return XML_ERROR_MISPLACED_XML_PI; - default: - return XML_ERROR_SYNTAX; - } -#ifdef XML_DTD - case XML_ROLE_IGNORE_SECT: - { - enum XML_Error result; - if (defaultHandler) - reportDefault(parser, enc, s, next); - handleDefault = XML_FALSE; - result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); - if (result != XML_ERROR_NONE) - return result; - else if (!next) { - processor = ignoreSectionProcessor; - return result; - } - } - break; -#endif /* XML_DTD */ - case XML_ROLE_GROUP_OPEN: - if (prologState.level >= groupSize) { - if (groupSize) { - char *temp = (char *)REALLOC(groupConnector, groupSize *= 2); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - groupConnector = temp; - if (dtd->scaffIndex) { - int *temp = (int *)REALLOC(dtd->scaffIndex, - groupSize * sizeof(int)); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - dtd->scaffIndex = temp; - } - } - else { - groupConnector = (char *)MALLOC(groupSize = 32); - if (!groupConnector) - return XML_ERROR_NO_MEMORY; - } - } - groupConnector[prologState.level] = 0; - if (dtd->in_eldecl) { - int myindex = nextScaffoldPart(parser); - if (myindex < 0) - return XML_ERROR_NO_MEMORY; - dtd->scaffIndex[dtd->scaffLevel] = myindex; - dtd->scaffLevel++; - dtd->scaffold[myindex].type = XML_CTYPE_SEQ; - if (elementDeclHandler) - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_GROUP_SEQUENCE: - if (groupConnector[prologState.level] == ASCII_PIPE) - return XML_ERROR_SYNTAX; - groupConnector[prologState.level] = ASCII_COMMA; - if (dtd->in_eldecl && elementDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_GROUP_CHOICE: - if (groupConnector[prologState.level] == ASCII_COMMA) - return XML_ERROR_SYNTAX; - if (dtd->in_eldecl - && !groupConnector[prologState.level] - && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type - != XML_CTYPE_MIXED) - ) { - dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type - = XML_CTYPE_CHOICE; - if (elementDeclHandler) - handleDefault = XML_FALSE; - } - groupConnector[prologState.level] = ASCII_PIPE; - break; - case XML_ROLE_PARAM_ENTITY_REF: -#ifdef XML_DTD - case XML_ROLE_INNER_PARAM_ENTITY_REF: - dtd->hasParamEntityRefs = XML_TRUE; - if (!paramEntityParsing) - dtd->keepProcessing = dtd->standalone; - else { - const XML_Char *name; - ENTITY *entity; - name = poolStoreString(&dtd->pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); - poolDiscard(&dtd->pool); - /* first, determine if a check for an existing declaration is needed; - if yes, check that the entity exists, and that it is internal, - otherwise call the skipped entity handler - */ - if (prologState.documentEntity && - (dtd->standalone - ? !openInternalEntities - : !dtd->hasParamEntityRefs)) { - if (!entity) - return XML_ERROR_UNDEFINED_ENTITY; - else if (!entity->is_internal) - return XML_ERROR_ENTITY_DECLARED_IN_PE; - } - else if (!entity) { - dtd->keepProcessing = dtd->standalone; - /* cannot report skipped entities in declarations */ - if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) { - skippedEntityHandler(handlerArg, name, 1); - handleDefault = XML_FALSE; - } - break; - } - if (entity->open) - return XML_ERROR_RECURSIVE_ENTITY_REF; - if (entity->textPtr) { - enum XML_Error result; - XML_Bool betweenDecl = - (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); - result = processInternalEntity(parser, entity, betweenDecl); - if (result != XML_ERROR_NONE) - return result; - handleDefault = XML_FALSE; - break; - } - if (externalEntityRefHandler) { - dtd->paramEntityRead = XML_FALSE; - entity->open = XML_TRUE; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) { - entity->open = XML_FALSE; - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - } - entity->open = XML_FALSE; - handleDefault = XML_FALSE; - if (!dtd->paramEntityRead) { - dtd->keepProcessing = dtd->standalone; - break; - } - } - else { - dtd->keepProcessing = dtd->standalone; - break; - } - } -#endif /* XML_DTD */ - if (!dtd->standalone && - notStandaloneHandler && - !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - break; - - /* Element declaration stuff */ - - case XML_ROLE_ELEMENT_NAME: - if (elementDeclHandler) { - declElementType = getElementType(parser, enc, s, next); - if (!declElementType) - return XML_ERROR_NO_MEMORY; - dtd->scaffLevel = 0; - dtd->scaffCount = 0; - dtd->in_eldecl = XML_TRUE; - handleDefault = XML_FALSE; - } - break; - - case XML_ROLE_CONTENT_ANY: - case XML_ROLE_CONTENT_EMPTY: - if (dtd->in_eldecl) { - if (elementDeclHandler) { - XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content)); - if (!content) - return XML_ERROR_NO_MEMORY; - content->quant = XML_CQUANT_NONE; - content->name = NULL; - content->numchildren = 0; - content->children = NULL; - content->type = ((role == XML_ROLE_CONTENT_ANY) ? - XML_CTYPE_ANY : - XML_CTYPE_EMPTY); - *eventEndPP = s; - elementDeclHandler(handlerArg, declElementType->name, content); - handleDefault = XML_FALSE; - } - dtd->in_eldecl = XML_FALSE; - } - break; - - case XML_ROLE_CONTENT_PCDATA: - if (dtd->in_eldecl) { - dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type - = XML_CTYPE_MIXED; - if (elementDeclHandler) - handleDefault = XML_FALSE; - } - break; - - case XML_ROLE_CONTENT_ELEMENT: - quant = XML_CQUANT_NONE; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_OPT: - quant = XML_CQUANT_OPT; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_REP: - quant = XML_CQUANT_REP; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_PLUS: - quant = XML_CQUANT_PLUS; - elementContent: - if (dtd->in_eldecl) { - ELEMENT_TYPE *el; - const XML_Char *name; - int nameLen; - const char *nxt = (quant == XML_CQUANT_NONE - ? next - : next - enc->minBytesPerChar); - int myindex = nextScaffoldPart(parser); - if (myindex < 0) - return XML_ERROR_NO_MEMORY; - dtd->scaffold[myindex].type = XML_CTYPE_NAME; - dtd->scaffold[myindex].quant = quant; - el = getElementType(parser, enc, s, nxt); - if (!el) - return XML_ERROR_NO_MEMORY; - name = el->name; - dtd->scaffold[myindex].name = name; - nameLen = 0; - for (; name[nameLen++]; ); - dtd->contentStringLen += nameLen; - if (elementDeclHandler) - handleDefault = XML_FALSE; - } - break; - - case XML_ROLE_GROUP_CLOSE: - quant = XML_CQUANT_NONE; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_OPT: - quant = XML_CQUANT_OPT; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_REP: - quant = XML_CQUANT_REP; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_PLUS: - quant = XML_CQUANT_PLUS; - closeGroup: - if (dtd->in_eldecl) { - if (elementDeclHandler) - handleDefault = XML_FALSE; - dtd->scaffLevel--; - dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant; - if (dtd->scaffLevel == 0) { - if (!handleDefault) { - XML_Content *model = build_model(parser); - if (!model) - return XML_ERROR_NO_MEMORY; - *eventEndPP = s; - elementDeclHandler(handlerArg, declElementType->name, model); - } - dtd->in_eldecl = XML_FALSE; - dtd->contentStringLen = 0; - } - } - break; - /* End element declaration stuff */ - - case XML_ROLE_PI: - if (!reportProcessingInstruction(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - handleDefault = XML_FALSE; - break; - case XML_ROLE_COMMENT: - if (!reportComment(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - handleDefault = XML_FALSE; - break; - case XML_ROLE_NONE: - switch (tok) { - case XML_TOK_BOM: - handleDefault = XML_FALSE; - break; - } - break; - case XML_ROLE_DOCTYPE_NONE: - if (startDoctypeDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_ENTITY_NONE: - if (dtd->keepProcessing && entityDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_NOTATION_NONE: - if (notationDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_ATTLIST_NONE: - if (dtd->keepProcessing && attlistDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_ELEMENT_NONE: - if (elementDeclHandler) - handleDefault = XML_FALSE; - break; - } /* end of big switch */ - - if (handleDefault && defaultHandler) - reportDefault(parser, enc, s, next); - - switch (ps_parsing) { - case XML_SUSPENDED: - *nextPtr = next; - return XML_ERROR_NONE; - case XML_FINISHED: - return XML_ERROR_ABORTED; - default: - s = next; - tok = XmlPrologTok(enc, s, end, &next); - } - } - /* not reached */ -} - -static enum XML_Error PTRCALL -epilogProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - processor = epilogProcessor; - eventPtr = s; - for (;;) { - const char *next = NULL; - int tok = XmlPrologTok(encoding, s, end, &next); - eventEndPtr = next; - switch (tok) { - /* report partial linebreak - it might be the last token */ - case -XML_TOK_PROLOG_S: - if (defaultHandler) { - reportDefault(parser, encoding, s, next); - if (ps_parsing == XML_FINISHED) - return XML_ERROR_ABORTED; - } - *nextPtr = next; - return XML_ERROR_NONE; - case XML_TOK_NONE: - *nextPtr = s; - return XML_ERROR_NONE; - case XML_TOK_PROLOG_S: - if (defaultHandler) - reportDefault(parser, encoding, s, next); - break; - case XML_TOK_PI: - if (!reportProcessingInstruction(parser, encoding, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_COMMENT: - if (!reportComment(parser, encoding, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_INVALID: - eventPtr = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (!ps_finalBuffer) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (!ps_finalBuffer) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - default: - return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; - } - eventPtr = s = next; - switch (ps_parsing) { - case XML_SUSPENDED: - *nextPtr = next; - return XML_ERROR_NONE; - case XML_FINISHED: - return XML_ERROR_ABORTED; - default: ; - } - } -} - -static enum XML_Error -processInternalEntity(XML_Parser parser, ENTITY *entity, - XML_Bool betweenDecl) -{ - const char *textStart, *textEnd; - const char *next; - enum XML_Error result; - OPEN_INTERNAL_ENTITY *openEntity; - - if (freeInternalEntities) { - openEntity = freeInternalEntities; - freeInternalEntities = openEntity->next; - } - else { - openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(sizeof(OPEN_INTERNAL_ENTITY)); - if (!openEntity) - return XML_ERROR_NO_MEMORY; - } - entity->open = XML_TRUE; - entity->processed = 0; - openEntity->next = openInternalEntities; - openInternalEntities = openEntity; - openEntity->entity = entity; - openEntity->startTagLevel = tagLevel; - openEntity->betweenDecl = betweenDecl; - openEntity->internalEventPtr = NULL; - openEntity->internalEventEndPtr = NULL; - textStart = (char *)entity->textPtr; - textEnd = (char *)(entity->textPtr + entity->textLen); - -#ifdef XML_DTD - if (entity->is_param) { - int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); - result = doProlog(parser, internalEncoding, textStart, textEnd, tok, - next, &next, XML_FALSE); - } - else -#endif /* XML_DTD */ - result = doContent(parser, tagLevel, internalEncoding, textStart, - textEnd, &next, XML_FALSE); - - if (result == XML_ERROR_NONE) { - if (textEnd != next && ps_parsing == XML_SUSPENDED) { - entity->processed = (int)(next - textStart); - processor = internalEntityProcessor; - } - else { - entity->open = XML_FALSE; - openInternalEntities = openEntity->next; - /* put openEntity back in list of free instances */ - openEntity->next = freeInternalEntities; - freeInternalEntities = openEntity; - } - } - return result; -} - -static enum XML_Error PTRCALL -internalEntityProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - ENTITY *entity; - const char *textStart, *textEnd; - const char *next; - enum XML_Error result; - OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities; - if (!openEntity) - return XML_ERROR_UNEXPECTED_STATE; - - entity = openEntity->entity; - textStart = ((char *)entity->textPtr) + entity->processed; - textEnd = (char *)(entity->textPtr + entity->textLen); - -#ifdef XML_DTD - if (entity->is_param) { - int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); - result = doProlog(parser, internalEncoding, textStart, textEnd, tok, - next, &next, XML_FALSE); - } - else -#endif /* XML_DTD */ - result = doContent(parser, openEntity->startTagLevel, internalEncoding, - textStart, textEnd, &next, XML_FALSE); - - if (result != XML_ERROR_NONE) - return result; - else if (textEnd != next && ps_parsing == XML_SUSPENDED) { - entity->processed = (int)(next - (char *)entity->textPtr); - return result; - } - else { - entity->open = XML_FALSE; - openInternalEntities = openEntity->next; - /* put openEntity back in list of free instances */ - openEntity->next = freeInternalEntities; - freeInternalEntities = openEntity; - } - -#ifdef XML_DTD - if (entity->is_param) { - int tok; - processor = prologProcessor; - tok = XmlPrologTok(encoding, s, end, &next); - return doProlog(parser, encoding, s, end, tok, next, nextPtr, - (XML_Bool)!ps_finalBuffer); - } - else -#endif /* XML_DTD */ - { - processor = contentProcessor; - /* see externalEntityContentProcessor vs contentProcessor */ - return doContent(parser, parentParser ? 1 : 0, encoding, s, end, - nextPtr, (XML_Bool)!ps_finalBuffer); - } -} - -static enum XML_Error PTRCALL -errorProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - return errorCode; -} - -static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, - const char *ptr, const char *end, - STRING_POOL *pool) -{ - enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, - end, pool); - if (result) - return result; - if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) - poolChop(pool); - if (!poolAppendChar(pool, XML_T('\0'))) - return XML_ERROR_NO_MEMORY; - return XML_ERROR_NONE; -} - -static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, - const char *ptr, const char *end, - STRING_POOL *pool) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - for (;;) { - const char *next; - int tok = XmlAttributeValueTok(enc, ptr, end, &next); - switch (tok) { - case XML_TOK_NONE: - return XML_ERROR_NONE; - case XML_TOK_INVALID: - if (enc == encoding) - eventPtr = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_CHAR_REF: - { - XML_Char buf[XML_ENCODE_MAX]; - int i; - int n = XmlCharRefNumber(enc, ptr); - if (n < 0) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BAD_CHAR_REF; - } - if (!isCdata - && n == 0x20 /* space */ - && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) - break; - n = XmlEncode(n, (ICHAR *)buf); - if (!n) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BAD_CHAR_REF; - } - for (i = 0; i < n; i++) { - if (!poolAppendChar(pool, buf[i])) - return XML_ERROR_NO_MEMORY; - } - } - break; - case XML_TOK_DATA_CHARS: - if (!poolAppend(pool, enc, ptr, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_TRAILING_CR: - next = ptr + enc->minBytesPerChar; - /* fall through */ - case XML_TOK_ATTRIBUTE_VALUE_S: - case XML_TOK_DATA_NEWLINE: - if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) - break; - if (!poolAppendChar(pool, 0x20)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_ENTITY_REF: - { - const XML_Char *name; - ENTITY *entity; - char checkEntityDecl; - XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, - ptr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (ch) { - if (!poolAppendChar(pool, ch)) - return XML_ERROR_NO_MEMORY; - break; - } - name = poolStoreString(&temp2Pool, enc, - ptr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); - poolDiscard(&temp2Pool); - /* First, determine if a check for an existing declaration is needed; - if yes, check that the entity exists, and that it is internal. - */ - if (pool == &dtd->pool) /* are we called from prolog? */ - checkEntityDecl = -#ifdef XML_DTD - prologState.documentEntity && -#endif /* XML_DTD */ - (dtd->standalone - ? !openInternalEntities - : !dtd->hasParamEntityRefs); - else /* if (pool == &tempPool): we are called from content */ - checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; - if (checkEntityDecl) { - if (!entity) - return XML_ERROR_UNDEFINED_ENTITY; - else if (!entity->is_internal) - return XML_ERROR_ENTITY_DECLARED_IN_PE; - } - else if (!entity) { - /* Cannot report skipped entity here - see comments on - skippedEntityHandler. - if (skippedEntityHandler) - skippedEntityHandler(handlerArg, name, 0); - */ - /* Cannot call the default handler because this would be - out of sync with the call to the startElementHandler. - if ((pool == &tempPool) && defaultHandler) - reportDefault(parser, enc, ptr, next); - */ - break; - } - if (entity->open) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_RECURSIVE_ENTITY_REF; - } - if (entity->notation) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BINARY_ENTITY_REF; - } - if (!entity->textPtr) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; - } - else { - enum XML_Error result; - const XML_Char *textEnd = entity->textPtr + entity->textLen; - entity->open = XML_TRUE; - result = appendAttributeValue(parser, internalEncoding, isCdata, - (char *)entity->textPtr, - (char *)textEnd, pool); - entity->open = XML_FALSE; - if (result) - return result; - } - } - break; - default: - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_UNEXPECTED_STATE; - } - ptr = next; - } - /* not reached */ -} - -static enum XML_Error -storeEntityValue(XML_Parser parser, - const ENCODING *enc, - const char *entityTextPtr, - const char *entityTextEnd) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - STRING_POOL *pool = &(dtd->entityValuePool); - enum XML_Error result = XML_ERROR_NONE; -#ifdef XML_DTD - int oldInEntityValue = prologState.inEntityValue; - prologState.inEntityValue = 1; -#endif /* XML_DTD */ - /* never return Null for the value argument in EntityDeclHandler, - since this would indicate an external entity; therefore we - have to make sure that entityValuePool.start is not null */ - if (!pool->blocks) { - if (!poolGrow(pool)) - return XML_ERROR_NO_MEMORY; - } - - for (;;) { - const char *next; - int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); - switch (tok) { - case XML_TOK_PARAM_ENTITY_REF: -#ifdef XML_DTD - if (isParamEntity || enc != encoding) { - const XML_Char *name; - ENTITY *entity; - name = poolStoreString(&tempPool, enc, - entityTextPtr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) { - result = XML_ERROR_NO_MEMORY; - goto endEntityValue; - } - entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); - poolDiscard(&tempPool); - if (!entity) { - /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ - /* cannot report skipped entity here - see comments on - skippedEntityHandler - if (skippedEntityHandler) - skippedEntityHandler(handlerArg, name, 0); - */ - dtd->keepProcessing = dtd->standalone; - goto endEntityValue; - } - if (entity->open) { - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_RECURSIVE_ENTITY_REF; - goto endEntityValue; - } - if (entity->systemId) { - if (externalEntityRefHandler) { - dtd->paramEntityRead = XML_FALSE; - entity->open = XML_TRUE; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) { - entity->open = XML_FALSE; - result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; - goto endEntityValue; - } - entity->open = XML_FALSE; - if (!dtd->paramEntityRead) - dtd->keepProcessing = dtd->standalone; - } - else - dtd->keepProcessing = dtd->standalone; - } - else { - entity->open = XML_TRUE; - result = storeEntityValue(parser, - internalEncoding, - (char *)entity->textPtr, - (char *)(entity->textPtr - + entity->textLen)); - entity->open = XML_FALSE; - if (result) - goto endEntityValue; - } - break; - } -#endif /* XML_DTD */ - /* In the internal subset, PE references are not legal - within markup declarations, e.g entity values in this case. */ - eventPtr = entityTextPtr; - result = XML_ERROR_PARAM_ENTITY_REF; - goto endEntityValue; - case XML_TOK_NONE: - result = XML_ERROR_NONE; - goto endEntityValue; - case XML_TOK_ENTITY_REF: - case XML_TOK_DATA_CHARS: - if (!poolAppend(pool, enc, entityTextPtr, next)) { - result = XML_ERROR_NO_MEMORY; - goto endEntityValue; - } - break; - case XML_TOK_TRAILING_CR: - next = entityTextPtr + enc->minBytesPerChar; - /* fall through */ - case XML_TOK_DATA_NEWLINE: - if (pool->end == pool->ptr && !poolGrow(pool)) { - result = XML_ERROR_NO_MEMORY; - goto endEntityValue; - } - *(pool->ptr)++ = 0xA; - break; - case XML_TOK_CHAR_REF: - { - XML_Char buf[XML_ENCODE_MAX]; - int i; - int n = XmlCharRefNumber(enc, entityTextPtr); - if (n < 0) { - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_BAD_CHAR_REF; - goto endEntityValue; - } - n = XmlEncode(n, (ICHAR *)buf); - if (!n) { - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_BAD_CHAR_REF; - goto endEntityValue; - } - for (i = 0; i < n; i++) { - if (pool->end == pool->ptr && !poolGrow(pool)) { - result = XML_ERROR_NO_MEMORY; - goto endEntityValue; - } - *(pool->ptr)++ = buf[i]; - } - } - break; - case XML_TOK_PARTIAL: - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_INVALID_TOKEN; - goto endEntityValue; - case XML_TOK_INVALID: - if (enc == encoding) - eventPtr = next; - result = XML_ERROR_INVALID_TOKEN; - goto endEntityValue; - default: - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_UNEXPECTED_STATE; - goto endEntityValue; - } - entityTextPtr = next; - } -endEntityValue: -#ifdef XML_DTD - prologState.inEntityValue = oldInEntityValue; -#endif /* XML_DTD */ - return result; -} - -static void FASTCALL -normalizeLines(XML_Char *s) -{ - XML_Char *p; - for (;; s++) { - if (*s == XML_T('\0')) - return; - if (*s == 0xD) - break; - } - p = s; - do { - if (*s == 0xD) { - *p++ = 0xA; - if (*++s == 0xA) - s++; - } - else - *p++ = *s++; - } while (*s); - *p = XML_T('\0'); -} - -static int -reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, - const char *start, const char *end) -{ - const XML_Char *target; - XML_Char *data; - const char *tem; - if (!processingInstructionHandler) { - if (defaultHandler) - reportDefault(parser, enc, start, end); - return 1; - } - start += enc->minBytesPerChar * 2; - tem = start + XmlNameLength(enc, start); - target = poolStoreString(&tempPool, enc, start, tem); - if (!target) - return 0; - poolFinish(&tempPool); - data = poolStoreString(&tempPool, enc, - XmlSkipS(enc, tem), - end - enc->minBytesPerChar*2); - if (!data) - return 0; - normalizeLines(data); - processingInstructionHandler(handlerArg, target, data); - poolClear(&tempPool); - return 1; -} - -static int -reportComment(XML_Parser parser, const ENCODING *enc, - const char *start, const char *end) -{ - XML_Char *data; - if (!commentHandler) { - if (defaultHandler) - reportDefault(parser, enc, start, end); - return 1; - } - data = poolStoreString(&tempPool, - enc, - start + enc->minBytesPerChar * 4, - end - enc->minBytesPerChar * 3); - if (!data) - return 0; - normalizeLines(data); - commentHandler(handlerArg, data); - poolClear(&tempPool); - return 1; -} - -static void -reportDefault(XML_Parser parser, const ENCODING *enc, - const char *s, const char *end) -{ - if (MUST_CONVERT(enc, s)) { - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - do { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf)); - *eventPP = s; - } while (s != end); - } - else - defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); -} - - -static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, - XML_Bool isId, const XML_Char *value, XML_Parser parser) -{ - DEFAULT_ATTRIBUTE *att; - if (value || isId) { - /* The handling of default attributes gets messed up if we have - a default which duplicates a non-default. */ - int i; - for (i = 0; i < type->nDefaultAtts; i++) - if (attId == type->defaultAtts[i].id) - return 1; - if (isId && !type->idAtt && !attId->xmlns) - type->idAtt = attId; - } - if (type->nDefaultAtts == type->allocDefaultAtts) { - if (type->allocDefaultAtts == 0) { - type->allocDefaultAtts = 8; - type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts - * sizeof(DEFAULT_ATTRIBUTE)); - if (!type->defaultAtts) - return 0; - } - else { - DEFAULT_ATTRIBUTE *temp; - int count = type->allocDefaultAtts * 2; - temp = (DEFAULT_ATTRIBUTE *) - REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); - if (temp == NULL) - return 0; - type->allocDefaultAtts = count; - type->defaultAtts = temp; - } - } - att = type->defaultAtts + type->nDefaultAtts; - att->id = attId; - att->value = value; - att->isCdata = isCdata; - if (!isCdata) - attId->maybeTokenized = XML_TRUE; - type->nDefaultAtts += 1; - return 1; -} - -static int -setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - const XML_Char *name; - for (name = elementType->name; *name; name++) { - if (*name == XML_T(ASCII_COLON)) { - PREFIX *prefix; - const XML_Char *s; - for (s = elementType->name; s != name; s++) { - if (!poolAppendChar(&dtd->pool, *s)) - return 0; - } - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) - return 0; - prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), - sizeof(PREFIX)); - if (!prefix) - return 0; - if (prefix->name == poolStart(&dtd->pool)) - poolFinish(&dtd->pool); - else - poolDiscard(&dtd->pool); - elementType->prefix = prefix; - - } - } - return 1; -} - -static ATTRIBUTE_ID * -getAttributeId(XML_Parser parser, const ENCODING *enc, - const char *start, const char *end) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - ATTRIBUTE_ID *id; - const XML_Char *name; - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) - return NULL; - name = poolStoreString(&dtd->pool, enc, start, end); - if (!name) - return NULL; - /* skip quotation mark - its storage will be re-used (like in name[-1]) */ - ++name; - id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); - if (!id) - return NULL; - if (id->name != name) - poolDiscard(&dtd->pool); - else { - poolFinish(&dtd->pool); - if (!ns) - ; - else if (name[0] == XML_T(ASCII_x) - && name[1] == XML_T(ASCII_m) - && name[2] == XML_T(ASCII_l) - && name[3] == XML_T(ASCII_n) - && name[4] == XML_T(ASCII_s) - && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) { - if (name[5] == XML_T('\0')) - id->prefix = &dtd->defaultPrefix; - else - id->prefix = (PREFIX *)lookup(&dtd->prefixes, name + 6, sizeof(PREFIX)); - id->xmlns = XML_TRUE; - } - else { - int i; - for (i = 0; name[i]; i++) { - /* attributes without prefix are *not* in the default namespace */ - if (name[i] == XML_T(ASCII_COLON)) { - int j; - for (j = 0; j < i; j++) { - if (!poolAppendChar(&dtd->pool, name[j])) - return NULL; - } - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) - return NULL; - id->prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), - sizeof(PREFIX)); - if (id->prefix->name == poolStart(&dtd->pool)) - poolFinish(&dtd->pool); - else - poolDiscard(&dtd->pool); - break; - } - } - } - } - return id; -} - -#define CONTEXT_SEP XML_T(ASCII_FF) - -static const XML_Char * -getContext(XML_Parser parser) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - HASH_TABLE_ITER iter; - XML_Bool needSep = XML_FALSE; - - if (dtd->defaultPrefix.binding) { - int i; - int len; - if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) - return NULL; - len = dtd->defaultPrefix.binding->uriLen; - if (namespaceSeparator) - len--; - for (i = 0; i < len; i++) - if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i])) - return NULL; - needSep = XML_TRUE; - } - - hashTableIterInit(&iter, &(dtd->prefixes)); - for (;;) { - int i; - int len; - const XML_Char *s; - PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); - if (!prefix) - break; - if (!prefix->binding) - continue; - if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) - return NULL; - for (s = prefix->name; *s; s++) - if (!poolAppendChar(&tempPool, *s)) - return NULL; - if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) - return NULL; - len = prefix->binding->uriLen; - if (namespaceSeparator) - len--; - for (i = 0; i < len; i++) - if (!poolAppendChar(&tempPool, prefix->binding->uri[i])) - return NULL; - needSep = XML_TRUE; - } - - - hashTableIterInit(&iter, &(dtd->generalEntities)); - for (;;) { - const XML_Char *s; - ENTITY *e = (ENTITY *)hashTableIterNext(&iter); - if (!e) - break; - if (!e->open) - continue; - if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) - return NULL; - for (s = e->name; *s; s++) - if (!poolAppendChar(&tempPool, *s)) - return 0; - needSep = XML_TRUE; - } - - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return NULL; - return tempPool.start; -} - -static XML_Bool -setContext(XML_Parser parser, const XML_Char *context) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - const XML_Char *s = context; - - while (*context != XML_T('\0')) { - if (*s == CONTEXT_SEP || *s == XML_T('\0')) { - ENTITY *e; - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return XML_FALSE; - e = (ENTITY *)lookup(&dtd->generalEntities, poolStart(&tempPool), 0); - if (e) - e->open = XML_TRUE; - if (*s != XML_T('\0')) - s++; - context = s; - poolDiscard(&tempPool); - } - else if (*s == XML_T(ASCII_EQUALS)) { - PREFIX *prefix; - if (poolLength(&tempPool) == 0) - prefix = &dtd->defaultPrefix; - else { - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return XML_FALSE; - prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&tempPool), - sizeof(PREFIX)); - if (!prefix) - return XML_FALSE; - if (prefix->name == poolStart(&tempPool)) { - prefix->name = poolCopyString(&dtd->pool, prefix->name); - if (!prefix->name) - return XML_FALSE; - } - poolDiscard(&tempPool); - } - for (context = s + 1; - *context != CONTEXT_SEP && *context != XML_T('\0'); - context++) - if (!poolAppendChar(&tempPool, *context)) - return XML_FALSE; - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return XML_FALSE; - if (addBinding(parser, prefix, NULL, poolStart(&tempPool), - &inheritedBindings) != XML_ERROR_NONE) - return XML_FALSE; - poolDiscard(&tempPool); - if (*context != XML_T('\0')) - ++context; - s = context; - } - else { - if (!poolAppendChar(&tempPool, *s)) - return XML_FALSE; - s++; - } - } - return XML_TRUE; -} - -static void FASTCALL -normalizePublicId(XML_Char *publicId) -{ - XML_Char *p = publicId; - XML_Char *s; - for (s = publicId; *s; s++) { - switch (*s) { - case 0x20: - case 0xD: - case 0xA: - if (p != publicId && p[-1] != 0x20) - *p++ = 0x20; - break; - default: - *p++ = *s; - } - } - if (p != publicId && p[-1] == 0x20) - --p; - *p = XML_T('\0'); -} - -static DTD * -dtdCreate(const XML_Memory_Handling_Suite *ms) -{ - DTD *p = (DTD *)ms->malloc_fcn(sizeof(DTD)); - if (p == NULL) - return p; - poolInit(&(p->pool), ms); - poolInit(&(p->entityValuePool), ms); - hashTableInit(&(p->generalEntities), ms); - hashTableInit(&(p->elementTypes), ms); - hashTableInit(&(p->attributeIds), ms); - hashTableInit(&(p->prefixes), ms); -#ifdef XML_DTD - p->paramEntityRead = XML_FALSE; - hashTableInit(&(p->paramEntities), ms); -#endif /* XML_DTD */ - p->defaultPrefix.name = NULL; - p->defaultPrefix.binding = NULL; - - p->in_eldecl = XML_FALSE; - p->scaffIndex = NULL; - p->scaffold = NULL; - p->scaffLevel = 0; - p->scaffSize = 0; - p->scaffCount = 0; - p->contentStringLen = 0; - - p->keepProcessing = XML_TRUE; - p->hasParamEntityRefs = XML_FALSE; - p->standalone = XML_FALSE; - return p; -} - -static void -dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) -{ - HASH_TABLE_ITER iter; - hashTableIterInit(&iter, &(p->elementTypes)); - for (;;) { - ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); - if (!e) - break; - if (e->allocDefaultAtts != 0) - ms->free_fcn(e->defaultAtts); - } - hashTableClear(&(p->generalEntities)); -#ifdef XML_DTD - p->paramEntityRead = XML_FALSE; - hashTableClear(&(p->paramEntities)); -#endif /* XML_DTD */ - hashTableClear(&(p->elementTypes)); - hashTableClear(&(p->attributeIds)); - hashTableClear(&(p->prefixes)); - poolClear(&(p->pool)); - poolClear(&(p->entityValuePool)); - p->defaultPrefix.name = NULL; - p->defaultPrefix.binding = NULL; - - p->in_eldecl = XML_FALSE; - - ms->free_fcn(p->scaffIndex); - p->scaffIndex = NULL; - ms->free_fcn(p->scaffold); - p->scaffold = NULL; - - p->scaffLevel = 0; - p->scaffSize = 0; - p->scaffCount = 0; - p->contentStringLen = 0; - - p->keepProcessing = XML_TRUE; - p->hasParamEntityRefs = XML_FALSE; - p->standalone = XML_FALSE; -} - -static void -dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms) -{ - HASH_TABLE_ITER iter; - hashTableIterInit(&iter, &(p->elementTypes)); - for (;;) { - ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); - if (!e) - break; - if (e->allocDefaultAtts != 0) - ms->free_fcn(e->defaultAtts); - } - hashTableDestroy(&(p->generalEntities)); -#ifdef XML_DTD - hashTableDestroy(&(p->paramEntities)); -#endif /* XML_DTD */ - hashTableDestroy(&(p->elementTypes)); - hashTableDestroy(&(p->attributeIds)); - hashTableDestroy(&(p->prefixes)); - poolDestroy(&(p->pool)); - poolDestroy(&(p->entityValuePool)); - if (isDocEntity) { - ms->free_fcn(p->scaffIndex); - ms->free_fcn(p->scaffold); - } - ms->free_fcn(p); -} - -/* Do a deep copy of the DTD. Return 0 for out of memory, non-zero otherwise. - The new DTD has already been initialized. -*/ -static int -dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) -{ - HASH_TABLE_ITER iter; - - /* Copy the prefix table. */ - - hashTableIterInit(&iter, &(oldDtd->prefixes)); - for (;;) { - const XML_Char *name; - const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); - if (!oldP) - break; - name = poolCopyString(&(newDtd->pool), oldP->name); - if (!name) - return 0; - if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX))) - return 0; - } - - hashTableIterInit(&iter, &(oldDtd->attributeIds)); - - /* Copy the attribute id table. */ - - for (;;) { - ATTRIBUTE_ID *newA; - const XML_Char *name; - const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); - - if (!oldA) - break; - /* Remember to allocate the scratch byte before the name. */ - if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) - return 0; - name = poolCopyString(&(newDtd->pool), oldA->name); - if (!name) - return 0; - ++name; - newA = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), name, - sizeof(ATTRIBUTE_ID)); - if (!newA) - return 0; - newA->maybeTokenized = oldA->maybeTokenized; - if (oldA->prefix) { - newA->xmlns = oldA->xmlns; - if (oldA->prefix == &oldDtd->defaultPrefix) - newA->prefix = &newDtd->defaultPrefix; - else - newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), - oldA->prefix->name, 0); - } - } - - /* Copy the element type table. */ - - hashTableIterInit(&iter, &(oldDtd->elementTypes)); - - for (;;) { - int i; - ELEMENT_TYPE *newE; - const XML_Char *name; - const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); - if (!oldE) - break; - name = poolCopyString(&(newDtd->pool), oldE->name); - if (!name) - return 0; - newE = (ELEMENT_TYPE *)lookup(&(newDtd->elementTypes), name, - sizeof(ELEMENT_TYPE)); - if (!newE) - return 0; - if (oldE->nDefaultAtts) { - newE->defaultAtts = (DEFAULT_ATTRIBUTE *) - ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); - if (!newE->defaultAtts) { - ms->free_fcn(newE); - return 0; - } - } - if (oldE->idAtt) - newE->idAtt = (ATTRIBUTE_ID *) - lookup(&(newDtd->attributeIds), oldE->idAtt->name, 0); - newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; - if (oldE->prefix) - newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), - oldE->prefix->name, 0); - for (i = 0; i < newE->nDefaultAtts; i++) { - newE->defaultAtts[i].id = (ATTRIBUTE_ID *) - lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); - newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; - if (oldE->defaultAtts[i].value) { - newE->defaultAtts[i].value - = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value); - if (!newE->defaultAtts[i].value) - return 0; - } - else - newE->defaultAtts[i].value = NULL; - } - } - - /* Copy the entity tables. */ - if (!copyEntityTable(&(newDtd->generalEntities), - &(newDtd->pool), - &(oldDtd->generalEntities))) - return 0; - -#ifdef XML_DTD - if (!copyEntityTable(&(newDtd->paramEntities), - &(newDtd->pool), - &(oldDtd->paramEntities))) - return 0; - newDtd->paramEntityRead = oldDtd->paramEntityRead; -#endif /* XML_DTD */ - - newDtd->keepProcessing = oldDtd->keepProcessing; - newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; - newDtd->standalone = oldDtd->standalone; - - /* Don't want deep copying for scaffolding */ - newDtd->in_eldecl = oldDtd->in_eldecl; - newDtd->scaffold = oldDtd->scaffold; - newDtd->contentStringLen = oldDtd->contentStringLen; - newDtd->scaffSize = oldDtd->scaffSize; - newDtd->scaffLevel = oldDtd->scaffLevel; - newDtd->scaffIndex = oldDtd->scaffIndex; - - return 1; -} /* End dtdCopy */ - -static int -copyEntityTable(HASH_TABLE *newTable, - STRING_POOL *newPool, - const HASH_TABLE *oldTable) -{ - HASH_TABLE_ITER iter; - const XML_Char *cachedOldBase = NULL; - const XML_Char *cachedNewBase = NULL; - - hashTableIterInit(&iter, oldTable); - - for (;;) { - ENTITY *newE; - const XML_Char *name; - const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); - if (!oldE) - break; - name = poolCopyString(newPool, oldE->name); - if (!name) - return 0; - newE = (ENTITY *)lookup(newTable, name, sizeof(ENTITY)); - if (!newE) - return 0; - if (oldE->systemId) { - const XML_Char *tem = poolCopyString(newPool, oldE->systemId); - if (!tem) - return 0; - newE->systemId = tem; - if (oldE->base) { - if (oldE->base == cachedOldBase) - newE->base = cachedNewBase; - else { - cachedOldBase = oldE->base; - tem = poolCopyString(newPool, cachedOldBase); - if (!tem) - return 0; - cachedNewBase = newE->base = tem; - } - } - if (oldE->publicId) { - tem = poolCopyString(newPool, oldE->publicId); - if (!tem) - return 0; - newE->publicId = tem; - } - } - else { - const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr, - oldE->textLen); - if (!tem) - return 0; - newE->textPtr = tem; - newE->textLen = oldE->textLen; - } - if (oldE->notation) { - const XML_Char *tem = poolCopyString(newPool, oldE->notation); - if (!tem) - return 0; - newE->notation = tem; - } - newE->is_param = oldE->is_param; - newE->is_internal = oldE->is_internal; - } - return 1; -} - -#define INIT_POWER 6 - -static XML_Bool FASTCALL -keyeq(KEY s1, KEY s2) -{ - for (; *s1 == *s2; s1++, s2++) - if (*s1 == 0) - return XML_TRUE; - return XML_FALSE; -} - -static unsigned long FASTCALL -hash(KEY s) -{ - unsigned long h = 0; - while (*s) - h = CHAR_HASH(h, *s++); - return h; -} - -static NAMED * -lookup(HASH_TABLE *table, KEY name, size_t createSize) -{ - size_t i; - if (table->size == 0) { - size_t tsize; - if (!createSize) - return NULL; - table->power = INIT_POWER; - /* table->size is a power of 2 */ - table->size = (size_t)1 << INIT_POWER; - tsize = table->size * sizeof(NAMED *); - table->v = (NAMED **)table->mem->malloc_fcn(tsize); - if (!table->v) { - table->size = 0; - return NULL; - } - memset(table->v, 0, tsize); - i = hash(name) & ((unsigned long)table->size - 1); - } - else { - unsigned long h = hash(name); - unsigned long mask = (unsigned long)table->size - 1; - unsigned char step = 0; - i = h & mask; - while (table->v[i]) { - if (keyeq(name, table->v[i]->name)) - return table->v[i]; - if (!step) - step = PROBE_STEP(h, mask, table->power); - i < step ? (i += table->size - step) : (i -= step); - } - if (!createSize) - return NULL; - - /* check for overflow (table is half full) */ - if (table->used >> (table->power - 1)) { - unsigned char newPower = table->power + 1; - size_t newSize = (size_t)1 << newPower; - unsigned long newMask = (unsigned long)newSize - 1; - size_t tsize = newSize * sizeof(NAMED *); - NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); - if (!newV) - return NULL; - memset(newV, 0, tsize); - for (i = 0; i < table->size; i++) - if (table->v[i]) { - unsigned long newHash = hash(table->v[i]->name); - size_t j = newHash & newMask; - step = 0; - while (newV[j]) { - if (!step) - step = PROBE_STEP(newHash, newMask, newPower); - j < step ? (j += newSize - step) : (j -= step); - } - newV[j] = table->v[i]; - } - table->mem->free_fcn(table->v); - table->v = newV; - table->power = newPower; - table->size = newSize; - i = h & newMask; - step = 0; - while (table->v[i]) { - if (!step) - step = PROBE_STEP(h, newMask, newPower); - i < step ? (i += newSize - step) : (i -= step); - } - } - } - table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); - if (!table->v[i]) - return NULL; - memset(table->v[i], 0, createSize); - table->v[i]->name = name; - (table->used)++; - return table->v[i]; -} - -static void FASTCALL -hashTableClear(HASH_TABLE *table) -{ - size_t i; - for (i = 0; i < table->size; i++) { - table->mem->free_fcn(table->v[i]); - table->v[i] = NULL; - } - table->used = 0; -} - -static void FASTCALL -hashTableDestroy(HASH_TABLE *table) -{ - size_t i; - for (i = 0; i < table->size; i++) - table->mem->free_fcn(table->v[i]); - table->mem->free_fcn(table->v); -} - -static void FASTCALL -hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) -{ - p->power = 0; - p->size = 0; - p->used = 0; - p->v = NULL; - p->mem = ms; -} - -static void FASTCALL -hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) -{ - iter->p = table->v; - iter->end = iter->p + table->size; -} - -static NAMED * FASTCALL -hashTableIterNext(HASH_TABLE_ITER *iter) -{ - while (iter->p != iter->end) { - NAMED *tem = *(iter->p)++; - if (tem) - return tem; - } - return NULL; -} - -static void FASTCALL -poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) -{ - pool->blocks = NULL; - pool->freeBlocks = NULL; - pool->start = NULL; - pool->ptr = NULL; - pool->end = NULL; - pool->mem = ms; -} - -static void FASTCALL -poolClear(STRING_POOL *pool) -{ - if (!pool->freeBlocks) - pool->freeBlocks = pool->blocks; - else { - BLOCK *p = pool->blocks; - while (p) { - BLOCK *tem = p->next; - p->next = pool->freeBlocks; - pool->freeBlocks = p; - p = tem; - } - } - pool->blocks = NULL; - pool->start = NULL; - pool->ptr = NULL; - pool->end = NULL; -} - -static void FASTCALL -poolDestroy(STRING_POOL *pool) -{ - BLOCK *p = pool->blocks; - while (p) { - BLOCK *tem = p->next; - pool->mem->free_fcn(p); - p = tem; - } - p = pool->freeBlocks; - while (p) { - BLOCK *tem = p->next; - pool->mem->free_fcn(p); - p = tem; - } -} - -static XML_Char * -poolAppend(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end) -{ - if (!pool->ptr && !poolGrow(pool)) - return NULL; - for (;;) { - XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); - if (ptr == end) - break; - if (!poolGrow(pool)) - return NULL; - } - return pool->start; -} - -static const XML_Char * FASTCALL -poolCopyString(STRING_POOL *pool, const XML_Char *s) -{ - do { - if (!poolAppendChar(pool, *s)) - return NULL; - } while (*s++); - s = pool->start; - poolFinish(pool); - return s; -} - -static const XML_Char * -poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) -{ - if (!pool->ptr && !poolGrow(pool)) - return NULL; - for (; n > 0; --n, s++) { - if (!poolAppendChar(pool, *s)) - return NULL; - } - s = pool->start; - poolFinish(pool); - return s; -} - -static const XML_Char * FASTCALL -poolAppendString(STRING_POOL *pool, const XML_Char *s) -{ - while (*s) { - if (!poolAppendChar(pool, *s)) - return NULL; - s++; - } - return pool->start; -} - -static XML_Char * -poolStoreString(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end) -{ - if (!poolAppend(pool, enc, ptr, end)) - return NULL; - if (pool->ptr == pool->end && !poolGrow(pool)) - return NULL; - *(pool->ptr)++ = 0; - return pool->start; -} - -static XML_Bool FASTCALL -poolGrow(STRING_POOL *pool) -{ - if (pool->freeBlocks) { - if (pool->start == 0) { - pool->blocks = pool->freeBlocks; - pool->freeBlocks = pool->freeBlocks->next; - pool->blocks->next = NULL; - pool->start = pool->blocks->s; - pool->end = pool->start + pool->blocks->size; - pool->ptr = pool->start; - return XML_TRUE; - } - if (pool->end - pool->start < pool->freeBlocks->size) { - BLOCK *tem = pool->freeBlocks->next; - pool->freeBlocks->next = pool->blocks; - pool->blocks = pool->freeBlocks; - pool->freeBlocks = tem; - memcpy(pool->blocks->s, pool->start, - (pool->end - pool->start) * sizeof(XML_Char)); - pool->ptr = pool->blocks->s + (pool->ptr - pool->start); - pool->start = pool->blocks->s; - pool->end = pool->start + pool->blocks->size; - return XML_TRUE; - } - } - if (pool->blocks && pool->start == pool->blocks->s) { - int blockSize = (int)(pool->end - pool->start)*2; - pool->blocks = (BLOCK *) - pool->mem->realloc_fcn(pool->blocks, - (offsetof(BLOCK, s) - + blockSize * sizeof(XML_Char))); - if (pool->blocks == NULL) - return XML_FALSE; - pool->blocks->size = blockSize; - pool->ptr = pool->blocks->s + (pool->ptr - pool->start); - pool->start = pool->blocks->s; - pool->end = pool->start + blockSize; - } - else { - BLOCK *tem; - int blockSize = (int)(pool->end - pool->start); - if (blockSize < INIT_BLOCK_SIZE) - blockSize = INIT_BLOCK_SIZE; - else - blockSize *= 2; - tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s) - + blockSize * sizeof(XML_Char)); - if (!tem) - return XML_FALSE; - tem->size = blockSize; - tem->next = pool->blocks; - pool->blocks = tem; - if (pool->ptr != pool->start) - memcpy(tem->s, pool->start, - (pool->ptr - pool->start) * sizeof(XML_Char)); - pool->ptr = tem->s + (pool->ptr - pool->start); - pool->start = tem->s; - pool->end = tem->s + blockSize; - } - return XML_TRUE; -} - -static int FASTCALL -nextScaffoldPart(XML_Parser parser) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - CONTENT_SCAFFOLD * me; - int next; - - if (!dtd->scaffIndex) { - dtd->scaffIndex = (int *)MALLOC(groupSize * sizeof(int)); - if (!dtd->scaffIndex) - return -1; - dtd->scaffIndex[0] = 0; - } - - if (dtd->scaffCount >= dtd->scaffSize) { - CONTENT_SCAFFOLD *temp; - if (dtd->scaffold) { - temp = (CONTENT_SCAFFOLD *) - REALLOC(dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); - if (temp == NULL) - return -1; - dtd->scaffSize *= 2; - } - else { - temp = (CONTENT_SCAFFOLD *)MALLOC(INIT_SCAFFOLD_ELEMENTS - * sizeof(CONTENT_SCAFFOLD)); - if (temp == NULL) - return -1; - dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; - } - dtd->scaffold = temp; - } - next = dtd->scaffCount++; - me = &dtd->scaffold[next]; - if (dtd->scaffLevel) { - CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; - if (parent->lastchild) { - dtd->scaffold[parent->lastchild].nextsib = next; - } - if (!parent->childcnt) - parent->firstchild = next; - parent->lastchild = next; - parent->childcnt++; - } - me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; - return next; -} - -static void -build_node(XML_Parser parser, - int src_node, - XML_Content *dest, - XML_Content **contpos, - XML_Char **strpos) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - dest->type = dtd->scaffold[src_node].type; - dest->quant = dtd->scaffold[src_node].quant; - if (dest->type == XML_CTYPE_NAME) { - const XML_Char *src; - dest->name = *strpos; - src = dtd->scaffold[src_node].name; - for (;;) { - *(*strpos)++ = *src; - if (!*src) - break; - src++; - } - dest->numchildren = 0; - dest->children = NULL; - } - else { - unsigned int i; - int cn; - dest->numchildren = dtd->scaffold[src_node].childcnt; - dest->children = *contpos; - *contpos += dest->numchildren; - for (i = 0, cn = dtd->scaffold[src_node].firstchild; - i < dest->numchildren; - i++, cn = dtd->scaffold[cn].nextsib) { - build_node(parser, cn, &(dest->children[i]), contpos, strpos); - } - dest->name = NULL; - } -} - -static XML_Content * -build_model (XML_Parser parser) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - XML_Content *ret; - XML_Content *cpos; - XML_Char * str; - int allocsize = (dtd->scaffCount * sizeof(XML_Content) - + (dtd->contentStringLen * sizeof(XML_Char))); - - ret = (XML_Content *)MALLOC(allocsize); - if (!ret) - return NULL; - - str = (XML_Char *) (&ret[dtd->scaffCount]); - cpos = &ret[1]; - - build_node(parser, 0, ret, &cpos, &str); - return ret; -} - -static ELEMENT_TYPE * -getElementType(XML_Parser parser, - const ENCODING *enc, - const char *ptr, - const char *end) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); - ELEMENT_TYPE *ret; - - if (!name) - return NULL; - ret = (ELEMENT_TYPE *) lookup(&dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); - if (!ret) - return NULL; - if (ret->name != name) - poolDiscard(&dtd->pool); - else { - poolFinish(&dtd->pool); - if (!setElementTypePrefix(parser, ret)) - return NULL; - } - return ret; -} diff -Nru gpick-0.2.4/extern/expat/lib/xmlrole.c gpick-0.2.5/extern/expat/lib/xmlrole.c --- gpick-0.2.4/extern/expat/lib/xmlrole.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/xmlrole.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1336 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#include - -#ifdef COMPILED_FROM_DSP -#include "winconfig.h" -#elif defined(MACOS_CLASSIC) -#include "macconfig.h" -#elif defined(__amigaos__) -#include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" -#else -#ifdef HAVE_EXPAT_CONFIG_H -#include -#endif -#endif /* ndef COMPILED_FROM_DSP */ - -#include "expat_external.h" -#include "internal.h" -#include "xmlrole.h" -#include "ascii.h" - -/* Doesn't check: - - that ,| are not mixed in a model group - content of literals - -*/ - -static const char KW_ANY[] = { - ASCII_A, ASCII_N, ASCII_Y, '\0' }; -static const char KW_ATTLIST[] = { - ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' }; -static const char KW_CDATA[] = { - ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_DOCTYPE[] = { - ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' }; -static const char KW_ELEMENT[] = { - ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' }; -static const char KW_EMPTY[] = { - ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' }; -static const char KW_ENTITIES[] = { - ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, - '\0' }; -static const char KW_ENTITY[] = { - ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; -static const char KW_FIXED[] = { - ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' }; -static const char KW_ID[] = { - ASCII_I, ASCII_D, '\0' }; -static const char KW_IDREF[] = { - ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; -static const char KW_IDREFS[] = { - ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; -#ifdef XML_DTD -static const char KW_IGNORE[] = { - ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; -#endif -static const char KW_IMPLIED[] = { - ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; -#ifdef XML_DTD -static const char KW_INCLUDE[] = { - ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; -#endif -static const char KW_NDATA[] = { - ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_NMTOKEN[] = { - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; -static const char KW_NMTOKENS[] = { - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, - '\0' }; -static const char KW_NOTATION[] = - { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, - '\0' }; -static const char KW_PCDATA[] = { - ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_PUBLIC[] = { - ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' }; -static const char KW_REQUIRED[] = { - ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D, - '\0' }; -static const char KW_SYSTEM[] = { - ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' }; - -#ifndef MIN_BYTES_PER_CHAR -#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar) -#endif - -#ifdef XML_DTD -#define setTopLevel(state) \ - ((state)->handler = ((state)->documentEntity \ - ? internalSubset \ - : externalSubset1)) -#else /* not XML_DTD */ -#define setTopLevel(state) ((state)->handler = internalSubset) -#endif /* not XML_DTD */ - -typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc); - -static PROLOG_HANDLER - prolog0, prolog1, prolog2, - doctype0, doctype1, doctype2, doctype3, doctype4, doctype5, - internalSubset, - entity0, entity1, entity2, entity3, entity4, entity5, entity6, - entity7, entity8, entity9, entity10, - notation0, notation1, notation2, notation3, notation4, - attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6, - attlist7, attlist8, attlist9, - element0, element1, element2, element3, element4, element5, element6, - element7, -#ifdef XML_DTD - externalSubset0, externalSubset1, - condSect0, condSect1, condSect2, -#endif /* XML_DTD */ - declClose, - error; - -static int FASTCALL common(PROLOG_STATE *state, int tok); - -static int PTRCALL -prolog0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - state->handler = prolog1; - return XML_ROLE_NONE; - case XML_TOK_XML_DECL: - state->handler = prolog1; - return XML_ROLE_XML_DECL; - case XML_TOK_PI: - state->handler = prolog1; - return XML_ROLE_PI; - case XML_TOK_COMMENT: - state->handler = prolog1; - return XML_ROLE_COMMENT; - case XML_TOK_BOM: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (!XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_DOCTYPE)) - break; - state->handler = doctype0; - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static int PTRCALL -prolog1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_PI: - return XML_ROLE_PI; - case XML_TOK_COMMENT: - return XML_ROLE_COMMENT; - case XML_TOK_BOM: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (!XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_DOCTYPE)) - break; - state->handler = doctype0; - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static int PTRCALL -prolog2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_PI: - return XML_ROLE_PI; - case XML_TOK_COMMENT: - return XML_ROLE_COMMENT; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static int PTRCALL -doctype0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = doctype1; - return XML_ROLE_DOCTYPE_NAME; - } - return common(state, tok); -} - -static int PTRCALL -doctype1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = internalSubset; - return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = doctype3; - return XML_ROLE_DOCTYPE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = doctype2; - return XML_ROLE_DOCTYPE_NONE; - } - break; - } - return common(state, tok); -} - -static int PTRCALL -doctype2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_LITERAL: - state->handler = doctype3; - return XML_ROLE_DOCTYPE_PUBLIC_ID; - } - return common(state, tok); -} - -static int PTRCALL -doctype3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_LITERAL: - state->handler = doctype4; - return XML_ROLE_DOCTYPE_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -doctype4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = internalSubset; - return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - } - return common(state, tok); -} - -static int PTRCALL -doctype5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - } - return common(state, tok); -} - -static int PTRCALL -internalSubset(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ENTITY)) { - state->handler = entity0; - return XML_ROLE_ENTITY_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ATTLIST)) { - state->handler = attlist0; - return XML_ROLE_ATTLIST_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ELEMENT)) { - state->handler = element0; - return XML_ROLE_ELEMENT_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_NOTATION)) { - state->handler = notation0; - return XML_ROLE_NOTATION_NONE; - } - break; - case XML_TOK_PI: - return XML_ROLE_PI; - case XML_TOK_COMMENT: - return XML_ROLE_COMMENT; - case XML_TOK_PARAM_ENTITY_REF: - return XML_ROLE_PARAM_ENTITY_REF; - case XML_TOK_CLOSE_BRACKET: - state->handler = doctype5; - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_NONE: - return XML_ROLE_NONE; - } - return common(state, tok); -} - -#ifdef XML_DTD - -static int PTRCALL -externalSubset0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - state->handler = externalSubset1; - if (tok == XML_TOK_XML_DECL) - return XML_ROLE_TEXT_DECL; - return externalSubset1(state, tok, ptr, end, enc); -} - -static int PTRCALL -externalSubset1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_COND_SECT_OPEN: - state->handler = condSect0; - return XML_ROLE_NONE; - case XML_TOK_COND_SECT_CLOSE: - if (state->includeLevel == 0) - break; - state->includeLevel -= 1; - return XML_ROLE_NONE; - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_CLOSE_BRACKET: - break; - case XML_TOK_NONE: - if (state->includeLevel) - break; - return XML_ROLE_NONE; - default: - return internalSubset(state, tok, ptr, end, enc); - } - return common(state, tok); -} - -#endif /* XML_DTD */ - -static int PTRCALL -entity0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_PERCENT: - state->handler = entity1; - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - state->handler = entity2; - return XML_ROLE_GENERAL_ENTITY_NAME; - } - return common(state, tok); -} - -static int PTRCALL -entity1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - state->handler = entity7; - return XML_ROLE_PARAM_ENTITY_NAME; - } - return common(state, tok); -} - -static int PTRCALL -entity2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = entity4; - return XML_ROLE_ENTITY_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = entity3; - return XML_ROLE_ENTITY_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = declClose; - state->role_none = XML_ROLE_ENTITY_NONE; - return XML_ROLE_ENTITY_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -entity3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_LITERAL: - state->handler = entity4; - return XML_ROLE_ENTITY_PUBLIC_ID; - } - return common(state, tok); -} - -static int PTRCALL -entity4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_LITERAL: - state->handler = entity5; - return XML_ROLE_ENTITY_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -entity5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_ENTITY_COMPLETE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) { - state->handler = entity6; - return XML_ROLE_ENTITY_NONE; - } - break; - } - return common(state, tok); -} - -static int PTRCALL -entity6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - state->handler = declClose; - state->role_none = XML_ROLE_ENTITY_NONE; - return XML_ROLE_ENTITY_NOTATION_NAME; - } - return common(state, tok); -} - -static int PTRCALL -entity7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = entity9; - return XML_ROLE_ENTITY_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = entity8; - return XML_ROLE_ENTITY_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = declClose; - state->role_none = XML_ROLE_ENTITY_NONE; - return XML_ROLE_ENTITY_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -entity8(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_LITERAL: - state->handler = entity9; - return XML_ROLE_ENTITY_PUBLIC_ID; - } - return common(state, tok); -} - -static int PTRCALL -entity9(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_LITERAL: - state->handler = entity10; - return XML_ROLE_ENTITY_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -entity10(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_ENTITY_COMPLETE; - } - return common(state, tok); -} - -static int PTRCALL -notation0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_NAME: - state->handler = notation1; - return XML_ROLE_NOTATION_NAME; - } - return common(state, tok); -} - -static int PTRCALL -notation1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = notation3; - return XML_ROLE_NOTATION_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = notation2; - return XML_ROLE_NOTATION_NONE; - } - break; - } - return common(state, tok); -} - -static int PTRCALL -notation2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_LITERAL: - state->handler = notation4; - return XML_ROLE_NOTATION_PUBLIC_ID; - } - return common(state, tok); -} - -static int PTRCALL -notation3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_LITERAL: - state->handler = declClose; - state->role_none = XML_ROLE_NOTATION_NONE; - return XML_ROLE_NOTATION_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -notation4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_LITERAL: - state->handler = declClose; - state->role_none = XML_ROLE_NOTATION_NONE; - return XML_ROLE_NOTATION_SYSTEM_ID; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_NOTATION_NO_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -attlist0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist1; - return XML_ROLE_ATTLIST_ELEMENT_NAME; - } - return common(state, tok); -} - -static int PTRCALL -attlist1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist2; - return XML_ROLE_ATTRIBUTE_NAME; - } - return common(state, tok); -} - -static int PTRCALL -attlist2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NAME: - { - static const char * const types[] = { - KW_CDATA, - KW_ID, - KW_IDREF, - KW_IDREFS, - KW_ENTITY, - KW_ENTITIES, - KW_NMTOKEN, - KW_NMTOKENS, - }; - int i; - for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++) - if (XmlNameMatchesAscii(enc, ptr, end, types[i])) { - state->handler = attlist8; - return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i; - } - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) { - state->handler = attlist5; - return XML_ROLE_ATTLIST_NONE; - } - break; - case XML_TOK_OPEN_PAREN: - state->handler = attlist3; - return XML_ROLE_ATTLIST_NONE; - } - return common(state, tok); -} - -static int PTRCALL -attlist3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NMTOKEN: - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist4; - return XML_ROLE_ATTRIBUTE_ENUM_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -attlist4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = attlist8; - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_OR: - state->handler = attlist3; - return XML_ROLE_ATTLIST_NONE; - } - return common(state, tok); -} - -static int PTRCALL -attlist5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_OPEN_PAREN: - state->handler = attlist6; - return XML_ROLE_ATTLIST_NONE; - } - return common(state, tok); -} - -static int PTRCALL -attlist6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NAME: - state->handler = attlist7; - return XML_ROLE_ATTRIBUTE_NOTATION_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -attlist7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = attlist8; - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_OR: - state->handler = attlist6; - return XML_ROLE_ATTLIST_NONE; - } - return common(state, tok); -} - -/* default value */ -static int PTRCALL -attlist8(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_POUND_NAME: - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_IMPLIED)) { - state->handler = attlist1; - return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE; - } - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_REQUIRED)) { - state->handler = attlist1; - return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE; - } - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_FIXED)) { - state->handler = attlist9; - return XML_ROLE_ATTLIST_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = attlist1; - return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -attlist9(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_LITERAL: - state->handler = attlist1; - return XML_ROLE_FIXED_ATTRIBUTE_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -element0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element1; - return XML_ROLE_ELEMENT_NAME; - } - return common(state, tok); -} - -static int PTRCALL -element1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_CONTENT_EMPTY; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_ANY)) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_CONTENT_ANY; - } - break; - case XML_TOK_OPEN_PAREN: - state->handler = element2; - state->level = 1; - return XML_ROLE_GROUP_OPEN; - } - return common(state, tok); -} - -static int PTRCALL -element2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_POUND_NAME: - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_PCDATA)) { - state->handler = element3; - return XML_ROLE_CONTENT_PCDATA; - } - break; - case XML_TOK_OPEN_PAREN: - state->level = 2; - state->handler = element6; - return XML_ROLE_GROUP_OPEN; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT; - case XML_TOK_NAME_QUESTION: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_OPT; - case XML_TOK_NAME_ASTERISK: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_REP; - case XML_TOK_NAME_PLUS: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_PLUS; - } - return common(state, tok); -} - -static int PTRCALL -element3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_GROUP_CLOSE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_OR: - state->handler = element4; - return XML_ROLE_ELEMENT_NONE; - } - return common(state, tok); -} - -static int PTRCALL -element4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element5; - return XML_ROLE_CONTENT_ELEMENT; - } - return common(state, tok); -} - -static int PTRCALL -element5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_OR: - state->handler = element4; - return XML_ROLE_ELEMENT_NONE; - } - return common(state, tok); -} - -static int PTRCALL -element6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_OPEN_PAREN: - state->level += 1; - return XML_ROLE_GROUP_OPEN; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT; - case XML_TOK_NAME_QUESTION: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_OPT; - case XML_TOK_NAME_ASTERISK: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_REP; - case XML_TOK_NAME_PLUS: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_PLUS; - } - return common(state, tok); -} - -static int PTRCALL -element7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_CLOSE_PAREN: - state->level -= 1; - if (state->level == 0) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - } - return XML_ROLE_GROUP_CLOSE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->level -= 1; - if (state->level == 0) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - } - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_CLOSE_PAREN_QUESTION: - state->level -= 1; - if (state->level == 0) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - } - return XML_ROLE_GROUP_CLOSE_OPT; - case XML_TOK_CLOSE_PAREN_PLUS: - state->level -= 1; - if (state->level == 0) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - } - return XML_ROLE_GROUP_CLOSE_PLUS; - case XML_TOK_COMMA: - state->handler = element6; - return XML_ROLE_GROUP_SEQUENCE; - case XML_TOK_OR: - state->handler = element6; - return XML_ROLE_GROUP_CHOICE; - } - return common(state, tok); -} - -#ifdef XML_DTD - -static int PTRCALL -condSect0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) { - state->handler = condSect1; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_IGNORE)) { - state->handler = condSect2; - return XML_ROLE_NONE; - } - break; - } - return common(state, tok); -} - -static int PTRCALL -condSect1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = externalSubset1; - state->includeLevel += 1; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -static int PTRCALL -condSect2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = externalSubset1; - return XML_ROLE_IGNORE_SECT; - } - return common(state, tok); -} - -#endif /* XML_DTD */ - -static int PTRCALL -declClose(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return state->role_none; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return state->role_none; - } - return common(state, tok); -} - -static int PTRCALL -error(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - return XML_ROLE_NONE; -} - -static int FASTCALL -common(PROLOG_STATE *state, int tok) -{ -#ifdef XML_DTD - if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF) - return XML_ROLE_INNER_PARAM_ENTITY_REF; -#endif - state->handler = error; - return XML_ROLE_ERROR; -} - -void -XmlPrologStateInit(PROLOG_STATE *state) -{ - state->handler = prolog0; -#ifdef XML_DTD - state->documentEntity = 1; - state->includeLevel = 0; - state->inEntityValue = 0; -#endif /* XML_DTD */ -} - -#ifdef XML_DTD - -void -XmlPrologStateInitExternalEntity(PROLOG_STATE *state) -{ - state->handler = externalSubset0; - state->documentEntity = 0; - state->includeLevel = 0; -} - -#endif /* XML_DTD */ diff -Nru gpick-0.2.4/extern/expat/lib/xmlrole.h gpick-0.2.5/extern/expat/lib/xmlrole.h --- gpick-0.2.4/extern/expat/lib/xmlrole.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/xmlrole.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifndef XmlRole_INCLUDED -#define XmlRole_INCLUDED 1 - -#ifdef __VMS -/* 0 1 2 3 0 1 2 3 - 1234567890123456789012345678901 1234567890123456789012345678901 */ -#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt -#endif - -#include "xmltok.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - XML_ROLE_ERROR = -1, - XML_ROLE_NONE = 0, - XML_ROLE_XML_DECL, - XML_ROLE_INSTANCE_START, - XML_ROLE_DOCTYPE_NONE, - XML_ROLE_DOCTYPE_NAME, - XML_ROLE_DOCTYPE_SYSTEM_ID, - XML_ROLE_DOCTYPE_PUBLIC_ID, - XML_ROLE_DOCTYPE_INTERNAL_SUBSET, - XML_ROLE_DOCTYPE_CLOSE, - XML_ROLE_GENERAL_ENTITY_NAME, - XML_ROLE_PARAM_ENTITY_NAME, - XML_ROLE_ENTITY_NONE, - XML_ROLE_ENTITY_VALUE, - XML_ROLE_ENTITY_SYSTEM_ID, - XML_ROLE_ENTITY_PUBLIC_ID, - XML_ROLE_ENTITY_COMPLETE, - XML_ROLE_ENTITY_NOTATION_NAME, - XML_ROLE_NOTATION_NONE, - XML_ROLE_NOTATION_NAME, - XML_ROLE_NOTATION_SYSTEM_ID, - XML_ROLE_NOTATION_NO_SYSTEM_ID, - XML_ROLE_NOTATION_PUBLIC_ID, - XML_ROLE_ATTRIBUTE_NAME, - XML_ROLE_ATTRIBUTE_TYPE_CDATA, - XML_ROLE_ATTRIBUTE_TYPE_ID, - XML_ROLE_ATTRIBUTE_TYPE_IDREF, - XML_ROLE_ATTRIBUTE_TYPE_IDREFS, - XML_ROLE_ATTRIBUTE_TYPE_ENTITY, - XML_ROLE_ATTRIBUTE_TYPE_ENTITIES, - XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN, - XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS, - XML_ROLE_ATTRIBUTE_ENUM_VALUE, - XML_ROLE_ATTRIBUTE_NOTATION_VALUE, - XML_ROLE_ATTLIST_NONE, - XML_ROLE_ATTLIST_ELEMENT_NAME, - XML_ROLE_IMPLIED_ATTRIBUTE_VALUE, - XML_ROLE_REQUIRED_ATTRIBUTE_VALUE, - XML_ROLE_DEFAULT_ATTRIBUTE_VALUE, - XML_ROLE_FIXED_ATTRIBUTE_VALUE, - XML_ROLE_ELEMENT_NONE, - XML_ROLE_ELEMENT_NAME, - XML_ROLE_CONTENT_ANY, - XML_ROLE_CONTENT_EMPTY, - XML_ROLE_CONTENT_PCDATA, - XML_ROLE_GROUP_OPEN, - XML_ROLE_GROUP_CLOSE, - XML_ROLE_GROUP_CLOSE_REP, - XML_ROLE_GROUP_CLOSE_OPT, - XML_ROLE_GROUP_CLOSE_PLUS, - XML_ROLE_GROUP_CHOICE, - XML_ROLE_GROUP_SEQUENCE, - XML_ROLE_CONTENT_ELEMENT, - XML_ROLE_CONTENT_ELEMENT_REP, - XML_ROLE_CONTENT_ELEMENT_OPT, - XML_ROLE_CONTENT_ELEMENT_PLUS, - XML_ROLE_PI, - XML_ROLE_COMMENT, -#ifdef XML_DTD - XML_ROLE_TEXT_DECL, - XML_ROLE_IGNORE_SECT, - XML_ROLE_INNER_PARAM_ENTITY_REF, -#endif /* XML_DTD */ - XML_ROLE_PARAM_ENTITY_REF -}; - -typedef struct prolog_state { - int (PTRCALL *handler) (struct prolog_state *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc); - unsigned level; - int role_none; -#ifdef XML_DTD - unsigned includeLevel; - int documentEntity; - int inEntityValue; -#endif /* XML_DTD */ -} PROLOG_STATE; - -void XmlPrologStateInit(PROLOG_STATE *); -#ifdef XML_DTD -void XmlPrologStateInitExternalEntity(PROLOG_STATE *); -#endif /* XML_DTD */ - -#define XmlTokenRole(state, tok, ptr, end, enc) \ - (((state)->handler)(state, tok, ptr, end, enc)) - -#ifdef __cplusplus -} -#endif - -#endif /* not XmlRole_INCLUDED */ diff -Nru gpick-0.2.4/extern/expat/lib/xmltok.c gpick-0.2.5/extern/expat/lib/xmltok.c --- gpick-0.2.4/extern/expat/lib/xmltok.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/xmltok.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1651 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#include - -#ifdef COMPILED_FROM_DSP -#include "winconfig.h" -#elif defined(MACOS_CLASSIC) -#include "macconfig.h" -#elif defined(__amigaos__) -#include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" -#else -#ifdef HAVE_EXPAT_CONFIG_H -#include -#endif -#endif /* ndef COMPILED_FROM_DSP */ - -#include "expat_external.h" -#include "internal.h" -#include "xmltok.h" -#include "nametab.h" - -#ifdef XML_DTD -#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok) -#else -#define IGNORE_SECTION_TOK_VTABLE /* as nothing */ -#endif - -#define VTABLE1 \ - { PREFIX(prologTok), PREFIX(contentTok), \ - PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \ - { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \ - PREFIX(sameName), \ - PREFIX(nameMatchesAscii), \ - PREFIX(nameLength), \ - PREFIX(skipS), \ - PREFIX(getAtts), \ - PREFIX(charRefNumber), \ - PREFIX(predefinedEntityName), \ - PREFIX(updatePosition), \ - PREFIX(isPublicId) - -#define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16) - -#define UCS2_GET_NAMING(pages, hi, lo) \ - (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1 << ((lo) & 0x1F))) - -/* A 2 byte UTF-8 representation splits the characters 11 bits between - the bottom 5 and 6 bits of the bytes. We need 8 bits to index into - pages, 3 bits to add to that index and 5 bits to generate the mask. -*/ -#define UTF8_GET_NAMING2(pages, byte) \ - (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \ - + ((((byte)[0]) & 3) << 1) \ - + ((((byte)[1]) >> 5) & 1)] \ - & (1 << (((byte)[1]) & 0x1F))) - -/* A 3 byte UTF-8 representation splits the characters 16 bits between - the bottom 4, 6 and 6 bits of the bytes. We need 8 bits to index - into pages, 3 bits to add to that index and 5 bits to generate the - mask. -*/ -#define UTF8_GET_NAMING3(pages, byte) \ - (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \ - + ((((byte)[1]) >> 2) & 0xF)] \ - << 3) \ - + ((((byte)[1]) & 3) << 1) \ - + ((((byte)[2]) >> 5) & 1)] \ - & (1 << (((byte)[2]) & 0x1F))) - -#define UTF8_GET_NAMING(pages, p, n) \ - ((n) == 2 \ - ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \ - : ((n) == 3 \ - ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \ - : 0)) - -/* Detection of invalid UTF-8 sequences is based on Table 3.1B - of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/ - with the additional restriction of not allowing the Unicode - code points 0xFFFF and 0xFFFE (sequences EF,BF,BF and EF,BF,BE). - Implementation details: - (A & 0x80) == 0 means A < 0x80 - and - (A & 0xC0) == 0xC0 means A > 0xBF -*/ - -#define UTF8_INVALID2(p) \ - ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0) - -#define UTF8_INVALID3(p) \ - (((p)[2] & 0x80) == 0 \ - || \ - ((*p) == 0xEF && (p)[1] == 0xBF \ - ? \ - (p)[2] > 0xBD \ - : \ - ((p)[2] & 0xC0) == 0xC0) \ - || \ - ((*p) == 0xE0 \ - ? \ - (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \ - : \ - ((p)[1] & 0x80) == 0 \ - || \ - ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0))) - -#define UTF8_INVALID4(p) \ - (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 \ - || \ - ((p)[2] & 0x80) == 0 || ((p)[2] & 0xC0) == 0xC0 \ - || \ - ((*p) == 0xF0 \ - ? \ - (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \ - : \ - ((p)[1] & 0x80) == 0 \ - || \ - ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0))) - -static int PTRFASTCALL -isNever(const ENCODING *enc, const char *p) -{ - return 0; -} - -static int PTRFASTCALL -utf8_isName2(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING2(namePages, (const unsigned char *)p); -} - -static int PTRFASTCALL -utf8_isName3(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING3(namePages, (const unsigned char *)p); -} - -#define utf8_isName4 isNever - -static int PTRFASTCALL -utf8_isNmstrt2(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p); -} - -static int PTRFASTCALL -utf8_isNmstrt3(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p); -} - -#define utf8_isNmstrt4 isNever - -static int PTRFASTCALL -utf8_isInvalid2(const ENCODING *enc, const char *p) -{ - return UTF8_INVALID2((const unsigned char *)p); -} - -static int PTRFASTCALL -utf8_isInvalid3(const ENCODING *enc, const char *p) -{ - return UTF8_INVALID3((const unsigned char *)p); -} - -static int PTRFASTCALL -utf8_isInvalid4(const ENCODING *enc, const char *p) -{ - return UTF8_INVALID4((const unsigned char *)p); -} - -struct normal_encoding { - ENCODING enc; - unsigned char type[256]; -#ifdef XML_MIN_SIZE - int (PTRFASTCALL *byteType)(const ENCODING *, const char *); - int (PTRFASTCALL *isNameMin)(const ENCODING *, const char *); - int (PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *); - int (PTRFASTCALL *byteToAscii)(const ENCODING *, const char *); - int (PTRCALL *charMatches)(const ENCODING *, const char *, int); -#endif /* XML_MIN_SIZE */ - int (PTRFASTCALL *isName2)(const ENCODING *, const char *); - int (PTRFASTCALL *isName3)(const ENCODING *, const char *); - int (PTRFASTCALL *isName4)(const ENCODING *, const char *); - int (PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *); - int (PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *); - int (PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *); - int (PTRFASTCALL *isInvalid2)(const ENCODING *, const char *); - int (PTRFASTCALL *isInvalid3)(const ENCODING *, const char *); - int (PTRFASTCALL *isInvalid4)(const ENCODING *, const char *); -}; - -#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *) (enc)) - -#ifdef XML_MIN_SIZE - -#define STANDARD_VTABLE(E) \ - E ## byteType, \ - E ## isNameMin, \ - E ## isNmstrtMin, \ - E ## byteToAscii, \ - E ## charMatches, - -#else - -#define STANDARD_VTABLE(E) /* as nothing */ - -#endif - -#define NORMAL_VTABLE(E) \ - E ## isName2, \ - E ## isName3, \ - E ## isName4, \ - E ## isNmstrt2, \ - E ## isNmstrt3, \ - E ## isNmstrt4, \ - E ## isInvalid2, \ - E ## isInvalid3, \ - E ## isInvalid4 - -static int FASTCALL checkCharRefNumber(int); - -#include "xmltok_impl.h" -#include "ascii.h" - -#ifdef XML_MIN_SIZE -#define sb_isNameMin isNever -#define sb_isNmstrtMin isNever -#endif - -#ifdef XML_MIN_SIZE -#define MINBPC(enc) ((enc)->minBytesPerChar) -#else -/* minimum bytes per character */ -#define MINBPC(enc) 1 -#endif - -#define SB_BYTE_TYPE(enc, p) \ - (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) - -#ifdef XML_MIN_SIZE -static int PTRFASTCALL -sb_byteType(const ENCODING *enc, const char *p) -{ - return SB_BYTE_TYPE(enc, p); -} -#define BYTE_TYPE(enc, p) \ - (AS_NORMAL_ENCODING(enc)->byteType(enc, p)) -#else -#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) -#endif - -#ifdef XML_MIN_SIZE -#define BYTE_TO_ASCII(enc, p) \ - (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p)) -static int PTRFASTCALL -sb_byteToAscii(const ENCODING *enc, const char *p) -{ - return *p; -} -#else -#define BYTE_TO_ASCII(enc, p) (*(p)) -#endif - -#define IS_NAME_CHAR(enc, p, n) \ - (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p)) -#define IS_NMSTRT_CHAR(enc, p, n) \ - (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p)) -#define IS_INVALID_CHAR(enc, p, n) \ - (AS_NORMAL_ENCODING(enc)->isInvalid ## n(enc, p)) - -#ifdef XML_MIN_SIZE -#define IS_NAME_CHAR_MINBPC(enc, p) \ - (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p)) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) \ - (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p)) -#else -#define IS_NAME_CHAR_MINBPC(enc, p) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) -#endif - -#ifdef XML_MIN_SIZE -#define CHAR_MATCHES(enc, p, c) \ - (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c)) -static int PTRCALL -sb_charMatches(const ENCODING *enc, const char *p, int c) -{ - return *p == c; -} -#else -/* c is an ASCII character */ -#define CHAR_MATCHES(enc, p, c) (*(p) == c) -#endif - -#define PREFIX(ident) normal_ ## ident -#define XML_TOK_IMPL_C -#include "xmltok_impl.c" -#undef XML_TOK_IMPL_C - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ - UTF8_cval1 = 0x00, - UTF8_cval2 = 0xc0, - UTF8_cval3 = 0xe0, - UTF8_cval4 = 0xf0 -}; - -static void PTRCALL -utf8_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - char *to; - const char *from; - if (fromLim - *fromP > toLim - *toP) { - /* Avoid copying partial characters. */ - for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--) - if (((unsigned char)fromLim[-1] & 0xc0) != 0x80) - break; - } - for (to = *toP, from = *fromP; from != fromLim; from++, to++) - *to = *from; - *fromP = from; - *toP = to; -} - -static void PTRCALL -utf8_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - unsigned short *to = *toP; - const char *from = *fromP; - while (from != fromLim && to != toLim) { - switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) { - case BT_LEAD2: - *to++ = (unsigned short)(((from[0] & 0x1f) << 6) | (from[1] & 0x3f)); - from += 2; - break; - case BT_LEAD3: - *to++ = (unsigned short)(((from[0] & 0xf) << 12) - | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f)); - from += 3; - break; - case BT_LEAD4: - { - unsigned long n; - if (to + 1 == toLim) - goto after; - n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) - | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f); - n -= 0x10000; - to[0] = (unsigned short)((n >> 10) | 0xD800); - to[1] = (unsigned short)((n & 0x3FF) | 0xDC00); - to += 2; - from += 4; - } - break; - default: - *to++ = *from++; - break; - } - } -after: - *fromP = from; - *toP = to; -} - -#ifdef XML_NS -static const struct normal_encoding utf8_encoding_ns = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#include "asciitab.h" -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; -#endif - -static const struct normal_encoding utf8_encoding = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -#ifdef XML_NS - -static const struct normal_encoding internal_utf8_encoding_ns = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#include "iasciitab.h" -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -#endif - -static const struct normal_encoding internal_utf8_encoding = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -static void PTRCALL -latin1_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - for (;;) { - unsigned char c; - if (*fromP == fromLim) - break; - c = (unsigned char)**fromP; - if (c & 0x80) { - if (toLim - *toP < 2) - break; - *(*toP)++ = (char)((c >> 6) | UTF8_cval2); - *(*toP)++ = (char)((c & 0x3f) | 0x80); - (*fromP)++; - } - else { - if (*toP == toLim) - break; - *(*toP)++ = *(*fromP)++; - } - } -} - -static void PTRCALL -latin1_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - while (*fromP != fromLim && *toP != toLim) - *(*toP)++ = (unsigned char)*(*fromP)++; -} - -#ifdef XML_NS - -static const struct normal_encoding latin1_encoding_ns = { - { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(sb_) -}; - -#endif - -static const struct normal_encoding latin1_encoding = { - { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(sb_) -}; - -static void PTRCALL -ascii_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - while (*fromP != fromLim && *toP != toLim) - *(*toP)++ = *(*fromP)++; -} - -#ifdef XML_NS - -static const struct normal_encoding ascii_encoding_ns = { - { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, - { -#include "asciitab.h" -/* BT_NONXML == 0 */ - }, - STANDARD_VTABLE(sb_) -}; - -#endif - -static const struct normal_encoding ascii_encoding = { - { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -/* BT_NONXML == 0 */ - }, - STANDARD_VTABLE(sb_) -}; - -static int PTRFASTCALL -unicode_byte_type(char hi, char lo) -{ - switch ((unsigned char)hi) { - case 0xD8: case 0xD9: case 0xDA: case 0xDB: - return BT_LEAD4; - case 0xDC: case 0xDD: case 0xDE: case 0xDF: - return BT_TRAIL; - case 0xFF: - switch ((unsigned char)lo) { - case 0xFF: - case 0xFE: - return BT_NONXML; - } - break; - } - return BT_NONASCII; -} - -#define DEFINE_UTF16_TO_UTF8(E) \ -static void PTRCALL \ -E ## toUtf8(const ENCODING *enc, \ - const char **fromP, const char *fromLim, \ - char **toP, const char *toLim) \ -{ \ - const char *from; \ - for (from = *fromP; from != fromLim; from += 2) { \ - int plane; \ - unsigned char lo2; \ - unsigned char lo = GET_LO(from); \ - unsigned char hi = GET_HI(from); \ - switch (hi) { \ - case 0: \ - if (lo < 0x80) { \ - if (*toP == toLim) { \ - *fromP = from; \ - return; \ - } \ - *(*toP)++ = lo; \ - break; \ - } \ - /* fall through */ \ - case 0x1: case 0x2: case 0x3: \ - case 0x4: case 0x5: case 0x6: case 0x7: \ - if (toLim - *toP < 2) { \ - *fromP = from; \ - return; \ - } \ - *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \ - *(*toP)++ = ((lo & 0x3f) | 0x80); \ - break; \ - default: \ - if (toLim - *toP < 3) { \ - *fromP = from; \ - return; \ - } \ - /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \ - *(*toP)++ = ((hi >> 4) | UTF8_cval3); \ - *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \ - *(*toP)++ = ((lo & 0x3f) | 0x80); \ - break; \ - case 0xD8: case 0xD9: case 0xDA: case 0xDB: \ - if (toLim - *toP < 4) { \ - *fromP = from; \ - return; \ - } \ - plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \ - *(*toP)++ = ((plane >> 2) | UTF8_cval4); \ - *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \ - from += 2; \ - lo2 = GET_LO(from); \ - *(*toP)++ = (((lo & 0x3) << 4) \ - | ((GET_HI(from) & 0x3) << 2) \ - | (lo2 >> 6) \ - | 0x80); \ - *(*toP)++ = ((lo2 & 0x3f) | 0x80); \ - break; \ - } \ - } \ - *fromP = from; \ -} - -#define DEFINE_UTF16_TO_UTF16(E) \ -static void PTRCALL \ -E ## toUtf16(const ENCODING *enc, \ - const char **fromP, const char *fromLim, \ - unsigned short **toP, const unsigned short *toLim) \ -{ \ - /* Avoid copying first half only of surrogate */ \ - if (fromLim - *fromP > ((toLim - *toP) << 1) \ - && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \ - fromLim -= 2; \ - for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \ - *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ -} - -#define SET2(ptr, ch) \ - (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8))) -#define GET_LO(ptr) ((unsigned char)(ptr)[0]) -#define GET_HI(ptr) ((unsigned char)(ptr)[1]) - -DEFINE_UTF16_TO_UTF8(little2_) -DEFINE_UTF16_TO_UTF16(little2_) - -#undef SET2 -#undef GET_LO -#undef GET_HI - -#define SET2(ptr, ch) \ - (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF))) -#define GET_LO(ptr) ((unsigned char)(ptr)[1]) -#define GET_HI(ptr) ((unsigned char)(ptr)[0]) - -DEFINE_UTF16_TO_UTF8(big2_) -DEFINE_UTF16_TO_UTF16(big2_) - -#undef SET2 -#undef GET_LO -#undef GET_HI - -#define LITTLE2_BYTE_TYPE(enc, p) \ - ((p)[1] == 0 \ - ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \ - : unicode_byte_type((p)[1], (p)[0])) -#define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1) -#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c) -#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0]) -#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0]) - -#ifdef XML_MIN_SIZE - -static int PTRFASTCALL -little2_byteType(const ENCODING *enc, const char *p) -{ - return LITTLE2_BYTE_TYPE(enc, p); -} - -static int PTRFASTCALL -little2_byteToAscii(const ENCODING *enc, const char *p) -{ - return LITTLE2_BYTE_TO_ASCII(enc, p); -} - -static int PTRCALL -little2_charMatches(const ENCODING *enc, const char *p, int c) -{ - return LITTLE2_CHAR_MATCHES(enc, p, c); -} - -static int PTRFASTCALL -little2_isNameMin(const ENCODING *enc, const char *p) -{ - return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p); -} - -static int PTRFASTCALL -little2_isNmstrtMin(const ENCODING *enc, const char *p) -{ - return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p); -} - -#undef VTABLE -#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 - -#else /* not XML_MIN_SIZE */ - -#undef PREFIX -#define PREFIX(ident) little2_ ## ident -#define MINBPC(enc) 2 -/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ -#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) -#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) -#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c) -#define IS_NAME_CHAR(enc, p, n) 0 -#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) -#define IS_NMSTRT_CHAR(enc, p, n) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) - -#define XML_TOK_IMPL_C -#include "xmltok_impl.c" -#undef XML_TOK_IMPL_C - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -#endif /* not XML_MIN_SIZE */ - -#ifdef XML_NS - -static const struct normal_encoding little2_encoding_ns = { - { VTABLE, 2, 0, -#if BYTEORDER == 1234 - 1 -#else - 0 -#endif - }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - -static const struct normal_encoding little2_encoding = { - { VTABLE, 2, 0, -#if BYTEORDER == 1234 - 1 -#else - 0 -#endif - }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#if BYTEORDER != 4321 - -#ifdef XML_NS - -static const struct normal_encoding internal_little2_encoding_ns = { - { VTABLE, 2, 0, 1 }, - { -#include "iasciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - -static const struct normal_encoding internal_little2_encoding = { - { VTABLE, 2, 0, 1 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - - -#define BIG2_BYTE_TYPE(enc, p) \ - ((p)[0] == 0 \ - ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \ - : unicode_byte_type((p)[0], (p)[1])) -#define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1) -#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c) -#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1]) -#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1]) - -#ifdef XML_MIN_SIZE - -static int PTRFASTCALL -big2_byteType(const ENCODING *enc, const char *p) -{ - return BIG2_BYTE_TYPE(enc, p); -} - -static int PTRFASTCALL -big2_byteToAscii(const ENCODING *enc, const char *p) -{ - return BIG2_BYTE_TO_ASCII(enc, p); -} - -static int PTRCALL -big2_charMatches(const ENCODING *enc, const char *p, int c) -{ - return BIG2_CHAR_MATCHES(enc, p, c); -} - -static int PTRFASTCALL -big2_isNameMin(const ENCODING *enc, const char *p) -{ - return BIG2_IS_NAME_CHAR_MINBPC(enc, p); -} - -static int PTRFASTCALL -big2_isNmstrtMin(const ENCODING *enc, const char *p) -{ - return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p); -} - -#undef VTABLE -#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 - -#else /* not XML_MIN_SIZE */ - -#undef PREFIX -#define PREFIX(ident) big2_ ## ident -#define MINBPC(enc) 2 -/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ -#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) -#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) -#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c) -#define IS_NAME_CHAR(enc, p, n) 0 -#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p) -#define IS_NMSTRT_CHAR(enc, p, n) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) - -#define XML_TOK_IMPL_C -#include "xmltok_impl.c" -#undef XML_TOK_IMPL_C - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -#endif /* not XML_MIN_SIZE */ - -#ifdef XML_NS - -static const struct normal_encoding big2_encoding_ns = { - { VTABLE, 2, 0, -#if BYTEORDER == 4321 - 1 -#else - 0 -#endif - }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -static const struct normal_encoding big2_encoding = { - { VTABLE, 2, 0, -#if BYTEORDER == 4321 - 1 -#else - 0 -#endif - }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#if BYTEORDER != 1234 - -#ifdef XML_NS - -static const struct normal_encoding internal_big2_encoding_ns = { - { VTABLE, 2, 0, 1 }, - { -#include "iasciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -static const struct normal_encoding internal_big2_encoding = { - { VTABLE, 2, 0, 1 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -#undef PREFIX - -static int FASTCALL -streqci(const char *s1, const char *s2) -{ - for (;;) { - char c1 = *s1++; - char c2 = *s2++; - if (ASCII_a <= c1 && c1 <= ASCII_z) - c1 += ASCII_A - ASCII_a; - if (ASCII_a <= c2 && c2 <= ASCII_z) - c2 += ASCII_A - ASCII_a; - if (c1 != c2) - return 0; - if (!c1) - break; - } - return 1; -} - -static void PTRCALL -initUpdatePosition(const ENCODING *enc, const char *ptr, - const char *end, POSITION *pos) -{ - normal_updatePosition(&utf8_encoding.enc, ptr, end, pos); -} - -static int -toAscii(const ENCODING *enc, const char *ptr, const char *end) -{ - char buf[1]; - char *p = buf; - XmlUtf8Convert(enc, &ptr, end, &p, p + 1); - if (p == buf) - return -1; - else - return buf[0]; -} - -static int FASTCALL -isSpace(int c) -{ - switch (c) { - case 0x20: - case 0xD: - case 0xA: - case 0x9: - return 1; - } - return 0; -} - -/* Return 1 if there's just optional white space or there's an S - followed by name=val. -*/ -static int -parsePseudoAttribute(const ENCODING *enc, - const char *ptr, - const char *end, - const char **namePtr, - const char **nameEndPtr, - const char **valPtr, - const char **nextTokPtr) -{ - int c; - char open; - if (ptr == end) { - *namePtr = NULL; - return 1; - } - if (!isSpace(toAscii(enc, ptr, end))) { - *nextTokPtr = ptr; - return 0; - } - do { - ptr += enc->minBytesPerChar; - } while (isSpace(toAscii(enc, ptr, end))); - if (ptr == end) { - *namePtr = NULL; - return 1; - } - *namePtr = ptr; - for (;;) { - c = toAscii(enc, ptr, end); - if (c == -1) { - *nextTokPtr = ptr; - return 0; - } - if (c == ASCII_EQUALS) { - *nameEndPtr = ptr; - break; - } - if (isSpace(c)) { - *nameEndPtr = ptr; - do { - ptr += enc->minBytesPerChar; - } while (isSpace(c = toAscii(enc, ptr, end))); - if (c != ASCII_EQUALS) { - *nextTokPtr = ptr; - return 0; - } - break; - } - ptr += enc->minBytesPerChar; - } - if (ptr == *namePtr) { - *nextTokPtr = ptr; - return 0; - } - ptr += enc->minBytesPerChar; - c = toAscii(enc, ptr, end); - while (isSpace(c)) { - ptr += enc->minBytesPerChar; - c = toAscii(enc, ptr, end); - } - if (c != ASCII_QUOT && c != ASCII_APOS) { - *nextTokPtr = ptr; - return 0; - } - open = (char)c; - ptr += enc->minBytesPerChar; - *valPtr = ptr; - for (;; ptr += enc->minBytesPerChar) { - c = toAscii(enc, ptr, end); - if (c == open) - break; - if (!(ASCII_a <= c && c <= ASCII_z) - && !(ASCII_A <= c && c <= ASCII_Z) - && !(ASCII_0 <= c && c <= ASCII_9) - && c != ASCII_PERIOD - && c != ASCII_MINUS - && c != ASCII_UNDERSCORE) { - *nextTokPtr = ptr; - return 0; - } - } - *nextTokPtr = ptr + enc->minBytesPerChar; - return 1; -} - -static const char KW_version[] = { - ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0' -}; - -static const char KW_encoding[] = { - ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, '\0' -}; - -static const char KW_standalone[] = { - ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o, - ASCII_n, ASCII_e, '\0' -}; - -static const char KW_yes[] = { - ASCII_y, ASCII_e, ASCII_s, '\0' -}; - -static const char KW_no[] = { - ASCII_n, ASCII_o, '\0' -}; - -static int -doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, - const char *, - const char *), - int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingName, - const ENCODING **encoding, - int *standalone) -{ - const char *val = NULL; - const char *name = NULL; - const char *nameEnd = NULL; - ptr += 5 * enc->minBytesPerChar; - end -= 2 * enc->minBytesPerChar; - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr) - || !name) { - *badPtr = ptr; - return 0; - } - if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) { - if (!isGeneralTextEntity) { - *badPtr = name; - return 0; - } - } - else { - if (versionPtr) - *versionPtr = val; - if (versionEndPtr) - *versionEndPtr = ptr; - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { - *badPtr = ptr; - return 0; - } - if (!name) { - if (isGeneralTextEntity) { - /* a TextDecl must have an EncodingDecl */ - *badPtr = ptr; - return 0; - } - return 1; - } - } - if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) { - int c = toAscii(enc, val, end); - if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) { - *badPtr = val; - return 0; - } - if (encodingName) - *encodingName = val; - if (encoding) - *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar); - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { - *badPtr = ptr; - return 0; - } - if (!name) - return 1; - } - if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone) - || isGeneralTextEntity) { - *badPtr = name; - return 0; - } - if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) { - if (standalone) - *standalone = 1; - } - else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) { - if (standalone) - *standalone = 0; - } - else { - *badPtr = val; - return 0; - } - while (isSpace(toAscii(enc, ptr, end))) - ptr += enc->minBytesPerChar; - if (ptr != end) { - *badPtr = ptr; - return 0; - } - return 1; -} - -static int FASTCALL -checkCharRefNumber(int result) -{ - switch (result >> 8) { - case 0xD8: case 0xD9: case 0xDA: case 0xDB: - case 0xDC: case 0xDD: case 0xDE: case 0xDF: - return -1; - case 0: - if (latin1_encoding.type[result] == BT_NONXML) - return -1; - break; - case 0xFF: - if (result == 0xFFFE || result == 0xFFFF) - return -1; - break; - } - return result; -} - -int FASTCALL -XmlUtf8Encode(int c, char *buf) -{ - enum { - /* minN is minimum legal resulting value for N byte sequence */ - min2 = 0x80, - min3 = 0x800, - min4 = 0x10000 - }; - - if (c < 0) - return 0; - if (c < min2) { - buf[0] = (char)(c | UTF8_cval1); - return 1; - } - if (c < min3) { - buf[0] = (char)((c >> 6) | UTF8_cval2); - buf[1] = (char)((c & 0x3f) | 0x80); - return 2; - } - if (c < min4) { - buf[0] = (char)((c >> 12) | UTF8_cval3); - buf[1] = (char)(((c >> 6) & 0x3f) | 0x80); - buf[2] = (char)((c & 0x3f) | 0x80); - return 3; - } - if (c < 0x110000) { - buf[0] = (char)((c >> 18) | UTF8_cval4); - buf[1] = (char)(((c >> 12) & 0x3f) | 0x80); - buf[2] = (char)(((c >> 6) & 0x3f) | 0x80); - buf[3] = (char)((c & 0x3f) | 0x80); - return 4; - } - return 0; -} - -int FASTCALL -XmlUtf16Encode(int charNum, unsigned short *buf) -{ - if (charNum < 0) - return 0; - if (charNum < 0x10000) { - buf[0] = (unsigned short)charNum; - return 1; - } - if (charNum < 0x110000) { - charNum -= 0x10000; - buf[0] = (unsigned short)((charNum >> 10) + 0xD800); - buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00); - return 2; - } - return 0; -} - -struct unknown_encoding { - struct normal_encoding normal; - CONVERTER convert; - void *userData; - unsigned short utf16[256]; - char utf8[256][4]; -}; - -#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *) (enc)) - -int -XmlSizeOfUnknownEncoding(void) -{ - return sizeof(struct unknown_encoding); -} - -static int PTRFASTCALL -unknown_isName(const ENCODING *enc, const char *p) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - int c = uenc->convert(uenc->userData, p); - if (c & ~0xFFFF) - return 0; - return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF); -} - -static int PTRFASTCALL -unknown_isNmstrt(const ENCODING *enc, const char *p) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - int c = uenc->convert(uenc->userData, p); - if (c & ~0xFFFF) - return 0; - return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF); -} - -static int PTRFASTCALL -unknown_isInvalid(const ENCODING *enc, const char *p) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - int c = uenc->convert(uenc->userData, p); - return (c & ~0xFFFF) || checkCharRefNumber(c) < 0; -} - -static void PTRCALL -unknown_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - char buf[XML_UTF8_ENCODE_MAX]; - for (;;) { - const char *utf8; - int n; - if (*fromP == fromLim) - break; - utf8 = uenc->utf8[(unsigned char)**fromP]; - n = *utf8++; - if (n == 0) { - int c = uenc->convert(uenc->userData, *fromP); - n = XmlUtf8Encode(c, buf); - if (n > toLim - *toP) - break; - utf8 = buf; - *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2)); - } - else { - if (n > toLim - *toP) - break; - (*fromP)++; - } - do { - *(*toP)++ = *utf8++; - } while (--n != 0); - } -} - -static void PTRCALL -unknown_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - while (*fromP != fromLim && *toP != toLim) { - unsigned short c = uenc->utf16[(unsigned char)**fromP]; - if (c == 0) { - c = (unsigned short) - uenc->convert(uenc->userData, *fromP); - *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2)); - } - else - (*fromP)++; - *(*toP)++ = c; - } -} - -ENCODING * -XmlInitUnknownEncoding(void *mem, - int *table, - CONVERTER convert, - void *userData) -{ - int i; - struct unknown_encoding *e = (struct unknown_encoding *)mem; - for (i = 0; i < (int)sizeof(struct normal_encoding); i++) - ((char *)mem)[i] = ((char *)&latin1_encoding)[i]; - for (i = 0; i < 128; i++) - if (latin1_encoding.type[i] != BT_OTHER - && latin1_encoding.type[i] != BT_NONXML - && table[i] != i) - return 0; - for (i = 0; i < 256; i++) { - int c = table[i]; - if (c == -1) { - e->normal.type[i] = BT_MALFORM; - /* This shouldn't really get used. */ - e->utf16[i] = 0xFFFF; - e->utf8[i][0] = 1; - e->utf8[i][1] = 0; - } - else if (c < 0) { - if (c < -4) - return 0; - e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2)); - e->utf8[i][0] = 0; - e->utf16[i] = 0; - } - else if (c < 0x80) { - if (latin1_encoding.type[c] != BT_OTHER - && latin1_encoding.type[c] != BT_NONXML - && c != i) - return 0; - e->normal.type[i] = latin1_encoding.type[c]; - e->utf8[i][0] = 1; - e->utf8[i][1] = (char)c; - e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c); - } - else if (checkCharRefNumber(c) < 0) { - e->normal.type[i] = BT_NONXML; - /* This shouldn't really get used. */ - e->utf16[i] = 0xFFFF; - e->utf8[i][0] = 1; - e->utf8[i][1] = 0; - } - else { - if (c > 0xFFFF) - return 0; - if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff)) - e->normal.type[i] = BT_NMSTRT; - else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff)) - e->normal.type[i] = BT_NAME; - else - e->normal.type[i] = BT_OTHER; - e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1); - e->utf16[i] = (unsigned short)c; - } - } - e->userData = userData; - e->convert = convert; - if (convert) { - e->normal.isName2 = unknown_isName; - e->normal.isName3 = unknown_isName; - e->normal.isName4 = unknown_isName; - e->normal.isNmstrt2 = unknown_isNmstrt; - e->normal.isNmstrt3 = unknown_isNmstrt; - e->normal.isNmstrt4 = unknown_isNmstrt; - e->normal.isInvalid2 = unknown_isInvalid; - e->normal.isInvalid3 = unknown_isInvalid; - e->normal.isInvalid4 = unknown_isInvalid; - } - e->normal.enc.utf8Convert = unknown_toUtf8; - e->normal.enc.utf16Convert = unknown_toUtf16; - return &(e->normal.enc); -} - -/* If this enumeration is changed, getEncodingIndex and encodings -must also be changed. */ -enum { - UNKNOWN_ENC = -1, - ISO_8859_1_ENC = 0, - US_ASCII_ENC, - UTF_8_ENC, - UTF_16_ENC, - UTF_16BE_ENC, - UTF_16LE_ENC, - /* must match encodingNames up to here */ - NO_ENC -}; - -static const char KW_ISO_8859_1[] = { - ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9, - ASCII_MINUS, ASCII_1, '\0' -}; -static const char KW_US_ASCII[] = { - ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I, - '\0' -}; -static const char KW_UTF_8[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0' -}; -static const char KW_UTF_16[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0' -}; -static const char KW_UTF_16BE[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E, - '\0' -}; -static const char KW_UTF_16LE[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E, - '\0' -}; - -static int FASTCALL -getEncodingIndex(const char *name) -{ - static const char * const encodingNames[] = { - KW_ISO_8859_1, - KW_US_ASCII, - KW_UTF_8, - KW_UTF_16, - KW_UTF_16BE, - KW_UTF_16LE, - }; - int i; - if (name == NULL) - return NO_ENC; - for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++) - if (streqci(name, encodingNames[i])) - return i; - return UNKNOWN_ENC; -} - -/* For binary compatibility, we store the index of the encoding - specified at initialization in the isUtf16 member. -*/ - -#define INIT_ENC_INDEX(enc) ((int)(enc)->initEnc.isUtf16) -#define SET_INIT_ENC_INDEX(enc, i) ((enc)->initEnc.isUtf16 = (char)i) - -/* This is what detects the encoding. encodingTable maps from - encoding indices to encodings; INIT_ENC_INDEX(enc) is the index of - the external (protocol) specified encoding; state is - XML_CONTENT_STATE if we're parsing an external text entity, and - XML_PROLOG_STATE otherwise. -*/ - - -static int -initScan(const ENCODING * const *encodingTable, - const INIT_ENCODING *enc, - int state, - const char *ptr, - const char *end, - const char **nextTokPtr) -{ - const ENCODING **encPtr; - - if (ptr == end) - return XML_TOK_NONE; - encPtr = enc->encPtr; - if (ptr + 1 == end) { - /* only a single byte available for auto-detection */ -#ifndef XML_DTD /* FIXME */ - /* a well-formed document entity must have more than one byte */ - if (state != XML_CONTENT_STATE) - return XML_TOK_PARTIAL; -#endif - /* so we're parsing an external text entity... */ - /* if UTF-16 was externally specified, then we need at least 2 bytes */ - switch (INIT_ENC_INDEX(enc)) { - case UTF_16_ENC: - case UTF_16LE_ENC: - case UTF_16BE_ENC: - return XML_TOK_PARTIAL; - } - switch ((unsigned char)*ptr) { - case 0xFE: - case 0xFF: - case 0xEF: /* possibly first byte of UTF-8 BOM */ - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - /* fall through */ - case 0x00: - case 0x3C: - return XML_TOK_PARTIAL; - } - } - else { - switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) { - case 0xFEFF: - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - *nextTokPtr = ptr + 2; - *encPtr = encodingTable[UTF_16BE_ENC]; - return XML_TOK_BOM; - /* 00 3C is handled in the default case */ - case 0x3C00: - if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC - || INIT_ENC_INDEX(enc) == UTF_16_ENC) - && state == XML_CONTENT_STATE) - break; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - case 0xFFFE: - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - *nextTokPtr = ptr + 2; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XML_TOK_BOM; - case 0xEFBB: - /* Maybe a UTF-8 BOM (EF BB BF) */ - /* If there's an explicitly specified (external) encoding - of ISO-8859-1 or some flavour of UTF-16 - and this is an external text entity, - don't look for the BOM, - because it might be a legal data. - */ - if (state == XML_CONTENT_STATE) { - int e = INIT_ENC_INDEX(enc); - if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC - || e == UTF_16LE_ENC || e == UTF_16_ENC) - break; - } - if (ptr + 2 == end) - return XML_TOK_PARTIAL; - if ((unsigned char)ptr[2] == 0xBF) { - *nextTokPtr = ptr + 3; - *encPtr = encodingTable[UTF_8_ENC]; - return XML_TOK_BOM; - } - break; - default: - if (ptr[0] == '\0') { - /* 0 isn't a legal data character. Furthermore a document - entity can only start with ASCII characters. So the only - way this can fail to be big-endian UTF-16 if it it's an - external parsed general entity that's labelled as - UTF-16LE. - */ - if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC) - break; - *encPtr = encodingTable[UTF_16BE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - } - else if (ptr[1] == '\0') { - /* We could recover here in the case: - - parsing an external entity - - second byte is 0 - - no externally specified encoding - - no encoding declaration - by assuming UTF-16LE. But we don't, because this would mean when - presented just with a single byte, we couldn't reliably determine - whether we needed further bytes. - */ - if (state == XML_CONTENT_STATE) - break; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - } - break; - } - } - *encPtr = encodingTable[INIT_ENC_INDEX(enc)]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); -} - - -#define NS(x) x -#define ns(x) x -#define XML_TOK_NS_C -#include "xmltok_ns.c" -#undef XML_TOK_NS_C -#undef NS -#undef ns - -#ifdef XML_NS - -#define NS(x) x ## NS -#define ns(x) x ## _ns - -#define XML_TOK_NS_C -#include "xmltok_ns.c" -#undef XML_TOK_NS_C - -#undef NS -#undef ns - -ENCODING * -XmlInitUnknownEncodingNS(void *mem, - int *table, - CONVERTER convert, - void *userData) -{ - ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData); - if (enc) - ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON; - return enc; -} - -#endif /* XML_NS */ diff -Nru gpick-0.2.4/extern/expat/lib/xmltok.h gpick-0.2.5/extern/expat/lib/xmltok.h --- gpick-0.2.4/extern/expat/lib/xmltok.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/xmltok.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,316 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifndef XmlTok_INCLUDED -#define XmlTok_INCLUDED 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* The following token may be returned by XmlContentTok */ -#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be - start of illegal ]]> sequence */ -/* The following tokens may be returned by both XmlPrologTok and - XmlContentTok. -*/ -#define XML_TOK_NONE -4 /* The string to be scanned is empty */ -#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan; - might be part of CRLF sequence */ -#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */ -#define XML_TOK_PARTIAL -1 /* only part of a token */ -#define XML_TOK_INVALID 0 - -/* The following tokens are returned by XmlContentTok; some are also - returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok. -*/ -#define XML_TOK_START_TAG_WITH_ATTS 1 -#define XML_TOK_START_TAG_NO_ATTS 2 -#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag */ -#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4 -#define XML_TOK_END_TAG 5 -#define XML_TOK_DATA_CHARS 6 -#define XML_TOK_DATA_NEWLINE 7 -#define XML_TOK_CDATA_SECT_OPEN 8 -#define XML_TOK_ENTITY_REF 9 -#define XML_TOK_CHAR_REF 10 /* numeric character reference */ - -/* The following tokens may be returned by both XmlPrologTok and - XmlContentTok. -*/ -#define XML_TOK_PI 11 /* processing instruction */ -#define XML_TOK_XML_DECL 12 /* XML decl or text decl */ -#define XML_TOK_COMMENT 13 -#define XML_TOK_BOM 14 /* Byte order mark */ - -/* The following tokens are returned only by XmlPrologTok */ -#define XML_TOK_PROLOG_S 15 -#define XML_TOK_DECL_OPEN 16 /* */ -#define XML_TOK_NAME 18 -#define XML_TOK_NMTOKEN 19 -#define XML_TOK_POUND_NAME 20 /* #name */ -#define XML_TOK_OR 21 /* | */ -#define XML_TOK_PERCENT 22 -#define XML_TOK_OPEN_PAREN 23 -#define XML_TOK_CLOSE_PAREN 24 -#define XML_TOK_OPEN_BRACKET 25 -#define XML_TOK_CLOSE_BRACKET 26 -#define XML_TOK_LITERAL 27 -#define XML_TOK_PARAM_ENTITY_REF 28 -#define XML_TOK_INSTANCE_START 29 - -/* The following occur only in element type declarations */ -#define XML_TOK_NAME_QUESTION 30 /* name? */ -#define XML_TOK_NAME_ASTERISK 31 /* name* */ -#define XML_TOK_NAME_PLUS 32 /* name+ */ -#define XML_TOK_COND_SECT_OPEN 33 /* */ -#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */ -#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */ -#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */ -#define XML_TOK_COMMA 38 - -/* The following token is returned only by XmlAttributeValueTok */ -#define XML_TOK_ATTRIBUTE_VALUE_S 39 - -/* The following token is returned only by XmlCdataSectionTok */ -#define XML_TOK_CDATA_SECT_CLOSE 40 - -/* With namespace processing this is returned by XmlPrologTok for a - name with a colon. -*/ -#define XML_TOK_PREFIXED_NAME 41 - -#ifdef XML_DTD -#define XML_TOK_IGNORE_SECT 42 -#endif /* XML_DTD */ - -#ifdef XML_DTD -#define XML_N_STATES 4 -#else /* not XML_DTD */ -#define XML_N_STATES 3 -#endif /* not XML_DTD */ - -#define XML_PROLOG_STATE 0 -#define XML_CONTENT_STATE 1 -#define XML_CDATA_SECTION_STATE 2 -#ifdef XML_DTD -#define XML_IGNORE_SECTION_STATE 3 -#endif /* XML_DTD */ - -#define XML_N_LITERAL_TYPES 2 -#define XML_ATTRIBUTE_VALUE_LITERAL 0 -#define XML_ENTITY_VALUE_LITERAL 1 - -/* The size of the buffer passed to XmlUtf8Encode must be at least this. */ -#define XML_UTF8_ENCODE_MAX 4 -/* The size of the buffer passed to XmlUtf16Encode must be at least this. */ -#define XML_UTF16_ENCODE_MAX 2 - -typedef struct position { - /* first line and first column are 0 not 1 */ - XML_Size lineNumber; - XML_Size columnNumber; -} POSITION; - -typedef struct { - const char *name; - const char *valuePtr; - const char *valueEnd; - char normalized; -} ATTRIBUTE; - -struct encoding; -typedef struct encoding ENCODING; - -typedef int (PTRCALL *SCANNER)(const ENCODING *, - const char *, - const char *, - const char **); - -struct encoding { - SCANNER scanners[XML_N_STATES]; - SCANNER literalScanners[XML_N_LITERAL_TYPES]; - int (PTRCALL *sameName)(const ENCODING *, - const char *, - const char *); - int (PTRCALL *nameMatchesAscii)(const ENCODING *, - const char *, - const char *, - const char *); - int (PTRFASTCALL *nameLength)(const ENCODING *, const char *); - const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *); - int (PTRCALL *getAtts)(const ENCODING *enc, - const char *ptr, - int attsMax, - ATTRIBUTE *atts); - int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr); - int (PTRCALL *predefinedEntityName)(const ENCODING *, - const char *, - const char *); - void (PTRCALL *updatePosition)(const ENCODING *, - const char *ptr, - const char *end, - POSITION *); - int (PTRCALL *isPublicId)(const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr); - void (PTRCALL *utf8Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - char **toP, - const char *toLim); - void (PTRCALL *utf16Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - unsigned short **toP, - const unsigned short *toLim); - int minBytesPerChar; - char isUtf8; - char isUtf16; -}; - -/* Scan the string starting at ptr until the end of the next complete - token, but do not scan past eptr. Return an integer giving the - type of token. - - Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set. - - Return XML_TOK_PARTIAL when the string does not contain a complete - token; nextTokPtr will not be set. - - Return XML_TOK_INVALID when the string does not start a valid - token; nextTokPtr will be set to point to the character which made - the token invalid. - - Otherwise the string starts with a valid token; nextTokPtr will be - set to point to the character following the end of that token. - - Each data character counts as a single token, but adjacent data - characters may be returned together. Similarly for characters in - the prolog outside literals, comments and processing instructions. -*/ - - -#define XmlTok(enc, state, ptr, end, nextTokPtr) \ - (((enc)->scanners[state])(enc, ptr, end, nextTokPtr)) - -#define XmlPrologTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr) - -#define XmlContentTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr) - -#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr) - -#ifdef XML_DTD - -#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr) - -#endif /* XML_DTD */ - -/* This is used for performing a 2nd-level tokenization on the content - of a literal that has already been returned by XmlTok. -*/ -#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \ - (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr)) - -#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \ - XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr) - -#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \ - XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr) - -#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2)) - -#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \ - (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2)) - -#define XmlNameLength(enc, ptr) \ - (((enc)->nameLength)(enc, ptr)) - -#define XmlSkipS(enc, ptr) \ - (((enc)->skipS)(enc, ptr)) - -#define XmlGetAttributes(enc, ptr, attsMax, atts) \ - (((enc)->getAtts)(enc, ptr, attsMax, atts)) - -#define XmlCharRefNumber(enc, ptr) \ - (((enc)->charRefNumber)(enc, ptr)) - -#define XmlPredefinedEntityName(enc, ptr, end) \ - (((enc)->predefinedEntityName)(enc, ptr, end)) - -#define XmlUpdatePosition(enc, ptr, end, pos) \ - (((enc)->updatePosition)(enc, ptr, end, pos)) - -#define XmlIsPublicId(enc, ptr, end, badPtr) \ - (((enc)->isPublicId)(enc, ptr, end, badPtr)) - -#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \ - (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim)) - -#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \ - (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim)) - -typedef struct { - ENCODING initEnc; - const ENCODING **encPtr; -} INIT_ENCODING; - -int XmlParseXmlDecl(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingNamePtr, - const ENCODING **namedEncodingPtr, - int *standalonePtr); - -int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name); -const ENCODING *XmlGetUtf8InternalEncoding(void); -const ENCODING *XmlGetUtf16InternalEncoding(void); -int FASTCALL XmlUtf8Encode(int charNumber, char *buf); -int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf); -int XmlSizeOfUnknownEncoding(void); - - -typedef int (XMLCALL *CONVERTER) (void *userData, const char *p); - -ENCODING * -XmlInitUnknownEncoding(void *mem, - int *table, - CONVERTER convert, - void *userData); - -int XmlParseXmlDeclNS(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingNamePtr, - const ENCODING **namedEncodingPtr, - int *standalonePtr); - -int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name); -const ENCODING *XmlGetUtf8InternalEncodingNS(void); -const ENCODING *XmlGetUtf16InternalEncodingNS(void); -ENCODING * -XmlInitUnknownEncodingNS(void *mem, - int *table, - CONVERTER convert, - void *userData); -#ifdef __cplusplus -} -#endif - -#endif /* not XmlTok_INCLUDED */ diff -Nru gpick-0.2.4/extern/expat/lib/xmltok_impl.c gpick-0.2.5/extern/expat/lib/xmltok_impl.c --- gpick-0.2.4/extern/expat/lib/xmltok_impl.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/xmltok_impl.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1783 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* This file is included! */ -#ifdef XML_TOK_IMPL_C - -#ifndef IS_INVALID_CHAR -#define IS_INVALID_CHAR(enc, ptr, n) (0) -#endif - -#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (IS_INVALID_CHAR(enc, ptr, n)) { \ - *(nextTokPtr) = (ptr); \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define INVALID_CASES(ptr, nextTokPtr) \ - INVALID_LEAD_CASE(2, ptr, nextTokPtr) \ - INVALID_LEAD_CASE(3, ptr, nextTokPtr) \ - INVALID_LEAD_CASE(4, ptr, nextTokPtr) \ - case BT_NONXML: \ - case BT_MALFORM: \ - case BT_TRAIL: \ - *(nextTokPtr) = (ptr); \ - return XML_TOK_INVALID; - -#define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (!IS_NAME_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \ - case BT_NONASCII: \ - if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - case BT_NMSTRT: \ - case BT_HEX: \ - case BT_DIGIT: \ - case BT_NAME: \ - case BT_MINUS: \ - ptr += MINBPC(enc); \ - break; \ - CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \ - CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \ - CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr) - -#define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \ - case BT_NONASCII: \ - if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - case BT_NMSTRT: \ - case BT_HEX: \ - ptr += MINBPC(enc); \ - break; \ - CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \ - CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \ - CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr) - -#ifndef PREFIX -#define PREFIX(ident) ident -#endif - -/* ptr points to character following " */ - switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) { - case BT_S: case BT_CR: case BT_LF: case BT_PERCNT: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - /* fall through */ - case BT_S: case BT_CR: case BT_LF: - *nextTokPtr = ptr; - return XML_TOK_DECL_OPEN; - case BT_NMSTRT: - case BT_HEX: - ptr += MINBPC(enc); - break; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return XML_TOK_PARTIAL; -} - -static int PTRCALL -PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, - const char *end, int *tokPtr) -{ - int upper = 0; - *tokPtr = XML_TOK_PI; - if (end - ptr != MINBPC(enc)*3) - return 1; - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_x: - break; - case ASCII_X: - upper = 1; - break; - default: - return 1; - } - ptr += MINBPC(enc); - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_m: - break; - case ASCII_M: - upper = 1; - break; - default: - return 1; - } - ptr += MINBPC(enc); - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_l: - break; - case ASCII_L: - upper = 1; - break; - default: - return 1; - } - if (upper) - return 0; - *tokPtr = XML_TOK_XML_DECL; - return 1; -} - -/* ptr points to character following " 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB)) - break; - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr -= MINBPC(enc); - break; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CDATA_SECT_CLOSE; - case BT_CR: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - case BT_LF: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - INVALID_CASES(ptr, nextTokPtr) - default: - ptr += MINBPC(enc); - break; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_DATA_CHARS; \ - } \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONXML: - case BT_MALFORM: - case BT_TRAIL: - case BT_CR: - case BT_LF: - case BT_RSQB: - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -/* ptr points to character following " 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_LT: - return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_AMP: - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_CR: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - case BT_LF: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_RSQB; - if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB)) - break; - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_RSQB; - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr -= MINBPC(enc); - break; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - INVALID_CASES(ptr, nextTokPtr) - default: - ptr += MINBPC(enc); - break; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_DATA_CHARS; \ - } \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_RSQB: - if (ptr + MINBPC(enc) != end) { - if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) { - ptr += MINBPC(enc); - break; - } - if (ptr + 2*MINBPC(enc) != end) { - if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) { - ptr += MINBPC(enc); - break; - } - *nextTokPtr = ptr + 2*MINBPC(enc); - return XML_TOK_INVALID; - } - } - /* fall through */ - case BT_AMP: - case BT_LT: - case BT_NONXML: - case BT_MALFORM: - case BT_TRAIL: - case BT_CR: - case BT_LF: - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -/* ptr points to character following "%" */ - -static int PTRCALL -PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - if (ptr == end) - return -XML_TOK_PERCENT; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) - case BT_S: case BT_LF: case BT_CR: case BT_PERCNT: - *nextTokPtr = ptr; - return XML_TOK_PERCENT; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_SEMI: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_PARAM_ENTITY_REF; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return XML_TOK_PARTIAL; -} - -static int PTRCALL -PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - if (ptr == end) - return XML_TOK_PARTIAL; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_CR: case BT_LF: case BT_S: - case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR: - *nextTokPtr = ptr; - return XML_TOK_POUND_NAME; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return -XML_TOK_POUND_NAME; -} - -static int PTRCALL -PREFIX(scanLit)(int open, const ENCODING *enc, - const char *ptr, const char *end, - const char **nextTokPtr) -{ - while (ptr != end) { - int t = BYTE_TYPE(enc, ptr); - switch (t) { - INVALID_CASES(ptr, nextTokPtr) - case BT_QUOT: - case BT_APOS: - ptr += MINBPC(enc); - if (t != open) - break; - if (ptr == end) - return -XML_TOK_LITERAL; - *nextTokPtr = ptr; - switch (BYTE_TYPE(enc, ptr)) { - case BT_S: case BT_CR: case BT_LF: - case BT_GT: case BT_PERCNT: case BT_LSQB: - return XML_TOK_LITERAL; - default: - return XML_TOK_INVALID; - } - default: - ptr += MINBPC(enc); - break; - } - } - return XML_TOK_PARTIAL; -} - -static int PTRCALL -PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - int tok; - if (ptr == end) - return XML_TOK_NONE; - if (MINBPC(enc) > 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_QUOT: - return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_APOS: - return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_LT: - { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - switch (BYTE_TYPE(enc, ptr)) { - case BT_EXCL: - return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_QUEST: - return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_NMSTRT: - case BT_HEX: - case BT_NONASCII: - case BT_LEAD2: - case BT_LEAD3: - case BT_LEAD4: - *nextTokPtr = ptr - MINBPC(enc); - return XML_TOK_INSTANCE_START; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - case BT_CR: - if (ptr + MINBPC(enc) == end) { - *nextTokPtr = end; - /* indicate that this might be part of a CR/LF pair */ - return -XML_TOK_PROLOG_S; - } - /* fall through */ - case BT_S: case BT_LF: - for (;;) { - ptr += MINBPC(enc); - if (ptr == end) - break; - switch (BYTE_TYPE(enc, ptr)) { - case BT_S: case BT_LF: - break; - case BT_CR: - /* don't split CR/LF pair */ - if (ptr + MINBPC(enc) != end) - break; - /* fall through */ - default: - *nextTokPtr = ptr; - return XML_TOK_PROLOG_S; - } - } - *nextTokPtr = ptr; - return XML_TOK_PROLOG_S; - case BT_PERCNT: - return PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_COMMA: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_COMMA; - case BT_LSQB: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OPEN_BRACKET; - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return -XML_TOK_CLOSE_BRACKET; - if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) { - if (ptr + MINBPC(enc) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) { - *nextTokPtr = ptr + 2*MINBPC(enc); - return XML_TOK_COND_SECT_CLOSE; - } - } - *nextTokPtr = ptr; - return XML_TOK_CLOSE_BRACKET; - case BT_LPAR: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OPEN_PAREN; - case BT_RPAR: - ptr += MINBPC(enc); - if (ptr == end) - return -XML_TOK_CLOSE_PAREN; - switch (BYTE_TYPE(enc, ptr)) { - case BT_AST: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_ASTERISK; - case BT_QUEST: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_QUESTION; - case BT_PLUS: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_PLUS; - case BT_CR: case BT_LF: case BT_S: - case BT_GT: case BT_COMMA: case BT_VERBAR: - case BT_RPAR: - *nextTokPtr = ptr; - return XML_TOK_CLOSE_PAREN; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - case BT_VERBAR: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OR; - case BT_GT: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DECL_CLOSE; - case BT_NUM: - return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr); -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (IS_NMSTRT_CHAR(enc, ptr, n)) { \ - ptr += n; \ - tok = XML_TOK_NAME; \ - break; \ - } \ - if (IS_NAME_CHAR(enc, ptr, n)) { \ - ptr += n; \ - tok = XML_TOK_NMTOKEN; \ - break; \ - } \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NMSTRT: - case BT_HEX: - tok = XML_TOK_NAME; - ptr += MINBPC(enc); - break; - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: -#ifdef XML_NS - case BT_COLON: -#endif - tok = XML_TOK_NMTOKEN; - ptr += MINBPC(enc); - break; - case BT_NONASCII: - if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { - ptr += MINBPC(enc); - tok = XML_TOK_NAME; - break; - } - if (IS_NAME_CHAR_MINBPC(enc, ptr)) { - ptr += MINBPC(enc); - tok = XML_TOK_NMTOKEN; - break; - } - /* fall through */ - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_GT: case BT_RPAR: case BT_COMMA: - case BT_VERBAR: case BT_LSQB: case BT_PERCNT: - case BT_S: case BT_CR: case BT_LF: - *nextTokPtr = ptr; - return tok; -#ifdef XML_NS - case BT_COLON: - ptr += MINBPC(enc); - switch (tok) { - case XML_TOK_NAME: - if (ptr == end) - return XML_TOK_PARTIAL; - tok = XML_TOK_PREFIXED_NAME; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - default: - tok = XML_TOK_NMTOKEN; - break; - } - break; - case XML_TOK_PREFIXED_NAME: - tok = XML_TOK_NMTOKEN; - break; - } - break; -#endif - case BT_PLUS: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_PLUS; - case BT_AST: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_ASTERISK; - case BT_QUEST: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_QUESTION; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return -tok; -} - -static int PTRCALL -PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, - const char *end, const char **nextTokPtr) -{ - const char *start; - if (ptr == end) - return XML_TOK_NONE; - start = ptr; - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_AMP: - if (ptr == start) - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_LT: - /* this is for inside entity references */ - *nextTokPtr = ptr; - return XML_TOK_INVALID; - case BT_LF: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_CR: - if (ptr == start) { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_S: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_ATTRIBUTE_VALUE_S; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -static int PTRCALL -PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, - const char *end, const char **nextTokPtr) -{ - const char *start; - if (ptr == end) - return XML_TOK_NONE; - start = ptr; - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_AMP: - if (ptr == start) - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_PERCNT: - if (ptr == start) { - int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc), - end, nextTokPtr); - return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_LF: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_CR: - if (ptr == start) { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -#ifdef XML_DTD - -static int PTRCALL -PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, - const char *end, const char **nextTokPtr) -{ - int level = 0; - if (MINBPC(enc) > 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - end = ptr + n; - } - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - INVALID_CASES(ptr, nextTokPtr) - case BT_LT: - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) { - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) { - ++level; - ptr += MINBPC(enc); - } - } - break; - case BT_RSQB: - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) { - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr += MINBPC(enc); - if (level == 0) { - *nextTokPtr = ptr; - return XML_TOK_IGNORE_SECT; - } - --level; - } - } - break; - default: - ptr += MINBPC(enc); - break; - } - } - return XML_TOK_PARTIAL; -} - -#endif /* XML_DTD */ - -static int PTRCALL -PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, - const char **badPtr) -{ - ptr += MINBPC(enc); - end -= MINBPC(enc); - for (; ptr != end; ptr += MINBPC(enc)) { - switch (BYTE_TYPE(enc, ptr)) { - case BT_DIGIT: - case BT_HEX: - case BT_MINUS: - case BT_APOS: - case BT_LPAR: - case BT_RPAR: - case BT_PLUS: - case BT_COMMA: - case BT_SOL: - case BT_EQUALS: - case BT_QUEST: - case BT_CR: - case BT_LF: - case BT_SEMI: - case BT_EXCL: - case BT_AST: - case BT_PERCNT: - case BT_NUM: -#ifdef XML_NS - case BT_COLON: -#endif - break; - case BT_S: - if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) { - *badPtr = ptr; - return 0; - } - break; - case BT_NAME: - case BT_NMSTRT: - if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) - break; - default: - switch (BYTE_TO_ASCII(enc, ptr)) { - case 0x24: /* $ */ - case 0x40: /* @ */ - break; - default: - *badPtr = ptr; - return 0; - } - break; - } - } - return 1; -} - -/* This must only be called for a well-formed start-tag or empty - element tag. Returns the number of attributes. Pointers to the - first attsMax attributes are stored in atts. -*/ - -static int PTRCALL -PREFIX(getAtts)(const ENCODING *enc, const char *ptr, - int attsMax, ATTRIBUTE *atts) -{ - enum { other, inName, inValue } state = inName; - int nAtts = 0; - int open = 0; /* defined when state == inValue; - initialization just to shut up compilers */ - - for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) { - switch (BYTE_TYPE(enc, ptr)) { -#define START_NAME \ - if (state == other) { \ - if (nAtts < attsMax) { \ - atts[nAtts].name = ptr; \ - atts[nAtts].normalized = 1; \ - } \ - state = inName; \ - } -#define LEAD_CASE(n) \ - case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONASCII: - case BT_NMSTRT: - case BT_HEX: - START_NAME - break; -#undef START_NAME - case BT_QUOT: - if (state != inValue) { - if (nAtts < attsMax) - atts[nAtts].valuePtr = ptr + MINBPC(enc); - state = inValue; - open = BT_QUOT; - } - else if (open == BT_QUOT) { - state = other; - if (nAtts < attsMax) - atts[nAtts].valueEnd = ptr; - nAtts++; - } - break; - case BT_APOS: - if (state != inValue) { - if (nAtts < attsMax) - atts[nAtts].valuePtr = ptr + MINBPC(enc); - state = inValue; - open = BT_APOS; - } - else if (open == BT_APOS) { - state = other; - if (nAtts < attsMax) - atts[nAtts].valueEnd = ptr; - nAtts++; - } - break; - case BT_AMP: - if (nAtts < attsMax) - atts[nAtts].normalized = 0; - break; - case BT_S: - if (state == inName) - state = other; - else if (state == inValue - && nAtts < attsMax - && atts[nAtts].normalized - && (ptr == atts[nAtts].valuePtr - || BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE - || BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE - || BYTE_TYPE(enc, ptr + MINBPC(enc)) == open)) - atts[nAtts].normalized = 0; - break; - case BT_CR: case BT_LF: - /* This case ensures that the first attribute name is counted - Apart from that we could just change state on the quote. */ - if (state == inName) - state = other; - else if (state == inValue && nAtts < attsMax) - atts[nAtts].normalized = 0; - break; - case BT_GT: - case BT_SOL: - if (state != inValue) - return nAtts; - break; - default: - break; - } - } - /* not reached */ -} - -static int PTRFASTCALL -PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) -{ - int result = 0; - /* skip &# */ - ptr += 2*MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_x)) { - for (ptr += MINBPC(enc); - !CHAR_MATCHES(enc, ptr, ASCII_SEMI); - ptr += MINBPC(enc)) { - int c = BYTE_TO_ASCII(enc, ptr); - switch (c) { - case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4: - case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9: - result <<= 4; - result |= (c - ASCII_0); - break; - case ASCII_A: case ASCII_B: case ASCII_C: - case ASCII_D: case ASCII_E: case ASCII_F: - result <<= 4; - result += 10 + (c - ASCII_A); - break; - case ASCII_a: case ASCII_b: case ASCII_c: - case ASCII_d: case ASCII_e: case ASCII_f: - result <<= 4; - result += 10 + (c - ASCII_a); - break; - } - if (result >= 0x110000) - return -1; - } - } - else { - for (; !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) { - int c = BYTE_TO_ASCII(enc, ptr); - result *= 10; - result += (c - ASCII_0); - if (result >= 0x110000) - return -1; - } - } - return checkCharRefNumber(result); -} - -static int PTRCALL -PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, - const char *end) -{ - switch ((end - ptr)/MINBPC(enc)) { - case 2: - if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) { - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_l: - return ASCII_LT; - case ASCII_g: - return ASCII_GT; - } - } - break; - case 3: - if (CHAR_MATCHES(enc, ptr, ASCII_a)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_m)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_p)) - return ASCII_AMP; - } - } - break; - case 4: - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_q: - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_u)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_o)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_t)) - return ASCII_QUOT; - } - } - break; - case ASCII_a: - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_p)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_o)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_s)) - return ASCII_APOS; - } - } - break; - } - } - return 0; -} - -static int PTRCALL -PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) -{ - for (;;) { - switch (BYTE_TYPE(enc, ptr1)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (*ptr1++ != *ptr2++) \ - return 0; - LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2) -#undef LEAD_CASE - /* fall through */ - if (*ptr1++ != *ptr2++) - return 0; - break; - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 1) { - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 2) { - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 3) { - if (*ptr2++ != *ptr1++) - return 0; - } - } - } - break; - default: - if (MINBPC(enc) == 1 && *ptr1 == *ptr2) - return 1; - switch (BYTE_TYPE(enc, ptr2)) { - case BT_LEAD2: - case BT_LEAD3: - case BT_LEAD4: - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - return 0; - default: - return 1; - } - } - } - /* not reached */ -} - -static int PTRCALL -PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, - const char *end1, const char *ptr2) -{ - for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { - if (ptr1 == end1) - return 0; - if (!CHAR_MATCHES(enc, ptr1, *ptr2)) - return 0; - } - return ptr1 == end1; -} - -static int PTRFASTCALL -PREFIX(nameLength)(const ENCODING *enc, const char *ptr) -{ - const char *start = ptr; - for (;;) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - ptr += MINBPC(enc); - break; - default: - return (int)(ptr - start); - } - } -} - -static const char * PTRFASTCALL -PREFIX(skipS)(const ENCODING *enc, const char *ptr) -{ - for (;;) { - switch (BYTE_TYPE(enc, ptr)) { - case BT_LF: - case BT_CR: - case BT_S: - ptr += MINBPC(enc); - break; - default: - return ptr; - } - } -} - -static void PTRCALL -PREFIX(updatePosition)(const ENCODING *enc, - const char *ptr, - const char *end, - POSITION *pos) -{ - while (ptr < end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_LF: - pos->columnNumber = (XML_Size)-1; - pos->lineNumber++; - ptr += MINBPC(enc); - break; - case BT_CR: - pos->lineNumber++; - ptr += MINBPC(enc); - if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - pos->columnNumber = (XML_Size)-1; - break; - default: - ptr += MINBPC(enc); - break; - } - pos->columnNumber++; - } -} - -#undef DO_LEAD_CASE -#undef MULTIBYTE_CASES -#undef INVALID_CASES -#undef CHECK_NAME_CASE -#undef CHECK_NAME_CASES -#undef CHECK_NMSTRT_CASE -#undef CHECK_NMSTRT_CASES - -#endif /* XML_TOK_IMPL_C */ diff -Nru gpick-0.2.4/extern/expat/lib/xmltok_impl.h gpick-0.2.5/extern/expat/lib/xmltok_impl.h --- gpick-0.2.4/extern/expat/lib/xmltok_impl.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/xmltok_impl.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -enum { - BT_NONXML, - BT_MALFORM, - BT_LT, - BT_AMP, - BT_RSQB, - BT_LEAD2, - BT_LEAD3, - BT_LEAD4, - BT_TRAIL, - BT_CR, - BT_LF, - BT_GT, - BT_QUOT, - BT_APOS, - BT_EQUALS, - BT_QUEST, - BT_EXCL, - BT_SOL, - BT_SEMI, - BT_NUM, - BT_LSQB, - BT_S, - BT_NMSTRT, - BT_COLON, - BT_HEX, - BT_DIGIT, - BT_NAME, - BT_MINUS, - BT_OTHER, /* known not to be a name or name start character */ - BT_NONASCII, /* might be a name or name start character */ - BT_PERCNT, - BT_LPAR, - BT_RPAR, - BT_AST, - BT_PLUS, - BT_COMMA, - BT_VERBAR -}; - -#include diff -Nru gpick-0.2.4/extern/expat/lib/xmltok_ns.c gpick-0.2.5/extern/expat/lib/xmltok_ns.c --- gpick-0.2.4/extern/expat/lib/xmltok_ns.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/expat/lib/xmltok_ns.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* This file is included! */ -#ifdef XML_TOK_NS_C - -const ENCODING * -NS(XmlGetUtf8InternalEncoding)(void) -{ - return &ns(internal_utf8_encoding).enc; -} - -const ENCODING * -NS(XmlGetUtf16InternalEncoding)(void) -{ -#if BYTEORDER == 1234 - return &ns(internal_little2_encoding).enc; -#elif BYTEORDER == 4321 - return &ns(internal_big2_encoding).enc; -#else - const short n = 1; - return (*(const char *)&n - ? &ns(internal_little2_encoding).enc - : &ns(internal_big2_encoding).enc); -#endif -} - -static const ENCODING * const NS(encodings)[] = { - &ns(latin1_encoding).enc, - &ns(ascii_encoding).enc, - &ns(utf8_encoding).enc, - &ns(big2_encoding).enc, - &ns(big2_encoding).enc, - &ns(little2_encoding).enc, - &ns(utf8_encoding).enc /* NO_ENC */ -}; - -static int PTRCALL -NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - return initScan(NS(encodings), (const INIT_ENCODING *)enc, - XML_PROLOG_STATE, ptr, end, nextTokPtr); -} - -static int PTRCALL -NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - return initScan(NS(encodings), (const INIT_ENCODING *)enc, - XML_CONTENT_STATE, ptr, end, nextTokPtr); -} - -int -NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, - const char *name) -{ - int i = getEncodingIndex(name); - if (i == UNKNOWN_ENC) - return 0; - SET_INIT_ENC_INDEX(p, i); - p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog); - p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent); - p->initEnc.updatePosition = initUpdatePosition; - p->encPtr = encPtr; - *encPtr = &(p->initEnc); - return 1; -} - -static const ENCODING * -NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) -{ -#define ENCODING_MAX 128 - char buf[ENCODING_MAX]; - char *p = buf; - int i; - XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1); - if (ptr != end) - return 0; - *p = 0; - if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2) - return enc; - i = getEncodingIndex(buf); - if (i == UNKNOWN_ENC) - return 0; - return NS(encodings)[i]; -} - -int -NS(XmlParseXmlDecl)(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingName, - const ENCODING **encoding, - int *standalone) -{ - return doParseXmlDecl(NS(findEncoding), - isGeneralTextEntity, - enc, - ptr, - end, - badPtr, - versionPtr, - versionEndPtr, - encodingName, - encoding, - standalone); -} - -#endif /* XML_TOK_NS_C */ diff -Nru gpick-0.2.4/extern/lua/COPYRIGHT gpick-0.2.5/extern/lua/COPYRIGHT --- gpick-0.2.4/extern/lua/COPYRIGHT 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/COPYRIGHT 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -Lua License ------------ - -Lua is licensed under the terms of the MIT license reproduced below. -This means that Lua is free software and can be used for both academic -and commercial purposes at absolutely no cost. - -For details and rationale, see http://www.lua.org/license.html . - -=============================================================================== - -Copyright (C) 1994-2008 Lua.org, PUC-Rio. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -=============================================================================== - -(end of COPYRIGHT) diff -Nru gpick-0.2.4/extern/lua/HISTORY gpick-0.2.5/extern/lua/HISTORY --- gpick-0.2.4/extern/lua/HISTORY 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/HISTORY 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ -HISTORY for Lua 5.1 - -* Changes from version 5.0 to 5.1 - ------------------------------- - Language: - + new module system. - + new semantics for control variables of fors. - + new semantics for setn/getn. - + new syntax/semantics for varargs. - + new long strings and comments. - + new `mod' operator (`%') - + new length operator #t - + metatables for all types - API: - + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer. - + user supplies memory allocator (lua_open becomes lua_newstate). - + luaopen_* functions must be called through Lua. - Implementation: - + new configuration scheme via luaconf.h. - + incremental garbage collection. - + better handling of end-of-line in the lexer. - + fully reentrant parser (new Lua function `load') - + better support for 64-bit machines. - + native loadlib support for Mac OS X. - + standard distribution in only one library (lualib.a merged into lua.a) - -* Changes from version 4.0 to 5.0 - ------------------------------- - Language: - + lexical scoping. - + Lua coroutines. - + standard libraries now packaged in tables. - + tags replaced by metatables and tag methods replaced by metamethods, - stored in metatables. - + proper tail calls. - + each function can have its own global table, which can be shared. - + new __newindex metamethod, called when we insert a new key into a table. - + new block comments: --[[ ... ]]. - + new generic for. - + new weak tables. - + new boolean type. - + new syntax "local function". - + (f()) returns the first value returned by f. - + {f()} fills a table with all values returned by f. - + \n ignored in [[\n . - + fixed and-or priorities. - + more general syntax for function definition (e.g. function a.x.y:f()...end). - + more general syntax for function calls (e.g. (print or write)(9)). - + new functions (time/date, tmpfile, unpack, require, load*, etc.). - API: - + chunks are loaded by using lua_load; new luaL_loadfile and luaL_loadbuffer. - + introduced lightweight userdata, a simple "void*" without a metatable. - + new error handling protocol: the core no longer prints error messages; - all errors are reported to the caller on the stack. - + new lua_atpanic for host cleanup. - + new, signal-safe, hook scheme. - Implementation: - + new license: MIT. - + new, faster, register-based virtual machine. - + support for external multithreading and coroutines. - + new and consistent error message format. - + the core no longer needs "stdio.h" for anything (except for a single - use of sprintf to convert numbers to strings). - + lua.c now runs the environment variable LUA_INIT, if present. It can - be "@filename", to run a file, or the chunk itself. - + support for user extensions in lua.c. - sample implementation given for command line editing. - + new dynamic loading library, active by default on several platforms. - + safe garbage-collector metamethods. - + precompiled bytecodes checked for integrity (secure binary dostring). - + strings are fully aligned. - + position capture in string.find. - + read('*l') can read lines with embedded zeros. - -* Changes from version 3.2 to 4.0 - ------------------------------- - Language: - + new "break" and "for" statements (both numerical and for tables). - + uniform treatment of globals: globals are now stored in a Lua table. - + improved error messages. - + no more '$debug': full speed *and* full debug information. - + new read form: read(N) for next N bytes. - + general read patterns now deprecated. - (still available with -DCOMPAT_READPATTERNS.) - + all return values are passed as arguments for the last function - (old semantics still available with -DLUA_COMPAT_ARGRET) - + garbage collection tag methods for tables now deprecated. - + there is now only one tag method for order. - API: - + New API: fully re-entrant, simpler, and more efficient. - + New debug API. - Implementation: - + faster than ever: cleaner virtual machine and new hashing algorithm. - + non-recursive garbage-collector algorithm. - + reduced memory usage for programs with many strings. - + improved treatment for memory allocation errors. - + improved support for 16-bit machines (we hope). - + code now compiles unmodified as both ANSI C and C++. - + numbers in bases other than 10 are converted using strtoul. - + new -f option in Lua to support #! scripts. - + luac can now combine text and binaries. - -* Changes from version 3.1 to 3.2 - ------------------------------- - + redirected all output in Lua's core to _ERRORMESSAGE and _ALERT. - + increased limit on the number of constants and globals per function - (from 2^16 to 2^24). - + debugging info (lua_debug and hooks) moved into lua_state and new API - functions provided to get and set this info. - + new debug lib gives full debugging access within Lua. - + new table functions "foreachi", "sort", "tinsert", "tremove", "getn". - + new io functions "flush", "seek". - -* Changes from version 3.0 to 3.1 - ------------------------------- - + NEW FEATURE: anonymous functions with closures (via "upvalues"). - + new syntax: - - local variables in chunks. - - better scope control with DO block END. - - constructors can now be also written: { record-part; list-part }. - - more general syntax for function calls and lvalues, e.g.: - f(x).y=1 - o:f(x,y):g(z) - f"string" is sugar for f("string") - + strings may now contain arbitrary binary data (e.g., embedded zeros). - + major code re-organization and clean-up; reduced module interdependecies. - + no arbitrary limits on the total number of constants and globals. - + support for multiple global contexts. - + better syntax error messages. - + new traversal functions "foreach" and "foreachvar". - + the default for numbers is now double. - changing it to use floats or longs is easy. - + complete debug information stored in pre-compiled chunks. - + sample interpreter now prompts user when run interactively, and also - handles control-C interruptions gracefully. - -* Changes from version 2.5 to 3.0 - ------------------------------- - + NEW CONCEPT: "tag methods". - Tag methods replace fallbacks as the meta-mechanism for extending the - semantics of Lua. Whereas fallbacks had a global nature, tag methods - work on objects having the same tag (e.g., groups of tables). - Existing code that uses fallbacks should work without change. - + new, general syntax for constructors {[exp] = exp, ... }. - + support for handling variable number of arguments in functions (varargs). - + support for conditional compilation ($if ... $else ... $end). - + cleaner semantics in API simplifies host code. - + better support for writing libraries (auxlib.h). - + better type checking and error messages in the standard library. - + luac can now also undump. - -* Changes from version 2.4 to 2.5 - ------------------------------- - + io and string libraries are now based on pattern matching; - the old libraries are still available for compatibility - + dofile and dostring can now return values (via return statement) - + better support for 16- and 64-bit machines - + expanded documentation, with more examples - -* Changes from version 2.2 to 2.4 - ------------------------------- - + external compiler creates portable binary files that can be loaded faster - + interface for debugging and profiling - + new "getglobal" fallback - + new functions for handling references to Lua objects - + new functions in standard lib - + only one copy of each string is stored - + expanded documentation, with more examples - -* Changes from version 2.1 to 2.2 - ------------------------------- - + functions now may be declared with any "lvalue" as a name - + garbage collection of functions - + support for pipes - -* Changes from version 1.1 to 2.1 - ------------------------------- - + object-oriented support - + fallbacks - + simplified syntax for tables - + many internal improvements - -(end of HISTORY) diff -Nru gpick-0.2.4/extern/lua/INSTALL gpick-0.2.5/extern/lua/INSTALL --- gpick-0.2.4/extern/lua/INSTALL 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/INSTALL 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -INSTALL for Lua 5.1 - -* Building Lua - ------------ - Lua is built in the src directory, but the build process can be - controlled from the top-level Makefile. - - Building Lua on Unix systems should be very easy. First do "make" and - see if your platform is listed. If so, just do "make xxx", where xxx - is your platform name. The platforms currently supported are: - aix ansi bsd freebsd generic linux macosx mingw posix solaris - - If your platform is not listed, try the closest one or posix, generic, - ansi, in this order. - - See below for customization instructions and for instructions on how - to build with other Windows compilers. - - If you want to check that Lua has been built correctly, do "make test" - after building Lua. Also, have a look at the example programs in test. - -* Installing Lua - -------------- - Once you have built Lua, you may want to install it in an official - place in your system. In this case, do "make install". The official - place and the way to install files are defined in Makefile. You must - have the right permissions to install files. - - If you want to build and install Lua in one step, do "make xxx install", - where xxx is your platform name. - - If you want to install Lua locally, then do "make local". This will - create directories bin, include, lib, man, and install Lua there as - follows: - - bin: lua luac - include: lua.h luaconf.h lualib.h lauxlib.h lua.hpp - lib: liblua.a - man/man1: lua.1 luac.1 - - These are the only directories you need for development. - - There are man pages for lua and luac, in both nroff and html, and a - reference manual in html in doc, some sample code in test, and some - useful stuff in etc. You don't need these directories for development. - - If you want to install Lua locally, but in some other directory, do - "make install INSTALL_TOP=xxx", where xxx is your chosen directory. - - See below for instructions for Windows and other systems. - -* Customization - ------------- - Three things can be customized by editing a file: - - Where and how to install Lua -- edit Makefile. - - How to build Lua -- edit src/Makefile. - - Lua features -- edit src/luaconf.h. - - You don't actually need to edit the Makefiles because you may set the - relevant variables when invoking make. - - On the other hand, if you need to select some Lua features, you'll need - to edit src/luaconf.h. The edited file will be the one installed, and - it will be used by any Lua clients that you build, to ensure consistency. - - We strongly recommend that you enable dynamic loading. This is done - automatically for all platforms listed above that have this feature - (and also Windows). See src/luaconf.h and also src/Makefile. - -* Building Lua on Windows and other systems - ----------------------------------------- - If you're not using the usual Unix tools, then the instructions for - building Lua depend on the compiler you use. You'll need to create - projects (or whatever your compiler uses) for building the library, - the interpreter, and the compiler, as follows: - - library: lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c - lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c - ltable.c ltm.c lundump.c lvm.c lzio.c - lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c - ltablib.c lstrlib.c loadlib.c linit.c - - interpreter: library, lua.c - - compiler: library, luac.c print.c - - If you use Visual Studio .NET, you can use etc/luavs.bat in its - "Command Prompt". - - If all you want is to build the Lua interpreter, you may put all .c files - in a single project, except for luac.c and print.c. Or just use etc/all.c. - - To use Lua as a library in your own programs, you'll need to know how to - create and use libraries with your compiler. - - As mentioned above, you may edit luaconf.h to select some features before - building Lua. - -(end of INSTALL) diff -Nru gpick-0.2.4/extern/lua/Makefile gpick-0.2.5/extern/lua/Makefile --- gpick-0.2.4/extern/lua/Makefile 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -# makefile for installing Lua -# see INSTALL for installation instructions -# see src/Makefile and src/luaconf.h for further customization - -# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= - -# Your platform. See PLATS for possible values. -PLAT= none - -# Where to install. The installation starts in the src and doc directories, -# so take care if INSTALL_TOP is not an absolute path. -INSTALL_TOP= /usr/local -INSTALL_BIN= $(INSTALL_TOP)/bin -INSTALL_INC= $(INSTALL_TOP)/include -INSTALL_LIB= $(INSTALL_TOP)/lib -INSTALL_MAN= $(INSTALL_TOP)/man/man1 -# -# You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with -# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc). -INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V -INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V - -# How to install. If your install program does not support "-p", then you -# may have to run ranlib on the installed liblua.a (do "make ranlib"). -INSTALL= install -p -INSTALL_EXEC= $(INSTALL) -m 0755 -INSTALL_DATA= $(INSTALL) -m 0644 -# -# If you don't have install you can use cp instead. -# INSTALL= cp -p -# INSTALL_EXEC= $(INSTALL) -# INSTALL_DATA= $(INSTALL) - -# Utilities. -MKDIR= mkdir -p -RANLIB= ranlib - -# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= - -# Convenience platforms targets. -PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris - -# What to install. -TO_BIN= lua luac -TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp -TO_LIB= liblua.a -TO_MAN= lua.1 luac.1 - -# Lua version and release. -V= 5.1 -R= 5.1.4 - -all: $(PLAT) - -$(PLATS) clean: - cd src && $(MAKE) $@ - -test: dummy - src/lua test/hello.lua - -install: dummy - cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) - cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) - cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) - cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) - cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) - -ranlib: - cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB) - -local: - $(MAKE) install INSTALL_TOP=.. - -none: - @echo "Please do" - @echo " make PLATFORM" - @echo "where PLATFORM is one of these:" - @echo " $(PLATS)" - @echo "See INSTALL for complete instructions." - -# make may get confused with test/ and INSTALL in a case-insensitive OS -dummy: - -# echo config parameters -echo: - @echo "" - @echo "These are the parameters currently set in src/Makefile to build Lua $R:" - @echo "" - @cd src && $(MAKE) -s echo - @echo "" - @echo "These are the parameters currently set in Makefile to install Lua $R:" - @echo "" - @echo "PLAT = $(PLAT)" - @echo "INSTALL_TOP = $(INSTALL_TOP)" - @echo "INSTALL_BIN = $(INSTALL_BIN)" - @echo "INSTALL_INC = $(INSTALL_INC)" - @echo "INSTALL_LIB = $(INSTALL_LIB)" - @echo "INSTALL_MAN = $(INSTALL_MAN)" - @echo "INSTALL_LMOD = $(INSTALL_LMOD)" - @echo "INSTALL_CMOD = $(INSTALL_CMOD)" - @echo "INSTALL_EXEC = $(INSTALL_EXEC)" - @echo "INSTALL_DATA = $(INSTALL_DATA)" - @echo "" - @echo "See also src/luaconf.h ." - @echo "" - -# echo private config parameters -pecho: - @echo "V = $(V)" - @echo "R = $(R)" - @echo "TO_BIN = $(TO_BIN)" - @echo "TO_INC = $(TO_INC)" - @echo "TO_LIB = $(TO_LIB)" - @echo "TO_MAN = $(TO_MAN)" - -# echo config parameters as Lua code -# uncomment the last sed expression if you want nil instead of empty strings -lecho: - @echo "-- installation parameters for Lua $R" - @echo "VERSION = '$V'" - @echo "RELEASE = '$R'" - @$(MAKE) echo | grep = | sed -e 's/= /= "/' -e 's/$$/"/' #-e 's/""/nil/' - @echo "-- EOF" - -# list targets that do not create files (but not all makes understand .PHONY) -.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho - -# (end of Makefile) diff -Nru gpick-0.2.4/extern/lua/README gpick-0.2.5/extern/lua/README --- gpick-0.2.4/extern/lua/README 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -README for Lua 5.1 - -See INSTALL for installation instructions. -See HISTORY for a summary of changes since the last released version. - -* What is Lua? - ------------ - Lua is a powerful, light-weight programming language designed for extending - applications. Lua is also frequently used as a general-purpose, stand-alone - language. Lua is free software. - - For complete information, visit Lua's web site at http://www.lua.org/ . - For an executive summary, see http://www.lua.org/about.html . - - Lua has been used in many different projects around the world. - For a short list, see http://www.lua.org/uses.html . - -* Availability - ------------ - Lua is freely available for both academic and commercial purposes. - See COPYRIGHT and http://www.lua.org/license.html for details. - Lua can be downloaded at http://www.lua.org/download.html . - -* Installation - ------------ - Lua is implemented in pure ANSI C, and compiles unmodified in all known - platforms that have an ANSI C compiler. In most Unix-like platforms, simply - do "make" with a suitable target. See INSTALL for detailed instructions. - -* Origin - ------ - Lua is developed at Lua.org, a laboratory of the Department of Computer - Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro - in Brazil). - For more information about the authors, see http://www.lua.org/authors.html . - -(end of README) diff -Nru gpick-0.2.4/extern/lua/SConscript gpick-0.2.5/extern/lua/SConscript --- gpick-0.2.4/extern/lua/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/SConscript 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#!/usr/bin/env python - -from tools.gpick import * - -Import('*') -local_env = env.Clone() - -local_env.Append ( - CPPPATH = ['.'] - ) - -sources = ['src/lapi.c', 'src/lauxlib.c', 'src/lcode.c', 'src/lgc.c', 'src/llex.c', 'src/lmathlib.c', 'src/lobject.c', 'src/lopcodes.c', 'src/loslib.c', 'src/lparser.c', 'src/lstate.c', 'src/lstring.c', 'src/lstrlib.c', 'src/ltable.c', 'src/ltablib.c', 'src/ltm.c', 'src/lvm.c', 'src/lzio.c', 'src/lbaselib.c', 'src/ldblib.c', 'src/lfunc.c', 'src/lmem.c', 'src/ldebug.c', 'src/lua.c', 'src/ldo.c', 'src/ldump.c', 'src/lundump.c', 'src/linit.c', 'src/liolib.c', 'src/loadlib.c'] - -executable = local_env.StaticLibrary( - 'lua', - source = [sources]) - -library = GpickLibrary(executable); -library.include_dirs = ['#extern/lua/src'] -env.DefineLibrary('lua', library) - -Return('executable') diff -Nru gpick-0.2.4/extern/lua/src/Makefile gpick-0.2.5/extern/lua/src/Makefile --- gpick-0.2.4/extern/lua/src/Makefile 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ -# makefile for building Lua -# see ../INSTALL for installation instructions -# see ../Makefile and luaconf.h for further customization - -# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= - -# Your platform. See PLATS for possible values. -PLAT= none - -CC= gcc -CFLAGS= -O2 -Wall $(MYCFLAGS) -AR= ar rcu -RANLIB= ranlib -RM= rm -f -LIBS= -lm $(MYLIBS) - -MYCFLAGS= -MYLDFLAGS= -MYLIBS= - -# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= - -PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris - -LUA_A= liblua.a -CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ - lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ - lundump.o lvm.o lzio.o -LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ - lstrlib.o loadlib.o linit.o - -LUA_T= lua -LUA_O= lua.o - -LUAC_T= luac -LUAC_O= luac.o print.o - -ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) -ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) -ALL_A= $(LUA_A) - -default: $(PLAT) - -all: $(ALL_T) - -o: $(ALL_O) - -a: $(ALL_A) - -$(LUA_A): $(CORE_O) $(LIB_O) - $(AR) $@ $? - $(RANLIB) $@ - -$(LUA_T): $(LUA_O) $(LUA_A) - $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) - -$(LUAC_T): $(LUAC_O) $(LUA_A) - $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) - -clean: - $(RM) $(ALL_T) $(ALL_O) - -depend: - @$(CC) $(CFLAGS) -MM l*.c print.c - -echo: - @echo "PLAT = $(PLAT)" - @echo "CC = $(CC)" - @echo "CFLAGS = $(CFLAGS)" - @echo "AR = $(AR)" - @echo "RANLIB = $(RANLIB)" - @echo "RM = $(RM)" - @echo "MYCFLAGS = $(MYCFLAGS)" - @echo "MYLDFLAGS = $(MYLDFLAGS)" - @echo "MYLIBS = $(MYLIBS)" - -# convenience targets for popular platforms - -none: - @echo "Please choose a platform:" - @echo " $(PLATS)" - -aix: - $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" - -ansi: - $(MAKE) all MYCFLAGS=-DLUA_ANSI - -bsd: - $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" - -freebsd: - $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" - -generic: - $(MAKE) all MYCFLAGS= - -linux: - $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" - -macosx: - $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" -# use this on Mac OS X 10.3- -# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX - -mingw: - $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ - "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ - "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe - $(MAKE) "LUAC_T=luac.exe" luac.exe - -posix: - $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX - -solaris: - $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" - -# list targets that do not create files (but not all makes understand .PHONY) -.PHONY: all $(PLATS) default o a clean depend echo none - -# DO NOT DELETE - -lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ - lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \ - lundump.h lvm.h -lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h -lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h -lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ - lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ - ltable.h -ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h -ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ - llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ - lfunc.h lstring.h lgc.h ltable.h lvm.h -ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ - lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \ - ltable.h lundump.h lvm.h -ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ - lzio.h lmem.h lundump.h -lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \ - lstate.h ltm.h lzio.h -lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ - lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h -linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h -liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h -llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ - lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h -lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h -lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h ldo.h -loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h -lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ - ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h -lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h -loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h -lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ - lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ - lfunc.h lstring.h lgc.h ltable.h -lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h -lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \ - ltm.h lzio.h lstring.h lgc.h -lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h -ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h -ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h -ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ - lmem.h lstring.h lgc.h ltable.h -lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h -luac.o: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \ - lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \ - lundump.h -lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ - llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h -lvm.o: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ - lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h -lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \ - lzio.h -print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h lopcodes.h lundump.h - -# (end of Makefile) diff -Nru gpick-0.2.4/extern/lua/src/lapi.c gpick-0.2.5/extern/lua/src/lapi.c --- gpick-0.2.4/extern/lua/src/lapi.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lapi.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1087 +0,0 @@ -/* -** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ -** Lua API -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include -#include - -#define lapi_c -#define LUA_CORE - -#include "lua.h" - -#include "lapi.h" -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lundump.h" -#include "lvm.h" - - - -const char lua_ident[] = - "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" - "$Authors: " LUA_AUTHORS " $\n" - "$URL: www.lua.org $\n"; - - - -#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) - -#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) - -#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} - - - -static TValue *index2adr (lua_State *L, int idx) { - if (idx > 0) { - TValue *o = L->base + (idx - 1); - api_check(L, idx <= L->ci->top - L->base); - if (o >= L->top) return cast(TValue *, luaO_nilobject); - else return o; - } - else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx != 0 && -idx <= L->top - L->base); - return L->top + idx; - } - else switch (idx) { /* pseudo-indices */ - case LUA_REGISTRYINDEX: return registry(L); - case LUA_ENVIRONINDEX: { - Closure *func = curr_func(L); - sethvalue(L, &L->env, func->c.env); - return &L->env; - } - case LUA_GLOBALSINDEX: return gt(L); - default: { - Closure *func = curr_func(L); - idx = LUA_GLOBALSINDEX - idx; - return (idx <= func->c.nupvalues) - ? &func->c.upvalue[idx-1] - : cast(TValue *, luaO_nilobject); - } - } -} - - -static Table *getcurrenv (lua_State *L) { - if (L->ci == L->base_ci) /* no enclosing function? */ - return hvalue(gt(L)); /* use global table as environment */ - else { - Closure *func = curr_func(L); - return func->c.env; - } -} - - -void luaA_pushobject (lua_State *L, const TValue *o) { - setobj2s(L, L->top, o); - api_incr_top(L); -} - - -LUA_API int lua_checkstack (lua_State *L, int size) { - int res = 1; - lua_lock(L); - if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) - res = 0; /* stack overflow */ - else if (size > 0) { - luaD_checkstack(L, size); - if (L->ci->top < L->top + size) - L->ci->top = L->top + size; - } - lua_unlock(L); - return res; -} - - -LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { - int i; - if (from == to) return; - lua_lock(to); - api_checknelems(from, n); - api_check(from, G(from) == G(to)); - api_check(from, to->ci->top - to->top >= n); - from->top -= n; - for (i = 0; i < n; i++) { - setobj2s(to, to->top++, from->top + i); - } - lua_unlock(to); -} - - -LUA_API void lua_setlevel (lua_State *from, lua_State *to) { - to->nCcalls = from->nCcalls; -} - - -LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { - lua_CFunction old; - lua_lock(L); - old = G(L)->panic; - G(L)->panic = panicf; - lua_unlock(L); - return old; -} - - -LUA_API lua_State *lua_newthread (lua_State *L) { - lua_State *L1; - lua_lock(L); - luaC_checkGC(L); - L1 = luaE_newthread(L); - setthvalue(L, L->top, L1); - api_incr_top(L); - lua_unlock(L); - luai_userstatethread(L, L1); - return L1; -} - - - -/* -** basic stack manipulation -*/ - - -LUA_API int lua_gettop (lua_State *L) { - return cast_int(L->top - L->base); -} - - -LUA_API void lua_settop (lua_State *L, int idx) { - lua_lock(L); - if (idx >= 0) { - api_check(L, idx <= L->stack_last - L->base); - while (L->top < L->base + idx) - setnilvalue(L->top++); - L->top = L->base + idx; - } - else { - api_check(L, -(idx+1) <= (L->top - L->base)); - L->top += idx+1; /* `subtract' index (index is negative) */ - } - lua_unlock(L); -} - - -LUA_API void lua_remove (lua_State *L, int idx) { - StkId p; - lua_lock(L); - p = index2adr(L, idx); - api_checkvalidindex(L, p); - while (++p < L->top) setobjs2s(L, p-1, p); - L->top--; - lua_unlock(L); -} - - -LUA_API void lua_insert (lua_State *L, int idx) { - StkId p; - StkId q; - lua_lock(L); - p = index2adr(L, idx); - api_checkvalidindex(L, p); - for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); - setobjs2s(L, p, L->top); - lua_unlock(L); -} - - -LUA_API void lua_replace (lua_State *L, int idx) { - StkId o; - lua_lock(L); - /* explicit test for incompatible code */ - if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) - luaG_runerror(L, "no calling environment"); - api_checknelems(L, 1); - o = index2adr(L, idx); - api_checkvalidindex(L, o); - if (idx == LUA_ENVIRONINDEX) { - Closure *func = curr_func(L); - api_check(L, ttistable(L->top - 1)); - func->c.env = hvalue(L->top - 1); - luaC_barrier(L, func, L->top - 1); - } - else { - setobj(L, o, L->top - 1); - if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ - luaC_barrier(L, curr_func(L), L->top - 1); - } - L->top--; - lua_unlock(L); -} - - -LUA_API void lua_pushvalue (lua_State *L, int idx) { - lua_lock(L); - setobj2s(L, L->top, index2adr(L, idx)); - api_incr_top(L); - lua_unlock(L); -} - - - -/* -** access functions (stack -> C) -*/ - - -LUA_API int lua_type (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); -} - - -LUA_API const char *lua_typename (lua_State *L, int t) { - UNUSED(L); - return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; -} - - -LUA_API int lua_iscfunction (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - return iscfunction(o); -} - - -LUA_API int lua_isnumber (lua_State *L, int idx) { - TValue n; - const TValue *o = index2adr(L, idx); - return tonumber(o, &n); -} - - -LUA_API int lua_isstring (lua_State *L, int idx) { - int t = lua_type(L, idx); - return (t == LUA_TSTRING || t == LUA_TNUMBER); -} - - -LUA_API int lua_isuserdata (lua_State *L, int idx) { - const TValue *o = index2adr(L, idx); - return (ttisuserdata(o) || ttislightuserdata(o)); -} - - -LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { - StkId o1 = index2adr(L, index1); - StkId o2 = index2adr(L, index2); - return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 - : luaO_rawequalObj(o1, o2); -} - - -LUA_API int lua_equal (lua_State *L, int index1, int index2) { - StkId o1, o2; - int i; - lua_lock(L); /* may call tag method */ - o1 = index2adr(L, index1); - o2 = index2adr(L, index2); - i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); - lua_unlock(L); - return i; -} - - -LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { - StkId o1, o2; - int i; - lua_lock(L); /* may call tag method */ - o1 = index2adr(L, index1); - o2 = index2adr(L, index2); - i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 - : luaV_lessthan(L, o1, o2); - lua_unlock(L); - return i; -} - - - -LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { - TValue n; - const TValue *o = index2adr(L, idx); - if (tonumber(o, &n)) - return nvalue(o); - else - return 0; -} - - -LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { - TValue n; - const TValue *o = index2adr(L, idx); - if (tonumber(o, &n)) { - lua_Integer res; - lua_Number num = nvalue(o); - lua_number2integer(res, num); - return res; - } - else - return 0; -} - - -LUA_API int lua_toboolean (lua_State *L, int idx) { - const TValue *o = index2adr(L, idx); - return !l_isfalse(o); -} - - -LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { - StkId o = index2adr(L, idx); - if (!ttisstring(o)) { - lua_lock(L); /* `luaV_tostring' may create a new string */ - if (!luaV_tostring(L, o)) { /* conversion failed? */ - if (len != NULL) *len = 0; - lua_unlock(L); - return NULL; - } - luaC_checkGC(L); - o = index2adr(L, idx); /* previous call may reallocate the stack */ - lua_unlock(L); - } - if (len != NULL) *len = tsvalue(o)->len; - return svalue(o); -} - - -LUA_API size_t lua_objlen (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - switch (ttype(o)) { - case LUA_TSTRING: return tsvalue(o)->len; - case LUA_TUSERDATA: return uvalue(o)->len; - case LUA_TTABLE: return luaH_getn(hvalue(o)); - case LUA_TNUMBER: { - size_t l; - lua_lock(L); /* `luaV_tostring' may create a new string */ - l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); - lua_unlock(L); - return l; - } - default: return 0; - } -} - - -LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; -} - - -LUA_API void *lua_touserdata (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - switch (ttype(o)) { - case LUA_TUSERDATA: return (rawuvalue(o) + 1); - case LUA_TLIGHTUSERDATA: return pvalue(o); - default: return NULL; - } -} - - -LUA_API lua_State *lua_tothread (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - return (!ttisthread(o)) ? NULL : thvalue(o); -} - - -LUA_API const void *lua_topointer (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - switch (ttype(o)) { - case LUA_TTABLE: return hvalue(o); - case LUA_TFUNCTION: return clvalue(o); - case LUA_TTHREAD: return thvalue(o); - case LUA_TUSERDATA: - case LUA_TLIGHTUSERDATA: - return lua_touserdata(L, idx); - default: return NULL; - } -} - - - -/* -** push functions (C -> stack) -*/ - - -LUA_API void lua_pushnil (lua_State *L) { - lua_lock(L); - setnilvalue(L->top); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { - lua_lock(L); - setnvalue(L->top, n); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { - lua_lock(L); - setnvalue(L->top, cast_num(n)); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { - lua_lock(L); - luaC_checkGC(L); - setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushstring (lua_State *L, const char *s) { - if (s == NULL) - lua_pushnil(L); - else - lua_pushlstring(L, s, strlen(s)); -} - - -LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, - va_list argp) { - const char *ret; - lua_lock(L); - luaC_checkGC(L); - ret = luaO_pushvfstring(L, fmt, argp); - lua_unlock(L); - return ret; -} - - -LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { - const char *ret; - va_list argp; - lua_lock(L); - luaC_checkGC(L); - va_start(argp, fmt); - ret = luaO_pushvfstring(L, fmt, argp); - va_end(argp); - lua_unlock(L); - return ret; -} - - -LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { - Closure *cl; - lua_lock(L); - luaC_checkGC(L); - api_checknelems(L, n); - cl = luaF_newCclosure(L, n, getcurrenv(L)); - cl->c.f = fn; - L->top -= n; - while (n--) - setobj2n(L, &cl->c.upvalue[n], L->top+n); - setclvalue(L, L->top, cl); - lua_assert(iswhite(obj2gco(cl))); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushboolean (lua_State *L, int b) { - lua_lock(L); - setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { - lua_lock(L); - setpvalue(L->top, p); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API int lua_pushthread (lua_State *L) { - lua_lock(L); - setthvalue(L, L->top, L); - api_incr_top(L); - lua_unlock(L); - return (G(L)->mainthread == L); -} - - - -/* -** get functions (Lua -> stack) -*/ - - -LUA_API void lua_gettable (lua_State *L, int idx) { - StkId t; - lua_lock(L); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - luaV_gettable(L, t, L->top - 1, L->top - 1); - lua_unlock(L); -} - - -LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { - StkId t; - TValue key; - lua_lock(L); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - setsvalue(L, &key, luaS_new(L, k)); - luaV_gettable(L, t, &key, L->top); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_rawget (lua_State *L, int idx) { - StkId t; - lua_lock(L); - t = index2adr(L, idx); - api_check(L, ttistable(t)); - setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); - lua_unlock(L); -} - - -LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { - StkId o; - lua_lock(L); - o = index2adr(L, idx); - api_check(L, ttistable(o)); - setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { - lua_lock(L); - luaC_checkGC(L); - sethvalue(L, L->top, luaH_new(L, narray, nrec)); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API int lua_getmetatable (lua_State *L, int objindex) { - const TValue *obj; - Table *mt = NULL; - int res; - lua_lock(L); - obj = index2adr(L, objindex); - switch (ttype(obj)) { - case LUA_TTABLE: - mt = hvalue(obj)->metatable; - break; - case LUA_TUSERDATA: - mt = uvalue(obj)->metatable; - break; - default: - mt = G(L)->mt[ttype(obj)]; - break; - } - if (mt == NULL) - res = 0; - else { - sethvalue(L, L->top, mt); - api_incr_top(L); - res = 1; - } - lua_unlock(L); - return res; -} - - -LUA_API void lua_getfenv (lua_State *L, int idx) { - StkId o; - lua_lock(L); - o = index2adr(L, idx); - api_checkvalidindex(L, o); - switch (ttype(o)) { - case LUA_TFUNCTION: - sethvalue(L, L->top, clvalue(o)->c.env); - break; - case LUA_TUSERDATA: - sethvalue(L, L->top, uvalue(o)->env); - break; - case LUA_TTHREAD: - setobj2s(L, L->top, gt(thvalue(o))); - break; - default: - setnilvalue(L->top); - break; - } - api_incr_top(L); - lua_unlock(L); -} - - -/* -** set functions (stack -> Lua) -*/ - - -LUA_API void lua_settable (lua_State *L, int idx) { - StkId t; - lua_lock(L); - api_checknelems(L, 2); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - luaV_settable(L, t, L->top - 2, L->top - 1); - L->top -= 2; /* pop index and value */ - lua_unlock(L); -} - - -LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { - StkId t; - TValue key; - lua_lock(L); - api_checknelems(L, 1); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - setsvalue(L, &key, luaS_new(L, k)); - luaV_settable(L, t, &key, L->top - 1); - L->top--; /* pop value */ - lua_unlock(L); -} - - -LUA_API void lua_rawset (lua_State *L, int idx) { - StkId t; - lua_lock(L); - api_checknelems(L, 2); - t = index2adr(L, idx); - api_check(L, ttistable(t)); - setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); - luaC_barriert(L, hvalue(t), L->top-1); - L->top -= 2; - lua_unlock(L); -} - - -LUA_API void lua_rawseti (lua_State *L, int idx, int n) { - StkId o; - lua_lock(L); - api_checknelems(L, 1); - o = index2adr(L, idx); - api_check(L, ttistable(o)); - setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); - luaC_barriert(L, hvalue(o), L->top-1); - L->top--; - lua_unlock(L); -} - - -LUA_API int lua_setmetatable (lua_State *L, int objindex) { - TValue *obj; - Table *mt; - lua_lock(L); - api_checknelems(L, 1); - obj = index2adr(L, objindex); - api_checkvalidindex(L, obj); - if (ttisnil(L->top - 1)) - mt = NULL; - else { - api_check(L, ttistable(L->top - 1)); - mt = hvalue(L->top - 1); - } - switch (ttype(obj)) { - case LUA_TTABLE: { - hvalue(obj)->metatable = mt; - if (mt) - luaC_objbarriert(L, hvalue(obj), mt); - break; - } - case LUA_TUSERDATA: { - uvalue(obj)->metatable = mt; - if (mt) - luaC_objbarrier(L, rawuvalue(obj), mt); - break; - } - default: { - G(L)->mt[ttype(obj)] = mt; - break; - } - } - L->top--; - lua_unlock(L); - return 1; -} - - -LUA_API int lua_setfenv (lua_State *L, int idx) { - StkId o; - int res = 1; - lua_lock(L); - api_checknelems(L, 1); - o = index2adr(L, idx); - api_checkvalidindex(L, o); - api_check(L, ttistable(L->top - 1)); - switch (ttype(o)) { - case LUA_TFUNCTION: - clvalue(o)->c.env = hvalue(L->top - 1); - break; - case LUA_TUSERDATA: - uvalue(o)->env = hvalue(L->top - 1); - break; - case LUA_TTHREAD: - sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); - break; - default: - res = 0; - break; - } - if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); - L->top--; - lua_unlock(L); - return res; -} - - -/* -** `load' and `call' functions (run Lua code) -*/ - - -#define adjustresults(L,nres) \ - { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } - - -#define checkresults(L,na,nr) \ - api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) - - -LUA_API void lua_call (lua_State *L, int nargs, int nresults) { - StkId func; - lua_lock(L); - api_checknelems(L, nargs+1); - checkresults(L, nargs, nresults); - func = L->top - (nargs+1); - luaD_call(L, func, nresults); - adjustresults(L, nresults); - lua_unlock(L); -} - - - -/* -** Execute a protected call. -*/ -struct CallS { /* data to `f_call' */ - StkId func; - int nresults; -}; - - -static void f_call (lua_State *L, void *ud) { - struct CallS *c = cast(struct CallS *, ud); - luaD_call(L, c->func, c->nresults); -} - - - -LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { - struct CallS c; - int status; - ptrdiff_t func; - lua_lock(L); - api_checknelems(L, nargs+1); - checkresults(L, nargs, nresults); - if (errfunc == 0) - func = 0; - else { - StkId o = index2adr(L, errfunc); - api_checkvalidindex(L, o); - func = savestack(L, o); - } - c.func = L->top - (nargs+1); /* function to be called */ - c.nresults = nresults; - status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); - adjustresults(L, nresults); - lua_unlock(L); - return status; -} - - -/* -** Execute a protected C call. -*/ -struct CCallS { /* data to `f_Ccall' */ - lua_CFunction func; - void *ud; -}; - - -static void f_Ccall (lua_State *L, void *ud) { - struct CCallS *c = cast(struct CCallS *, ud); - Closure *cl; - cl = luaF_newCclosure(L, 0, getcurrenv(L)); - cl->c.f = c->func; - setclvalue(L, L->top, cl); /* push function */ - api_incr_top(L); - setpvalue(L->top, c->ud); /* push only argument */ - api_incr_top(L); - luaD_call(L, L->top - 2, 0); -} - - -LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { - struct CCallS c; - int status; - lua_lock(L); - c.func = func; - c.ud = ud; - status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); - lua_unlock(L); - return status; -} - - -LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, - const char *chunkname) { - ZIO z; - int status; - lua_lock(L); - if (!chunkname) chunkname = "?"; - luaZ_init(L, &z, reader, data); - status = luaD_protectedparser(L, &z, chunkname); - lua_unlock(L); - return status; -} - - -LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { - int status; - TValue *o; - lua_lock(L); - api_checknelems(L, 1); - o = L->top - 1; - if (isLfunction(o)) - status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); - else - status = 1; - lua_unlock(L); - return status; -} - - -LUA_API int lua_status (lua_State *L) { - return L->status; -} - - -/* -** Garbage-collection function -*/ - -LUA_API int lua_gc (lua_State *L, int what, int data) { - int res = 0; - global_State *g; - lua_lock(L); - g = G(L); - switch (what) { - case LUA_GCSTOP: { - g->GCthreshold = MAX_LUMEM; - break; - } - case LUA_GCRESTART: { - g->GCthreshold = g->totalbytes; - break; - } - case LUA_GCCOLLECT: { - luaC_fullgc(L); - break; - } - case LUA_GCCOUNT: { - /* GC values are expressed in Kbytes: #bytes/2^10 */ - res = cast_int(g->totalbytes >> 10); - break; - } - case LUA_GCCOUNTB: { - res = cast_int(g->totalbytes & 0x3ff); - break; - } - case LUA_GCSTEP: { - lu_mem a = (cast(lu_mem, data) << 10); - if (a <= g->totalbytes) - g->GCthreshold = g->totalbytes - a; - else - g->GCthreshold = 0; - while (g->GCthreshold <= g->totalbytes) { - luaC_step(L); - if (g->gcstate == GCSpause) { /* end of cycle? */ - res = 1; /* signal it */ - break; - } - } - break; - } - case LUA_GCSETPAUSE: { - res = g->gcpause; - g->gcpause = data; - break; - } - case LUA_GCSETSTEPMUL: { - res = g->gcstepmul; - g->gcstepmul = data; - break; - } - default: res = -1; /* invalid option */ - } - lua_unlock(L); - return res; -} - - - -/* -** miscellaneous functions -*/ - - -LUA_API int lua_error (lua_State *L) { - lua_lock(L); - api_checknelems(L, 1); - luaG_errormsg(L); - lua_unlock(L); - return 0; /* to avoid warnings */ -} - - -LUA_API int lua_next (lua_State *L, int idx) { - StkId t; - int more; - lua_lock(L); - t = index2adr(L, idx); - api_check(L, ttistable(t)); - more = luaH_next(L, hvalue(t), L->top - 1); - if (more) { - api_incr_top(L); - } - else /* no more elements */ - L->top -= 1; /* remove key */ - lua_unlock(L); - return more; -} - - -LUA_API void lua_concat (lua_State *L, int n) { - lua_lock(L); - api_checknelems(L, n); - if (n >= 2) { - luaC_checkGC(L); - luaV_concat(L, n, cast_int(L->top - L->base) - 1); - L->top -= (n-1); - } - else if (n == 0) { /* push empty string */ - setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); - api_incr_top(L); - } - /* else n == 1; nothing to do */ - lua_unlock(L); -} - - -LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { - lua_Alloc f; - lua_lock(L); - if (ud) *ud = G(L)->ud; - f = G(L)->frealloc; - lua_unlock(L); - return f; -} - - -LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { - lua_lock(L); - G(L)->ud = ud; - G(L)->frealloc = f; - lua_unlock(L); -} - - -LUA_API void *lua_newuserdata (lua_State *L, size_t size) { - Udata *u; - lua_lock(L); - luaC_checkGC(L); - u = luaS_newudata(L, size, getcurrenv(L)); - setuvalue(L, L->top, u); - api_incr_top(L); - lua_unlock(L); - return u + 1; -} - - - - -static const char *aux_upvalue (StkId fi, int n, TValue **val) { - Closure *f; - if (!ttisfunction(fi)) return NULL; - f = clvalue(fi); - if (f->c.isC) { - if (!(1 <= n && n <= f->c.nupvalues)) return NULL; - *val = &f->c.upvalue[n-1]; - return ""; - } - else { - Proto *p = f->l.p; - if (!(1 <= n && n <= p->sizeupvalues)) return NULL; - *val = f->l.upvals[n-1]->v; - return getstr(p->upvalues[n-1]); - } -} - - -LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { - const char *name; - TValue *val; - lua_lock(L); - name = aux_upvalue(index2adr(L, funcindex), n, &val); - if (name) { - setobj2s(L, L->top, val); - api_incr_top(L); - } - lua_unlock(L); - return name; -} - - -LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { - const char *name; - TValue *val; - StkId fi; - lua_lock(L); - fi = index2adr(L, funcindex); - api_checknelems(L, 1); - name = aux_upvalue(fi, n, &val); - if (name) { - L->top--; - setobj(L, val, L->top); - luaC_barrier(L, clvalue(fi), L->top); - } - lua_unlock(L); - return name; -} - diff -Nru gpick-0.2.4/extern/lua/src/lapi.h gpick-0.2.5/extern/lua/src/lapi.h --- gpick-0.2.4/extern/lua/src/lapi.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lapi.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* -** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ -** Auxiliary functions from Lua API -** See Copyright Notice in lua.h -*/ - -#ifndef lapi_h -#define lapi_h - - -#include "lobject.h" - - -LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lauxlib.c gpick-0.2.5/extern/lua/src/lauxlib.c --- gpick-0.2.4/extern/lua/src/lauxlib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lauxlib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,652 +0,0 @@ -/* -** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ -** Auxiliary functions for building Lua libraries -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include -#include -#include -#include - - -/* This file uses only the official API of Lua. -** Any function declared here could be written as an application function. -*/ - -#define lauxlib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" - - -#define FREELIST_REF 0 /* free list of references */ - - -/* convert a stack index to positive */ -#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ - lua_gettop(L) + (i) + 1) - - -/* -** {====================================================== -** Error-report functions -** ======================================================= -*/ - - -LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { - lua_Debug ar; - if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ - return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); - lua_getinfo(L, "n", &ar); - if (strcmp(ar.namewhat, "method") == 0) { - narg--; /* do not count `self' */ - if (narg == 0) /* error is in the self argument itself? */ - return luaL_error(L, "calling " LUA_QS " on bad self (%s)", - ar.name, extramsg); - } - if (ar.name == NULL) - ar.name = "?"; - return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", - narg, ar.name, extramsg); -} - - -LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { - const char *msg = lua_pushfstring(L, "%s expected, got %s", - tname, luaL_typename(L, narg)); - return luaL_argerror(L, narg, msg); -} - - -static void tag_error (lua_State *L, int narg, int tag) { - luaL_typerror(L, narg, lua_typename(L, tag)); -} - - -LUALIB_API void luaL_where (lua_State *L, int level) { - lua_Debug ar; - if (lua_getstack(L, level, &ar)) { /* check function at level */ - lua_getinfo(L, "Sl", &ar); /* get info about it */ - if (ar.currentline > 0) { /* is there info? */ - lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); - return; - } - } - lua_pushliteral(L, ""); /* else, no information available... */ -} - - -LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { - va_list argp; - va_start(argp, fmt); - luaL_where(L, 1); - lua_pushvfstring(L, fmt, argp); - va_end(argp); - lua_concat(L, 2); - return lua_error(L); -} - -/* }====================================================== */ - - -LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, - const char *const lst[]) { - const char *name = (def) ? luaL_optstring(L, narg, def) : - luaL_checkstring(L, narg); - int i; - for (i=0; lst[i]; i++) - if (strcmp(lst[i], name) == 0) - return i; - return luaL_argerror(L, narg, - lua_pushfstring(L, "invalid option " LUA_QS, name)); -} - - -LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { - lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ - if (!lua_isnil(L, -1)) /* name already in use? */ - return 0; /* leave previous value on top, but return 0 */ - lua_pop(L, 1); - lua_newtable(L); /* create metatable */ - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ - return 1; -} - - -LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { - void *p = lua_touserdata(L, ud); - if (p != NULL) { /* value is a userdata? */ - if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ - lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ - if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ - lua_pop(L, 2); /* remove both metatables */ - return p; - } - } - } - luaL_typerror(L, ud, tname); /* else error */ - return NULL; /* to avoid warnings */ -} - - -LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { - if (!lua_checkstack(L, space)) - luaL_error(L, "stack overflow (%s)", mes); -} - - -LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { - if (lua_type(L, narg) != t) - tag_error(L, narg, t); -} - - -LUALIB_API void luaL_checkany (lua_State *L, int narg) { - if (lua_type(L, narg) == LUA_TNONE) - luaL_argerror(L, narg, "value expected"); -} - - -LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { - const char *s = lua_tolstring(L, narg, len); - if (!s) tag_error(L, narg, LUA_TSTRING); - return s; -} - - -LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, - const char *def, size_t *len) { - if (lua_isnoneornil(L, narg)) { - if (len) - *len = (def ? strlen(def) : 0); - return def; - } - else return luaL_checklstring(L, narg, len); -} - - -LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { - lua_Number d = lua_tonumber(L, narg); - if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ - tag_error(L, narg, LUA_TNUMBER); - return d; -} - - -LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { - return luaL_opt(L, luaL_checknumber, narg, def); -} - - -LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { - lua_Integer d = lua_tointeger(L, narg); - if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ - tag_error(L, narg, LUA_TNUMBER); - return d; -} - - -LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, - lua_Integer def) { - return luaL_opt(L, luaL_checkinteger, narg, def); -} - - -LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { - if (!lua_getmetatable(L, obj)) /* no metatable? */ - return 0; - lua_pushstring(L, event); - lua_rawget(L, -2); - if (lua_isnil(L, -1)) { - lua_pop(L, 2); /* remove metatable and metafield */ - return 0; - } - else { - lua_remove(L, -2); /* remove only metatable */ - return 1; - } -} - - -LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { - obj = abs_index(L, obj); - if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ - return 0; - lua_pushvalue(L, obj); - lua_call(L, 1, 1); - return 1; -} - - -LUALIB_API void (luaL_register) (lua_State *L, const char *libname, - const luaL_Reg *l) { - luaI_openlib(L, libname, l, 0); -} - - -static int libsize (const luaL_Reg *l) { - int size = 0; - for (; l->name; l++) size++; - return size; -} - - -LUALIB_API void luaI_openlib (lua_State *L, const char *libname, - const luaL_Reg *l, int nup) { - if (libname) { - int size = libsize(l); - /* check whether lib already exists */ - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); - lua_getfield(L, -1, libname); /* get _LOADED[libname] */ - if (!lua_istable(L, -1)) { /* not found? */ - lua_pop(L, 1); /* remove previous result */ - /* try global variable (and create one if it does not exist) */ - if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) - luaL_error(L, "name conflict for module " LUA_QS, libname); - lua_pushvalue(L, -1); - lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ - } - lua_remove(L, -2); /* remove _LOADED table */ - lua_insert(L, -(nup+1)); /* move library table to below upvalues */ - } - for (; l->name; l++) { - int i; - for (i=0; ifunc, nup); - lua_setfield(L, -(nup+2), l->name); - } - lua_pop(L, nup); /* remove upvalues */ -} - - - -/* -** {====================================================== -** getn-setn: size for arrays -** ======================================================= -*/ - -#if defined(LUA_COMPAT_GETN) - -static int checkint (lua_State *L, int topop) { - int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; - lua_pop(L, topop); - return n; -} - - -static void getsizes (lua_State *L) { - lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); - if (lua_isnil(L, -1)) { /* no `size' table? */ - lua_pop(L, 1); /* remove nil */ - lua_newtable(L); /* create it */ - lua_pushvalue(L, -1); /* `size' will be its own metatable */ - lua_setmetatable(L, -2); - lua_pushliteral(L, "kv"); - lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ - } -} - - -LUALIB_API void luaL_setn (lua_State *L, int t, int n) { - t = abs_index(L, t); - lua_pushliteral(L, "n"); - lua_rawget(L, t); - if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ - lua_pushliteral(L, "n"); /* use it */ - lua_pushinteger(L, n); - lua_rawset(L, t); - } - else { /* use `sizes' */ - getsizes(L); - lua_pushvalue(L, t); - lua_pushinteger(L, n); - lua_rawset(L, -3); /* sizes[t] = n */ - lua_pop(L, 1); /* remove `sizes' */ - } -} - - -LUALIB_API int luaL_getn (lua_State *L, int t) { - int n; - t = abs_index(L, t); - lua_pushliteral(L, "n"); /* try t.n */ - lua_rawget(L, t); - if ((n = checkint(L, 1)) >= 0) return n; - getsizes(L); /* else try sizes[t] */ - lua_pushvalue(L, t); - lua_rawget(L, -2); - if ((n = checkint(L, 2)) >= 0) return n; - return (int)lua_objlen(L, t); -} - -#endif - -/* }====================================================== */ - - - -LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, - const char *r) { - const char *wild; - size_t l = strlen(p); - luaL_Buffer b; - luaL_buffinit(L, &b); - while ((wild = strstr(s, p)) != NULL) { - luaL_addlstring(&b, s, wild - s); /* push prefix */ - luaL_addstring(&b, r); /* push replacement in place of pattern */ - s = wild + l; /* continue after `p' */ - } - luaL_addstring(&b, s); /* push last suffix */ - luaL_pushresult(&b); - return lua_tostring(L, -1); -} - - -LUALIB_API const char *luaL_findtable (lua_State *L, int idx, - const char *fname, int szhint) { - const char *e; - lua_pushvalue(L, idx); - do { - e = strchr(fname, '.'); - if (e == NULL) e = fname + strlen(fname); - lua_pushlstring(L, fname, e - fname); - lua_rawget(L, -2); - if (lua_isnil(L, -1)) { /* no such field? */ - lua_pop(L, 1); /* remove this nil */ - lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ - lua_pushlstring(L, fname, e - fname); - lua_pushvalue(L, -2); - lua_settable(L, -4); /* set new table into field */ - } - else if (!lua_istable(L, -1)) { /* field has a non-table value? */ - lua_pop(L, 2); /* remove table and value */ - return fname; /* return problematic part of the name */ - } - lua_remove(L, -2); /* remove previous table */ - fname = e + 1; - } while (*e == '.'); - return NULL; -} - - - -/* -** {====================================================== -** Generic Buffer manipulation -** ======================================================= -*/ - - -#define bufflen(B) ((B)->p - (B)->buffer) -#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) - -#define LIMIT (LUA_MINSTACK/2) - - -static int emptybuffer (luaL_Buffer *B) { - size_t l = bufflen(B); - if (l == 0) return 0; /* put nothing on stack */ - else { - lua_pushlstring(B->L, B->buffer, l); - B->p = B->buffer; - B->lvl++; - return 1; - } -} - - -static void adjuststack (luaL_Buffer *B) { - if (B->lvl > 1) { - lua_State *L = B->L; - int toget = 1; /* number of levels to concat */ - size_t toplen = lua_strlen(L, -1); - do { - size_t l = lua_strlen(L, -(toget+1)); - if (B->lvl - toget + 1 >= LIMIT || toplen > l) { - toplen += l; - toget++; - } - else break; - } while (toget < B->lvl); - lua_concat(L, toget); - B->lvl = B->lvl - toget + 1; - } -} - - -LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { - if (emptybuffer(B)) - adjuststack(B); - return B->buffer; -} - - -LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { - while (l--) - luaL_addchar(B, *s++); -} - - -LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { - luaL_addlstring(B, s, strlen(s)); -} - - -LUALIB_API void luaL_pushresult (luaL_Buffer *B) { - emptybuffer(B); - lua_concat(B->L, B->lvl); - B->lvl = 1; -} - - -LUALIB_API void luaL_addvalue (luaL_Buffer *B) { - lua_State *L = B->L; - size_t vl; - const char *s = lua_tolstring(L, -1, &vl); - if (vl <= bufffree(B)) { /* fit into buffer? */ - memcpy(B->p, s, vl); /* put it there */ - B->p += vl; - lua_pop(L, 1); /* remove from stack */ - } - else { - if (emptybuffer(B)) - lua_insert(L, -2); /* put buffer before new value */ - B->lvl++; /* add new value into B stack */ - adjuststack(B); - } -} - - -LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { - B->L = L; - B->p = B->buffer; - B->lvl = 0; -} - -/* }====================================================== */ - - -LUALIB_API int luaL_ref (lua_State *L, int t) { - int ref; - t = abs_index(L, t); - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* remove from stack */ - return LUA_REFNIL; /* `nil' has a unique fixed reference */ - } - lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ - ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ - lua_pop(L, 1); /* remove it from stack */ - if (ref != 0) { /* any free element? */ - lua_rawgeti(L, t, ref); /* remove it from list */ - lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ - } - else { /* no free elements */ - ref = (int)lua_objlen(L, t); - ref++; /* create new reference */ - } - lua_rawseti(L, t, ref); - return ref; -} - - -LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { - if (ref >= 0) { - t = abs_index(L, t); - lua_rawgeti(L, t, FREELIST_REF); - lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ - lua_pushinteger(L, ref); - lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ - } -} - - - -/* -** {====================================================== -** Load functions -** ======================================================= -*/ - -typedef struct LoadF { - int extraline; - FILE *f; - char buff[LUAL_BUFFERSIZE]; -} LoadF; - - -static const char *getF (lua_State *L, void *ud, size_t *size) { - LoadF *lf = (LoadF *)ud; - (void)L; - if (lf->extraline) { - lf->extraline = 0; - *size = 1; - return "\n"; - } - if (feof(lf->f)) return NULL; - *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); - return (*size > 0) ? lf->buff : NULL; -} - - -static int errfile (lua_State *L, const char *what, int fnameindex) { - const char *serr = strerror(errno); - const char *filename = lua_tostring(L, fnameindex) + 1; - lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); - lua_remove(L, fnameindex); - return LUA_ERRFILE; -} - - -LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { - LoadF lf; - int status, readstatus; - int c; - int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ - lf.extraline = 0; - if (filename == NULL) { - lua_pushliteral(L, "=stdin"); - lf.f = stdin; - } - else { - lua_pushfstring(L, "@%s", filename); - lf.f = fopen(filename, "r"); - if (lf.f == NULL) return errfile(L, "open", fnameindex); - } - c = getc(lf.f); - if (c == '#') { /* Unix exec. file? */ - lf.extraline = 1; - while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ - if (c == '\n') c = getc(lf.f); - } - if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ - lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ - if (lf.f == NULL) return errfile(L, "reopen", fnameindex); - /* skip eventual `#!...' */ - while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; - lf.extraline = 0; - } - ungetc(c, lf.f); - status = lua_load(L, getF, &lf, lua_tostring(L, -1)); - readstatus = ferror(lf.f); - if (filename) fclose(lf.f); /* close file (even in case of errors) */ - if (readstatus) { - lua_settop(L, fnameindex); /* ignore results from `lua_load' */ - return errfile(L, "read", fnameindex); - } - lua_remove(L, fnameindex); - return status; -} - - -typedef struct LoadS { - const char *s; - size_t size; -} LoadS; - - -static const char *getS (lua_State *L, void *ud, size_t *size) { - LoadS *ls = (LoadS *)ud; - (void)L; - if (ls->size == 0) return NULL; - *size = ls->size; - ls->size = 0; - return ls->s; -} - - -LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, - const char *name) { - LoadS ls; - ls.s = buff; - ls.size = size; - return lua_load(L, getS, &ls, name); -} - - -LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { - return luaL_loadbuffer(L, s, strlen(s), s); -} - - - -/* }====================================================== */ - - -static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { - (void)ud; - (void)osize; - if (nsize == 0) { - free(ptr); - return NULL; - } - else - return realloc(ptr, nsize); -} - - -static int panic (lua_State *L) { - (void)L; /* to avoid warnings */ - fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", - lua_tostring(L, -1)); - return 0; -} - - -LUALIB_API lua_State *luaL_newstate (void) { - lua_State *L = lua_newstate(l_alloc, NULL); - if (L) lua_atpanic(L, &panic); - return L; -} - diff -Nru gpick-0.2.4/extern/lua/src/lauxlib.h gpick-0.2.5/extern/lua/src/lauxlib.h --- gpick-0.2.4/extern/lua/src/lauxlib.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lauxlib.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ -/* -** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ -** Auxiliary functions for building Lua libraries -** See Copyright Notice in lua.h -*/ - - -#ifndef lauxlib_h -#define lauxlib_h - - -#include -#include - -#include "lua.h" - - -#if defined(LUA_COMPAT_GETN) -LUALIB_API int (luaL_getn) (lua_State *L, int t); -LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); -#else -#define luaL_getn(L,i) ((int)lua_objlen(L, i)) -#define luaL_setn(L,i,j) ((void)0) /* no op! */ -#endif - -#if defined(LUA_COMPAT_OPENLIB) -#define luaI_openlib luaL_openlib -#endif - - -/* extra error code for `luaL_load' */ -#define LUA_ERRFILE (LUA_ERRERR+1) - - -typedef struct luaL_Reg { - const char *name; - lua_CFunction func; -} luaL_Reg; - - - -LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, - const luaL_Reg *l, int nup); -LUALIB_API void (luaL_register) (lua_State *L, const char *libname, - const luaL_Reg *l); -LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); -LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); -LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); -LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); -LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, - size_t *l); -LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, - const char *def, size_t *l); -LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); -LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); - -LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); -LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, - lua_Integer def); - -LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); -LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); -LUALIB_API void (luaL_checkany) (lua_State *L, int narg); - -LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); -LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); - -LUALIB_API void (luaL_where) (lua_State *L, int lvl); -LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); - -LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, - const char *const lst[]); - -LUALIB_API int (luaL_ref) (lua_State *L, int t); -LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); - -LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); -LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, - const char *name); -LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); - -LUALIB_API lua_State *(luaL_newstate) (void); - - -LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, - const char *r); - -LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, - const char *fname, int szhint); - - - - -/* -** =============================================================== -** some useful macros -** =============================================================== -*/ - -#define luaL_argcheck(L, cond,numarg,extramsg) \ - ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) -#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) -#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) -#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) -#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) -#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) -#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) - -#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) - -#define luaL_dofile(L, fn) \ - (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) - -#define luaL_dostring(L, s) \ - (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) - -#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) - -#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) - -/* -** {====================================================== -** Generic Buffer manipulation -** ======================================================= -*/ - - - -typedef struct luaL_Buffer { - char *p; /* current position in buffer */ - int lvl; /* number of strings in the stack (level) */ - lua_State *L; - char buffer[LUAL_BUFFERSIZE]; -} luaL_Buffer; - -#define luaL_addchar(B,c) \ - ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ - (*(B)->p++ = (char)(c))) - -/* compatibility only */ -#define luaL_putchar(B,c) luaL_addchar(B,c) - -#define luaL_addsize(B,n) ((B)->p += (n)) - -LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); -LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); -LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); -LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); -LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); -LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); - - -/* }====================================================== */ - - -/* compatibility with ref system */ - -/* pre-defined references */ -#define LUA_NOREF (-2) -#define LUA_REFNIL (-1) - -#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ - (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) - -#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) - -#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) - - -#define luaL_reg luaL_Reg - -#endif - - diff -Nru gpick-0.2.4/extern/lua/src/lbaselib.c gpick-0.2.5/extern/lua/src/lbaselib.c --- gpick-0.2.4/extern/lua/src/lbaselib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lbaselib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,653 +0,0 @@ -/* -** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ -** Basic library -** See Copyright Notice in lua.h -*/ - - - -#include -#include -#include -#include - -#define lbaselib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - - - -/* -** If your system does not support `stdout', you can just remove this function. -** If you need, you can define your own `print' function, following this -** model but changing `fputs' to put the strings at a proper place -** (a console window or a log file, for instance). -*/ -static int luaB_print (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int i; - lua_getglobal(L, "tostring"); - for (i=1; i<=n; i++) { - const char *s; - lua_pushvalue(L, -1); /* function to be called */ - lua_pushvalue(L, i); /* value to print */ - lua_call(L, 1, 1); - s = lua_tostring(L, -1); /* get result */ - if (s == NULL) - return luaL_error(L, LUA_QL("tostring") " must return a string to " - LUA_QL("print")); - if (i>1) fputs("\t", stdout); - fputs(s, stdout); - lua_pop(L, 1); /* pop result */ - } - fputs("\n", stdout); - return 0; -} - - -static int luaB_tonumber (lua_State *L) { - int base = luaL_optint(L, 2, 10); - if (base == 10) { /* standard conversion */ - luaL_checkany(L, 1); - if (lua_isnumber(L, 1)) { - lua_pushnumber(L, lua_tonumber(L, 1)); - return 1; - } - } - else { - const char *s1 = luaL_checkstring(L, 1); - char *s2; - unsigned long n; - luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); - n = strtoul(s1, &s2, base); - if (s1 != s2) { /* at least one valid digit? */ - while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ - if (*s2 == '\0') { /* no invalid trailing characters? */ - lua_pushnumber(L, (lua_Number)n); - return 1; - } - } - } - lua_pushnil(L); /* else not a number */ - return 1; -} - - -static int luaB_error (lua_State *L) { - int level = luaL_optint(L, 2, 1); - lua_settop(L, 1); - if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ - luaL_where(L, level); - lua_pushvalue(L, 1); - lua_concat(L, 2); - } - return lua_error(L); -} - - -static int luaB_getmetatable (lua_State *L) { - luaL_checkany(L, 1); - if (!lua_getmetatable(L, 1)) { - lua_pushnil(L); - return 1; /* no metatable */ - } - luaL_getmetafield(L, 1, "__metatable"); - return 1; /* returns either __metatable field (if present) or metatable */ -} - - -static int luaB_setmetatable (lua_State *L) { - int t = lua_type(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, - "nil or table expected"); - if (luaL_getmetafield(L, 1, "__metatable")) - luaL_error(L, "cannot change a protected metatable"); - lua_settop(L, 2); - lua_setmetatable(L, 1); - return 1; -} - - -static void getfunc (lua_State *L, int opt) { - if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); - else { - lua_Debug ar; - int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); - luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); - if (lua_getstack(L, level, &ar) == 0) - luaL_argerror(L, 1, "invalid level"); - lua_getinfo(L, "f", &ar); - if (lua_isnil(L, -1)) - luaL_error(L, "no function environment for tail call at level %d", - level); - } -} - - -static int luaB_getfenv (lua_State *L) { - getfunc(L, 1); - if (lua_iscfunction(L, -1)) /* is a C function? */ - lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ - else - lua_getfenv(L, -1); - return 1; -} - - -static int luaB_setfenv (lua_State *L) { - luaL_checktype(L, 2, LUA_TTABLE); - getfunc(L, 0); - lua_pushvalue(L, 2); - if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { - /* change environment of current thread */ - lua_pushthread(L); - lua_insert(L, -2); - lua_setfenv(L, -2); - return 0; - } - else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) - luaL_error(L, - LUA_QL("setfenv") " cannot change environment of given object"); - return 1; -} - - -static int luaB_rawequal (lua_State *L) { - luaL_checkany(L, 1); - luaL_checkany(L, 2); - lua_pushboolean(L, lua_rawequal(L, 1, 2)); - return 1; -} - - -static int luaB_rawget (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checkany(L, 2); - lua_settop(L, 2); - lua_rawget(L, 1); - return 1; -} - -static int luaB_rawset (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checkany(L, 2); - luaL_checkany(L, 3); - lua_settop(L, 3); - lua_rawset(L, 1); - return 1; -} - - -static int luaB_gcinfo (lua_State *L) { - lua_pushinteger(L, lua_getgccount(L)); - return 1; -} - - -static int luaB_collectgarbage (lua_State *L) { - static const char *const opts[] = {"stop", "restart", "collect", - "count", "step", "setpause", "setstepmul", NULL}; - static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, - LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; - int o = luaL_checkoption(L, 1, "collect", opts); - int ex = luaL_optint(L, 2, 0); - int res = lua_gc(L, optsnum[o], ex); - switch (optsnum[o]) { - case LUA_GCCOUNT: { - int b = lua_gc(L, LUA_GCCOUNTB, 0); - lua_pushnumber(L, res + ((lua_Number)b/1024)); - return 1; - } - case LUA_GCSTEP: { - lua_pushboolean(L, res); - return 1; - } - default: { - lua_pushnumber(L, res); - return 1; - } - } -} - - -static int luaB_type (lua_State *L) { - luaL_checkany(L, 1); - lua_pushstring(L, luaL_typename(L, 1)); - return 1; -} - - -static int luaB_next (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 2); /* create a 2nd argument if there isn't one */ - if (lua_next(L, 1)) - return 2; - else { - lua_pushnil(L); - return 1; - } -} - - -static int luaB_pairs (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ - lua_pushvalue(L, 1); /* state, */ - lua_pushnil(L); /* and initial value */ - return 3; -} - - -static int ipairsaux (lua_State *L) { - int i = luaL_checkint(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - i++; /* next value */ - lua_pushinteger(L, i); - lua_rawgeti(L, 1, i); - return (lua_isnil(L, -1)) ? 0 : 2; -} - - -static int luaB_ipairs (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ - lua_pushvalue(L, 1); /* state, */ - lua_pushinteger(L, 0); /* and initial value */ - return 3; -} - - -static int load_aux (lua_State *L, int status) { - if (status == 0) /* OK? */ - return 1; - else { - lua_pushnil(L); - lua_insert(L, -2); /* put before error message */ - return 2; /* return nil plus error message */ - } -} - - -static int luaB_loadstring (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - const char *chunkname = luaL_optstring(L, 2, s); - return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); -} - - -static int luaB_loadfile (lua_State *L) { - const char *fname = luaL_optstring(L, 1, NULL); - return load_aux(L, luaL_loadfile(L, fname)); -} - - -/* -** Reader for generic `load' function: `lua_load' uses the -** stack for internal stuff, so the reader cannot change the -** stack top. Instead, it keeps its resulting string in a -** reserved slot inside the stack. -*/ -static const char *generic_reader (lua_State *L, void *ud, size_t *size) { - (void)ud; /* to avoid warnings */ - luaL_checkstack(L, 2, "too many nested functions"); - lua_pushvalue(L, 1); /* get function */ - lua_call(L, 0, 1); /* call it */ - if (lua_isnil(L, -1)) { - *size = 0; - return NULL; - } - else if (lua_isstring(L, -1)) { - lua_replace(L, 3); /* save string in a reserved stack slot */ - return lua_tolstring(L, 3, size); - } - else luaL_error(L, "reader function must return a string"); - return NULL; /* to avoid warnings */ -} - - -static int luaB_load (lua_State *L) { - int status; - const char *cname = luaL_optstring(L, 2, "=(load)"); - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ - status = lua_load(L, generic_reader, NULL, cname); - return load_aux(L, status); -} - - -static int luaB_dofile (lua_State *L) { - const char *fname = luaL_optstring(L, 1, NULL); - int n = lua_gettop(L); - if (luaL_loadfile(L, fname) != 0) lua_error(L); - lua_call(L, 0, LUA_MULTRET); - return lua_gettop(L) - n; -} - - -static int luaB_assert (lua_State *L) { - luaL_checkany(L, 1); - if (!lua_toboolean(L, 1)) - return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); - return lua_gettop(L); -} - - -static int luaB_unpack (lua_State *L) { - int i, e, n; - luaL_checktype(L, 1, LUA_TTABLE); - i = luaL_optint(L, 2, 1); - e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); - if (i > e) return 0; /* empty range */ - n = e - i + 1; /* number of elements */ - if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ - return luaL_error(L, "too many results to unpack"); - lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ - while (i++ < e) /* push arg[i + 1...e] */ - lua_rawgeti(L, 1, i); - return n; -} - - -static int luaB_select (lua_State *L) { - int n = lua_gettop(L); - if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { - lua_pushinteger(L, n-1); - return 1; - } - else { - int i = luaL_checkint(L, 1); - if (i < 0) i = n + i; - else if (i > n) i = n; - luaL_argcheck(L, 1 <= i, 1, "index out of range"); - return n - i; - } -} - - -static int luaB_pcall (lua_State *L) { - int status; - luaL_checkany(L, 1); - status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); - lua_pushboolean(L, (status == 0)); - lua_insert(L, 1); - return lua_gettop(L); /* return status + all results */ -} - - -static int luaB_xpcall (lua_State *L) { - int status; - luaL_checkany(L, 2); - lua_settop(L, 2); - lua_insert(L, 1); /* put error function under function to be called */ - status = lua_pcall(L, 0, LUA_MULTRET, 1); - lua_pushboolean(L, (status == 0)); - lua_replace(L, 1); - return lua_gettop(L); /* return status + all results */ -} - - -static int luaB_tostring (lua_State *L) { - luaL_checkany(L, 1); - if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ - return 1; /* use its value */ - switch (lua_type(L, 1)) { - case LUA_TNUMBER: - lua_pushstring(L, lua_tostring(L, 1)); - break; - case LUA_TSTRING: - lua_pushvalue(L, 1); - break; - case LUA_TBOOLEAN: - lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); - break; - case LUA_TNIL: - lua_pushliteral(L, "nil"); - break; - default: - lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); - break; - } - return 1; -} - - -static int luaB_newproxy (lua_State *L) { - lua_settop(L, 1); - lua_newuserdata(L, 0); /* create proxy */ - if (lua_toboolean(L, 1) == 0) - return 1; /* no metatable */ - else if (lua_isboolean(L, 1)) { - lua_newtable(L); /* create a new metatable `m' ... */ - lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ - lua_pushboolean(L, 1); - lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ - } - else { - int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ - if (lua_getmetatable(L, 1)) { - lua_rawget(L, lua_upvalueindex(1)); - validproxy = lua_toboolean(L, -1); - lua_pop(L, 1); /* remove value */ - } - luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); - lua_getmetatable(L, 1); /* metatable is valid; get it */ - } - lua_setmetatable(L, 2); - return 1; -} - - -static const luaL_Reg base_funcs[] = { - {"assert", luaB_assert}, - {"collectgarbage", luaB_collectgarbage}, - {"dofile", luaB_dofile}, - {"error", luaB_error}, - {"gcinfo", luaB_gcinfo}, - {"getfenv", luaB_getfenv}, - {"getmetatable", luaB_getmetatable}, - {"loadfile", luaB_loadfile}, - {"load", luaB_load}, - {"loadstring", luaB_loadstring}, - {"next", luaB_next}, - {"pcall", luaB_pcall}, - {"print", luaB_print}, - {"rawequal", luaB_rawequal}, - {"rawget", luaB_rawget}, - {"rawset", luaB_rawset}, - {"select", luaB_select}, - {"setfenv", luaB_setfenv}, - {"setmetatable", luaB_setmetatable}, - {"tonumber", luaB_tonumber}, - {"tostring", luaB_tostring}, - {"type", luaB_type}, - {"unpack", luaB_unpack}, - {"xpcall", luaB_xpcall}, - {NULL, NULL} -}; - - -/* -** {====================================================== -** Coroutine library -** ======================================================= -*/ - -#define CO_RUN 0 /* running */ -#define CO_SUS 1 /* suspended */ -#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ -#define CO_DEAD 3 - -static const char *const statnames[] = - {"running", "suspended", "normal", "dead"}; - -static int costatus (lua_State *L, lua_State *co) { - if (L == co) return CO_RUN; - switch (lua_status(co)) { - case LUA_YIELD: - return CO_SUS; - case 0: { - lua_Debug ar; - if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ - return CO_NOR; /* it is running */ - else if (lua_gettop(co) == 0) - return CO_DEAD; - else - return CO_SUS; /* initial state */ - } - default: /* some error occured */ - return CO_DEAD; - } -} - - -static int luaB_costatus (lua_State *L) { - lua_State *co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "coroutine expected"); - lua_pushstring(L, statnames[costatus(L, co)]); - return 1; -} - - -static int auxresume (lua_State *L, lua_State *co, int narg) { - int status = costatus(L, co); - if (!lua_checkstack(co, narg)) - luaL_error(L, "too many arguments to resume"); - if (status != CO_SUS) { - lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); - return -1; /* error flag */ - } - lua_xmove(L, co, narg); - lua_setlevel(L, co); - status = lua_resume(co, narg); - if (status == 0 || status == LUA_YIELD) { - int nres = lua_gettop(co); - if (!lua_checkstack(L, nres + 1)) - luaL_error(L, "too many results to resume"); - lua_xmove(co, L, nres); /* move yielded values */ - return nres; - } - else { - lua_xmove(co, L, 1); /* move error message */ - return -1; /* error flag */ - } -} - - -static int luaB_coresume (lua_State *L) { - lua_State *co = lua_tothread(L, 1); - int r; - luaL_argcheck(L, co, 1, "coroutine expected"); - r = auxresume(L, co, lua_gettop(L) - 1); - if (r < 0) { - lua_pushboolean(L, 0); - lua_insert(L, -2); - return 2; /* return false + error message */ - } - else { - lua_pushboolean(L, 1); - lua_insert(L, -(r + 1)); - return r + 1; /* return true + `resume' returns */ - } -} - - -static int luaB_auxwrap (lua_State *L) { - lua_State *co = lua_tothread(L, lua_upvalueindex(1)); - int r = auxresume(L, co, lua_gettop(L)); - if (r < 0) { - if (lua_isstring(L, -1)) { /* error object is a string? */ - luaL_where(L, 1); /* add extra info */ - lua_insert(L, -2); - lua_concat(L, 2); - } - lua_error(L); /* propagate error */ - } - return r; -} - - -static int luaB_cocreate (lua_State *L) { - lua_State *NL = lua_newthread(L); - luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, - "Lua function expected"); - lua_pushvalue(L, 1); /* move function to top */ - lua_xmove(L, NL, 1); /* move function from L to NL */ - return 1; -} - - -static int luaB_cowrap (lua_State *L) { - luaB_cocreate(L); - lua_pushcclosure(L, luaB_auxwrap, 1); - return 1; -} - - -static int luaB_yield (lua_State *L) { - return lua_yield(L, lua_gettop(L)); -} - - -static int luaB_corunning (lua_State *L) { - if (lua_pushthread(L)) - lua_pushnil(L); /* main thread is not a coroutine */ - return 1; -} - - -static const luaL_Reg co_funcs[] = { - {"create", luaB_cocreate}, - {"resume", luaB_coresume}, - {"running", luaB_corunning}, - {"status", luaB_costatus}, - {"wrap", luaB_cowrap}, - {"yield", luaB_yield}, - {NULL, NULL} -}; - -/* }====================================================== */ - - -static void auxopen (lua_State *L, const char *name, - lua_CFunction f, lua_CFunction u) { - lua_pushcfunction(L, u); - lua_pushcclosure(L, f, 1); - lua_setfield(L, -2, name); -} - - -static void base_open (lua_State *L) { - /* set global _G */ - lua_pushvalue(L, LUA_GLOBALSINDEX); - lua_setglobal(L, "_G"); - /* open lib into global table */ - luaL_register(L, "_G", base_funcs); - lua_pushliteral(L, LUA_VERSION); - lua_setglobal(L, "_VERSION"); /* set global _VERSION */ - /* `ipairs' and `pairs' need auxliliary functions as upvalues */ - auxopen(L, "ipairs", luaB_ipairs, ipairsaux); - auxopen(L, "pairs", luaB_pairs, luaB_next); - /* `newproxy' needs a weaktable as upvalue */ - lua_createtable(L, 0, 1); /* new table `w' */ - lua_pushvalue(L, -1); /* `w' will be its own metatable */ - lua_setmetatable(L, -2); - lua_pushliteral(L, "kv"); - lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ - lua_pushcclosure(L, luaB_newproxy, 1); - lua_setglobal(L, "newproxy"); /* set global `newproxy' */ -} - - -LUALIB_API int luaopen_base (lua_State *L) { - base_open(L); - luaL_register(L, LUA_COLIBNAME, co_funcs); - return 2; -} - diff -Nru gpick-0.2.4/extern/lua/src/lcode.c gpick-0.2.5/extern/lua/src/lcode.c --- gpick-0.2.4/extern/lua/src/lcode.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lcode.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,839 +0,0 @@ -/* -** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ -** Code generator for Lua -** See Copyright Notice in lua.h -*/ - - -#include - -#define lcode_c -#define LUA_CORE - -#include "lua.h" - -#include "lcode.h" -#include "ldebug.h" -#include "ldo.h" -#include "lgc.h" -#include "llex.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" -#include "ltable.h" - - -#define hasjumps(e) ((e)->t != (e)->f) - - -static int isnumeral(expdesc *e) { - return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); -} - - -void luaK_nil (FuncState *fs, int from, int n) { - Instruction *previous; - if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ - if (fs->pc == 0) { /* function start? */ - if (from >= fs->nactvar) - return; /* positions are already clean */ - } - else { - previous = &fs->f->code[fs->pc-1]; - if (GET_OPCODE(*previous) == OP_LOADNIL) { - int pfrom = GETARG_A(*previous); - int pto = GETARG_B(*previous); - if (pfrom <= from && from <= pto+1) { /* can connect both? */ - if (from+n-1 > pto) - SETARG_B(*previous, from+n-1); - return; - } - } - } - } - luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ -} - - -int luaK_jump (FuncState *fs) { - int jpc = fs->jpc; /* save list of jumps to here */ - int j; - fs->jpc = NO_JUMP; - j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); - luaK_concat(fs, &j, jpc); /* keep them on hold */ - return j; -} - - -void luaK_ret (FuncState *fs, int first, int nret) { - luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); -} - - -static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { - luaK_codeABC(fs, op, A, B, C); - return luaK_jump(fs); -} - - -static void fixjump (FuncState *fs, int pc, int dest) { - Instruction *jmp = &fs->f->code[pc]; - int offset = dest-(pc+1); - lua_assert(dest != NO_JUMP); - if (abs(offset) > MAXARG_sBx) - luaX_syntaxerror(fs->ls, "control structure too long"); - SETARG_sBx(*jmp, offset); -} - - -/* -** returns current `pc' and marks it as a jump target (to avoid wrong -** optimizations with consecutive instructions not in the same basic block). -*/ -int luaK_getlabel (FuncState *fs) { - fs->lasttarget = fs->pc; - return fs->pc; -} - - -static int getjump (FuncState *fs, int pc) { - int offset = GETARG_sBx(fs->f->code[pc]); - if (offset == NO_JUMP) /* point to itself represents end of list */ - return NO_JUMP; /* end of list */ - else - return (pc+1)+offset; /* turn offset into absolute position */ -} - - -static Instruction *getjumpcontrol (FuncState *fs, int pc) { - Instruction *pi = &fs->f->code[pc]; - if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) - return pi-1; - else - return pi; -} - - -/* -** check whether list has any jump that do not produce a value -** (or produce an inverted value) -*/ -static int need_value (FuncState *fs, int list) { - for (; list != NO_JUMP; list = getjump(fs, list)) { - Instruction i = *getjumpcontrol(fs, list); - if (GET_OPCODE(i) != OP_TESTSET) return 1; - } - return 0; /* not found */ -} - - -static int patchtestreg (FuncState *fs, int node, int reg) { - Instruction *i = getjumpcontrol(fs, node); - if (GET_OPCODE(*i) != OP_TESTSET) - return 0; /* cannot patch other instructions */ - if (reg != NO_REG && reg != GETARG_B(*i)) - SETARG_A(*i, reg); - else /* no register to put value or register already has the value */ - *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); - - return 1; -} - - -static void removevalues (FuncState *fs, int list) { - for (; list != NO_JUMP; list = getjump(fs, list)) - patchtestreg(fs, list, NO_REG); -} - - -static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, - int dtarget) { - while (list != NO_JUMP) { - int next = getjump(fs, list); - if (patchtestreg(fs, list, reg)) - fixjump(fs, list, vtarget); - else - fixjump(fs, list, dtarget); /* jump to default target */ - list = next; - } -} - - -static void dischargejpc (FuncState *fs) { - patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); - fs->jpc = NO_JUMP; -} - - -void luaK_patchlist (FuncState *fs, int list, int target) { - if (target == fs->pc) - luaK_patchtohere(fs, list); - else { - lua_assert(target < fs->pc); - patchlistaux(fs, list, target, NO_REG, target); - } -} - - -void luaK_patchtohere (FuncState *fs, int list) { - luaK_getlabel(fs); - luaK_concat(fs, &fs->jpc, list); -} - - -void luaK_concat (FuncState *fs, int *l1, int l2) { - if (l2 == NO_JUMP) return; - else if (*l1 == NO_JUMP) - *l1 = l2; - else { - int list = *l1; - int next; - while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ - list = next; - fixjump(fs, list, l2); - } -} - - -void luaK_checkstack (FuncState *fs, int n) { - int newstack = fs->freereg + n; - if (newstack > fs->f->maxstacksize) { - if (newstack >= MAXSTACK) - luaX_syntaxerror(fs->ls, "function or expression too complex"); - fs->f->maxstacksize = cast_byte(newstack); - } -} - - -void luaK_reserveregs (FuncState *fs, int n) { - luaK_checkstack(fs, n); - fs->freereg += n; -} - - -static void freereg (FuncState *fs, int reg) { - if (!ISK(reg) && reg >= fs->nactvar) { - fs->freereg--; - lua_assert(reg == fs->freereg); - } -} - - -static void freeexp (FuncState *fs, expdesc *e) { - if (e->k == VNONRELOC) - freereg(fs, e->u.s.info); -} - - -static int addk (FuncState *fs, TValue *k, TValue *v) { - lua_State *L = fs->L; - TValue *idx = luaH_set(L, fs->h, k); - Proto *f = fs->f; - int oldsize = f->sizek; - if (ttisnumber(idx)) { - lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); - return cast_int(nvalue(idx)); - } - else { /* constant not found; create a new entry */ - setnvalue(idx, cast_num(fs->nk)); - luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, - MAXARG_Bx, "constant table overflow"); - while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); - setobj(L, &f->k[fs->nk], v); - luaC_barrier(L, f, v); - return fs->nk++; - } -} - - -int luaK_stringK (FuncState *fs, TString *s) { - TValue o; - setsvalue(fs->L, &o, s); - return addk(fs, &o, &o); -} - - -int luaK_numberK (FuncState *fs, lua_Number r) { - TValue o; - setnvalue(&o, r); - return addk(fs, &o, &o); -} - - -static int boolK (FuncState *fs, int b) { - TValue o; - setbvalue(&o, b); - return addk(fs, &o, &o); -} - - -static int nilK (FuncState *fs) { - TValue k, v; - setnilvalue(&v); - /* cannot use nil as key; instead use table itself to represent nil */ - sethvalue(fs->L, &k, fs->h); - return addk(fs, &k, &v); -} - - -void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { - if (e->k == VCALL) { /* expression is an open function call? */ - SETARG_C(getcode(fs, e), nresults+1); - } - else if (e->k == VVARARG) { - SETARG_B(getcode(fs, e), nresults+1); - SETARG_A(getcode(fs, e), fs->freereg); - luaK_reserveregs(fs, 1); - } -} - - -void luaK_setoneret (FuncState *fs, expdesc *e) { - if (e->k == VCALL) { /* expression is an open function call? */ - e->k = VNONRELOC; - e->u.s.info = GETARG_A(getcode(fs, e)); - } - else if (e->k == VVARARG) { - SETARG_B(getcode(fs, e), 2); - e->k = VRELOCABLE; /* can relocate its simple result */ - } -} - - -void luaK_dischargevars (FuncState *fs, expdesc *e) { - switch (e->k) { - case VLOCAL: { - e->k = VNONRELOC; - break; - } - case VUPVAL: { - e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); - e->k = VRELOCABLE; - break; - } - case VGLOBAL: { - e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); - e->k = VRELOCABLE; - break; - } - case VINDEXED: { - freereg(fs, e->u.s.aux); - freereg(fs, e->u.s.info); - e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); - e->k = VRELOCABLE; - break; - } - case VVARARG: - case VCALL: { - luaK_setoneret(fs, e); - break; - } - default: break; /* there is one value available (somewhere) */ - } -} - - -static int code_label (FuncState *fs, int A, int b, int jump) { - luaK_getlabel(fs); /* those instructions may be jump targets */ - return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); -} - - -static void discharge2reg (FuncState *fs, expdesc *e, int reg) { - luaK_dischargevars(fs, e); - switch (e->k) { - case VNIL: { - luaK_nil(fs, reg, 1); - break; - } - case VFALSE: case VTRUE: { - luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); - break; - } - case VK: { - luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); - break; - } - case VKNUM: { - luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); - break; - } - case VRELOCABLE: { - Instruction *pc = &getcode(fs, e); - SETARG_A(*pc, reg); - break; - } - case VNONRELOC: { - if (reg != e->u.s.info) - luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); - break; - } - default: { - lua_assert(e->k == VVOID || e->k == VJMP); - return; /* nothing to do... */ - } - } - e->u.s.info = reg; - e->k = VNONRELOC; -} - - -static void discharge2anyreg (FuncState *fs, expdesc *e) { - if (e->k != VNONRELOC) { - luaK_reserveregs(fs, 1); - discharge2reg(fs, e, fs->freereg-1); - } -} - - -static void exp2reg (FuncState *fs, expdesc *e, int reg) { - discharge2reg(fs, e, reg); - if (e->k == VJMP) - luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ - if (hasjumps(e)) { - int final; /* position after whole expression */ - int p_f = NO_JUMP; /* position of an eventual LOAD false */ - int p_t = NO_JUMP; /* position of an eventual LOAD true */ - if (need_value(fs, e->t) || need_value(fs, e->f)) { - int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); - p_f = code_label(fs, reg, 0, 1); - p_t = code_label(fs, reg, 1, 0); - luaK_patchtohere(fs, fj); - } - final = luaK_getlabel(fs); - patchlistaux(fs, e->f, final, reg, p_f); - patchlistaux(fs, e->t, final, reg, p_t); - } - e->f = e->t = NO_JUMP; - e->u.s.info = reg; - e->k = VNONRELOC; -} - - -void luaK_exp2nextreg (FuncState *fs, expdesc *e) { - luaK_dischargevars(fs, e); - freeexp(fs, e); - luaK_reserveregs(fs, 1); - exp2reg(fs, e, fs->freereg - 1); -} - - -int luaK_exp2anyreg (FuncState *fs, expdesc *e) { - luaK_dischargevars(fs, e); - if (e->k == VNONRELOC) { - if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ - if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ - exp2reg(fs, e, e->u.s.info); /* put value on it */ - return e->u.s.info; - } - } - luaK_exp2nextreg(fs, e); /* default */ - return e->u.s.info; -} - - -void luaK_exp2val (FuncState *fs, expdesc *e) { - if (hasjumps(e)) - luaK_exp2anyreg(fs, e); - else - luaK_dischargevars(fs, e); -} - - -int luaK_exp2RK (FuncState *fs, expdesc *e) { - luaK_exp2val(fs, e); - switch (e->k) { - case VKNUM: - case VTRUE: - case VFALSE: - case VNIL: { - if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ - e->u.s.info = (e->k == VNIL) ? nilK(fs) : - (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : - boolK(fs, (e->k == VTRUE)); - e->k = VK; - return RKASK(e->u.s.info); - } - else break; - } - case VK: { - if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ - return RKASK(e->u.s.info); - else break; - } - default: break; - } - /* not a constant in the right range: put it in a register */ - return luaK_exp2anyreg(fs, e); -} - - -void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { - switch (var->k) { - case VLOCAL: { - freeexp(fs, ex); - exp2reg(fs, ex, var->u.s.info); - return; - } - case VUPVAL: { - int e = luaK_exp2anyreg(fs, ex); - luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); - break; - } - case VGLOBAL: { - int e = luaK_exp2anyreg(fs, ex); - luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); - break; - } - case VINDEXED: { - int e = luaK_exp2RK(fs, ex); - luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); - break; - } - default: { - lua_assert(0); /* invalid var kind to store */ - break; - } - } - freeexp(fs, ex); -} - - -void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { - int func; - luaK_exp2anyreg(fs, e); - freeexp(fs, e); - func = fs->freereg; - luaK_reserveregs(fs, 2); - luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); - freeexp(fs, key); - e->u.s.info = func; - e->k = VNONRELOC; -} - - -static void invertjump (FuncState *fs, expdesc *e) { - Instruction *pc = getjumpcontrol(fs, e->u.s.info); - lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && - GET_OPCODE(*pc) != OP_TEST); - SETARG_A(*pc, !(GETARG_A(*pc))); -} - - -static int jumponcond (FuncState *fs, expdesc *e, int cond) { - if (e->k == VRELOCABLE) { - Instruction ie = getcode(fs, e); - if (GET_OPCODE(ie) == OP_NOT) { - fs->pc--; /* remove previous OP_NOT */ - return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); - } - /* else go through */ - } - discharge2anyreg(fs, e); - freeexp(fs, e); - return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); -} - - -void luaK_goiftrue (FuncState *fs, expdesc *e) { - int pc; /* pc of last jump */ - luaK_dischargevars(fs, e); - switch (e->k) { - case VK: case VKNUM: case VTRUE: { - pc = NO_JUMP; /* always true; do nothing */ - break; - } - case VFALSE: { - pc = luaK_jump(fs); /* always jump */ - break; - } - case VJMP: { - invertjump(fs, e); - pc = e->u.s.info; - break; - } - default: { - pc = jumponcond(fs, e, 0); - break; - } - } - luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ - luaK_patchtohere(fs, e->t); - e->t = NO_JUMP; -} - - -static void luaK_goiffalse (FuncState *fs, expdesc *e) { - int pc; /* pc of last jump */ - luaK_dischargevars(fs, e); - switch (e->k) { - case VNIL: case VFALSE: { - pc = NO_JUMP; /* always false; do nothing */ - break; - } - case VTRUE: { - pc = luaK_jump(fs); /* always jump */ - break; - } - case VJMP: { - pc = e->u.s.info; - break; - } - default: { - pc = jumponcond(fs, e, 1); - break; - } - } - luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ - luaK_patchtohere(fs, e->f); - e->f = NO_JUMP; -} - - -static void codenot (FuncState *fs, expdesc *e) { - luaK_dischargevars(fs, e); - switch (e->k) { - case VNIL: case VFALSE: { - e->k = VTRUE; - break; - } - case VK: case VKNUM: case VTRUE: { - e->k = VFALSE; - break; - } - case VJMP: { - invertjump(fs, e); - break; - } - case VRELOCABLE: - case VNONRELOC: { - discharge2anyreg(fs, e); - freeexp(fs, e); - e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); - e->k = VRELOCABLE; - break; - } - default: { - lua_assert(0); /* cannot happen */ - break; - } - } - /* interchange true and false lists */ - { int temp = e->f; e->f = e->t; e->t = temp; } - removevalues(fs, e->f); - removevalues(fs, e->t); -} - - -void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { - t->u.s.aux = luaK_exp2RK(fs, k); - t->k = VINDEXED; -} - - -static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { - lua_Number v1, v2, r; - if (!isnumeral(e1) || !isnumeral(e2)) return 0; - v1 = e1->u.nval; - v2 = e2->u.nval; - switch (op) { - case OP_ADD: r = luai_numadd(v1, v2); break; - case OP_SUB: r = luai_numsub(v1, v2); break; - case OP_MUL: r = luai_nummul(v1, v2); break; - case OP_DIV: - if (v2 == 0) return 0; /* do not attempt to divide by 0 */ - r = luai_numdiv(v1, v2); break; - case OP_MOD: - if (v2 == 0) return 0; /* do not attempt to divide by 0 */ - r = luai_nummod(v1, v2); break; - case OP_POW: r = luai_numpow(v1, v2); break; - case OP_UNM: r = luai_numunm(v1); break; - case OP_LEN: return 0; /* no constant folding for 'len' */ - default: lua_assert(0); r = 0; break; - } - if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ - e1->u.nval = r; - return 1; -} - - -static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { - if (constfolding(op, e1, e2)) - return; - else { - int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; - int o1 = luaK_exp2RK(fs, e1); - if (o1 > o2) { - freeexp(fs, e1); - freeexp(fs, e2); - } - else { - freeexp(fs, e2); - freeexp(fs, e1); - } - e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); - e1->k = VRELOCABLE; - } -} - - -static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, - expdesc *e2) { - int o1 = luaK_exp2RK(fs, e1); - int o2 = luaK_exp2RK(fs, e2); - freeexp(fs, e2); - freeexp(fs, e1); - if (cond == 0 && op != OP_EQ) { - int temp; /* exchange args to replace by `<' or `<=' */ - temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ - cond = 1; - } - e1->u.s.info = condjump(fs, op, cond, o1, o2); - e1->k = VJMP; -} - - -void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { - expdesc e2; - e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; - switch (op) { - case OPR_MINUS: { - if (!isnumeral(e)) - luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ - codearith(fs, OP_UNM, e, &e2); - break; - } - case OPR_NOT: codenot(fs, e); break; - case OPR_LEN: { - luaK_exp2anyreg(fs, e); /* cannot operate on constants */ - codearith(fs, OP_LEN, e, &e2); - break; - } - default: lua_assert(0); - } -} - - -void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { - switch (op) { - case OPR_AND: { - luaK_goiftrue(fs, v); - break; - } - case OPR_OR: { - luaK_goiffalse(fs, v); - break; - } - case OPR_CONCAT: { - luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ - break; - } - case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: - case OPR_MOD: case OPR_POW: { - if (!isnumeral(v)) luaK_exp2RK(fs, v); - break; - } - default: { - luaK_exp2RK(fs, v); - break; - } - } -} - - -void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { - switch (op) { - case OPR_AND: { - lua_assert(e1->t == NO_JUMP); /* list must be closed */ - luaK_dischargevars(fs, e2); - luaK_concat(fs, &e2->f, e1->f); - *e1 = *e2; - break; - } - case OPR_OR: { - lua_assert(e1->f == NO_JUMP); /* list must be closed */ - luaK_dischargevars(fs, e2); - luaK_concat(fs, &e2->t, e1->t); - *e1 = *e2; - break; - } - case OPR_CONCAT: { - luaK_exp2val(fs, e2); - if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { - lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); - freeexp(fs, e1); - SETARG_B(getcode(fs, e2), e1->u.s.info); - e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; - } - else { - luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ - codearith(fs, OP_CONCAT, e1, e2); - } - break; - } - case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; - case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; - case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; - case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; - case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; - case OPR_POW: codearith(fs, OP_POW, e1, e2); break; - case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; - case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; - case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; - case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; - case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; - case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; - default: lua_assert(0); - } -} - - -void luaK_fixline (FuncState *fs, int line) { - fs->f->lineinfo[fs->pc - 1] = line; -} - - -static int luaK_code (FuncState *fs, Instruction i, int line) { - Proto *f = fs->f; - dischargejpc(fs); /* `pc' will change */ - /* put new instruction in code array */ - luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, - MAX_INT, "code size overflow"); - f->code[fs->pc] = i; - /* save corresponding line information */ - luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, - MAX_INT, "code size overflow"); - f->lineinfo[fs->pc] = line; - return fs->pc++; -} - - -int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { - lua_assert(getOpMode(o) == iABC); - lua_assert(getBMode(o) != OpArgN || b == 0); - lua_assert(getCMode(o) != OpArgN || c == 0); - return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); -} - - -int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { - lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); - lua_assert(getCMode(o) == OpArgN); - return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); -} - - -void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { - int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; - int b = (tostore == LUA_MULTRET) ? 0 : tostore; - lua_assert(tostore != 0); - if (c <= MAXARG_C) - luaK_codeABC(fs, OP_SETLIST, base, b, c); - else { - luaK_codeABC(fs, OP_SETLIST, base, b, 0); - luaK_code(fs, cast(Instruction, c), fs->ls->lastline); - } - fs->freereg = base + 1; /* free registers with list values */ -} - diff -Nru gpick-0.2.4/extern/lua/src/lcode.h gpick-0.2.5/extern/lua/src/lcode.h --- gpick-0.2.4/extern/lua/src/lcode.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lcode.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* -** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ -** Code generator for Lua -** See Copyright Notice in lua.h -*/ - -#ifndef lcode_h -#define lcode_h - -#include "llex.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" - - -/* -** Marks the end of a patch list. It is an invalid value both as an absolute -** address, and as a list link (would link an element to itself). -*/ -#define NO_JUMP (-1) - - -/* -** grep "ORDER OPR" if you change these enums -*/ -typedef enum BinOpr { - OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, - OPR_CONCAT, - OPR_NE, OPR_EQ, - OPR_LT, OPR_LE, OPR_GT, OPR_GE, - OPR_AND, OPR_OR, - OPR_NOBINOPR -} BinOpr; - - -typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; - - -#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) - -#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) - -#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) - -LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); -LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); -LUAI_FUNC void luaK_fixline (FuncState *fs, int line); -LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); -LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); -LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); -LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); -LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); -LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); -LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); -LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); -LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); -LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_jump (FuncState *fs); -LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); -LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); -LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); -LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); -LUAI_FUNC int luaK_getlabel (FuncState *fs); -LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); -LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); -LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); -LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/ldblib.c gpick-0.2.5/extern/lua/src/ldblib.c --- gpick-0.2.4/extern/lua/src/ldblib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ldblib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,397 +0,0 @@ -/* -** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ -** Interface from Lua to its debug API -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include - -#define ldblib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - - -static int db_getregistry (lua_State *L) { - lua_pushvalue(L, LUA_REGISTRYINDEX); - return 1; -} - - -static int db_getmetatable (lua_State *L) { - luaL_checkany(L, 1); - if (!lua_getmetatable(L, 1)) { - lua_pushnil(L); /* no metatable */ - } - return 1; -} - - -static int db_setmetatable (lua_State *L) { - int t = lua_type(L, 2); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, - "nil or table expected"); - lua_settop(L, 2); - lua_pushboolean(L, lua_setmetatable(L, 1)); - return 1; -} - - -static int db_getfenv (lua_State *L) { - lua_getfenv(L, 1); - return 1; -} - - -static int db_setfenv (lua_State *L) { - luaL_checktype(L, 2, LUA_TTABLE); - lua_settop(L, 2); - if (lua_setfenv(L, 1) == 0) - luaL_error(L, LUA_QL("setfenv") - " cannot change environment of given object"); - return 1; -} - - -static void settabss (lua_State *L, const char *i, const char *v) { - lua_pushstring(L, v); - lua_setfield(L, -2, i); -} - - -static void settabsi (lua_State *L, const char *i, int v) { - lua_pushinteger(L, v); - lua_setfield(L, -2, i); -} - - -static lua_State *getthread (lua_State *L, int *arg) { - if (lua_isthread(L, 1)) { - *arg = 1; - return lua_tothread(L, 1); - } - else { - *arg = 0; - return L; - } -} - - -static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { - if (L == L1) { - lua_pushvalue(L, -2); - lua_remove(L, -3); - } - else - lua_xmove(L1, L, 1); - lua_setfield(L, -2, fname); -} - - -static int db_getinfo (lua_State *L) { - lua_Debug ar; - int arg; - lua_State *L1 = getthread(L, &arg); - const char *options = luaL_optstring(L, arg+2, "flnSu"); - if (lua_isnumber(L, arg+1)) { - if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { - lua_pushnil(L); /* level out of range */ - return 1; - } - } - else if (lua_isfunction(L, arg+1)) { - lua_pushfstring(L, ">%s", options); - options = lua_tostring(L, -1); - lua_pushvalue(L, arg+1); - lua_xmove(L, L1, 1); - } - else - return luaL_argerror(L, arg+1, "function or level expected"); - if (!lua_getinfo(L1, options, &ar)) - return luaL_argerror(L, arg+2, "invalid option"); - lua_createtable(L, 0, 2); - if (strchr(options, 'S')) { - settabss(L, "source", ar.source); - settabss(L, "short_src", ar.short_src); - settabsi(L, "linedefined", ar.linedefined); - settabsi(L, "lastlinedefined", ar.lastlinedefined); - settabss(L, "what", ar.what); - } - if (strchr(options, 'l')) - settabsi(L, "currentline", ar.currentline); - if (strchr(options, 'u')) - settabsi(L, "nups", ar.nups); - if (strchr(options, 'n')) { - settabss(L, "name", ar.name); - settabss(L, "namewhat", ar.namewhat); - } - if (strchr(options, 'L')) - treatstackoption(L, L1, "activelines"); - if (strchr(options, 'f')) - treatstackoption(L, L1, "func"); - return 1; /* return table */ -} - - -static int db_getlocal (lua_State *L) { - int arg; - lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - const char *name; - if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ - return luaL_argerror(L, arg+1, "level out of range"); - name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); - if (name) { - lua_xmove(L1, L, 1); - lua_pushstring(L, name); - lua_pushvalue(L, -2); - return 2; - } - else { - lua_pushnil(L); - return 1; - } -} - - -static int db_setlocal (lua_State *L) { - int arg; - lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ - return luaL_argerror(L, arg+1, "level out of range"); - luaL_checkany(L, arg+3); - lua_settop(L, arg+3); - lua_xmove(L, L1, 1); - lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); - return 1; -} - - -static int auxupvalue (lua_State *L, int get) { - const char *name; - int n = luaL_checkint(L, 2); - luaL_checktype(L, 1, LUA_TFUNCTION); - if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ - name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); - if (name == NULL) return 0; - lua_pushstring(L, name); - lua_insert(L, -(get+1)); - return get + 1; -} - - -static int db_getupvalue (lua_State *L) { - return auxupvalue(L, 1); -} - - -static int db_setupvalue (lua_State *L) { - luaL_checkany(L, 3); - return auxupvalue(L, 0); -} - - - -static const char KEY_HOOK = 'h'; - - -static void hookf (lua_State *L, lua_Debug *ar) { - static const char *const hooknames[] = - {"call", "return", "line", "count", "tail return"}; - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_rawget(L, LUA_REGISTRYINDEX); - lua_pushlightuserdata(L, L); - lua_rawget(L, -2); - if (lua_isfunction(L, -1)) { - lua_pushstring(L, hooknames[(int)ar->event]); - if (ar->currentline >= 0) - lua_pushinteger(L, ar->currentline); - else lua_pushnil(L); - lua_assert(lua_getinfo(L, "lS", ar)); - lua_call(L, 2, 0); - } -} - - -static int makemask (const char *smask, int count) { - int mask = 0; - if (strchr(smask, 'c')) mask |= LUA_MASKCALL; - if (strchr(smask, 'r')) mask |= LUA_MASKRET; - if (strchr(smask, 'l')) mask |= LUA_MASKLINE; - if (count > 0) mask |= LUA_MASKCOUNT; - return mask; -} - - -static char *unmakemask (int mask, char *smask) { - int i = 0; - if (mask & LUA_MASKCALL) smask[i++] = 'c'; - if (mask & LUA_MASKRET) smask[i++] = 'r'; - if (mask & LUA_MASKLINE) smask[i++] = 'l'; - smask[i] = '\0'; - return smask; -} - - -static void gethooktable (lua_State *L) { - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_rawget(L, LUA_REGISTRYINDEX); - if (!lua_istable(L, -1)) { - lua_pop(L, 1); - lua_createtable(L, 0, 1); - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_pushvalue(L, -2); - lua_rawset(L, LUA_REGISTRYINDEX); - } -} - - -static int db_sethook (lua_State *L) { - int arg, mask, count; - lua_Hook func; - lua_State *L1 = getthread(L, &arg); - if (lua_isnoneornil(L, arg+1)) { - lua_settop(L, arg+1); - func = NULL; mask = 0; count = 0; /* turn off hooks */ - } - else { - const char *smask = luaL_checkstring(L, arg+2); - luaL_checktype(L, arg+1, LUA_TFUNCTION); - count = luaL_optint(L, arg+3, 0); - func = hookf; mask = makemask(smask, count); - } - gethooktable(L); - lua_pushlightuserdata(L, L1); - lua_pushvalue(L, arg+1); - lua_rawset(L, -3); /* set new hook */ - lua_pop(L, 1); /* remove hook table */ - lua_sethook(L1, func, mask, count); /* set hooks */ - return 0; -} - - -static int db_gethook (lua_State *L) { - int arg; - lua_State *L1 = getthread(L, &arg); - char buff[5]; - int mask = lua_gethookmask(L1); - lua_Hook hook = lua_gethook(L1); - if (hook != NULL && hook != hookf) /* external hook? */ - lua_pushliteral(L, "external hook"); - else { - gethooktable(L); - lua_pushlightuserdata(L, L1); - lua_rawget(L, -2); /* get hook */ - lua_remove(L, -2); /* remove hook table */ - } - lua_pushstring(L, unmakemask(mask, buff)); - lua_pushinteger(L, lua_gethookcount(L1)); - return 3; -} - - -static int db_debug (lua_State *L) { - for (;;) { - char buffer[250]; - fputs("lua_debug> ", stderr); - if (fgets(buffer, sizeof(buffer), stdin) == 0 || - strcmp(buffer, "cont\n") == 0) - return 0; - if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || - lua_pcall(L, 0, 0, 0)) { - fputs(lua_tostring(L, -1), stderr); - fputs("\n", stderr); - } - lua_settop(L, 0); /* remove eventual returns */ - } -} - - -#define LEVELS1 12 /* size of the first part of the stack */ -#define LEVELS2 10 /* size of the second part of the stack */ - -static int db_errorfb (lua_State *L) { - int level; - int firstpart = 1; /* still before eventual `...' */ - int arg; - lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - if (lua_isnumber(L, arg+2)) { - level = (int)lua_tointeger(L, arg+2); - lua_pop(L, 1); - } - else - level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ - if (lua_gettop(L) == arg) - lua_pushliteral(L, ""); - else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ - else lua_pushliteral(L, "\n"); - lua_pushliteral(L, "stack traceback:"); - while (lua_getstack(L1, level++, &ar)) { - if (level > LEVELS1 && firstpart) { - /* no more than `LEVELS2' more levels? */ - if (!lua_getstack(L1, level+LEVELS2, &ar)) - level--; /* keep going */ - else { - lua_pushliteral(L, "\n\t..."); /* too many levels */ - while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ - level++; - } - firstpart = 0; - continue; - } - lua_pushliteral(L, "\n\t"); - lua_getinfo(L1, "Snl", &ar); - lua_pushfstring(L, "%s:", ar.short_src); - if (ar.currentline > 0) - lua_pushfstring(L, "%d:", ar.currentline); - if (*ar.namewhat != '\0') /* is there a name? */ - lua_pushfstring(L, " in function " LUA_QS, ar.name); - else { - if (*ar.what == 'm') /* main? */ - lua_pushfstring(L, " in main chunk"); - else if (*ar.what == 'C' || *ar.what == 't') - lua_pushliteral(L, " ?"); /* C function or tail call */ - else - lua_pushfstring(L, " in function <%s:%d>", - ar.short_src, ar.linedefined); - } - lua_concat(L, lua_gettop(L) - arg); - } - lua_concat(L, lua_gettop(L) - arg); - return 1; -} - - -static const luaL_Reg dblib[] = { - {"debug", db_debug}, - {"getfenv", db_getfenv}, - {"gethook", db_gethook}, - {"getinfo", db_getinfo}, - {"getlocal", db_getlocal}, - {"getregistry", db_getregistry}, - {"getmetatable", db_getmetatable}, - {"getupvalue", db_getupvalue}, - {"setfenv", db_setfenv}, - {"sethook", db_sethook}, - {"setlocal", db_setlocal}, - {"setmetatable", db_setmetatable}, - {"setupvalue", db_setupvalue}, - {"traceback", db_errorfb}, - {NULL, NULL} -}; - - -LUALIB_API int luaopen_debug (lua_State *L) { - luaL_register(L, LUA_DBLIBNAME, dblib); - return 1; -} - diff -Nru gpick-0.2.4/extern/lua/src/ldebug.c gpick-0.2.5/extern/lua/src/ldebug.c --- gpick-0.2.4/extern/lua/src/ldebug.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ldebug.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,638 +0,0 @@ -/* -** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ -** Debug Interface -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include - - -#define ldebug_c -#define LUA_CORE - -#include "lua.h" - -#include "lapi.h" -#include "lcode.h" -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lvm.h" - - - -static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); - - -static int currentpc (lua_State *L, CallInfo *ci) { - if (!isLua(ci)) return -1; /* function is not a Lua function? */ - if (ci == L->ci) - ci->savedpc = L->savedpc; - return pcRel(ci->savedpc, ci_func(ci)->l.p); -} - - -static int currentline (lua_State *L, CallInfo *ci) { - int pc = currentpc(L, ci); - if (pc < 0) - return -1; /* only active lua functions have current-line information */ - else - return getline(ci_func(ci)->l.p, pc); -} - - -/* -** this function can be called asynchronous (e.g. during a signal) -*/ -LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { - if (func == NULL || mask == 0) { /* turn off hooks? */ - mask = 0; - func = NULL; - } - L->hook = func; - L->basehookcount = count; - resethookcount(L); - L->hookmask = cast_byte(mask); - return 1; -} - - -LUA_API lua_Hook lua_gethook (lua_State *L) { - return L->hook; -} - - -LUA_API int lua_gethookmask (lua_State *L) { - return L->hookmask; -} - - -LUA_API int lua_gethookcount (lua_State *L) { - return L->basehookcount; -} - - -LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { - int status; - CallInfo *ci; - lua_lock(L); - for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { - level--; - if (f_isLua(ci)) /* Lua function? */ - level -= ci->tailcalls; /* skip lost tail calls */ - } - if (level == 0 && ci > L->base_ci) { /* level found? */ - status = 1; - ar->i_ci = cast_int(ci - L->base_ci); - } - else if (level < 0) { /* level is of a lost tail call? */ - status = 1; - ar->i_ci = 0; - } - else status = 0; /* no such level */ - lua_unlock(L); - return status; -} - - -static Proto *getluaproto (CallInfo *ci) { - return (isLua(ci) ? ci_func(ci)->l.p : NULL); -} - - -static const char *findlocal (lua_State *L, CallInfo *ci, int n) { - const char *name; - Proto *fp = getluaproto(ci); - if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) - return name; /* is a local variable in a Lua function */ - else { - StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; - if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ - return "(*temporary)"; - else - return NULL; - } -} - - -LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { - CallInfo *ci = L->base_ci + ar->i_ci; - const char *name = findlocal(L, ci, n); - lua_lock(L); - if (name) - luaA_pushobject(L, ci->base + (n - 1)); - lua_unlock(L); - return name; -} - - -LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { - CallInfo *ci = L->base_ci + ar->i_ci; - const char *name = findlocal(L, ci, n); - lua_lock(L); - if (name) - setobjs2s(L, ci->base + (n - 1), L->top - 1); - L->top--; /* pop value */ - lua_unlock(L); - return name; -} - - -static void funcinfo (lua_Debug *ar, Closure *cl) { - if (cl->c.isC) { - ar->source = "=[C]"; - ar->linedefined = -1; - ar->lastlinedefined = -1; - ar->what = "C"; - } - else { - ar->source = getstr(cl->l.p->source); - ar->linedefined = cl->l.p->linedefined; - ar->lastlinedefined = cl->l.p->lastlinedefined; - ar->what = (ar->linedefined == 0) ? "main" : "Lua"; - } - luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); -} - - -static void info_tailcall (lua_Debug *ar) { - ar->name = ar->namewhat = ""; - ar->what = "tail"; - ar->lastlinedefined = ar->linedefined = ar->currentline = -1; - ar->source = "=(tail call)"; - luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); - ar->nups = 0; -} - - -static void collectvalidlines (lua_State *L, Closure *f) { - if (f == NULL || f->c.isC) { - setnilvalue(L->top); - } - else { - Table *t = luaH_new(L, 0, 0); - int *lineinfo = f->l.p->lineinfo; - int i; - for (i=0; il.p->sizelineinfo; i++) - setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); - sethvalue(L, L->top, t); - } - incr_top(L); -} - - -static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, - Closure *f, CallInfo *ci) { - int status = 1; - if (f == NULL) { - info_tailcall(ar); - return status; - } - for (; *what; what++) { - switch (*what) { - case 'S': { - funcinfo(ar, f); - break; - } - case 'l': { - ar->currentline = (ci) ? currentline(L, ci) : -1; - break; - } - case 'u': { - ar->nups = f->c.nupvalues; - break; - } - case 'n': { - ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; - if (ar->namewhat == NULL) { - ar->namewhat = ""; /* not found */ - ar->name = NULL; - } - break; - } - case 'L': - case 'f': /* handled by lua_getinfo */ - break; - default: status = 0; /* invalid option */ - } - } - return status; -} - - -LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { - int status; - Closure *f = NULL; - CallInfo *ci = NULL; - lua_lock(L); - if (*what == '>') { - StkId func = L->top - 1; - luai_apicheck(L, ttisfunction(func)); - what++; /* skip the '>' */ - f = clvalue(func); - L->top--; /* pop function */ - } - else if (ar->i_ci != 0) { /* no tail call? */ - ci = L->base_ci + ar->i_ci; - lua_assert(ttisfunction(ci->func)); - f = clvalue(ci->func); - } - status = auxgetinfo(L, what, ar, f, ci); - if (strchr(what, 'f')) { - if (f == NULL) setnilvalue(L->top); - else setclvalue(L, L->top, f); - incr_top(L); - } - if (strchr(what, 'L')) - collectvalidlines(L, f); - lua_unlock(L); - return status; -} - - -/* -** {====================================================== -** Symbolic Execution and code checker -** ======================================================= -*/ - -#define check(x) if (!(x)) return 0; - -#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) - -#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) - - - -static int precheck (const Proto *pt) { - check(pt->maxstacksize <= MAXSTACK); - check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); - check(!(pt->is_vararg & VARARG_NEEDSARG) || - (pt->is_vararg & VARARG_HASARG)); - check(pt->sizeupvalues <= pt->nups); - check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); - check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); - return 1; -} - - -#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) - -int luaG_checkopenop (Instruction i) { - switch (GET_OPCODE(i)) { - case OP_CALL: - case OP_TAILCALL: - case OP_RETURN: - case OP_SETLIST: { - check(GETARG_B(i) == 0); - return 1; - } - default: return 0; /* invalid instruction after an open call */ - } -} - - -static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { - switch (mode) { - case OpArgN: check(r == 0); break; - case OpArgU: break; - case OpArgR: checkreg(pt, r); break; - case OpArgK: - check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); - break; - } - return 1; -} - - -static Instruction symbexec (const Proto *pt, int lastpc, int reg) { - int pc; - int last; /* stores position of last instruction that changed `reg' */ - last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ - check(precheck(pt)); - for (pc = 0; pc < lastpc; pc++) { - Instruction i = pt->code[pc]; - OpCode op = GET_OPCODE(i); - int a = GETARG_A(i); - int b = 0; - int c = 0; - check(op < NUM_OPCODES); - checkreg(pt, a); - switch (getOpMode(op)) { - case iABC: { - b = GETARG_B(i); - c = GETARG_C(i); - check(checkArgMode(pt, b, getBMode(op))); - check(checkArgMode(pt, c, getCMode(op))); - break; - } - case iABx: { - b = GETARG_Bx(i); - if (getBMode(op) == OpArgK) check(b < pt->sizek); - break; - } - case iAsBx: { - b = GETARG_sBx(i); - if (getBMode(op) == OpArgR) { - int dest = pc+1+b; - check(0 <= dest && dest < pt->sizecode); - if (dest > 0) { - int j; - /* check that it does not jump to a setlist count; this - is tricky, because the count from a previous setlist may - have the same value of an invalid setlist; so, we must - go all the way back to the first of them (if any) */ - for (j = 0; j < dest; j++) { - Instruction d = pt->code[dest-1-j]; - if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; - } - /* if 'j' is even, previous value is not a setlist (even if - it looks like one) */ - check((j&1) == 0); - } - } - break; - } - } - if (testAMode(op)) { - if (a == reg) last = pc; /* change register `a' */ - } - if (testTMode(op)) { - check(pc+2 < pt->sizecode); /* check skip */ - check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); - } - switch (op) { - case OP_LOADBOOL: { - if (c == 1) { /* does it jump? */ - check(pc+2 < pt->sizecode); /* check its jump */ - check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || - GETARG_C(pt->code[pc+1]) != 0); - } - break; - } - case OP_LOADNIL: { - if (a <= reg && reg <= b) - last = pc; /* set registers from `a' to `b' */ - break; - } - case OP_GETUPVAL: - case OP_SETUPVAL: { - check(b < pt->nups); - break; - } - case OP_GETGLOBAL: - case OP_SETGLOBAL: { - check(ttisstring(&pt->k[b])); - break; - } - case OP_SELF: { - checkreg(pt, a+1); - if (reg == a+1) last = pc; - break; - } - case OP_CONCAT: { - check(b < c); /* at least two operands */ - break; - } - case OP_TFORLOOP: { - check(c >= 1); /* at least one result (control variable) */ - checkreg(pt, a+2+c); /* space for results */ - if (reg >= a+2) last = pc; /* affect all regs above its base */ - break; - } - case OP_FORLOOP: - case OP_FORPREP: - checkreg(pt, a+3); - /* go through */ - case OP_JMP: { - int dest = pc+1+b; - /* not full check and jump is forward and do not skip `lastpc'? */ - if (reg != NO_REG && pc < dest && dest <= lastpc) - pc += b; /* do the jump */ - break; - } - case OP_CALL: - case OP_TAILCALL: { - if (b != 0) { - checkreg(pt, a+b-1); - } - c--; /* c = num. returns */ - if (c == LUA_MULTRET) { - check(checkopenop(pt, pc)); - } - else if (c != 0) - checkreg(pt, a+c-1); - if (reg >= a) last = pc; /* affect all registers above base */ - break; - } - case OP_RETURN: { - b--; /* b = num. returns */ - if (b > 0) checkreg(pt, a+b-1); - break; - } - case OP_SETLIST: { - if (b > 0) checkreg(pt, a + b); - if (c == 0) { - pc++; - check(pc < pt->sizecode - 1); - } - break; - } - case OP_CLOSURE: { - int nup, j; - check(b < pt->sizep); - nup = pt->p[b]->nups; - check(pc + nup < pt->sizecode); - for (j = 1; j <= nup; j++) { - OpCode op1 = GET_OPCODE(pt->code[pc + j]); - check(op1 == OP_GETUPVAL || op1 == OP_MOVE); - } - if (reg != NO_REG) /* tracing? */ - pc += nup; /* do not 'execute' these pseudo-instructions */ - break; - } - case OP_VARARG: { - check((pt->is_vararg & VARARG_ISVARARG) && - !(pt->is_vararg & VARARG_NEEDSARG)); - b--; - if (b == LUA_MULTRET) check(checkopenop(pt, pc)); - checkreg(pt, a+b-1); - break; - } - default: break; - } - } - return pt->code[last]; -} - -#undef check -#undef checkjump -#undef checkreg - -/* }====================================================== */ - - -int luaG_checkcode (const Proto *pt) { - return (symbexec(pt, pt->sizecode, NO_REG) != 0); -} - - -static const char *kname (Proto *p, int c) { - if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) - return svalue(&p->k[INDEXK(c)]); - else - return "?"; -} - - -static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, - const char **name) { - if (isLua(ci)) { /* a Lua function? */ - Proto *p = ci_func(ci)->l.p; - int pc = currentpc(L, ci); - Instruction i; - *name = luaF_getlocalname(p, stackpos+1, pc); - if (*name) /* is a local? */ - return "local"; - i = symbexec(p, pc, stackpos); /* try symbolic execution */ - lua_assert(pc != -1); - switch (GET_OPCODE(i)) { - case OP_GETGLOBAL: { - int g = GETARG_Bx(i); /* global index */ - lua_assert(ttisstring(&p->k[g])); - *name = svalue(&p->k[g]); - return "global"; - } - case OP_MOVE: { - int a = GETARG_A(i); - int b = GETARG_B(i); /* move from `b' to `a' */ - if (b < a) - return getobjname(L, ci, b, name); /* get name for `b' */ - break; - } - case OP_GETTABLE: { - int k = GETARG_C(i); /* key index */ - *name = kname(p, k); - return "field"; - } - case OP_GETUPVAL: { - int u = GETARG_B(i); /* upvalue index */ - *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; - return "upvalue"; - } - case OP_SELF: { - int k = GETARG_C(i); /* key index */ - *name = kname(p, k); - return "method"; - } - default: break; - } - } - return NULL; /* no useful name found */ -} - - -static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { - Instruction i; - if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) - return NULL; /* calling function is not Lua (or is unknown) */ - ci--; /* calling function */ - i = ci_func(ci)->l.p->code[currentpc(L, ci)]; - if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || - GET_OPCODE(i) == OP_TFORLOOP) - return getobjname(L, ci, GETARG_A(i), name); - else - return NULL; /* no useful name can be found */ -} - - -/* only ANSI way to check whether a pointer points to an array */ -static int isinstack (CallInfo *ci, const TValue *o) { - StkId p; - for (p = ci->base; p < ci->top; p++) - if (o == p) return 1; - return 0; -} - - -void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { - const char *name = NULL; - const char *t = luaT_typenames[ttype(o)]; - const char *kind = (isinstack(L->ci, o)) ? - getobjname(L, L->ci, cast_int(o - L->base), &name) : - NULL; - if (kind) - luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", - op, kind, name, t); - else - luaG_runerror(L, "attempt to %s a %s value", op, t); -} - - -void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { - if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; - lua_assert(!ttisstring(p1) && !ttisnumber(p1)); - luaG_typeerror(L, p1, "concatenate"); -} - - -void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { - TValue temp; - if (luaV_tonumber(p1, &temp) == NULL) - p2 = p1; /* first operand is wrong */ - luaG_typeerror(L, p2, "perform arithmetic on"); -} - - -int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { - const char *t1 = luaT_typenames[ttype(p1)]; - const char *t2 = luaT_typenames[ttype(p2)]; - if (t1[2] == t2[2]) - luaG_runerror(L, "attempt to compare two %s values", t1); - else - luaG_runerror(L, "attempt to compare %s with %s", t1, t2); - return 0; -} - - -static void addinfo (lua_State *L, const char *msg) { - CallInfo *ci = L->ci; - if (isLua(ci)) { /* is Lua code? */ - char buff[LUA_IDSIZE]; /* add file:line information */ - int line = currentline(L, ci); - luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); - luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); - } -} - - -void luaG_errormsg (lua_State *L) { - if (L->errfunc != 0) { /* is there an error handling function? */ - StkId errfunc = restorestack(L, L->errfunc); - if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); - setobjs2s(L, L->top, L->top - 1); /* move argument */ - setobjs2s(L, L->top - 1, errfunc); /* push function */ - incr_top(L); - luaD_call(L, L->top - 2, 1); /* call it */ - } - luaD_throw(L, LUA_ERRRUN); -} - - -void luaG_runerror (lua_State *L, const char *fmt, ...) { - va_list argp; - va_start(argp, fmt); - addinfo(L, luaO_pushvfstring(L, fmt, argp)); - va_end(argp); - luaG_errormsg(L); -} - diff -Nru gpick-0.2.4/extern/lua/src/ldebug.h gpick-0.2.5/extern/lua/src/ldebug.h --- gpick-0.2.4/extern/lua/src/ldebug.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ldebug.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* -** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ -** Auxiliary functions from Debug Interface module -** See Copyright Notice in lua.h -*/ - -#ifndef ldebug_h -#define ldebug_h - - -#include "lstate.h" - - -#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) - -#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) - -#define resethookcount(L) (L->hookcount = L->basehookcount) - - -LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, - const char *opname); -LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); -LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); -LUAI_FUNC void luaG_errormsg (lua_State *L); -LUAI_FUNC int luaG_checkcode (const Proto *pt); -LUAI_FUNC int luaG_checkopenop (Instruction i); - -#endif diff -Nru gpick-0.2.4/extern/lua/src/ldo.c gpick-0.2.5/extern/lua/src/ldo.c --- gpick-0.2.4/extern/lua/src/ldo.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ldo.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,518 +0,0 @@ -/* -** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ -** Stack and Call structure of Lua -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include - -#define ldo_c -#define LUA_CORE - -#include "lua.h" - -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lundump.h" -#include "lvm.h" -#include "lzio.h" - - - - -/* -** {====================================================== -** Error-recovery functions -** ======================================================= -*/ - - -/* chain list of long jump buffers */ -struct lua_longjmp { - struct lua_longjmp *previous; - luai_jmpbuf b; - volatile int status; /* error code */ -}; - - -void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { - switch (errcode) { - case LUA_ERRMEM: { - setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); - break; - } - case LUA_ERRERR: { - setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); - break; - } - case LUA_ERRSYNTAX: - case LUA_ERRRUN: { - setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ - break; - } - } - L->top = oldtop + 1; -} - - -static void restore_stack_limit (lua_State *L) { - lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); - if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ - int inuse = cast_int(L->ci - L->base_ci); - if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ - luaD_reallocCI(L, LUAI_MAXCALLS); - } -} - - -static void resetstack (lua_State *L, int status) { - L->ci = L->base_ci; - L->base = L->ci->base; - luaF_close(L, L->base); /* close eventual pending closures */ - luaD_seterrorobj(L, status, L->base); - L->nCcalls = L->baseCcalls; - L->allowhook = 1; - restore_stack_limit(L); - L->errfunc = 0; - L->errorJmp = NULL; -} - - -void luaD_throw (lua_State *L, int errcode) { - if (L->errorJmp) { - L->errorJmp->status = errcode; - LUAI_THROW(L, L->errorJmp); - } - else { - L->status = cast_byte(errcode); - if (G(L)->panic) { - resetstack(L, errcode); - lua_unlock(L); - G(L)->panic(L); - } - exit(EXIT_FAILURE); - } -} - - -int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { - struct lua_longjmp lj; - lj.status = 0; - lj.previous = L->errorJmp; /* chain new error handler */ - L->errorJmp = &lj; - LUAI_TRY(L, &lj, - (*f)(L, ud); - ); - L->errorJmp = lj.previous; /* restore old error handler */ - return lj.status; -} - -/* }====================================================== */ - - -static void correctstack (lua_State *L, TValue *oldstack) { - CallInfo *ci; - GCObject *up; - L->top = (L->top - oldstack) + L->stack; - for (up = L->openupval; up != NULL; up = up->gch.next) - gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; - for (ci = L->base_ci; ci <= L->ci; ci++) { - ci->top = (ci->top - oldstack) + L->stack; - ci->base = (ci->base - oldstack) + L->stack; - ci->func = (ci->func - oldstack) + L->stack; - } - L->base = (L->base - oldstack) + L->stack; -} - - -void luaD_reallocstack (lua_State *L, int newsize) { - TValue *oldstack = L->stack; - int realsize = newsize + 1 + EXTRA_STACK; - lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); - luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); - L->stacksize = realsize; - L->stack_last = L->stack+newsize; - correctstack(L, oldstack); -} - - -void luaD_reallocCI (lua_State *L, int newsize) { - CallInfo *oldci = L->base_ci; - luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); - L->size_ci = newsize; - L->ci = (L->ci - oldci) + L->base_ci; - L->end_ci = L->base_ci + L->size_ci - 1; -} - - -void luaD_growstack (lua_State *L, int n) { - if (n <= L->stacksize) /* double size is enough? */ - luaD_reallocstack(L, 2*L->stacksize); - else - luaD_reallocstack(L, L->stacksize + n); -} - - -static CallInfo *growCI (lua_State *L) { - if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ - luaD_throw(L, LUA_ERRERR); - else { - luaD_reallocCI(L, 2*L->size_ci); - if (L->size_ci > LUAI_MAXCALLS) - luaG_runerror(L, "stack overflow"); - } - return ++L->ci; -} - - -void luaD_callhook (lua_State *L, int event, int line) { - lua_Hook hook = L->hook; - if (hook && L->allowhook) { - ptrdiff_t top = savestack(L, L->top); - ptrdiff_t ci_top = savestack(L, L->ci->top); - lua_Debug ar; - ar.event = event; - ar.currentline = line; - if (event == LUA_HOOKTAILRET) - ar.i_ci = 0; /* tail call; no debug information about it */ - else - ar.i_ci = cast_int(L->ci - L->base_ci); - luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - L->ci->top = L->top + LUA_MINSTACK; - lua_assert(L->ci->top <= L->stack_last); - L->allowhook = 0; /* cannot call hooks inside a hook */ - lua_unlock(L); - (*hook)(L, &ar); - lua_lock(L); - lua_assert(!L->allowhook); - L->allowhook = 1; - L->ci->top = restorestack(L, ci_top); - L->top = restorestack(L, top); - } -} - - -static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { - int i; - int nfixargs = p->numparams; - Table *htab = NULL; - StkId base, fixed; - for (; actual < nfixargs; ++actual) - setnilvalue(L->top++); -#if defined(LUA_COMPAT_VARARG) - if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ - int nvar = actual - nfixargs; /* number of extra arguments */ - lua_assert(p->is_vararg & VARARG_HASARG); - luaC_checkGC(L); - htab = luaH_new(L, nvar, 1); /* create `arg' table */ - for (i=0; itop - nvar + i); - /* store counter in field `n' */ - setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); - } -#endif - /* move fixed parameters to final position */ - fixed = L->top - actual; /* first fixed argument */ - base = L->top; /* final position of first argument */ - for (i=0; itop++, fixed+i); - setnilvalue(fixed+i); - } - /* add `arg' parameter */ - if (htab) { - sethvalue(L, L->top++, htab); - lua_assert(iswhite(obj2gco(htab))); - } - return base; -} - - -static StkId tryfuncTM (lua_State *L, StkId func) { - const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); - StkId p; - ptrdiff_t funcr = savestack(L, func); - if (!ttisfunction(tm)) - luaG_typeerror(L, func, "call"); - /* Open a hole inside the stack at `func' */ - for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); - incr_top(L); - func = restorestack(L, funcr); /* previous call may change stack */ - setobj2s(L, func, tm); /* tag method is the new function to be called */ - return func; -} - - - -#define inc_ci(L) \ - ((L->ci == L->end_ci) ? growCI(L) : \ - (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) - - -int luaD_precall (lua_State *L, StkId func, int nresults) { - LClosure *cl; - ptrdiff_t funcr; - if (!ttisfunction(func)) /* `func' is not a function? */ - func = tryfuncTM(L, func); /* check the `function' tag method */ - funcr = savestack(L, func); - cl = &clvalue(func)->l; - L->ci->savedpc = L->savedpc; - if (!cl->isC) { /* Lua function? prepare its call */ - CallInfo *ci; - StkId st, base; - Proto *p = cl->p; - luaD_checkstack(L, p->maxstacksize); - func = restorestack(L, funcr); - if (!p->is_vararg) { /* no varargs? */ - base = func + 1; - if (L->top > base + p->numparams) - L->top = base + p->numparams; - } - else { /* vararg function */ - int nargs = cast_int(L->top - func) - 1; - base = adjust_varargs(L, p, nargs); - func = restorestack(L, funcr); /* previous call may change the stack */ - } - ci = inc_ci(L); /* now `enter' new function */ - ci->func = func; - L->base = ci->base = base; - ci->top = L->base + p->maxstacksize; - lua_assert(ci->top <= L->stack_last); - L->savedpc = p->code; /* starting point */ - ci->tailcalls = 0; - ci->nresults = nresults; - for (st = L->top; st < ci->top; st++) - setnilvalue(st); - L->top = ci->top; - if (L->hookmask & LUA_MASKCALL) { - L->savedpc++; /* hooks assume 'pc' is already incremented */ - luaD_callhook(L, LUA_HOOKCALL, -1); - L->savedpc--; /* correct 'pc' */ - } - return PCRLUA; - } - else { /* if is a C function, call it */ - CallInfo *ci; - int n; - luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - ci = inc_ci(L); /* now `enter' new function */ - ci->func = restorestack(L, funcr); - L->base = ci->base = ci->func + 1; - ci->top = L->top + LUA_MINSTACK; - lua_assert(ci->top <= L->stack_last); - ci->nresults = nresults; - if (L->hookmask & LUA_MASKCALL) - luaD_callhook(L, LUA_HOOKCALL, -1); - lua_unlock(L); - n = (*curr_func(L)->c.f)(L); /* do the actual call */ - lua_lock(L); - if (n < 0) /* yielding? */ - return PCRYIELD; - else { - luaD_poscall(L, L->top - n); - return PCRC; - } - } -} - - -static StkId callrethooks (lua_State *L, StkId firstResult) { - ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ - luaD_callhook(L, LUA_HOOKRET, -1); - if (f_isLua(L->ci)) { /* Lua function? */ - while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ - luaD_callhook(L, LUA_HOOKTAILRET, -1); - } - return restorestack(L, fr); -} - - -int luaD_poscall (lua_State *L, StkId firstResult) { - StkId res; - int wanted, i; - CallInfo *ci; - if (L->hookmask & LUA_MASKRET) - firstResult = callrethooks(L, firstResult); - ci = L->ci--; - res = ci->func; /* res == final position of 1st result */ - wanted = ci->nresults; - L->base = (ci - 1)->base; /* restore base */ - L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ - /* move results to correct place */ - for (i = wanted; i != 0 && firstResult < L->top; i--) - setobjs2s(L, res++, firstResult++); - while (i-- > 0) - setnilvalue(res++); - L->top = res; - return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ -} - - -/* -** Call a function (C or Lua). The function to be called is at *func. -** The arguments are on the stack, right after the function. -** When returns, all the results are on the stack, starting at the original -** function position. -*/ -void luaD_call (lua_State *L, StkId func, int nResults) { - if (++L->nCcalls >= LUAI_MAXCCALLS) { - if (L->nCcalls == LUAI_MAXCCALLS) - luaG_runerror(L, "C stack overflow"); - else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) - luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ - } - if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ - luaV_execute(L, 1); /* call it */ - L->nCcalls--; - luaC_checkGC(L); -} - - -static void resume (lua_State *L, void *ud) { - StkId firstArg = cast(StkId, ud); - CallInfo *ci = L->ci; - if (L->status == 0) { /* start coroutine? */ - lua_assert(ci == L->base_ci && firstArg > L->base); - if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) - return; - } - else { /* resuming from previous yield */ - lua_assert(L->status == LUA_YIELD); - L->status = 0; - if (!f_isLua(ci)) { /* `common' yield? */ - /* finish interrupted execution of `OP_CALL' */ - lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || - GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); - if (luaD_poscall(L, firstArg)) /* complete it... */ - L->top = L->ci->top; /* and correct top if not multiple results */ - } - else /* yielded inside a hook: just continue its execution */ - L->base = L->ci->base; - } - luaV_execute(L, cast_int(L->ci - L->base_ci)); -} - - -static int resume_error (lua_State *L, const char *msg) { - L->top = L->ci->base; - setsvalue2s(L, L->top, luaS_new(L, msg)); - incr_top(L); - lua_unlock(L); - return LUA_ERRRUN; -} - - -LUA_API int lua_resume (lua_State *L, int nargs) { - int status; - lua_lock(L); - if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) - return resume_error(L, "cannot resume non-suspended coroutine"); - if (L->nCcalls >= LUAI_MAXCCALLS) - return resume_error(L, "C stack overflow"); - luai_userstateresume(L, nargs); - lua_assert(L->errfunc == 0); - L->baseCcalls = ++L->nCcalls; - status = luaD_rawrunprotected(L, resume, L->top - nargs); - if (status != 0) { /* error? */ - L->status = cast_byte(status); /* mark thread as `dead' */ - luaD_seterrorobj(L, status, L->top); - L->ci->top = L->top; - } - else { - lua_assert(L->nCcalls == L->baseCcalls); - status = L->status; - } - --L->nCcalls; - lua_unlock(L); - return status; -} - - -LUA_API int lua_yield (lua_State *L, int nresults) { - luai_userstateyield(L, nresults); - lua_lock(L); - if (L->nCcalls > L->baseCcalls) - luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); - L->base = L->top - nresults; /* protect stack slots below */ - L->status = LUA_YIELD; - lua_unlock(L); - return -1; -} - - -int luaD_pcall (lua_State *L, Pfunc func, void *u, - ptrdiff_t old_top, ptrdiff_t ef) { - int status; - unsigned short oldnCcalls = L->nCcalls; - ptrdiff_t old_ci = saveci(L, L->ci); - lu_byte old_allowhooks = L->allowhook; - ptrdiff_t old_errfunc = L->errfunc; - L->errfunc = ef; - status = luaD_rawrunprotected(L, func, u); - if (status != 0) { /* an error occurred? */ - StkId oldtop = restorestack(L, old_top); - luaF_close(L, oldtop); /* close eventual pending closures */ - luaD_seterrorobj(L, status, oldtop); - L->nCcalls = oldnCcalls; - L->ci = restoreci(L, old_ci); - L->base = L->ci->base; - L->savedpc = L->ci->savedpc; - L->allowhook = old_allowhooks; - restore_stack_limit(L); - } - L->errfunc = old_errfunc; - return status; -} - - - -/* -** Execute a protected parser. -*/ -struct SParser { /* data to `f_parser' */ - ZIO *z; - Mbuffer buff; /* buffer to be used by the scanner */ - const char *name; -}; - -static void f_parser (lua_State *L, void *ud) { - int i; - Proto *tf; - Closure *cl; - struct SParser *p = cast(struct SParser *, ud); - int c = luaZ_lookahead(p->z); - luaC_checkGC(L); - tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, - &p->buff, p->name); - cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); - cl->l.p = tf; - for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ - cl->l.upvals[i] = luaF_newupval(L); - setclvalue(L, L->top, cl); - incr_top(L); -} - - -int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { - struct SParser p; - int status; - p.z = z; p.name = name; - luaZ_initbuffer(L, &p.buff); - status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); - luaZ_freebuffer(L, &p.buff); - return status; -} - - diff -Nru gpick-0.2.4/extern/lua/src/ldo.h gpick-0.2.5/extern/lua/src/ldo.h --- gpick-0.2.4/extern/lua/src/ldo.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ldo.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* -** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ -** Stack and Call structure of Lua -** See Copyright Notice in lua.h -*/ - -#ifndef ldo_h -#define ldo_h - - -#include "lobject.h" -#include "lstate.h" -#include "lzio.h" - - -#define luaD_checkstack(L,n) \ - if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ - luaD_growstack(L, n); \ - else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); - - -#define incr_top(L) {luaD_checkstack(L,1); L->top++;} - -#define savestack(L,p) ((char *)(p) - (char *)L->stack) -#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) - -#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) -#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) - - -/* results from luaD_precall */ -#define PCRLUA 0 /* initiated a call to a Lua function */ -#define PCRC 1 /* did a call to a C function */ -#define PCRYIELD 2 /* C funtion yielded */ - - -/* type of protected functions, to be ran by `runprotected' */ -typedef void (*Pfunc) (lua_State *L, void *ud); - -LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); -LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); -LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); -LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); -LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, - ptrdiff_t oldtop, ptrdiff_t ef); -LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); -LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); -LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); -LUAI_FUNC void luaD_growstack (lua_State *L, int n); - -LUAI_FUNC void luaD_throw (lua_State *L, int errcode); -LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); - -LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); - -#endif - diff -Nru gpick-0.2.4/extern/lua/src/ldump.c gpick-0.2.5/extern/lua/src/ldump.c --- gpick-0.2.4/extern/lua/src/ldump.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ldump.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ -/* -** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ -** save precompiled Lua chunks -** See Copyright Notice in lua.h -*/ - -#include - -#define ldump_c -#define LUA_CORE - -#include "lua.h" - -#include "lobject.h" -#include "lstate.h" -#include "lundump.h" - -typedef struct { - lua_State* L; - lua_Writer writer; - void* data; - int strip; - int status; -} DumpState; - -#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) -#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) - -static void DumpBlock(const void* b, size_t size, DumpState* D) -{ - if (D->status==0) - { - lua_unlock(D->L); - D->status=(*D->writer)(D->L,b,size,D->data); - lua_lock(D->L); - } -} - -static void DumpChar(int y, DumpState* D) -{ - char x=(char)y; - DumpVar(x,D); -} - -static void DumpInt(int x, DumpState* D) -{ - DumpVar(x,D); -} - -static void DumpNumber(lua_Number x, DumpState* D) -{ - DumpVar(x,D); -} - -static void DumpVector(const void* b, int n, size_t size, DumpState* D) -{ - DumpInt(n,D); - DumpMem(b,n,size,D); -} - -static void DumpString(const TString* s, DumpState* D) -{ - if (s==NULL || getstr(s)==NULL) - { - size_t size=0; - DumpVar(size,D); - } - else - { - size_t size=s->tsv.len+1; /* include trailing '\0' */ - DumpVar(size,D); - DumpBlock(getstr(s),size,D); - } -} - -#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) - -static void DumpFunction(const Proto* f, const TString* p, DumpState* D); - -static void DumpConstants(const Proto* f, DumpState* D) -{ - int i,n=f->sizek; - DumpInt(n,D); - for (i=0; ik[i]; - DumpChar(ttype(o),D); - switch (ttype(o)) - { - case LUA_TNIL: - break; - case LUA_TBOOLEAN: - DumpChar(bvalue(o),D); - break; - case LUA_TNUMBER: - DumpNumber(nvalue(o),D); - break; - case LUA_TSTRING: - DumpString(rawtsvalue(o),D); - break; - default: - lua_assert(0); /* cannot happen */ - break; - } - } - n=f->sizep; - DumpInt(n,D); - for (i=0; ip[i],f->source,D); -} - -static void DumpDebug(const Proto* f, DumpState* D) -{ - int i,n; - n= (D->strip) ? 0 : f->sizelineinfo; - DumpVector(f->lineinfo,n,sizeof(int),D); - n= (D->strip) ? 0 : f->sizelocvars; - DumpInt(n,D); - for (i=0; ilocvars[i].varname,D); - DumpInt(f->locvars[i].startpc,D); - DumpInt(f->locvars[i].endpc,D); - } - n= (D->strip) ? 0 : f->sizeupvalues; - DumpInt(n,D); - for (i=0; iupvalues[i],D); -} - -static void DumpFunction(const Proto* f, const TString* p, DumpState* D) -{ - DumpString((f->source==p || D->strip) ? NULL : f->source,D); - DumpInt(f->linedefined,D); - DumpInt(f->lastlinedefined,D); - DumpChar(f->nups,D); - DumpChar(f->numparams,D); - DumpChar(f->is_vararg,D); - DumpChar(f->maxstacksize,D); - DumpCode(f,D); - DumpConstants(f,D); - DumpDebug(f,D); -} - -static void DumpHeader(DumpState* D) -{ - char h[LUAC_HEADERSIZE]; - luaU_header(h); - DumpBlock(h,LUAC_HEADERSIZE,D); -} - -/* -** dump Lua function as precompiled chunk -*/ -int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) -{ - DumpState D; - D.L=L; - D.writer=w; - D.data=data; - D.strip=strip; - D.status=0; - DumpHeader(&D); - DumpFunction(f,NULL,&D); - return D.status; -} diff -Nru gpick-0.2.4/extern/lua/src/lfunc.c gpick-0.2.5/extern/lua/src/lfunc.c --- gpick-0.2.4/extern/lua/src/lfunc.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lfunc.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ -/* -** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ -** Auxiliary functions to manipulate prototypes and closures -** See Copyright Notice in lua.h -*/ - - -#include - -#define lfunc_c -#define LUA_CORE - -#include "lua.h" - -#include "lfunc.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" - - - -Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { - Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); - luaC_link(L, obj2gco(c), LUA_TFUNCTION); - c->c.isC = 1; - c->c.env = e; - c->c.nupvalues = cast_byte(nelems); - return c; -} - - -Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { - Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); - luaC_link(L, obj2gco(c), LUA_TFUNCTION); - c->l.isC = 0; - c->l.env = e; - c->l.nupvalues = cast_byte(nelems); - while (nelems--) c->l.upvals[nelems] = NULL; - return c; -} - - -UpVal *luaF_newupval (lua_State *L) { - UpVal *uv = luaM_new(L, UpVal); - luaC_link(L, obj2gco(uv), LUA_TUPVAL); - uv->v = &uv->u.value; - setnilvalue(uv->v); - return uv; -} - - -UpVal *luaF_findupval (lua_State *L, StkId level) { - global_State *g = G(L); - GCObject **pp = &L->openupval; - UpVal *p; - UpVal *uv; - while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { - lua_assert(p->v != &p->u.value); - if (p->v == level) { /* found a corresponding upvalue? */ - if (isdead(g, obj2gco(p))) /* is it dead? */ - changewhite(obj2gco(p)); /* ressurect it */ - return p; - } - pp = &p->next; - } - uv = luaM_new(L, UpVal); /* not found: create a new one */ - uv->tt = LUA_TUPVAL; - uv->marked = luaC_white(g); - uv->v = level; /* current value lives in the stack */ - uv->next = *pp; /* chain it in the proper position */ - *pp = obj2gco(uv); - uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ - uv->u.l.next = g->uvhead.u.l.next; - uv->u.l.next->u.l.prev = uv; - g->uvhead.u.l.next = uv; - lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); - return uv; -} - - -static void unlinkupval (UpVal *uv) { - lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); - uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ - uv->u.l.prev->u.l.next = uv->u.l.next; -} - - -void luaF_freeupval (lua_State *L, UpVal *uv) { - if (uv->v != &uv->u.value) /* is it open? */ - unlinkupval(uv); /* remove from open list */ - luaM_free(L, uv); /* free upvalue */ -} - - -void luaF_close (lua_State *L, StkId level) { - UpVal *uv; - global_State *g = G(L); - while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { - GCObject *o = obj2gco(uv); - lua_assert(!isblack(o) && uv->v != &uv->u.value); - L->openupval = uv->next; /* remove from `open' list */ - if (isdead(g, o)) - luaF_freeupval(L, uv); /* free upvalue */ - else { - unlinkupval(uv); - setobj(L, &uv->u.value, uv->v); - uv->v = &uv->u.value; /* now current value lives here */ - luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ - } - } -} - - -Proto *luaF_newproto (lua_State *L) { - Proto *f = luaM_new(L, Proto); - luaC_link(L, obj2gco(f), LUA_TPROTO); - f->k = NULL; - f->sizek = 0; - f->p = NULL; - f->sizep = 0; - f->code = NULL; - f->sizecode = 0; - f->sizelineinfo = 0; - f->sizeupvalues = 0; - f->nups = 0; - f->upvalues = NULL; - f->numparams = 0; - f->is_vararg = 0; - f->maxstacksize = 0; - f->lineinfo = NULL; - f->sizelocvars = 0; - f->locvars = NULL; - f->linedefined = 0; - f->lastlinedefined = 0; - f->source = NULL; - return f; -} - - -void luaF_freeproto (lua_State *L, Proto *f) { - luaM_freearray(L, f->code, f->sizecode, Instruction); - luaM_freearray(L, f->p, f->sizep, Proto *); - luaM_freearray(L, f->k, f->sizek, TValue); - luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); - luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); - luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); - luaM_free(L, f); -} - - -void luaF_freeclosure (lua_State *L, Closure *c) { - int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : - sizeLclosure(c->l.nupvalues); - luaM_freemem(L, c, size); -} - - -/* -** Look for n-th local variable at line `line' in function `func'. -** Returns NULL if not found. -*/ -const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { - int i; - for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { - if (pc < f->locvars[i].endpc) { /* is variable active? */ - local_number--; - if (local_number == 0) - return getstr(f->locvars[i].varname); - } - } - return NULL; /* not found */ -} - diff -Nru gpick-0.2.4/extern/lua/src/lfunc.h gpick-0.2.5/extern/lua/src/lfunc.h --- gpick-0.2.4/extern/lua/src/lfunc.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lfunc.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ -** Auxiliary functions to manipulate prototypes and closures -** See Copyright Notice in lua.h -*/ - -#ifndef lfunc_h -#define lfunc_h - - -#include "lobject.h" - - -#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ - cast(int, sizeof(TValue)*((n)-1))) - -#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ - cast(int, sizeof(TValue *)*((n)-1))) - - -LUAI_FUNC Proto *luaF_newproto (lua_State *L); -LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); -LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); -LUAI_FUNC UpVal *luaF_newupval (lua_State *L); -LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); -LUAI_FUNC void luaF_close (lua_State *L, StkId level); -LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); -LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); -LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); -LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, - int pc); - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lgc.c gpick-0.2.5/extern/lua/src/lgc.c --- gpick-0.2.4/extern/lua/src/lgc.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lgc.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,711 +0,0 @@ -/* -** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ -** Garbage Collector -** See Copyright Notice in lua.h -*/ - -#include - -#define lgc_c -#define LUA_CORE - -#include "lua.h" - -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" - - -#define GCSTEPSIZE 1024u -#define GCSWEEPMAX 40 -#define GCSWEEPCOST 10 -#define GCFINALIZECOST 100 - - -#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) - -#define makewhite(g,x) \ - ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) - -#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) -#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) - -#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) - - -#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) -#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) - - -#define KEYWEAK bitmask(KEYWEAKBIT) -#define VALUEWEAK bitmask(VALUEWEAKBIT) - - - -#define markvalue(g,o) { checkconsistency(o); \ - if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } - -#define markobject(g,t) { if (iswhite(obj2gco(t))) \ - reallymarkobject(g, obj2gco(t)); } - - -#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) - - -static void removeentry (Node *n) { - lua_assert(ttisnil(gval(n))); - if (iscollectable(gkey(n))) - setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ -} - - -static void reallymarkobject (global_State *g, GCObject *o) { - lua_assert(iswhite(o) && !isdead(g, o)); - white2gray(o); - switch (o->gch.tt) { - case LUA_TSTRING: { - return; - } - case LUA_TUSERDATA: { - Table *mt = gco2u(o)->metatable; - gray2black(o); /* udata are never gray */ - if (mt) markobject(g, mt); - markobject(g, gco2u(o)->env); - return; - } - case LUA_TUPVAL: { - UpVal *uv = gco2uv(o); - markvalue(g, uv->v); - if (uv->v == &uv->u.value) /* closed? */ - gray2black(o); /* open upvalues are never black */ - return; - } - case LUA_TFUNCTION: { - gco2cl(o)->c.gclist = g->gray; - g->gray = o; - break; - } - case LUA_TTABLE: { - gco2h(o)->gclist = g->gray; - g->gray = o; - break; - } - case LUA_TTHREAD: { - gco2th(o)->gclist = g->gray; - g->gray = o; - break; - } - case LUA_TPROTO: { - gco2p(o)->gclist = g->gray; - g->gray = o; - break; - } - default: lua_assert(0); - } -} - - -static void marktmu (global_State *g) { - GCObject *u = g->tmudata; - if (u) { - do { - u = u->gch.next; - makewhite(g, u); /* may be marked, if left from previous GC */ - reallymarkobject(g, u); - } while (u != g->tmudata); - } -} - - -/* move `dead' udata that need finalization to list `tmudata' */ -size_t luaC_separateudata (lua_State *L, int all) { - global_State *g = G(L); - size_t deadmem = 0; - GCObject **p = &g->mainthread->next; - GCObject *curr; - while ((curr = *p) != NULL) { - if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) - p = &curr->gch.next; /* don't bother with them */ - else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { - markfinalized(gco2u(curr)); /* don't need finalization */ - p = &curr->gch.next; - } - else { /* must call its gc method */ - deadmem += sizeudata(gco2u(curr)); - markfinalized(gco2u(curr)); - *p = curr->gch.next; - /* link `curr' at the end of `tmudata' list */ - if (g->tmudata == NULL) /* list is empty? */ - g->tmudata = curr->gch.next = curr; /* creates a circular list */ - else { - curr->gch.next = g->tmudata->gch.next; - g->tmudata->gch.next = curr; - g->tmudata = curr; - } - } - } - return deadmem; -} - - -static int traversetable (global_State *g, Table *h) { - int i; - int weakkey = 0; - int weakvalue = 0; - const TValue *mode; - if (h->metatable) - markobject(g, h->metatable); - mode = gfasttm(g, h->metatable, TM_MODE); - if (mode && ttisstring(mode)) { /* is there a weak mode? */ - weakkey = (strchr(svalue(mode), 'k') != NULL); - weakvalue = (strchr(svalue(mode), 'v') != NULL); - if (weakkey || weakvalue) { /* is really weak? */ - h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ - h->marked |= cast_byte((weakkey << KEYWEAKBIT) | - (weakvalue << VALUEWEAKBIT)); - h->gclist = g->weak; /* must be cleared after GC, ... */ - g->weak = obj2gco(h); /* ... so put in the appropriate list */ - } - } - if (weakkey && weakvalue) return 1; - if (!weakvalue) { - i = h->sizearray; - while (i--) - markvalue(g, &h->array[i]); - } - i = sizenode(h); - while (i--) { - Node *n = gnode(h, i); - lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); - if (ttisnil(gval(n))) - removeentry(n); /* remove empty entries */ - else { - lua_assert(!ttisnil(gkey(n))); - if (!weakkey) markvalue(g, gkey(n)); - if (!weakvalue) markvalue(g, gval(n)); - } - } - return weakkey || weakvalue; -} - - -/* -** All marks are conditional because a GC may happen while the -** prototype is still being created -*/ -static void traverseproto (global_State *g, Proto *f) { - int i; - if (f->source) stringmark(f->source); - for (i=0; isizek; i++) /* mark literals */ - markvalue(g, &f->k[i]); - for (i=0; isizeupvalues; i++) { /* mark upvalue names */ - if (f->upvalues[i]) - stringmark(f->upvalues[i]); - } - for (i=0; isizep; i++) { /* mark nested protos */ - if (f->p[i]) - markobject(g, f->p[i]); - } - for (i=0; isizelocvars; i++) { /* mark local-variable names */ - if (f->locvars[i].varname) - stringmark(f->locvars[i].varname); - } -} - - - -static void traverseclosure (global_State *g, Closure *cl) { - markobject(g, cl->c.env); - if (cl->c.isC) { - int i; - for (i=0; ic.nupvalues; i++) /* mark its upvalues */ - markvalue(g, &cl->c.upvalue[i]); - } - else { - int i; - lua_assert(cl->l.nupvalues == cl->l.p->nups); - markobject(g, cl->l.p); - for (i=0; il.nupvalues; i++) /* mark its upvalues */ - markobject(g, cl->l.upvals[i]); - } -} - - -static void checkstacksizes (lua_State *L, StkId max) { - int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ - int s_used = cast_int(max - L->stack); /* part of stack in use */ - if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ - return; /* do not touch the stacks */ - if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) - luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ - condhardstacktests(luaD_reallocCI(L, ci_used + 1)); - if (4*s_used < L->stacksize && - 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) - luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ - condhardstacktests(luaD_reallocstack(L, s_used)); -} - - -static void traversestack (global_State *g, lua_State *l) { - StkId o, lim; - CallInfo *ci; - markvalue(g, gt(l)); - lim = l->top; - for (ci = l->base_ci; ci <= l->ci; ci++) { - lua_assert(ci->top <= l->stack_last); - if (lim < ci->top) lim = ci->top; - } - for (o = l->stack; o < l->top; o++) - markvalue(g, o); - for (; o <= lim; o++) - setnilvalue(o); - checkstacksizes(l, lim); -} - - -/* -** traverse one gray object, turning it to black. -** Returns `quantity' traversed. -*/ -static l_mem propagatemark (global_State *g) { - GCObject *o = g->gray; - lua_assert(isgray(o)); - gray2black(o); - switch (o->gch.tt) { - case LUA_TTABLE: { - Table *h = gco2h(o); - g->gray = h->gclist; - if (traversetable(g, h)) /* table is weak? */ - black2gray(o); /* keep it gray */ - return sizeof(Table) + sizeof(TValue) * h->sizearray + - sizeof(Node) * sizenode(h); - } - case LUA_TFUNCTION: { - Closure *cl = gco2cl(o); - g->gray = cl->c.gclist; - traverseclosure(g, cl); - return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : - sizeLclosure(cl->l.nupvalues); - } - case LUA_TTHREAD: { - lua_State *th = gco2th(o); - g->gray = th->gclist; - th->gclist = g->grayagain; - g->grayagain = o; - black2gray(o); - traversestack(g, th); - return sizeof(lua_State) + sizeof(TValue) * th->stacksize + - sizeof(CallInfo) * th->size_ci; - } - case LUA_TPROTO: { - Proto *p = gco2p(o); - g->gray = p->gclist; - traverseproto(g, p); - return sizeof(Proto) + sizeof(Instruction) * p->sizecode + - sizeof(Proto *) * p->sizep + - sizeof(TValue) * p->sizek + - sizeof(int) * p->sizelineinfo + - sizeof(LocVar) * p->sizelocvars + - sizeof(TString *) * p->sizeupvalues; - } - default: lua_assert(0); return 0; - } -} - - -static size_t propagateall (global_State *g) { - size_t m = 0; - while (g->gray) m += propagatemark(g); - return m; -} - - -/* -** The next function tells whether a key or value can be cleared from -** a weak table. Non-collectable objects are never removed from weak -** tables. Strings behave as `values', so are never removed too. for -** other objects: if really collected, cannot keep them; for userdata -** being finalized, keep them in keys, but not in values -*/ -static int iscleared (const TValue *o, int iskey) { - if (!iscollectable(o)) return 0; - if (ttisstring(o)) { - stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ - return 0; - } - return iswhite(gcvalue(o)) || - (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); -} - - -/* -** clear collected entries from weaktables -*/ -static void cleartable (GCObject *l) { - while (l) { - Table *h = gco2h(l); - int i = h->sizearray; - lua_assert(testbit(h->marked, VALUEWEAKBIT) || - testbit(h->marked, KEYWEAKBIT)); - if (testbit(h->marked, VALUEWEAKBIT)) { - while (i--) { - TValue *o = &h->array[i]; - if (iscleared(o, 0)) /* value was collected? */ - setnilvalue(o); /* remove value */ - } - } - i = sizenode(h); - while (i--) { - Node *n = gnode(h, i); - if (!ttisnil(gval(n)) && /* non-empty entry? */ - (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { - setnilvalue(gval(n)); /* remove value ... */ - removeentry(n); /* remove entry from table */ - } - } - l = h->gclist; - } -} - - -static void freeobj (lua_State *L, GCObject *o) { - switch (o->gch.tt) { - case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; - case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; - case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; - case LUA_TTABLE: luaH_free(L, gco2h(o)); break; - case LUA_TTHREAD: { - lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); - luaE_freethread(L, gco2th(o)); - break; - } - case LUA_TSTRING: { - G(L)->strt.nuse--; - luaM_freemem(L, o, sizestring(gco2ts(o))); - break; - } - case LUA_TUSERDATA: { - luaM_freemem(L, o, sizeudata(gco2u(o))); - break; - } - default: lua_assert(0); - } -} - - - -#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) - - -static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { - GCObject *curr; - global_State *g = G(L); - int deadmask = otherwhite(g); - while ((curr = *p) != NULL && count-- > 0) { - if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ - sweepwholelist(L, &gco2th(curr)->openupval); - if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ - lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); - makewhite(g, curr); /* make it white (for next cycle) */ - p = &curr->gch.next; - } - else { /* must erase `curr' */ - lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); - *p = curr->gch.next; - if (curr == g->rootgc) /* is the first element of the list? */ - g->rootgc = curr->gch.next; /* adjust first */ - freeobj(L, curr); - } - } - return p; -} - - -static void checkSizes (lua_State *L) { - global_State *g = G(L); - /* check size of string hash */ - if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && - g->strt.size > MINSTRTABSIZE*2) - luaS_resize(L, g->strt.size/2); /* table is too big */ - /* check size of buffer */ - if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ - size_t newsize = luaZ_sizebuffer(&g->buff) / 2; - luaZ_resizebuffer(L, &g->buff, newsize); - } -} - - -static void GCTM (lua_State *L) { - global_State *g = G(L); - GCObject *o = g->tmudata->gch.next; /* get first element */ - Udata *udata = rawgco2u(o); - const TValue *tm; - /* remove udata from `tmudata' */ - if (o == g->tmudata) /* last element? */ - g->tmudata = NULL; - else - g->tmudata->gch.next = udata->uv.next; - udata->uv.next = g->mainthread->next; /* return it to `root' list */ - g->mainthread->next = o; - makewhite(g, o); - tm = fasttm(L, udata->uv.metatable, TM_GC); - if (tm != NULL) { - lu_byte oldah = L->allowhook; - lu_mem oldt = g->GCthreshold; - L->allowhook = 0; /* stop debug hooks during GC tag method */ - g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ - setobj2s(L, L->top, tm); - setuvalue(L, L->top+1, udata); - L->top += 2; - luaD_call(L, L->top - 2, 0); - L->allowhook = oldah; /* restore hooks */ - g->GCthreshold = oldt; /* restore threshold */ - } -} - - -/* -** Call all GC tag methods -*/ -void luaC_callGCTM (lua_State *L) { - while (G(L)->tmudata) - GCTM(L); -} - - -void luaC_freeall (lua_State *L) { - global_State *g = G(L); - int i; - g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ - sweepwholelist(L, &g->rootgc); - for (i = 0; i < g->strt.size; i++) /* free all string lists */ - sweepwholelist(L, &g->strt.hash[i]); -} - - -static void markmt (global_State *g) { - int i; - for (i=0; imt[i]) markobject(g, g->mt[i]); -} - - -/* mark root set */ -static void markroot (lua_State *L) { - global_State *g = G(L); - g->gray = NULL; - g->grayagain = NULL; - g->weak = NULL; - markobject(g, g->mainthread); - /* make global table be traversed before main stack */ - markvalue(g, gt(g->mainthread)); - markvalue(g, registry(L)); - markmt(g); - g->gcstate = GCSpropagate; -} - - -static void remarkupvals (global_State *g) { - UpVal *uv; - for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { - lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); - if (isgray(obj2gco(uv))) - markvalue(g, uv->v); - } -} - - -static void atomic (lua_State *L) { - global_State *g = G(L); - size_t udsize; /* total size of userdata to be finalized */ - /* remark occasional upvalues of (maybe) dead threads */ - remarkupvals(g); - /* traverse objects cautch by write barrier and by 'remarkupvals' */ - propagateall(g); - /* remark weak tables */ - g->gray = g->weak; - g->weak = NULL; - lua_assert(!iswhite(obj2gco(g->mainthread))); - markobject(g, L); /* mark running thread */ - markmt(g); /* mark basic metatables (again) */ - propagateall(g); - /* remark gray again */ - g->gray = g->grayagain; - g->grayagain = NULL; - propagateall(g); - udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ - marktmu(g); /* mark `preserved' userdata */ - udsize += propagateall(g); /* remark, to propagate `preserveness' */ - cleartable(g->weak); /* remove collected objects from weak tables */ - /* flip current white */ - g->currentwhite = cast_byte(otherwhite(g)); - g->sweepstrgc = 0; - g->sweepgc = &g->rootgc; - g->gcstate = GCSsweepstring; - g->estimate = g->totalbytes - udsize; /* first estimate */ -} - - -static l_mem singlestep (lua_State *L) { - global_State *g = G(L); - /*lua_checkmemory(L);*/ - switch (g->gcstate) { - case GCSpause: { - markroot(L); /* start a new collection */ - return 0; - } - case GCSpropagate: { - if (g->gray) - return propagatemark(g); - else { /* no more `gray' objects */ - atomic(L); /* finish mark phase */ - return 0; - } - } - case GCSsweepstring: { - lu_mem old = g->totalbytes; - sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); - if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ - g->gcstate = GCSsweep; /* end sweep-string phase */ - lua_assert(old >= g->totalbytes); - g->estimate -= old - g->totalbytes; - return GCSWEEPCOST; - } - case GCSsweep: { - lu_mem old = g->totalbytes; - g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); - if (*g->sweepgc == NULL) { /* nothing more to sweep? */ - checkSizes(L); - g->gcstate = GCSfinalize; /* end sweep phase */ - } - lua_assert(old >= g->totalbytes); - g->estimate -= old - g->totalbytes; - return GCSWEEPMAX*GCSWEEPCOST; - } - case GCSfinalize: { - if (g->tmudata) { - GCTM(L); - if (g->estimate > GCFINALIZECOST) - g->estimate -= GCFINALIZECOST; - return GCFINALIZECOST; - } - else { - g->gcstate = GCSpause; /* end collection */ - g->gcdept = 0; - return 0; - } - } - default: lua_assert(0); return 0; - } -} - - -void luaC_step (lua_State *L) { - global_State *g = G(L); - l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; - if (lim == 0) - lim = (MAX_LUMEM-1)/2; /* no limit */ - g->gcdept += g->totalbytes - g->GCthreshold; - do { - lim -= singlestep(L); - if (g->gcstate == GCSpause) - break; - } while (lim > 0); - if (g->gcstate != GCSpause) { - if (g->gcdept < GCSTEPSIZE) - g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ - else { - g->gcdept -= GCSTEPSIZE; - g->GCthreshold = g->totalbytes; - } - } - else { - lua_assert(g->totalbytes >= g->estimate); - setthreshold(g); - } -} - - -void luaC_fullgc (lua_State *L) { - global_State *g = G(L); - if (g->gcstate <= GCSpropagate) { - /* reset sweep marks to sweep all elements (returning them to white) */ - g->sweepstrgc = 0; - g->sweepgc = &g->rootgc; - /* reset other collector lists */ - g->gray = NULL; - g->grayagain = NULL; - g->weak = NULL; - g->gcstate = GCSsweepstring; - } - lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); - /* finish any pending sweep phase */ - while (g->gcstate != GCSfinalize) { - lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); - singlestep(L); - } - markroot(L); - while (g->gcstate != GCSpause) { - singlestep(L); - } - setthreshold(g); -} - - -void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { - global_State *g = G(L); - lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); - lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); - lua_assert(ttype(&o->gch) != LUA_TTABLE); - /* must keep invariant? */ - if (g->gcstate == GCSpropagate) - reallymarkobject(g, v); /* restore invariant */ - else /* don't mind */ - makewhite(g, o); /* mark as white just to avoid other barriers */ -} - - -void luaC_barrierback (lua_State *L, Table *t) { - global_State *g = G(L); - GCObject *o = obj2gco(t); - lua_assert(isblack(o) && !isdead(g, o)); - lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); - black2gray(o); /* make table gray (again) */ - t->gclist = g->grayagain; - g->grayagain = o; -} - - -void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { - global_State *g = G(L); - o->gch.next = g->rootgc; - g->rootgc = o; - o->gch.marked = luaC_white(g); - o->gch.tt = tt; -} - - -void luaC_linkupval (lua_State *L, UpVal *uv) { - global_State *g = G(L); - GCObject *o = obj2gco(uv); - o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ - g->rootgc = o; - if (isgray(o)) { - if (g->gcstate == GCSpropagate) { - gray2black(o); /* closed upvalues need barrier */ - luaC_barrier(L, uv, uv->v); - } - else { /* sweep phase: sweep it (turning it into white) */ - makewhite(g, o); - lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); - } - } -} - diff -Nru gpick-0.2.4/extern/lua/src/lgc.h gpick-0.2.5/extern/lua/src/lgc.h --- gpick-0.2.4/extern/lua/src/lgc.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lgc.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -/* -** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ -** Garbage Collector -** See Copyright Notice in lua.h -*/ - -#ifndef lgc_h -#define lgc_h - - -#include "lobject.h" - - -/* -** Possible states of the Garbage Collector -*/ -#define GCSpause 0 -#define GCSpropagate 1 -#define GCSsweepstring 2 -#define GCSsweep 3 -#define GCSfinalize 4 - - -/* -** some userful bit tricks -*/ -#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) -#define setbits(x,m) ((x) |= (m)) -#define testbits(x,m) ((x) & (m)) -#define bitmask(b) (1<<(b)) -#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) -#define l_setbit(x,b) setbits(x, bitmask(b)) -#define resetbit(x,b) resetbits(x, bitmask(b)) -#define testbit(x,b) testbits(x, bitmask(b)) -#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) -#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) -#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) - - - -/* -** Layout for bit use in `marked' field: -** bit 0 - object is white (type 0) -** bit 1 - object is white (type 1) -** bit 2 - object is black -** bit 3 - for userdata: has been finalized -** bit 3 - for tables: has weak keys -** bit 4 - for tables: has weak values -** bit 5 - object is fixed (should not be collected) -** bit 6 - object is "super" fixed (only the main thread) -*/ - - -#define WHITE0BIT 0 -#define WHITE1BIT 1 -#define BLACKBIT 2 -#define FINALIZEDBIT 3 -#define KEYWEAKBIT 3 -#define VALUEWEAKBIT 4 -#define FIXEDBIT 5 -#define SFIXEDBIT 6 -#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) - - -#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) -#define isblack(x) testbit((x)->gch.marked, BLACKBIT) -#define isgray(x) (!isblack(x) && !iswhite(x)) - -#define otherwhite(g) (g->currentwhite ^ WHITEBITS) -#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) - -#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) -#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) - -#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) - -#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) - - -#define luaC_checkGC(L) { \ - condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ - if (G(L)->totalbytes >= G(L)->GCthreshold) \ - luaC_step(L); } - - -#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ - luaC_barrierf(L,obj2gco(p),gcvalue(v)); } - -#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ - luaC_barrierback(L,t); } - -#define luaC_objbarrier(L,p,o) \ - { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ - luaC_barrierf(L,obj2gco(p),obj2gco(o)); } - -#define luaC_objbarriert(L,t,o) \ - { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } - -LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); -LUAI_FUNC void luaC_callGCTM (lua_State *L); -LUAI_FUNC void luaC_freeall (lua_State *L); -LUAI_FUNC void luaC_step (lua_State *L); -LUAI_FUNC void luaC_fullgc (lua_State *L); -LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); -LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); -LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); -LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/linit.c gpick-0.2.5/extern/lua/src/linit.c --- gpick-0.2.4/extern/lua/src/linit.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/linit.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ -** Initialization of libraries for lua.c -** See Copyright Notice in lua.h -*/ - - -#define linit_c -#define LUA_LIB - -#include "lua.h" - -#include "lualib.h" -#include "lauxlib.h" - - -static const luaL_Reg lualibs[] = { - {"", luaopen_base}, - {LUA_LOADLIBNAME, luaopen_package}, - {LUA_TABLIBNAME, luaopen_table}, - {LUA_IOLIBNAME, luaopen_io}, - {LUA_OSLIBNAME, luaopen_os}, - {LUA_STRLIBNAME, luaopen_string}, - {LUA_MATHLIBNAME, luaopen_math}, - {LUA_DBLIBNAME, luaopen_debug}, - {NULL, NULL} -}; - - -LUALIB_API void luaL_openlibs (lua_State *L) { - const luaL_Reg *lib = lualibs; - for (; lib->func; lib++) { - lua_pushcfunction(L, lib->func); - lua_pushstring(L, lib->name); - lua_call(L, 1, 0); - } -} - diff -Nru gpick-0.2.4/extern/lua/src/liolib.c gpick-0.2.5/extern/lua/src/liolib.c --- gpick-0.2.4/extern/lua/src/liolib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/liolib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,553 +0,0 @@ -/* -** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ -** Standard I/O (and system) library -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include -#include - -#define liolib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - - -#define IO_INPUT 1 -#define IO_OUTPUT 2 - - -static const char *const fnames[] = {"input", "output"}; - - -static int pushresult (lua_State *L, int i, const char *filename) { - int en = errno; /* calls to Lua API may change this value */ - if (i) { - lua_pushboolean(L, 1); - return 1; - } - else { - lua_pushnil(L); - if (filename) - lua_pushfstring(L, "%s: %s", filename, strerror(en)); - else - lua_pushfstring(L, "%s", strerror(en)); - lua_pushinteger(L, en); - return 3; - } -} - - -static void fileerror (lua_State *L, int arg, const char *filename) { - lua_pushfstring(L, "%s: %s", filename, strerror(errno)); - luaL_argerror(L, arg, lua_tostring(L, -1)); -} - - -#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) - - -static int io_type (lua_State *L) { - void *ud; - luaL_checkany(L, 1); - ud = lua_touserdata(L, 1); - lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); - if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) - lua_pushnil(L); /* not a file */ - else if (*((FILE **)ud) == NULL) - lua_pushliteral(L, "closed file"); - else - lua_pushliteral(L, "file"); - return 1; -} - - -static FILE *tofile (lua_State *L) { - FILE **f = tofilep(L); - if (*f == NULL) - luaL_error(L, "attempt to use a closed file"); - return *f; -} - - - -/* -** When creating file handles, always creates a `closed' file handle -** before opening the actual file; so, if there is a memory error, the -** file is not left opened. -*/ -static FILE **newfile (lua_State *L) { - FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); - *pf = NULL; /* file handle is currently `closed' */ - luaL_getmetatable(L, LUA_FILEHANDLE); - lua_setmetatable(L, -2); - return pf; -} - - -/* -** function to (not) close the standard files stdin, stdout, and stderr -*/ -static int io_noclose (lua_State *L) { - lua_pushnil(L); - lua_pushliteral(L, "cannot close standard file"); - return 2; -} - - -/* -** function to close 'popen' files -*/ -static int io_pclose (lua_State *L) { - FILE **p = tofilep(L); - int ok = lua_pclose(L, *p); - *p = NULL; - return pushresult(L, ok, NULL); -} - - -/* -** function to close regular files -*/ -static int io_fclose (lua_State *L) { - FILE **p = tofilep(L); - int ok = (fclose(*p) == 0); - *p = NULL; - return pushresult(L, ok, NULL); -} - - -static int aux_close (lua_State *L) { - lua_getfenv(L, 1); - lua_getfield(L, -1, "__close"); - return (lua_tocfunction(L, -1))(L); -} - - -static int io_close (lua_State *L) { - if (lua_isnone(L, 1)) - lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); - tofile(L); /* make sure argument is a file */ - return aux_close(L); -} - - -static int io_gc (lua_State *L) { - FILE *f = *tofilep(L); - /* ignore closed files */ - if (f != NULL) - aux_close(L); - return 0; -} - - -static int io_tostring (lua_State *L) { - FILE *f = *tofilep(L); - if (f == NULL) - lua_pushliteral(L, "file (closed)"); - else - lua_pushfstring(L, "file (%p)", f); - return 1; -} - - -static int io_open (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - const char *mode = luaL_optstring(L, 2, "r"); - FILE **pf = newfile(L); - *pf = fopen(filename, mode); - return (*pf == NULL) ? pushresult(L, 0, filename) : 1; -} - - -/* -** this function has a separated environment, which defines the -** correct __close for 'popen' files -*/ -static int io_popen (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - const char *mode = luaL_optstring(L, 2, "r"); - FILE **pf = newfile(L); - *pf = lua_popen(L, filename, mode); - return (*pf == NULL) ? pushresult(L, 0, filename) : 1; -} - - -static int io_tmpfile (lua_State *L) { - FILE **pf = newfile(L); - *pf = tmpfile(); - return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; -} - - -static FILE *getiofile (lua_State *L, int findex) { - FILE *f; - lua_rawgeti(L, LUA_ENVIRONINDEX, findex); - f = *(FILE **)lua_touserdata(L, -1); - if (f == NULL) - luaL_error(L, "standard %s file is closed", fnames[findex - 1]); - return f; -} - - -static int g_iofile (lua_State *L, int f, const char *mode) { - if (!lua_isnoneornil(L, 1)) { - const char *filename = lua_tostring(L, 1); - if (filename) { - FILE **pf = newfile(L); - *pf = fopen(filename, mode); - if (*pf == NULL) - fileerror(L, 1, filename); - } - else { - tofile(L); /* check that it's a valid file handle */ - lua_pushvalue(L, 1); - } - lua_rawseti(L, LUA_ENVIRONINDEX, f); - } - /* return current value */ - lua_rawgeti(L, LUA_ENVIRONINDEX, f); - return 1; -} - - -static int io_input (lua_State *L) { - return g_iofile(L, IO_INPUT, "r"); -} - - -static int io_output (lua_State *L) { - return g_iofile(L, IO_OUTPUT, "w"); -} - - -static int io_readline (lua_State *L); - - -static void aux_lines (lua_State *L, int idx, int toclose) { - lua_pushvalue(L, idx); - lua_pushboolean(L, toclose); /* close/not close file when finished */ - lua_pushcclosure(L, io_readline, 2); -} - - -static int f_lines (lua_State *L) { - tofile(L); /* check that it's a valid file handle */ - aux_lines(L, 1, 0); - return 1; -} - - -static int io_lines (lua_State *L) { - if (lua_isnoneornil(L, 1)) { /* no arguments? */ - /* will iterate over default input */ - lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); - return f_lines(L); - } - else { - const char *filename = luaL_checkstring(L, 1); - FILE **pf = newfile(L); - *pf = fopen(filename, "r"); - if (*pf == NULL) - fileerror(L, 1, filename); - aux_lines(L, lua_gettop(L), 1); - return 1; - } -} - - -/* -** {====================================================== -** READ -** ======================================================= -*/ - - -static int read_number (lua_State *L, FILE *f) { - lua_Number d; - if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { - lua_pushnumber(L, d); - return 1; - } - else return 0; /* read fails */ -} - - -static int test_eof (lua_State *L, FILE *f) { - int c = getc(f); - ungetc(c, f); - lua_pushlstring(L, NULL, 0); - return (c != EOF); -} - - -static int read_line (lua_State *L, FILE *f) { - luaL_Buffer b; - luaL_buffinit(L, &b); - for (;;) { - size_t l; - char *p = luaL_prepbuffer(&b); - if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ - luaL_pushresult(&b); /* close buffer */ - return (lua_objlen(L, -1) > 0); /* check whether read something */ - } - l = strlen(p); - if (l == 0 || p[l-1] != '\n') - luaL_addsize(&b, l); - else { - luaL_addsize(&b, l - 1); /* do not include `eol' */ - luaL_pushresult(&b); /* close buffer */ - return 1; /* read at least an `eol' */ - } - } -} - - -static int read_chars (lua_State *L, FILE *f, size_t n) { - size_t rlen; /* how much to read */ - size_t nr; /* number of chars actually read */ - luaL_Buffer b; - luaL_buffinit(L, &b); - rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ - do { - char *p = luaL_prepbuffer(&b); - if (rlen > n) rlen = n; /* cannot read more than asked */ - nr = fread(p, sizeof(char), rlen, f); - luaL_addsize(&b, nr); - n -= nr; /* still have to read `n' chars */ - } while (n > 0 && nr == rlen); /* until end of count or eof */ - luaL_pushresult(&b); /* close buffer */ - return (n == 0 || lua_objlen(L, -1) > 0); -} - - -static int g_read (lua_State *L, FILE *f, int first) { - int nargs = lua_gettop(L) - 1; - int success; - int n; - clearerr(f); - if (nargs == 0) { /* no arguments? */ - success = read_line(L, f); - n = first+1; /* to return 1 result */ - } - else { /* ensure stack space for all results and for auxlib's buffer */ - luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); - success = 1; - for (n = first; nargs-- && success; n++) { - if (lua_type(L, n) == LUA_TNUMBER) { - size_t l = (size_t)lua_tointeger(L, n); - success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); - } - else { - const char *p = lua_tostring(L, n); - luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); - switch (p[1]) { - case 'n': /* number */ - success = read_number(L, f); - break; - case 'l': /* line */ - success = read_line(L, f); - break; - case 'a': /* file */ - read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ - success = 1; /* always success */ - break; - default: - return luaL_argerror(L, n, "invalid format"); - } - } - } - } - if (ferror(f)) - return pushresult(L, 0, NULL); - if (!success) { - lua_pop(L, 1); /* remove last result */ - lua_pushnil(L); /* push nil instead */ - } - return n - first; -} - - -static int io_read (lua_State *L) { - return g_read(L, getiofile(L, IO_INPUT), 1); -} - - -static int f_read (lua_State *L) { - return g_read(L, tofile(L), 2); -} - - -static int io_readline (lua_State *L) { - FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); - int sucess; - if (f == NULL) /* file is already closed? */ - luaL_error(L, "file is already closed"); - sucess = read_line(L, f); - if (ferror(f)) - return luaL_error(L, "%s", strerror(errno)); - if (sucess) return 1; - else { /* EOF */ - if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ - lua_settop(L, 0); - lua_pushvalue(L, lua_upvalueindex(1)); - aux_close(L); /* close it */ - } - return 0; - } -} - -/* }====================================================== */ - - -static int g_write (lua_State *L, FILE *f, int arg) { - int nargs = lua_gettop(L) - 1; - int status = 1; - for (; nargs--; arg++) { - if (lua_type(L, arg) == LUA_TNUMBER) { - /* optimization: could be done exactly as for strings */ - status = status && - fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; - } - else { - size_t l; - const char *s = luaL_checklstring(L, arg, &l); - status = status && (fwrite(s, sizeof(char), l, f) == l); - } - } - return pushresult(L, status, NULL); -} - - -static int io_write (lua_State *L) { - return g_write(L, getiofile(L, IO_OUTPUT), 1); -} - - -static int f_write (lua_State *L) { - return g_write(L, tofile(L), 2); -} - - -static int f_seek (lua_State *L) { - static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; - static const char *const modenames[] = {"set", "cur", "end", NULL}; - FILE *f = tofile(L); - int op = luaL_checkoption(L, 2, "cur", modenames); - long offset = luaL_optlong(L, 3, 0); - op = fseek(f, offset, mode[op]); - if (op) - return pushresult(L, 0, NULL); /* error */ - else { - lua_pushinteger(L, ftell(f)); - return 1; - } -} - - -static int f_setvbuf (lua_State *L) { - static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; - static const char *const modenames[] = {"no", "full", "line", NULL}; - FILE *f = tofile(L); - int op = luaL_checkoption(L, 2, NULL, modenames); - lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); - int res = setvbuf(f, NULL, mode[op], sz); - return pushresult(L, res == 0, NULL); -} - - - -static int io_flush (lua_State *L) { - return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); -} - - -static int f_flush (lua_State *L) { - return pushresult(L, fflush(tofile(L)) == 0, NULL); -} - - -static const luaL_Reg iolib[] = { - {"close", io_close}, - {"flush", io_flush}, - {"input", io_input}, - {"lines", io_lines}, - {"open", io_open}, - {"output", io_output}, - {"popen", io_popen}, - {"read", io_read}, - {"tmpfile", io_tmpfile}, - {"type", io_type}, - {"write", io_write}, - {NULL, NULL} -}; - - -static const luaL_Reg flib[] = { - {"close", io_close}, - {"flush", f_flush}, - {"lines", f_lines}, - {"read", f_read}, - {"seek", f_seek}, - {"setvbuf", f_setvbuf}, - {"write", f_write}, - {"__gc", io_gc}, - {"__tostring", io_tostring}, - {NULL, NULL} -}; - - -static void createmeta (lua_State *L) { - luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ - lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_register(L, NULL, flib); /* file methods */ -} - - -static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { - *newfile(L) = f; - if (k > 0) { - lua_pushvalue(L, -1); - lua_rawseti(L, LUA_ENVIRONINDEX, k); - } - lua_pushvalue(L, -2); /* copy environment */ - lua_setfenv(L, -2); /* set it */ - lua_setfield(L, -3, fname); -} - - -static void newfenv (lua_State *L, lua_CFunction cls) { - lua_createtable(L, 0, 1); - lua_pushcfunction(L, cls); - lua_setfield(L, -2, "__close"); -} - - -LUALIB_API int luaopen_io (lua_State *L) { - createmeta(L); - /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ - newfenv(L, io_fclose); - lua_replace(L, LUA_ENVIRONINDEX); - /* open library */ - luaL_register(L, LUA_IOLIBNAME, iolib); - /* create (and set) default files */ - newfenv(L, io_noclose); /* close function for default files */ - createstdfile(L, stdin, IO_INPUT, "stdin"); - createstdfile(L, stdout, IO_OUTPUT, "stdout"); - createstdfile(L, stderr, 0, "stderr"); - lua_pop(L, 1); /* pop environment for default files */ - lua_getfield(L, -1, "popen"); - newfenv(L, io_pclose); /* create environment for 'popen' */ - lua_setfenv(L, -2); /* set fenv for 'popen' */ - lua_pop(L, 1); /* pop 'popen' */ - return 1; -} - diff -Nru gpick-0.2.4/extern/lua/src/llex.c gpick-0.2.5/extern/lua/src/llex.c --- gpick-0.2.4/extern/lua/src/llex.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/llex.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,461 +0,0 @@ -/* -** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ -** Lexical Analyzer -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include - -#define llex_c -#define LUA_CORE - -#include "lua.h" - -#include "ldo.h" -#include "llex.h" -#include "lobject.h" -#include "lparser.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "lzio.h" - - - -#define next(ls) (ls->current = zgetc(ls->z)) - - - - -#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') - - -/* ORDER RESERVED */ -const char *const luaX_tokens [] = { - "and", "break", "do", "else", "elseif", - "end", "false", "for", "function", "if", - "in", "local", "nil", "not", "or", "repeat", - "return", "then", "true", "until", "while", - "..", "...", "==", ">=", "<=", "~=", - "", "", "", "", - NULL -}; - - -#define save_and_next(ls) (save(ls, ls->current), next(ls)) - - -static void save (LexState *ls, int c) { - Mbuffer *b = ls->buff; - if (b->n + 1 > b->buffsize) { - size_t newsize; - if (b->buffsize >= MAX_SIZET/2) - luaX_lexerror(ls, "lexical element too long", 0); - newsize = b->buffsize * 2; - luaZ_resizebuffer(ls->L, b, newsize); - } - b->buffer[b->n++] = cast(char, c); -} - - -void luaX_init (lua_State *L) { - int i; - for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ - } -} - - -#define MAXSRC 80 - - -const char *luaX_token2str (LexState *ls, int token) { - if (token < FIRST_RESERVED) { - lua_assert(token == cast(unsigned char, token)); - return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : - luaO_pushfstring(ls->L, "%c", token); - } - else - return luaX_tokens[token-FIRST_RESERVED]; -} - - -static const char *txtToken (LexState *ls, int token) { - switch (token) { - case TK_NAME: - case TK_STRING: - case TK_NUMBER: - save(ls, '\0'); - return luaZ_buffer(ls->buff); - default: - return luaX_token2str(ls, token); - } -} - - -void luaX_lexerror (LexState *ls, const char *msg, int token) { - char buff[MAXSRC]; - luaO_chunkid(buff, getstr(ls->source), MAXSRC); - msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); - if (token) - luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); - luaD_throw(ls->L, LUA_ERRSYNTAX); -} - - -void luaX_syntaxerror (LexState *ls, const char *msg) { - luaX_lexerror(ls, msg, ls->t.token); -} - - -TString *luaX_newstring (LexState *ls, const char *str, size_t l) { - lua_State *L = ls->L; - TString *ts = luaS_newlstr(L, str, l); - TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ - if (ttisnil(o)) - setbvalue(o, 1); /* make sure `str' will not be collected */ - return ts; -} - - -static void inclinenumber (LexState *ls) { - int old = ls->current; - lua_assert(currIsNewline(ls)); - next(ls); /* skip `\n' or `\r' */ - if (currIsNewline(ls) && ls->current != old) - next(ls); /* skip `\n\r' or `\r\n' */ - if (++ls->linenumber >= MAX_INT) - luaX_syntaxerror(ls, "chunk has too many lines"); -} - - -void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { - ls->decpoint = '.'; - ls->L = L; - ls->lookahead.token = TK_EOS; /* no look-ahead token */ - ls->z = z; - ls->fs = NULL; - ls->linenumber = 1; - ls->lastline = 1; - ls->source = source; - luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ - next(ls); /* read first char */ -} - - - -/* -** ======================================================= -** LEXICAL ANALYZER -** ======================================================= -*/ - - - -static int check_next (LexState *ls, const char *set) { - if (!strchr(set, ls->current)) - return 0; - save_and_next(ls); - return 1; -} - - -static void buffreplace (LexState *ls, char from, char to) { - size_t n = luaZ_bufflen(ls->buff); - char *p = luaZ_buffer(ls->buff); - while (n--) - if (p[n] == from) p[n] = to; -} - - -static void trydecpoint (LexState *ls, SemInfo *seminfo) { - /* format error: try to update decimal point separator */ - struct lconv *cv = localeconv(); - char old = ls->decpoint; - ls->decpoint = (cv ? cv->decimal_point[0] : '.'); - buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ - if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { - /* format error with correct decimal point: no more options */ - buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ - luaX_lexerror(ls, "malformed number", TK_NUMBER); - } -} - - -/* LUA_NUMBER */ -static void read_numeral (LexState *ls, SemInfo *seminfo) { - lua_assert(isdigit(ls->current)); - do { - save_and_next(ls); - } while (isdigit(ls->current) || ls->current == '.'); - if (check_next(ls, "Ee")) /* `E'? */ - check_next(ls, "+-"); /* optional exponent sign */ - while (isalnum(ls->current) || ls->current == '_') - save_and_next(ls); - save(ls, '\0'); - buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ - if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ - trydecpoint(ls, seminfo); /* try to update decimal point separator */ -} - - -static int skip_sep (LexState *ls) { - int count = 0; - int s = ls->current; - lua_assert(s == '[' || s == ']'); - save_and_next(ls); - while (ls->current == '=') { - save_and_next(ls); - count++; - } - return (ls->current == s) ? count : (-count) - 1; -} - - -static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { - int cont = 0; - (void)(cont); /* avoid warnings when `cont' is not used */ - save_and_next(ls); /* skip 2nd `[' */ - if (currIsNewline(ls)) /* string starts with a newline? */ - inclinenumber(ls); /* skip it */ - for (;;) { - switch (ls->current) { - case EOZ: - luaX_lexerror(ls, (seminfo) ? "unfinished long string" : - "unfinished long comment", TK_EOS); - break; /* to avoid warnings */ -#if defined(LUA_COMPAT_LSTR) - case '[': { - if (skip_sep(ls) == sep) { - save_and_next(ls); /* skip 2nd `[' */ - cont++; -#if LUA_COMPAT_LSTR == 1 - if (sep == 0) - luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); -#endif - } - break; - } -#endif - case ']': { - if (skip_sep(ls) == sep) { - save_and_next(ls); /* skip 2nd `]' */ -#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 - cont--; - if (sep == 0 && cont >= 0) break; -#endif - goto endloop; - } - break; - } - case '\n': - case '\r': { - save(ls, '\n'); - inclinenumber(ls); - if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ - break; - } - default: { - if (seminfo) save_and_next(ls); - else next(ls); - } - } - } endloop: - if (seminfo) - seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), - luaZ_bufflen(ls->buff) - 2*(2 + sep)); -} - - -static void read_string (LexState *ls, int del, SemInfo *seminfo) { - save_and_next(ls); - while (ls->current != del) { - switch (ls->current) { - case EOZ: - luaX_lexerror(ls, "unfinished string", TK_EOS); - continue; /* to avoid warnings */ - case '\n': - case '\r': - luaX_lexerror(ls, "unfinished string", TK_STRING); - continue; /* to avoid warnings */ - case '\\': { - int c; - next(ls); /* do not save the `\' */ - switch (ls->current) { - case 'a': c = '\a'; break; - case 'b': c = '\b'; break; - case 'f': c = '\f'; break; - case 'n': c = '\n'; break; - case 'r': c = '\r'; break; - case 't': c = '\t'; break; - case 'v': c = '\v'; break; - case '\n': /* go through */ - case '\r': save(ls, '\n'); inclinenumber(ls); continue; - case EOZ: continue; /* will raise an error next loop */ - default: { - if (!isdigit(ls->current)) - save_and_next(ls); /* handles \\, \", \', and \? */ - else { /* \xxx */ - int i = 0; - c = 0; - do { - c = 10*c + (ls->current-'0'); - next(ls); - } while (++i<3 && isdigit(ls->current)); - if (c > UCHAR_MAX) - luaX_lexerror(ls, "escape sequence too large", TK_STRING); - save(ls, c); - } - continue; - } - } - save(ls, c); - next(ls); - continue; - } - default: - save_and_next(ls); - } - } - save_and_next(ls); /* skip delimiter */ - seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, - luaZ_bufflen(ls->buff) - 2); -} - - -static int llex (LexState *ls, SemInfo *seminfo) { - luaZ_resetbuffer(ls->buff); - for (;;) { - switch (ls->current) { - case '\n': - case '\r': { - inclinenumber(ls); - continue; - } - case '-': { - next(ls); - if (ls->current != '-') return '-'; - /* else is a comment */ - next(ls); - if (ls->current == '[') { - int sep = skip_sep(ls); - luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ - if (sep >= 0) { - read_long_string(ls, NULL, sep); /* long comment */ - luaZ_resetbuffer(ls->buff); - continue; - } - } - /* else short comment */ - while (!currIsNewline(ls) && ls->current != EOZ) - next(ls); - continue; - } - case '[': { - int sep = skip_sep(ls); - if (sep >= 0) { - read_long_string(ls, seminfo, sep); - return TK_STRING; - } - else if (sep == -1) return '['; - else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); - } - case '=': { - next(ls); - if (ls->current != '=') return '='; - else { next(ls); return TK_EQ; } - } - case '<': { - next(ls); - if (ls->current != '=') return '<'; - else { next(ls); return TK_LE; } - } - case '>': { - next(ls); - if (ls->current != '=') return '>'; - else { next(ls); return TK_GE; } - } - case '~': { - next(ls); - if (ls->current != '=') return '~'; - else { next(ls); return TK_NE; } - } - case '"': - case '\'': { - read_string(ls, ls->current, seminfo); - return TK_STRING; - } - case '.': { - save_and_next(ls); - if (check_next(ls, ".")) { - if (check_next(ls, ".")) - return TK_DOTS; /* ... */ - else return TK_CONCAT; /* .. */ - } - else if (!isdigit(ls->current)) return '.'; - else { - read_numeral(ls, seminfo); - return TK_NUMBER; - } - } - case EOZ: { - return TK_EOS; - } - default: { - if (isspace(ls->current)) { - lua_assert(!currIsNewline(ls)); - next(ls); - continue; - } - else if (isdigit(ls->current)) { - read_numeral(ls, seminfo); - return TK_NUMBER; - } - else if (isalpha(ls->current) || ls->current == '_') { - /* identifier or reserved word */ - TString *ts; - do { - save_and_next(ls); - } while (isalnum(ls->current) || ls->current == '_'); - ts = luaX_newstring(ls, luaZ_buffer(ls->buff), - luaZ_bufflen(ls->buff)); - if (ts->tsv.reserved > 0) /* reserved word? */ - return ts->tsv.reserved - 1 + FIRST_RESERVED; - else { - seminfo->ts = ts; - return TK_NAME; - } - } - else { - int c = ls->current; - next(ls); - return c; /* single-char tokens (+ - / ...) */ - } - } - } - } -} - - -void luaX_next (LexState *ls) { - ls->lastline = ls->linenumber; - if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ - ls->t = ls->lookahead; /* use this one */ - ls->lookahead.token = TK_EOS; /* and discharge it */ - } - else - ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ -} - - -void luaX_lookahead (LexState *ls) { - lua_assert(ls->lookahead.token == TK_EOS); - ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); -} - diff -Nru gpick-0.2.4/extern/lua/src/llex.h gpick-0.2.5/extern/lua/src/llex.h --- gpick-0.2.4/extern/lua/src/llex.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/llex.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -/* -** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ -** Lexical Analyzer -** See Copyright Notice in lua.h -*/ - -#ifndef llex_h -#define llex_h - -#include "lobject.h" -#include "lzio.h" - - -#define FIRST_RESERVED 257 - -/* maximum length of a reserved word */ -#define TOKEN_LEN (sizeof("function")/sizeof(char)) - - -/* -* WARNING: if you change the order of this enumeration, -* grep "ORDER RESERVED" -*/ -enum RESERVED { - /* terminal symbols denoted by reserved words */ - TK_AND = FIRST_RESERVED, TK_BREAK, - TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, - TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, - TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, - /* other terminal symbols */ - TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, - TK_NAME, TK_STRING, TK_EOS -}; - -/* number of reserved words */ -#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) - - -/* array with token `names' */ -LUAI_DATA const char *const luaX_tokens []; - - -typedef union { - lua_Number r; - TString *ts; -} SemInfo; /* semantics information */ - - -typedef struct Token { - int token; - SemInfo seminfo; -} Token; - - -typedef struct LexState { - int current; /* current character (charint) */ - int linenumber; /* input line counter */ - int lastline; /* line of last token `consumed' */ - Token t; /* current token */ - Token lookahead; /* look ahead token */ - struct FuncState *fs; /* `FuncState' is private to the parser */ - struct lua_State *L; - ZIO *z; /* input stream */ - Mbuffer *buff; /* buffer for tokens */ - TString *source; /* current source name */ - char decpoint; /* locale decimal point */ -} LexState; - - -LUAI_FUNC void luaX_init (lua_State *L); -LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, - TString *source); -LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); -LUAI_FUNC void luaX_next (LexState *ls); -LUAI_FUNC void luaX_lookahead (LexState *ls); -LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); -LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); -LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/llimits.h gpick-0.2.5/extern/lua/src/llimits.h --- gpick-0.2.4/extern/lua/src/llimits.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/llimits.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -/* -** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ -** Limits, basic types, and some other `installation-dependent' definitions -** See Copyright Notice in lua.h -*/ - -#ifndef llimits_h -#define llimits_h - - -#include -#include - - -#include "lua.h" - - -typedef LUAI_UINT32 lu_int32; - -typedef LUAI_UMEM lu_mem; - -typedef LUAI_MEM l_mem; - - - -/* chars used as small naturals (so that `char' is reserved for characters) */ -typedef unsigned char lu_byte; - - -#define MAX_SIZET ((size_t)(~(size_t)0)-2) - -#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) - - -#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ - -/* -** conversion of pointer to integer -** this is for hashing only; there is no problem if the integer -** cannot hold the whole pointer value -*/ -#define IntPoint(p) ((unsigned int)(lu_mem)(p)) - - - -/* type to ensure maximum alignment */ -typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; - - -/* result of a `usual argument conversion' over lua_Number */ -typedef LUAI_UACNUMBER l_uacNumber; - - -/* internal assertions for in-house debugging */ -#ifdef lua_assert - -#define check_exp(c,e) (lua_assert(c), (e)) -#define api_check(l,e) lua_assert(e) - -#else - -#define lua_assert(c) ((void)0) -#define check_exp(c,e) (e) -#define api_check luai_apicheck - -#endif - - -#ifndef UNUSED -#define UNUSED(x) ((void)(x)) /* to avoid warnings */ -#endif - - -#ifndef cast -#define cast(t, exp) ((t)(exp)) -#endif - -#define cast_byte(i) cast(lu_byte, (i)) -#define cast_num(i) cast(lua_Number, (i)) -#define cast_int(i) cast(int, (i)) - - - -/* -** type for virtual-machine instructions -** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) -*/ -typedef lu_int32 Instruction; - - - -/* maximum stack for a Lua function */ -#define MAXSTACK 250 - - - -/* minimum size for the string table (must be power of 2) */ -#ifndef MINSTRTABSIZE -#define MINSTRTABSIZE 32 -#endif - - -/* minimum size for string buffer */ -#ifndef LUA_MINBUFFER -#define LUA_MINBUFFER 32 -#endif - - -#ifndef lua_lock -#define lua_lock(L) ((void) 0) -#define lua_unlock(L) ((void) 0) -#endif - -#ifndef luai_threadyield -#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} -#endif - - -/* -** macro to control inclusion of some hard tests on stack reallocation -*/ -#ifndef HARDSTACKTESTS -#define condhardstacktests(x) ((void)0) -#else -#define condhardstacktests(x) x -#endif - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lmathlib.c gpick-0.2.5/extern/lua/src/lmathlib.c --- gpick-0.2.4/extern/lua/src/lmathlib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lmathlib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,263 +0,0 @@ -/* -** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ -** Standard mathematical library -** See Copyright Notice in lua.h -*/ - - -#include -#include - -#define lmathlib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -#undef PI -#define PI (3.14159265358979323846) -#define RADIANS_PER_DEGREE (PI/180.0) - - - -static int math_abs (lua_State *L) { - lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); - return 1; -} - -static int math_sin (lua_State *L) { - lua_pushnumber(L, sin(luaL_checknumber(L, 1))); - return 1; -} - -static int math_sinh (lua_State *L) { - lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); - return 1; -} - -static int math_cos (lua_State *L) { - lua_pushnumber(L, cos(luaL_checknumber(L, 1))); - return 1; -} - -static int math_cosh (lua_State *L) { - lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); - return 1; -} - -static int math_tan (lua_State *L) { - lua_pushnumber(L, tan(luaL_checknumber(L, 1))); - return 1; -} - -static int math_tanh (lua_State *L) { - lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); - return 1; -} - -static int math_asin (lua_State *L) { - lua_pushnumber(L, asin(luaL_checknumber(L, 1))); - return 1; -} - -static int math_acos (lua_State *L) { - lua_pushnumber(L, acos(luaL_checknumber(L, 1))); - return 1; -} - -static int math_atan (lua_State *L) { - lua_pushnumber(L, atan(luaL_checknumber(L, 1))); - return 1; -} - -static int math_atan2 (lua_State *L) { - lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); - return 1; -} - -static int math_ceil (lua_State *L) { - lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); - return 1; -} - -static int math_floor (lua_State *L) { - lua_pushnumber(L, floor(luaL_checknumber(L, 1))); - return 1; -} - -static int math_fmod (lua_State *L) { - lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); - return 1; -} - -static int math_modf (lua_State *L) { - double ip; - double fp = modf(luaL_checknumber(L, 1), &ip); - lua_pushnumber(L, ip); - lua_pushnumber(L, fp); - return 2; -} - -static int math_sqrt (lua_State *L) { - lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); - return 1; -} - -static int math_pow (lua_State *L) { - lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); - return 1; -} - -static int math_log (lua_State *L) { - lua_pushnumber(L, log(luaL_checknumber(L, 1))); - return 1; -} - -static int math_log10 (lua_State *L) { - lua_pushnumber(L, log10(luaL_checknumber(L, 1))); - return 1; -} - -static int math_exp (lua_State *L) { - lua_pushnumber(L, exp(luaL_checknumber(L, 1))); - return 1; -} - -static int math_deg (lua_State *L) { - lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); - return 1; -} - -static int math_rad (lua_State *L) { - lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); - return 1; -} - -static int math_frexp (lua_State *L) { - int e; - lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); - lua_pushinteger(L, e); - return 2; -} - -static int math_ldexp (lua_State *L) { - lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); - return 1; -} - - - -static int math_min (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - lua_Number dmin = luaL_checknumber(L, 1); - int i; - for (i=2; i<=n; i++) { - lua_Number d = luaL_checknumber(L, i); - if (d < dmin) - dmin = d; - } - lua_pushnumber(L, dmin); - return 1; -} - - -static int math_max (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - lua_Number dmax = luaL_checknumber(L, 1); - int i; - for (i=2; i<=n; i++) { - lua_Number d = luaL_checknumber(L, i); - if (d > dmax) - dmax = d; - } - lua_pushnumber(L, dmax); - return 1; -} - - -static int math_random (lua_State *L) { - /* the `%' avoids the (rare) case of r==1, and is needed also because on - some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ - lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; - switch (lua_gettop(L)) { /* check number of arguments */ - case 0: { /* no arguments */ - lua_pushnumber(L, r); /* Number between 0 and 1 */ - break; - } - case 1: { /* only upper limit */ - int u = luaL_checkint(L, 1); - luaL_argcheck(L, 1<=u, 1, "interval is empty"); - lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ - break; - } - case 2: { /* lower and upper limits */ - int l = luaL_checkint(L, 1); - int u = luaL_checkint(L, 2); - luaL_argcheck(L, l<=u, 2, "interval is empty"); - lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ - break; - } - default: return luaL_error(L, "wrong number of arguments"); - } - return 1; -} - - -static int math_randomseed (lua_State *L) { - srand(luaL_checkint(L, 1)); - return 0; -} - - -static const luaL_Reg mathlib[] = { - {"abs", math_abs}, - {"acos", math_acos}, - {"asin", math_asin}, - {"atan2", math_atan2}, - {"atan", math_atan}, - {"ceil", math_ceil}, - {"cosh", math_cosh}, - {"cos", math_cos}, - {"deg", math_deg}, - {"exp", math_exp}, - {"floor", math_floor}, - {"fmod", math_fmod}, - {"frexp", math_frexp}, - {"ldexp", math_ldexp}, - {"log10", math_log10}, - {"log", math_log}, - {"max", math_max}, - {"min", math_min}, - {"modf", math_modf}, - {"pow", math_pow}, - {"rad", math_rad}, - {"random", math_random}, - {"randomseed", math_randomseed}, - {"sinh", math_sinh}, - {"sin", math_sin}, - {"sqrt", math_sqrt}, - {"tanh", math_tanh}, - {"tan", math_tan}, - {NULL, NULL} -}; - - -/* -** Open math library -*/ -LUALIB_API int luaopen_math (lua_State *L) { - luaL_register(L, LUA_MATHLIBNAME, mathlib); - lua_pushnumber(L, PI); - lua_setfield(L, -2, "pi"); - lua_pushnumber(L, HUGE_VAL); - lua_setfield(L, -2, "huge"); -#if defined(LUA_COMPAT_MOD) - lua_getfield(L, -1, "fmod"); - lua_setfield(L, -2, "mod"); -#endif - return 1; -} - diff -Nru gpick-0.2.4/extern/lua/src/lmem.c gpick-0.2.5/extern/lua/src/lmem.c --- gpick-0.2.4/extern/lua/src/lmem.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lmem.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/* -** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ -** Interface to Memory Manager -** See Copyright Notice in lua.h -*/ - - -#include - -#define lmem_c -#define LUA_CORE - -#include "lua.h" - -#include "ldebug.h" -#include "ldo.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" - - - -/* -** About the realloc function: -** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); -** (`osize' is the old size, `nsize' is the new size) -** -** Lua ensures that (ptr == NULL) iff (osize == 0). -** -** * frealloc(ud, NULL, 0, x) creates a new block of size `x' -** -** * frealloc(ud, p, x, 0) frees the block `p' -** (in this specific case, frealloc must return NULL). -** particularly, frealloc(ud, NULL, 0, 0) does nothing -** (which is equivalent to free(NULL) in ANSI C) -** -** frealloc returns NULL if it cannot create or reallocate the area -** (any reallocation to an equal or smaller size cannot fail!) -*/ - - - -#define MINSIZEARRAY 4 - - -void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, - int limit, const char *errormsg) { - void *newblock; - int newsize; - if (*size >= limit/2) { /* cannot double it? */ - if (*size >= limit) /* cannot grow even a little? */ - luaG_runerror(L, errormsg); - newsize = limit; /* still have at least one free place */ - } - else { - newsize = (*size)*2; - if (newsize < MINSIZEARRAY) - newsize = MINSIZEARRAY; /* minimum size */ - } - newblock = luaM_reallocv(L, block, *size, newsize, size_elems); - *size = newsize; /* update only when everything else is OK */ - return newblock; -} - - -void *luaM_toobig (lua_State *L) { - luaG_runerror(L, "memory allocation error: block too big"); - return NULL; /* to avoid warnings */ -} - - - -/* -** generic allocation routine. -*/ -void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { - global_State *g = G(L); - lua_assert((osize == 0) == (block == NULL)); - block = (*g->frealloc)(g->ud, block, osize, nsize); - if (block == NULL && nsize > 0) - luaD_throw(L, LUA_ERRMEM); - lua_assert((nsize == 0) == (block == NULL)); - g->totalbytes = (g->totalbytes - osize) + nsize; - return block; -} - diff -Nru gpick-0.2.4/extern/lua/src/lmem.h gpick-0.2.5/extern/lua/src/lmem.h --- gpick-0.2.4/extern/lua/src/lmem.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lmem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* -** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ -** Interface to Memory Manager -** See Copyright Notice in lua.h -*/ - -#ifndef lmem_h -#define lmem_h - - -#include - -#include "llimits.h" -#include "lua.h" - -#define MEMERRMSG "not enough memory" - - -#define luaM_reallocv(L,b,on,n,e) \ - ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ - luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ - luaM_toobig(L)) - -#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) -#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) -#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) - -#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) -#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) -#define luaM_newvector(L,n,t) \ - cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) - -#define luaM_growvector(L,v,nelems,size,t,limit,e) \ - if ((nelems)+1 > (size)) \ - ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) - -#define luaM_reallocvector(L, v,oldn,n,t) \ - ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) - - -LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, - size_t size); -LUAI_FUNC void *luaM_toobig (lua_State *L); -LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, - size_t size_elem, int limit, - const char *errormsg); - -#endif - diff -Nru gpick-0.2.4/extern/lua/src/loadlib.c gpick-0.2.5/extern/lua/src/loadlib.c --- gpick-0.2.4/extern/lua/src/loadlib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/loadlib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,666 +0,0 @@ -/* -** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ -** Dynamic library loader for Lua -** See Copyright Notice in lua.h -** -** This module contains an implementation of loadlib for Unix systems -** that have dlfcn, an implementation for Darwin (Mac OS X), an -** implementation for Windows, and a stub for other systems. -*/ - - -#include -#include - - -#define loadlib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -/* prefix for open functions in C libraries */ -#define LUA_POF "luaopen_" - -/* separator for open functions in C libraries */ -#define LUA_OFSEP "_" - - -#define LIBPREFIX "LOADLIB: " - -#define POF LUA_POF -#define LIB_FAIL "open" - - -/* error codes for ll_loadfunc */ -#define ERRLIB 1 -#define ERRFUNC 2 - -#define setprogdir(L) ((void)0) - - -static void ll_unloadlib (void *lib); -static void *ll_load (lua_State *L, const char *path); -static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); - - - -#if defined(LUA_DL_DLOPEN) -/* -** {======================================================================== -** This is an implementation of loadlib based on the dlfcn interface. -** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, -** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least -** as an emulation layer on top of native functions. -** ========================================================================= -*/ - -#include - -static void ll_unloadlib (void *lib) { - dlclose(lib); -} - - -static void *ll_load (lua_State *L, const char *path) { - void *lib = dlopen(path, RTLD_NOW); - if (lib == NULL) lua_pushstring(L, dlerror()); - return lib; -} - - -static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { - lua_CFunction f = (lua_CFunction)dlsym(lib, sym); - if (f == NULL) lua_pushstring(L, dlerror()); - return f; -} - -/* }====================================================== */ - - - -#elif defined(LUA_DL_DLL) -/* -** {====================================================================== -** This is an implementation of loadlib for Windows using native functions. -** ======================================================================= -*/ - -#include - - -#undef setprogdir - -static void setprogdir (lua_State *L) { - char buff[MAX_PATH + 1]; - char *lb; - DWORD nsize = sizeof(buff)/sizeof(char); - DWORD n = GetModuleFileNameA(NULL, buff, nsize); - if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) - luaL_error(L, "unable to get ModuleFileName"); - else { - *lb = '\0'; - luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); - lua_remove(L, -2); /* remove original string */ - } -} - - -static void pusherror (lua_State *L) { - int error = GetLastError(); - char buffer[128]; - if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, 0, buffer, sizeof(buffer), NULL)) - lua_pushstring(L, buffer); - else - lua_pushfstring(L, "system error %d\n", error); -} - -static void ll_unloadlib (void *lib) { - FreeLibrary((HINSTANCE)lib); -} - - -static void *ll_load (lua_State *L, const char *path) { - HINSTANCE lib = LoadLibraryA(path); - if (lib == NULL) pusherror(L); - return lib; -} - - -static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { - lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); - if (f == NULL) pusherror(L); - return f; -} - -/* }====================================================== */ - - - -#elif defined(LUA_DL_DYLD) -/* -** {====================================================================== -** Native Mac OS X / Darwin Implementation -** ======================================================================= -*/ - -#include - - -/* Mac appends a `_' before C function names */ -#undef POF -#define POF "_" LUA_POF - - -static void pusherror (lua_State *L) { - const char *err_str; - const char *err_file; - NSLinkEditErrors err; - int err_num; - NSLinkEditError(&err, &err_num, &err_file, &err_str); - lua_pushstring(L, err_str); -} - - -static const char *errorfromcode (NSObjectFileImageReturnCode ret) { - switch (ret) { - case NSObjectFileImageInappropriateFile: - return "file is not a bundle"; - case NSObjectFileImageArch: - return "library is for wrong CPU type"; - case NSObjectFileImageFormat: - return "bad format"; - case NSObjectFileImageAccess: - return "cannot access file"; - case NSObjectFileImageFailure: - default: - return "unable to load library"; - } -} - - -static void ll_unloadlib (void *lib) { - NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); -} - - -static void *ll_load (lua_State *L, const char *path) { - NSObjectFileImage img; - NSObjectFileImageReturnCode ret; - /* this would be a rare case, but prevents crashing if it happens */ - if(!_dyld_present()) { - lua_pushliteral(L, "dyld not present"); - return NULL; - } - ret = NSCreateObjectFileImageFromFile(path, &img); - if (ret == NSObjectFileImageSuccess) { - NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | - NSLINKMODULE_OPTION_RETURN_ON_ERROR); - NSDestroyObjectFileImage(img); - if (mod == NULL) pusherror(L); - return mod; - } - lua_pushstring(L, errorfromcode(ret)); - return NULL; -} - - -static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { - NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); - if (nss == NULL) { - lua_pushfstring(L, "symbol " LUA_QS " not found", sym); - return NULL; - } - return (lua_CFunction)NSAddressOfSymbol(nss); -} - -/* }====================================================== */ - - - -#else -/* -** {====================================================== -** Fallback for other systems -** ======================================================= -*/ - -#undef LIB_FAIL -#define LIB_FAIL "absent" - - -#define DLMSG "dynamic libraries not enabled; check your Lua installation" - - -static void ll_unloadlib (void *lib) { - (void)lib; /* to avoid warnings */ -} - - -static void *ll_load (lua_State *L, const char *path) { - (void)path; /* to avoid warnings */ - lua_pushliteral(L, DLMSG); - return NULL; -} - - -static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { - (void)lib; (void)sym; /* to avoid warnings */ - lua_pushliteral(L, DLMSG); - return NULL; -} - -/* }====================================================== */ -#endif - - - -static void **ll_register (lua_State *L, const char *path) { - void **plib; - lua_pushfstring(L, "%s%s", LIBPREFIX, path); - lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ - if (!lua_isnil(L, -1)) /* is there an entry? */ - plib = (void **)lua_touserdata(L, -1); - else { /* no entry yet; create one */ - lua_pop(L, 1); - plib = (void **)lua_newuserdata(L, sizeof(const void *)); - *plib = NULL; - luaL_getmetatable(L, "_LOADLIB"); - lua_setmetatable(L, -2); - lua_pushfstring(L, "%s%s", LIBPREFIX, path); - lua_pushvalue(L, -2); - lua_settable(L, LUA_REGISTRYINDEX); - } - return plib; -} - - -/* -** __gc tag method: calls library's `ll_unloadlib' function with the lib -** handle -*/ -static int gctm (lua_State *L) { - void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); - if (*lib) ll_unloadlib(*lib); - *lib = NULL; /* mark library as closed */ - return 0; -} - - -static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { - void **reg = ll_register(L, path); - if (*reg == NULL) *reg = ll_load(L, path); - if (*reg == NULL) - return ERRLIB; /* unable to load library */ - else { - lua_CFunction f = ll_sym(L, *reg, sym); - if (f == NULL) - return ERRFUNC; /* unable to find function */ - lua_pushcfunction(L, f); - return 0; /* return function */ - } -} - - -static int ll_loadlib (lua_State *L) { - const char *path = luaL_checkstring(L, 1); - const char *init = luaL_checkstring(L, 2); - int stat = ll_loadfunc(L, path, init); - if (stat == 0) /* no errors? */ - return 1; /* return the loaded function */ - else { /* error; error message is on stack top */ - lua_pushnil(L); - lua_insert(L, -2); - lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); - return 3; /* return nil, error message, and where */ - } -} - - - -/* -** {====================================================== -** 'require' function -** ======================================================= -*/ - - -static int readable (const char *filename) { - FILE *f = fopen(filename, "r"); /* try to open file */ - if (f == NULL) return 0; /* open failed */ - fclose(f); - return 1; -} - - -static const char *pushnexttemplate (lua_State *L, const char *path) { - const char *l; - while (*path == *LUA_PATHSEP) path++; /* skip separators */ - if (*path == '\0') return NULL; /* no more templates */ - l = strchr(path, *LUA_PATHSEP); /* find next separator */ - if (l == NULL) l = path + strlen(path); - lua_pushlstring(L, path, l - path); /* template */ - return l; -} - - -static const char *findfile (lua_State *L, const char *name, - const char *pname) { - const char *path; - name = luaL_gsub(L, name, ".", LUA_DIRSEP); - lua_getfield(L, LUA_ENVIRONINDEX, pname); - path = lua_tostring(L, -1); - if (path == NULL) - luaL_error(L, LUA_QL("package.%s") " must be a string", pname); - lua_pushliteral(L, ""); /* error accumulator */ - while ((path = pushnexttemplate(L, path)) != NULL) { - const char *filename; - filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); - lua_remove(L, -2); /* remove path template */ - if (readable(filename)) /* does file exist and is readable? */ - return filename; /* return that file name */ - lua_pushfstring(L, "\n\tno file " LUA_QS, filename); - lua_remove(L, -2); /* remove file name */ - lua_concat(L, 2); /* add entry to possible error message */ - } - return NULL; /* not found */ -} - - -static void loaderror (lua_State *L, const char *filename) { - luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", - lua_tostring(L, 1), filename, lua_tostring(L, -1)); -} - - -static int loader_Lua (lua_State *L) { - const char *filename; - const char *name = luaL_checkstring(L, 1); - filename = findfile(L, name, "path"); - if (filename == NULL) return 1; /* library not found in this path */ - if (luaL_loadfile(L, filename) != 0) - loaderror(L, filename); - return 1; /* library loaded successfully */ -} - - -static const char *mkfuncname (lua_State *L, const char *modname) { - const char *funcname; - const char *mark = strchr(modname, *LUA_IGMARK); - if (mark) modname = mark + 1; - funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); - funcname = lua_pushfstring(L, POF"%s", funcname); - lua_remove(L, -2); /* remove 'gsub' result */ - return funcname; -} - - -static int loader_C (lua_State *L) { - const char *funcname; - const char *name = luaL_checkstring(L, 1); - const char *filename = findfile(L, name, "cpath"); - if (filename == NULL) return 1; /* library not found in this path */ - funcname = mkfuncname(L, name); - if (ll_loadfunc(L, filename, funcname) != 0) - loaderror(L, filename); - return 1; /* library loaded successfully */ -} - - -static int loader_Croot (lua_State *L) { - const char *funcname; - const char *filename; - const char *name = luaL_checkstring(L, 1); - const char *p = strchr(name, '.'); - int stat; - if (p == NULL) return 0; /* is root */ - lua_pushlstring(L, name, p - name); - filename = findfile(L, lua_tostring(L, -1), "cpath"); - if (filename == NULL) return 1; /* root not found */ - funcname = mkfuncname(L, name); - if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { - if (stat != ERRFUNC) loaderror(L, filename); /* real error */ - lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, - name, filename); - return 1; /* function not found */ - } - return 1; -} - - -static int loader_preload (lua_State *L) { - const char *name = luaL_checkstring(L, 1); - lua_getfield(L, LUA_ENVIRONINDEX, "preload"); - if (!lua_istable(L, -1)) - luaL_error(L, LUA_QL("package.preload") " must be a table"); - lua_getfield(L, -1, name); - if (lua_isnil(L, -1)) /* not found? */ - lua_pushfstring(L, "\n\tno field package.preload['%s']", name); - return 1; -} - - -static const int sentinel_ = 0; -#define sentinel ((void *)&sentinel_) - - -static int ll_require (lua_State *L) { - const char *name = luaL_checkstring(L, 1); - int i; - lua_settop(L, 1); /* _LOADED table will be at index 2 */ - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, 2, name); - if (lua_toboolean(L, -1)) { /* is it there? */ - if (lua_touserdata(L, -1) == sentinel) /* check loops */ - luaL_error(L, "loop or previous error loading module " LUA_QS, name); - return 1; /* package is already loaded */ - } - /* else must load it; iterate over available loaders */ - lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); - if (!lua_istable(L, -1)) - luaL_error(L, LUA_QL("package.loaders") " must be a table"); - lua_pushliteral(L, ""); /* error message accumulator */ - for (i=1; ; i++) { - lua_rawgeti(L, -2, i); /* get a loader */ - if (lua_isnil(L, -1)) - luaL_error(L, "module " LUA_QS " not found:%s", - name, lua_tostring(L, -2)); - lua_pushstring(L, name); - lua_call(L, 1, 1); /* call it */ - if (lua_isfunction(L, -1)) /* did it find module? */ - break; /* module loaded successfully */ - else if (lua_isstring(L, -1)) /* loader returned error message? */ - lua_concat(L, 2); /* accumulate it */ - else - lua_pop(L, 1); - } - lua_pushlightuserdata(L, sentinel); - lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ - lua_pushstring(L, name); /* pass name as argument to module */ - lua_call(L, 1, 1); /* run loaded module */ - if (!lua_isnil(L, -1)) /* non-nil return? */ - lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ - lua_getfield(L, 2, name); - if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ - lua_pushboolean(L, 1); /* use true as result */ - lua_pushvalue(L, -1); /* extra copy to be returned */ - lua_setfield(L, 2, name); /* _LOADED[name] = true */ - } - return 1; -} - -/* }====================================================== */ - - - -/* -** {====================================================== -** 'module' function -** ======================================================= -*/ - - -static void setfenv (lua_State *L) { - lua_Debug ar; - if (lua_getstack(L, 1, &ar) == 0 || - lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ - lua_iscfunction(L, -1)) - luaL_error(L, LUA_QL("module") " not called from a Lua function"); - lua_pushvalue(L, -2); - lua_setfenv(L, -2); - lua_pop(L, 1); -} - - -static void dooptions (lua_State *L, int n) { - int i; - for (i = 2; i <= n; i++) { - lua_pushvalue(L, i); /* get option (a function) */ - lua_pushvalue(L, -2); /* module */ - lua_call(L, 1, 0); - } -} - - -static void modinit (lua_State *L, const char *modname) { - const char *dot; - lua_pushvalue(L, -1); - lua_setfield(L, -2, "_M"); /* module._M = module */ - lua_pushstring(L, modname); - lua_setfield(L, -2, "_NAME"); - dot = strrchr(modname, '.'); /* look for last dot in module name */ - if (dot == NULL) dot = modname; - else dot++; - /* set _PACKAGE as package name (full module name minus last part) */ - lua_pushlstring(L, modname, dot - modname); - lua_setfield(L, -2, "_PACKAGE"); -} - - -static int ll_module (lua_State *L) { - const char *modname = luaL_checkstring(L, 1); - int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ - if (!lua_istable(L, -1)) { /* not found? */ - lua_pop(L, 1); /* remove previous result */ - /* try global variable (and create one if it does not exist) */ - if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) - return luaL_error(L, "name conflict for module " LUA_QS, modname); - lua_pushvalue(L, -1); - lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ - } - /* check whether table already has a _NAME field */ - lua_getfield(L, -1, "_NAME"); - if (!lua_isnil(L, -1)) /* is table an initialized module? */ - lua_pop(L, 1); - else { /* no; initialize it */ - lua_pop(L, 1); - modinit(L, modname); - } - lua_pushvalue(L, -1); - setfenv(L); - dooptions(L, loaded - 1); - return 0; -} - - -static int ll_seeall (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - if (!lua_getmetatable(L, 1)) { - lua_createtable(L, 0, 1); /* create new metatable */ - lua_pushvalue(L, -1); - lua_setmetatable(L, 1); - } - lua_pushvalue(L, LUA_GLOBALSINDEX); - lua_setfield(L, -2, "__index"); /* mt.__index = _G */ - return 0; -} - - -/* }====================================================== */ - - - -/* auxiliary mark (for internal use) */ -#define AUXMARK "\1" - -static void setpath (lua_State *L, const char *fieldname, const char *envname, - const char *def) { - const char *path = getenv(envname); - if (path == NULL) /* no environment variable? */ - lua_pushstring(L, def); /* use default */ - else { - /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ - path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, - LUA_PATHSEP AUXMARK LUA_PATHSEP); - luaL_gsub(L, path, AUXMARK, def); - lua_remove(L, -2); - } - setprogdir(L); - lua_setfield(L, -2, fieldname); -} - - -static const luaL_Reg pk_funcs[] = { - {"loadlib", ll_loadlib}, - {"seeall", ll_seeall}, - {NULL, NULL} -}; - - -static const luaL_Reg ll_funcs[] = { - {"module", ll_module}, - {"require", ll_require}, - {NULL, NULL} -}; - - -static const lua_CFunction loaders[] = - {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; - - -LUALIB_API int luaopen_package (lua_State *L) { - int i; - /* create new type _LOADLIB */ - luaL_newmetatable(L, "_LOADLIB"); - lua_pushcfunction(L, gctm); - lua_setfield(L, -2, "__gc"); - /* create `package' table */ - luaL_register(L, LUA_LOADLIBNAME, pk_funcs); -#if defined(LUA_COMPAT_LOADLIB) - lua_getfield(L, -1, "loadlib"); - lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); -#endif - lua_pushvalue(L, -1); - lua_replace(L, LUA_ENVIRONINDEX); - /* create `loaders' table */ - lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); - /* fill it with pre-defined loaders */ - for (i=0; loaders[i] != NULL; i++) { - lua_pushcfunction(L, loaders[i]); - lua_rawseti(L, -2, i+1); - } - lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ - setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ - setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ - /* store config information */ - lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" - LUA_EXECDIR "\n" LUA_IGMARK); - lua_setfield(L, -2, "config"); - /* set field `loaded' */ - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); - lua_setfield(L, -2, "loaded"); - /* set field `preload' */ - lua_newtable(L); - lua_setfield(L, -2, "preload"); - lua_pushvalue(L, LUA_GLOBALSINDEX); - luaL_register(L, NULL, ll_funcs); /* open lib into global table */ - lua_pop(L, 1); - return 1; /* return 'package' table */ -} - diff -Nru gpick-0.2.4/extern/lua/src/lobject.c gpick-0.2.5/extern/lua/src/lobject.c --- gpick-0.2.4/extern/lua/src/lobject.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lobject.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -/* -** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ -** Some generic functions over Lua objects -** See Copyright Notice in lua.h -*/ - -#include -#include -#include -#include -#include - -#define lobject_c -#define LUA_CORE - -#include "lua.h" - -#include "ldo.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "lvm.h" - - - -const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; - - -/* -** converts an integer to a "floating point byte", represented as -** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if -** eeeee != 0 and (xxx) otherwise. -*/ -int luaO_int2fb (unsigned int x) { - int e = 0; /* expoent */ - while (x >= 16) { - x = (x+1) >> 1; - e++; - } - if (x < 8) return x; - else return ((e+1) << 3) | (cast_int(x) - 8); -} - - -/* converts back */ -int luaO_fb2int (int x) { - int e = (x >> 3) & 31; - if (e == 0) return x; - else return ((x & 7)+8) << (e - 1); -} - - -int luaO_log2 (unsigned int x) { - static const lu_byte log_2[256] = { - 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 - }; - int l = -1; - while (x >= 256) { l += 8; x >>= 8; } - return l + log_2[x]; - -} - - -int luaO_rawequalObj (const TValue *t1, const TValue *t2) { - if (ttype(t1) != ttype(t2)) return 0; - else switch (ttype(t1)) { - case LUA_TNIL: - return 1; - case LUA_TNUMBER: - return luai_numeq(nvalue(t1), nvalue(t2)); - case LUA_TBOOLEAN: - return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ - case LUA_TLIGHTUSERDATA: - return pvalue(t1) == pvalue(t2); - default: - lua_assert(iscollectable(t1)); - return gcvalue(t1) == gcvalue(t2); - } -} - - -int luaO_str2d (const char *s, lua_Number *result) { - char *endptr; - *result = lua_str2number(s, &endptr); - if (endptr == s) return 0; /* conversion failed */ - if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ - *result = cast_num(strtoul(s, &endptr, 16)); - if (*endptr == '\0') return 1; /* most common case */ - while (isspace(cast(unsigned char, *endptr))) endptr++; - if (*endptr != '\0') return 0; /* invalid trailing characters? */ - return 1; -} - - - -static void pushstr (lua_State *L, const char *str) { - setsvalue2s(L, L->top, luaS_new(L, str)); - incr_top(L); -} - - -/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ -const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { - int n = 1; - pushstr(L, ""); - for (;;) { - const char *e = strchr(fmt, '%'); - if (e == NULL) break; - setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); - incr_top(L); - switch (*(e+1)) { - case 's': { - const char *s = va_arg(argp, char *); - if (s == NULL) s = "(null)"; - pushstr(L, s); - break; - } - case 'c': { - char buff[2]; - buff[0] = cast(char, va_arg(argp, int)); - buff[1] = '\0'; - pushstr(L, buff); - break; - } - case 'd': { - setnvalue(L->top, cast_num(va_arg(argp, int))); - incr_top(L); - break; - } - case 'f': { - setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); - incr_top(L); - break; - } - case 'p': { - char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ - sprintf(buff, "%p", va_arg(argp, void *)); - pushstr(L, buff); - break; - } - case '%': { - pushstr(L, "%"); - break; - } - default: { - char buff[3]; - buff[0] = '%'; - buff[1] = *(e+1); - buff[2] = '\0'; - pushstr(L, buff); - break; - } - } - n += 2; - fmt = e+2; - } - pushstr(L, fmt); - luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); - L->top -= n; - return svalue(L->top - 1); -} - - -const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { - const char *msg; - va_list argp; - va_start(argp, fmt); - msg = luaO_pushvfstring(L, fmt, argp); - va_end(argp); - return msg; -} - - -void luaO_chunkid (char *out, const char *source, size_t bufflen) { - if (*source == '=') { - strncpy(out, source+1, bufflen); /* remove first char */ - out[bufflen-1] = '\0'; /* ensures null termination */ - } - else { /* out = "source", or "...source" */ - if (*source == '@') { - size_t l; - source++; /* skip the `@' */ - bufflen -= sizeof(" '...' "); - l = strlen(source); - strcpy(out, ""); - if (l > bufflen) { - source += (l-bufflen); /* get last part of file name */ - strcat(out, "..."); - } - strcat(out, source); - } - else { /* out = [string "string"] */ - size_t len = strcspn(source, "\n\r"); /* stop at first newline */ - bufflen -= sizeof(" [string \"...\"] "); - if (len > bufflen) len = bufflen; - strcpy(out, "[string \""); - if (source[len] != '\0') { /* must truncate? */ - strncat(out, source, len); - strcat(out, "..."); - } - else - strcat(out, source); - strcat(out, "\"]"); - } - } -} diff -Nru gpick-0.2.4/extern/lua/src/lobject.h gpick-0.2.5/extern/lua/src/lobject.h --- gpick-0.2.4/extern/lua/src/lobject.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lobject.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,381 +0,0 @@ -/* -** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ -** Type definitions for Lua objects -** See Copyright Notice in lua.h -*/ - - -#ifndef lobject_h -#define lobject_h - - -#include - - -#include "llimits.h" -#include "lua.h" - - -/* tags for values visible from Lua */ -#define LAST_TAG LUA_TTHREAD - -#define NUM_TAGS (LAST_TAG+1) - - -/* -** Extra tags for non-values -*/ -#define LUA_TPROTO (LAST_TAG+1) -#define LUA_TUPVAL (LAST_TAG+2) -#define LUA_TDEADKEY (LAST_TAG+3) - - -/* -** Union of all collectable objects -*/ -typedef union GCObject GCObject; - - -/* -** Common Header for all collectable objects (in macro form, to be -** included in other objects) -*/ -#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked - - -/* -** Common header in struct form -*/ -typedef struct GCheader { - CommonHeader; -} GCheader; - - - - -/* -** Union of all Lua values -*/ -typedef union { - GCObject *gc; - void *p; - lua_Number n; - int b; -} Value; - - -/* -** Tagged Values -*/ - -#define TValuefields Value value; int tt - -typedef struct lua_TValue { - TValuefields; -} TValue; - - -/* Macros to test type */ -#define ttisnil(o) (ttype(o) == LUA_TNIL) -#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) -#define ttisstring(o) (ttype(o) == LUA_TSTRING) -#define ttistable(o) (ttype(o) == LUA_TTABLE) -#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) -#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) -#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) -#define ttisthread(o) (ttype(o) == LUA_TTHREAD) -#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) - -/* Macros to access values */ -#define ttype(o) ((o)->tt) -#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) -#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) -#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) -#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) -#define tsvalue(o) (&rawtsvalue(o)->tsv) -#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) -#define uvalue(o) (&rawuvalue(o)->uv) -#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) -#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) -#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) -#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) - -#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) - -/* -** for internal debug only -*/ -#define checkconsistency(obj) \ - lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) - -#define checkliveness(g,obj) \ - lua_assert(!iscollectable(obj) || \ - ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) - - -/* Macros to set values */ -#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) - -#define setnvalue(obj,x) \ - { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } - -#define setpvalue(obj,x) \ - { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } - -#define setbvalue(obj,x) \ - { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } - -#define setsvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ - checkliveness(G(L),i_o); } - -#define setuvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ - checkliveness(G(L),i_o); } - -#define setthvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ - checkliveness(G(L),i_o); } - -#define setclvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ - checkliveness(G(L),i_o); } - -#define sethvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ - checkliveness(G(L),i_o); } - -#define setptvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ - checkliveness(G(L),i_o); } - - - - -#define setobj(L,obj1,obj2) \ - { const TValue *o2=(obj2); TValue *o1=(obj1); \ - o1->value = o2->value; o1->tt=o2->tt; \ - checkliveness(G(L),o1); } - - -/* -** different types of sets, according to destination -*/ - -/* from stack to (same) stack */ -#define setobjs2s setobj -/* to stack (not from same stack) */ -#define setobj2s setobj -#define setsvalue2s setsvalue -#define sethvalue2s sethvalue -#define setptvalue2s setptvalue -/* from table to same table */ -#define setobjt2t setobj -/* to table */ -#define setobj2t setobj -/* to new object */ -#define setobj2n setobj -#define setsvalue2n setsvalue - -#define setttype(obj, tt) (ttype(obj) = (tt)) - - -#define iscollectable(o) (ttype(o) >= LUA_TSTRING) - - - -typedef TValue *StkId; /* index to stack elements */ - - -/* -** String headers for string table -*/ -typedef union TString { - L_Umaxalign dummy; /* ensures maximum alignment for strings */ - struct { - CommonHeader; - lu_byte reserved; - unsigned int hash; - size_t len; - } tsv; -} TString; - - -#define getstr(ts) cast(const char *, (ts) + 1) -#define svalue(o) getstr(rawtsvalue(o)) - - - -typedef union Udata { - L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ - struct { - CommonHeader; - struct Table *metatable; - struct Table *env; - size_t len; - } uv; -} Udata; - - - - -/* -** Function Prototypes -*/ -typedef struct Proto { - CommonHeader; - TValue *k; /* constants used by the function */ - Instruction *code; - struct Proto **p; /* functions defined inside the function */ - int *lineinfo; /* map from opcodes to source lines */ - struct LocVar *locvars; /* information about local variables */ - TString **upvalues; /* upvalue names */ - TString *source; - int sizeupvalues; - int sizek; /* size of `k' */ - int sizecode; - int sizelineinfo; - int sizep; /* size of `p' */ - int sizelocvars; - int linedefined; - int lastlinedefined; - GCObject *gclist; - lu_byte nups; /* number of upvalues */ - lu_byte numparams; - lu_byte is_vararg; - lu_byte maxstacksize; -} Proto; - - -/* masks for new-style vararg */ -#define VARARG_HASARG 1 -#define VARARG_ISVARARG 2 -#define VARARG_NEEDSARG 4 - - -typedef struct LocVar { - TString *varname; - int startpc; /* first point where variable is active */ - int endpc; /* first point where variable is dead */ -} LocVar; - - - -/* -** Upvalues -*/ - -typedef struct UpVal { - CommonHeader; - TValue *v; /* points to stack or to its own value */ - union { - TValue value; /* the value (when closed) */ - struct { /* double linked list (when open) */ - struct UpVal *prev; - struct UpVal *next; - } l; - } u; -} UpVal; - - -/* -** Closures -*/ - -#define ClosureHeader \ - CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ - struct Table *env - -typedef struct CClosure { - ClosureHeader; - lua_CFunction f; - TValue upvalue[1]; -} CClosure; - - -typedef struct LClosure { - ClosureHeader; - struct Proto *p; - UpVal *upvals[1]; -} LClosure; - - -typedef union Closure { - CClosure c; - LClosure l; -} Closure; - - -#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) -#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) - - -/* -** Tables -*/ - -typedef union TKey { - struct { - TValuefields; - struct Node *next; /* for chaining */ - } nk; - TValue tvk; -} TKey; - - -typedef struct Node { - TValue i_val; - TKey i_key; -} Node; - - -typedef struct Table { - CommonHeader; - lu_byte flags; /* 1<

lsizenode)) - - -#define luaO_nilobject (&luaO_nilobject_) - -LUAI_DATA const TValue luaO_nilobject_; - -#define ceillog2(x) (luaO_log2((x)-1) + 1) - -LUAI_FUNC int luaO_log2 (unsigned int x); -LUAI_FUNC int luaO_int2fb (unsigned int x); -LUAI_FUNC int luaO_fb2int (int x); -LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); -LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); -LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, - va_list argp); -LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); -LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); - - -#endif - diff -Nru gpick-0.2.4/extern/lua/src/lopcodes.c gpick-0.2.5/extern/lua/src/lopcodes.c --- gpick-0.2.4/extern/lua/src/lopcodes.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lopcodes.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -/* -** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ -** See Copyright Notice in lua.h -*/ - - -#define lopcodes_c -#define LUA_CORE - - -#include "lopcodes.h" - - -/* ORDER OP */ - -const char *const luaP_opnames[NUM_OPCODES+1] = { - "MOVE", - "LOADK", - "LOADBOOL", - "LOADNIL", - "GETUPVAL", - "GETGLOBAL", - "GETTABLE", - "SETGLOBAL", - "SETUPVAL", - "SETTABLE", - "NEWTABLE", - "SELF", - "ADD", - "SUB", - "MUL", - "DIV", - "MOD", - "POW", - "UNM", - "NOT", - "LEN", - "CONCAT", - "JMP", - "EQ", - "LT", - "LE", - "TEST", - "TESTSET", - "CALL", - "TAILCALL", - "RETURN", - "FORLOOP", - "FORPREP", - "TFORLOOP", - "SETLIST", - "CLOSE", - "CLOSURE", - "VARARG", - NULL -}; - - -#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) - -const lu_byte luaP_opmodes[NUM_OPCODES] = { -/* T A B C mode opcode */ - opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ - ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ - ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ - ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ - ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ - ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ - ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ - ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ - ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ - ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ - ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ - ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ - ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ - ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ - ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ - ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ - ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ - ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ - ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ - ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ - ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ -}; - diff -Nru gpick-0.2.4/extern/lua/src/lopcodes.h gpick-0.2.5/extern/lua/src/lopcodes.h --- gpick-0.2.4/extern/lua/src/lopcodes.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lopcodes.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,268 +0,0 @@ -/* -** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ -** Opcodes for Lua virtual machine -** See Copyright Notice in lua.h -*/ - -#ifndef lopcodes_h -#define lopcodes_h - -#include "llimits.h" - - -/*=========================================================================== - We assume that instructions are unsigned numbers. - All instructions have an opcode in the first 6 bits. - Instructions can have the following fields: - `A' : 8 bits - `B' : 9 bits - `C' : 9 bits - `Bx' : 18 bits (`B' and `C' together) - `sBx' : signed Bx - - A signed argument is represented in excess K; that is, the number - value is the unsigned value minus K. K is exactly the maximum value - for that argument (so that -max is represented by 0, and +max is - represented by 2*max), which is half the maximum for the corresponding - unsigned argument. -===========================================================================*/ - - -enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ - - -/* -** size and position of opcode arguments. -*/ -#define SIZE_C 9 -#define SIZE_B 9 -#define SIZE_Bx (SIZE_C + SIZE_B) -#define SIZE_A 8 - -#define SIZE_OP 6 - -#define POS_OP 0 -#define POS_A (POS_OP + SIZE_OP) -#define POS_C (POS_A + SIZE_A) -#define POS_B (POS_C + SIZE_C) -#define POS_Bx POS_C - - -/* -** limits for opcode arguments. -** we use (signed) int to manipulate most arguments, -** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) -*/ -#if SIZE_Bx < LUAI_BITSINT-1 -#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ -#else -#define MAXARG_Bx MAX_INT -#define MAXARG_sBx MAX_INT -#endif - - -#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) -#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ - ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) -#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ - ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) -#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ - ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) -#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ - ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) -#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ - ((cast(Instruction, b)< C) then pc++ */ -OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ - -OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ -OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ -OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ - -OP_FORLOOP,/* A sBx R(A)+=R(A+2); - if R(A) =) R(A)*/ -OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ - -OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ -} OpCode; - - -#define NUM_OPCODES (cast(int, OP_VARARG) + 1) - - - -/*=========================================================================== - Notes: - (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, - and can be 0: OP_CALL then sets `top' to last_result+1, so - next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. - - (*) In OP_VARARG, if (B == 0) then use actual number of varargs and - set top (like in OP_CALL with C == 0). - - (*) In OP_RETURN, if (B == 0) then return up to `top' - - (*) In OP_SETLIST, if (B == 0) then B = `top'; - if (C == 0) then next `instruction' is real C - - (*) For comparisons, A specifies what condition the test should accept - (true or false). - - (*) All `skips' (pc++) assume that next instruction is a jump -===========================================================================*/ - - -/* -** masks for instruction properties. The format is: -** bits 0-1: op mode -** bits 2-3: C arg mode -** bits 4-5: B arg mode -** bit 6: instruction set register A -** bit 7: operator is a test -*/ - -enum OpArgMask { - OpArgN, /* argument is not used */ - OpArgU, /* argument is used */ - OpArgR, /* argument is a register or a jump offset */ - OpArgK /* argument is a constant or register/constant */ -}; - -LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; - -#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) -#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) -#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) -#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) -#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) - - -LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ - - -/* number of list items to accumulate before a SETLIST instruction */ -#define LFIELDS_PER_FLUSH 50 - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/loslib.c gpick-0.2.5/extern/lua/src/loslib.c --- gpick-0.2.4/extern/lua/src/loslib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/loslib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,243 +0,0 @@ -/* -** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ -** Standard Operating System library -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include -#include -#include - -#define loslib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -static int os_pushresult (lua_State *L, int i, const char *filename) { - int en = errno; /* calls to Lua API may change this value */ - if (i) { - lua_pushboolean(L, 1); - return 1; - } - else { - lua_pushnil(L); - lua_pushfstring(L, "%s: %s", filename, strerror(en)); - lua_pushinteger(L, en); - return 3; - } -} - - -static int os_execute (lua_State *L) { - lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); - return 1; -} - - -static int os_remove (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - return os_pushresult(L, remove(filename) == 0, filename); -} - - -static int os_rename (lua_State *L) { - const char *fromname = luaL_checkstring(L, 1); - const char *toname = luaL_checkstring(L, 2); - return os_pushresult(L, rename(fromname, toname) == 0, fromname); -} - - -static int os_tmpname (lua_State *L) { - char buff[LUA_TMPNAMBUFSIZE]; - int err; - lua_tmpnam(buff, err); - if (err) - return luaL_error(L, "unable to generate a unique filename"); - lua_pushstring(L, buff); - return 1; -} - - -static int os_getenv (lua_State *L) { - lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ - return 1; -} - - -static int os_clock (lua_State *L) { - lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); - return 1; -} - - -/* -** {====================================================== -** Time/Date operations -** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, -** wday=%w+1, yday=%j, isdst=? } -** ======================================================= -*/ - -static void setfield (lua_State *L, const char *key, int value) { - lua_pushinteger(L, value); - lua_setfield(L, -2, key); -} - -static void setboolfield (lua_State *L, const char *key, int value) { - if (value < 0) /* undefined? */ - return; /* does not set field */ - lua_pushboolean(L, value); - lua_setfield(L, -2, key); -} - -static int getboolfield (lua_State *L, const char *key) { - int res; - lua_getfield(L, -1, key); - res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); - lua_pop(L, 1); - return res; -} - - -static int getfield (lua_State *L, const char *key, int d) { - int res; - lua_getfield(L, -1, key); - if (lua_isnumber(L, -1)) - res = (int)lua_tointeger(L, -1); - else { - if (d < 0) - return luaL_error(L, "field " LUA_QS " missing in date table", key); - res = d; - } - lua_pop(L, 1); - return res; -} - - -static int os_date (lua_State *L) { - const char *s = luaL_optstring(L, 1, "%c"); - time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); - struct tm *stm; - if (*s == '!') { /* UTC? */ - stm = gmtime(&t); - s++; /* skip `!' */ - } - else - stm = localtime(&t); - if (stm == NULL) /* invalid date? */ - lua_pushnil(L); - else if (strcmp(s, "*t") == 0) { - lua_createtable(L, 0, 9); /* 9 = number of fields */ - setfield(L, "sec", stm->tm_sec); - setfield(L, "min", stm->tm_min); - setfield(L, "hour", stm->tm_hour); - setfield(L, "day", stm->tm_mday); - setfield(L, "month", stm->tm_mon+1); - setfield(L, "year", stm->tm_year+1900); - setfield(L, "wday", stm->tm_wday+1); - setfield(L, "yday", stm->tm_yday+1); - setboolfield(L, "isdst", stm->tm_isdst); - } - else { - char cc[3]; - luaL_Buffer b; - cc[0] = '%'; cc[2] = '\0'; - luaL_buffinit(L, &b); - for (; *s; s++) { - if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ - luaL_addchar(&b, *s); - else { - size_t reslen; - char buff[200]; /* should be big enough for any conversion result */ - cc[1] = *(++s); - reslen = strftime(buff, sizeof(buff), cc, stm); - luaL_addlstring(&b, buff, reslen); - } - } - luaL_pushresult(&b); - } - return 1; -} - - -static int os_time (lua_State *L) { - time_t t; - if (lua_isnoneornil(L, 1)) /* called without args? */ - t = time(NULL); /* get current time */ - else { - struct tm ts; - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 1); /* make sure table is at the top */ - ts.tm_sec = getfield(L, "sec", 0); - ts.tm_min = getfield(L, "min", 0); - ts.tm_hour = getfield(L, "hour", 12); - ts.tm_mday = getfield(L, "day", -1); - ts.tm_mon = getfield(L, "month", -1) - 1; - ts.tm_year = getfield(L, "year", -1) - 1900; - ts.tm_isdst = getboolfield(L, "isdst"); - t = mktime(&ts); - } - if (t == (time_t)(-1)) - lua_pushnil(L); - else - lua_pushnumber(L, (lua_Number)t); - return 1; -} - - -static int os_difftime (lua_State *L) { - lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), - (time_t)(luaL_optnumber(L, 2, 0)))); - return 1; -} - -/* }====================================================== */ - - -static int os_setlocale (lua_State *L) { - static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, - LC_NUMERIC, LC_TIME}; - static const char *const catnames[] = {"all", "collate", "ctype", "monetary", - "numeric", "time", NULL}; - const char *l = luaL_optstring(L, 1, NULL); - int op = luaL_checkoption(L, 2, "all", catnames); - lua_pushstring(L, setlocale(cat[op], l)); - return 1; -} - - -static int os_exit (lua_State *L) { - exit(luaL_optint(L, 1, EXIT_SUCCESS)); -} - -static const luaL_Reg syslib[] = { - {"clock", os_clock}, - {"date", os_date}, - {"difftime", os_difftime}, - {"execute", os_execute}, - {"exit", os_exit}, - {"getenv", os_getenv}, - {"remove", os_remove}, - {"rename", os_rename}, - {"setlocale", os_setlocale}, - {"time", os_time}, - {"tmpname", os_tmpname}, - {NULL, NULL} -}; - -/* }====================================================== */ - - - -LUALIB_API int luaopen_os (lua_State *L) { - luaL_register(L, LUA_OSLIBNAME, syslib); - return 1; -} - diff -Nru gpick-0.2.4/extern/lua/src/lparser.c gpick-0.2.5/extern/lua/src/lparser.c --- gpick-0.2.4/extern/lua/src/lparser.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lparser.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1339 +0,0 @@ -/* -** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ -** Lua Parser -** See Copyright Notice in lua.h -*/ - - -#include - -#define lparser_c -#define LUA_CORE - -#include "lua.h" - -#include "lcode.h" -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "llex.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" - - - -#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) - -#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) - -#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) - - -/* -** nodes for block list (list of active blocks) -*/ -typedef struct BlockCnt { - struct BlockCnt *previous; /* chain */ - int breaklist; /* list of jumps out of this loop */ - lu_byte nactvar; /* # active locals outside the breakable structure */ - lu_byte upval; /* true if some variable in the block is an upvalue */ - lu_byte isbreakable; /* true if `block' is a loop */ -} BlockCnt; - - - -/* -** prototypes for recursive non-terminal functions -*/ -static void chunk (LexState *ls); -static void expr (LexState *ls, expdesc *v); - - -static void anchor_token (LexState *ls) { - if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { - TString *ts = ls->t.seminfo.ts; - luaX_newstring(ls, getstr(ts), ts->tsv.len); - } -} - - -static void error_expected (LexState *ls, int token) { - luaX_syntaxerror(ls, - luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); -} - - -static void errorlimit (FuncState *fs, int limit, const char *what) { - const char *msg = (fs->f->linedefined == 0) ? - luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : - luaO_pushfstring(fs->L, "function at line %d has more than %d %s", - fs->f->linedefined, limit, what); - luaX_lexerror(fs->ls, msg, 0); -} - - -static int testnext (LexState *ls, int c) { - if (ls->t.token == c) { - luaX_next(ls); - return 1; - } - else return 0; -} - - -static void check (LexState *ls, int c) { - if (ls->t.token != c) - error_expected(ls, c); -} - -static void checknext (LexState *ls, int c) { - check(ls, c); - luaX_next(ls); -} - - -#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } - - - -static void check_match (LexState *ls, int what, int who, int where) { - if (!testnext(ls, what)) { - if (where == ls->linenumber) - error_expected(ls, what); - else { - luaX_syntaxerror(ls, luaO_pushfstring(ls->L, - LUA_QS " expected (to close " LUA_QS " at line %d)", - luaX_token2str(ls, what), luaX_token2str(ls, who), where)); - } - } -} - - -static TString *str_checkname (LexState *ls) { - TString *ts; - check(ls, TK_NAME); - ts = ls->t.seminfo.ts; - luaX_next(ls); - return ts; -} - - -static void init_exp (expdesc *e, expkind k, int i) { - e->f = e->t = NO_JUMP; - e->k = k; - e->u.s.info = i; -} - - -static void codestring (LexState *ls, expdesc *e, TString *s) { - init_exp(e, VK, luaK_stringK(ls->fs, s)); -} - - -static void checkname(LexState *ls, expdesc *e) { - codestring(ls, e, str_checkname(ls)); -} - - -static int registerlocalvar (LexState *ls, TString *varname) { - FuncState *fs = ls->fs; - Proto *f = fs->f; - int oldsize = f->sizelocvars; - luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, - LocVar, SHRT_MAX, "too many local variables"); - while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; - f->locvars[fs->nlocvars].varname = varname; - luaC_objbarrier(ls->L, f, varname); - return fs->nlocvars++; -} - - -#define new_localvarliteral(ls,v,n) \ - new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) - - -static void new_localvar (LexState *ls, TString *name, int n) { - FuncState *fs = ls->fs; - luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); - fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); -} - - -static void adjustlocalvars (LexState *ls, int nvars) { - FuncState *fs = ls->fs; - fs->nactvar = cast_byte(fs->nactvar + nvars); - for (; nvars; nvars--) { - getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; - } -} - - -static void removevars (LexState *ls, int tolevel) { - FuncState *fs = ls->fs; - while (fs->nactvar > tolevel) - getlocvar(fs, --fs->nactvar).endpc = fs->pc; -} - - -static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { - int i; - Proto *f = fs->f; - int oldsize = f->sizeupvalues; - for (i=0; inups; i++) { - if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { - lua_assert(f->upvalues[i] == name); - return i; - } - } - /* new one */ - luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); - luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, - TString *, MAX_INT, ""); - while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; - f->upvalues[f->nups] = name; - luaC_objbarrier(fs->L, f, name); - lua_assert(v->k == VLOCAL || v->k == VUPVAL); - fs->upvalues[f->nups].k = cast_byte(v->k); - fs->upvalues[f->nups].info = cast_byte(v->u.s.info); - return f->nups++; -} - - -static int searchvar (FuncState *fs, TString *n) { - int i; - for (i=fs->nactvar-1; i >= 0; i--) { - if (n == getlocvar(fs, i).varname) - return i; - } - return -1; /* not found */ -} - - -static void markupval (FuncState *fs, int level) { - BlockCnt *bl = fs->bl; - while (bl && bl->nactvar > level) bl = bl->previous; - if (bl) bl->upval = 1; -} - - -static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { - if (fs == NULL) { /* no more levels? */ - init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ - return VGLOBAL; - } - else { - int v = searchvar(fs, n); /* look up at current level */ - if (v >= 0) { - init_exp(var, VLOCAL, v); - if (!base) - markupval(fs, v); /* local will be used as an upval */ - return VLOCAL; - } - else { /* not found at current level; try upper one */ - if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) - return VGLOBAL; - var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ - var->k = VUPVAL; /* upvalue in this level */ - return VUPVAL; - } - } -} - - -static void singlevar (LexState *ls, expdesc *var) { - TString *varname = str_checkname(ls); - FuncState *fs = ls->fs; - if (singlevaraux(fs, varname, var, 1) == VGLOBAL) - var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ -} - - -static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { - FuncState *fs = ls->fs; - int extra = nvars - nexps; - if (hasmultret(e->k)) { - extra++; /* includes call itself */ - if (extra < 0) extra = 0; - luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ - if (extra > 1) luaK_reserveregs(fs, extra-1); - } - else { - if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ - if (extra > 0) { - int reg = fs->freereg; - luaK_reserveregs(fs, extra); - luaK_nil(fs, reg, extra); - } - } -} - - -static void enterlevel (LexState *ls) { - if (++ls->L->nCcalls > LUAI_MAXCCALLS) - luaX_lexerror(ls, "chunk has too many syntax levels", 0); -} - - -#define leavelevel(ls) ((ls)->L->nCcalls--) - - -static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { - bl->breaklist = NO_JUMP; - bl->isbreakable = isbreakable; - bl->nactvar = fs->nactvar; - bl->upval = 0; - bl->previous = fs->bl; - fs->bl = bl; - lua_assert(fs->freereg == fs->nactvar); -} - - -static void leaveblock (FuncState *fs) { - BlockCnt *bl = fs->bl; - fs->bl = bl->previous; - removevars(fs->ls, bl->nactvar); - if (bl->upval) - luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); - /* a block either controls scope or breaks (never both) */ - lua_assert(!bl->isbreakable || !bl->upval); - lua_assert(bl->nactvar == fs->nactvar); - fs->freereg = fs->nactvar; /* free registers */ - luaK_patchtohere(fs, bl->breaklist); -} - - -static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { - FuncState *fs = ls->fs; - Proto *f = fs->f; - int oldsize = f->sizep; - int i; - luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, - MAXARG_Bx, "constant table overflow"); - while (oldsize < f->sizep) f->p[oldsize++] = NULL; - f->p[fs->np++] = func->f; - luaC_objbarrier(ls->L, f, func->f); - init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); - for (i=0; if->nups; i++) { - OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; - luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); - } -} - - -static void open_func (LexState *ls, FuncState *fs) { - lua_State *L = ls->L; - Proto *f = luaF_newproto(L); - fs->f = f; - fs->prev = ls->fs; /* linked list of funcstates */ - fs->ls = ls; - fs->L = L; - ls->fs = fs; - fs->pc = 0; - fs->lasttarget = -1; - fs->jpc = NO_JUMP; - fs->freereg = 0; - fs->nk = 0; - fs->np = 0; - fs->nlocvars = 0; - fs->nactvar = 0; - fs->bl = NULL; - f->source = ls->source; - f->maxstacksize = 2; /* registers 0/1 are always valid */ - fs->h = luaH_new(L, 0, 0); - /* anchor table of constants and prototype (to avoid being collected) */ - sethvalue2s(L, L->top, fs->h); - incr_top(L); - setptvalue2s(L, L->top, f); - incr_top(L); -} - - -static void close_func (LexState *ls) { - lua_State *L = ls->L; - FuncState *fs = ls->fs; - Proto *f = fs->f; - removevars(ls, 0); - luaK_ret(fs, 0, 0); /* final return */ - luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); - f->sizecode = fs->pc; - luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); - f->sizelineinfo = fs->pc; - luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); - f->sizek = fs->nk; - luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); - f->sizep = fs->np; - luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); - f->sizelocvars = fs->nlocvars; - luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); - f->sizeupvalues = f->nups; - lua_assert(luaG_checkcode(f)); - lua_assert(fs->bl == NULL); - ls->fs = fs->prev; - L->top -= 2; /* remove table and prototype from the stack */ - /* last token read was anchored in defunct function; must reanchor it */ - if (fs) anchor_token(ls); -} - - -Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { - struct LexState lexstate; - struct FuncState funcstate; - lexstate.buff = buff; - luaX_setinput(L, &lexstate, z, luaS_new(L, name)); - open_func(&lexstate, &funcstate); - funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ - luaX_next(&lexstate); /* read first token */ - chunk(&lexstate); - check(&lexstate, TK_EOS); - close_func(&lexstate); - lua_assert(funcstate.prev == NULL); - lua_assert(funcstate.f->nups == 0); - lua_assert(lexstate.fs == NULL); - return funcstate.f; -} - - - -/*============================================================*/ -/* GRAMMAR RULES */ -/*============================================================*/ - - -static void field (LexState *ls, expdesc *v) { - /* field -> ['.' | ':'] NAME */ - FuncState *fs = ls->fs; - expdesc key; - luaK_exp2anyreg(fs, v); - luaX_next(ls); /* skip the dot or colon */ - checkname(ls, &key); - luaK_indexed(fs, v, &key); -} - - -static void yindex (LexState *ls, expdesc *v) { - /* index -> '[' expr ']' */ - luaX_next(ls); /* skip the '[' */ - expr(ls, v); - luaK_exp2val(ls->fs, v); - checknext(ls, ']'); -} - - -/* -** {====================================================================== -** Rules for Constructors -** ======================================================================= -*/ - - -struct ConsControl { - expdesc v; /* last list item read */ - expdesc *t; /* table descriptor */ - int nh; /* total number of `record' elements */ - int na; /* total number of array elements */ - int tostore; /* number of array elements pending to be stored */ -}; - - -static void recfield (LexState *ls, struct ConsControl *cc) { - /* recfield -> (NAME | `['exp1`]') = exp1 */ - FuncState *fs = ls->fs; - int reg = ls->fs->freereg; - expdesc key, val; - int rkkey; - if (ls->t.token == TK_NAME) { - luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); - checkname(ls, &key); - } - else /* ls->t.token == '[' */ - yindex(ls, &key); - cc->nh++; - checknext(ls, '='); - rkkey = luaK_exp2RK(fs, &key); - expr(ls, &val); - luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); - fs->freereg = reg; /* free registers */ -} - - -static void closelistfield (FuncState *fs, struct ConsControl *cc) { - if (cc->v.k == VVOID) return; /* there is no list item */ - luaK_exp2nextreg(fs, &cc->v); - cc->v.k = VVOID; - if (cc->tostore == LFIELDS_PER_FLUSH) { - luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ - cc->tostore = 0; /* no more items pending */ - } -} - - -static void lastlistfield (FuncState *fs, struct ConsControl *cc) { - if (cc->tostore == 0) return; - if (hasmultret(cc->v.k)) { - luaK_setmultret(fs, &cc->v); - luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); - cc->na--; /* do not count last expression (unknown number of elements) */ - } - else { - if (cc->v.k != VVOID) - luaK_exp2nextreg(fs, &cc->v); - luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); - } -} - - -static void listfield (LexState *ls, struct ConsControl *cc) { - expr(ls, &cc->v); - luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); - cc->na++; - cc->tostore++; -} - - -static void constructor (LexState *ls, expdesc *t) { - /* constructor -> ?? */ - FuncState *fs = ls->fs; - int line = ls->linenumber; - int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); - struct ConsControl cc; - cc.na = cc.nh = cc.tostore = 0; - cc.t = t; - init_exp(t, VRELOCABLE, pc); - init_exp(&cc.v, VVOID, 0); /* no value (yet) */ - luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ - checknext(ls, '{'); - do { - lua_assert(cc.v.k == VVOID || cc.tostore > 0); - if (ls->t.token == '}') break; - closelistfield(fs, &cc); - switch(ls->t.token) { - case TK_NAME: { /* may be listfields or recfields */ - luaX_lookahead(ls); - if (ls->lookahead.token != '=') /* expression? */ - listfield(ls, &cc); - else - recfield(ls, &cc); - break; - } - case '[': { /* constructor_item -> recfield */ - recfield(ls, &cc); - break; - } - default: { /* constructor_part -> listfield */ - listfield(ls, &cc); - break; - } - } - } while (testnext(ls, ',') || testnext(ls, ';')); - check_match(ls, '}', '{', line); - lastlistfield(fs, &cc); - SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ - SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ -} - -/* }====================================================================== */ - - - -static void parlist (LexState *ls) { - /* parlist -> [ param { `,' param } ] */ - FuncState *fs = ls->fs; - Proto *f = fs->f; - int nparams = 0; - f->is_vararg = 0; - if (ls->t.token != ')') { /* is `parlist' not empty? */ - do { - switch (ls->t.token) { - case TK_NAME: { /* param -> NAME */ - new_localvar(ls, str_checkname(ls), nparams++); - break; - } - case TK_DOTS: { /* param -> `...' */ - luaX_next(ls); -#if defined(LUA_COMPAT_VARARG) - /* use `arg' as default name */ - new_localvarliteral(ls, "arg", nparams++); - f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; -#endif - f->is_vararg |= VARARG_ISVARARG; - break; - } - default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); - } - } while (!f->is_vararg && testnext(ls, ',')); - } - adjustlocalvars(ls, nparams); - f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); - luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ -} - - -static void body (LexState *ls, expdesc *e, int needself, int line) { - /* body -> `(' parlist `)' chunk END */ - FuncState new_fs; - open_func(ls, &new_fs); - new_fs.f->linedefined = line; - checknext(ls, '('); - if (needself) { - new_localvarliteral(ls, "self", 0); - adjustlocalvars(ls, 1); - } - parlist(ls); - checknext(ls, ')'); - chunk(ls); - new_fs.f->lastlinedefined = ls->linenumber; - check_match(ls, TK_END, TK_FUNCTION, line); - close_func(ls); - pushclosure(ls, &new_fs, e); -} - - -static int explist1 (LexState *ls, expdesc *v) { - /* explist1 -> expr { `,' expr } */ - int n = 1; /* at least one expression */ - expr(ls, v); - while (testnext(ls, ',')) { - luaK_exp2nextreg(ls->fs, v); - expr(ls, v); - n++; - } - return n; -} - - -static void funcargs (LexState *ls, expdesc *f) { - FuncState *fs = ls->fs; - expdesc args; - int base, nparams; - int line = ls->linenumber; - switch (ls->t.token) { - case '(': { /* funcargs -> `(' [ explist1 ] `)' */ - if (line != ls->lastline) - luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); - luaX_next(ls); - if (ls->t.token == ')') /* arg list is empty? */ - args.k = VVOID; - else { - explist1(ls, &args); - luaK_setmultret(fs, &args); - } - check_match(ls, ')', '(', line); - break; - } - case '{': { /* funcargs -> constructor */ - constructor(ls, &args); - break; - } - case TK_STRING: { /* funcargs -> STRING */ - codestring(ls, &args, ls->t.seminfo.ts); - luaX_next(ls); /* must use `seminfo' before `next' */ - break; - } - default: { - luaX_syntaxerror(ls, "function arguments expected"); - return; - } - } - lua_assert(f->k == VNONRELOC); - base = f->u.s.info; /* base register for call */ - if (hasmultret(args.k)) - nparams = LUA_MULTRET; /* open call */ - else { - if (args.k != VVOID) - luaK_exp2nextreg(fs, &args); /* close last argument */ - nparams = fs->freereg - (base+1); - } - init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); - luaK_fixline(fs, line); - fs->freereg = base+1; /* call remove function and arguments and leaves - (unless changed) one result */ -} - - - - -/* -** {====================================================================== -** Expression parsing -** ======================================================================= -*/ - - -static void prefixexp (LexState *ls, expdesc *v) { - /* prefixexp -> NAME | '(' expr ')' */ - switch (ls->t.token) { - case '(': { - int line = ls->linenumber; - luaX_next(ls); - expr(ls, v); - check_match(ls, ')', '(', line); - luaK_dischargevars(ls->fs, v); - return; - } - case TK_NAME: { - singlevar(ls, v); - return; - } - default: { - luaX_syntaxerror(ls, "unexpected symbol"); - return; - } - } -} - - -static void primaryexp (LexState *ls, expdesc *v) { - /* primaryexp -> - prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ - FuncState *fs = ls->fs; - prefixexp(ls, v); - for (;;) { - switch (ls->t.token) { - case '.': { /* field */ - field(ls, v); - break; - } - case '[': { /* `[' exp1 `]' */ - expdesc key; - luaK_exp2anyreg(fs, v); - yindex(ls, &key); - luaK_indexed(fs, v, &key); - break; - } - case ':': { /* `:' NAME funcargs */ - expdesc key; - luaX_next(ls); - checkname(ls, &key); - luaK_self(fs, v, &key); - funcargs(ls, v); - break; - } - case '(': case TK_STRING: case '{': { /* funcargs */ - luaK_exp2nextreg(fs, v); - funcargs(ls, v); - break; - } - default: return; - } - } -} - - -static void simpleexp (LexState *ls, expdesc *v) { - /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | - constructor | FUNCTION body | primaryexp */ - switch (ls->t.token) { - case TK_NUMBER: { - init_exp(v, VKNUM, 0); - v->u.nval = ls->t.seminfo.r; - break; - } - case TK_STRING: { - codestring(ls, v, ls->t.seminfo.ts); - break; - } - case TK_NIL: { - init_exp(v, VNIL, 0); - break; - } - case TK_TRUE: { - init_exp(v, VTRUE, 0); - break; - } - case TK_FALSE: { - init_exp(v, VFALSE, 0); - break; - } - case TK_DOTS: { /* vararg */ - FuncState *fs = ls->fs; - check_condition(ls, fs->f->is_vararg, - "cannot use " LUA_QL("...") " outside a vararg function"); - fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ - init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); - break; - } - case '{': { /* constructor */ - constructor(ls, v); - return; - } - case TK_FUNCTION: { - luaX_next(ls); - body(ls, v, 0, ls->linenumber); - return; - } - default: { - primaryexp(ls, v); - return; - } - } - luaX_next(ls); -} - - -static UnOpr getunopr (int op) { - switch (op) { - case TK_NOT: return OPR_NOT; - case '-': return OPR_MINUS; - case '#': return OPR_LEN; - default: return OPR_NOUNOPR; - } -} - - -static BinOpr getbinopr (int op) { - switch (op) { - case '+': return OPR_ADD; - case '-': return OPR_SUB; - case '*': return OPR_MUL; - case '/': return OPR_DIV; - case '%': return OPR_MOD; - case '^': return OPR_POW; - case TK_CONCAT: return OPR_CONCAT; - case TK_NE: return OPR_NE; - case TK_EQ: return OPR_EQ; - case '<': return OPR_LT; - case TK_LE: return OPR_LE; - case '>': return OPR_GT; - case TK_GE: return OPR_GE; - case TK_AND: return OPR_AND; - case TK_OR: return OPR_OR; - default: return OPR_NOBINOPR; - } -} - - -static const struct { - lu_byte left; /* left priority for each binary operator */ - lu_byte right; /* right priority */ -} priority[] = { /* ORDER OPR */ - {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ - {10, 9}, {5, 4}, /* power and concat (right associative) */ - {3, 3}, {3, 3}, /* equality and inequality */ - {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ - {2, 2}, {1, 1} /* logical (and/or) */ -}; - -#define UNARY_PRIORITY 8 /* priority for unary operators */ - - -/* -** subexpr -> (simpleexp | unop subexpr) { binop subexpr } -** where `binop' is any binary operator with a priority higher than `limit' -*/ -static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { - BinOpr op; - UnOpr uop; - enterlevel(ls); - uop = getunopr(ls->t.token); - if (uop != OPR_NOUNOPR) { - luaX_next(ls); - subexpr(ls, v, UNARY_PRIORITY); - luaK_prefix(ls->fs, uop, v); - } - else simpleexp(ls, v); - /* expand while operators have priorities higher than `limit' */ - op = getbinopr(ls->t.token); - while (op != OPR_NOBINOPR && priority[op].left > limit) { - expdesc v2; - BinOpr nextop; - luaX_next(ls); - luaK_infix(ls->fs, op, v); - /* read sub-expression with higher priority */ - nextop = subexpr(ls, &v2, priority[op].right); - luaK_posfix(ls->fs, op, v, &v2); - op = nextop; - } - leavelevel(ls); - return op; /* return first untreated operator */ -} - - -static void expr (LexState *ls, expdesc *v) { - subexpr(ls, v, 0); -} - -/* }==================================================================== */ - - - -/* -** {====================================================================== -** Rules for Statements -** ======================================================================= -*/ - - -static int block_follow (int token) { - switch (token) { - case TK_ELSE: case TK_ELSEIF: case TK_END: - case TK_UNTIL: case TK_EOS: - return 1; - default: return 0; - } -} - - -static void block (LexState *ls) { - /* block -> chunk */ - FuncState *fs = ls->fs; - BlockCnt bl; - enterblock(fs, &bl, 0); - chunk(ls); - lua_assert(bl.breaklist == NO_JUMP); - leaveblock(fs); -} - - -/* -** structure to chain all variables in the left-hand side of an -** assignment -*/ -struct LHS_assign { - struct LHS_assign *prev; - expdesc v; /* variable (global, local, upvalue, or indexed) */ -}; - - -/* -** check whether, in an assignment to a local variable, the local variable -** is needed in a previous assignment (to a table). If so, save original -** local value in a safe place and use this safe copy in the previous -** assignment. -*/ -static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { - FuncState *fs = ls->fs; - int extra = fs->freereg; /* eventual position to save local variable */ - int conflict = 0; - for (; lh; lh = lh->prev) { - if (lh->v.k == VINDEXED) { - if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ - conflict = 1; - lh->v.u.s.info = extra; /* previous assignment will use safe copy */ - } - if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ - conflict = 1; - lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ - } - } - } - if (conflict) { - luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ - luaK_reserveregs(fs, 1); - } -} - - -static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { - expdesc e; - check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, - "syntax error"); - if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ - struct LHS_assign nv; - nv.prev = lh; - primaryexp(ls, &nv.v); - if (nv.v.k == VLOCAL) - check_conflict(ls, lh, &nv.v); - luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, - "variables in assignment"); - assignment(ls, &nv, nvars+1); - } - else { /* assignment -> `=' explist1 */ - int nexps; - checknext(ls, '='); - nexps = explist1(ls, &e); - if (nexps != nvars) { - adjust_assign(ls, nvars, nexps, &e); - if (nexps > nvars) - ls->fs->freereg -= nexps - nvars; /* remove extra values */ - } - else { - luaK_setoneret(ls->fs, &e); /* close last expression */ - luaK_storevar(ls->fs, &lh->v, &e); - return; /* avoid default */ - } - } - init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ - luaK_storevar(ls->fs, &lh->v, &e); -} - - -static int cond (LexState *ls) { - /* cond -> exp */ - expdesc v; - expr(ls, &v); /* read condition */ - if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ - luaK_goiftrue(ls->fs, &v); - return v.f; -} - - -static void breakstat (LexState *ls) { - FuncState *fs = ls->fs; - BlockCnt *bl = fs->bl; - int upval = 0; - while (bl && !bl->isbreakable) { - upval |= bl->upval; - bl = bl->previous; - } - if (!bl) - luaX_syntaxerror(ls, "no loop to break"); - if (upval) - luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); - luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); -} - - -static void whilestat (LexState *ls, int line) { - /* whilestat -> WHILE cond DO block END */ - FuncState *fs = ls->fs; - int whileinit; - int condexit; - BlockCnt bl; - luaX_next(ls); /* skip WHILE */ - whileinit = luaK_getlabel(fs); - condexit = cond(ls); - enterblock(fs, &bl, 1); - checknext(ls, TK_DO); - block(ls); - luaK_patchlist(fs, luaK_jump(fs), whileinit); - check_match(ls, TK_END, TK_WHILE, line); - leaveblock(fs); - luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ -} - - -static void repeatstat (LexState *ls, int line) { - /* repeatstat -> REPEAT block UNTIL cond */ - int condexit; - FuncState *fs = ls->fs; - int repeat_init = luaK_getlabel(fs); - BlockCnt bl1, bl2; - enterblock(fs, &bl1, 1); /* loop block */ - enterblock(fs, &bl2, 0); /* scope block */ - luaX_next(ls); /* skip REPEAT */ - chunk(ls); - check_match(ls, TK_UNTIL, TK_REPEAT, line); - condexit = cond(ls); /* read condition (inside scope block) */ - if (!bl2.upval) { /* no upvalues? */ - leaveblock(fs); /* finish scope */ - luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ - } - else { /* complete semantics when there are upvalues */ - breakstat(ls); /* if condition then break */ - luaK_patchtohere(ls->fs, condexit); /* else... */ - leaveblock(fs); /* finish scope... */ - luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ - } - leaveblock(fs); /* finish loop */ -} - - -static int exp1 (LexState *ls) { - expdesc e; - int k; - expr(ls, &e); - k = e.k; - luaK_exp2nextreg(ls->fs, &e); - return k; -} - - -static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { - /* forbody -> DO block */ - BlockCnt bl; - FuncState *fs = ls->fs; - int prep, endfor; - adjustlocalvars(ls, 3); /* control variables */ - checknext(ls, TK_DO); - prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); - enterblock(fs, &bl, 0); /* scope for declared variables */ - adjustlocalvars(ls, nvars); - luaK_reserveregs(fs, nvars); - block(ls); - leaveblock(fs); /* end of scope for declared variables */ - luaK_patchtohere(fs, prep); - endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : - luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); - luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ - luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); -} - - -static void fornum (LexState *ls, TString *varname, int line) { - /* fornum -> NAME = exp1,exp1[,exp1] forbody */ - FuncState *fs = ls->fs; - int base = fs->freereg; - new_localvarliteral(ls, "(for index)", 0); - new_localvarliteral(ls, "(for limit)", 1); - new_localvarliteral(ls, "(for step)", 2); - new_localvar(ls, varname, 3); - checknext(ls, '='); - exp1(ls); /* initial value */ - checknext(ls, ','); - exp1(ls); /* limit */ - if (testnext(ls, ',')) - exp1(ls); /* optional step */ - else { /* default step = 1 */ - luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); - luaK_reserveregs(fs, 1); - } - forbody(ls, base, line, 1, 1); -} - - -static void forlist (LexState *ls, TString *indexname) { - /* forlist -> NAME {,NAME} IN explist1 forbody */ - FuncState *fs = ls->fs; - expdesc e; - int nvars = 0; - int line; - int base = fs->freereg; - /* create control variables */ - new_localvarliteral(ls, "(for generator)", nvars++); - new_localvarliteral(ls, "(for state)", nvars++); - new_localvarliteral(ls, "(for control)", nvars++); - /* create declared variables */ - new_localvar(ls, indexname, nvars++); - while (testnext(ls, ',')) - new_localvar(ls, str_checkname(ls), nvars++); - checknext(ls, TK_IN); - line = ls->linenumber; - adjust_assign(ls, 3, explist1(ls, &e), &e); - luaK_checkstack(fs, 3); /* extra space to call generator */ - forbody(ls, base, line, nvars - 3, 0); -} - - -static void forstat (LexState *ls, int line) { - /* forstat -> FOR (fornum | forlist) END */ - FuncState *fs = ls->fs; - TString *varname; - BlockCnt bl; - enterblock(fs, &bl, 1); /* scope for loop and control variables */ - luaX_next(ls); /* skip `for' */ - varname = str_checkname(ls); /* first variable name */ - switch (ls->t.token) { - case '=': fornum(ls, varname, line); break; - case ',': case TK_IN: forlist(ls, varname); break; - default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); - } - check_match(ls, TK_END, TK_FOR, line); - leaveblock(fs); /* loop scope (`break' jumps to this point) */ -} - - -static int test_then_block (LexState *ls) { - /* test_then_block -> [IF | ELSEIF] cond THEN block */ - int condexit; - luaX_next(ls); /* skip IF or ELSEIF */ - condexit = cond(ls); - checknext(ls, TK_THEN); - block(ls); /* `then' part */ - return condexit; -} - - -static void ifstat (LexState *ls, int line) { - /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ - FuncState *fs = ls->fs; - int flist; - int escapelist = NO_JUMP; - flist = test_then_block(ls); /* IF cond THEN block */ - while (ls->t.token == TK_ELSEIF) { - luaK_concat(fs, &escapelist, luaK_jump(fs)); - luaK_patchtohere(fs, flist); - flist = test_then_block(ls); /* ELSEIF cond THEN block */ - } - if (ls->t.token == TK_ELSE) { - luaK_concat(fs, &escapelist, luaK_jump(fs)); - luaK_patchtohere(fs, flist); - luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ - block(ls); /* `else' part */ - } - else - luaK_concat(fs, &escapelist, flist); - luaK_patchtohere(fs, escapelist); - check_match(ls, TK_END, TK_IF, line); -} - - -static void localfunc (LexState *ls) { - expdesc v, b; - FuncState *fs = ls->fs; - new_localvar(ls, str_checkname(ls), 0); - init_exp(&v, VLOCAL, fs->freereg); - luaK_reserveregs(fs, 1); - adjustlocalvars(ls, 1); - body(ls, &b, 0, ls->linenumber); - luaK_storevar(fs, &v, &b); - /* debug information will only see the variable after this point! */ - getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; -} - - -static void localstat (LexState *ls) { - /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ - int nvars = 0; - int nexps; - expdesc e; - do { - new_localvar(ls, str_checkname(ls), nvars++); - } while (testnext(ls, ',')); - if (testnext(ls, '=')) - nexps = explist1(ls, &e); - else { - e.k = VVOID; - nexps = 0; - } - adjust_assign(ls, nvars, nexps, &e); - adjustlocalvars(ls, nvars); -} - - -static int funcname (LexState *ls, expdesc *v) { - /* funcname -> NAME {field} [`:' NAME] */ - int needself = 0; - singlevar(ls, v); - while (ls->t.token == '.') - field(ls, v); - if (ls->t.token == ':') { - needself = 1; - field(ls, v); - } - return needself; -} - - -static void funcstat (LexState *ls, int line) { - /* funcstat -> FUNCTION funcname body */ - int needself; - expdesc v, b; - luaX_next(ls); /* skip FUNCTION */ - needself = funcname(ls, &v); - body(ls, &b, needself, line); - luaK_storevar(ls->fs, &v, &b); - luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ -} - - -static void exprstat (LexState *ls) { - /* stat -> func | assignment */ - FuncState *fs = ls->fs; - struct LHS_assign v; - primaryexp(ls, &v.v); - if (v.v.k == VCALL) /* stat -> func */ - SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ - else { /* stat -> assignment */ - v.prev = NULL; - assignment(ls, &v, 1); - } -} - - -static void retstat (LexState *ls) { - /* stat -> RETURN explist */ - FuncState *fs = ls->fs; - expdesc e; - int first, nret; /* registers with returned values */ - luaX_next(ls); /* skip RETURN */ - if (block_follow(ls->t.token) || ls->t.token == ';') - first = nret = 0; /* return no values */ - else { - nret = explist1(ls, &e); /* optional return values */ - if (hasmultret(e.k)) { - luaK_setmultret(fs, &e); - if (e.k == VCALL && nret == 1) { /* tail call? */ - SET_OPCODE(getcode(fs,&e), OP_TAILCALL); - lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); - } - first = fs->nactvar; - nret = LUA_MULTRET; /* return all values */ - } - else { - if (nret == 1) /* only one single value? */ - first = luaK_exp2anyreg(fs, &e); - else { - luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ - first = fs->nactvar; /* return all `active' values */ - lua_assert(nret == fs->freereg - first); - } - } - } - luaK_ret(fs, first, nret); -} - - -static int statement (LexState *ls) { - int line = ls->linenumber; /* may be needed for error messages */ - switch (ls->t.token) { - case TK_IF: { /* stat -> ifstat */ - ifstat(ls, line); - return 0; - } - case TK_WHILE: { /* stat -> whilestat */ - whilestat(ls, line); - return 0; - } - case TK_DO: { /* stat -> DO block END */ - luaX_next(ls); /* skip DO */ - block(ls); - check_match(ls, TK_END, TK_DO, line); - return 0; - } - case TK_FOR: { /* stat -> forstat */ - forstat(ls, line); - return 0; - } - case TK_REPEAT: { /* stat -> repeatstat */ - repeatstat(ls, line); - return 0; - } - case TK_FUNCTION: { - funcstat(ls, line); /* stat -> funcstat */ - return 0; - } - case TK_LOCAL: { /* stat -> localstat */ - luaX_next(ls); /* skip LOCAL */ - if (testnext(ls, TK_FUNCTION)) /* local function? */ - localfunc(ls); - else - localstat(ls); - return 0; - } - case TK_RETURN: { /* stat -> retstat */ - retstat(ls); - return 1; /* must be last statement */ - } - case TK_BREAK: { /* stat -> breakstat */ - luaX_next(ls); /* skip BREAK */ - breakstat(ls); - return 1; /* must be last statement */ - } - default: { - exprstat(ls); - return 0; /* to avoid warnings */ - } - } -} - - -static void chunk (LexState *ls) { - /* chunk -> { stat [`;'] } */ - int islast = 0; - enterlevel(ls); - while (!islast && !block_follow(ls->t.token)) { - islast = statement(ls); - testnext(ls, ';'); - lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && - ls->fs->freereg >= ls->fs->nactvar); - ls->fs->freereg = ls->fs->nactvar; /* free registers */ - } - leavelevel(ls); -} - -/* }====================================================================== */ diff -Nru gpick-0.2.4/extern/lua/src/lparser.h gpick-0.2.5/extern/lua/src/lparser.h --- gpick-0.2.4/extern/lua/src/lparser.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lparser.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/* -** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ -** Lua Parser -** See Copyright Notice in lua.h -*/ - -#ifndef lparser_h -#define lparser_h - -#include "llimits.h" -#include "lobject.h" -#include "lzio.h" - - -/* -** Expression descriptor -*/ - -typedef enum { - VVOID, /* no value */ - VNIL, - VTRUE, - VFALSE, - VK, /* info = index of constant in `k' */ - VKNUM, /* nval = numerical value */ - VLOCAL, /* info = local register */ - VUPVAL, /* info = index of upvalue in `upvalues' */ - VGLOBAL, /* info = index of table; aux = index of global name in `k' */ - VINDEXED, /* info = table register; aux = index register (or `k') */ - VJMP, /* info = instruction pc */ - VRELOCABLE, /* info = instruction pc */ - VNONRELOC, /* info = result register */ - VCALL, /* info = instruction pc */ - VVARARG /* info = instruction pc */ -} expkind; - -typedef struct expdesc { - expkind k; - union { - struct { int info, aux; } s; - lua_Number nval; - } u; - int t; /* patch list of `exit when true' */ - int f; /* patch list of `exit when false' */ -} expdesc; - - -typedef struct upvaldesc { - lu_byte k; - lu_byte info; -} upvaldesc; - - -struct BlockCnt; /* defined in lparser.c */ - - -/* state needed to generate code for a given function */ -typedef struct FuncState { - Proto *f; /* current function header */ - Table *h; /* table to find (and reuse) elements in `k' */ - struct FuncState *prev; /* enclosing function */ - struct LexState *ls; /* lexical state */ - struct lua_State *L; /* copy of the Lua state */ - struct BlockCnt *bl; /* chain of current blocks */ - int pc; /* next position to code (equivalent to `ncode') */ - int lasttarget; /* `pc' of last `jump target' */ - int jpc; /* list of pending jumps to `pc' */ - int freereg; /* first free register */ - int nk; /* number of elements in `k' */ - int np; /* number of elements in `p' */ - short nlocvars; /* number of elements in `locvars' */ - lu_byte nactvar; /* number of active local variables */ - upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ - unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ -} FuncState; - - -LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, - const char *name); - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lstate.c gpick-0.2.5/extern/lua/src/lstate.c --- gpick-0.2.4/extern/lua/src/lstate.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lstate.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -/* -** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ -** Global State -** See Copyright Notice in lua.h -*/ - - -#include - -#define lstate_c -#define LUA_CORE - -#include "lua.h" - -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "llex.h" -#include "lmem.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" - - -#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) -#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) -#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) - - -/* -** Main thread combines a thread state and the global state -*/ -typedef struct LG { - lua_State l; - global_State g; -} LG; - - - -static void stack_init (lua_State *L1, lua_State *L) { - /* initialize CallInfo array */ - L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); - L1->ci = L1->base_ci; - L1->size_ci = BASIC_CI_SIZE; - L1->end_ci = L1->base_ci + L1->size_ci - 1; - /* initialize stack array */ - L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); - L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; - L1->top = L1->stack; - L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; - /* initialize first ci */ - L1->ci->func = L1->top; - setnilvalue(L1->top++); /* `function' entry for this `ci' */ - L1->base = L1->ci->base = L1->top; - L1->ci->top = L1->top + LUA_MINSTACK; -} - - -static void freestack (lua_State *L, lua_State *L1) { - luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); - luaM_freearray(L, L1->stack, L1->stacksize, TValue); -} - - -/* -** open parts that may cause memory-allocation errors -*/ -static void f_luaopen (lua_State *L, void *ud) { - global_State *g = G(L); - UNUSED(ud); - stack_init(L, L); /* init stack */ - sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ - sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ - luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ - luaT_init(L); - luaX_init(L); - luaS_fix(luaS_newliteral(L, MEMERRMSG)); - g->GCthreshold = 4*g->totalbytes; -} - - -static void preinit_state (lua_State *L, global_State *g) { - G(L) = g; - L->stack = NULL; - L->stacksize = 0; - L->errorJmp = NULL; - L->hook = NULL; - L->hookmask = 0; - L->basehookcount = 0; - L->allowhook = 1; - resethookcount(L); - L->openupval = NULL; - L->size_ci = 0; - L->nCcalls = L->baseCcalls = 0; - L->status = 0; - L->base_ci = L->ci = NULL; - L->savedpc = NULL; - L->errfunc = 0; - setnilvalue(gt(L)); -} - - -static void close_state (lua_State *L) { - global_State *g = G(L); - luaF_close(L, L->stack); /* close all upvalues for this thread */ - luaC_freeall(L); /* collect all objects */ - lua_assert(g->rootgc == obj2gco(L)); - lua_assert(g->strt.nuse == 0); - luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); - luaZ_freebuffer(L, &g->buff); - freestack(L, L); - lua_assert(g->totalbytes == sizeof(LG)); - (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); -} - - -lua_State *luaE_newthread (lua_State *L) { - lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); - luaC_link(L, obj2gco(L1), LUA_TTHREAD); - preinit_state(L1, G(L)); - stack_init(L1, L); /* init stack */ - setobj2n(L, gt(L1), gt(L)); /* share table of globals */ - L1->hookmask = L->hookmask; - L1->basehookcount = L->basehookcount; - L1->hook = L->hook; - resethookcount(L1); - lua_assert(iswhite(obj2gco(L1))); - return L1; -} - - -void luaE_freethread (lua_State *L, lua_State *L1) { - luaF_close(L1, L1->stack); /* close all upvalues for this thread */ - lua_assert(L1->openupval == NULL); - luai_userstatefree(L1); - freestack(L, L1); - luaM_freemem(L, fromstate(L1), state_size(lua_State)); -} - - -LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { - int i; - lua_State *L; - global_State *g; - void *l = (*f)(ud, NULL, 0, state_size(LG)); - if (l == NULL) return NULL; - L = tostate(l); - g = &((LG *)L)->g; - L->next = NULL; - L->tt = LUA_TTHREAD; - g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); - L->marked = luaC_white(g); - set2bits(L->marked, FIXEDBIT, SFIXEDBIT); - preinit_state(L, g); - g->frealloc = f; - g->ud = ud; - g->mainthread = L; - g->uvhead.u.l.prev = &g->uvhead; - g->uvhead.u.l.next = &g->uvhead; - g->GCthreshold = 0; /* mark it as unfinished state */ - g->strt.size = 0; - g->strt.nuse = 0; - g->strt.hash = NULL; - setnilvalue(registry(L)); - luaZ_initbuffer(L, &g->buff); - g->panic = NULL; - g->gcstate = GCSpause; - g->rootgc = obj2gco(L); - g->sweepstrgc = 0; - g->sweepgc = &g->rootgc; - g->gray = NULL; - g->grayagain = NULL; - g->weak = NULL; - g->tmudata = NULL; - g->totalbytes = sizeof(LG); - g->gcpause = LUAI_GCPAUSE; - g->gcstepmul = LUAI_GCMUL; - g->gcdept = 0; - for (i=0; imt[i] = NULL; - if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { - /* memory allocation error: free partial state */ - close_state(L); - L = NULL; - } - else - luai_userstateopen(L); - return L; -} - - -static void callallgcTM (lua_State *L, void *ud) { - UNUSED(ud); - luaC_callGCTM(L); /* call GC metamethods for all udata */ -} - - -LUA_API void lua_close (lua_State *L) { - L = G(L)->mainthread; /* only the main thread can be closed */ - lua_lock(L); - luaF_close(L, L->stack); /* close all upvalues for this thread */ - luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ - L->errfunc = 0; /* no error function during GC metamethods */ - do { /* repeat until no more errors */ - L->ci = L->base_ci; - L->base = L->top = L->ci->base; - L->nCcalls = L->baseCcalls = 0; - } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); - lua_assert(G(L)->tmudata == NULL); - luai_userstateclose(L); - close_state(L); -} - diff -Nru gpick-0.2.4/extern/lua/src/lstate.h gpick-0.2.5/extern/lua/src/lstate.h --- gpick-0.2.4/extern/lua/src/lstate.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lstate.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -/* -** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ -** Global State -** See Copyright Notice in lua.h -*/ - -#ifndef lstate_h -#define lstate_h - -#include "lua.h" - -#include "lobject.h" -#include "ltm.h" -#include "lzio.h" - - - -struct lua_longjmp; /* defined in ldo.c */ - - -/* table of globals */ -#define gt(L) (&L->l_gt) - -/* registry */ -#define registry(L) (&G(L)->l_registry) - - -/* extra stack space to handle TM calls and some other extras */ -#define EXTRA_STACK 5 - - -#define BASIC_CI_SIZE 8 - -#define BASIC_STACK_SIZE (2*LUA_MINSTACK) - - - -typedef struct stringtable { - GCObject **hash; - lu_int32 nuse; /* number of elements */ - int size; -} stringtable; - - -/* -** informations about a call -*/ -typedef struct CallInfo { - StkId base; /* base for this function */ - StkId func; /* function index in the stack */ - StkId top; /* top for this function */ - const Instruction *savedpc; - int nresults; /* expected number of results from this function */ - int tailcalls; /* number of tail calls lost under this entry */ -} CallInfo; - - - -#define curr_func(L) (clvalue(L->ci->func)) -#define ci_func(ci) (clvalue((ci)->func)) -#define f_isLua(ci) (!ci_func(ci)->c.isC) -#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) - - -/* -** `global state', shared by all threads of this state -*/ -typedef struct global_State { - stringtable strt; /* hash table for strings */ - lua_Alloc frealloc; /* function to reallocate memory */ - void *ud; /* auxiliary data to `frealloc' */ - lu_byte currentwhite; - lu_byte gcstate; /* state of garbage collector */ - int sweepstrgc; /* position of sweep in `strt' */ - GCObject *rootgc; /* list of all collectable objects */ - GCObject **sweepgc; /* position of sweep in `rootgc' */ - GCObject *gray; /* list of gray objects */ - GCObject *grayagain; /* list of objects to be traversed atomically */ - GCObject *weak; /* list of weak tables (to be cleared) */ - GCObject *tmudata; /* last element of list of userdata to be GC */ - Mbuffer buff; /* temporary buffer for string concatentation */ - lu_mem GCthreshold; - lu_mem totalbytes; /* number of bytes currently allocated */ - lu_mem estimate; /* an estimate of number of bytes actually in use */ - lu_mem gcdept; /* how much GC is `behind schedule' */ - int gcpause; /* size of pause between successive GCs */ - int gcstepmul; /* GC `granularity' */ - lua_CFunction panic; /* to be called in unprotected errors */ - TValue l_registry; - struct lua_State *mainthread; - UpVal uvhead; /* head of double-linked list of all open upvalues */ - struct Table *mt[NUM_TAGS]; /* metatables for basic types */ - TString *tmname[TM_N]; /* array with tag-method names */ -} global_State; - - -/* -** `per thread' state -*/ -struct lua_State { - CommonHeader; - lu_byte status; - StkId top; /* first free slot in the stack */ - StkId base; /* base of current function */ - global_State *l_G; - CallInfo *ci; /* call info for current function */ - const Instruction *savedpc; /* `savedpc' of current function */ - StkId stack_last; /* last free slot in the stack */ - StkId stack; /* stack base */ - CallInfo *end_ci; /* points after end of ci array*/ - CallInfo *base_ci; /* array of CallInfo's */ - int stacksize; - int size_ci; /* size of array `base_ci' */ - unsigned short nCcalls; /* number of nested C calls */ - unsigned short baseCcalls; /* nested C calls when resuming coroutine */ - lu_byte hookmask; - lu_byte allowhook; - int basehookcount; - int hookcount; - lua_Hook hook; - TValue l_gt; /* table of globals */ - TValue env; /* temporary place for environments */ - GCObject *openupval; /* list of open upvalues in this stack */ - GCObject *gclist; - struct lua_longjmp *errorJmp; /* current error recover point */ - ptrdiff_t errfunc; /* current error handling function (stack index) */ -}; - - -#define G(L) (L->l_G) - - -/* -** Union of all collectable objects -*/ -union GCObject { - GCheader gch; - union TString ts; - union Udata u; - union Closure cl; - struct Table h; - struct Proto p; - struct UpVal uv; - struct lua_State th; /* thread */ -}; - - -/* macros to convert a GCObject into a specific value */ -#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) -#define gco2ts(o) (&rawgco2ts(o)->tsv) -#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) -#define gco2u(o) (&rawgco2u(o)->uv) -#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) -#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) -#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) -#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) -#define ngcotouv(o) \ - check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) -#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) - -/* macro to convert any Lua object into a GCObject */ -#define obj2gco(v) (cast(GCObject *, (v))) - - -LUAI_FUNC lua_State *luaE_newthread (lua_State *L); -LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); - -#endif - diff -Nru gpick-0.2.4/extern/lua/src/lstring.c gpick-0.2.5/extern/lua/src/lstring.c --- gpick-0.2.4/extern/lua/src/lstring.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lstring.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -/* -** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ -** String table (keeps all strings handled by Lua) -** See Copyright Notice in lua.h -*/ - - -#include - -#define lstring_c -#define LUA_CORE - -#include "lua.h" - -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" - - - -void luaS_resize (lua_State *L, int newsize) { - GCObject **newhash; - stringtable *tb; - int i; - if (G(L)->gcstate == GCSsweepstring) - return; /* cannot resize during GC traverse */ - newhash = luaM_newvector(L, newsize, GCObject *); - tb = &G(L)->strt; - for (i=0; isize; i++) { - GCObject *p = tb->hash[i]; - while (p) { /* for each node in the list */ - GCObject *next = p->gch.next; /* save next */ - unsigned int h = gco2ts(p)->hash; - int h1 = lmod(h, newsize); /* new position */ - lua_assert(cast_int(h%newsize) == lmod(h, newsize)); - p->gch.next = newhash[h1]; /* chain it */ - newhash[h1] = p; - p = next; - } - } - luaM_freearray(L, tb->hash, tb->size, TString *); - tb->size = newsize; - tb->hash = newhash; -} - - -static TString *newlstr (lua_State *L, const char *str, size_t l, - unsigned int h) { - TString *ts; - stringtable *tb; - if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) - luaM_toobig(L); - ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); - ts->tsv.len = l; - ts->tsv.hash = h; - ts->tsv.marked = luaC_white(G(L)); - ts->tsv.tt = LUA_TSTRING; - ts->tsv.reserved = 0; - memcpy(ts+1, str, l*sizeof(char)); - ((char *)(ts+1))[l] = '\0'; /* ending 0 */ - tb = &G(L)->strt; - h = lmod(h, tb->size); - ts->tsv.next = tb->hash[h]; /* chain new entry */ - tb->hash[h] = obj2gco(ts); - tb->nuse++; - if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) - luaS_resize(L, tb->size*2); /* too crowded */ - return ts; -} - - -TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { - GCObject *o; - unsigned int h = cast(unsigned int, l); /* seed */ - size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ - size_t l1; - for (l1=l; l1>=step; l1-=step) /* compute hash */ - h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); - for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; - o != NULL; - o = o->gch.next) { - TString *ts = rawgco2ts(o); - if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { - /* string may be dead */ - if (isdead(G(L), o)) changewhite(o); - return ts; - } - } - return newlstr(L, str, l, h); /* not found */ -} - - -Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { - Udata *u; - if (s > MAX_SIZET - sizeof(Udata)) - luaM_toobig(L); - u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); - u->uv.marked = luaC_white(G(L)); /* is not finalized */ - u->uv.tt = LUA_TUSERDATA; - u->uv.len = s; - u->uv.metatable = NULL; - u->uv.env = e; - /* chain it on udata list (after main thread) */ - u->uv.next = G(L)->mainthread->next; - G(L)->mainthread->next = obj2gco(u); - return u; -} - diff -Nru gpick-0.2.4/extern/lua/src/lstring.h gpick-0.2.5/extern/lua/src/lstring.h --- gpick-0.2.4/extern/lua/src/lstring.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lstring.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* -** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ -** String table (keep all strings handled by Lua) -** See Copyright Notice in lua.h -*/ - -#ifndef lstring_h -#define lstring_h - - -#include "lgc.h" -#include "lobject.h" -#include "lstate.h" - - -#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) - -#define sizeudata(u) (sizeof(union Udata)+(u)->len) - -#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) -#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ - (sizeof(s)/sizeof(char))-1)) - -#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) - -LUAI_FUNC void luaS_resize (lua_State *L, int newsize); -LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); -LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lstrlib.c gpick-0.2.5/extern/lua/src/lstrlib.c --- gpick-0.2.4/extern/lua/src/lstrlib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lstrlib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,869 +0,0 @@ -/* -** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ -** Standard library for string operations and pattern-matching -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include -#include -#include - -#define lstrlib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -/* macro to `unsign' a character */ -#define uchar(c) ((unsigned char)(c)) - - - -static int str_len (lua_State *L) { - size_t l; - luaL_checklstring(L, 1, &l); - lua_pushinteger(L, l); - return 1; -} - - -static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { - /* relative string position: negative means back from end */ - if (pos < 0) pos += (ptrdiff_t)len + 1; - return (pos >= 0) ? pos : 0; -} - - -static int str_sub (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); - ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); - if (start < 1) start = 1; - if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; - if (start <= end) - lua_pushlstring(L, s+start-1, end-start+1); - else lua_pushliteral(L, ""); - return 1; -} - - -static int str_reverse (lua_State *L) { - size_t l; - luaL_Buffer b; - const char *s = luaL_checklstring(L, 1, &l); - luaL_buffinit(L, &b); - while (l--) luaL_addchar(&b, s[l]); - luaL_pushresult(&b); - return 1; -} - - -static int str_lower (lua_State *L) { - size_t l; - size_t i; - luaL_Buffer b; - const char *s = luaL_checklstring(L, 1, &l); - luaL_buffinit(L, &b); - for (i=0; i 0) - luaL_addlstring(&b, s, l); - luaL_pushresult(&b); - return 1; -} - - -static int str_byte (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); - ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); - int n, i; - if (posi <= 0) posi = 1; - if ((size_t)pose > l) pose = l; - if (posi > pose) return 0; /* empty interval; return no values */ - n = (int)(pose - posi + 1); - if (posi + n <= pose) /* overflow? */ - luaL_error(L, "string slice too long"); - luaL_checkstack(L, n, "string slice too long"); - for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) - return luaL_error(ms->L, "invalid capture index"); - return l; -} - - -static int capture_to_close (MatchState *ms) { - int level = ms->level; - for (level--; level>=0; level--) - if (ms->capture[level].len == CAP_UNFINISHED) return level; - return luaL_error(ms->L, "invalid pattern capture"); -} - - -static const char *classend (MatchState *ms, const char *p) { - switch (*p++) { - case L_ESC: { - if (*p == '\0') - luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); - return p+1; - } - case '[': { - if (*p == '^') p++; - do { /* look for a `]' */ - if (*p == '\0') - luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); - if (*(p++) == L_ESC && *p != '\0') - p++; /* skip escapes (e.g. `%]') */ - } while (*p != ']'); - return p+1; - } - default: { - return p; - } - } -} - - -static int match_class (int c, int cl) { - int res; - switch (tolower(cl)) { - case 'a' : res = isalpha(c); break; - case 'c' : res = iscntrl(c); break; - case 'd' : res = isdigit(c); break; - case 'l' : res = islower(c); break; - case 'p' : res = ispunct(c); break; - case 's' : res = isspace(c); break; - case 'u' : res = isupper(c); break; - case 'w' : res = isalnum(c); break; - case 'x' : res = isxdigit(c); break; - case 'z' : res = (c == 0); break; - default: return (cl == c); - } - return (islower(cl) ? res : !res); -} - - -static int matchbracketclass (int c, const char *p, const char *ec) { - int sig = 1; - if (*(p+1) == '^') { - sig = 0; - p++; /* skip the `^' */ - } - while (++p < ec) { - if (*p == L_ESC) { - p++; - if (match_class(c, uchar(*p))) - return sig; - } - else if ((*(p+1) == '-') && (p+2 < ec)) { - p+=2; - if (uchar(*(p-2)) <= c && c <= uchar(*p)) - return sig; - } - else if (uchar(*p) == c) return sig; - } - return !sig; -} - - -static int singlematch (int c, const char *p, const char *ep) { - switch (*p) { - case '.': return 1; /* matches any char */ - case L_ESC: return match_class(c, uchar(*(p+1))); - case '[': return matchbracketclass(c, p, ep-1); - default: return (uchar(*p) == c); - } -} - - -static const char *match (MatchState *ms, const char *s, const char *p); - - -static const char *matchbalance (MatchState *ms, const char *s, - const char *p) { - if (*p == 0 || *(p+1) == 0) - luaL_error(ms->L, "unbalanced pattern"); - if (*s != *p) return NULL; - else { - int b = *p; - int e = *(p+1); - int cont = 1; - while (++s < ms->src_end) { - if (*s == e) { - if (--cont == 0) return s+1; - } - else if (*s == b) cont++; - } - } - return NULL; /* string ends out of balance */ -} - - -static const char *max_expand (MatchState *ms, const char *s, - const char *p, const char *ep) { - ptrdiff_t i = 0; /* counts maximum expand for item */ - while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) - i++; - /* keeps trying to match with the maximum repetitions */ - while (i>=0) { - const char *res = match(ms, (s+i), ep+1); - if (res) return res; - i--; /* else didn't match; reduce 1 repetition to try again */ - } - return NULL; -} - - -static const char *min_expand (MatchState *ms, const char *s, - const char *p, const char *ep) { - for (;;) { - const char *res = match(ms, s, ep+1); - if (res != NULL) - return res; - else if (ssrc_end && singlematch(uchar(*s), p, ep)) - s++; /* try with one more repetition */ - else return NULL; - } -} - - -static const char *start_capture (MatchState *ms, const char *s, - const char *p, int what) { - const char *res; - int level = ms->level; - if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); - ms->capture[level].init = s; - ms->capture[level].len = what; - ms->level = level+1; - if ((res=match(ms, s, p)) == NULL) /* match failed? */ - ms->level--; /* undo capture */ - return res; -} - - -static const char *end_capture (MatchState *ms, const char *s, - const char *p) { - int l = capture_to_close(ms); - const char *res; - ms->capture[l].len = s - ms->capture[l].init; /* close capture */ - if ((res = match(ms, s, p)) == NULL) /* match failed? */ - ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ - return res; -} - - -static const char *match_capture (MatchState *ms, const char *s, int l) { - size_t len; - l = check_capture(ms, l); - len = ms->capture[l].len; - if ((size_t)(ms->src_end-s) >= len && - memcmp(ms->capture[l].init, s, len) == 0) - return s+len; - else return NULL; -} - - -static const char *match (MatchState *ms, const char *s, const char *p) { - init: /* using goto's to optimize tail recursion */ - switch (*p) { - case '(': { /* start capture */ - if (*(p+1) == ')') /* position capture? */ - return start_capture(ms, s, p+2, CAP_POSITION); - else - return start_capture(ms, s, p+1, CAP_UNFINISHED); - } - case ')': { /* end capture */ - return end_capture(ms, s, p+1); - } - case L_ESC: { - switch (*(p+1)) { - case 'b': { /* balanced string? */ - s = matchbalance(ms, s, p+2); - if (s == NULL) return NULL; - p+=4; goto init; /* else return match(ms, s, p+4); */ - } - case 'f': { /* frontier? */ - const char *ep; char previous; - p += 2; - if (*p != '[') - luaL_error(ms->L, "missing " LUA_QL("[") " after " - LUA_QL("%%f") " in pattern"); - ep = classend(ms, p); /* points to what is next */ - previous = (s == ms->src_init) ? '\0' : *(s-1); - if (matchbracketclass(uchar(previous), p, ep-1) || - !matchbracketclass(uchar(*s), p, ep-1)) return NULL; - p=ep; goto init; /* else return match(ms, s, ep); */ - } - default: { - if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ - s = match_capture(ms, s, uchar(*(p+1))); - if (s == NULL) return NULL; - p+=2; goto init; /* else return match(ms, s, p+2) */ - } - goto dflt; /* case default */ - } - } - } - case '\0': { /* end of pattern */ - return s; /* match succeeded */ - } - case '$': { - if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ - return (s == ms->src_end) ? s : NULL; /* check end of string */ - else goto dflt; - } - default: dflt: { /* it is a pattern item */ - const char *ep = classend(ms, p); /* points to what is next */ - int m = ssrc_end && singlematch(uchar(*s), p, ep); - switch (*ep) { - case '?': { /* optional */ - const char *res; - if (m && ((res=match(ms, s+1, ep+1)) != NULL)) - return res; - p=ep+1; goto init; /* else return match(ms, s, ep+1); */ - } - case '*': { /* 0 or more repetitions */ - return max_expand(ms, s, p, ep); - } - case '+': { /* 1 or more repetitions */ - return (m ? max_expand(ms, s+1, p, ep) : NULL); - } - case '-': { /* 0 or more repetitions (minimum) */ - return min_expand(ms, s, p, ep); - } - default: { - if (!m) return NULL; - s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ - } - } - } - } -} - - - -static const char *lmemfind (const char *s1, size_t l1, - const char *s2, size_t l2) { - if (l2 == 0) return s1; /* empty strings are everywhere */ - else if (l2 > l1) return NULL; /* avoids a negative `l1' */ - else { - const char *init; /* to search for a `*s2' inside `s1' */ - l2--; /* 1st char will be checked by `memchr' */ - l1 = l1-l2; /* `s2' cannot be found after that */ - while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { - init++; /* 1st char is already checked */ - if (memcmp(init, s2+1, l2) == 0) - return init-1; - else { /* correct `l1' and `s1' to try again */ - l1 -= init-s1; - s1 = init; - } - } - return NULL; /* not found */ - } -} - - -static void push_onecapture (MatchState *ms, int i, const char *s, - const char *e) { - if (i >= ms->level) { - if (i == 0) /* ms->level == 0, too */ - lua_pushlstring(ms->L, s, e - s); /* add whole match */ - else - luaL_error(ms->L, "invalid capture index"); - } - else { - ptrdiff_t l = ms->capture[i].len; - if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); - if (l == CAP_POSITION) - lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); - else - lua_pushlstring(ms->L, ms->capture[i].init, l); - } -} - - -static int push_captures (MatchState *ms, const char *s, const char *e) { - int i; - int nlevels = (ms->level == 0 && s) ? 1 : ms->level; - luaL_checkstack(ms->L, nlevels, "too many captures"); - for (i = 0; i < nlevels; i++) - push_onecapture(ms, i, s, e); - return nlevels; /* number of strings pushed */ -} - - -static int str_find_aux (lua_State *L, int find) { - size_t l1, l2; - const char *s = luaL_checklstring(L, 1, &l1); - const char *p = luaL_checklstring(L, 2, &l2); - ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; - if (init < 0) init = 0; - else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; - if (find && (lua_toboolean(L, 4) || /* explicit request? */ - strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ - /* do a plain search */ - const char *s2 = lmemfind(s+init, l1-init, p, l2); - if (s2) { - lua_pushinteger(L, s2-s+1); - lua_pushinteger(L, s2-s+l2); - return 2; - } - } - else { - MatchState ms; - int anchor = (*p == '^') ? (p++, 1) : 0; - const char *s1=s+init; - ms.L = L; - ms.src_init = s; - ms.src_end = s+l1; - do { - const char *res; - ms.level = 0; - if ((res=match(&ms, s1, p)) != NULL) { - if (find) { - lua_pushinteger(L, s1-s+1); /* start */ - lua_pushinteger(L, res-s); /* end */ - return push_captures(&ms, NULL, 0) + 2; - } - else - return push_captures(&ms, s1, res); - } - } while (s1++ < ms.src_end && !anchor); - } - lua_pushnil(L); /* not found */ - return 1; -} - - -static int str_find (lua_State *L) { - return str_find_aux(L, 1); -} - - -static int str_match (lua_State *L) { - return str_find_aux(L, 0); -} - - -static int gmatch_aux (lua_State *L) { - MatchState ms; - size_t ls; - const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); - const char *p = lua_tostring(L, lua_upvalueindex(2)); - const char *src; - ms.L = L; - ms.src_init = s; - ms.src_end = s+ls; - for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); - src <= ms.src_end; - src++) { - const char *e; - ms.level = 0; - if ((e = match(&ms, src, p)) != NULL) { - lua_Integer newstart = e-s; - if (e == src) newstart++; /* empty match? go at least one position */ - lua_pushinteger(L, newstart); - lua_replace(L, lua_upvalueindex(3)); - return push_captures(&ms, src, e); - } - } - return 0; /* not found */ -} - - -static int gmatch (lua_State *L) { - luaL_checkstring(L, 1); - luaL_checkstring(L, 2); - lua_settop(L, 2); - lua_pushinteger(L, 0); - lua_pushcclosure(L, gmatch_aux, 3); - return 1; -} - - -static int gfind_nodef (lua_State *L) { - return luaL_error(L, LUA_QL("string.gfind") " was renamed to " - LUA_QL("string.gmatch")); -} - - -static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, - const char *e) { - size_t l, i; - const char *news = lua_tolstring(ms->L, 3, &l); - for (i = 0; i < l; i++) { - if (news[i] != L_ESC) - luaL_addchar(b, news[i]); - else { - i++; /* skip ESC */ - if (!isdigit(uchar(news[i]))) - luaL_addchar(b, news[i]); - else if (news[i] == '0') - luaL_addlstring(b, s, e - s); - else { - push_onecapture(ms, news[i] - '1', s, e); - luaL_addvalue(b); /* add capture to accumulated result */ - } - } - } -} - - -static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, - const char *e) { - lua_State *L = ms->L; - switch (lua_type(L, 3)) { - case LUA_TNUMBER: - case LUA_TSTRING: { - add_s(ms, b, s, e); - return; - } - case LUA_TFUNCTION: { - int n; - lua_pushvalue(L, 3); - n = push_captures(ms, s, e); - lua_call(L, n, 1); - break; - } - case LUA_TTABLE: { - push_onecapture(ms, 0, s, e); - lua_gettable(L, 3); - break; - } - } - if (!lua_toboolean(L, -1)) { /* nil or false? */ - lua_pop(L, 1); - lua_pushlstring(L, s, e - s); /* keep original text */ - } - else if (!lua_isstring(L, -1)) - luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); - luaL_addvalue(b); /* add result to accumulator */ -} - - -static int str_gsub (lua_State *L) { - size_t srcl; - const char *src = luaL_checklstring(L, 1, &srcl); - const char *p = luaL_checkstring(L, 2); - int tr = lua_type(L, 3); - int max_s = luaL_optint(L, 4, srcl+1); - int anchor = (*p == '^') ? (p++, 1) : 0; - int n = 0; - MatchState ms; - luaL_Buffer b; - luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || - tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, - "string/function/table expected"); - luaL_buffinit(L, &b); - ms.L = L; - ms.src_init = src; - ms.src_end = src+srcl; - while (n < max_s) { - const char *e; - ms.level = 0; - e = match(&ms, src, p); - if (e) { - n++; - add_value(&ms, &b, src, e); - } - if (e && e>src) /* non empty match? */ - src = e; /* skip it */ - else if (src < ms.src_end) - luaL_addchar(&b, *src++); - else break; - if (anchor) break; - } - luaL_addlstring(&b, src, ms.src_end-src); - luaL_pushresult(&b); - lua_pushinteger(L, n); /* number of substitutions */ - return 2; -} - -/* }====================================================== */ - - -/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ -#define MAX_ITEM 512 -/* valid flags in a format specification */ -#define FLAGS "-+ #0" -/* -** maximum size of each format specification (such as '%-099.99d') -** (+10 accounts for %99.99x plus margin of error) -*/ -#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) - - -static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { - size_t l; - const char *s = luaL_checklstring(L, arg, &l); - luaL_addchar(b, '"'); - while (l--) { - switch (*s) { - case '"': case '\\': case '\n': { - luaL_addchar(b, '\\'); - luaL_addchar(b, *s); - break; - } - case '\r': { - luaL_addlstring(b, "\\r", 2); - break; - } - case '\0': { - luaL_addlstring(b, "\\000", 4); - break; - } - default: { - luaL_addchar(b, *s); - break; - } - } - s++; - } - luaL_addchar(b, '"'); -} - -static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { - const char *p = strfrmt; - while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ - if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) - luaL_error(L, "invalid format (repeated flags)"); - if (isdigit(uchar(*p))) p++; /* skip width */ - if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ - if (*p == '.') { - p++; - if (isdigit(uchar(*p))) p++; /* skip precision */ - if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ - } - if (isdigit(uchar(*p))) - luaL_error(L, "invalid format (width or precision too long)"); - *(form++) = '%'; - strncpy(form, strfrmt, p - strfrmt + 1); - form += p - strfrmt + 1; - *form = '\0'; - return p; -} - - -static void addintlen (char *form) { - size_t l = strlen(form); - char spec = form[l - 1]; - strcpy(form + l - 1, LUA_INTFRMLEN); - form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; - form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; -} - - -static int str_format (lua_State *L) { - int arg = 1; - size_t sfl; - const char *strfrmt = luaL_checklstring(L, arg, &sfl); - const char *strfrmt_end = strfrmt+sfl; - luaL_Buffer b; - luaL_buffinit(L, &b); - while (strfrmt < strfrmt_end) { - if (*strfrmt != L_ESC) - luaL_addchar(&b, *strfrmt++); - else if (*++strfrmt == L_ESC) - luaL_addchar(&b, *strfrmt++); /* %% */ - else { /* format item */ - char form[MAX_FORMAT]; /* to store the format (`%...') */ - char buff[MAX_ITEM]; /* to store the formatted item */ - arg++; - strfrmt = scanformat(L, strfrmt, form); - switch (*strfrmt++) { - case 'c': { - sprintf(buff, form, (int)luaL_checknumber(L, arg)); - break; - } - case 'd': case 'i': { - addintlen(form); - sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); - break; - } - case 'o': case 'u': case 'x': case 'X': { - addintlen(form); - sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); - break; - } - case 'e': case 'E': case 'f': - case 'g': case 'G': { - sprintf(buff, form, (double)luaL_checknumber(L, arg)); - break; - } - case 'q': { - addquoted(L, &b, arg); - continue; /* skip the 'addsize' at the end */ - } - case 's': { - size_t l; - const char *s = luaL_checklstring(L, arg, &l); - if (!strchr(form, '.') && l >= 100) { - /* no precision and string is too long to be formatted; - keep original string */ - lua_pushvalue(L, arg); - luaL_addvalue(&b); - continue; /* skip the `addsize' at the end */ - } - else { - sprintf(buff, form, s); - break; - } - } - default: { /* also treat cases `pnLlh' */ - return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " - LUA_QL("format"), *(strfrmt - 1)); - } - } - luaL_addlstring(&b, buff, strlen(buff)); - } - } - luaL_pushresult(&b); - return 1; -} - - -static const luaL_Reg strlib[] = { - {"byte", str_byte}, - {"char", str_char}, - {"dump", str_dump}, - {"find", str_find}, - {"format", str_format}, - {"gfind", gfind_nodef}, - {"gmatch", gmatch}, - {"gsub", str_gsub}, - {"len", str_len}, - {"lower", str_lower}, - {"match", str_match}, - {"rep", str_rep}, - {"reverse", str_reverse}, - {"sub", str_sub}, - {"upper", str_upper}, - {NULL, NULL} -}; - - -static void createmetatable (lua_State *L) { - lua_createtable(L, 0, 1); /* create metatable for strings */ - lua_pushliteral(L, ""); /* dummy string */ - lua_pushvalue(L, -2); - lua_setmetatable(L, -2); /* set string metatable */ - lua_pop(L, 1); /* pop dummy string */ - lua_pushvalue(L, -2); /* string library... */ - lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ - lua_pop(L, 1); /* pop metatable */ -} - - -/* -** Open string library -*/ -LUALIB_API int luaopen_string (lua_State *L) { - luaL_register(L, LUA_STRLIBNAME, strlib); -#if defined(LUA_COMPAT_GFIND) - lua_getfield(L, -1, "gmatch"); - lua_setfield(L, -2, "gfind"); -#endif - createmetatable(L); - return 1; -} - diff -Nru gpick-0.2.4/extern/lua/src/ltable.c gpick-0.2.5/extern/lua/src/ltable.c --- gpick-0.2.4/extern/lua/src/ltable.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ltable.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,588 +0,0 @@ -/* -** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ -** Lua tables (hash) -** See Copyright Notice in lua.h -*/ - - -/* -** Implementation of tables (aka arrays, objects, or hash tables). -** Tables keep its elements in two parts: an array part and a hash part. -** Non-negative integer keys are all candidates to be kept in the array -** part. The actual size of the array is the largest `n' such that at -** least half the slots between 0 and n are in use. -** Hash uses a mix of chained scatter table with Brent's variation. -** A main invariant of these tables is that, if an element is not -** in its main position (i.e. the `original' position that its hash gives -** to it), then the colliding element is in its own main position. -** Hence even when the load factor reaches 100%, performance remains good. -*/ - -#include -#include - -#define ltable_c -#define LUA_CORE - -#include "lua.h" - -#include "ldebug.h" -#include "ldo.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "ltable.h" - - -/* -** max size of array part is 2^MAXBITS -*/ -#if LUAI_BITSINT > 26 -#define MAXBITS 26 -#else -#define MAXBITS (LUAI_BITSINT-2) -#endif - -#define MAXASIZE (1 << MAXBITS) - - -#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) - -#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) -#define hashboolean(t,p) hashpow2(t, p) - - -/* -** for some types, it is better to avoid modulus by power of 2, as -** they tend to have many 2 factors. -*/ -#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) - - -#define hashpointer(t,p) hashmod(t, IntPoint(p)) - - -/* -** number of ints inside a lua_Number -*/ -#define numints cast_int(sizeof(lua_Number)/sizeof(int)) - - - -#define dummynode (&dummynode_) - -static const Node dummynode_ = { - {{NULL}, LUA_TNIL}, /* value */ - {{{NULL}, LUA_TNIL, NULL}} /* key */ -}; - - -/* -** hash for lua_Numbers -*/ -static Node *hashnum (const Table *t, lua_Number n) { - unsigned int a[numints]; - int i; - if (luai_numeq(n, 0)) /* avoid problems with -0 */ - return gnode(t, 0); - memcpy(a, &n, sizeof(a)); - for (i = 1; i < numints; i++) a[0] += a[i]; - return hashmod(t, a[0]); -} - - - -/* -** returns the `main' position of an element in a table (that is, the index -** of its hash value) -*/ -static Node *mainposition (const Table *t, const TValue *key) { - switch (ttype(key)) { - case LUA_TNUMBER: - return hashnum(t, nvalue(key)); - case LUA_TSTRING: - return hashstr(t, rawtsvalue(key)); - case LUA_TBOOLEAN: - return hashboolean(t, bvalue(key)); - case LUA_TLIGHTUSERDATA: - return hashpointer(t, pvalue(key)); - default: - return hashpointer(t, gcvalue(key)); - } -} - - -/* -** returns the index for `key' if `key' is an appropriate key to live in -** the array part of the table, -1 otherwise. -*/ -static int arrayindex (const TValue *key) { - if (ttisnumber(key)) { - lua_Number n = nvalue(key); - int k; - lua_number2int(k, n); - if (luai_numeq(cast_num(k), n)) - return k; - } - return -1; /* `key' did not match some condition */ -} - - -/* -** returns the index of a `key' for table traversals. First goes all -** elements in the array part, then elements in the hash part. The -** beginning of a traversal is signalled by -1. -*/ -static int findindex (lua_State *L, Table *t, StkId key) { - int i; - if (ttisnil(key)) return -1; /* first iteration */ - i = arrayindex(key); - if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ - return i-1; /* yes; that's the index (corrected to C) */ - else { - Node *n = mainposition(t, key); - do { /* check whether `key' is somewhere in the chain */ - /* key may be dead already, but it is ok to use it in `next' */ - if (luaO_rawequalObj(key2tval(n), key) || - (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && - gcvalue(gkey(n)) == gcvalue(key))) { - i = cast_int(n - gnode(t, 0)); /* key index in hash table */ - /* hash elements are numbered after array ones */ - return i + t->sizearray; - } - else n = gnext(n); - } while (n); - luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ - return 0; /* to avoid warnings */ - } -} - - -int luaH_next (lua_State *L, Table *t, StkId key) { - int i = findindex(L, t, key); /* find original element */ - for (i++; i < t->sizearray; i++) { /* try first array part */ - if (!ttisnil(&t->array[i])) { /* a non-nil value? */ - setnvalue(key, cast_num(i+1)); - setobj2s(L, key+1, &t->array[i]); - return 1; - } - } - for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ - if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ - setobj2s(L, key, key2tval(gnode(t, i))); - setobj2s(L, key+1, gval(gnode(t, i))); - return 1; - } - } - return 0; /* no more elements */ -} - - -/* -** {============================================================= -** Rehash -** ============================================================== -*/ - - -static int computesizes (int nums[], int *narray) { - int i; - int twotoi; /* 2^i */ - int a = 0; /* number of elements smaller than 2^i */ - int na = 0; /* number of elements to go to array part */ - int n = 0; /* optimal size for array part */ - for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { - if (nums[i] > 0) { - a += nums[i]; - if (a > twotoi/2) { /* more than half elements present? */ - n = twotoi; /* optimal size (till now) */ - na = a; /* all elements smaller than n will go to array part */ - } - } - if (a == *narray) break; /* all elements already counted */ - } - *narray = n; - lua_assert(*narray/2 <= na && na <= *narray); - return na; -} - - -static int countint (const TValue *key, int *nums) { - int k = arrayindex(key); - if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ - nums[ceillog2(k)]++; /* count as such */ - return 1; - } - else - return 0; -} - - -static int numusearray (const Table *t, int *nums) { - int lg; - int ttlg; /* 2^lg */ - int ause = 0; /* summation of `nums' */ - int i = 1; /* count to traverse all array keys */ - for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ - int lc = 0; /* counter */ - int lim = ttlg; - if (lim > t->sizearray) { - lim = t->sizearray; /* adjust upper limit */ - if (i > lim) - break; /* no more elements to count */ - } - /* count elements in range (2^(lg-1), 2^lg] */ - for (; i <= lim; i++) { - if (!ttisnil(&t->array[i-1])) - lc++; - } - nums[lg] += lc; - ause += lc; - } - return ause; -} - - -static int numusehash (const Table *t, int *nums, int *pnasize) { - int totaluse = 0; /* total number of elements */ - int ause = 0; /* summation of `nums' */ - int i = sizenode(t); - while (i--) { - Node *n = &t->node[i]; - if (!ttisnil(gval(n))) { - ause += countint(key2tval(n), nums); - totaluse++; - } - } - *pnasize += ause; - return totaluse; -} - - -static void setarrayvector (lua_State *L, Table *t, int size) { - int i; - luaM_reallocvector(L, t->array, t->sizearray, size, TValue); - for (i=t->sizearray; iarray[i]); - t->sizearray = size; -} - - -static void setnodevector (lua_State *L, Table *t, int size) { - int lsize; - if (size == 0) { /* no elements to hash part? */ - t->node = cast(Node *, dummynode); /* use common `dummynode' */ - lsize = 0; - } - else { - int i; - lsize = ceillog2(size); - if (lsize > MAXBITS) - luaG_runerror(L, "table overflow"); - size = twoto(lsize); - t->node = luaM_newvector(L, size, Node); - for (i=0; ilsizenode = cast_byte(lsize); - t->lastfree = gnode(t, size); /* all positions are free */ -} - - -static void resize (lua_State *L, Table *t, int nasize, int nhsize) { - int i; - int oldasize = t->sizearray; - int oldhsize = t->lsizenode; - Node *nold = t->node; /* save old hash ... */ - if (nasize > oldasize) /* array part must grow? */ - setarrayvector(L, t, nasize); - /* create new hash part with appropriate size */ - setnodevector(L, t, nhsize); - if (nasize < oldasize) { /* array part must shrink? */ - t->sizearray = nasize; - /* re-insert elements from vanishing slice */ - for (i=nasize; iarray[i])) - setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); - } - /* shrink array */ - luaM_reallocvector(L, t->array, oldasize, nasize, TValue); - } - /* re-insert elements from hash part */ - for (i = twoto(oldhsize) - 1; i >= 0; i--) { - Node *old = nold+i; - if (!ttisnil(gval(old))) - setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); - } - if (nold != dummynode) - luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ -} - - -void luaH_resizearray (lua_State *L, Table *t, int nasize) { - int nsize = (t->node == dummynode) ? 0 : sizenode(t); - resize(L, t, nasize, nsize); -} - - -static void rehash (lua_State *L, Table *t, const TValue *ek) { - int nasize, na; - int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ - int i; - int totaluse; - for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ - nasize = numusearray(t, nums); /* count keys in array part */ - totaluse = nasize; /* all those keys are integer keys */ - totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ - /* count extra key */ - nasize += countint(ek, nums); - totaluse++; - /* compute new size for array part */ - na = computesizes(nums, &nasize); - /* resize the table to new computed sizes */ - resize(L, t, nasize, totaluse - na); -} - - - -/* -** }============================================================= -*/ - - -Table *luaH_new (lua_State *L, int narray, int nhash) { - Table *t = luaM_new(L, Table); - luaC_link(L, obj2gco(t), LUA_TTABLE); - t->metatable = NULL; - t->flags = cast_byte(~0); - /* temporary values (kept only if some malloc fails) */ - t->array = NULL; - t->sizearray = 0; - t->lsizenode = 0; - t->node = cast(Node *, dummynode); - setarrayvector(L, t, narray); - setnodevector(L, t, nhash); - return t; -} - - -void luaH_free (lua_State *L, Table *t) { - if (t->node != dummynode) - luaM_freearray(L, t->node, sizenode(t), Node); - luaM_freearray(L, t->array, t->sizearray, TValue); - luaM_free(L, t); -} - - -static Node *getfreepos (Table *t) { - while (t->lastfree-- > t->node) { - if (ttisnil(gkey(t->lastfree))) - return t->lastfree; - } - return NULL; /* could not find a free place */ -} - - - -/* -** inserts a new key into a hash table; first, check whether key's main -** position is free. If not, check whether colliding node is in its main -** position or not: if it is not, move colliding node to an empty place and -** put new key in its main position; otherwise (colliding node is in its main -** position), new key goes to an empty position. -*/ -static TValue *newkey (lua_State *L, Table *t, const TValue *key) { - Node *mp = mainposition(t, key); - if (!ttisnil(gval(mp)) || mp == dummynode) { - Node *othern; - Node *n = getfreepos(t); /* get a free place */ - if (n == NULL) { /* cannot find a free place? */ - rehash(L, t, key); /* grow table */ - return luaH_set(L, t, key); /* re-insert key into grown table */ - } - lua_assert(n != dummynode); - othern = mainposition(t, key2tval(mp)); - if (othern != mp) { /* is colliding node out of its main position? */ - /* yes; move colliding node into free position */ - while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ - gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ - *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ - gnext(mp) = NULL; /* now `mp' is free */ - setnilvalue(gval(mp)); - } - else { /* colliding node is in its own main position */ - /* new node will go into free position */ - gnext(n) = gnext(mp); /* chain new position */ - gnext(mp) = n; - mp = n; - } - } - gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; - luaC_barriert(L, t, key); - lua_assert(ttisnil(gval(mp))); - return gval(mp); -} - - -/* -** search function for integers -*/ -const TValue *luaH_getnum (Table *t, int key) { - /* (1 <= key && key <= t->sizearray) */ - if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) - return &t->array[key-1]; - else { - lua_Number nk = cast_num(key); - Node *n = hashnum(t, nk); - do { /* check whether `key' is somewhere in the chain */ - if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) - return gval(n); /* that's it */ - else n = gnext(n); - } while (n); - return luaO_nilobject; - } -} - - -/* -** search function for strings -*/ -const TValue *luaH_getstr (Table *t, TString *key) { - Node *n = hashstr(t, key); - do { /* check whether `key' is somewhere in the chain */ - if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) - return gval(n); /* that's it */ - else n = gnext(n); - } while (n); - return luaO_nilobject; -} - - -/* -** main search function -*/ -const TValue *luaH_get (Table *t, const TValue *key) { - switch (ttype(key)) { - case LUA_TNIL: return luaO_nilobject; - case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); - case LUA_TNUMBER: { - int k; - lua_Number n = nvalue(key); - lua_number2int(k, n); - if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ - return luaH_getnum(t, k); /* use specialized version */ - /* else go through */ - } - default: { - Node *n = mainposition(t, key); - do { /* check whether `key' is somewhere in the chain */ - if (luaO_rawequalObj(key2tval(n), key)) - return gval(n); /* that's it */ - else n = gnext(n); - } while (n); - return luaO_nilobject; - } - } -} - - -TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { - const TValue *p = luaH_get(t, key); - t->flags = 0; - if (p != luaO_nilobject) - return cast(TValue *, p); - else { - if (ttisnil(key)) luaG_runerror(L, "table index is nil"); - else if (ttisnumber(key) && luai_numisnan(nvalue(key))) - luaG_runerror(L, "table index is NaN"); - return newkey(L, t, key); - } -} - - -TValue *luaH_setnum (lua_State *L, Table *t, int key) { - const TValue *p = luaH_getnum(t, key); - if (p != luaO_nilobject) - return cast(TValue *, p); - else { - TValue k; - setnvalue(&k, cast_num(key)); - return newkey(L, t, &k); - } -} - - -TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { - const TValue *p = luaH_getstr(t, key); - if (p != luaO_nilobject) - return cast(TValue *, p); - else { - TValue k; - setsvalue(L, &k, key); - return newkey(L, t, &k); - } -} - - -static int unbound_search (Table *t, unsigned int j) { - unsigned int i = j; /* i is zero or a present index */ - j++; - /* find `i' and `j' such that i is present and j is not */ - while (!ttisnil(luaH_getnum(t, j))) { - i = j; - j *= 2; - if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ - /* table was built with bad purposes: resort to linear search */ - i = 1; - while (!ttisnil(luaH_getnum(t, i))) i++; - return i - 1; - } - } - /* now do a binary search between them */ - while (j - i > 1) { - unsigned int m = (i+j)/2; - if (ttisnil(luaH_getnum(t, m))) j = m; - else i = m; - } - return i; -} - - -/* -** Try to find a boundary in table `t'. A `boundary' is an integer index -** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). -*/ -int luaH_getn (Table *t) { - unsigned int j = t->sizearray; - if (j > 0 && ttisnil(&t->array[j - 1])) { - /* there is a boundary in the array part: (binary) search for it */ - unsigned int i = 0; - while (j - i > 1) { - unsigned int m = (i+j)/2; - if (ttisnil(&t->array[m - 1])) j = m; - else i = m; - } - return i; - } - /* else must find a boundary in hash part */ - else if (t->node == dummynode) /* hash part is empty? */ - return j; /* that is easy... */ - else return unbound_search(t, j); -} - - - -#if defined(LUA_DEBUG) - -Node *luaH_mainposition (const Table *t, const TValue *key) { - return mainposition(t, key); -} - -int luaH_isdummy (Node *n) { return n == dummynode; } - -#endif diff -Nru gpick-0.2.4/extern/lua/src/ltable.h gpick-0.2.5/extern/lua/src/ltable.h --- gpick-0.2.4/extern/lua/src/ltable.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ltable.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* -** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ -** Lua tables (hash) -** See Copyright Notice in lua.h -*/ - -#ifndef ltable_h -#define ltable_h - -#include "lobject.h" - - -#define gnode(t,i) (&(t)->node[i]) -#define gkey(n) (&(n)->i_key.nk) -#define gval(n) (&(n)->i_val) -#define gnext(n) ((n)->i_key.nk.next) - -#define key2tval(n) (&(n)->i_key.tvk) - - -LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); -LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); -LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); -LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); -LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); -LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); -LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); -LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); -LUAI_FUNC void luaH_free (lua_State *L, Table *t); -LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); -LUAI_FUNC int luaH_getn (Table *t); - - -#if defined(LUA_DEBUG) -LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); -LUAI_FUNC int luaH_isdummy (Node *n); -#endif - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/ltablib.c gpick-0.2.5/extern/lua/src/ltablib.c --- gpick-0.2.4/extern/lua/src/ltablib.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ltablib.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,287 +0,0 @@ -/* -** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ -** Library for Table Manipulation -** See Copyright Notice in lua.h -*/ - - -#include - -#define ltablib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) - - -static int foreachi (lua_State *L) { - int i; - int n = aux_getn(L, 1); - luaL_checktype(L, 2, LUA_TFUNCTION); - for (i=1; i <= n; i++) { - lua_pushvalue(L, 2); /* function */ - lua_pushinteger(L, i); /* 1st argument */ - lua_rawgeti(L, 1, i); /* 2nd argument */ - lua_call(L, 2, 1); - if (!lua_isnil(L, -1)) - return 1; - lua_pop(L, 1); /* remove nil result */ - } - return 0; -} - - -static int foreach (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checktype(L, 2, LUA_TFUNCTION); - lua_pushnil(L); /* first key */ - while (lua_next(L, 1)) { - lua_pushvalue(L, 2); /* function */ - lua_pushvalue(L, -3); /* key */ - lua_pushvalue(L, -3); /* value */ - lua_call(L, 2, 1); - if (!lua_isnil(L, -1)) - return 1; - lua_pop(L, 2); /* remove value and result */ - } - return 0; -} - - -static int maxn (lua_State *L) { - lua_Number max = 0; - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushnil(L); /* first key */ - while (lua_next(L, 1)) { - lua_pop(L, 1); /* remove value */ - if (lua_type(L, -1) == LUA_TNUMBER) { - lua_Number v = lua_tonumber(L, -1); - if (v > max) max = v; - } - } - lua_pushnumber(L, max); - return 1; -} - - -static int getn (lua_State *L) { - lua_pushinteger(L, aux_getn(L, 1)); - return 1; -} - - -static int setn (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); -#ifndef luaL_setn - luaL_setn(L, 1, luaL_checkint(L, 2)); -#else - luaL_error(L, LUA_QL("setn") " is obsolete"); -#endif - lua_pushvalue(L, 1); - return 1; -} - - -static int tinsert (lua_State *L) { - int e = aux_getn(L, 1) + 1; /* first empty element */ - int pos; /* where to insert new element */ - switch (lua_gettop(L)) { - case 2: { /* called with only 2 arguments */ - pos = e; /* insert new element at the end */ - break; - } - case 3: { - int i; - pos = luaL_checkint(L, 2); /* 2nd argument is the position */ - if (pos > e) e = pos; /* `grow' array if necessary */ - for (i = e; i > pos; i--) { /* move up elements */ - lua_rawgeti(L, 1, i-1); - lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ - } - break; - } - default: { - return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); - } - } - luaL_setn(L, 1, e); /* new size */ - lua_rawseti(L, 1, pos); /* t[pos] = v */ - return 0; -} - - -static int tremove (lua_State *L) { - int e = aux_getn(L, 1); - int pos = luaL_optint(L, 2, e); - if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ - return 0; /* nothing to remove */ - luaL_setn(L, 1, e - 1); /* t.n = n-1 */ - lua_rawgeti(L, 1, pos); /* result = t[pos] */ - for ( ;pos= P */ - while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i>u) luaL_error(L, "invalid order function for sorting"); - lua_pop(L, 1); /* remove a[i] */ - } - /* repeat --j until a[j] <= P */ - while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { - if (j - -#define ltm_c -#define LUA_CORE - -#include "lua.h" - -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" - - - -const char *const luaT_typenames[] = { - "nil", "boolean", "userdata", "number", - "string", "table", "function", "userdata", "thread", - "proto", "upval" -}; - - -void luaT_init (lua_State *L) { - static const char *const luaT_eventname[] = { /* ORDER TM */ - "__index", "__newindex", - "__gc", "__mode", "__eq", - "__add", "__sub", "__mul", "__div", "__mod", - "__pow", "__unm", "__len", "__lt", "__le", - "__concat", "__call" - }; - int i; - for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); - luaS_fix(G(L)->tmname[i]); /* never collect these names */ - } -} - - -/* -** function to be used with macro "fasttm": optimized for absence of -** tag methods -*/ -const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { - const TValue *tm = luaH_getstr(events, ename); - lua_assert(event <= TM_EQ); - if (ttisnil(tm)) { /* no tag method? */ - events->flags |= cast_byte(1u<metatable; - break; - case LUA_TUSERDATA: - mt = uvalue(o)->metatable; - break; - default: - mt = G(L)->mt[ttype(o)]; - } - return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); -} - diff -Nru gpick-0.2.4/extern/lua/src/ltm.h gpick-0.2.5/extern/lua/src/ltm.h --- gpick-0.2.4/extern/lua/src/ltm.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/ltm.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* -** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ -** Tag methods -** See Copyright Notice in lua.h -*/ - -#ifndef ltm_h -#define ltm_h - - -#include "lobject.h" - - -/* -* WARNING: if you change the order of this enumeration, -* grep "ORDER TM" -*/ -typedef enum { - TM_INDEX, - TM_NEWINDEX, - TM_GC, - TM_MODE, - TM_EQ, /* last tag method with `fast' access */ - TM_ADD, - TM_SUB, - TM_MUL, - TM_DIV, - TM_MOD, - TM_POW, - TM_UNM, - TM_LEN, - TM_LT, - TM_LE, - TM_CONCAT, - TM_CALL, - TM_N /* number of elements in the enum */ -} TMS; - - - -#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ - ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) - -#define fasttm(l,et,e) gfasttm(G(l), et, e) - -LUAI_DATA const char *const luaT_typenames[]; - - -LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); -LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, - TMS event); -LUAI_FUNC void luaT_init (lua_State *L); - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lua.c gpick-0.2.5/extern/lua/src/lua.c --- gpick-0.2.4/extern/lua/src/lua.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lua.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,392 +0,0 @@ -/* -** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $ -** Lua stand-alone interpreter -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include -#include - -#define lua_c - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - - -static lua_State *globalL = NULL; - -static const char *progname = LUA_PROGNAME; - - - -static void lstop (lua_State *L, lua_Debug *ar) { - (void)ar; /* unused arg. */ - lua_sethook(L, NULL, 0, 0); - luaL_error(L, "interrupted!"); -} - - -static void laction (int i) { - signal(i, SIG_DFL); /* if another SIGINT happens before lstop, - terminate process (default action) */ - lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); -} - - -static void print_usage (void) { - fprintf(stderr, - "usage: %s [options] [script [args]].\n" - "Available options are:\n" - " -e stat execute string " LUA_QL("stat") "\n" - " -l name require library " LUA_QL("name") "\n" - " -i enter interactive mode after executing " LUA_QL("script") "\n" - " -v show version information\n" - " -- stop handling options\n" - " - execute stdin and stop handling options\n" - , - progname); - fflush(stderr); -} - - -static void l_message (const char *pname, const char *msg) { - if (pname) fprintf(stderr, "%s: ", pname); - fprintf(stderr, "%s\n", msg); - fflush(stderr); -} - - -static int report (lua_State *L, int status) { - if (status && !lua_isnil(L, -1)) { - const char *msg = lua_tostring(L, -1); - if (msg == NULL) msg = "(error object is not a string)"; - l_message(progname, msg); - lua_pop(L, 1); - } - return status; -} - - -static int traceback (lua_State *L) { - if (!lua_isstring(L, 1)) /* 'message' not a string? */ - return 1; /* keep it intact */ - lua_getfield(L, LUA_GLOBALSINDEX, "debug"); - if (!lua_istable(L, -1)) { - lua_pop(L, 1); - return 1; - } - lua_getfield(L, -1, "traceback"); - if (!lua_isfunction(L, -1)) { - lua_pop(L, 2); - return 1; - } - lua_pushvalue(L, 1); /* pass error message */ - lua_pushinteger(L, 2); /* skip this function and traceback */ - lua_call(L, 2, 1); /* call debug.traceback */ - return 1; -} - - -static int docall (lua_State *L, int narg, int clear) { - int status; - int base = lua_gettop(L) - narg; /* function index */ - lua_pushcfunction(L, traceback); /* push traceback function */ - lua_insert(L, base); /* put it under chunk and args */ - signal(SIGINT, laction); - status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); - signal(SIGINT, SIG_DFL); - lua_remove(L, base); /* remove traceback function */ - /* force a complete garbage collection in case of errors */ - if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); - return status; -} - - -static void print_version (void) { - l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); -} - - -static int getargs (lua_State *L, char **argv, int n) { - int narg; - int i; - int argc = 0; - while (argv[argc]) argc++; /* count total number of arguments */ - narg = argc - (n + 1); /* number of arguments to the script */ - luaL_checkstack(L, narg + 3, "too many arguments to script"); - for (i=n+1; i < argc; i++) - lua_pushstring(L, argv[i]); - lua_createtable(L, narg, n + 1); - for (i=0; i < argc; i++) { - lua_pushstring(L, argv[i]); - lua_rawseti(L, -2, i - n); - } - return narg; -} - - -static int dofile (lua_State *L, const char *name) { - int status = luaL_loadfile(L, name) || docall(L, 0, 1); - return report(L, status); -} - - -static int dostring (lua_State *L, const char *s, const char *name) { - int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); - return report(L, status); -} - - -static int dolibrary (lua_State *L, const char *name) { - lua_getglobal(L, "require"); - lua_pushstring(L, name); - return report(L, docall(L, 1, 1)); -} - - -static const char *get_prompt (lua_State *L, int firstline) { - const char *p; - lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); - p = lua_tostring(L, -1); - if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); - lua_pop(L, 1); /* remove global */ - return p; -} - - -static int incomplete (lua_State *L, int status) { - if (status == LUA_ERRSYNTAX) { - size_t lmsg; - const char *msg = lua_tolstring(L, -1, &lmsg); - const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); - if (strstr(msg, LUA_QL("")) == tp) { - lua_pop(L, 1); - return 1; - } - } - return 0; /* else... */ -} - - -static int pushline (lua_State *L, int firstline) { - char buffer[LUA_MAXINPUT]; - char *b = buffer; - size_t l; - const char *prmt = get_prompt(L, firstline); - if (lua_readline(L, b, prmt) == 0) - return 0; /* no input */ - l = strlen(b); - if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ - b[l-1] = '\0'; /* remove it */ - if (firstline && b[0] == '=') /* first line starts with `=' ? */ - lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ - else - lua_pushstring(L, b); - lua_freeline(L, b); - return 1; -} - - -static int loadline (lua_State *L) { - int status; - lua_settop(L, 0); - if (!pushline(L, 1)) - return -1; /* no input */ - for (;;) { /* repeat until gets a complete line */ - status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); - if (!incomplete(L, status)) break; /* cannot try to add lines? */ - if (!pushline(L, 0)) /* no more input? */ - return -1; - lua_pushliteral(L, "\n"); /* add a new line... */ - lua_insert(L, -2); /* ...between the two lines */ - lua_concat(L, 3); /* join them */ - } - lua_saveline(L, 1); - lua_remove(L, 1); /* remove line */ - return status; -} - - -static void dotty (lua_State *L) { - int status; - const char *oldprogname = progname; - progname = NULL; - while ((status = loadline(L)) != -1) { - if (status == 0) status = docall(L, 0, 0); - report(L, status); - if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ - lua_getglobal(L, "print"); - lua_insert(L, 1); - if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) - l_message(progname, lua_pushfstring(L, - "error calling " LUA_QL("print") " (%s)", - lua_tostring(L, -1))); - } - } - lua_settop(L, 0); /* clear stack */ - fputs("\n", stdout); - fflush(stdout); - progname = oldprogname; -} - - -static int handle_script (lua_State *L, char **argv, int n) { - int status; - const char *fname; - int narg = getargs(L, argv, n); /* collect arguments */ - lua_setglobal(L, "arg"); - fname = argv[n]; - if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) - fname = NULL; /* stdin */ - status = luaL_loadfile(L, fname); - lua_insert(L, -(narg+1)); - if (status == 0) - status = docall(L, narg, 0); - else - lua_pop(L, narg); - return report(L, status); -} - - -/* check that argument has no extra characters at the end */ -#define notail(x) {if ((x)[2] != '\0') return -1;} - - -static int collectargs (char **argv, int *pi, int *pv, int *pe) { - int i; - for (i = 1; argv[i] != NULL; i++) { - if (argv[i][0] != '-') /* not an option? */ - return i; - switch (argv[i][1]) { /* option */ - case '-': - notail(argv[i]); - return (argv[i+1] != NULL ? i+1 : 0); - case '\0': - return i; - case 'i': - notail(argv[i]); - *pi = 1; /* go through */ - case 'v': - notail(argv[i]); - *pv = 1; - break; - case 'e': - *pe = 1; /* go through */ - case 'l': - if (argv[i][2] == '\0') { - i++; - if (argv[i] == NULL) return -1; - } - break; - default: return -1; /* invalid option */ - } - } - return 0; -} - - -static int runargs (lua_State *L, char **argv, int n) { - int i; - for (i = 1; i < n; i++) { - if (argv[i] == NULL) continue; - lua_assert(argv[i][0] == '-'); - switch (argv[i][1]) { /* option */ - case 'e': { - const char *chunk = argv[i] + 2; - if (*chunk == '\0') chunk = argv[++i]; - lua_assert(chunk != NULL); - if (dostring(L, chunk, "=(command line)") != 0) - return 1; - break; - } - case 'l': { - const char *filename = argv[i] + 2; - if (*filename == '\0') filename = argv[++i]; - lua_assert(filename != NULL); - if (dolibrary(L, filename)) - return 1; /* stop if file fails */ - break; - } - default: break; - } - } - return 0; -} - - -static int handle_luainit (lua_State *L) { - const char *init = getenv(LUA_INIT); - if (init == NULL) return 0; /* status OK */ - else if (init[0] == '@') - return dofile(L, init+1); - else - return dostring(L, init, "=" LUA_INIT); -} - - -struct Smain { - int argc; - char **argv; - int status; -}; - - -static int pmain (lua_State *L) { - struct Smain *s = (struct Smain *)lua_touserdata(L, 1); - char **argv = s->argv; - int script; - int has_i = 0, has_v = 0, has_e = 0; - globalL = L; - if (argv[0] && argv[0][0]) progname = argv[0]; - lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ - luaL_openlibs(L); /* open libraries */ - lua_gc(L, LUA_GCRESTART, 0); - s->status = handle_luainit(L); - if (s->status != 0) return 0; - script = collectargs(argv, &has_i, &has_v, &has_e); - if (script < 0) { /* invalid args? */ - print_usage(); - s->status = 1; - return 0; - } - if (has_v) print_version(); - s->status = runargs(L, argv, (script > 0) ? script : s->argc); - if (s->status != 0) return 0; - if (script) - s->status = handle_script(L, argv, script); - if (s->status != 0) return 0; - if (has_i) - dotty(L); - else if (script == 0 && !has_e && !has_v) { - if (lua_stdin_is_tty()) { - print_version(); - dotty(L); - } - else dofile(L, NULL); /* executes stdin as a file */ - } - return 0; -} - - -int main (int argc, char **argv) { - int status; - struct Smain s; - lua_State *L = lua_open(); /* create state */ - if (L == NULL) { - l_message(argv[0], "cannot create state: not enough memory"); - return EXIT_FAILURE; - } - s.argc = argc; - s.argv = argv; - status = lua_cpcall(L, &pmain, &s); - report(L, status); - lua_close(L); - return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; -} - diff -Nru gpick-0.2.4/extern/lua/src/lua.h gpick-0.2.5/extern/lua/src/lua.h --- gpick-0.2.4/extern/lua/src/lua.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lua.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,388 +0,0 @@ -/* -** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ -** Lua - An Extensible Extension Language -** Lua.org, PUC-Rio, Brazil (http://www.lua.org) -** See Copyright Notice at the end of this file -*/ - - -#ifndef lua_h -#define lua_h - -#include -#include - - -#include "luaconf.h" - - -#define LUA_VERSION "Lua 5.1" -#define LUA_RELEASE "Lua 5.1.4" -#define LUA_VERSION_NUM 501 -#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" -#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" - - -/* mark for precompiled code (`Lua') */ -#define LUA_SIGNATURE "\033Lua" - -/* option for multiple returns in `lua_pcall' and `lua_call' */ -#define LUA_MULTRET (-1) - - -/* -** pseudo-indices -*/ -#define LUA_REGISTRYINDEX (-10000) -#define LUA_ENVIRONINDEX (-10001) -#define LUA_GLOBALSINDEX (-10002) -#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) - - -/* thread status; 0 is OK */ -#define LUA_YIELD 1 -#define LUA_ERRRUN 2 -#define LUA_ERRSYNTAX 3 -#define LUA_ERRMEM 4 -#define LUA_ERRERR 5 - - -typedef struct lua_State lua_State; - -typedef int (*lua_CFunction) (lua_State *L); - - -/* -** functions that read/write blocks when loading/dumping Lua chunks -*/ -typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); - -typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); - - -/* -** prototype for memory-allocation functions -*/ -typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); - - -/* -** basic types -*/ -#define LUA_TNONE (-1) - -#define LUA_TNIL 0 -#define LUA_TBOOLEAN 1 -#define LUA_TLIGHTUSERDATA 2 -#define LUA_TNUMBER 3 -#define LUA_TSTRING 4 -#define LUA_TTABLE 5 -#define LUA_TFUNCTION 6 -#define LUA_TUSERDATA 7 -#define LUA_TTHREAD 8 - - - -/* minimum Lua stack available to a C function */ -#define LUA_MINSTACK 20 - - -/* -** generic extra include file -*/ -#if defined(LUA_USER_H) -#include LUA_USER_H -#endif - - -/* type of numbers in Lua */ -typedef LUA_NUMBER lua_Number; - - -/* type for integer functions */ -typedef LUA_INTEGER lua_Integer; - - - -/* -** state manipulation -*/ -LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); -LUA_API void (lua_close) (lua_State *L); -LUA_API lua_State *(lua_newthread) (lua_State *L); - -LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); - - -/* -** basic stack manipulation -*/ -LUA_API int (lua_gettop) (lua_State *L); -LUA_API void (lua_settop) (lua_State *L, int idx); -LUA_API void (lua_pushvalue) (lua_State *L, int idx); -LUA_API void (lua_remove) (lua_State *L, int idx); -LUA_API void (lua_insert) (lua_State *L, int idx); -LUA_API void (lua_replace) (lua_State *L, int idx); -LUA_API int (lua_checkstack) (lua_State *L, int sz); - -LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); - - -/* -** access functions (stack -> C) -*/ - -LUA_API int (lua_isnumber) (lua_State *L, int idx); -LUA_API int (lua_isstring) (lua_State *L, int idx); -LUA_API int (lua_iscfunction) (lua_State *L, int idx); -LUA_API int (lua_isuserdata) (lua_State *L, int idx); -LUA_API int (lua_type) (lua_State *L, int idx); -LUA_API const char *(lua_typename) (lua_State *L, int tp); - -LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); -LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); -LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); - -LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); -LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); -LUA_API int (lua_toboolean) (lua_State *L, int idx); -LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); -LUA_API size_t (lua_objlen) (lua_State *L, int idx); -LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); -LUA_API void *(lua_touserdata) (lua_State *L, int idx); -LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); -LUA_API const void *(lua_topointer) (lua_State *L, int idx); - - -/* -** push functions (C -> stack) -*/ -LUA_API void (lua_pushnil) (lua_State *L); -LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); -LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); -LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); -LUA_API void (lua_pushstring) (lua_State *L, const char *s); -LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, - va_list argp); -LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); -LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); -LUA_API void (lua_pushboolean) (lua_State *L, int b); -LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); -LUA_API int (lua_pushthread) (lua_State *L); - - -/* -** get functions (Lua -> stack) -*/ -LUA_API void (lua_gettable) (lua_State *L, int idx); -LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); -LUA_API void (lua_rawget) (lua_State *L, int idx); -LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); -LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); -LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); -LUA_API int (lua_getmetatable) (lua_State *L, int objindex); -LUA_API void (lua_getfenv) (lua_State *L, int idx); - - -/* -** set functions (stack -> Lua) -*/ -LUA_API void (lua_settable) (lua_State *L, int idx); -LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); -LUA_API void (lua_rawset) (lua_State *L, int idx); -LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); -LUA_API int (lua_setmetatable) (lua_State *L, int objindex); -LUA_API int (lua_setfenv) (lua_State *L, int idx); - - -/* -** `load' and `call' functions (load and run Lua code) -*/ -LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); -LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); -LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); -LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, - const char *chunkname); - -LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); - - -/* -** coroutine functions -*/ -LUA_API int (lua_yield) (lua_State *L, int nresults); -LUA_API int (lua_resume) (lua_State *L, int narg); -LUA_API int (lua_status) (lua_State *L); - -/* -** garbage-collection function and options -*/ - -#define LUA_GCSTOP 0 -#define LUA_GCRESTART 1 -#define LUA_GCCOLLECT 2 -#define LUA_GCCOUNT 3 -#define LUA_GCCOUNTB 4 -#define LUA_GCSTEP 5 -#define LUA_GCSETPAUSE 6 -#define LUA_GCSETSTEPMUL 7 - -LUA_API int (lua_gc) (lua_State *L, int what, int data); - - -/* -** miscellaneous functions -*/ - -LUA_API int (lua_error) (lua_State *L); - -LUA_API int (lua_next) (lua_State *L, int idx); - -LUA_API void (lua_concat) (lua_State *L, int n); - -LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); -LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); - - - -/* -** =============================================================== -** some useful macros -** =============================================================== -*/ - -#define lua_pop(L,n) lua_settop(L, -(n)-1) - -#define lua_newtable(L) lua_createtable(L, 0, 0) - -#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) - -#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) - -#define lua_strlen(L,i) lua_objlen(L, (i)) - -#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) -#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) -#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) -#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) -#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) -#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) -#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) -#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) - -#define lua_pushliteral(L, s) \ - lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) - -#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) -#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) - -#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) - - - -/* -** compatibility macros and functions -*/ - -#define lua_open() luaL_newstate() - -#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) - -#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) - -#define lua_Chunkreader lua_Reader -#define lua_Chunkwriter lua_Writer - - -/* hack */ -LUA_API void lua_setlevel (lua_State *from, lua_State *to); - - -/* -** {====================================================================== -** Debug API -** ======================================================================= -*/ - - -/* -** Event codes -*/ -#define LUA_HOOKCALL 0 -#define LUA_HOOKRET 1 -#define LUA_HOOKLINE 2 -#define LUA_HOOKCOUNT 3 -#define LUA_HOOKTAILRET 4 - - -/* -** Event masks -*/ -#define LUA_MASKCALL (1 << LUA_HOOKCALL) -#define LUA_MASKRET (1 << LUA_HOOKRET) -#define LUA_MASKLINE (1 << LUA_HOOKLINE) -#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) - -typedef struct lua_Debug lua_Debug; /* activation record */ - - -/* Functions to be called by the debuger in specific events */ -typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); - - -LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); -LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); -LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); -LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); -LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); -LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); - -LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); -LUA_API lua_Hook lua_gethook (lua_State *L); -LUA_API int lua_gethookmask (lua_State *L); -LUA_API int lua_gethookcount (lua_State *L); - - -struct lua_Debug { - int event; - const char *name; /* (n) */ - const char *namewhat; /* (n) `global', `local', `field', `method' */ - const char *what; /* (S) `Lua', `C', `main', `tail' */ - const char *source; /* (S) */ - int currentline; /* (l) */ - int nups; /* (u) number of upvalues */ - int linedefined; /* (S) */ - int lastlinedefined; /* (S) */ - char short_src[LUA_IDSIZE]; /* (S) */ - /* private part */ - int i_ci; /* active function */ -}; - -/* }====================================================================== */ - - -/****************************************************************************** -* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/luac.c gpick-0.2.5/extern/lua/src/luac.c --- gpick-0.2.4/extern/lua/src/luac.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/luac.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,200 +0,0 @@ -/* -** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $ -** Lua compiler (saves bytecodes to files; also list bytecodes) -** See Copyright Notice in lua.h -*/ - -#include -#include -#include -#include - -#define luac_c -#define LUA_CORE - -#include "lua.h" -#include "lauxlib.h" - -#include "ldo.h" -#include "lfunc.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lstring.h" -#include "lundump.h" - -#define PROGNAME "luac" /* default program name */ -#define OUTPUT PROGNAME ".out" /* default output file */ - -static int listing=0; /* list bytecodes? */ -static int dumping=1; /* dump bytecodes? */ -static int stripping=0; /* strip debug information? */ -static char Output[]={ OUTPUT }; /* default output file name */ -static const char* output=Output; /* actual output file name */ -static const char* progname=PROGNAME; /* actual program name */ - -static void fatal(const char* message) -{ - fprintf(stderr,"%s: %s\n",progname,message); - exit(EXIT_FAILURE); -} - -static void cannot(const char* what) -{ - fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno)); - exit(EXIT_FAILURE); -} - -static void usage(const char* message) -{ - if (*message=='-') - fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message); - else - fprintf(stderr,"%s: %s\n",progname,message); - fprintf(stderr, - "usage: %s [options] [filenames].\n" - "Available options are:\n" - " - process stdin\n" - " -l list\n" - " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" - " -p parse only\n" - " -s strip debug information\n" - " -v show version information\n" - " -- stop handling options\n", - progname,Output); - exit(EXIT_FAILURE); -} - -#define IS(s) (strcmp(argv[i],s)==0) - -static int doargs(int argc, char* argv[]) -{ - int i; - int version=0; - if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; - for (i=1; itop+(i))->l.p) - -static const Proto* combine(lua_State* L, int n) -{ - if (n==1) - return toproto(L,-1); - else - { - int i,pc; - Proto* f=luaF_newproto(L); - setptvalue2s(L,L->top,f); incr_top(L); - f->source=luaS_newliteral(L,"=(" PROGNAME ")"); - f->maxstacksize=1; - pc=2*n+1; - f->code=luaM_newvector(L,pc,Instruction); - f->sizecode=pc; - f->p=luaM_newvector(L,n,Proto*); - f->sizep=n; - pc=0; - for (i=0; ip[i]=toproto(L,i-n-1); - f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i); - f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1); - } - f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0); - return f; - } -} - -static int writer(lua_State* L, const void* p, size_t size, void* u) -{ - UNUSED(L); - return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); -} - -struct Smain { - int argc; - char** argv; -}; - -static int pmain(lua_State* L) -{ - struct Smain* s = (struct Smain*)lua_touserdata(L, 1); - int argc=s->argc; - char** argv=s->argv; - const Proto* f; - int i; - if (!lua_checkstack(L,argc)) fatal("too many input files"); - for (i=0; i1); - if (dumping) - { - FILE* D= (output==NULL) ? stdout : fopen(output,"wb"); - if (D==NULL) cannot("open"); - lua_lock(L); - luaU_dump(L,f,writer,D,stripping); - lua_unlock(L); - if (ferror(D)) cannot("write"); - if (fclose(D)) cannot("close"); - } - return 0; -} - -int main(int argc, char* argv[]) -{ - lua_State* L; - struct Smain s; - int i=doargs(argc,argv); - argc-=i; argv+=i; - if (argc<=0) usage("no input files given"); - L=lua_open(); - if (L==NULL) fatal("not enough memory for state"); - s.argc=argc; - s.argv=argv; - if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1)); - lua_close(L); - return EXIT_SUCCESS; -} diff -Nru gpick-0.2.4/extern/lua/src/luaconf.h gpick-0.2.5/extern/lua/src/luaconf.h --- gpick-0.2.4/extern/lua/src/luaconf.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/luaconf.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,763 +0,0 @@ -/* -** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ -** Configuration file for Lua -** See Copyright Notice in lua.h -*/ - - -#ifndef lconfig_h -#define lconfig_h - -#include -#include - - -/* -** ================================================================== -** Search for "@@" to find all configurable definitions. -** =================================================================== -*/ - - -/* -@@ LUA_ANSI controls the use of non-ansi features. -** CHANGE it (define it) if you want Lua to avoid the use of any -** non-ansi feature or library. -*/ -#if defined(__STRICT_ANSI__) -#define LUA_ANSI -#endif - - -#if !defined(LUA_ANSI) && defined(_WIN32) -#define LUA_WIN -#endif - -#if defined(LUA_USE_LINUX) -#define LUA_USE_POSIX -#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ -#define LUA_USE_READLINE /* needs some extra libraries */ -#endif - -#if defined(LUA_USE_MACOSX) -#define LUA_USE_POSIX -#define LUA_DL_DYLD /* does not need extra library */ -#endif - - - -/* -@@ LUA_USE_POSIX includes all functionallity listed as X/Open System -@* Interfaces Extension (XSI). -** CHANGE it (define it) if your system is XSI compatible. -*/ -#if defined(LUA_USE_POSIX) -#define LUA_USE_MKSTEMP -#define LUA_USE_ISATTY -#define LUA_USE_POPEN -#define LUA_USE_ULONGJMP -#endif - - -/* -@@ LUA_PATH and LUA_CPATH are the names of the environment variables that -@* Lua check to set its paths. -@@ LUA_INIT is the name of the environment variable that Lua -@* checks for initialization code. -** CHANGE them if you want different names. -*/ -#define LUA_PATH "LUA_PATH" -#define LUA_CPATH "LUA_CPATH" -#define LUA_INIT "LUA_INIT" - - -/* -@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for -@* Lua libraries. -@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for -@* C libraries. -** CHANGE them if your machine has a non-conventional directory -** hierarchy or if you want to install your libraries in -** non-conventional directories. -*/ -#if defined(_WIN32) -/* -** In Windows, any exclamation mark ('!') in the path is replaced by the -** path of the directory of the executable file of the current process. -*/ -#define LUA_LDIR "!\\lua\\" -#define LUA_CDIR "!\\" -#define LUA_PATH_DEFAULT \ - ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ - LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" -#define LUA_CPATH_DEFAULT \ - ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" - -#else -#define LUA_ROOT "/usr/local/" -#define LUA_LDIR LUA_ROOT "share/lua/5.1/" -#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" -#define LUA_PATH_DEFAULT \ - "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ - LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" -#define LUA_CPATH_DEFAULT \ - "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" -#endif - - -/* -@@ LUA_DIRSEP is the directory separator (for submodules). -** CHANGE it if your machine does not use "/" as the directory separator -** and is not Windows. (On Windows Lua automatically uses "\".) -*/ -#if defined(_WIN32) -#define LUA_DIRSEP "\\" -#else -#define LUA_DIRSEP "/" -#endif - - -/* -@@ LUA_PATHSEP is the character that separates templates in a path. -@@ LUA_PATH_MARK is the string that marks the substitution points in a -@* template. -@@ LUA_EXECDIR in a Windows path is replaced by the executable's -@* directory. -@@ LUA_IGMARK is a mark to ignore all before it when bulding the -@* luaopen_ function name. -** CHANGE them if for some reason your system cannot use those -** characters. (E.g., if one of those characters is a common character -** in file/directory names.) Probably you do not need to change them. -*/ -#define LUA_PATHSEP ";" -#define LUA_PATH_MARK "?" -#define LUA_EXECDIR "!" -#define LUA_IGMARK "-" - - -/* -@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. -** CHANGE that if ptrdiff_t is not adequate on your machine. (On most -** machines, ptrdiff_t gives a good choice between int or long.) -*/ -#define LUA_INTEGER ptrdiff_t - - -/* -@@ LUA_API is a mark for all core API functions. -@@ LUALIB_API is a mark for all standard library functions. -** CHANGE them if you need to define those functions in some special way. -** For instance, if you want to create one Windows DLL with the core and -** the libraries, you may want to use the following definition (define -** LUA_BUILD_AS_DLL to get it). -*/ -#if defined(LUA_BUILD_AS_DLL) - -#if defined(LUA_CORE) || defined(LUA_LIB) -#define LUA_API __declspec(dllexport) -#else -#define LUA_API __declspec(dllimport) -#endif - -#else - -#define LUA_API extern - -#endif - -/* more often than not the libs go together with the core */ -#define LUALIB_API LUA_API - - -/* -@@ LUAI_FUNC is a mark for all extern functions that are not to be -@* exported to outside modules. -@@ LUAI_DATA is a mark for all extern (const) variables that are not to -@* be exported to outside modules. -** CHANGE them if you need to mark them in some special way. Elf/gcc -** (versions 3.2 and later) mark them as "hidden" to optimize access -** when Lua is compiled as a shared library. -*/ -#if defined(luaall_c) -#define LUAI_FUNC static -#define LUAI_DATA /* empty */ - -#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ - defined(__ELF__) -#define LUAI_FUNC __attribute__((visibility("hidden"))) extern -#define LUAI_DATA LUAI_FUNC - -#else -#define LUAI_FUNC extern -#define LUAI_DATA extern -#endif - - - -/* -@@ LUA_QL describes how error messages quote program elements. -** CHANGE it if you want a different appearance. -*/ -#define LUA_QL(x) "'" x "'" -#define LUA_QS LUA_QL("%s") - - -/* -@@ LUA_IDSIZE gives the maximum size for the description of the source -@* of a function in debug information. -** CHANGE it if you want a different size. -*/ -#define LUA_IDSIZE 60 - - -/* -** {================================================================== -** Stand-alone configuration -** =================================================================== -*/ - -#if defined(lua_c) || defined(luaall_c) - -/* -@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that -@* is, whether we're running lua interactively). -** CHANGE it if you have a better definition for non-POSIX/non-Windows -** systems. -*/ -#if defined(LUA_USE_ISATTY) -#include -#define lua_stdin_is_tty() isatty(0) -#elif defined(LUA_WIN) -#include -#include -#define lua_stdin_is_tty() _isatty(_fileno(stdin)) -#else -#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ -#endif - - -/* -@@ LUA_PROMPT is the default prompt used by stand-alone Lua. -@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. -** CHANGE them if you want different prompts. (You can also change the -** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) -*/ -#define LUA_PROMPT "> " -#define LUA_PROMPT2 ">> " - - -/* -@@ LUA_PROGNAME is the default name for the stand-alone Lua program. -** CHANGE it if your stand-alone interpreter has a different name and -** your system is not able to detect that name automatically. -*/ -#define LUA_PROGNAME "lua" - - -/* -@@ LUA_MAXINPUT is the maximum length for an input line in the -@* stand-alone interpreter. -** CHANGE it if you need longer lines. -*/ -#define LUA_MAXINPUT 512 - - -/* -@@ lua_readline defines how to show a prompt and then read a line from -@* the standard input. -@@ lua_saveline defines how to "save" a read line in a "history". -@@ lua_freeline defines how to free a line read by lua_readline. -** CHANGE them if you want to improve this functionality (e.g., by using -** GNU readline and history facilities). -*/ -#if defined(LUA_USE_READLINE) -#include -#include -#include -#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) -#define lua_saveline(L,idx) \ - if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ - add_history(lua_tostring(L, idx)); /* add it to history */ -#define lua_freeline(L,b) ((void)L, free(b)) -#else -#define lua_readline(L,b,p) \ - ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ - fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ -#define lua_saveline(L,idx) { (void)L; (void)idx; } -#define lua_freeline(L,b) { (void)L; (void)b; } -#endif - -#endif - -/* }================================================================== */ - - -/* -@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles -@* as a percentage. -** CHANGE it if you want the GC to run faster or slower (higher values -** mean larger pauses which mean slower collection.) You can also change -** this value dynamically. -*/ -#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ - - -/* -@@ LUAI_GCMUL defines the default speed of garbage collection relative to -@* memory allocation as a percentage. -** CHANGE it if you want to change the granularity of the garbage -** collection. (Higher values mean coarser collections. 0 represents -** infinity, where each step performs a full collection.) You can also -** change this value dynamically. -*/ -#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ - - - -/* -@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. -** CHANGE it (define it) if you want exact compatibility with the -** behavior of setn/getn in Lua 5.0. -*/ -#undef LUA_COMPAT_GETN - -/* -@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. -** CHANGE it to undefined as soon as you do not need a global 'loadlib' -** function (the function is still available as 'package.loadlib'). -*/ -#undef LUA_COMPAT_LOADLIB - -/* -@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. -** CHANGE it to undefined as soon as your programs use only '...' to -** access vararg parameters (instead of the old 'arg' table). -*/ -#define LUA_COMPAT_VARARG - -/* -@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. -** CHANGE it to undefined as soon as your programs use 'math.fmod' or -** the new '%' operator instead of 'math.mod'. -*/ -#define LUA_COMPAT_MOD - -/* -@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting -@* facility. -** CHANGE it to 2 if you want the old behaviour, or undefine it to turn -** off the advisory error when nesting [[...]]. -*/ -#define LUA_COMPAT_LSTR 1 - -/* -@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. -** CHANGE it to undefined as soon as you rename 'string.gfind' to -** 'string.gmatch'. -*/ -#define LUA_COMPAT_GFIND - -/* -@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' -@* behavior. -** CHANGE it to undefined as soon as you replace to 'luaL_register' -** your uses of 'luaL_openlib' -*/ -#define LUA_COMPAT_OPENLIB - - - -/* -@@ luai_apicheck is the assert macro used by the Lua-C API. -** CHANGE luai_apicheck if you want Lua to perform some checks in the -** parameters it gets from API calls. This may slow down the interpreter -** a bit, but may be quite useful when debugging C code that interfaces -** with Lua. A useful redefinition is to use assert.h. -*/ -#if defined(LUA_USE_APICHECK) -#include -#define luai_apicheck(L,o) { (void)L; assert(o); } -#else -#define luai_apicheck(L,o) { (void)L; } -#endif - - -/* -@@ LUAI_BITSINT defines the number of bits in an int. -** CHANGE here if Lua cannot automatically detect the number of bits of -** your machine. Probably you do not need to change this. -*/ -/* avoid overflows in comparison */ -#if INT_MAX-20 < 32760 -#define LUAI_BITSINT 16 -#elif INT_MAX > 2147483640L -/* int has at least 32 bits */ -#define LUAI_BITSINT 32 -#else -#error "you must define LUA_BITSINT with number of bits in an integer" -#endif - - -/* -@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. -@@ LUAI_INT32 is an signed integer with at least 32 bits. -@@ LUAI_UMEM is an unsigned integer big enough to count the total -@* memory used by Lua. -@@ LUAI_MEM is a signed integer big enough to count the total memory -@* used by Lua. -** CHANGE here if for some weird reason the default definitions are not -** good enough for your machine. (The definitions in the 'else' -** part always works, but may waste space on machines with 64-bit -** longs.) Probably you do not need to change this. -*/ -#if LUAI_BITSINT >= 32 -#define LUAI_UINT32 unsigned int -#define LUAI_INT32 int -#define LUAI_MAXINT32 INT_MAX -#define LUAI_UMEM size_t -#define LUAI_MEM ptrdiff_t -#else -/* 16-bit ints */ -#define LUAI_UINT32 unsigned long -#define LUAI_INT32 long -#define LUAI_MAXINT32 LONG_MAX -#define LUAI_UMEM unsigned long -#define LUAI_MEM long -#endif - - -/* -@@ LUAI_MAXCALLS limits the number of nested calls. -** CHANGE it if you need really deep recursive calls. This limit is -** arbitrary; its only purpose is to stop infinite recursion before -** exhausting memory. -*/ -#define LUAI_MAXCALLS 20000 - - -/* -@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function -@* can use. -** CHANGE it if you need lots of (Lua) stack space for your C -** functions. This limit is arbitrary; its only purpose is to stop C -** functions to consume unlimited stack space. (must be smaller than -** -LUA_REGISTRYINDEX) -*/ -#define LUAI_MAXCSTACK 8000 - - - -/* -** {================================================================== -** CHANGE (to smaller values) the following definitions if your system -** has a small C stack. (Or you may want to change them to larger -** values if your system has a large C stack and these limits are -** too rigid for you.) Some of these constants control the size of -** stack-allocated arrays used by the compiler or the interpreter, while -** others limit the maximum number of recursive calls that the compiler -** or the interpreter can perform. Values too large may cause a C stack -** overflow for some forms of deep constructs. -** =================================================================== -*/ - - -/* -@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and -@* syntactical nested non-terminals in a program. -*/ -#define LUAI_MAXCCALLS 200 - - -/* -@@ LUAI_MAXVARS is the maximum number of local variables per function -@* (must be smaller than 250). -*/ -#define LUAI_MAXVARS 200 - - -/* -@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function -@* (must be smaller than 250). -*/ -#define LUAI_MAXUPVALUES 60 - - -/* -@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. -*/ -#define LUAL_BUFFERSIZE BUFSIZ - -/* }================================================================== */ - - - - -/* -** {================================================================== -@@ LUA_NUMBER is the type of numbers in Lua. -** CHANGE the following definitions only if you want to build Lua -** with a number type different from double. You may also need to -** change lua_number2int & lua_number2integer. -** =================================================================== -*/ - -#define LUA_NUMBER_DOUBLE -#define LUA_NUMBER double - -/* -@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' -@* over a number. -*/ -#define LUAI_UACNUMBER double - - -/* -@@ LUA_NUMBER_SCAN is the format for reading numbers. -@@ LUA_NUMBER_FMT is the format for writing numbers. -@@ lua_number2str converts a number to a string. -@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. -@@ lua_str2number converts a string to a number. -*/ -#define LUA_NUMBER_SCAN "%lf" -#define LUA_NUMBER_FMT "%.14g" -#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) -#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ -#define lua_str2number(s,p) strtod((s), (p)) - - -/* -@@ The luai_num* macros define the primitive operations over numbers. -*/ -#if defined(LUA_CORE) -#include -#define luai_numadd(a,b) ((a)+(b)) -#define luai_numsub(a,b) ((a)-(b)) -#define luai_nummul(a,b) ((a)*(b)) -#define luai_numdiv(a,b) ((a)/(b)) -#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) -#define luai_numpow(a,b) (pow(a,b)) -#define luai_numunm(a) (-(a)) -#define luai_numeq(a,b) ((a)==(b)) -#define luai_numlt(a,b) ((a)<(b)) -#define luai_numle(a,b) ((a)<=(b)) -#define luai_numisnan(a) (!luai_numeq((a), (a))) -#endif - - -/* -@@ lua_number2int is a macro to convert lua_Number to int. -@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. -** CHANGE them if you know a faster way to convert a lua_Number to -** int (with any rounding method and without throwing errors) in your -** system. In Pentium machines, a naive typecast from double to int -** in C is extremely slow, so any alternative is worth trying. -*/ - -/* On a Pentium, resort to a trick */ -#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ - (defined(__i386) || defined (_M_IX86) || defined(__i386__)) - -/* On a Microsoft compiler, use assembler */ -#if defined(_MSC_VER) - -#define lua_number2int(i,d) __asm fld d __asm fistp i -#define lua_number2integer(i,n) lua_number2int(i, n) - -/* the next trick should work on any Pentium, but sometimes clashes - with a DirectX idiosyncrasy */ -#else - -union luai_Cast { double l_d; long l_l; }; -#define lua_number2int(i,d) \ - { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } -#define lua_number2integer(i,n) lua_number2int(i, n) - -#endif - - -/* this option always works, but may be slow */ -#else -#define lua_number2int(i,d) ((i)=(int)(d)) -#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) - -#endif - -/* }================================================================== */ - - -/* -@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. -** CHANGE it if your system requires alignments larger than double. (For -** instance, if your system supports long doubles and they must be -** aligned in 16-byte boundaries, then you should add long double in the -** union.) Probably you do not need to change this. -*/ -#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } - - -/* -@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. -** CHANGE them if you prefer to use longjmp/setjmp even with C++ -** or if want/don't to use _longjmp/_setjmp instead of regular -** longjmp/setjmp. By default, Lua handles errors with exceptions when -** compiling as C++ code, with _longjmp/_setjmp when asked to use them, -** and with longjmp/setjmp otherwise. -*/ -#if defined(__cplusplus) -/* C++ exceptions */ -#define LUAI_THROW(L,c) throw(c) -#define LUAI_TRY(L,c,a) try { a } catch(...) \ - { if ((c)->status == 0) (c)->status = -1; } -#define luai_jmpbuf int /* dummy variable */ - -#elif defined(LUA_USE_ULONGJMP) -/* in Unix, try _longjmp/_setjmp (more efficient) */ -#define LUAI_THROW(L,c) _longjmp((c)->b, 1) -#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } -#define luai_jmpbuf jmp_buf - -#else -/* default handling with long jumps */ -#define LUAI_THROW(L,c) longjmp((c)->b, 1) -#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } -#define luai_jmpbuf jmp_buf - -#endif - - -/* -@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern -@* can do during pattern-matching. -** CHANGE it if you need more captures. This limit is arbitrary. -*/ -#define LUA_MAXCAPTURES 32 - - -/* -@@ lua_tmpnam is the function that the OS library uses to create a -@* temporary name. -@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. -** CHANGE them if you have an alternative to tmpnam (which is considered -** insecure) or if you want the original tmpnam anyway. By default, Lua -** uses tmpnam except when POSIX is available, where it uses mkstemp. -*/ -#if defined(loslib_c) || defined(luaall_c) - -#if defined(LUA_USE_MKSTEMP) -#include -#define LUA_TMPNAMBUFSIZE 32 -#define lua_tmpnam(b,e) { \ - strcpy(b, "/tmp/lua_XXXXXX"); \ - e = mkstemp(b); \ - if (e != -1) close(e); \ - e = (e == -1); } - -#else -#define LUA_TMPNAMBUFSIZE L_tmpnam -#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } -#endif - -#endif - - -/* -@@ lua_popen spawns a new process connected to the current one through -@* the file streams. -** CHANGE it if you have a way to implement it in your system. -*/ -#if defined(LUA_USE_POPEN) - -#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) -#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) - -#elif defined(LUA_WIN) - -#define lua_popen(L,c,m) ((void)L, _popen(c,m)) -#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) - -#else - -#define lua_popen(L,c,m) ((void)((void)c, m), \ - luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) -#define lua_pclose(L,file) ((void)((void)L, file), 0) - -#endif - -/* -@@ LUA_DL_* define which dynamic-library system Lua should use. -** CHANGE here if Lua has problems choosing the appropriate -** dynamic-library system for your platform (either Windows' DLL, Mac's -** dyld, or Unix's dlopen). If your system is some kind of Unix, there -** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for -** it. To use dlopen you also need to adapt the src/Makefile (probably -** adding -ldl to the linker options), so Lua does not select it -** automatically. (When you change the makefile to add -ldl, you must -** also add -DLUA_USE_DLOPEN.) -** If you do not want any kind of dynamic library, undefine all these -** options. -** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. -*/ -#if defined(LUA_USE_DLOPEN) -#define LUA_DL_DLOPEN -#endif - -#if defined(LUA_WIN) -#define LUA_DL_DLL -#endif - - -/* -@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State -@* (the data goes just *before* the lua_State pointer). -** CHANGE (define) this if you really need that. This value must be -** a multiple of the maximum alignment required for your machine. -*/ -#define LUAI_EXTRASPACE 0 - - -/* -@@ luai_userstate* allow user-specific actions on threads. -** CHANGE them if you defined LUAI_EXTRASPACE and need to do something -** extra when a thread is created/deleted/resumed/yielded. -*/ -#define luai_userstateopen(L) ((void)L) -#define luai_userstateclose(L) ((void)L) -#define luai_userstatethread(L,L1) ((void)L) -#define luai_userstatefree(L) ((void)L) -#define luai_userstateresume(L,n) ((void)L) -#define luai_userstateyield(L,n) ((void)L) - - -/* -@@ LUA_INTFRMLEN is the length modifier for integer conversions -@* in 'string.format'. -@@ LUA_INTFRM_T is the integer type correspoding to the previous length -@* modifier. -** CHANGE them if your system supports long long or does not support long. -*/ - -#if defined(LUA_USELONGLONG) - -#define LUA_INTFRMLEN "ll" -#define LUA_INTFRM_T long long - -#else - -#define LUA_INTFRMLEN "l" -#define LUA_INTFRM_T long - -#endif - - - -/* =================================================================== */ - -/* -** Local configuration. You can use this space to add your redefinitions -** without modifying the main part of the file. -*/ - - - -#endif - diff -Nru gpick-0.2.4/extern/lua/src/lualib.h gpick-0.2.5/extern/lua/src/lualib.h --- gpick-0.2.4/extern/lua/src/lualib.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lualib.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* -** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ -** Lua standard libraries -** See Copyright Notice in lua.h -*/ - - -#ifndef lualib_h -#define lualib_h - -#include "lua.h" - - -/* Key to file-handle type */ -#define LUA_FILEHANDLE "FILE*" - - -#define LUA_COLIBNAME "coroutine" -LUALIB_API int (luaopen_base) (lua_State *L); - -#define LUA_TABLIBNAME "table" -LUALIB_API int (luaopen_table) (lua_State *L); - -#define LUA_IOLIBNAME "io" -LUALIB_API int (luaopen_io) (lua_State *L); - -#define LUA_OSLIBNAME "os" -LUALIB_API int (luaopen_os) (lua_State *L); - -#define LUA_STRLIBNAME "string" -LUALIB_API int (luaopen_string) (lua_State *L); - -#define LUA_MATHLIBNAME "math" -LUALIB_API int (luaopen_math) (lua_State *L); - -#define LUA_DBLIBNAME "debug" -LUALIB_API int (luaopen_debug) (lua_State *L); - -#define LUA_LOADLIBNAME "package" -LUALIB_API int (luaopen_package) (lua_State *L); - - -/* open all previous libraries */ -LUALIB_API void (luaL_openlibs) (lua_State *L); - - - -#ifndef lua_assert -#define lua_assert(x) ((void)0) -#endif - - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lundump.c gpick-0.2.5/extern/lua/src/lundump.c --- gpick-0.2.4/extern/lua/src/lundump.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lundump.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ -/* -** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ -** load precompiled Lua chunks -** See Copyright Notice in lua.h -*/ - -#include - -#define lundump_c -#define LUA_CORE - -#include "lua.h" - -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstring.h" -#include "lundump.h" -#include "lzio.h" - -typedef struct { - lua_State* L; - ZIO* Z; - Mbuffer* b; - const char* name; -} LoadState; - -#ifdef LUAC_TRUST_BINARIES -#define IF(c,s) -#define error(S,s) -#else -#define IF(c,s) if (c) error(S,s) - -static void error(LoadState* S, const char* why) -{ - luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); - luaD_throw(S->L,LUA_ERRSYNTAX); -} -#endif - -#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) -#define LoadByte(S) (lu_byte)LoadChar(S) -#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) -#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) - -static void LoadBlock(LoadState* S, void* b, size_t size) -{ - size_t r=luaZ_read(S->Z,b,size); - IF (r!=0, "unexpected end"); -} - -static int LoadChar(LoadState* S) -{ - char x; - LoadVar(S,x); - return x; -} - -static int LoadInt(LoadState* S) -{ - int x; - LoadVar(S,x); - IF (x<0, "bad integer"); - return x; -} - -static lua_Number LoadNumber(LoadState* S) -{ - lua_Number x; - LoadVar(S,x); - return x; -} - -static TString* LoadString(LoadState* S) -{ - size_t size; - LoadVar(S,size); - if (size==0) - return NULL; - else - { - char* s=luaZ_openspace(S->L,S->b,size); - LoadBlock(S,s,size); - return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ - } -} - -static void LoadCode(LoadState* S, Proto* f) -{ - int n=LoadInt(S); - f->code=luaM_newvector(S->L,n,Instruction); - f->sizecode=n; - LoadVector(S,f->code,n,sizeof(Instruction)); -} - -static Proto* LoadFunction(LoadState* S, TString* p); - -static void LoadConstants(LoadState* S, Proto* f) -{ - int i,n; - n=LoadInt(S); - f->k=luaM_newvector(S->L,n,TValue); - f->sizek=n; - for (i=0; ik[i]); - for (i=0; ik[i]; - int t=LoadChar(S); - switch (t) - { - case LUA_TNIL: - setnilvalue(o); - break; - case LUA_TBOOLEAN: - setbvalue(o,LoadChar(S)!=0); - break; - case LUA_TNUMBER: - setnvalue(o,LoadNumber(S)); - break; - case LUA_TSTRING: - setsvalue2n(S->L,o,LoadString(S)); - break; - default: - error(S,"bad constant"); - break; - } - } - n=LoadInt(S); - f->p=luaM_newvector(S->L,n,Proto*); - f->sizep=n; - for (i=0; ip[i]=NULL; - for (i=0; ip[i]=LoadFunction(S,f->source); -} - -static void LoadDebug(LoadState* S, Proto* f) -{ - int i,n; - n=LoadInt(S); - f->lineinfo=luaM_newvector(S->L,n,int); - f->sizelineinfo=n; - LoadVector(S,f->lineinfo,n,sizeof(int)); - n=LoadInt(S); - f->locvars=luaM_newvector(S->L,n,LocVar); - f->sizelocvars=n; - for (i=0; ilocvars[i].varname=NULL; - for (i=0; ilocvars[i].varname=LoadString(S); - f->locvars[i].startpc=LoadInt(S); - f->locvars[i].endpc=LoadInt(S); - } - n=LoadInt(S); - f->upvalues=luaM_newvector(S->L,n,TString*); - f->sizeupvalues=n; - for (i=0; iupvalues[i]=NULL; - for (i=0; iupvalues[i]=LoadString(S); -} - -static Proto* LoadFunction(LoadState* S, TString* p) -{ - Proto* f; - if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); - f=luaF_newproto(S->L); - setptvalue2s(S->L,S->L->top,f); incr_top(S->L); - f->source=LoadString(S); if (f->source==NULL) f->source=p; - f->linedefined=LoadInt(S); - f->lastlinedefined=LoadInt(S); - f->nups=LoadByte(S); - f->numparams=LoadByte(S); - f->is_vararg=LoadByte(S); - f->maxstacksize=LoadByte(S); - LoadCode(S,f); - LoadConstants(S,f); - LoadDebug(S,f); - IF (!luaG_checkcode(f), "bad code"); - S->L->top--; - S->L->nCcalls--; - return f; -} - -static void LoadHeader(LoadState* S) -{ - char h[LUAC_HEADERSIZE]; - char s[LUAC_HEADERSIZE]; - luaU_header(h); - LoadBlock(S,s,LUAC_HEADERSIZE); - IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); -} - -/* -** load precompiled chunk -*/ -Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) -{ - LoadState S; - if (*name=='@' || *name=='=') - S.name=name+1; - else if (*name==LUA_SIGNATURE[0]) - S.name="binary string"; - else - S.name=name; - S.L=L; - S.Z=Z; - S.b=buff; - LoadHeader(&S); - return LoadFunction(&S,luaS_newliteral(L,"=?")); -} - -/* -* make header -*/ -void luaU_header (char* h) -{ - int x=1; - memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); - h+=sizeof(LUA_SIGNATURE)-1; - *h++=(char)LUAC_VERSION; - *h++=(char)LUAC_FORMAT; - *h++=(char)*(char*)&x; /* endianness */ - *h++=(char)sizeof(int); - *h++=(char)sizeof(size_t); - *h++=(char)sizeof(Instruction); - *h++=(char)sizeof(lua_Number); - *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ -} diff -Nru gpick-0.2.4/extern/lua/src/lundump.h gpick-0.2.5/extern/lua/src/lundump.h --- gpick-0.2.4/extern/lua/src/lundump.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lundump.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ -** load precompiled Lua chunks -** See Copyright Notice in lua.h -*/ - -#ifndef lundump_h -#define lundump_h - -#include "lobject.h" -#include "lzio.h" - -/* load one chunk; from lundump.c */ -LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); - -/* make header; from lundump.c */ -LUAI_FUNC void luaU_header (char* h); - -/* dump one chunk; from ldump.c */ -LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); - -#ifdef luac_c -/* print one chunk; from print.c */ -LUAI_FUNC void luaU_print (const Proto* f, int full); -#endif - -/* for header of binary files -- this is Lua 5.1 */ -#define LUAC_VERSION 0x51 - -/* for header of binary files -- this is the official format */ -#define LUAC_FORMAT 0 - -/* size of header of binary files */ -#define LUAC_HEADERSIZE 12 - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lvm.c gpick-0.2.5/extern/lua/src/lvm.c --- gpick-0.2.4/extern/lua/src/lvm.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lvm.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,763 +0,0 @@ -/* -** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ -** Lua virtual machine -** See Copyright Notice in lua.h -*/ - - -#include -#include -#include - -#define lvm_c -#define LUA_CORE - -#include "lua.h" - -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lvm.h" - - - -/* limit for table tag-method chains (to avoid loops) */ -#define MAXTAGLOOP 100 - - -const TValue *luaV_tonumber (const TValue *obj, TValue *n) { - lua_Number num; - if (ttisnumber(obj)) return obj; - if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { - setnvalue(n, num); - return n; - } - else - return NULL; -} - - -int luaV_tostring (lua_State *L, StkId obj) { - if (!ttisnumber(obj)) - return 0; - else { - char s[LUAI_MAXNUMBER2STR]; - lua_Number n = nvalue(obj); - lua_number2str(s, n); - setsvalue2s(L, obj, luaS_new(L, s)); - return 1; - } -} - - -static void traceexec (lua_State *L, const Instruction *pc) { - lu_byte mask = L->hookmask; - const Instruction *oldpc = L->savedpc; - L->savedpc = pc; - if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { - resethookcount(L); - luaD_callhook(L, LUA_HOOKCOUNT, -1); - } - if (mask & LUA_MASKLINE) { - Proto *p = ci_func(L->ci)->l.p; - int npc = pcRel(pc, p); - int newline = getline(p, npc); - /* call linehook when enter a new function, when jump back (loop), - or when enter a new line */ - if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) - luaD_callhook(L, LUA_HOOKLINE, newline); - } -} - - -static void callTMres (lua_State *L, StkId res, const TValue *f, - const TValue *p1, const TValue *p2) { - ptrdiff_t result = savestack(L, res); - setobj2s(L, L->top, f); /* push function */ - setobj2s(L, L->top+1, p1); /* 1st argument */ - setobj2s(L, L->top+2, p2); /* 2nd argument */ - luaD_checkstack(L, 3); - L->top += 3; - luaD_call(L, L->top - 3, 1); - res = restorestack(L, result); - L->top--; - setobjs2s(L, res, L->top); -} - - - -static void callTM (lua_State *L, const TValue *f, const TValue *p1, - const TValue *p2, const TValue *p3) { - setobj2s(L, L->top, f); /* push function */ - setobj2s(L, L->top+1, p1); /* 1st argument */ - setobj2s(L, L->top+2, p2); /* 2nd argument */ - setobj2s(L, L->top+3, p3); /* 3th argument */ - luaD_checkstack(L, 4); - L->top += 4; - luaD_call(L, L->top - 4, 0); -} - - -void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { - int loop; - for (loop = 0; loop < MAXTAGLOOP; loop++) { - const TValue *tm; - if (ttistable(t)) { /* `t' is a table? */ - Table *h = hvalue(t); - const TValue *res = luaH_get(h, key); /* do a primitive get */ - if (!ttisnil(res) || /* result is no nil? */ - (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ - setobj2s(L, val, res); - return; - } - /* else will try the tag method */ - } - else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) - luaG_typeerror(L, t, "index"); - if (ttisfunction(tm)) { - callTMres(L, val, tm, t, key); - return; - } - t = tm; /* else repeat with `tm' */ - } - luaG_runerror(L, "loop in gettable"); -} - - -void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { - int loop; - for (loop = 0; loop < MAXTAGLOOP; loop++) { - const TValue *tm; - if (ttistable(t)) { /* `t' is a table? */ - Table *h = hvalue(t); - TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ - if (!ttisnil(oldval) || /* result is no nil? */ - (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ - setobj2t(L, oldval, val); - luaC_barriert(L, h, val); - return; - } - /* else will try the tag method */ - } - else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) - luaG_typeerror(L, t, "index"); - if (ttisfunction(tm)) { - callTM(L, tm, t, key, val); - return; - } - t = tm; /* else repeat with `tm' */ - } - luaG_runerror(L, "loop in settable"); -} - - -static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, - StkId res, TMS event) { - const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ - if (ttisnil(tm)) - tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ - if (ttisnil(tm)) return 0; - callTMres(L, res, tm, p1, p2); - return 1; -} - - -static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, - TMS event) { - const TValue *tm1 = fasttm(L, mt1, event); - const TValue *tm2; - if (tm1 == NULL) return NULL; /* no metamethod */ - if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ - tm2 = fasttm(L, mt2, event); - if (tm2 == NULL) return NULL; /* no metamethod */ - if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ - return tm1; - return NULL; -} - - -static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, - TMS event) { - const TValue *tm1 = luaT_gettmbyobj(L, p1, event); - const TValue *tm2; - if (ttisnil(tm1)) return -1; /* no metamethod? */ - tm2 = luaT_gettmbyobj(L, p2, event); - if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ - return -1; - callTMres(L, L->top, tm1, p1, p2); - return !l_isfalse(L->top); -} - - -static int l_strcmp (const TString *ls, const TString *rs) { - const char *l = getstr(ls); - size_t ll = ls->tsv.len; - const char *r = getstr(rs); - size_t lr = rs->tsv.len; - for (;;) { - int temp = strcoll(l, r); - if (temp != 0) return temp; - else { /* strings are equal up to a `\0' */ - size_t len = strlen(l); /* index of first `\0' in both strings */ - if (len == lr) /* r is finished? */ - return (len == ll) ? 0 : 1; - else if (len == ll) /* l is finished? */ - return -1; /* l is smaller than r (because r is not finished) */ - /* both strings longer than `len'; go on comparing (after the `\0') */ - len++; - l += len; ll -= len; r += len; lr -= len; - } - } -} - - -int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { - int res; - if (ttype(l) != ttype(r)) - return luaG_ordererror(L, l, r); - else if (ttisnumber(l)) - return luai_numlt(nvalue(l), nvalue(r)); - else if (ttisstring(l)) - return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; - else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) - return res; - return luaG_ordererror(L, l, r); -} - - -static int lessequal (lua_State *L, const TValue *l, const TValue *r) { - int res; - if (ttype(l) != ttype(r)) - return luaG_ordererror(L, l, r); - else if (ttisnumber(l)) - return luai_numle(nvalue(l), nvalue(r)); - else if (ttisstring(l)) - return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; - else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ - return res; - else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ - return !res; - return luaG_ordererror(L, l, r); -} - - -int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { - const TValue *tm; - lua_assert(ttype(t1) == ttype(t2)); - switch (ttype(t1)) { - case LUA_TNIL: return 1; - case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); - case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ - case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); - case LUA_TUSERDATA: { - if (uvalue(t1) == uvalue(t2)) return 1; - tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, - TM_EQ); - break; /* will try TM */ - } - case LUA_TTABLE: { - if (hvalue(t1) == hvalue(t2)) return 1; - tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); - break; /* will try TM */ - } - default: return gcvalue(t1) == gcvalue(t2); - } - if (tm == NULL) return 0; /* no TM? */ - callTMres(L, L->top, tm, t1, t2); /* call TM */ - return !l_isfalse(L->top); -} - - -void luaV_concat (lua_State *L, int total, int last) { - do { - StkId top = L->base + last + 1; - int n = 2; /* number of elements handled in this pass (at least 2) */ - if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { - if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) - luaG_concaterror(L, top-2, top-1); - } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ - (void)tostring(L, top - 2); /* result is first op (as string) */ - else { - /* at least two string values; get as many as possible */ - size_t tl = tsvalue(top-1)->len; - char *buffer; - int i; - /* collect total length */ - for (n = 1; n < total && tostring(L, top-n-1); n++) { - size_t l = tsvalue(top-n-1)->len; - if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); - tl += l; - } - buffer = luaZ_openspace(L, &G(L)->buff, tl); - tl = 0; - for (i=n; i>0; i--) { /* concat all strings */ - size_t l = tsvalue(top-i)->len; - memcpy(buffer+tl, svalue(top-i), l); - tl += l; - } - setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); - } - total -= n-1; /* got `n' strings to create 1 new */ - last -= n-1; - } while (total > 1); /* repeat until only 1 result left */ -} - - -static void Arith (lua_State *L, StkId ra, const TValue *rb, - const TValue *rc, TMS op) { - TValue tempb, tempc; - const TValue *b, *c; - if ((b = luaV_tonumber(rb, &tempb)) != NULL && - (c = luaV_tonumber(rc, &tempc)) != NULL) { - lua_Number nb = nvalue(b), nc = nvalue(c); - switch (op) { - case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; - case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; - case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; - case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; - case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; - case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; - case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; - default: lua_assert(0); break; - } - } - else if (!call_binTM(L, rb, rc, ra, op)) - luaG_aritherror(L, rb, rc); -} - - - -/* -** some macros for common tasks in `luaV_execute' -*/ - -#define runtime_check(L, c) { if (!(c)) break; } - -#define RA(i) (base+GETARG_A(i)) -/* to be used after possible stack reallocation */ -#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) -#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) -#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ - ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) -#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ - ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) -#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) - - -#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} - - -#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } - - -#define arith_op(op,tm) { \ - TValue *rb = RKB(i); \ - TValue *rc = RKC(i); \ - if (ttisnumber(rb) && ttisnumber(rc)) { \ - lua_Number nb = nvalue(rb), nc = nvalue(rc); \ - setnvalue(ra, op(nb, nc)); \ - } \ - else \ - Protect(Arith(L, ra, rb, rc, tm)); \ - } - - - -void luaV_execute (lua_State *L, int nexeccalls) { - LClosure *cl; - StkId base; - TValue *k; - const Instruction *pc; - reentry: /* entry point */ - lua_assert(isLua(L->ci)); - pc = L->savedpc; - cl = &clvalue(L->ci->func)->l; - base = L->base; - k = cl->p->k; - /* main loop of interpreter */ - for (;;) { - const Instruction i = *pc++; - StkId ra; - if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && - (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { - traceexec(L, pc); - if (L->status == LUA_YIELD) { /* did hook yield? */ - L->savedpc = pc - 1; - return; - } - base = L->base; - } - /* warning!! several calls may realloc the stack and invalidate `ra' */ - ra = RA(i); - lua_assert(base == L->base && L->base == L->ci->base); - lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); - lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); - switch (GET_OPCODE(i)) { - case OP_MOVE: { - setobjs2s(L, ra, RB(i)); - continue; - } - case OP_LOADK: { - setobj2s(L, ra, KBx(i)); - continue; - } - case OP_LOADBOOL: { - setbvalue(ra, GETARG_B(i)); - if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ - continue; - } - case OP_LOADNIL: { - TValue *rb = RB(i); - do { - setnilvalue(rb--); - } while (rb >= ra); - continue; - } - case OP_GETUPVAL: { - int b = GETARG_B(i); - setobj2s(L, ra, cl->upvals[b]->v); - continue; - } - case OP_GETGLOBAL: { - TValue g; - TValue *rb = KBx(i); - sethvalue(L, &g, cl->env); - lua_assert(ttisstring(rb)); - Protect(luaV_gettable(L, &g, rb, ra)); - continue; - } - case OP_GETTABLE: { - Protect(luaV_gettable(L, RB(i), RKC(i), ra)); - continue; - } - case OP_SETGLOBAL: { - TValue g; - sethvalue(L, &g, cl->env); - lua_assert(ttisstring(KBx(i))); - Protect(luaV_settable(L, &g, KBx(i), ra)); - continue; - } - case OP_SETUPVAL: { - UpVal *uv = cl->upvals[GETARG_B(i)]; - setobj(L, uv->v, ra); - luaC_barrier(L, uv, ra); - continue; - } - case OP_SETTABLE: { - Protect(luaV_settable(L, ra, RKB(i), RKC(i))); - continue; - } - case OP_NEWTABLE: { - int b = GETARG_B(i); - int c = GETARG_C(i); - sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); - Protect(luaC_checkGC(L)); - continue; - } - case OP_SELF: { - StkId rb = RB(i); - setobjs2s(L, ra+1, rb); - Protect(luaV_gettable(L, rb, RKC(i), ra)); - continue; - } - case OP_ADD: { - arith_op(luai_numadd, TM_ADD); - continue; - } - case OP_SUB: { - arith_op(luai_numsub, TM_SUB); - continue; - } - case OP_MUL: { - arith_op(luai_nummul, TM_MUL); - continue; - } - case OP_DIV: { - arith_op(luai_numdiv, TM_DIV); - continue; - } - case OP_MOD: { - arith_op(luai_nummod, TM_MOD); - continue; - } - case OP_POW: { - arith_op(luai_numpow, TM_POW); - continue; - } - case OP_UNM: { - TValue *rb = RB(i); - if (ttisnumber(rb)) { - lua_Number nb = nvalue(rb); - setnvalue(ra, luai_numunm(nb)); - } - else { - Protect(Arith(L, ra, rb, rb, TM_UNM)); - } - continue; - } - case OP_NOT: { - int res = l_isfalse(RB(i)); /* next assignment may change this value */ - setbvalue(ra, res); - continue; - } - case OP_LEN: { - const TValue *rb = RB(i); - switch (ttype(rb)) { - case LUA_TTABLE: { - setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); - break; - } - case LUA_TSTRING: { - setnvalue(ra, cast_num(tsvalue(rb)->len)); - break; - } - default: { /* try metamethod */ - Protect( - if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) - luaG_typeerror(L, rb, "get length of"); - ) - } - } - continue; - } - case OP_CONCAT: { - int b = GETARG_B(i); - int c = GETARG_C(i); - Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); - setobjs2s(L, RA(i), base+b); - continue; - } - case OP_JMP: { - dojump(L, pc, GETARG_sBx(i)); - continue; - } - case OP_EQ: { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - Protect( - if (equalobj(L, rb, rc) == GETARG_A(i)) - dojump(L, pc, GETARG_sBx(*pc)); - ) - pc++; - continue; - } - case OP_LT: { - Protect( - if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) - dojump(L, pc, GETARG_sBx(*pc)); - ) - pc++; - continue; - } - case OP_LE: { - Protect( - if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) - dojump(L, pc, GETARG_sBx(*pc)); - ) - pc++; - continue; - } - case OP_TEST: { - if (l_isfalse(ra) != GETARG_C(i)) - dojump(L, pc, GETARG_sBx(*pc)); - pc++; - continue; - } - case OP_TESTSET: { - TValue *rb = RB(i); - if (l_isfalse(rb) != GETARG_C(i)) { - setobjs2s(L, ra, rb); - dojump(L, pc, GETARG_sBx(*pc)); - } - pc++; - continue; - } - case OP_CALL: { - int b = GETARG_B(i); - int nresults = GETARG_C(i) - 1; - if (b != 0) L->top = ra+b; /* else previous instruction set top */ - L->savedpc = pc; - switch (luaD_precall(L, ra, nresults)) { - case PCRLUA: { - nexeccalls++; - goto reentry; /* restart luaV_execute over new Lua function */ - } - case PCRC: { - /* it was a C function (`precall' called it); adjust results */ - if (nresults >= 0) L->top = L->ci->top; - base = L->base; - continue; - } - default: { - return; /* yield */ - } - } - } - case OP_TAILCALL: { - int b = GETARG_B(i); - if (b != 0) L->top = ra+b; /* else previous instruction set top */ - L->savedpc = pc; - lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); - switch (luaD_precall(L, ra, LUA_MULTRET)) { - case PCRLUA: { - /* tail call: put new frame in place of previous one */ - CallInfo *ci = L->ci - 1; /* previous frame */ - int aux; - StkId func = ci->func; - StkId pfunc = (ci+1)->func; /* previous function index */ - if (L->openupval) luaF_close(L, ci->base); - L->base = ci->base = ci->func + ((ci+1)->base - pfunc); - for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ - setobjs2s(L, func+aux, pfunc+aux); - ci->top = L->top = func+aux; /* correct top */ - lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); - ci->savedpc = L->savedpc; - ci->tailcalls++; /* one more call lost */ - L->ci--; /* remove new frame */ - goto reentry; - } - case PCRC: { /* it was a C function (`precall' called it) */ - base = L->base; - continue; - } - default: { - return; /* yield */ - } - } - } - case OP_RETURN: { - int b = GETARG_B(i); - if (b != 0) L->top = ra+b-1; - if (L->openupval) luaF_close(L, base); - L->savedpc = pc; - b = luaD_poscall(L, ra); - if (--nexeccalls == 0) /* was previous function running `here'? */ - return; /* no: return */ - else { /* yes: continue its execution */ - if (b) L->top = L->ci->top; - lua_assert(isLua(L->ci)); - lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); - goto reentry; - } - } - case OP_FORLOOP: { - lua_Number step = nvalue(ra+2); - lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ - lua_Number limit = nvalue(ra+1); - if (luai_numlt(0, step) ? luai_numle(idx, limit) - : luai_numle(limit, idx)) { - dojump(L, pc, GETARG_sBx(i)); /* jump back */ - setnvalue(ra, idx); /* update internal index... */ - setnvalue(ra+3, idx); /* ...and external index */ - } - continue; - } - case OP_FORPREP: { - const TValue *init = ra; - const TValue *plimit = ra+1; - const TValue *pstep = ra+2; - L->savedpc = pc; /* next steps may throw errors */ - if (!tonumber(init, ra)) - luaG_runerror(L, LUA_QL("for") " initial value must be a number"); - else if (!tonumber(plimit, ra+1)) - luaG_runerror(L, LUA_QL("for") " limit must be a number"); - else if (!tonumber(pstep, ra+2)) - luaG_runerror(L, LUA_QL("for") " step must be a number"); - setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); - dojump(L, pc, GETARG_sBx(i)); - continue; - } - case OP_TFORLOOP: { - StkId cb = ra + 3; /* call base */ - setobjs2s(L, cb+2, ra+2); - setobjs2s(L, cb+1, ra+1); - setobjs2s(L, cb, ra); - L->top = cb+3; /* func. + 2 args (state and index) */ - Protect(luaD_call(L, cb, GETARG_C(i))); - L->top = L->ci->top; - cb = RA(i) + 3; /* previous call may change the stack */ - if (!ttisnil(cb)) { /* continue loop? */ - setobjs2s(L, cb-1, cb); /* save control variable */ - dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ - } - pc++; - continue; - } - case OP_SETLIST: { - int n = GETARG_B(i); - int c = GETARG_C(i); - int last; - Table *h; - if (n == 0) { - n = cast_int(L->top - ra) - 1; - L->top = L->ci->top; - } - if (c == 0) c = cast_int(*pc++); - runtime_check(L, ttistable(ra)); - h = hvalue(ra); - last = ((c-1)*LFIELDS_PER_FLUSH) + n; - if (last > h->sizearray) /* needs more space? */ - luaH_resizearray(L, h, last); /* pre-alloc it at once */ - for (; n > 0; n--) { - TValue *val = ra+n; - setobj2t(L, luaH_setnum(L, h, last--), val); - luaC_barriert(L, h, val); - } - continue; - } - case OP_CLOSE: { - luaF_close(L, ra); - continue; - } - case OP_CLOSURE: { - Proto *p; - Closure *ncl; - int nup, j; - p = cl->p->p[GETARG_Bx(i)]; - nup = p->nups; - ncl = luaF_newLclosure(L, nup, cl->env); - ncl->l.p = p; - for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; - else { - lua_assert(GET_OPCODE(*pc) == OP_MOVE); - ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); - } - } - setclvalue(L, ra, ncl); - Protect(luaC_checkGC(L)); - continue; - } - case OP_VARARG: { - int b = GETARG_B(i) - 1; - int j; - CallInfo *ci = L->ci; - int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; - if (b == LUA_MULTRET) { - Protect(luaD_checkstack(L, n)); - ra = RA(i); /* previous call may change the stack */ - b = n; - L->top = ra + n; - } - for (j = 0; j < b; j++) { - if (j < n) { - setobjs2s(L, ra + j, ci->base - n + j); - } - else { - setnilvalue(ra + j); - } - } - continue; - } - } - } -} - diff -Nru gpick-0.2.4/extern/lua/src/lvm.h gpick-0.2.5/extern/lua/src/lvm.h --- gpick-0.2.4/extern/lua/src/lvm.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lvm.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ -** Lua virtual machine -** See Copyright Notice in lua.h -*/ - -#ifndef lvm_h -#define lvm_h - - -#include "ldo.h" -#include "lobject.h" -#include "ltm.h" - - -#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) - -#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ - (((o) = luaV_tonumber(o,n)) != NULL)) - -#define equalobj(L,o1,o2) \ - (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) - - -LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); -LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); -LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); -LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); -LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, - StkId val); -LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, - StkId val); -LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); -LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); - -#endif diff -Nru gpick-0.2.4/extern/lua/src/lzio.c gpick-0.2.5/extern/lua/src/lzio.c --- gpick-0.2.4/extern/lua/src/lzio.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lzio.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/* -** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ -** a generic input stream interface -** See Copyright Notice in lua.h -*/ - - -#include - -#define lzio_c -#define LUA_CORE - -#include "lua.h" - -#include "llimits.h" -#include "lmem.h" -#include "lstate.h" -#include "lzio.h" - - -int luaZ_fill (ZIO *z) { - size_t size; - lua_State *L = z->L; - const char *buff; - lua_unlock(L); - buff = z->reader(L, z->data, &size); - lua_lock(L); - if (buff == NULL || size == 0) return EOZ; - z->n = size - 1; - z->p = buff; - return char2int(*(z->p++)); -} - - -int luaZ_lookahead (ZIO *z) { - if (z->n == 0) { - if (luaZ_fill(z) == EOZ) - return EOZ; - else { - z->n++; /* luaZ_fill removed first byte; put back it */ - z->p--; - } - } - return char2int(*z->p); -} - - -void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { - z->L = L; - z->reader = reader; - z->data = data; - z->n = 0; - z->p = NULL; -} - - -/* --------------------------------------------------------------- read --- */ -size_t luaZ_read (ZIO *z, void *b, size_t n) { - while (n) { - size_t m; - if (luaZ_lookahead(z) == EOZ) - return n; /* return number of missing bytes */ - m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ - memcpy(b, z->p, m); - z->n -= m; - z->p += m; - b = (char *)b + m; - n -= m; - } - return 0; -} - -/* ------------------------------------------------------------------------ */ -char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { - if (n > buff->buffsize) { - if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; - luaZ_resizebuffer(L, buff, n); - } - return buff->buffer; -} - - diff -Nru gpick-0.2.4/extern/lua/src/lzio.h gpick-0.2.5/extern/lua/src/lzio.h --- gpick-0.2.4/extern/lua/src/lzio.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/lzio.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -/* -** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ -** Buffered streams -** See Copyright Notice in lua.h -*/ - - -#ifndef lzio_h -#define lzio_h - -#include "lua.h" - -#include "lmem.h" - - -#define EOZ (-1) /* end of stream */ - -typedef struct Zio ZIO; - -#define char2int(c) cast(int, cast(unsigned char, (c))) - -#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) - -typedef struct Mbuffer { - char *buffer; - size_t n; - size_t buffsize; -} Mbuffer; - -#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) - -#define luaZ_buffer(buff) ((buff)->buffer) -#define luaZ_sizebuffer(buff) ((buff)->buffsize) -#define luaZ_bufflen(buff) ((buff)->n) - -#define luaZ_resetbuffer(buff) ((buff)->n = 0) - - -#define luaZ_resizebuffer(L, buff, size) \ - (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ - (buff)->buffsize = size) - -#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) - - -LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); -LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, - void *data); -LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ -LUAI_FUNC int luaZ_lookahead (ZIO *z); - - - -/* --------- Private Part ------------------ */ - -struct Zio { - size_t n; /* bytes still unread */ - const char *p; /* current position in buffer */ - lua_Reader reader; - void* data; /* additional data */ - lua_State *L; /* Lua state (for reader) */ -}; - - -LUAI_FUNC int luaZ_fill (ZIO *z); - -#endif diff -Nru gpick-0.2.4/extern/lua/src/print.c gpick-0.2.5/extern/lua/src/print.c --- gpick-0.2.4/extern/lua/src/print.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/extern/lua/src/print.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ -/* -** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ -** print bytecodes -** See Copyright Notice in lua.h -*/ - -#include -#include - -#define luac_c -#define LUA_CORE - -#include "ldebug.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lundump.h" - -#define PrintFunction luaU_print - -#define Sizeof(x) ((int)sizeof(x)) -#define VOID(p) ((const void*)(p)) - -static void PrintString(const TString* ts) -{ - const char* s=getstr(ts); - size_t i,n=ts->tsv.len; - putchar('"'); - for (i=0; ik[i]; - switch (ttype(o)) - { - case LUA_TNIL: - printf("nil"); - break; - case LUA_TBOOLEAN: - printf(bvalue(o) ? "true" : "false"); - break; - case LUA_TNUMBER: - printf(LUA_NUMBER_FMT,nvalue(o)); - break; - case LUA_TSTRING: - PrintString(rawtsvalue(o)); - break; - default: /* cannot happen */ - printf("? type=%d",ttype(o)); - break; - } -} - -static void PrintCode(const Proto* f) -{ - const Instruction* code=f->code; - int pc,n=f->sizecode; - for (pc=0; pc0) printf("[%d]\t",line); else printf("[-]\t"); - printf("%-9s\t",luaP_opnames[o]); - switch (getOpMode(o)) - { - case iABC: - printf("%d",a); - if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b); - if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c); - break; - case iABx: - if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx); - break; - case iAsBx: - if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx); - break; - } - switch (o) - { - case OP_LOADK: - printf("\t; "); PrintConstant(f,bx); - break; - case OP_GETUPVAL: - case OP_SETUPVAL: - printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-"); - break; - case OP_GETGLOBAL: - case OP_SETGLOBAL: - printf("\t; %s",svalue(&f->k[bx])); - break; - case OP_GETTABLE: - case OP_SELF: - if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } - break; - case OP_SETTABLE: - case OP_ADD: - case OP_SUB: - case OP_MUL: - case OP_DIV: - case OP_POW: - case OP_EQ: - case OP_LT: - case OP_LE: - if (ISK(b) || ISK(c)) - { - printf("\t; "); - if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-"); - printf(" "); - if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-"); - } - break; - case OP_JMP: - case OP_FORLOOP: - case OP_FORPREP: - printf("\t; to %d",sbx+pc+2); - break; - case OP_CLOSURE: - printf("\t; %p",VOID(f->p[bx])); - break; - case OP_SETLIST: - if (c==0) printf("\t; %d",(int)code[++pc]); - else printf("\t; %d",c); - break; - default: - break; - } - printf("\n"); - } -} - -#define SS(x) (x==1)?"":"s" -#define S(x) x,SS(x) - -static void PrintHeader(const Proto* f) -{ - const char* s=getstr(f->source); - if (*s=='@' || *s=='=') - s++; - else if (*s==LUA_SIGNATURE[0]) - s="(bstring)"; - else - s="(string)"; - printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n", - (f->linedefined==0)?"main":"function",s, - f->linedefined,f->lastlinedefined, - S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f)); - printf("%d%s param%s, %d slot%s, %d upvalue%s, ", - f->numparams,f->is_vararg?"+":"",SS(f->numparams), - S(f->maxstacksize),S(f->nups)); - printf("%d local%s, %d constant%s, %d function%s\n", - S(f->sizelocvars),S(f->sizek),S(f->sizep)); -} - -static void PrintConstants(const Proto* f) -{ - int i,n=f->sizek; - printf("constants (%d) for %p:\n",n,VOID(f)); - for (i=0; isizelocvars; - printf("locals (%d) for %p:\n",n,VOID(f)); - for (i=0; ilocvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); - } -} - -static void PrintUpvalues(const Proto* f) -{ - int i,n=f->sizeupvalues; - printf("upvalues (%d) for %p:\n",n,VOID(f)); - if (f->upvalues==NULL) return; - for (i=0; iupvalues[i])); - } -} - -void PrintFunction(const Proto* f, int full) -{ - int i,n=f->sizep; - PrintHeader(f); - PrintCode(f); - if (full) - { - PrintConstants(f); - PrintLocals(f); - PrintUpvalues(f); - } - for (i=0; ip[i],full); -} diff -Nru gpick-0.2.4/installer/License.txt gpick-0.2.5/installer/License.txt --- gpick-0.2.4/installer/License.txt 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/installer/License.txt 2013-02-28 17:43:59.000000000 +0000 @@ -1,4 +1,4 @@ -Copyright (c) 2009, Albertas Vysniauskas +Copyright (c) 2009-2013, Albertas Vyniauskas and Gpick developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/installer/Makefile gpick-0.2.5/installer/Makefile --- gpick-0.2.4/installer/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/installer/Makefile 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,42 @@ + +VERSION_FULL=$(shell python -c 'import getversion; getversion.getversion("full")') +VERSION=$(shell python -c 'import getversion; getversion.getversion("ms")') +MSI=gpick_$(VERSION_FULL) + +HEAT_SRCS=gpick_files.xstl gtk_files.xstl +SRCS=gpick.wxs $(HEAT_SRCS:.xstl=.wxs) +OBJS=$(SRCS:.wxs=.wixobj) +CANDLE=candle.exe +LIGHT=light.exe +HEAT=heat.exe + +HEAT_FLAGS=-ag -dr INSTALLDIR -suid -srd -var var.FilePath +FLAGS=-dFilePath=files -dVersionFull=$(VERSION_FULL) -dVersion=$(VERSION) +LIGHT_FLAGS=-ext WixUtilExtension -ext WixUIExtension $(FLAGS) +CANDLE_FLAGS=$(FLAGS) + +DEPFILES= files/Gpick.exe + +.SUFFIXES: .wxs .wixobj .xstl + +all: $(MSI).msi + +$(MSI).msi: $(OBJS) $(DEPFILES) $(HEAT_SRCS) + $(LIGHT) -nologo $(LIGHT_FLAGS) -out $@ $(OBJS) + +.xstl.wxs: + $(HEAT) dir "files" -nologo $(HEAT_FLAGS) -cg C.Files.$(<:.xstl=) -t $< -out $@ + +.wxs.wixobj: + $(CANDLE) -nologo $(CANDLE_FLAGS) -out $@ $^ + +clean: + $(RM) $(MSI).msi $(OBJS) + +install: $(MSI).msi + $(RM) install.log + msiexec -i $(MSI).msi -l*v install.log + +uninstall: + msiexec -x $(MSI).msi + diff -Nru gpick-0.2.4/installer/getversion.py gpick-0.2.5/installer/getversion.py --- gpick-0.2.4/installer/getversion.py 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/installer/getversion.py 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,14 @@ +import os,sys,re +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import version + +def getversion(style): + if style == "full": + print version.GPICK_BUILD_VERSION + else: + result = re.match(r"^(\d+\.\d+\.\d+)(.*)$", version.GPICK_BUILD_VERSION) + if result: + print result.group(1) + else: + print "invalid_version" diff -Nru gpick-0.2.4/installer/gpick.wxs gpick-0.2.5/installer/gpick.wxs --- gpick-0.2.4/installer/gpick.wxs 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/installer/gpick.wxs 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + Privileged + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + NOT Installed + Installed AND PATCH + + Installed + NOT Installed + 1 + + NOT Installed OR WixUI_InstallMode = "Change" + Installed AND NOT PATCH + Installed AND PATCH + + 1 + + 1 + 1 + 1 + 1 + + + + + + + + + + + + + + + + + + diff -Nru gpick-0.2.4/installer/gpick_files.xstl gpick-0.2.5/installer/gpick_files.xstl --- gpick-0.2.4/installer/gpick_files.xstl 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/installer/gpick_files.xstl 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,11 @@ + + + + + + + + + + + diff -Nru gpick-0.2.4/installer/gtk_files.xstl gpick-0.2.5/installer/gtk_files.xstl --- gpick-0.2.4/installer/gtk_files.xstl 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/installer/gtk_files.xstl 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,11 @@ + + + + + + + + + + + diff -Nru gpick-0.2.4/installer/script.nsi gpick-0.2.5/installer/script.nsi --- gpick-0.2.4/installer/script.nsi 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/installer/script.nsi 2013-02-28 17:43:59.000000000 +0000 @@ -1,18 +1,38 @@ !include "MUI2.nsh" +!include "FileFunc.nsh" ; GetOptions !include ..\build\version.nsi -Name "gpick" -OutFile "gpick_${VERSION}_win32-setup.exe" -Caption "gpick v${VERSION} Setup" + +!define PRODUCT_VERSION "${VERSION}" +!define PRODUCT_NAME "Gpick" +!define PRODUCT_NAME_SMALL "gpick" +!define PRODUCT_PUBLISHER "Albertas Vyniauskas" +!define PRODUCT_WEB_SITE "http://code.google.com/p/gpick/" + +!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" +!define PRODUCT_UNINST_ROOT_KEY "HKLM" + +!define REGISTRY_APP_PATHS "Software\Microsoft\Windows\CurrentVersion\App Paths" + + +Name "Gpick" +OutFile "Gpick_${VERSION}_win32-setup.exe" +Caption "Gpick v${VERSION} Setup" SetCompressor /SOLID lzma SetCompressorDictSize 32 -InstallDir $PROGRAMFILES\gpick -InstallDirRegKey HKLM "Software\gpick" "" +InstallDir $PROGRAMFILES\Gpick +InstallDirRegKey HKLM "Software\Gpick" "" RequestExecutionLevel admin +; gtk installer name for embedding +!define GTK_INSTALLER_EXE "gtk2-runtime-2.24.10-2012-10-10-ash.exe" + Var MUI_TEMP Var STARTMENU_FOLDER +var install_option_removeold ; uninstall the old version first (if present): yes (default), no. +var gtk_mode ; "public", "private" or "none" +var gtk_tmp ; temporary variable !define MUI_WELCOMEPAGE !define MUI_LICENSEPAGE @@ -24,27 +44,33 @@ !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "License.txt" +!define MUI_PAGE_CUSTOMFUNCTION_LEAVE on_components_page_leave +!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER !insertmacro MUI_PAGE_INSTFILES +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_FINISHPAGE_NOREBOOTSUPPORT +!insertmacro MUI_PAGE_FINISH + !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_LANGUAGE "English" - - - AllowSkipFiles off +var gtk_dll_abs_path + Section "!Program Files" SecProgramFiles SectionIn RO SetOutPath "$INSTDIR" File ..\build\source\gpick.exe - + File lua5.2.dll + SetOutPath "$INSTDIR\share\gpick" File ..\share\gpick\colors0.txt @@ -60,13 +86,149 @@ File ..\share\gpick\layouts.lua SetOutPath "$INSTDIR" - WriteRegStr HKLM "Software\gpick" "" $INSTDIR + WriteRegStr HKLM "Software\Gpick" "" $INSTDIR + + SetShellVarContext all ; use all user variables as opposed to current user + + ; Don't set any paths for this exe if it has a private GTK+ installation. +!ifndef NO_GTK + StrCmp $gtk_mode "private" skip_exe_PATH +!endif + ; set a special path for this exe, as GTK may not be in a global path. + ReadRegStr $gtk_dll_abs_path HKLM "SOFTWARE\GTK\2.0" "DllPath" + WriteRegStr HKLM "${REGISTRY_APP_PATHS}\gpick.exe" "Path" "$gtk_dll_abs_path" +!ifndef NO_GTK + skip_exe_PATH: +!endif + +!ifndef NO_GTK + WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "GtkInstalledMode" "$gtk_mode" +!endif + + WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "InstallationDirectory" "$INSTDIR" + WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "Vendor" "${PRODUCT_PUBLISHER}" + + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}" + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe" + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR" + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\gpick.ico" + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" + WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoModify" 1 + WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoRepair" 1 + WriteUninstaller "$INSTDIR\Uninstall.exe" SectionEnd +Section "GTK+ (for this program only)" SecGtkPrivate + SectionIn 1 + SetShellVarContext all ; use all user variables as opposed to current user + AddSize 12200 ; ~ size of unpacked gtk + SetOutPath "$INSTDIR" + File "${GTK_INSTALLER_EXE}" + ; TODO: in the future, when we have translations for this program, + ; make the GTK+ translations installation dependent on their installation status. + ExecWait '"${GTK_INSTALLER_EXE}" /sideeffects=no /dllpath=root /translations=no /compatdlls=no /S /D=$INSTDIR' + Delete "$INSTDIR\${GTK_INSTALLER_EXE}" +SectionEnd + +; disabled by default +Section /o "GTK+ (shared installation)" SecGtkPublic + SectionIn 1 + SetShellVarContext all ; use all user variables as opposed to current user + AddSize 12200 ; ~ size of unpacked gtk + SetOutPath "$INSTDIR" + File "${GTK_INSTALLER_EXE}" + ExecWait '"${GTK_INSTALLER_EXE}"' + Delete "$INSTDIR\${GTK_INSTALLER_EXE}" +SectionEnd + + + +; Executed on installation start +Function .onInit + SetShellVarContext all ; use all user variables as opposed to current user + + ${GetOptions} "$CMDLINE" "/removeold=" $install_option_removeold + + Call PreventMultipleInstances + Call DetectPrevInstallation + StrCpy $gtk_mode "private" ; default +FunctionEnd + +function .onselchange + +!ifndef NO_GTK + ; Remember which gtk section was selected. + ; Deselect the other section. + + ; If it was private, we check if public is checked and uncheck private. + + StrCmp $gtk_mode "private" check_public ; old selection + StrCmp $gtk_mode "public" check_private ; old selection + goto check_exit + + check_public: + SectionGetFlags ${SecGtkPublic} $gtk_tmp ; see if it's checked + IntOp $gtk_tmp $gtk_tmp & ${SF_SELECTED} + IntCmp $gtk_tmp ${SF_SELECTED} "" check_exit check_exit + SectionGetFlags ${SecGtkPrivate} $gtk_tmp ; unselect the other one + IntOp $gtk_tmp $gtk_tmp & ${SECTION_OFF} + SectionSetFlags ${SecGtkPrivate} $gtk_tmp + goto check_exit + + check_private: + SectionGetFlags ${SecGtkPrivate} $gtk_tmp ; see if it's checked + IntOp $gtk_tmp $gtk_tmp & ${SF_SELECTED} + IntCmp $gtk_tmp ${SF_SELECTED} "" check_exit check_exit + SectionGetFlags ${SecGtkPublic} $gtk_tmp ; unselect the other one + IntOp $gtk_tmp $gtk_tmp & ${SECTION_OFF} + SectionSetFlags ${SecGtkPublic} $gtk_tmp + + check_exit: + + + ; store the current mode + StrCpy $gtk_mode "none" + + SectionGetFlags ${SecGtkPrivate} $gtk_tmp + IntOp $gtk_tmp $gtk_tmp & ${SF_SELECTED} + IntCmp $gtk_tmp ${SF_SELECTED} "" mode_end_private mode_end_private + StrCpy $gtk_mode "private" + mode_end_private: + + SectionGetFlags ${SecGtkPublic} $gtk_tmp + IntOp $gtk_tmp $gtk_tmp & ${SF_SELECTED} + IntCmp $gtk_tmp ${SF_SELECTED} "" mode_end_public mode_end_public + StrCpy $gtk_mode "public" + mode_end_public: + + ; MessageBox MB_ICONINFORMATION|MB_OK "gtk_mode: $gtk_mode" /SD IDOK +!endif ; !NO_GTK + +functionend + + +Function on_components_page_leave + StrCmp $gtk_mode "none" "" noabort + Call AskForGtk + noabort: +FunctionEnd + + +; Section descriptions +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${SecProgramFiles} "Gpick - Advanced color picker" + !insertmacro MUI_DESCRIPTION_TEXT ${SecGtkPrivate} "GTK+ libraries, needed by Gpick. \ + This will install a private version of GTK+, usable only by Gpick." + !insertmacro MUI_DESCRIPTION_TEXT ${SecGtkPublic} "GTK+ libraries, needed by Gpick. \ + This will install a system-wide version of GTK+, shareable with other programs." +!insertmacro MUI_FUNCTION_DESCRIPTION_END + Section "Desktop Shortcut" SecDesktopShortcut SetOutPath "$INSTDIR" - CreateShortCut "$DESKTOP\gpick.lnk" "$INSTDIR\gpick.exe" "" + CreateShortCut "$DESKTOP\Gpick.lnk" "$INSTDIR\Gpick.exe" "" SectionEnd Section "-Start Menu Shortcut" SecStartMenu @@ -76,46 +238,62 @@ !insertmacro MUI_STARTMENU_WRITE_BEGIN Application CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\gpick.lnk" "$INSTDIR\gpick.exe" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Gpick.lnk" "$INSTDIR\Gpick.exe" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_END SectionEnd +; ------------------ POST INSTALL ;Uninstaller Section Section "Uninstall" + SetShellVarContext all ; use all user variables as opposed to current user + SetAutoClose false + ReadRegStr $gtk_mode HKLM "SOFTWARE\${PRODUCT_NAME}" "GtkInstalledMode" + StrCmp $gtk_mode "private" "" skip_gtk_remove + ; remove private GTK+, specify the same custom options are during installation + ExecWait "$INSTDIR\gtk2_runtime_uninst.exe /remove_config=yes /sideeffects=no /dllpath=root /translations=no /compatdlls=no /S" + ; _?=$INSTDIR + ; Delete "$INSTDIR\gtk2_runtime_uninst.exe" ; If using _? flag, it won't get deleted automatically, do it manually. +skip_gtk_remove: + + DeleteRegKey HKLM "SOFTWARE\${PRODUCT_NAME}" + DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}" + StrCmp $gtk_mode "private" skip_exe_PATH_remove + DeleteRegKey HKLM "${REGISTRY_APP_PATHS}\gpick.exe" +skip_exe_PATH_remove: + + Delete "$INSTDIR\Uninstall.exe" -Delete "$INSTDIR\Uninstall.exe" - -Delete "$INSTDIR\gpick.exe" - -Delete "$INSTDIR\share\gpick\colors0.txt" -Delete "$INSTDIR\share\gpick\colors.txt" -Delete "$INSTDIR\share\gpick\gpick-falloff-none.png" -Delete "$INSTDIR\share\gpick\gpick-falloff-linear.png" -Delete "$INSTDIR\share\gpick\gpick-falloff-quadratic.png" -Delete "$INSTDIR\share\gpick\gpick-falloff-cubic.png" -Delete "$INSTDIR\share\gpick\gpick-falloff-exponential.png" -Delete "$INSTDIR\share\gpick\gpick.png" -Delete "$INSTDIR\share\gpick\init.lua" -Delete "$INSTDIR\share\gpick\helpers.lua" -Delete "$INSTDIR\share\gpick\layouts.lua" -RMDir "$INSTDIR\share\gpick" -RMDir "$INSTDIR\share" + Delete "$INSTDIR\gpick.exe" + Delete "$INSTDIR\lua5.2.dll" + Delete "$INSTDIR\share\gpick\colors0.txt" + Delete "$INSTDIR\share\gpick\colors.txt" + Delete "$INSTDIR\share\gpick\gpick-falloff-none.png" + Delete "$INSTDIR\share\gpick\gpick-falloff-linear.png" + Delete "$INSTDIR\share\gpick\gpick-falloff-quadratic.png" + Delete "$INSTDIR\share\gpick\gpick-falloff-cubic.png" + Delete "$INSTDIR\share\gpick\gpick-falloff-exponential.png" + Delete "$INSTDIR\share\gpick\gpick.png" + Delete "$INSTDIR\share\gpick\init.lua" + Delete "$INSTDIR\share\gpick\helpers.lua" + Delete "$INSTDIR\share\gpick\layouts.lua" + RMDir "$INSTDIR\share\gpick" + RMDir "$INSTDIR\share\locale" + RMDir "$INSTDIR\share" -RMDir "$INSTDIR" + RMDir "$INSTDIR" - !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP - Delete "$SMPROGRAMS\$MUI_TEMP\gpick.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\Gpick.lnk" Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" - Delete "$DESKTOP\gpick.lnk" + Delete "$DESKTOP\Gpick.lnk" ;Delete empty start menu parent diretories StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" @@ -130,6 +308,92 @@ StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop startMenuDeleteLoopDone: - DeleteRegKey /ifempty HKLM "Software\gpick" + DeleteRegKey /ifempty HKLM "Software\Gpick" + +SectionEnd -SectionEnd \ No newline at end of file +; Detect previous installation +Function DetectPrevInstallation + ; if /removeold=no option is given, don't check anything. + StrCmp $install_option_removeold "no" old_detect_done + + SetShellVarContext all ; use all user variables as opposed to current user + push $R0 + + ; detect previous installation + ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" + StrCmp $R0 "" old_detect_done + + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ + "${PRODUCT_NAME} is already installed. $\n$\nClick `OK` to remove the \ + previous version or `Cancel` to continue anyway." \ + /SD IDOK IDOK old_uninst + ; Abort + goto old_detect_done + + ; Run the old uninstaller + old_uninst: + ClearErrors + IfSilent old_silent_uninst old_nosilent_uninst + + old_nosilent_uninst: + ExecWait '$R0' + goto old_uninst_continue + + old_silent_uninst: + ExecWait '$R0 /S _?=$INSTDIR' + + old_uninst_continue: + + IfErrors old_no_remove_uninstaller + + ; You can either use Delete /REBOOTOK in the uninstaller or add some code + ; here to remove to remove the uninstaller. Use a registry key to check + ; whether the user has chosen to uninstall. If you are using an uninstaller + ; components page, make sure all sections are uninstalled. + old_no_remove_uninstaller: + + old_detect_done: ; old installation not found, all ok + + pop $R0 +FunctionEnd + +; detect GTK installation (any of available versions) +Function AskForGtk + SetShellVarContext all ; use all user variables as opposed to current user + push $R0 + + ReadRegStr $R0 HKLM "SOFTWARE\GTK\2.0" "DllPath" + StrCmp $R0 "" no_gtk have_gtk + + no_gtk: + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ + "GTK2-Runtime is not installed. This product needs it to function properly.$\n\ + Please install GTK2-Runtime from http://gtk-win.sf.net/ first.$\n$\n\ + Click 'Cancel' to abort the installation \ + or 'OK' to continue anyway." \ + /SD IDOK IDOK have_gtk + ;Abort ; Abort has different meaning from onpage callbacks, so use Quit + Quit + goto end_gtk_check + + have_gtk: + ; do nothing + + end_gtk_check: + + pop $R0 +FunctionEnd + + + +; Prevent running multiple instances of the installer +Function PreventMultipleInstances + Push $R0 + System::Call 'kernel32::CreateMutexA(i 0, i 0, t ${PRODUCT_NAME}) ?e' + Pop $R0 + StrCmp $R0 0 +3 + MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK + Abort + Pop $R0 +FunctionEnd diff -Nru gpick-0.2.4/res/gray-pattern.svg gpick-0.2.5/res/gray-pattern.svg --- gpick-0.2.4/res/gray-pattern.svg 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/res/gray-pattern.svg 2013-01-01 16:10:51.000000000 +0000 @@ -0,0 +1,133 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + Binary files /tmp/yR5ToU1Wwf/gpick-0.2.4/share/gpick/gpick-gray-pattern.png and /tmp/nhh_qGkd8F/gpick-0.2.5/share/gpick/gpick-gray-pattern.png differ diff -Nru gpick-0.2.4/share/gpick/init.lua gpick-0.2.5/share/gpick/init.lua --- gpick-0.2.4/share/gpick/init.lua 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/share/gpick/init.lua 2013-02-28 17:43:59.000000000 +0000 @@ -170,27 +170,27 @@ gpick.converters['color_web_hex'] = { - human_readable = 'Web: hex code', + human_readable = _("Web: hex code"), serialize = gpick.serialize_web_hex, deserialize = gpick.deserialize_web_hex } gpick.converters['color_web_hex_3_digit'] = { - human_readable = 'Web: hex code (3 digits)', + human_readable = _("Web: hex code (3 digits)"), serialize = gpick.serialize_web_hex_3_digit, deserialize = gpick.deserialize_web_hex_3_digit } gpick.converters['color_web_hex_no_hash'] = { - human_readable = 'Web: hex code (no hash)', + human_readable = _("Web: hex code (no hash symbol)"), serialize = gpick.serialize_web_hex_no_hash, deserialize = gpick.deserialize_web_hex_no_hash } gpick.converters['color_css_hsl'] = { - human_readable = 'CSS: hue saturation lightness', + human_readable = _("CSS: hue saturation lightness"), serialize = gpick.serialize_css_hsl, deserialize = nil } gpick.converters['color_css_rgb'] = { - human_readable = 'CSS: red green blue', + human_readable = _("CSS: red green blue"), serialize = gpick.serialize_css_rgb, deserialize = gpick.deserialize_css_rgb } @@ -236,12 +236,6 @@ deserialize = nil }; -gpick.converters['color_csv'] = { - human_readable = 'CSV', - serialize = gpick.serialize_color_csv, - deserialize = nil -}; - gpick.color_serialize = function(converter, color_object) return gpick.converters[converter].serialize(color_object) end @@ -250,3 +244,25 @@ return gpick.converters[converter].deserialize(text, color_object) end +gpick.component_to_text = function(component_type, color) + if component_type == 'rgb' then + return {round(color:red()*255) .. '', round(color:green()*255) .. '', round(color:blue()*255) .. ''} + end + if component_type == 'hsl' then + return {round(color:hue()*360) .. '', round(color:saturation()*100) .. '', round(color:lightness()*100) .. ''} + end + if component_type == 'hsv' then + return {round(color:hue()*360) .. '', round(color:saturation()*100) .. '', round(color:value()*100) .. ''} + end + if component_type == 'cmyk' then + return {round(color:cyan()*255) .. '', round(color:magenta()*255) .. '', round(color:yellow()*255) .. '', round(color:key_black()*255) .. ''} + end + if component_type == 'lab' then + return {round(color:lab_lightness()) .. '', round(color:lab_a()) .. '', round(color:lab_b()) .. ''} + end + if component_type == 'lch' then + return {round(color:lch_lightness()) .. '', round(color:lch_chroma()) .. '', round(color:lch_hue()) .. ''} + end + return {} +end + diff -Nru gpick-0.2.4/share/gpick/layouts.lua gpick-0.2.5/share/gpick/layouts.lua --- gpick-0.2.4/share/gpick/layouts.lua 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/share/gpick/layouts.lua 2013-02-28 17:43:59.000000000 +0000 @@ -12,7 +12,7 @@ local styles_n = # button_style; local styles_text_n = # text_style; - local texts = {'Homepage', 'About us', 'Links to us', 'Privacy', 'Terms', 'Contact us', 'RSS'}; + local texts = {_("Homepage"), _("About us"), _("Links to us"), _("Privacy"), _("Terms"), _("Contact us"), _("RSS")}; for i=0,buttons-1 do local button = layout:new_fill("button", padding, i*size+padding, 1-padding*2, size-padding, button_style[i % styles_n + 1] ); @@ -27,7 +27,7 @@ local text = color:new(); for i=0,lines-1 do - container:add(layout:new_text("content_text", 0.02, i*0.06+0.01, 0.96, 0.06, style, 'The quick brown fox jumps over the lazy dog')); + container:add(layout:new_text("content_text", 0.02, i*0.06+0.01, 0.96, 0.06, style, _("The quick brown fox jumps over the lazy dog"))); end; return container; end; @@ -43,25 +43,25 @@ end; gpick.layouts['std_layout_webpage_1'] = { - human_readable = 'Webpage', + human_readable = _("Webpage"), mask = 0, build = function (layout_system) local styles = { - header = layout_style:new("header_b:Header", color:new(0.2, 0.2, 0.2)), - header_text = layout_style:new("header_t:Header text", color:new(1.0, 1.0, 1.0), 1.0), + header = layout_style:new("header_b:" .. _("Header"), color:new(0.2, 0.2, 0.2)), + header_text = layout_style:new("header_t:" .. _("Header text"), color:new(1.0, 1.0, 1.0), 1.0), - content = layout_style:new("content_b:Content", color:new(0.6, 0.6, 0.6)), - content_text = layout_style:new("content_t:Content text", color:new(0.1, 0.1, 0.1), 0.6), + content = layout_style:new("content_b:" .. _("Content"), color:new(0.6, 0.6, 0.6)), + content_text = layout_style:new("content_t:" .. _("Content text"), color:new(0.1, 0.1, 0.1), 0.6), - sidebar = layout_style:new("sidebar_b:Sidebar", color:new(0.7, 0.7, 0.7)), + sidebar = layout_style:new("sidebar_b:" .. _("Sidebar"), color:new(0.7, 0.7, 0.7)), - button = layout_style:new("navitem_b:Button", color:new(0.3, 0.3, 0.3)), - button_hover = layout_style:new("navitem_bh:Button (hover)", color:new(0.35, 0.35, 0.35)), - button_text = layout_style:new("navitem_t:Button text", color:new(0.8, 0.8, 0.8), 0.95), - button_text_hover = layout_style:new("navitem_th:Button text (hover)", color:new(0.9, 0.9, 0.9), 0.95), + button = layout_style:new("navitem_b:" .. _("Button"), color:new(0.3, 0.3, 0.3)), + button_hover = layout_style:new("navitem_bh:" .. _("Button (hover)"), color:new(0.35, 0.35, 0.35)), + button_text = layout_style:new("navitem_t:" .. _("Button text"), color:new(0.8, 0.8, 0.8), 0.95), + button_text_hover = layout_style:new("navitem_th:" .. _("Button text (hover)"), color:new(0.9, 0.9, 0.9), 0.95), - footer = layout_style:new("footer_b:Footer", color:new(0.1, 0.1, 0.1)), + footer = layout_style:new("footer_b:" .. _("Footer"), color:new(0.1, 0.1, 0.1)), }; for i,v in pairs(styles) do layout_system:addstyle(v); @@ -70,7 +70,7 @@ local root = layout:new_box("root", 0, 0, 640, 480); layout_system:setbox(root); - root:add(layout:new_fill("header", 0, 0, 1, 0.15, styles['header']):add(layout:new_text("header_text", 0.25, 0.25, 0.5, 0.5, styles['header_text'], 'Header'))); + root:add(layout:new_fill("header", 0, 0, 1, 0.15, styles['header']):add(layout:new_text("header_text", 0.25, 0.25, 0.5, 0.5, styles['header_text'], _("Header")))); root:add(layouts.add_buttons(layout:new_fill("sidebar", 0, 0.15, 0.25, 0.8, styles['sidebar']), 6, 0.7, { styles['button'], styles['button'], styles['button_hover'] }, { styles['button_text'], styles['button_text'], styles['button_text_hover'] }, 0, 0)); root:add(layouts.add_text(layout:new_fill("content", 0.25, 0.15, 0.75, 0.8, styles['content']), 10, styles['content_text'])); root:add(layout:new_fill("footer", 0, 0.95, 1, 0.05, styles['footer']):add(layouts.make_helper(layout:new_text("footer_text", 0.25, 0.5, 0.5, 0.45, nil, styles['footer']:humanname())))); @@ -79,15 +79,15 @@ end; }; gpick.layouts['std_layout_menu_1'] = { - human_readable = 'Menu', + human_readable = _("Menu"), mask = 0, build = function (layout_system) local styles = { - menu = layout_style:new("menu_b:Menu", color:new(0.7, 0.7, 0.7)), - button = layout_style:new("navitem_b:Button", color:new(0.3, 0.3, 0.3)), - button_hover = layout_style:new("navitem_bh:Button (hover)", color:new(0.3, 0.3, 0.3)), - button_text = layout_style:new("navitem_t:Button Text", color:new(0.8, 0.8, 0.8), 1.0), - button_text_hover = layout_style:new("navitem_th:Button Text (hover)", color:new(0.8, 0.8, 0.8), 1.0), + menu = layout_style:new("menu_b:" .. _("Menu"), color:new(0.7, 0.7, 0.7)), + button = layout_style:new("navitem_b:" .. _("Button"), color:new(0.3, 0.3, 0.3)), + button_hover = layout_style:new("navitem_bh:" .. _("Button (hover)"), color:new(0.3, 0.3, 0.3)), + button_text = layout_style:new("navitem_t:" .. _("Button text"), color:new(0.8, 0.8, 0.8), 1.0), + button_text_hover = layout_style:new("navitem_th:" .. _("Button text (hover)"), color:new(0.8, 0.8, 0.8), 1.0), }; for i,v in pairs(styles) do layout_system:addstyle(v); @@ -103,22 +103,23 @@ gpick.layouts['std_layout_brightness_darkness'] = { - human_readable = 'Brightness-Darkness', + human_readable = _("Brightness-Darkness"), mask = 1, build = function (layout_system) local styles = { - main = layout_style:new("main:Main", color:new(0.7, 0.7, 0.7)), - bvar1 = layout_style:new("b1:B1", color:new(0.3, 0.3, 0.3)), - bvar2 = layout_style:new("b2:B2", color:new(0.3, 0.3, 0.3)), - bvar3 = layout_style:new("b3:B3", color:new(0.3, 0.3, 0.3)), - bvar4 = layout_style:new("b4:B4", color:new(0.3, 0.3, 0.3)), - cvar1 = layout_style:new("c1:C1", color:new(0.3, 0.3, 0.3)), - cvar2 = layout_style:new("c2:C2", color:new(0.3, 0.3, 0.3)), - cvar3 = layout_style:new("c3:C3", color:new(0.3, 0.3, 0.3)), - cvar4 = layout_style:new("c4:C4", color:new(0.3, 0.3, 0.3)), + main = layout_style:new("main:" .. _("main"), color:new(0.7, 0.7, 0.7)), + bvar1 = layout_style:new("b1:b1", color:new(0.3, 0.3, 0.3)), + bvar2 = layout_style:new("b2:b2", color:new(0.3, 0.3, 0.3)), + bvar3 = layout_style:new("b3:b3", color:new(0.3, 0.3, 0.3)), + bvar4 = layout_style:new("b4:b4", color:new(0.3, 0.3, 0.3)), + cvar1 = layout_style:new("c1:c1", color:new(0.3, 0.3, 0.3)), + cvar2 = layout_style:new("c2:c2", color:new(0.3, 0.3, 0.3)), + cvar3 = layout_style:new("c3:c3", color:new(0.3, 0.3, 0.3)), + cvar4 = layout_style:new("c4:c4", color:new(0.3, 0.3, 0.3)), }; - for i,v in pairs(styles) do - layout_system:addstyle(v); + local styles_order = {'cvar4', 'cvar3', 'cvar2','cvar1', 'main', 'bvar1', 'bvar2', 'bvar3', 'bvar4'}; + for i,v in ipairs(styles_order) do + layout_system:addstyle(styles[v]); end; local root = layout:new_box("root", 0, 0, 320, 128); @@ -140,51 +141,51 @@ end; }; gpick.layouts['std_layout_grid_1'] = { - human_readable = 'Grid (4x3)', + human_readable = _("Grid (4x3)"), mask = 0, build = function (layout_system) local root = layout:new_box("root", 0, 0, 400, 300); layout_system:setbox(root); - + for j=0,2 do - for i=0,3 do + for i=0,3 do local item_i = 1 + (i + j * 4); - local style = layout_style:new("item" .. item_i .. ":Item" .. item_i, color:new(0.8, 0.8, 0.8), 1.0); - local style_text = layout_style:new("item" .. item_i .. "_text:Item" .. item_i .. " Text", color:new(0.2, 0.2, 0.2), 0.5); + local style = layout_style:new("item" .. item_i .. ":" .. _("Item") .. item_i, color:new(0.8, 0.8, 0.8), 1.0); + local style_text = layout_style:new("item" .. item_i .. "_text:" .. _("Item text") .. item_i, color:new(0.2, 0.2, 0.2), 0.5); layout_system:addstyle(style); - layout_system:addstyle(style_text); - + layout_system:addstyle(style_text); + local fill = layout:new_fill("b" .. item_i, (1 / 4) * i, (1 / 3) * j, (1 / 4) * 0.95, (1 / 3) * 0.95, style); - fill:add(layout:new_text("item_text".. item_i, 0, 0.25, 1, 0.5, style_text, "Item" .. item_i)); - - + fill:add(layout:new_text("item_text".. item_i, 0, 0.25, 1, 0.5, style_text, _("Item") .. item_i)); + + root:add(fill); end; end; return 1; end; }; - - + + gpick.layouts['std_layout_grid_2'] = { - human_readable = 'Grid (5x4)', + human_readable = _("Grid (5x4)"), mask = 0, build = function (layout_system) local root = layout:new_box("root", 0, 0, 500, 400); layout_system:setbox(root); - + for j=0,3 do - for i=0,4 do + for i=0,4 do local item_i = 1 + (i + j * 5); - local style = layout_style:new("item" .. item_i .. ":Item" .. item_i, color:new(0.8, 0.8, 0.8), 1.0); - local style_text = layout_style:new("item" .. item_i .. "_text:Item" .. item_i .. " Text", color:new(0.2, 0.2, 0.2), 0.5); + local style = layout_style:new("item" .. item_i .. ":" .. _("Item") .. item_i, color:new(0.8, 0.8, 0.8), 1.0); + local style_text = layout_style:new("item" .. item_i .. "_text:" .. _("Item text") .. item_i, color:new(0.2, 0.2, 0.2), 0.5); layout_system:addstyle(style); - layout_system:addstyle(style_text); - + layout_system:addstyle(style_text); + local fill = layout:new_fill("b" .. item_i, (1 / 5) * i, (1 / 4) * j, (1 / 5) * 0.95, (1 / 4) * 0.95, style); - fill:add(layout:new_text("item_text".. item_i, 0, 0.25, 1, 0.5, style_text, "Item" .. item_i)); - - + fill:add(layout:new_text("item_text".. item_i, 0, 0.25, 1, 0.5, style_text, _("Item") .. item_i)); + + root:add(fill); end; end; diff -Nru gpick-0.2.4/share/locale/es/LC_MESSAGES/gpick.po gpick-0.2.5/share/locale/es/LC_MESSAGES/gpick.po --- gpick-0.2.4/share/locale/es/LC_MESSAGES/gpick.po 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/share/locale/es/LC_MESSAGES/gpick.po 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,1259 @@ +msgid "" +msgstr "" +"Project-Id-Version: gpick 0.2.5rc1\n" +"POT-Creation-Date: 2013-01-05 16:16+0200\n" +"PO-Revision-Date: 2013-01-06 17:59-0300\n" +"Last-Translator: Guillermo Espertino \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: source/BlendColors.cpp:114 source/BlendColors.cpp:116 +msgid "blend node" +msgstr "nodo de mezcla" + +#: source/BlendColors.cpp:119 +msgid "blend" +msgstr "mezcla" + +#: source/BlendColors.cpp:308 source/BrightnessDarkness.cpp:260 +#: source/ColorMixer.cpp:321 source/ColorPicker.cpp:367 +#: source/GenerateScheme.cpp:444 source/LayoutPreview.cpp:405 +#: source/Variations.cpp:331 source/uiDialogOptions.cpp:215 +#: source/uiDialogOptions.cpp:234 +msgid "_Add to palette" +msgstr "_Agregar a la paleta" + +#: source/BlendColors.cpp:314 source/BrightnessDarkness.cpp:265 +#: source/ColorMixer.cpp:326 source/ColorPicker.cpp:371 +#: source/GenerateScheme.cpp:449 source/LayoutPreview.cpp:410 +#: source/Variations.cpp:336 +msgid "A_dd all to palette" +msgstr "Agregar to_do a la paleta" + +#: source/BlendColors.cpp:320 source/BrightnessDarkness.cpp:271 +#: source/ColorMixer.cpp:333 source/ColorPicker.cpp:377 +#: source/GenerateScheme.cpp:456 source/LayoutPreview.cpp:416 +#: source/Variations.cpp:343 source/uiDialogOptions.cpp:220 +#: source/uiDialogOptions.cpp:239 +msgid "_Copy to clipboard" +msgstr "_Copiar al portapapeles" + +#: source/BlendColors.cpp:374 source/GenerateScheme.cpp:485 +msgid "_Reset" +msgstr "_Reestablecer" + +#: source/BlendColors.cpp:517 +msgid "Start:" +msgstr "Inicio:" + +#: source/BlendColors.cpp:533 +msgid "Middle:" +msgstr "Medio:" + +#: source/BlendColors.cpp:551 +msgid "End:" +msgstr "Final:" + +#: source/BlendColors.cpp:568 source/GenerateScheme.cpp:875 +#: source/uiDialogGenerate.cpp:237 source/uiDialogMix.cpp:249 +#: source/transformation/ColorVisionDeficiency.cpp:363 +msgid "Type:" +msgstr "Tipo:" + +#: source/BlendColors.cpp:570 source/ColorWheelType.cpp:56 +#: source/uiDialogMix.cpp:251 +msgid "RGB" +msgstr "RGB" + +#: source/BlendColors.cpp:571 source/uiDialogMix.cpp:252 +msgid "HSV" +msgstr "HSV" + +#: source/BlendColors.cpp:572 source/uiDialogMix.cpp:253 +msgid "HSV shortest hue distance" +msgstr "HSV distancia de matiz más corta" + +#: source/BlendColors.cpp:573 source/uiDialogMix.cpp:254 +msgid "LAB" +msgstr "LAB" + +#: source/BlendColors.cpp:582 +msgid "Start steps:" +msgstr "Pasos al inicio:" + +#: source/BlendColors.cpp:590 +msgid "End steps:" +msgstr "Pasos al final:" + +#: source/BlendColors.cpp:627 +msgid "Blend colors" +msgstr "Mezclar colores" + +#: source/BrightnessDarkness.cpp:86 +msgid "brightness darkness" +msgstr "brillo oscuridad" + +#: source/BrightnessDarkness.cpp:287 source/ColorMixer.cpp:373 +#: source/ColorPicker.cpp:387 source/GenerateScheme.cpp:469 +#: source/LayoutPreview.cpp:430 source/Variations.cpp:383 +msgid "_Edit..." +msgstr "_Editar..." + +#: source/BrightnessDarkness.cpp:292 source/ColorMixer.cpp:378 +#: source/ColorPicker.cpp:391 source/GenerateScheme.cpp:474 +#: source/LayoutPreview.cpp:435 source/Variations.cpp:388 +msgid "_Paste" +msgstr "_Pegar" + +#: source/BrightnessDarkness.cpp:385 +msgid "Brightness" +msgstr "Brillo" + +#: source/BrightnessDarkness.cpp:385 +msgid "Darkness" +msgstr "Oscuridad" + +#: source/BrightnessDarkness.cpp:431 +msgid "Brightness Darkness" +msgstr "Brillo - Oscuridad" + +#: source/ColorMixer.cpp:66 +msgid "Normal" +msgstr "Normal" + +#: source/ColorMixer.cpp:67 +msgid "Multiply" +msgstr "Multiplicar" + +#: source/ColorMixer.cpp:68 +msgid "Add" +msgstr "Suma" + +#: source/ColorMixer.cpp:69 +msgid "Difference" +msgstr "Diferencia" + +#: source/ColorMixer.cpp:70 source/ColorPicker.cpp:1180 +#: source/ColorPicker.cpp:1194 source/ColorSpaceType.cpp:30 +#: source/ColorSpaceType.cpp:37 source/Variations.cpp:66 +msgid "Hue" +msgstr "Matiz" + +#: source/ColorMixer.cpp:71 source/ColorPicker.cpp:1180 +#: source/ColorPicker.cpp:1194 source/ColorSpaceType.cpp:31 +#: source/ColorSpaceType.cpp:38 source/Variations.cpp:67 +msgid "Saturation" +msgstr "Saturación" + +#: source/ColorMixer.cpp:72 source/ColorPicker.cpp:1194 +#: source/ColorPicker.cpp:1236 source/ColorPicker.cpp:1250 +#: source/ColorSpaceType.cpp:39 source/ColorSpaceType.cpp:59 +#: source/ColorSpaceType.cpp:66 source/Variations.cpp:68 +msgid "Lightness" +msgstr "Luminosidad" + +#: source/ColorMixer.cpp:114 +msgid "color mixer" +msgstr "mezclador de colores" + +#: source/ColorMixer.cpp:234 +#, fuzzy +msgid "secondary" +msgstr "Vista _Secundaria" + +#: source/ColorMixer.cpp:238 source/Variations.cpp:229 +#, c-format +msgid "primary %d" +msgstr "" + +#: source/ColorMixer.cpp:244 +#, c-format +msgid "result %d" +msgstr "" + +#: source/ColorMixer.cpp:704 +msgid "Opacity:" +msgstr "Opacidad:" + +#: source/ColorMixer.cpp:732 +msgid "Color mixer" +msgstr "Mezclador de colores" + +#: source/ColorPicker.cpp:424 +msgid "Press Spacebar to sample color under mouse pointer" +msgstr "Presione Espacio para capturar el color debajo del puntero" + +#: source/ColorPicker.cpp:699 source/uiConverter.cpp:163 +msgid "Copy" +msgstr "Copiar" + +#: source/ColorPicker.cpp:703 source/uiConverter.cpp:172 +msgid "Paste" +msgstr "Pegar" + +#: source/ColorPicker.cpp:709 source/uiColorInput.cpp:119 +msgid "Edit" +msgstr "Editar" + +#: source/ColorPicker.cpp:771 source/uiApp.cpp:1012 +#: source/uiDialogSort.cpp:222 +msgid "None" +msgstr "Ninguna" + +#: source/ColorPicker.cpp:772 +msgid "Linear" +msgstr "Lineal" + +#: source/ColorPicker.cpp:773 +msgid "Quadratic" +msgstr "Cuadrática" + +#: source/ColorPicker.cpp:774 +msgid "Cubic" +msgstr "Cúbica" + +#: source/ColorPicker.cpp:775 +msgid "Exponential" +msgstr "Exponencial" + +#: source/ColorPicker.cpp:951 +msgid "Click on swatch area to begin adding colors to palette" +msgstr "" +"Haga click sobre el área de muestras para empezar a agregar colores a la " +"paleta" + +#: source/ColorPicker.cpp:1143 +msgid "Settings" +msgstr "Ajustes" + +#: source/ColorPicker.cpp:1153 +msgid "Oversample:" +msgstr "Sobremuestreo:" + +#: source/ColorPicker.cpp:1160 +msgid "Falloff:" +msgstr "Atenuación:" + +#: source/ColorPicker.cpp:1167 +msgid "Zoom:" +msgstr "Ampliación:" + +#: source/ColorPicker.cpp:1180 source/ColorSpaceType.cpp:32 +msgid "Value" +msgstr "Valor" + +#: source/ColorPicker.cpp:1208 source/ColorSpaceType.cpp:44 +msgid "Red" +msgstr "Rojo" + +#: source/ColorPicker.cpp:1208 source/ColorSpaceType.cpp:45 +msgid "Green" +msgstr "Verde" + +#: source/ColorPicker.cpp:1208 source/ColorSpaceType.cpp:46 +msgid "Blue" +msgstr "Azul" + +#: source/ColorPicker.cpp:1222 source/ColorSpaceType.cpp:51 +msgid "Cyan" +msgstr "Cián" + +#: source/ColorPicker.cpp:1222 source/ColorSpaceType.cpp:52 +msgid "Magenta" +msgstr "Magenta" + +#: source/ColorPicker.cpp:1222 source/ColorSpaceType.cpp:53 +msgid "Yellow" +msgstr "Amarillo" + +#: source/ColorPicker.cpp:1222 source/ColorSpaceType.cpp:54 +msgid "Key" +msgstr "Negro (key)" + +#: source/ColorPicker.cpp:1258 +msgid "Info" +msgstr "Información" + +#: source/ColorPicker.cpp:1267 +msgid "Color name:" +msgstr "Nombre del color:" + +#: source/ColorPicker.cpp:1280 +msgid "Contrast:" +msgstr "Contraste:" + +#: source/ColorPicker.cpp:1285 source/ColorPicker.cpp:1291 +msgid "Sample" +msgstr "Muestra" + +#: source/ColorPicker.cpp:1324 +msgid "Color picker" +msgstr "Selector de color" + +#: source/ColorWheelType.cpp:57 +msgid "RYB v1" +msgstr "RYB v1" + +#: source/ColorWheelType.cpp:58 +msgid "RYB v2" +msgstr "RYB v2" + +#: source/GenerateScheme.cpp:90 +msgid "Complementary" +msgstr "Complementarios" + +#: source/GenerateScheme.cpp:91 +msgid "Analogous" +msgstr "Análogos" + +#: source/GenerateScheme.cpp:92 +msgid "Triadic" +msgstr "Tríada" + +#: source/GenerateScheme.cpp:93 +msgid "Split-Complementary" +msgstr "Complementarios divididos" + +#: source/GenerateScheme.cpp:94 +msgid "Rectangle (tetradic)" +msgstr "Rectangular (Tétrada)" + +#: source/GenerateScheme.cpp:95 +msgid "Square" +msgstr "Cuadrado" + +#: source/GenerateScheme.cpp:96 +msgid "Neutral" +msgstr "Neutros" + +#: source/GenerateScheme.cpp:97 +msgid "Clash" +msgstr "Complementarios en tensión" + +#: source/GenerateScheme.cpp:98 +msgid "Five-Tone" +msgstr "Cinco Tonos" + +#: source/GenerateScheme.cpp:99 +msgid "Six-Tone" +msgstr "Seis Tonos" + +#: source/GenerateScheme.cpp:119 source/uiDialogGenerate.cpp:76 +msgid "scheme" +msgstr "armonía" + +#: source/GenerateScheme.cpp:292 +msgid "_Locked" +msgstr "_Bloqueado" + +#: source/GenerateScheme.cpp:299 +msgid "_Reset scheme" +msgstr "_Reestablecer armonía" + +#: source/GenerateScheme.cpp:851 +msgid "Hue:" +msgstr "Matiz:" + +#: source/GenerateScheme.cpp:858 source/uiDialogVariations.cpp:171 +msgid "Saturation:" +msgstr "Saturación:" + +#: source/GenerateScheme.cpp:866 source/uiDialogVariations.cpp:156 +msgid "Lightness:" +msgstr "Luminosidad:" + +#: source/GenerateScheme.cpp:885 source/uiDialogGenerate.cpp:246 +msgid "Color wheel:" +msgstr "Rueda de color:" + +#: source/GenerateScheme.cpp:919 +msgid "Scheme generation" +msgstr "Generación de armonías" + +#: source/LayoutPreview.cpp:78 +msgid "layout preview" +msgstr "vista previa de diseño" + +#: source/LayoutPreview.cpp:153 +msgid "Style item" +msgstr "Ítem de estilo" + +#: source/LayoutPreview.cpp:162 +msgid "CSS selector" +msgstr "Selector CSS" + +#: source/LayoutPreview.cpp:184 +msgid "Assign CSS selectors" +msgstr "Asignar selectores CSS" + +#: source/LayoutPreview.cpp:547 source/LayoutPreview.cpp:595 +#: source/uiApp.cpp:690 source/uiApp.cpp:711 +msgid "File could not be saved" +msgstr "El archivo no pudo ser guardado" + +#: source/LayoutPreview.cpp:558 source/uiExport.cpp:457 +#: source/uiExport.cpp:523 +msgid "Export" +msgstr "Exportar" + +#: source/LayoutPreview.cpp:572 +msgid "Cascading Style Sheets *.css" +msgstr "Hojas de Estilos en Cascada *.css" + +#: source/LayoutPreview.cpp:666 +msgid "Layout:" +msgstr "Diseño:" + +#: source/LayoutPreview.cpp:672 +msgid "Export CSS File" +msgstr "Exportar Archivo CSS" + +#: source/LayoutPreview.cpp:673 +msgid "Export CSS file" +msgstr "Exportar archivo CSS" + +#: source/LayoutPreview.cpp:682 +msgid "_Export CSS File As..." +msgstr "_Exportar archivo CSS como..." + +#: source/LayoutPreview.cpp:686 +msgid "_Assign CSS Selectors..." +msgstr "_Asignar selectores CSS..." + +#: source/LayoutPreview.cpp:759 +msgid "Layout preview" +msgstr "Vista previa de diseño" + +#: source/ToolColorNaming.cpp:25 +msgid "_Empty" +msgstr "Ninguno" + +#: source/ToolColorNaming.cpp:26 +msgid "_Automatic name" +msgstr "Nombre _automático" + +#: source/ToolColorNaming.cpp:27 +msgid "_Tool specific" +msgstr "Específico de la herramien_ta" + +#: source/Variations.cpp:69 +msgid "Lightness (Lab)" +msgstr "Luminosidad (Lab)" + +#: source/Variations.cpp:110 +msgid "variations" +msgstr "variaciones" + +#: source/Variations.cpp:225 +#, fuzzy +msgid "all colors" +msgstr "Mezclar colores" + +#: source/Variations.cpp:239 +#, c-format +msgid "result %d line %d" +msgstr "" + +#: source/Variations.cpp:717 +#: source/transformation/ColorVisionDeficiency.cpp:386 +msgid "Strength:" +msgstr "Intensidad:" + +#: source/Variations.cpp:745 source/uiDialogVariations.cpp:142 +msgid "Variations" +msgstr "Variaciones" + +#: source/uiAbout.cpp:88 +msgid "About Gpick" +msgstr "Acerca de Gpick" + +#: source/uiAbout.cpp:121 +msgid "Advanced color picker" +msgstr "Selector de color avanzado" + +#: source/uiAbout.cpp:126 +msgid "Copyrights © 2009-2013, Albertas Vyšniauskas and Gpick development team" +msgstr "" +"Copyrights © 2009-2013, Albertas Vyšniauskas y el equipo de desarrollo de " +"Gpick" + +#: source/uiAbout.cpp:141 +msgid "License" +msgstr "Licencia" + +#: source/uiAbout.cpp:142 +msgid "Credits" +msgstr "Créditos" + +#: source/uiAbout.cpp:143 +msgid "Expat License" +msgstr "Licencia Expat" + +#: source/uiAbout.cpp:144 +msgid "Lua License" +msgstr "Licencia Lua" + +#: source/uiApp.cpp:354 +msgid "New palette" +msgstr "Nueva paleta" + +#: source/uiApp.cpp:360 +msgid "(Imported)" +msgstr "(Importado)" + +#: source/uiApp.cpp:530 source/uiApp.cpp:545 source/uiApp.cpp:563 +#: source/uiApp.cpp:641 +msgid "File could not be opened" +msgstr "El archivo no pudo ser abierto" + +#: source/uiApp.cpp:531 source/uiApp.cpp:546 source/uiApp.cpp:564 +#: source/uiApp.cpp:642 +msgid "Open" +msgstr "Abrir" + +#: source/uiApp.cpp:576 source/uiExport.cpp:473 source/uiExport.cpp:587 +msgid "Gpick Palette (*.gpa)" +msgstr "Paleta de Gpick (*.gpa)" + +#: source/uiApp.cpp:577 source/uiExport.cpp:474 source/uiExport.cpp:588 +msgid "GIMP/Inkscape Palette (*.gpl)" +msgstr "Paleta de GIMP/Inkscape (*.gpl)" + +#: source/uiApp.cpp:578 source/uiExport.cpp:476 source/uiExport.cpp:589 +msgid "Adobe Swatch Exchange (*.ase)" +msgstr "Adobe Swatch Exchange (*.ase)" + +#: source/uiApp.cpp:584 source/uiExport.cpp:598 +#: source/tools/PaletteFromImage.cpp:548 +msgid "All files" +msgstr "Todos los archivos" + +#: source/uiApp.cpp:589 source/uiExport.cpp:607 +msgid "All supported formats" +msgstr "Todos los formatos soportados" + +#: source/uiApp.cpp:610 +msgid "Open File" +msgstr "Abrir archivo" + +#: source/uiApp.cpp:659 source/uiApp.cpp:691 +msgid "Save As" +msgstr "Guardar como" + +#: source/uiApp.cpp:712 +msgid "Save" +msgstr "Guardar" + +#: source/uiApp.cpp:771 +msgid "Open Last File" +msgstr "Abrir el último archivo" + +#: source/uiApp.cpp:916 +msgid "Recent _files" +msgstr "Archivos _Recientes" + +#: source/uiApp.cpp:946 +msgid "Ex_port..." +msgstr "E_xportar..." + +#: source/uiApp.cpp:954 +msgid "Expo_rt Selected..." +msgstr "Ex_portar Seleccionados..." + +#: source/uiApp.cpp:962 +msgid "_Import..." +msgstr "_Importar..." + +#: source/uiApp.cpp:977 +msgid "_File" +msgstr "_Archivo" + +#: source/uiApp.cpp:985 +msgid "Edit _Converters..." +msgstr "Editar _Convertidores..." + +#: source/uiApp.cpp:989 +msgid "Display _Filters..." +msgstr "Mostrar _Filtros" + +#: source/uiApp.cpp:1001 +msgid "_Edit" +msgstr "_Editar" + +#: source/uiApp.cpp:1037 +msgid "_Secondary View" +msgstr "Vista _Secundaria" + +#: source/uiApp.cpp:1043 +msgid "Palette" +msgstr "Paleta" + +#: source/uiApp.cpp:1049 +msgid "_View" +msgstr "_Vista" + +#: source/uiApp.cpp:1055 +msgid "Palette From _Image..." +msgstr "Paleta desde _Imagen..." + +#: source/uiApp.cpp:1063 +msgid "_Tools" +msgstr "_Herramientas" + +#: source/uiApp.cpp:1078 +msgid "_Help" +msgstr "A_yuda" + +#: source/uiApp.cpp:1386 +msgid "_Copy to Clipboard" +msgstr "_Copiar al Portapapeles" + +#: source/uiApp.cpp:1402 +msgid "_Mix Colors..." +msgstr "_Mezclar Colores..." + +#: source/uiApp.cpp:1407 +msgid "_Variations..." +msgstr "_Variaciones..." + +#: source/uiApp.cpp:1412 +msgid "_Generate..." +msgstr "_Generar..." + +#: source/uiApp.cpp:1421 +msgid "C_lear names" +msgstr "_Limpiar nombres" + +#: source/uiApp.cpp:1427 +msgid "Autona_me" +msgstr "No_mbre automático" + +#: source/uiApp.cpp:1433 +msgid "Auto_number..." +msgstr "_Numerado automático" + +#: source/uiApp.cpp:1441 +msgid "R_everse" +msgstr "_Reverso" + +#: source/uiApp.cpp:1447 +msgid "Group and _sort..." +msgstr "Agrupar y ordenar" + +#: source/uiApp.cpp:1455 +msgid "_Remove" +msgstr "_Quitar" + +#: source/uiApp.cpp:1461 +msgid "Remove _All" +msgstr "Quitar _Todo" + +#: source/uiApp.cpp:1869 +msgid "Color pic_ker" +msgstr "Selector de _Color" + +#: source/uiApp.cpp:1878 +msgid "Scheme _generation" +msgstr "_Generación de armonías" + +#: source/uiApp.cpp:1897 +msgid "Lay_out preview" +msgstr "Vista previa de diseñ_o" + +#: source/uiApp.cpp:1947 +msgid "Pick colors (Ctrl+P)" +msgstr "Elegir color (CTRL+P)" + +#: source/uiApp.cpp:1956 +msgid "" +"File is currently in a non-native format, possible loss of precision and/or " +"metadata." +msgstr "" +"El archivo está actualmente en un formato no-nativo, posible pérdida de " +"precisión y/o metadatos." + +#: source/uiColorInput.cpp:45 +msgid "Edit color" +msgstr "Editar color" + +#: source/uiColorInput.cpp:69 +msgid "Color:" +msgstr "Color:" + +#: source/uiConverter.cpp:56 +msgid "Test color" +msgstr "Probar color" + +#: source/uiConverter.cpp:74 +msgid "error" +msgstr "error" + +#: source/uiConverter.cpp:145 +msgid "Function name" +msgstr "Nombre de la función" + +#: source/uiConverter.cpp:154 +msgid "Example" +msgstr "Ejemplo" + +#: source/uiConverter.cpp:196 +msgid "Converters" +msgstr "Convertidores" + +#: source/uiConverter.cpp:224 +msgid "Displays:" +msgstr "Visualizaciones:" + +#: source/uiConverter.cpp:230 +msgid "Color list:" +msgstr "Lista de colores:" + +#: source/uiDialogAutonumber.cpp:108 +msgid "Autonumber colors" +msgstr "Autonumerar colores" + +#: source/uiDialogAutonumber.cpp:122 +msgid "Name:" +msgstr "Nombre:" + +#: source/uiDialogAutonumber.cpp:132 +msgid "Decimal places:" +msgstr "Lugares decimales:" + +#: source/uiDialogAutonumber.cpp:139 +msgid "Starting number:" +msgstr "Número inicial:" + +#: source/uiDialogAutonumber.cpp:146 +msgid "_Decreasing" +msgstr "_Decreciente" + +#: source/uiDialogAutonumber.cpp:152 +msgid "_Append" +msgstr "_Agregar" + +#: source/uiDialogAutonumber.cpp:158 +msgid "Sample:" +msgstr "Muestra:" + +#: source/uiDialogGenerate.cpp:216 +msgid "Generate colors" +msgstr "Generar colores" + +#: source/uiDialogGenerate.cpp:230 source/tools/PaletteFromImage.cpp:599 +msgid "Colors:" +msgstr "Colores:" + +#: source/uiDialogGenerate.cpp:257 +msgid "Chaos:" +msgstr "Caos:" + +#: source/uiDialogGenerate.cpp:263 +msgid "Seed:" +msgstr "Semilla:" + +#: source/uiDialogGenerate.cpp:271 +msgid "_Reverse" +msgstr "_Reverso" + +#: source/uiDialogMix.cpp:76 source/uiDialogMix.cpp:78 +msgid "mix node" +msgstr "nodo de mezcla" + +#: source/uiDialogMix.cpp:81 +msgid "mix" +msgstr "mezcla" + +#: source/uiDialogMix.cpp:235 +msgid "Mix colors" +msgstr "Mezclar colores" + +#: source/uiDialogMix.cpp:262 source/uiDialogVariations.cpp:186 +msgid "Steps:" +msgstr "Pasos:" + +#: source/uiDialogMix.cpp:270 +msgid "_Include Endpoints" +msgstr "_incluir extremos" + +#: source/uiDialogOptions.cpp:117 source/tools/PaletteFromImage.cpp:589 +msgid "Options" +msgstr "Opciones" + +#: source/uiDialogOptions.cpp:134 +msgid "System" +msgstr "Sistema" + +#: source/uiDialogOptions.cpp:143 +msgid "_Single instance" +msgstr "In_stancia única" + +#: source/uiDialogOptions.cpp:148 +msgid "Save/_Restore palette" +msgstr "Guardar/_Reestablecer paleta" + +#: source/uiDialogOptions.cpp:154 +msgid "System tray" +msgstr "Bandeja de sistema" + +#: source/uiDialogOptions.cpp:162 +msgid "_Minimize to system tray" +msgstr "_Minimizar a la bandeja de sistema" + +#: source/uiDialogOptions.cpp:167 +msgid "_Close to system tray" +msgstr "_Cerrar a la bandeja de sistema" + +#: source/uiDialogOptions.cpp:172 +msgid "_Start in system tray" +msgstr "Iniciar en la bandeja de _sistema" + +#: source/uiDialogOptions.cpp:178 +msgid "_Main" +msgstr "_Principal" + +#: source/uiDialogOptions.cpp:184 +msgid "Display" +msgstr "Visualización" + +#: source/uiDialogOptions.cpp:193 +msgid "_Refresh rate:" +msgstr "Tasa de _refresco:" + +#: source/uiDialogOptions.cpp:201 +msgid "_Magnified area size:" +msgstr "Tamaño del área _magnificada:" + +#: source/uiDialogOptions.cpp:207 +msgid "Floating picker click behaviour" +msgstr "Comportamiento del selector flotante" + +#: source/uiDialogOptions.cpp:226 +msgid "'Spacebar' button behaviour" +msgstr "Comportamiento de la barra espaciadora" + +#: source/uiDialogOptions.cpp:244 +msgid "_Rotate swatch" +msgstr "_Rotar muestras" + +#: source/uiDialogOptions.cpp:251 +msgid "Enabled color spaces" +msgstr "Espacios de color habilitados" + +#: source/uiDialogOptions.cpp:266 +msgid "Lab settings" +msgstr "Ajustes Lab" + +#: source/uiDialogOptions.cpp:278 +msgid "_Illuminant:" +msgstr "_Iluminante" + +#: source/uiDialogOptions.cpp:302 +msgid "_Observer:" +msgstr "_Observador" + +#: source/uiDialogOptions.cpp:321 +msgid "Other settings" +msgstr "Otros ajustes" + +#: source/uiDialogOptions.cpp:330 +msgid "_Mask out of gamut colors" +msgstr "En_mascarar colores fuera de gamut" + +#: source/uiDialogOptions.cpp:336 +msgid "_Picker" +msgstr "_Selector" + +#: source/uiDialogOptions.cpp:341 +msgid "Color name generation" +msgstr "Generación de nombres de color" + +#: source/uiDialogOptions.cpp:350 +msgid "_Imprecision postfix" +msgstr "Sufijo de _impresición" + +#: source/uiDialogOptions.cpp:356 +msgid "Tool color naming" +msgstr "Asignación de nombres de color" + +#: source/uiDialogOptions.cpp:381 +msgid "_Color names" +msgstr "Nombre del _color" + +#: source/uiDialogSort.cpp:135 source/uiDialogSort.cpp:223 +msgid "RGB Red" +msgstr "Rojo RGB" + +#: source/uiDialogSort.cpp:136 source/uiDialogSort.cpp:224 +msgid "RGB Green" +msgstr "Verde RGB" + +#: source/uiDialogSort.cpp:137 source/uiDialogSort.cpp:225 +msgid "RGB Blue" +msgstr "Azul RGB" + +#: source/uiDialogSort.cpp:138 source/uiDialogSort.cpp:226 +msgid "RGB Grayscale" +msgstr "Escala de grises RGB" + +#: source/uiDialogSort.cpp:139 source/uiDialogSort.cpp:227 +msgid "HSL Hue" +msgstr "Matiz HSL" + +#: source/uiDialogSort.cpp:140 source/uiDialogSort.cpp:228 +msgid "HSL Saturation" +msgstr "Saturación HSL" + +#: source/uiDialogSort.cpp:141 source/uiDialogSort.cpp:229 +msgid "HSL Lightness" +msgstr "Luminosidad HSL" + +#: source/uiDialogSort.cpp:142 source/uiDialogSort.cpp:230 +msgid "Lab Lightness" +msgstr "Luminosidad Lab" + +#: source/uiDialogSort.cpp:143 source/uiDialogSort.cpp:231 +msgid "Lab A" +msgstr "Lab A" + +#: source/uiDialogSort.cpp:144 source/uiDialogSort.cpp:232 +msgid "Lab B" +msgstr "Lab B" + +#: source/uiDialogSort.cpp:145 source/uiDialogSort.cpp:233 +msgid "LCh Lightness" +msgstr "Luminosidad LCh" + +#: source/uiDialogSort.cpp:146 source/uiDialogSort.cpp:234 +msgid "LCh Chroma" +msgstr "Crominancia LCh" + +#: source/uiDialogSort.cpp:147 source/uiDialogSort.cpp:235 +msgid "LCh Hue" +msgstr "Matiz LCh" + +#: source/uiDialogSort.cpp:556 +msgid "Group and sort" +msgstr "Agrupar y ordenar" + +#: source/uiDialogSort.cpp:564 +msgid "Group type:" +msgstr "Tipo de grupo:" + +#: source/uiDialogSort.cpp:574 +msgid "Grouping sensitivity:" +msgstr "Sensibilidad de agrupamiento:" + +#: source/uiDialogSort.cpp:581 +msgid "Maximum number of groups:" +msgstr "Número máximo de grupos:" + +#: source/uiDialogSort.cpp:588 +msgid "Sort type:" +msgstr "Tipo de ordenamiento:" + +#: source/uiDialogSort.cpp:598 +msgid "_Reverse group order" +msgstr "Orden de grupo inve_rso" + +#: source/uiDialogSort.cpp:604 +msgid "_Reverse order inside groups" +msgstr "Orden de grupo inve_rso dentro de grupos" + +#: source/uiDialogVariations.cpp:60 +msgid "variation" +msgstr "variación" + +#: source/uiDialogVariations.cpp:194 +msgid "_Use multiplication" +msgstr "_Usar multiplicación" + +#: source/uiExport.cpp:475 +msgid "Alias/WaveFront Material (*.mtl)" +msgstr "Material de Alias/WaveFront (*.mtl)" + +#: source/uiExport.cpp:477 +msgid "Text file (*.txt)" +msgstr "Archivo de texto (*.txt)" + +#: source/uiExport.cpp:522 +msgid "File could not be exported" +msgstr "El archivo no pudo ser exportado" + +#: source/uiExport.cpp:573 source/uiExport.cpp:654 source/uiExport.cpp:666 +msgid "Import" +msgstr "Importar" + +#: source/uiExport.cpp:653 +msgid "File format is not supported" +msgstr "El formato de archivo no está soportado" + +#: source/uiExport.cpp:665 +msgid "File could not be imported" +msgstr "El archivo no pudo ser importado" + +#: source/uiListPalette.cpp:158 source/uiListPalette.cpp:160 +#, c-format +msgid "%d color" +msgid_plural "%d colors" +msgstr[0] "%d color" +msgstr[1] "%d colores" + +#: source/uiListPalette.cpp:166 +msgid "selected" +msgstr "seleccionado" + +#: source/uiListPalette.cpp:172 source/uiListPalette.cpp:174 +#, c-format +msgid "Total %d color" +msgid_plural "Total %d colors" +msgstr[0] "Total %d color" +msgstr[1] "Total %d colores" + +#: source/uiListPalette.cpp:353 +msgid "Preview" +msgstr "Vista previa" + +#: source/uiListPalette.cpp:708 source/uiListPalette.cpp:717 +msgid "Color" +msgstr "Color" + +#: source/uiListPalette.cpp:726 source/uiTransformations.cpp:183 +msgid "Name" +msgstr "Nombre" + +#: source/uiStatusIcon.cpp:67 +msgid "_Show Main Window" +msgstr "Mo_strar Ventana Principal" + +#: source/uiStatusIcon.cpp:74 +msgid "_Quit" +msgstr "Salir" + +#: source/uiTransformations.cpp:245 +msgid "Display filters" +msgstr "Filtros de visualización" + +#: source/uiTransformations.cpp:259 +msgid "_Enabled" +msgstr "_Activado" + +#: source/tools/PaletteFromImage.cpp:514 +msgid "Palette from image" +msgstr "Paleta desde imagen" + +#: source/tools/PaletteFromImage.cpp:527 +msgid "Image" +msgstr "Imagen" + +#: source/tools/PaletteFromImage.cpp:536 +msgid "Image file" +msgstr "Archivo de imagen" + +#: source/tools/PaletteFromImage.cpp:556 +msgid "All images" +msgstr "Todas las imágenes" + +#: source/transformation/ColorVisionDeficiency.cpp:41 +msgid "Color vision deficiency" +msgstr "Visión de color deficiente" + +#: source/transformation/ColorVisionDeficiency.cpp:330 +msgid "Protanomaly" +msgstr "Protanomalía" + +#: source/transformation/ColorVisionDeficiency.cpp:331 +msgid "Deuteranomaly" +msgstr "Deuteranomalía" + +#: source/transformation/ColorVisionDeficiency.cpp:332 +msgid "Tritanomaly" +msgstr "Tritanomalía" + +#: source/transformation/ColorVisionDeficiency.cpp:333 +msgid "Protanopia" +msgstr "Protanopía" + +#: source/transformation/ColorVisionDeficiency.cpp:334 +msgid "Deuteranopia" +msgstr "Deuteranopía" + +#: source/transformation/ColorVisionDeficiency.cpp:335 +msgid "Tritanopia" +msgstr "Tritanopía" + +#: source/transformation/ColorVisionDeficiency.cpp:422 +msgid "Altered spectral sensitivity of red receptors" +msgstr "Sensibilidad espectral alterada en receptores de rojos" + +#: source/transformation/ColorVisionDeficiency.cpp:423 +msgid "Altered spectral sensitivity of green receptors" +msgstr "Sensibilidad espectral alterada en receptores de verdes" + +#: source/transformation/ColorVisionDeficiency.cpp:424 +msgid "Altered spectral sensitivity of blue receptors" +msgstr "Sensibilidad espectral alterada en receptores de azules" + +#: source/transformation/ColorVisionDeficiency.cpp:425 +msgid "Absence of red receptors" +msgstr "Ausencia de receptores de rojo" + +#: source/transformation/ColorVisionDeficiency.cpp:426 +msgid "Absence of green receptors" +msgstr "Ausencia de receptores de verde" + +#: source/transformation/ColorVisionDeficiency.cpp:427 +msgid "Absence of blue receptors" +msgstr "Ausencia de receptores de azul" + +#: source/transformation/GammaModification.cpp:38 +msgid "Gamma modification" +msgstr "Modificación de gamma" + +#: source/transformation/GammaModification.cpp:88 +#: source/transformation/Quantization.cpp:96 +msgid "Value:" +msgstr "Valor:" + +#: source/transformation/Quantization.cpp:40 +msgid "Quantization" +msgstr "Cuantización" + +#: source/transformation/Quantization.cpp:101 +msgid "Clip top-end" +msgstr "Recortar límite superior" + +#: share/gpick/init.lua:173 +msgid "Web: hex code" +msgstr "" + +#: share/gpick/init.lua:178 +msgid "Web: hex code (3 digits)" +msgstr "" + +#: share/gpick/init.lua:183 +msgid "Web: hex code (no hash symbol)" +msgstr "" + +#: share/gpick/init.lua:188 +msgid "CSS: hue saturation lightness" +msgstr "" + +#: share/gpick/init.lua:193 +msgid "CSS: red green blue" +msgstr "" + +#: share/gpick/layouts.lua:15 +msgid "Homepage" +msgstr "" + +#: share/gpick/layouts.lua:15 +#, fuzzy +msgid "About us" +msgstr "Acerca de Gpick" + +#: share/gpick/layouts.lua:15 +msgid "Links to us" +msgstr "" + +#: share/gpick/layouts.lua:15 +msgid "Privacy" +msgstr "" + +#: share/gpick/layouts.lua:15 +msgid "Terms" +msgstr "" + +#: share/gpick/layouts.lua:15 +#, fuzzy +msgid "Contact us" +msgstr "Contraste:" + +#: share/gpick/layouts.lua:15 +msgid "RSS" +msgstr "" + +#: share/gpick/layouts.lua:30 +msgid "The quick brown fox jumps over the lazy dog" +msgstr "" + +#: share/gpick/layouts.lua:46 +msgid "Webpage" +msgstr "" + +#: share/gpick/layouts.lua:51 share/gpick/layouts.lua:73 +msgid "Header" +msgstr "" + +#: share/gpick/layouts.lua:52 +msgid "Header text" +msgstr "" + +#: share/gpick/layouts.lua:54 +#, fuzzy +msgid "Content" +msgstr "Contraste:" + +#: share/gpick/layouts.lua:55 +msgid "Content text" +msgstr "" + +#: share/gpick/layouts.lua:57 +msgid "Sidebar" +msgstr "" + +#: share/gpick/layouts.lua:59 share/gpick/layouts.lua:87 +msgid "Button" +msgstr "" + +#: share/gpick/layouts.lua:60 share/gpick/layouts.lua:88 +msgid "Button (hover)" +msgstr "" + +#: share/gpick/layouts.lua:61 share/gpick/layouts.lua:89 +msgid "Button text" +msgstr "" + +#: share/gpick/layouts.lua:62 share/gpick/layouts.lua:90 +msgid "Button text (hover)" +msgstr "" + +#: share/gpick/layouts.lua:64 +msgid "Footer" +msgstr "" + +#: share/gpick/layouts.lua:82 share/gpick/layouts.lua:86 +msgid "Menu" +msgstr "" + +#: share/gpick/layouts.lua:106 +#, fuzzy +msgid "Brightness-Darkness" +msgstr "Brillo - Oscuridad" + +#: share/gpick/layouts.lua:110 +msgid "main" +msgstr "" + +#: share/gpick/layouts.lua:144 +msgid "Grid (4x3)" +msgstr "" + +#: share/gpick/layouts.lua:153 share/gpick/layouts.lua:159 +#: share/gpick/layouts.lua:180 share/gpick/layouts.lua:186 +msgid "Item" +msgstr "" + +#: share/gpick/layouts.lua:154 share/gpick/layouts.lua:181 +msgid "Item text" +msgstr "" + +#: share/gpick/layouts.lua:171 +msgid "Grid (5x4)" +msgstr "" + +#~ msgid "Edit _Transformations..." +#~ msgstr "Editar _Transformaciones..." diff -Nru gpick-0.2.4/share/locale/lt/LC_MESSAGES/gpick.po gpick-0.2.5/share/locale/lt/LC_MESSAGES/gpick.po --- gpick-0.2.4/share/locale/lt/LC_MESSAGES/gpick.po 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/share/locale/lt/LC_MESSAGES/gpick.po 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,1256 @@ +# +msgid "" +msgstr "" +"Project-Id-Version: gpick 0.2.4\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-01-09 00:06+0200\n" +"PO-Revision-Date: 2013-01-09 00:07+0300\n" +"Last-Translator: Albertas Vyšniauskas \n" +"Language-Team: \n" +"Language: Lithuanian\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.5.4\n" +"X-Poedit-SourceCharset: UTF-8\n" +"Plural-Forms: nplurals=3; plural=((n%10==1) && (n%100!=11) ? 0 : ((n%10>=2) " +"&& (n%100<10) || (n%100>=20)) ? 1 : 2);\n" + +#: source/BlendColors.cpp:114 source/BlendColors.cpp:116 +msgid "blend node" +msgstr "suliejimo mazgas" + +#: source/BlendColors.cpp:119 +msgid "blend" +msgstr "suliejimas" + +#: source/BlendColors.cpp:308 source/BrightnessDarkness.cpp:260 +#: source/ColorMixer.cpp:321 source/ColorPicker.cpp:367 +#: source/GenerateScheme.cpp:444 source/LayoutPreview.cpp:405 +#: source/Variations.cpp:331 source/uiDialogOptions.cpp:215 +#: source/uiDialogOptions.cpp:234 +msgid "_Add to palette" +msgstr "_Įkelti į paletę" + +#: source/BlendColors.cpp:314 source/BrightnessDarkness.cpp:265 +#: source/ColorMixer.cpp:326 source/ColorPicker.cpp:371 +#: source/GenerateScheme.cpp:449 source/LayoutPreview.cpp:410 +#: source/Variations.cpp:336 +msgid "A_dd all to palette" +msgstr "Į_kelti visas į paletę" + +#: source/BlendColors.cpp:320 source/BrightnessDarkness.cpp:271 +#: source/ColorMixer.cpp:333 source/ColorPicker.cpp:377 +#: source/GenerateScheme.cpp:456 source/LayoutPreview.cpp:416 +#: source/Variations.cpp:343 source/uiDialogOptions.cpp:220 +#: source/uiDialogOptions.cpp:239 +msgid "_Copy to clipboard" +msgstr "_Kopijuoti" + +#: source/BlendColors.cpp:374 source/GenerateScheme.cpp:485 +msgid "_Reset" +msgstr "_Atstatyti" + +#: source/BlendColors.cpp:517 +msgid "Start:" +msgstr "Pradžia:" + +#: source/BlendColors.cpp:533 +msgid "Middle:" +msgstr "Vidurys:" + +#: source/BlendColors.cpp:551 +msgid "End:" +msgstr "Pabaiga:" + +#: source/BlendColors.cpp:568 source/GenerateScheme.cpp:875 +#: source/uiDialogGenerate.cpp:237 source/uiDialogMix.cpp:249 +#: source/transformation/ColorVisionDeficiency.cpp:363 +msgid "Type:" +msgstr "Tipas:" + +#: source/BlendColors.cpp:570 source/ColorWheelType.cpp:56 +#: source/uiDialogMix.cpp:251 +msgid "RGB" +msgstr "RGB" + +#: source/BlendColors.cpp:571 source/uiDialogMix.cpp:252 +msgid "HSV" +msgstr "HSV" + +#: source/BlendColors.cpp:572 source/uiDialogMix.cpp:253 +msgid "HSV shortest hue distance" +msgstr "HSV su mažiausiu atspalvio skirumu" + +#: source/BlendColors.cpp:573 source/uiDialogMix.cpp:254 +msgid "LAB" +msgstr "LAB" + +#: source/BlendColors.cpp:582 +msgid "Start steps:" +msgstr "Pradiniai žingsniai:" + +#: source/BlendColors.cpp:590 +msgid "End steps:" +msgstr "Pabaigos žingsniai:" + +#: source/BlendColors.cpp:627 +msgid "Blend colors" +msgstr "Sulieti spalvas" + +#: source/BrightnessDarkness.cpp:86 +msgid "brightness darkness" +msgstr "šviesumas tamsumas" + +#: source/BrightnessDarkness.cpp:287 source/ColorMixer.cpp:373 +#: source/ColorPicker.cpp:387 source/GenerateScheme.cpp:469 +#: source/LayoutPreview.cpp:430 source/Variations.cpp:383 +msgid "_Edit..." +msgstr "_Keisti..." + +#: source/BrightnessDarkness.cpp:292 source/ColorMixer.cpp:378 +#: source/ColorPicker.cpp:391 source/GenerateScheme.cpp:474 +#: source/LayoutPreview.cpp:435 source/Variations.cpp:388 +msgid "_Paste" +msgstr "_Įdėti" + +#: source/BrightnessDarkness.cpp:385 +msgid "Brightness" +msgstr "Šviesumas" + +#: source/BrightnessDarkness.cpp:385 +msgid "Darkness" +msgstr "Tamsumas" + +#: source/BrightnessDarkness.cpp:431 +msgid "Brightness Darkness" +msgstr "Šviesumas, tamsumas" + +#: source/ColorMixer.cpp:66 +msgid "Normal" +msgstr "Paprastas" + +#: source/ColorMixer.cpp:67 +msgid "Multiply" +msgstr "Daugyba" + +#: source/ColorMixer.cpp:68 +msgid "Add" +msgstr "Sudėtis" + +#: source/ColorMixer.cpp:69 +msgid "Difference" +msgstr "Skirtumas" + +#: source/ColorMixer.cpp:70 source/ColorPicker.cpp:1180 +#: source/ColorPicker.cpp:1194 source/ColorSpaceType.cpp:30 +#: source/ColorSpaceType.cpp:37 source/Variations.cpp:66 +msgid "Hue" +msgstr "Atspalvis" + +#: source/ColorMixer.cpp:71 source/ColorPicker.cpp:1180 +#: source/ColorPicker.cpp:1194 source/ColorSpaceType.cpp:31 +#: source/ColorSpaceType.cpp:38 source/Variations.cpp:67 +msgid "Saturation" +msgstr "Įsotinimas" + +#: source/ColorMixer.cpp:72 source/ColorPicker.cpp:1194 +#: source/ColorPicker.cpp:1236 source/ColorPicker.cpp:1250 +#: source/ColorSpaceType.cpp:39 source/ColorSpaceType.cpp:59 +#: source/ColorSpaceType.cpp:66 source/Variations.cpp:68 +msgid "Lightness" +msgstr "Šviesumas" + +#: source/ColorMixer.cpp:114 +msgid "color mixer" +msgstr "spalvų maišyklė" + +#: source/ColorMixer.cpp:234 +msgid "secondary" +msgstr "antrinė" + +#: source/ColorMixer.cpp:238 source/Variations.cpp:229 +#, c-format +msgid "primary %d" +msgstr "pirminė %d" + +#: source/ColorMixer.cpp:244 +#, c-format +msgid "result %d" +msgstr "rezultatas %d" + +#: source/ColorMixer.cpp:704 +msgid "Opacity:" +msgstr "Nepermatomumas:" + +#: source/ColorMixer.cpp:732 +msgid "Color mixer" +msgstr "Spalvų maišyklė" + +#: source/ColorPicker.cpp:424 +msgid "Press Spacebar to sample color under mouse pointer" +msgstr "Paspauskite Tarpą norėdami gauti spalvą esančią po pelės kursoriu" + +#: source/ColorPicker.cpp:699 source/uiConverter.cpp:163 +msgid "Copy" +msgstr "Kopijavimas" + +#: source/ColorPicker.cpp:703 source/uiConverter.cpp:172 +msgid "Paste" +msgstr "Įdėjimas" + +#: source/ColorPicker.cpp:709 source/uiColorInput.cpp:119 +msgid "Edit" +msgstr "Keisti" + +#: source/ColorPicker.cpp:771 source/uiApp.cpp:1012 +#: source/uiDialogSort.cpp:222 +msgid "None" +msgstr "Joks" + +#: source/ColorPicker.cpp:772 +msgid "Linear" +msgstr "Tiesinis" + +#: source/ColorPicker.cpp:773 +msgid "Quadratic" +msgstr "Kvardatinis" + +#: source/ColorPicker.cpp:774 +msgid "Cubic" +msgstr "Kubinis" + +#: source/ColorPicker.cpp:775 +msgid "Exponential" +msgstr "Eksponentinis" + +#: source/ColorPicker.cpp:951 +msgid "Click on swatch area to begin adding colors to palette" +msgstr "Paspauskite mėginio plote norėdami pradėti spalvų rinkimą į paletę" + +#: source/ColorPicker.cpp:1143 +msgid "Settings" +msgstr "Nustatymai" + +#: source/ColorPicker.cpp:1153 +msgid "Oversample:" +msgstr "Mėginio vidurkis" + +#: source/ColorPicker.cpp:1160 +msgid "Falloff:" +msgstr "Nuožulnumas:" + +#: source/ColorPicker.cpp:1167 +msgid "Zoom:" +msgstr "Priartinimas:" + +#: source/ColorPicker.cpp:1180 source/ColorSpaceType.cpp:32 +msgid "Value" +msgstr "Reikšmė" + +#: source/ColorPicker.cpp:1208 source/ColorSpaceType.cpp:44 +msgid "Red" +msgstr "Raudona" + +#: source/ColorPicker.cpp:1208 source/ColorSpaceType.cpp:45 +msgid "Green" +msgstr "Žalia" + +#: source/ColorPicker.cpp:1208 source/ColorSpaceType.cpp:46 +msgid "Blue" +msgstr "Mėlyna" + +#: source/ColorPicker.cpp:1222 source/ColorSpaceType.cpp:51 +msgid "Cyan" +msgstr "Žydra" + +#: source/ColorPicker.cpp:1222 source/ColorSpaceType.cpp:52 +msgid "Magenta" +msgstr "Purpurinė" + +#: source/ColorPicker.cpp:1222 source/ColorSpaceType.cpp:53 +msgid "Yellow" +msgstr "Geltona" + +#: source/ColorPicker.cpp:1222 source/ColorSpaceType.cpp:54 +msgid "Key" +msgstr "Juoda" + +#: source/ColorPicker.cpp:1258 +msgid "Info" +msgstr "Informacija" + +#: source/ColorPicker.cpp:1267 +msgid "Color name:" +msgstr "Spalvos pavadinimas:" + +#: source/ColorPicker.cpp:1280 +msgid "Contrast:" +msgstr "Kontrastas:" + +#: source/ColorPicker.cpp:1285 source/ColorPicker.cpp:1291 +msgid "Sample" +msgstr "Pavyzdys" + +#: source/ColorPicker.cpp:1324 +msgid "Color picker" +msgstr "Spalvų rinkyklė" + +#: source/ColorWheelType.cpp:57 +msgid "RYB v1" +msgstr "RYB v1" + +#: source/ColorWheelType.cpp:58 +msgid "RYB v2" +msgstr "RYB v2" + +#: source/GenerateScheme.cpp:90 +msgid "Complementary" +msgstr "Papildanti" + +#: source/GenerateScheme.cpp:91 +msgid "Analogous" +msgstr "Analogiška" + +#: source/GenerateScheme.cpp:92 +msgid "Triadic" +msgstr "Triada" + +#: source/GenerateScheme.cpp:93 +msgid "Split-Complementary" +msgstr "Perskirtas papildantis" + +#: source/GenerateScheme.cpp:94 +msgid "Rectangle (tetradic)" +msgstr "Keturkampis (tetrada)" + +#: source/GenerateScheme.cpp:95 +msgid "Square" +msgstr "Kvadratas" + +#: source/GenerateScheme.cpp:96 +msgid "Neutral" +msgstr "Neutralus" + +#: source/GenerateScheme.cpp:97 +msgid "Clash" +msgstr "Nedarna" + +#: source/GenerateScheme.cpp:98 +msgid "Five-Tone" +msgstr "Penki tonai" + +#: source/GenerateScheme.cpp:99 +msgid "Six-Tone" +msgstr "Šeši tonai" + +#: source/GenerateScheme.cpp:119 source/uiDialogGenerate.cpp:76 +msgid "scheme" +msgstr "schema" + +#: source/GenerateScheme.cpp:292 +msgid "_Locked" +msgstr "_Užrakinta" + +#: source/GenerateScheme.cpp:299 +msgid "_Reset scheme" +msgstr "_Atstatyti schemą" + +#: source/GenerateScheme.cpp:851 +msgid "Hue:" +msgstr "Atspalvis:" + +#: source/GenerateScheme.cpp:858 source/uiDialogVariations.cpp:171 +msgid "Saturation:" +msgstr "Įsotinimas:" + +#: source/GenerateScheme.cpp:866 source/uiDialogVariations.cpp:156 +msgid "Lightness:" +msgstr "Šviesumas:" + +#: source/GenerateScheme.cpp:885 source/uiDialogGenerate.cpp:246 +msgid "Color wheel:" +msgstr "Spalvų ratas:" + +#: source/GenerateScheme.cpp:919 +msgid "Scheme generation" +msgstr "Schemos generavimas" + +#: source/LayoutPreview.cpp:78 +msgid "layout preview" +msgstr "išdėstymo peržiūra" + +#: source/LayoutPreview.cpp:153 +msgid "Style item" +msgstr "Stiliaus objektas" + +#: source/LayoutPreview.cpp:162 +msgid "CSS selector" +msgstr "CSS selectorius" + +#: source/LayoutPreview.cpp:184 +msgid "Assign CSS selectors" +msgstr "Priskirti CSS selektorius" + +#: source/LayoutPreview.cpp:547 source/LayoutPreview.cpp:595 +#: source/uiApp.cpp:690 source/uiApp.cpp:711 +msgid "File could not be saved" +msgstr "Nepavyko išsaugoti failą" + +#: source/LayoutPreview.cpp:558 source/uiExport.cpp:457 +#: source/uiExport.cpp:523 +msgid "Export" +msgstr "Eksportuoti" + +#: source/LayoutPreview.cpp:572 +msgid "Cascading Style Sheets *.css" +msgstr "Cascading Style Sheets *.css" + +#: source/LayoutPreview.cpp:666 +msgid "Layout:" +msgstr "Išdėstymas:" + +#: source/LayoutPreview.cpp:672 +msgid "Export CSS File" +msgstr "Eksportuoti CSS failą" + +#: source/LayoutPreview.cpp:673 +msgid "Export CSS file" +msgstr "Eksportuoti CSS failą" + +#: source/LayoutPreview.cpp:682 +msgid "_Export CSS File As..." +msgstr "_Eksportuoti CSS failą kaip..." + +#: source/LayoutPreview.cpp:686 +msgid "_Assign CSS Selectors..." +msgstr "_Priskirti CSS selektorius..." + +#: source/LayoutPreview.cpp:759 +msgid "Layout preview" +msgstr "Išdėstymo peržiūra" + +#: source/ToolColorNaming.cpp:25 +msgid "_Empty" +msgstr "_Tuščia" + +#: source/ToolColorNaming.cpp:26 +msgid "_Automatic name" +msgstr "_Automatinis pavadinimas" + +#: source/ToolColorNaming.cpp:27 +msgid "_Tool specific" +msgstr "_Priklausomai nuo įrankio" + +#: source/Variations.cpp:69 +msgid "Lightness (Lab)" +msgstr "Šviesumas (Lab)" + +#: source/Variations.cpp:110 +msgid "variations" +msgstr "pokyčiai" + +#: source/Variations.cpp:225 +msgid "all colors" +msgstr "visos spalvos" + +#: source/Variations.cpp:239 +#, c-format +msgid "result %d line %d" +msgstr "rezultatas %d eilutėje %d" + +#: source/Variations.cpp:717 +#: source/transformation/ColorVisionDeficiency.cpp:386 +msgid "Strength:" +msgstr "Stiprumas:" + +#: source/Variations.cpp:745 source/uiDialogVariations.cpp:142 +msgid "Variations" +msgstr "Pokyčiai" + +#: source/uiAbout.cpp:88 +msgid "About Gpick" +msgstr "Apie Gpick" + +#: source/uiAbout.cpp:121 +msgid "Advanced color picker" +msgstr "Pažangi spalvų rinkyklė" + +#: source/uiAbout.cpp:126 +msgid "Copyrights © 2009-2013, Albertas Vyšniauskas and Gpick development team" +msgstr "" +"Autorinės teisės priklauso © 2009-2013, Albertui Vyšniauskui ir Gpick kūrimo " +"komandai" + +#: source/uiAbout.cpp:141 +msgid "License" +msgstr "Licencija" + +#: source/uiAbout.cpp:142 +msgid "Credits" +msgstr "Padėkos" + +#: source/uiAbout.cpp:143 +msgid "Expat License" +msgstr "Expat licencija" + +#: source/uiAbout.cpp:144 +msgid "Lua License" +msgstr "Lua licencija" + +#: source/uiApp.cpp:354 +msgid "New palette" +msgstr "Nauja paletė" + +#: source/uiApp.cpp:360 +msgid "(Imported)" +msgstr "(Importuotas)" + +#: source/uiApp.cpp:530 source/uiApp.cpp:545 source/uiApp.cpp:563 +#: source/uiApp.cpp:641 +msgid "File could not be opened" +msgstr "Nepavyko atidaryti failo" + +#: source/uiApp.cpp:531 source/uiApp.cpp:546 source/uiApp.cpp:564 +#: source/uiApp.cpp:642 +msgid "Open" +msgstr "Atidaryti" + +#: source/uiApp.cpp:576 source/uiExport.cpp:473 source/uiExport.cpp:587 +msgid "Gpick Palette (*.gpa)" +msgstr "Gpick paletė (*.gpa)" + +#: source/uiApp.cpp:577 source/uiExport.cpp:474 source/uiExport.cpp:588 +msgid "GIMP/Inkscape Palette (*.gpl)" +msgstr "GIMP/Inkscape paletė (*.gpl)" + +#: source/uiApp.cpp:578 source/uiExport.cpp:476 source/uiExport.cpp:589 +msgid "Adobe Swatch Exchange (*.ase)" +msgstr "Adobe Swatch Exchange (*.ase)" + +#: source/uiApp.cpp:584 source/uiExport.cpp:598 +#: source/tools/PaletteFromImage.cpp:548 +msgid "All files" +msgstr "Visi failai" + +#: source/uiApp.cpp:589 source/uiExport.cpp:607 +msgid "All supported formats" +msgstr "Visi palaikomi formatai" + +#: source/uiApp.cpp:610 +msgid "Open File" +msgstr "Atidaryti failą" + +#: source/uiApp.cpp:659 source/uiApp.cpp:691 +msgid "Save As" +msgstr "Išsaugoti kaip" + +#: source/uiApp.cpp:712 +msgid "Save" +msgstr "Išsaugoti" + +#: source/uiApp.cpp:771 +msgid "Open Last File" +msgstr "Atidaryti vėliausią failą" + +#: source/uiApp.cpp:916 +msgid "Recent _files" +msgstr "Paskutiniai _failai" + +#: source/uiApp.cpp:946 +msgid "Ex_port..." +msgstr "Eksportuoti..." + +#: source/uiApp.cpp:954 +msgid "Expo_rt Selected..." +msgstr "Eksportuoti _pažymėtas..." + +#: source/uiApp.cpp:962 +msgid "_Import..." +msgstr "_Importuoti..." + +#: source/uiApp.cpp:977 +msgid "_File" +msgstr "_Failas" + +#: source/uiApp.cpp:985 +msgid "Edit _Converters..." +msgstr "Keisti _keitėjus..." + +#: source/uiApp.cpp:989 +msgid "Display _Filters..." +msgstr "Rodymo _Filtrai..." + +#: source/uiApp.cpp:1001 +msgid "_Edit" +msgstr "_Keisti" + +#: source/uiApp.cpp:1037 +msgid "_Secondary View" +msgstr "_Antrinis vaizdas" + +#: source/uiApp.cpp:1043 +msgid "Palette" +msgstr "Paletė" + +#: source/uiApp.cpp:1049 +msgid "_View" +msgstr "_Rodymas" + +#: source/uiApp.cpp:1055 +msgid "Palette From _Image..." +msgstr "Paletė iš paveikslėlio..." + +#: source/uiApp.cpp:1063 +msgid "_Tools" +msgstr "_Įrankiai" + +#: source/uiApp.cpp:1078 +msgid "_Help" +msgstr "_Pagalba" + +#: source/uiApp.cpp:1386 +msgid "_Copy to Clipboard" +msgstr "_Kopijuoti" + +#: source/uiApp.cpp:1402 +msgid "_Mix Colors..." +msgstr "_Maišyti spalvas..." + +#: source/uiApp.cpp:1407 +msgid "_Variations..." +msgstr "_Pokyčiai..." + +#: source/uiApp.cpp:1412 +msgid "_Generate..." +msgstr "_Generuoti..." + +#: source/uiApp.cpp:1421 +msgid "C_lear names" +msgstr "I_švalyti pavadinimus" + +#: source/uiApp.cpp:1427 +msgid "Autona_me" +msgstr "Auto. pavadinimai" + +#: source/uiApp.cpp:1433 +msgid "Auto_number..." +msgstr "Auto. _numeracija..." + +#: source/uiApp.cpp:1441 +msgid "R_everse" +msgstr "_Atvirkščiai" + +#: source/uiApp.cpp:1447 +msgid "Group and _sort..." +msgstr "_Grupavimas ir rūšiavimas..." + +#: source/uiApp.cpp:1455 +msgid "_Remove" +msgstr "_Pašalinti" + +#: source/uiApp.cpp:1461 +msgid "Remove _All" +msgstr "Pašalinti _visas" + +#: source/uiApp.cpp:1869 +msgid "Color pic_ker" +msgstr "Spalvų rin_kyklė" + +#: source/uiApp.cpp:1878 +msgid "Scheme _generation" +msgstr "Schemos _generavimas" + +#: source/uiApp.cpp:1897 +msgid "Lay_out preview" +msgstr "Maket_o peržiūra" + +#: source/uiApp.cpp:1947 +msgid "Pick colors (Ctrl+P)" +msgstr "Rinkti spalvas (Vald+P)" + +#: source/uiApp.cpp:1956 +msgid "" +"File is currently in a non-native format, possible loss of precision and/or " +"metadata." +msgstr "" +"Šiuo metu failas išsaugotas ne pagrindiniu formatu, galimas tinkslumo ir/ar " +"metaduomenų praradimas." + +#: source/uiColorInput.cpp:45 +msgid "Edit color" +msgstr "Keisti spalvą" + +#: source/uiColorInput.cpp:69 +msgid "Color:" +msgstr "Spalva:" + +#: source/uiConverter.cpp:56 +msgid "Test color" +msgstr "Testavimo spalva" + +#: source/uiConverter.cpp:74 +msgid "error" +msgstr "klaida" + +#: source/uiConverter.cpp:145 +msgid "Function name" +msgstr "Funkcijos pavadinimas" + +#: source/uiConverter.cpp:154 +msgid "Example" +msgstr "Pavyzdys" + +#: source/uiConverter.cpp:196 +msgid "Converters" +msgstr "Keitėjai" + +#: source/uiConverter.cpp:224 +msgid "Displays:" +msgstr "Rodymas:" + +#: source/uiConverter.cpp:230 +msgid "Color list:" +msgstr "Spalvų sąrašas::" + +#: source/uiDialogAutonumber.cpp:108 +msgid "Autonumber colors" +msgstr "Sunumeruoti spalvas" + +#: source/uiDialogAutonumber.cpp:122 +msgid "Name:" +msgstr "Pavadinimas:" + +#: source/uiDialogAutonumber.cpp:132 +msgid "Decimal places:" +msgstr "Skaitmenys:" + +#: source/uiDialogAutonumber.cpp:139 +msgid "Starting number:" +msgstr "Pradėti nuo:" + +#: source/uiDialogAutonumber.cpp:146 +msgid "_Decreasing" +msgstr "Mažėjantis" + +#: source/uiDialogAutonumber.cpp:152 +msgid "_Append" +msgstr "_Pridėti" + +#: source/uiDialogAutonumber.cpp:158 +msgid "Sample:" +msgstr "Pavyzdys:" + +#: source/uiDialogGenerate.cpp:216 +msgid "Generate colors" +msgstr "Generuoti spalvas" + +#: source/uiDialogGenerate.cpp:230 source/tools/PaletteFromImage.cpp:599 +msgid "Colors:" +msgstr "Spalvos:" + +#: source/uiDialogGenerate.cpp:257 +msgid "Chaos:" +msgstr "Chaosas:" + +#: source/uiDialogGenerate.cpp:263 +msgid "Seed:" +msgstr "Sėkla:" + +#: source/uiDialogGenerate.cpp:271 +msgid "_Reverse" +msgstr "_Atvirkščiai" + +#: source/uiDialogMix.cpp:76 source/uiDialogMix.cpp:78 +msgid "mix node" +msgstr "maišymo mazgas" + +#: source/uiDialogMix.cpp:81 +msgid "mix" +msgstr "maišymas" + +#: source/uiDialogMix.cpp:235 +msgid "Mix colors" +msgstr "Maišyti spalvas" + +#: source/uiDialogMix.cpp:262 source/uiDialogVariations.cpp:186 +msgid "Steps:" +msgstr "Žingsniai:" + +#: source/uiDialogMix.cpp:270 +msgid "_Include Endpoints" +msgstr "Įtraukti _galinius taškus" + +#: source/uiDialogOptions.cpp:117 source/tools/PaletteFromImage.cpp:589 +msgid "Options" +msgstr "Nustatymai" + +#: source/uiDialogOptions.cpp:134 +msgid "System" +msgstr "Sistema" + +#: source/uiDialogOptions.cpp:143 +msgid "_Single instance" +msgstr "_Vienas egzempliorius" + +#: source/uiDialogOptions.cpp:148 +msgid "Save/_Restore palette" +msgstr "I6saugoti/_Atstatyti paletę" + +#: source/uiDialogOptions.cpp:154 +msgid "System tray" +msgstr "Sisteminis dėklas" + +#: source/uiDialogOptions.cpp:162 +msgid "_Minimize to system tray" +msgstr "_Nuleisti į sisteminį dėklą" + +#: source/uiDialogOptions.cpp:167 +msgid "_Close to system tray" +msgstr "_Uždaryti į sisteminį dėklą" + +#: source/uiDialogOptions.cpp:172 +msgid "_Start in system tray" +msgstr "_Paleisti sisteminiame dėkle" + +#: source/uiDialogOptions.cpp:178 +msgid "_Main" +msgstr "_Pagrindiniai" + +#: source/uiDialogOptions.cpp:184 +msgid "Display" +msgstr "Rodymas" + +#: source/uiDialogOptions.cpp:193 +msgid "_Refresh rate:" +msgstr "_Atnaujinimo dažnis:" + +#: source/uiDialogOptions.cpp:201 +msgid "_Magnified area size:" +msgstr "_Padidinto ploto dydis:" + +#: source/uiDialogOptions.cpp:207 +msgid "Floating picker click behaviour" +msgstr "Slankaus rinkėjo elgsena" + +#: source/uiDialogOptions.cpp:226 +msgid "'Spacebar' button behaviour" +msgstr "'Tarpo' mygtuko elgsena" + +#: source/uiDialogOptions.cpp:244 +msgid "_Rotate swatch" +msgstr "_Pasukti mėginį" + +#: source/uiDialogOptions.cpp:251 +msgid "Enabled color spaces" +msgstr "Aktyvios spalvų erdvės" + +#: source/uiDialogOptions.cpp:266 +msgid "Lab settings" +msgstr "Lab nustatymai" + +#: source/uiDialogOptions.cpp:278 +msgid "_Illuminant:" +msgstr "_Apšvietimas:" + +#: source/uiDialogOptions.cpp:302 +msgid "_Observer:" +msgstr "_Stebėtojas:" + +#: source/uiDialogOptions.cpp:321 +msgid "Other settings" +msgstr "Kiti nustatymai" + +#: source/uiDialogOptions.cpp:330 +msgid "_Mask out of gamut colors" +msgstr "Maskuoti spalvas esančias už gamos ribų" + +#: source/uiDialogOptions.cpp:336 +msgid "_Picker" +msgstr "_Rinkėjas" + +#: source/uiDialogOptions.cpp:341 +msgid "Color name generation" +msgstr "Spalvų pavadinimų generavimas" + +#: source/uiDialogOptions.cpp:350 +msgid "_Imprecision postfix" +msgstr "_Netikslumo ženklas" + +#: source/uiDialogOptions.cpp:356 +msgid "Tool color naming" +msgstr "Įrankių spalvų pavadinimai" + +#: source/uiDialogOptions.cpp:381 +msgid "_Color names" +msgstr "_Spalvų pavadinimai" + +#: source/uiDialogSort.cpp:135 source/uiDialogSort.cpp:223 +msgid "RGB Red" +msgstr "RGB Raudona" + +#: source/uiDialogSort.cpp:136 source/uiDialogSort.cpp:224 +msgid "RGB Green" +msgstr "RGB Žalia" + +#: source/uiDialogSort.cpp:137 source/uiDialogSort.cpp:225 +msgid "RGB Blue" +msgstr "RGB Mėlyna" + +#: source/uiDialogSort.cpp:138 source/uiDialogSort.cpp:226 +msgid "RGB Grayscale" +msgstr "RGB Pustonis" + +#: source/uiDialogSort.cpp:139 source/uiDialogSort.cpp:227 +msgid "HSL Hue" +msgstr "HSL Atspalvis" + +#: source/uiDialogSort.cpp:140 source/uiDialogSort.cpp:228 +msgid "HSL Saturation" +msgstr "HSL Įsotinimas" + +#: source/uiDialogSort.cpp:141 source/uiDialogSort.cpp:229 +msgid "HSL Lightness" +msgstr "HSL Šviesumas" + +#: source/uiDialogSort.cpp:142 source/uiDialogSort.cpp:230 +msgid "Lab Lightness" +msgstr "Lab Šviesumas" + +#: source/uiDialogSort.cpp:143 source/uiDialogSort.cpp:231 +msgid "Lab A" +msgstr "Lab A" + +#: source/uiDialogSort.cpp:144 source/uiDialogSort.cpp:232 +msgid "Lab B" +msgstr "Lab B" + +#: source/uiDialogSort.cpp:145 source/uiDialogSort.cpp:233 +msgid "LCh Lightness" +msgstr "LCh Šviesumas" + +#: source/uiDialogSort.cpp:146 source/uiDialogSort.cpp:234 +msgid "LCh Chroma" +msgstr "LCh Chroma" + +#: source/uiDialogSort.cpp:147 source/uiDialogSort.cpp:235 +msgid "LCh Hue" +msgstr "LCh Atspalvis" + +#: source/uiDialogSort.cpp:556 +msgid "Group and sort" +msgstr "Grupuoti ir rūšiuoti" + +#: source/uiDialogSort.cpp:564 +msgid "Group type:" +msgstr "Grupavimo tipas:" + +#: source/uiDialogSort.cpp:574 +msgid "Grouping sensitivity:" +msgstr "Grupavimo jautrumas:" + +#: source/uiDialogSort.cpp:581 +msgid "Maximum number of groups:" +msgstr "Maksimalus grupių skaičius:" + +#: source/uiDialogSort.cpp:588 +msgid "Sort type:" +msgstr "Rūšiavimo tipas:" + +#: source/uiDialogSort.cpp:598 +msgid "_Reverse group order" +msgstr "_Atvirkščia grupių tvarka" + +#: source/uiDialogSort.cpp:604 +msgid "_Reverse order inside groups" +msgstr "_Atvirkščia tvarka grupėse" + +#: source/uiDialogVariations.cpp:60 +msgid "variation" +msgstr "pokyčiai" + +#: source/uiDialogVariations.cpp:194 +msgid "_Use multiplication" +msgstr "_Naudoti daugybą" + +#: source/uiExport.cpp:475 +msgid "Alias/WaveFront Material (*.mtl)" +msgstr "Alias/WaveFront Material (*.mtl)" + +#: source/uiExport.cpp:477 +msgid "Text file (*.txt)" +msgstr "Tekstinis failas (*.txt)" + +#: source/uiExport.cpp:522 +msgid "File could not be exported" +msgstr "Nepavyko eksportuoti failą" + +#: source/uiExport.cpp:573 source/uiExport.cpp:654 source/uiExport.cpp:666 +msgid "Import" +msgstr "Importuoti" + +#: source/uiExport.cpp:653 +msgid "File format is not supported" +msgstr "Failo formatas nėra palaikomas" + +#: source/uiExport.cpp:665 +msgid "File could not be imported" +msgstr "Nepavyko importuoti failą" + +#: source/uiListPalette.cpp:158 source/uiListPalette.cpp:160 +#, c-format +msgid "%d color" +msgid_plural "%d colors" +msgstr[0] "%d spalva" +msgstr[1] "%d spalvos" +msgstr[2] "%d spalvų" + +#: source/uiListPalette.cpp:166 +msgid "selected" +msgstr "pasirinkta" + +#: source/uiListPalette.cpp:172 source/uiListPalette.cpp:174 +#, c-format +msgid "Total %d color" +msgid_plural "Total %d colors" +msgstr[0] "Viso %d spalva" +msgstr[1] "Viso %d spalvos" +msgstr[2] "Viso %d spalvų" + +#: source/uiListPalette.cpp:353 +msgid "Preview" +msgstr "Peržiūra" + +#: source/uiListPalette.cpp:708 source/uiListPalette.cpp:717 +msgid "Color" +msgstr "Spalva" + +#: source/uiListPalette.cpp:726 source/uiTransformations.cpp:183 +msgid "Name" +msgstr "Pavadinimas" + +#: source/uiStatusIcon.cpp:67 +msgid "_Show Main Window" +msgstr "_Rodyti pagrindinį langą" + +#: source/uiStatusIcon.cpp:74 +msgid "_Quit" +msgstr "_Išeiti" + +#: source/uiTransformations.cpp:245 +msgid "Display filters" +msgstr "Rodymo filtrai" + +#: source/uiTransformations.cpp:259 +msgid "_Enabled" +msgstr "_Įjungta" + +#: source/tools/PaletteFromImage.cpp:514 +msgid "Palette from image" +msgstr "Paletė iš paveikslėlio" + +#: source/tools/PaletteFromImage.cpp:527 +msgid "Image" +msgstr "Paveikslėlis" + +#: source/tools/PaletteFromImage.cpp:536 +msgid "Image file" +msgstr "Paveikslėlio failas" + +#: source/tools/PaletteFromImage.cpp:556 +msgid "All images" +msgstr "Visi paveikslėliai" + +#: source/transformation/ColorVisionDeficiency.cpp:41 +msgid "Color vision deficiency" +msgstr "Spalvų matymo defektai" + +#: source/transformation/ColorVisionDeficiency.cpp:330 +msgid "Protanomaly" +msgstr "Protanomalija" + +#: source/transformation/ColorVisionDeficiency.cpp:331 +msgid "Deuteranomaly" +msgstr "Deuteranomalija" + +#: source/transformation/ColorVisionDeficiency.cpp:332 +msgid "Tritanomaly" +msgstr "Tritanomalija" + +#: source/transformation/ColorVisionDeficiency.cpp:333 +msgid "Protanopia" +msgstr "Protanopija" + +#: source/transformation/ColorVisionDeficiency.cpp:334 +msgid "Deuteranopia" +msgstr "Deuteranopija" + +#: source/transformation/ColorVisionDeficiency.cpp:335 +msgid "Tritanopia" +msgstr "Tritanopija" + +#: source/transformation/ColorVisionDeficiency.cpp:422 +msgid "Altered spectral sensitivity of red receptors" +msgstr "Pakitęs raudonų receptorių spektro jautrumas" + +#: source/transformation/ColorVisionDeficiency.cpp:423 +msgid "Altered spectral sensitivity of green receptors" +msgstr "Pakitęs žalių receptorių spektro jautrumas" + +#: source/transformation/ColorVisionDeficiency.cpp:424 +msgid "Altered spectral sensitivity of blue receptors" +msgstr "Pakitęs mėlynų receptorių spektro jautrumas" + +#: source/transformation/ColorVisionDeficiency.cpp:425 +msgid "Absence of red receptors" +msgstr "Raudonų receptorių nebūvimas" + +#: source/transformation/ColorVisionDeficiency.cpp:426 +msgid "Absence of green receptors" +msgstr "Žalių receptorių nebūvimas" + +#: source/transformation/ColorVisionDeficiency.cpp:427 +msgid "Absence of blue receptors" +msgstr "Mėlynų receptorių nebūvimas" + +#: source/transformation/GammaModification.cpp:38 +msgid "Gamma modification" +msgstr "Gamos pakeitimas" + +#: source/transformation/GammaModification.cpp:88 +#: source/transformation/Quantization.cpp:96 +msgid "Value:" +msgstr "Reikšmė:" + +#: source/transformation/Quantization.cpp:40 +msgid "Quantization" +msgstr "Kvantavimas" + +#: source/transformation/Quantization.cpp:101 +msgid "Clip top-end" +msgstr "Apkirpti viršutinę dalį" + +#: share/gpick/init.lua:173 +msgid "Web: hex code" +msgstr "Tinklas: šešioliktainis kodas" + +#: share/gpick/init.lua:178 +msgid "Web: hex code (3 digits)" +msgstr "Tinklas: šešioliktainis kodas (3 skaitmenys)" + +#: share/gpick/init.lua:183 +msgid "Web: hex code (no hash symbol)" +msgstr "Tinklas: šešioliktainis kodas (be grotelių simbolio)" + +#: share/gpick/init.lua:188 +msgid "CSS: hue saturation lightness" +msgstr "CSS: atspalvis įsotinimas šviesumas" + +#: share/gpick/init.lua:193 +msgid "CSS: red green blue" +msgstr "CSS: raudona žalia mėlyna" + +#: share/gpick/layouts.lua:15 +msgid "Homepage" +msgstr "Namų puslapis" + +#: share/gpick/layouts.lua:15 +msgid "About us" +msgstr "Apie mus" + +#: share/gpick/layouts.lua:15 +msgid "Links to us" +msgstr "Nuorodos" + +#: share/gpick/layouts.lua:15 +msgid "Privacy" +msgstr "Privatumas" + +#: share/gpick/layouts.lua:15 +msgid "Terms" +msgstr "Sąlygos" + +#: share/gpick/layouts.lua:15 +msgid "Contact us" +msgstr "Kontaktai" + +#: share/gpick/layouts.lua:15 +msgid "RSS" +msgstr "RSS" + +#: share/gpick/layouts.lua:30 +msgid "The quick brown fox jumps over the lazy dog" +msgstr "Greita ruda lapė šoka per tingų šunį" + +#: share/gpick/layouts.lua:46 +msgid "Webpage" +msgstr "Puslapis" + +#: share/gpick/layouts.lua:51 share/gpick/layouts.lua:73 +msgid "Header" +msgstr "Antraštė" + +#: share/gpick/layouts.lua:52 +msgid "Header text" +msgstr "Antraštės tekstas" + +#: share/gpick/layouts.lua:54 +msgid "Content" +msgstr "Turinys" + +#: share/gpick/layouts.lua:55 +msgid "Content text" +msgstr "Turinio tekstas" + +#: share/gpick/layouts.lua:57 +msgid "Sidebar" +msgstr "Šonas" + +#: share/gpick/layouts.lua:59 share/gpick/layouts.lua:87 +msgid "Button" +msgstr "Mygtukas" + +#: share/gpick/layouts.lua:60 share/gpick/layouts.lua:88 +msgid "Button (hover)" +msgstr "Mygtukas (pažymėtas)" + +#: share/gpick/layouts.lua:61 share/gpick/layouts.lua:89 +msgid "Button text" +msgstr "Mygtuko tekstas" + +#: share/gpick/layouts.lua:62 share/gpick/layouts.lua:90 +msgid "Button text (hover)" +msgstr "Mytuko tekstas (pažymėtas)" + +#: share/gpick/layouts.lua:64 +msgid "Footer" +msgstr "Paraštė" + +#: share/gpick/layouts.lua:82 share/gpick/layouts.lua:86 +msgid "Menu" +msgstr "Meniu" + +#: share/gpick/layouts.lua:106 +msgid "Brightness-Darkness" +msgstr "Šviesumas-Tamsumas" + +#: share/gpick/layouts.lua:110 +msgid "main" +msgstr "pagrindinis" + +#: share/gpick/layouts.lua:144 +msgid "Grid (4x3)" +msgstr "Tinklas (4x3)" + +#: share/gpick/layouts.lua:153 share/gpick/layouts.lua:159 +#: share/gpick/layouts.lua:180 share/gpick/layouts.lua:186 +msgid "Item" +msgstr "Lauk." + +#: share/gpick/layouts.lua:154 share/gpick/layouts.lua:181 +msgid "Item text" +msgstr "Laukelio tekstas" + +#: share/gpick/layouts.lua:171 +msgid "Grid (5x4)" +msgstr "Tinklas (5x4)" diff -Nru gpick-0.2.4/share/locale/ru/LC_MESSAGES/gpick.po gpick-0.2.5/share/locale/ru/LC_MESSAGES/gpick.po --- gpick-0.2.4/share/locale/ru/LC_MESSAGES/gpick.po 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/share/locale/ru/LC_MESSAGES/gpick.po 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,1356 @@ +# Translation of Gpick into Russian +# Александр Прокудин , 2011. +# +msgid "" +msgstr "" +"Project-Id-Version: gpick 0.2.5\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-01-10 04:26+0400\n" +"PO-Revision-Date: 2013-01-10 14:18+0300\n" +"Last-Translator: Александр Прокудин \n" +"Language-Team: Russian \n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); 10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"X-Poedit-Language: Russian\n" +"X-Poedit-Country: RUSSIAN FEDERATION\n" + +#: source/BlendColors.cpp:114 +#: source/BlendColors.cpp:116 +msgid "blend node" +msgstr "основной" + +#: source/BlendColors.cpp:119 +msgid "blend" +msgstr "переход" + +#: source/BlendColors.cpp:308 +#: source/BrightnessDarkness.cpp:260 +#: source/ColorMixer.cpp:321 +#: source/ColorPicker.cpp:367 +#: source/GenerateScheme.cpp:444 +#: source/LayoutPreview.cpp:405 +#: source/Variations.cpp:331 +#: source/uiDialogOptions.cpp:215 +#: source/uiDialogOptions.cpp:234 +msgid "_Add to palette" +msgstr "_Добавить в палитру" + +#: source/BlendColors.cpp:314 +#: source/BrightnessDarkness.cpp:265 +#: source/ColorMixer.cpp:326 +#: source/ColorPicker.cpp:371 +#: source/GenerateScheme.cpp:449 +#: source/LayoutPreview.cpp:410 +#: source/Variations.cpp:336 +msgid "A_dd all to palette" +msgstr "Доб_авить все в палитру" + +#: source/BlendColors.cpp:320 +#: source/BrightnessDarkness.cpp:271 +#: source/ColorMixer.cpp:333 +#: source/ColorPicker.cpp:377 +#: source/GenerateScheme.cpp:456 +#: source/LayoutPreview.cpp:416 +#: source/Variations.cpp:343 +#: source/uiDialogOptions.cpp:220 +#: source/uiDialogOptions.cpp:239 +msgid "_Copy to clipboard" +msgstr "С_копировать в буфер обмена" + +#: source/BlendColors.cpp:374 +#: source/GenerateScheme.cpp:485 +msgid "_Reset" +msgstr "С_бросить" + +#: source/BlendColors.cpp:517 +msgid "Start:" +msgstr "Начало:" + +#: source/BlendColors.cpp:533 +msgid "Middle:" +msgstr "Середина:" + +#: source/BlendColors.cpp:551 +msgid "End:" +msgstr "Конец:" + +#: source/BlendColors.cpp:568 +#: source/GenerateScheme.cpp:875 +#: source/uiDialogGenerate.cpp:237 +#: source/uiDialogMix.cpp:249 +#: source/transformation/ColorVisionDeficiency.cpp:363 +msgid "Type:" +msgstr "Тип:" + +#: source/BlendColors.cpp:570 +#: source/ColorWheelType.cpp:56 +#: source/uiDialogMix.cpp:251 +msgid "RGB" +msgstr "RGB" + +#: source/BlendColors.cpp:571 +#: source/uiDialogMix.cpp:252 +msgid "HSV" +msgstr "HSV" + +#: source/BlendColors.cpp:572 +#: source/uiDialogMix.cpp:253 +msgid "HSV shortest hue distance" +msgstr "HSV, кратчайшее расстояние" + +#: source/BlendColors.cpp:573 +#: source/uiDialogMix.cpp:254 +msgid "LAB" +msgstr "LAB" + +#: source/BlendColors.cpp:582 +msgid "Start steps:" +msgstr "Шагов в начале:" + +#: source/BlendColors.cpp:590 +msgid "End steps:" +msgstr "Шагов в конце:" + +#: source/BlendColors.cpp:627 +msgid "Blend colors" +msgstr "Переход между цветами" + +#: source/BrightnessDarkness.cpp:86 +msgid "brightness darkness" +msgstr "Яркость-Темнота" + +#: source/BrightnessDarkness.cpp:287 +#: source/ColorMixer.cpp:373 +#: source/ColorPicker.cpp:387 +#: source/GenerateScheme.cpp:469 +#: source/LayoutPreview.cpp:430 +#: source/Variations.cpp:383 +msgid "_Edit..." +msgstr "_Изменить…" + +#: source/BrightnessDarkness.cpp:292 +#: source/ColorMixer.cpp:378 +#: source/ColorPicker.cpp:391 +#: source/GenerateScheme.cpp:474 +#: source/LayoutPreview.cpp:435 +#: source/Variations.cpp:388 +msgid "_Paste" +msgstr "_Вставить" + +#: source/BrightnessDarkness.cpp:385 +msgid "Brightness" +msgstr "Яркость" + +#: source/BrightnessDarkness.cpp:385 +msgid "Darkness" +msgstr "Темнота" + +#: source/BrightnessDarkness.cpp:431 +msgid "Brightness Darkness" +msgstr "Яркость-Темнота" + +#: source/ColorMixer.cpp:66 +msgid "Normal" +msgstr "Нормальный" + +#: source/ColorMixer.cpp:67 +msgid "Multiply" +msgstr "Умножение" + +#: source/ColorMixer.cpp:68 +msgid "Add" +msgstr "Добавление" + +#: source/ColorMixer.cpp:69 +msgid "Difference" +msgstr "Разница" + +#: source/ColorMixer.cpp:70 +#: source/ColorPicker.cpp:1180 +#: source/ColorPicker.cpp:1194 +#: source/ColorSpaceType.cpp:30 +#: source/ColorSpaceType.cpp:37 +#: source/Variations.cpp:66 +msgid "Hue" +msgstr "Тон" + +#: source/ColorMixer.cpp:71 +#: source/ColorPicker.cpp:1180 +#: source/ColorPicker.cpp:1194 +#: source/ColorSpaceType.cpp:31 +#: source/ColorSpaceType.cpp:38 +#: source/Variations.cpp:67 +msgid "Saturation" +msgstr "Насыщенность" + +#: source/ColorMixer.cpp:72 +#: source/ColorPicker.cpp:1194 +#: source/ColorPicker.cpp:1236 +#: source/ColorPicker.cpp:1250 +#: source/ColorSpaceType.cpp:39 +#: source/ColorSpaceType.cpp:59 +#: source/ColorSpaceType.cpp:66 +#: source/Variations.cpp:68 +msgid "Lightness" +msgstr "Светлота" + +#: source/ColorMixer.cpp:114 +msgid "color mixer" +msgstr "Микшер цветов" + +#: source/ColorMixer.cpp:234 +msgid "secondary" +msgstr "первичный" + +#: source/ColorMixer.cpp:238 +#: source/Variations.cpp:229 +#, c-format +msgid "primary %d" +msgstr "вторичный %d" + +#: source/ColorMixer.cpp:244 +#, c-format +msgid "result %d" +msgstr "результат %d" + +#: source/ColorMixer.cpp:704 +msgid "Opacity:" +msgstr "Непрозрачность:" + +#: source/ColorMixer.cpp:732 +msgid "Color mixer" +msgstr "Микшер цветов" + +#: source/ColorPicker.cpp:424 +msgid "Press Spacebar to sample color under mouse pointer" +msgstr "Нажмите пробел для добавления цвета под указателем" + +#: source/ColorPicker.cpp:699 +#: source/uiConverter.cpp:163 +msgid "Copy" +msgstr "Копирование" + +#: source/ColorPicker.cpp:703 +#: source/uiConverter.cpp:172 +msgid "Paste" +msgstr "Вставка" + +#: source/ColorPicker.cpp:709 +#: source/uiColorInput.cpp:119 +msgid "Edit" +msgstr "Изменить" + +#: source/ColorPicker.cpp:771 +#: source/uiApp.cpp:1012 +#: source/uiDialogSort.cpp:222 +msgid "None" +msgstr "Нет" + +#: source/ColorPicker.cpp:772 +msgid "Linear" +msgstr "Линейное" + +#: source/ColorPicker.cpp:773 +msgid "Quadratic" +msgstr "Квадратичное" + +#: source/ColorPicker.cpp:774 +msgid "Cubic" +msgstr "Кубическое" + +#: source/ColorPicker.cpp:775 +msgid "Exponential" +msgstr "Экспоненциальное" + +#: source/ColorPicker.cpp:951 +msgid "Click on swatch area to begin adding colors to palette" +msgstr "" + +#: source/ColorPicker.cpp:1143 +msgid "Settings" +msgstr "Параметры" + +#: source/ColorPicker.cpp:1153 +msgid "Oversample:" +msgstr "Оверсэмплинг:" + +#: source/ColorPicker.cpp:1160 +msgid "Falloff:" +msgstr "Спадание:" + +#: source/ColorPicker.cpp:1167 +msgid "Zoom:" +msgstr "Масштаб:" + +#: source/ColorPicker.cpp:1180 +#: source/ColorSpaceType.cpp:32 +msgid "Value" +msgstr "Значение" + +#: source/ColorPicker.cpp:1208 +#: source/ColorSpaceType.cpp:44 +msgid "Red" +msgstr "Красный" + +#: source/ColorPicker.cpp:1208 +#: source/ColorSpaceType.cpp:45 +msgid "Green" +msgstr "Зелёный" + +#: source/ColorPicker.cpp:1208 +#: source/ColorSpaceType.cpp:46 +msgid "Blue" +msgstr "Синий" + +#: source/ColorPicker.cpp:1222 +#: source/ColorSpaceType.cpp:51 +msgid "Cyan" +msgstr "Cyan" + +#: source/ColorPicker.cpp:1222 +#: source/ColorSpaceType.cpp:52 +msgid "Magenta" +msgstr "Magenta" + +#: source/ColorPicker.cpp:1222 +#: source/ColorSpaceType.cpp:53 +msgid "Yellow" +msgstr "Yellow" + +#: source/ColorPicker.cpp:1222 +#: source/ColorSpaceType.cpp:54 +msgid "Key" +msgstr "Key" + +#: source/ColorPicker.cpp:1258 +msgid "Info" +msgstr "Информация" + +#: source/ColorPicker.cpp:1267 +msgid "Color name:" +msgstr "Название цвета:" + +#: source/ColorPicker.cpp:1280 +msgid "Contrast:" +msgstr "Контраст:" + +#: source/ColorPicker.cpp:1285 +#: source/ColorPicker.cpp:1291 +msgid "Sample" +msgstr "Образец" + +#: source/ColorPicker.cpp:1324 +msgid "Color picker" +msgstr "Пипетка" + +#: source/ColorWheelType.cpp:57 +msgid "RYB v1" +msgstr "RYB v1" + +#: source/ColorWheelType.cpp:58 +msgid "RYB v2" +msgstr "RYB v2" + +#: source/GenerateScheme.cpp:90 +msgid "Complementary" +msgstr "Противоположные" + +#: source/GenerateScheme.cpp:91 +msgid "Analogous" +msgstr "Аналоговая" + +#: source/GenerateScheme.cpp:92 +msgid "Triadic" +msgstr "Триады" + +#: source/GenerateScheme.cpp:93 +msgid "Split-Complementary" +msgstr "Разделённые противоположные" + +#: source/GenerateScheme.cpp:94 +msgid "Rectangle (tetradic)" +msgstr "Прямоугольник (тетрады)" + +#: source/GenerateScheme.cpp:95 +msgid "Square" +msgstr "Квадрат" + +#: source/GenerateScheme.cpp:96 +msgid "Neutral" +msgstr "Нейтральная" + +#: source/GenerateScheme.cpp:97 +msgid "Clash" +msgstr "Конфликт" + +#: source/GenerateScheme.cpp:98 +msgid "Five-Tone" +msgstr "Пять тонов" + +#: source/GenerateScheme.cpp:99 +msgid "Six-Tone" +msgstr "Шесть тонов" + +#: source/GenerateScheme.cpp:119 +#: source/uiDialogGenerate.cpp:76 +msgid "scheme" +msgstr "Схема" + +#: source/GenerateScheme.cpp:292 +msgid "_Locked" +msgstr "_Блокировать насыщенность и светлоту" + +#: source/GenerateScheme.cpp:299 +msgid "_Reset scheme" +msgstr "_Сбросить изменения" + +#: source/GenerateScheme.cpp:851 +msgid "Hue:" +msgstr "Тон:" + +#: source/GenerateScheme.cpp:858 +#: source/uiDialogVariations.cpp:171 +msgid "Saturation:" +msgstr "Насыщенность:" + +#: source/GenerateScheme.cpp:866 +#: source/uiDialogVariations.cpp:156 +msgid "Lightness:" +msgstr "Светлота:" + +#: source/GenerateScheme.cpp:885 +#: source/uiDialogGenerate.cpp:246 +msgid "Color wheel:" +msgstr "Цветовой круг:" + +#: source/GenerateScheme.cpp:919 +msgid "Scheme generation" +msgstr "Создание цветовой схемы" + +#: source/LayoutPreview.cpp:78 +msgid "layout preview" +msgstr "Просмотр макета" + +#: source/LayoutPreview.cpp:153 +msgid "Style item" +msgstr "Объект стиля" + +#: source/LayoutPreview.cpp:162 +msgid "CSS selector" +msgstr "Селектор CSS" + +#: source/LayoutPreview.cpp:184 +msgid "Assign CSS selectors" +msgstr "Назначить селекторы CSS" + +#: source/LayoutPreview.cpp:547 +#: source/LayoutPreview.cpp:595 +#: source/uiApp.cpp:690 +#: source/uiApp.cpp:711 +msgid "File could not be saved" +msgstr "Не удалось сохранить файл" + +#: source/LayoutPreview.cpp:558 +#: source/uiExport.cpp:457 +#: source/uiExport.cpp:523 +msgid "Export" +msgstr "Экспортировать" + +#: source/LayoutPreview.cpp:572 +msgid "Cascading Style Sheets *.css" +msgstr "Каскадные таблицы стилей (*.css)" + +#: source/LayoutPreview.cpp:666 +msgid "Layout:" +msgstr "Макет:" + +#: source/LayoutPreview.cpp:672 +msgid "Export CSS File" +msgstr "Экспортировать файл CSS" + +#: source/LayoutPreview.cpp:673 +msgid "Export CSS file" +msgstr "Экспортировать файл CSS" + +#: source/LayoutPreview.cpp:682 +msgid "_Export CSS File As..." +msgstr "_Экспортировать файл CSS как…" + +#: source/LayoutPreview.cpp:686 +msgid "_Assign CSS Selectors..." +msgstr "_Назначить селекторы CSS…" + +#: source/LayoutPreview.cpp:759 +msgid "Layout preview" +msgstr "Просмотр макета" + +#: source/ToolColorNaming.cpp:25 +msgid "_Empty" +msgstr "_Без названия" + +#: source/ToolColorNaming.cpp:26 +msgid "_Automatic name" +msgstr "_Автоматическое именование" + +#: source/ToolColorNaming.cpp:27 +msgid "_Tool specific" +msgstr "_В зависимости от инструмента" + +#: source/Variations.cpp:69 +msgid "Lightness (Lab)" +msgstr "Светлота (Lab)" + +#: source/Variations.cpp:110 +msgid "variations" +msgstr "Вариации" + +#: source/Variations.cpp:225 +msgid "all colors" +msgstr "все цвета" + +#: source/Variations.cpp:239 +#, c-format +msgid "result %d line %d" +msgstr "результат %d строка %d" + +#: source/Variations.cpp:717 +#: source/transformation/ColorVisionDeficiency.cpp:386 +msgid "Strength:" +msgstr "Сила:" + +#: source/Variations.cpp:745 +#: source/uiDialogVariations.cpp:142 +msgid "Variations" +msgstr "Вариации светлоты и насыщенности" + +#: source/uiAbout.cpp:88 +msgid "About Gpick" +msgstr "О программе Gpick" + +#: source/uiAbout.cpp:121 +msgid "Advanced color picker" +msgstr "Продвинутая цветовая пипетка" + +#: source/uiAbout.cpp:126 +msgid "Copyrights © 2009-2013, Albertas Vyšniauskas and Gpick development team" +msgstr "Авторские права © 2009-2013, Albertas Vyšniauskas and Gpick development team" + +#: source/uiAbout.cpp:141 +msgid "License" +msgstr "Лицензия" + +#: source/uiAbout.cpp:142 +msgid "Credits" +msgstr "Авторы" + +#: source/uiAbout.cpp:143 +msgid "Expat License" +msgstr "Лицензия на Expat" + +#: source/uiAbout.cpp:144 +msgid "Lua License" +msgstr "Лицензия на Lua" + +#: source/uiApp.cpp:354 +msgid "New palette" +msgstr "Новая палитра" + +#: source/uiApp.cpp:360 +msgid "(Imported)" +msgstr "(импортировано)" + +#: source/uiApp.cpp:530 +#: source/uiApp.cpp:545 +#: source/uiApp.cpp:563 +#: source/uiApp.cpp:641 +msgid "File could not be opened" +msgstr "Не удалось открыть файл" + +#: source/uiApp.cpp:531 +#: source/uiApp.cpp:546 +#: source/uiApp.cpp:564 +#: source/uiApp.cpp:642 +msgid "Open" +msgstr "Открыть" + +#: source/uiApp.cpp:576 +#: source/uiExport.cpp:473 +#: source/uiExport.cpp:587 +msgid "Gpick Palette (*.gpa)" +msgstr "Палитры Gpick (*.gpa)" + +#: source/uiApp.cpp:577 +#: source/uiExport.cpp:474 +#: source/uiExport.cpp:588 +msgid "GIMP/Inkscape Palette (*.gpl)" +msgstr "Палитры GIMP/Inkscape (*.gpl)" + +#: source/uiApp.cpp:578 +#: source/uiExport.cpp:476 +#: source/uiExport.cpp:589 +msgid "Adobe Swatch Exchange (*.ase)" +msgstr "Палитры Adobe Swatch Exchange (*.ase)" + +#: source/uiApp.cpp:584 +#: source/uiExport.cpp:598 +#: source/tools/PaletteFromImage.cpp:548 +msgid "All files" +msgstr "Все файлы" + +#: source/uiApp.cpp:589 +#: source/uiExport.cpp:607 +msgid "All supported formats" +msgstr "Все поддерживаемые форматы" + +#: source/uiApp.cpp:610 +msgid "Open File" +msgstr "Открыть файл" + +#: source/uiApp.cpp:659 +#: source/uiApp.cpp:691 +msgid "Save As" +msgstr "Сохранить как" + +#: source/uiApp.cpp:712 +msgid "Save" +msgstr "Сохранить" + +#: source/uiApp.cpp:771 +msgid "Open Last File" +msgstr "Открыть последний файл" + +#: source/uiApp.cpp:916 +msgid "Recent _files" +msgstr "_Недавние файлы" + +#: source/uiApp.cpp:946 +msgid "Ex_port..." +msgstr "_Экспортировать…" + +#: source/uiApp.cpp:954 +msgid "Expo_rt Selected..." +msgstr "Экспортировать _выделенное…" + +#: source/uiApp.cpp:962 +msgid "_Import..." +msgstr "_Импортировать…" + +#: source/uiApp.cpp:977 +msgid "_File" +msgstr "_Файл" + +#: source/uiApp.cpp:985 +msgid "Edit _Converters..." +msgstr "_Конвертеры…" + +#: source/uiApp.cpp:989 +msgid "Display _Filters..." +msgstr "_Экранные фильтры..." + +#: source/uiApp.cpp:1001 +msgid "_Edit" +msgstr "_Правка" + +#: source/uiApp.cpp:1037 +msgid "_Secondary View" +msgstr "_Дополнительная панель" + +#: source/uiApp.cpp:1043 +msgid "Palette" +msgstr "Палитра цветов" + +#: source/uiApp.cpp:1049 +msgid "_View" +msgstr "_Вид" + +#: source/uiApp.cpp:1055 +msgid "Palette From _Image..." +msgstr "_Палитра из изображения…" + +#: source/uiApp.cpp:1063 +msgid "_Tools" +msgstr "_Инструменты" + +#: source/uiApp.cpp:1078 +msgid "_Help" +msgstr "_Справка" + +#: source/uiApp.cpp:1386 +msgid "_Copy to Clipboard" +msgstr "С_копировать в буфер обмена" + +#: source/uiApp.cpp:1402 +msgid "_Mix Colors..." +msgstr "С_мешать цвета…" + +#: source/uiApp.cpp:1407 +msgid "_Variations..." +msgstr "Вариации _светлоты и насыщенности…" + +#: source/uiApp.cpp:1412 +msgid "_Generate..." +msgstr "Вариации _тонов…" + +#: source/uiApp.cpp:1421 +msgid "C_lear names" +msgstr "Ст_ереть названия" + +#: source/uiApp.cpp:1427 +msgid "Autona_me" +msgstr "_Автоматически подобрать названия" + +#: source/uiApp.cpp:1433 +msgid "Auto_number..." +msgstr "Автоматически _пронумеровать..." + +#: source/uiApp.cpp:1441 +msgid "R_everse" +msgstr "_Развернуть" + +#: source/uiApp.cpp:1447 +msgid "Group and _sort..." +msgstr "С_группировать и отсортировать..." + +#: source/uiApp.cpp:1455 +msgid "_Remove" +msgstr "_Удалить" + +#: source/uiApp.cpp:1461 +msgid "Remove _All" +msgstr "Удалить _все" + +#: source/uiApp.cpp:1869 +msgid "Color pic_ker" +msgstr "П_ипетка" + +#: source/uiApp.cpp:1878 +msgid "Scheme _generation" +msgstr "Создание _цветовой схемы" + +#: source/uiApp.cpp:1897 +msgid "Lay_out preview" +msgstr "Просмотр _макета" + +#: source/uiApp.cpp:1947 +msgid "Pick colors (Ctrl+P)" +msgstr "Снять цвет пипеткой (Ctrl+P)" + +#: source/uiApp.cpp:1956 +msgid "File is currently in a non-native format, possible loss of precision and/or metadata." +msgstr "Файл сохранён не в собственном формате Gpick, возможны потери точности или метаданных." + +#: source/uiColorInput.cpp:45 +msgid "Edit color" +msgstr "Изменить цвет" + +#: source/uiColorInput.cpp:69 +msgid "Color:" +msgstr "Цвет:" + +#: source/uiConverter.cpp:56 +msgid "Test color" +msgstr "Пробный цвет" + +#: source/uiConverter.cpp:74 +msgid "error" +msgstr "Ошибка" + +#: source/uiConverter.cpp:145 +msgid "Function name" +msgstr "Название функции" + +#: source/uiConverter.cpp:154 +msgid "Example" +msgstr "Пример" + +#: source/uiConverter.cpp:196 +msgid "Converters" +msgstr "Конвертеры" + +#: source/uiConverter.cpp:224 +msgid "Displays:" +msgstr "Показывает:" + +#: source/uiConverter.cpp:230 +msgid "Color list:" +msgstr "Список цветов:" + +#: source/uiDialogAutonumber.cpp:108 +msgid "Autonumber colors" +msgstr "Автоматически пронумеровать цвета" + +#: source/uiDialogAutonumber.cpp:122 +msgid "Name:" +msgstr "Название:" + +#: source/uiDialogAutonumber.cpp:132 +msgid "Decimal places:" +msgstr "Число разрядов:" + +#: source/uiDialogAutonumber.cpp:139 +msgid "Starting number:" +msgstr "Начать с цифры:" + +#: source/uiDialogAutonumber.cpp:146 +msgid "_Decreasing" +msgstr "По _нисходящей" + +#: source/uiDialogAutonumber.cpp:152 +msgid "_Append" +msgstr "_Добавлять поверх" + +#: source/uiDialogAutonumber.cpp:158 +msgid "Sample:" +msgstr "Образец:" + +#: source/uiDialogGenerate.cpp:216 +msgid "Generate colors" +msgstr "Вариации тонов" + +#: source/uiDialogGenerate.cpp:230 +#: source/tools/PaletteFromImage.cpp:599 +msgid "Colors:" +msgstr "Цветов:" + +#: source/uiDialogGenerate.cpp:257 +msgid "Chaos:" +msgstr "Хаос:" + +#: source/uiDialogGenerate.cpp:263 +msgid "Seed:" +msgstr "Зерно:" + +#: source/uiDialogGenerate.cpp:271 +msgid "_Reverse" +msgstr "_Развернуть" + +#: source/uiDialogMix.cpp:76 +#: source/uiDialogMix.cpp:78 +msgid "mix node" +msgstr "" + +#: source/uiDialogMix.cpp:81 +msgid "mix" +msgstr "" + +#: source/uiDialogMix.cpp:235 +msgid "Mix colors" +msgstr "Смешать цвета" + +#: source/uiDialogMix.cpp:262 +#: source/uiDialogVariations.cpp:186 +msgid "Steps:" +msgstr "Шагов:" + +#: source/uiDialogMix.cpp:270 +msgid "_Include Endpoints" +msgstr "_Включая оконечные цвета" + +#: source/uiDialogOptions.cpp:117 +#: source/tools/PaletteFromImage.cpp:589 +msgid "Options" +msgstr "Параметры" + +#: source/uiDialogOptions.cpp:134 +msgid "System" +msgstr "Системные" + +#: source/uiDialogOptions.cpp:143 +msgid "_Single instance" +msgstr "_Запускать лишь одну копию приложения" + +#: source/uiDialogOptions.cpp:148 +msgid "Save/_Restore palette" +msgstr "Сохранить/_Восстановить палитру" + +#: source/uiDialogOptions.cpp:154 +msgid "System tray" +msgstr "Область уведомления" + +#: source/uiDialogOptions.cpp:162 +msgid "_Minimize to system tray" +msgstr "С_ворачивать в область уведомления" + +#: source/uiDialogOptions.cpp:167 +msgid "_Close to system tray" +msgstr "_Закрывать в область уведомления" + +#: source/uiDialogOptions.cpp:172 +msgid "_Start in system tray" +msgstr "З_апускать в области уведомления" + +#: source/uiDialogOptions.cpp:178 +msgid "_Main" +msgstr "О_сновные" + +#: source/uiDialogOptions.cpp:184 +msgid "Display" +msgstr "Внешний вид" + +#: source/uiDialogOptions.cpp:193 +msgid "_Refresh rate:" +msgstr "_Частота обновления:" + +#: source/uiDialogOptions.cpp:201 +msgid "_Magnified area size:" +msgstr "_Размер области увеличения:" + +#: source/uiDialogOptions.cpp:207 +msgid "Floating picker click behaviour" +msgstr "Действие по щелчку пипеткой" + +#: source/uiDialogOptions.cpp:226 +msgid "'Spacebar' button behaviour" +msgstr "Действие по нажатию пробела" + +#: source/uiDialogOptions.cpp:244 +msgid "_Rotate swatch" +msgstr "По_вернуть образец" + +#: source/uiDialogOptions.cpp:251 +msgid "Enabled color spaces" +msgstr "Используемые цветовые пространства" + +#: source/uiDialogOptions.cpp:266 +msgid "Lab settings" +msgstr "Параметры Lab" + +#: source/uiDialogOptions.cpp:278 +msgid "_Illuminant:" +msgstr "Ос_ветитель:" + +#: source/uiDialogOptions.cpp:302 +msgid "_Observer:" +msgstr "_Наблюдатель:" + +#: source/uiDialogOptions.cpp:321 +msgid "Other settings" +msgstr "Прочие параметры" + +#: source/uiDialogOptions.cpp:330 +msgid "_Mask out of gamut colors" +msgstr "_Маскировать цвета вне охвата" + +#: source/uiDialogOptions.cpp:336 +msgid "_Picker" +msgstr "_Пипетка" + +#: source/uiDialogOptions.cpp:341 +msgid "Color name generation" +msgstr "Подбор названий" + +#: source/uiDialogOptions.cpp:350 +msgid "_Imprecision postfix" +msgstr "Помечать _неточное совпадение тильдой" + +#: source/uiDialogOptions.cpp:356 +msgid "Tool color naming" +msgstr "Именование снятых цветов" + +#: source/uiDialogOptions.cpp:381 +msgid "_Color names" +msgstr "_Названия цветов" + +#: source/uiDialogSort.cpp:135 +#: source/uiDialogSort.cpp:223 +msgid "RGB Red" +msgstr "Красный в RGB" + +#: source/uiDialogSort.cpp:136 +#: source/uiDialogSort.cpp:224 +msgid "RGB Green" +msgstr "Зелёный в RGB" + +#: source/uiDialogSort.cpp:137 +#: source/uiDialogSort.cpp:225 +msgid "RGB Blue" +msgstr "Синий в RGB" + +#: source/uiDialogSort.cpp:138 +#: source/uiDialogSort.cpp:226 +msgid "RGB Grayscale" +msgstr "Градации серого в RGB" + +#: source/uiDialogSort.cpp:139 +#: source/uiDialogSort.cpp:227 +msgid "HSL Hue" +msgstr "Тон HSL" + +#: source/uiDialogSort.cpp:140 +#: source/uiDialogSort.cpp:228 +msgid "HSL Saturation" +msgstr "Насыщенность в HSL" + +#: source/uiDialogSort.cpp:141 +#: source/uiDialogSort.cpp:229 +msgid "HSL Lightness" +msgstr "Светлота в HSL" + +#: source/uiDialogSort.cpp:142 +#: source/uiDialogSort.cpp:230 +msgid "Lab Lightness" +msgstr "Светлота в Lab" + +#: source/uiDialogSort.cpp:143 +#: source/uiDialogSort.cpp:231 +msgid "Lab A" +msgstr "Lab A" + +#: source/uiDialogSort.cpp:144 +#: source/uiDialogSort.cpp:232 +msgid "Lab B" +msgstr "Lab B" + +#: source/uiDialogSort.cpp:145 +#: source/uiDialogSort.cpp:233 +msgid "LCh Lightness" +msgstr "Светлота в LCh" + +#: source/uiDialogSort.cpp:146 +#: source/uiDialogSort.cpp:234 +msgid "LCh Chroma" +msgstr "Цветность в LCh" + +#: source/uiDialogSort.cpp:147 +#: source/uiDialogSort.cpp:235 +msgid "LCh Hue" +msgstr "Тон в LCh" + +#: source/uiDialogSort.cpp:556 +msgid "Group and sort" +msgstr "Сгруппировать и отсортировать" + +#: source/uiDialogSort.cpp:564 +msgid "Group type:" +msgstr "Критерий группировки:" + +#: source/uiDialogSort.cpp:574 +msgid "Grouping sensitivity:" +msgstr "Чувствительность группировки:" + +#: source/uiDialogSort.cpp:581 +msgid "Maximum number of groups:" +msgstr "Предельное количество групп:" + +#: source/uiDialogSort.cpp:588 +msgid "Sort type:" +msgstr "Критерий сортировки:" + +#: source/uiDialogSort.cpp:598 +msgid "_Reverse group order" +msgstr "О_братить порядок группировки" + +#: source/uiDialogSort.cpp:604 +msgid "_Reverse order inside groups" +msgstr "Обратить порядок _внутри группы" + +#: source/uiDialogVariations.cpp:60 +msgid "variation" +msgstr "Вариации светлоты и насыщенности" + +#: source/uiDialogVariations.cpp:194 +msgid "_Use multiplication" +msgstr "_Использовать умножение" + +#: source/uiExport.cpp:475 +msgid "Alias/WaveFront Material (*.mtl)" +msgstr "Материалы Alias/WaveFront (*.mtl)" + +#: source/uiExport.cpp:477 +msgid "Text file (*.txt)" +msgstr "Текстовые файлы (*.txt)" + +#: source/uiExport.cpp:522 +msgid "File could not be exported" +msgstr "Не удалось экспортировать файл" + +#: source/uiExport.cpp:573 +#: source/uiExport.cpp:654 +#: source/uiExport.cpp:666 +msgid "Import" +msgstr "Импортировать" + +#: source/uiExport.cpp:653 +msgid "File format is not supported" +msgstr "Этот формат файлов не поддерживается" + +#: source/uiExport.cpp:665 +msgid "File could not be imported" +msgstr "Не удалось импортировать файл" + +#: source/uiListPalette.cpp:158 +#: source/uiListPalette.cpp:160 +#, c-format +msgid "%d color" +msgid_plural "%d colors" +msgstr[0] "%d цвет" +msgstr[1] "%d цвета" +msgstr[2] "%d цветов" + +#: source/uiListPalette.cpp:166 +msgid "selected" +msgstr "выбрано" + +#: source/uiListPalette.cpp:172 +#: source/uiListPalette.cpp:174 +#, c-format +msgid "Total %d color" +msgid_plural "Total %d colors" +msgstr[0] "Всего %d цвет" +msgstr[1] "Всего %d цвета" +msgstr[2] "Всего %d цветов" + +#: source/uiListPalette.cpp:353 +msgid "Preview" +msgstr "Предпросмотр" + +#: source/uiListPalette.cpp:708 +#: source/uiListPalette.cpp:717 +msgid "Color" +msgstr "Цвет" + +#: source/uiListPalette.cpp:726 +#: source/uiTransformations.cpp:183 +msgid "Name" +msgstr "Название" + +#: source/uiStatusIcon.cpp:67 +msgid "_Show Main Window" +msgstr "_Показать основное окно" + +#: source/uiStatusIcon.cpp:74 +msgid "_Quit" +msgstr "В_ыход" + +#: source/uiTransformations.cpp:245 +msgid "Display filters" +msgstr "Экранные фильтры" + +#: source/uiTransformations.cpp:259 +msgid "_Enabled" +msgstr "_Применять экранные фильтры" + +#: source/tools/PaletteFromImage.cpp:514 +msgid "Palette from image" +msgstr "Палитра из изображения" + +#: source/tools/PaletteFromImage.cpp:527 +msgid "Image" +msgstr "Изображение" + +#: source/tools/PaletteFromImage.cpp:536 +msgid "Image file" +msgstr "Файл изображения" + +#: source/tools/PaletteFromImage.cpp:556 +msgid "All images" +msgstr "Все изображения" + +#: source/transformation/ColorVisionDeficiency.cpp:41 +msgid "Color vision deficiency" +msgstr "Цветонеразличение" + +#: source/transformation/ColorVisionDeficiency.cpp:330 +msgid "Protanomaly" +msgstr "Протаномалия" + +#: source/transformation/ColorVisionDeficiency.cpp:331 +msgid "Deuteranomaly" +msgstr "Дейтераномалия" + +#: source/transformation/ColorVisionDeficiency.cpp:332 +msgid "Tritanomaly" +msgstr "Тританомалия" + +#: source/transformation/ColorVisionDeficiency.cpp:333 +msgid "Protanopia" +msgstr "Протанопия" + +#: source/transformation/ColorVisionDeficiency.cpp:334 +msgid "Deuteranopia" +msgstr "Дейтеранопия" + +#: source/transformation/ColorVisionDeficiency.cpp:335 +msgid "Tritanopia" +msgstr "Тританопия" + +#: source/transformation/ColorVisionDeficiency.cpp:422 +msgid "Altered spectral sensitivity of red receptors" +msgstr "Слабое восприятие красного цвета" + +#: source/transformation/ColorVisionDeficiency.cpp:423 +msgid "Altered spectral sensitivity of green receptors" +msgstr "Слабое восприятие зелёного цвета" + +#: source/transformation/ColorVisionDeficiency.cpp:424 +msgid "Altered spectral sensitivity of blue receptors" +msgstr "Слабое восприятие синего цвета" + +#: source/transformation/ColorVisionDeficiency.cpp:425 +msgid "Absence of red receptors" +msgstr "Отсутствие рецепторов красного цвета" + +#: source/transformation/ColorVisionDeficiency.cpp:426 +msgid "Absence of green receptors" +msgstr "Отсутствие рецепторов зелёного цвета" + +#: source/transformation/ColorVisionDeficiency.cpp:427 +msgid "Absence of blue receptors" +msgstr "Отсутствие рецепторов синего цвета" + +#: source/transformation/GammaModification.cpp:38 +msgid "Gamma modification" +msgstr "Гамма-коррекция" + +#: source/transformation/GammaModification.cpp:88 +#: source/transformation/Quantization.cpp:96 +msgid "Value:" +msgstr "Значение:" + +#: source/transformation/Quantization.cpp:40 +msgid "Quantization" +msgstr "Квантование" + +#: source/transformation/Quantization.cpp:101 +msgid "Clip top-end" +msgstr "" + +#: share/gpick/init.lua:173 +msgid "Web: hex code" +msgstr "Web: hex-код" + +#: share/gpick/init.lua:178 +msgid "Web: hex code (3 digits)" +msgstr "Web: hex-код (3 знака)" + +#: share/gpick/init.lua:183 +msgid "Web: hex code (no hash symbol)" +msgstr "Web: hex-код (без решётки)" + +#: share/gpick/init.lua:188 +msgid "CSS: hue saturation lightness" +msgstr "CSS: тон, насыщенность, светлота" + +#: share/gpick/init.lua:193 +msgid "CSS: red green blue" +msgstr "CSS: красный, зелёный, синий" + +#: share/gpick/layouts.lua:15 +msgid "Homepage" +msgstr "Homepage" + +#: share/gpick/layouts.lua:15 +msgid "About us" +msgstr "About us" + +#: share/gpick/layouts.lua:15 +msgid "Links to us" +msgstr "Links to us" + +#: share/gpick/layouts.lua:15 +msgid "Privacy" +msgstr "Privacy" + +#: share/gpick/layouts.lua:15 +msgid "Terms" +msgstr "Terms" + +#: share/gpick/layouts.lua:15 +msgid "Contact us" +msgstr "Contact us" + +#: share/gpick/layouts.lua:15 +msgid "RSS" +msgstr "RSS" + +#: share/gpick/layouts.lua:30 +msgid "The quick brown fox jumps over the lazy dog" +msgstr "" + +#: share/gpick/layouts.lua:46 +msgid "Webpage" +msgstr "Webpage" + +#: share/gpick/layouts.lua:51 +#: share/gpick/layouts.lua:73 +msgid "Header" +msgstr "Header" + +#: share/gpick/layouts.lua:52 +msgid "Header text" +msgstr "Header text" + +#: share/gpick/layouts.lua:54 +msgid "Content" +msgstr "Content" + +#: share/gpick/layouts.lua:55 +msgid "Content text" +msgstr "Content text" + +#: share/gpick/layouts.lua:57 +msgid "Sidebar" +msgstr "Sidebar" + +#: share/gpick/layouts.lua:59 +#: share/gpick/layouts.lua:87 +msgid "Button" +msgstr "Button" + +#: share/gpick/layouts.lua:60 +#: share/gpick/layouts.lua:88 +msgid "Button (hover)" +msgstr "Button (hover)" + +#: share/gpick/layouts.lua:61 +#: share/gpick/layouts.lua:89 +msgid "Button text" +msgstr "Button text" + +#: share/gpick/layouts.lua:62 +#: share/gpick/layouts.lua:90 +msgid "Button text (hover)" +msgstr "Button text (hover)" + +#: share/gpick/layouts.lua:64 +msgid "Footer" +msgstr "Footer" + +#: share/gpick/layouts.lua:82 +#: share/gpick/layouts.lua:86 +msgid "Menu" +msgstr "Menu" + +#: share/gpick/layouts.lua:106 +msgid "Brightness-Darkness" +msgstr "Brightness-Darkness" + +#: share/gpick/layouts.lua:110 +msgid "main" +msgstr "основной" + +#: share/gpick/layouts.lua:144 +msgid "Grid (4x3)" +msgstr "Сетка (4x3)" + +#: share/gpick/layouts.lua:153 +#: share/gpick/layouts.lua:159 +#: share/gpick/layouts.lua:180 +#: share/gpick/layouts.lua:186 +msgid "Item" +msgstr "Item" + +#: share/gpick/layouts.lua:154 +#: share/gpick/layouts.lua:181 +msgid "Item text" +msgstr "Item text" + +#: share/gpick/layouts.lua:171 +msgid "Grid (5x4)" +msgstr "Сетка (5x4)" + +#~ msgid "Edit _Transformations..." +#~ msgstr "_Коррекция вывода цвета…" diff -Nru gpick-0.2.4/source/BezierCubicCurve.h gpick-0.2.5/source/BezierCubicCurve.h --- gpick-0.2.4/source/BezierCubicCurve.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/BezierCubicCurve.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/BlendColors.cpp gpick-0.2.5/source/BlendColors.cpp --- gpick-0.2.4/source/BlendColors.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/BlendColors.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,633 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "BlendColors.h" +#include "uiListPalette.h" +#include "uiUtilities.h" +#include "MathUtil.h" +#include "DynvHelpers.h" +#include "GlobalStateStruct.h" +#include "ToolColorNaming.h" +#include "DragDrop.h" +#include "ColorList.h" +#include "MathUtil.h" +#include "ColorRYB.h" +#include "gtk/ColorWidget.h" +#include "uiColorInput.h" +#include "CopyPaste.h" +#include "Converter.h" +#include "DynvHelpers.h" +#include "uiApp.h" +#include "ToolColorNaming.h" +#include "Internationalisation.h" + +#include +#include +#include +#include +#include + +#ifndef _MSC_VER +#include +#endif +#include + +using namespace std; + +#define STORE_COLOR() struct ColorObject *color_object = color_list_new_color_object(color_list, &r); \ + float mixfactor = step_i/(float)(steps-1); \ + name_assigner.assign(color_object, &r, start_name.c_str(), end_name.c_str(), (int)((1.0 - mixfactor)*100), (int)(mixfactor*100), (((step_i == 0 || step_i == steps - 1) && stage == 0) || (stage == 1 && step_i == steps - 1))); \ + color_list_add_color_object(color_list, color_object, 1); \ + color_object_release(color_object) + +#define STORE_LINEARCOLOR() color_linear_get_rgb(&r, &r); \ + STORE_COLOR() + + +typedef struct BlendColorsArgs{ + ColorSource source; + + GtkWidget *main; + + GtkWidget *mix_type; + GtkWidget *steps1; + GtkWidget *steps2; + + GtkWidget *start_color; + GtkWidget *middle_color; + GtkWidget *end_color; + + GtkWidget *preview_list; + struct ColorList *preview_color_list; + + struct dynvSystem *params; + GlobalState* gs; +}BlendColorsArgs; + +class BlendColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + const char *m_color_start; + const char *m_color_end; + int m_start_percent; + int m_end_percent; + bool m_is_color_item; + public: + BlendColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + m_is_color_item = false; + } + + void assign(struct ColorObject *color_object, Color *color, const char *start_color_name, const char *end_color_name, int start_percent, int end_percent, bool is_color_item){ + m_color_start = start_color_name; + m_color_end = end_color_name; + m_start_percent = start_percent; + m_end_percent = end_percent; + m_is_color_item = is_color_item; + ToolColorNameAssigner::assign(color_object, color); + } + + void assign(struct ColorObject *color_object, Color *color, const char *item_name){ + m_color_start = item_name; + m_is_color_item = true; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + if (m_is_color_item){ + if (m_end_percent == 100){ + m_stream << m_color_end << " " << _("blend node"); + }else{ + m_stream << m_color_start << " " << _("blend node"); + } + }else{ + m_stream << m_color_start << " " << m_start_percent << " " << _("blend") << " " << m_end_percent << " " << m_color_end; + } + return m_stream.str(); + } +}; + +static int source_get_color(BlendColorsArgs *args, struct ColorObject** color); + +static void calc( BlendColorsArgs *args, bool preview, int limit){ + + gint steps1 = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(args->steps1)); + gint steps2 = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(args->steps2)); + gint type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->mix_type)); + + Color r; + gint step_i; + + stringstream s; + s.precision(0); + s.setf(ios::fixed,ios::floatfield); + + Color a,b; + + struct ColorList *color_list; + color_list = args->preview_color_list; + + BlendColorNameAssigner name_assigner(args->gs); + + int steps; + for (int stage = 0; stage < 2; stage++){ + if (stage == 0){ + steps = steps1 + 1; + gtk_color_get_color(GTK_COLOR(args->start_color), &a); + gtk_color_get_color(GTK_COLOR(args->middle_color), &b); + }else{ + steps = steps2 + 1; + gtk_color_get_color(GTK_COLOR(args->middle_color), &a); + gtk_color_get_color(GTK_COLOR(args->end_color), &b); + } + + string start_name = color_names_get(args->gs->color_names, &a, false); + string end_name = color_names_get(args->gs->color_names, &b, false); + + if (type == 0){ + color_rgb_get_linear(&a, &a); + color_rgb_get_linear(&b, &b); + } + step_i = stage; + + switch (type) { + case 0: + for (; step_i < steps; ++step_i) { + MIX_COMPONENTS(r.rgb, a.rgb, b.rgb, red, green, blue); + STORE_LINEARCOLOR(); + } + break; + + case 1: + { + Color a_hsv, b_hsv, r_hsv; + color_rgb_to_hsv(&a, &a_hsv); + color_rgb_to_hsv(&b, &b_hsv); + + for (; step_i < steps; ++step_i) { + MIX_COMPONENTS(r_hsv.hsv, a_hsv.hsv, b_hsv.hsv, hue, saturation, value); + color_hsv_to_rgb(&r_hsv, &r); + STORE_COLOR(); + + } + } + break; + + case 2: + { + Color a_hsv, b_hsv, r_hsv; + color_rgb_to_hsv(&a, &a_hsv); + color_rgb_to_hsv(&b, &b_hsv); + + if (a_hsv.hsv.hue>b_hsv.hsv.hue){ + if (a_hsv.hsv.hue-b_hsv.hsv.hue>0.5) + a_hsv.hsv.hue-=1; + }else{ + if (b_hsv.hsv.hue-a_hsv.hsv.hue>0.5) + b_hsv.hsv.hue-=1; + } + for (; step_i < steps; ++step_i) { + MIX_COMPONENTS(r_hsv.hsv, a_hsv.hsv, b_hsv.hsv, hue, saturation, value); + if (r_hsv.hsv.hue<0) r_hsv.hsv.hue+=1; + color_hsv_to_rgb(&r_hsv, &r); + STORE_COLOR(); + } + } + break; + + case 3: + { + Color a_lab, b_lab, r_lab; + color_rgb_to_lab_d50(&a, &a_lab); + color_rgb_to_lab_d50(&b, &b_lab); + + for (; step_i < steps; ++step_i) { + MIX_COMPONENTS(r_lab.lab, a_lab.lab, b_lab.lab, L, a, b); + color_lab_to_rgb_d50(&r_lab, &r); + color_rgb_normalize(&r); + STORE_COLOR(); + } + } + break; + } + } +} + +static PaletteListCallbackReturn add_to_palette_cb_helper(struct ColorObject* color_object, void *userdata){ + BlendColorsArgs *args = (BlendColorsArgs*)userdata; + color_list_add_color_object(args->gs->colors, color_object, 1); + return PALETTE_LIST_CALLBACK_NO_UPDATE; +} + +static gboolean add_to_palette_cb(GtkWidget *widget, BlendColorsArgs *args) { + palette_list_foreach_selected(args->preview_list, add_to_palette_cb_helper, args); + return true; +} + +static gboolean add_all_to_palette_cb(GtkWidget *widget, BlendColorsArgs *args) { + palette_list_foreach(args->preview_list, add_to_palette_cb_helper, args); + return true; +} + +static PaletteListCallbackReturn color_list_selected(struct ColorObject* color_object, void *userdata){ + color_list_add_color_object((struct ColorList *)userdata, color_object, 1); + return PALETTE_LIST_CALLBACK_NO_UPDATE; +} + +typedef struct CopyMenuItem{ + gchar* function_name; + struct ColorObject* color_object; + GlobalState* gs; + GtkWidget* palette_widget; +}CopyMenuItem; + +static void converter_destroy_params(CopyMenuItem* args){ + color_object_release(args->color_object); + g_free(args->function_name); + delete args; +} + +static void converter_callback_copy(GtkWidget *widget, gpointer item) { + CopyMenuItem* itemdata=(CopyMenuItem*)g_object_get_data(G_OBJECT(widget), "item_data"); + converter_get_clipboard(itemdata->function_name, itemdata->color_object, itemdata->palette_widget, itemdata->gs->params); +} + + +static GtkWidget* converter_create_copy_menu_item (GtkWidget *menu, const gchar* function, struct ColorObject* color_object, GtkWidget* palette_widget, GlobalState *gs){ + GtkWidget* item=0; + gchar* converted; + + if (converters_color_serialize((Converters*)dynv_get_pointer_wd(gs->params, "Converters", 0), function, color_object, &converted)==0){ + item = gtk_menu_item_new_with_image(converted, gtk_image_new_from_stock(GTK_STOCK_COPY, GTK_ICON_SIZE_MENU)); + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(converter_callback_copy), 0); + + CopyMenuItem* itemdata=new CopyMenuItem; + itemdata->function_name=g_strdup(function); + itemdata->palette_widget=palette_widget; + itemdata->color_object=color_object_ref(color_object); + itemdata->gs = gs; + + g_object_set_data_full(G_OBJECT(item), "item_data", itemdata, (GDestroyNotify)converter_destroy_params); + + g_free(converted); + } + + return item; +} + +static gboolean preview_list_button_press_cb(GtkWidget *widget, GdkEventButton *event, BlendColorsArgs *args) { + GtkWidget *menu; + + if (event->button == 1 && event->type == GDK_2BUTTON_PRESS){ + //add_to_palette_cb(widget, args); + //return true; + }else if (event->button == 3 && event->type == GDK_BUTTON_PRESS){ + + GtkWidget* item ; + gint32 button, event_time; + + menu = gtk_menu_new (); + + bool selection_avail = palette_list_get_selected_count(widget) != 0; + + item = gtk_menu_item_new_with_image (_("_Add to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (add_to_palette_cb), args); + if (!selection_avail) gtk_widget_set_sensitive(item, false); + + + item = gtk_menu_item_new_with_image (_("A_dd all to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (add_all_to_palette_cb), args); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); + + item = gtk_menu_item_new_with_mnemonic (_("_Copy to clipboard")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + if (selection_avail){ + struct ColorList *color_list = color_list_new(NULL); + palette_list_forfirst_selected(args->preview_list, color_list_selected, color_list); + if (color_list_get_count(color_list) != 0){ + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), converter_create_copy_menu (*color_list->colors.begin(), args->preview_list, args->gs)); + } + color_list_destroy(color_list); + }else{ + gtk_widget_set_sensitive(item, false); + } + + gtk_widget_show_all (GTK_WIDGET(menu)); + + button = event->button; + event_time = event->time; + + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time); + + g_object_ref_sink(menu); + g_object_unref(menu); + + return TRUE; + } + return FALSE; +} + + +static void update(GtkWidget *widget, BlendColorsArgs *args ){ + color_list_remove_all(args->preview_color_list); + calc(args, true, 101); +} + +static void reset_middle_color_cb(GtkWidget *widget, BlendColorsArgs *args){ + Color a, b; + gtk_color_get_color(GTK_COLOR(args->start_color), &a); + gtk_color_get_color(GTK_COLOR(args->end_color), &b); + color_multiply(&a, 0.5); + color_multiply(&b, 0.5); + color_add(&a, &b); + gtk_color_set_color(GTK_COLOR(args->middle_color), &a, ""); + update(0, args); +} + +static gboolean color_button_press_cb(GtkWidget *widget, GdkEventButton *event, BlendColorsArgs *args) { + GtkWidget *menu; + + if (event->button == 3 && event->type == GDK_BUTTON_PRESS){ + GtkWidget* item ; + gint32 button, event_time; + menu = gtk_menu_new (); + + item = gtk_menu_item_new_with_mnemonic(_("_Reset")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (reset_middle_color_cb), args); + + gtk_widget_show_all (GTK_WIDGET(menu)); + + button = event->button; + event_time = event->time; + + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time); + + g_object_ref_sink(menu); + g_object_unref(menu); + + return TRUE; + } + return FALSE; +} + +static int set_rgb_color(BlendColorsArgs *args, struct ColorObject* color, uint32_t color_index){ + Color c; + color_object_get_color(color, &c); + if (color_index == 1){ + gtk_color_set_color(GTK_COLOR(args->start_color), &c, ""); + }else if (color_index == 2){ + gtk_color_set_color(GTK_COLOR(args->middle_color), &c, ""); + }else if (color_index == 3){ + gtk_color_set_color(GTK_COLOR(args->end_color), &c, ""); + } + update(0, args); + return 0; +} + +static int get_rgb_color(BlendColorsArgs *args, uint32_t color_index, struct ColorObject** color){ + Color c; + if (color_index == 1){ + gtk_color_get_color(GTK_COLOR(args->start_color), &c); + }else if (color_index == 2){ + gtk_color_get_color(GTK_COLOR(args->middle_color), &c); + }else if (color_index == 3){ + gtk_color_get_color(GTK_COLOR(args->end_color), &c); + } + + *color = color_list_new_color_object(args->gs->colors, &c); + + BlendColorNameAssigner name_assigner(args->gs); + const char *item_name[] = { + "start", + "middle", + "end", + }; + name_assigner.assign(*color, &c, item_name[color_index - 1]); + + return 0; +} + +static struct ColorObject* get_color_object(struct DragDrop* dd){ + BlendColorsArgs* args = (BlendColorsArgs*)dd->userdata; + struct ColorObject* colorobject; + if (get_rgb_color(args, (uintptr_t)dd->userdata2, &colorobject) == 0){ + return colorobject; + } + return 0; +} + +static int set_color_object_at(struct DragDrop* dd, struct ColorObject* colorobject, int x, int y, bool move){ + BlendColorsArgs* args = static_cast(dd->userdata); + set_rgb_color(args, colorobject, (uintptr_t)dd->userdata2); + return 0; +} + +static int source_get_color(BlendColorsArgs *args, struct ColorObject** color){ + return -1; +} + +static int source_set_color(BlendColorsArgs *args, struct ColorObject* color){ + return -1; +} + +static int source_activate(BlendColorsArgs *args){ + update(0, args); + return 0; +} + +static int source_deactivate(BlendColorsArgs *args){ + return 0; +} + +static int source_destroy(BlendColorsArgs *args){ + gint steps1 = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(args->steps1)); + gint steps2 = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(args->steps2)); + gint type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->mix_type)); + dynv_set_int32(args->params, "type", type); + dynv_set_int32(args->params, "steps1", steps1); + dynv_set_int32(args->params, "steps2", steps2); + + Color c; + gtk_color_get_color(GTK_COLOR(args->start_color), &c); + dynv_set_color(args->params, "start_color", &c); + gtk_color_get_color(GTK_COLOR(args->middle_color), &c); + dynv_set_color(args->params, "middle_color", &c); + gtk_color_get_color(GTK_COLOR(args->end_color), &c); + dynv_set_color(args->params, "end_color", &c); + + color_list_destroy(args->preview_color_list); + + dynv_system_release(args->params); + gtk_widget_destroy(args->main); + delete args; + return 0; +} + +static ColorSource* source_implement(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace){ + BlendColorsArgs *args = new BlendColorsArgs; + + args->params = dynv_system_ref(dynv_namespace); + args->gs = gs; + + color_source_init(&args->source, source->identificator, source->hr_name); + args->source.destroy = (int (*)(ColorSource *source))source_destroy; + args->source.get_color = (int (*)(ColorSource *source, ColorObject** color))source_get_color; + args->source.set_color = (int (*)(ColorSource *source, ColorObject* color))source_set_color; + args->source.deactivate = (int (*)(ColorSource *source))source_deactivate; + args->source.activate = (int (*)(ColorSource *source))source_activate; + + + GtkWidget *table, *widget; + GtkWidget *mix_type, *mix_steps; + + gint table_y; + table = gtk_table_new(6, 2, FALSE); + table_y = 0; + + struct DragDrop dd; + dragdrop_init(&dd, gs); + + dd.userdata = args; + dd.get_color_object = get_color_object; + dd.set_color_object_at = set_color_object_at; + + Color c; + color_set(&c, 0.5); + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Start:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->start_color = widget = gtk_color_new(); + gtk_color_set_color(GTK_COLOR(args->start_color), dynv_get_color_wdc(args->params, "start_color", &c), ""); + gtk_color_set_rounded(GTK_COLOR(widget), true); + gtk_color_set_hcenter(GTK_COLOR(widget), true); + gtk_color_set_roundness(GTK_COLOR(widget), 5); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0); + + gtk_drag_dest_set( widget, GtkDestDefaults(GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT), 0, 0, GDK_ACTION_COPY); + gtk_drag_source_set( widget, GDK_BUTTON1_MASK, 0, 0, GDK_ACTION_COPY); + dd.handler_map = dynv_system_get_handler_map(gs->colors->params); + dd.userdata2 = (void*)1; + dragdrop_widget_attach(widget, DragDropFlags(DRAGDROP_SOURCE | DRAGDROP_DESTINATION), &dd); + + table_y++; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Middle:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->middle_color = widget = gtk_color_new(); + + g_signal_connect(G_OBJECT(widget), "button-press-event", G_CALLBACK(color_button_press_cb), args); + gtk_color_set_color(GTK_COLOR(args->middle_color), dynv_get_color_wdc(args->params, "middle_color", &c), ""); + gtk_color_set_rounded(GTK_COLOR(widget), true); + gtk_color_set_hcenter(GTK_COLOR(widget), true); + gtk_color_set_roundness(GTK_COLOR(widget), 5); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0); + + gtk_drag_dest_set( widget, GtkDestDefaults(GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT), 0, 0, GDK_ACTION_COPY); + gtk_drag_source_set( widget, GDK_BUTTON1_MASK, 0, 0, GDK_ACTION_COPY); + dd.handler_map = dynv_system_get_handler_map(gs->colors->params); + dd.userdata2 = (void*)2; + dragdrop_widget_attach(widget, DragDropFlags(DRAGDROP_SOURCE | DRAGDROP_DESTINATION), &dd); + + table_y++; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("End:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->end_color = widget = gtk_color_new(); + gtk_color_set_color(GTK_COLOR(args->end_color), dynv_get_color_wdc(args->params, "end_color", &c), ""); + gtk_color_set_rounded(GTK_COLOR(widget), true); + gtk_color_set_hcenter(GTK_COLOR(widget), true); + gtk_color_set_roundness(GTK_COLOR(widget), 5); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0); + + gtk_drag_dest_set( widget, GtkDestDefaults(GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT), 0, 0, GDK_ACTION_COPY); + gtk_drag_source_set( widget, GDK_BUTTON1_MASK, 0, 0, GDK_ACTION_COPY); + dd.handler_map = dynv_system_get_handler_map(gs->colors->params); + dd.userdata2 = (void*)3; + dragdrop_widget_attach(widget, DragDropFlags(DRAGDROP_SOURCE | DRAGDROP_DESTINATION), &dd); + + table_y = 0; + + GtkWidget* vbox = gtk_vbox_new(false, 0); + gtk_box_pack_start(GTK_BOX(vbox), gtk_label_aligned_new(_("Type:"),0,0,0,0), false, false, 0); + args->mix_type = mix_type = gtk_combo_box_new_text(); + gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), _("RGB")); + gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), _("HSV")); + gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), _("HSV shortest hue distance")); + gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), _("LAB")); + gtk_combo_box_set_active(GTK_COMBO_BOX(mix_type), dynv_get_int32_wd(args->params, "type", 0)); + gtk_box_pack_start(GTK_BOX(vbox), mix_type, false, false, 0); + g_signal_connect(G_OBJECT(mix_type), "changed", G_CALLBACK (update), args); + gtk_table_attach(GTK_TABLE(table), vbox, 4, 5, table_y, table_y+3, GtkAttachOptions(GTK_FILL),GtkAttachOptions(GTK_FILL),5,0); + + table_y = 0; + + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Start steps:"),0,0,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + mix_steps = gtk_spin_button_new_with_range (1,255,1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mix_steps), dynv_get_int32_wd(args->params, "steps1", 3)); + gtk_table_attach(GTK_TABLE(table), mix_steps,3,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + table_y++; + args->steps1 = mix_steps; + g_signal_connect(G_OBJECT(mix_steps), "value-changed", G_CALLBACK (update), args); + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("End steps:"),0,0,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + mix_steps = gtk_spin_button_new_with_range (1,255,1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mix_steps), dynv_get_int32_wd(args->params, "steps2", 3)); + gtk_table_attach(GTK_TABLE(table), mix_steps,3,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + table_y++; + args->steps2 = mix_steps; + g_signal_connect(G_OBJECT(mix_steps), "value-changed", G_CALLBACK (update), args); + + table_y = 3; + + GtkWidget* preview; + struct ColorList* preview_color_list = NULL; + gtk_table_attach(GTK_TABLE(table), preview = palette_list_preview_new(gs, false, false, gs->colors, &preview_color_list), 0, 5, table_y, table_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); + + args->preview_list = palette_list_get_widget(preview_color_list); + + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(args->preview_list)); + gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); + + g_signal_connect(G_OBJECT(args->preview_list), "button-press-event", G_CALLBACK(preview_list_button_press_cb), args); + table_y++; + + args->preview_color_list = preview_color_list; + + update(0, args); + + gtk_widget_show_all(table); + + args->main = table; + args->source.widget = table; + + return (ColorSource*)args; +} + + +int blend_colors_source_register(ColorSourceManager *csm){ + ColorSource *color_source = new ColorSource; + color_source_init(color_source, "blend_colors", _("Blend colors")); + color_source->implement = (ColorSource* (*)(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace))source_implement; + color_source->default_accelerator = GDK_b; + color_source_manager_add_source(csm, color_source); + return 0; +} + diff -Nru gpick-0.2.4/source/BlendColors.h gpick-0.2.5/source/BlendColors.h --- gpick-0.2.4/source/BlendColors.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/BlendColors.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef BLEND_COLORS_H_ +#define BLEND_COLORS_H_ + +#include "ColorSourceManager.h" + +int blend_colors_source_register(ColorSourceManager *csm); + +#endif /* BLEND_COLORS_H_ */ + + + diff -Nru gpick-0.2.4/source/BrightnessDarkness.cpp gpick-0.2.5/source/BrightnessDarkness.cpp --- gpick-0.2.4/source/BrightnessDarkness.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/BrightnessDarkness.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,6 +20,7 @@ #include "DragDrop.h" #include "GlobalStateStruct.h" +#include "ToolColorNaming.h" #include "uiUtilities.h" #include "ColorList.h" #include "MathUtil.h" @@ -30,6 +31,7 @@ #include "CopyPaste.h" #include "Converter.h" #include "DynvHelpers.h" +#include "Internationalisation.h" #include "gtk/LayoutPreview.h" #include "layout/Layout.h" @@ -38,6 +40,7 @@ #include "uiApp.h" #include +#include #include #include @@ -65,6 +68,25 @@ GlobalState* gs; }BrightnessDarknessArgs; +class BrightnessDarknessColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + const char *m_ident; + public: + BrightnessDarknessColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + } + + void assign(struct ColorObject *color_object, Color *color, const char *ident){ + m_ident = ident; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << color_names_get(m_gs->color_names, color, false) << " " << _("brightness darkness") << " " << m_ident; + return m_stream.str(); + } +}; static void calc(BrightnessDarknessArgs *args, bool preview, bool save_settings){ double brightness = gtk_range_2d_get_x(GTK_RANGE_2D(args->brightness_darkness)); @@ -80,14 +102,14 @@ color_rgb_to_hsl(&color, &hsl_orig); Box* box; - char tmp[4]; + string name; for (int i = 1; i <= 4; i++){ color_copy(&hsl_orig, &hsl); hsl.hsl.lightness = mix_float(hsl.hsl.lightness, mix_float(hsl.hsl.lightness, 1, brightness), i / 4.0); //clamp_float(hsl.hsl.lightness + brightness / 8.0 * i, 0, 1); color_hsl_to_rgb(&hsl, &r); - snprintf(tmp, sizeof(tmp), "b%d", i); - box = args->layout_system->GetNamedBox(tmp); + name = boost::str(boost::format("b%d") % i); + box = args->layout_system->GetNamedBox(name.c_str()); if (box && box->style){ color_copy(&r, &box->style->color); } @@ -97,8 +119,8 @@ hsl.hsl.lightness = mix_float(hsl.hsl.lightness, mix_float(hsl.hsl.lightness, 0, darkness), i / 4.0); //clamp_float(hsl.hsl.lightness - darkness / 8.0 * i, 0, 1); color_hsl_to_rgb(&hsl, &r); - snprintf(tmp, sizeof(tmp), "c%d", i); - box = args->layout_system->GetNamedBox(tmp); + name = boost::str(boost::format("c%d") % i); + box = args->layout_system->GetNamedBox(name.c_str()); if (box && box->style){ color_copy(&r, &box->style->color); } @@ -114,12 +136,16 @@ } static int source_get_color(BrightnessDarknessArgs *args, struct ColorObject** color){ + Style* style = 0; Color c; if (gtk_layout_preview_get_current_color(GTK_LAYOUT_PREVIEW(args->layout_view), &c) == 0){ + if (gtk_layout_preview_get_current_style(GTK_LAYOUT_PREVIEW(args->layout_view), &style) != 0){ + return -1; + } *color = color_list_new_color_object(args->gs->colors, &c); - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string((*color)->params, "name", name.c_str()); + BrightnessDarknessColorNameAssigner name_assigner(args->gs); + name_assigner.assign(*color, &c, style->human_name.c_str()); return 0; } return -1; @@ -191,20 +217,18 @@ struct ColorObject *color_object; if (source_get_color(args, &color_object)==0){ - dynv_set_string(color_object->params, "name", ""); color_list_add_color_object(args->gs->colors, color_object, 1); color_object_release(color_object); } } static void add_all_to_palette_cb(GtkWidget *widget, BrightnessDarknessArgs *args) { - struct ColorObject *color_object; + BrightnessDarknessColorNameAssigner name_assigner(args->gs); for (list::iterator i = args->layout_system->styles.begin(); i != args->layout_system->styles.end(); i++){ - color_object = color_list_new_color_object(args->gs->colors, &(*i)->color); - dynv_set_string(color_object->params, "name", (*i)->ident_name.c_str()); + name_assigner.assign(color_object, &(*i)->color, (*i)->human_name.c_str()); color_list_add_color_object(args->gs->colors, color_object, 1); color_object_release(color_object); } @@ -233,18 +257,18 @@ bool selection_avail = gtk_layout_preview_is_selected(GTK_LAYOUT_PREVIEW(args->layout_view)); bool edit_avail = gtk_layout_preview_is_editable(GTK_LAYOUT_PREVIEW(args->layout_view)); - item = gtk_menu_item_new_with_image ("_Add to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Add to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (add_to_palette_cb), args); if (!selection_avail) gtk_widget_set_sensitive(item, false); - item = gtk_menu_item_new_with_image ("_Add all to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("A_dd all to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (add_all_to_palette_cb), args); gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_mnemonic ("_Copy to clipboard"); + item = gtk_menu_item_new_with_mnemonic (_("_Copy to clipboard")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); if (selection_avail){ @@ -260,12 +284,12 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_image ("_Edit...", gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Edit..."), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (edit_cb), args); if (!selection_avail) gtk_widget_set_sensitive(item, false); - item = gtk_menu_item_new_with_image ("_Paste", gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Paste"), gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (paste_cb), args); if (!selection_avail) gtk_widget_set_sensitive(item, false); @@ -311,6 +335,10 @@ } static int source_activate(BrightnessDarknessArgs *args){ + + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + gtk_layout_preview_set_transformation_chain(GTK_LAYOUT_PREVIEW(args->layout_view), chain); + gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "empty"), ""); return 0; } @@ -318,7 +346,7 @@ static int source_deactivate(BrightnessDarknessArgs *args){ dynv_set_color(args->params, "color", &args->color); calc(args, true, true); - return 0; + return 0; } static ColorSource* source_implement(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace){ @@ -354,7 +382,7 @@ args->brightness_darkness = widget = gtk_range_2d_new(); gtk_range_2d_set_values(GTK_RANGE_2D(widget), dynv_get_float_wd(dynv_namespace, "brightness", 0.5), dynv_get_float_wd(dynv_namespace, "darkness", 0.5)); - gtk_range_2d_set_axis(GTK_RANGE_2D(widget), "Brightness", "Darkness"); + gtk_range_2d_set_axis(GTK_RANGE_2D(widget), _("Brightness"), _("Darkness")); g_signal_connect(G_OBJECT(widget), "values_changed", G_CALLBACK(update), args); gtk_box_pack_start(GTK_BOX(hbox), widget, false, false, 0); @@ -385,7 +413,7 @@ color_copy(color, &args->color); gtk_layout_preview_set_color_named(GTK_LAYOUT_PREVIEW(args->layout_view), color, "main"); - calc(args, true, false); + calc(args, true, false); gtk_widget_show_all(hbox); @@ -399,10 +427,11 @@ } int brightness_darkness_source_register(ColorSourceManager *csm){ - ColorSource *color_source = new ColorSource; - color_source_init(color_source, "brightness_darkness", "Brightness Darkness"); + ColorSource *color_source = new ColorSource; + color_source_init(color_source, "brightness_darkness", _("Brightness Darkness")); color_source->implement = (ColorSource* (*)(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace))source_implement; - color_source_manager_add_source(csm, color_source); + color_source->default_accelerator = GDK_d; + color_source_manager_add_source(csm, color_source); return 0; } diff -Nru gpick-0.2.4/source/BrightnessDarkness.h gpick-0.2.5/source/BrightnessDarkness.h --- gpick-0.2.4/source/BrightnessDarkness.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/BrightnessDarkness.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ChangeNotification.cpp gpick-0.2.5/source/ChangeNotification.cpp --- gpick-0.2.4/source/ChangeNotification.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ChangeNotification.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -51,12 +51,12 @@ return false; } -bool ChangeNotification::addLink(shared_ptr notification_link){ - links.insert(pair >(notification_link->source_name, notification_link)); +bool ChangeNotification::addLink(boost::shared_ptr notification_link){ + links.insert(pair >(notification_link->source_name, notification_link)); return true; } -bool ChangeNotification::removeLink(shared_ptr notification_link){ +bool ChangeNotification::removeLink(boost::shared_ptr notification_link){ return true; } diff -Nru gpick-0.2.4/source/ChangeNotification.h gpick-0.2.5/source/ChangeNotification.h --- gpick-0.2.4/source/ChangeNotification.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ChangeNotification.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -26,7 +26,6 @@ #include #include -using namespace boost; class ChangeNotification; @@ -47,7 +46,7 @@ class ChangeNotification{ protected: std::map sources; - std::multimap > links; + std::multimap > links; public: ChangeNotification(); ~ChangeNotification(); @@ -55,8 +54,8 @@ bool registerSource(const char *location, ColorSource *source); bool unregisterSource(const char *location, ColorSource *source); - bool addLink(shared_ptr notification_link); - bool removeLink(shared_ptr notification_link); + bool addLink(boost::shared_ptr notification_link); + bool removeLink(boost::shared_ptr notification_link); }; #endif /* CHANGENOTIFICATION_H_ */ diff -Nru gpick-0.2.4/source/Color.cpp gpick-0.2.5/source/Color.cpp --- gpick-0.2.4/source/Color.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Color.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -23,8 +23,41 @@ #include using namespace std; -void -color_rgb_to_hsv(Color* a, Color* b) +// Constant used for lab->xyz transform. Should be calculated with maximum accuracy possible. +#define EPSILON (216.0 / 24389.0) + +static vector3 references[][2] = { + {{{{109.850, 100.000, 35.585}}}, {{{111.144, 100.000, 35.200}}}}, + {{{{ 98.074, 100.000, 118.232}}}, {{{ 97.285, 100.000, 116.145}}}}, + {{{{ 96.422, 100.000, 82.521}}}, {{{ 96.720, 100.000, 81.427}}}}, + {{{{ 95.682, 100.000, 92.149}}}, {{{ 95.799, 100.000, 90.926}}}}, + {{{{ 95.047, 100.000, 108.883}}}, {{{ 94.811, 100.000, 107.304}}}}, + {{{{ 94.972, 100.000, 122.638}}}, {{{ 94.416, 100.000, 120.641}}}}, + {{{{ 99.187, 100.000, 67.395}}}, {{{103.280, 100.000, 69.026}}}}, + {{{{ 95.044, 100.000, 108.755}}}, {{{ 95.792, 100.000, 107.687}}}}, + {{{{100.966, 100.000, 64.370}}}, {{{103.866, 100.000, 65.627}}}}, +}; + +static matrix3x3 sRGB_transformation; +static matrix3x3 sRGB_transformation_inverted; + +static matrix3x3 d65_d50_adaptation_matrix; +static matrix3x3 d50_d65_adaptation_matrix; + + +void color_init() +{ + // constants used below are sRGB working space red, green and blue primaries for D65 reference white + color_get_working_space_matrix(0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), &sRGB_transformation); + matrix3x3_inverse(&sRGB_transformation, &sRGB_transformation_inverted); + + color_get_chromatic_adaptation_matrix(color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), color_get_reference(REFERENCE_ILLUMINANT_D50, REFERENCE_OBSERVER_2), &d65_d50_adaptation_matrix); + color_get_chromatic_adaptation_matrix(color_get_reference(REFERENCE_ILLUMINANT_D50, REFERENCE_OBSERVER_2), color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), &d50_d65_adaptation_matrix); + +} + + +void color_rgb_to_hsv(const Color* a, Color* b) { float min, max, delta; @@ -60,8 +93,7 @@ } -void -color_hsv_to_rgb(Color* a, Color* b) +void color_hsv_to_rgb(const Color* a, Color* b) { float h,v, f, x, y, z; int i; @@ -109,8 +141,7 @@ } } -void -color_rgb_to_xyz(Color* a, Color* b, matrix3x3* transformation) +void color_rgb_to_xyz(const Color* a, Color* b, const matrix3x3* transformation) { float R=a->rgb.red, G=a->rgb.green, B=a->rgb.blue; @@ -144,8 +175,7 @@ b->xyz.z = rgb.z; } -void -color_xyz_to_rgb(Color* a, Color* b, matrix3x3* transformation_inverted) +void color_xyz_to_rgb(const Color* a, Color* b, const matrix3x3* transformation_inverted) { vector3 rgb; float R,G,B; @@ -156,17 +186,17 @@ B=rgb.z; if (R>0.0031308){ - R=1.055*(pow(R,1/2.4))-0.055; + R=1.055*(pow(R,1/2.4f))-0.055; }else{ R=12.92*R; } if (G>0.0031308){ - G=1.055*(pow(G,1/2.4))-0.055; + G=1.055*(pow(G,1/2.4f))-0.055; }else{ G=12.92*G; } if(B>0.0031308){ - B=1.055*(pow(B,1/2.4))-0.055; + B=1.055*(pow(B,1/2.4f))-0.055; }else{ B=12.92*B; } @@ -178,76 +208,61 @@ -void -color_rgb_to_lab(Color* a, Color* b, vector3* reference_white, matrix3x3* transformation) +void color_rgb_to_lab(const Color* a, Color* b, const vector3* reference_white, const matrix3x3* transformation, const matrix3x3* adaptation_matrix) { Color c; color_rgb_to_xyz(a, &c, transformation); + color_xyz_chromatic_adaptation(&c, &c, adaptation_matrix); color_xyz_to_lab(&c, b, reference_white); } -void -color_lab_to_rgb(Color* a, Color* b, vector3* reference_white, matrix3x3* transformation_inverted) +void color_lab_to_rgb(const Color* a, Color* b, const vector3* reference_white, const matrix3x3* transformation_inverted, const matrix3x3* adaptation_matrix_inverted) { Color c; color_lab_to_xyz(a, &c, reference_white); + color_xyz_chromatic_adaptation(&c, &c, adaptation_matrix_inverted); color_xyz_to_rgb(&c, b, transformation_inverted); } -void -color_copy(Color* a, Color* b) +void color_copy(const Color* a, Color* b) { - b->m.m1=a->m.m1; - b->m.m2=a->m.m2; - b->m.m3=a->m.m3; - b->m.m4=a->m.m4; + b->m.m1 = a->m.m1; + b->m.m2 = a->m.m2; + b->m.m3 = a->m.m3; + b->m.m4 = a->m.m4; } -void -color_add(Color* a, Color* b) +void color_add(Color* a, const Color* b) { - a->m.m1+=b->m.m1; - a->m.m2+=b->m.m2; - a->m.m3+=b->m.m3; - a->m.m4+=b->m.m4; + a->m.m1 += b->m.m1; + a->m.m2 += b->m.m2; + a->m.m3 += b->m.m3; + a->m.m4 += b->m.m4; } -void -color_multiply(Color* a, float b) +void color_multiply(Color* a, float b) { - a->m.m1*=b; - a->m.m2*=b; - a->m.m3*=b; - a->m.m4*=b; + a->m.m1 *= b; + a->m.m2 *= b; + a->m.m3 *= b; + a->m.m4 *= b; } -void -color_zero(Color* a) +void color_zero(Color* a) { - a->m.m1=0; - a->m.m2=0; - a->m.m3=0; - a->m.m4=0; + a->m.m1 = 0; + a->m.m2 = 0; + a->m.m3 = 0; + a->m.m4 = 0; } void -color_get_contrasting(Color* a, Color* b) +color_get_contrasting(const Color* a, Color* b) { Color t; + color_rgb_to_lab(a, &t, color_get_reference(REFERENCE_ILLUMINANT_D50, REFERENCE_OBSERVER_2), &sRGB_transformation, &d65_d50_adaptation_matrix); - static vector3 d65={ - {{95.047, 100.000, 108.883}} - }; - static matrix3x3 transformation={{ //sRGB transformation matrix - {0.4124564, 0.3575761, 0.1804375}, - {0.2126729, 0.7151522, 0.0721750}, - {0.0193339, 0.1191920, 0.9503041}, - }}; - - color_rgb_to_lab(a, &t, &d65, &transformation); - - - if (t.lab.L>3){ + if (t.lab.L > 50){ t.hsv.value=0; }else{ t.hsv.value=1; @@ -259,21 +274,23 @@ color_hsv_to_rgb(&t, b); } -void -color_set(Color* a, float value) +void color_set(Color* a, float value) { a->rgb.red = a->rgb.green = a->rgb.blue = value; } -Color* color_new() { +Color* color_new() +{ return new Color; } -void color_destroy(Color *a) { +void color_destroy(Color *a) +{ delete a; } -void color_rgb_to_hsl(Color* a, Color* b) { +void color_rgb_to_hsl(const Color* a, Color* b) +{ float min, max, delta; min = min_float_3(a->rgb.red, a->rgb.green, a->rgb.blue); @@ -310,7 +327,8 @@ } -void color_hsl_to_rgb(Color* a, Color* b) { +void color_hsl_to_rgb(const Color* a, Color* b) +{ if (a->hsl.saturation == 0) { b->rgb.red = b->rgb.green = b->rgb.blue = a->hsl.lightness; } else { @@ -361,57 +379,94 @@ } } -void color_lab_to_lch(Color* a, Color* b) { - float H; - H = atan2(a->lab.b, a->lab.a); +void color_lab_to_lch(const Color* a, Color* b) +{ + double H; + if (a->lab.a == 0 && a->lab.b == 0){ + H = 0; + }else{ + H = atan2(a->lab.b, a->lab.a); + } - if (H > 0) - H /= PI; - else - H = (2*PI - abs_float(H))/PI; + H *= 180.0 / PI; + + if (H < 0) H += 360; + if (H >= 360) H -= 360; b->lch.L = a->lab.L; - b->lch.C = sqrt(a->lab.b * a->lab.b + a->lab.a * a->lab.a); + b->lch.C = sqrt(a->lab.a * a->lab.a + a->lab.b * a->lab.b); b->lch.h = H; } -void color_rgb_to_lch(Color* a, Color* b){ +void color_lch_to_lab(const Color* a, Color* b) +{ + b->lab.L = a->lch.L; + b->lab.a = a->lch.C * cos(a->lch.h * PI / 180.0); + b->lab.b = a->lch.C * sin(a->lch.h * PI / 180.0); +} + +void color_rgb_to_lch_d50(const Color* a, Color* b) +{ Color c; + color_rgb_to_lab(a, &c, color_get_reference(REFERENCE_ILLUMINANT_D50, REFERENCE_OBSERVER_2), &sRGB_transformation, &d65_d50_adaptation_matrix); + color_lab_to_lch(&c, b); +} - static vector3 d65={ - {{95.047, 100.000, 108.883}} - }; - static matrix3x3 transformation={{ //sRGB transformation matrix - {0.4124564, 0.3575761, 0.1804375}, - {0.2126729, 0.7151522, 0.0721750}, - {0.0193339, 0.1191920, 0.9503041} - }}; +void color_lch_to_rgb_d50(const Color* a, Color* b) +{ + Color c; + color_lch_to_lab(a, &c); + color_lab_to_rgb(&c, b, color_get_reference(REFERENCE_ILLUMINANT_D50, REFERENCE_OBSERVER_2), &sRGB_transformation_inverted, &d50_d65_adaptation_matrix); +} - color_rgb_to_lab(a, &c, &d65, &transformation); +void color_rgb_to_lch(const Color* a, Color* b, const vector3* reference_white, const matrix3x3* transformation, const matrix3x3* adaptation_matrix) +{ + Color c; + color_rgb_to_lab(a, &c, reference_white, transformation, adaptation_matrix); color_lab_to_lch(&c, b); } -void color_xyz_to_lab(Color* a, Color* b, vector3* reference_white){ +void color_lch_to_rgb(const Color* a, Color* b, const vector3* reference_white, const matrix3x3* transformation_inverted, const matrix3x3* adaptation_matrix_inverted) +{ + Color c; + color_lch_to_lab(a, &c); + color_lab_to_rgb(&c, b, reference_white, transformation_inverted, adaptation_matrix_inverted); +} + +void color_rgb_to_lab_d50(const Color* a, Color* b) +{ + color_rgb_to_lab(a, b, color_get_reference(REFERENCE_ILLUMINANT_D50, REFERENCE_OBSERVER_2), &sRGB_transformation, &d65_d50_adaptation_matrix); +} + +void color_lab_to_rgb_d50(const Color* a, Color* b) +{ + color_lab_to_rgb(a, b, color_get_reference(REFERENCE_ILLUMINANT_D50, REFERENCE_OBSERVER_2), &sRGB_transformation_inverted, &d50_d65_adaptation_matrix); +} + +#define Kk (24389.0 / 27.0) + +void color_xyz_to_lab(const Color* a, Color* b, const vector3* reference_white) +{ float X,Y,Z; X = a->xyz.x / reference_white->x; //95.047f; Y = a->xyz.y / reference_white->y; //100.000f; Z = a->xyz.z / reference_white->z; //108.883f; - if (X>0.008856){ - X=pow(X,1.0/3.0); + if (X>EPSILON){ + X=pow(X,1.0f/3.0f); }else{ - X=(7.787*X)+(16.0/116.0); + X=(Kk*X+16.0f)/116.0f; } - if (Y>0.008856){ - Y=pow(Y,1.0/3.0); + if (Y>EPSILON){ + Y=pow(Y,1.0f/3.0f); }else{ - Y=(7.787*Y)+(16.0/116.0); + Y=(Kk*Y+16.0f)/116.0f; } - if (Z>0.008856){ - Z=pow(Z,1.0/3.0); + if (Z>EPSILON){ + Z=pow(Z,1.0f/3.0f); }else{ - Z=(7.787*Z)+(16.0/116.0); + Z=(Kk*Z+16.0f)/116.0f; } b->lab.L=(116*Y)-16; @@ -420,29 +475,29 @@ } -void color_lab_to_xyz(Color* a, Color* b, vector3* reference_white) { +void color_lab_to_xyz(const Color* a, Color* b, const vector3* reference_white) +{ float x, y, z; float fy = (a->lab.L + 16) / 116; float fx = a->lab.a / 500 + fy; float fz = fy - a->lab.b / 200; - float e=0.008856; - float K=903.3; + const double K=(24389.0 / 27.0); - if (pow(fx, 3)>e){ + if (pow(fx, 3)>EPSILON){ x=pow(fx, 3); }else{ x=(116*fx-16)/K; } - if (a->lab.L > K*e){ + if (a->lab.L > K*EPSILON){ y=pow((a->lab.L+16)/116, 3); }else{ y=a->lab.L/K; } - if (pow(fz, 3)>e){ + if (pow(fz, 3)>EPSILON){ z=pow(fz, 3); }else{ z=(116*fz-16)/K; @@ -453,7 +508,8 @@ b->xyz.z = z * reference_white->z; //108.883f; } -void color_get_working_space_matrix(float xr, float yr, float xg, float yg, float xb, float yb, vector3* reference_white, matrix3x3* result){ +void color_get_working_space_matrix(float xr, float yr, float xg, float yg, float xb, float yb, const vector3* reference_white, matrix3x3* result) +{ float Xr,Yr,Zr; float Xg,Yg,Zg; float Xb,Yb,Zb; @@ -489,7 +545,8 @@ result->m[0][2]=Xb*v.z; result->m[1][2]=Yb*v.z; result->m[2][2]=Zb*v.z; } -void color_get_chromatic_adaptation_matrix(vector3* source_reference_white, vector3* destination_reference_white, matrix3x3* result){ +void color_get_chromatic_adaptation_matrix(const vector3* source_reference_white, const vector3* destination_reference_white, matrix3x3* result) +{ matrix3x3 Ma; //Bradford matrix @@ -517,7 +574,8 @@ matrix3x3_multiply(&M, &Ma_inv, result); } -void color_xyz_chromatic_adaptation(Color* a, Color* result, matrix3x3* adaptation ){ +void color_xyz_chromatic_adaptation(const Color* a, Color* result, const matrix3x3* adaptation) +{ vector3 x; x.x=a->xyz.x; x.y=a->xyz.y; @@ -528,19 +586,22 @@ result->xyz.z=x.z; } -void color_rgb_to_cmy(Color* a, Color* b){ +void color_rgb_to_cmy(const Color* a, Color* b) +{ b->cmy.c = 1 - a->rgb.red; b->cmy.m = 1 - a->rgb.green; b->cmy.y = 1 - a->rgb.blue; } -void color_cmy_to_rgb(Color* a, Color* b){ +void color_cmy_to_rgb(const Color* a, Color* b) +{ b->rgb.red = 1 - a->cmy.c; b->rgb.green = 1 - a->cmy.m; b->rgb.blue = 1 - a->cmy.y; } -void color_cmy_to_cmyk(Color* a, Color* b){ +void color_cmy_to_cmyk(const Color* a, Color* b) +{ float k = 1; if (a->cmy.c < k) k = a->cmy.c; @@ -557,33 +618,38 @@ b->cmyk.k = k; } -void color_cmyk_to_cmy(Color* a, Color* b){ +void color_cmyk_to_cmy(const Color* a, Color* b) +{ b->cmy.c = (a->cmyk.c * (1 - a->cmyk.k) + a->cmyk.k); b->cmy.m = (a->cmyk.m * (1 - a->cmyk.k) + a->cmyk.k); b->cmy.y = (a->cmyk.y * (1 - a->cmyk.k) + a->cmyk.k); } -void color_rgb_to_cmyk(Color* a, Color* b){ +void color_rgb_to_cmyk(const Color* a, Color* b) +{ Color c; color_rgb_to_cmy(a, &c); color_cmy_to_cmyk(&c, b); } -void color_cmyk_to_rgb(Color* a, Color* b){ +void color_cmyk_to_rgb(const Color* a, Color* b) +{ Color c; color_cmyk_to_cmy(a, &c); color_cmy_to_rgb(&c, b); } -void color_rgb_normalize(Color* a){ +void color_rgb_normalize(Color* a) +{ a->rgb.red = clamp_float(a->rgb.red, 0, 1); a->rgb.green = clamp_float(a->rgb.green, 0, 1); a->rgb.blue = clamp_float(a->rgb.blue, 0, 1); } -void color_hsl_to_hsv(Color *a, Color *b){ - float l = a->hsl.lightness * 2.0; +void color_hsl_to_hsv(const Color *a, Color *b) +{ + float l = a->hsl.lightness * 2.0; float s = a->hsl.saturation * ((l <= 1.0) ? (l) : (2.0 - l)); b->hsv.hue = a->hsl.hue; @@ -596,7 +662,8 @@ } } -void color_hsv_to_hsl(Color *a, Color *b){ +void color_hsv_to_hsl(const Color *a, Color *b) +{ float l = (2.0 - a->hsv.saturation) * a->hsv.value; float s = (a->hsv.saturation * a->hsv.value) / ((l <= 1.0) ? (l) : (2 - l)); if (l == 0) s = 0; @@ -606,3 +673,93 @@ b->hsl.lightness = l / 2.0; } +void color_rgb_get_linear(const Color* a, Color* b) +{ + b->rgb.red = pow(a->rgb.red, 1.0f / 2.1f); + b->rgb.green = pow(a->rgb.green, 1.0f / 2.0f); + b->rgb.blue = pow(a->rgb.blue, 1.0f / 2.1f); +} + +void color_linear_get_rgb(const Color* a, Color* b) +{ + b->rgb.red = pow(a->rgb.red, 2.1f); + b->rgb.green = pow(a->rgb.green, 2.0f); + b->rgb.blue = pow(a->rgb.blue, 2.1f); +} + +const matrix3x3* color_get_sRGB_transformation_matrix() +{ + return &sRGB_transformation; +} + +const matrix3x3* color_get_inverted_sRGB_transformation_matrix() +{ + return &sRGB_transformation_inverted; +} + +const matrix3x3* color_get_d65_d50_adaptation_matrix() +{ + return &d65_d50_adaptation_matrix; +} + +const matrix3x3* color_get_d50_d65_adaptation_matrix() +{ + return &d50_d65_adaptation_matrix; +} + +const vector3* color_get_reference(ReferenceIlluminant illuminant, ReferenceObserver observer) +{ + return &references[illuminant][observer]; +} + +const ReferenceIlluminant color_get_illuminant(const char *illuminant) +{ + const struct{ + const char *label; + ReferenceIlluminant illuminant; + }illuminants[] = { + {"A", REFERENCE_ILLUMINANT_A}, + {"C", REFERENCE_ILLUMINANT_C}, + {"D50", REFERENCE_ILLUMINANT_D50}, + {"D55", REFERENCE_ILLUMINANT_D55}, + {"D65", REFERENCE_ILLUMINANT_D65}, + {"D75", REFERENCE_ILLUMINANT_D75}, + {"F2", REFERENCE_ILLUMINANT_F2}, + {"F7", REFERENCE_ILLUMINANT_F7}, + {"F11", REFERENCE_ILLUMINANT_F11}, + {0, REFERENCE_ILLUMINANT_D50}, + }; + for (int i = 0; illuminants[i].label; i++){ + if (string(illuminants[i].label).compare(illuminant) == 0){ + return illuminants[i].illuminant; + } + } + return REFERENCE_ILLUMINANT_D50; +}; + +const ReferenceObserver color_get_observer(const char *observer) +{ + const struct{ + const char *label; + ReferenceObserver observer; + }observers[] = { + {"2", REFERENCE_OBSERVER_2}, + {"10", REFERENCE_OBSERVER_10}, + {0, REFERENCE_OBSERVER_2}, + }; + for (int i = 0; observers[i].label; i++){ + if (string(observers[i].label).compare(observer) == 0){ + return observers[i].observer; + } + } + return REFERENCE_OBSERVER_2; +} + +bool color_is_rgb_out_of_gamut(const Color* a) +{ + if (a->rgb.red < 0 || a->rgb.red > 1) return true; + if (a->rgb.green < 0 || a->rgb.green > 1) return true; + if (a->rgb.blue < 0 || a->rgb.blue > 1) return true; + return false; +} + diff -Nru gpick-0.2.4/source/Color.h gpick-0.2.5/source/Color.h --- gpick-0.2.4/source/Color.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Color.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,12 +21,12 @@ #include "MathUtil.h" -/** \file Color.h - * \brief Color structure and functions to convert colors from one colorspace to another +/** \file source/Color.h + * \brief Color structure and functions to convert colors from one color space to another. */ /** \struct Color - * \brief Color structure is an union of all available colorspaces + * \brief Color structure is an union of all available color spaces. */ typedef struct Color{ union{ @@ -76,95 +76,394 @@ float m2; float m3; float m4; - }m; - float ma[4]; + }m; /**< General data access structure */ + float ma[4]; /**< General data access array */ }; }Color; +/** \enum ReferenceIlluminant + * \brief Reference illuminants. + */ +enum ReferenceIlluminant { + REFERENCE_ILLUMINANT_A = 0, + REFERENCE_ILLUMINANT_C = 1, + REFERENCE_ILLUMINANT_D50 = 2, + REFERENCE_ILLUMINANT_D55 = 3, + REFERENCE_ILLUMINANT_D65 = 4, + REFERENCE_ILLUMINANT_D75 = 5, + REFERENCE_ILLUMINANT_F2 = 6, + REFERENCE_ILLUMINANT_F7 = 7, + REFERENCE_ILLUMINANT_F11 = 8, +}; + +/** \enum ReferenceObserver + * \brief Reference observers. + */ +enum ReferenceObserver { + REFERENCE_OBSERVER_2 = 0, + REFERENCE_OBSERVER_10 = 1, +}; + + +/** + * Initialize things needed for color conversion functions. Must be called before using any other functions. + */ +void color_init(); + +/** + * Convert RGB color space to HSL color space. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in HSL color space. + */ +void color_rgb_to_hsl(const Color* a, Color* b); + +/** + * Convert HSL color space to RGB color space. + * @param[in] a Source color in HSL color space. + * @param[out] b Destination color in RGB color space. + */ +void color_hsl_to_rgb(const Color* a, Color* b); + +/** + * Convert HSL color space to HSV color space. + * @param[in] a Source color in HSL color space. + * @param[out] b Destination color in HSV color space. + */ +void color_hsl_to_hsv(const Color *a, Color *b); + /** - * Convert RGB colorspace to HSL colorspace - * @param[in] a Source color in RGB colorspace - * @param[out] b Destination color in HSL colorspace + * Convert HSV color space to HSL color space. + * @param[in] a Source color in HSV color space. + * @param[out] b Destination color in HSL color space. */ -void color_rgb_to_hsl(Color* a, Color* b); +void color_hsv_to_hsl(const Color *a, Color *b); /** - * Convert HSL colorspace to RGB colorspace - * @param[in] a Source color in HSL colorspace - * @param[out] b Destination color in RGB colorspace + * Convert RGB color space to HSV color space. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in HSV color space. */ -void color_hsl_to_rgb(Color* a, Color* b); +void color_rgb_to_hsv(const Color* a, Color* b); /** - * Convert HSL colorspace to HSV colorspace - * @param[in] a Source color in HSL colorspace - * @param[out] b Destination color in HSV colorspace + * Convert HSV color space to RGB color space. + * @param[in] a Source color in HSV color space. + * @param[out] b Destination color in RGB color space. */ -void color_hsl_to_hsv(Color *a, Color *b); +void color_hsv_to_rgb(const Color* a, Color* b); /** - * Convert HSV colorspace to HSL colorspace - * @param[in] a Source color in HSV colorspace - * @param[out] b Destination color in HSL colorspace + * Convert RGB color space to XYZ color space. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in XYZ color space. + * @param[in] transformation Transformation matrix for RGB to XYZ conversion. */ -void color_hsv_to_hsl(Color *a, Color *b); +void color_rgb_to_xyz(const Color* a, Color* b, const matrix3x3* transformation); /** - * Convert RGB colorspace to HSV colorspace - * @param[in] a Source color in RGB colorspace - * @param[out] b Destination color in HSV colorspace + * Convert XYZ color space to RGB color space. + * @param[in] a Source color in XYZ color space. + * @param[out] b Destination color in RGB color space. + * @param[in] transformation_inverted Transformation matrix for XYZ to RGB conversion. */ -void color_rgb_to_hsv(Color* a, Color* b); +void color_xyz_to_rgb(const Color* a, Color* b, const matrix3x3* transformation_inverted); /** - * Convert HSV colorspace to RGB colorspace - * @param[in] a Source color in HSV colorspace - * @param[out] b Destination color in RGB colorspace + * Convert XYZ color space to Lab color space. + * @param[in] a Source color in XYZ color space. + * @param[out] b Destination color in Lab color space. + * @param[in] reference_white Reference white color values. */ -void color_hsv_to_rgb(Color* a, Color* b); +void color_xyz_to_lab(const Color* a, Color* b, const vector3* reference_white); -void color_rgb_to_xyz(Color* a, Color* b, matrix3x3* transformation); -void color_xyz_to_rgb(Color* a, Color* b, matrix3x3* transformation_inverted); +/** + * Convert Lab color space to XYZ color space. + * @param[in] a Source color in Lab color space. + * @param[out] b Destination color in XYZ color space. + * @param[in] reference_white Reference white color values. + */ +void color_lab_to_xyz(const Color* a, Color* b, const vector3* reference_white); -void color_xyz_to_lab(Color* a, Color* b, vector3* reference_white); -void color_lab_to_xyz(Color* a, Color* b, vector3* reference_white); +/** + * Convert RGB color space to Lab color space. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in Lab color space. + * @param[in] reference_white Reference white color values. + * @param[in] transformation Transformation matrix for RGB to XYZ conversion. + * @param[in] adaptation_matrix XYZ chromatic adaptation matrix. + */ +void color_rgb_to_lab(const Color* a, Color* b, const vector3* reference_white, const matrix3x3* transformation, const matrix3x3* adaptation_matrix); -void color_rgb_to_lab(Color* a, Color* b, vector3* reference_white, matrix3x3* transformation); -void color_lab_to_rgb(Color* a, Color* b, vector3* reference_white, matrix3x3* transformation_inverted); +/** + * Convert Lab color space to RGB color space. + * @param[in] a Source color in Lab color space. + * @param[out] b Destination color in RGB color space. + * @param[in] reference_white Reference white color values. + * @param[in] transformation_inverted Transformation matrix for XYZ to RGB conversion. + * @param[in] adaptation_matrix_inverted Inverted XYZ chromatic adaptation matrix. + */ +void color_lab_to_rgb(const Color* a, Color* b, const vector3* reference_white, const matrix3x3* transformation_inverted, const matrix3x3* adaptation_matrix_inverted); -void color_lab_to_lch(Color* a, Color* b); -void color_rgb_to_lch(Color* a, Color* b); +/** + * Convert RGB color space to Lab color space with illuminant D50, observer 2, sRGB transformation matrix and D65-D50 adaptation matrix. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in Lab color space. + */ +void color_rgb_to_lab_d50(const Color* a, Color* b); -void color_rgb_to_cmy(Color* a, Color* b); -void color_cmy_to_rgb(Color* a, Color* b); +/** + * Convert Lab color space to RGB color space with illuminant D50, observer 2, inverted sRGB transformation matrix and D50-D65 adaptation matrix. + * @param[in] a Source color in Lab color space. + * @param[out] b Destination color in RGB color space. + */ +void color_lab_to_rgb_d50(const Color* a, Color* b); + +/** + * Convert Lab color space to LCH color space. + * @param[in] a Source color in Lab color space. + * @param[out] b Destination color in LCH color space. + */ +void color_lab_to_lch(const Color* a, Color* b); -void color_cmy_to_cmyk(Color* a, Color* b); -void color_cmyk_to_cmy(Color* a, Color* b); +/** + * Convert Lab color space to LCH color space. + * @param[in] a Source color in Lab color space. + * @param[out] b Destination color in LCH color space. + */ +void color_lch_to_lab(const Color* a, Color* b); + +/** + * Convert RGB color space to LCH color space. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in LCH color space. + * @param[in] reference_white Reference white color values. + * @param[in] transformation Transformation matrix for RGB to XYZ conversion. + * @param[in] adaptation_matrix XYZ chromatic adaptation matrix. + */ +void color_rgb_to_lch(const Color* a, Color* b, const vector3* reference_white, const matrix3x3* transformation, const matrix3x3* adaptation_matrix); + +/** + * Convert LCH color space to RGB color space. + * @param[in] a Source color in LCH color space. + * @param[out] b Destination color in RGB color space. + * @param[in] reference_white Reference white color values. + * @param[in] transformation_inverted Transformation matrix for XYZ to RGB conversion. + * @param[in] adaptation_matrix_inverted Inverted XYZ chromatic adaptation matrix. + */ +void color_lch_to_rgb(const Color* a, Color* b, const vector3* reference_white, const matrix3x3* transformation_inverted, const matrix3x3* adaptation_matrix_inverted); + +/** + * Convert RGB color space to LCH color space with illuminant D50, observer 2, sRGB transformation matrix and D65-D50 adaptation matrix. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in LCH color space. + */ +void color_rgb_to_lch_d50(const Color* a, Color* b); + +/** + * Convert LCH color space to RGB color space with illuminant D50, observer 2, inverted sRGB transformation matrix and D50-D65 adaptation matrix. + * @param[in] a Source color in LCH color space. + * @param[out] b Destination color in RGB color space. + */ +void color_lch_to_rgb_d50(const Color* a, Color* b); + +/** + * Convert RGB color space to CMY color space. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in CMY color space. + */ +void color_rgb_to_cmy(const Color* a, Color* b); + +/** + * Convert CMY color space to RGB color space. + * @param[in] a Source color in CMY color space. + * @param[out] b Destination color in RGB color space. + */ +void color_cmy_to_rgb(const Color* a, Color* b); + +/** + * Convert CMY color space to CMYK color space. + * @param[in] a Source color in CMY color space. + * @param[out] b Destination color in CMYK color space. + */ +void color_cmy_to_cmyk(const Color* a, Color* b); + +/** + * Convert CMYK color space to CMY color space. + * @param[in] a Source color in CMYK color space. + * @param[out] b Destination color in CMY color space. + */ +void color_cmyk_to_cmy(const Color* a, Color* b); + +/** + * Convert RGB color space to CMYK color space. + * @param[in] a Source color in RGB color space. + * @param[out] b Destination color in CMYK color space. + */ +void color_rgb_to_cmyk(const Color* a, Color* b); -void color_rgb_to_cmyk(Color* a, Color* b); -void color_cmyk_to_rgb(Color* a, Color* b); +/** + * Convert CMYK color space to RGB color space. + * @param[in] a Source color in CMYK color space. + * @param[out] b Destination color in RGB color space. + */ +void color_cmyk_to_rgb(const Color* a, Color* b); +/** + * Normalize RGB color values. + * @param[in,out] a Color in RGB color space. + */ void color_rgb_normalize(Color* a); -void color_copy(Color* a, Color* b); +/** + * Check whenever the color contains invalid (out of RGB gamut) value. + * @param[in] a Color in RGB color space. + * @return True, when color is out of RGB gamut. + */ +bool color_is_rgb_out_of_gamut(const Color* a); + +/** + * Transform RGB color to linear RGB color. + * @param[in] a Color in RGB color space. + * @param[out] b Linear color in RGB color space. + */ +void color_rgb_get_linear(const Color* a, Color* b); + +/** + * Transform linear RGB color to RGB color. + * @param[in] a Linear color in RGB color space. + * @param[out] b Color in RGB color space. + */ +void color_linear_get_rgb(const Color* a, Color* b); + +/** + * Copy color. + * @param[in] a Source color in any color space. + * @param[out] b Destination color. + */ +void color_copy(const Color* a, Color* b); -void color_add(Color* a, Color* b); +/** + * Add color values. + * @param[in,out] a Source color in any color space. + * @param[in] b Color values. + */ +void color_add(Color* a, const Color* b); +/** + * Multiply color values by specified amount. + * @param[in,out] a Source color in any color space. + * @param[in] b Multiplier. + */ void color_multiply(Color* a, float b); +/** + * Set all color values to zero. + * @param[in,out] a Color to be set. + */ void color_zero(Color* a); +/** + * Create new Color structure. + * @return Color structure with unspecified values. + */ Color* color_new(); +/** + * Free memory associated with Color structure. + * @param[in] a Color to be freed. + */ void color_destroy(Color* a); +/** + * Set all color values to specified value. + * @param[in,out] a Color to be set. + * @param[in] value Value which is used. + */ void color_set(Color* a, float value); -void color_get_contrasting(Color* a, Color* b); +/** + * Get either black or white color depending on which has more contrast with specified color. + * @param[in] a Source color in RGB color space. + * @param[out] b Color with most contrast in RGB color space. + */ +void color_get_contrasting(const Color* a, Color* b); -void color_get_working_space_matrix(float xr, float yr, float xg, float yg, float xb, float yb, vector3* reference_white, matrix3x3* result); -void color_get_chromatic_adaptation_matrix(vector3* source_reference_white, vector3* destination_reference_white, matrix3x3* result); -void color_xyz_chromatic_adaptation(Color* a, Color* result, matrix3x3* adaptation ); +/** + * Calculate working space matrix. + * @param[in] xr Red primary in x channel. + * @param[in] yr Red primary in y channel. + * @param[in] xg Green primary in x channel. + * @param[in] yg Green primary in y channel. + * @param[in] xb Blue primary in x channel. + * @param[in] yb Blue primary in y channel. + * @param[in] reference_white Reference white vector. + * @param[out] result Calculated working space matrix. + */ +void color_get_working_space_matrix(float xr, float yr, float xg, float yg, float xb, float yb, const vector3* reference_white, matrix3x3* result); + +/** + * Calculate chromatic adaptation matrix from source and destination reference white vectors. + * @param[in] source_reference_white Source reference white vector. + * @param[in] destination_reference_white Destination reference white vector. + * @param[out] result Calculated chromatic adaptation matrix. + */ +void color_get_chromatic_adaptation_matrix(const vector3* source_reference_white, const vector3* destination_reference_white, matrix3x3* result); + +/** + * Apply chromatic adaptation matrix to the XYZ color. + * @param[in] a Source color in XYZ color space. + * @param[out] result Pointer to a Color structure where the result is stored in XYZ color space. + * @param[in] adaptation Chromatic adaptation matrix. + * @see color_get_chromatic_adaptation_matrix. + */ +void color_xyz_chromatic_adaptation(const Color* a, Color* result, const matrix3x3* adaptation); + +/** + * Get working space matrix for sRGB. + * @return Constant reference to sRGB working space matrix. + */ +const matrix3x3* color_get_sRGB_transformation_matrix(); + +/** + * Get inverted working space matrix for sRGB. + * @return Constant reference to inverted sRGB working space matrix. + */ +const matrix3x3* color_get_inverted_sRGB_transformation_matrix(); + +/** + * Get D65 to D50 chromatic adaptation matrix. + * @return Constant reference to chromatic adaptation matrix. + */ +const matrix3x3* color_get_d65_d50_adaptation_matrix(); + +/** + * Get D50 to D65 chromatic adaptation matrix. + * @return Constant reference to chromatic adaptation matrix. + */ +const matrix3x3* color_get_d50_d65_adaptation_matrix(); + +/** + * Get reference white vector for specified illuminant and observer. + * @param[in] illuminant Illuminant. + * @param[in] observer Observer. + * @return Reference white vector. + */ +const vector3* color_get_reference(ReferenceIlluminant illuminant, ReferenceObserver observer); + +/** + * Get illuminant by name. + * @param[in] illuminant Illuminant name. + * @return Reference illuminant. + */ +const ReferenceIlluminant color_get_illuminant(const char *illuminant); + +/** + * Get observer by name. + * @param[in] observer Observer name. + * @return Reference observer. + */ +const ReferenceObserver color_get_observer(const char *observer); #endif /* COLOR_H_ */ + diff -Nru gpick-0.2.4/source/ColorAction.cpp gpick-0.2.5/source/ColorAction.cpp --- gpick-0.2.4/source/ColorAction.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorAction.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorAction.h gpick-0.2.5/source/ColorAction.h --- gpick-0.2.4/source/ColorAction.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorAction.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorList.cpp gpick-0.2.5/source/ColorList.cpp --- gpick-0.2.4/source/ColorList.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorList.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorList.h gpick-0.2.5/source/ColorList.h --- gpick-0.2.4/source/ColorList.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorList.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorMixer.cpp gpick-0.2.5/source/ColorMixer.cpp --- gpick-0.2.4/source/ColorMixer.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorMixer.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,6 +20,7 @@ #include "DragDrop.h" #include "GlobalStateStruct.h" +#include "ToolColorNaming.h" #include "uiUtilities.h" #include "ColorList.h" #include "MathUtil.h" @@ -31,10 +32,12 @@ #include "CopyPaste.h" #include "Converter.h" #include "DynvHelpers.h" +#include "Internationalisation.h" #include "uiApp.h" #include +#include #include #include @@ -59,14 +62,14 @@ int mode_id; }ColorMixerType; -static const ColorMixerType color_mixer_types[] = { - {"Normal", "normal", MODE_ID_NORMAL}, - {"Multiply", "multiply", MODE_ID_MULTIPLY}, - {"Add", "add", MODE_ID_ADD}, - {"Difference", "difference", MODE_ID_DIFFERENCE}, - {"Hue", "hue", MODE_ID_HUE}, - {"Saturation", "saturation", MODE_ID_SATURATION}, - {"Lightness", "lightness", MODE_ID_LIGHTNESS}, +const ColorMixerType color_mixer_types[] = { + {N_("Normal"), "normal", MODE_ID_NORMAL}, + {N_("Multiply"), "multiply", MODE_ID_MULTIPLY}, + {N_("Add"), "add", MODE_ID_ADD}, + {N_("Difference"), "difference", MODE_ID_DIFFERENCE}, + {N_("Hue"), "hue", MODE_ID_HUE}, + {N_("Saturation"), "saturation", MODE_ID_SATURATION}, + {N_("Lightness"), "lightness", MODE_ID_LIGHTNESS}, }; typedef struct ColorMixerArgs{ @@ -82,7 +85,7 @@ GtkWidget *color_previews; const ColorMixerType *mixer_type; - struct{ + struct{ GtkWidget *input; GtkWidget *output; }color[MAX_COLOR_LINES]; @@ -93,10 +96,31 @@ GlobalState* gs; }ColorMixerArgs; +class ColorMixerColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + const char *m_ident; + public: + ColorMixerColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + } + + void assign(struct ColorObject *color_object, Color *color, const char *ident){ + m_ident = ident; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << color_names_get(m_gs->color_names, color, false) << " " << _("color mixer") << " " << m_ident; + return m_stream.str(); + } +}; static int set_rgb_color(ColorMixerArgs *args, struct ColorObject* color, uint32_t color_index); static int set_rgb_color_by_widget(ColorMixerArgs *args, struct ColorObject* color, GtkWidget* color_widget); + + static void calc(ColorMixerArgs *args, bool preview, bool save_settings){ double opacity = gtk_range_get_value(GTK_RANGE(args->opacity)); @@ -112,24 +136,24 @@ switch (args->mixer_type->mode_id){ case MODE_ID_NORMAL: - r.rgb.red = color2.rgb.red; - r.rgb.green = color2.rgb.green; - r.rgb.blue = color2.rgb.blue; + r.rgb.red = color2.rgb.red; + r.rgb.green = color2.rgb.green; + r.rgb.blue = color2.rgb.blue; break; case MODE_ID_MULTIPLY: - r.rgb.red = color.rgb.red * color2.rgb.red; - r.rgb.green = color.rgb.green * color2.rgb.green; - r.rgb.blue = color.rgb.blue * color2.rgb.blue; + r.rgb.red = color.rgb.red * color2.rgb.red; + r.rgb.green = color.rgb.green * color2.rgb.green; + r.rgb.blue = color.rgb.blue * color2.rgb.blue; break; case MODE_ID_ADD: - r.rgb.red = clamp_float(color.rgb.red + color2.rgb.red, 0, 1); - r.rgb.green = clamp_float(color.rgb.green + color2.rgb.green, 0, 1); - r.rgb.blue = clamp_float(color.rgb.blue + color2.rgb.blue, 0, 1); + r.rgb.red = clamp_float(color.rgb.red + color2.rgb.red, 0, 1); + r.rgb.green = clamp_float(color.rgb.green + color2.rgb.green, 0, 1); + r.rgb.blue = clamp_float(color.rgb.blue + color2.rgb.blue, 0, 1); break; case MODE_ID_DIFFERENCE: - r.rgb.red = fabs(color.rgb.red - color2.rgb.red); - r.rgb.green = fabs(color.rgb.green - color2.rgb.green); - r.rgb.blue = fabs(color.rgb.blue - color2.rgb.blue); + r.rgb.red = fabs(color.rgb.red - color2.rgb.red); + r.rgb.green = fabs(color.rgb.green - color2.rgb.green); + r.rgb.blue = fabs(color.rgb.blue - color2.rgb.blue); break; case MODE_ID_HUE: color_rgb_to_hsv(&color, &hsv1); @@ -198,42 +222,67 @@ color_object_release(color_object); } +static boost::format format_ignore_arg_errors(const std::string &f_string) { + boost::format fmter(f_string); + fmter.exceptions(boost::io::all_error_bits ^ (boost::io::too_many_args_bit | boost::io::too_few_args_bit)); + return fmter; +} -static void on_color_add_to_palette(GtkWidget *widget, gpointer item) { - ColorMixerArgs* args = (ColorMixerArgs*)item; - Color c; - - gtk_color_get_color(GTK_COLOR(g_object_get_data(G_OBJECT(widget), "color_widget")), &c); +static string identify_color_widget(GtkWidget *widget, ColorMixerArgs *args) +{ + if (args->secondary_color == widget){ + return _("secondary"); + }else for (int i = 0; i < MAX_COLOR_LINES; ++i){ + if (args->color[i].input == widget){ + try{ + return (format_ignore_arg_errors(_("primary %d")) % (i + 1)).str(); + }catch(const boost::io::format_error &e){ + return (format_ignore_arg_errors("primary %d") % (i + 1)).str(); + } + }else if (args->color[i].output == widget){ + try{ + return (format_ignore_arg_errors(_("result %d")) % (i + 1)).str(); + }catch(const boost::io::format_error &e){ + return (format_ignore_arg_errors("result %d") % (i + 1)).str(); + } + } + } + return "unknown"; +} - struct ColorObject *color_object = color_list_new_color_object(args->gs->colors, &c); - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); +static void add_color_to_palette(GtkWidget *color_widget, ColorMixerColorNameAssigner &name_assigner, ColorMixerArgs *args) +{ + Color c; + struct ColorObject *color_object; + string widget_ident; + gtk_color_get_color(GTK_COLOR(color_widget), &c); + color_object = color_list_new_color_object(args->gs->colors, &c); + widget_ident = identify_color_widget(color_widget, args); + name_assigner.assign(color_object, &c, widget_ident.c_str()); color_list_add_color_object(args->gs->colors, color_object, 1); color_object_release(color_object); } +static void on_color_add_to_palette(GtkWidget *widget, gpointer item) { + ColorMixerArgs* args = (ColorMixerArgs*)item; + GtkWidget *color_widget = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "color_widget")); + ColorMixerColorNameAssigner name_assigner(args->gs); + add_color_to_palette(color_widget, name_assigner, args); +} + static void on_color_add_all_to_palette(GtkWidget *widget, gpointer item) { ColorMixerArgs* args = (ColorMixerArgs*)item; - Color c; + ColorMixerColorNameAssigner name_assigner(args->gs); for (int i = 0; i < MAX_COLOR_LINES; ++i){ - gtk_color_get_color(GTK_COLOR(args->color[i].input), &c); - - struct ColorObject *color_object = color_list_new_color_object(args->gs->colors, &c); - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); - color_list_add_color_object(args->gs->colors, color_object, 1); - color_object_release(color_object); + add_color_to_palette(args->color[i].input, name_assigner, args); + } - gtk_color_get_color(GTK_COLOR(args->color[i].output), &c); + add_color_to_palette(args->secondary_color, name_assigner, args); - color_object = color_list_new_color_object(args->gs->colors, &c); - name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); - color_list_add_color_object(args->gs->colors, color_object, 1); - color_object_release(color_object); + for (int i = 0; i < MAX_COLOR_LINES; ++i){ + add_color_to_palette(args->color[i].output, name_assigner, args); } - } static gboolean color_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, ColorMixerArgs *args){ @@ -242,17 +291,10 @@ } -static void on_color_activate(GtkWidget *widget, gpointer item) { +static void on_color_activate(GtkWidget *widget, gpointer item) { ColorMixerArgs* args=(ColorMixerArgs*)item; - Color c; - - gtk_color_get_color(GTK_COLOR(widget), &c); - - struct ColorObject *color_object=color_list_new_color_object(args->gs->colors, &c); - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); - color_list_add_color_object(args->gs->colors, color_object, 1); - color_object_release(color_object); + ColorMixerColorNameAssigner name_assigner(args->gs); + add_color_to_palette(widget, name_assigner, args); } static void type_toggled_cb(GtkWidget *widget, ColorMixerArgs *args) { @@ -265,7 +307,7 @@ Color c; gtk_color_get_color(GTK_COLOR(color_widget), &c); - gtk_color_set_color(GTK_COLOR(args->secondary_color), &c, args->mixer_type->name); + gtk_color_set_color(GTK_COLOR(args->secondary_color), &c, _(args->mixer_type->name)); update(0, args); } } @@ -276,19 +318,19 @@ menu = gtk_menu_new (); - item = gtk_menu_item_new_with_image ("_Add to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Add to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_add_to_palette), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); - item = gtk_menu_item_new_with_image ("_Add all to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("A_dd all to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_add_all_to_palette), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_mnemonic ("_Copy to clipboard"); + item = gtk_menu_item_new_with_mnemonic (_("_Copy to clipboard")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); Color c; @@ -315,7 +357,7 @@ if (secondary_color){ GSList *group = 0; for (uint32_t i = 0; i < sizeof(color_mixer_types) / sizeof(ColorMixerType); i++){ - item = gtk_radio_menu_item_new_with_label(group, color_mixer_types[i].name); + item = gtk_radio_menu_item_new_with_label(group, _(color_mixer_types[i].name)); group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item)); if (args->mixer_type == &color_mixer_types[i]){ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), true); @@ -328,12 +370,12 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); } - item = gtk_menu_item_new_with_image ("_Edit...", gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Edit..."), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_edit), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); - item = gtk_menu_item_new_with_image ("_Paste", gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Paste"), gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_paste), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); @@ -441,16 +483,18 @@ } static int source_get_color(ColorMixerArgs *args, ColorObject** color){ + ColorMixerColorNameAssigner name_assigner(args->gs); Color c; + string widget_ident; if (args->last_focused_color){ gtk_color_get_color(GTK_COLOR(args->last_focused_color), &c); + widget_ident = identify_color_widget(args->last_focused_color, args); }else{ gtk_color_get_color(GTK_COLOR(args->color[0].input), &c); + widget_ident = identify_color_widget(args->color[0].input, args); } *color = color_list_new_color_object(args->gs->colors, &c); - - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string((*color)->params, "name", name.c_str()); + name_assigner.assign(*color, &c, widget_ident.c_str()); return 0; } @@ -463,7 +507,7 @@ if (args->color[i].input == color_widget){ set_rgb_color(args, color_object, i); return 0; - }else if (args->color[i].output == color_widget){ + }else if (args->color[i].output == color_widget){ set_rgb_color(args, color_object, i); return 0; } @@ -471,11 +515,12 @@ return -1; } + static int set_rgb_color(ColorMixerArgs *args, struct ColorObject* color, uint32_t color_index){ Color c; color_object_get_color(color, &c); if (color_index == (uint32_t)-1){ - gtk_color_set_color(GTK_COLOR(args->secondary_color), &c, args->mixer_type->name); + gtk_color_set_color(GTK_COLOR(args->secondary_color), &c, _(args->mixer_type->name)); }else{ gtk_color_set_color(GTK_COLOR(args->color[color_index].input), &c, ""); } @@ -493,6 +538,15 @@ } static int source_activate(ColorMixerArgs *args){ + + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + gtk_color_set_transformation_chain(GTK_COLOR(args->secondary_color), chain); + + for (int i = 0; i < MAX_COLOR_LINES; ++i){ + gtk_color_set_transformation_chain(GTK_COLOR(args->color[i].input), chain); + gtk_color_set_transformation_chain(GTK_COLOR(args->color[i].output), chain); + } + gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "empty"), ""); return 0; } @@ -576,9 +630,9 @@ dragdrop_widget_attach(widget, DragDropFlags(DRAGDROP_SOURCE | DRAGDROP_DESTINATION), &dd); - for (int i = 0; i < MAX_COLOR_LINES; ++i){ + for (intptr_t i = 0; i < MAX_COLOR_LINES; ++i){ - for (int j = 0; j < 2; ++j){ + for (intptr_t j = 0; j < 2; ++j){ widget = gtk_color_new(); gtk_color_set_rounded(GTK_COLOR(widget), true); @@ -636,7 +690,7 @@ sprintf(tmp, "color%d", i); gtk_color_set_color(GTK_COLOR(args->color[i].input), dynv_get_color_wdc(args->params, tmp, &c), ""); } - gtk_color_set_color(GTK_COLOR(args->secondary_color), dynv_get_color_wdc(args->params, "secondary_color", &c), args->mixer_type->name); + gtk_color_set_color(GTK_COLOR(args->secondary_color), dynv_get_color_wdc(args->params, "secondary_color", &c), _(args->mixer_type->name)); hbox2 = gtk_hbox_new(FALSE, 0); @@ -647,7 +701,7 @@ gtk_box_pack_start(GTK_BOX(hbox2), table, true, true, 0); table_y = 0; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Opacity:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,0,0); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Opacity:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,0,0); args->opacity = gtk_hscale_new_with_range(1, 100, 1); gtk_range_set_value(GTK_RANGE(args->opacity), dynv_get_float_wd(args->params, "opacity", 50)); g_signal_connect(G_OBJECT(args->opacity), "value-changed", G_CALLBACK (update), args); @@ -675,8 +729,9 @@ int color_mixer_source_register(ColorSourceManager *csm){ ColorSource *color_source = new ColorSource; - color_source_init(color_source, "color_mixer", "Color mixer"); + color_source_init(color_source, "color_mixer", _("Color mixer")); color_source->implement = (ColorSource* (*)(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace))source_implement; + color_source->default_accelerator = GDK_m; color_source_manager_add_source(csm, color_source); return 0; } diff -Nru gpick-0.2.4/source/ColorMixer.h gpick-0.2.5/source/ColorMixer.h --- gpick-0.2.4/source/ColorMixer.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorMixer.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorNames.cpp gpick-0.2.5/source/ColorNames.cpp --- gpick-0.2.4/source/ColorNames.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorNames.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2009-2011, Albertas Vyšniauskas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ColorNames.h" -#include "MathUtil.h" - -#include -#include -#include -#include -using namespace std; - -//CIE94 color difference calculation -float color_names_distance_lch(Color* a, Color* b){ - return sqrt( - pow((b->lch.L-a->lch.L)/1,2)+ - pow((b->lch.C-a->lch.C)/(1+0.045*a->lch.C),2)+ - pow((b->lch.h-a->lch.h)/(1+0.015*a->lch.C),2)); -} - -ColorNames* -color_names_new() -{ - ColorNames* cnames = new ColorNames; - cnames->colorspace_convert=color_rgb_to_lch; - cnames->colorspace_distance=color_names_distance_lch; - return cnames; -} - - -void color_names_strip_spaces(string& string_x, string& stripchars){ - if(string_x.empty()) return; - if (stripchars.empty()) return; - - size_t startIndex = string_x.find_first_not_of(stripchars); - size_t endIndex = string_x.find_last_not_of(stripchars); - - if ((startIndex==string::npos)||(endIndex==string::npos)){ - string_x.erase(); - return; - } - string_x = string_x.substr(startIndex, (endIndex-startIndex)+1 ); -} - -void -color_names_get_color_xyz(ColorNames* cnames, Color* c, int* x1, int* y1, int* z1, int* x2, int* y2, int* z2){ - *x1=clamp_int(int(c->xyz.x*8-0.5),0,7); - *y1=clamp_int(int(c->xyz.y*8-0.5),0,7); - *z1=clamp_int(int(c->xyz.z*8-0.5),0,7); - - *x2=clamp_int(int(c->xyz.x*8+0.5),0,7); - *y2=clamp_int(int(c->xyz.y*8+0.5),0,7); - *z2=clamp_int(int(c->xyz.z*8+0.5),0,7); -} - -list* -color_names_get_color_list(ColorNames* cnames, Color* c){ - int x,y,z; - x=clamp_int(int(c->xyz.x*8),0,7); - y=clamp_int(int(c->xyz.y*8),0,7); - z=clamp_int(int(c->xyz.z*8),0,7); - - return &cnames->colors[x][y][z]; -} - -int -color_names_load_from_file(ColorNames* cnames, const char* filename) -{ - ifstream file(filename, ifstream::in); - - if (file.is_open()) - { - string line; - stringstream rline (ios::in | ios::out); - Color color; - string name; - string strip_chars = " \t,.\n\r"; - - while (!(file.eof())) - { - getline(file, line); - if (line.empty()) continue; - - if (line.at(0)=='!') continue; - - rline.clear(); - rline.str(line); - - - rline>>color.rgb.red>>color.rgb.green>>color.rgb.blue; - getline(rline, name); - - color_names_strip_spaces(name, strip_chars); - - string::iterator i(name.begin()); - - if (i != name.end()) - name[0] = toupper((unsigned char)name[0]); - - while(++i != name.end()){ - *i = tolower((unsigned char)*i); - } - - color_multiply(&color, 1/255.0); - - ColorNameEntry* name_entry = new ColorNameEntry; - name_entry->name=name; - cnames->names.push_back(name_entry); - - ColorEntry* color_entry = new ColorEntry; - color_entry->name=name_entry; - - cnames->colorspace_convert(&color, &color_entry->color); - color_names_get_color_list(cnames, &color_entry->color)->push_back(color_entry); - - } - - file.close(); - return 0; - } - return -1; -} - -void -color_names_destroy(ColorNames* cnames) -{ - for (list::iterator i=cnames->names.begin();i!=cnames->names.end();++i){ - delete (*i); - } - for (int x=0;x<8;x++){ - for (int y=0;y<8;y++){ - for (int z=0;z<8;z++){ - for (list::iterator i=cnames->colors[x][y][z].begin();i!=cnames->colors[x][y][z].end();++i){ - delete (*i); - } - } - } - } - delete cnames; -} - -string -color_names_get(ColorNames* cnames, Color* color, bool imprecision_postfix) -{ - Color c1; - cnames->colorspace_convert(color, &c1); - - int x1,y1,z1,x2,y2,z2; - color_names_get_color_xyz(cnames, &c1, &x1, &y1, &z1, &x2, &y2, &z2); - - float result_delta=1e5; - ColorEntry* color_entry=NULL; - - /* Search expansion should be from 0 to 7, but this would only increase search time and return - * wrong color names when no closely matching color is found. Search expansion is only usefull - * when color name database is very small (16 colors) - */ - for (int expansion=0; expansion<2; ++expansion){ - for (int x_i = max_int(x1 - expansion, 0); x_i <= min_int(x2 + expansion, 7); ++x_i) { - for (int y_i = max_int(y1 - expansion, 0); y_i <= min_int(y2 + expansion, 7); ++y_i) { - for (int z_i = max_int(z1 - expansion, 0); z_i <= min_int(z2 + expansion, 7); ++z_i) { - for (list::iterator i=cnames->colors[x_i][y_i][z_i].begin(); i!=cnames->colors[x_i][y_i][z_i].end();++i){ - float delta = cnames->colorspace_distance(&(*i)->color, &c1); - //float delta = pow((*i)->color.xyz.x-c1.xyz.x,2) + pow((*i)->color.xyz.y-c1.xyz.y,2) + pow((*i)->color.xyz.z-c1.xyz.z,2); - if (deltaname->name;//<<" "<0.1) s<<" ~"; - return s.str();//(*result_i)->name; - } - - return string(""); -} diff -Nru gpick-0.2.4/source/ColorNames.h gpick-0.2.5/source/ColorNames.h --- gpick-0.2.4/source/ColorNames.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorNames.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2009-2011, Albertas Vyšniauskas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef COLORNAMES_H_ -#define COLORNAMES_H_ - -#include "Color.h" - -#include -#include -using namespace std; - -typedef struct ColorNameEntry{ - string name; -}ColorNameEntry; - -typedef struct ColorEntry{ - Color color; - ColorNameEntry* name; -}ColorEntry; - -typedef struct ColorNames{ - list names; - list colors[8][8][8]; - void (*colorspace_convert)(Color* a, Color* b); - float (*colorspace_distance)(Color* a, Color* b); -}ColorNames; - -ColorNames* -color_names_new(); - -int -color_names_load_from_file(ColorNames* cnames, const char* filename); - -void -color_names_destroy(ColorNames* cnames); - -string -color_names_get(ColorNames* cnames, Color* color, bool imprecision_postfix); - -#endif /* COLORNAMES_H_ */ diff -Nru gpick-0.2.4/source/ColorObject.cpp gpick-0.2.5/source/ColorObject.cpp --- gpick-0.2.4/source/ColorObject.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorObject.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorObject.h gpick-0.2.5/source/ColorObject.h --- gpick-0.2.4/source/ColorObject.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorObject.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorPicker.cpp gpick-0.2.5/source/ColorPicker.cpp --- gpick-0.2.4/source/ColorPicker.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorPicker.cpp 2013-01-03 21:36:41.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -25,6 +25,7 @@ #include "FloatingPicker.h" #include "ColorRYB.h" #include "ColorWheelType.h" +#include "ColorSpaceType.h" #include "gtk/Swatch.h" #include "gtk/Zoomed.h" @@ -35,10 +36,15 @@ #include "uiUtilities.h" #include "uiColorInput.h" #include "uiConverter.h" +#include "Internationalisation.h" #include #include +#ifdef _MSC_VER +#define M_PI 3.14159265359 +#endif +#include #include #include #include @@ -57,6 +63,7 @@ GtkWidget* expanderCMYK; GtkWidget* expanderXYZ; GtkWidget* expanderLAB; + GtkWidget* expanderLCH; GtkWidget* expanderInfo; GtkWidget* expanderMain; @@ -71,6 +78,7 @@ GtkWidget* rgb_control; GtkWidget* cmyk_control; GtkWidget* lab_control; + GtkWidget* lch_control; GtkWidget* color_name; GtkWidget* statusbar; @@ -88,7 +96,26 @@ }ColorPickerArgs; +struct ColorCompItem{ + GtkWidget *widget; + GtkColorComponentComp component; + int component_id; +}; + static int source_set_color(ColorPickerArgs *args, ColorObject* color); +static int source_set_nth_color(ColorPickerArgs *args, uint32_t color_n, ColorObject* color); +static int source_get_nth_color(ColorPickerArgs *args, uint32_t color_n, ColorObject** color); + +static void updateMainColorNow(ColorPickerArgs* args){ + if (!dynv_get_bool_wd(args->params, "zoomed_enabled", true)){ + Color c; + gtk_swatch_get_active_color(GTK_SWATCH(args->swatch_display), &c); + gchar* text = main_get_color_text(args->gs, &c, COLOR_TEXT_TYPE_DISPLAY); + gtk_color_set_color(GTK_COLOR(args->color_code), &c, text); + if (text) g_free(text); + gtk_swatch_set_main_color(GTK_SWATCH(args->swatch_display), &c); + } +} static gboolean updateMainColor( gpointer data ){ ColorPickerArgs* args=(ColorPickerArgs*)data; @@ -112,8 +139,12 @@ sampler_get_screen_rect(args->gs->sampler, pointer, window_size, &sampler_rect); screen_reader_add_rect(args->gs->screen_reader, screen, sampler_rect); - gtk_zoomed_get_screen_rect(GTK_ZOOMED(args->zoomed_display), pointer, window_size, &zoomed_rect); - screen_reader_add_rect(args->gs->screen_reader, screen, zoomed_rect); + bool zoomed_enabled = dynv_get_bool_wd(args->params, "zoomed_enabled", true); + + if (zoomed_enabled){ + gtk_zoomed_get_screen_rect(GTK_ZOOMED(args->zoomed_display), pointer, window_size, &zoomed_rect); + screen_reader_add_rect(args->gs->screen_reader, screen, zoomed_rect); + } screen_reader_update_pixbuf(args->gs->screen_reader, &final_rect); @@ -124,15 +155,16 @@ sampler_get_color_sample(args->gs->sampler, pointer, window_size, offset, &c); gchar* text = main_get_color_text(args->gs, &c, COLOR_TEXT_TYPE_DISPLAY); - gtk_color_set_color(GTK_COLOR(args->color_code), &c, text); if (text) g_free(text); gtk_swatch_set_main_color(GTK_SWATCH(args->swatch_display), &c); - offset = Vec2(zoomed_rect.getX()-final_rect.getX(), zoomed_rect.getY()-final_rect.getY()); - gtk_zoomed_update(GTK_ZOOMED(args->zoomed_display), pointer, window_size, offset, screen_reader_get_pixbuf(args->gs->screen_reader)); + if (zoomed_enabled){ + offset = Vec2(zoomed_rect.getX()-final_rect.getX(), zoomed_rect.getY()-final_rect.getY()); + gtk_zoomed_update(GTK_ZOOMED(args->zoomed_display), pointer, window_size, offset, screen_reader_get_pixbuf(args->gs->screen_reader)); + } return TRUE; } @@ -142,16 +174,40 @@ return true; } +static void updateComponentText(ColorPickerArgs *args, GtkColorComponent *component, const char *type){ + Color transformed_color; + gtk_color_component_get_transformed_color(component, &transformed_color); + lua_State* L = static_cast(dynv_get_pointer_wdc(args->gs->params, "lua_State", 0)); + list str = color_space_color_to_text(type, &transformed_color, L); + int j = 0; + const char *text[4]; + memset(text, 0, sizeof(text)); + for (list::iterator i = str.begin(); i != str.end(); i++){ + text[j] = (*i).c_str(); + j++; + if (j > 3) break; + } + gtk_color_component_set_text(component, text); +} -static void updateDiplays(ColorPickerArgs *args, GtkWidget *except_widget){ +static void updateDisplays(ColorPickerArgs *args, GtkWidget *except_widget){ + updateMainColorNow(args); Color c, c2; gtk_swatch_get_active_color(GTK_SWATCH(args->swatch_display),&c); if (except_widget != args->hsl_control) gtk_color_component_set_color(GTK_COLOR_COMPONENT(args->hsl_control), &c); if (except_widget != args->hsv_control) gtk_color_component_set_color(GTK_COLOR_COMPONENT(args->hsv_control), &c); - if (except_widget != args->rgb_control) gtk_color_component_set_color(GTK_COLOR_COMPONENT(args->rgb_control), &c); + if (except_widget != args->rgb_control) gtk_color_component_set_color(GTK_COLOR_COMPONENT(args->rgb_control), &c); if (except_widget != args->cmyk_control) gtk_color_component_set_color(GTK_COLOR_COMPONENT(args->cmyk_control), &c); if (except_widget != args->lab_control) gtk_color_component_set_color(GTK_COLOR_COMPONENT(args->lab_control), &c); + if (except_widget != args->lch_control) gtk_color_component_set_color(GTK_COLOR_COMPONENT(args->lch_control), &c); + + updateComponentText(args, GTK_COLOR_COMPONENT(args->hsl_control), "hsl"); + updateComponentText(args, GTK_COLOR_COMPONENT(args->hsv_control), "hsv"); + updateComponentText(args, GTK_COLOR_COMPONENT(args->rgb_control), "rgb"); + updateComponentText(args, GTK_COLOR_COMPONENT(args->cmyk_control), "cmyk"); + updateComponentText(args, GTK_COLOR_COMPONENT(args->lab_control), "lab"); + updateComponentText(args, GTK_COLOR_COMPONENT(args->lch_control), "lch"); string color_name = color_names_get(args->gs->color_names, &c, true); gtk_entry_set_text(GTK_ENTRY(args->color_name), color_name.c_str()); @@ -162,16 +218,9 @@ stringstream ss; ss.setf(ios::fixed, ios::floatfield); - matrix3x3 adaptation_matrix, working_space_matrix; - vector3 d50, d65; - vector3_set(&d50, 96.442, 100.000, 82.821); - vector3_set(&d65, 95.047, 100.000, 108.883); - color_get_chromatic_adaptation_matrix(&d50, &d65, &adaptation_matrix); - color_get_working_space_matrix(0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, &d65, &working_space_matrix); - Color c_lab, c2_lab; - color_rgb_to_lab(&c, &c_lab, &d50, &working_space_matrix); - color_rgb_to_lab(&c2, &c2_lab, &d50, &working_space_matrix); + color_rgb_to_lab_d50(&c, &c_lab); + color_rgb_to_lab_d50(&c2, &c2_lab); const ColorWheelType *wheel = &color_wheel_types_get()[0]; Color hsl1, hsl2; @@ -183,7 +232,7 @@ wheel->rgbhue_to_hue(hsl2.hsl.hue, &hue2); double complementary = std::abs(hue1 - hue2); - complementary -= std::floor(complementary); + complementary -= std::floor(complementary); complementary *= std::sin(hsl1.hsl.lightness * M_PI) * std::sin(hsl2.hsl.lightness * M_PI); complementary *= std::sin(hsl1.hsl.saturation * M_PI / 2) * std::sin(hsl2.hsl.saturation * M_PI / 2); @@ -194,13 +243,13 @@ static void on_swatch_active_color_changed( GtkWidget *widget, gint32 new_active_color, gpointer data ){ - ColorPickerArgs* args=(ColorPickerArgs*)data; - updateDiplays(args, widget); + ColorPickerArgs* args = (ColorPickerArgs*)data; + updateDisplays(args, widget); } static void on_swatch_color_changed( GtkWidget *widget, gpointer data ){ ColorPickerArgs* args=(ColorPickerArgs*)data; - updateDiplays(args, widget); + updateDisplays(args, widget); } @@ -315,17 +364,17 @@ Color c; gtk_swatch_get_active_color(GTK_SWATCH(args->swatch_display), &c); - item = gtk_menu_item_new_with_image ("_Add to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Add to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_swatch_menu_add_to_palette), args); - item = gtk_menu_item_new_with_image ("_Add all to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("A_dd all to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_swatch_menu_add_all_to_palette), args); gtk_menu_shell_append (GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); - item = gtk_menu_item_new_with_mnemonic ("_Copy to clipboard"); + item = gtk_menu_item_new_with_mnemonic (_("_Copy to clipboard")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); struct ColorObject* color_object; @@ -335,11 +384,11 @@ gtk_menu_shell_append (GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); - item = gtk_menu_item_new_with_image ("_Edit...", gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Edit..."), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_swatch_color_edit), args); - item = gtk_menu_item_new_with_image ("_Paste", gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Paste"), gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (paste_cb), args); @@ -372,7 +421,7 @@ if (event->in){ - gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "swatch_focused"), "Press Spacebar to sample color under mouse pointer"); + gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "swatch_focused"), _("Press Spacebar to sample color under mouse pointer")); }else{ gtk_statusbar_pop(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "swatch_focused")); } @@ -380,8 +429,6 @@ } - - static gboolean on_key_up (GtkWidget *widget, GdkEventKey *event, gpointer data) { ColorPickerArgs* args=(ColorPickerArgs*)data; @@ -390,6 +437,19 @@ switch(event->keyval) { + case GDK_m: + { + int x, y; + gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL); + math::Vec2 position(x, y); + if ((event->state&modifiers)==GDK_CONTROL_MASK){ + gtk_zoomed_set_mark(GTK_ZOOMED(args->zoomed_display), 1, position); + }else{ + gtk_zoomed_set_mark(GTK_ZOOMED(args->zoomed_display), 0, position); + } + } + break; + case GDK_c: if ((event->state&modifiers)==GDK_CONTROL_MASK){ @@ -414,49 +474,49 @@ case GDK_1: gtk_swatch_set_active_index(GTK_SWATCH(args->swatch_display), 1); - updateDiplays(args, widget); + updateDisplays(args, widget); return TRUE; break; case GDK_2: gtk_swatch_set_active_index(GTK_SWATCH(args->swatch_display), 2); - updateDiplays(args, widget); + updateDisplays(args, widget); return TRUE; break; case GDK_3: gtk_swatch_set_active_index(GTK_SWATCH(args->swatch_display), 3); - updateDiplays(args, widget); + updateDisplays(args, widget); return TRUE; break; case GDK_4: gtk_swatch_set_active_index(GTK_SWATCH(args->swatch_display), 4); - updateDiplays(args, widget); + updateDisplays(args, widget); return TRUE; break; case GDK_5: gtk_swatch_set_active_index(GTK_SWATCH(args->swatch_display), 5); - updateDiplays(args, widget); + updateDisplays(args, widget); return TRUE; break; case GDK_6: gtk_swatch_set_active_index(GTK_SWATCH(args->swatch_display), 6); - updateDiplays(args, widget); + updateDisplays(args, widget); return TRUE; break; case GDK_Right: gtk_swatch_move_active(GTK_SWATCH(args->swatch_display),1); - updateDiplays(args, widget); + updateDisplays(args, widget); return TRUE; break; case GDK_Left: gtk_swatch_move_active(GTK_SWATCH(args->swatch_display),-1); - updateDiplays(args, widget); + updateDisplays(args, widget); return TRUE; break; @@ -464,8 +524,6 @@ updateMainColor(args); gtk_swatch_set_color_to_main(GTK_SWATCH(args->swatch_display)); - - if (dynv_get_bool_wd(args->params, "sampler.add_to_palette", true)){ Color c; gtk_swatch_get_active_color(GTK_SWATCH(args->swatch_display), &c); @@ -496,7 +554,17 @@ if (dynv_get_bool_wd(args->params, "sampler.rotate_swatch_after_sample", true)){ gtk_swatch_move_active(GTK_SWATCH(args->swatch_display),1); } - updateDiplays(args, widget); + updateDisplays(args, widget); + return TRUE; + break; + + case GDK_a: + on_swatch_menu_add_all_to_palette(NULL, args); + return TRUE; + break; + + case GDK_e: + on_swatch_color_edit(NULL, args); return TRUE; break; @@ -521,18 +589,20 @@ gtk_zoomed_set_zoom(GTK_ZOOMED(args->zoomed_display), gtk_range_get_value(GTK_RANGE(slider))); } - static void color_component_change_value(GtkWidget *widget, Color* c, ColorPickerArgs* args){ gtk_swatch_set_active_color(GTK_SWATCH(args->swatch_display), c); - updateDiplays(args, widget); + updateDisplays(args, widget); +} + +static void color_component_input_clicked(GtkWidget *widget, int component_id, ColorPickerArgs* args){ + dialog_color_component_input_show(GTK_WINDOW(gtk_widget_get_toplevel(args->main)), GTK_COLOR_COMPONENT(widget), component_id, dynv_get_dynv(args->params, "component_edit")); } static void ser_decimal_get(GtkColorComponentComp component, int component_id, Color* color, const char *text){ double v; stringstream ss(text); ss >> v; - - switch (component){ + switch (component){ case hsv: case hsl: if (component_id == 0){ @@ -573,21 +643,14 @@ }; -struct ColorCompItem{ - GtkWidget *widget; - GtkColorComponentComp component; - int component_id; -}; static void color_component_copy(GtkWidget *widget, ColorPickerArgs* args){ - Color color; struct ColorCompItem *comp_item = (struct ColorCompItem*)g_object_get_data(G_OBJECT(gtk_widget_get_parent(widget)), "comp_item"); - gtk_color_component_get_transformed_color(GTK_COLOR_COMPONENT(comp_item->widget), &color); - - string text = serial[0].set(comp_item->component, comp_item->component_id, &color); - - gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), text.c_str(), text.length()); - gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); + const char *text = gtk_color_component_get_text(GTK_COLOR_COMPONENT(comp_item->widget), comp_item->component_id); + if (text){ + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), text, strlen(text)); + gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); + } } static void color_component_paste(GtkWidget *widget, ColorPickerArgs* args){ @@ -603,10 +666,15 @@ gtk_color_component_get_color(GTK_COLOR_COMPONENT(comp_item->widget), &color); gtk_swatch_set_active_color(GTK_SWATCH(args->swatch_display), &color); - updateDiplays(args, comp_item->widget); + updateDisplays(args, comp_item->widget); } } +static void color_component_edit(GtkWidget *widget, ColorPickerArgs* args){ + struct ColorCompItem *comp_item = (struct ColorCompItem*)g_object_get_data(G_OBJECT(gtk_widget_get_parent(widget)), "comp_item"); + dialog_color_component_input_show(GTK_WINDOW(gtk_widget_get_toplevel(args->main)), GTK_COLOR_COMPONENT(comp_item->widget), comp_item->component_id, dynv_get_dynv(args->params, "component_edit")); +} + static void destroy_comp_item(struct ColorCompItem *comp_item){ delete comp_item; } @@ -628,14 +696,20 @@ g_object_set_data_full(G_OBJECT(menu), "comp_item", comp_item, (GDestroyNotify)destroy_comp_item); - item = gtk_menu_item_new_with_image("Copy", gtk_image_new_from_stock(GTK_STOCK_COPY, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("Copy"), gtk_image_new_from_stock(GTK_STOCK_COPY, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(color_component_copy), args); - item = gtk_menu_item_new_with_image("Paste", gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("Paste"), gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(color_component_paste), args); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); + + item = gtk_menu_item_new_with_image(_("Edit"), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(color_component_edit), args); + gtk_widget_show_all(GTK_WIDGET(menu)); if (event){ @@ -694,11 +768,11 @@ GtkTreeIter iter1; const char* falloff_types[][2] = { - { "gpick-falloff-none", "None" }, - { "gpick-falloff-linear", "Linear" }, - { "gpick-falloff-quadratic", "Quadratic" }, - { "gpick-falloff-cubic", "Cubic" }, - { "gpick-falloff-exponential", "Exponential" }, + { "gpick-falloff-none", _("None")}, + { "gpick-falloff-linear", _("Linear")}, + { "gpick-falloff-quadratic", _("Quadratic")}, + { "gpick-falloff-cubic", _("Cubic")}, + { "gpick-falloff-exponential", _("Exponential")}, }; gint32 falloff_type_ids[]={ @@ -760,6 +834,7 @@ dynv_set_bool(args->params, "expander.hsv", gtk_expander_get_expanded(GTK_EXPANDER(args->expanderHSV))); dynv_set_bool(args->params, "expander.hsl", gtk_expander_get_expanded(GTK_EXPANDER(args->expanderHSL))); dynv_set_bool(args->params, "expander.lab", gtk_expander_get_expanded(GTK_EXPANDER(args->expanderLAB))); + dynv_set_bool(args->params, "expander.lch", gtk_expander_get_expanded(GTK_EXPANDER(args->expanderLCH))); dynv_set_bool(args->params, "expander.cmyk", gtk_expander_get_expanded(GTK_EXPANDER(args->expanderCMYK))); dynv_set_bool(args->params, "expander.info", gtk_expander_get_expanded(GTK_EXPANDER(args->expanderInfo))); @@ -788,15 +863,38 @@ return 0; } +static int source_set_nth_color(ColorPickerArgs *args, uint32_t color_n, ColorObject* color){ + if (color_n < 0 || color_n > 6) return -1; + Color c; + color_object_get_color(color, &c); + gtk_swatch_set_color(GTK_SWATCH(args->swatch_display), color_n + 1, &c); + + updateDisplays(args, 0); + return 0; +} + +static int source_get_nth_color(ColorPickerArgs *args, uint32_t color_n, ColorObject** color){ + if (color_n < 0 || color_n > 6) return -1; + Color c; + + gtk_swatch_get_color(GTK_SWATCH(args->swatch_display), color_n + 1, &c); + + struct ColorObject *color_object = color_list_new_color_object(args->gs->colors, &c); + string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); + dynv_set_string(color_object->params, "name", name.c_str()); + + *color = color_object; + + return 0; +} -static int source_set_color(ColorPickerArgs *args, ColorObject* color){ +static int source_set_color(ColorPickerArgs *args, ColorObject* color){ Color c; color_object_get_color(color, &c); gtk_swatch_set_active_color(GTK_SWATCH(args->swatch_display), &c); - updateDiplays(args, 0); - + updateDisplays(args, 0); return 0; } @@ -807,12 +905,50 @@ args->timeout_source_id = 0; } - float refresh_rate = dynv_get_float_wd(args->global_params, "refresh_rate", 30); - args->timeout_source_id = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, 1000/refresh_rate, (GSourceFunc)updateMainColorTimer, args, (GDestroyNotify)NULL); + struct{ + GtkWidget *widget; + const char *setting; + }color_spaces[] = { + {args->expanderCMYK, "color_space.cmyk"}, + {args->expanderHSL, "color_space.hsl"}, + {args->expanderHSV, "color_space.hsv"}, + {args->expanderLAB, "color_space.lab"}, + {args->expanderLCH, "color_space.lch"}, + {args->expanderRGB, "color_space.rgb"}, + {0, 0}, + }; + for (int i = 0; color_spaces[i].setting; i++){ + if (dynv_get_bool_wd(args->params, color_spaces[i].setting, true)) + gtk_widget_show(color_spaces[i].widget); + else + gtk_widget_hide(color_spaces[i].widget); + } + + bool out_of_gamut_mask = dynv_get_bool_wd(args->params, "out_of_gamut_mask", true); + + gtk_color_component_set_out_of_gamut_mask(GTK_COLOR_COMPONENT(args->lab_control), out_of_gamut_mask); + gtk_color_component_set_lab_illuminant(GTK_COLOR_COMPONENT(args->lab_control), color_get_illuminant(dynv_get_string_wd(args->params, "lab.illuminant", "D50"))); + gtk_color_component_set_lab_observer(GTK_COLOR_COMPONENT(args->lab_control), color_get_observer(dynv_get_string_wd(args->params, "lab.observer", "2"))); + updateComponentText(args, GTK_COLOR_COMPONENT(args->lab_control), "lab"); + + gtk_color_component_set_out_of_gamut_mask(GTK_COLOR_COMPONENT(args->lch_control), out_of_gamut_mask); + gtk_color_component_set_lab_illuminant(GTK_COLOR_COMPONENT(args->lch_control), color_get_illuminant(dynv_get_string_wd(args->params, "lab.illuminant", "D50"))); + gtk_color_component_set_lab_observer(GTK_COLOR_COMPONENT(args->lch_control), color_get_observer(dynv_get_string_wd(args->params, "lab.observer", "2"))); + updateComponentText(args, GTK_COLOR_COMPONENT(args->lch_control), "lch"); + + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + gtk_swatch_set_transformation_chain(GTK_SWATCH(args->swatch_display), chain); + gtk_color_set_transformation_chain(GTK_COLOR(args->color_code), chain); + gtk_color_set_transformation_chain(GTK_COLOR(args->contrastCheck), chain); + + if (dynv_get_bool_wd(args->params, "zoomed_enabled", true)){ + float refresh_rate = dynv_get_float_wd(args->global_params, "refresh_rate", 30); + args->timeout_source_id = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, 1000/refresh_rate, (GSourceFunc)updateMainColorTimer, args, (GDestroyNotify)NULL); + } gtk_zoomed_set_size(GTK_ZOOMED(args->zoomed_display), dynv_get_int32_wd(args->params, "zoom_size", 150)); - gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "focus_swatch"), "Click on swatch area to begin adding colors to palette"); + gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "focus_swatch"), _("Click on swatch area to begin adding colors to palette")); return 0; } @@ -842,7 +978,7 @@ color_object_get_color(colorobject, &c); gtk_swatch_set_color(GTK_SWATCH(dd->widget), color_index, &c); - updateDiplays((ColorPickerArgs*)dd->userdata, 0); + updateDisplays((ColorPickerArgs*)dd->userdata, 0); return 0; } @@ -876,7 +1012,7 @@ Color c; color_object_get_color(colorobject, &c); gtk_color_set_color(GTK_COLOR(args->contrastCheck), &c, "Sample"); - updateDiplays((ColorPickerArgs*)dd->userdata, 0); + updateDisplays((ColorPickerArgs*)dd->userdata, 0); return 0; } @@ -885,6 +1021,29 @@ return; } +static void on_zoomed_activate(GtkWidget *widget, ColorPickerArgs *args){ + if (dynv_get_bool_wd(args->params, "zoomed_enabled", true)){ + gtk_zoomed_set_fade(GTK_ZOOMED(args->zoomed_display), true); + dynv_set_bool(args->params, "zoomed_enabled", false); + + if (args->timeout_source_id > 0){ + g_source_remove(args->timeout_source_id); + args->timeout_source_id = 0; + } + }else{ + gtk_zoomed_set_fade(GTK_ZOOMED(args->zoomed_display), false); + dynv_set_bool(args->params, "zoomed_enabled", true); + + if (args->timeout_source_id > 0){ + g_source_remove(args->timeout_source_id); + args->timeout_source_id = 0; + } + float refresh_rate = dynv_get_float_wd(args->global_params, "refresh_rate", 30); + args->timeout_source_id = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, 1000/refresh_rate, (GSourceFunc)updateMainColorTimer, args, (GDestroyNotify)NULL); + } + return; +} + static ColorSource* source_implement(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace){ ColorPickerArgs* args = new ColorPickerArgs; @@ -897,6 +1056,8 @@ args->source.destroy = (int (*)(ColorSource *source))source_destroy; args->source.get_color = (int (*)(ColorSource *source, ColorObject** color))source_get_color; args->source.set_color = (int (*)(ColorSource *source, ColorObject* color))source_set_color; + args->source.get_nth_color = (int (*)(ColorSource *source, uint32_t color_n, ColorObject** color))source_get_nth_color; + args->source.set_nth_color = (int (*)(ColorSource *source, uint32_t color_n, ColorObject* color))source_set_nth_color; args->source.activate = (int (*)(ColorSource *source))source_activate; args->source.deactivate = (int (*)(ColorSource *source))source_deactivate; @@ -926,6 +1087,7 @@ g_signal_connect(G_OBJECT(widget), "popup-menu", G_CALLBACK(swatch_popup_menu_cb), args); gtk_swatch_set_active_index(GTK_SWATCH(widget), dynv_get_int32_wd(args->params, "swatch.active_color", 1)); + args->swatch_display = widget; gtk_drag_dest_set(widget, GtkDestDefaults(GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT), 0, 0, GDK_ACTION_COPY); @@ -955,14 +1117,20 @@ } } + + args->color_code = gtk_color_new(); gtk_box_pack_start (GTK_BOX(vbox), args->color_code, false, true, 0); g_signal_connect(G_OBJECT(args->color_code), "activated", G_CALLBACK(show_dialog_converter), args); args->zoomed_display = gtk_zoomed_new(); + if (!dynv_get_bool_wd(args->params, "zoomed_enabled", true)){ + gtk_zoomed_set_fade(GTK_ZOOMED(args->zoomed_display), true); + } gtk_zoomed_set_size(GTK_ZOOMED(args->zoomed_display), dynv_get_int32_wd(args->params, "zoom_size", 150)); gtk_box_pack_start (GTK_BOX(vbox), args->zoomed_display, false, false, 0); + g_signal_connect(G_OBJECT(args->zoomed_display), "activated", G_CALLBACK(on_zoomed_activate), args); scrolled = gtk_scrolled_window_new(0, 0); @@ -972,7 +1140,7 @@ vbox = gtk_vbox_new(false, 5); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), vbox); - expander=gtk_expander_new("Settings"); + expander=gtk_expander_new(_("Settings")); gtk_expander_set_expanded(GTK_EXPANDER(expander), dynv_get_bool_wd(args->params, "expander.settings", false)); args->expanderSettings=expander; gtk_box_pack_start (GTK_BOX(vbox), expander, FALSE, FALSE, 0); @@ -982,24 +1150,24 @@ gtk_container_add(GTK_CONTAINER(expander), table); - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Oversample:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Oversample:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); widget = gtk_hscale_new_with_range (0,16,1); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (on_oversample_value_changed), args); gtk_range_set_value(GTK_RANGE(widget), dynv_get_int32_wd(args->params, "sampler.oversample", 0)); gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Falloff:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Falloff:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); widget = create_falloff_type_list(); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (on_oversample_falloff_changed), args); gtk_combo_box_set_active(GTK_COMBO_BOX(widget), dynv_get_int32_wd(args->params, "sampler.falloff", NONE)); gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Zoom:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); - widget = gtk_hscale_new_with_range (2, 15, 0.5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Zoom:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + widget = gtk_hscale_new_with_range (0, 100, 1); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (on_zoom_value_changed), args); - gtk_range_set_value(GTK_RANGE(widget), dynv_get_float_wd(args->params, "zoom", 2)); + gtk_range_set_value(GTK_RANGE(widget), dynv_get_float_wd(args->params, "zoom", 20)); gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); table_y++; @@ -1009,9 +1177,12 @@ gtk_box_pack_start(GTK_BOX(vbox), expander, FALSE, FALSE, 0); widget = gtk_color_component_new(hsv); + const char *hsv_labels[] = {"H", _("Hue"), "S", _("Saturation"), "V", _("Value"), NULL}; + gtk_color_component_set_label(GTK_COLOR_COMPONENT(widget), hsv_labels); args->hsv_control = widget; g_signal_connect(G_OBJECT(widget), "color-changed", G_CALLBACK(color_component_change_value), args); g_signal_connect(G_OBJECT(widget), "button_release_event", G_CALLBACK(color_component_key_up_cb), args); + g_signal_connect(G_OBJECT(widget), "input-clicked", G_CALLBACK(color_component_input_clicked), args); gtk_container_add(GTK_CONTAINER(expander), widget); expander=gtk_expander_new("HSL"); @@ -1020,9 +1191,12 @@ gtk_box_pack_start(GTK_BOX(vbox), expander, FALSE, FALSE, 0); widget = gtk_color_component_new(hsl); + const char *hsl_labels[] = {"H", _("Hue"), "S", _("Saturation"), "L", _("Lightness"), NULL}; + gtk_color_component_set_label(GTK_COLOR_COMPONENT(widget), hsl_labels); args->hsl_control = widget; g_signal_connect(G_OBJECT(widget), "color-changed", G_CALLBACK(color_component_change_value), args); g_signal_connect(G_OBJECT(widget), "button_release_event", G_CALLBACK(color_component_key_up_cb), args); + g_signal_connect(G_OBJECT(widget), "input-clicked", G_CALLBACK(color_component_input_clicked), args); gtk_container_add(GTK_CONTAINER(expander), widget); expander=gtk_expander_new("RGB"); @@ -1031,9 +1205,12 @@ gtk_box_pack_start (GTK_BOX(vbox), expander, FALSE, FALSE, 0); widget = gtk_color_component_new(rgb); + const char *rgb_labels[] = {"R", _("Red"), "G", _("Green"), "B", _("Blue"), NULL}; + gtk_color_component_set_label(GTK_COLOR_COMPONENT(widget), rgb_labels); args->rgb_control = widget; g_signal_connect(G_OBJECT(widget), "color-changed", G_CALLBACK(color_component_change_value), args); g_signal_connect(G_OBJECT(widget), "button_release_event", G_CALLBACK(color_component_key_up_cb), args); + g_signal_connect(G_OBJECT(widget), "input-clicked", G_CALLBACK(color_component_input_clicked), args); gtk_container_add(GTK_CONTAINER(expander), widget); expander=gtk_expander_new("CMYK"); @@ -1042,9 +1219,12 @@ gtk_box_pack_start(GTK_BOX(vbox), expander, FALSE, FALSE, 0); widget = gtk_color_component_new(cmyk); + const char *cmyk_labels[] = {"C", _("Cyan"), "M", _("Magenta"), "Y", _("Yellow"), "K", _("Key"), NULL}; + gtk_color_component_set_label(GTK_COLOR_COMPONENT(widget), cmyk_labels); args->cmyk_control = widget; g_signal_connect(G_OBJECT(widget), "color-changed", G_CALLBACK(color_component_change_value), args); g_signal_connect(G_OBJECT(widget), "button_release_event", G_CALLBACK(color_component_key_up_cb), args); + g_signal_connect(G_OBJECT(widget), "input-clicked", G_CALLBACK(color_component_input_clicked), args); gtk_container_add(GTK_CONTAINER(expander), widget); expander = gtk_expander_new("Lab"); @@ -1053,12 +1233,29 @@ gtk_box_pack_start (GTK_BOX(vbox), expander, FALSE, FALSE, 0); widget = gtk_color_component_new(lab); + const char *lab_labels[] = {"L", _("Lightness"), "a", "a", "b", "b", NULL}; + gtk_color_component_set_label(GTK_COLOR_COMPONENT(widget), lab_labels); args->lab_control = widget; g_signal_connect(G_OBJECT(widget), "color-changed", G_CALLBACK(color_component_change_value), args); g_signal_connect(G_OBJECT(widget), "button_release_event", G_CALLBACK(color_component_key_up_cb), args); + g_signal_connect(G_OBJECT(widget), "input-clicked", G_CALLBACK(color_component_input_clicked), args); + gtk_container_add(GTK_CONTAINER(expander), widget); + + expander = gtk_expander_new("LCH"); + gtk_expander_set_expanded(GTK_EXPANDER(expander), dynv_get_bool_wd(args->params, "expander.lch", false)); + args->expanderLCH = expander; + gtk_box_pack_start (GTK_BOX(vbox), expander, FALSE, FALSE, 0); + + widget = gtk_color_component_new(lch); + const char *lch_labels[] = {"L", _("Lightness"), "C", "Chroma", "H", "Hue", NULL}; + gtk_color_component_set_label(GTK_COLOR_COMPONENT(widget), lch_labels); + args->lch_control = widget; + g_signal_connect(G_OBJECT(widget), "color-changed", G_CALLBACK(color_component_change_value), args); + g_signal_connect(G_OBJECT(widget), "button_release_event", G_CALLBACK(color_component_key_up_cb), args); + g_signal_connect(G_OBJECT(widget), "input-clicked", G_CALLBACK(color_component_input_clicked), args); gtk_container_add(GTK_CONTAINER(expander), widget); - expander=gtk_expander_new("Info"); + expander=gtk_expander_new(_("Info")); gtk_expander_set_expanded(GTK_EXPANDER(expander), dynv_get_bool_wd(args->params, "expander.info", false)); args->expanderInfo=expander; gtk_box_pack_start (GTK_BOX(vbox), expander, FALSE, FALSE, 0); @@ -1067,7 +1264,7 @@ table_y=0; gtk_container_add(GTK_CONTAINER(expander), table); - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Color name:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Color name:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); widget = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), widget,1,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); gtk_editable_set_editable(GTK_EDITABLE(widget), FALSE); @@ -1080,18 +1277,18 @@ dd.get_color_object = get_color_object_contrast; dd.set_color_object_at = set_color_object_at_contrast; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Contrast:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Contrast:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); widget = gtk_color_new(); Color *c; if ((c = const_cast(dynv_get_color_wd(args->params, "contrast.color", 0)))){ - gtk_color_set_color(GTK_COLOR(widget), c, "Sample"); + gtk_color_set_color(GTK_COLOR(widget), c, _("Sample")); }else{ Color c; c.rgb.red = 1; c.rgb.green = 1; c.rgb.blue = 1; - gtk_color_set_color(GTK_COLOR(widget), &c, "Sample"); + gtk_color_set_color(GTK_COLOR(widget), &c, _("Sample")); } gtk_color_set_rounded(GTK_COLOR(widget), true); gtk_color_set_hcenter(GTK_COLOR(widget), true); @@ -1110,7 +1307,7 @@ table_y++; - updateDiplays(args, 0); + updateDisplays(args, 0); args->main = main_hbox; @@ -1123,11 +1320,12 @@ } int color_picker_source_register(ColorSourceManager *csm){ - ColorSource *color_source = new ColorSource; - color_source_init(color_source, "color_picker", "Color picker"); + ColorSource *color_source = new ColorSource; + color_source_init(color_source, "color_picker", _("Color picker")); color_source->implement = (ColorSource* (*)(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace))source_implement; color_source->single_instance_only = true; - color_source_manager_add_source(csm, color_source); + color_source->default_accelerator = GDK_c; + color_source_manager_add_source(csm, color_source); return 0; } diff -Nru gpick-0.2.4/source/ColorPicker.h gpick-0.2.5/source/ColorPicker.h --- gpick-0.2.4/source/ColorPicker.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorPicker.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorRYB.cpp gpick-0.2.5/source/ColorRYB.cpp --- gpick-0.2.4/source/ColorRYB.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorRYB.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorRYB.h gpick-0.2.5/source/ColorRYB.h --- gpick-0.2.4/source/ColorRYB.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorRYB.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,7 +21,9 @@ #include "Color.h" +#ifndef _MSC_VER #include +#endif #include double color_ryb_transform_lightness(double hue1, double hue2); diff -Nru gpick-0.2.4/source/ColorSource.cpp gpick-0.2.5/source/ColorSource.cpp --- gpick-0.2.4/source/ColorSource.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorSource.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -27,6 +27,8 @@ source->hr_name = g_strdup(name); source->set_color = 0; source->get_color = 0; + source->set_nth_color = 0; + source->get_nth_color = 0; source->activate = 0; source->deactivate = 0; source->destroy = 0; @@ -36,6 +38,7 @@ source->implement = 0; source->widget = 0; source->single_instance_only = false; + source->needs_viewport = true; return 0; } @@ -65,6 +68,31 @@ return -1; } +int color_source_set_nth_color(ColorSource *source, uint32_t color_n, ColorObject *color){ + if (source && source->set_nth_color) + return source->set_nth_color(source, color_n, color); + else if (!source) + cerr << "Color source undefined" << endl; + return -1; +} + +int color_source_get_nth_color(ColorSource *source, uint32_t color_n, ColorObject **color){ + if (source && source->get_nth_color) + return source->get_nth_color(source, color_n, color); + else if (!source) + cerr << "Color source undefined" << endl; + return -1; +} + +int color_source_get_default_accelerator(ColorSource *source) +{ + if (source && source->default_accelerator) + return source->default_accelerator; + else if (!source) + cerr << "Color source undefined" << endl; + return 0; +} + int color_source_destroy(ColorSource* source){ if (source->destroy) return source->destroy(source); g_free(source->identificator); diff -Nru gpick-0.2.4/source/ColorSource.h gpick-0.2.5/source/ColorSource.h --- gpick-0.2.4/source/ColorSource.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorSource.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -42,6 +42,9 @@ int (*set_color)(ColorSource *source, ColorObject *color); int (*get_color)(ColorSource *source, ColorObject **color); + int (*set_nth_color)(ColorSource *source, uint32_t color_n, ColorObject *color); + int (*get_nth_color)(ColorSource *source, uint32_t color_n, ColorObject **color); + int (*activate)(ColorSource *source); int (*deactivate)(ColorSource *source); @@ -52,6 +55,8 @@ int (*destroy)(ColorSource *source); bool single_instance_only; + bool needs_viewport; + int default_accelerator; GtkWidget *widget; void* userdata; @@ -63,7 +68,11 @@ int color_source_deactivate(ColorSource *source); int color_source_set_color(ColorSource *source, ColorObject *color); +int color_source_set_nth_color(ColorSource *source, uint32_t color_n, ColorObject *color); int color_source_get_color(ColorSource *source, ColorObject *color); +int color_source_get_nth_color(ColorSource *source, uint32_t color_n, ColorObject **color); + +int color_source_get_default_accelerator(ColorSource *source); ColorSource* color_source_implement(ColorSource* source, GlobalState *gs, struct dynvSystem *dynv_namespace); GtkWidget* color_source_get_widget(ColorSource* source); diff -Nru gpick-0.2.4/source/ColorSourceManager.cpp gpick-0.2.5/source/ColorSourceManager.cpp --- gpick-0.2.4/source/ColorSourceManager.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorSourceManager.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorSourceManager.h gpick-0.2.5/source/ColorSourceManager.h --- gpick-0.2.4/source/ColorSourceManager.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorSourceManager.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ColorSpaceType.cpp gpick-0.2.5/source/ColorSpaceType.cpp --- gpick-0.2.4/source/ColorSpaceType.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/ColorSpaceType.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ColorSpaceType.h" +#include "Internationalisation.h" +#include "LuaExt.h" + +#include + +using namespace std; + +const ColorSpaceType color_space_types[] = { + {hsv, 3, + { + {_("Hue"), 360, 0, 360, 0.01}, + {_("Saturation"), 100, 0, 100, 0.01}, + {_("Value"), 100, 0, 100, 0.01}, + }, + }, + {hsl, 3, + { + {_("Hue"), 360, 0, 360, 0.01}, + {_("Saturation"), 100, 0, 100, 0.01}, + {_("Lightness"), 100, 0, 100, 0.01}, + }, + }, + {rgb, 3, + { + {_("Red"), 255, 0, 255, 0.01}, + {_("Green"), 255, 0, 255, 0.01}, + {_("Blue"), 255, 0, 255, 0.01}, + }, + }, + {cmyk, 4, + { + {_("Cyan"), 255, 0, 255, 0.01}, + {_("Magenta"), 255, 0, 255, 0.01}, + {_("Yellow"), 255, 0, 255, 0.01}, + {_("Key"), 255, 0, 255, 0.01} + } + }, + {lab, 3, + { + {_("Lightness"), 1, 0, 100, 0.0001}, + {"a", 1, -145, 145, 0.0001}, + {"b", 1, -145, 145, 0.0001} + } + }, + {lch, 3, + { + {_("Lightness"), 1, 0, 100, 0.0001}, + {"Chroma", 1, 0, 100, 0.0001}, + {"Hue", 1, 0, 360, 0.0001} + } + }, +}; + +const ColorSpaceType* color_space_get_types() +{ + return color_space_types; + +} + +uint32_t color_space_count_types() +{ + return sizeof(color_space_types) / sizeof(ColorSpaceType); +} + +std::list color_space_color_to_text(const char *type, const Color *color, lua_State* L) +{ + list result; + + int status; + int stack_top = lua_gettop(L); + + lua_getglobal(L, "gpick"); + int gpick_namespace = lua_gettop(L); + if (lua_type(L, -1) != LUA_TNIL){ + + lua_pushstring(L, "component_to_text"); + lua_gettable(L, gpick_namespace); + if (lua_type(L, -1) != LUA_TNIL){ + + lua_pushstring(L, type); + lua_pushcolor(L, color); + + status = lua_pcall(L, 2, 1, 0); + if (status == 0){ + if (lua_type(L, -1) == LUA_TTABLE){ + + for (int i = 0; i < 4; i++){ + lua_pushinteger(L, i + 1); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING){ + const char* converted = lua_tostring(L, -1); + result.push_back(string(converted)); + } + lua_pop(L, 1); + } + + lua_settop(L, stack_top); + return result; + }else{ + cerr << "gpick.component_to_text: returned not a table value, type is \"" << type << "\"" << endl; + } + }else{ + cerr << "gpick.component_to_text: " << lua_tostring (L, -1) << endl; + } + }else{ + cerr << "gpick.component_to_text: no such function" << endl; + } + } + + lua_settop(L, stack_top); + return result; +} + diff -Nru gpick-0.2.4/source/ColorSpaceType.h gpick-0.2.5/source/ColorSpaceType.h --- gpick-0.2.4/source/ColorSpaceType.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/ColorSpaceType.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef COLORSPACETYPE_H_ +#define COLORSPACETYPE_H_ + +#include "gtk/ColorComponent.h" +#include "Color.h" +#include +#include + +extern "C"{ +#include +#include +#include +#include +} + +#include +#include + +typedef struct ColorSpaceType +{ + GtkColorComponentComp comp_type; + int8_t n_items; + struct { + const char *name; + double raw_scale; + double min_value; + double max_value; + double step; + }items[4]; +}ColorSpaceType; + +const ColorSpaceType* color_space_get_types(); +uint32_t color_space_count_types(); + +std::list color_space_color_to_text(const char *type, const Color *color, lua_State* L); + +#endif /* COLORSPACETYPE_H_ */ + diff -Nru gpick-0.2.4/source/ColorWheelType.cpp gpick-0.2.5/source/ColorWheelType.cpp --- gpick-0.2.4/source/ColorWheelType.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorWheelType.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -19,6 +19,7 @@ #include "ColorWheelType.h" #include "ColorRYB.h" #include "MathUtil.h" +#include "Internationalisation.h" static void rgb_hue2hue(double hue, Color* hsl){ @@ -52,9 +53,9 @@ } const ColorWheelType color_wheel_types[]={ - {"RGB", rgb_hue2hue, rgb_rgbhue2hue}, - {"RYB v1", ryb1_hue2hue, ryb1_rgbhue2hue}, - {"RYB v2", ryb2_hue2hue, ryb2_rgbhue2hue}, + {N_("RGB"), rgb_hue2hue, rgb_rgbhue2hue}, + {N_("RYB v1"), ryb1_hue2hue, ryb1_rgbhue2hue}, + {N_("RYB v2"), ryb2_hue2hue, ryb2_rgbhue2hue}, }; const ColorWheelType* color_wheel_types_get(){ diff -Nru gpick-0.2.4/source/ColorWheelType.h gpick-0.2.5/source/ColorWheelType.h --- gpick-0.2.4/source/ColorWheelType.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ColorWheelType.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,13 +22,40 @@ #include "Color.h" #include +/** \file source/ColorWheelType.h + * \brief Color wheel type description structure and functions + */ + +/** \struct ColorWheelType + * \brief ColorWheelType structure contains color wheel type name and conversion functions + */ typedef struct ColorWheelType{ - const char *name; + const char *name; /**< Name of a color wheel */ +/** + * Callback used to convert color wheel specific hue into the color in a HSL color space + * @param[in] hue Color wheel specific hue value + * @param[out] hsl Result as a color in HSL color space + */ void (*hue_to_hsl)(double hue, Color* hsl); + +/** + * Callback used to convert HSL color space hue into color wheel specific hue + * @param[in] rgbhue HSL color space hue value + * @param[out] hue Color wheel specific hue value + */ void (*rgbhue_to_hue)(double rgbhue, double *hue); }ColorWheelType; +/** + * Get available color wheel types + * @return Constant array of available color wheel types + */ const ColorWheelType* color_wheel_types_get(); + +/** + * Get the number of available color wheel types + * @return Number of available color wheel types + */ const uint32_t color_wheel_types_get_n(); #endif /* COLOR_WHEEL_TYPE_H_ */ diff -Nru gpick-0.2.4/source/Converter.cpp gpick-0.2.5/source/Converter.cpp --- gpick-0.2.4/source/Converter.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Converter.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/Converter.h gpick-0.2.5/source/Converter.h --- gpick-0.2.4/source/Converter.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Converter.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,7 +20,9 @@ #define CONVERTER_H_ #include "dynv/DynvSystem.h" +#ifndef _MSC_VER #include +#endif #include class Converters; diff -Nru gpick-0.2.4/source/CopyPaste.cpp gpick-0.2.5/source/CopyPaste.cpp --- gpick-0.2.4/source/CopyPaste.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/CopyPaste.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/CopyPaste.h gpick-0.2.5/source/CopyPaste.h --- gpick-0.2.4/source/CopyPaste.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/CopyPaste.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/DragDrop.cpp gpick-0.2.5/source/DragDrop.cpp --- gpick-0.2.4/source/DragDrop.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/DragDrop.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -19,9 +19,11 @@ #include "DragDrop.h" #include "gtk/ColorWidget.h" #include "uiApp.h" +#include "dynv/DynvXml.h" #include #include +#include using namespace std; @@ -29,11 +31,13 @@ TARGET_STRING = 1, TARGET_ROOTWIN, TARGET_COLOR, - TARGET_COLOR_OBJECT, + TARGET_COLOR_OBJECT_LIST, + TARGET_COLOR_OBJECT_LIST_SERIALIZED, }; static GtkTargetEntry targets[] = { - { (char*)"colorobject", GTK_TARGET_SAME_APP, TARGET_COLOR_OBJECT }, + { (char*)"colorobject-list", GTK_TARGET_SAME_APP, TARGET_COLOR_OBJECT_LIST }, + { (char*)"application/x-colorobject-list", GTK_TARGET_OTHER_APP, TARGET_COLOR_OBJECT_LIST_SERIALIZED }, { (char*)"application/x-color", 0, TARGET_COLOR }, { (char*)"text/plain", 0, TARGET_STRING }, { (char*)"STRING", 0, TARGET_STRING }, @@ -62,9 +66,12 @@ dd->data_get = 0; dd->data_delete = 0; dd->drag_end = 0; + dd->get_color_object_list = 0; + dd->set_color_object_list_at = 0; dd->handler_map = 0; - dd->color_object = 0; + dd->data_type = DragDrop::DATA_TYPE_NONE; + memset(&dd->data, 0, sizeof(dd->data)); dd->widget = 0; dd->gs = gs; dd->dragwidget = 0; @@ -124,11 +131,92 @@ if (!success) switch (target_type){ - case TARGET_COLOR_OBJECT: + case TARGET_COLOR_OBJECT_LIST: { - struct ColorObject* color_object; - memcpy(&color_object, selection_data->data, sizeof(struct ColorObject*)); - dd->set_color_object_at(dd, color_object, x, y, context->action & GDK_ACTION_MOVE ); + struct ColorList{ + uint64_t color_object_n; + struct ColorObject* color_object; + }data; + + memcpy(&data, selection_data->data, sizeof(data)); + + if (data.color_object_n > 1){ + struct ColorObject **color_objects = new struct ColorObject*[data.color_object_n]; + memcpy(color_objects, selection_data->data + offsetof(ColorList, color_object), sizeof(struct ColorObject*) * data.color_object_n); + + if (dd->set_color_object_list_at) + dd->set_color_object_list_at(dd, color_objects, data.color_object_n, x, y, context->action & GDK_ACTION_MOVE ); + else if (dd->set_color_object_at) + dd->set_color_object_at(dd, data.color_object, x, y, context->action & GDK_ACTION_MOVE ); + + }else{ + if (dd->set_color_object_at) + dd->set_color_object_at(dd, data.color_object, x, y, context->action & GDK_ACTION_MOVE ); + } + + } + success = true; + break; + + case TARGET_COLOR_OBJECT_LIST_SERIALIZED: + { + char *buffer = new char [selection_data->length + 1]; + buffer[selection_data->length] = 0; + memcpy(buffer, selection_data->data, selection_data->length); + stringstream str(buffer); + delete [] buffer; + struct dynvSystem *params = dynv_system_create(dd->handler_map); + dynv_xml_deserialize(params, str); + + uint32_t color_n = 0; + struct dynvSystem **colors = (struct dynvSystem**)dynv_get_dynv_array_wd(params, "colors", 0, 0, &color_n); + if (color_n > 0 && colors){ + if (color_n > 1){ + if (dd->set_color_object_list_at){ + struct ColorObject **color_objects = new struct ColorObject*[color_n]; + for (uint32_t i = 0; i < color_n; i++){ + color_objects[i] = color_object_new(NULL); + color_objects[i]->params = dynv_system_ref(colors[i]); + color_objects[i] = color_object_copy(color_objects[i]); + } + dd->set_color_object_list_at(dd, color_objects, color_n, x, y, false); + for (uint32_t i = 0; i < color_n; i++){ + color_object_release(color_objects[i]); + } + delete [] color_objects; + }else if (dd->set_color_object_at){ + struct ColorObject* color_object = color_object_new(NULL); + color_object->params = dynv_system_ref(colors[0]); + dd->set_color_object_at(dd, color_object, x, y, false); + color_object_release(color_object); + } + }else{ + if (dd->set_color_object_at){ + struct ColorObject* color_object = color_object_new(NULL); + color_object->params = dynv_system_ref(colors[0]); + dd->set_color_object_at(dd, color_object, x, y, false); + color_object_release(color_object); + } + } + } + if (colors){ + for (uint32_t i = 0; i < color_n; i++){ + dynv_system_release(colors[i]); + } + delete [] colors; + } + + /* + if (data.color_object_n > 1){ + memcpy(color_objects, selection_data->data + offsetof(ColorList, color_object), sizeof(struct ColorObject*) * data.color_object_n); + + if (dd->set_color_object_list_at) + else if (dd->set_color_object_at) + dd->set_color_object_at(dd, data.color_object, x, y, context->action & GDK_ACTION_MOVE ); + + }else{ + } */ + } success = true; break; @@ -254,82 +342,253 @@ if (!success){ - struct ColorObject* color_object = dd->color_object; - if (!color_object) return; - Color color; + if (dd->data_type == DragDrop::DATA_TYPE_COLOR_OBJECT){ - switch (target_type){ - case TARGET_COLOR_OBJECT: - gtk_selection_data_set (selection_data, gdk_atom_intern ("colorobject", TRUE), 8, (guchar *)&color_object, sizeof(struct ColorObject*)); - break; + struct ColorObject* color_object = dd->data.color_object.color_object; + if (!color_object) return; + Color color; + + switch (target_type){ + case TARGET_COLOR_OBJECT_LIST: + { + struct{ + uint64_t color_object_n; + struct ColorObject* color_object; + }data; + data.color_object_n = 1; + data.color_object = color_object; + gtk_selection_data_set(selection_data, gdk_atom_intern("colorobject", TRUE), 8, (guchar *)&data, sizeof(data)); + } + break; - case TARGET_STRING: - { - color_object_get_color(color_object, &color); - char* text = main_get_color_text(dd->gs, &color, COLOR_TEXT_TYPE_COPY); - if (text){ - gtk_selection_data_set_text(selection_data, text, strlen(text)+1); - g_free(text); + case TARGET_COLOR_OBJECT_LIST_SERIALIZED: + { + struct dynvSystem *params = dynv_system_create(dd->handler_map); + struct dynvSystem **colors = new struct dynvSystem*[1]; + colors[0] = color_object->params; + dynv_set_dynv_array(params, "colors", (const dynvSystem**)colors, 1); + delete [] colors; + + stringstream str; + str << "" << endl; + dynv_xml_serialize(params, str); + str << "" << endl; + string xml_data = str.str(); + + gtk_selection_data_set(selection_data, gdk_atom_intern("application/x-colorobject-list", TRUE), 8, (guchar *)xml_data.c_str(), xml_data.length()); + } + break; + + case TARGET_STRING: + { + color_object_get_color(color_object, &color); + char* text = main_get_color_text(dd->gs, &color, COLOR_TEXT_TYPE_COPY); + if (text){ + gtk_selection_data_set_text(selection_data, text, strlen(text)+1); + g_free(text); + } + } + break; + + case TARGET_COLOR: + { + color_object_get_color(color_object, &color); + guint16 data_color[4]; + + data_color[0] = int(color.rgb.red * 0xFFFF); + data_color[1] = int(color.rgb.green * 0xFFFF); + data_color[2] = int(color.rgb.blue * 0xFFFF); + data_color[3] = 0xffff; + + gtk_selection_data_set (selection_data, gdk_atom_intern ("application/x-color", TRUE), 16, (guchar *)data_color, 8); } + break; + + case TARGET_ROOTWIN: + g_print ("Dropped on the root window!\n"); + break; + + default: + g_assert_not_reached (); } - break; + }else if (dd->data_type == DragDrop::DATA_TYPE_COLOR_OBJECTS){ - case TARGET_COLOR: - { - color_object_get_color(color_object, &color); - guint16 data_color[4]; + struct ColorObject** color_objects = dd->data.color_objects.color_objects; + uint32_t color_object_n = dd->data.color_objects.color_object_n; + if (!color_objects) return; + Color color; + + switch (target_type){ + case TARGET_COLOR_OBJECT_LIST: + { + struct ColorList{ + uint64_t color_object_n; + struct ColorObject* color_object[1]; + }; + uint32_t data_length = sizeof(uint64_t) + sizeof(struct ColorObject*) * color_object_n; + struct ColorList *data = (struct ColorList*)new char [data_length]; + + data->color_object_n = color_object_n; + memcpy(&data->color_object[0], color_objects, sizeof(struct ColorObject*) * color_object_n); + + gtk_selection_data_set(selection_data, gdk_atom_intern("colorobject", TRUE), 8, (guchar *)data, data_length); + delete [] (char*)data; + } + break; - data_color[0] = int(color.rgb.red * 0xFFFF); - data_color[1] = int(color.rgb.green * 0xFFFF); - data_color[2] = int(color.rgb.blue * 0xFFFF); - data_color[3] = 0xffff; + case TARGET_COLOR_OBJECT_LIST_SERIALIZED: + { + struct dynvSystem *params = dynv_system_create(dd->handler_map); + + if (color_object_n > 0){ + struct dynvSystem **colors = new struct dynvSystem*[color_object_n]; + for (uint32_t i = 0; i < color_object_n; i++){ + colors[i] = color_objects[i]->params; + } + dynv_set_dynv_array(params, "colors", (const dynvSystem**)colors, color_object_n); + delete [] colors; + } + + stringstream str; + str << "" << endl; + dynv_xml_serialize(params, str); + str << "" << endl; + string xml_data = str.str(); - gtk_selection_data_set (selection_data, gdk_atom_intern ("application/x-color", TRUE), 16, (guchar *)data_color, 8); + gtk_selection_data_set(selection_data, gdk_atom_intern("application/x-colorobject-list", TRUE), 8, (guchar *)xml_data.c_str(), xml_data.length()); + } + break; + + case TARGET_STRING: + { + stringstream ss; + for (uint32_t i = 0; i != color_object_n; i++){ + struct ColorObject *color_object = color_objects[i]; + + color_object_get_color(color_object, &color); + char* text = main_get_color_text(dd->gs, &color, COLOR_TEXT_TYPE_COPY); + if (text){ + ss << text << endl; + g_free(text); + } + } + gtk_selection_data_set_text(selection_data, ss.str().c_str(), ss.str().length() + 1); + } + break; + + case TARGET_COLOR: + { + struct ColorObject *color_object = color_objects[0]; + + color_object_get_color(color_object, &color); + guint16 data_color[4]; + + data_color[0] = int(color.rgb.red * 0xFFFF); + data_color[1] = int(color.rgb.green * 0xFFFF); + data_color[2] = int(color.rgb.blue * 0xFFFF); + data_color[3] = 0xffff; + + gtk_selection_data_set (selection_data, gdk_atom_intern ("application/x-color", TRUE), 16, (guchar *)data_color, 8); + } + break; + + case TARGET_ROOTWIN: + g_print ("Dropped on the root window!\n"); + break; + + default: + g_assert_not_reached (); } - break; - case TARGET_ROOTWIN: - g_print ("Dropped on the root window!\n"); - break; - default: - g_assert_not_reached (); + } + } } static void drag_begin(GtkWidget *widget, GdkDragContext *context, gpointer user_data){ struct DragDrop *dd = (struct DragDrop*)user_data; - struct ColorObject* color_object = dd->get_color_object(dd); - if (color_object){ - dd->color_object = color_object; - - GtkWidget* dragwindow = gtk_window_new(GTK_WINDOW_POPUP); - GtkWidget* colorwidget = gtk_color_new(); - gtk_container_add(GTK_CONTAINER(dragwindow), colorwidget); - gtk_window_resize(GTK_WINDOW(dragwindow), 164, 24); - - Color color; - color_object_get_color(color_object, &color); - - char* text = main_get_color_text(dd->gs, &color, COLOR_TEXT_TYPE_DISPLAY); - gtk_color_set_color(GTK_COLOR(colorwidget), &color, text); - g_free(text); + if (dd->get_color_object_list){ + uint32_t color_object_n; + struct ColorObject** color_objects = dd->get_color_object_list(dd, &color_object_n); + if (color_objects){ + dd->data_type = DragDrop::DATA_TYPE_COLOR_OBJECTS; + dd->data.color_objects.color_objects = color_objects; + dd->data.color_objects.color_object_n = color_object_n; + + GtkWidget* dragwindow = gtk_window_new(GTK_WINDOW_POPUP); + GtkWidget* hbox = gtk_vbox_new(true, 0); + gtk_container_add(GTK_CONTAINER(dragwindow), hbox); + gtk_window_resize(GTK_WINDOW(dragwindow), 164, 24 * std::min(color_object_n, (uint32_t)5)); - gtk_drag_set_icon_widget(context, dragwindow, 0, 0); - gtk_widget_show_all(dragwindow); + for (int i = 0; i < std::min(color_object_n, (uint32_t)5); i++){ + Color color; + color_object_get_color(color_objects[i], &color); + + GtkWidget* colorwidget = gtk_color_new(); + char* text = main_get_color_text(dd->gs, &color, COLOR_TEXT_TYPE_DISPLAY); + gtk_color_set_color(GTK_COLOR(colorwidget), &color, text); + g_free(text); + + gtk_box_pack_start(GTK_BOX(hbox), colorwidget, true, true, 0); + } - dd->dragwidget = dragwindow; + gtk_drag_set_icon_widget(context, dragwindow, 0, 0); + gtk_widget_show_all(dragwindow); + + dd->dragwidget = dragwindow; + return; + } + } + + if (dd->get_color_object){ + struct ColorObject* color_object = dd->get_color_object(dd); + if (color_object){ + dd->data_type = DragDrop::DATA_TYPE_COLOR_OBJECT; + dd->data.color_object.color_object = color_object; + + GtkWidget* dragwindow = gtk_window_new(GTK_WINDOW_POPUP); + GtkWidget* colorwidget = gtk_color_new(); + gtk_container_add(GTK_CONTAINER(dragwindow), colorwidget); + gtk_window_resize(GTK_WINDOW(dragwindow), 164, 24); + + Color color; + color_object_get_color(color_object, &color); + + char* text = main_get_color_text(dd->gs, &color, COLOR_TEXT_TYPE_DISPLAY); + gtk_color_set_color(GTK_COLOR(colorwidget), &color, text); + g_free(text); + + gtk_drag_set_icon_widget(context, dragwindow, 0, 0); + gtk_widget_show_all(dragwindow); + + dd->dragwidget = dragwindow; + return; + } } } static void drag_end(GtkWidget *widget, GdkDragContext *context, gpointer user_data){ struct DragDrop *dd = (struct DragDrop*)user_data; - if (dd->color_object){ - color_object_release(dd->color_object); - dd->color_object = 0; + if (dd->data_type == DragDrop::DATA_TYPE_COLOR_OBJECT){ + if (dd->data.color_object.color_object){ + color_object_release(dd->data.color_object.color_object); + memset(&dd->data, 0, sizeof(dd->data)); + } + dd->data_type = DragDrop::DATA_TYPE_NONE; + } + if (dd->data_type == DragDrop::DATA_TYPE_COLOR_OBJECTS){ + if (dd->data.color_objects.color_objects){ + for (uint32_t i = 0; i < dd->data.color_objects.color_object_n; i++){ + color_object_release(dd->data.color_objects.color_objects[i]); + } + delete [] dd->data.color_objects.color_objects; + memset(&dd->data, 0, sizeof(dd->data)); + } + dd->data_type = DragDrop::DATA_TYPE_NONE; } if (dd->dragwidget){ diff -Nru gpick-0.2.4/source/DragDrop.h gpick-0.2.5/source/DragDrop.h --- gpick-0.2.4/source/DragDrop.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/DragDrop.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -34,13 +34,32 @@ struct ColorObject* (*get_color_object)(struct DragDrop* dd); int (*set_color_object_at)(struct DragDrop* dd, struct ColorObject* colorobject, int x, int y, bool move); + + struct ColorObject** (*get_color_object_list)(struct DragDrop* dd, uint32_t *colorobject_n); + int (*set_color_object_list_at)(struct DragDrop* dd, struct ColorObject** colorobject, uint32_t colorobject_n, int x, int y, bool move); + bool (*test_at)(struct DragDrop* dd, int x, int y); bool (*data_received)(struct DragDrop* dd, GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint target_type, guint time); bool (*data_get)(struct DragDrop* dd, GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint target_type, guint time); bool (*data_delete)(struct DragDrop* dd, GtkWidget *widget, GdkDragContext *context); bool (*drag_end)(struct DragDrop* dd, GtkWidget *widget, GdkDragContext *context); - struct ColorObject* color_object; + enum DataType{ + DATA_TYPE_NONE, + DATA_TYPE_COLOR_OBJECT, + DATA_TYPE_COLOR_OBJECTS, + }; + DataType data_type; + union{ + struct{ + struct ColorObject* color_object; + }color_object; + struct{ + struct ColorObject** color_objects; + uint32_t color_object_n; + }color_objects; + }data; + struct dynvHandlerMap* handler_map; GtkWidget* dragwidget; GlobalState *gs; diff -Nru gpick-0.2.4/source/DynvHelpers.cpp gpick-0.2.5/source/DynvHelpers.cpp --- gpick-0.2.4/source/DynvHelpers.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/DynvHelpers.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -166,6 +166,15 @@ }else return (const Color**)r; } +const struct dynvSystem** dynv_get_dynv_array_wd(struct dynvSystem* dynv_system, const char *path, const struct dynvSystem** default_value, uint32_t default_count, uint32_t *count){ + int error; + void** r = dynv_get_array(dynv_system, "dynv", path, count, &error); + if (error){ + if (count) *count = default_count; + return default_value; + }else return (const struct dynvSystem**)r; +} + void dynv_set_int32_array(struct dynvSystem* dynv_system, const char *path, int32_t* values, uint32_t count){ dynv_set_array(dynv_system, "int32", path, (const void**)values, count); } @@ -185,3 +194,8 @@ void dynv_set_color_array(struct dynvSystem* dynv_system, const char *path, const Color** values, uint32_t count){ dynv_set_array(dynv_system, "color", path, (const void**)values, count); } + +void dynv_set_dynv_array(struct dynvSystem* dynv_system, const char *path, const struct dynvSystem** values, uint32_t count){ + dynv_set_array(dynv_system, "dynv", path, (const void**)values, count); +} + diff -Nru gpick-0.2.4/source/DynvHelpers.h gpick-0.2.5/source/DynvHelpers.h --- gpick-0.2.4/source/DynvHelpers.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/DynvHelpers.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -23,7 +23,9 @@ #include "Color.h" #include +#ifndef _MSC_VER #include +#endif int32_t dynv_get_int32_wd(struct dynvSystem* dynv_system, const char *path, int32_t default_value); float dynv_get_float_wd(struct dynvSystem* dynv_system, const char *path, float default_value); @@ -48,11 +50,13 @@ bool* dynv_get_bool_array_wd(struct dynvSystem* dynv_system, const char *path, bool *default_value, uint32_t default_count, uint32_t *count); const char** dynv_get_string_array_wd(struct dynvSystem* dynv_system, const char *path, const char** default_value, uint32_t default_count, uint32_t *count); const Color** dynv_get_color_array_wd(struct dynvSystem* dynv_system, const char *path, const Color** default_value, uint32_t default_count, uint32_t *count); +const struct dynvSystem** dynv_get_dynv_array_wd(struct dynvSystem* dynv_system, const char *path, const struct dynvSystem** default_value, uint32_t default_count, uint32_t *count); void dynv_set_int32_array(struct dynvSystem* dynv_system, const char *path, int32_t* values, uint32_t count); void dynv_set_float_array(struct dynvSystem* dynv_system, const char *path, float* values, uint32_t count); void dynv_set_bool_array(struct dynvSystem* dynv_system, const char *path, bool* values, uint32_t count); void dynv_set_string_array(struct dynvSystem* dynv_system, const char *path, const char** values, uint32_t count); void dynv_set_color_array(struct dynvSystem* dynv_system, const char *path, const Color** values, uint32_t count); +void dynv_set_dynv_array(struct dynvSystem* dynv_system, const char *path, const struct dynvSystem** values, uint32_t count); #endif /* DYNVHELPERS_H_ */ diff -Nru gpick-0.2.4/source/Endian.h gpick-0.2.5/source/Endian.h --- gpick-0.2.4/source/Endian.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Endian.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/FileFormat.cpp gpick-0.2.5/source/FileFormat.cpp --- gpick-0.2.4/source/FileFormat.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/FileFormat.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -69,6 +69,8 @@ file.read((char*) &header, sizeof(header)); if (file.fail()){ file.close(); + + dynv_io_free(mem_io); return -1; } @@ -143,6 +145,7 @@ } dynv_handler_map_release(handler_map); + dynv_io_free(mem_io); file.close(); return 0; @@ -151,6 +154,8 @@ } int palette_file_save(const char* filename, struct ColorList* color_list){ + if (!filename || !color_list) return -1; + ofstream file(filename, ios::binary); if (file.is_open()){ struct dynvIO* mem_io=dynv_io_memory_new(); @@ -222,7 +227,7 @@ prepare_chunk_header(&header, CHUNK_TYPE_COLOR_POSITIONS, color_list->colors.size()*sizeof(uint32_t)); file.write((char*)&header, sizeof(header)); - file.write((char*)positions, color_list->colors.size()*sizeof(long)); + file.write((char*)positions, color_list->colors.size()*sizeof(uint32_t)); delete [] positions; diff -Nru gpick-0.2.4/source/FileFormat.h gpick-0.2.5/source/FileFormat.h --- gpick-0.2.4/source/FileFormat.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/FileFormat.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/FloatingPicker.cpp gpick-0.2.5/source/FloatingPicker.cpp --- gpick-0.2.4/source/FloatingPicker.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/FloatingPicker.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -27,9 +27,14 @@ #include "ColorPicker.h" #include "Converter.h" #include "DynvHelpers.h" +#include "ToolColorNaming.h" #include +#include +#include + using namespace math; +using namespace std; typedef struct FloatingPickerArgs{ GtkWidget* parent; @@ -48,6 +53,24 @@ bool click_mode; }FloatingPickerArgs; +class PickerColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + public: + PickerColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + } + + void assign(struct ColorObject *color_object, Color *color){ + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << color_names_get(m_gs->color_names, color, false); + return m_stream.str(); + } +}; + static void get_color_sample(FloatingPickerArgs *args, bool updateWidgets, Color* c){ GdkScreen *screen; @@ -224,8 +247,8 @@ if (dynv_get_bool_wd(args->gs->params, "gpick.picker.sampler.add_on_release", false)){ - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); + PickerColorNameAssigner name_assigner(args->gs); + name_assigner.assign(color_object, &c); color_list_add_color_object(args->gs->colors, color_object, 1); } @@ -245,6 +268,7 @@ static gboolean key_up_cb (GtkWidget *widget, GdkEventKey *event, FloatingPickerArgs *args){ GdkEventButton event2; + guint modifiers = gtk_accelerator_get_default_mod_mask(); switch(event->keyval){ case GDK_Escape: @@ -255,6 +279,18 @@ button_release_cb(widget, &event2, args); return TRUE; break; + case GDK_m: + { + int x, y; + gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL); + math::Vec2 position(x, y); + if ((event->state&modifiers)==GDK_CONTROL_MASK){ + gtk_zoomed_set_mark(GTK_ZOOMED(args->zoomed), 1, position); + }else{ + gtk_zoomed_set_mark(GTK_ZOOMED(args->zoomed), 0, position); + } + } + break; default: if (color_picker_key_up(args->color_source, event)){ args->release_mode = false; //key pressed and color picked, disable copy on mouse button release diff -Nru gpick-0.2.4/source/FloatingPicker.h gpick-0.2.5/source/FloatingPicker.h --- gpick-0.2.4/source/FloatingPicker.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/FloatingPicker.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/GenerateScheme.cpp gpick-0.2.5/source/GenerateScheme.cpp --- gpick-0.2.4/source/GenerateScheme.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/GenerateScheme.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,6 +20,7 @@ #include "DragDrop.h" #include "GlobalStateStruct.h" +#include "ToolColorNaming.h" #include "uiUtilities.h" #include "ColorList.h" #include "MathUtil.h" @@ -31,10 +32,12 @@ #include "CopyPaste.h" #include "Converter.h" #include "DynvHelpers.h" +#include "Internationalisation.h" #include "uiApp.h" #include +#include #include #include @@ -83,36 +86,53 @@ struct ColorList *preview_color_list; }GenerateSchemeArgs; -typedef struct SchemeType{ - const char *name; - int32_t colors; - int32_t turn_types; - double turn[4]; -}SchemeType; - const SchemeType scheme_types[]={ - {"Complementary", 1, 1, {180}}, - {"Analogous", 5, 1, {30}}, - {"Triadic", 2, 1, {120}}, - {"Split-Complementary", 2, 2, {150, 60}}, - {"Rectangle (tetradic)", 3, 2, {60, 120}}, - {"Square", 3, 1, {90}}, - {"Neutral", 5, 1, {15}}, - {"Clash", 2, 2, {90, 180}}, - {"Five-Tone", 4, 4, {115, 40, 50, 40}}, - {"Six-Tone", 5, 2, {30, 90}}, + {N_("Complementary"), 1, 1, {180}}, + {N_("Analogous"), 5, 1, {30}}, + {N_("Triadic"), 2, 1, {120}}, + {N_("Split-Complementary"), 2, 2, {150, 60}}, + {N_("Rectangle (tetradic)"), 3, 2, {60, 120}}, + {N_("Square"), 3, 1, {90}}, + {N_("Neutral"), 5, 1, {15}}, + {N_("Clash"), 2, 2, {90, 180}}, + {N_("Five-Tone"), 4, 4, {115, 40, 50, 40}}, + {N_("Six-Tone"), 5, 2, {30, 90}}, +}; + +class GenerateSchemeColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + int32_t m_ident; + int32_t m_schemetype; + public: + GenerateSchemeColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + } + + void assign(struct ColorObject *color_object, Color *color, const int32_t ident, const int32_t schemetype){ + m_ident = ident; + m_schemetype = schemetype; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << _("scheme") << " " << _(generate_scheme_get_scheme_type(m_schemetype)->name) << " #" << m_ident << "[" << color_names_get(m_gs->color_names, color, false) << "]"; + return m_stream.str(); + } }; static int set_rgb_color(GenerateSchemeArgs *args, struct ColorObject* color, uint32_t color_index); static int set_rgb_color_by_widget(GenerateSchemeArgs *args, struct ColorObject* color, GtkWidget* color_widget); +// XXX needs to have name assignment in here. + static void calc(GenerateSchemeArgs *args, bool preview, bool save_settings){ int32_t type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->gen_type)); int32_t wheel_type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->wheel_type)); gtk_color_wheel_set_color_wheel_type(GTK_COLOR_WHEEL(args->color_wheel), &color_wheel_types_get()[wheel_type]); - gtk_color_wheel_set_n_colors(GTK_COLOR_WHEEL(args->color_wheel), scheme_types[type].colors + 1); + gtk_color_wheel_set_n_colors(GTK_COLOR_WHEEL(args->color_wheel), generate_scheme_get_scheme_type(type)->colors + 1); //gfloat chaos = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_chaos)); //gboolean correction = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_brightness_correction)); @@ -151,7 +171,7 @@ Color hsv; - for (step_i = 0; step_i <= scheme_types[type].colors; ++step_i) { + for (step_i = 0; step_i <= generate_scheme_get_scheme_type(type)->colors; ++step_i) { wheel->hue_to_hsl(wrap_float(hue + args->mod[step_i].hue), &hsl); hsl.hsl.lightness = clamp_float(hsl.hsl.lightness + lightness, 0, 1); @@ -177,7 +197,7 @@ gtk_color_wheel_set_saturation(GTK_COLOR_WHEEL(args->color_wheel), step_i, hsv.hsv.saturation); gtk_color_wheel_set_value(GTK_COLOR_WHEEL(args->color_wheel), step_i, hsv.hsv.value); - hue_step = (scheme_types[type].turn[step_i%scheme_types[type].turn_types]) / (360.0) + hue_step = (generate_scheme_get_scheme_type(type)->turn[step_i % generate_scheme_get_scheme_type(type)->turn_types]) / (360.0) + chaos*(((random_get(args->gs->random)&0xFFFFFFFF)/(gdouble)0xFFFFFFFF)-0.5); hue = wrap_float(hue + hue_step); @@ -187,7 +207,7 @@ if (preview){ - uint32_t total_colors = scheme_types[type].colors+1; + uint32_t total_colors = generate_scheme_get_scheme_type(type)->colors + 1; if (total_colors > MAX_COLOR_WIDGETS) total_colors = MAX_COLOR_WIDGETS; for (uint32_t i = args->colors_visible; i > total_colors; --i) @@ -269,14 +289,14 @@ menu = gtk_menu_new(); - item = gtk_check_menu_item_new_with_mnemonic("_Locked"); + item = gtk_check_menu_item_new_with_mnemonic(_("_Locked")); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), args->wheel_locked); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_signal_connect(G_OBJECT(item), "toggled", G_CALLBACK(color_wheel_locked_toggled_cb), args); gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_image("_Reset scheme", gtk_image_new_from_stock(GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("_Reset scheme"), gtk_image_new_from_stock(GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK(color_reset_scheme_cb), args); @@ -356,34 +376,44 @@ color_object_release(color_object); } +static string identify_color_widget(GtkWidget *widget, GenerateSchemeArgs *args) +{ + for (int i = 0; i < MAX_COLOR_WIDGETS; ++i){ + if (args->colors[i] == widget){ + return "result " + boost::lexical_cast(i + 1); + } + } + return "unknown"; +} -static void on_color_add_to_palette(GtkWidget *widget, gpointer item) { - GenerateSchemeArgs* args=(GenerateSchemeArgs*)item; +static void add_color_to_palette(GtkWidget *color_widget, GenerateSchemeColorNameAssigner &name_assigner, GenerateSchemeArgs *args) +{ Color c; - - gtk_color_get_color(GTK_COLOR(g_object_get_data(G_OBJECT(widget), "color_widget")), &c); - - struct ColorObject *color_object=color_list_new_color_object(args->gs->colors, &c); - string name=color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); + struct ColorObject *color_object; + string widget_ident; + int32_t type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->gen_type)); + gtk_color_get_color(GTK_COLOR(color_widget), &c); + color_object = color_list_new_color_object(args->gs->colors, &c); + widget_ident = identify_color_widget(color_widget, args); + name_assigner.assign(color_object, &c, atoi(widget_ident.c_str()+7), type); color_list_add_color_object(args->gs->colors, color_object, 1); color_object_release(color_object); } +static void on_color_add_to_palette(GtkWidget *widget, gpointer item) { + GenerateSchemeArgs* args = (GenerateSchemeArgs*)item; + GtkWidget *color_widget = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "color_widget")); + GenerateSchemeColorNameAssigner name_assigner(args->gs); + add_color_to_palette(color_widget, name_assigner, args); +} + static void on_color_add_all_to_palette(GtkWidget *widget, gpointer item) { - GenerateSchemeArgs* args=(GenerateSchemeArgs*)item; - Color c; + GenerateSchemeArgs* args = (GenerateSchemeArgs*)item; + GenerateSchemeColorNameAssigner name_assigner(args->gs); for (int i = 0; i < args->colors_visible; ++i){ - gtk_color_get_color(GTK_COLOR(args->colors[i]), &c); - - struct ColorObject *color_object=color_list_new_color_object(args->gs->colors, &c); - string name=color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); - color_list_add_color_object(args->gs->colors, color_object, 1); - color_object_release(color_object); + add_color_to_palette(args->colors[i], name_assigner, args); } - } static gboolean color_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, GenerateSchemeArgs *args){ @@ -401,15 +431,8 @@ static void on_color_activate(GtkWidget *widget, gpointer item) { GenerateSchemeArgs* args=(GenerateSchemeArgs*)item; - Color c; - - gtk_color_get_color(GTK_COLOR(widget), &c); - - struct ColorObject *color_object=color_list_new_color_object(args->gs->colors, &c); - string name=color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); - color_list_add_color_object(args->gs->colors, color_object, 1); - color_object_release(color_object); + GenerateSchemeColorNameAssigner name_assigner(args->gs); + add_color_to_palette(widget, name_assigner, args); } static void color_show_menu(GtkWidget* widget, GenerateSchemeArgs* args, GdkEventButton *event ){ @@ -418,19 +441,19 @@ menu = gtk_menu_new (); - item = gtk_menu_item_new_with_image ("_Add to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Add to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_add_to_palette), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); - item = gtk_menu_item_new_with_image ("_Add all to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("A_dd all to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_add_all_to_palette), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_mnemonic ("_Copy to clipboard"); + item = gtk_menu_item_new_with_mnemonic (_("_Copy to clipboard")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); Color c; @@ -443,12 +466,12 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_image ("_Edit...", gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Edit..."), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_edit), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); - item = gtk_menu_item_new_with_image ("_Paste", gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Paste"), gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_paste), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); @@ -459,7 +482,7 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_image("_Reset", gtk_image_new_from_stock(GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("_Reset"), gtk_image_new_from_stock(GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK(color_reset_cb), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); @@ -557,16 +580,19 @@ } static int source_get_color(GenerateSchemeArgs *args, ColorObject** color){ + GenerateSchemeColorNameAssigner name_assigner(args->gs); Color c; + string widget_ident; + int32_t type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->gen_type)); if (args->last_focused_color){ gtk_color_get_color(GTK_COLOR(args->last_focused_color), &c); + widget_ident = identify_color_widget(args->last_focused_color, args); }else{ gtk_color_get_color(GTK_COLOR(args->colors[0]), &c); + widget_ident = identify_color_widget(args->colors[0], args); } *color = color_list_new_color_object(args->gs->colors, &c); - - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string((*color)->params, "name", name.c_str()); + name_assigner.assign(*color, &c, atoi(widget_ident.c_str() + 7), type); return 0; } @@ -622,6 +648,10 @@ return 0; } +static int source_set_nth_color(GenerateSchemeArgs *args, uint32_t color_n, ColorObject* color){ + if (color_n < 0 || color_n > 6) return -1; + return set_rgb_color(args, color, color_n); +} static int source_set_color(GenerateSchemeArgs *args, struct ColorObject* color){ if (args->last_focused_color){ @@ -632,6 +662,12 @@ } static int source_activate(GenerateSchemeArgs *args){ + + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + for (uint32_t i = 0; i < MAX_COLOR_WIDGETS; ++i){ + gtk_color_set_transformation_chain(GTK_COLOR(args->colors[i]), chain); + } + gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "empty"), ""); return 0; } @@ -719,6 +755,7 @@ args->source.destroy = (int (*)(ColorSource *source))source_destroy; args->source.get_color = (int (*)(ColorSource *source, ColorObject** color))source_get_color; args->source.set_color = (int (*)(ColorSource *source, ColorObject* color))source_set_color; + args->source.set_nth_color = (int (*)(ColorSource *source, uint32_t color_n, ColorObject* color))source_set_nth_color; args->source.deactivate = (int (*)(ColorSource *source))source_deactivate; args->source.activate = (int (*)(ColorSource *source))source_activate; @@ -749,7 +786,7 @@ gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 5); args->color_previews = gtk_table_new(3, 2, false); - gtk_box_pack_start(GTK_BOX(vbox), args->color_previews, true, true, 5); + gtk_box_pack_start(GTK_BOX(vbox), args->color_previews, true, true, 0); struct DragDrop dd; dragdrop_init(&dd, gs); @@ -758,9 +795,10 @@ dd.get_color_object = get_color_object; dd.set_color_object_at = set_color_object_at; - for (int i = 0; i < MAX_COLOR_WIDGETS; ++i){ + for (intptr_t i = 0; i < MAX_COLOR_WIDGETS; ++i){ widget = gtk_color_new(); gtk_color_set_rounded(GTK_COLOR(widget), true); + gtk_color_set_roundness(GTK_COLOR(widget), 5); gtk_color_set_hcenter(GTK_COLOR(widget), true); gtk_table_attach(GTK_TABLE(args->color_previews), widget, i % 2, (i % 2) + 1, i / 2, i / 2 + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 0, 0); @@ -785,7 +823,7 @@ hbox2 = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox2, false, false, 5); + gtk_box_pack_start(GTK_BOX(vbox), hbox2, false, false, 0); args->color_wheel = gtk_color_wheel_new(); gtk_box_pack_start(GTK_BOX(hbox2), args->color_wheel, false, false, 0); @@ -807,17 +845,17 @@ gint table_y; table = gtk_table_new(5, 2, false); - gtk_box_pack_start(GTK_BOX(hbox2), table, true, true, 5); + gtk_box_pack_start(GTK_BOX(hbox2), table, true, true, 0); table_y = 0; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Hue:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Hue:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->hue = gtk_hscale_new_with_range(0, 360, 1); gtk_range_set_value(GTK_RANGE(args->hue), dynv_get_float_wd(args->params, "hue", 180)); g_signal_connect (G_OBJECT (args->hue), "value-changed", G_CALLBACK (update), args); gtk_table_attach(GTK_TABLE(table), args->hue,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Saturation:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Saturation:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->saturation = gtk_hscale_new_with_range(0, 120, 1); gtk_range_set_value(GTK_RANGE(args->saturation), dynv_get_float_wd(args->params, "saturation", 100)); g_signal_connect (G_OBJECT (args->saturation), "value-changed", G_CALLBACK (update), args); @@ -825,7 +863,7 @@ gtk_table_attach(GTK_TABLE(table), args->saturation,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Lightness:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Lightness:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->lightness = gtk_hscale_new_with_range(-50, 80, 1); gtk_range_set_value(GTK_RANGE(args->lightness), dynv_get_float_wd(args->params, "lightness", 0)); g_signal_connect (G_OBJECT (args->lightness), "value-changed", G_CALLBACK (update), args); @@ -834,21 +872,21 @@ table_y++; //table_y=0; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Type:",0,0.5,0,0),0,1,table_y,table_y+1, GTK_FILL, GTK_SHRINK, 5, 5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Type:"),0,0.5,0,0),0,1,table_y,table_y+1, GTK_FILL, GTK_SHRINK, 5, 5); args->gen_type = gtk_combo_box_new_text(); - for (uint32_t i=0; igen_type), scheme_types[i].name); + for (uint32_t i = 0; i < generate_scheme_get_n_scheme_types(); i++){ + gtk_combo_box_append_text(GTK_COMBO_BOX(args->gen_type), _(generate_scheme_get_scheme_type(i)->name)); } gtk_combo_box_set_active(GTK_COMBO_BOX(args->gen_type), dynv_get_int32_wd(args->params, "type", 0)); g_signal_connect (G_OBJECT (args->gen_type), "changed", G_CALLBACK(update), args); gtk_table_attach(GTK_TABLE(table), args->gen_type,1,2,table_y,table_y+1, GTK_FILL, GTK_SHRINK,5,0); table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Color wheel:",0,0.5,0,0),0,1,table_y,table_y+1, GTK_FILL, GTK_SHRINK, 5, 5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Color wheel:"),0,0.5,0,0),0,1,table_y,table_y+1, GTK_FILL, GTK_SHRINK, 5, 5); args->wheel_type = gtk_combo_box_new_text(); for (uint32_t i = 0; i < color_wheel_types_get_n(); i++){ - gtk_combo_box_append_text(GTK_COMBO_BOX(args->wheel_type), color_wheel_types_get()[i].name); + gtk_combo_box_append_text(GTK_COMBO_BOX(args->wheel_type), _(color_wheel_types_get()[i].name)); } gtk_combo_box_set_active(GTK_COMBO_BOX(args->wheel_type), dynv_get_int32_wd(args->params, "wheel_type", 0)); g_signal_connect (G_OBJECT (args->wheel_type), "changed", G_CALLBACK(update), args); @@ -877,10 +915,25 @@ } int generate_scheme_source_register(ColorSourceManager *csm){ - ColorSource *color_source = new ColorSource; - color_source_init(color_source, "generate_scheme", "Scheme generation"); + ColorSource *color_source = new ColorSource; + color_source_init(color_source, "generate_scheme", _("Scheme generation")); color_source->implement = (ColorSource* (*)(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace))source_implement; - color_source_manager_add_source(csm, color_source); + color_source->default_accelerator = GDK_g; + color_source_manager_add_source(csm, color_source); return 0; } +const SchemeType* generate_scheme_get_scheme_type(uint32_t index) +{ + if (index >= 0 && index < generate_scheme_get_n_scheme_types()) + return &scheme_types[index]; + else + return 0; +} + +uint32_t generate_scheme_get_n_scheme_types() +{ + return sizeof(scheme_types) / sizeof(SchemeType); +} + + diff -Nru gpick-0.2.4/source/GenerateScheme.h gpick-0.2.5/source/GenerateScheme.h --- gpick-0.2.4/source/GenerateScheme.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/GenerateScheme.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,6 +21,15 @@ #include "ColorSourceManager.h" +typedef struct SchemeType{ + const char *name; + int32_t colors; + int32_t turn_types; + double turn[4]; +}SchemeType; + int generate_scheme_source_register(ColorSourceManager *csm); +const SchemeType* generate_scheme_get_scheme_type(uint32_t index); +uint32_t generate_scheme_get_n_scheme_types(); #endif /* GENERATESCHEME_H_ */ diff -Nru gpick-0.2.4/source/GlobalState.cpp gpick-0.2.5/source/GlobalState.cpp --- gpick-0.2.4/source/GlobalState.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/GlobalState.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,9 +22,14 @@ #include "ScreenReader.h" #include "Converter.h" +#include "color_names/DownloadNameFile.h" + #include "layout/LuaBindings.h" #include "layout/Layout.h" +#include "transformation/Chain.h" +#include "transformation/Factory.h" + #include "dynv/DynvMemoryIO.h" #include "dynv/DynvVarString.h" #include "dynv/DynvVarInt32.h" @@ -77,6 +82,10 @@ //destroy layout system layout::layouts_term((layout::Layouts*)dynv_get_pointer_wd(gs->params, "Layouts", 0)); + //destroy transformation chain + transformation::Chain *chain = reinterpret_cast(dynv_get_pointer_wdc(gs->params, "TransformationChain", 0)); + delete chain; + //destroy color list, random generator and other systems color_list_destroy(gs->colors); random_destroy(gs->random); @@ -92,10 +101,14 @@ int global_state_init(GlobalState *gs, GlobalStateLevel level){ //Create configuration directory if it doesn't exit - struct stat st; + GStatBuf st; gchar* config_dir = build_config_path(NULL); if (g_stat(config_dir, &st)!=0){ +#ifndef _MSC_VER g_mkdir(config_dir, S_IRWXU); +#else + g_mkdir(config_dir, NULL); +#endif } g_free(config_dir); @@ -130,7 +143,14 @@ //create and load color names gs->color_names = color_names_new(); gchar* tmp; - color_names_load_from_file(gs->color_names, tmp=build_filename("colors.txt")); + if (color_names_load_from_file(gs->color_names, tmp=build_filename("colors.txt")) != 0){ + g_free(tmp); + + if (color_names_load_from_file(gs->color_names, tmp=build_config_path("colors.txt")) != 0){ + download_name_file(tmp); + color_names_load_from_file(gs->color_names, tmp); + } + } g_free(tmp); color_names_load_from_file(gs->color_names, tmp=build_filename("colors0.txt")); g_free(tmp); @@ -189,8 +209,7 @@ gchar* lua_path = g_strjoin(";", lua_root_path, lua_user_path, (void*)0); - lua_pushstring(L, "package"); - lua_gettable(L, LUA_GLOBALSINDEX); + lua_getglobal(L, "package"); lua_pushstring(L, "path"); lua_pushstring(L, lua_path); lua_settable(L, -3); @@ -294,6 +313,32 @@ gs->loaded_levels = GlobalStateLevel(gs->loaded_levels | GLOBALSTATE_CONVERTERS); } + if ((level & GLOBALSTATE_TRANSFORMATIONS) && !(gs->loaded_levels & GLOBALSTATE_TRANSFORMATIONS)){ + transformation::Chain *chain = new transformation::Chain(); + dynv_set_pointer(gs->params, "TransformationChain", chain); + chain->setEnabled(dynv_get_bool_wd(gs->params, "gpick.transformations.enabled", false)); + + struct dynvSystem** config_array; + uint32_t config_size; + + if ((config_array = (struct dynvSystem**)dynv_get_dynv_array_wd(gs->params, "gpick.transformations.items", 0, 0, &config_size))){ + for (uint32_t i = 0; i != config_size; i++){ + const char *name = dynv_get_string_wd(config_array[i], "name", 0); + if (name){ + boost::shared_ptr tran = transformation::Factory::create(name); + if (tran){ + tran->deserialize(config_array[i]); + chain->add(tran); + } + } + dynv_system_release(config_array[i]); + } + + delete [] config_array; + } + + gs->loaded_levels = GlobalStateLevel(gs->loaded_levels | GLOBALSTATE_TRANSFORMATIONS); + } if ((level & GLOBALSTATE_OTHER) && !(gs->loaded_levels & GLOBALSTATE_OTHER)){ //create layout system diff -Nru gpick-0.2.4/source/GlobalState.h gpick-0.2.5/source/GlobalState.h --- gpick-0.2.4/source/GlobalState.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/GlobalState.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -28,6 +28,7 @@ GLOBALSTATE_CONVERTERS = 8, GLOBALSTATE_COLOR_NAMES = 16, GLOBALSTATE_OTHER = 32, + GLOBALSTATE_TRANSFORMATIONS = 64, GLOBALSTATE_ALL = 0xffffffff, }; diff -Nru gpick-0.2.4/source/GlobalStateStruct.h gpick-0.2.5/source/GlobalStateStruct.h --- gpick-0.2.4/source/GlobalStateStruct.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/GlobalStateStruct.h 2013-02-28 17:43:59.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,7 +22,7 @@ #include "GlobalState.h" #include "Sampler.h" -#include "ColorNames.h" +#include "color_names/ColorNames.h" #include "Random.h" #include "dynv/DynvSystem.h" #include "ColorList.h" diff -Nru gpick-0.2.4/source/Internationalisation.h gpick-0.2.5/source/Internationalisation.h --- gpick-0.2.4/source/Internationalisation.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/Internationalisation.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef INTERNATIONALISATIOM_H_ +#define INTERNATIONALISATIOM_H_ + +#ifdef ENABLE_NLS +#include +#define _(STRING) gettext(STRING) +#define N_(STRING) STRING +#else +#define _(STRING) STRING +#define N_(STRING) STRING +#endif + +void initialize_internationalisation(); + +#endif /* INTERNATIONALISATIOM_H_ */ + diff -Nru gpick-0.2.4/source/LayoutPreview.cpp gpick-0.2.5/source/LayoutPreview.cpp --- gpick-0.2.4/source/LayoutPreview.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/LayoutPreview.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -23,12 +23,15 @@ #include "uiApp.h" #include "Converter.h" #include "DynvHelpers.h" +#include "Internationalisation.h" #include "GlobalStateStruct.h" +#include "ToolColorNaming.h" #include "uiUtilities.h" #include "ColorList.h" #include "MathUtil.h" +#include #include "gtk/LayoutPreview.h" #include "layout/Layout.h" #include "layout/Style.h" @@ -57,6 +60,26 @@ GlobalState *gs; }LayoutPreviewArgs; +class LayoutPreviewColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + const char *m_ident; + public: + LayoutPreviewColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + } + + void assign(struct ColorObject *color_object, Color *color, const char *ident){ + m_ident = ident; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << _("layout preview") << " " << m_ident << " [" << color_names_get(m_gs->color_names, color, false) << "]"; + return m_stream.str(); + } +}; + typedef enum{ LAYOUTLIST_HUMAN_NAME = 0, LAYOUTLIST_PTR, @@ -127,7 +150,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable(col, true); - gtk_tree_view_column_set_title(col, "Style item"); + gtk_tree_view_column_set_title(col, _("Style item")); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, true); gtk_tree_view_column_add_attribute(col, renderer, "text", STYLELIST_HUMAN_NAME); @@ -136,7 +159,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable(col, true); - gtk_tree_view_column_set_title(col, "CSS selector"); + gtk_tree_view_column_set_title(col, _("CSS selector")); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, true); gtk_tree_view_column_add_attribute(col, renderer, "text", STYLELIST_CSS_SELECTOR); @@ -158,7 +181,7 @@ GtkWidget *table; - GtkWidget *dialog = gtk_dialog_new_with_buttons("Assign CSS selectors", GTK_WINDOW(gtk_widget_get_toplevel(args->main)), GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Assign CSS selectors"), GTK_WINDOW(gtk_widget_get_toplevel(args->main)), GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -246,15 +269,12 @@ } static int source_get_color(LayoutPreviewArgs *args, struct ColorObject** color){ - Color c; - if (gtk_layout_preview_get_current_color(GTK_LAYOUT_PREVIEW(args->layout), &c)==0){ - - struct ColorObject *color_object = color_list_new_color_object(args->gs->colors, &c); - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); - + Style *style = 0; + if (gtk_layout_preview_get_current_style(GTK_LAYOUT_PREVIEW(args->layout), &style) == 0){ + struct ColorObject *color_object = color_list_new_color_object(args->gs->colors, &style->color); + LayoutPreviewColorNameAssigner name_assigner(args->gs); + name_assigner.assign(color_object, &style->color, style->ident_name.c_str()); *color = color_object; - return 0; } return -1; @@ -341,29 +361,28 @@ } } -static void add_to_palette_cb(GtkWidget *widget, gpointer item) { - LayoutPreviewArgs* args=(LayoutPreviewArgs*)item; +static void add_color_to_palette(Style *style, LayoutPreviewColorNameAssigner &name_assigner, LayoutPreviewArgs *args) +{ + struct ColorObject *color_object; + color_object = color_list_new_color_object(args->gs->colors, &style->color); + name_assigner.assign(color_object, &style->color, style->ident_name.c_str()); + color_list_add_color_object(args->gs->colors, color_object, 1); + color_object_release(color_object); +} +static void add_to_palette_cb(GtkWidget *widget, gpointer item) { + LayoutPreviewArgs* args = (LayoutPreviewArgs*)item; + LayoutPreviewColorNameAssigner name_assigner(args->gs); Style* style = 0; if (gtk_layout_preview_get_current_style(GTK_LAYOUT_PREVIEW(args->layout), &style) == 0){ - struct ColorObject *color_object; - color_object = color_list_new_color_object(args->gs->colors, &style->color); - dynv_set_string(color_object->params, "name", style->ident_name.c_str()); - color_list_add_color_object(args->gs->colors, color_object, 1); - color_object_release(color_object); + add_color_to_palette(style, name_assigner, args); } } static void add_all_to_palette_cb(GtkWidget *widget, LayoutPreviewArgs *args) { - - struct ColorObject *color_object; - + LayoutPreviewColorNameAssigner name_assigner(args->gs); for (list::iterator i = args->layout_system->styles.begin(); i != args->layout_system->styles.end(); i++){ - - color_object = color_list_new_color_object(args->gs->colors, &(*i)->color); - dynv_set_string(color_object->params, "name", (*i)->ident_name.c_str()); - color_list_add_color_object(args->gs->colors, color_object, 1); - color_object_release(color_object); + add_color_to_palette(*i, name_assigner, args); } } @@ -383,18 +402,18 @@ bool selection_avail = gtk_layout_preview_is_selected(GTK_LAYOUT_PREVIEW(args->layout)); - item = gtk_menu_item_new_with_image ("_Add to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("_Add to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (add_to_palette_cb), args); if (!selection_avail) gtk_widget_set_sensitive(item, false); - item = gtk_menu_item_new_with_image ("_Add all to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("A_dd all to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (add_all_to_palette_cb), args); gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_mnemonic ("_Copy to clipboard"); + item = gtk_menu_item_new_with_mnemonic(_("_Copy to clipboard")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); if (selection_avail){ @@ -408,12 +427,12 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_image ("_Edit...", gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Edit..."), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (edit_cb), args); if (!selection_avail) gtk_widget_set_sensitive(item, false); - item = gtk_menu_item_new_with_image ("_Paste", gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Paste"), gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (paste_cb), args); if (!selection_avail) gtk_widget_set_sensitive(item, false); @@ -525,7 +544,7 @@ }else{ GtkWidget* message; - message=gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(widget)), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "File could not be saved"); + message=gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(widget)), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be saved")); gtk_dialog_run(GTK_DIALOG(message)); gtk_widget_destroy(message); } @@ -536,7 +555,7 @@ GtkWidget *dialog; GtkFileFilter *filter; - dialog = gtk_file_chooser_dialog_new ("Export", GTK_WINDOW(gtk_widget_get_toplevel(widget)), + dialog = gtk_file_chooser_dialog_new(_("Export"), GTK_WINDOW(gtk_widget_get_toplevel(widget)), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK, @@ -550,7 +569,7 @@ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), default_path); filter = gtk_file_filter_new(); - gtk_file_filter_set_name(filter, "Cascading Style Sheets *.css"); + gtk_file_filter_set_name(filter, _("Cascading Style Sheets *.css")); gtk_file_filter_add_pattern(filter, "*.css"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); @@ -573,7 +592,7 @@ finished = true; }else{ GtkWidget* message; - message=gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "File could not be saved"); + message=gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be saved")); //gtk_window_set_title(GTK_WINDOW(dialog), "Open"); gtk_dialog_run(GTK_DIALOG(message)); gtk_widget_destroy(message); @@ -599,6 +618,10 @@ } static int source_activate(LayoutPreviewArgs *args){ + + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + gtk_layout_preview_set_transformation_chain(GTK_LAYOUT_PREVIEW(args->layout), chain); + gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "empty"), ""); return 0; } @@ -638,16 +661,16 @@ table_y++; tool = gtk_tool_item_new(); - gtk_tool_item_set_expand(tool, true); + gtk_tool_item_set_expand(tool, true); GtkWidget *layout_dropdown = layout_preview_dropdown_new(args, 0); - gtk_container_add(GTK_CONTAINER(tool), attach_label(layout_dropdown, "Layout:")); + gtk_container_add(GTK_CONTAINER(tool), attach_label(layout_dropdown, _("Layout:"))); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool, -1); g_signal_connect (G_OBJECT(layout_dropdown), "changed", G_CALLBACK(layout_changed_cb), args); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1); - tool = gtk_menu_tool_button_new(gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_BUTTON), "Export CSS File"); - gtk_tool_item_set_tooltip_text(tool, "Export CSS file"); + tool = gtk_menu_tool_button_new(gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_BUTTON), _("Export CSS File")); + gtk_tool_item_set_tooltip_text(tool, _("Export CSS file")); g_signal_connect(G_OBJECT(tool), "clicked", G_CALLBACK(export_css_cb), args); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool, -1); @@ -656,11 +679,11 @@ menu = gtk_menu_new (); - item = gtk_menu_item_new_with_image("_Export CSS File As...", gtk_image_new_from_stock(GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("_Export CSS File As..."), gtk_image_new_from_stock(GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (export_css_as_cb), args); - item = gtk_menu_item_new_with_mnemonic("_Assign CSS Selectors..."); + item = gtk_menu_item_new_with_mnemonic(_("_Assign CSS Selectors...")); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (assign_css_selectors_cb), args); @@ -683,7 +706,6 @@ dd.test_at = test_at; dd.handler_map = dynv_system_get_handler_map(gs->colors->params); - gtk_drag_dest_set(args->layout, GtkDestDefaults(GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT), 0, 0, GDK_ACTION_COPY); gtk_drag_source_set(args->layout, GDK_BUTTON1_MASK, 0, 0, GDK_ACTION_COPY); dragdrop_widget_attach(args->layout, DragDropFlags(DRAGDROP_SOURCE | DRAGDROP_DESTINATION), &dd); @@ -691,6 +713,7 @@ args->gs = gs; + // Restore settings and fill list const char* layout_name = dynv_get_string_wd(args->params, "layout_name", "std_layout_menu_1"); @@ -732,10 +755,12 @@ } int layout_preview_source_register(ColorSourceManager *csm){ - ColorSource *color_source = new ColorSource; - color_source_init(color_source, "layout_preview", "Layout preview"); + ColorSource *color_source = new ColorSource; + color_source_init(color_source, "layout_preview", _("Layout preview")); + color_source->needs_viewport = false; color_source->implement = (ColorSource* (*)(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace))source_implement; - color_source_manager_add_source(csm, color_source); + color_source->default_accelerator = GDK_l; + color_source_manager_add_source(csm, color_source); return 0; } diff -Nru gpick-0.2.4/source/LayoutPreview.h gpick-0.2.5/source/LayoutPreview.h --- gpick-0.2.4/source/LayoutPreview.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/LayoutPreview.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/LuaExt.cpp gpick-0.2.5/source/LuaExt.cpp --- gpick-0.2.4/source/LuaExt.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/LuaExt.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -18,6 +18,7 @@ #include "LuaExt.h" #include +#include "Internationalisation.h" #include using namespace std; @@ -42,7 +43,7 @@ return (Color *)ud; } -int lua_pushcolor (lua_State *L, Color* color) { +int lua_pushcolor (lua_State *L, const Color* color) { Color *c = (Color*)lua_newuserdata(L, sizeof(Color)); luaL_getmetatable(L, "color"); lua_setmetatable(L, -2); @@ -189,6 +190,35 @@ return 1; } + +static int lua_color_lab_lightness (lua_State *L) { + Color *c = lua_checkcolor(L, 1); + if (lua_type(L, 2)==LUA_TNUMBER){ + c->lab.L = luaL_checknumber(L, 2); + } + lua_pushnumber(L, c->lab.L); + return 1; +} + +static int lua_color_lab_a (lua_State *L) { + Color *c = lua_checkcolor(L, 1); + if (lua_type(L, 2)==LUA_TNUMBER){ + c->lab.a = luaL_checknumber(L, 2); + } + lua_pushnumber(L, c->lab.a); + return 1; +} + +static int lua_color_lab_b (lua_State *L) { + Color *c = lua_checkcolor(L, 1); + if (lua_type(L, 2)==LUA_TNUMBER){ + c->lab.b = luaL_checknumber(L, 2); + } + lua_pushnumber(L, c->lab.b); + return 1; +} + + static int lua_color_rgb_to_hsl (lua_State *L) { Color *c = lua_checkcolor(L, 1); Color c2; @@ -215,12 +245,39 @@ return 1; } -static const struct luaL_reg lua_colorlib_f [] = { +static int lua_color_lch_lightness(lua_State *L) { + Color *c = lua_checkcolor(L, 1); + if (lua_type(L, 2)==LUA_TNUMBER){ + c->lch.L = luaL_checknumber(L, 2); + } + lua_pushnumber(L, c->lch.L); + return 1; +} + +static int lua_color_lch_chroma(lua_State *L) { + Color *c = lua_checkcolor(L, 1); + if (lua_type(L, 2)==LUA_TNUMBER){ + c->lch.C = luaL_checknumber(L, 2); + } + lua_pushnumber(L, c->lch.C); + return 1; +} + +static int lua_color_lch_hue(lua_State *L) { + Color *c = lua_checkcolor(L, 1); + if (lua_type(L, 2)==LUA_TNUMBER){ + c->lch.h = luaL_checknumber(L, 2); + } + lua_pushnumber(L, c->lch.h); + return 1; +} + +static const struct luaL_Reg lua_colorlib_f [] = { {"new", lua_newcolor}, {NULL, NULL} }; -static const struct luaL_reg lua_colorlib_m [] = { +static const struct luaL_Reg lua_colorlib_m [] = { {"__tostring", lua_color2string}, {"red", lua_color_red}, {"green", lua_color_green}, @@ -230,6 +287,7 @@ {"hue", lua_color_hue}, {"saturation", lua_color_saturation}, {"lightness", lua_color_lightness}, + {"value", lua_color_lightness}, {"hsl", lua_color_hsl}, {"cyan", lua_color_cyan}, @@ -238,30 +296,33 @@ {"key_black", lua_color_key_black}, {"cmyk", lua_color_cmyk}, + {"lab_lightness", lua_color_lab_lightness}, + {"lab_a", lua_color_lab_a}, + {"lab_b", lua_color_lab_b}, + + {"lch_lightness", lua_color_lch_lightness}, + {"lch_chroma", lua_color_lch_chroma}, + {"lch_hue", lua_color_lch_hue}, + {"rgb_to_hsl", lua_color_rgb_to_hsl}, {"hsl_to_rgb", lua_color_hsl_to_rgb}, {"rgb_to_cmyk", lua_color_rgb_to_cmyk}, {NULL, NULL} }; - -static int luaopen_color (lua_State *L) { +static int luaopen_color(lua_State *L) { luaL_newmetatable(L, "color"); - - lua_pushstring(L, "__index"); - lua_pushvalue(L, -2); /* pushes the metatable */ - lua_settable(L, -3); /* metatable.__index = metatable */ - - luaL_register(L, NULL, lua_colorlib_m); - luaL_register(L, "color", lua_colorlib_f); - - lua_pop(L, 2); - + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + luaL_setfuncs(L, lua_colorlib_m, 0); + lua_pop(L, 1); + + luaL_newlibtable(L, lua_colorlib_f); + luaL_setfuncs(L, lua_colorlib_f, 0); + lua_setglobal(L, "color"); return 1; } - - static int lua_newcolorobject (lua_State *L) { struct ColorObject** c = (struct ColorObject**)lua_newuserdata(L, sizeof(struct ColorObject*)); luaL_getmetatable(L, "colorobject"); @@ -299,12 +360,12 @@ return 0; } -static const struct luaL_reg lua_colorobjectlib_f [] = { +static const struct luaL_Reg lua_colorobjectlib_f [] = { {"new", lua_newcolorobject}, {NULL, NULL} }; -static const struct luaL_reg lua_colorobjectlib_m [] = { +static const struct luaL_Reg lua_colorobjectlib_m [] = { {"get_color", lua_colorobject_get_color}, {"set_color", lua_colorobject_set_color}, {NULL, NULL} @@ -313,16 +374,28 @@ int luaopen_colorobject (lua_State *L) { luaL_newmetatable(L, "colorobject"); + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + luaL_setfuncs(L, lua_colorobjectlib_m, 0); + lua_pop(L, 1); - lua_pushstring(L, "__index"); - lua_pushvalue(L, -2); /* pushes the metatable */ - lua_settable(L, -3); /* metatable.__index = metatable */ - - luaL_register(L, NULL, lua_colorobjectlib_m); - luaL_register(L, "colorobject", lua_colorobjectlib_f); + luaL_newlibtable(L, lua_colorobjectlib_f); + luaL_setfuncs(L, lua_colorobjectlib_f, 0); + lua_setglobal(L, "colorobject"); + return 1; +} - lua_pop(L, 2); +int lua_i18n_gettext(lua_State *L) +{ + const char *text = luaL_checkstring(L, 1); + lua_pushstring(L, _(text)); + return 1; +} +int luaopen_i18n(lua_State *L) +{ + lua_pushcclosure(L, lua_i18n_gettext, 0); + lua_setglobal(L, "_"); return 1; } @@ -330,6 +403,7 @@ int lua_ext_colors_openlib(lua_State *L){ luaopen_color(L); luaopen_colorobject(L); - return 0; + luaopen_i18n(L); + return 0; } diff -Nru gpick-0.2.4/source/LuaExt.h gpick-0.2.5/source/LuaExt.h --- gpick-0.2.4/source/LuaExt.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/LuaExt.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -34,7 +34,7 @@ int lua_pushcolorobject (lua_State *L, struct ColorObject* color_object); struct ColorObject** lua_checkcolorobject (lua_State *L, int index); -int lua_pushcolor (lua_State *L, Color* color); +int lua_pushcolor (lua_State *L, const Color* color); Color *lua_checkcolor (lua_State *L, int index); diff -Nru gpick-0.2.4/source/MathUtil.cpp gpick-0.2.5/source/MathUtil.cpp --- gpick-0.2.4/source/MathUtil.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/MathUtil.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -102,11 +102,11 @@ } } -void matrix3x3_copy(matrix3x3* matrix, matrix3x3* result) { +void matrix3x3_copy(const matrix3x3* matrix, matrix3x3* result) { memcpy(result, matrix, sizeof(matrix3x3)); } -void matrix3x3_multiply(matrix3x3* matrix1, matrix3x3* matrix2, matrix3x3* result){ +void matrix3x3_multiply(const matrix3x3* matrix1, const matrix3x3* matrix2, matrix3x3* result){ int i,j,k; matrix3x3 matrix_t; @@ -129,7 +129,7 @@ } } -double matrix3x3_determinant(matrix3x3* matrix) { +double matrix3x3_determinant(const matrix3x3* matrix) { double det=0; double t; int i,j; @@ -150,7 +150,7 @@ return det; } -void matrix3x3_transpose(matrix3x3* matrix, matrix3x3* result) { +void matrix3x3_transpose(const matrix3x3* matrix, matrix3x3* result) { int i,j; matrix3x3 matrix_t; @@ -167,8 +167,8 @@ } -int matrix3x3_inverse(matrix3x3* matrix, matrix3x3* result){ - double det=matrix3x3_determinant(matrix); +int matrix3x3_inverse(const matrix3x3* matrix, matrix3x3* result){ + double det = matrix3x3_determinant(matrix); if (det==0) return -1; double invdet=1/det; @@ -201,17 +201,17 @@ } -float vector2_length(vector2* v1) { +float vector2_length(const vector2* v1) { return sqrt(v1->x * v1->x + v1->y * v1->y); } -void vector2_normalize(vector2* v1, vector2* r) { +void vector2_normalize(const vector2* v1, vector2* r) { float l = vector2_length(v1); r->x = v1->x / l; r->y = v1->y / l; } -float vector2_dot(vector2* v1, vector2* v2) { +float vector2_dot(const vector2* v1, const vector2* v2) { return v1->x * v2->x + v1->y * v2->y; } @@ -237,7 +237,7 @@ } -void vector3_multiply_matrix3x3(vector3* vector, matrix3x3* matrix, vector3* result) { +void vector3_multiply_matrix3x3(const vector3* vector, const matrix3x3* matrix, vector3* result) { vector3 vector_t; @@ -257,11 +257,17 @@ vector->z = z; } -void vector3_copy(vector3* vector, vector3* result){ +void vector3_copy(const vector3* vector, vector3* result){ memcpy(result, vector, sizeof(vector3)); } -float vector3_length(vector3* vector) { +float vector3_length(const vector3* vector) { return sqrt(vector->x * vector->x + vector->y * vector->y + vector->z * vector->z); } +void vector3_clamp(vector3* vector, float a, float b){ + vector->x = clamp_float(vector->x, a, b); + vector->y = clamp_float(vector->y, a, b); + vector->z = clamp_float(vector->z, a, b); +} + diff -Nru gpick-0.2.4/source/MathUtil.h gpick-0.2.5/source/MathUtil.h --- gpick-0.2.4/source/MathUtil.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/MathUtil.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,6 +21,9 @@ #define PI 3.14159265 +#define MIX(r,a,b,component) r.component = mix_float(a.component, b.component, step_i/(float)(steps-1)) +#define MIX_COMPONENTS(r,a,b,ca,cb,cc) MIX(r,a,b,ca); MIX(r,a,b,cb); MIX(r,a,b,cc) + float min_float_3(float a, float b, float c); float max_float_3(float a, float b, float c); @@ -51,10 +54,10 @@ }matrix3x3; void matrix3x3_identity(matrix3x3* matrix); -void matrix3x3_multiply(matrix3x3* matrix1, matrix3x3* matrix2, matrix3x3* result); -double matrix3x3_determinant(matrix3x3* matrix); -int matrix3x3_inverse(matrix3x3* matrix, matrix3x3* result); -void matrix3x3_transpose(matrix3x3* matrix, matrix3x3* result); +void matrix3x3_multiply(const matrix3x3* matrix1, const matrix3x3* matrix2, matrix3x3* result); +double matrix3x3_determinant(const matrix3x3* matrix); +int matrix3x3_inverse(const matrix3x3* matrix, matrix3x3* result); +void matrix3x3_transpose(const matrix3x3* matrix, matrix3x3* result); typedef struct vector2{ float x; @@ -63,11 +66,11 @@ void vector2_set(vector2* v1, float x, float y); -float vector2_length(vector2* v1); +float vector2_length(const vector2* v1); -void vector2_normalize(vector2* v1, vector2* r); +void vector2_normalize(const vector2* v1, vector2* r); -float vector2_dot(vector2* v1, vector2* v2); +float vector2_dot(const vector2* v1, const vector2* v2); typedef struct vector3{ @@ -82,10 +85,13 @@ }vector3; void vector3_set(vector3* vector, float x, float y, float z); -void vector3_copy(vector3* vector, vector3* result); +void vector3_copy(const vector3* vector, vector3* result); + +float vector3_length(const vector3* vector); -float vector3_length(vector3* vector); +void vector3_multiply_matrix3x3(const vector3* vector, const matrix3x3* matrix, vector3* result ); -void vector3_multiply_matrix3x3(vector3* vector, matrix3x3* matrix, vector3* result ); +void vector3_clamp(vector3* vector, float a, float b); #endif /* MATHUTIL_H_ */ + diff -Nru gpick-0.2.4/source/Noise.cpp gpick-0.2.5/source/Noise.cpp --- gpick-0.2.4/source/Noise.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Noise.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -63,6 +63,10 @@ return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v); } +/** + * Improved Perlin noise algorithm implemented by using reference Java implementation from. + * \see http://mrl.nyu.edu/~perlin/noise/ + */ double noise(double x, double y, double z){ int X = (int)floor(x) & 255, Y = (int)floor(y) & 255, diff -Nru gpick-0.2.4/source/Noise.h gpick-0.2.5/source/Noise.h --- gpick-0.2.4/source/Noise.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Noise.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -19,6 +19,18 @@ #ifndef NOISE_H_ #define NOISE_H_ +/** \file source/Noise.h + * \brief Improved Perlin noise implementation. + */ + +/** + * Returns noise value for specified position. + * @param[in] x X coordinate. + * @param[in] y y coordinate. + * @param[in] z Z coordinate. + * @return Noise value. + */ double noise(double x, double y, double z); #endif /* NOISE_H_ */ + diff -Nru gpick-0.2.4/source/Paths.cpp gpick-0.2.5/source/Paths.cpp --- gpick-0.2.4/source/Paths.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Paths.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -38,7 +38,7 @@ } i=paths; - struct stat sb; + GStatBuf sb; while (i){ tmp = g_build_filename((gchar*)i->data, "gpick", NULL); diff -Nru gpick-0.2.4/source/Paths.h gpick-0.2.5/source/Paths.h --- gpick-0.2.4/source/Paths.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Paths.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,7 +21,23 @@ #include +/** \file source/Paths.h + * \brief Data and configuration filename building functions. + */ + +/** + * Construct filename to a data file. + * @param[in] filename Relative data file name. + * @return Filename to the data file. This value must be released by using g_free. + */ gchar* build_filename(const gchar* filename); + +/** + * Construct filename to a configuration file. + * @param[in] filename Relative configuration file name. + * @return Filename to the configuration file. This value must be released by using g_free. + */ gchar* build_config_path(const gchar *filename); #endif /* PATHS_H_ */ + diff -Nru gpick-0.2.4/source/Random.cpp gpick-0.2.5/source/Random.cpp --- gpick-0.2.4/source/Random.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Random.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/Random.h gpick-0.2.5/source/Random.h --- gpick-0.2.4/source/Random.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Random.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/Rect2.h gpick-0.2.5/source/Rect2.h --- gpick-0.2.4/source/Rect2.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Rect2.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -64,23 +64,56 @@ return *this; }; - const Rect2 impose(const Rect2 &rect){ - x1 = rect.x1 + x1 * rect.getWidth(); - y1 = rect.y1 + y1 * rect.getHeight(); - - x2 = rect.x1 + x2 * rect.getWidth(); - y2 = rect.y1 + y2 * rect.getHeight(); - - return *this; + Rect2 impose(const Rect2 &rect) const{ + Rect2 r; + r.x1 = rect.x1 + x1 * rect.getWidth(); + r.y1 = rect.y1 + y1 * rect.getHeight(); + r.x2 = rect.x1 + x2 * rect.getWidth(); + r.y2 = rect.y1 + y2 * rect.getHeight(); + r.empty = false; + return r; } - bool isInside(const T &x, const T &y){ + bool isInside(const T &x, const T &y) const{ if (xx2 || yy2) return false; else return true; } + bool isInside(const Rect2 &r) const{ + if (empty || r.empty) return false; + if (x1 < r.x1 || x2 > r.x2) return false; + if (y1 < r.y1 || y2 > r.y2) return false; + return true; + } + + Rect2 positionInside(const Rect2& rect) const{ + Rect2 r; + r.empty = false; + if (rect.x1 < x1){ + r.x1 = x1; + r.x2 = x1 + rect.getWidth(); + }else if (rect.x2 > x2){ + r.x1 = x2 - rect.getWidth(); + r.x2 = x2; + }else{ + r.x1 = rect.x1; + r.x2 = rect.x2; + } + if (rect.y1 < y1){ + r.y1 = y1; + r.y2 = y1 + rect.getHeight(); + }else if (rect.y2 > y2){ + r.y1 = y2 - rect.getHeight(); + r.y2 = y2; + }else{ + r.y1 = rect.y1; + r.y2 = rect.y2; + } + return r; + } + bool isEmpty() const{ return empty; }; @@ -97,6 +130,12 @@ T getHeight() const{ return y2-y1; }; + T getCenterX() const{ + return (x1 + x2) / 2; + }; + T getCenterY() const{ + return (y1 + y2) / 2; + }; private: bool empty; diff -Nru gpick-0.2.4/source/RegisterSources.cpp gpick-0.2.5/source/RegisterSources.cpp --- gpick-0.2.4/source/RegisterSources.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/RegisterSources.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -24,6 +24,7 @@ #include "Variations.h" #include "BrightnessDarkness.h" #include "ColorMixer.h" +#include "BlendColors.h" int register_sources(ColorSourceManager *csm){ generate_scheme_source_register(csm); @@ -32,6 +33,7 @@ variations_source_register(csm); brightness_darkness_source_register(csm); color_mixer_source_register(csm); + blend_colors_source_register(csm); return 0; } diff -Nru gpick-0.2.4/source/RegisterSources.h gpick-0.2.5/source/RegisterSources.h --- gpick-0.2.4/source/RegisterSources.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/RegisterSources.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/SConscript gpick-0.2.5/source/SConscript --- gpick-0.2.4/source/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/SConscript 2013-02-28 17:43:59.000000000 +0000 @@ -8,43 +8,51 @@ Import('*') local_env = env.Clone() -if not local_env.GetOption('clean'): +if not local_env.GetOption('clean') and not env['TOOLCHAIN'] == 'msvc': local_env.ParseConfig('pkg-config --cflags --libs $GTK_PC') - if not env['INTERNAL_LUA']: - local_env.ParseConfig('pkg-config --cflags --libs $LUA_PC') - if local_env.has_key('UNIQUE_PC'): - local_env.ParseConfig('pkg-config --libs $UNIQUE_PC') - if local_env.has_key('DBUSGLIB_PC'): - local_env.ParseConfig('pkg-config --libs $DBUSGLIB_PC') + local_env.ParseConfig('pkg-config --cflags --libs $LUA_PC') + if env['DOWNLOAD_RESENE_COLOR_LIST']: + local_env.ParseConfig('pkg-config --libs $CURL_PC') + +if local_env['ENABLE_NLS']: + local_env.Append( + CPPDEFINES = ['ENABLE_NLS'], + ) -sources = local_env.Glob('*.cpp') + local_env.Glob('dynv/*.cpp') + local_env.Glob('tools/*.cpp') +sources = local_env.Glob('*.cpp') + local_env.Glob('dynv/*.cpp') + local_env.Glob('transformation/*.cpp') objects = [] objects.append(SConscript(['version/SConscript'], exports='env')) -objects.append(SConscript(['unique/SConscript'], exports='env')) objects.append(SConscript(['gtk/SConscript'], exports='env')) objects.append(SConscript(['layout/SConscript'], exports='env')) +objects.append(SConscript(['internationalisation/SConscript'], exports='env')) +objects.append(SConscript(['dbus/SConscript'], exports='env')) +objects.append(SConscript(['tools/SConscript'], exports='env')) + +if env['EXPERIMENTAL_CSS_PARSER']: + parser_objects, generated_files = SConscript(['cssparser/SConscript'], exports='env') + objects.append(parser_objects) +else: + generated_files = [] -parser_objects, generated_files = SConscript(['cssparser/SConscript'], exports='env') -objects.append(parser_objects) +objects.append(SConscript(['color_names/SConscript'], exports='env')) + +if env['TOOLCHAIN'] == 'msvc': + local_env.Append(LIBS = ['glib-2.0', 'gtk-win32-2.0', 'gobject-2.0', 'gdk-win32-2.0', 'cairo', 'gdk_pixbuf-2.0', 'lua5.2', 'expat2.1', 'pango-1.0', 'pangocairo-1.0', 'intl']) if local_env['BUILD_TARGET'] == 'win32': - local_env.Append(LINKFLAGS = '-mwindows') + if not (env['TOOLCHAIN'] == 'msvc'): + local_env.Append(LINKFLAGS = '-mwindows') + local_env.Append(LIBS=['expat']) + else: + local_env.Append(LINKFLAGS = ['/SUBSYSTEM:WINDOWS', '/ENTRY:mainCRTStartup'], CPPDEFINES = ['XML_STATIC']) objects.append(SConscript(['winres/SConscript'], exports='env')) elif local_env['BUILD_TARGET'] == 'linux2': - local_env.Append(LIBS=['rt']) - -if not env['INTERNAL_EXPAT']: - local_env.Append(LIBS=['expat']) + local_env.Append(LIBS=['rt', 'expat']) executable = local_env.Program( 'gpick', source = [sources, objects]) -if env['INTERNAL_EXPAT']: - Depends(executable, local_env.UseLibrary('expat')) -if env['INTERNAL_LUA']: - Depends(executable, local_env.UseLibrary('lua')) - Return('executable', 'generated_files') diff -Nru gpick-0.2.4/source/Sampler.cpp gpick-0.2.5/source/Sampler.cpp --- gpick-0.2.4/source/Sampler.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Sampler.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -131,7 +131,7 @@ int center_y = y-top; - float max_distance = 1 / sqrt(2 * pow(sampler->oversample, 2)); + float max_distance = 1 / sqrt(2 * pow((double)sampler->oversample, 2)); for (int x=-sampler->oversample; x <= sampler->oversample; ++x){ for (int y=-sampler->oversample; y <= sampler->oversample; ++y){ @@ -143,7 +143,7 @@ float f; if (sampler->oversample){ - f = sampler->falloff_fnc(sqrt(x * x + y * y) * max_distance); + f = sampler->falloff_fnc(sqrt((double)(x * x + y * y)) * max_distance); }else{ f = 1; } diff -Nru gpick-0.2.4/source/Sampler.h gpick-0.2.5/source/Sampler.h --- gpick-0.2.4/source/Sampler.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Sampler.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ScreenReader.cpp gpick-0.2.5/source/ScreenReader.cpp --- gpick-0.2.4/source/ScreenReader.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ScreenReader.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ScreenReader.h gpick-0.2.5/source/ScreenReader.h --- gpick-0.2.4/source/ScreenReader.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/ScreenReader.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/ToolColorNaming.cpp gpick-0.2.5/source/ToolColorNaming.cpp --- gpick-0.2.4/source/ToolColorNaming.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/ToolColorNaming.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ToolColorNaming.h" +#include "Internationalisation.h" +#include +using namespace std; + +const ToolColorNamingOption options[] = { + {TOOL_COLOR_NAMING_EMPTY, "empty", N_("_Empty")}, + {TOOL_COLOR_NAMING_AUTOMATIC_NAME, "automatic_name", N_("_Automatic name")}, + {TOOL_COLOR_NAMING_TOOL_SPECIFIC, "tool_specific", N_("_Tool specific")}, + {TOOL_COLOR_NAMING_UNKNOWN, 0, 0}, +}; + +const ToolColorNamingOption* tool_color_naming_get_options(){ + return options; +} + +ToolColorNamingType tool_color_naming_name_to_type(const char *name){ + string n = name; + int i = 0; + while (options[i].name){ + if (n.compare(options[i].name) == 0){ + return options[i].type; + } + i++; + } + return TOOL_COLOR_NAMING_UNKNOWN; +} + +ToolColorNameAssigner::ToolColorNameAssigner(GlobalState *gs):m_gs(gs){ + m_color_naming_type = tool_color_naming_name_to_type(dynv_get_string_wd(m_gs->params, "gpick.color_names.tool_color_naming", "tool_specific")); + if (m_color_naming_type == TOOL_COLOR_NAMING_AUTOMATIC_NAME){ + m_imprecision_postfix = dynv_get_bool_wd(m_gs->params, "gpick.color_names.imprecision_postfix", true); + }else{ + m_imprecision_postfix = false; + } +} + +ToolColorNameAssigner::~ToolColorNameAssigner(){ +} + +void ToolColorNameAssigner::assign(struct ColorObject *color_object, Color *color){ + string name; + switch (m_color_naming_type){ + case TOOL_COLOR_NAMING_UNKNOWN: + case TOOL_COLOR_NAMING_EMPTY: + dynv_set_string(color_object->params, "name", ""); + break; + case TOOL_COLOR_NAMING_AUTOMATIC_NAME: + name = color_names_get(m_gs->color_names, color, m_imprecision_postfix); + dynv_set_string(color_object->params, "name", name.c_str()); + break; + case TOOL_COLOR_NAMING_TOOL_SPECIFIC: + name = getToolSpecificName(color_object, color); + dynv_set_string(color_object->params, "name", name.c_str()); + break; + } +} + +std::string ToolColorNameAssigner::getToolSpecificName(struct ColorObject *color_object, Color *color){ + return string(""); +} + diff -Nru gpick-0.2.4/source/ToolColorNaming.h gpick-0.2.5/source/ToolColorNaming.h --- gpick-0.2.4/source/ToolColorNaming.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/ToolColorNaming.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TOOL_COLOR_NAMING_H_ +#define TOOL_COLOR_NAMING_H_ + +#include "GlobalStateStruct.h" +#include "DynvHelpers.h" + +enum ToolColorNamingType { + TOOL_COLOR_NAMING_UNKNOWN = 0, + TOOL_COLOR_NAMING_EMPTY, + TOOL_COLOR_NAMING_AUTOMATIC_NAME, + TOOL_COLOR_NAMING_TOOL_SPECIFIC, +}; + +typedef struct ToolColorNamingOption{ + ToolColorNamingType type; + const char *name; + const char *label; +}ToolColorNamingOption; + +const ToolColorNamingOption* tool_color_naming_get_options(); +ToolColorNamingType tool_color_naming_name_to_type(const char *name); + +class ToolColorNameAssigner{ + protected: + ToolColorNamingType m_color_naming_type; + GlobalState* m_gs; + bool m_imprecision_postfix; + public: + ToolColorNameAssigner(GlobalState *gs); + virtual ~ToolColorNameAssigner(); + + void assign(struct ColorObject *color_object, Color *color); + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color); +}; + +#endif /* TOOL_COLOR_NAMING_H_ */ + diff -Nru gpick-0.2.4/source/Variations.cpp gpick-0.2.5/source/Variations.cpp --- gpick-0.2.4/source/Variations.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Variations.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,6 +20,7 @@ #include "DragDrop.h" #include "GlobalStateStruct.h" +#include "ToolColorNaming.h" #include "uiUtilities.h" #include "ColorList.h" #include "MathUtil.h" @@ -31,10 +32,12 @@ #include "CopyPaste.h" #include "Converter.h" #include "DynvHelpers.h" +#include "Internationalisation.h" #include "uiApp.h" #include +#include #include #include @@ -50,6 +53,7 @@ #define COMPONENT_ID_HSL_LIGHTNESS 3 #define COMPONENT_ID_LAB_LIGHTNESS 4 + typedef struct VariationType{ const char *name; const char *symbol; @@ -59,10 +63,10 @@ }VariationType; const VariationType variation_types[] = { - {"Hue", "HHSL", "hsl_hue", COMPONENT_ID_HSL_HUE, 1}, - {"Saturation", "SHSL", "hsl_saturation", COMPONENT_ID_HSL_SATURATION, 1}, - {"Lightness", "LHSL", "hsl_lightness", COMPONENT_ID_HSL_LIGHTNESS, 1}, - {"Lightness (Lab)", "LLab", "lab_lightness", COMPONENT_ID_LAB_LIGHTNESS, 1}, + {N_("Hue"), "HHSL", "hsl_hue", COMPONENT_ID_HSL_HUE, 1}, + {N_("Saturation"), "SHSL", "hsl_saturation", COMPONENT_ID_HSL_SATURATION, 1}, + {N_("Lightness"), "LHSL", "hsl_lightness", COMPONENT_ID_HSL_LIGHTNESS, 1}, + {N_("Lightness (Lab)"), "LLab", "lab_lightness", COMPONENT_ID_LAB_LIGHTNESS, 1}, }; typedef struct VariationsArgs{ @@ -76,7 +80,7 @@ GtkWidget *color_previews; GtkWidget *all_colors; - struct{ + struct{ GtkWidget *color; GtkWidget *var_colors[VAR_COLOR_WIDGETS + 1]; const VariationType *type; @@ -88,6 +92,32 @@ GlobalState* gs; }VariationsArgs; +class VariationsColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + const char *m_ident; + public: + VariationsColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + } + + void assign(struct ColorObject *color_object, Color *color, const char *ident){ + m_ident = ident; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << color_names_get(m_gs->color_names, color, false) << " " << _("variations") << " " << m_ident; + return m_stream.str(); + } +}; + +static boost::format format_ignore_arg_errors(const std::string &f_string) { + boost::format fmter(f_string); + fmter.exceptions(boost::io::all_error_bits ^ (boost::io::too_many_args_bit | boost::io::too_few_args_bit)); + return fmter; +} + static int set_rgb_color(VariationsArgs *args, struct ColorObject* color, uint32_t color_index); static int set_rgb_color_by_widget(VariationsArgs *args, struct ColorObject* color, GtkWidget* color_widget); @@ -101,10 +131,6 @@ } Color color, hsl, lab, r, hsl_mod, lab_mod; - matrix3x3 adaptation_matrix, working_space_matrix, working_space_matrix_inverted; - vector3 d50, d65; - vector3_set(&d50, 96.442, 100.000, 82.821); - vector3_set(&d65, 95.047, 100.000, 108.883); for (int i = 0; i < MAX_COLOR_LINES; ++i){ gtk_color_get_color(GTK_COLOR(args->color[i].color), &color); @@ -117,10 +143,7 @@ break; case COMPONENT_ID_LAB_LIGHTNESS: { - color_get_chromatic_adaptation_matrix(&d50, &d65, &adaptation_matrix); - color_get_working_space_matrix(0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, &d65, &working_space_matrix); - matrix3x3_inverse(&working_space_matrix, &working_space_matrix_inverted); - color_rgb_to_lab(&color, &lab, &d50, &working_space_matrix); + color_rgb_to_lab_d50(&color, &lab); } break; } @@ -147,7 +170,7 @@ case COMPONENT_ID_LAB_LIGHTNESS: color_copy(&lab, &lab_mod); lab_mod.lab.L = clamp_float(lab.lab.L + (args->color[i].type->strength_mult * strength * (j - VAR_COLOR_WIDGETS / 2)) / 4.0, 0, 100); - color_lab_to_rgb(&lab_mod, &r, &d50, &working_space_matrix_inverted); + color_lab_to_rgb_d50(&lab_mod, &r); color_rgb_normalize(&r); break; } @@ -196,37 +219,62 @@ color_object_release(color_object); } +static string identify_color_widget(GtkWidget *widget, VariationsArgs *args) +{ + if (args->all_colors == widget){ + return _("all colors"); + }else for (int i = 0; i < MAX_COLOR_LINES; ++i){ + if (args->color[i].color == widget){ + try{ + return (format_ignore_arg_errors(_("primary %d")) % (i + 1)).str(); + }catch(const boost::io::format_error &e){ + return (format_ignore_arg_errors("primary %d") % (i + 1)).str(); + } + } + for (int j = 0; j <= VAR_COLOR_WIDGETS; ++j){ + if (args->color[i].var_colors[j] == widget){ + if (j > VAR_COLOR_WIDGETS / 2) + j--; + try{ + return (format_ignore_arg_errors(_("result %d line %d")) % (j + 1) % (i + 1)).str(); + }catch(const boost::io::format_error &e){ + return (format_ignore_arg_errors("result %d line %d") % (j + 1) % (i + 1)).str(); + } + } + } + } + return "unknown"; +} -static void on_color_add_to_palette(GtkWidget *widget, gpointer item) { - VariationsArgs* args=(VariationsArgs*)item; +static void add_color_to_palette(GtkWidget *color_widget, VariationsColorNameAssigner &name_assigner, VariationsArgs *args) +{ Color c; - - gtk_color_get_color(GTK_COLOR(g_object_get_data(G_OBJECT(widget), "color_widget")), &c); - - struct ColorObject *color_object=color_list_new_color_object(args->gs->colors, &c); - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); + struct ColorObject *color_object; + string widget_ident; + gtk_color_get_color(GTK_COLOR(color_widget), &c); + color_object = color_list_new_color_object(args->gs->colors, &c); + widget_ident = identify_color_widget(color_widget, args); + name_assigner.assign(color_object, &c, widget_ident.c_str()); color_list_add_color_object(args->gs->colors, color_object, 1); color_object_release(color_object); } +static void on_color_add_to_palette(GtkWidget *widget, gpointer item) { + VariationsArgs* args = (VariationsArgs*)item; + GtkWidget *color_widget = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "color_widget")); + VariationsColorNameAssigner name_assigner(args->gs); + add_color_to_palette(color_widget, name_assigner, args); +} + static void on_color_add_all_to_palette(GtkWidget *widget, gpointer item) { - VariationsArgs* args=(VariationsArgs*)item; - Color c; + VariationsArgs* args = (VariationsArgs*)item; + VariationsColorNameAssigner name_assigner(args->gs); for (int i = 0; i < MAX_COLOR_LINES; ++i){ for (int j = 0; j < VAR_COLOR_WIDGETS + 1; ++j){ - - gtk_color_get_color(GTK_COLOR(args->color[i].var_colors[j]), &c); - - struct ColorObject *color_object = color_list_new_color_object(args->gs->colors, &c); - string name=color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); - color_list_add_color_object(args->gs->colors, color_object, 1); - color_object_release(color_object); + add_color_to_palette(args->color[i].var_colors[j], name_assigner, args); } } - } static gboolean color_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, VariationsArgs *args){ @@ -280,19 +328,19 @@ menu = gtk_menu_new (); - item = gtk_menu_item_new_with_image ("_Add to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("_Add to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_add_to_palette), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); - item = gtk_menu_item_new_with_image ("_Add all to palette", gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("A_dd all to palette"), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_add_all_to_palette), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_mnemonic ("_Copy to clipboard"); + item = gtk_menu_item_new_with_mnemonic(_("_Copy to clipboard")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); Color c; @@ -319,7 +367,7 @@ if (!all_colors){ GSList *group = 0; for (uint32_t i = 0; i < sizeof(variation_types) / sizeof(VariationType); i++){ - item = gtk_radio_menu_item_new_with_label(group, variation_types[i].name); + item = gtk_radio_menu_item_new_with_label(group, _(variation_types[i].name)); group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item)); if (args->color[line_id].type == &variation_types[i]){ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), true); @@ -332,12 +380,12 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); } - item = gtk_menu_item_new_with_image ("_Edit...", gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Edit..."), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_edit), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); - item = gtk_menu_item_new_with_image ("_Paste", gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Paste"), gtk_image_new_from_stock(GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_color_paste), args); g_object_set_data(G_OBJECT(item), "color_widget", widget); @@ -430,7 +478,7 @@ char tmp[32]; for (gint i = 0; i < MAX_COLOR_LINES; ++i){ sprintf(tmp, "type%d", i); - dynv_set_string(args->params, tmp, args->color[i].type->unique_name); + dynv_set_string(args->params, tmp, args->color[i].type->unique_name); sprintf(tmp, "color%d", i); gtk_color_get_color(GTK_COLOR(args->color[i].color), &c); @@ -448,16 +496,18 @@ } static int source_get_color(VariationsArgs *args, ColorObject** color){ + VariationsColorNameAssigner name_assigner(args->gs); Color c; + string widget_ident; if (args->last_focused_color){ gtk_color_get_color(GTK_COLOR(args->last_focused_color), &c); + widget_ident = identify_color_widget(args->last_focused_color, args); }else{ gtk_color_get_color(GTK_COLOR(args->color[0].color), &c); + widget_ident = identify_color_widget(args->color[0].color, args); } *color = color_list_new_color_object(args->gs->colors, &c); - - string name = color_names_get(args->gs->color_names, &c, dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string((*color)->params, "name", name.c_str()); + name_assigner.assign(*color, &c, widget_ident.c_str()); return 0; } @@ -478,7 +528,7 @@ static int set_rgb_color(VariationsArgs *args, struct ColorObject* color, uint32_t color_index){ Color c; color_object_get_color(color, &c); - if (color_index == -1){ + if (color_index == (uint32_t)-1){ gtk_color_set_color(GTK_COLOR(args->all_colors), &c, ""); for (int i = 0; i < MAX_COLOR_LINES; ++i){ gtk_color_set_color(GTK_COLOR(args->color[i].color), &c, args->color[i].type->symbol); @@ -500,6 +550,17 @@ } static int source_activate(VariationsArgs *args){ + + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + gtk_color_set_transformation_chain(GTK_COLOR(args->all_colors), chain); + + for (int i = 0; i < MAX_COLOR_LINES; ++i){ + gtk_color_set_transformation_chain(GTK_COLOR(args->color[i].color), chain); + for (int j = 0; j < VAR_COLOR_WIDGETS + 1; ++j){ + gtk_color_set_transformation_chain(GTK_COLOR(args->color[i].var_colors[j]), chain); + } + } + gtk_statusbar_push(GTK_STATUSBAR(args->statusbar), gtk_statusbar_get_context_id(GTK_STATUSBAR(args->statusbar), "empty"), ""); return 0; } @@ -582,8 +643,8 @@ dragdrop_widget_attach(widget, DragDropFlags(DRAGDROP_SOURCE | DRAGDROP_DESTINATION), &dd); - for (int i = 0; i < MAX_COLOR_LINES; ++i){ - for (int j = 0; j < VAR_COLOR_WIDGETS + 1; ++j){ + for (intptr_t i = 0; i < MAX_COLOR_LINES; ++i){ + for (intptr_t j = 0; j < VAR_COLOR_WIDGETS + 1; ++j){ widget = gtk_color_new(); gtk_color_set_rounded(GTK_COLOR(widget), true); @@ -653,7 +714,7 @@ gtk_box_pack_start(GTK_BOX(hbox2), table, true, true, 0); table_y = 0; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Strength:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,0,0); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Strength:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,0,0); args->strength = gtk_hscale_new_with_range(1, 100, 1); gtk_range_set_value(GTK_RANGE(args->strength), dynv_get_float_wd(args->params, "strength", 30)); g_signal_connect(G_OBJECT(args->strength), "value-changed", G_CALLBACK (update), args); @@ -680,10 +741,11 @@ } int variations_source_register(ColorSourceManager *csm){ - ColorSource *color_source = new ColorSource; - color_source_init(color_source, "variations", "Variations"); + ColorSource *color_source = new ColorSource; + color_source_init(color_source, "variations", _("Variations")); color_source->implement = (ColorSource* (*)(ColorSource *source, GlobalState *gs, struct dynvSystem *dynv_namespace))source_implement; - color_source_manager_add_source(csm, color_source); + color_source->default_accelerator = GDK_v; + color_source_manager_add_source(csm, color_source); return 0; } diff -Nru gpick-0.2.4/source/Variations.h gpick-0.2.5/source/Variations.h --- gpick-0.2.4/source/Variations.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Variations.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/Vector2.h gpick-0.2.5/source/Vector2.h --- gpick-0.2.4/source/Vector2.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/Vector2.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -19,6 +19,8 @@ #ifndef VECTOR2_H_ #define VECTOR2_H_ +#include + namespace math{ /** \class Vec2 @@ -68,6 +70,16 @@ return r; }; + friend bool operator!= (const Vec2& lhs, const Vec2& rhs){ + if (lhs.x != rhs.x) return false; + if (lhs.y != rhs.y) return false; + return true; + }; + + static T distance(const Vec2&a, const Vec2& b){ + return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); + }; + T x; T y; }; diff -Nru gpick-0.2.4/source/color_names/ColorNames.cpp gpick-0.2.5/source/color_names/ColorNames.cpp --- gpick-0.2.4/source/color_names/ColorNames.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/color_names/ColorNames.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ColorNames.h" +#include "../MathUtil.h" + +#include +#include +#include +#include +#include +using namespace std; + +//CIE94 color difference calculation +float color_names_distance_lch(const Color* a, const Color* b) +{ + Color al, bl; + color_lab_to_lch(a, &al); + color_lab_to_lch(b, &bl); + return sqrt( + pow((bl.lch.L - al.lch.L) / 1, 2) + + pow((bl.lch.C - al.lch.C) / (1 + 0.045 * al.lch.C), 2) + + pow((pow(a->lab.a - b->lab.a, 2) + pow(a->lab.b - b->lab.b, 2) - (bl.lch.C - al.lch.C)) / (1 + 0.015 * al.lch.C), 2)); +} + +ColorNames* color_names_new() +{ + ColorNames* cnames = new ColorNames; + cnames->color_space_convert = color_rgb_to_lab_d50; + cnames->color_space_distance = color_names_distance_lch; + return cnames; +} + + +static void color_names_strip_spaces(string& string_x, string& stripchars){ + if(string_x.empty()) return; + if (stripchars.empty()) return; + + size_t startIndex = string_x.find_first_not_of(stripchars); + size_t endIndex = string_x.find_last_not_of(stripchars); + + if ((startIndex==string::npos)||(endIndex==string::npos)){ + string_x.erase(); + return; + } + string_x = string_x.substr(startIndex, (endIndex-startIndex)+1 ); +} + +void color_names_get_color_xyz(ColorNames* cnames, Color* c, int* x1, int* y1, int* z1, int* x2, int* y2, int* z2) +{ + *x1=clamp_int(int(c->xyz.x*8-0.5),0,7); + *y1=clamp_int(int(c->xyz.y*8-0.5),0,7); + *z1=clamp_int(int(c->xyz.z*8-0.5),0,7); + + *x2=clamp_int(int(c->xyz.x*8+0.5),0,7); + *y2=clamp_int(int(c->xyz.y*8+0.5),0,7); + *z2=clamp_int(int(c->xyz.z*8+0.5),0,7); +} + +list* color_names_get_color_list(ColorNames* cnames, Color* c) +{ + int x,y,z; + x=clamp_int(int(c->xyz.x*8),0,7); + y=clamp_int(int(c->xyz.y*8),0,7); + z=clamp_int(int(c->xyz.z*8),0,7); + + return &cnames->colors[x][y][z]; +} + +int color_names_load_from_file(ColorNames* cnames, const char* filename) +{ + ifstream file(filename, ifstream::in); + + if (file.is_open()) + { + string line; + stringstream rline (ios::in | ios::out); + Color color; + string name; + string strip_chars = " \t,.\n\r"; + + while (!(file.eof())) + { + getline(file, line); + if (line.empty()) continue; + + if (line.at(0)=='!') continue; + + rline.clear(); + rline.str(line); + + + rline>>color.rgb.red>>color.rgb.green>>color.rgb.blue; + getline(rline, name); + + color_names_strip_spaces(name, strip_chars); + + string::iterator i(name.begin()); + + if (i != name.end()) + name[0] = toupper((unsigned char)name[0]); + + while(++i != name.end()){ + *i = tolower((unsigned char)*i); + } + + color_multiply(&color, 1/255.0); + + ColorNameEntry* name_entry = new ColorNameEntry; + name_entry->name=name; + cnames->names.push_back(name_entry); + + ColorEntry* color_entry = new ColorEntry; + color_entry->name=name_entry; + + cnames->color_space_convert(&color, &color_entry->color); + color_names_get_color_list(cnames, &color_entry->color)->push_back(color_entry); + + } + + file.close(); + return 0; + } + return -1; +} + +void color_names_destroy(ColorNames* cnames) +{ + for (list::iterator i=cnames->names.begin();i!=cnames->names.end();++i){ + delete (*i); + } + for (int x=0;x<8;x++){ + for (int y=0;y<8;y++){ + for (int z=0;z<8;z++){ + for (list::iterator i=cnames->colors[x][y][z].begin();i!=cnames->colors[x][y][z].end();++i){ + delete (*i); + } + } + } + } + delete cnames; +} + +string color_names_get(ColorNames* cnames, Color* color, bool imprecision_postfix) +{ + Color c1; + cnames->color_space_convert(color, &c1); + + int x1,y1,z1,x2,y2,z2; + color_names_get_color_xyz(cnames, &c1, &x1, &y1, &z1, &x2, &y2, &z2); + + float result_delta=1e5; + ColorEntry* color_entry=NULL; + + char skip_mask[8][8][8]; + memset(&skip_mask, 0, sizeof(skip_mask)); + + /* Search expansion should be from 0 to 7, but this would only increase search time and return + * wrong color names when no closely matching color is found. Search expansion is only useful + * when color name database is very small (16 colors) + */ + for (int expansion = 0; expansion < 7; ++expansion){ + int x_start = std::max(x1 - expansion, 0), x_end = std::min(x2 + expansion, 7); + int y_start = std::max(y1 - expansion, 0), y_end = std::min(y2 + expansion, 7); + int z_start = std::max(z1 - expansion, 0), z_end = std::min(z2 + expansion, 7); + + for (int x_i = x_start; x_i <= x_end; ++x_i) { + for (int y_i = y_start; y_i <= y_end; ++y_i) { + for (int z_i = z_start; z_i <= z_end; ++z_i) { + if (skip_mask[x_i][y_i][z_i]) continue; // skip checked items + skip_mask[x_i][y_i][z_i] = 1; + + for (list::iterator i=cnames->colors[x_i][y_i][z_i].begin(); i!=cnames->colors[x_i][y_i][z_i].end();++i){ + float delta = cnames->color_space_distance(&(*i)->color, &c1); + //float delta = pow((*i)->color.xyz.x-c1.xyz.x,2) + pow((*i)->color.xyz.y-c1.xyz.y,2) + pow((*i)->color.xyz.z-c1.xyz.z,2); + if (delta < result_delta) + { + result_delta=delta; + color_entry=*i; + } + } + } + } + } + //no need for further expansion if we have found a match + if (color_entry) break; + } + + if (color_entry){ + stringstream s; + s<name->name;//<<" "<0.1) s<<" ~"; + return s.str();//(*result_i)->name; + } + + return string(""); +} + diff -Nru gpick-0.2.4/source/color_names/ColorNames.h gpick-0.2.5/source/color_names/ColorNames.h --- gpick-0.2.4/source/color_names/ColorNames.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/color_names/ColorNames.h 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifndef COLORNAMES_H_ +#define COLORNAMES_H_ + +#include "../Color.h" + +#include +#include + +typedef struct ColorNameEntry{ + std::string name; +}ColorNameEntry; + +typedef struct ColorEntry{ + Color color; + ColorNameEntry* name; +}ColorEntry; + +typedef struct ColorNames{ + std::list names; + std::list colors[8][8][8]; + void (*color_space_convert)(const Color* a, Color* b); + float (*color_space_distance)(const Color* a, const Color* b); +}ColorNames; + +ColorNames* color_names_new(); + +int color_names_load_from_file(ColorNames* cnames, const char* filename); + +void color_names_destroy(ColorNames* cnames); + +std::string color_names_get(ColorNames* cnames, Color* color, bool imprecision_postfix); + +#endif /* COLORNAMES_H_ */ diff -Nru gpick-0.2.4/source/color_names/DownloadNameFile.cpp gpick-0.2.5/source/color_names/DownloadNameFile.cpp --- gpick-0.2.4/source/color_names/DownloadNameFile.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/color_names/DownloadNameFile.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,56 @@ +#include "DownloadNameFile.h" + +#include +#include + +using namespace std; + +#ifdef DOWNLOAD_RESENE_COLOR_LIST + +#include + +static size_t data_write_function(void *ptr, size_t size, size_t nmemb, stringstream *data) +{ + (*data).write(reinterpret_cast(ptr), size * nmemb); + return size * nmemb; +} + +int download_name_file(const char *destination_filename) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if (curl) { + stringstream data; + + curl_easy_setopt(curl, CURLOPT_URL, "http://gpick.googlecode.com/hg/share/gpick/colors.txt"); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, data_write_function); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data); + + res = curl_easy_perform(curl); + if (res != CURLE_OK){ + curl_easy_cleanup(curl); + return -1; + } + + ofstream fout(destination_filename); + if (fout.is_open()){ + string data_str = data.str(); + fout.write(data_str.c_str(), data_str.length()); + fout.close(); + } + + curl_easy_cleanup(curl); + }else return -1; + return 0; +} + +#else + +int download_name_file(const char *destination_filename) +{ + return -1; +} + +#endif diff -Nru gpick-0.2.4/source/color_names/DownloadNameFile.h gpick-0.2.5/source/color_names/DownloadNameFile.h --- gpick-0.2.4/source/color_names/DownloadNameFile.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/color_names/DownloadNameFile.h 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,7 @@ +#ifndef HEADER_DOWNLOAD_NAME_FILE_H_ +#define HEADER_DOWNLOAD_NAME_FILE_H_ + +int download_name_file(const char *destination_filename); + +#endif /* HEADER_ */ + diff -Nru gpick-0.2.4/source/color_names/SConscript gpick-0.2.5/source/color_names/SConscript --- gpick-0.2.4/source/color_names/SConscript 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/color_names/SConscript 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import os +import sys + +Import('*') +local_env = env.Clone() + +if not local_env.GetOption('clean') and not env['TOOLCHAIN'] == 'msvc': + if local_env['DOWNLOAD_RESENE_COLOR_LIST']: + local_env.ParseConfig('pkg-config --cflags --libs $CURL_PC') + +if local_env['DOWNLOAD_RESENE_COLOR_LIST']: + local_env.Append( + CPPDEFINES = ['DOWNLOAD_RESENE_COLOR_LIST'], + ) + +sources = local_env.Glob('*.cpp') +objects = local_env.StaticObject(source = [sources]) +Return('objects') + diff -Nru gpick-0.2.4/source/cssparser/SConscript gpick-0.2.5/source/cssparser/SConscript --- gpick-0.2.4/source/cssparser/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/SConscript 2013-01-01 16:10:52.000000000 +0000 @@ -7,6 +7,7 @@ local_env = env.Clone() local_env.PrependUnique(CPPPATH = ['.']) +local_env.Append(CPPDEFINES = ['YY_NO_UNISTD_H']) if not env['PREBUILD_GRAMMAR']: parser = local_env.Lemon('css_grammar.y') diff -Nru gpick-0.2.4/source/cssparser/css_grammar.c gpick-0.2.5/source/cssparser/css_grammar.c --- gpick-0.2.4/source/cssparser/css_grammar.c 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/css_grammar.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1549 +0,0 @@ -/* Driver template for the LEMON parser generator. -** The author disclaims copyright to this source code. -*/ -/* First off, code is included that follows the "include" declaration -** in the input grammar file. */ -#include -#line 2 "../build/source/cssparser/css_grammar.y" - - -#include -#include "css_lex.h" -#include - -using namespace css_parser; - -#line 17 "../build/source/cssparser/css_grammar.c" -/* Next is all token values, in a form suitable for use by makeheaders. -** This section will be null unless lemon is run with the -m switch. -*/ -/* -** These constants (all generated automatically by the parser generator) -** specify the various kinds of tokens (terminals) that the parser -** understands. -** -** Each symbol here is a terminal symbol in the grammar. -*/ -/* Make sure the INTERFACE macro is defined. -*/ -#ifndef INTERFACE -# define INTERFACE 1 -#endif -/* The next thing included is series of defines which control -** various aspects of the generated parser. -** YYCODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** YYNOCODE is a number of type YYCODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash -** table. -** YYFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** YYACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** css_parseTOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** YYMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is css_parseTOKENTYPE. The entry in the union -** for base tokens is called "yy0". -** YYSTACKDEPTH is the maximum depth of the parser's stack. If -** zero the stack is dynamically sized using realloc() -** css_parseARG_SDECL A static variable declaration for the %extra_argument -** css_parseARG_PDECL A parameter declaration for the %extra_argument -** css_parseARG_STORE Code to store %extra_argument into yypParser -** css_parseARG_FETCH Code to extract %extra_argument from yypParser -** YYNSTATE the combined number of states. -** YYNRULE the number of rules in the grammar -** YYERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ -#define YYCODETYPE unsigned char -#define YYNOCODE 87 -#define YYACTIONTYPE unsigned short int -#define css_parseTOKENTYPE css_yystype -typedef union { - int yyinit; - css_parseTOKENTYPE yy0; - css_ruleset* yy31; - css_simple_selector* yy49; - css_property* yy76; - css_properties* yy80; - css_selectors* yy91; - css_hex* yy104; - css_selector* yy136; - css_function* yy141; - css_base* yy162; - int yy173; -} YYMINORTYPE; -#ifndef YYSTACKDEPTH -#define YYSTACKDEPTH 100 -#endif -#define css_parseARG_SDECL parse_parm_s *parm ; -#define css_parseARG_PDECL , parse_parm_s *parm -#define css_parseARG_FETCH parse_parm_s *parm = yypParser->parm -#define css_parseARG_STORE yypParser->parm = parm -#define YYNSTATE 183 -#define YYNRULE 103 -#define YYERRORSYMBOL 43 -#define YYERRSYMDT yy173 -#define YY_NO_ACTION (YYNSTATE+YYNRULE+2) -#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) -#define YY_ERROR_ACTION (YYNSTATE+YYNRULE) - -/* The yyzerominor constant is used to initialize instances of -** YYMINORTYPE objects to zero. */ -static const YYMINORTYPE yyzerominor = { 0 }; - -/* Define the yytestcase() macro to be a no-op if is not already defined -** otherwise. -** -** Applications can choose to define yytestcase() in the %include section -** to a macro that can assist in verifying code coverage. For production -** code the yytestcase() macro should be turned off. But it is useful -** for testing. -*/ -#ifndef yytestcase -# define yytestcase(X) -#endif - - -/* Next are the tables used to determine what action to take based on the -** current state and lookahead token. These tables are used to implement -** functions that take a state number and lookahead value and return an -** action integer. -** -** Suppose the action integer is N. Then the action is determined as -** follows -** -** 0 <= N < YYNSTATE Shift N. That is, push the lookahead -** token onto the stack and goto state N. -** -** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. -** -** N == YYNSTATE+YYNRULE A syntax error has occurred. -** -** N == YYNSTATE+YYNRULE+1 The parser accepts its input. -** -** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused -** slots in the yy_action[] table. -** -** The action table is constructed as a single large table named yy_action[]. -** Given state S and lookahead X, the action is computed as -** -** yy_action[ yy_shift_ofst[S] + X ] -** -** If the index value yy_shift_ofst[S]+X is out of range or if the value -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. -** -** The formula above is for computing the action when the lookahead is -** a terminal symbol. If the lookahead is a non-terminal (as occurs after -** a reduce action) then the yy_reduce_ofst[] array is used in place of -** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of -** YY_SHIFT_USE_DFLT. -** -** The following are the tables generated in this section: -** -** yy_action[] A single table containing all actions. -** yy_lookahead[] A table containing the lookahead for each entry in -** yy_action. Used to detect hash collisions. -** yy_shift_ofst[] For each state, the offset into yy_action for -** shifting terminals. -** yy_reduce_ofst[] For each state, the offset into yy_action for -** shifting non-terminals after a reduce. -** yy_default[] Default action for each state. -*/ -#define YY_ACTTAB_COUNT (340) -static const YYACTIONTYPE yy_action[] = { - /* 0 */ 38, 180, 178, 182, 181, 23, 12, 13, 139, 140, - /* 10 */ 21, 137, 138, 136, 139, 140, 20, 137, 138, 175, - /* 20 */ 82, 179, 177, 176, 65, 123, 175, 152, 168, 66, - /* 30 */ 175, 63, 258, 59, 175, 258, 149, 175, 158, 99, - /* 40 */ 41, 60, 50, 51, 65, 100, 86, 55, 153, 66, - /* 50 */ 75, 63, 183, 59, 152, 170, 79, 95, 158, 58, - /* 60 */ 166, 60, 61, 64, 159, 175, 99, 139, 140, 19, - /* 70 */ 137, 138, 100, 86, 55, 153, 32, 45, 49, 175, - /* 80 */ 54, 146, 61, 64, 159, 24, 12, 13, 139, 140, - /* 90 */ 21, 137, 138, 136, 164, 12, 13, 139, 140, 21, - /* 100 */ 137, 138, 135, 167, 152, 71, 70, 72, 69, 68, - /* 110 */ 67, 124, 73, 74, 175, 52, 99, 50, 51, 152, - /* 120 */ 6, 169, 100, 86, 55, 153, 175, 65, 118, 175, - /* 130 */ 147, 99, 66, 120, 63, 173, 33, 100, 86, 55, - /* 140 */ 153, 158, 12, 13, 139, 140, 21, 137, 138, 134, - /* 150 */ 12, 13, 139, 140, 21, 137, 138, 133, 143, 144, - /* 160 */ 148, 141, 142, 175, 80, 61, 64, 159, 65, 174, - /* 170 */ 78, 118, 76, 66, 132, 63, 122, 175, 29, 98, - /* 180 */ 163, 30, 158, 3, 118, 77, 126, 123, 161, 122, - /* 190 */ 62, 31, 118, 163, 30, 5, 17, 122, 53, 28, - /* 200 */ 151, 163, 30, 161, 123, 62, 61, 64, 159, 175, - /* 210 */ 80, 118, 172, 93, 7, 156, 122, 62, 27, 150, - /* 220 */ 163, 30, 154, 118, 162, 18, 157, 84, 122, 160, - /* 230 */ 26, 62, 163, 30, 9, 156, 123, 62, 99, 130, - /* 240 */ 18, 157, 84, 123, 100, 86, 55, 56, 132, 48, - /* 250 */ 132, 2, 145, 157, 84, 129, 167, 57, 46, 43, - /* 260 */ 37, 287, 83, 5, 25, 175, 57, 157, 84, 168, - /* 270 */ 57, 128, 34, 157, 84, 87, 44, 132, 127, 125, - /* 280 */ 39, 121, 119, 11, 117, 40, 116, 115, 114, 113, - /* 290 */ 112, 111, 165, 110, 109, 108, 107, 106, 105, 104, - /* 300 */ 10, 103, 102, 155, 57, 101, 288, 4, 92, 91, - /* 310 */ 85, 90, 97, 96, 22, 36, 16, 15, 42, 35, - /* 320 */ 14, 94, 89, 288, 88, 288, 288, 288, 288, 1, - /* 330 */ 288, 288, 171, 288, 288, 131, 8, 47, 288, 81, -}; -static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 50, 1, 52, 3, 4, 55, 56, 57, 58, 59, - /* 10 */ 60, 61, 62, 63, 58, 59, 60, 61, 62, 1, - /* 20 */ 70, 71, 72, 73, 2, 43, 1, 2, 1, 7, - /* 30 */ 1, 9, 10, 11, 1, 13, 18, 1, 16, 14, - /* 40 */ 7, 19, 15, 16, 2, 20, 21, 22, 23, 7, - /* 50 */ 28, 9, 0, 11, 2, 10, 11, 21, 16, 17, - /* 60 */ 78, 19, 40, 41, 42, 1, 14, 58, 59, 60, - /* 70 */ 61, 62, 20, 21, 22, 23, 24, 25, 26, 1, - /* 80 */ 2, 17, 40, 41, 42, 55, 56, 57, 58, 59, - /* 90 */ 60, 61, 62, 63, 13, 56, 57, 58, 59, 60, - /* 100 */ 61, 62, 63, 1, 2, 31, 32, 33, 34, 35, - /* 110 */ 36, 43, 38, 39, 1, 2, 14, 15, 16, 2, - /* 120 */ 81, 10, 20, 21, 22, 23, 1, 2, 44, 1, - /* 130 */ 17, 14, 7, 49, 9, 7, 68, 20, 21, 22, - /* 140 */ 23, 16, 56, 57, 58, 59, 60, 61, 62, 63, - /* 150 */ 56, 57, 58, 59, 60, 61, 62, 63, 58, 59, - /* 160 */ 2, 61, 62, 1, 2, 40, 41, 42, 2, 41, - /* 170 */ 10, 44, 21, 7, 12, 9, 49, 1, 51, 21, - /* 180 */ 53, 54, 16, 69, 44, 10, 10, 43, 46, 49, - /* 190 */ 48, 51, 44, 53, 54, 81, 69, 49, 40, 51, - /* 200 */ 2, 53, 54, 46, 43, 48, 40, 41, 42, 1, - /* 210 */ 2, 44, 74, 75, 45, 46, 49, 48, 51, 2, - /* 220 */ 53, 54, 78, 44, 82, 83, 84, 85, 49, 46, - /* 230 */ 51, 48, 53, 54, 45, 46, 43, 48, 14, 78, - /* 240 */ 83, 84, 85, 43, 20, 21, 22, 11, 12, 11, - /* 250 */ 12, 69, 2, 84, 85, 74, 1, 2, 77, 2, - /* 260 */ 79, 64, 65, 81, 68, 1, 2, 84, 85, 1, - /* 270 */ 2, 78, 66, 84, 85, 66, 77, 12, 78, 68, - /* 280 */ 68, 68, 68, 68, 68, 80, 68, 68, 68, 68, - /* 290 */ 68, 68, 13, 68, 68, 68, 68, 68, 68, 68, - /* 300 */ 68, 68, 68, 68, 2, 68, 86, 68, 68, 68, - /* 310 */ 68, 68, 68, 68, 68, 68, 68, 68, 27, 68, - /* 320 */ 68, 68, 68, 86, 68, 86, 86, 86, 86, 67, - /* 330 */ 86, 86, 74, 86, 86, 74, 77, 77, 86, 76, -}; -#define YY_SHIFT_USE_DFLT (-1) -#define YY_SHIFT_COUNT (125) -#define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (302) -static const short yy_shift_ofst[] = { - /* 0 */ 291, 52, 102, 102, 25, 117, 117, 22, 268, 42, - /* 10 */ 125, 125, 224, 224, 264, 264, 264, 255, 166, 224, - /* 20 */ 224, 224, 162, 27, 27, 208, 279, 279, 279, 279, - /* 30 */ 302, 279, -1, 128, 0, 36, 208, 238, 236, 208, - /* 40 */ 265, -1, -1, -1, -1, -1, -1, -1, -1, -1, - /* 50 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - /* 60 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - /* 70 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - /* 80 */ -1, -1, -1, -1, 74, 113, 158, 0, 176, 33, - /* 90 */ 64, 18, 78, 45, 29, 257, 29, 29, 250, 217, - /* 100 */ 198, 29, 29, 29, 29, 29, 29, 29, 29, 29, - /* 110 */ 29, 29, 29, 29, 29, 29, 29, 29, 151, 29, - /* 120 */ 175, 29, 160, 81, 111, 29, -}; -#define YY_REDUCE_USE_DFLT (-51) -#define YY_REDUCE_COUNT (83) -#define YY_REDUCE_MIN (-50) -#define YY_REDUCE_MAX (263) -static const short yy_reduce_ofst[] = { - /* 0 */ 197, -50, 39, 39, 30, 94, 86, 142, 127, 157, - /* 10 */ 189, 169, 9, -44, 179, 167, 148, 140, 183, 100, - /* 20 */ 100, 100, 181, 182, 114, 138, 200, 193, 161, 144, - /* 30 */ 84, -18, 68, 263, 262, 205, 261, 260, 259, 258, - /* 40 */ 199, 256, 254, 253, 252, 251, 249, 248, 247, 246, - /* 50 */ 245, 244, 243, 242, 241, 240, 239, 237, 235, 234, - /* 60 */ 233, 232, 231, 230, 229, 228, 227, 226, 225, 223, - /* 70 */ 222, 221, 220, 219, 218, 216, 215, 214, 213, 212, - /* 80 */ 211, 196, 209, 206, -}; -static const YYACTIONTYPE yy_default[] = { - /* 0 */ 192, 286, 246, 248, 286, 286, 286, 265, 217, 265, - /* 10 */ 265, 265, 238, 236, 217, 217, 217, 217, 265, 239, - /* 20 */ 237, 240, 286, 245, 247, 201, 286, 286, 286, 286, - /* 30 */ 255, 286, 184, 286, 194, 215, 286, 286, 286, 286, - /* 40 */ 286, 184, 184, 184, 184, 184, 184, 184, 184, 184, - /* 50 */ 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, - /* 60 */ 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, - /* 70 */ 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, - /* 80 */ 184, 184, 188, 188, 286, 286, 286, 195, 286, 286, - /* 90 */ 286, 286, 286, 286, 216, 286, 250, 249, 286, 286, - /* 100 */ 286, 257, 268, 267, 281, 280, 279, 278, 277, 276, - /* 110 */ 275, 274, 273, 272, 271, 270, 269, 259, 286, 252, - /* 120 */ 254, 251, 253, 286, 286, 200, 193, 214, 213, 211, - /* 130 */ 212, 210, 283, 242, 244, 243, 241, 235, 234, 233, - /* 140 */ 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, - /* 150 */ 222, 221, 220, 219, 208, 282, 260, 266, 264, 263, - /* 160 */ 262, 261, 256, 218, 285, 284, 209, 187, 186, 207, - /* 170 */ 206, 203, 202, 205, 204, 185, 199, 198, 197, 196, - /* 180 */ 191, 190, 189, -}; - -/* The next table maps tokens into fallback tokens. If a construct -** like the following: -** -** %fallback ID X Y Z. -** -** appears in the grammar, then ID becomes a fallback token for X, Y, -** and Z. Whenever one of the tokens X, Y, or Z is input to the parser -** but it does not parse, the type of the token is changed to ID and -** the parse is retried before an error is thrown. -*/ -#ifdef YYFALLBACK -static const YYCODETYPE yyFallback[] = { -}; -#endif /* YYFALLBACK */ - -/* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ -struct yyStackEntry { - YYACTIONTYPE stateno; /* The state-number */ - YYCODETYPE major; /* The major token value. This is the code - ** number for the token at this stack level */ - YYMINORTYPE minor; /* The user-supplied minor token value. This - ** is the value of the token */ -}; -typedef struct yyStackEntry yyStackEntry; - -/* The state of the parser is completely contained in an instance of -** the following structure */ -struct yyParser { - int yyidx; /* Index of top element in stack */ -#ifdef YYTRACKMAXSTACKDEPTH - int yyidxMax; /* Maximum value of yyidx */ -#endif - int yyerrcnt; /* Shifts left before out of the error */ - css_parseARG_SDECL /* A place to hold %extra_argument */ -#if YYSTACKDEPTH<=0 - int yystksz; /* Current side of the stack */ - yyStackEntry *yystack; /* The parser's stack */ -#else - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ -#endif -}; -typedef struct yyParser yyParser; - -#ifndef NDEBUG -#include -static FILE *yyTraceFILE = 0; -static char *yyTracePrompt = 0; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* -** Turn parser tracing on by giving a stream to which to write the trace -** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL -** -** Inputs: -**

    -**
  • A FILE* to which trace output should be written. -** If NULL, then tracing is turned off. -**
  • A prefix string written at the beginning of every -** line of trace output. If NULL, then tracing is -** turned off. -**
-** -** Outputs: -** None. -*/ -void css_parseTrace(FILE *TraceFILE, char *zTracePrompt){ - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if( yyTraceFILE==0 ) yyTracePrompt = 0; - else if( yyTracePrompt==0 ) yyTraceFILE = 0; -} -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ -static const char *const yyTokenName[] = { - "$", "S", "IDENT", "CDO", - "CDC", "INCLUDES", "DASHMATCH", "STRING", - "INVALID", "HEXCOLOR", "SEMICOLON", "COMMA", - "LBRACE", "RBRACE", "HASH", "GREATER", - "PLUS", "CLPARENTH", "RBRACK", "SLASH", - "DOT", "COLON", "LBRACK", "ASTERISK", - "IMPORT_SYM", "PAGE_SYM", "MEDIA_SYM", "CHARSET_SYM", - "IMPORTANT_SYM", "FONTFACE_SYM", "NAMESPACE_SYM", "EMS", - "EXS", "LENGTH", "ANGLE", "TIME", - "FREQ", "DIMENSION", "PERCENTAGE", "NUMBER", - "FUNCTION", "URI", "MINUS", "error", - "property", "expr", "term", "hexcolor", - "function", "declaration", "selectors", "maybe_declarations", - "ruleset", "declarations", "declaration_list", "selector", - "universal_selector", "type_selector", "class_selector", "id_selector", - "simple_selectors", "pseudo_selector", "attribute_selector", "simple_selector", - "stylesheet", "maybe_charset", "maybe_sgml", "maybe_rules", - "maybe_space", "space", "rule", "import", - "media", "page", "medium", "maybe_medium", - "uri_or_string", "block_start", "block_end", "media_list", - "maybe_pseudo_page", "combinator", "maybe_prio", "operator", - "unary_operator", "maybe_unary_operator", -}; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing reduce actions, the names of all rules are required. -*/ -static const char *const yyRuleName[] = { - /* 0 */ "stylesheet ::= maybe_charset maybe_sgml maybe_rules", - /* 1 */ "maybe_space ::=", - /* 2 */ "maybe_space ::= maybe_space S", - /* 3 */ "space ::= S", - /* 4 */ "space ::= space S", - /* 5 */ "maybe_sgml ::=", - /* 6 */ "maybe_sgml ::= maybe_sgml CDO", - /* 7 */ "maybe_sgml ::= maybe_sgml CDC", - /* 8 */ "maybe_sgml ::= maybe_sgml S", - /* 9 */ "maybe_charset ::=", - /* 10 */ "maybe_charset ::= CHARSET_SYM maybe_space STRING maybe_space SEMICOLON", - /* 11 */ "maybe_rules ::=", - /* 12 */ "maybe_rules ::= maybe_rules rule maybe_sgml", - /* 13 */ "rule ::= import", - /* 14 */ "rule ::= ruleset", - /* 15 */ "rule ::= media", - /* 16 */ "rule ::= page", - /* 17 */ "medium ::= IDENT maybe_space", - /* 18 */ "maybe_medium ::=", - /* 19 */ "maybe_medium ::= medium", - /* 20 */ "maybe_medium ::= maybe_medium COMMA maybe_space medium", - /* 21 */ "uri_or_string ::= URI", - /* 22 */ "uri_or_string ::= STRING", - /* 23 */ "import ::= IMPORT_SYM maybe_space uri_or_string maybe_space maybe_medium SEMICOLON", - /* 24 */ "import ::= IMPORT_SYM error SEMICOLON", - /* 25 */ "ruleset ::= selectors block_start maybe_declarations block_end", - /* 26 */ "ruleset ::= selectors block_start space maybe_declarations block_end", - /* 27 */ "media_list ::= media_list COMMA maybe_space medium", - /* 28 */ "media_list ::= medium", - /* 29 */ "media ::= MEDIA_SYM maybe_space media_list block_start maybe_space maybe_declarations block_end", - /* 30 */ "media ::= MEDIA_SYM maybe_space block_start maybe_space maybe_declarations block_end", - /* 31 */ "page ::= PAGE_SYM maybe_space maybe_pseudo_page block_start maybe_space maybe_declarations block_end", - /* 32 */ "maybe_pseudo_page ::=", - /* 33 */ "maybe_pseudo_page ::= COLON IDENT maybe_space", - /* 34 */ "maybe_declarations ::=", - /* 35 */ "maybe_declarations ::= declarations", - /* 36 */ "universal_selector ::= ASTERISK", - /* 37 */ "type_selector ::= IDENT", - /* 38 */ "class_selector ::= DOT IDENT", - /* 39 */ "id_selector ::= HASH IDENT", - /* 40 */ "attribute_selector ::= LBRACK maybe_space IDENT maybe_space RBRACK", - /* 41 */ "pseudo_selector ::= COLON IDENT", - /* 42 */ "pseudo_selector ::= COLON FUNCTION maybe_space CLPARENTH", - /* 43 */ "pseudo_selector ::= COLON FUNCTION maybe_space IDENT maybe_space CLPARENTH", - /* 44 */ "pseudo_selector ::= COLON COLON IDENT", - /* 45 */ "simple_selectors ::= simple_selectors id_selector", - /* 46 */ "simple_selectors ::= simple_selectors class_selector", - /* 47 */ "simple_selectors ::= simple_selectors attribute_selector", - /* 48 */ "simple_selectors ::= simple_selectors pseudo_selector", - /* 49 */ "simple_selectors ::= id_selector", - /* 50 */ "simple_selectors ::= class_selector", - /* 51 */ "simple_selectors ::= attribute_selector", - /* 52 */ "simple_selectors ::= pseudo_selector", - /* 53 */ "simple_selector ::= type_selector", - /* 54 */ "simple_selector ::= type_selector simple_selectors", - /* 55 */ "simple_selector ::= universal_selector", - /* 56 */ "simple_selector ::= universal_selector simple_selectors", - /* 57 */ "simple_selector ::= simple_selectors", - /* 58 */ "selector ::= simple_selector", - /* 59 */ "selector ::= selector combinator simple_selector", - /* 60 */ "selector ::= selector space simple_selector", - /* 61 */ "selector ::= selector space combinator simple_selector", - /* 62 */ "selectors ::= selector", - /* 63 */ "selectors ::= selector space", - /* 64 */ "selectors ::= selectors COMMA maybe_space selector", - /* 65 */ "selectors ::= selectors COMMA maybe_space selector space", - /* 66 */ "combinator ::= PLUS maybe_space", - /* 67 */ "combinator ::= GREATER maybe_space", - /* 68 */ "declaration_list ::= declaration SEMICOLON maybe_space", - /* 69 */ "declaration_list ::= declaration_list declaration SEMICOLON maybe_space", - /* 70 */ "declarations ::= declaration", - /* 71 */ "declarations ::= declaration_list declaration", - /* 72 */ "declarations ::= declaration_list", - /* 73 */ "declaration ::= property COLON maybe_space expr maybe_prio", - /* 74 */ "property ::= IDENT maybe_space", - /* 75 */ "maybe_prio ::=", - /* 76 */ "maybe_prio ::= IMPORTANT_SYM maybe_space", - /* 77 */ "expr ::= term", - /* 78 */ "expr ::= expr term", - /* 79 */ "expr ::= expr operator term", - /* 80 */ "unary_operator ::= MINUS", - /* 81 */ "unary_operator ::= PLUS", - /* 82 */ "maybe_unary_operator ::=", - /* 83 */ "maybe_unary_operator ::= unary_operator", - /* 84 */ "operator ::= SLASH maybe_space", - /* 85 */ "operator ::= COMMA maybe_space", - /* 86 */ "term ::= maybe_unary_operator NUMBER maybe_space", - /* 87 */ "term ::= maybe_unary_operator PERCENTAGE maybe_space", - /* 88 */ "term ::= maybe_unary_operator LENGTH maybe_space", - /* 89 */ "term ::= maybe_unary_operator EMS maybe_space", - /* 90 */ "term ::= maybe_unary_operator EXS maybe_space", - /* 91 */ "term ::= maybe_unary_operator ANGLE maybe_space", - /* 92 */ "term ::= maybe_unary_operator TIME maybe_space", - /* 93 */ "term ::= maybe_unary_operator FREQ maybe_space", - /* 94 */ "term ::= STRING maybe_space", - /* 95 */ "term ::= IDENT maybe_space", - /* 96 */ "term ::= URI maybe_space", - /* 97 */ "term ::= HEXCOLOR maybe_space", - /* 98 */ "term ::= function maybe_space", - /* 99 */ "function ::= FUNCTION maybe_space expr CLPARENTH maybe_space", - /* 100 */ "block_start ::= LBRACE", - /* 101 */ "block_end ::= RBRACE", - /* 102 */ "block_end ::= error RBRACE", -}; -#endif /* NDEBUG */ - - -#if YYSTACKDEPTH<=0 -/* -** Try to increase the size of the parser stack. -*/ -static void yyGrowStack(yyParser *p){ - int newSize; - yyStackEntry *pNew; - - newSize = p->yystksz*2 + 100; - pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); - if( pNew ){ - p->yystack = pNew; - p->yystksz = newSize; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", - yyTracePrompt, p->yystksz); - } -#endif - } -} -#endif - -/* -** This function allocates a new parser. -** The only argument is a pointer to a function which works like -** malloc. -** -** Inputs: -** A pointer to the function used to allocate memory. -** -** Outputs: -** A pointer to a parser. This pointer is used in subsequent calls -** to css_parse and css_parseFree. -*/ -void *css_parseAlloc(void *(*mallocProc)(size_t)){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); - if( pParser ){ - pParser->yyidx = -1; -#ifdef YYTRACKMAXSTACKDEPTH - pParser->yyidxMax = 0; -#endif -#if YYSTACKDEPTH<=0 - pParser->yystack = NULL; - pParser->yystksz = 0; - yyGrowStack(pParser); -#endif - } - return pParser; -} - -/* The following function deletes the value associated with a -** symbol. The symbol can be either a terminal or nonterminal. -** "yymajor" is the symbol code, and "yypminor" is a pointer to -** the value. -*/ -static void yy_destructor( - yyParser *yypParser, /* The parser */ - YYCODETYPE yymajor, /* Type code for object to destroy */ - YYMINORTYPE *yypminor /* The object to be destroyed */ -){ - css_parseARG_FETCH; - switch( yymajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - default: break; /* If no destructor action specified: do nothing */ - } -} - -/* -** Pop the parser's stack once. -** -** If there is a destructor routine associated with the token which -** is popped from the stack, then call it. -** -** Return the major token number for the symbol popped. -*/ -static int yy_pop_parser_stack(yyParser *pParser){ - YYCODETYPE yymajor; - yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; - - if( pParser->yyidx<0 ) return 0; -#ifndef NDEBUG - if( yyTraceFILE && pParser->yyidx>=0 ){ - fprintf(yyTraceFILE,"%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos->major]); - } -#endif - yymajor = yytos->major; - yy_destructor(pParser, yymajor, &yytos->minor); - pParser->yyidx--; - return yymajor; -} - -/* -** Deallocate and destroy a parser. Destructors are all called for -** all stack elements before shutting the parser down. -** -** Inputs: -**
    -**
  • A pointer to the parser. This should be a pointer -** obtained from css_parseAlloc. -**
  • A pointer to a function used to reclaim memory obtained -** from malloc. -**
-*/ -void css_parseFree( - void *p, /* The parser to be deleted */ - void (*freeProc)(void*) /* Function used to reclaim memory */ -){ - yyParser *pParser = (yyParser*)p; - if( pParser==0 ) return; - while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); -#if YYSTACKDEPTH<=0 - free(pParser->yystack); -#endif - (*freeProc)((void*)pParser); -} - -/* -** Return the peak depth of the stack for a parser. -*/ -#ifdef YYTRACKMAXSTACKDEPTH -int css_parseStackPeak(void *p){ - yyParser *pParser = (yyParser*)p; - return pParser->yyidxMax; -} -#endif - -/* -** Find the appropriate action for a parser given the terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_shift_action( - yyParser *pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - if( stateno>YY_SHIFT_COUNT - || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ - return yy_default[stateno]; - } - assert( iLookAhead!=YYNOCODE ); - i += iLookAhead; - if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ - if( iLookAhead>0 ){ -#ifdef YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } -#endif - return yy_find_shift_action(pParser, iFallback); - } -#endif -#ifdef YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if( -#if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && -#endif -#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); - } -#endif /* NDEBUG */ - return yy_action[j]; - } - } -#endif /* YYWILDCARD */ - } - return yy_default[stateno]; - }else{ - return yy_action[i]; - } -} - -/* -** Find the appropriate action for a parser given the non-terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_reduce_action( - int stateno, /* Current state number */ - YYCODETYPE iLookAhead /* The look-ahead token */ -){ - int i; -#ifdef YYERRORSYMBOL - if( stateno>YY_REDUCE_COUNT ){ - return yy_default[stateno]; - } -#else - assert( stateno<=YY_REDUCE_COUNT ); -#endif - i = yy_reduce_ofst[stateno]; - assert( i!=YY_REDUCE_USE_DFLT ); - assert( iLookAhead!=YYNOCODE ); - i += iLookAhead; -#ifdef YYERRORSYMBOL - if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ - return yy_default[stateno]; - } -#else - assert( i>=0 && iyyidx--; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - css_parseARG_STORE; /* Suppress warning about unused %extra_argument var */ -} - -/* -** Perform a shift action. -*/ -static void yy_shift( - yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ -){ - yyStackEntry *yytos; - yypParser->yyidx++; -#ifdef YYTRACKMAXSTACKDEPTH - if( yypParser->yyidx>yypParser->yyidxMax ){ - yypParser->yyidxMax = yypParser->yyidx; - } -#endif -#if YYSTACKDEPTH>0 - if( yypParser->yyidx>=YYSTACKDEPTH ){ - yyStackOverflow(yypParser, yypMinor); - return; - } -#else - if( yypParser->yyidx>=yypParser->yystksz ){ - yyGrowStack(yypParser); - if( yypParser->yyidx>=yypParser->yystksz ){ - yyStackOverflow(yypParser, yypMinor); - return; - } - } -#endif - yytos = &yypParser->yystack[yypParser->yyidx]; - yytos->stateno = (YYACTIONTYPE)yyNewState; - yytos->major = (YYCODETYPE)yyMajor; - yytos->minor = *yypMinor; -#ifndef NDEBUG - if( yyTraceFILE && yypParser->yyidx>0 ){ - int i; - fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); - fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); - for(i=1; i<=yypParser->yyidx; i++) - fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); - fprintf(yyTraceFILE,"\n"); - } -#endif -} - -/* The following table contains information about every rule that -** is used during the reduce. -*/ -static const struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ -} yyRuleInfo[] = { - { 64, 3 }, - { 68, 0 }, - { 68, 2 }, - { 69, 1 }, - { 69, 2 }, - { 66, 0 }, - { 66, 2 }, - { 66, 2 }, - { 66, 2 }, - { 65, 0 }, - { 65, 5 }, - { 67, 0 }, - { 67, 3 }, - { 70, 1 }, - { 70, 1 }, - { 70, 1 }, - { 70, 1 }, - { 74, 2 }, - { 75, 0 }, - { 75, 1 }, - { 75, 4 }, - { 76, 1 }, - { 76, 1 }, - { 71, 6 }, - { 71, 3 }, - { 52, 4 }, - { 52, 5 }, - { 79, 4 }, - { 79, 1 }, - { 72, 7 }, - { 72, 6 }, - { 73, 7 }, - { 80, 0 }, - { 80, 3 }, - { 51, 0 }, - { 51, 1 }, - { 56, 1 }, - { 57, 1 }, - { 58, 2 }, - { 59, 2 }, - { 62, 5 }, - { 61, 2 }, - { 61, 4 }, - { 61, 6 }, - { 61, 3 }, - { 60, 2 }, - { 60, 2 }, - { 60, 2 }, - { 60, 2 }, - { 60, 1 }, - { 60, 1 }, - { 60, 1 }, - { 60, 1 }, - { 63, 1 }, - { 63, 2 }, - { 63, 1 }, - { 63, 2 }, - { 63, 1 }, - { 55, 1 }, - { 55, 3 }, - { 55, 3 }, - { 55, 4 }, - { 50, 1 }, - { 50, 2 }, - { 50, 4 }, - { 50, 5 }, - { 81, 2 }, - { 81, 2 }, - { 54, 3 }, - { 54, 4 }, - { 53, 1 }, - { 53, 2 }, - { 53, 1 }, - { 49, 5 }, - { 44, 2 }, - { 82, 0 }, - { 82, 2 }, - { 45, 1 }, - { 45, 2 }, - { 45, 3 }, - { 84, 1 }, - { 84, 1 }, - { 85, 0 }, - { 85, 1 }, - { 83, 2 }, - { 83, 2 }, - { 46, 3 }, - { 46, 3 }, - { 46, 3 }, - { 46, 3 }, - { 46, 3 }, - { 46, 3 }, - { 46, 3 }, - { 46, 3 }, - { 46, 2 }, - { 46, 2 }, - { 46, 2 }, - { 46, 2 }, - { 46, 2 }, - { 48, 5 }, - { 77, 1 }, - { 78, 1 }, - { 78, 2 }, -}; - -static void yy_accept(yyParser*); /* Forward Declaration */ - -/* -** Perform a reduce action and the shift that must immediately -** follow the reduce. -*/ -static void yy_reduce( - yyParser *yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ -){ - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yyStackEntry *yymsp; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - css_parseARG_FETCH; - yymsp = &yypParser->yystack[yypParser->yyidx]; -#ifndef NDEBUG - if( yyTraceFILE && yyruleno>=0 - && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno]); - } -#endif /* NDEBUG */ - - /* Silence complaints from purify about yygotominor being uninitialized - ** in some cases when it is copied into the stack after the following - ** switch. yygotominor is uninitialized when a rule reduces that does - ** not set the value of its left-hand side nonterminal. Leaving the - ** value of the nonterminal uninitialized is utterly harmless as long - ** as the value is never used. So really the only thing this code - ** accomplishes is to quieten purify. - ** - ** 2007-01-16: The wireshark project (www.wireshark.org) reports that - ** without this code, their parser segfaults. I'm not sure what there - ** parser is doing to make this happen. This is the second bug report - ** from wireshark this week. Clearly they are stressing Lemon in ways - ** that it has not been previously stressed... (SQLite ticket #2172) - */ - /*memset(&yygotominor, 0, sizeof(yygotominor));*/ - yygotominor = yyzerominor; - - - switch( yyruleno ){ - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** #line - ** { ... } // User supplied code - ** #line - ** break; - */ - case 25: /* ruleset ::= selectors block_start maybe_declarations block_end */ -#line 113 "../build/source/cssparser/css_grammar.y" -{ - css_ruleset *ruleset = new(parm) css_ruleset(); - ruleset->setSelectors(yymsp[-3].minor.yy91->selectors_); - if (yymsp[-1].minor.yy80) ruleset->addProperties(yymsp[-1].minor.yy80); - yygotominor.yy31 = ruleset; - - parm->page->addRuleset(ruleset); -} -#line 995 "../build/source/cssparser/css_grammar.c" - break; - case 26: /* ruleset ::= selectors block_start space maybe_declarations block_end */ -#line 122 "../build/source/cssparser/css_grammar.y" -{ - css_ruleset *ruleset = new(parm) css_ruleset(); - ruleset->setSelectors(yymsp[-4].minor.yy91->selectors_); - if (yymsp[-1].minor.yy80) ruleset->addProperties(yymsp[-1].minor.yy80); - yygotominor.yy31 = ruleset; - - parm->page->addRuleset(ruleset); -} -#line 1007 "../build/source/cssparser/css_grammar.c" - break; - case 34: /* maybe_declarations ::= */ -#line 142 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy80 = 0; } -#line 1012 "../build/source/cssparser/css_grammar.c" - break; - case 35: /* maybe_declarations ::= declarations */ -#line 143 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy80 = yymsp[0].minor.yy80; } -#line 1017 "../build/source/cssparser/css_grammar.c" - break; - case 36: /* universal_selector ::= ASTERISK */ - case 37: /* type_selector ::= IDENT */ yytestcase(yyruleno==37); - case 38: /* class_selector ::= DOT IDENT */ yytestcase(yyruleno==38); - case 39: /* id_selector ::= HASH IDENT */ yytestcase(yyruleno==39); - case 41: /* pseudo_selector ::= COLON IDENT */ yytestcase(yyruleno==41); - case 44: /* pseudo_selector ::= COLON COLON IDENT */ yytestcase(yyruleno==44); -#line 145 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy49 = new(parm) css_simple_selector(yymsp[0].minor.yy0.string); } -#line 1027 "../build/source/cssparser/css_grammar.c" - break; - case 40: /* attribute_selector ::= LBRACK maybe_space IDENT maybe_space RBRACK */ -#line 150 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy49 = new(parm) css_simple_selector(yymsp[-2].minor.yy0.string); } -#line 1032 "../build/source/cssparser/css_grammar.c" - break; - case 45: /* simple_selectors ::= simple_selectors id_selector */ - case 46: /* simple_selectors ::= simple_selectors class_selector */ yytestcase(yyruleno==46); - case 47: /* simple_selectors ::= simple_selectors attribute_selector */ yytestcase(yyruleno==47); - case 48: /* simple_selectors ::= simple_selectors pseudo_selector */ yytestcase(yyruleno==48); -#line 157 "../build/source/cssparser/css_grammar.y" -{ yymsp[-1].minor.yy136->addSimpleSelector(yymsp[0].minor.yy49); yygotominor.yy136 = yymsp[-1].minor.yy136; } -#line 1040 "../build/source/cssparser/css_grammar.c" - break; - case 49: /* simple_selectors ::= id_selector */ - case 50: /* simple_selectors ::= class_selector */ yytestcase(yyruleno==50); - case 51: /* simple_selectors ::= attribute_selector */ yytestcase(yyruleno==51); - case 52: /* simple_selectors ::= pseudo_selector */ yytestcase(yyruleno==52); - case 53: /* simple_selector ::= type_selector */ yytestcase(yyruleno==53); - case 55: /* simple_selector ::= universal_selector */ yytestcase(yyruleno==55); -#line 161 "../build/source/cssparser/css_grammar.y" -{ - css_selector* selector = new(parm) css_selector(); - selector->addSimpleSelector(yymsp[0].minor.yy49); - yygotominor.yy136 = selector; -} -#line 1054 "../build/source/cssparser/css_grammar.c" - break; - case 54: /* simple_selector ::= type_selector simple_selectors */ - case 56: /* simple_selector ::= universal_selector simple_selectors */ yytestcase(yyruleno==56); -#line 187 "../build/source/cssparser/css_grammar.y" -{ - yymsp[0].minor.yy136->prependSimpleSelector(yymsp[-1].minor.yy49); - yygotominor.yy136 = yymsp[0].minor.yy136; -} -#line 1063 "../build/source/cssparser/css_grammar.c" - break; - case 57: /* simple_selector ::= simple_selectors */ -#line 200 "../build/source/cssparser/css_grammar.y" -{ - yygotominor.yy136 = yymsp[0].minor.yy136; -} -#line 1070 "../build/source/cssparser/css_grammar.c" - break; - case 58: /* selector ::= simple_selector */ -#line 205 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy136 = yymsp[0].minor.yy136; } -#line 1075 "../build/source/cssparser/css_grammar.c" - break; - case 59: /* selector ::= selector combinator simple_selector */ -#line 206 "../build/source/cssparser/css_grammar.y" -{ - yymsp[-2].minor.yy136->addSelector(yymsp[0].minor.yy136); - yygotominor.yy136 = yymsp[-2].minor.yy136; -} -#line 1083 "../build/source/cssparser/css_grammar.c" - break; - case 60: /* selector ::= selector space simple_selector */ -#line 210 "../build/source/cssparser/css_grammar.y" -{ - yymsp[-2].minor.yy136->addSelector(yymsp[0].minor.yy136); - yygotominor.yy136 = yymsp[-2].minor.yy136; -} -#line 1091 "../build/source/cssparser/css_grammar.c" - break; - case 61: /* selector ::= selector space combinator simple_selector */ -#line 214 "../build/source/cssparser/css_grammar.y" -{ - yymsp[-3].minor.yy136->addSelector(yymsp[0].minor.yy136); - yygotominor.yy136 = yymsp[-3].minor.yy136; -} -#line 1099 "../build/source/cssparser/css_grammar.c" - break; - case 62: /* selectors ::= selector */ -#line 219 "../build/source/cssparser/css_grammar.y" -{ - css_selectors* selectors = new(parm) css_selectors(); - selectors->addSelector(yymsp[0].minor.yy136); - yygotominor.yy91 = selectors; -} -#line 1108 "../build/source/cssparser/css_grammar.c" - break; - case 63: /* selectors ::= selector space */ -#line 225 "../build/source/cssparser/css_grammar.y" -{ - css_selectors* selectors = new(parm) css_selectors(); - selectors->addSelector(yymsp[-1].minor.yy136); - yygotominor.yy91 = selectors; -} -#line 1117 "../build/source/cssparser/css_grammar.c" - break; - case 64: /* selectors ::= selectors COMMA maybe_space selector */ -#line 231 "../build/source/cssparser/css_grammar.y" -{ - yymsp[-3].minor.yy91->addSelector(yymsp[0].minor.yy136); - yygotominor.yy91 = yymsp[-3].minor.yy91; -} -#line 1125 "../build/source/cssparser/css_grammar.c" - break; - case 65: /* selectors ::= selectors COMMA maybe_space selector space */ -#line 236 "../build/source/cssparser/css_grammar.y" -{ - yymsp[-4].minor.yy91->addSelector(yymsp[-1].minor.yy136); - yygotominor.yy91 = yymsp[-4].minor.yy91; -} -#line 1133 "../build/source/cssparser/css_grammar.c" - break; - case 68: /* declaration_list ::= declaration SEMICOLON maybe_space */ -#line 245 "../build/source/cssparser/css_grammar.y" -{ - css_properties* properties = new(parm) css_properties(); - if (yymsp[-2].minor.yy76) properties->addProperty(yymsp[-2].minor.yy76); - yygotominor.yy80 = properties; -} -#line 1142 "../build/source/cssparser/css_grammar.c" - break; - case 69: /* declaration_list ::= declaration_list declaration SEMICOLON maybe_space */ -#line 250 "../build/source/cssparser/css_grammar.y" -{ - if (yymsp[-2].minor.yy76) yymsp[-3].minor.yy80->addProperty(yymsp[-2].minor.yy76); - yygotominor.yy80 = yymsp[-3].minor.yy80; -} -#line 1150 "../build/source/cssparser/css_grammar.c" - break; - case 70: /* declarations ::= declaration */ -#line 255 "../build/source/cssparser/css_grammar.y" -{ - css_properties* properties = new(parm) css_properties(); - if (yymsp[0].minor.yy76) properties->addProperty(yymsp[0].minor.yy76); - yygotominor.yy80 = properties; -} -#line 1159 "../build/source/cssparser/css_grammar.c" - break; - case 71: /* declarations ::= declaration_list declaration */ -#line 260 "../build/source/cssparser/css_grammar.y" -{ - if (yymsp[0].minor.yy76) yymsp[-1].minor.yy80->addProperty(yymsp[0].minor.yy76); - yygotominor.yy80 = yymsp[-1].minor.yy80; -} -#line 1167 "../build/source/cssparser/css_grammar.c" - break; - case 72: /* declarations ::= declaration_list */ -#line 264 "../build/source/cssparser/css_grammar.y" -{ - yygotominor.yy80 = yymsp[0].minor.yy80; -} -#line 1174 "../build/source/cssparser/css_grammar.c" - break; - case 73: /* declaration ::= property COLON maybe_space expr maybe_prio */ -#line 268 "../build/source/cssparser/css_grammar.y" -{ - if (strcmp(yymsp[-4].minor.yy76->name_, "color") == 0 || strcmp(yymsp[-4].minor.yy76->name_, "background-color") == 0){ - yymsp[-4].minor.yy76->addValue(yymsp[-1].minor.yy162); - yygotominor.yy76 = yymsp[-4].minor.yy76; - }else{ - yygotominor.yy76 = 0; - } -} -#line 1186 "../build/source/cssparser/css_grammar.c" - break; - case 74: /* property ::= IDENT maybe_space */ -#line 277 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy76 = new(parm) css_property(yymsp[-1].minor.yy0.string);} -#line 1191 "../build/source/cssparser/css_grammar.c" - break; - case 77: /* expr ::= term */ -#line 283 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy162 = yymsp[0].minor.yy162; } -#line 1196 "../build/source/cssparser/css_grammar.c" - break; - case 78: /* expr ::= expr term */ -#line 284 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy162 = yymsp[-1].minor.yy162; yygotominor.yy162 = yymsp[0].minor.yy162; } -#line 1201 "../build/source/cssparser/css_grammar.c" - break; - case 79: /* expr ::= expr operator term */ -#line 285 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy162 = yymsp[-2].minor.yy162; yygotominor.yy162 = yymsp[0].minor.yy162; } -#line 1206 "../build/source/cssparser/css_grammar.c" - break; - case 86: /* term ::= maybe_unary_operator NUMBER maybe_space */ -#line 296 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy162 = new(parm) css_number(yymsp[-1].minor.yy0.number); } -#line 1211 "../build/source/cssparser/css_grammar.c" - break; - case 87: /* term ::= maybe_unary_operator PERCENTAGE maybe_space */ - case 88: /* term ::= maybe_unary_operator LENGTH maybe_space */ yytestcase(yyruleno==88); - case 89: /* term ::= maybe_unary_operator EMS maybe_space */ yytestcase(yyruleno==89); - case 90: /* term ::= maybe_unary_operator EXS maybe_space */ yytestcase(yyruleno==90); - case 91: /* term ::= maybe_unary_operator ANGLE maybe_space */ yytestcase(yyruleno==91); - case 92: /* term ::= maybe_unary_operator TIME maybe_space */ yytestcase(yyruleno==92); - case 93: /* term ::= maybe_unary_operator FREQ maybe_space */ yytestcase(yyruleno==93); - case 96: /* term ::= URI maybe_space */ yytestcase(yyruleno==96); -#line 297 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy162 = 0; } -#line 1223 "../build/source/cssparser/css_grammar.c" - break; - case 94: /* term ::= STRING maybe_space */ - case 95: /* term ::= IDENT maybe_space */ yytestcase(yyruleno==95); -#line 304 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy162 = new(parm) css_string(yymsp[-1].minor.yy0.string); } -#line 1229 "../build/source/cssparser/css_grammar.c" - break; - case 97: /* term ::= HEXCOLOR maybe_space */ -#line 307 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy162 = new(parm) css_hex(yymsp[-1].minor.yy0.string); } -#line 1234 "../build/source/cssparser/css_grammar.c" - break; - case 98: /* term ::= function maybe_space */ -#line 308 "../build/source/cssparser/css_grammar.y" -{ yygotominor.yy162 = yymsp[-1].minor.yy141; } -#line 1239 "../build/source/cssparser/css_grammar.c" - break; - case 99: /* function ::= FUNCTION maybe_space expr CLPARENTH maybe_space */ -#line 311 "../build/source/cssparser/css_grammar.y" -{ - css_function* function = new(parm) css_function(yymsp[-4].minor.yy0.string); - function->addArgument(yymsp[-2].minor.yy162); - yygotominor.yy141 = function; -} -#line 1248 "../build/source/cssparser/css_grammar.c" - break; - default: - /* (0) stylesheet ::= maybe_charset maybe_sgml maybe_rules */ yytestcase(yyruleno==0); - /* (1) maybe_space ::= */ yytestcase(yyruleno==1); - /* (2) maybe_space ::= maybe_space S */ yytestcase(yyruleno==2); - /* (3) space ::= S */ yytestcase(yyruleno==3); - /* (4) space ::= space S */ yytestcase(yyruleno==4); - /* (5) maybe_sgml ::= */ yytestcase(yyruleno==5); - /* (6) maybe_sgml ::= maybe_sgml CDO */ yytestcase(yyruleno==6); - /* (7) maybe_sgml ::= maybe_sgml CDC */ yytestcase(yyruleno==7); - /* (8) maybe_sgml ::= maybe_sgml S */ yytestcase(yyruleno==8); - /* (9) maybe_charset ::= */ yytestcase(yyruleno==9); - /* (10) maybe_charset ::= CHARSET_SYM maybe_space STRING maybe_space SEMICOLON */ yytestcase(yyruleno==10); - /* (11) maybe_rules ::= */ yytestcase(yyruleno==11); - /* (12) maybe_rules ::= maybe_rules rule maybe_sgml */ yytestcase(yyruleno==12); - /* (13) rule ::= import */ yytestcase(yyruleno==13); - /* (14) rule ::= ruleset */ yytestcase(yyruleno==14); - /* (15) rule ::= media */ yytestcase(yyruleno==15); - /* (16) rule ::= page */ yytestcase(yyruleno==16); - /* (17) medium ::= IDENT maybe_space */ yytestcase(yyruleno==17); - /* (18) maybe_medium ::= */ yytestcase(yyruleno==18); - /* (19) maybe_medium ::= medium */ yytestcase(yyruleno==19); - /* (20) maybe_medium ::= maybe_medium COMMA maybe_space medium */ yytestcase(yyruleno==20); - /* (21) uri_or_string ::= URI */ yytestcase(yyruleno==21); - /* (22) uri_or_string ::= STRING */ yytestcase(yyruleno==22); - /* (23) import ::= IMPORT_SYM maybe_space uri_or_string maybe_space maybe_medium SEMICOLON */ yytestcase(yyruleno==23); - /* (24) import ::= IMPORT_SYM error SEMICOLON */ yytestcase(yyruleno==24); - /* (27) media_list ::= media_list COMMA maybe_space medium */ yytestcase(yyruleno==27); - /* (28) media_list ::= medium */ yytestcase(yyruleno==28); - /* (29) media ::= MEDIA_SYM maybe_space media_list block_start maybe_space maybe_declarations block_end */ yytestcase(yyruleno==29); - /* (30) media ::= MEDIA_SYM maybe_space block_start maybe_space maybe_declarations block_end */ yytestcase(yyruleno==30); - /* (31) page ::= PAGE_SYM maybe_space maybe_pseudo_page block_start maybe_space maybe_declarations block_end */ yytestcase(yyruleno==31); - /* (32) maybe_pseudo_page ::= */ yytestcase(yyruleno==32); - /* (33) maybe_pseudo_page ::= COLON IDENT maybe_space */ yytestcase(yyruleno==33); - /* (42) pseudo_selector ::= COLON FUNCTION maybe_space CLPARENTH */ yytestcase(yyruleno==42); - /* (43) pseudo_selector ::= COLON FUNCTION maybe_space IDENT maybe_space CLPARENTH */ yytestcase(yyruleno==43); - /* (66) combinator ::= PLUS maybe_space */ yytestcase(yyruleno==66); - /* (67) combinator ::= GREATER maybe_space */ yytestcase(yyruleno==67); - /* (75) maybe_prio ::= */ yytestcase(yyruleno==75); - /* (76) maybe_prio ::= IMPORTANT_SYM maybe_space */ yytestcase(yyruleno==76); - /* (80) unary_operator ::= MINUS */ yytestcase(yyruleno==80); - /* (81) unary_operator ::= PLUS */ yytestcase(yyruleno==81); - /* (82) maybe_unary_operator ::= */ yytestcase(yyruleno==82); - /* (83) maybe_unary_operator ::= unary_operator */ yytestcase(yyruleno==83); - /* (84) operator ::= SLASH maybe_space */ yytestcase(yyruleno==84); - /* (85) operator ::= COMMA maybe_space */ yytestcase(yyruleno==85); - /* (100) block_start ::= LBRACE */ yytestcase(yyruleno==100); - /* (101) block_end ::= RBRACE */ yytestcase(yyruleno==101); - /* (102) block_end ::= error RBRACE */ yytestcase(yyruleno==102); - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser->yyidx -= yysize; - yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); - if( yyact < YYNSTATE ){ -#ifdef NDEBUG - /* If we are not debugging and the reduce action popped at least - ** one element off the stack, then we can push the new element back - ** onto the stack here, and skip the stack overflow test in yy_shift(). - ** That gives a significant speed improvement. */ - if( yysize ){ - yypParser->yyidx++; - yymsp -= yysize-1; - yymsp->stateno = (YYACTIONTYPE)yyact; - yymsp->major = (YYCODETYPE)yygoto; - yymsp->minor = yygotominor; - }else -#endif - { - yy_shift(yypParser,yyact,yygoto,&yygotominor); - } - }else{ - assert( yyact == YYNSTATE + YYNRULE + 1 ); - yy_accept(yypParser); - } -} - -/* -** The following code executes when the parse fails -*/ -#ifndef YYNOERRORRECOVERY -static void yy_parse_failed( - yyParser *yypParser /* The parser */ -){ - css_parseARG_FETCH; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - css_parseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} -#endif /* YYNOERRORRECOVERY */ - -/* -** The following code executes when a syntax error first occurs. -*/ -static void yy_syntax_error( - yyParser *yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ -){ - css_parseARG_FETCH; -#define TOKEN (yyminor.yy0) -#line 67 "../build/source/cssparser/css_grammar.y" - - printf("Error: %s\n", yyTokenName[yymajor]); -#line 1360 "../build/source/cssparser/css_grammar.c" - css_parseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* -** The following is executed when the parser accepts -*/ -static void yy_accept( - yyParser *yypParser /* The parser */ -){ - css_parseARG_FETCH; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - css_parseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "css_parseAlloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -**
    -**
  • A pointer to the parser (an opaque structure.) -**
  • The major token number. -**
  • The minor token number. -**
  • An option argument of a grammar-specified type. -**
-** -** Outputs: -** None. -*/ -void css_parse( - void *yyp, /* The parser */ - int yymajor, /* The major token code number */ - css_parseTOKENTYPE yyminor /* The value for the token */ - css_parseARG_PDECL /* Optional %extra_argument parameter */ -){ - YYMINORTYPE yyminorunion; - int yyact; /* The parser action. */ - int yyendofinput; /* True if we are at the end of input */ -#ifdef YYERRORSYMBOL - int yyerrorhit = 0; /* True if yymajor has invoked an error */ -#endif - yyParser *yypParser; /* The parser */ - - /* (re)initialize the parser, if necessary */ - yypParser = (yyParser*)yyp; - if( yypParser->yyidx<0 ){ -#if YYSTACKDEPTH<=0 - if( yypParser->yystksz <=0 ){ - /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ - yyminorunion = yyzerominor; - yyStackOverflow(yypParser, &yyminorunion); - return; - } -#endif - yypParser->yyidx = 0; - yypParser->yyerrcnt = -1; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; - } - yyminorunion.yy0 = yyminor; - yyendofinput = (yymajor==0); - css_parseARG_STORE; - -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); - } -#endif - - do{ - yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); - if( yyactyyerrcnt--; - yymajor = YYNOCODE; - }else if( yyact < YYNSTATE + YYNRULE ){ - yy_reduce(yypParser,yyact-YYNSTATE); - }else{ - assert( yyact == YY_ERROR_ACTION ); -#ifdef YYERRORSYMBOL - int yymx; -#endif -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); - } -#endif -#ifdef YYERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( yypParser->yyerrcnt<0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yymx = yypParser->yystack[yypParser->yyidx].major; - if( yymx==YYERRORSYMBOL || yyerrorhit ){ -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sDiscard input token %s\n", - yyTracePrompt,yyTokenName[yymajor]); - } -#endif - yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); - yymajor = YYNOCODE; - }else{ - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_reduce_action( - yypParser->yystack[yypParser->yyidx].stateno, - YYERRORSYMBOL)) >= YYNSTATE - ){ - yy_pop_parser_stack(yypParser); - } - if( yypParser->yyidx < 0 || yymajor==0 ){ - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - yy_parse_failed(yypParser); - yymajor = YYNOCODE; - }else if( yymx!=YYERRORSYMBOL ){ - YYMINORTYPE u2; - u2.YYERRSYMDT = 0; - yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); - } - } - yypParser->yyerrcnt = 3; - yyerrorhit = 1; -#elif defined(YYNOERRORRECOVERY) - /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to - ** do any kind of error recovery. Instead, simply invoke the syntax - ** error routine and continue going as if nothing had happened. - ** - ** Applications can set this macro (for example inside %include) if - ** they intend to abandon the parse upon the first syntax error seen. - */ - yy_syntax_error(yypParser,yymajor,yyminorunion); - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - yymajor = YYNOCODE; - -#else /* YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( yypParser->yyerrcnt<=0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yypParser->yyerrcnt = 3; - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - if( yyendofinput ){ - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; -#endif - } - }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); - return; -} diff -Nru gpick-0.2.4/source/cssparser/css_grammar.h gpick-0.2.5/source/cssparser/css_grammar.h --- gpick-0.2.4/source/cssparser/css_grammar.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/css_grammar.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -#define CSS_TOKEN_S 1 -#define CSS_TOKEN_IDENT 2 -#define CSS_TOKEN_CDO 3 -#define CSS_TOKEN_CDC 4 -#define CSS_TOKEN_INCLUDES 5 -#define CSS_TOKEN_DASHMATCH 6 -#define CSS_TOKEN_STRING 7 -#define CSS_TOKEN_INVALID 8 -#define CSS_TOKEN_HEXCOLOR 9 -#define CSS_TOKEN_SEMICOLON 10 -#define CSS_TOKEN_COMMA 11 -#define CSS_TOKEN_LBRACE 12 -#define CSS_TOKEN_RBRACE 13 -#define CSS_TOKEN_HASH 14 -#define CSS_TOKEN_GREATER 15 -#define CSS_TOKEN_PLUS 16 -#define CSS_TOKEN_CLPARENTH 17 -#define CSS_TOKEN_RBRACK 18 -#define CSS_TOKEN_SLASH 19 -#define CSS_TOKEN_DOT 20 -#define CSS_TOKEN_COLON 21 -#define CSS_TOKEN_LBRACK 22 -#define CSS_TOKEN_ASTERISK 23 -#define CSS_TOKEN_IMPORT_SYM 24 -#define CSS_TOKEN_PAGE_SYM 25 -#define CSS_TOKEN_MEDIA_SYM 26 -#define CSS_TOKEN_CHARSET_SYM 27 -#define CSS_TOKEN_IMPORTANT_SYM 28 -#define CSS_TOKEN_FONTFACE_SYM 29 -#define CSS_TOKEN_NAMESPACE_SYM 30 -#define CSS_TOKEN_EMS 31 -#define CSS_TOKEN_EXS 32 -#define CSS_TOKEN_LENGTH 33 -#define CSS_TOKEN_ANGLE 34 -#define CSS_TOKEN_TIME 35 -#define CSS_TOKEN_FREQ 36 -#define CSS_TOKEN_DIMENSION 37 -#define CSS_TOKEN_PERCENTAGE 38 -#define CSS_TOKEN_NUMBER 39 -#define CSS_TOKEN_FUNCTION 40 -#define CSS_TOKEN_URI 41 -#define CSS_TOKEN_MINUS 42 diff -Nru gpick-0.2.4/source/cssparser/css_grammar_wrap.cpp gpick-0.2.5/source/cssparser/css_grammar_wrap.cpp --- gpick-0.2.4/source/cssparser/css_grammar_wrap.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/css_grammar_wrap.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/cssparser/css_lex.cpp gpick-0.2.5/source/cssparser/css_lex.cpp --- gpick-0.2.4/source/cssparser/css_lex.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/css_lex.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,3981 +0,0 @@ -#line 2 "build/source/cssparser/css_lex.cpp" - -#line 4 "build/source/cssparser/css_lex.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE css_restart(yyin ,yyscanner ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via css_restart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void css_restart (FILE *input_file ,yyscan_t yyscanner ); -void css__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE css__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void css__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void css__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void css_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void css_pop_buffer_state (yyscan_t yyscanner ); - -static void css_ensure_buffer_stack (yyscan_t yyscanner ); -static void css__load_buffer_state (yyscan_t yyscanner ); -static void css__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); - -#define YY_FLUSH_BUFFER css__flush_buffer(YY_CURRENT_BUFFER ,yyscanner) - -YY_BUFFER_STATE css__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE css__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE css__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *css_alloc (yy_size_t ,yyscan_t yyscanner ); -void *css_realloc (void *,yy_size_t ,yyscan_t yyscanner ); -void css_free (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer css__create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - css_ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - css__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - css_ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - css__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define css_wrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 64 -#define YY_END_OF_BUFFER 65 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[1036] = - { 0, - 0, 0, 5, 5, 10, 10, 65, 63, 2, 1, - 1, 1, 63, 17, 52, 17, 61, 51, 49, 58, - 48, 57, 50, 44, 59, 60, 63, 62, 63, 18, - 18, 55, 63, 56, 53, 63, 54, 63, 5, 4, - 4, 6, 10, 9, 9, 12, 2, 1, 1, 1, - 0, 0, 0, 0, 17, 16, 0, 0, 17, 0, - 18, 0, 44, 3, 43, 0, 0, 44, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 39, - 0, 0, 0, 0, 0, 0, 0, 0, 47, 18, - 0, 18, 0, 18, 18, 18, 18, 18, 18, 15, - - 14, 5, 4, 4, 4, 6, 6, 7, 10, 9, - 9, 9, 12, 11, 0, 0, 0, 0, 0, 0, - 0, 17, 17, 17, 0, 17, 17, 17, 0, 42, - 0, 30, 0, 42, 0, 27, 28, 0, 42, 0, - 40, 0, 32, 0, 42, 0, 31, 38, 0, 34, - 33, 29, 0, 42, 0, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 39, - 0, 0, 0, 0, 0, 0, 0, 18, 18, 18, - 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 11, 12, 13, 0, 0, 0, 0, 0, 0, - - 0, 0, 17, 17, 17, 19, 17, 17, 17, 42, - 42, 42, 42, 42, 30, 35, 0, 42, 42, 42, - 42, 42, 42, 42, 42, 27, 28, 42, 0, 42, - 42, 42, 42, 42, 42, 42, 40, 42, 42, 42, - 32, 41, 0, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 31, 38, 42, 42, 42, 42, 42, 33, - 29, 36, 0, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 39, 42, 42, 8, 0, 0, 0, - 0, 0, 0, 18, 18, 47, 18, 18, 18, 18, - - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 11, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 17, 0, 17, 42, 42, 42, - 42, 42, 30, 30, 42, 42, 42, 35, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 27, 28, 27, - 37, 0, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 40, 40, 42, 42, 42, 32, 32, 42, - 42, 42, 41, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 31, 38, 31, 42, 42, 42, 42, 42, - 34, 33, 29, 42, 42, 42, 42, 42, 42, 42, - - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 39, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 34, 42, - 42, 42, 39, 39, 0, 0, 0, 0, 0, 21, - 18, 0, 0, 0, 0, 46, 0, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 17, 0, 17, 42, 42, - 42, 42, 30, 30, 30, 30, 42, 42, 42, 35, - - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 27, 28, 27, 27, 27, 28, 28, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 40, 40, 40, 40, 42, - 42, 42, 32, 32, 32, 32, 42, 42, 42, 41, - 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 31, 38, 31, 31, 31, 38, 38, 42, - 42, 42, 42, 42, 34, 33, 29, 34, 34, 33, - 33, 29, 29, 42, 42, 42, 36, 42, 42, 42, - 42, 42, 42, 36, 42, 42, 42, 42, 42, 42, - - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 39, 42, 42, 42, 34, 42, 36, 0, 0, 0, - 22, 0, 18, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 46, 0, 0, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 17, 19, 17, 42, 42, 42, 42, - 30, 30, 42, 42, 42, 35, 35, 35, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 27, 28, 27, - 42, 42, 42, 37, 42, 42, 42, 42, 42, 42, - - 37, 42, 42, 42, 42, 42, 37, 42, 42, 42, - 40, 40, 42, 42, 42, 32, 32, 42, 42, 42, - 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 31, 38, 31, 42, 42, 42, 42, - 42, 34, 33, 29, 42, 42, 42, 36, 36, 36, - 42, 42, 42, 42, 36, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 39, 42, 42, 42, 34, 42, 36, 0, 0, 20, - 0, 18, 0, 45, 0, 0, 0, 0, 0, 0, - 0, 0, 18, 18, 18, 18, 18, 18, 18, 18, - - 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 17, 17, 42, 42, 42, 30, - 30, 42, 42, 42, 35, 42, 42, 42, 42, 42, - 42, 42, 27, 28, 27, 42, 42, 42, 37, 37, - 37, 42, 42, 42, 42, 42, 42, 42, 42, 37, - 42, 42, 40, 40, 42, 42, 32, 32, 42, 42, - 42, 41, 41, 42, 42, 42, 42, 42, 42, 42, - 31, 38, 31, 42, 42, 42, 42, 34, 33, 29, - 42, 42, 42, 36, 42, 42, 42, 36, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 39, - - 42, 42, 42, 34, 42, 36, 0, 0, 0, 18, - 0, 0, 0, 0, 0, 0, 0, 18, 18, 18, - 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 42, 30, 30, 42, 42, 35, 42, - 27, 28, 27, 42, 42, 42, 37, 42, 42, 42, - 42, 42, 37, 40, 40, 32, 32, 42, 42, 41, - 41, 42, 31, 38, 31, 34, 33, 29, 42, 42, - 36, 42, 36, 24, 0, 0, 0, 0, 0, 18, - 18, 26, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 35, 42, 42, 37, 42, 41, 41, - - 36, 23, 25, 0, 0, 0, 0, 0, 0, 26, - 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, - 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, - 26, 26, 0, 0, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 4, 5, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 6, 7, 8, 9, 10, 11, 10, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 10, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 46, 53, 54, 55, 56, 46, 46, 57, 46, 58, - 59, 60, 61, 10, 46, 10, 62, 63, 64, 65, - - 66, 67, 68, 69, 70, 46, 71, 72, 73, 74, - 75, 76, 46, 77, 78, 79, 80, 46, 46, 81, - 46, 82, 83, 84, 85, 86, 1, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87 - } ; - -static yyconst flex_int32_t yy_meta[88] = - { 0, - 1, 2, 3, 3, 3, 2, 2, 4, 2, 2, - 2, 4, 5, 2, 6, 2, 2, 7, 2, 2, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 2, 2, 2, 2, 9, 2, 10, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 2, 11, - 2, 10, 10, 10, 10, 10, 10, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 2, 2, 2, 2, 11 - } ; - -static yyconst flex_int16_t yy_base[1069] = - { 0, - 0, 0, 85, 88, 91, 94, 4098, 5911, 99, 103, - 110, 113, 117, 94, 0, 92, 5911, 5911, 5911, 5911, - 4030, 103, 4072, 177, 5911, 5911, 4079, 5911, 96, 97, - 98, 5911, 244, 5911, 5911, 4046, 5911, 4041, 0, 139, - 175, 119, 0, 178, 181, 4049, 134, 186, 189, 205, - 273, 4051, 101, 267, 151, 5911, 341, 0, 137, 406, - 152, 453, 328, 5911, 5911, 3999, 363, 0, 3986, 231, - 254, 440, 236, 178, 255, 257, 364, 359, 261, 3966, - 521, 4007, 218, 96, 254, 256, 279, 297, 5911, 312, - 588, 436, 635, 315, 711, 310, 314, 373, 449, 5911, - - 5911, 0, 392, 417, 447, 153, 397, 5911, 0, 450, - 453, 456, 4000, 284, 702, 571, 617, 478, 3967, 3950, - 366, 340, 629, 777, 0, 201, 621, 843, 890, 3915, - 948, 3854, 995, 444, 618, 3832, 3808, 739, 404, 801, - 3782, 865, 3776, 875, 428, 982, 3747, 3712, 1020, 3711, - 3676, 3675, 1045, 581, 979, 3674, 1125, 657, 1057, 702, - 1172, 766, 626, 610, 451, 627, 872, 796, 658, 3654, - 3688, 340, 619, 667, 681, 682, 701, 454, 1236, 696, - 1084, 733, 3682, 3665, 881, 876, 1283, 742, 804, 810, - 1266, 489, 3658, 5911, 735, 1028, 836, 744, 768, 852, - - 874, 990, 365, 919, 1330, 0, 682, 1076, 1377, 3615, - 1443, 930, 794, 822, 3608, 3589, 1182, 1092, 3622, 3621, - 1113, 848, 3611, 891, 3610, 3550, 3541, 1036, 1155, 1095, - 3577, 3559, 1005, 1147, 903, 943, 3520, 1156, 942, 961, - 3513, 3512, 1404, 1190, 3542, 3509, 1017, 1193, 1024, 3511, - 1050, 3494, 3452, 3449, 1226, 3483, 611, 3468, 972, 3417, - 3416, 3415, 1268, 1202, 3452, 3419, 894, 1490, 1258, 1520, - 1306, 1538, 1352, 1360, 1520, 1532, 1568, 1593, 1605, 1620, - 1627, 1704, 1692, 1654, 1719, 1733, 5911, 744, 797, 978, - 1063, 1094, 1103, 978, 1791, 1632, 1205, 1106, 1120, 697, - - 1314, 3414, 3381, 1792, 1844, 1363, 1400, 1429, 1873, 1284, - 1698, 964, 1118, 1749, 1430, 3382, 3367, 1173, 1466, 1840, - 1845, 1467, 1207, 1601, 1930, 0, 1977, 1176, 2024, 1474, - 1250, 1251, 1432, 1680, 1475, 3359, 3348, 3298, 1563, 3319, - 3312, 2024, 1705, 1274, 3308, 1343, 3300, 1742, 1799, 1832, - 3238, 1866, 1591, 3244, 3206, 1433, 3185, 3184, 1925, 1642, - 1390, 1441, 1857, 1932, 1622, 1438, 1534, 1938, 1943, 1729, - 1540, 1557, 3127, 1646, 3136, 3117, 1973, 1892, 1574, 3112, - 1587, 3100, 1978, 2006, 2018, 2047, 3099, 1078, 3070, 1220, - 2032, 2054, 2074, 1744, 3065, 3052, 1759, 3014, 2977, 2091, - - 2136, 2077, 2085, 2109, 2166, 2117, 2207, 2177, 2165, 2249, - 2255, 2267, 2285, 2290, 2367, 2372, 2273, 2381, 2408, 1639, - 1700, 1674, 2182, 2293, 2251, 2379, 1835, 2246, 1416, 2126, - 1749, 2345, 1854, 2348, 2167, 2393, 2394, 2435, 2339, 1729, - 1929, 2457, 2928, 1183, 1168, 2938, 1444, 1640, 1528, 5911, - 2502, 2498, 2543, 938, 1031, 5911, 2603, 2095, 1703, 1922, - 2557, 2569, 2098, 2913, 2910, 2574, 2343, 2417, 2669, 127, - 304, 348, 2652, 2160, 2560, 2128, 1921, 1923, 2164, 2126, - 2587, 2241, 2286, 2328, 438, 2716, 0, 2763, 2810, 2276, - 2042, 2043, 2279, 2531, 2838, 1278, 2322, 2861, 2841, 2592, - - 2434, 2830, 2792, 2810, 2129, 2420, 2593, 2081, 2647, 2165, - 2624, 2646, 2679, 2698, 2540, 1588, 2524, 1612, 2466, 2527, - 2513, 2484, 2485, 2476, 2711, 2331, 2456, 2433, 2757, 2407, - 2550, 2265, 2487, 2182, 2364, 2716, 2721, 2369, 1836, 2529, - 2404, 2453, 2762, 2793, 2361, 2010, 2749, 2459, 2598, 2804, - 2818, 2833, 2373, 2360, 2839, 2541, 2808, 2836, 2596, 2357, - 2599, 2318, 2877, 2882, 2889, 2252, 2068, 2247, 2204, 2875, - 2262, 1514, 2250, 1797, 2902, 2907, 2912, 2187, 2404, 2176, - 2599, 2128, 2862, 2898, 2114, 2102, 2924, 2910, 2096, 2095, - 2936, 2709, 2917, 0, 2981, 1385, 2920, 2938, 3000, 2946, - - 3029, 3047, 3112, 3094, 3106, 3123, 3154, 3172, 3252, 3214, - 2987, 3258, 3266, 3033, 2661, 3184, 2926, 2706, 2706, 1649, - 5911, 1828, 3327, 3065, 1032, 3078, 3392, 1145, 3457, 3139, - 3199, 3232, 3275, 3523, 3590, 2954, 2807, 2904, 3291, 3357, - 3656, 2097, 594, 2046, 2009, 3375, 3722, 1999, 1948, 3440, - 2918, 3384, 3142, 1950, 1941, 3107, 2973, 3639, 3705, 3163, - 3155, 3192, 786, 3788, 5911, 3835, 3882, 937, 2976, 2977, - 3369, 3380, 3169, 1875, 1874, 3396, 1830, 2864, 1147, 1863, - 1815, 3446, 3078, 2997, 1778, 2999, 1749, 3422, 3462, 3467, - 3206, 1747, 1737, 3499, 3278, 1719, 1705, 3735, 3026, 3450, - - 0, 1180, 1667, 1639, 3537, 3248, 0, 1396, 3093, 3163, - 3528, 3552, 1515, 3181, 3207, 3564, 3573, 3293, 3228, 3238, - 3603, 3619, 1560, 3092, 1765, 1558, 1550, 3631, 3315, 3271, - 1527, 3371, 1509, 3661, 3668, 3698, 3381, 1466, 2056, 1465, - 2365, 3727, 3751, 3764, 3303, 1450, 1438, 3774, 1400, 3132, - 1783, 1401, 1368, 3829, 0, 3929, 3948, 1901, 3974, 2963, - 3818, 3877, 3959, 3929, 3835, 4018, 4025, 4039, 4045, 3923, - 3799, 4051, 4059, 3448, 0, 3586, 0, 2300, 3451, 5911, - 3474, 4117, 3882, 5911, 1098, 3976, 4183, 1222, 3927, 4249, - 4068, 4296, 1800, 3520, 3648, 4147, 4159, 1359, 1351, 4196, - - 4164, 4279, 3272, 3822, 3989, 1303, 1293, 3737, 4055, 4291, - 3915, 3257, 4118, 2073, 4297, 4350, 4397, 3650, 3677, 4212, - 4224, 2238, 1268, 1216, 4229, 1190, 1187, 4325, 3733, 1114, - 3741, 1096, 4234, 4260, 4338, 3980, 1089, 1005, 4392, 924, - 3578, 2410, 930, 908, 4405, 897, 896, 4438, 3806, 0, - 3746, 3782, 4397, 4426, 3804, 3849, 4444, 4449, 2492, 3876, - 3879, 4474, 4479, 869, 829, 4484, 3969, 800, 3993, 799, - 4489, 4499, 4504, 734, 2447, 721, 2830, 4509, 4514, 4519, - 2558, 686, 655, 4524, 627, 626, 4529, 0, 4535, 4543, - 4549, 4557, 4568, 4573, 4579, 4596, 4620, 4644, 4655, 4673, - - 4682, 4707, 4716, 4726, 4732, 4741, 629, 3996, 4013, 4760, - 1134, 4088, 4781, 1276, 3978, 4828, 4875, 4040, 4050, 4785, - 4811, 4858, 3227, 4616, 4076, 612, 597, 4097, 4871, 4101, - 4055, 4533, 2652, 4823, 4828, 4876, 478, 470, 4833, 4917, - 4922, 4941, 4946, 2703, 460, 336, 4951, 338, 317, 4959, - 4965, 4970, 4984, 4989, 5009, 5034, 5048, 4069, 4157, 5053, - 5058, 5068, 5073, 5078, 5083, 5093, 5098, 5107, 274, 265, - 5112, 5117, 5142, 5911, 4201, 4340, 5182, 5229, 5276, 5157, - 5166, 5911, 5109, 4283, 4392, 4430, 4290, 4327, 5212, 4446, - 4574, 4679, 2724, 5181, 238, 151, 5187, 5223, 5229, 5271, - - 5276, 5911, 5911, 5323, 5370, 5417, 4592, 142, 139, 5911, - 4328, 5322, 5369, 4583, 4594, 4700, 2906, 5306, 5464, 5511, - 5558, 4668, 5192, 4646, 4572, 4963, 2970, 5411, 5458, 4674, - 5911, 153, 3060, 3412, 5911, 5625, 5636, 5647, 5651, 5661, - 5663, 5670, 5681, 5692, 5703, 5714, 5725, 5736, 5740, 5750, - 5752, 5757, 5768, 5779, 5783, 5793, 5797, 5806, 5810, 5820, - 5831, 5842, 5846, 5856, 5867, 5877, 5888, 5899 - } ; - -static yyconst flex_int16_t yy_def[1069] = - { 0, - 1035, 1, 1036, 1036, 1037, 1037, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1038, 1039, 1040, 1035, 1035, 1035, 1035, - 1041, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1042, - 1042, 1035, 1043, 1035, 1035, 1035, 1035, 1035, 1044, 1035, - 1035, 1045, 1046, 1035, 1035, 1047, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1038, 1035, 1048, 1049, 1040, 1050, - 1042, 1043, 24, 1035, 1035, 1051, 1035, 24, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1042, - 1053, 1042, 1053, 1042, 1042, 95, 95, 95, 1042, 1035, - - 1035, 1044, 1035, 1035, 1035, 1045, 1045, 1035, 1046, 1035, - 1035, 1035, 1047, 1054, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1038, 1038, 1038, 1055, 1040, 1040, 1040, 81, 1052, - 1056, 1052, 1056, 1052, 133, 1052, 1052, 133, 1052, 133, - 1052, 133, 1052, 133, 1052, 133, 1052, 1052, 133, 1052, - 1052, 1052, 133, 1052, 133, 1052, 1052, 157, 157, 157, - 157, 157, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1042, 95, 1042, - 93, 179, 179, 179, 1042, 1042, 95, 187, 187, 187, - 187, 1054, 1047, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - - 1035, 1035, 1038, 1038, 124, 1057, 1040, 1040, 128, 1052, - 157, 211, 211, 211, 1052, 1052, 133, 211, 211, 211, - 211, 211, 211, 211, 211, 1052, 1052, 1052, 133, 211, - 211, 211, 1052, 211, 211, 211, 1052, 211, 211, 211, - 1052, 1052, 133, 211, 211, 211, 1052, 211, 211, 211, - 211, 211, 1052, 1052, 211, 211, 211, 211, 211, 1052, - 1052, 1052, 133, 211, 211, 211, 1052, 157, 268, 268, - 268, 268, 268, 268, 274, 274, 274, 274, 274, 274, - 274, 274, 268, 283, 283, 274, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1042, 179, 1058, 179, 179, 179, 1042, - - 295, 295, 295, 295, 187, 305, 305, 305, 305, 1042, - 1042, 1054, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 124, 1059, 128, 1052, 211, 329, - 329, 329, 329, 329, 211, 211, 211, 1052, 329, 329, - 329, 329, 329, 329, 329, 329, 329, 329, 329, 329, - 1052, 133, 211, 211, 211, 329, 329, 329, 329, 329, - 329, 329, 329, 329, 329, 329, 329, 329, 329, 211, - 211, 211, 1052, 329, 329, 329, 329, 329, 329, 329, - 329, 329, 329, 329, 329, 329, 329, 329, 329, 329, - 329, 329, 329, 211, 211, 211, 329, 329, 329, 329, - - 268, 401, 401, 401, 401, 401, 401, 407, 407, 407, - 407, 407, 407, 407, 407, 401, 416, 416, 407, 1052, - 1052, 1052, 1052, 401, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 401, 1052, - 1052, 401, 1052, 1052, 1035, 1035, 1035, 1035, 1035, 1035, - 295, 1058, 1058, 1060, 1061, 1035, 1062, 295, 295, 295, - 295, 295, 451, 451, 451, 451, 1042, 1042, 451, 469, - 469, 469, 469, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 124, 1063, 128, 329, 489, - 489, 489, 489, 489, 1052, 1052, 329, 329, 329, 329, - - 489, 489, 489, 489, 1052, 1052, 489, 489, 489, 489, - 489, 489, 489, 489, 1052, 1052, 1052, 1052, 211, 211, - 211, 329, 329, 329, 329, 489, 489, 489, 489, 1052, - 1052, 489, 489, 489, 489, 489, 489, 1052, 1052, 489, - 489, 489, 489, 489, 1052, 1052, 329, 329, 329, 329, - 329, 489, 489, 489, 489, 1052, 1052, 489, 489, 489, - 489, 489, 489, 489, 489, 1052, 1052, 1052, 1052, 489, - 489, 489, 489, 489, 489, 489, 489, 1052, 1052, 1052, - 1052, 1052, 1052, 329, 329, 329, 329, 489, 489, 489, - 489, 1052, 1052, 489, 401, 595, 595, 595, 595, 595, - - 595, 595, 595, 595, 595, 595, 595, 603, 603, 595, - 595, 595, 603, 595, 595, 595, 595, 1035, 1035, 1035, - 1035, 1035, 451, 1035, 1060, 1035, 1064, 1061, 1065, 1066, - 1066, 1066, 1066, 1066, 1067, 451, 451, 451, 451, 451, - 451, 641, 623, 623, 623, 623, 623, 647, 647, 647, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1068, 1035, 128, 489, 667, 667, 667, - 667, 667, 489, 489, 489, 489, 1052, 1052, 667, 667, - 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, - 329, 329, 329, 329, 489, 489, 489, 489, 1052, 1052, - - 489, 667, 667, 667, 667, 667, 667, 667, 667, 667, - 667, 667, 667, 667, 667, 667, 667, 489, 489, 489, - 489, 489, 1052, 1052, 667, 667, 667, 667, 667, 667, - 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, - 667, 667, 667, 667, 489, 489, 489, 489, 1052, 1052, - 667, 667, 667, 667, 667, 595, 756, 756, 756, 756, - 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - 756, 756, 756, 756, 756, 756, 756, 1035, 1035, 1035, - 1035, 623, 1035, 1035, 1060, 1060, 1060, 1061, 1061, 1061, - 1066, 634, 623, 623, 623, 623, 623, 782, 782, 782, - - 641, 641, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1068, 128, 667, 817, 817, 817, - 817, 667, 667, 667, 667, 817, 817, 817, 817, 817, - 817, 817, 817, 817, 817, 489, 489, 489, 489, 1052, - 1052, 667, 667, 667, 667, 817, 817, 817, 817, 817, - 817, 817, 817, 817, 817, 817, 817, 817, 667, 667, - 667, 667, 667, 817, 817, 817, 817, 817, 817, 817, - 817, 817, 817, 817, 817, 817, 817, 817, 817, 817, - 667, 667, 667, 667, 817, 817, 817, 817, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - - 1052, 1052, 1052, 1052, 1052, 1052, 1035, 1035, 1035, 641, - 1060, 1060, 787, 1061, 1061, 790, 634, 782, 782, 782, - 782, 641, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1052, 1052, 1052, 817, 817, 817, 1052, - 1052, 1052, 1052, 667, 667, 667, 667, 817, 817, 817, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 817, 817, 817, - 817, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 817, 817, - 817, 1052, 1052, 1035, 1035, 1035, 787, 790, 634, 641, - 641, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1052, 817, 817, 817, 1052, 1052, 1052, - - 1052, 1035, 1035, 787, 790, 634, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1052, 787, 790, - 634, 1035, 1035, 1035, 1035, 1035, 1035, 1060, 1061, 1035, - 1035, 1035, 1035, 1035, 0, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035 - } ; - -static yyconst flex_int16_t yy_nxt[5999] = - { 0, - 8, 9, 10, 11, 12, 9, 13, 14, 15, 8, - 8, 16, 8, 17, 18, 19, 20, 21, 22, 23, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 25, 26, 27, 8, 28, 29, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 31, 30, 30, 32, 33, - 34, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, - 30, 30, 35, 36, 37, 38, 30, 40, 40, 41, - 40, 40, 41, 44, 44, 45, 44, 44, 45, 42, - - 47, 56, 42, 56, 47, 48, 48, 49, 46, 89, - 89, 46, 48, 48, 49, 50, 48, 49, 51, 51, - 51, 51, 51, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 107, 83, 47, 52, 84, 108, 47, - 85, 103, 103, 104, 86, 87, 173, 88, 56, 116, - 92, 60, 647, 57, 647, 1031, 91, 93, 56, 83, - 117, 53, 84, 1023, 89, 85, 1023, 1035, 86, 87, - 173, 88, 1035, 116, 92, 1018, 54, 105, 103, 104, - 110, 110, 111, 112, 110, 111, 53, 65, 48, 48, - 49, 50, 48, 49, 66, 67, 60, 68, 68, 68, - - 68, 68, 68, 68, 68, 68, 68, 48, 48, 49, - 57, 91, 56, 69, 69, 70, 71, 72, 69, 73, - 74, 75, 69, 76, 69, 77, 69, 69, 78, 79, - 80, 69, 69, 69, 69, 141, 81, 142, 69, 69, - 70, 71, 72, 69, 73, 74, 75, 76, 69, 77, - 69, 69, 78, 79, 80, 69, 69, 69, 69, 141, - 60, 172, 1018, 69, 95, 96, 96, 96, 96, 97, - 96, 98, 96, 96, 51, 51, 51, 51, 51, 132, - 96, 96, 96, 96, 96, 96, 172, 118, 139, 1001, - 133, 119, 52, 120, 134, 140, 175, 154, 1001, 99, - - 145, 193, 174, 132, 143, 96, 96, 96, 96, 96, - 96, 121, 139, 135, 144, 176, 146, 53, 194, 134, - 155, 175, 154, 99, 89, 145, 174, 89, 143, 650, - 188, 647, 54, 177, 188, 188, 121, 188, 998, 191, - 176, 188, 53, 55, 55, 123, 1035, 56, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 177, 998, - 997, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 91, 56, 650, 91, 647, 288, 124, 124, 124, - 124, 124, 124, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 188, 103, 103, 104, 150, 191, 57, - - 188, 288, 124, 124, 124, 124, 124, 124, 59, 59, - 127, 107, 147, 151, 116, 152, 1035, 148, 153, 105, - 103, 104, 150, 149, 57, 117, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 147, 151, 116, 152, - 228, 148, 128, 128, 128, 128, 128, 128, 89, 103, - 103, 104, 110, 110, 111, 112, 110, 111, 110, 110, - 111, 89, 119, 229, 120, 228, 89, 128, 128, 128, - 128, 128, 128, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 180, 997, 242, 216, 243, 136, 96, - 96, 96, 96, 96, 96, 181, 137, 994, 201, 138, - - 143, 92, 119, 217, 120, 994, 1035, 180, 93, 242, - 144, 216, 136, 91, 96, 96, 96, 96, 96, 96, - 137, 156, 156, 1035, 143, 92, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 157, 158, 158, 158, 159, 160, 161, 162, 158, - 158, 156, 156, 156, 156, 156, 156, 158, 158, 158, - 158, 158, 158, 163, 164, 165, 156, 166, 156, 167, - 156, 156, 168, 169, 170, 156, 156, 156, 156, 156, - 156, 156, 158, 158, 158, 158, 158, 158, 163, 164, - 165, 166, 156, 167, 156, 156, 168, 169, 170, 156, - - 156, 156, 156, 156, 156, 156, 156, 156, 179, 179, - 179, 179, 179, 179, 179, 179, 179, 179, 989, 798, - 262, 799, 195, 59, 179, 179, 179, 179, 179, 179, - 196, 55, 56, 989, 974, 392, 56, 197, 218, 393, - 263, 198, 219, 199, 220, 262, 195, 972, 972, 179, - 179, 179, 179, 179, 179, 182, 179, 179, 179, 179, - 183, 179, 184, 179, 179, 200, 210, 141, 289, 142, - 145, 179, 179, 179, 179, 179, 179, 269, 139, 971, - 60, 269, 269, 269, 269, 140, 146, 185, 57, 200, - 210, 141, 289, 56, 154, 145, 179, 179, 179, 179, - - 179, 179, 139, 51, 51, 51, 51, 51, 296, 296, - 971, 185, 94, 94, 94, 186, 94, 155, 290, 154, - 291, 52, 282, 89, 283, 284, 269, 269, 269, 269, - 292, 187, 188, 188, 188, 188, 189, 188, 190, 188, - 188, 60, 290, 293, 966, 291, 53, 188, 188, 188, - 188, 188, 188, 301, 292, 91, 91, 966, 302, 221, - 303, 54, 306, 222, 223, 224, 225, 306, 293, 306, - 91, 53, 188, 188, 188, 188, 188, 188, 203, 122, - 122, 204, 203, 320, 56, 313, 282, 226, 283, 284, - 269, 269, 269, 269, 314, 227, 445, 205, 205, 205, - - 205, 205, 205, 205, 205, 205, 205, 321, 320, 313, - 198, 226, 199, 205, 205, 205, 205, 205, 205, 227, - 445, 230, 964, 964, 306, 211, 231, 211, 232, 309, - 306, 306, 321, 333, 150, 309, 57, 306, 205, 205, - 205, 205, 205, 205, 207, 126, 126, 208, 207, 210, - 151, 446, 152, 233, 56, 153, 319, 962, 333, 150, - 198, 334, 199, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 210, 151, 446, 152, 233, 94, 209, - 209, 209, 209, 209, 209, 234, 334, 348, 89, 211, - 235, 211, 236, 89, 322, 238, 156, 962, 119, 239, - - 120, 240, 60, 195, 209, 209, 209, 209, 209, 209, - 158, 196, 348, 210, 158, 158, 158, 158, 951, 951, - 147, 122, 237, 210, 241, 148, 56, 195, 180, 950, - 350, 149, 156, 156, 156, 91, 156, 210, 156, 363, - 181, 156, 156, 156, 147, 626, 237, 210, 241, 148, - 330, 950, 180, 131, 331, 350, 332, 156, 156, 156, - 156, 818, 156, 819, 363, 156, 156, 156, 211, 211, - 211, 211, 211, 211, 211, 211, 211, 211, 57, 364, - 178, 193, 368, 131, 211, 211, 211, 211, 211, 211, - 89, 323, 323, 323, 324, 323, 392, 627, 1035, 264, - - 393, 369, 244, 265, 364, 266, 245, 368, 246, 211, - 211, 211, 211, 211, 211, 212, 211, 211, 211, 213, - 211, 214, 211, 211, 211, 247, 369, 210, 447, 947, - 210, 211, 211, 211, 211, 211, 211, 91, 116, 626, - 248, 228, 626, 215, 249, 250, 251, 252, 315, 117, - 247, 210, 447, 316, 210, 317, 211, 211, 211, 211, - 211, 211, 116, 383, 229, 255, 228, 215, 253, 256, - 257, 258, 259, 254, 242, 351, 243, 269, 126, 318, - 274, 275, 276, 269, 277, 278, 279, 56, 383, 385, - 629, 627, 253, 210, 280, 352, 281, 254, 242, 260, - - 351, 261, 576, 318, 297, 626, 577, 448, 298, 179, - 299, 179, 339, 947, 385, 356, 340, 210, 341, 280, - 357, 281, 358, 260, 942, 261, 156, 156, 156, 267, - 156, 300, 448, 343, 449, 60, 178, 344, 345, 346, - 347, 626, 942, 450, 461, 268, 269, 269, 269, 270, - 271, 272, 273, 269, 269, 300, 626, 627, 462, 449, - 178, 269, 269, 269, 269, 269, 269, 360, 450, 461, - 474, 826, 361, 827, 362, 353, 365, 475, 210, 354, - 366, 355, 367, 462, 131, 443, 269, 269, 269, 269, - 269, 269, 269, 627, 474, 274, 275, 276, 269, 277, - - 278, 279, 335, 210, 629, 846, 336, 847, 337, 285, - 374, 286, 940, 378, 375, 940, 376, 379, 380, 381, - 382, 618, 397, 313, 338, 458, 398, 210, 399, 459, - 210, 460, 314, 626, 285, 131, 286, 178, 178, 178, - 294, 178, 131, 939, 576, 618, 386, 313, 577, 338, - 387, 388, 389, 390, 210, 116, 295, 295, 295, 295, - 295, 295, 295, 295, 295, 295, 117, 310, 310, 310, - 311, 310, 295, 295, 295, 295, 295, 295, 402, 116, - 495, 629, 402, 402, 402, 402, 306, 626, 394, 493, - 494, 306, 395, 306, 396, 939, 89, 295, 295, 295, - - 295, 295, 295, 305, 306, 306, 306, 306, 307, 306, - 308, 306, 306, 512, 493, 494, 210, 929, 92, 306, - 306, 306, 306, 306, 306, 93, 415, 929, 416, 417, - 402, 402, 402, 402, 463, 629, 92, 131, 512, 464, - 210, 465, 92, 93, 306, 306, 306, 306, 306, 306, - 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, - 92, 420, 420, 420, 421, 420, 325, 325, 325, 325, - 325, 325, 415, 922, 416, 417, 402, 402, 402, 402, - 402, 922, 514, 470, 402, 402, 402, 402, 470, 887, - 470, 325, 325, 325, 325, 325, 325, 327, 327, 327, - - 327, 327, 327, 327, 327, 327, 327, 514, 132, 756, - 756, 756, 756, 327, 327, 327, 327, 327, 327, 133, - 470, 851, 887, 852, 370, 473, 536, 470, 211, 371, - 211, 372, 132, 495, 495, 495, 496, 495, 327, 327, - 327, 327, 327, 327, 210, 210, 210, 328, 210, 470, - 480, 536, 210, 526, 473, 316, 470, 317, 527, 131, - 528, 373, 884, 329, 329, 329, 329, 329, 329, 329, - 329, 329, 329, 141, 884, 142, 210, 537, 543, 329, - 329, 329, 329, 329, 329, 373, 482, 485, 878, 878, - 198, 119, 199, 120, 490, 497, 620, 141, 491, 498, - - 492, 499, 537, 543, 329, 329, 329, 329, 329, 329, - 401, 402, 402, 402, 403, 404, 405, 406, 402, 402, - 620, 422, 422, 422, 423, 422, 402, 402, 402, 402, - 402, 402, 872, 425, 425, 425, 426, 425, 743, 855, - 402, 856, 744, 407, 408, 409, 402, 410, 411, 412, - 872, 402, 402, 402, 402, 402, 402, 413, 402, 414, - 424, 407, 408, 409, 402, 410, 411, 412, 130, 427, - 427, 427, 428, 427, 544, 418, 550, 419, 866, 135, - 136, 622, 413, 501, 414, 424, 866, 502, 137, 503, - 515, 138, 130, 551, 429, 429, 429, 430, 429, 544, - - 418, 550, 419, 323, 136, 622, 431, 431, 431, 432, - 431, 522, 137, 563, 517, 523, 130, 524, 551, 131, - 139, 433, 433, 433, 434, 433, 565, 140, 435, 435, - 435, 436, 435, 452, 452, 452, 452, 452, 563, 454, - 130, 130, 540, 455, 139, 456, 541, 131, 542, 116, - 141, 565, 142, 130, 143, 443, 443, 443, 444, 443, - 117, 848, 533, 145, 144, 130, 552, 534, 130, 535, - 553, 131, 554, 116, 141, 147, 621, 130, 143, 146, - 148, 495, 495, 495, 496, 495, 149, 132, 145, 848, - 402, 457, 130, 440, 440, 440, 441, 440, 133, 147, - - 310, 621, 420, 780, 148, 437, 437, 437, 438, 437, - 89, 132, 402, 131, 134, 402, 402, 402, 402, 402, - 433, 433, 433, 434, 433, 507, 845, 780, 442, 508, - 509, 510, 511, 135, 435, 435, 435, 436, 435, 134, - 845, 639, 439, 515, 515, 515, 516, 515, 132, 547, - 92, 155, 130, 442, 548, 402, 549, 93, 151, 133, - 152, 839, 145, 153, 584, 154, 639, 439, 585, 476, - 586, 839, 132, 477, 92, 478, 130, 834, 146, 588, - 402, 147, 151, 589, 152, 590, 148, 145, 155, 864, - 154, 865, 149, 467, 467, 467, 468, 467, 143, 479, - - 517, 517, 517, 518, 517, 147, 834, 885, 144, 886, - 148, 451, 451, 451, 451, 451, 451, 451, 451, 451, - 451, 743, 143, 479, 918, 744, 919, 451, 451, 451, - 451, 451, 451, 515, 515, 515, 516, 515, 538, 180, - 828, 483, 483, 483, 484, 483, 483, 483, 483, 484, - 483, 181, 451, 451, 451, 451, 451, 451, 538, 538, - 538, 539, 538, 180, 469, 470, 470, 470, 470, 471, - 470, 472, 470, 470, 310, 310, 310, 311, 310, 781, - 470, 470, 470, 470, 470, 470, 519, 139, 828, 131, - 520, 195, 521, 470, 140, 131, 195, 145, 470, 196, - - 470, 825, 825, 781, 196, 470, 470, 470, 470, 470, - 470, 139, 558, 146, 210, 195, 559, 560, 561, 562, - 195, 898, 145, 899, 900, 92, 530, 530, 530, 531, - 530, 440, 93, 538, 538, 538, 539, 538, 210, 545, - 545, 545, 546, 545, 545, 545, 545, 546, 545, 92, - 486, 486, 486, 486, 486, 486, 486, 486, 486, 486, - 640, 532, 658, 810, 659, 154, 486, 486, 486, 486, - 486, 486, 810, 802, 556, 556, 556, 557, 556, 566, - 566, 566, 567, 566, 229, 640, 532, 658, 155, 659, - 154, 486, 486, 486, 486, 486, 486, 488, 488, 488, - - 488, 488, 488, 488, 488, 488, 488, 568, 568, 568, - 569, 568, 545, 488, 488, 488, 488, 488, 488, 566, - 566, 566, 567, 566, 802, 505, 505, 505, 506, 505, - 242, 800, 243, 578, 578, 578, 579, 578, 488, 488, - 488, 488, 488, 488, 489, 489, 489, 489, 489, 489, - 489, 489, 489, 489, 242, 580, 580, 580, 581, 580, - 489, 489, 489, 489, 489, 489, 216, 570, 800, 131, - 566, 571, 572, 573, 574, 582, 582, 582, 583, 582, - 879, 671, 672, 217, 880, 489, 489, 489, 489, 489, - 489, 216, 592, 592, 592, 593, 592, 596, 316, 641, - - 317, 596, 596, 596, 596, 596, 671, 672, 601, 602, - 603, 596, 604, 605, 606, 636, 754, 754, 643, 637, - 688, 638, 607, 644, 608, 645, 748, 131, 429, 609, - 594, 610, 611, 596, 596, 596, 596, 609, 748, 610, - 611, 596, 596, 596, 596, 688, 660, 607, 657, 608, - 263, 316, 477, 317, 478, 594, 595, 596, 596, 596, - 597, 598, 599, 600, 596, 596, 425, 425, 425, 426, - 425, 216, 596, 596, 596, 596, 596, 596, 422, 422, - 422, 423, 422, 141, 422, 142, 596, 131, 217, 601, - 602, 603, 596, 604, 605, 606, 216, 596, 596, 596, - - 596, 596, 596, 612, 690, 613, 568, 141, 420, 420, - 420, 421, 420, 136, 651, 147, 474, 614, 711, 652, - 148, 137, 134, 475, 138, 130, 149, 596, 612, 690, - 613, 596, 596, 596, 596, 131, 135, 136, 651, 147, - 474, 135, 614, 711, 148, 137, 131, 134, 427, 130, - 427, 427, 427, 428, 427, 132, 429, 429, 429, 430, - 429, 663, 937, 131, 938, 198, 133, 199, 431, 431, - 431, 432, 431, 742, 443, 443, 443, 444, 443, 132, - 495, 495, 495, 496, 495, 742, 433, 433, 433, 434, - 433, 435, 435, 435, 436, 435, 668, 130, 139, 136, - - 669, 139, 670, 130, 707, 140, 131, 137, 140, 596, - 138, 131, 141, 596, 142, 130, 143, 596, 596, 596, - 596, 130, 139, 136, 352, 139, 144, 130, 145, 707, - 483, 137, 131, 130, 596, 216, 141, 195, 147, 130, - 143, 735, 673, 148, 146, 196, 674, 431, 675, 149, - 433, 702, 217, 145, 907, 89, 703, 130, 704, 596, - 216, 195, 147, 596, 596, 596, 596, 148, 437, 437, - 437, 438, 437, 440, 440, 440, 441, 440, 907, 195, - 735, 425, 433, 433, 433, 434, 433, 196, 728, 879, - 180, 145, 596, 880, 143, 435, 596, 596, 596, 596, - - 712, 728, 181, 195, 144, 615, 578, 146, 616, 435, - 435, 435, 436, 435, 180, 130, 145, 596, 143, 467, - 131, 151, 505, 152, 145, 712, 153, 136, 131, 89, - 615, 155, 150, 616, 948, 137, 949, 437, 138, 130, - 146, 147, 596, 228, 716, 151, 148, 152, 151, 145, - 152, 136, 149, 153, 679, 705, 147, 150, 680, 137, - 681, 148, 216, 131, 180, 147, 229, 149, 228, 716, - 148, 967, 151, 150, 152, 968, 181, 596, 705, 217, - 147, 596, 596, 596, 596, 148, 691, 216, 180, 151, - 692, 152, 693, 717, 153, 721, 617, 698, 150, 452, - - 452, 452, 452, 452, 695, 454, 698, 708, 696, 455, - 697, 456, 709, 151, 710, 152, 263, 958, 717, 959, - 721, 617, 623, 623, 623, 623, 623, 623, 623, 623, - 623, 623, 495, 495, 495, 496, 495, 694, 623, 623, - 623, 623, 623, 623, 624, 624, 624, 624, 624, 713, - 1035, 694, 530, 714, 1035, 715, 456, 457, 641, 641, - 641, 642, 641, 623, 623, 623, 623, 623, 623, 296, - 641, 641, 641, 642, 641, 467, 467, 467, 468, 467, - 653, 296, 969, 131, 970, 654, 228, 655, 661, 661, - 661, 662, 661, 677, 677, 677, 678, 677, 242, 131, - - 243, 580, 457, 630, 631, 624, 624, 624, 631, 229, - 630, 228, 656, 683, 630, 630, 633, 684, 685, 686, - 687, 180, 242, 634, 634, 634, 634, 634, 634, 634, - 634, 634, 634, 181, 722, 734, 656, 313, 736, 634, - 634, 634, 634, 634, 634, 180, 314, 515, 515, 515, - 516, 515, 689, 310, 310, 310, 311, 310, 131, 722, - 734, 313, 635, 736, 634, 634, 634, 634, 634, 634, - 94, 94, 94, 186, 94, 689, 477, 647, 478, 647, - 517, 517, 517, 518, 517, 756, 756, 756, 756, 647, - 647, 647, 647, 647, 648, 647, 649, 647, 647, 515, - - 515, 515, 516, 515, 92, 647, 647, 647, 647, 647, - 647, 93, 699, 699, 699, 700, 699, 538, 538, 538, - 539, 538, 538, 538, 538, 539, 538, 995, 92, 996, - 647, 647, 647, 647, 647, 647, 664, 664, 664, 664, - 664, 664, 664, 664, 664, 664, 778, 779, 262, 654, - 701, 655, 664, 664, 664, 664, 664, 664, 530, 530, - 530, 531, 530, 545, 545, 545, 546, 545, 263, 718, - 352, 778, 779, 262, 719, 701, 720, 664, 664, 664, - 664, 664, 664, 666, 666, 666, 666, 666, 666, 666, - 666, 666, 666, 706, 545, 545, 545, 546, 545, 666, - - 666, 666, 666, 666, 666, 723, 723, 723, 724, 723, - 556, 505, 505, 505, 506, 505, 229, 682, 706, 723, - 723, 723, 724, 723, 666, 666, 666, 666, 666, 666, - 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, - 556, 556, 556, 557, 556, 796, 667, 667, 667, 667, - 667, 667, 216, 725, 967, 682, 729, 726, 968, 727, - 730, 731, 732, 733, 582, 242, 677, 243, 676, 217, - 796, 667, 667, 667, 667, 667, 667, 216, 566, 566, - 566, 567, 566, 568, 568, 568, 569, 568, 676, 242, - 566, 566, 566, 567, 566, 737, 242, 131, 243, 738, - - 739, 740, 741, 578, 578, 578, 579, 578, 580, 580, - 580, 581, 580, 582, 582, 582, 583, 582, 745, 592, - 242, 131, 746, 131, 747, 749, 749, 749, 750, 749, - 751, 806, 646, 807, 752, 646, 753, 592, 592, 592, - 593, 592, 797, 761, 762, 763, 756, 764, 765, 766, - 756, 756, 756, 756, 803, 619, 262, 767, 769, 768, - 770, 771, 756, 756, 756, 756, 769, 797, 770, 771, - 756, 756, 756, 756, 793, 755, 263, 804, 794, 803, - 795, 262, 767, 898, 768, 899, 900, 131, 443, 443, - 443, 444, 443, 811, 926, 263, 927, 477, 591, 478, - - 755, 756, 756, 756, 756, 757, 758, 759, 760, 756, - 756, 756, 756, 756, 756, 820, 821, 756, 756, 756, - 756, 756, 756, 761, 762, 763, 756, 764, 765, 766, - 420, 420, 420, 421, 420, 591, 833, 772, 835, 773, - 820, 821, 756, 756, 756, 756, 756, 756, 422, 422, - 422, 423, 422, 756, 756, 756, 756, 756, 756, 756, - 756, 833, 772, 835, 773, 351, 624, 624, 624, 624, - 624, 756, 756, 756, 756, 216, 587, 132, 456, 783, - 783, 783, 783, 783, 985, 352, 986, 774, 133, 587, - 351, 784, 217, 575, 723, 427, 427, 427, 428, 427, - - 216, 132, 829, 830, 831, 832, 135, 429, 429, 429, - 430, 429, 774, 425, 425, 425, 426, 425, 756, 756, - 756, 756, 575, 564, 431, 431, 431, 432, 431, 853, - 756, 756, 756, 756, 749, 564, 756, 756, 756, 756, - 624, 624, 624, 624, 624, 555, 139, 756, 756, 756, - 756, 131, 456, 140, 853, 433, 433, 433, 434, 433, - 136, 651, 809, 141, 555, 142, 652, 654, 137, 655, - 139, 138, 143, 435, 435, 435, 436, 435, 756, 756, - 756, 756, 144, 814, 136, 651, 131, 141, 316, 822, - 317, 131, 137, 823, 661, 824, 143, 145, 457, 854, - - 624, 624, 624, 624, 624, 313, 529, 529, 756, 756, - 756, 756, 456, 146, 314, 440, 440, 440, 441, 440, - 147, 857, 145, 777, 854, 148, 836, 525, 130, 313, - 837, 149, 838, 624, 624, 624, 624, 624, 756, 756, - 756, 756, 313, 263, 147, 456, 857, 858, 777, 148, - 776, 314, 130, 437, 437, 437, 438, 437, 457, 433, - 433, 433, 434, 433, 862, 525, 313, 435, 435, 435, - 436, 435, 858, 155, 863, 776, 624, 624, 624, 624, - 624, 982, 756, 756, 756, 756, 983, 850, 456, 862, - 775, 457, 641, 641, 641, 642, 641, 131, 842, 863, - - 130, 145, 843, 296, 844, 982, 151, 352, 152, 474, - 871, 153, 850, 859, 147, 775, 475, 146, 860, 148, - 861, 923, 130, 881, 130, 149, 145, 882, 513, 883, - 151, 924, 152, 474, 457, 871, 513, 504, 147, 867, - 868, 869, 870, 148, 504, 923, 130, 782, 782, 782, - 782, 782, 782, 782, 782, 782, 782, 131, 641, 641, - 641, 642, 641, 782, 782, 782, 782, 782, 782, 296, - 495, 495, 495, 496, 495, 500, 467, 467, 467, 468, - 467, 495, 495, 495, 496, 495, 500, 481, 782, 782, - 782, 782, 782, 782, 625, 625, 786, 677, 677, 677, - - 678, 677, 481, 466, 805, 874, 875, 876, 877, 806, - 873, 807, 787, 787, 787, 787, 787, 787, 787, 787, - 787, 787, 180, 515, 515, 515, 516, 515, 787, 787, - 787, 787, 787, 787, 181, 873, 466, 1008, 808, 1009, - 400, 310, 310, 310, 311, 310, 180, 505, 505, 505, - 506, 505, 699, 787, 787, 787, 787, 787, 787, 628, - 628, 789, 808, 517, 517, 517, 518, 517, 515, 515, - 515, 516, 515, 400, 131, 131, 131, 790, 790, 790, - 790, 790, 790, 790, 790, 790, 790, 908, 216, 351, - 216, 391, 92, 790, 790, 790, 790, 790, 790, 93, - - 840, 840, 840, 841, 840, 217, 391, 217, 131, 352, - 909, 131, 908, 216, 351, 216, 92, 384, 790, 790, - 790, 790, 790, 790, 631, 631, 631, 791, 631, 538, - 538, 538, 539, 538, 384, 909, 456, 377, 530, 530, - 530, 531, 530, 792, 792, 792, 792, 792, 792, 792, - 792, 792, 792, 538, 538, 538, 539, 538, 920, 792, - 792, 792, 792, 792, 792, 545, 545, 545, 546, 545, - 377, 131, 131, 849, 545, 545, 545, 546, 545, 131, - 840, 359, 457, 920, 792, 792, 792, 792, 792, 792, - 630, 631, 624, 624, 624, 631, 229, 630, 849, 359, - - 131, 630, 630, 633, 723, 723, 723, 724, 723, 131, - 634, 634, 634, 634, 634, 634, 634, 634, 634, 634, - 723, 723, 723, 724, 723, 906, 634, 634, 634, 634, - 634, 634, 556, 556, 556, 557, 556, 131, 349, 349, - 812, 812, 812, 813, 812, 263, 342, 342, 131, 635, - 906, 634, 634, 634, 634, 634, 634, 1035, 1035, 1035, - 1035, 1035, 566, 566, 566, 567, 566, 131, 296, 568, - 568, 568, 569, 568, 131, 312, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 921, 304, 242, 935, - 243, 474, 90, 90, 90, 90, 90, 90, 475, 566, - - 566, 566, 567, 566, 304, 287, 812, 812, 812, 813, - 812, 921, 242, 131, 935, 474, 936, 90, 90, 90, - 90, 90, 90, 94, 94, 94, 186, 94, 578, 578, - 578, 579, 578, 131, 131, 131, 699, 699, 699, 700, - 699, 936, 801, 801, 801, 801, 801, 801, 801, 801, - 801, 801, 580, 580, 580, 581, 580, 474, 801, 801, - 801, 801, 801, 801, 475, 582, 582, 582, 583, 582, - 131, 131, 941, 803, 707, 749, 749, 749, 750, 749, - 943, 474, 954, 801, 801, 801, 801, 801, 801, 203, - 122, 122, 204, 203, 352, 56, 804, 941, 803, 707, - - 443, 443, 443, 444, 443, 943, 131, 954, 815, 815, - 815, 815, 815, 815, 815, 815, 815, 815, 955, 420, - 420, 420, 421, 420, 815, 815, 815, 815, 815, 815, - 592, 592, 592, 593, 592, 131, 429, 429, 429, 430, - 429, 131, 925, 955, 956, 953, 926, 57, 927, 815, - 815, 815, 815, 815, 815, 816, 816, 816, 816, 816, - 816, 816, 816, 816, 816, 352, 132, 131, 888, 956, - 953, 816, 816, 816, 816, 816, 816, 133, 422, 422, - 422, 423, 422, 783, 783, 783, 783, 783, 263, 957, - 132, 131, 141, 888, 142, 784, 816, 816, 816, 816, - - 816, 816, 817, 817, 817, 817, 817, 817, 817, 817, - 817, 817, 960, 131, 957, 961, 141, 903, 817, 817, - 817, 817, 817, 817, 440, 440, 440, 441, 440, 628, - 427, 427, 427, 428, 427, 933, 135, 960, 626, 477, - 961, 478, 903, 817, 817, 817, 817, 817, 817, 889, - 889, 889, 889, 889, 889, 889, 889, 889, 889, 905, - 425, 425, 425, 426, 425, 889, 889, 889, 889, 889, - 889, 890, 891, 892, 131, 893, 894, 895, 625, 202, - 788, 139, 155, 626, 905, 896, 629, 897, 140, 626, - 889, 889, 889, 889, 889, 889, 202, 890, 891, 892, - - 944, 893, 894, 895, 945, 139, 946, 136, 963, 928, - 896, 901, 897, 902, 806, 137, 807, 1035, 138, 431, - 431, 431, 432, 431, 171, 131, 433, 433, 433, 434, - 433, 136, 965, 963, 975, 627, 901, 629, 902, 137, - 435, 435, 435, 436, 435, 131, 437, 437, 437, 438, - 437, 976, 433, 433, 433, 434, 433, 965, 129, 975, - 435, 435, 435, 436, 435, 115, 114, 143, 145, 624, - 631, 624, 624, 624, 101, 930, 976, 144, 980, 100, - 654, 456, 655, 904, 146, 82, 64, 147, 981, 62, - 785, 143, 148, 145, 145, 626, 988, 1035, 149, 151, - - 926, 152, 927, 980, 153, 999, 1035, 147, 904, 651, - 146, 147, 148, 981, 652, 1035, 148, 990, 149, 145, - 812, 993, 806, 151, 807, 152, 654, 457, 655, 1035, - 999, 147, 1035, 651, 1035, 1035, 148, 910, 910, 910, - 910, 910, 910, 910, 910, 910, 910, 627, 641, 641, - 641, 642, 641, 910, 910, 910, 910, 910, 910, 296, - 641, 641, 641, 642, 641, 94, 94, 94, 186, 94, - 474, 296, 1035, 1035, 1035, 1035, 89, 475, 910, 910, - 910, 910, 910, 910, 911, 785, 785, 912, 911, 1035, - 626, 1035, 1035, 1000, 474, 1035, 1035, 467, 467, 467, - - 468, 467, 1035, 913, 913, 913, 913, 913, 913, 913, - 913, 913, 913, 495, 495, 495, 496, 495, 1000, 913, - 913, 913, 913, 913, 913, 495, 495, 495, 496, 495, - 677, 677, 677, 678, 677, 515, 515, 515, 516, 515, - 1035, 1002, 627, 180, 913, 913, 913, 913, 913, 913, - 914, 788, 788, 915, 914, 181, 1035, 1035, 1035, 1035, - 626, 517, 517, 517, 518, 517, 1002, 180, 1035, 916, - 916, 916, 916, 916, 916, 916, 916, 916, 916, 1035, - 310, 310, 310, 311, 310, 916, 916, 916, 916, 916, - 916, 89, 931, 931, 931, 932, 931, 1035, 203, 122, - - 122, 204, 203, 1011, 56, 1035, 1035, 985, 629, 986, - 916, 916, 916, 916, 916, 916, 917, 917, 917, 917, - 917, 917, 917, 917, 917, 917, 505, 505, 505, 506, - 505, 92, 917, 917, 917, 917, 917, 917, 93, 515, - 515, 515, 516, 515, 982, 651, 1035, 1014, 1024, 983, - 652, 926, 985, 927, 986, 92, 57, 917, 917, 917, - 917, 917, 917, 1035, 1035, 1035, 1035, 216, 982, 651, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 1003, 1035, 1035, 1035, 217, 1035, 59, 59, 59, 59, - 59, 59, 216, 840, 840, 840, 841, 840, 538, 538, - - 538, 539, 538, 1035, 1035, 1003, 699, 699, 699, 700, - 699, 59, 59, 59, 59, 59, 59, 934, 934, 934, - 934, 934, 934, 934, 934, 934, 934, 538, 538, 538, - 539, 538, 1012, 934, 934, 934, 934, 934, 934, 530, - 530, 530, 531, 530, 850, 545, 545, 545, 546, 545, - 545, 545, 545, 546, 545, 1035, 1035, 1012, 934, 934, - 934, 934, 934, 934, 352, 1035, 1017, 1035, 1035, 850, - 1013, 806, 1035, 807, 952, 723, 723, 723, 724, 723, - 723, 723, 723, 724, 723, 556, 556, 556, 557, 556, - 566, 566, 566, 567, 566, 1013, 1035, 229, 1035, 952, - - 568, 568, 568, 569, 568, 566, 566, 566, 567, 566, - 578, 578, 578, 579, 578, 580, 580, 580, 581, 580, - 582, 582, 582, 583, 582, 749, 749, 749, 750, 749, - 592, 592, 592, 593, 592, 931, 156, 156, 156, 267, - 156, 242, 1035, 243, 420, 420, 420, 421, 420, 1035, - 422, 422, 422, 423, 422, 1035, 1035, 1035, 425, 425, - 425, 426, 425, 1035, 1035, 242, 1035, 1035, 973, 427, - 427, 427, 428, 427, 429, 429, 429, 430, 429, 1035, - 431, 431, 431, 432, 431, 1035, 1035, 651, 263, 134, - 1035, 132, 652, 973, 131, 1035, 1035, 433, 433, 433, - - 434, 433, 133, 1027, 1035, 136, 1035, 926, 135, 927, - 803, 651, 1022, 137, 134, 132, 138, 1008, 1035, 1009, - 139, 435, 435, 435, 436, 435, 982, 140, 143, 136, - 141, 983, 142, 804, 1035, 803, 984, 137, 144, 145, - 985, 1035, 986, 923, 139, 437, 437, 437, 438, 437, - 982, 1035, 143, 924, 141, 146, 440, 440, 440, 441, - 440, 1035, 1035, 1035, 145, 987, 1033, 923, 147, 1035, - 985, 1035, 986, 148, 443, 443, 443, 444, 443, 149, - 1035, 991, 150, 433, 433, 433, 434, 433, 1030, 987, - 1035, 154, 147, 1008, 1034, 1009, 1035, 148, 151, 1008, - - 152, 1009, 1015, 153, 1035, 1035, 1035, 150, 435, 435, - 435, 436, 435, 1035, 155, 803, 154, 156, 156, 156, - 267, 156, 151, 1035, 152, 145, 1035, 156, 156, 156, - 267, 156, 131, 156, 156, 156, 267, 156, 804, 1035, - 803, 146, 156, 156, 156, 267, 156, 1035, 1035, 923, - 145, 1035, 1035, 1035, 1035, 147, 1035, 1035, 216, 924, - 148, 178, 178, 178, 294, 178, 149, 1035, 1035, 1035, - 1035, 262, 89, 923, 1035, 217, 1035, 1035, 1035, 147, - 1035, 1035, 1035, 216, 148, 131, 641, 641, 641, 642, - 641, 263, 1035, 1035, 1035, 1035, 262, 296, 1035, 1035, - - 131, 977, 977, 977, 977, 977, 977, 977, 977, 977, - 977, 1035, 641, 641, 641, 642, 641, 977, 977, 977, - 977, 977, 977, 296, 210, 210, 210, 328, 210, 495, - 495, 495, 496, 495, 677, 677, 677, 678, 677, 1035, - 1035, 1035, 977, 977, 977, 977, 977, 977, 978, 978, - 978, 978, 978, 978, 978, 978, 978, 978, 1035, 467, - 467, 467, 468, 467, 978, 978, 978, 978, 978, 978, - 89, 1035, 991, 991, 991, 992, 991, 495, 495, 495, - 496, 495, 131, 1035, 1035, 1035, 1035, 131, 1035, 978, - 978, 978, 978, 978, 978, 979, 979, 979, 979, 979, - - 979, 979, 979, 979, 979, 180, 1035, 803, 1035, 1035, - 1035, 979, 979, 979, 979, 979, 979, 181, 505, 505, - 505, 506, 505, 515, 515, 515, 516, 515, 1035, 180, - 804, 1035, 803, 1035, 1035, 131, 979, 979, 979, 979, - 979, 979, 517, 517, 517, 518, 517, 515, 515, 515, - 516, 515, 840, 840, 840, 841, 840, 1035, 1035, 216, - 699, 699, 699, 700, 699, 1025, 530, 530, 530, 531, - 530, 210, 210, 210, 328, 210, 217, 1035, 1035, 1035, - 1035, 131, 1035, 1035, 216, 210, 210, 210, 328, 210, - 538, 538, 538, 539, 538, 1035, 1035, 1035, 953, 1035, - - 131, 228, 1035, 1035, 1035, 131, 1035, 1035, 1035, 351, - 538, 538, 538, 539, 538, 1035, 1035, 982, 352, 1035, - 1035, 1035, 983, 953, 229, 1035, 228, 1035, 1035, 352, - 1035, 1035, 1035, 1035, 351, 545, 545, 545, 546, 545, - 1035, 982, 1035, 131, 1035, 1035, 1035, 1035, 131, 545, - 545, 545, 546, 545, 723, 723, 723, 724, 723, 723, - 723, 723, 724, 723, 1035, 1035, 1035, 1035, 131, 556, - 556, 556, 557, 556, 566, 566, 566, 567, 566, 568, - 568, 568, 569, 568, 566, 566, 566, 567, 566, 1035, - 1035, 1035, 1035, 131, 578, 578, 578, 579, 578, 580, - - 580, 580, 581, 580, 1035, 1035, 1035, 131, 582, 582, - 582, 583, 582, 749, 749, 749, 750, 749, 592, 592, - 592, 593, 592, 1035, 1035, 242, 1035, 243, 1035, 1007, - 1035, 1035, 131, 1035, 1008, 1035, 1009, 131, 1035, 1035, - 1035, 1035, 131, 210, 210, 210, 328, 210, 1035, 242, - 1035, 1035, 131, 1035, 1035, 1035, 262, 131, 641, 641, - 641, 642, 641, 1010, 1035, 1035, 131, 641, 641, 641, - 642, 641, 1035, 1035, 1035, 1035, 263, 1035, 1035, 1035, - 1035, 262, 677, 677, 677, 678, 677, 1010, 840, 840, - 840, 841, 840, 1031, 1031, 1031, 1032, 1031, 1035, 1035, - - 1035, 131, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, - 1004, 1004, 1035, 1015, 1015, 1015, 1016, 1015, 1004, 1004, - 1004, 1004, 1004, 1004, 699, 699, 699, 700, 699, 1035, - 723, 723, 723, 724, 723, 1035, 1035, 1035, 1035, 1035, - 131, 1035, 1035, 1004, 1004, 1004, 1004, 1004, 1004, 1005, - 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1035, - 1035, 923, 351, 1035, 1035, 1005, 1005, 1005, 1005, 1005, - 1005, 924, 723, 723, 723, 724, 723, 749, 749, 749, - 750, 749, 352, 1035, 1035, 923, 1035, 351, 131, 1035, - 1005, 1005, 1005, 1005, 1005, 1005, 1006, 1006, 1006, 1006, - - 1006, 1006, 1006, 1006, 1006, 1006, 1035, 840, 840, 840, - 841, 840, 1006, 1006, 1006, 1006, 1006, 1006, 1035, 1035, - 1035, 1035, 1035, 1025, 1025, 1025, 1026, 1025, 1035, 1035, - 131, 1035, 1035, 1035, 1035, 131, 1035, 1006, 1006, 1006, - 1006, 1006, 1006, 1019, 1019, 1019, 1019, 1019, 1019, 1019, - 1019, 1019, 1019, 1035, 1035, 1035, 1035, 1035, 1035, 1019, - 1019, 1019, 1019, 1019, 1019, 131, 1035, 1035, 1035, 1035, - 1025, 1025, 1025, 1026, 1025, 1035, 982, 1035, 1035, 1035, - 1035, 983, 1035, 1035, 1019, 1019, 1019, 1019, 1019, 1019, - 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, - - 982, 1035, 1035, 1035, 1035, 1035, 1020, 1020, 1020, 1020, - 1020, 1020, 911, 785, 785, 912, 911, 1035, 626, 1035, - 1035, 1035, 1035, 982, 1035, 1035, 1035, 1035, 983, 1035, - 1035, 1020, 1020, 1020, 1020, 1020, 1020, 1021, 1021, 1021, - 1021, 1021, 1021, 1021, 1021, 1021, 1021, 982, 1035, 1035, - 1035, 1035, 1035, 1021, 1021, 1021, 1021, 1021, 1021, 914, - 788, 788, 915, 914, 1035, 1035, 1035, 1035, 1035, 626, - 627, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1021, 1021, - 1021, 1021, 1021, 1021, 1028, 1028, 1028, 1028, 1028, 1028, - 1028, 1028, 1028, 1028, 1035, 1035, 1035, 1035, 1035, 1035, - - 1028, 1028, 1028, 1028, 1028, 1028, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 629, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1028, 1028, 1028, 1028, 1028, - 1028, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, - 1029, 1035, 1035, 1035, 1035, 1035, 1035, 1029, 1029, 1029, - 1029, 1029, 1029, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1029, 1029, 1029, 1029, 1029, 1029, 453, 453, - 453, 453, 453, 453, 453, 453, 453, 453, 1035, 1035, - 1035, 1035, 1035, 1035, 453, 453, 453, 453, 453, 453, - - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 453, - 453, 453, 453, 453, 453, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 55, 55, 1035, - 55, 55, 55, 55, 55, 55, 55, 55, 58, 1035, - 58, 59, 59, 1035, 59, 59, 59, 59, 59, 59, - 59, 59, 61, 61, 90, 1035, 90, 90, 1035, 90, - 90, 94, 94, 1035, 94, 94, 94, 94, 94, 94, - 94, 94, 102, 102, 1035, 102, 102, 1035, 102, 102, - - 102, 102, 102, 106, 106, 1035, 106, 106, 106, 106, - 106, 106, 106, 106, 109, 109, 1035, 109, 109, 109, - 1035, 109, 109, 109, 109, 113, 113, 1035, 113, 113, - 113, 113, 113, 1035, 113, 113, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 125, 1035, 125, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 69, 69, 130, 130, 1035, 130, 130, 178, 178, - 1035, 178, 178, 178, 178, 178, 178, 178, 178, 192, - 192, 1035, 192, 192, 192, 192, 192, 192, 192, 192, - 206, 1035, 206, 210, 210, 1035, 210, 210, 210, 210, - - 210, 210, 210, 210, 326, 1035, 326, 453, 453, 453, - 1035, 453, 453, 453, 453, 453, 453, 487, 1035, 487, - 625, 625, 1035, 625, 625, 625, 625, 625, 625, 625, - 625, 628, 628, 1035, 628, 628, 628, 628, 628, 628, - 628, 628, 632, 632, 632, 632, 632, 632, 632, 632, - 632, 632, 632, 665, 1035, 665, 785, 785, 785, 785, - 785, 785, 785, 785, 785, 785, 785, 788, 788, 788, - 788, 788, 788, 788, 788, 788, 788, 788, 453, 453, - 1035, 1035, 453, 453, 453, 453, 453, 453, 632, 632, - 632, 632, 632, 632, 632, 632, 632, 632, 632, 55, - - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 7, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035 - - } ; - -static yyconst flex_int16_t yy_chk[5999] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, - 4, 4, 4, 5, 5, 5, 6, 6, 6, 3, - - 9, 14, 4, 16, 9, 10, 10, 10, 5, 30, - 31, 6, 11, 11, 11, 12, 12, 12, 13, 13, - 13, 13, 13, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 42, 29, 47, 13, 29, 42, 47, - 29, 40, 40, 40, 29, 29, 84, 29, 59, 53, - 31, 16, 470, 14, 470, 1032, 30, 31, 55, 29, - 53, 13, 29, 1009, 61, 29, 1008, 106, 29, 29, - 84, 29, 106, 53, 31, 996, 13, 41, 41, 41, - 44, 44, 44, 45, 45, 45, 13, 24, 48, 48, - 48, 49, 49, 49, 24, 24, 59, 24, 24, 24, - - 24, 24, 24, 24, 24, 24, 24, 50, 50, 50, - 55, 61, 126, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 74, 24, 74, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 74, - 126, 83, 995, 24, 33, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 51, 51, 51, 51, 51, 70, - 33, 33, 33, 33, 33, 33, 83, 54, 73, 970, - 70, 54, 51, 54, 71, 73, 86, 79, 969, 33, - - 76, 114, 85, 70, 75, 33, 33, 33, 33, 33, - 33, 54, 73, 71, 75, 87, 76, 51, 114, 71, - 79, 86, 79, 33, 90, 76, 85, 94, 75, 471, - 96, 471, 51, 88, 97, 96, 54, 96, 949, 97, - 87, 97, 51, 57, 57, 57, 63, 122, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 88, 948, - 946, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 90, 203, 472, 94, 472, 172, 57, 57, 57, - 57, 57, 57, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 98, 103, 103, 103, 78, 98, 122, - - 98, 172, 57, 57, 57, 57, 57, 57, 60, 60, - 60, 107, 77, 78, 121, 78, 107, 77, 78, 104, - 104, 104, 78, 77, 203, 121, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 77, 78, 121, 78, - 139, 77, 60, 60, 60, 60, 60, 60, 92, 105, - 105, 105, 110, 110, 110, 111, 111, 111, 112, 112, - 112, 99, 485, 139, 485, 139, 178, 60, 60, 60, - 60, 60, 60, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 92, 945, 145, 134, 145, 72, 62, - 62, 62, 62, 62, 62, 92, 72, 938, 118, 72, - - 165, 99, 118, 134, 118, 937, 192, 92, 99, 145, - 165, 134, 72, 178, 62, 62, 62, 62, 62, 62, - 72, 81, 81, 192, 165, 99, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - - 81, 81, 81, 81, 81, 81, 81, 81, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 927, 643, - 154, 643, 116, 127, 91, 91, 91, 91, 91, 91, - 116, 123, 127, 926, 907, 257, 123, 117, 135, 257, - 154, 117, 135, 117, 135, 154, 116, 886, 885, 91, - 91, 91, 91, 91, 91, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 117, 135, 164, 173, 164, - 166, 93, 93, 93, 93, 93, 93, 158, 163, 883, - 127, 158, 158, 158, 158, 163, 166, 93, 123, 117, - 135, 164, 173, 207, 169, 166, 93, 93, 93, 93, - - 93, 93, 163, 115, 115, 115, 115, 115, 180, 300, - 882, 93, 95, 95, 95, 95, 95, 169, 174, 169, - 175, 115, 160, 95, 160, 160, 160, 160, 160, 160, - 176, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 207, 174, 177, 876, 175, 115, 95, 95, 95, - 95, 95, 95, 182, 176, 180, 300, 874, 182, 138, - 182, 115, 188, 138, 138, 138, 138, 188, 177, 188, - 95, 115, 95, 95, 95, 95, 95, 95, 124, 124, - 124, 124, 124, 198, 124, 195, 162, 138, 162, 162, - 162, 162, 162, 162, 195, 138, 288, 124, 124, 124, - - 124, 124, 124, 124, 124, 124, 124, 199, 198, 195, - 663, 138, 663, 124, 124, 124, 124, 124, 124, 138, - 288, 140, 870, 868, 189, 140, 140, 140, 140, 189, - 190, 189, 199, 213, 168, 190, 124, 190, 124, 124, - 124, 124, 124, 124, 128, 128, 128, 128, 128, 140, - 168, 289, 168, 140, 128, 168, 197, 865, 213, 168, - 197, 214, 197, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 140, 168, 289, 168, 140, 186, 128, - 128, 128, 128, 128, 128, 142, 214, 222, 186, 142, - 142, 142, 142, 185, 201, 144, 267, 864, 201, 144, - - 201, 144, 128, 200, 128, 128, 128, 128, 128, 128, - 129, 200, 222, 142, 129, 129, 129, 129, 847, 846, - 167, 204, 142, 144, 144, 167, 204, 200, 185, 844, - 224, 167, 129, 129, 129, 186, 129, 142, 129, 235, - 185, 129, 129, 129, 167, 454, 142, 144, 144, 167, - 212, 843, 185, 267, 212, 224, 212, 129, 129, 129, - 129, 668, 129, 668, 235, 129, 129, 129, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 204, 236, - 294, 312, 239, 840, 131, 131, 131, 131, 131, 131, - 294, 202, 202, 202, 202, 202, 259, 454, 312, 155, - - 259, 240, 146, 155, 236, 155, 146, 239, 146, 131, - 131, 131, 131, 131, 131, 133, 133, 133, 133, 133, - 133, 133, 133, 133, 133, 146, 240, 155, 290, 838, - 146, 133, 133, 133, 133, 133, 133, 294, 202, 625, - 149, 233, 455, 133, 149, 149, 149, 149, 196, 202, - 146, 155, 290, 196, 146, 196, 133, 133, 133, 133, - 133, 133, 202, 249, 233, 153, 233, 133, 149, 153, - 153, 153, 153, 149, 247, 228, 247, 159, 208, 196, - 159, 159, 159, 159, 159, 159, 159, 208, 249, 251, - 455, 625, 149, 153, 159, 228, 159, 149, 247, 153, - - 228, 153, 388, 196, 181, 785, 388, 291, 181, 181, - 181, 181, 218, 837, 251, 230, 218, 153, 218, 159, - 230, 159, 230, 153, 832, 153, 157, 157, 157, 157, - 157, 181, 291, 221, 292, 208, 181, 221, 221, 221, - 221, 911, 830, 293, 298, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 181, 628, 785, 299, 292, - 181, 157, 157, 157, 157, 157, 157, 234, 293, 298, - 313, 679, 234, 679, 234, 229, 238, 313, 328, 229, - 238, 229, 238, 299, 157, 444, 157, 157, 157, 157, - 157, 157, 161, 911, 313, 161, 161, 161, 161, 161, - - 161, 161, 217, 229, 628, 702, 217, 702, 217, 161, - 244, 161, 827, 248, 244, 826, 244, 248, 248, 248, - 248, 445, 264, 318, 217, 297, 264, 229, 264, 297, - 217, 297, 318, 788, 161, 328, 161, 179, 179, 179, - 179, 179, 444, 824, 390, 445, 255, 318, 390, 217, - 255, 255, 255, 255, 217, 323, 179, 179, 179, 179, - 179, 179, 179, 179, 179, 179, 323, 191, 191, 191, - 191, 191, 179, 179, 179, 179, 179, 179, 269, 323, - 496, 788, 269, 269, 269, 269, 191, 914, 263, 331, - 332, 191, 263, 191, 263, 823, 310, 179, 179, 179, - - 179, 179, 179, 187, 187, 187, 187, 187, 187, 187, - 187, 187, 187, 344, 331, 332, 263, 807, 191, 187, - 187, 187, 187, 187, 187, 191, 271, 806, 271, 271, - 271, 271, 271, 271, 301, 914, 310, 496, 344, 301, - 263, 301, 191, 310, 187, 187, 187, 187, 187, 187, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 310, 274, 274, 274, 274, 274, 205, 205, 205, 205, - 205, 205, 273, 799, 273, 273, 273, 273, 273, 273, - 274, 798, 346, 306, 274, 274, 274, 274, 306, 753, - 306, 205, 205, 205, 205, 205, 205, 209, 209, 209, - - 209, 209, 209, 209, 209, 209, 209, 346, 274, 596, - 596, 596, 596, 209, 209, 209, 209, 209, 209, 274, - 307, 708, 752, 708, 243, 307, 361, 307, 243, 243, - 243, 243, 274, 333, 333, 333, 333, 333, 209, 209, - 209, 209, 209, 209, 211, 211, 211, 211, 211, 308, - 315, 361, 243, 356, 308, 315, 308, 315, 356, 749, - 356, 243, 747, 211, 211, 211, 211, 211, 211, 211, - 211, 211, 211, 429, 746, 429, 243, 362, 366, 211, - 211, 211, 211, 211, 211, 243, 319, 322, 740, 738, - 319, 322, 319, 322, 330, 335, 447, 429, 330, 335, - - 330, 335, 362, 366, 211, 211, 211, 211, 211, 211, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 447, 275, 275, 275, 275, 275, 268, 268, 268, 268, - 268, 268, 733, 276, 276, 276, 276, 276, 572, 713, - 270, 713, 572, 270, 270, 270, 270, 270, 270, 270, - 731, 268, 268, 268, 268, 268, 268, 270, 272, 270, - 275, 272, 272, 272, 272, 272, 272, 272, 275, 277, - 277, 277, 277, 277, 367, 272, 371, 272, 727, 275, - 276, 449, 270, 339, 270, 275, 726, 339, 276, 339, - 516, 276, 275, 372, 278, 278, 278, 278, 278, 367, - - 272, 371, 272, 324, 276, 449, 279, 279, 279, 279, - 279, 353, 276, 379, 518, 353, 277, 353, 372, 723, - 277, 280, 280, 280, 280, 280, 381, 277, 281, 281, - 281, 281, 281, 296, 296, 296, 296, 296, 379, 296, - 277, 278, 365, 296, 277, 296, 365, 516, 365, 324, - 278, 381, 278, 279, 279, 284, 284, 284, 284, 284, - 324, 704, 360, 280, 279, 278, 374, 360, 280, 360, - 374, 518, 374, 324, 278, 281, 448, 279, 279, 280, - 281, 334, 334, 334, 334, 334, 281, 420, 280, 703, - 284, 296, 280, 283, 283, 283, 283, 283, 420, 281, - - 311, 448, 421, 620, 281, 282, 282, 282, 282, 282, - 311, 420, 283, 284, 422, 284, 283, 283, 283, 283, - 285, 285, 285, 285, 285, 343, 697, 620, 283, 343, - 343, 343, 343, 422, 286, 286, 286, 286, 286, 422, - 696, 459, 282, 348, 348, 348, 348, 348, 421, 370, - 311, 283, 282, 283, 370, 285, 370, 311, 282, 421, - 282, 693, 285, 282, 394, 440, 459, 282, 394, 314, - 394, 692, 421, 314, 311, 314, 282, 687, 285, 397, - 285, 286, 282, 397, 282, 397, 286, 285, 440, 725, - 440, 725, 286, 304, 304, 304, 304, 304, 431, 314, - - 349, 349, 349, 349, 349, 286, 685, 751, 431, 751, - 286, 295, 295, 295, 295, 295, 295, 295, 295, 295, - 295, 574, 431, 314, 793, 574, 793, 295, 295, 295, - 295, 295, 295, 350, 350, 350, 350, 350, 539, 304, - 681, 320, 320, 320, 320, 320, 321, 321, 321, 321, - 321, 304, 295, 295, 295, 295, 295, 295, 363, 363, - 363, 363, 363, 304, 305, 305, 305, 305, 305, 305, - 305, 305, 305, 305, 309, 309, 309, 309, 309, 622, - 305, 305, 305, 305, 305, 305, 352, 427, 680, 677, - 352, 320, 352, 309, 427, 539, 321, 433, 309, 320, - - 309, 675, 674, 622, 321, 305, 305, 305, 305, 305, - 305, 427, 378, 433, 352, 320, 378, 378, 378, 378, - 321, 758, 433, 758, 758, 309, 359, 359, 359, 359, - 359, 441, 309, 364, 364, 364, 364, 364, 352, 368, - 368, 368, 368, 368, 369, 369, 369, 369, 369, 309, - 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, - 460, 359, 477, 655, 478, 441, 325, 325, 325, 325, - 325, 325, 654, 649, 377, 377, 377, 377, 377, 383, - 383, 383, 383, 383, 359, 460, 359, 477, 441, 478, - 441, 325, 325, 325, 325, 325, 325, 327, 327, 327, - - 327, 327, 327, 327, 327, 327, 327, 384, 384, 384, - 384, 384, 546, 327, 327, 327, 327, 327, 327, 385, - 385, 385, 385, 385, 648, 342, 342, 342, 342, 342, - 377, 645, 377, 391, 391, 391, 391, 391, 327, 327, - 327, 327, 327, 327, 329, 329, 329, 329, 329, 329, - 329, 329, 329, 329, 377, 392, 392, 392, 392, 392, - 329, 329, 329, 329, 329, 329, 342, 386, 644, 546, - 567, 386, 386, 386, 386, 393, 393, 393, 393, 393, - 739, 491, 492, 342, 739, 329, 329, 329, 329, 329, - 329, 342, 400, 400, 400, 400, 400, 402, 814, 642, - - 814, 402, 402, 402, 402, 403, 491, 492, 403, 403, - 403, 403, 403, 403, 403, 458, 590, 589, 463, 458, - 508, 458, 403, 463, 403, 463, 586, 567, 430, 404, - 400, 404, 404, 404, 404, 404, 404, 406, 585, 406, - 406, 406, 406, 406, 406, 508, 480, 403, 476, 403, - 400, 480, 476, 480, 476, 400, 401, 401, 401, 401, - 401, 401, 401, 401, 401, 401, 409, 409, 409, 409, - 409, 505, 401, 401, 401, 401, 401, 401, 408, 408, - 408, 408, 408, 430, 423, 430, 405, 582, 505, 405, - 405, 405, 405, 405, 405, 405, 505, 401, 401, 401, - - 401, 401, 401, 405, 510, 405, 569, 430, 407, 407, - 407, 407, 407, 409, 474, 435, 479, 408, 534, 474, - 435, 409, 423, 479, 409, 408, 435, 407, 405, 510, - 405, 407, 407, 407, 407, 580, 408, 409, 474, 435, - 479, 423, 408, 534, 435, 409, 578, 423, 428, 408, - 410, 410, 410, 410, 410, 407, 411, 411, 411, 411, - 411, 482, 822, 569, 822, 482, 407, 482, 412, 412, - 412, 412, 412, 573, 417, 417, 417, 417, 417, 407, - 493, 493, 493, 493, 493, 571, 413, 413, 413, 413, - 413, 414, 414, 414, 414, 414, 490, 410, 428, 425, - - 490, 410, 490, 411, 532, 428, 568, 425, 410, 417, - 425, 566, 411, 424, 411, 412, 412, 424, 424, 424, - 424, 410, 428, 425, 532, 410, 412, 411, 413, 532, - 484, 425, 417, 413, 417, 424, 411, 483, 414, 412, - 412, 562, 497, 414, 413, 483, 497, 432, 497, 414, - 434, 526, 424, 413, 778, 467, 526, 413, 526, 439, - 424, 483, 414, 439, 439, 439, 439, 414, 415, 415, - 415, 415, 415, 416, 416, 416, 416, 416, 778, 484, - 560, 426, 418, 418, 418, 418, 418, 484, 554, 741, - 467, 434, 416, 741, 432, 436, 416, 416, 416, 416, - - 535, 553, 467, 484, 432, 415, 579, 434, 416, 419, - 419, 419, 419, 419, 467, 415, 434, 418, 432, 468, - 545, 415, 506, 415, 418, 535, 415, 426, 538, 468, - 415, 416, 437, 416, 842, 426, 842, 438, 426, 415, - 418, 436, 418, 530, 541, 415, 436, 415, 437, 418, - 437, 426, 436, 437, 501, 528, 419, 437, 501, 426, - 501, 419, 506, 579, 468, 436, 530, 419, 530, 541, - 436, 875, 437, 438, 437, 875, 468, 442, 527, 506, - 419, 442, 442, 442, 442, 419, 519, 506, 468, 438, - 519, 438, 519, 542, 438, 548, 442, 524, 438, 452, - - 452, 452, 452, 452, 522, 452, 523, 533, 522, 452, - 522, 452, 533, 438, 533, 438, 442, 859, 542, 859, - 548, 442, 451, 451, 451, 451, 451, 451, 451, 451, - 451, 451, 494, 494, 494, 494, 494, 521, 451, 451, - 451, 451, 451, 451, 453, 453, 453, 453, 453, 540, - 453, 520, 531, 540, 453, 540, 453, 452, 461, 461, - 461, 461, 461, 451, 451, 451, 451, 451, 451, 461, - 462, 462, 462, 462, 462, 466, 466, 466, 466, 466, - 475, 462, 881, 517, 881, 475, 531, 475, 481, 481, - 481, 481, 481, 500, 500, 500, 500, 500, 556, 515, - - 556, 581, 453, 457, 457, 457, 457, 457, 457, 531, - 457, 531, 475, 507, 457, 457, 457, 507, 507, 507, - 507, 466, 556, 457, 457, 457, 457, 457, 457, 457, - 457, 457, 457, 466, 549, 559, 475, 481, 561, 457, - 457, 457, 457, 457, 457, 466, 481, 512, 512, 512, - 512, 512, 511, 473, 473, 473, 473, 473, 581, 549, - 559, 481, 457, 561, 457, 457, 457, 457, 457, 457, - 469, 469, 469, 469, 469, 509, 933, 473, 933, 473, - 513, 513, 513, 513, 513, 615, 615, 615, 615, 469, - 469, 469, 469, 469, 469, 469, 469, 469, 469, 514, - - 514, 514, 514, 514, 473, 469, 469, 469, 469, 469, - 469, 473, 525, 525, 525, 525, 525, 536, 536, 536, - 536, 536, 537, 537, 537, 537, 537, 944, 473, 944, - 469, 469, 469, 469, 469, 469, 486, 486, 486, 486, - 486, 486, 486, 486, 486, 486, 618, 619, 592, 993, - 525, 993, 486, 486, 486, 486, 486, 486, 529, 529, - 529, 529, 529, 543, 543, 543, 543, 543, 592, 547, - 525, 618, 619, 592, 547, 525, 547, 486, 486, 486, - 486, 486, 486, 488, 488, 488, 488, 488, 488, 488, - 488, 488, 488, 529, 544, 544, 544, 544, 544, 488, - - 488, 488, 488, 488, 488, 550, 550, 550, 550, 550, - 557, 504, 504, 504, 504, 504, 529, 503, 529, 551, - 551, 551, 551, 551, 488, 488, 488, 488, 488, 488, - 489, 489, 489, 489, 489, 489, 489, 489, 489, 489, - 555, 555, 555, 555, 555, 637, 489, 489, 489, 489, - 489, 489, 504, 552, 877, 502, 558, 552, 877, 552, - 558, 558, 558, 558, 583, 557, 678, 557, 499, 504, - 637, 489, 489, 489, 489, 489, 489, 504, 563, 563, - 563, 563, 563, 564, 564, 564, 564, 564, 498, 557, - 565, 565, 565, 565, 565, 570, 555, 495, 555, 570, - - 570, 570, 570, 575, 575, 575, 575, 575, 576, 576, - 576, 576, 576, 577, 577, 577, 577, 577, 584, 593, - 555, 583, 584, 678, 584, 587, 587, 587, 587, 587, - 588, 1017, 465, 1017, 588, 464, 588, 591, 591, 591, - 591, 591, 638, 597, 597, 597, 597, 597, 597, 597, - 617, 617, 617, 617, 651, 446, 593, 597, 598, 597, - 598, 598, 598, 598, 598, 598, 600, 638, 600, 600, - 600, 600, 600, 600, 636, 591, 593, 651, 636, 651, - 636, 593, 597, 760, 597, 760, 760, 443, 611, 611, - 611, 611, 611, 657, 1027, 591, 1027, 657, 399, 657, - - 591, 595, 595, 595, 595, 595, 595, 595, 595, 595, - 595, 611, 611, 611, 611, 669, 670, 595, 595, 595, - 595, 595, 595, 599, 599, 599, 599, 599, 599, 599, - 601, 601, 601, 601, 601, 398, 684, 599, 686, 599, - 669, 670, 595, 595, 595, 595, 595, 595, 602, 602, - 602, 602, 602, 601, 601, 601, 601, 614, 614, 614, - 614, 684, 599, 686, 599, 699, 624, 624, 624, 624, - 624, 602, 602, 602, 602, 614, 396, 601, 624, 626, - 626, 626, 626, 626, 1033, 699, 1033, 602, 601, 395, - 699, 626, 614, 389, 724, 604, 604, 604, 604, 604, - - 614, 601, 683, 683, 683, 683, 602, 605, 605, 605, - 605, 605, 602, 603, 603, 603, 603, 603, 604, 604, - 604, 604, 387, 382, 606, 606, 606, 606, 606, 709, - 605, 605, 605, 605, 750, 380, 603, 603, 603, 603, - 630, 630, 630, 630, 630, 376, 604, 606, 606, 606, - 606, 724, 630, 604, 709, 607, 607, 607, 607, 607, - 603, 656, 653, 605, 375, 605, 656, 653, 603, 653, - 604, 603, 606, 608, 608, 608, 608, 608, 607, 607, - 607, 607, 606, 660, 603, 656, 373, 605, 660, 673, - 660, 750, 603, 673, 662, 673, 606, 607, 630, 710, - - 631, 631, 631, 631, 631, 661, 358, 357, 616, 616, - 616, 616, 631, 607, 661, 610, 610, 610, 610, 610, - 608, 714, 607, 616, 710, 608, 691, 355, 608, 661, - 691, 608, 691, 632, 632, 632, 632, 632, 610, 610, - 610, 610, 662, 616, 608, 632, 714, 715, 616, 608, - 610, 662, 608, 609, 609, 609, 609, 609, 631, 612, - 612, 612, 612, 612, 719, 354, 662, 613, 613, 613, - 613, 613, 715, 610, 720, 610, 633, 633, 633, 633, - 633, 923, 612, 612, 612, 612, 923, 706, 633, 719, - 609, 632, 639, 639, 639, 639, 639, 351, 695, 720, - - 609, 612, 695, 639, 695, 923, 609, 706, 609, 812, - 730, 609, 706, 718, 613, 609, 812, 612, 718, 613, - 718, 803, 613, 745, 609, 613, 612, 745, 347, 745, - 609, 803, 609, 812, 633, 730, 345, 341, 613, 729, - 729, 729, 729, 613, 340, 803, 613, 623, 623, 623, - 623, 623, 623, 623, 623, 623, 623, 338, 640, 640, - 640, 640, 640, 623, 623, 623, 623, 623, 623, 640, - 671, 671, 671, 671, 671, 337, 646, 646, 646, 646, - 646, 672, 672, 672, 672, 672, 336, 317, 623, 623, - 623, 623, 623, 623, 627, 627, 627, 676, 676, 676, - - 676, 676, 316, 303, 652, 737, 737, 737, 737, 652, - 732, 652, 627, 627, 627, 627, 627, 627, 627, 627, - 627, 627, 646, 688, 688, 688, 688, 688, 627, 627, - 627, 627, 627, 627, 646, 732, 302, 1034, 652, 1034, - 266, 650, 650, 650, 650, 650, 646, 682, 682, 682, - 682, 682, 700, 627, 627, 627, 627, 627, 627, 629, - 629, 629, 652, 689, 689, 689, 689, 689, 690, 690, - 690, 690, 690, 265, 262, 261, 260, 629, 629, 629, - 629, 629, 629, 629, 629, 629, 629, 779, 682, 700, - 774, 258, 650, 629, 629, 629, 629, 629, 629, 650, - - 694, 694, 694, 694, 694, 682, 256, 774, 254, 700, - 781, 253, 779, 682, 700, 774, 650, 252, 629, 629, - 629, 629, 629, 629, 634, 634, 634, 634, 634, 711, - 711, 711, 711, 711, 250, 781, 634, 246, 705, 705, - 705, 705, 705, 634, 634, 634, 634, 634, 634, 634, - 634, 634, 634, 712, 712, 712, 712, 712, 794, 634, - 634, 634, 634, 634, 634, 716, 716, 716, 716, 716, - 245, 242, 241, 705, 717, 717, 717, 717, 717, 237, - 841, 232, 634, 794, 634, 634, 634, 634, 634, 634, - 635, 635, 635, 635, 635, 635, 705, 635, 705, 231, - - 227, 635, 635, 635, 721, 721, 721, 721, 721, 226, - 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, - 722, 722, 722, 722, 722, 776, 635, 635, 635, 635, - 635, 635, 728, 728, 728, 728, 728, 841, 225, 223, - 658, 658, 658, 658, 658, 776, 220, 219, 216, 635, - 776, 635, 635, 635, 635, 635, 635, 641, 641, 641, - 641, 641, 734, 734, 734, 734, 734, 215, 641, 735, - 735, 735, 735, 735, 210, 193, 641, 641, 641, 641, - 641, 641, 641, 641, 641, 641, 795, 184, 728, 818, - 728, 658, 641, 641, 641, 641, 641, 641, 658, 736, - - 736, 736, 736, 736, 183, 171, 659, 659, 659, 659, - 659, 795, 728, 170, 818, 658, 819, 641, 641, 641, - 641, 641, 641, 647, 647, 647, 647, 647, 742, 742, - 742, 742, 742, 156, 152, 151, 698, 698, 698, 698, - 698, 819, 647, 647, 647, 647, 647, 647, 647, 647, - 647, 647, 743, 743, 743, 743, 743, 659, 647, 647, - 647, 647, 647, 647, 659, 744, 744, 744, 744, 744, - 150, 148, 829, 808, 698, 748, 748, 748, 748, 748, - 831, 659, 851, 647, 647, 647, 647, 647, 647, 664, - 664, 664, 664, 664, 698, 664, 808, 829, 808, 698, - - 771, 771, 771, 771, 771, 831, 147, 851, 664, 664, - 664, 664, 664, 664, 664, 664, 664, 664, 852, 761, - 761, 761, 761, 761, 664, 664, 664, 664, 664, 664, - 754, 754, 754, 754, 754, 143, 765, 765, 765, 765, - 765, 141, 804, 852, 855, 849, 804, 664, 804, 664, - 664, 664, 664, 664, 664, 666, 666, 666, 666, 666, - 666, 666, 666, 666, 666, 849, 761, 137, 754, 855, - 849, 666, 666, 666, 666, 666, 666, 761, 762, 762, - 762, 762, 762, 783, 783, 783, 783, 783, 754, 856, - 761, 136, 765, 754, 765, 783, 666, 666, 666, 666, - - 666, 666, 667, 667, 667, 667, 667, 667, 667, 667, - 667, 667, 860, 132, 856, 861, 765, 762, 667, 667, - 667, 667, 667, 667, 770, 770, 770, 770, 770, 789, - 764, 764, 764, 764, 764, 811, 762, 860, 789, 811, - 861, 811, 762, 667, 667, 667, 667, 667, 667, 756, - 756, 756, 756, 756, 756, 756, 756, 756, 756, 770, - 763, 763, 763, 763, 763, 756, 756, 756, 756, 756, - 756, 757, 757, 757, 130, 757, 757, 757, 786, 120, - 915, 764, 770, 786, 770, 757, 789, 757, 764, 915, - 756, 756, 756, 756, 756, 756, 119, 759, 759, 759, - - 836, 759, 759, 759, 836, 764, 836, 763, 867, 805, - 757, 759, 757, 759, 805, 763, 805, 113, 763, 766, - 766, 766, 766, 766, 82, 80, 767, 767, 767, 767, - 767, 763, 869, 867, 908, 786, 759, 915, 759, 763, - 768, 768, 768, 768, 768, 69, 769, 769, 769, 769, - 769, 909, 772, 772, 772, 772, 772, 869, 66, 908, - 773, 773, 773, 773, 773, 52, 46, 766, 767, 791, - 791, 791, 791, 791, 38, 809, 909, 766, 918, 36, - 809, 791, 809, 769, 767, 27, 23, 768, 919, 21, - 912, 766, 768, 767, 772, 912, 925, 7, 768, 769, - - 925, 769, 925, 918, 769, 958, 0, 773, 769, 931, - 772, 768, 773, 919, 931, 0, 768, 928, 773, 772, - 813, 930, 928, 769, 928, 769, 930, 791, 930, 0, - 958, 773, 0, 931, 0, 0, 773, 782, 782, 782, - 782, 782, 782, 782, 782, 782, 782, 912, 796, 796, - 796, 796, 796, 782, 782, 782, 782, 782, 782, 796, - 797, 797, 797, 797, 797, 801, 801, 801, 801, 801, - 813, 797, 0, 0, 0, 0, 801, 813, 782, 782, - 782, 782, 782, 782, 787, 787, 787, 787, 787, 0, - 787, 0, 0, 959, 813, 0, 0, 800, 800, 800, - - 800, 800, 0, 787, 787, 787, 787, 787, 787, 787, - 787, 787, 787, 820, 820, 820, 820, 820, 959, 787, - 787, 787, 787, 787, 787, 821, 821, 821, 821, 821, - 825, 825, 825, 825, 825, 833, 833, 833, 833, 833, - 0, 975, 787, 800, 787, 787, 787, 787, 787, 787, - 790, 790, 790, 790, 790, 800, 0, 0, 0, 0, - 790, 834, 834, 834, 834, 834, 975, 800, 0, 790, - 790, 790, 790, 790, 790, 790, 790, 790, 790, 0, - 802, 802, 802, 802, 802, 790, 790, 790, 790, 790, - 790, 802, 810, 810, 810, 810, 810, 0, 815, 815, - - 815, 815, 815, 984, 815, 0, 0, 984, 790, 984, - 790, 790, 790, 790, 790, 790, 792, 792, 792, 792, - 792, 792, 792, 792, 792, 792, 828, 828, 828, 828, - 828, 802, 792, 792, 792, 792, 792, 792, 802, 835, - 835, 835, 835, 835, 987, 810, 0, 988, 1011, 987, - 810, 988, 1011, 988, 1011, 802, 815, 792, 792, 792, - 792, 792, 792, 0, 0, 0, 0, 828, 987, 810, - 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, - 976, 0, 0, 0, 828, 0, 816, 816, 816, 816, - 816, 816, 828, 839, 839, 839, 839, 839, 853, 853, - - 853, 853, 853, 0, 0, 976, 845, 845, 845, 845, - 845, 816, 816, 816, 816, 816, 816, 817, 817, 817, - 817, 817, 817, 817, 817, 817, 817, 854, 854, 854, - 854, 854, 985, 817, 817, 817, 817, 817, 817, 848, - 848, 848, 848, 848, 845, 857, 857, 857, 857, 857, - 858, 858, 858, 858, 858, 0, 0, 985, 817, 817, - 817, 817, 817, 817, 845, 0, 990, 0, 0, 845, - 986, 990, 0, 990, 848, 862, 862, 862, 862, 862, - 863, 863, 863, 863, 863, 866, 866, 866, 866, 866, - 871, 871, 871, 871, 871, 986, 0, 848, 0, 848, - - 872, 872, 872, 872, 872, 873, 873, 873, 873, 873, - 878, 878, 878, 878, 878, 879, 879, 879, 879, 879, - 880, 880, 880, 880, 880, 884, 884, 884, 884, 884, - 887, 887, 887, 887, 887, 932, 889, 889, 889, 889, - 889, 866, 0, 866, 890, 890, 890, 890, 890, 0, - 891, 891, 891, 891, 891, 0, 0, 0, 892, 892, - 892, 892, 892, 0, 0, 866, 0, 0, 887, 893, - 893, 893, 893, 893, 894, 894, 894, 894, 894, 0, - 895, 895, 895, 895, 895, 0, 0, 932, 887, 891, - 0, 890, 932, 887, 889, 0, 0, 896, 896, 896, - - 896, 896, 890, 1014, 0, 892, 0, 1014, 891, 1014, - 991, 932, 1007, 892, 891, 890, 892, 1007, 0, 1007, - 893, 897, 897, 897, 897, 897, 1025, 893, 895, 892, - 894, 1025, 894, 991, 0, 991, 924, 892, 895, 896, - 924, 0, 924, 1015, 893, 898, 898, 898, 898, 898, - 1025, 0, 895, 1015, 894, 896, 899, 899, 899, 899, - 899, 0, 0, 0, 896, 924, 1024, 1015, 897, 0, - 1024, 0, 1024, 897, 900, 900, 900, 900, 900, 897, - 0, 992, 898, 901, 901, 901, 901, 901, 1022, 924, - 0, 899, 897, 1022, 1030, 1022, 0, 897, 898, 1030, - - 898, 1030, 1016, 898, 0, 0, 0, 898, 902, 902, - 902, 902, 902, 0, 899, 992, 899, 903, 903, 903, - 903, 903, 898, 0, 898, 901, 0, 904, 904, 904, - 904, 904, 900, 905, 905, 905, 905, 905, 992, 0, - 992, 901, 906, 906, 906, 906, 906, 0, 0, 1016, - 901, 0, 0, 0, 0, 902, 0, 0, 903, 1016, - 902, 910, 910, 910, 910, 910, 902, 0, 0, 0, - 0, 905, 910, 1016, 0, 903, 0, 0, 0, 902, - 0, 0, 0, 903, 902, 904, 920, 920, 920, 920, - 920, 905, 0, 0, 0, 0, 905, 920, 0, 0, - - 906, 913, 913, 913, 913, 913, 913, 913, 913, 913, - 913, 0, 921, 921, 921, 921, 921, 913, 913, 913, - 913, 913, 913, 921, 934, 934, 934, 934, 934, 935, - 935, 935, 935, 935, 939, 939, 939, 939, 939, 0, - 0, 0, 913, 913, 913, 913, 913, 913, 916, 916, - 916, 916, 916, 916, 916, 916, 916, 916, 0, 922, - 922, 922, 922, 922, 916, 916, 916, 916, 916, 916, - 922, 0, 929, 929, 929, 929, 929, 936, 936, 936, - 936, 936, 934, 0, 0, 0, 0, 935, 0, 916, - 916, 916, 916, 916, 916, 917, 917, 917, 917, 917, - - 917, 917, 917, 917, 917, 922, 0, 929, 0, 0, - 0, 917, 917, 917, 917, 917, 917, 922, 940, 940, - 940, 940, 940, 941, 941, 941, 941, 941, 0, 922, - 929, 0, 929, 0, 0, 936, 917, 917, 917, 917, - 917, 917, 942, 942, 942, 942, 942, 943, 943, 943, - 943, 943, 947, 947, 947, 947, 947, 0, 0, 940, - 950, 950, 950, 950, 950, 1026, 951, 951, 951, 951, - 951, 952, 952, 952, 952, 952, 940, 0, 0, 0, - 0, 941, 0, 0, 940, 953, 953, 953, 953, 953, - 954, 954, 954, 954, 954, 0, 0, 0, 950, 0, - - 942, 951, 0, 0, 0, 943, 0, 0, 0, 952, - 955, 955, 955, 955, 955, 0, 0, 1026, 950, 0, - 0, 0, 1026, 950, 951, 0, 951, 0, 0, 952, - 0, 0, 0, 0, 952, 956, 956, 956, 956, 956, - 0, 1026, 0, 953, 0, 0, 0, 0, 954, 957, - 957, 957, 957, 957, 960, 960, 960, 960, 960, 961, - 961, 961, 961, 961, 0, 0, 0, 0, 955, 962, - 962, 962, 962, 962, 963, 963, 963, 963, 963, 964, - 964, 964, 964, 964, 965, 965, 965, 965, 965, 0, - 0, 0, 0, 956, 966, 966, 966, 966, 966, 967, - - 967, 967, 967, 967, 0, 0, 0, 957, 968, 968, - 968, 968, 968, 971, 971, 971, 971, 971, 972, 972, - 972, 972, 972, 0, 0, 962, 0, 962, 0, 983, - 0, 0, 963, 0, 983, 0, 983, 964, 0, 0, - 0, 0, 965, 973, 973, 973, 973, 973, 0, 962, - 0, 0, 966, 0, 0, 0, 972, 967, 980, 980, - 980, 980, 980, 983, 0, 0, 968, 981, 981, 981, - 981, 981, 0, 0, 0, 0, 972, 0, 0, 0, - 0, 972, 994, 994, 994, 994, 994, 983, 997, 997, - 997, 997, 997, 1023, 1023, 1023, 1023, 1023, 0, 0, - - 0, 973, 977, 977, 977, 977, 977, 977, 977, 977, - 977, 977, 0, 989, 989, 989, 989, 989, 977, 977, - 977, 977, 977, 977, 998, 998, 998, 998, 998, 0, - 999, 999, 999, 999, 999, 0, 0, 0, 0, 0, - 994, 0, 0, 977, 977, 977, 977, 977, 977, 978, - 978, 978, 978, 978, 978, 978, 978, 978, 978, 0, - 0, 989, 998, 0, 0, 978, 978, 978, 978, 978, - 978, 989, 1000, 1000, 1000, 1000, 1000, 1001, 1001, 1001, - 1001, 1001, 998, 0, 0, 989, 0, 998, 999, 0, - 978, 978, 978, 978, 978, 978, 979, 979, 979, 979, - - 979, 979, 979, 979, 979, 979, 0, 1018, 1018, 1018, - 1018, 1018, 979, 979, 979, 979, 979, 979, 0, 0, - 0, 0, 0, 1012, 1012, 1012, 1012, 1012, 0, 0, - 1000, 0, 0, 0, 0, 1001, 0, 979, 979, 979, - 979, 979, 979, 1004, 1004, 1004, 1004, 1004, 1004, 1004, - 1004, 1004, 1004, 0, 0, 0, 0, 0, 0, 1004, - 1004, 1004, 1004, 1004, 1004, 1018, 0, 0, 0, 0, - 1013, 1013, 1013, 1013, 1013, 0, 1012, 0, 0, 0, - 0, 1012, 0, 0, 1004, 1004, 1004, 1004, 1004, 1004, - 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, - - 1012, 0, 0, 0, 0, 0, 1005, 1005, 1005, 1005, - 1005, 1005, 1028, 1028, 1028, 1028, 1028, 0, 1028, 0, - 0, 0, 0, 1013, 0, 0, 0, 0, 1013, 0, - 0, 1005, 1005, 1005, 1005, 1005, 1005, 1006, 1006, 1006, - 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1013, 0, 0, - 0, 0, 0, 1006, 1006, 1006, 1006, 1006, 1006, 1029, - 1029, 1029, 1029, 1029, 0, 0, 0, 0, 0, 1029, - 1028, 0, 0, 0, 0, 0, 0, 0, 1006, 1006, - 1006, 1006, 1006, 1006, 1019, 1019, 1019, 1019, 1019, 1019, - 1019, 1019, 1019, 1019, 0, 0, 0, 0, 0, 0, - - 1019, 1019, 1019, 1019, 1019, 1019, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1029, 0, 0, - 0, 0, 0, 0, 0, 1019, 1019, 1019, 1019, 1019, - 1019, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, - 1020, 0, 0, 0, 0, 0, 0, 1020, 1020, 1020, - 1020, 1020, 1020, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1020, 1020, 1020, 1020, 1020, 1020, 1021, 1021, - 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 0, 0, - 0, 0, 0, 0, 1021, 1021, 1021, 1021, 1021, 1021, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1021, - 1021, 1021, 1021, 1021, 1021, 1036, 1036, 1036, 1036, 1036, - 1036, 1036, 1036, 1036, 1036, 1036, 1037, 1037, 1037, 1037, - 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1038, 1038, 0, - 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1039, 0, - 1039, 1040, 1040, 0, 1040, 1040, 1040, 1040, 1040, 1040, - 1040, 1040, 1041, 1041, 1042, 0, 1042, 1042, 0, 1042, - 1042, 1043, 1043, 0, 1043, 1043, 1043, 1043, 1043, 1043, - 1043, 1043, 1044, 1044, 0, 1044, 1044, 0, 1044, 1044, - - 1044, 1044, 1044, 1045, 1045, 0, 1045, 1045, 1045, 1045, - 1045, 1045, 1045, 1045, 1046, 1046, 0, 1046, 1046, 1046, - 0, 1046, 1046, 1046, 1046, 1047, 1047, 0, 1047, 1047, - 1047, 1047, 1047, 0, 1047, 1047, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1049, 0, 1049, - 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, - 1050, 1051, 1051, 1052, 1052, 0, 1052, 1052, 1053, 1053, - 0, 1053, 1053, 1053, 1053, 1053, 1053, 1053, 1053, 1054, - 1054, 0, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, - 1055, 0, 1055, 1056, 1056, 0, 1056, 1056, 1056, 1056, - - 1056, 1056, 1056, 1056, 1057, 0, 1057, 1058, 1058, 1058, - 0, 1058, 1058, 1058, 1058, 1058, 1058, 1059, 0, 1059, - 1060, 1060, 0, 1060, 1060, 1060, 1060, 1060, 1060, 1060, - 1060, 1061, 1061, 0, 1061, 1061, 1061, 1061, 1061, 1061, - 1061, 1061, 1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, - 1062, 1062, 1062, 1063, 0, 1063, 1064, 1064, 1064, 1064, - 1064, 1064, 1064, 1064, 1064, 1064, 1064, 1065, 1065, 1065, - 1065, 1065, 1065, 1065, 1065, 1065, 1065, 1065, 1066, 1066, - 0, 0, 1066, 1066, 1066, 1066, 1066, 1066, 1067, 1067, - 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1068, - - 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035 - - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "source/cssparser/css_lex.l" -#define YY_NO_UNISTD_H 1 -#line 15 "source/cssparser/css_lex.l" -#include "css_grammar.h" -#include -#include "memory_manager.h" - -using namespace std; - -#define YY_USER_ACTION { yyextra->last_column += yyleng; yyextra->position += yyleng; } - -char* css_strdup(char* x, void * yyscanner); - - - - -#line 2127 "build/source/cssparser/css_lex.cpp" - -#define INITIAL 0 -#define comment 1 -#define sgml 2 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - YYSTYPE * yylval_r; - - }; /* end struct yyguts_t */ - -static int yy_init_globals (yyscan_t yyscanner ); - - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval yyg->yylval_r - -int css_lex_init (yyscan_t* scanner); - -int css_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int css_lex_destroy (yyscan_t yyscanner ); - -int css_get_debug (yyscan_t yyscanner ); - -void css_set_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE css_get_extra (yyscan_t yyscanner ); - -void css_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *css_get_in (yyscan_t yyscanner ); - -void css_set_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *css_get_out (yyscan_t yyscanner ); - -void css_set_out (FILE * out_str ,yyscan_t yyscanner ); - -int css_get_leng (yyscan_t yyscanner ); - -char *css_get_text (yyscan_t yyscanner ); - -int css_get_lineno (yyscan_t yyscanner ); - -void css_set_lineno (int line_number ,yyscan_t yyscanner ); - -YYSTYPE * css_get_lval (yyscan_t yyscanner ); - -void css_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int css_wrap (yyscan_t yyscanner ); -#else -extern int css_wrap (yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); -#else -static int input (yyscan_t yyscanner ); -#endif - -#endif - - static void yy_push_state (int new_state ,yyscan_t yyscanner); - - static void yy_pop_state (yyscan_t yyscanner ); - - static int yy_top_state (yyscan_t yyscanner ); - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int css_lex \ - (YYSTYPE * yylval_param ,yyscan_t yyscanner); - -#define YY_DECL int css_lex \ - (YYSTYPE * yylval_param , yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - -#line 85 "source/cssparser/css_lex.l" - - - - CSS_LOCATION_STEP (*yyextra); - - - -#line 2379 "build/source/cssparser/css_lex.cpp" - - yylval = yylval_param; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - css_ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - css__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - css__load_buffer_state(yyscanner ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1036 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_current_state != 1035 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -/* rule 1 can match eol */ -YY_RULE_SETUP -#line 92 "source/cssparser/css_lex.l" -{CSS_LOCATION_LINES (*yyextra, yyleng); CSS_LOCATION_STEP (*yyextra); return CSS_TOKEN_S;} - YY_BREAK -case 2: -YY_RULE_SETUP -#line 94 "source/cssparser/css_lex.l" -{CSS_LOCATION_STEP (*yyextra); return CSS_TOKEN_S;} - YY_BREAK -case 3: -YY_RULE_SETUP -#line 96 "source/cssparser/css_lex.l" -{ yy_push_state(comment, yyscanner); } - YY_BREAK -case 4: -/* rule 4 can match eol */ -YY_RULE_SETUP -#line 97 "source/cssparser/css_lex.l" -{CSS_LOCATION_LINES (*yyextra, yyleng); CSS_LOCATION_STEP (*yyextra); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 98 "source/cssparser/css_lex.l" -/* eat up comments */ - YY_BREAK -case 6: -YY_RULE_SETUP -#line 99 "source/cssparser/css_lex.l" -/* eat up '*'s not followed by '/'s */ - YY_BREAK -case 7: -YY_RULE_SETUP -#line 100 "source/cssparser/css_lex.l" -{ yy_pop_state(yyscanner); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 102 "source/cssparser/css_lex.l" -{ yy_push_state(sgml, yyscanner); } - YY_BREAK -case 9: -/* rule 9 can match eol */ -YY_RULE_SETUP -#line 103 "source/cssparser/css_lex.l" -{CSS_LOCATION_LINES (*yyextra, yyleng); CSS_LOCATION_STEP (*yyextra); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 104 "source/cssparser/css_lex.l" -/* eat all until '-' */ - YY_BREAK -case 11: -YY_RULE_SETUP -#line 105 "source/cssparser/css_lex.l" -/* eat all '--'s not followed by '>'s */ - YY_BREAK -case 12: -YY_RULE_SETUP -#line 106 "source/cssparser/css_lex.l" -/* eat all '-'s not followed by '-'s */ - YY_BREAK -case 13: -YY_RULE_SETUP -#line 107 "source/cssparser/css_lex.l" -{ yy_pop_state(yyscanner); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 109 "source/cssparser/css_lex.l" -{return CSS_TOKEN_INCLUDES;} - YY_BREAK -case 15: -YY_RULE_SETUP -#line 110 "source/cssparser/css_lex.l" -{return CSS_TOKEN_DASHMATCH;} - YY_BREAK -case 16: -/* rule 16 can match eol */ -YY_RULE_SETUP -#line 112 "source/cssparser/css_lex.l" -{yylval->string = css_strdup(yytext, yyscanner); return CSS_TOKEN_STRING;} - YY_BREAK -case 17: -/* rule 17 can match eol */ -YY_RULE_SETUP -#line 113 "source/cssparser/css_lex.l" -{return CSS_TOKEN_INVALID; /* unclosed string */} - YY_BREAK -case 18: -/* rule 18 can match eol */ -YY_RULE_SETUP -#line 115 "source/cssparser/css_lex.l" -{yylval->string = css_strdup(yytext, yyscanner); return CSS_TOKEN_IDENT; } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 117 "source/cssparser/css_lex.l" -{yylval->string = css_strdup(yytext, yyscanner); return CSS_TOKEN_HEXCOLOR;} - YY_BREAK -case 20: -YY_RULE_SETUP -#line 119 "source/cssparser/css_lex.l" -{return CSS_TOKEN_IMPORT_SYM;} - YY_BREAK -case 21: -YY_RULE_SETUP -#line 120 "source/cssparser/css_lex.l" -{return CSS_TOKEN_PAGE_SYM;} - YY_BREAK -case 22: -YY_RULE_SETUP -#line 121 "source/cssparser/css_lex.l" -{return CSS_TOKEN_MEDIA_SYM;} - YY_BREAK -case 23: -YY_RULE_SETUP -#line 122 "source/cssparser/css_lex.l" -{return CSS_TOKEN_FONTFACE_SYM;} - YY_BREAK -case 24: -YY_RULE_SETUP -#line 123 "source/cssparser/css_lex.l" -{return CSS_TOKEN_CHARSET_SYM;} - YY_BREAK -case 25: -YY_RULE_SETUP -#line 124 "source/cssparser/css_lex.l" -{return CSS_TOKEN_NAMESPACE_SYM;} - YY_BREAK -case 26: -/* rule 26 can match eol */ -YY_RULE_SETUP -#line 126 "source/cssparser/css_lex.l" -{return CSS_TOKEN_IMPORTANT_SYM;} - YY_BREAK -case 27: -/* rule 27 can match eol */ -YY_RULE_SETUP -#line 128 "source/cssparser/css_lex.l" -{return CSS_TOKEN_EMS;} - YY_BREAK -case 28: -/* rule 28 can match eol */ -YY_RULE_SETUP -#line 129 "source/cssparser/css_lex.l" -{return CSS_TOKEN_EXS;} - YY_BREAK -case 29: -/* rule 29 can match eol */ -YY_RULE_SETUP -#line 130 "source/cssparser/css_lex.l" -{return CSS_TOKEN_LENGTH;} - YY_BREAK -case 30: -/* rule 30 can match eol */ -YY_RULE_SETUP -#line 131 "source/cssparser/css_lex.l" -{return CSS_TOKEN_LENGTH;} - YY_BREAK -case 31: -/* rule 31 can match eol */ -YY_RULE_SETUP -#line 132 "source/cssparser/css_lex.l" -{return CSS_TOKEN_LENGTH;} - YY_BREAK -case 32: -/* rule 32 can match eol */ -YY_RULE_SETUP -#line 133 "source/cssparser/css_lex.l" -{return CSS_TOKEN_LENGTH;} - YY_BREAK -case 33: -/* rule 33 can match eol */ -YY_RULE_SETUP -#line 134 "source/cssparser/css_lex.l" -{return CSS_TOKEN_LENGTH;} - YY_BREAK -case 34: -/* rule 34 can match eol */ -YY_RULE_SETUP -#line 135 "source/cssparser/css_lex.l" -{return CSS_TOKEN_LENGTH;} - YY_BREAK -case 35: -/* rule 35 can match eol */ -YY_RULE_SETUP -#line 136 "source/cssparser/css_lex.l" -{return CSS_TOKEN_ANGLE;} - YY_BREAK -case 36: -/* rule 36 can match eol */ -YY_RULE_SETUP -#line 137 "source/cssparser/css_lex.l" -{return CSS_TOKEN_ANGLE;} - YY_BREAK -case 37: -/* rule 37 can match eol */ -YY_RULE_SETUP -#line 138 "source/cssparser/css_lex.l" -{return CSS_TOKEN_ANGLE;} - YY_BREAK -case 38: -/* rule 38 can match eol */ -YY_RULE_SETUP -#line 139 "source/cssparser/css_lex.l" -{return CSS_TOKEN_TIME;} - YY_BREAK -case 39: -/* rule 39 can match eol */ -YY_RULE_SETUP -#line 140 "source/cssparser/css_lex.l" -{return CSS_TOKEN_TIME;} - YY_BREAK -case 40: -/* rule 40 can match eol */ -YY_RULE_SETUP -#line 141 "source/cssparser/css_lex.l" -{return CSS_TOKEN_FREQ;} - YY_BREAK -case 41: -/* rule 41 can match eol */ -YY_RULE_SETUP -#line 142 "source/cssparser/css_lex.l" -{return CSS_TOKEN_FREQ;} - YY_BREAK -case 42: -/* rule 42 can match eol */ -YY_RULE_SETUP -#line 143 "source/cssparser/css_lex.l" -{return CSS_TOKEN_DIMENSION;} - YY_BREAK -case 43: -YY_RULE_SETUP -#line 145 "source/cssparser/css_lex.l" -{yylval->number = strtod(yytext, 0); return CSS_TOKEN_PERCENTAGE;} - YY_BREAK -case 44: -YY_RULE_SETUP -#line 146 "source/cssparser/css_lex.l" -{yylval->number = strtod(yytext, 0); return CSS_TOKEN_NUMBER;} - YY_BREAK -case 45: -/* rule 45 can match eol */ -YY_RULE_SETUP -#line 148 "source/cssparser/css_lex.l" -{return CSS_TOKEN_URI;} - YY_BREAK -case 46: -/* rule 46 can match eol */ -YY_RULE_SETUP -#line 149 "source/cssparser/css_lex.l" -{return CSS_TOKEN_URI;} - YY_BREAK -case 47: -/* rule 47 can match eol */ -YY_RULE_SETUP -#line 151 "source/cssparser/css_lex.l" -{yylval->string = css_strdup(yytext, yyscanner); return CSS_TOKEN_FUNCTION;} - YY_BREAK -case 48: -YY_RULE_SETUP -#line 153 "source/cssparser/css_lex.l" -{return CSS_TOKEN_MINUS;} - YY_BREAK -case 49: -YY_RULE_SETUP -#line 154 "source/cssparser/css_lex.l" -{return CSS_TOKEN_PLUS;} - YY_BREAK -case 50: -YY_RULE_SETUP -#line 155 "source/cssparser/css_lex.l" -{return CSS_TOKEN_SLASH;} - YY_BREAK -case 51: -YY_RULE_SETUP -#line 156 "source/cssparser/css_lex.l" -{return CSS_TOKEN_ASTERISK;} - YY_BREAK -case 52: -YY_RULE_SETUP -#line 157 "source/cssparser/css_lex.l" -{return CSS_TOKEN_HASH;} - YY_BREAK -case 53: -YY_RULE_SETUP -#line 158 "source/cssparser/css_lex.l" -{return CSS_TOKEN_LBRACE;} - YY_BREAK -case 54: -YY_RULE_SETUP -#line 159 "source/cssparser/css_lex.l" -{return CSS_TOKEN_RBRACE;} - YY_BREAK -case 55: -YY_RULE_SETUP -#line 160 "source/cssparser/css_lex.l" -{return CSS_TOKEN_LBRACK;} - YY_BREAK -case 56: -YY_RULE_SETUP -#line 161 "source/cssparser/css_lex.l" -{return CSS_TOKEN_RBRACK;} - YY_BREAK -case 57: -YY_RULE_SETUP -#line 162 "source/cssparser/css_lex.l" -{return CSS_TOKEN_DOT;} - YY_BREAK -case 58: -YY_RULE_SETUP -#line 163 "source/cssparser/css_lex.l" -{return CSS_TOKEN_COMMA;} - YY_BREAK -case 59: -YY_RULE_SETUP -#line 164 "source/cssparser/css_lex.l" -{return CSS_TOKEN_COLON;} - YY_BREAK -case 60: -YY_RULE_SETUP -#line 165 "source/cssparser/css_lex.l" -{return CSS_TOKEN_SEMICOLON;} - YY_BREAK -case 61: -YY_RULE_SETUP -#line 166 "source/cssparser/css_lex.l" -{return CSS_TOKEN_CLPARENTH;} - YY_BREAK -case 62: -YY_RULE_SETUP -#line 167 "source/cssparser/css_lex.l" -{return CSS_TOKEN_GREATER;} - YY_BREAK -case 63: -YY_RULE_SETUP -#line 169 "source/cssparser/css_lex.l" -{printf("Unknown char\n"); -return *yytext;} - YY_BREAK -case 64: -YY_RULE_SETUP -#line 172 "source/cssparser/css_lex.l" -ECHO; - YY_BREAK -#line 2807 "build/source/cssparser/css_lex.cpp" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(comment): -case YY_STATE_EOF(sgml): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * css_lex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( css_wrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of css_lex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - css_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - css_restart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) css_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1036 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) -{ - register int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1036 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 1035); - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - -{ - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - css_restart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( css_wrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void css_restart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - css_ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - css__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - css__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - css__load_buffer_state(yyscanner ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void css__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * css_pop_buffer_state(); - * css_push_buffer_state(new_buffer); - */ - css_ensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - css__load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (css_wrap()) processing, but the only time this flag - * is looked at is after css_wrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; -} - -static void css__load_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE css__create_buffer (FILE * file, int size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) css_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in css__create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) css_alloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in css__create_buffer()" ); - - b->yy_is_our_buffer = 1; - - css__init_buffer(b,file ,yyscanner); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with css__create_buffer() - * @param yyscanner The scanner object. - */ - void css__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - css_free((void *) b->yy_ch_buf ,yyscanner ); - - css_free((void *) b ,yyscanner ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a css_restart() or at EOF. - */ - static void css__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - -{ - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - css__flush_buffer(b ,yyscanner); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then css__init_buffer was _probably_ - * called from css_restart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void css__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - css__load_buffer_state(yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void css_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - css_ensure_buffer_stack(yyscanner); - - /* This block is copied from css__switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from css__switch_to_buffer. */ - css__load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void css_pop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - css__delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - css__load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void css_ensure_buffer_stack (yyscan_t yyscanner) -{ - int num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)css_alloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in css_ensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)css_realloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in css_ensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE css__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) css_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in css__scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - css__switch_to_buffer(b ,yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to css_lex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * css__scan_bytes() instead. - */ -YY_BUFFER_STATE css__scan_string (yyconst char * yystr , yyscan_t yyscanner) -{ - - return css__scan_bytes(yystr,strlen(yystr) ,yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to css_lex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE css__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) css_alloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in css__scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = css__scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in css__scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - - static void yy_push_state (int new_state , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) - { - yy_size_t new_size; - - yyg->yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yyg->yy_start_stack_depth * sizeof( int ); - - if ( ! yyg->yy_start_stack ) - yyg->yy_start_stack = (int *) css_alloc(new_size ,yyscanner ); - - else - yyg->yy_start_stack = (int *) css_realloc((void *) yyg->yy_start_stack,new_size ,yyscanner ); - - if ( ! yyg->yy_start_stack ) - YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); - } - - yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); -} - - static void yy_pop_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( --yyg->yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); -} - - static int yy_top_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1]; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE css_get_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int css_get_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int css_get_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *css_get_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *css_get_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int css_get_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *css_get_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void css_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param line_number - * @param yyscanner The scanner object. - */ -void css_set_lineno (int line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "css_set_lineno called with no buffer" , yyscanner); - - yylineno = line_number; -} - -/** Set the current column. - * @param line_number - * @param yyscanner The scanner object. - */ -void css_set_column (int column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "css_set_column called with no buffer" , yyscanner); - - yycolumn = column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * @param yyscanner The scanner object. - * @see css__switch_to_buffer - */ -void css_set_in (FILE * in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = in_str ; -} - -void css_set_out (FILE * out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = out_str ; -} - -int css_get_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void css_set_debug (int bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -YYSTYPE * css_get_lval (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylval; -} - -void css_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylval = yylval_param; -} - -/* User-visible API */ - -/* css_lex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ - -int css_lex_init(yyscan_t* ptr_yy_globals) - -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) css_alloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - -/* css_lex_init_extra has the same functionality as css_lex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to css_alloc in - * the yyextra field. - */ - -int css_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - -{ - struct yyguts_t dummy_yyguts; - - css_set_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) css_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - css_set_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); -} - -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from css_lex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * css_lex_init() - */ - return 0; -} - -/* css_lex_destroy is for both reentrant and non-reentrant scanners. */ -int css_lex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - css__delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - css_pop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - css_free(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - css_free(yyg->yy_start_stack ,yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * css_lex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - css_free ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -#define YYTABLES_NAME "yytables" - -#line 172 "source/cssparser/css_lex.l" - - - - - void * css_alloc (size_t bytes, void* yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return memory_alloc (yyextra->memory, bytes); - } - - void * css_realloc (void * ptr, size_t bytes, void* yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return memory_realloc (yyextra->memory, ptr, bytes); - } - - void css_free (void * ptr, void * yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - memory_free(yyextra->memory, ptr); - } - - char* css_strdup(char* x, void * yyscanner){ - uint32_t size=strlen(x)+1; - char* r=(char*)css_alloc(size, yyscanner); - memcpy(r, x, size); - return r; - } - - - - diff -Nru gpick-0.2.4/source/cssparser/css_lex.h gpick-0.2.5/source/cssparser/css_lex.h --- gpick-0.2.4/source/cssparser/css_lex.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/css_lex.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,357 +0,0 @@ -#ifndef css_HEADER_H -#define css_HEADER_H 1 -#define css_IN_HEADER 1 - -#line 6 "build/source/cssparser/css_lex.h" - -#line 8 "build/source/cssparser/css_lex.h" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void css_restart (FILE *input_file ,yyscan_t yyscanner ); -void css__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE css__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void css__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void css__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void css_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void css_pop_buffer_state (yyscan_t yyscanner ); - -YY_BUFFER_STATE css__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE css__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE css__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *css_alloc (yy_size_t ,yyscan_t yyscanner ); -void *css_realloc (void *,yy_size_t ,yyscan_t yyscanner ); -void css_free (void * ,yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define css_wrap(n) 1 -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define comment 1 -#define sgml 2 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int css_lex_init (yyscan_t* scanner); - -int css_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int css_lex_destroy (yyscan_t yyscanner ); - -int css_get_debug (yyscan_t yyscanner ); - -void css_set_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE css_get_extra (yyscan_t yyscanner ); - -void css_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *css_get_in (yyscan_t yyscanner ); - -void css_set_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *css_get_out (yyscan_t yyscanner ); - -void css_set_out (FILE * out_str ,yyscan_t yyscanner ); - -int css_get_leng (yyscan_t yyscanner ); - -char *css_get_text (yyscan_t yyscanner ); - -int css_get_lineno (yyscan_t yyscanner ); - -void css_set_lineno (int line_number ,yyscan_t yyscanner ); - -YYSTYPE * css_get_lval (yyscan_t yyscanner ); - -void css_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int css_wrap (yyscan_t yyscanner ); -#else -extern int css_wrap (yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int css_lex \ - (YYSTYPE * yylval_param ,yyscan_t yyscanner); - -#define YY_DECL int css_lex \ - (YYSTYPE * yylval_param , yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#line 172 "source/cssparser/css_lex.l" - - -#line 356 "build/source/cssparser/css_lex.h" -#undef css_IN_HEADER -#endif /* css_HEADER_H */ diff -Nru gpick-0.2.4/source/cssparser/css_parser.cpp gpick-0.2.5/source/cssparser/css_parser.cpp --- gpick-0.2.4/source/cssparser/css_parser.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/css_parser.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/cssparser/css_parser.h gpick-0.2.5/source/cssparser/css_parser.h --- gpick-0.2.4/source/cssparser/css_parser.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/css_parser.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -19,7 +19,9 @@ #ifndef CSS_PARSER_H #define CSS_PARSER_H +#ifndef _MSC_VER #include +#endif #include #include diff -Nru gpick-0.2.4/source/cssparser/memory_manager.cpp gpick-0.2.5/source/cssparser/memory_manager.cpp --- gpick-0.2.4/source/cssparser/memory_manager.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/memory_manager.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/cssparser/memory_manager.h gpick-0.2.5/source/cssparser/memory_manager.h --- gpick-0.2.4/source/cssparser/memory_manager.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/cssparser/memory_manager.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -19,7 +19,9 @@ #ifndef MEMORY_MANAGER_H #define MEMORY_MANAGER_H +#ifndef _MSC_VER #include +#endif #include struct MemoryPage; @@ -29,13 +31,13 @@ uint32_t total_free; uint32_t atom_size; struct MemoryPage* next_page; - + uint8_t *map; uint8_t *raw_memory; }; struct Memory{ - struct MemoryPage* pages; + struct MemoryPage* pages; }; struct Memory* memory_new(); @@ -45,4 +47,4 @@ void memory_free(struct Memory* mem, void* mem_ptr); void* memory_realloc(struct Memory* memory, void* mem_ptr, uint32_t size); -#endif /* MEMORY_MANAGER_H */ \ No newline at end of file +#endif /* MEMORY_MANAGER_H */ diff -Nru gpick-0.2.4/source/dbus/Control.cpp gpick-0.2.5/source/dbus/Control.cpp --- gpick-0.2.4/source/dbus/Control.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/dbus/Control.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "DbusInterface.h" + +#include +using namespace std; + +static GDBusObjectManagerServer *manager = NULL; + +typedef struct DbusInterface { + bool (*on_control_activate_floating_picker)(void *userdata); + bool (*on_single_instance_activate)(void *userdata); + void *userdata; +}DbusInterface; + +static DbusInterface dbus_interface; + +static gboolean on_control_activate_floating_picker(GpickControl *control, GDBusMethodInvocation *invocation, gpointer user_data) +{ + DbusInterface *dbus_interface = reinterpret_cast(user_data); + bool result = dbus_interface->on_control_activate_floating_picker(dbus_interface->userdata); + gpick_control_complete_activate_floating_picker(control, invocation); + return result; +} + +static gboolean on_single_instance_activate(GpickSingleInstance *single_instance, GDBusMethodInvocation *invocation, gpointer user_data) +{ + DbusInterface *dbus_interface = reinterpret_cast(user_data); + bool result = dbus_interface->on_single_instance_activate(dbus_interface->userdata); + gpick_single_instance_complete_activate(single_instance, invocation); + return result; +} + +static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) +{ + GpickObjectSkeleton *object; + manager = g_dbus_object_manager_server_new ("/gpick"); + + GpickControl *control; + object = gpick_object_skeleton_new("/gpick/Control"); + control = gpick_control_skeleton_new(); + gpick_object_skeleton_set_control(object, control); + g_object_unref(control); + + g_signal_connect(control, "handle-activate-floating-picker", G_CALLBACK(on_control_activate_floating_picker), user_data); + g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object)); + g_object_unref(object); + + GpickSingleInstance *single_instance; + object = gpick_object_skeleton_new("/gpick/SingleInstance"); + single_instance = gpick_single_instance_skeleton_new(); + gpick_object_skeleton_set_single_instance(object, single_instance); + g_object_unref(single_instance); + + g_signal_connect(single_instance, "handle-activate", G_CALLBACK(on_single_instance_activate), user_data); + g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object)); + g_object_unref(object); + + g_dbus_object_manager_server_set_connection(manager, connection); +} + +static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) +{ +} + +static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) +{ +} + +guint gpick_own_name(bool (*on_control_activate_floating_picker)(void *userdata), bool (*on_single_instance_activate)(void *userdata), void *userdata) +{ + dbus_interface.on_control_activate_floating_picker = on_control_activate_floating_picker; + dbus_interface.on_single_instance_activate = on_single_instance_activate; + dbus_interface.userdata = userdata; + return g_bus_own_name(G_BUS_TYPE_SESSION, "com.google.code.gpick", GBusNameOwnerFlags(G_BUS_NAME_OWNER_FLAGS_REPLACE), on_bus_acquired, on_name_acquired, on_name_lost, &dbus_interface, NULL); +} + +void gpick_unown_name(guint bus_id) +{ + g_bus_unown_name(bus_id); +} + +GDBusObjectManager* gpick_get_manager() +{ + GDBusObjectManager *manager; + GError *error = NULL; + manager = gpick_object_manager_client_new_for_bus_sync(G_BUS_TYPE_SESSION, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "com.google.code.gpick", "/gpick", NULL, &error); + if (manager == NULL) { + cerr << "Error getting object manager client: " << error->message << endl; + g_error_free (error); + return 0; + } + return manager; +} + +bool gpick_control_activate_floating_picker() +{ + GDBusObjectManager *manager = gpick_get_manager(); + if (!manager) return false; + GError *error = NULL; + GDBusInterface *interface = g_dbus_object_manager_get_interface(manager, "/gpick/Control", "com.google.code.gpick.Control"); + bool result = false; + if (interface){ + if (!gpick_control_call_activate_floating_picker_sync(GPICK_CONTROL(interface), NULL, &error)){ + cerr << "Error calling \"Control.ActivateFloatingPicker\": " << error->message << endl; + g_error_free (error); + }else result = true; + g_object_unref(interface); + } + g_object_unref(manager); + return result; +} + +bool gpick_single_instance_activate() +{ + GDBusObjectManager *manager = gpick_get_manager(); + if (!manager) return false; + GError *error = NULL; + GDBusInterface *interface = g_dbus_object_manager_get_interface(manager, "/gpick/SingleInstance", "com.google.code.gpick.SingleInstance"); + bool result = false; + if (interface){ + if (!gpick_single_instance_call_activate_sync(GPICK_SINGLE_INSTANCE(interface), NULL, &error)){ + cerr << "Error calling \"SingleInstance.Activate\": " << error->message << endl; + g_error_free (error); + }else result = true; + g_object_unref(interface); + } + g_object_unref(manager); + return result; +} + diff -Nru gpick-0.2.4/source/dbus/Control.h gpick-0.2.5/source/dbus/Control.h --- gpick-0.2.4/source/dbus/Control.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/dbus/Control.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef UI_DBUS_CONTROL_H_ +#define UI_DBUS_CONTROL_H_ + +#include + +/** \file source/dbus/Control.h + * \brief D-Bus interface and functions. + */ + +/** + * Try to get ownership of a bus. + */ +guint gpick_own_name(bool (*on_control_activate_floating_picker)(void *userdata), bool (*on_single_instance_activate)(void *userdata), void *userdata); + +/** + * Release ownership of a bus. + */ +void gpick_unown_name(guint bus_id); + +/** + * Activate main window in a remove Gpick instance. + */ +bool gpick_single_instance_activate(); + +/** + * Activate floating color picker in a remote Gpick instance. + */ +bool gpick_control_activate_floating_picker(); + +#endif /* UI_DBUS_CONTROL_H_ */ + diff -Nru gpick-0.2.4/source/dbus/DbusInterface.c gpick-0.2.5/source/dbus/DbusInterface.c --- gpick-0.2.4/source/dbus/DbusInterface.c 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/dbus/DbusInterface.c 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,2457 @@ +/* + * Generated by gdbus-codegen 2.32.3. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "DbusInterface.h" + +#ifdef G_OS_UNIX +# include +#endif + +typedef struct +{ + GDBusArgInfo parent_struct; + gboolean use_gvariant; +} _ExtendedGDBusArgInfo; + +typedef struct +{ + GDBusMethodInfo parent_struct; + const gchar *signal_name; + gboolean pass_fdlist; +} _ExtendedGDBusMethodInfo; + +typedef struct +{ + GDBusSignalInfo parent_struct; + const gchar *signal_name; +} _ExtendedGDBusSignalInfo; + +typedef struct +{ + GDBusPropertyInfo parent_struct; + const gchar *hyphen_name; + gboolean use_gvariant; +} _ExtendedGDBusPropertyInfo; + +typedef struct +{ + GDBusInterfaceInfo parent_struct; + const gchar *hyphen_name; +} _ExtendedGDBusInterfaceInfo; + +typedef struct +{ + const _ExtendedGDBusPropertyInfo *info; + guint prop_id; + GValue orig_value; /* the value before the change */ +} ChangedProperty; + +static void +_changed_property_free (ChangedProperty *data) +{ + g_value_unset (&data->orig_value); + g_free (data); +} + +static gboolean +_g_strv_equal0 (gchar **a, gchar **b) +{ + gboolean ret = FALSE; + guint n; + if (a == NULL && b == NULL) + { + ret = TRUE; + goto out; + } + if (a == NULL || b == NULL) + goto out; + if (g_strv_length (a) != g_strv_length (b)) + goto out; + for (n = 0; a[n] != NULL; n++) + if (g_strcmp0 (a[n], b[n]) != 0) + goto out; + ret = TRUE; +out: + return ret; +} + +static gboolean +_g_variant_equal0 (GVariant *a, GVariant *b) +{ + gboolean ret = FALSE; + if (a == NULL && b == NULL) + { + ret = TRUE; + goto out; + } + if (a == NULL || b == NULL) + goto out; + ret = g_variant_equal (a, b); +out: + return ret; +} + +G_GNUC_UNUSED static gboolean +_g_value_equal (const GValue *a, const GValue *b) +{ + gboolean ret = FALSE; + g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b)); + switch (G_VALUE_TYPE (a)) + { + case G_TYPE_BOOLEAN: + ret = (g_value_get_boolean (a) == g_value_get_boolean (b)); + break; + case G_TYPE_UCHAR: + ret = (g_value_get_uchar (a) == g_value_get_uchar (b)); + break; + case G_TYPE_INT: + ret = (g_value_get_int (a) == g_value_get_int (b)); + break; + case G_TYPE_UINT: + ret = (g_value_get_uint (a) == g_value_get_uint (b)); + break; + case G_TYPE_INT64: + ret = (g_value_get_int64 (a) == g_value_get_int64 (b)); + break; + case G_TYPE_UINT64: + ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b)); + break; + case G_TYPE_DOUBLE: + ret = (g_value_get_double (a) == g_value_get_double (b)); + break; + case G_TYPE_STRING: + ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0); + break; + case G_TYPE_VARIANT: + ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b)); + break; + default: + if (G_VALUE_TYPE (a) == G_TYPE_STRV) + ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b)); + else + g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a))); + break; + } + return ret; +} + +/* ------------------------------------------------------------------------ + * Code for interface com.google.code.gpick.SingleInstance + * ------------------------------------------------------------------------ + */ + +/** + * SECTION:GpickSingleInstance + * @title: GpickSingleInstance + * @short_description: Generated C code for the com.google.code.gpick.SingleInstance D-Bus interface + * + * This section contains code for working with the com.google.code.gpick.SingleInstance D-Bus interface in C. + */ + +/* ---- Introspection data for com.google.code.gpick.SingleInstance ---- */ + +static const _ExtendedGDBusMethodInfo _gpick_single_instance_method_info_activate = +{ + { + -1, + "Activate", + NULL, + NULL, + NULL + }, + "handle-activate", + FALSE +}; + +static const _ExtendedGDBusMethodInfo * const _gpick_single_instance_method_info_pointers[] = +{ + &_gpick_single_instance_method_info_activate, + NULL +}; + +static const _ExtendedGDBusInterfaceInfo _gpick_single_instance_interface_info = +{ + { + -1, + "com.google.code.gpick.SingleInstance", + (GDBusMethodInfo **) &_gpick_single_instance_method_info_pointers, + NULL, + NULL, + NULL + }, + "single-instance", +}; + + +/** + * gpick_single_instance_interface_info: + * + * Gets a machine-readable description of the com.google.code.gpick.SingleInstance D-Bus interface. + * + * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. + */ +GDBusInterfaceInfo * +gpick_single_instance_interface_info (void) +{ + return (GDBusInterfaceInfo *) &_gpick_single_instance_interface_info; +} + +/** + * gpick_single_instance_override_properties: + * @klass: The class structure for a #GObject-derived class. + * @property_id_begin: The property id to assign to the first overridden property. + * + * Overrides all #GObject properties in the #GpickSingleInstance interface for a concrete class. + * The properties are overridden in the order they are defined. + * + * Returns: The last property id. + */ +guint +gpick_single_instance_override_properties (GObjectClass *klass, guint property_id_begin) +{ + return property_id_begin - 1; +} + + + +/** + * GpickSingleInstance: + * + * Abstract interface type for the D-Bus interface com.google.code.gpick.SingleInstance. + */ + +/** + * GpickSingleInstanceIface: + * @parent_iface: The parent interface. + * @handle_activate: Handler for the #GpickSingleInstance::handle-activate signal. + * + * Virtual table for the D-Bus interface com.google.code.gpick.SingleInstance. + */ + +static void +gpick_single_instance_default_init (GpickSingleInstanceIface *iface) +{ + /* GObject signals for incoming D-Bus method calls: */ + /** + * GpickSingleInstance::handle-activate: + * @object: A #GpickSingleInstance. + * @invocation: A #GDBusMethodInvocation. + * + * Signal emitted when a remote caller is invoking the Activate() D-Bus method. + * + * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call gpick_single_instance_complete_activate() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. + * + * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. + */ + g_signal_new ("handle-activate", + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GpickSingleInstanceIface, handle_activate), + g_signal_accumulator_true_handled, + NULL, + g_cclosure_marshal_generic, + G_TYPE_BOOLEAN, + 1, + G_TYPE_DBUS_METHOD_INVOCATION); + +} + +typedef GpickSingleInstanceIface GpickSingleInstanceInterface; +G_DEFINE_INTERFACE (GpickSingleInstance, gpick_single_instance, G_TYPE_OBJECT); + +/** + * gpick_single_instance_call_activate: + * @proxy: A #GpickSingleInstanceProxy. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously invokes the Activate() D-Bus method on @proxy. + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_single_instance_call_activate_finish() to get the result of the operation. + * + * See gpick_single_instance_call_activate_sync() for the synchronous, blocking version of this method. + */ +void +gpick_single_instance_call_activate ( + GpickSingleInstance *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_dbus_proxy_call (G_DBUS_PROXY (proxy), + "Activate", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + callback, + user_data); +} + +/** + * gpick_single_instance_call_activate_finish: + * @proxy: A #GpickSingleInstanceProxy. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_single_instance_call_activate(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with gpick_single_instance_call_activate(). + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +gpick_single_instance_call_activate_finish ( + GpickSingleInstance *proxy, + GAsyncResult *res, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * gpick_single_instance_call_activate_sync: + * @proxy: A #GpickSingleInstanceProxy. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously invokes the Activate() D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * + * See gpick_single_instance_call_activate() for the asynchronous version of this method. + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +gpick_single_instance_call_activate_sync ( + GpickSingleInstance *proxy, + GCancellable *cancellable, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), + "Activate", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * gpick_single_instance_complete_activate: + * @object: A #GpickSingleInstance. + * @invocation: (transfer full): A #GDBusMethodInvocation. + * + * Helper function used in service implementations to finish handling invocations of the Activate() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * + * This method will free @invocation, you cannot use it afterwards. + */ +void +gpick_single_instance_complete_activate ( + GpickSingleInstance *object, + GDBusMethodInvocation *invocation) +{ + g_dbus_method_invocation_return_value (invocation, + g_variant_new ("()")); +} + +/* ------------------------------------------------------------------------ */ + +/** + * GpickSingleInstanceProxy: + * + * The #GpickSingleInstanceProxy structure contains only private data and should only be accessed using the provided API. + */ + +/** + * GpickSingleInstanceProxyClass: + * @parent_class: The parent class. + * + * Class structure for #GpickSingleInstanceProxy. + */ + +struct _GpickSingleInstanceProxyPrivate +{ + GData *qdata; +}; + +static void gpick_single_instance_proxy_iface_init (GpickSingleInstanceIface *iface); + +G_DEFINE_TYPE_WITH_CODE (GpickSingleInstanceProxy, gpick_single_instance_proxy, G_TYPE_DBUS_PROXY, + G_IMPLEMENT_INTERFACE (GPICK_TYPE_SINGLE_INSTANCE, gpick_single_instance_proxy_iface_init)); + +static void +gpick_single_instance_proxy_finalize (GObject *object) +{ + GpickSingleInstanceProxy *proxy = GPICK_SINGLE_INSTANCE_PROXY (object); + g_datalist_clear (&proxy->priv->qdata); + G_OBJECT_CLASS (gpick_single_instance_proxy_parent_class)->finalize (object); +} + +static void +gpick_single_instance_proxy_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ +} + +static void +gpick_single_instance_proxy_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ +} + +static void +gpick_single_instance_proxy_g_signal (GDBusProxy *proxy, + const gchar *sender_name, + const gchar *signal_name, + GVariant *parameters) +{ + _ExtendedGDBusSignalInfo *info; + GVariantIter iter; + GVariant *child; + GValue *paramv; + guint num_params; + guint n; + guint signal_id; + info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, signal_name); + if (info == NULL) + return; + num_params = g_variant_n_children (parameters); + paramv = g_new0 (GValue, num_params + 1); + g_value_init (¶mv[0], GPICK_TYPE_SINGLE_INSTANCE); + g_value_set_object (¶mv[0], proxy); + g_variant_iter_init (&iter, parameters); + n = 1; + while ((child = g_variant_iter_next_value (&iter)) != NULL) + { + _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1]; + if (arg_info->use_gvariant) + { + g_value_init (¶mv[n], G_TYPE_VARIANT); + g_value_set_variant (¶mv[n], child); + n++; + } + else + g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); + g_variant_unref (child); + } + signal_id = g_signal_lookup (info->signal_name, GPICK_TYPE_SINGLE_INSTANCE); + g_signal_emitv (paramv, signal_id, 0, NULL); + for (n = 0; n < num_params + 1; n++) + g_value_unset (¶mv[n]); + g_free (paramv); +} + +static void +gpick_single_instance_proxy_g_properties_changed (GDBusProxy *_proxy, + GVariant *changed_properties, + const gchar *const *invalidated_properties) +{ + GpickSingleInstanceProxy *proxy = GPICK_SINGLE_INSTANCE_PROXY (_proxy); + guint n; + const gchar *key; + GVariantIter *iter; + _ExtendedGDBusPropertyInfo *info; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) + { + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, key); + g_datalist_remove_data (&proxy->priv->qdata, key); + if (info != NULL) + g_object_notify (G_OBJECT (proxy), info->hyphen_name); + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) + { + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, invalidated_properties[n]); + g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); + if (info != NULL) + g_object_notify (G_OBJECT (proxy), info->hyphen_name); + } +} + +static void +gpick_single_instance_proxy_init (GpickSingleInstanceProxy *proxy) +{ + proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, GPICK_TYPE_SINGLE_INSTANCE_PROXY, GpickSingleInstanceProxyPrivate); + g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), gpick_single_instance_interface_info ()); +} + +static void +gpick_single_instance_proxy_class_init (GpickSingleInstanceProxyClass *klass) +{ + GObjectClass *gobject_class; + GDBusProxyClass *proxy_class; + + g_type_class_add_private (klass, sizeof (GpickSingleInstanceProxyPrivate)); + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = gpick_single_instance_proxy_finalize; + gobject_class->get_property = gpick_single_instance_proxy_get_property; + gobject_class->set_property = gpick_single_instance_proxy_set_property; + + proxy_class = G_DBUS_PROXY_CLASS (klass); + proxy_class->g_signal = gpick_single_instance_proxy_g_signal; + proxy_class->g_properties_changed = gpick_single_instance_proxy_g_properties_changed; + +} + +static void +gpick_single_instance_proxy_iface_init (GpickSingleInstanceIface *iface) +{ +} + +/** + * gpick_single_instance_proxy_new: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Asynchronously creates a proxy for the D-Bus interface com.google.code.gpick.SingleInstance. See g_dbus_proxy_new() for more details. + * + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_single_instance_proxy_new_finish() to get the result of the operation. + * + * See gpick_single_instance_proxy_new_sync() for the synchronous, blocking version of this constructor. + */ +void +gpick_single_instance_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (GPICK_TYPE_SINGLE_INSTANCE_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.SingleInstance", NULL); +} + +/** + * gpick_single_instance_proxy_new_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_single_instance_proxy_new(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with gpick_single_instance_proxy_new(). + * + * Returns: (transfer full) (type GpickSingleInstanceProxy): The constructed proxy object or %NULL if @error is set. + */ +GpickSingleInstance * +gpick_single_instance_proxy_new_finish ( + GAsyncResult *res, + GError **error) +{ + GObject *ret; + GObject *source_object; + source_object = g_async_result_get_source_object (res); + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); + g_object_unref (source_object); + if (ret != NULL) + return GPICK_SINGLE_INSTANCE (ret); + else + return NULL; +} + +/** + * gpick_single_instance_proxy_new_sync: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Synchronously creates a proxy for the D-Bus interface com.google.code.gpick.SingleInstance. See g_dbus_proxy_new_sync() for more details. + * + * The calling thread is blocked until a reply is received. + * + * See gpick_single_instance_proxy_new() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type GpickSingleInstanceProxy): The constructed proxy object or %NULL if @error is set. + */ +GpickSingleInstance * +gpick_single_instance_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + ret = g_initable_new (GPICK_TYPE_SINGLE_INSTANCE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.SingleInstance", NULL); + if (ret != NULL) + return GPICK_SINGLE_INSTANCE (ret); + else + return NULL; +} + + +/** + * gpick_single_instance_proxy_new_for_bus: + * @bus_type: A #GBusType. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: A bus name (well-known or unique). + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Like gpick_single_instance_proxy_new() but takes a #GBusType instead of a #GDBusConnection. + * + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_single_instance_proxy_new_for_bus_finish() to get the result of the operation. + * + * See gpick_single_instance_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor. + */ +void +gpick_single_instance_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (GPICK_TYPE_SINGLE_INSTANCE_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.SingleInstance", NULL); +} + +/** + * gpick_single_instance_proxy_new_for_bus_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_single_instance_proxy_new_for_bus(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with gpick_single_instance_proxy_new_for_bus(). + * + * Returns: (transfer full) (type GpickSingleInstanceProxy): The constructed proxy object or %NULL if @error is set. + */ +GpickSingleInstance * +gpick_single_instance_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error) +{ + GObject *ret; + GObject *source_object; + source_object = g_async_result_get_source_object (res); + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); + g_object_unref (source_object); + if (ret != NULL) + return GPICK_SINGLE_INSTANCE (ret); + else + return NULL; +} + +/** + * gpick_single_instance_proxy_new_for_bus_sync: + * @bus_type: A #GBusType. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: A bus name (well-known or unique). + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Like gpick_single_instance_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. + * + * The calling thread is blocked until a reply is received. + * + * See gpick_single_instance_proxy_new_for_bus() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type GpickSingleInstanceProxy): The constructed proxy object or %NULL if @error is set. + */ +GpickSingleInstance * +gpick_single_instance_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + ret = g_initable_new (GPICK_TYPE_SINGLE_INSTANCE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.SingleInstance", NULL); + if (ret != NULL) + return GPICK_SINGLE_INSTANCE (ret); + else + return NULL; +} + + +/* ------------------------------------------------------------------------ */ + +/** + * GpickSingleInstanceSkeleton: + * + * The #GpickSingleInstanceSkeleton structure contains only private data and should only be accessed using the provided API. + */ + +/** + * GpickSingleInstanceSkeletonClass: + * @parent_class: The parent class. + * + * Class structure for #GpickSingleInstanceSkeleton. + */ + +struct _GpickSingleInstanceSkeletonPrivate +{ + GValue *properties; + GList *changed_properties; + GSource *changed_properties_idle_source; + GMainContext *context; + GMutex lock; +}; + +static void +_gpick_single_instance_skeleton_handle_method_call ( + GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + GpickSingleInstanceSkeleton *skeleton = GPICK_SINGLE_INSTANCE_SKELETON (user_data); + _ExtendedGDBusMethodInfo *info; + GVariantIter iter; + GVariant *child; + GValue *paramv; + guint num_params; + guint num_extra; + guint n; + guint signal_id; + GValue return_value = G_VALUE_INIT; + info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation); + g_assert (info != NULL); + num_params = g_variant_n_children (parameters); + num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra); + n = 0; + g_value_init (¶mv[n], GPICK_TYPE_SINGLE_INSTANCE); + g_value_set_object (¶mv[n++], skeleton); + g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION); + g_value_set_object (¶mv[n++], invocation); + if (info->pass_fdlist) + { +#ifdef G_OS_UNIX + g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST); + g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation))); +#else + g_assert_not_reached (); +#endif + } + g_variant_iter_init (&iter, parameters); + while ((child = g_variant_iter_next_value (&iter)) != NULL) + { + _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra]; + if (arg_info->use_gvariant) + { + g_value_init (¶mv[n], G_TYPE_VARIANT); + g_value_set_variant (¶mv[n], child); + n++; + } + else + g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); + g_variant_unref (child); + } + signal_id = g_signal_lookup (info->signal_name, GPICK_TYPE_SINGLE_INSTANCE); + g_value_init (&return_value, G_TYPE_BOOLEAN); + g_signal_emitv (paramv, signal_id, 0, &return_value); + if (!g_value_get_boolean (&return_value)) + g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name); + g_value_unset (&return_value); + for (n = 0; n < num_params + num_extra; n++) + g_value_unset (¶mv[n]); + g_free (paramv); +} + +static GVariant * +_gpick_single_instance_skeleton_handle_get_property ( + GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GError **error, + gpointer user_data) +{ + GpickSingleInstanceSkeleton *skeleton = GPICK_SINGLE_INSTANCE_SKELETON (user_data); + GValue value = G_VALUE_INIT; + GParamSpec *pspec; + _ExtendedGDBusPropertyInfo *info; + GVariant *ret; + ret = NULL; + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, property_name); + g_assert (info != NULL); + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); + if (pspec == NULL) + { + g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); + } + else + { + g_value_init (&value, pspec->value_type); + g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value); + ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)); + g_value_unset (&value); + } + return ret; +} + +static gboolean +_gpick_single_instance_skeleton_handle_set_property ( + GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GVariant *variant, + GError **error, + gpointer user_data) +{ + GpickSingleInstanceSkeleton *skeleton = GPICK_SINGLE_INSTANCE_SKELETON (user_data); + GValue value = G_VALUE_INIT; + GParamSpec *pspec; + _ExtendedGDBusPropertyInfo *info; + gboolean ret; + ret = FALSE; + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, property_name); + g_assert (info != NULL); + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); + if (pspec == NULL) + { + g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); + } + else + { + if (info->use_gvariant) + g_value_set_variant (&value, variant); + else + g_dbus_gvariant_to_gvalue (variant, &value); + g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value); + g_value_unset (&value); + ret = TRUE; + } + return ret; +} + +static const GDBusInterfaceVTable _gpick_single_instance_skeleton_vtable = +{ + _gpick_single_instance_skeleton_handle_method_call, + _gpick_single_instance_skeleton_handle_get_property, + _gpick_single_instance_skeleton_handle_set_property +}; + +static GDBusInterfaceInfo * +gpick_single_instance_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton) +{ + return gpick_single_instance_interface_info (); +} + +static GDBusInterfaceVTable * +gpick_single_instance_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton) +{ + return (GDBusInterfaceVTable *) &_gpick_single_instance_skeleton_vtable; +} + +static GVariant * +gpick_single_instance_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton) +{ + GpickSingleInstanceSkeleton *skeleton = GPICK_SINGLE_INSTANCE_SKELETON (_skeleton); + + GVariantBuilder builder; + guint n; + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + if (_gpick_single_instance_interface_info.parent_struct.properties == NULL) + goto out; + for (n = 0; _gpick_single_instance_interface_info.parent_struct.properties[n] != NULL; n++) + { + GDBusPropertyInfo *info = _gpick_single_instance_interface_info.parent_struct.properties[n]; + if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) + { + GVariant *value; + value = _gpick_single_instance_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "com.google.code.gpick.SingleInstance", info->name, NULL, skeleton); + if (value != NULL) + { + g_variant_take_ref (value); + g_variant_builder_add (&builder, "{sv}", info->name, value); + g_variant_unref (value); + } + } + } +out: + return g_variant_builder_end (&builder); +} + +static void +gpick_single_instance_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) +{ +} + +static void gpick_single_instance_skeleton_iface_init (GpickSingleInstanceIface *iface); +G_DEFINE_TYPE_WITH_CODE (GpickSingleInstanceSkeleton, gpick_single_instance_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, + G_IMPLEMENT_INTERFACE (GPICK_TYPE_SINGLE_INSTANCE, gpick_single_instance_skeleton_iface_init)); + +static void +gpick_single_instance_skeleton_finalize (GObject *object) +{ + GpickSingleInstanceSkeleton *skeleton = GPICK_SINGLE_INSTANCE_SKELETON (object); + g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); + if (skeleton->priv->changed_properties_idle_source != NULL) + g_source_destroy (skeleton->priv->changed_properties_idle_source); + g_main_context_unref (skeleton->priv->context); + g_mutex_clear (&skeleton->priv->lock); + G_OBJECT_CLASS (gpick_single_instance_skeleton_parent_class)->finalize (object); +} + +static void +gpick_single_instance_skeleton_init (GpickSingleInstanceSkeleton *skeleton) +{ + skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, GPICK_TYPE_SINGLE_INSTANCE_SKELETON, GpickSingleInstanceSkeletonPrivate); + g_mutex_init (&skeleton->priv->lock); + skeleton->priv->context = g_main_context_ref_thread_default (); +} + +static void +gpick_single_instance_skeleton_class_init (GpickSingleInstanceSkeletonClass *klass) +{ + GObjectClass *gobject_class; + GDBusInterfaceSkeletonClass *skeleton_class; + + g_type_class_add_private (klass, sizeof (GpickSingleInstanceSkeletonPrivate)); + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = gpick_single_instance_skeleton_finalize; + + skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass); + skeleton_class->get_info = gpick_single_instance_skeleton_dbus_interface_get_info; + skeleton_class->get_properties = gpick_single_instance_skeleton_dbus_interface_get_properties; + skeleton_class->flush = gpick_single_instance_skeleton_dbus_interface_flush; + skeleton_class->get_vtable = gpick_single_instance_skeleton_dbus_interface_get_vtable; +} + +static void +gpick_single_instance_skeleton_iface_init (GpickSingleInstanceIface *iface) +{ +} + +/** + * gpick_single_instance_skeleton_new: + * + * Creates a skeleton object for the D-Bus interface com.google.code.gpick.SingleInstance. + * + * Returns: (transfer full) (type GpickSingleInstanceSkeleton): The skeleton object. + */ +GpickSingleInstance * +gpick_single_instance_skeleton_new (void) +{ + return GPICK_SINGLE_INSTANCE (g_object_new (GPICK_TYPE_SINGLE_INSTANCE_SKELETON, NULL)); +} + +/* ------------------------------------------------------------------------ + * Code for interface com.google.code.gpick.Control + * ------------------------------------------------------------------------ + */ + +/** + * SECTION:GpickControl + * @title: GpickControl + * @short_description: Generated C code for the com.google.code.gpick.Control D-Bus interface + * + * This section contains code for working with the com.google.code.gpick.Control D-Bus interface in C. + */ + +/* ---- Introspection data for com.google.code.gpick.Control ---- */ + +static const _ExtendedGDBusMethodInfo _gpick_control_method_info_activate_floating_picker = +{ + { + -1, + "ActivateFloatingPicker", + NULL, + NULL, + NULL + }, + "handle-activate-floating-picker", + FALSE +}; + +static const _ExtendedGDBusMethodInfo * const _gpick_control_method_info_pointers[] = +{ + &_gpick_control_method_info_activate_floating_picker, + NULL +}; + +static const _ExtendedGDBusInterfaceInfo _gpick_control_interface_info = +{ + { + -1, + "com.google.code.gpick.Control", + (GDBusMethodInfo **) &_gpick_control_method_info_pointers, + NULL, + NULL, + NULL + }, + "control", +}; + + +/** + * gpick_control_interface_info: + * + * Gets a machine-readable description of the com.google.code.gpick.Control D-Bus interface. + * + * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. + */ +GDBusInterfaceInfo * +gpick_control_interface_info (void) +{ + return (GDBusInterfaceInfo *) &_gpick_control_interface_info; +} + +/** + * gpick_control_override_properties: + * @klass: The class structure for a #GObject-derived class. + * @property_id_begin: The property id to assign to the first overridden property. + * + * Overrides all #GObject properties in the #GpickControl interface for a concrete class. + * The properties are overridden in the order they are defined. + * + * Returns: The last property id. + */ +guint +gpick_control_override_properties (GObjectClass *klass, guint property_id_begin) +{ + return property_id_begin - 1; +} + + + +/** + * GpickControl: + * + * Abstract interface type for the D-Bus interface com.google.code.gpick.Control. + */ + +/** + * GpickControlIface: + * @parent_iface: The parent interface. + * @handle_activate_floating_picker: Handler for the #GpickControl::handle-activate-floating-picker signal. + * + * Virtual table for the D-Bus interface com.google.code.gpick.Control. + */ + +static void +gpick_control_default_init (GpickControlIface *iface) +{ + /* GObject signals for incoming D-Bus method calls: */ + /** + * GpickControl::handle-activate-floating-picker: + * @object: A #GpickControl. + * @invocation: A #GDBusMethodInvocation. + * + * Signal emitted when a remote caller is invoking the ActivateFloatingPicker() D-Bus method. + * + * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call gpick_control_complete_activate_floating_picker() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. + * + * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. + */ + g_signal_new ("handle-activate-floating-picker", + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GpickControlIface, handle_activate_floating_picker), + g_signal_accumulator_true_handled, + NULL, + g_cclosure_marshal_generic, + G_TYPE_BOOLEAN, + 1, + G_TYPE_DBUS_METHOD_INVOCATION); + +} + +typedef GpickControlIface GpickControlInterface; +G_DEFINE_INTERFACE (GpickControl, gpick_control, G_TYPE_OBJECT); + +/** + * gpick_control_call_activate_floating_picker: + * @proxy: A #GpickControlProxy. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously invokes the ActivateFloatingPicker() D-Bus method on @proxy. + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_control_call_activate_floating_picker_finish() to get the result of the operation. + * + * See gpick_control_call_activate_floating_picker_sync() for the synchronous, blocking version of this method. + */ +void +gpick_control_call_activate_floating_picker ( + GpickControl *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_dbus_proxy_call (G_DBUS_PROXY (proxy), + "ActivateFloatingPicker", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + callback, + user_data); +} + +/** + * gpick_control_call_activate_floating_picker_finish: + * @proxy: A #GpickControlProxy. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_control_call_activate_floating_picker(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with gpick_control_call_activate_floating_picker(). + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +gpick_control_call_activate_floating_picker_finish ( + GpickControl *proxy, + GAsyncResult *res, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * gpick_control_call_activate_floating_picker_sync: + * @proxy: A #GpickControlProxy. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously invokes the ActivateFloatingPicker() D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * + * See gpick_control_call_activate_floating_picker() for the asynchronous version of this method. + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +gpick_control_call_activate_floating_picker_sync ( + GpickControl *proxy, + GCancellable *cancellable, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), + "ActivateFloatingPicker", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * gpick_control_complete_activate_floating_picker: + * @object: A #GpickControl. + * @invocation: (transfer full): A #GDBusMethodInvocation. + * + * Helper function used in service implementations to finish handling invocations of the ActivateFloatingPicker() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * + * This method will free @invocation, you cannot use it afterwards. + */ +void +gpick_control_complete_activate_floating_picker ( + GpickControl *object, + GDBusMethodInvocation *invocation) +{ + g_dbus_method_invocation_return_value (invocation, + g_variant_new ("()")); +} + +/* ------------------------------------------------------------------------ */ + +/** + * GpickControlProxy: + * + * The #GpickControlProxy structure contains only private data and should only be accessed using the provided API. + */ + +/** + * GpickControlProxyClass: + * @parent_class: The parent class. + * + * Class structure for #GpickControlProxy. + */ + +struct _GpickControlProxyPrivate +{ + GData *qdata; +}; + +static void gpick_control_proxy_iface_init (GpickControlIface *iface); + +G_DEFINE_TYPE_WITH_CODE (GpickControlProxy, gpick_control_proxy, G_TYPE_DBUS_PROXY, + G_IMPLEMENT_INTERFACE (GPICK_TYPE_CONTROL, gpick_control_proxy_iface_init)); + +static void +gpick_control_proxy_finalize (GObject *object) +{ + GpickControlProxy *proxy = GPICK_CONTROL_PROXY (object); + g_datalist_clear (&proxy->priv->qdata); + G_OBJECT_CLASS (gpick_control_proxy_parent_class)->finalize (object); +} + +static void +gpick_control_proxy_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ +} + +static void +gpick_control_proxy_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ +} + +static void +gpick_control_proxy_g_signal (GDBusProxy *proxy, + const gchar *sender_name, + const gchar *signal_name, + GVariant *parameters) +{ + _ExtendedGDBusSignalInfo *info; + GVariantIter iter; + GVariant *child; + GValue *paramv; + guint num_params; + guint n; + guint signal_id; + info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_gpick_control_interface_info, signal_name); + if (info == NULL) + return; + num_params = g_variant_n_children (parameters); + paramv = g_new0 (GValue, num_params + 1); + g_value_init (¶mv[0], GPICK_TYPE_CONTROL); + g_value_set_object (¶mv[0], proxy); + g_variant_iter_init (&iter, parameters); + n = 1; + while ((child = g_variant_iter_next_value (&iter)) != NULL) + { + _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1]; + if (arg_info->use_gvariant) + { + g_value_init (¶mv[n], G_TYPE_VARIANT); + g_value_set_variant (¶mv[n], child); + n++; + } + else + g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); + g_variant_unref (child); + } + signal_id = g_signal_lookup (info->signal_name, GPICK_TYPE_CONTROL); + g_signal_emitv (paramv, signal_id, 0, NULL); + for (n = 0; n < num_params + 1; n++) + g_value_unset (¶mv[n]); + g_free (paramv); +} + +static void +gpick_control_proxy_g_properties_changed (GDBusProxy *_proxy, + GVariant *changed_properties, + const gchar *const *invalidated_properties) +{ + GpickControlProxy *proxy = GPICK_CONTROL_PROXY (_proxy); + guint n; + const gchar *key; + GVariantIter *iter; + _ExtendedGDBusPropertyInfo *info; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) + { + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info, key); + g_datalist_remove_data (&proxy->priv->qdata, key); + if (info != NULL) + g_object_notify (G_OBJECT (proxy), info->hyphen_name); + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) + { + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info, invalidated_properties[n]); + g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); + if (info != NULL) + g_object_notify (G_OBJECT (proxy), info->hyphen_name); + } +} + +static void +gpick_control_proxy_init (GpickControlProxy *proxy) +{ + proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, GPICK_TYPE_CONTROL_PROXY, GpickControlProxyPrivate); + g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), gpick_control_interface_info ()); +} + +static void +gpick_control_proxy_class_init (GpickControlProxyClass *klass) +{ + GObjectClass *gobject_class; + GDBusProxyClass *proxy_class; + + g_type_class_add_private (klass, sizeof (GpickControlProxyPrivate)); + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = gpick_control_proxy_finalize; + gobject_class->get_property = gpick_control_proxy_get_property; + gobject_class->set_property = gpick_control_proxy_set_property; + + proxy_class = G_DBUS_PROXY_CLASS (klass); + proxy_class->g_signal = gpick_control_proxy_g_signal; + proxy_class->g_properties_changed = gpick_control_proxy_g_properties_changed; + +} + +static void +gpick_control_proxy_iface_init (GpickControlIface *iface) +{ +} + +/** + * gpick_control_proxy_new: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Asynchronously creates a proxy for the D-Bus interface com.google.code.gpick.Control. See g_dbus_proxy_new() for more details. + * + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_control_proxy_new_finish() to get the result of the operation. + * + * See gpick_control_proxy_new_sync() for the synchronous, blocking version of this constructor. + */ +void +gpick_control_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (GPICK_TYPE_CONTROL_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.Control", NULL); +} + +/** + * gpick_control_proxy_new_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_control_proxy_new(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with gpick_control_proxy_new(). + * + * Returns: (transfer full) (type GpickControlProxy): The constructed proxy object or %NULL if @error is set. + */ +GpickControl * +gpick_control_proxy_new_finish ( + GAsyncResult *res, + GError **error) +{ + GObject *ret; + GObject *source_object; + source_object = g_async_result_get_source_object (res); + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); + g_object_unref (source_object); + if (ret != NULL) + return GPICK_CONTROL (ret); + else + return NULL; +} + +/** + * gpick_control_proxy_new_sync: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Synchronously creates a proxy for the D-Bus interface com.google.code.gpick.Control. See g_dbus_proxy_new_sync() for more details. + * + * The calling thread is blocked until a reply is received. + * + * See gpick_control_proxy_new() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type GpickControlProxy): The constructed proxy object or %NULL if @error is set. + */ +GpickControl * +gpick_control_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + ret = g_initable_new (GPICK_TYPE_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.Control", NULL); + if (ret != NULL) + return GPICK_CONTROL (ret); + else + return NULL; +} + + +/** + * gpick_control_proxy_new_for_bus: + * @bus_type: A #GBusType. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: A bus name (well-known or unique). + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Like gpick_control_proxy_new() but takes a #GBusType instead of a #GDBusConnection. + * + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_control_proxy_new_for_bus_finish() to get the result of the operation. + * + * See gpick_control_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor. + */ +void +gpick_control_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (GPICK_TYPE_CONTROL_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.Control", NULL); +} + +/** + * gpick_control_proxy_new_for_bus_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_control_proxy_new_for_bus(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with gpick_control_proxy_new_for_bus(). + * + * Returns: (transfer full) (type GpickControlProxy): The constructed proxy object or %NULL if @error is set. + */ +GpickControl * +gpick_control_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error) +{ + GObject *ret; + GObject *source_object; + source_object = g_async_result_get_source_object (res); + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); + g_object_unref (source_object); + if (ret != NULL) + return GPICK_CONTROL (ret); + else + return NULL; +} + +/** + * gpick_control_proxy_new_for_bus_sync: + * @bus_type: A #GBusType. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: A bus name (well-known or unique). + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Like gpick_control_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. + * + * The calling thread is blocked until a reply is received. + * + * See gpick_control_proxy_new_for_bus() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type GpickControlProxy): The constructed proxy object or %NULL if @error is set. + */ +GpickControl * +gpick_control_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + ret = g_initable_new (GPICK_TYPE_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.Control", NULL); + if (ret != NULL) + return GPICK_CONTROL (ret); + else + return NULL; +} + + +/* ------------------------------------------------------------------------ */ + +/** + * GpickControlSkeleton: + * + * The #GpickControlSkeleton structure contains only private data and should only be accessed using the provided API. + */ + +/** + * GpickControlSkeletonClass: + * @parent_class: The parent class. + * + * Class structure for #GpickControlSkeleton. + */ + +struct _GpickControlSkeletonPrivate +{ + GValue *properties; + GList *changed_properties; + GSource *changed_properties_idle_source; + GMainContext *context; + GMutex lock; +}; + +static void +_gpick_control_skeleton_handle_method_call ( + GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + GpickControlSkeleton *skeleton = GPICK_CONTROL_SKELETON (user_data); + _ExtendedGDBusMethodInfo *info; + GVariantIter iter; + GVariant *child; + GValue *paramv; + guint num_params; + guint num_extra; + guint n; + guint signal_id; + GValue return_value = G_VALUE_INIT; + info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation); + g_assert (info != NULL); + num_params = g_variant_n_children (parameters); + num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra); + n = 0; + g_value_init (¶mv[n], GPICK_TYPE_CONTROL); + g_value_set_object (¶mv[n++], skeleton); + g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION); + g_value_set_object (¶mv[n++], invocation); + if (info->pass_fdlist) + { +#ifdef G_OS_UNIX + g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST); + g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation))); +#else + g_assert_not_reached (); +#endif + } + g_variant_iter_init (&iter, parameters); + while ((child = g_variant_iter_next_value (&iter)) != NULL) + { + _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra]; + if (arg_info->use_gvariant) + { + g_value_init (¶mv[n], G_TYPE_VARIANT); + g_value_set_variant (¶mv[n], child); + n++; + } + else + g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); + g_variant_unref (child); + } + signal_id = g_signal_lookup (info->signal_name, GPICK_TYPE_CONTROL); + g_value_init (&return_value, G_TYPE_BOOLEAN); + g_signal_emitv (paramv, signal_id, 0, &return_value); + if (!g_value_get_boolean (&return_value)) + g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name); + g_value_unset (&return_value); + for (n = 0; n < num_params + num_extra; n++) + g_value_unset (¶mv[n]); + g_free (paramv); +} + +static GVariant * +_gpick_control_skeleton_handle_get_property ( + GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GError **error, + gpointer user_data) +{ + GpickControlSkeleton *skeleton = GPICK_CONTROL_SKELETON (user_data); + GValue value = G_VALUE_INIT; + GParamSpec *pspec; + _ExtendedGDBusPropertyInfo *info; + GVariant *ret; + ret = NULL; + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info, property_name); + g_assert (info != NULL); + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); + if (pspec == NULL) + { + g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); + } + else + { + g_value_init (&value, pspec->value_type); + g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value); + ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)); + g_value_unset (&value); + } + return ret; +} + +static gboolean +_gpick_control_skeleton_handle_set_property ( + GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GVariant *variant, + GError **error, + gpointer user_data) +{ + GpickControlSkeleton *skeleton = GPICK_CONTROL_SKELETON (user_data); + GValue value = G_VALUE_INIT; + GParamSpec *pspec; + _ExtendedGDBusPropertyInfo *info; + gboolean ret; + ret = FALSE; + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info, property_name); + g_assert (info != NULL); + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); + if (pspec == NULL) + { + g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); + } + else + { + if (info->use_gvariant) + g_value_set_variant (&value, variant); + else + g_dbus_gvariant_to_gvalue (variant, &value); + g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value); + g_value_unset (&value); + ret = TRUE; + } + return ret; +} + +static const GDBusInterfaceVTable _gpick_control_skeleton_vtable = +{ + _gpick_control_skeleton_handle_method_call, + _gpick_control_skeleton_handle_get_property, + _gpick_control_skeleton_handle_set_property +}; + +static GDBusInterfaceInfo * +gpick_control_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton) +{ + return gpick_control_interface_info (); +} + +static GDBusInterfaceVTable * +gpick_control_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton) +{ + return (GDBusInterfaceVTable *) &_gpick_control_skeleton_vtable; +} + +static GVariant * +gpick_control_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton) +{ + GpickControlSkeleton *skeleton = GPICK_CONTROL_SKELETON (_skeleton); + + GVariantBuilder builder; + guint n; + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + if (_gpick_control_interface_info.parent_struct.properties == NULL) + goto out; + for (n = 0; _gpick_control_interface_info.parent_struct.properties[n] != NULL; n++) + { + GDBusPropertyInfo *info = _gpick_control_interface_info.parent_struct.properties[n]; + if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) + { + GVariant *value; + value = _gpick_control_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "com.google.code.gpick.Control", info->name, NULL, skeleton); + if (value != NULL) + { + g_variant_take_ref (value); + g_variant_builder_add (&builder, "{sv}", info->name, value); + g_variant_unref (value); + } + } + } +out: + return g_variant_builder_end (&builder); +} + +static void +gpick_control_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) +{ +} + +static void gpick_control_skeleton_iface_init (GpickControlIface *iface); +G_DEFINE_TYPE_WITH_CODE (GpickControlSkeleton, gpick_control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, + G_IMPLEMENT_INTERFACE (GPICK_TYPE_CONTROL, gpick_control_skeleton_iface_init)); + +static void +gpick_control_skeleton_finalize (GObject *object) +{ + GpickControlSkeleton *skeleton = GPICK_CONTROL_SKELETON (object); + g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); + if (skeleton->priv->changed_properties_idle_source != NULL) + g_source_destroy (skeleton->priv->changed_properties_idle_source); + g_main_context_unref (skeleton->priv->context); + g_mutex_clear (&skeleton->priv->lock); + G_OBJECT_CLASS (gpick_control_skeleton_parent_class)->finalize (object); +} + +static void +gpick_control_skeleton_init (GpickControlSkeleton *skeleton) +{ + skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, GPICK_TYPE_CONTROL_SKELETON, GpickControlSkeletonPrivate); + g_mutex_init (&skeleton->priv->lock); + skeleton->priv->context = g_main_context_ref_thread_default (); +} + +static void +gpick_control_skeleton_class_init (GpickControlSkeletonClass *klass) +{ + GObjectClass *gobject_class; + GDBusInterfaceSkeletonClass *skeleton_class; + + g_type_class_add_private (klass, sizeof (GpickControlSkeletonPrivate)); + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = gpick_control_skeleton_finalize; + + skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass); + skeleton_class->get_info = gpick_control_skeleton_dbus_interface_get_info; + skeleton_class->get_properties = gpick_control_skeleton_dbus_interface_get_properties; + skeleton_class->flush = gpick_control_skeleton_dbus_interface_flush; + skeleton_class->get_vtable = gpick_control_skeleton_dbus_interface_get_vtable; +} + +static void +gpick_control_skeleton_iface_init (GpickControlIface *iface) +{ +} + +/** + * gpick_control_skeleton_new: + * + * Creates a skeleton object for the D-Bus interface com.google.code.gpick.Control. + * + * Returns: (transfer full) (type GpickControlSkeleton): The skeleton object. + */ +GpickControl * +gpick_control_skeleton_new (void) +{ + return GPICK_CONTROL (g_object_new (GPICK_TYPE_CONTROL_SKELETON, NULL)); +} + +/* ------------------------------------------------------------------------ + * Code for Object, ObjectProxy and ObjectSkeleton + * ------------------------------------------------------------------------ + */ + +/** + * SECTION:GpickObject + * @title: GpickObject + * @short_description: Specialized GDBusObject types + * + * This section contains the #GpickObject, #GpickObjectProxy, and #GpickObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces. + */ + +/** + * GpickObject: + * + * The #GpickObject type is a specialized container of interfaces. + */ + +/** + * GpickObjectIface: + * @parent_iface: The parent interface. + * + * Virtual table for the #GpickObject interface. + */ + +static void +gpick_object_default_init (GpickObjectIface *iface) +{ + /** + * GpickObject:single-instance: + * + * The #GpickSingleInstance instance corresponding to the D-Bus interface com.google.code.gpick.SingleInstance, if any. + * + * Connect to the #GObject::notify signal to get informed of property changes. + */ + g_object_interface_install_property (iface, g_param_spec_object ("single-instance", "single-instance", "single-instance", GPICK_TYPE_SINGLE_INSTANCE, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS)); + + /** + * GpickObject:control: + * + * The #GpickControl instance corresponding to the D-Bus interface com.google.code.gpick.Control, if any. + * + * Connect to the #GObject::notify signal to get informed of property changes. + */ + g_object_interface_install_property (iface, g_param_spec_object ("control", "control", "control", GPICK_TYPE_CONTROL, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS)); + +} + +typedef GpickObjectIface GpickObjectInterface; +G_DEFINE_INTERFACE_WITH_CODE (GpickObject, gpick_object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT)); + +/** + * gpick_object_get_single_instance: + * @object: A #GpickObject. + * + * Gets the #GpickSingleInstance instance for the D-Bus interface com.google.code.gpick.SingleInstance on @object, if any. + * + * Returns: (transfer full): A #GpickSingleInstance that must be freed with g_object_unref() or %NULL if @object does not implement the interface. + */ +GpickSingleInstance *gpick_object_get_single_instance (GpickObject *object) +{ + GDBusInterface *ret; + ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.SingleInstance"); + if (ret == NULL) + return NULL; + return GPICK_SINGLE_INSTANCE (ret); +} + +/** + * gpick_object_get_control: + * @object: A #GpickObject. + * + * Gets the #GpickControl instance for the D-Bus interface com.google.code.gpick.Control on @object, if any. + * + * Returns: (transfer full): A #GpickControl that must be freed with g_object_unref() or %NULL if @object does not implement the interface. + */ +GpickControl *gpick_object_get_control (GpickObject *object) +{ + GDBusInterface *ret; + ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.Control"); + if (ret == NULL) + return NULL; + return GPICK_CONTROL (ret); +} + + +/** + * gpick_object_peek_single_instance: (skip) + * @object: A #GpickObject. + * + * Like gpick_object_get_single_instance() but doesn't increase the reference count on the returned object. + * + * It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running. + * + * Returns: (transfer none): A #GpickSingleInstance or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object. + */ +GpickSingleInstance *gpick_object_peek_single_instance (GpickObject *object) +{ + GDBusInterface *ret; + ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.SingleInstance"); + if (ret == NULL) + return NULL; + g_object_unref (ret); + return GPICK_SINGLE_INSTANCE (ret); +} + +/** + * gpick_object_peek_control: (skip) + * @object: A #GpickObject. + * + * Like gpick_object_get_control() but doesn't increase the reference count on the returned object. + * + * It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running. + * + * Returns: (transfer none): A #GpickControl or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object. + */ +GpickControl *gpick_object_peek_control (GpickObject *object) +{ + GDBusInterface *ret; + ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.Control"); + if (ret == NULL) + return NULL; + g_object_unref (ret); + return GPICK_CONTROL (ret); +} + + +static void +gpick_object_notify (GDBusObject *object, GDBusInterface *interface) +{ + g_object_notify (G_OBJECT (object), ((_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface))->hyphen_name); +} + +/** + * GpickObjectProxy: + * + * The #GpickObjectProxy structure contains only private data and should only be accessed using the provided API. + */ + +/** + * GpickObjectProxyClass: + * @parent_class: The parent class. + * + * Class structure for #GpickObjectProxy. + */ + +static void +gpick_object_proxy__gpick_object_iface_init (GpickObjectIface *iface) +{ +} + +static void +gpick_object_proxy__g_dbus_object_iface_init (GDBusObjectIface *iface) +{ + iface->interface_added = gpick_object_notify; + iface->interface_removed = gpick_object_notify; +} + + +G_DEFINE_TYPE_WITH_CODE (GpickObjectProxy, gpick_object_proxy, G_TYPE_DBUS_OBJECT_PROXY, + G_IMPLEMENT_INTERFACE (GPICK_TYPE_OBJECT, gpick_object_proxy__gpick_object_iface_init) + G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, gpick_object_proxy__g_dbus_object_iface_init)); + +static void +gpick_object_proxy_init (GpickObjectProxy *object) +{ +} + +static void +gpick_object_proxy_set_property (GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); +} + +static void +gpick_object_proxy_get_property (GObject *gobject, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GpickObjectProxy *object = GPICK_OBJECT_PROXY (gobject); + GDBusInterface *interface; + + switch (prop_id) + { + case 1: + interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.SingleInstance"); + g_value_take_object (value, interface); + break; + + case 2: + interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.Control"); + g_value_take_object (value, interface); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + break; + } +} + +static void +gpick_object_proxy_class_init (GpickObjectProxyClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->set_property = gpick_object_proxy_set_property; + gobject_class->get_property = gpick_object_proxy_get_property; + + g_object_class_override_property (gobject_class, 1, "single-instance"); + g_object_class_override_property (gobject_class, 2, "control"); +} + +/** + * gpick_object_proxy_new: + * @connection: A #GDBusConnection. + * @object_path: An object path. + * + * Creates a new proxy object. + * + * Returns: (transfer full): The proxy object. + */ +GpickObjectProxy * +gpick_object_proxy_new (GDBusConnection *connection, + const gchar *object_path) +{ + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); + g_return_val_if_fail (g_variant_is_object_path (object_path), NULL); + return GPICK_OBJECT_PROXY (g_object_new (GPICK_TYPE_OBJECT_PROXY, "g-connection", connection, "g-object-path", object_path, NULL)); +} + +/** + * GpickObjectSkeleton: + * + * The #GpickObjectSkeleton structure contains only private data and should only be accessed using the provided API. + */ + +/** + * GpickObjectSkeletonClass: + * @parent_class: The parent class. + * + * Class structure for #GpickObjectSkeleton. + */ + +static void +gpick_object_skeleton__gpick_object_iface_init (GpickObjectIface *iface) +{ +} + + +static void +gpick_object_skeleton__g_dbus_object_iface_init (GDBusObjectIface *iface) +{ + iface->interface_added = gpick_object_notify; + iface->interface_removed = gpick_object_notify; +} + +G_DEFINE_TYPE_WITH_CODE (GpickObjectSkeleton, gpick_object_skeleton, G_TYPE_DBUS_OBJECT_SKELETON, + G_IMPLEMENT_INTERFACE (GPICK_TYPE_OBJECT, gpick_object_skeleton__gpick_object_iface_init) + G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, gpick_object_skeleton__g_dbus_object_iface_init)); + +static void +gpick_object_skeleton_init (GpickObjectSkeleton *object) +{ +} + +static void +gpick_object_skeleton_set_property (GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GpickObjectSkeleton *object = GPICK_OBJECT_SKELETON (gobject); + GDBusInterfaceSkeleton *interface; + + switch (prop_id) + { + case 1: + interface = g_value_get_object (value); + if (interface != NULL) + { + g_warn_if_fail (GPICK_IS_SINGLE_INSTANCE (interface)); + g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface); + } + else + { + g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "com.google.code.gpick.SingleInstance"); + } + break; + + case 2: + interface = g_value_get_object (value); + if (interface != NULL) + { + g_warn_if_fail (GPICK_IS_CONTROL (interface)); + g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface); + } + else + { + g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "com.google.code.gpick.Control"); + } + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + break; + } +} + +static void +gpick_object_skeleton_get_property (GObject *gobject, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GpickObjectSkeleton *object = GPICK_OBJECT_SKELETON (gobject); + GDBusInterface *interface; + + switch (prop_id) + { + case 1: + interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.SingleInstance"); + g_value_take_object (value, interface); + break; + + case 2: + interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.Control"); + g_value_take_object (value, interface); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + break; + } +} + +static void +gpick_object_skeleton_class_init (GpickObjectSkeletonClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->set_property = gpick_object_skeleton_set_property; + gobject_class->get_property = gpick_object_skeleton_get_property; + + g_object_class_override_property (gobject_class, 1, "single-instance"); + g_object_class_override_property (gobject_class, 2, "control"); +} + +/** + * gpick_object_skeleton_new: + * @object_path: An object path. + * + * Creates a new skeleton object. + * + * Returns: (transfer full): The skeleton object. + */ +GpickObjectSkeleton * +gpick_object_skeleton_new (const gchar *object_path) +{ + g_return_val_if_fail (g_variant_is_object_path (object_path), NULL); + return GPICK_OBJECT_SKELETON (g_object_new (GPICK_TYPE_OBJECT_SKELETON, "g-object-path", object_path, NULL)); +} + +/** + * gpick_object_skeleton_set_single_instance: + * @object: A #GpickObjectSkeleton. + * @interface_: (allow-none): A #GpickSingleInstance or %NULL to clear the interface. + * + * Sets the #GpickSingleInstance instance for the D-Bus interface com.google.code.gpick.SingleInstance on @object. + */ +void gpick_object_skeleton_set_single_instance (GpickObjectSkeleton *object, GpickSingleInstance *interface_) +{ + g_object_set (G_OBJECT (object), "single-instance", interface_, NULL); +} + +/** + * gpick_object_skeleton_set_control: + * @object: A #GpickObjectSkeleton. + * @interface_: (allow-none): A #GpickControl or %NULL to clear the interface. + * + * Sets the #GpickControl instance for the D-Bus interface com.google.code.gpick.Control on @object. + */ +void gpick_object_skeleton_set_control (GpickObjectSkeleton *object, GpickControl *interface_) +{ + g_object_set (G_OBJECT (object), "control", interface_, NULL); +} + + +/* ------------------------------------------------------------------------ + * Code for ObjectManager client + * ------------------------------------------------------------------------ + */ + +/** + * SECTION:GpickObjectManagerClient + * @title: GpickObjectManagerClient + * @short_description: Generated GDBusObjectManagerClient type + * + * This section contains a #GDBusObjectManagerClient that uses gpick_object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. + */ + +/** + * GpickObjectManagerClient: + * + * The #GpickObjectManagerClient structure contains only private data and should only be accessed using the provided API. + */ + +/** + * GpickObjectManagerClientClass: + * @parent_class: The parent class. + * + * Class structure for #GpickObjectManagerClient. + */ + +G_DEFINE_TYPE (GpickObjectManagerClient, gpick_object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT); + +static void +gpick_object_manager_client_init (GpickObjectManagerClient *manager) +{ +} + +static void +gpick_object_manager_client_class_init (GpickObjectManagerClientClass *klass) +{ +} + +/** + * gpick_object_manager_client_get_proxy_type: + * @manager: A #GDBusObjectManagerClient. + * @object_path: The object path of the remote object (unused). + * @interface_name: (allow-none): Interface name of the remote object or %NULL to get the object proxy #GType. + * @user_data: User data (unused). + * + * A #GDBusProxyTypeFunc that maps @interface_name to the generated #GDBusObjectProxy- and #GDBusProxy-derived types. + * + * Returns: A #GDBusProxy-derived #GType if @interface_name is not %NULL, otherwise the #GType for #GpickObjectProxy. + */ +GType +gpick_object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data) +{ + static gsize once_init_value = 0; + static GHashTable *lookup_hash; + GType ret; + + if (interface_name == NULL) + return GPICK_TYPE_OBJECT_PROXY; + if (g_once_init_enter (&once_init_value)) + { + lookup_hash = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (lookup_hash, "com.google.code.gpick.SingleInstance", GSIZE_TO_POINTER (GPICK_TYPE_SINGLE_INSTANCE_PROXY)); + g_hash_table_insert (lookup_hash, "com.google.code.gpick.Control", GSIZE_TO_POINTER (GPICK_TYPE_CONTROL_PROXY)); + g_once_init_leave (&once_init_value, 1); + } + ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name)); + if (ret == (GType) 0) + ret = G_TYPE_DBUS_PROXY; + return ret; +} + +/** + * gpick_object_manager_client_new: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. + * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Asynchronously creates #GDBusObjectManagerClient using gpick_object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details. + * + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_object_manager_client_new_finish() to get the result of the operation. + * + * See gpick_object_manager_client_new_sync() for the synchronous, blocking version of this constructor. + */ +void +gpick_object_manager_client_new ( + GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (GPICK_TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", gpick_object_manager_client_get_proxy_type, NULL); +} + +/** + * gpick_object_manager_client_new_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_object_manager_client_new(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with gpick_object_manager_client_new(). + * + * Returns: (transfer full) (type GpickObjectManagerClient): The constructed object manager client or %NULL if @error is set. + */ +GDBusObjectManager * +gpick_object_manager_client_new_finish ( + GAsyncResult *res, + GError **error) +{ + GObject *ret; + GObject *source_object; + source_object = g_async_result_get_source_object (res); + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); + g_object_unref (source_object); + if (ret != NULL) + return G_DBUS_OBJECT_MANAGER (ret); + else + return NULL; +} + +/** + * gpick_object_manager_client_new_sync: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. + * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Synchronously creates #GDBusObjectManagerClient using gpick_object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details. + * + * The calling thread is blocked until a reply is received. + * + * See gpick_object_manager_client_new() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type GpickObjectManagerClient): The constructed object manager client or %NULL if @error is set. + */ +GDBusObjectManager * +gpick_object_manager_client_new_sync ( + GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + ret = g_initable_new (GPICK_TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", gpick_object_manager_client_get_proxy_type, NULL); + if (ret != NULL) + return G_DBUS_OBJECT_MANAGER (ret); + else + return NULL; +} + + +/** + * gpick_object_manager_client_new_for_bus: + * @bus_type: A #GBusType. + * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. + * @name: A bus name (well-known or unique). + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Like gpick_object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection. + * + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_object_manager_client_new_for_bus_finish() to get the result of the operation. + * + * See gpick_object_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor. + */ +void +gpick_object_manager_client_new_for_bus ( + GBusType bus_type, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (GPICK_TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", gpick_object_manager_client_get_proxy_type, NULL); +} + +/** + * gpick_object_manager_client_new_for_bus_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_object_manager_client_new_for_bus(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with gpick_object_manager_client_new_for_bus(). + * + * Returns: (transfer full) (type GpickObjectManagerClient): The constructed object manager client or %NULL if @error is set. + */ +GDBusObjectManager * +gpick_object_manager_client_new_for_bus_finish ( + GAsyncResult *res, + GError **error) +{ + GObject *ret; + GObject *source_object; + source_object = g_async_result_get_source_object (res); + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); + g_object_unref (source_object); + if (ret != NULL) + return G_DBUS_OBJECT_MANAGER (ret); + else + return NULL; +} + +/** + * gpick_object_manager_client_new_for_bus_sync: + * @bus_type: A #GBusType. + * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. + * @name: A bus name (well-known or unique). + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Like gpick_object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection. + * + * The calling thread is blocked until a reply is received. + * + * See gpick_object_manager_client_new_for_bus() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type GpickObjectManagerClient): The constructed object manager client or %NULL if @error is set. + */ +GDBusObjectManager * +gpick_object_manager_client_new_for_bus_sync ( + GBusType bus_type, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + ret = g_initable_new (GPICK_TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", gpick_object_manager_client_get_proxy_type, NULL); + if (ret != NULL) + return G_DBUS_OBJECT_MANAGER (ret); + else + return NULL; +} + + diff -Nru gpick-0.2.4/source/dbus/DbusInterface.h gpick-0.2.5/source/dbus/DbusInterface.h --- gpick-0.2.4/source/dbus/DbusInterface.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/dbus/DbusInterface.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,462 @@ +/* + * Generated by gdbus-codegen 2.32.3. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifndef __DBUSINTERFACE_H__ +#define __DBUSINTERFACE_H__ + +#include + +G_BEGIN_DECLS + + +/* ------------------------------------------------------------------------ */ +/* Declarations for com.google.code.gpick.SingleInstance */ + +#define GPICK_TYPE_SINGLE_INSTANCE (gpick_single_instance_get_type ()) +#define GPICK_SINGLE_INSTANCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_SINGLE_INSTANCE, GpickSingleInstance)) +#define GPICK_IS_SINGLE_INSTANCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_SINGLE_INSTANCE)) +#define GPICK_SINGLE_INSTANCE_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GPICK_TYPE_SINGLE_INSTANCE, GpickSingleInstanceIface)) + +struct _GpickSingleInstance; +typedef struct _GpickSingleInstance GpickSingleInstance; +typedef struct _GpickSingleInstanceIface GpickSingleInstanceIface; + +struct _GpickSingleInstanceIface +{ + GTypeInterface parent_iface; + + gboolean (*handle_activate) ( + GpickSingleInstance *object, + GDBusMethodInvocation *invocation); + +}; + +GType gpick_single_instance_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *gpick_single_instance_interface_info (void); +guint gpick_single_instance_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void gpick_single_instance_complete_activate ( + GpickSingleInstance *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void gpick_single_instance_call_activate ( + GpickSingleInstance *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean gpick_single_instance_call_activate_finish ( + GpickSingleInstance *proxy, + GAsyncResult *res, + GError **error); + +gboolean gpick_single_instance_call_activate_sync ( + GpickSingleInstance *proxy, + GCancellable *cancellable, + GError **error); + + + +/* ---- */ + +#define GPICK_TYPE_SINGLE_INSTANCE_PROXY (gpick_single_instance_proxy_get_type ()) +#define GPICK_SINGLE_INSTANCE_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_SINGLE_INSTANCE_PROXY, GpickSingleInstanceProxy)) +#define GPICK_SINGLE_INSTANCE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GPICK_TYPE_SINGLE_INSTANCE_PROXY, GpickSingleInstanceProxyClass)) +#define GPICK_SINGLE_INSTANCE_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPICK_TYPE_SINGLE_INSTANCE_PROXY, GpickSingleInstanceProxyClass)) +#define GPICK_IS_SINGLE_INSTANCE_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_SINGLE_INSTANCE_PROXY)) +#define GPICK_IS_SINGLE_INSTANCE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPICK_TYPE_SINGLE_INSTANCE_PROXY)) + +typedef struct _GpickSingleInstanceProxy GpickSingleInstanceProxy; +typedef struct _GpickSingleInstanceProxyClass GpickSingleInstanceProxyClass; +typedef struct _GpickSingleInstanceProxyPrivate GpickSingleInstanceProxyPrivate; + +struct _GpickSingleInstanceProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + GpickSingleInstanceProxyPrivate *priv; +}; + +struct _GpickSingleInstanceProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType gpick_single_instance_proxy_get_type (void) G_GNUC_CONST; + +void gpick_single_instance_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GpickSingleInstance *gpick_single_instance_proxy_new_finish ( + GAsyncResult *res, + GError **error); +GpickSingleInstance *gpick_single_instance_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void gpick_single_instance_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GpickSingleInstance *gpick_single_instance_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +GpickSingleInstance *gpick_single_instance_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define GPICK_TYPE_SINGLE_INSTANCE_SKELETON (gpick_single_instance_skeleton_get_type ()) +#define GPICK_SINGLE_INSTANCE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_SINGLE_INSTANCE_SKELETON, GpickSingleInstanceSkeleton)) +#define GPICK_SINGLE_INSTANCE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GPICK_TYPE_SINGLE_INSTANCE_SKELETON, GpickSingleInstanceSkeletonClass)) +#define GPICK_SINGLE_INSTANCE_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPICK_TYPE_SINGLE_INSTANCE_SKELETON, GpickSingleInstanceSkeletonClass)) +#define GPICK_IS_SINGLE_INSTANCE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_SINGLE_INSTANCE_SKELETON)) +#define GPICK_IS_SINGLE_INSTANCE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPICK_TYPE_SINGLE_INSTANCE_SKELETON)) + +typedef struct _GpickSingleInstanceSkeleton GpickSingleInstanceSkeleton; +typedef struct _GpickSingleInstanceSkeletonClass GpickSingleInstanceSkeletonClass; +typedef struct _GpickSingleInstanceSkeletonPrivate GpickSingleInstanceSkeletonPrivate; + +struct _GpickSingleInstanceSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + GpickSingleInstanceSkeletonPrivate *priv; +}; + +struct _GpickSingleInstanceSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType gpick_single_instance_skeleton_get_type (void) G_GNUC_CONST; + +GpickSingleInstance *gpick_single_instance_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for com.google.code.gpick.Control */ + +#define GPICK_TYPE_CONTROL (gpick_control_get_type ()) +#define GPICK_CONTROL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_CONTROL, GpickControl)) +#define GPICK_IS_CONTROL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_CONTROL)) +#define GPICK_CONTROL_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GPICK_TYPE_CONTROL, GpickControlIface)) + +struct _GpickControl; +typedef struct _GpickControl GpickControl; +typedef struct _GpickControlIface GpickControlIface; + +struct _GpickControlIface +{ + GTypeInterface parent_iface; + + gboolean (*handle_activate_floating_picker) ( + GpickControl *object, + GDBusMethodInvocation *invocation); + +}; + +GType gpick_control_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *gpick_control_interface_info (void); +guint gpick_control_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void gpick_control_complete_activate_floating_picker ( + GpickControl *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void gpick_control_call_activate_floating_picker ( + GpickControl *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean gpick_control_call_activate_floating_picker_finish ( + GpickControl *proxy, + GAsyncResult *res, + GError **error); + +gboolean gpick_control_call_activate_floating_picker_sync ( + GpickControl *proxy, + GCancellable *cancellable, + GError **error); + + + +/* ---- */ + +#define GPICK_TYPE_CONTROL_PROXY (gpick_control_proxy_get_type ()) +#define GPICK_CONTROL_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_CONTROL_PROXY, GpickControlProxy)) +#define GPICK_CONTROL_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GPICK_TYPE_CONTROL_PROXY, GpickControlProxyClass)) +#define GPICK_CONTROL_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPICK_TYPE_CONTROL_PROXY, GpickControlProxyClass)) +#define GPICK_IS_CONTROL_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_CONTROL_PROXY)) +#define GPICK_IS_CONTROL_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPICK_TYPE_CONTROL_PROXY)) + +typedef struct _GpickControlProxy GpickControlProxy; +typedef struct _GpickControlProxyClass GpickControlProxyClass; +typedef struct _GpickControlProxyPrivate GpickControlProxyPrivate; + +struct _GpickControlProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + GpickControlProxyPrivate *priv; +}; + +struct _GpickControlProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType gpick_control_proxy_get_type (void) G_GNUC_CONST; + +void gpick_control_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GpickControl *gpick_control_proxy_new_finish ( + GAsyncResult *res, + GError **error); +GpickControl *gpick_control_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void gpick_control_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GpickControl *gpick_control_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +GpickControl *gpick_control_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define GPICK_TYPE_CONTROL_SKELETON (gpick_control_skeleton_get_type ()) +#define GPICK_CONTROL_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_CONTROL_SKELETON, GpickControlSkeleton)) +#define GPICK_CONTROL_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GPICK_TYPE_CONTROL_SKELETON, GpickControlSkeletonClass)) +#define GPICK_CONTROL_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPICK_TYPE_CONTROL_SKELETON, GpickControlSkeletonClass)) +#define GPICK_IS_CONTROL_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_CONTROL_SKELETON)) +#define GPICK_IS_CONTROL_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPICK_TYPE_CONTROL_SKELETON)) + +typedef struct _GpickControlSkeleton GpickControlSkeleton; +typedef struct _GpickControlSkeletonClass GpickControlSkeletonClass; +typedef struct _GpickControlSkeletonPrivate GpickControlSkeletonPrivate; + +struct _GpickControlSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + GpickControlSkeletonPrivate *priv; +}; + +struct _GpickControlSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType gpick_control_skeleton_get_type (void) G_GNUC_CONST; + +GpickControl *gpick_control_skeleton_new (void); + + +/* ---- */ + +#define GPICK_TYPE_OBJECT (gpick_object_get_type ()) +#define GPICK_OBJECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_OBJECT, GpickObject)) +#define GPICK_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_OBJECT)) +#define GPICK_OBJECT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GPICK_TYPE_OBJECT, GpickObject)) + +struct _GpickObject; +typedef struct _GpickObject GpickObject; +typedef struct _GpickObjectIface GpickObjectIface; + +struct _GpickObjectIface +{ + GTypeInterface parent_iface; +}; + +GType gpick_object_get_type (void) G_GNUC_CONST; + +GpickSingleInstance *gpick_object_get_single_instance (GpickObject *object); +GpickControl *gpick_object_get_control (GpickObject *object); +GpickSingleInstance *gpick_object_peek_single_instance (GpickObject *object); +GpickControl *gpick_object_peek_control (GpickObject *object); + +#define GPICK_TYPE_OBJECT_PROXY (gpick_object_proxy_get_type ()) +#define GPICK_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_OBJECT_PROXY, GpickObjectProxy)) +#define GPICK_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GPICK_TYPE_OBJECT_PROXY, GpickObjectProxyClass)) +#define GPICK_OBJECT_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPICK_TYPE_OBJECT_PROXY, GpickObjectProxyClass)) +#define GPICK_IS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_OBJECT_PROXY)) +#define GPICK_IS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPICK_TYPE_OBJECT_PROXY)) + +typedef struct _GpickObjectProxy GpickObjectProxy; +typedef struct _GpickObjectProxyClass GpickObjectProxyClass; +typedef struct _GpickObjectProxyPrivate GpickObjectProxyPrivate; + +struct _GpickObjectProxy +{ + /*< private >*/ + GDBusObjectProxy parent_instance; + GpickObjectProxyPrivate *priv; +}; + +struct _GpickObjectProxyClass +{ + GDBusObjectProxyClass parent_class; +}; + +GType gpick_object_proxy_get_type (void) G_GNUC_CONST; +GpickObjectProxy *gpick_object_proxy_new (GDBusConnection *connection, const gchar *object_path); + +#define GPICK_TYPE_OBJECT_SKELETON (gpick_object_skeleton_get_type ()) +#define GPICK_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_OBJECT_SKELETON, GpickObjectSkeleton)) +#define GPICK_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GPICK_TYPE_OBJECT_SKELETON, GpickObjectSkeletonClass)) +#define GPICK_OBJECT_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPICK_TYPE_OBJECT_SKELETON, GpickObjectSkeletonClass)) +#define GPICK_IS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_OBJECT_SKELETON)) +#define GPICK_IS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPICK_TYPE_OBJECT_SKELETON)) + +typedef struct _GpickObjectSkeleton GpickObjectSkeleton; +typedef struct _GpickObjectSkeletonClass GpickObjectSkeletonClass; +typedef struct _GpickObjectSkeletonPrivate GpickObjectSkeletonPrivate; + +struct _GpickObjectSkeleton +{ + /*< private >*/ + GDBusObjectSkeleton parent_instance; + GpickObjectSkeletonPrivate *priv; +}; + +struct _GpickObjectSkeletonClass +{ + GDBusObjectSkeletonClass parent_class; +}; + +GType gpick_object_skeleton_get_type (void) G_GNUC_CONST; +GpickObjectSkeleton *gpick_object_skeleton_new (const gchar *object_path); +void gpick_object_skeleton_set_single_instance (GpickObjectSkeleton *object, GpickSingleInstance *interface_); +void gpick_object_skeleton_set_control (GpickObjectSkeleton *object, GpickControl *interface_); + +/* ---- */ + +#define GPICK_TYPE_OBJECT_MANAGER_CLIENT (gpick_object_manager_client_get_type ()) +#define GPICK_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_OBJECT_MANAGER_CLIENT, GpickObjectManagerClient)) +#define GPICK_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GPICK_TYPE_OBJECT_MANAGER_CLIENT, GpickObjectManagerClientClass)) +#define GPICK_OBJECT_MANAGER_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPICK_TYPE_OBJECT_MANAGER_CLIENT, GpickObjectManagerClientClass)) +#define GPICK_IS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPICK_TYPE_OBJECT_MANAGER_CLIENT)) +#define GPICK_IS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPICK_TYPE_OBJECT_MANAGER_CLIENT)) + +typedef struct _GpickObjectManagerClient GpickObjectManagerClient; +typedef struct _GpickObjectManagerClientClass GpickObjectManagerClientClass; +typedef struct _GpickObjectManagerClientPrivate GpickObjectManagerClientPrivate; + +struct _GpickObjectManagerClient +{ + /*< private >*/ + GDBusObjectManagerClient parent_instance; + GpickObjectManagerClientPrivate *priv; +}; + +struct _GpickObjectManagerClientClass +{ + GDBusObjectManagerClientClass parent_class; +}; + +GType gpick_object_manager_client_get_type (void) G_GNUC_CONST; + +GType gpick_object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data); + +void gpick_object_manager_client_new ( + GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GDBusObjectManager *gpick_object_manager_client_new_finish ( + GAsyncResult *res, + GError **error); +GDBusObjectManager *gpick_object_manager_client_new_sync ( + GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void gpick_object_manager_client_new_for_bus ( + GBusType bus_type, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GDBusObjectManager *gpick_object_manager_client_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +GDBusObjectManager *gpick_object_manager_client_new_for_bus_sync ( + GBusType bus_type, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +G_END_DECLS + +#endif /* __DBUSINTERFACE_H__ */ diff -Nru gpick-0.2.4/source/dbus/SConscript gpick-0.2.5/source/dbus/SConscript --- gpick-0.2.4/source/dbus/SConscript 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/dbus/SConscript 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import os +import sys + +Import('*') +local_env = env.Clone() + +if not local_env.GetOption('clean') and not env['TOOLCHAIN'] == 'msvc': + local_env.ParseConfig('pkg-config --cflags $GIO_PC') + +if not env['BUILD_TARGET'] == 'win32': + sources = local_env.Glob('*.c') + local_env.Glob('*.cpp') +else: + sources = local_env.Glob('win32dummy/*.cpp') + +objects = local_env.StaticObject(source = [sources]) +Return('objects') diff -Nru gpick-0.2.4/source/dbus/interface.xml gpick-0.2.5/source/dbus/interface.xml --- gpick-0.2.4/source/dbus/interface.xml 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/dbus/interface.xml 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,11 @@ + + + + + + + + + + + diff -Nru gpick-0.2.4/source/dbus/win32dummy/Control.cpp gpick-0.2.5/source/dbus/win32dummy/Control.cpp --- gpick-0.2.4/source/dbus/win32dummy/Control.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/dbus/win32dummy/Control.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +guint gpick_own_name(bool (*on_control_activate_floating_picker)(void *userdata), bool (*on_single_instance_activate)(void *userdata), void *userdata) +{ + return 0; +} + +void gpick_unown_name(guint bus_id) +{ +} + +bool gpick_control_activate_floating_picker() +{ + return false; +} + +bool gpick_single_instance_activate() +{ + return false; +} + diff -Nru gpick-0.2.4/source/dynv/DynvHandler.cpp gpick-0.2.5/source/dynv/DynvHandler.cpp --- gpick-0.2.4/source/dynv/DynvHandler.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvHandler.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvHandler.h gpick-0.2.5/source/dynv/DynvHandler.h --- gpick-0.2.4/source/dynv/DynvHandler.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvHandler.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -25,7 +25,9 @@ #include #include +#ifndef _MSC_VER #include +#endif struct dynvIO; @@ -36,7 +38,7 @@ int (*create)(struct dynvVariable* variable); int (*destroy)(struct dynvVariable* variable); - int (*get)(struct dynvVariable* variable, void** value); + int (*get)(struct dynvVariable* variable, void** value, bool *deref); int (*serialize)(struct dynvVariable* variable, struct dynvIO* io); int (*deserialize)(struct dynvVariable* variable, struct dynvIO* io); diff -Nru gpick-0.2.4/source/dynv/DynvIO.cpp gpick-0.2.5/source/dynv/DynvIO.cpp --- gpick-0.2.4/source/dynv/DynvIO.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvIO.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvIO.h gpick-0.2.5/source/dynv/DynvIO.h --- gpick-0.2.4/source/dynv/DynvIO.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvIO.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvMemoryIO.cpp gpick-0.2.5/source/dynv/DynvMemoryIO.cpp --- gpick-0.2.4/source/dynv/DynvMemoryIO.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvMemoryIO.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -98,7 +98,7 @@ static int dynv_io_memory_free(struct dynvIO* io){ struct dynvMemoryIO* mem_io=(struct dynvMemoryIO*)io->userdata; - if (mem_io->buffer) delete mem_io->buffer; + if (mem_io->buffer) delete [] mem_io->buffer; delete mem_io; return 0; } diff -Nru gpick-0.2.4/source/dynv/DynvMemoryIO.h gpick-0.2.5/source/dynv/DynvMemoryIO.h --- gpick-0.2.4/source/dynv/DynvMemoryIO.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvMemoryIO.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvSystem.cpp gpick-0.2.5/source/dynv/DynvSystem.cpp --- gpick-0.2.4/source/dynv/DynvSystem.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvSystem.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -183,7 +183,8 @@ if (variable->handler==handler){ if (variable->handler->get!=NULL){ void* value = 0; - if (variable->handler->get(variable, &value)==0){ + bool deref = true; + if (variable->handler->get(variable, &value, &deref)==0){ *error = 0; return value; }else{ @@ -239,8 +240,12 @@ i = variable; for (uint32_t j=0; j!=n; j++){ void *var; - if (i->handler->get && i->handler->get(i, &var)==0){ - memcpy(array, var, handler->data_size); + bool deref = true; + if (i->handler->get && i->handler->get(i, &var, &deref)==0){ + if (deref) + memcpy(array, var, handler->data_size); + else + memcpy(array, &var, handler->data_size); }else{ memset(array, 0, handler->data_size); //array[j] = 0; @@ -493,7 +498,8 @@ variable = (*i).second; handler = (*i).second->handler; - if (handler->get(variable, &value)==0){ + bool deref = true; + if (handler->get(variable, &value, &deref)==0){ new_variable = dynv_variable_create(variable->name, handler); new_dynv->variables[new_variable->name] = new_variable; new_variable->handler->create(new_variable); diff -Nru gpick-0.2.4/source/dynv/DynvSystem.h gpick-0.2.5/source/dynv/DynvSystem.h --- gpick-0.2.4/source/dynv/DynvSystem.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvSystem.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVarBool.cpp gpick-0.2.5/source/dynv/DynvVarBool.cpp --- gpick-0.2.4/source/dynv/DynvVarBool.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarBool.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -41,7 +41,7 @@ return 0; } -static int get(struct dynvVariable* variable, void** value){ +static int get(struct dynvVariable* variable, void** value, bool *deref){ *value = &variable->bool_value; return 0; } diff -Nru gpick-0.2.4/source/dynv/DynvVarBool.h gpick-0.2.5/source/dynv/DynvVarBool.h --- gpick-0.2.4/source/dynv/DynvVarBool.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarBool.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVarColor.cpp gpick-0.2.5/source/dynv/DynvVarColor.cpp --- gpick-0.2.4/source/dynv/DynvVarColor.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarColor.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -51,7 +51,7 @@ return 0; } -static int dynv_var_color_get(struct dynvVariable* variable, void** value){ +static int dynv_var_color_get(struct dynvVariable* variable, void** value, bool *deref){ if (variable->ptr_value){ *value = &variable->ptr_value; return 0; diff -Nru gpick-0.2.4/source/dynv/DynvVarColor.h gpick-0.2.5/source/dynv/DynvVarColor.h --- gpick-0.2.4/source/dynv/DynvVarColor.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarColor.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVarDynv.cpp gpick-0.2.5/source/dynv/DynvVarDynv.cpp --- gpick-0.2.4/source/dynv/DynvVarDynv.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarDynv.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -41,13 +41,17 @@ static int set(struct dynvVariable* variable, void* value, bool deref){ if (variable->ptr_value) dynv_system_release((struct dynvSystem*)variable->ptr_value); - variable->ptr_value = dynv_system_ref((struct dynvSystem*)value); + if (deref) + variable->ptr_value = dynv_system_ref(*((struct dynvSystem**)value)); + else + variable->ptr_value = dynv_system_ref((struct dynvSystem*)value); return 0; } -static int get(struct dynvVariable* variable, void** value){ +static int get(struct dynvVariable* variable, void** value, bool *deref){ if (variable->ptr_value){ *value= dynv_system_ref((struct dynvSystem*)variable->ptr_value); + *deref = false; return 0; } return -1; diff -Nru gpick-0.2.4/source/dynv/DynvVarDynv.h gpick-0.2.5/source/dynv/DynvVarDynv.h --- gpick-0.2.4/source/dynv/DynvVarDynv.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarDynv.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVarFloat.cpp gpick-0.2.5/source/dynv/DynvVarFloat.cpp --- gpick-0.2.4/source/dynv/DynvVarFloat.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarFloat.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -38,7 +38,7 @@ return 0; } -static int dynv_var_float_get(struct dynvVariable* variable, void** value){ +static int dynv_var_float_get(struct dynvVariable* variable, void** value, bool *deref){ *value = &variable->float_value; return 0; } diff -Nru gpick-0.2.4/source/dynv/DynvVarFloat.h gpick-0.2.5/source/dynv/DynvVarFloat.h --- gpick-0.2.4/source/dynv/DynvVarFloat.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarFloat.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVarInt32.cpp gpick-0.2.5/source/dynv/DynvVarInt32.cpp --- gpick-0.2.4/source/dynv/DynvVarInt32.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarInt32.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -38,7 +38,7 @@ return 0; } -static int dynv_var_int32_get(struct dynvVariable* variable, void** value){ +static int dynv_var_int32_get(struct dynvVariable* variable, void** value, bool *deref){ *value = &variable->int_value; return 0; } diff -Nru gpick-0.2.4/source/dynv/DynvVarInt32.h gpick-0.2.5/source/dynv/DynvVarInt32.h --- gpick-0.2.4/source/dynv/DynvVarInt32.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarInt32.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVarPtr.cpp gpick-0.2.5/source/dynv/DynvVarPtr.cpp --- gpick-0.2.4/source/dynv/DynvVarPtr.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarPtr.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -35,7 +35,7 @@ return 0; } -static int dynv_var_ptr_get(struct dynvVariable* variable, void** value){ +static int dynv_var_ptr_get(struct dynvVariable* variable, void** value, bool *deref){ *value = &variable->ptr_value; return 0; } diff -Nru gpick-0.2.4/source/dynv/DynvVarPtr.h gpick-0.2.5/source/dynv/DynvVarPtr.h --- gpick-0.2.4/source/dynv/DynvVarPtr.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarPtr.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVarString.cpp gpick-0.2.5/source/dynv/DynvVarString.cpp --- gpick-0.2.4/source/dynv/DynvVarString.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarString.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -49,7 +49,7 @@ return 0; } -static int dynv_var_string_get(struct dynvVariable* variable, void** value){ +static int dynv_var_string_get(struct dynvVariable* variable, void** value, bool *deref){ if (variable->ptr_value){ *value = &variable->ptr_value; return 0; diff -Nru gpick-0.2.4/source/dynv/DynvVarString.h gpick-0.2.5/source/dynv/DynvVarString.h --- gpick-0.2.4/source/dynv/DynvVarString.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVarString.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVariable.cpp gpick-0.2.5/source/dynv/DynvVariable.cpp --- gpick-0.2.4/source/dynv/DynvVariable.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVariable.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/dynv/DynvVariable.h gpick-0.2.5/source/dynv/DynvVariable.h --- gpick-0.2.4/source/dynv/DynvVariable.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvVariable.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,7 +20,9 @@ #define DYNVVARIABLE_H_ #include +#ifndef _MSC_VER #include +#endif struct dynvHandler; diff -Nru gpick-0.2.4/source/dynv/DynvXml.cpp gpick-0.2.5/source/dynv/DynvXml.cpp --- gpick-0.2.4/source/dynv/DynvXml.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvXml.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -121,8 +121,16 @@ }else{ variable = dynv_variable_create(0, entity->list_handler); variable->handler->create(variable); - xml->entity.push(n = new XmlEntity(variable, entity->dynv, false)); - + if (strcmp(entity->list_handler->name, "dynv") == 0){ + struct dynvHandlerMap* handler_map = dynv_system_get_handler_map(entity->dynv); + struct dynvSystem* dlevel_new = dynv_system_create(handler_map); + dynv_handler_map_release(handler_map); + entity->list_handler->set(variable, dlevel_new, false); + xml->entity.push(n = new XmlEntity(variable, dlevel_new, false)); + dynv_system_release(dlevel_new); + }else{ + xml->entity.push(n = new XmlEntity(variable, entity->dynv, false)); + } entity->variable->next = variable; entity->variable = variable; } @@ -145,10 +153,16 @@ if ((variable = dynv_system_add_empty(entity->dynv, handler, name))){ handler->set(variable, dlevel_new, false); - dynv_system_release(dlevel_new); } - xml->entity.push(new XmlEntity(0, dlevel_new, false)); + if (list && strcmp(list, "true")==0){ + xml->entity.push(n = new XmlEntity(variable, dlevel_new, true)); + n->list_handler = handler; + }else{ + xml->entity.push(n = new XmlEntity(variable, dlevel_new, false)); + } + + dynv_system_release(dlevel_new); }else if (handler->deserialize_xml){ if (list && strcmp(list, "true")==0){ @@ -198,7 +212,8 @@ dynv_system_remove(entity->dynv, entity->variable->name); } }else if (entity->variable){ - entity->variable->handler->deserialize_xml(entity->variable, entity->entity_data.str().c_str()); + if (entity->variable->handler->deserialize_xml) + entity->variable->handler->deserialize_xml(entity->variable, entity->entity_data.str().c_str()); } delete entity; } diff -Nru gpick-0.2.4/source/dynv/DynvXml.h gpick-0.2.5/source/dynv/DynvXml.h --- gpick-0.2.4/source/dynv/DynvXml.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/dynv/DynvXml.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/gtk/ColorCell.cpp gpick-0.2.5/source/gtk/ColorCell.cpp --- gpick-0.2.4/source/gtk/ColorCell.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/ColorCell.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -19,6 +19,8 @@ #include "ColorCell.h" #include "../ColorObject.h" +#include + static void custom_cell_renderer_color_init(CustomCellRendererColor *cellcolor); static void custom_cell_renderer_color_class_init(CustomCellRendererColorClass *klass); @@ -191,7 +193,7 @@ cairo_rectangle(cr, expose_area->x, expose_area->y, expose_area->width, expose_area->height); Color c; color_object_get_color(cellcolor->color, &c); - cairo_set_source_rgb(cr, c.rgb.red, c.rgb.green, c.rgb.blue); + cairo_set_source_rgb(cr, boost::math::round(c.rgb.red * 255.0) / 255.0, boost::math::round(c.rgb.green * 255.0) / 255.0, boost::math::round(c.rgb.blue * 255.0) / 255.0); cairo_fill(cr); cairo_destroy(cr); diff -Nru gpick-0.2.4/source/gtk/ColorCell.h gpick-0.2.5/source/gtk/ColorCell.h --- gpick-0.2.4/source/gtk/ColorCell.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/ColorCell.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/gtk/ColorComponent.cpp gpick-0.2.5/source/gtk/ColorComponent.cpp --- gpick-0.2.4/source/gtk/ColorComponent.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/ColorComponent.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,10 +21,12 @@ #include "../Color.h" #include "../MathUtil.h" +#include "../Paths.h" #include #include #include +#include using namespace std; #define GTK_COLOR_COMPONENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_COLOR_COMPONENT, GtkColorComponentPrivate)) @@ -38,14 +40,18 @@ static gboolean gtk_color_component_button_press (GtkWidget *node_system, GdkEventButton *event); static gboolean gtk_color_component_motion_notify (GtkWidget *node_system, GdkEventMotion *event); static void update_rgb_color(GtkColorComponentPrivate *ns, Color *c); +static void gtk_color_component_size_request (GtkWidget *widget, GtkRequisition *requisition); +static void gtk_color_component_finalize(GObject *color_obj); enum{ COLOR_CHANGED, + INPUT_CLICKED, LAST_SIGNAL }; -static guint gtk_color_component_signals[LAST_SIGNAL] = { 0 }; +static const int MaxNumberOfComponents = 4; +static guint gtk_color_component_signals[LAST_SIGNAL] = {0, 0}; typedef struct GtkColorComponentPrivate{ Color orig_color; @@ -53,9 +59,21 @@ GtkColorComponentComp component; int n_components; int capture_on; + gint last_event_position; + bool changing_color; - double range[4]; - double offset[4]; + bool out_of_gamut_mask; + + ReferenceIlluminant lab_illuminant; + ReferenceObserver lab_observer; + + cairo_surface_t *pattern_surface; + cairo_pattern_t *pattern; + + const char *label[MaxNumberOfComponents][2]; + gchar *text[MaxNumberOfComponents]; + double range[MaxNumberOfComponents]; + double offset[MaxNumberOfComponents]; }GtkColorComponentPrivate; static void gtk_color_component_class_init (GtkColorComponentClass *color_component_class){ @@ -71,19 +89,30 @@ widget_class->button_release_event = gtk_color_component_button_release; widget_class->button_press_event = gtk_color_component_button_press; widget_class->motion_notify_event = gtk_color_component_motion_notify; + widget_class->size_request = gtk_color_component_size_request; g_type_class_add_private(obj_class, sizeof(GtkColorComponentPrivate)); + obj_class->finalize = gtk_color_component_finalize; - gtk_color_component_signals[COLOR_CHANGED] = g_signal_new ( + gtk_color_component_signals[COLOR_CHANGED] = g_signal_new( "color-changed", - G_OBJECT_CLASS_TYPE (obj_class), + G_OBJECT_CLASS_TYPE(obj_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GtkColorComponentClass, color_changed), + G_STRUCT_OFFSET(GtkColorComponentClass, color_changed), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); + gtk_color_component_signals[INPUT_CLICKED] = g_signal_new( + "input-clicked", + G_OBJECT_CLASS_TYPE(obj_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(GtkColorComponentClass, input_clicked), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, + G_TYPE_INT); } static void gtk_color_component_init (GtkColorComponent *color_component){ @@ -91,12 +120,49 @@ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK); } +static void gtk_color_component_finalize(GObject *color_obj){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_obj); + for (int i = 0; i != sizeof(ns->text) / sizeof(gchar*); i++){ + if (ns->text[i]){ + g_free(ns->text[i]); + ns->text[i] = 0; + } + } + if (ns->pattern_surface) + cairo_surface_destroy(ns->pattern_surface); + if (ns->pattern) + cairo_pattern_destroy(ns->pattern); + + gpointer parent_class = g_type_class_peek_parent(G_OBJECT_CLASS(GTK_COLOR_COMPONENT_GET_CLASS(color_obj))); + G_OBJECT_CLASS(parent_class)->finalize(color_obj); +} + GtkWidget *gtk_color_component_new (GtkColorComponentComp component){ GtkWidget* widget = (GtkWidget*)g_object_new(GTK_TYPE_COLOR_COMPONENT, NULL); GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(widget); + gchar* pattern_filename = build_filename("gpick-gray-pattern.png"); + ns->pattern_surface = cairo_image_surface_create_from_png(pattern_filename); + g_free(pattern_filename); + + ns->pattern = cairo_pattern_create_for_surface(ns->pattern_surface); + cairo_pattern_set_extend(ns->pattern, CAIRO_EXTEND_REPEAT); + ns->component = component; + ns->last_event_position = -1; + ns->changing_color = false; + ns->lab_illuminant = REFERENCE_ILLUMINANT_D50; + ns->lab_observer= REFERENCE_OBSERVER_2; + ns->out_of_gamut_mask = false; + + for (int i = 0; i != sizeof(ns->text) / sizeof(gchar*); i++){ + ns->text[i] = 0; + } + for (int i = 0; i != sizeof(ns->label) / sizeof(const char*[2]); i++){ + ns->label[i][0] = 0; + ns->label[i][1] = 0; + } switch (component){ case lab: @@ -107,6 +173,15 @@ ns->offset[1] = ns->offset[2] = -145; break; + case lch: + ns->n_components = 3; + ns->range[0] = 100; + ns->offset[0] = 0; + ns->range[1] = 136; + ns->range[2] = 360; + ns->offset[1] = ns->offset[2] = 0; + break; + case xyz: break; @@ -123,7 +198,7 @@ ns->offset[0] = ns->offset[1] = ns->offset[2] = ns->offset[3] = 0; } - gtk_widget_set_size_request(GTK_WIDGET(widget), 200, 16 * ns->n_components); + gtk_widget_set_size_request(GTK_WIDGET(widget), 242, 16 * ns->n_components); return widget; } @@ -155,12 +230,36 @@ return component; } +const char* gtk_color_component_get_text(GtkColorComponent* color_component, gint component_id){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + return ns->text[component_id]; +} + +void gtk_color_component_set_text(GtkColorComponent* color_component, const char **text){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + for (int i = 0; i != sizeof(ns->text) / sizeof(gchar*); i++){ + if (!text[i]) break; + if (ns->text[i]){ + g_free(ns->text[i]); + } + ns->text[i] = g_strdup(text[i]); + } + gtk_widget_queue_draw(GTK_WIDGET(color_component)); +} + +void gtk_color_component_set_label(GtkColorComponent* color_component, const char **label){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + for (int i = 0; i != MaxNumberOfComponents * 2; i++){ + if (!label[i]) break; + ns->label[i >> 1][i & 1] = label[i]; + } + gtk_widget_queue_draw(GTK_WIDGET(color_component)); +} + void gtk_color_component_set_color(GtkColorComponent* color_component, Color* color){ GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); color_copy(color, &ns->orig_color); - Color c1; - switch (ns->component){ case rgb: color_copy(&ns->orig_color, &ns->color); @@ -175,22 +274,22 @@ color_rgb_to_cmyk(&ns->orig_color, &ns->color); break; case lab: - matrix3x3 adaptation_matrix, working_space_matrix; - vector3 d50, d65; - vector3_set(&d50, 96.442, 100.000, 82.821); - vector3_set(&d65, 95.047, 100.000, 108.883); - color_get_chromatic_adaptation_matrix(&d50, &d65, &adaptation_matrix); - color_get_working_space_matrix(0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, &d65, &working_space_matrix); - - color_rgb_to_xyz(&ns->orig_color, &c1, &working_space_matrix); - color_xyz_chromatic_adaptation(&c1, &c1, &adaptation_matrix); - - color_xyz_to_lab(&c1, &ns->color, &d50); - + { + matrix3x3 adaptation_matrix; + color_get_chromatic_adaptation_matrix(color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), color_get_reference(ns->lab_illuminant, ns->lab_observer), &adaptation_matrix); + color_rgb_to_lab(&ns->orig_color, &ns->color, color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_sRGB_transformation_matrix(), &adaptation_matrix); + } break; case xyz: /* todo */ break; + case lch: + { + matrix3x3 adaptation_matrix; + color_get_chromatic_adaptation_matrix(color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), color_get_reference(ns->lab_illuminant, ns->lab_observer), &adaptation_matrix); + color_rgb_to_lch(&ns->orig_color, &ns->color, color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_sRGB_transformation_matrix(), &adaptation_matrix); + } + break; } @@ -203,18 +302,27 @@ result->rgb.blue = color1->rgb.blue * (1 - position) + color2->rgb.blue * position; } +static void gtk_color_component_size_request (GtkWidget *widget, GtkRequisition *requisition){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(widget); + + gint width = 240 + widget->style->xthickness * 2; + gint height = ns->n_components * 16 + widget->style->ythickness * 2; + + requisition->width = width; + requisition->height = height; +} + static gboolean gtk_color_component_expose (GtkWidget *widget, GdkEventExpose *event){ cairo_t *cr; GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(widget); - cr = gdk_cairo_create (widget->window); + cr = gdk_cairo_create(widget->window); cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, event->area.height); cairo_clip(cr); - Color c[4]; - Color c2[4]; - double pointer_pos[4]; + Color c[MaxNumberOfComponents]; + double pointer_pos[MaxNumberOfComponents]; float steps; int i, j; @@ -227,13 +335,15 @@ unsigned char *data = cairo_image_surface_get_data(surface); int stride = cairo_image_surface_get_stride(surface); int surface_width = cairo_image_surface_get_width(surface); - int surface_height = cairo_image_surface_get_height(surface); unsigned char *col_ptr; Color *rgb_points = new Color[ns->n_components * 200]; double int_part; + matrix3x3 adaptation_matrix; + + vector > out_of_gamut(MaxNumberOfComponents, vector(false, 1)); switch (ns->component) { case rgb: @@ -387,39 +497,70 @@ case lab: steps = 100; - matrix3x3 adaptation_matrix, working_space_matrix, working_space_matrix_inv; - vector3 d50, d65; - vector3_set(&d50, 96.442, 100.000, 82.821); - vector3_set(&d65, 95.047, 100.000, 108.883); - color_get_chromatic_adaptation_matrix(&d65, &d50, &adaptation_matrix); - color_get_working_space_matrix(0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, &d65, &working_space_matrix); + color_get_chromatic_adaptation_matrix(color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), &adaptation_matrix); - matrix3x3_inverse(&working_space_matrix, &working_space_matrix_inv); + for (j = 0; j < 3; ++j){ + color_copy(&ns->color, &c[j]); - for (i = 0; i < 3; ++i){ - color_copy(&ns->color, &c[i]); - } - for (i = 0; i <= steps; ++i){ - c[0].lab.L = (i / steps) * ns->range[0] + ns->offset[0]; - color_lab_to_xyz(&c[0], &c2[0], &d50); - color_xyz_chromatic_adaptation(&c2[0], &c2[0], &adaptation_matrix); - color_xyz_to_rgb(&c2[0], &rgb_points[0 * (int(steps) + 1) + i], &working_space_matrix_inv); - color_rgb_normalize(&rgb_points[0 * (int(steps) + 1) + i]); + out_of_gamut[j] = vector(steps + 1, false); + + for (i = 0; i <= steps; ++i){ + c[j].ma[j] = (i / steps) * ns->range[j] + ns->offset[j]; + color_lab_to_rgb(&c[j], &rgb_points[j * (int(steps) + 1) + i], color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_inverted_sRGB_transformation_matrix(), &adaptation_matrix); + + if (color_is_rgb_out_of_gamut(&rgb_points[j * (int(steps) + 1) + i])){ + out_of_gamut[j][i] = true; + } + color_rgb_normalize(&rgb_points[j * (int(steps) + 1) + i]); + } } - for (i = 0; i <= steps; ++i){ - c[1].lab.a = (i / steps) * ns->range[1] + ns->offset[1]; - color_lab_to_xyz(&c[1], &c2[1], &d50); - color_xyz_chromatic_adaptation(&c2[1], &c2[1], &adaptation_matrix); - color_xyz_to_rgb(&c2[1], &rgb_points[1 * (int(steps) + 1) + i], &working_space_matrix_inv); - color_rgb_normalize(&rgb_points[1 * (int(steps) + 1) + i]); + for (i = 0; i < surface_width; ++i){ + + float position = modf(i * steps / surface_width, &int_part); + int index = i * int(steps) / surface_width; + + interpolate_colors(&rgb_points[0 * (int(steps) + 1) + index], &rgb_points[0 * (int(steps) + 1) + index + 1], position, &c[0]); + interpolate_colors(&rgb_points[1 * (int(steps) + 1) + index], &rgb_points[1 * (int(steps) + 1) + index + 1], position, &c[1]); + interpolate_colors(&rgb_points[2 * (int(steps) + 1) + index], &rgb_points[2 * (int(steps) + 1) + index + 1], position, &c[2]); + + col_ptr = data + i * 4; + + for (int y = 0; y < ns->n_components * 16; ++y){ + if ((y & 0x0f) != 0x0f){ + col_ptr[2] = (unsigned char)(c[y / 16].rgb.red * 255); + col_ptr[1] = (unsigned char)(c[y / 16].rgb.green * 255); + col_ptr[0] = (unsigned char)(c[y / 16].rgb.blue * 255); + col_ptr[3] = 0xff; + }else{ + col_ptr[0] = 0x00; + col_ptr[1] = 0x00; + col_ptr[2] = 0x00; + col_ptr[3] = 0x00; + } + col_ptr += stride; + } } - for (i = 0; i <= steps; ++i){ - c[2].lab.b = (i / steps) * ns->range[2] + ns->offset[2]; - color_lab_to_xyz(&c[2], &c2[2], &d50); - color_xyz_chromatic_adaptation(&c2[2], &c2[2], &adaptation_matrix); - color_xyz_to_rgb(&c2[2], &rgb_points[2 * (int(steps) + 1) + i], &working_space_matrix_inv); - color_rgb_normalize(&rgb_points[2 * (int(steps) + 1) + i]); + break; + + case lch: + steps = 100; + + color_get_chromatic_adaptation_matrix(color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), &adaptation_matrix); + + for (j = 0; j < 3; ++j){ + color_copy(&ns->color, &c[j]); + + out_of_gamut[j] = vector(steps + 1, false); + + for (i = 0; i <= steps; ++i){ + c[j].ma[j] = (i / steps) * ns->range[j] + ns->offset[j]; + color_lch_to_rgb(&c[j], &rgb_points[j * (int(steps) + 1) + i], color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_inverted_sRGB_transformation_matrix(), &adaptation_matrix); + if (color_is_rgb_out_of_gamut(&rgb_points[j * (int(steps) + 1) + i])){ + out_of_gamut[j][i] = true; + } + color_rgb_normalize(&rgb_points[j * (int(steps) + 1) + i]); + } } for (i = 0; i < surface_width; ++i){ @@ -458,28 +599,110 @@ cairo_surface_mark_dirty(surface); cairo_save(cr); - cairo_set_source_surface(cr, surface, 0, 0); + int offset_x = widget->allocation.width - widget->style->xthickness * 2 - 240; + + cairo_set_source_surface(cr, surface, offset_x, 0); cairo_surface_destroy(surface); for (i = 0; i < ns->n_components; ++i){ - cairo_rectangle(cr, 0, 16 * i, 200, 15); + cairo_rectangle(cr, offset_x, 16 * i, 200, 15); cairo_fill(cr); } cairo_restore(cr); for (i = 0; i < ns->n_components; ++i){ - cairo_move_to(cr, 200*pointer_pos[i], 16 * i + 9); - cairo_line_to(cr, 200*pointer_pos[i]+3, 16 * i + 16); - cairo_line_to(cr, 200*pointer_pos[i]-3, 16 * i + 16); + cairo_matrix_t matrix; + cairo_matrix_init_translate(&matrix, -offset_x - 64, -64 + 5 * i); + cairo_pattern_set_matrix(ns->pattern, &matrix); + + if (ns->out_of_gamut_mask){ + int first_out_of_gamut = 0; + bool out_of_gamut_found = false; + + cairo_matrix_t matrix; + cairo_set_source(cr, ns->pattern); + + for (int j = 0; j < out_of_gamut[i].size(); j++){ + if (out_of_gamut[i][j]){ + if (!out_of_gamut_found){ + out_of_gamut_found = true; + first_out_of_gamut = j; + } + }else{ + if (out_of_gamut_found){ + cairo_rectangle(cr, offset_x + (first_out_of_gamut * 200.0 / out_of_gamut[i].size()), 16 * i, (j - first_out_of_gamut) * 200.0 / out_of_gamut[i].size(), 15); + cairo_fill(cr); + out_of_gamut_found = false; + } + } + } + + if (out_of_gamut_found){ + cairo_rectangle(cr, offset_x + (first_out_of_gamut * 200.0 / out_of_gamut[i].size()), 16 * i, (out_of_gamut[i].size() - first_out_of_gamut) * 200.0 / out_of_gamut[i].size(), 15); + cairo_fill(cr); + } + } + + cairo_move_to(cr, offset_x + 200 * pointer_pos[i], 16 * i + 9); + cairo_line_to(cr, offset_x + 200 * pointer_pos[i] + 3, 16 * i + 16); + cairo_line_to(cr, offset_x + 200 * pointer_pos[i] - 3, 16 * i + 16); cairo_set_source_rgb(cr, 1, 1, 1); cairo_fill_preserve(cr); cairo_set_source_rgb(cr, 0, 0, 0); cairo_set_line_width(cr, 1); cairo_stroke(cr); - } - cairo_destroy (cr); + if (ns->text[i] || ns->label[i]){ + PangoLayout *layout; + PangoFontDescription *font_description; + font_description = pango_font_description_new(); + layout = pango_cairo_create_layout(cr); + + pango_font_description_set_family(font_description, "sans"); + pango_font_description_set_weight(font_description, PANGO_WEIGHT_NORMAL); + pango_font_description_set_absolute_size(font_description, 12 * PANGO_SCALE); + pango_layout_set_font_description(layout, font_description); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD); + pango_layout_set_single_paragraph_mode(layout, true); + + gdk_cairo_set_source_color(cr, &widget->style->text[0]); + int width, height; + + if (ns->text[i]){ + pango_layout_set_text(layout, ns->text[i], -1); + pango_layout_set_width(layout, 40 * PANGO_SCALE); + pango_layout_set_height(layout, 16 * PANGO_SCALE); + pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT); + pango_cairo_update_layout(cr, layout); + + pango_layout_get_pixel_size(layout, &width, &height); + cairo_move_to(cr, 200 + offset_x, i * 16); + pango_cairo_show_layout(cr, layout); + } + + if (ns->label[i] && offset_x > 10){ + if (offset_x > 50){ + pango_layout_set_text(layout, ns->label[i][1], -1); + }else{ + pango_layout_set_text(layout, ns->label[i][0], -1); + } + pango_layout_set_width(layout, (offset_x - 10) * PANGO_SCALE); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); + pango_layout_set_height(layout, 16 * PANGO_SCALE); + pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); + pango_cairo_update_layout(cr, layout); + + pango_layout_get_pixel_size(layout, &width, &height); + cairo_move_to(cr, 5, i * 16); + pango_cairo_show_layout(cr, layout); + } + + g_object_unref(layout); + pango_font_description_free(font_description); + } + } + cairo_destroy(cr); return TRUE; } @@ -508,31 +731,43 @@ color_rgb_normalize(c); break; case lab: - matrix3x3 adaptation_matrix, working_space_matrix, working_space_matrix_inv; - vector3 d50, d65; - vector3_set(&d50, 96.442, 100.000, 82.821); - vector3_set(&d65, 95.047, 100.000, 108.883); - color_get_chromatic_adaptation_matrix(&d65, &d50, &adaptation_matrix); - color_get_working_space_matrix(0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, &d65, &working_space_matrix); - - matrix3x3_inverse(&working_space_matrix, &working_space_matrix_inv); - - Color c2; - - color_lab_to_xyz(&ns->color, &c2, &d50); - color_xyz_chromatic_adaptation(&c2, &c2, &adaptation_matrix); - color_xyz_to_rgb(&c2, c, &working_space_matrix_inv); - color_rgb_normalize(c); - + { + matrix3x3 adaptation_matrix; + color_get_chromatic_adaptation_matrix(color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), &adaptation_matrix); + color_lab_to_rgb(&ns->color, c, color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_inverted_sRGB_transformation_matrix(), &adaptation_matrix); + color_rgb_normalize(c); + } break; - case xyz: - + /* TODO */ + break; + case lch: + { + matrix3x3 adaptation_matrix; + color_get_chromatic_adaptation_matrix(color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_reference(REFERENCE_ILLUMINANT_D65, REFERENCE_OBSERVER_2), &adaptation_matrix); + color_lch_to_rgb(&ns->color, c, color_get_reference(ns->lab_illuminant, ns->lab_observer), color_get_inverted_sRGB_transformation_matrix(), &adaptation_matrix); + color_rgb_normalize(c); + } break; } } +void gtk_color_component_get_raw_color(GtkColorComponent* color_component, Color* color){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + color_copy(&ns->color, color); +} + +void gtk_color_component_set_raw_color(GtkColorComponent* color_component, Color* color){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + color_copy(color, &ns->color); + Color c; + update_rgb_color(ns, &c); + color_copy(&c, &ns->orig_color); + gtk_widget_queue_draw(GTK_WIDGET(color_component)); + g_signal_emit(GTK_WIDGET(color_component), gtk_color_component_signals[COLOR_CHANGED], 0, &c); +} + static void gtk_color_component_emit_color_change(GtkWidget *widget, int component, double value){ GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(widget); @@ -544,6 +779,9 @@ } static gboolean gtk_color_component_button_release (GtkWidget *widget, GdkEventButton *event){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(widget); + gdk_pointer_ungrab(GDK_CURRENT_TIME); + ns->changing_color = false; return false; } @@ -551,18 +789,27 @@ GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(widget); if ((event->type == GDK_BUTTON_PRESS) && (event->button == 1)){ - if (event->x < 0 || event->x > 200) return FALSE; + int component = event->y / 16; + if (component < 0) component = 0; + else if (component >= ns->n_components) component = ns->n_components - 1; + + int offset_x = widget->allocation.width - widget->style->xthickness * 2 - 240; + + if (event->x < offset_x || event->x > 200 + offset_x) { + g_signal_emit(widget, gtk_color_component_signals[INPUT_CLICKED], 0, component); + return FALSE; + } + ns->changing_color = true; + ns->last_event_position = event->x; double value; - value = event->x / 200.0; + value = (event->x - offset_x) / 200.0; if (value < 0) value = 0; else if (value > 1) value = 1; - int component = event->y / 16; - if (component < 0) component = 0; - else if (component >= ns->n_components) component = ns->n_components - 1; ns->capture_on = component; + gdk_pointer_grab(gtk_widget_get_window(widget), false, GdkEventMask(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, NULL, GDK_CURRENT_TIME); gtk_color_component_emit_color_change(widget, component, value); gtk_widget_queue_draw(widget); @@ -574,11 +821,13 @@ static gboolean gtk_color_component_motion_notify (GtkWidget *widget, GdkEventMotion *event){ GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(widget); - if ((event->state & GDK_BUTTON1_MASK)){ - if (event->x < 0 || event->x > 200) return FALSE; + if (ns->changing_color && (event->state & GDK_BUTTON1_MASK)){ + int offset_x = widget->allocation.width - widget->style->xthickness * 2 - 240; + if ((event->x < offset_x && ns->last_event_position < offset_x) || ((event->x > 200 + offset_x) && (ns->last_event_position > 200 + offset_x))) return FALSE; + ns->last_event_position = event->x; double value; - value = event->x / 200.0; + value = (event->x - offset_x) / 200.0; if (value < 0) value = 0; else if (value > 1) value = 1; @@ -593,3 +842,30 @@ return FALSE; } +void gtk_color_component_set_lab_illuminant(GtkColorComponent* color_component, ReferenceIlluminant illuminant){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + ns->lab_illuminant = illuminant; + gtk_color_component_set_color(color_component, &ns->orig_color); + gtk_widget_queue_draw(GTK_WIDGET(color_component)); +} + +void gtk_color_component_set_lab_observer(GtkColorComponent* color_component, ReferenceObserver observer){ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + ns->lab_observer = observer; + gtk_color_component_set_color(color_component, &ns->orig_color); + gtk_widget_queue_draw(GTK_WIDGET(color_component)); +} + +void gtk_color_component_set_out_of_gamut_mask(GtkColorComponent* color_component, bool mask_enabled) +{ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + ns->out_of_gamut_mask = mask_enabled; + gtk_widget_queue_draw(GTK_WIDGET(color_component)); +} + +bool gtk_color_component_get_out_of_gamut_mask(GtkColorComponent* color_component) +{ + GtkColorComponentPrivate *ns = GTK_COLOR_COMPONENT_GET_PRIVATE(color_component); + return ns->out_of_gamut_mask; +} + diff -Nru gpick-0.2.4/source/gtk/ColorComponent.h gpick-0.2.5/source/gtk/ColorComponent.h --- gpick-0.2.4/source/gtk/ColorComponent.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/ColorComponent.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -29,7 +29,7 @@ #define GTK_COLOR_COMPONENT_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GTK_COLOR_COMPONENT, GtkColorComponentClass)) #define GTK_IS_COLOR_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_COMPONENT)) #define GTK_IS_COLOR_COMPONENT_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_COLOR_COMPONENT)) -#define GTK_COLOR_COMPONENT_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COLOR_COMPONENT, GtkColorComponentClass)) +#define GTK_COLOR_COMPONENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COLOR_COMPONENT, GtkColorComponentClass)) typedef struct GtkColorComponent GtkColorComponent; typedef struct GtkColorComponentClass GtkColorComponentClass; @@ -45,6 +45,7 @@ typedef struct GtkColorComponentClass{ GtkDrawingAreaClass parent_class; void (*color_changed)(GtkWidget* widget, Color* c, gpointer userdata); + void (*input_clicked)(GtkWidget* widget, int component_id, gpointer userdata); }GtkColorComponentClass; enum GtkColorComponentComp{ @@ -54,15 +55,27 @@ cmyk, xyz, lab, + lch, }; GtkWidget* gtk_color_component_new (GtkColorComponentComp component); void gtk_color_component_set_color(GtkColorComponent* color_component, Color* color); +void gtk_color_component_set_text(GtkColorComponent* color_component, const char **text); +const char* gtk_color_component_get_text(GtkColorComponent* color_component, gint component_id); +void gtk_color_component_set_label(GtkColorComponent* color_component, const char **label); void gtk_color_component_get_color(GtkColorComponent* color_component, Color* color); +void gtk_color_component_get_raw_color(GtkColorComponent* color_component, Color* color); +void gtk_color_component_set_raw_color(GtkColorComponent* color_component, Color* color); void gtk_color_component_get_transformed_color(GtkColorComponent* color_component, Color* color); void gtk_color_component_set_transformed_color(GtkColorComponent* color_component, Color* color); +void gtk_color_component_set_out_of_gamut_mask(GtkColorComponent* color_component, bool mask_enabled); +bool gtk_color_component_get_out_of_gamut_mask(GtkColorComponent* color_component); + +void gtk_color_component_set_lab_illuminant(GtkColorComponent* color_component, ReferenceIlluminant illuminant); +void gtk_color_component_set_lab_observer(GtkColorComponent* color_component, ReferenceObserver observer); + GtkColorComponentComp gtk_color_component_get_component(GtkColorComponent* color_component); int gtk_color_component_get_component_id_at(GtkColorComponent* color_component, gint x, gint y); diff -Nru gpick-0.2.4/source/gtk/ColorWheel.cpp gpick-0.2.5/source/gtk/ColorWheel.cpp --- gpick-0.2.4/source/gtk/ColorWheel.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/ColorWheel.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,6 +21,9 @@ #include "../ColorWheelType.h" #include "../MathUtil.h" #include +#ifdef _MSC_VER +#define M_PI 3.14159265359 +#endif #include #include @@ -328,7 +331,7 @@ if ((dist >= inner_radius_sq) && (dist <= radius_sq)){ - double angle = atan2(dx, dy) + M_PI; + double angle = atan2((double)dx, (double)dy) + M_PI; wheel->hue_to_hsl(angle / (M_PI * 2), &c); color_hsl_to_rgb(&c, &c); diff -Nru gpick-0.2.4/source/gtk/ColorWheel.h gpick-0.2.5/source/gtk/ColorWheel.h --- gpick-0.2.4/source/gtk/ColorWheel.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/ColorWheel.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/gtk/ColorWidget.cpp gpick-0.2.5/source/gtk/ColorWidget.cpp --- gpick-0.2.4/source/gtk/ColorWidget.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/ColorWidget.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,6 +21,11 @@ #include "../MathUtil.h" #include +#include + +#include +using namespace std; + #define GTK_COLOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_COLOR, GtkColorPrivate)) G_DEFINE_TYPE (GtkColor, gtk_color, GTK_TYPE_DRAWING_AREA); @@ -52,6 +57,7 @@ bool secondary_color; double roundness; + transformation::Chain *transformation_chain; } GtkColorPrivate; static void gtk_color_class_init(GtkColorClass *color_class) { @@ -92,6 +98,7 @@ ns->h_center = false; ns->secondary_color = false; ns->roundness = 20; + ns->transformation_chain = 0; GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS); @@ -157,7 +164,13 @@ if (ns->secondary_color){ }else{ - color_get_contrasting(&ns->color, &ns->text_color); + if (ns->transformation_chain){ + Color c; + ns->transformation_chain->apply(&ns->color, &c); + color_get_contrasting(&c, &ns->text_color); + }else{ + color_get_contrasting(&ns->color, &ns->text_color); + } } if (ns->text) @@ -220,13 +233,19 @@ cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, event->area.height); cairo_clip(cr); + Color color; if (ns->rounded_rectangle){ - cairo_rounded_rectangle(cr, widget->style->xthickness, widget->style->ythickness, - widget->allocation.width-widget->style->xthickness*2, widget->allocation.height-widget->style->ythickness*2, ns->roundness); + cairo_rounded_rectangle(cr, widget->style->xthickness, widget->style->ythickness, widget->allocation.width-widget->style->xthickness*2, widget->allocation.height-widget->style->ythickness*2, ns->roundness); - cairo_set_source_rgb(cr, ns->color.rgb.red, ns->color.rgb.green, ns->color.rgb.blue); + if (ns->transformation_chain){ + ns->transformation_chain->apply(&ns->color, &color); + }else{ + color_copy(&ns->color, &color); + } + + cairo_set_source_rgb(cr, boost::math::round(color.rgb.red * 255.0) / 255.0, boost::math::round(color.rgb.green * 255.0) / 255.0, boost::math::round(color.rgb.blue * 255.0) / 255.0); cairo_fill_preserve(cr); if (GTK_WIDGET_HAS_FOCUS(widget)){ @@ -241,7 +260,13 @@ }else{ cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, event->area.height); - cairo_set_source_rgb(cr, ns->color.rgb.red, ns->color.rgb.green, ns->color.rgb.blue); + + if (ns->transformation_chain){ + ns->transformation_chain->apply(&ns->color, &color); + }else{ + color_copy(&ns->color, &color); + } + cairo_set_source_rgb(cr, color.rgb.red, color.rgb.green, color.rgb.blue); cairo_fill(cr); } @@ -256,9 +281,18 @@ pango_font_description_set_weight(font_description, PANGO_WEIGHT_NORMAL); pango_font_description_set_absolute_size(font_description, 14 * PANGO_SCALE); pango_layout_set_font_description(layout, font_description); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - cairo_set_source_rgb(cr, ns->text_color.rgb.red, ns->text_color.rgb.green, ns->text_color.rgb.blue); + if (ns->transformation_chain){ + if (ns->secondary_color){ + ns->transformation_chain->apply(&ns->text_color, &color); + }else{ + color_copy(&ns->text_color, &color); + } + }else{ + color_copy(&ns->text_color, &color); + } + cairo_set_source_rgb(cr, color.rgb.red, color.rgb.green, color.rgb.blue); pango_layout_set_markup(layout, ns->text, -1); pango_layout_set_width(layout, (widget->allocation.width - widget->style->xthickness * 2) * PANGO_SCALE); @@ -304,3 +338,18 @@ return FALSE; } +void gtk_color_set_transformation_chain(GtkColor* widget, transformation::Chain *chain){ + GtkColorPrivate *ns = GTK_COLOR_GET_PRIVATE(widget); + ns->transformation_chain = chain; + if (!ns->secondary_color){ + if (ns->transformation_chain){ + Color c; + ns->transformation_chain->apply(&ns->color, &c); + color_get_contrasting(&c, &ns->text_color); + }else{ + color_get_contrasting(&ns->color, &ns->text_color); + } + } + gtk_widget_queue_draw(GTK_WIDGET(widget)); +} + diff -Nru gpick-0.2.4/source/gtk/ColorWidget.h gpick-0.2.5/source/gtk/ColorWidget.h --- gpick-0.2.4/source/gtk/ColorWidget.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/ColorWidget.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,7 +22,7 @@ #include #include "../Color.h" - +#include "../transformation/Chain.h" G_BEGIN_DECLS @@ -59,6 +59,8 @@ void gtk_color_set_rounded(GtkColor* widget, bool rounded_rectangle); void gtk_color_set_roundness(GtkColor* widget, double roundness); void gtk_color_set_hcenter(GtkColor* widget, bool hcenter); +void gtk_color_set_transformation_chain(GtkColor* widget, transformation::Chain *chain); + GType gtk_color_get_type(void); G_END_DECLS diff -Nru gpick-0.2.4/source/gtk/LayoutPreview.cpp gpick-0.2.5/source/gtk/LayoutPreview.cpp --- gpick-0.2.4/source/gtk/LayoutPreview.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/LayoutPreview.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -18,6 +18,7 @@ #include "LayoutPreview.h" #include "../layout/System.h" +#include "../transformation/Chain.h" #include "../Rect2.h" #include @@ -50,6 +51,7 @@ Rect2 area; Style* selected_style; Box* selected_box; + transformation::Chain *transformation_chain; }GtkLayoutPreviewPrivate; @@ -88,6 +90,7 @@ ns->selected_style = 0; ns->selected_box = 0; ns->system = 0; + ns->transformation_chain = 0; g_signal_connect(G_OBJECT(widget), "destroy", G_CALLBACK (gtk_layout_preview_destroy), NULL); @@ -130,7 +133,8 @@ if (ns->system && ns->system->box){ ns->area = Rect2(0, 0, 1, 1); - ns->system->box->Draw(cr, ns->area); + layout::Context context(cr, ns->transformation_chain); + ns->system->box->Draw(&context, ns->area); } cairo_destroy(cr); @@ -291,3 +295,9 @@ return false; } +void gtk_layout_preview_set_transformation_chain(GtkLayoutPreview* widget, transformation::Chain *chain){ + GtkLayoutPreviewPrivate *ns = GTK_LAYOUT_PREVEW_GET_PRIVATE(widget); + ns->transformation_chain = chain; + gtk_widget_queue_draw(GTK_WIDGET(widget)); +} + diff -Nru gpick-0.2.4/source/gtk/LayoutPreview.h gpick-0.2.5/source/gtk/LayoutPreview.h --- gpick-0.2.4/source/gtk/LayoutPreview.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/LayoutPreview.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -23,6 +23,7 @@ #include #include "../ColorObject.h" #include "../layout/System.h" +#include "../transformation/Chain.h" G_BEGIN_DECLS @@ -71,6 +72,8 @@ int gtk_layout_preview_get_current_style(GtkLayoutPreview* widget, layout::Style** style); +void gtk_layout_preview_set_transformation_chain(GtkLayoutPreview* widget, transformation::Chain *chain); + G_END_DECLS diff -Nru gpick-0.2.4/source/gtk/Range2D.cpp gpick-0.2.5/source/gtk/Range2D.cpp --- gpick-0.2.4/source/gtk/Range2D.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/Range2D.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,6 +20,9 @@ #include "../Color.h" #include "../MathUtil.h" #include +#ifdef _MSC_VER +#define M_PI 3.14159265359 +#endif #include #include diff -Nru gpick-0.2.4/source/gtk/Range2D.h gpick-0.2.5/source/gtk/Range2D.h --- gpick-0.2.4/source/gtk/Range2D.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/Range2D.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/gtk/SConscript gpick-0.2.5/source/gtk/SConscript --- gpick-0.2.4/source/gtk/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/SConscript 2013-01-01 16:10:52.000000000 +0000 @@ -6,17 +6,13 @@ Import('*') local_env = env.Clone() -if not local_env.GetOption('clean'): +if not local_env.GetOption('clean') and not env['TOOLCHAIN'] == 'msvc': local_env.ParseConfig('pkg-config --cflags --libs $GTK_PC') - if not env['INTERNAL_LUA']: - local_env.ParseConfig('pkg-config --cflags --libs $LUA_PC') + local_env.ParseConfig('pkg-config --cflags --libs $LUA_PC') sources = local_env.Glob('*.cpp') objects = local_env.StaticObject( source = [sources]) -if env['INTERNAL_LUA']: - Depends(objects, local_env.UseLibrary('lua')) - Return('objects') diff -Nru gpick-0.2.4/source/gtk/Swatch.cpp gpick-0.2.5/source/gtk/Swatch.cpp --- gpick-0.2.4/source/gtk/Swatch.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/Swatch.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,6 +21,8 @@ #include "../MathUtil.h" #include +#include + #define GTK_SWATCH_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_SWATCH, GtkSwatchPrivate)) G_DEFINE_TYPE (GtkSwatch, gtk_swatch, GTK_TYPE_DRAWING_AREA); @@ -42,6 +44,7 @@ typedef struct GtkSwatchPrivate { Color color[7]; gint32 current_color; + transformation::Chain *transformation_chain; } GtkSwatchPrivate; static void gtk_swatch_class_init(GtkSwatchClass *swatch_class) { @@ -91,6 +94,7 @@ for (gint32 i = 0; i < 7; ++i) color_set(&ns->color[i], i/7.0); ns->current_color = 1; + ns->transformation_chain = 0; GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS); return widget; @@ -237,6 +241,7 @@ gtk_swatch_draw_hexagon(cr, radius_multi * cos(rotation + i * (2 * PI) / edges), radius_multi * sin(rotation + i * (2 * PI) / edges), 27); } + cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); cairo_stroke(cr); cairo_set_source_rgb(cr, 1, 1, 1); @@ -244,22 +249,40 @@ * PI) / edges), 27); cairo_stroke(cr); + Color color; + //Draw fill for (int i = 1; i < 7; ++i) { if (i == ns->current_color) continue; - cairo_set_source_rgb(cr, ns->color[i].rgb.red, ns->color[i].rgb.green, ns->color[i].rgb.blue); + + if (ns->transformation_chain){ + ns->transformation_chain->apply(&ns->color[i], &color); + }else{ + color_copy(&ns->color[i], &color); + } + cairo_set_source_rgb(cr, boost::math::round(color.rgb.red * 255.0) / 255.0, boost::math::round(color.rgb.green * 255.0) / 255.0, boost::math::round(color.rgb.blue * 255.0) / 255.0); + gtk_swatch_draw_hexagon(cr, radius_multi * cos(rotation + i * (2 * PI) / edges), radius_multi * sin(rotation + i * (2 * PI) / edges), 25.5); cairo_fill(cr); } - cairo_set_source_rgb(cr, ns->color[ns->current_color].rgb.red, ns->color[ns->current_color].rgb.green, ns->color[ns->current_color].rgb.blue); - gtk_swatch_draw_hexagon(cr, radius_multi * cos(rotation + (ns->current_color) * (2 * PI) / edges), radius_multi * sin(rotation + (ns->current_color) * (2 - * PI) / edges), 25.5); + if (ns->transformation_chain){ + ns->transformation_chain->apply(&ns->color[ns->current_color], &color); + }else{ + color_copy(&ns->color[ns->current_color], &color); + } + cairo_set_source_rgb(cr, boost::math::round(color.rgb.red * 255.0) / 255.0, boost::math::round(color.rgb.green * 255.0) / 255.0, boost::math::round(color.rgb.blue * 255.0) / 255.0); + gtk_swatch_draw_hexagon(cr, radius_multi * cos(rotation + (ns->current_color) * (2 * PI) / edges), radius_multi * sin(rotation + (ns->current_color) * (2 * PI) / edges), 25.5); cairo_fill(cr); //Draw center - cairo_set_source_rgb(cr, ns->color[0].rgb.red, ns->color[0].rgb.green, ns->color[0].rgb.blue); + if (ns->transformation_chain){ + ns->transformation_chain->apply(&ns->color[0], &color); + }else{ + color_copy(&ns->color[0], &color); + } + cairo_set_source_rgb(cr, boost::math::round(color.rgb.red * 255.0) / 255.0, boost::math::round(color.rgb.green * 255.0) / 255.0, boost::math::round(color.rgb.blue * 255.0) / 255.0); gtk_swatch_draw_hexagon(cr, 0, 0, 25.5); cairo_fill(cr); @@ -267,12 +290,18 @@ char numb[2] = " "; for (int i = 1; i < 7; ++i) { Color c; - color_get_contrasting(&ns->color[i], &c); + if (ns->transformation_chain){ + Color t; + ns->transformation_chain->apply(&ns->color[i], &t); + color_get_contrasting(&t, &c); + }else{ + color_get_contrasting(&ns->color[i], &c); + } cairo_text_extents_t extends; numb[0] = '0' + i; cairo_text_extents(cr, numb, &extends); - cairo_set_source_rgb(cr, c.rgb.red, c.rgb.green, c.rgb.blue); + cairo_set_source_rgb(cr, boost::math::round(c.rgb.red * 255.0) / 255.0, boost::math::round(c.rgb.green * 255.0) / 255.0, boost::math::round(c.rgb.blue * 255.0) / 255.0); cairo_move_to(cr, radius_multi * cos(rotation + i * (2 * PI) / edges) - extends.width / 2, radius_multi * sin(rotation + i * (2 * PI) / edges) + extends.height / 2); cairo_show_text(cr, numb); @@ -347,3 +376,9 @@ return FALSE; } +void gtk_swatch_set_transformation_chain(GtkSwatch* widget, transformation::Chain *chain){ + GtkSwatchPrivate *ns = GTK_SWATCH_GET_PRIVATE(widget); + ns->transformation_chain = chain; + gtk_widget_queue_draw(GTK_WIDGET(widget)); +} + diff -Nru gpick-0.2.4/source/gtk/Swatch.h gpick-0.2.5/source/gtk/Swatch.h --- gpick-0.2.4/source/gtk/Swatch.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/Swatch.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,6 +22,7 @@ #include #include "../Color.h" +#include "../transformation/Chain.h" G_BEGIN_DECLS @@ -70,9 +71,10 @@ void gtk_swatch_get_active_color(GtkSwatch* swatch, Color* color); void gtk_swatch_set_color_count(GtkSwatch* swatch, gint32 colors); - gint gtk_swatch_get_color_at(GtkSwatch* swatch, gint x, gint y); +void gtk_swatch_set_transformation_chain(GtkSwatch* widget, transformation::Chain *chain); + GType gtk_swatch_get_type(void); G_END_DECLS diff -Nru gpick-0.2.4/source/gtk/Zoomed.cpp gpick-0.2.5/source/gtk/Zoomed.cpp --- gpick-0.2.4/source/gtk/Zoomed.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/Zoomed.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,7 +22,10 @@ #include "../MathUtil.h" #include +#include #include +#include +#include using namespace std; #define GTK_ZOOMED_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ZOOMED, GtkZoomedPrivate)) @@ -36,12 +39,13 @@ static GtkWindowClass *parent_class = NULL; +static gboolean +gtk_zoomed_button_press (GtkWidget *node_system, GdkEventButton *event); + /* static gboolean gtk_zoomed_button_release (GtkWidget *widget, GdkEventButton *event); -static gboolean -gtk_zoomed_button_press (GtkWidget *node_system, GdkEventButton *event); static gboolean gtk_zoomed_motion_notify (GtkWidget *node_system, GdkEventMotion *event); @@ -50,6 +54,7 @@ enum { COLOR_CHANGED, + ACTIVATED, LAST_SIGNAL }; @@ -66,8 +71,19 @@ GdkPixbuf *pixbuf; vector2 point; + vector2 point_size; int32_t width_height; + struct{ + bool valid; + math::Vec2 position; + }marks[2]; + + math::Vec2 pointer; + math::Vec2 screen_size; + + bool fade; + }GtkZoomedPrivate; static void @@ -84,20 +100,28 @@ /* GtkWidget signals */ widget_class->expose_event = gtk_zoomed_expose; - /*widget_class->button_release_event = gtk_zoomed_button_release; widget_class->button_press_event = gtk_zoomed_button_press; + /*widget_class->button_release_event = gtk_zoomed_button_release; widget_class->motion_notify_event = gtk_zoomed_motion_notify;*/ obj_class->finalize = gtk_zoomed_finalize; g_type_class_add_private (obj_class, sizeof (GtkZoomedPrivate)); + gtk_zoomed_signals[ACTIVATED] = g_signal_new( + "activated", + G_OBJECT_CLASS_TYPE(obj_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(GtkZoomedClass, activated), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); gtk_zoomed_signals[COLOR_CHANGED] = g_signal_new ( "color-changed", - G_OBJECT_CLASS_TYPE (obj_class), + G_OBJECT_CLASS_TYPE(obj_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GtkZoomedClass, color_changed), + G_STRUCT_OFFSET(GtkZoomedClass, color_changed), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, @@ -108,7 +132,7 @@ gtk_zoomed_init (GtkZoomed *zoomed) { gtk_widget_add_events (GTK_WIDGET (zoomed), - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK); + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK | GDK_2BUTTON_PRESS); } @@ -120,12 +144,23 @@ GtkWidget* widget=(GtkWidget*)g_object_new (GTK_TYPE_ZOOMED, NULL); GtkZoomedPrivate *ns=GTK_ZOOMED_GET_PRIVATE(widget); - ns->zoom = 2; + ns->fade = false; + ns->zoom = 20; ns->point.x = 0; ns->point.y = 0; ns->width_height = 150; ns->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, ns->width_height, ns->width_height); + int rowstride; + rowstride = gdk_pixbuf_get_rowstride(ns->pixbuf); + guchar *pixels = gdk_pixbuf_get_pixels(ns->pixbuf); + for (int y = 0; y < ns->width_height; y++){ + guchar *p = pixels + y * rowstride; + for (int x = 0; x < ns->width_height * 3; x++){ + p[x] = 0x80; + } + } + gtk_widget_set_size_request(GTK_WIDGET(widget), ns->width_height + widget->style->xthickness*2, ns->width_height + widget->style->ythickness*2); return widget; @@ -147,10 +182,26 @@ ns->width_height = width_height; ns->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, ns->width_height, ns->width_height); + int rowstride; + rowstride = gdk_pixbuf_get_rowstride(ns->pixbuf); + guchar *pixels = gdk_pixbuf_get_pixels(ns->pixbuf); + for (int y = 0; y < ns->width_height; y++){ + guchar *p = pixels + y * rowstride; + for (int x = 0; x < ns->width_height * 3; x++){ + p[x] = 0x80; + } + } + gtk_widget_set_size_request(GTK_WIDGET(zoomed), ns->width_height + GTK_WIDGET(zoomed)->style->xthickness*2, ns->width_height + GTK_WIDGET(zoomed)->style->ythickness*2); } } +void gtk_zoomed_set_fade(GtkZoomed* zoomed, bool fade){ + GtkZoomedPrivate *ns = GTK_ZOOMED_GET_PRIVATE(zoomed); + ns->fade = fade; + gtk_widget_queue_draw(GTK_WIDGET(zoomed)); +} + static void gtk_zoomed_finalize(GObject *zoomed_obj){ GtkZoomedPrivate *ns = GTK_ZOOMED_GET_PRIVATE(zoomed_obj); @@ -162,36 +213,48 @@ G_OBJECT_CLASS(parent_class)->finalize (zoomed_obj); } +static double zoom_transformation(double value) +{ + return (1 - log(1 + value * 0.01 * 3) / log((double)(1 + 3))) / 2; +} + +void gtk_zoomed_get_current_screen_rect(GtkZoomed* zoomed, math::Rect2 *rect) +{ + GtkZoomedPrivate *ns = GTK_ZOOMED_GET_PRIVATE(zoomed); + gtk_zoomed_get_screen_rect(zoomed, ns->pointer, ns->screen_size, rect); +} + void gtk_zoomed_get_screen_rect(GtkZoomed* zoomed, math::Vec2& pointer, math::Vec2& screen_size, math::Rect2 *rect){ - GtkZoomedPrivate *ns=GTK_ZOOMED_GET_PRIVATE(zoomed); + GtkZoomedPrivate *ns = GTK_ZOOMED_GET_PRIVATE(zoomed); - gint32 x=pointer.x, y=pointer.y; - gint32 width=screen_size.x, height=screen_size.y; + gint32 x = pointer.x, y = pointer.y; + gint32 width = screen_size.x, height = screen_size.y; gint32 left, right, top, bottom; - gint32 area_width = gint32(ns->width_height / ns->zoom); + gint32 area_width = uint32_t(ns->width_height * zoom_transformation(ns->zoom)); + if (!area_width) area_width = 1; - left = x - area_width/2; - top = y - area_width/2; - right = x + (area_width-area_width/2); - bottom = y + (area_width-area_width/2); - - if (left<0){ - right+=-left; - left=0; - } - if (right>width){ - left-=right-width; - right=width; - } - if (top<0){ - bottom+=-top; - top=0; - } - if (bottom>height){ - top-=bottom-height; - bottom=height; + left = x - area_width / 2; + top = y - area_width / 2; + right = x + (area_width - area_width / 2); + bottom = y + (area_width - area_width / 2); + + if (left < 0){ + right += -left; + left = 0; + } + if (right > width){ + left -= right - width; + right = width; + } + if (top < 0){ + bottom += -top; + top = 0; + } + if (bottom > height){ + top -= bottom - height; + bottom = height; } width = right - left; @@ -200,58 +263,110 @@ *rect = math::Rect2(left, top, right, bottom); } +math::Vec2 gtk_zoomed_get_screen_position(GtkZoomed* zoomed, const math::Vec2& position){ + GtkZoomedPrivate *ns=GTK_ZOOMED_GET_PRIVATE(zoomed); + + gint32 x = ns->pointer.x, y = ns->pointer.y; + gint32 width = ns->screen_size.x, height = ns->screen_size.y; + + gint32 left, right, top, bottom; + + gint32 area_width = uint32_t(ns->width_height * zoom_transformation(ns->zoom)); + if (!area_width) area_width = 1; + + left = x - area_width / 2; + top = y - area_width / 2; + right = x + (area_width - area_width / 2); + bottom = y + (area_width - area_width / 2); + + if (left < 0){ + right += -left; + left=0; + } + if (right > width){ + left -= right - width; + right = width; + } + if (top < 0){ + bottom += -top; + top = 0; + } + if (bottom > height){ + top -= bottom - height; + bottom = height; + } + + gint32 xl = ((position.x - left) * ns->width_height) / area_width; + gint32 xh = (((position.x + 1) - left) * ns->width_height) / area_width; + gint32 yl = ((position.y - top) * ns->width_height) / area_width; + gint32 yh = (((position.y + 1) - top) * ns->width_height) / area_width; + + math::Vec2 result((xl + xh) / 2.0, (yl + yh) / 2.0); + return result; +} + void gtk_zoomed_update(GtkZoomed* zoomed, math::Vec2& pointer, math::Vec2& screen_size, math::Vec2& offset, GdkPixbuf* pixbuf){ GtkZoomedPrivate *ns=GTK_ZOOMED_GET_PRIVATE(zoomed); + ns->pointer = pointer; + ns->screen_size = screen_size; + gint32 x=pointer.x, y=pointer.y; gint32 width=screen_size.x, height=screen_size.y; gint32 left, right, top, bottom; - gint32 area_width = gint32(ns->width_height / ns->zoom); + gint32 area_width = uint32_t(ns->width_height * zoom_transformation(ns->zoom)); + if (!area_width) area_width = 1; - left = x - area_width/2; - top = y - area_width/2; - right = x + (area_width-area_width/2); - bottom = y + (area_width-area_width/2); + left = x - area_width / 2; + top = y - area_width / 2; + right = x + (area_width - area_width / 2); + bottom = y + (area_width - area_width / 2); - if (left<0){ - right+=-left; + if (left < 0){ + right += -left; left=0; } - if (right>width){ - left-=right-width; - right=width; - } - if (top<0){ - bottom+=-top; - top=0; - } - if (bottom>height){ - top-=bottom-height; - bottom=height; - } - - ns->point.x = (x - left) * ns->zoom + (ns->width_height / (double)area_width)/2.0; - ns->point.y = (y - top) * ns->zoom + (ns->width_height / (double)area_width)/2.0; + if (right > width){ + left -= right - width; + right = width; + } + if (top < 0){ + bottom += -top; + top = 0; + } + if (bottom > height){ + top -= bottom - height; + bottom = height; + } + + gint32 xl = ((x - left) * ns->width_height) / area_width; + gint32 xh = (((x + 1) - left) * ns->width_height) / area_width; + gint32 yl = ((y - top) * ns->width_height) / area_width; + gint32 yh = (((y + 1) - top) * ns->width_height) / area_width; + + ns->point.x = (xl + xh) / 2.0; + ns->point.y = (yl + yh) / 2.0; + ns->point_size.x = xh - xl; + ns->point_size.y = yh - yl; width = right - left; height = bottom - top; - - gdk_pixbuf_scale(pixbuf, ns->pixbuf, 0, 0, ns->width_height, ns->width_height, offset.x, offset.y, ns->width_height / (double)width, ns->width_height / (double)height, GDK_INTERP_NEAREST); + gdk_pixbuf_scale(pixbuf, ns->pixbuf, 0, 0, ns->width_height, ns->width_height, -offset.x * ns->width_height / (double)width, -offset.y * ns->width_height / (double)height, ns->width_height / (double)width, ns->width_height / (double)height, GDK_INTERP_NEAREST); gtk_widget_queue_draw(GTK_WIDGET(zoomed)); } void gtk_zoomed_set_zoom (GtkZoomed* zoomed, gfloat zoom) { GtkZoomedPrivate *ns=GTK_ZOOMED_GET_PRIVATE(zoomed); - if (zoom<2){ - ns->zoom=2; - }else if (zoom>15){ - ns->zoom=15; + if (zoom < 0){ + ns->zoom = 0; + }else if (zoom > 100){ + ns->zoom = 100; }else{ - ns->zoom=zoom; + ns->zoom = zoom; } gtk_widget_queue_draw(GTK_WIDGET(zoomed)); } @@ -262,39 +377,158 @@ } static gboolean gtk_zoomed_expose (GtkWidget *widget, GdkEventExpose *event){ + GtkZoomedPrivate *ns = GTK_ZOOMED_GET_PRIVATE(widget); - GtkZoomedPrivate *ns=GTK_ZOOMED_GET_PRIVATE(widget); - if (ns->pixbuf){ - - gint pixbuf_x = max(event->area.x-widget->style->xthickness, 0); - gint pixbuf_y = max(event->area.y-widget->style->ythickness, 0); - - gint pixbuf_width = min(ns->width_height - pixbuf_x, ns->width_height); - gint pixbuf_height = min(ns->width_height - pixbuf_y, ns->width_height); + cairo_t *cr; + cr = gdk_cairo_create(widget->window); + cairo_translate(cr, widget->style->xthickness, widget->style->ythickness); - if (pixbuf_width>0 && pixbuf_height>0) - gdk_draw_pixbuf(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - ns->pixbuf, - pixbuf_x, pixbuf_y, - pixbuf_x+widget->style->xthickness, pixbuf_y+widget->style->ythickness, - pixbuf_width, pixbuf_height, - GDK_RGB_DITHER_NONE, 0, 0); + if (ns->pixbuf){ + gdk_cairo_set_source_pixbuf(cr, ns->pixbuf, 0, 0); + if (ns->fade){ + cairo_paint_with_alpha(cr, 0.2); + }else{ + cairo_paint(cr); + } } - cairo_t *cr; - cr = gdk_cairo_create (widget->window); + if (!ns->fade){ + float radius; + float size = vector2_length(&ns->point_size); + if (size < 5){ + radius = 5; + }else if (size < 25){ + radius = 7; + }else if (size < 50){ + radius = 10; + }else{ + radius = 15; + } - cairo_translate(cr, widget->style->xthickness, widget->style->ythickness); + cairo_set_source_rgba(cr, 0,0,0,0.75); + cairo_arc(cr, ns->point.x, ns->point.y, radius + 0.5, -PI, PI); + cairo_stroke(cr); + + cairo_set_source_rgba(cr, 1,1,1,0.75); + cairo_arc(cr, ns->point.x, ns->point.y, radius, -PI, PI); + cairo_stroke(cr); + } + + PangoLayout *layout; + PangoFontDescription *font_description; + font_description = pango_font_description_new(); + layout = pango_cairo_create_layout(cr); + + pango_font_description_set_family(font_description, "sans"); + pango_font_description_set_absolute_size(font_description, 12 * PANGO_SCALE); + pango_layout_set_font_description(layout, font_description); + + math::Rect2 area_rect; + math::Rect2 widget_rect = math::Rect2(5, 5, ns->width_height - 5, ns->width_height - 5); + gtk_zoomed_get_current_screen_rect(GTK_ZOOMED(widget), &area_rect); + + cairo_rectangle(cr, widget->style->xthickness, widget->style->ythickness, ns->width_height - widget->style->xthickness * 2, ns->width_height - widget->style->ythickness * 2); + cairo_clip(cr); + + vector > relative_positions(2); + + bool draw_distance = true; + for (int i = 0; i < 2; i++){ + if (ns->marks[i].valid){ + relative_positions[i] = gtk_zoomed_get_screen_position(GTK_ZOOMED(widget), ns->marks[i].position); + }else{ + draw_distance = false; + } + } - cairo_set_source_rgba(cr, 0,0,0,0.75); - cairo_arc(cr, ns->point.x, ns->point.y, 5.5, -PI, PI); - cairo_stroke(cr); - - cairo_set_source_rgba(cr, 1,1,1,0.75); - cairo_arc(cr, ns->point.x, ns->point.y, 5, -PI, PI); - cairo_stroke(cr); + for (int layer = 0; layer != 2; layer++){ + if (draw_distance){ + cairo_move_to(cr, relative_positions[0].x, relative_positions[0].y); + for (int i = 1; i < 2; i++){ + cairo_line_to(cr, relative_positions[i].x, relative_positions[i].y); + } + if (layer == 0){ + cairo_set_source_rgba(cr, 0, 0, 0, 1); + cairo_set_line_width(cr, 3); + }else{ + cairo_set_source_rgba(cr, 1, 1, 1, 1); + cairo_set_line_width(cr, 1); + } + cairo_stroke(cr); + } + for (int i = 0; i < 2; i++){ + if (ns->marks[i].valid){ + cairo_arc(cr, relative_positions[i].x, relative_positions[i].y, 2, -PI, PI); + + if (layer == 0){ + cairo_set_source_rgba(cr, 0, 0, 0, 1); + cairo_set_line_width(cr, 2); + cairo_stroke(cr); + }else{ + cairo_set_source_rgba(cr, 1, 1, 1, 1); + cairo_fill(cr); + } + + stringstream ss; + ss << ns->marks[i].position.x << "x" << ns->marks[i].position.y; + + pango_layout_set_text(layout, ss.str().c_str(), -1); + pango_cairo_update_layout(cr, layout); + + cairo_move_to(cr, relative_positions[i].x + 5, relative_positions[i].y); + if (layer == 0){ + cairo_set_source_rgba(cr, 0, 0, 0, 1); + pango_cairo_layout_path(cr, layout); + cairo_set_line_width(cr, 1.5); + cairo_stroke(cr); + }else{ + cairo_set_source_rgba(cr, 1, 1, 1, 1); + pango_cairo_show_layout(cr, layout); + } + } + } + } + for (int layer = 0; layer != 2; layer++){ + if (draw_distance){ + double distance = math::Vec2::distance( + math::Vec2(ns->marks[0].position.x, ns->marks[0].position.y), + math::Vec2(ns->marks[1].position.x, ns->marks[1].position.y) + ); + math::Vec2 center = (ns->marks[0].position + ns->marks[1].position) * 0.5; + + stringstream ss; + ss << fixed << setprecision(1) << distance << endl << 1 + abs(ns->marks[0].position.x - ns->marks[1].position.x) << "x" << 1 + abs(ns->marks[0].position.y - ns->marks[1].position.y); + pango_layout_set_text(layout, ss.str().c_str(), -1); + pango_cairo_update_layout(cr, layout); + + + math::Vec2 relative_position = gtk_zoomed_get_screen_position(GTK_ZOOMED(widget), center); + + PangoRectangle rect; + pango_layout_get_pixel_extents(layout, NULL, &rect); + int text_width = rect.width; + int text_height = rect.height; + + math::Rect2 text_rect(relative_position.x + 10, relative_position.y, relative_position.x + 10 + text_width, relative_position.y + text_height); + if (!text_rect.isInside(widget_rect)) + text_rect = widget_rect.positionInside(text_rect); + + cairo_move_to(cr, text_rect.getX(), text_rect.getY()); + + if (layer == 0){ + cairo_set_source_rgba(cr, 0, 0, 0, 1); + pango_cairo_layout_path(cr, layout); + cairo_set_line_width(cr, 1.5); + cairo_stroke(cr); + }else{ + cairo_set_source_rgba(cr, 1, 1, 1, 1); + pango_cairo_show_layout(cr, layout); + } + } + } + g_object_unref(layout); + pango_font_description_free(font_description); cairo_destroy (cr); @@ -303,3 +537,32 @@ return true; } +static gboolean gtk_zoomed_button_press(GtkWidget *widget, GdkEventButton *event){ + gtk_widget_grab_focus(widget); + + if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1)) { + g_signal_emit(widget, gtk_zoomed_signals[ACTIVATED], 0); + } + + return FALSE; +} + +void gtk_zoomed_set_mark(GtkZoomed *zoomed, int index, math::Vec2& position) +{ + GtkZoomedPrivate *ns = GTK_ZOOMED_GET_PRIVATE(zoomed); + + ns->marks[index].position = position; + ns->marks[index].valid = true; + + gtk_widget_queue_draw(GTK_WIDGET(zoomed)); +} + +void gtk_zoomed_clear_mark(GtkZoomed *zoomed, int index) +{ + GtkZoomedPrivate *ns = GTK_ZOOMED_GET_PRIVATE(zoomed); + + ns->marks[index].valid = false; + + gtk_widget_queue_draw(GTK_WIDGET(zoomed)); +} + diff -Nru gpick-0.2.4/source/gtk/Zoomed.h gpick-0.2.5/source/gtk/Zoomed.h --- gpick-0.2.4/source/gtk/Zoomed.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/gtk/Zoomed.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -51,17 +51,23 @@ { GtkDrawingAreaClass parent_class; void (* color_changed)(GtkWidget* widget, Color* c, gpointer userdata); + void (*activated)(GtkWidget* widget, gpointer userdata); }GtkZoomedClass; GtkWidget* gtk_zoomed_new (); -void gtk_zoomed_set_zoom (GtkZoomed* zoomed, gfloat zoom); -gfloat gtk_zoomed_get_zoom (GtkZoomed* zoomed); +void gtk_zoomed_set_zoom(GtkZoomed* zoomed, gfloat zoom); +gfloat gtk_zoomed_get_zoom(GtkZoomed* zoomed); + +void gtk_zoomed_set_fade(GtkZoomed* zoomed, bool fade); int32_t gtk_zoomed_get_size(GtkZoomed *zoomed); void gtk_zoomed_set_size(GtkZoomed *zoomed, int32_t width_height); +void gtk_zoomed_set_mark(GtkZoomed *zoomed, int index, math::Vec2& position); +void gtk_zoomed_clear_mark(GtkZoomed *zoomed, int index); + void gtk_zoomed_update(GtkZoomed* zoomed, math::Vec2& pointer, math::Vec2& screen_size, math::Vec2& offset, GdkPixbuf* pixbuf); void gtk_zoomed_get_screen_rect(GtkZoomed* zoomed, math::Vec2& pointer, math::Vec2& screen_size, math::Rect2 *rect); diff -Nru gpick-0.2.4/source/internationalisation/Internationalisation.cpp gpick-0.2.5/source/internationalisation/Internationalisation.cpp --- gpick-0.2.4/source/internationalisation/Internationalisation.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/internationalisation/Internationalisation.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef ENABLE_NLS +#include +#endif +#include +#include +#include + +#define TO_STRING(x) #x +#define T_(x) TO_STRING(x) + +void initialize_internationalisation() +{ +#ifdef ENABLE_NLS + bindtextdomain("gpick", T_(LOCALEDIR)); + + char *td = textdomain("gpick"); + if (!(td && (strcmp(td, "gpick") == 0))){ + fprintf(stderr, "failed to load textdomain \"gpick\"\n"); + } +#endif +} + diff -Nru gpick-0.2.4/source/internationalisation/SConscript gpick-0.2.5/source/internationalisation/SConscript --- gpick-0.2.4/source/internationalisation/SConscript 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/internationalisation/SConscript 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import os +import sys + +Import('*') +local_env = env.Clone() + +if not local_env.GetOption('clean'): + if local_env['ENABLE_NLS']: + local_env.Append( + CPPDEFINES = ['ENABLE_NLS', 'LOCALEDIR=' + local_env['LOCALEDIR']], + ) + +sources = local_env.Glob('*.cpp') +objects = local_env.StaticObject([sources]) + +Return('objects') diff -Nru gpick-0.2.4/source/layout/Box.cpp gpick-0.2.5/source/layout/Box.cpp --- gpick-0.2.4/source/layout/Box.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/Box.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,6 +21,9 @@ #include #include #include + +#include + using namespace std; using namespace math; @@ -36,23 +39,15 @@ } } -void Box::Draw(cairo_t *cr, const Rect2& parent_rect ){ - /*Rect2 draw_rect = rect; - draw_rect.impose( parent_rect ); - - cairo_set_source_rgb(cr, 1, 1, 1); - cairo_rectangle(cr, draw_rect.getX(), draw_rect.getY(), draw_rect.getWidth(), draw_rect.getHeight()); - cairo_fill(cr);*/ - - DrawChildren(cr, parent_rect); +void Box::Draw(Context *context, const Rect2& parent_rect ){ + DrawChildren(context, parent_rect); } -void Box::DrawChildren(cairo_t *cr, const math::Rect2& parent_rect ){ - Rect2 child_rect = rect; - child_rect.impose( parent_rect ); +void Box::DrawChildren(Context *context, const math::Rect2& parent_rect ){ + Rect2 child_rect = rect.impose( parent_rect ); for (list::iterator i = child.begin(); i!=child.end(); i++){ - (*i)->Draw(cr, child_rect); + (*i)->Draw(context, child_rect); } } @@ -112,9 +107,10 @@ } } -void Text::Draw(cairo_t *cr, const Rect2& parent_rect ){ - Rect2 draw_rect = rect; - draw_rect.impose( parent_rect ); +void Text::Draw(Context *context, const Rect2& parent_rect ){ + Rect2 draw_rect = rect.impose( parent_rect ); + + cairo_t *cr = context->getCairo(); if (text!=""){ if (helper_only){ @@ -124,7 +120,14 @@ } if (style){ cairo_set_font_size(cr, style->font_size * draw_rect.getHeight()); - cairo_set_source_rgb(cr, style->color.rgb.red, style->color.rgb.green, style->color.rgb.blue); + Color color; + if (context->getTransformationChain()){ + context->getTransformationChain()->apply(&style->color, &color); + }else{ + color_copy(&style->color, &color); + } + + cairo_set_source_rgb(cr, boost::math::round(color.rgb.red * 255.0) / 255.0, boost::math::round(color.rgb.green * 255.0) / 255.0, boost::math::round(color.rgb.blue * 255.0) / 255.0); }else{ cairo_set_font_size(cr, draw_rect.getHeight()); cairo_set_source_rgb(cr, 0, 0, 0); @@ -145,14 +148,21 @@ } } - DrawChildren(cr, parent_rect); + DrawChildren(context, parent_rect); } -void Fill::Draw(cairo_t *cr, const Rect2& parent_rect ){ - Rect2 draw_rect = rect; - draw_rect.impose( parent_rect ); +void Fill::Draw(Context *context, const Rect2& parent_rect ){ + Rect2 draw_rect = rect.impose( parent_rect ); + + cairo_t *cr = context->getCairo(); - cairo_set_source_rgb(cr, style->color.rgb.red, style->color.rgb.green, style->color.rgb.blue); + Color color; + if (context->getTransformationChain()){ + context->getTransformationChain()->apply(&style->color, &color); + }else{ + color_copy(&style->color, &color); + } + cairo_set_source_rgb(cr, boost::math::round(color.rgb.red * 255.0) / 255.0, boost::math::round(color.rgb.green * 255.0) / 255.0, boost::math::round(color.rgb.blue * 255.0) / 255.0); cairo_rectangle(cr, draw_rect.getX(), draw_rect.getY(), draw_rect.getWidth(), draw_rect.getHeight()); cairo_fill(cr); @@ -163,7 +173,7 @@ cairo_stroke(cr); } - DrawChildren(cr, parent_rect); + DrawChildren(context, parent_rect); } diff -Nru gpick-0.2.4/source/layout/Box.h gpick-0.2.5/source/layout/Box.h --- gpick-0.2.4/source/layout/Box.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/Box.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -25,6 +25,7 @@ #include "ReferenceCounter.h" #include "Style.h" +#include "Context.h" #include @@ -43,8 +44,8 @@ math::Rect2 rect; std::list child; - virtual void Draw(cairo_t *cr, const math::Rect2& parent_rect ); - void DrawChildren(cairo_t *cr, const math::Rect2& parent_rect ); + virtual void Draw(Context *context, const math::Rect2& parent_rect ); + void DrawChildren(Context *context, const math::Rect2& parent_rect ); void AddChild(Box* box); void SetStyle(Style *style); @@ -61,14 +62,14 @@ public: std::string text; - virtual void Draw(cairo_t *cr, const math::Rect2& parent_rect ); + virtual void Draw(Context *context, const math::Rect2& parent_rect ); Text(const char* name, float x, float y, float width, float height):Box(name,x,y,width,height){ }; }; class Fill:public Box{ public: - virtual void Draw(cairo_t *cr, const math::Rect2& parent_rect ); + virtual void Draw(Context *context, const math::Rect2& parent_rect ); Fill(const char* name, float x, float y, float width, float height):Box(name,x,y,width,height){ }; }; diff -Nru gpick-0.2.4/source/layout/Context.cpp gpick-0.2.5/source/layout/Context.cpp --- gpick-0.2.4/source/layout/Context.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/layout/Context.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "Context.h" + +namespace layout{ + +Context::Context(cairo_t *cr_, transformation::Chain *chain_) +{ + cr = cr_; + chain = chain_; +} + +Context::~Context() +{ + +} + +cairo_t* Context::getCairo() const +{ + return cr; +} + +transformation::Chain* Context::getTransformationChain() const +{ + return chain; +} + +} + diff -Nru gpick-0.2.4/source/layout/Context.h gpick-0.2.5/source/layout/Context.h --- gpick-0.2.4/source/layout/Context.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/layout/Context.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef LAYOUT_CONTEXT_H_ +#define LAYOUT_CONTEXT_H_ + +#include "../transformation/Chain.h" + +#include +#ifndef _MSC_VER +#include +#endif +#include +#include +#include + +namespace layout{ + +class Context{ +protected: + cairo_t *cr; + transformation::Chain *chain; +public: + Context(cairo_t *cr, transformation::Chain *chain); + ~Context(); + + cairo_t* getCairo() const; + transformation::Chain* getTransformationChain() const; +}; + +} + +#endif /* LAYOUT_SYSTEM_H_ */ + diff -Nru gpick-0.2.4/source/layout/Layout.cpp gpick-0.2.5/source/layout/Layout.cpp --- gpick-0.2.4/source/layout/Layout.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/Layout.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/layout/Layout.h gpick-0.2.5/source/layout/Layout.h --- gpick-0.2.4/source/layout/Layout.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/Layout.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,7 +20,9 @@ #define LAYOUT_LAYOUT_H_ #include "../dynv/DynvSystem.h" +#ifndef _MSC_VER #include +#endif #include #include "System.h" diff -Nru gpick-0.2.4/source/layout/LuaBindings.cpp gpick-0.2.5/source/layout/LuaBindings.cpp --- gpick-0.2.4/source/layout/LuaBindings.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/LuaBindings.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -77,13 +77,14 @@ } -static const struct luaL_reg lua_lstylelib_f [] = { +static const struct luaL_Reg lua_lstylelib_f [] = { {"new", lua_lstyle_new}, {NULL, NULL} }; -static const struct luaL_reg lua_lstylelib_m [] = { +static const struct luaL_Reg lua_lstylelib_m [] = { {"humanname", lua_lstyle_humanname}, + {"__gc", lua_lstyle_gc}, {NULL, NULL} }; @@ -209,23 +210,24 @@ } } -int lua_gclbox (lua_State *L) { +int lua_box_gc(lua_State *L) { Box* box = lua_checklbox(L, 1); Box::unref(box); return 0; } -static const struct luaL_reg lua_lboxlib_f [] = { +static const struct luaL_Reg lua_lboxlib_f [] = { {"new_box", lua_new_box}, {"new_text", lua_new_text}, {"new_fill", lua_new_fill}, {NULL, NULL} }; -static const struct luaL_reg lua_lboxlib_m [] = { +static const struct luaL_Reg lua_lboxlib_m [] = { {"add", lua_add}, {"helper_only", lua_box_helper_only}, {"locked", lua_box_locked}, + {"__gc", lua_box_gc}, {NULL, NULL} }; @@ -261,7 +263,7 @@ return 0; } -static const struct luaL_reg lua_systemlib_m [] = { +static const struct luaL_Reg lua_systemlib_m [] = { {"addstyle", lua_lsystem_addstyle}, {"setbox", lua_lsystem_setbox}, {NULL, NULL} @@ -270,41 +272,29 @@ int luaopen_lbox (lua_State *L) { luaL_newmetatable(L, "layout"); + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + luaL_setfuncs(L, lua_lboxlib_m, 0); + lua_pop(L, 1); - lua_pushstring(L, "__index"); - lua_pushvalue(L, -2); /* pushes the metatable */ - lua_settable(L, -3); /* metatable.__index = metatable */ - - lua_pushstring(L, "__gc"); - lua_pushcfunction(L, lua_gclbox); - lua_settable(L, -3); - - luaL_register(L, NULL, lua_lboxlib_m); - luaL_register(L, "layout", lua_lboxlib_f); - lua_pop(L, 2); - + luaL_newlibtable(L, lua_lboxlib_f); + luaL_setfuncs(L, lua_lboxlib_f, 0); + lua_setglobal(L, "layout"); luaL_newmetatable(L, "layout_style"); + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + luaL_setfuncs(L, lua_lstylelib_m, 0); + lua_pop(L, 1); - lua_pushstring(L, "__index"); - lua_pushvalue(L, -2); /* pushes the metatable */ - lua_settable(L, -3); /* metatable.__index = metatable */ - - lua_pushstring(L, "__gc"); - lua_pushcfunction(L, lua_lstyle_gc); - lua_settable(L, -3); - - luaL_register(L, NULL, lua_lstylelib_m); - luaL_register(L, "layout_style", lua_lstylelib_f); - lua_pop(L, 2); + luaL_newlibtable(L, lua_lstylelib_f); + luaL_setfuncs(L, lua_lstylelib_f, 0); + lua_setglobal(L, "layout_style"); luaL_newmetatable(L, "layout_system"); - - lua_pushstring(L, "__index"); - lua_pushvalue(L, -2); /* pushes the metatable */ - lua_settable(L, -3); /* metatable.__index = metatable */ - - luaL_register(L, NULL, lua_systemlib_m); + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + luaL_setfuncs(L, lua_systemlib_m, 0); lua_pop(L, 1); return 1; diff -Nru gpick-0.2.4/source/layout/LuaBindings.h gpick-0.2.5/source/layout/LuaBindings.h --- gpick-0.2.4/source/layout/LuaBindings.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/LuaBindings.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/layout/ReferenceCounter.cpp gpick-0.2.5/source/layout/ReferenceCounter.cpp --- gpick-0.2.4/source/layout/ReferenceCounter.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/ReferenceCounter.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/layout/ReferenceCounter.h gpick-0.2.5/source/layout/ReferenceCounter.h --- gpick-0.2.4/source/layout/ReferenceCounter.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/ReferenceCounter.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,7 +20,9 @@ #define LAYOUT_REFERENCECOUNTER_H_ #include +#ifndef _MSC_VER #include +#endif namespace layout{ diff -Nru gpick-0.2.4/source/layout/SConscript gpick-0.2.5/source/layout/SConscript --- gpick-0.2.4/source/layout/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/SConscript 2013-01-01 16:10:52.000000000 +0000 @@ -6,17 +6,13 @@ Import('*') local_env = env.Clone() -if not local_env.GetOption('clean'): +if not local_env.GetOption('clean') and not env['TOOLCHAIN'] == 'msvc': local_env.ParseConfig('pkg-config --cflags --libs $GTK_PC') - if not env['INTERNAL_LUA']: - local_env.ParseConfig('pkg-config --cflags --libs $LUA_PC') + local_env.ParseConfig('pkg-config --cflags --libs $LUA_PC') sources = local_env.Glob('*.cpp') objects = local_env.StaticObject( source = [sources]) -if env['INTERNAL_LUA']: - Depends(objects, local_env.UseLibrary('lua')) - Return('objects') diff -Nru gpick-0.2.4/source/layout/Style.cpp gpick-0.2.5/source/layout/Style.cpp --- gpick-0.2.4/source/layout/Style.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/Style.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/layout/Style.h gpick-0.2.5/source/layout/Style.h --- gpick-0.2.4/source/layout/Style.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/Style.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/layout/System.cpp gpick-0.2.5/source/layout/System.cpp --- gpick-0.2.4/source/layout/System.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/System.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -34,9 +34,9 @@ Box::unref(box); } -void System::Draw(cairo_t *cr, const math::Rect2& parent_rect ){ +void System::Draw(Context *context, const math::Rect2& parent_rect ){ if (!box) return; - box->Draw(cr, parent_rect); + box->Draw(context, parent_rect); } void System::AddStyle(Style *_style){ diff -Nru gpick-0.2.4/source/layout/System.h gpick-0.2.5/source/layout/System.h --- gpick-0.2.4/source/layout/System.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/layout/System.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -23,10 +23,13 @@ #include "../Vector2.h" #include "Box.h" #include "Style.h" +#include "Context.h" #include "ReferenceCounter.h" #include +#ifndef _MSC_VER #include +#endif #include #include #include @@ -41,7 +44,7 @@ System(); virtual ~System(); - void Draw(cairo_t *cr, const math::Rect2& parent_rect ); + void Draw(Context *context, const math::Rect2& parent_rect ); Box* GetBoxAt(const math::Vec2& point); Box* GetNamedBox(const char *name); diff -Nru gpick-0.2.4/source/main.cpp gpick-0.2.5/source/main.cpp --- gpick-0.2.4/source/main.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/main.cpp 2013-01-05 15:43:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,15 +21,24 @@ #include "Paths.h" #include "uiAbout.h" #include "uiApp.h" +#include "Internationalisation.h" +#include "version/Version.h" +#include "DynvHelpers.h" #include +#include +using namespace std; -static gchar **commandline_filename=NULL; -static gchar *commandline_geometry=NULL; +static gchar **commandline_filename = NULL; +static gchar *commandline_geometry = NULL; +static gboolean pick_color = FALSE; +static gboolean version_information = FALSE; static GOptionEntry commandline_entries[] = { - { "geometry", 'g', 0, G_OPTION_ARG_STRING, &commandline_geometry, "Window geometry", "GEOMETRY" }, - { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &commandline_filename, NULL, "[FILE...]" }, + { "geometry", 'g', 0, G_OPTION_ARG_STRING, &commandline_geometry, "Window geometry", "GEOMETRY" }, + { "pick", 'p', 0, G_OPTION_ARG_NONE, &pick_color, "Pick a color", NULL }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &version_information, "Print version information", NULL }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &commandline_filename, NULL, "[FILE...]" }, { NULL } }; @@ -37,6 +46,9 @@ gtk_set_locale(); gtk_init(&argc, &argv); + + initialize_internationalisation(); + g_set_application_name(program_name); gchar* tmp; @@ -57,10 +69,29 @@ return -1; } - AppArgs *args = app_create_main(); + if (version_information){ + string version = string(program_name) + " version " + string(gpick_build_version); + string revision = "Revision " + string(gpick_build_revision); + string build_date = "Built at " + string(gpick_build_date); + g_print ("%s\n%s\n%s\n", version.c_str(), revision.c_str(), build_date.c_str()); + return 0; + } + + AppOptions options; + options.floating_picker_mode = pick_color; + + AppArgs *args = app_create_main(&options); if (args){ - if (commandline_filename) app_load_file(args, commandline_filename[0]); + if (commandline_filename){ + app_load_file(args, commandline_filename[0]); + }else{ + if (app_is_autoload_enabled(args)){ + gchar* autosave_file = build_config_path("autosave.gpa"); + app_load_file(args, autosave_file, true); + g_free(autosave_file); + } + } if (commandline_geometry) app_parse_geometry(args, commandline_geometry); int r = app_run(args); diff -Nru gpick-0.2.4/source/main.h gpick-0.2.5/source/main.h --- gpick-0.2.4/source/main.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/main.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/tools/PaletteFromCssFile.cpp gpick-0.2.5/source/tools/PaletteFromCssFile.cpp --- gpick-0.2.4/source/tools/PaletteFromCssFile.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/tools/PaletteFromCssFile.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -29,9 +29,9 @@ void tools_palette_from_css_file_show(GtkWindow* parent, GlobalState* gs) { +#ifdef EXPERIMENTAL_CSS_PARSER parse_file("test.css"); - - +#endif } diff -Nru gpick-0.2.4/source/tools/PaletteFromCssFile.h gpick-0.2.5/source/tools/PaletteFromCssFile.h --- gpick-0.2.4/source/tools/PaletteFromCssFile.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/tools/PaletteFromCssFile.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/tools/PaletteFromImage.cpp gpick-0.2.5/source/tools/PaletteFromImage.cpp --- gpick-0.2.4/source/tools/PaletteFromImage.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/tools/PaletteFromImage.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,7 +20,9 @@ #include "../uiUtilities.h" #include "../uiListPalette.h" #include "../GlobalStateStruct.h" +#include "../ToolColorNaming.h" #include "../DynvHelpers.h" +#include "../Internationalisation.h" #include #include @@ -69,8 +71,8 @@ string filename; uint32_t n_colors; - string previuos_filename; - Node *previuos_node; + string previous_filename; + Node *previous_node; struct ColorList *color_list; struct ColorList *preview_color_list; @@ -79,6 +81,29 @@ GlobalState* gs; }PaletteFromImageArgs; +class PaletteColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + const char *m_filename; + int m_index; + public: + PaletteColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + m_index = 0; + } + + void assign(struct ColorObject *color_object, Color *color, const char *filename, const int index){ + m_filename = filename; + m_index = index; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << m_filename << " #" << m_index; + return m_stream.str(); + } +}; + /** * Allocate and initialize a new node with specified parent * @param[in] parent Parent node @@ -225,19 +250,18 @@ } static void node_reduce(Node *node, uint32_t colors){ - PruneData prune_data; - prune_data.n_colors = node_count_leafs(node); - prune_data.n_colors_target = colors; - prune_data.threshold = 0; + PruneData prune_data; + prune_data.n_colors = node_count_leafs(node); + prune_data.n_colors_target = colors; + prune_data.threshold = 0; - while (prune_data.n_colors > colors){ - prune_data.min_distance = node->distance; + while (prune_data.n_colors > colors){ + prune_data.min_distance = node->distance; - if (node_prune_threshold(node, &prune_data)) break; + if (node_prune_threshold(node, &prune_data)) break; - prune_data.threshold = prune_data.min_distance; + prune_data.threshold = prune_data.min_distance; } - } static void node_update(Node *node, Color *color, Cube *cube, uint32_t max_depth){ @@ -306,17 +330,17 @@ static Node* process_image(PaletteFromImageArgs *args, const char *filename, Node* node){ - if (args->previuos_filename == filename){ - if (args->previuos_node) - return node_copy(args->previuos_node, 0); + if (args->previous_filename == filename){ + if (args->previous_node) + return node_copy(args->previous_node, 0); else return 0; } - args->previuos_filename = filename; - if (args->previuos_node){ - node_delete(args->previuos_node); - args->previuos_node = 0; + args->previous_filename = filename; + if (args->previous_node){ + node_delete(args->previous_node); + args->previous_node = 0; } GError *error = NULL; @@ -344,7 +368,7 @@ Color color; - args->previuos_node = node_new(0); + args->previous_node = node_new(0); for (int y = 0; y < height; y++){ ptr = image_data + rowstride * y; @@ -354,7 +378,7 @@ color.xyz.y = ptr[1] / 255.0; color.xyz.z = ptr[2] / 255.0; - node_update(args->previuos_node, &color, &cube, 5); + node_update(args->previous_node, &color, &cube, 5); ptr += channels; } @@ -362,9 +386,9 @@ g_object_unref(pixbuf); - node_reduce(args->previuos_node, 200); + node_reduce(args->previous_node, 200); - return node_copy(args->previuos_node, 0); + return node_copy(args->previous_node, 0); } @@ -398,7 +422,10 @@ static void calc(PaletteFromImageArgs *args, bool preview, int limit){ Node *root_node = 0; - if (!args->filename.empty()) + int index = 0; + gchar *name = g_path_get_basename(args->filename.c_str()); + PaletteColorNameAssigner name_assigner(args->gs); + if (!args->filename.empty()) root_node = process_image(args, args->filename.c_str(), root_node); struct ColorList *color_list; @@ -418,10 +445,10 @@ for (list::iterator i = tmp_list.begin(); i != tmp_list.end(); i++){ struct ColorObject *color_object = color_list_new_color_object(color_list, &(*i)); - string name = color_names_get(args->gs->color_names, &(*i), dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true)); - dynv_set_string(color_object->params, "name", name.c_str()); + name_assigner.assign(color_object, &(*i), name, index); color_list_add_color_object(color_list, color_object, 1); color_object_release(color_object); + index++; } } @@ -440,7 +467,7 @@ static void destroy_cb(GtkWidget* widget, PaletteFromImageArgs *args){ - if (args->previuos_node) node_delete(args->previuos_node); + if (args->previous_node) node_delete(args->previous_node); color_list_destroy(args->preview_color_list); dynv_system_release(args->params); @@ -477,14 +504,14 @@ PaletteFromImageArgs *args = new PaletteFromImageArgs; - args->previuos_filename = ""; + args->previous_filename = ""; args->gs = gs; args->params = dynv_get_dynv(args->gs->params, "gpick.tools.palette_from_image"); - args->previuos_node = 0; + args->previous_node = 0; GtkWidget *table, *table_m, *widget; - GtkWidget *dialog = gtk_dialog_new_with_buttons("Palette from image", parent, GtkDialogFlags(GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_ADD, GTK_RESPONSE_APPLY, NULL); + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Palette from image"), parent, GtkDialogFlags(GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_ADD, GTK_RESPONSE_APPLY, NULL); gtk_window_set_default_size(GTK_WINDOW(dialog), dynv_get_int32_wd(args->params, "window.width", -1), dynv_get_int32_wd(args->params, "window.height", -1)); @@ -497,7 +524,7 @@ table_m = gtk_table_new(3, 1, FALSE); table_m_y = 0; - frame = gtk_frame_new("Image"); + frame = gtk_frame_new(_("Image")); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); table_m_y++; @@ -506,7 +533,7 @@ table_y=0; gtk_container_add(GTK_CONTAINER(frame), table); - args->file_browser = widget = gtk_file_chooser_button_new("Image file", GTK_FILE_CHOOSER_ACTION_OPEN); + args->file_browser = widget = gtk_file_chooser_button_new(_("Image file"), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget), dynv_get_string_wd(args->params, "current_folder", "")); gtk_table_attach(GTK_TABLE(table), widget, 0, 3, table_y, table_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); g_signal_connect(G_OBJECT(args->file_browser), "file-set", G_CALLBACK(update), args); @@ -518,7 +545,7 @@ GtkFileFilter *all_image_filter; filter = gtk_file_filter_new(); - gtk_file_filter_set_name(filter, "All files"); + gtk_file_filter_set_name(filter, _("All files")); gtk_file_filter_add_pattern(filter, "*"); g_object_set_data_full(G_OBJECT(filter), "name", (void*)"all_files", GDestroyNotify(NULL)); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(widget), filter); @@ -526,7 +553,7 @@ all_image_filter = gtk_file_filter_new(); - gtk_file_filter_set_name(all_image_filter, "All images"); + gtk_file_filter_set_name(all_image_filter, _("All images")); g_object_set_data_full(G_OBJECT(all_image_filter), "name", (void*)"all_images", GDestroyNotify(NULL)); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(widget), all_image_filter); if (g_strcmp0("all_images", selected_filter) == 0) gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(widget), all_image_filter); @@ -559,7 +586,7 @@ if (formats) g_slist_free(formats); - frame = gtk_frame_new("Options"); + frame = gtk_frame_new(_("Options")); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); table_m_y++; @@ -569,7 +596,7 @@ - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Colors:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Colors:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->range_colors = widget = gtk_spin_button_new_with_range (1, 100, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->range_colors), dynv_get_int32_wd(args->params, "colors", 3)); gtk_table_attach(GTK_TABLE(table), widget,1,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); @@ -578,7 +605,7 @@ /* - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Threshold:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Threshold:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->merge_threshold = widget = gtk_hscale_new_with_range(0, 100, 0.1); gtk_range_set_value(GTK_RANGE(widget), dynv_get_float_wd(args->params, "merge_threshold", 20)); g_signal_connect(G_OBJECT(widget), "value-changed", G_CALLBACK(update), args); @@ -589,7 +616,7 @@ */ struct ColorList* preview_color_list = NULL; - gtk_table_attach(GTK_TABLE(table_m), args->preview_expander = palette_list_preview_new(gs, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 1, table_m_y, table_m_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); + gtk_table_attach(GTK_TABLE(table_m), args->preview_expander = palette_list_preview_new(gs, true, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 1, table_m_y, table_m_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); table_m_y++; args->preview_color_list = preview_color_list; diff -Nru gpick-0.2.4/source/tools/PaletteFromImage.h gpick-0.2.5/source/tools/PaletteFromImage.h --- gpick-0.2.4/source/tools/PaletteFromImage.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/tools/PaletteFromImage.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/tools/SConscript gpick-0.2.5/source/tools/SConscript --- gpick-0.2.4/source/tools/SConscript 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/tools/SConscript 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,21 @@ +#!/usr/bin/env python +Import('*') +local_env = env.Clone() + +if not local_env.GetOption('clean') and not env['TOOLCHAIN'] == 'msvc': + local_env.ParseConfig('pkg-config --cflags --libs $GTK_PC') + local_env.ParseConfig('pkg-config --cflags --libs $LUA_PC') + +if local_env['ENABLE_NLS']: + local_env.Append( + CPPDEFINES = ['ENABLE_NLS'], + ) + +if env['EXPERIMENTAL_CSS_PARSER']: + local_env.Append( + CPPDEFINES = ['EXPERIMENTAL_CSS_PARSER'], + ) +sources = local_env.Glob('*.cpp') +objects = local_env.StaticObject( + source = [sources]) +Return('objects') diff -Nru gpick-0.2.4/source/transformation/Chain.cpp gpick-0.2.5/source/transformation/Chain.cpp --- gpick-0.2.4/source/transformation/Chain.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Chain.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Chain.h" + +using namespace std; + +namespace transformation { + +Chain::Chain() +{ + enabled = true; +} + +void Chain::apply(const Color *input, Color *output) +{ + if (!enabled) { + color_copy(input, output); + return; + } + Color tmp[2]; + Color *tmp_p[3]; + + color_copy(input, &tmp[0]); + + tmp_p[0] = &tmp[0]; + tmp_p[1] = &tmp[1]; + for (TransformationList::iterator i = transformation_chain.begin(); i != transformation_chain.end(); i++){ + + (*i)->apply(tmp_p[0], tmp_p[1]); + + tmp_p[2] = tmp_p[0]; + tmp_p[0] = tmp_p[1]; + tmp_p[1] = tmp_p[2]; + } + + color_copy(tmp_p[0], output); +} + +void Chain::add(boost::shared_ptr transformation) +{ + transformation_chain.push_back(transformation); +} + +void Chain::remove(const Transformation *transformation) +{ + for (TransformationList::iterator i = transformation_chain.begin(); i != transformation_chain.end(); i++){ + if ((*i).get() == transformation){ + transformation_chain.erase(i); + return; + } + } +} + +void Chain::clear() +{ + transformation_chain.clear(); +} + +Chain::TransformationList& Chain::getAll() +{ + return transformation_chain; +} + +void Chain::setEnabled(bool enabled_) +{ + enabled = enabled_; +} + +} + diff -Nru gpick-0.2.4/source/transformation/Chain.h gpick-0.2.5/source/transformation/Chain.h --- gpick-0.2.4/source/transformation/Chain.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Chain.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMATION_CHAIN_H_ +#define TRANSFORMATION_CHAIN_H_ + +#include "Transformation.h" +#include +#include + +/** \file source/transformation/Chain.h + * \brief Class for transformation object list handling. + */ + +namespace transformation { + +/** \class Chain + * \brief Transformation object chain management class. + */ +class Chain{ + public: + typedef std::list > TransformationList; + protected: + TransformationList transformation_chain; + bool enabled; + public: + /** + * Chain constructor. + */ + Chain(); + + /** + * Apply transformation chain to color. + * @param[in] input Source color in RGB color space. + * @param[out] output Destination color in RGB color space. + */ + void apply(const Color *input, Color *output); + + /** + * Add transformation object into the list. + * @param[in] transformation Transformation object. + */ + void add(boost::shared_ptr transformation); + + /** + * Remove transformation object from the list. + * @param[in] transformation Transformation object. + */ + void remove(const Transformation *transformation); + + /** + * Clear transformation object list. + */ + void clear(); + + /** + * Enable/disable transformation chain. + * @param[in] enabled Enabled. + */ + void setEnabled(bool enabled); + + /** + * Get the list of transformation objects. + * @return Transformation object list. + */ + TransformationList& getAll(); +}; + +} + +#endif /* TRANSFORMATION_CHAIN_H_ */ + diff -Nru gpick-0.2.4/source/transformation/ColorVisionDeficiency.cpp gpick-0.2.5/source/transformation/ColorVisionDeficiency.cpp --- gpick-0.2.4/source/transformation/ColorVisionDeficiency.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/ColorVisionDeficiency.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,449 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ColorVisionDeficiency.h" +#include "../MathUtil.h" +#include "../uiUtilities.h" +#include "../Internationalisation.h" +#include +#include +#include + +#include +using namespace std; + +namespace transformation { + +static const char * transformation_name = "color_vision_deficiency"; + +const char *ColorVisionDeficiency::getName() +{ + return transformation_name; +} + +const char *ColorVisionDeficiency::getReadableName() +{ + return _("Color vision deficiency"); +} + +const char* ColorVisionDeficiency::deficiency_type_string[] = { + "protanomaly", + "deuteranomaly", + "tritanomaly", + "protanopia", + "deuteranopia", + "tritanopia", +}; + +const double protanomaly[11][9] = { +{1.000000,0.000000,-0.000000,0.000000,1.000000,0.000000,-0.000000,-0.000000,1.000000}, +{0.856167,0.182038,-0.038205,0.029342,0.955115,0.015544,-0.002880,-0.001563,1.004443}, +{0.734766,0.334872,-0.069637,0.051840,0.919198,0.028963,-0.004928,-0.004209,1.009137}, +{0.630323,0.465641,-0.095964,0.069181,0.890046,0.040773,-0.006308,-0.007724,1.014032}, +{0.539009,0.579343,-0.118352,0.082546,0.866121,0.051332,-0.007136,-0.011959,1.019095}, +{0.458064,0.679578,-0.137642,0.092785,0.846313,0.060902,-0.007494,-0.016807,1.024301}, +{0.385450,0.769005,-0.154455,0.100526,0.829802,0.069673,-0.007442,-0.022190,1.029632}, +{0.319627,0.849633,-0.169261,0.106241,0.815969,0.077790,-0.007025,-0.028051,1.035076}, +{0.259411,0.923008,-0.182420,0.110296,0.804340,0.085364,-0.006276,-0.034346,1.040622}, +{0.203876,0.990338,-0.194214,0.112975,0.794542,0.092483,-0.005222,-0.041043,1.046265}, +{0.152286,1.052583,-0.204868,0.114503,0.786281,0.099216,-0.003882,-0.048116,1.051998}, +}; + +const double deuteranomaly[11][9] = { +{1.000000,0.000000,-0.000000,0.000000,1.000000,0.000000,-0.000000,-0.000000,1.000000}, +{0.866435,0.177704,-0.044139,0.049567,0.939063,0.011370,-0.003453,0.007233,0.996220}, +{0.760729,0.319078,-0.079807,0.090568,0.889315,0.020117,-0.006027,0.013325,0.992702}, +{0.675425,0.433850,-0.109275,0.125303,0.847755,0.026942,-0.007950,0.018572,0.989378}, +{0.605511,0.528560,-0.134071,0.155318,0.812366,0.032316,-0.009376,0.023176,0.986200}, +{0.547494,0.607765,-0.155259,0.181692,0.781742,0.036566,-0.010410,0.027275,0.983136}, +{0.498864,0.674741,-0.173604,0.205199,0.754872,0.039929,-0.011131,0.030969,0.980162}, +{0.457771,0.731899,-0.189670,0.226409,0.731012,0.042579,-0.011595,0.034333,0.977261}, +{0.422823,0.781057,-0.203881,0.245752,0.709602,0.044646,-0.011843,0.037423,0.974421}, +{0.392952,0.823610,-0.216562,0.263559,0.690210,0.046232,-0.011910,0.040281,0.971630}, +{0.367322,0.860646,-0.227968,0.280085,0.672501,0.047413,-0.011820,0.042940,0.968881}, +}; + +const double tritanomaly[11][9] = { +{1.000000,0.000000,-0.000000,0.000000,1.000000,0.000000,-0.000000,-0.000000,1.000000}, +{0.926670,0.092514,-0.019184,0.021191,0.964503,0.014306,0.008437,0.054813,0.936750}, +{0.895720,0.133330,-0.029050,0.029997,0.945400,0.024603,0.013027,0.104707,0.882266}, +{0.905871,0.127791,-0.033662,0.026856,0.941251,0.031893,0.013410,0.148296,0.838294}, +{0.948035,0.089490,-0.037526,0.014364,0.946792,0.038844,0.010853,0.193991,0.795156}, +{1.017277,0.027029,-0.044306,-0.006113,0.958479,0.047634,0.006379,0.248708,0.744913}, +{1.104996,-0.046633,-0.058363,-0.032137,0.971635,0.060503,0.001336,0.317922,0.680742}, +{1.193214,-0.109812,-0.083402,-0.058496,0.979410,0.079086,-0.002346,0.403492,0.598854}, +{1.257728,-0.139648,-0.118081,-0.078003,0.975409,0.102594,-0.003316,0.501214,0.502102}, +{1.278864,-0.125333,-0.153531,-0.084748,0.957674,0.127074,-0.000989,0.601151,0.399838}, +{1.255528,-0.076749,-0.178779,-0.078411,0.930809,0.147602,0.004733,0.691367,0.303900}, +}; + +const double rgb_to_lms[3][3] = { +{0.05059983, 0.08585369, 0.00952420}, +{0.01893033, 0.08925308, 0.01370054}, +{0.00292202, 0.00975732, 0.07145979}, +}; + +const double lms_to_rgb[3][3] = { +{30.830854, -29.832659, 1.610474}, +{-6.481468, 17.715578, -2.532642}, +{-0.375690, -1.199062, 14.273846}, +}; + +const double anchor[] = { +0.080080, 0.157900, 0.589700, +0.128400, 0.223700, 0.363600, +0.985600, 0.732500, 0.001079, +0.091400, 0.007009, 0.000000, +}; + +const double rgb_anchor[] = { +rgb_to_lms[0][0] + rgb_to_lms[0][1] + rgb_to_lms[0][2], +rgb_to_lms[1][0] + rgb_to_lms[1][1] + rgb_to_lms[1][2], +rgb_to_lms[2][0] + rgb_to_lms[2][1] + rgb_to_lms[2][2], +}; + +const vector3 protanopia_abc[2] = { + {{{ + rgb_anchor[1] * anchor[8] - rgb_anchor[2] * anchor[7], + rgb_anchor[2] * anchor[6] - rgb_anchor[0] * anchor[8], + rgb_anchor[0] * anchor[7] - rgb_anchor[1] * anchor[6], + }}}, + {{{ + rgb_anchor[1] * anchor[2] - rgb_anchor[2] * anchor[1], + rgb_anchor[2] * anchor[0] - rgb_anchor[0] * anchor[2], + rgb_anchor[0] * anchor[1] - rgb_anchor[1] * anchor[0], + }}}, +}; + +const vector3 deuteranopia_abc[2] = { + {{{ + rgb_anchor[1] * anchor[8] - rgb_anchor[2] * anchor[7], + rgb_anchor[2] * anchor[6] - rgb_anchor[0] * anchor[8], + rgb_anchor[0] * anchor[7] - rgb_anchor[1] * anchor[6], + }}}, + {{{ + rgb_anchor[1] * anchor[2] - rgb_anchor[2] * anchor[1], + rgb_anchor[2] * anchor[0] - rgb_anchor[0] * anchor[2], + rgb_anchor[0] * anchor[1] - rgb_anchor[1] * anchor[0], + }}}, +}; + +const vector3 tritanopia_abc[2] = { + {{{ + rgb_anchor[1] * anchor[11] - rgb_anchor[2] * anchor[10], + rgb_anchor[2] * anchor[9] - rgb_anchor[0] * anchor[11], + rgb_anchor[0] * anchor[10] - rgb_anchor[1] * anchor[9], + }}}, + {{{ + rgb_anchor[1] * anchor[5] - rgb_anchor[2] * anchor[4], + rgb_anchor[2] * anchor[3] - rgb_anchor[0] * anchor[5], + rgb_anchor[0] * anchor[4] - rgb_anchor[1] * anchor[3], + }}}, +}; + +static void load_matrix(const double matrix_data[9], matrix3x3 *matrix) +{ + matrix->m[0][0] = matrix_data[0]; + matrix->m[1][0] = matrix_data[1]; + matrix->m[2][0] = matrix_data[2]; + matrix->m[0][1] = matrix_data[3]; + matrix->m[1][1] = matrix_data[4]; + matrix->m[2][1] = matrix_data[5]; + matrix->m[0][2] = matrix_data[6]; + matrix->m[1][2] = matrix_data[7]; + matrix->m[2][2] = matrix_data[8]; +} + +static void load_matrix(const double matrix_data[3][3], matrix3x3 *matrix) +{ + matrix->m[0][0] = matrix_data[0][0]; + matrix->m[1][0] = matrix_data[1][0]; + matrix->m[2][0] = matrix_data[2][0]; + matrix->m[0][1] = matrix_data[0][1]; + matrix->m[1][1] = matrix_data[1][1]; + matrix->m[2][1] = matrix_data[2][1]; + matrix->m[0][2] = matrix_data[0][2]; + matrix->m[1][2] = matrix_data[1][2]; + matrix->m[2][2] = matrix_data[2][2]; +} + +static void load_vector(const Color *color, vector3 *vector) +{ + vector->x = color->rgb.red; + vector->y = color->rgb.green; + vector->z = color->rgb.blue; +} + +void ColorVisionDeficiency::apply(Color *input, Color *output) +{ + Color linear_input, linear_output; + color_rgb_get_linear(input, &linear_input); + vector3 vi, vo1, vo2; + load_vector(&linear_input, &vi); + matrix3x3 matrix1, matrix2; + int index = floor(strength * 10); + int index_secondary = std::min(index + 1, 10); + float interpolation_factor = 1 - ((strength * 10) - index); + + vector3 lms; + if ((type == PROTANOPIA) || (type == DEUTERANOPIA) || (type == TRITANOPIA)){ + load_matrix(rgb_to_lms, &matrix1); + load_matrix(lms_to_rgb, &matrix2); + vector3_multiply_matrix3x3(&vi, &matrix1, &lms); + } + + switch (type){ + case PROTANOMALY: + load_matrix(protanomaly[index], &matrix1); + load_matrix(protanomaly[index_secondary], &matrix2); + vector3_multiply_matrix3x3(&vi, &matrix1, &vo1); + vector3_multiply_matrix3x3(&vi, &matrix2, &vo2); + break; + case DEUTERANOMALY: + load_matrix(deuteranomaly[index], &matrix1); + load_matrix(deuteranomaly[index_secondary], &matrix2); + vector3_multiply_matrix3x3(&vi, &matrix1, &vo1); + vector3_multiply_matrix3x3(&vi, &matrix2, &vo2); + break; + case TRITANOMALY: + load_matrix(tritanomaly[index], &matrix1); + load_matrix(tritanomaly[index_secondary], &matrix2); + vector3_multiply_matrix3x3(&vi, &matrix1, &vo1); + vector3_multiply_matrix3x3(&vi, &matrix2, &vo2); + break; + case PROTANOPIA: + if (lms.z / lms.y < rgb_anchor[2] / rgb_anchor[1]){ + lms.x = -(protanopia_abc[0].y * lms.y + protanopia_abc[0].z * lms.z) / protanopia_abc[0].x; + }else{ + lms.x = -(protanopia_abc[1].y * lms.y + protanopia_abc[1].z * lms.z) / protanopia_abc[1].x; + } + vector3_multiply_matrix3x3(&lms, &matrix2, &vo1); + load_vector(&linear_input, &vo2); + interpolation_factor = strength; + break; + case DEUTERANOPIA: + if (lms.z / lms.x < rgb_anchor[2] / rgb_anchor[0]){ + lms.y = -(deuteranopia_abc[0].x * lms.x + deuteranopia_abc[0].z * lms.z) / deuteranopia_abc[0].y; + }else{ + lms.y = -(deuteranopia_abc[1].x * lms.x + deuteranopia_abc[1].z * lms.z) / deuteranopia_abc[1].y; + } + vector3_multiply_matrix3x3(&lms, &matrix2, &vo1); + load_vector(&linear_input, &vo2); + interpolation_factor = strength; + break; + case TRITANOPIA: + if (lms.y / lms.x < rgb_anchor[1] / rgb_anchor[0]){ + lms.z = -(tritanopia_abc[0].x * lms.x + tritanopia_abc[0].y * lms.y) / tritanopia_abc[0].z; + }else{ + lms.z = -(tritanopia_abc[1].x * lms.x + tritanopia_abc[1].y * lms.y) / tritanopia_abc[1].z; + } + vector3_multiply_matrix3x3(&lms, &matrix2, &vo1); + load_vector(&linear_input, &vo2); + interpolation_factor = strength; + break; + default: + color_copy(input, output); + return; + } + + linear_output.rgb.red = vo1.x * interpolation_factor + vo2.x * (1 - interpolation_factor); + linear_output.rgb.green = vo1.y * interpolation_factor + vo2.y * (1 - interpolation_factor); + linear_output.rgb.blue = vo1.z * interpolation_factor + vo2.z * (1 - interpolation_factor); + color_linear_get_rgb(&linear_output, output); + color_rgb_normalize(output); +} + +ColorVisionDeficiency::ColorVisionDeficiency():Transformation(transformation_name, getReadableName()) +{ + type = PROTANOMALY; + strength = 0.5; +} + +ColorVisionDeficiency::ColorVisionDeficiency(DeficiencyType type_, float strength_):Transformation(transformation_name, getReadableName()) +{ + type = type_; + strength = strength_; +} + +ColorVisionDeficiency::~ColorVisionDeficiency() +{ + +} + + +void ColorVisionDeficiency::serialize(struct dynvSystem *dynv) +{ + dynv_set_float(dynv, "strength", strength); + dynv_set_string(dynv, "type", deficiency_type_string[type]); + Transformation::serialize(dynv); +} + +ColorVisionDeficiency::DeficiencyType ColorVisionDeficiency::typeFromString(const char *type_string) +{ + for (int i = 0; i < DEFICIENCY_TYPE_COUNT; i++){ + if (strcmp(type_string, deficiency_type_string[i]) == 0){ + return (DeficiencyType)i; + } + } + return PROTANOMALY; +} + +void ColorVisionDeficiency::deserialize(struct dynvSystem *dynv) +{ + strength = dynv_get_float_wd(dynv, "strength", 0.5); + type = typeFromString(dynv_get_string_wd(dynv, "type", "protanomaly")); +} + + +static GtkWidget* create_type_list(void){ + GtkListStore *store; + GtkCellRenderer *renderer; + GtkWidget *widget; + store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); + widget = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); + gtk_combo_box_set_add_tearoffs(GTK_COMBO_BOX(widget), 0); + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, 0); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL); + g_object_unref(GTK_TREE_MODEL(store)); + GtkTreeIter iter1; + + struct { + const char *name; + int type; + } types[] = { + {_("Protanomaly"), ColorVisionDeficiency::PROTANOMALY}, + {_("Deuteranomaly"), ColorVisionDeficiency::DEUTERANOMALY}, + {_("Tritanomaly"), ColorVisionDeficiency::TRITANOMALY}, + {_("Protanopia"), ColorVisionDeficiency::PROTANOPIA}, + {_("Deuteranopia"), ColorVisionDeficiency::DEUTERANOPIA}, + {_("Tritanopia"), ColorVisionDeficiency::TRITANOPIA}, + }; + + for (int i = 0; i < ColorVisionDeficiency::DEFICIENCY_TYPE_COUNT; ++i){ + gtk_list_store_append(store, &iter1); + gtk_list_store_set(store, &iter1, + 0, types[i].name, + 1, types[i].type, + -1); + } + + return widget; +} + +boost::shared_ptr ColorVisionDeficiency::getConfig(){ + boost::shared_ptr config = boost::shared_ptr(new ColorVisionDeficiencyConfig(*this)); + return config; +} + + +ColorVisionDeficiencyConfig::ColorVisionDeficiencyConfig(ColorVisionDeficiency &transformation){ + + GtkWidget *table = gtk_table_new(2, 2, false); + GtkWidget *widget; + int table_y = 0; + + table_y = 0; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Type:"), 0, 0.5, 0, 0), 0, 1, table_y, table_y + 1, GTK_FILL, GTK_FILL, 5, 5); + type = widget = create_type_list(); + g_signal_connect(G_OBJECT(type), "changed", G_CALLBACK(ColorVisionDeficiencyConfig::type_combobox_change_cb), this); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 5, 0); + table_y++; + + info_bar = widget = gtk_info_bar_new(); + info_label = gtk_label_new(""); + gtk_label_set_line_wrap(GTK_LABEL(info_label), true); + gtk_label_set_justify(GTK_LABEL(info_label), GTK_JUSTIFY_LEFT); + gtk_label_set_single_line_mode(GTK_LABEL(info_label), false); + gtk_misc_set_alignment(GTK_MISC(info_label), 0, 0.5); + gtk_widget_set_size_request(info_label, 1, -1); + GtkWidget *content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar)); + gtk_container_add(GTK_CONTAINER(content_area), info_label); + gtk_widget_show_all(info_bar); + g_signal_connect(G_OBJECT(info_label), "size-allocate", G_CALLBACK(info_label_size_allocate_cb), this); + + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 5, 0); + table_y++; + + gtk_combo_box_set_active(GTK_COMBO_BOX(type), transformation.type); + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Strength:"), 0, 0.5, 0, 0), 0, 1, table_y, table_y + 1, GTK_FILL, GTK_FILL, 5, 5); + strength = widget = gtk_hscale_new_with_range(0, 100, 1); + gtk_range_set_value(GTK_RANGE(widget), transformation.strength * 100); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 5, 0); + table_y++; + + main = table; + gtk_widget_show_all(main); + + g_object_ref(main); + +} + +ColorVisionDeficiencyConfig::~ColorVisionDeficiencyConfig(){ + g_object_unref(main); +} + +GtkWidget* ColorVisionDeficiencyConfig::getWidget(){ + return main; +} + +void ColorVisionDeficiencyConfig::applyConfig(dynvSystem *dynv){ + dynv_set_float(dynv, "strength", gtk_range_get_value(GTK_RANGE(strength)) / 100.0f); + + GtkTreeIter iter; + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(type), &iter)) { + GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(type)); + ColorVisionDeficiency::DeficiencyType type_id; + gtk_tree_model_get(model, &iter, 1, &type_id, -1); + dynv_set_string(dynv, "type", ColorVisionDeficiency::deficiency_type_string[type_id]); + } +} + +void ColorVisionDeficiencyConfig::type_combobox_change_cb(GtkWidget *widget, ColorVisionDeficiencyConfig *this_) +{ + const char *descriptions[] = { + _("Altered spectral sensitivity of red receptors"), + _("Altered spectral sensitivity of green receptors"), + _("Altered spectral sensitivity of blue receptors"), + _("Absence of red receptors"), + _("Absence of green receptors"), + _("Absence of blue receptors"), + }; + + GtkTreeIter iter; + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(this_->type), &iter)) { + GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(this_->type)); + ColorVisionDeficiency::DeficiencyType type_id; + gtk_tree_model_get(model, &iter, 1, &type_id, -1); + + gtk_label_set_text(GTK_LABEL(this_->info_label), descriptions[type_id]); + }else{ + gtk_label_set_text(GTK_LABEL(this_->info_label), ""); + } + gtk_info_bar_set_message_type(GTK_INFO_BAR(this_->info_bar), GTK_MESSAGE_INFO); +} + +void ColorVisionDeficiencyConfig::info_label_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, ColorVisionDeficiencyConfig *this_) +{ + gtk_widget_set_size_request(this_->info_label, allocation->width - 16, -1); +} + +} + diff -Nru gpick-0.2.4/source/transformation/ColorVisionDeficiency.h gpick-0.2.5/source/transformation/ColorVisionDeficiency.h --- gpick-0.2.4/source/transformation/ColorVisionDeficiency.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/ColorVisionDeficiency.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMATION_COLOR_VISION_DEFICIENCY_H_ +#define TRANSFORMATION_COLOR_VISION_DEFICIENCY_H_ + +#include "Transformation.h" + +namespace transformation { + +class ColorVisionDeficiency; + +class ColorVisionDeficiencyConfig: public Configuration{ + protected: + GtkWidget *main; + GtkWidget *info_bar; + GtkWidget *info_label; + GtkWidget *type; + GtkWidget *strength; + + static void type_combobox_change_cb(GtkWidget *widget, ColorVisionDeficiencyConfig *this_); + static void info_label_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, ColorVisionDeficiencyConfig *this_); + public: + ColorVisionDeficiencyConfig(ColorVisionDeficiency &transformation); + virtual ~ColorVisionDeficiencyConfig(); + + virtual GtkWidget* getWidget(); + virtual void applyConfig(dynvSystem *dynv); +}; + +class ColorVisionDeficiency: public Transformation{ + public: + enum DeficiencyType{ + PROTANOMALY, + DEUTERANOMALY, + TRITANOMALY, + PROTANOPIA, + DEUTERANOPIA, + TRITANOPIA, + DEFICIENCY_TYPE_COUNT, + }; + static const char *deficiency_type_string[]; + + static const char *getName(); + static const char *getReadableName(); + protected: + float strength; + DeficiencyType type; + virtual void apply(Color *input, Color *output); + + public: + ColorVisionDeficiency(); + ColorVisionDeficiency(DeficiencyType type, float strength); + virtual ~ColorVisionDeficiency(); + + virtual void serialize(struct dynvSystem *dynv); + virtual void deserialize(struct dynvSystem *dynv); + + virtual boost::shared_ptr getConfig(); + + DeficiencyType typeFromString(const char *type_string); + + friend class ColorVisionDeficiencyConfig; +}; + +} + +#endif /* TRANSFORMATION_COLOR_VISION_DEFICIENCY_H_ */ + + diff -Nru gpick-0.2.4/source/transformation/Configuration.cpp gpick-0.2.5/source/transformation/Configuration.cpp --- gpick-0.2.4/source/transformation/Configuration.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Configuration.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Configuration.h" + +namespace transformation { + +Configuration::Configuration() +{ +} + +Configuration::~Configuration() +{ +} + +GtkWidget* Configuration::getWidget() +{ + return 0; +} + +void Configuration::applyConfig(dynvSystem *dynv) +{ +} + +} + diff -Nru gpick-0.2.4/source/transformation/Configuration.h gpick-0.2.5/source/transformation/Configuration.h --- gpick-0.2.4/source/transformation/Configuration.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Configuration.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMATION_CONFIGURATION_H_ +#define TRANSFORMATION_CONFIGURATION_H_ + +#include "../DynvHelpers.h" +#include + +/** \file source/transformation/Configuration.h + * \brief Class for transformation object configuration handling. + */ + +namespace transformation { + +/** \class Configuration + * \brief Transformation object configuration management class. + */ +class Configuration{ + protected: + public: + Configuration(); + virtual ~Configuration(); + + virtual GtkWidget* getWidget(); + virtual void applyConfig(dynvSystem *dynv); +}; + +} + +#endif /* TRANSFORMATION_CONFIGURATION_H_ */ + diff -Nru gpick-0.2.4/source/transformation/Factory.cpp gpick-0.2.5/source/transformation/Factory.cpp --- gpick-0.2.4/source/transformation/Factory.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Factory.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Factory.h" + +#include "ColorVisionDeficiency.h" +#include "GammaModification.h" +#include "Quantization.h" + +#include + +namespace transformation { + +boost::shared_ptr Factory::create(const char *type) +{ + if (strcmp(ColorVisionDeficiency::getName(), type) == 0){ + return boost::shared_ptr(new ColorVisionDeficiency()); + } + if (strcmp(GammaModification::getName(), type) == 0){ + return boost::shared_ptr(new GammaModification()); + } + if (strcmp(Quantization::getName(), type) == 0){ + return boost::shared_ptr(new Quantization()); + } + return boost::shared_ptr(); +} + +std::vector Factory::getAllTypes() +{ + std::vector result; + result.push_back(TypeInfo(ColorVisionDeficiency::getName(), ColorVisionDeficiency::getReadableName())); + result.push_back(TypeInfo(GammaModification::getName(), GammaModification::getReadableName())); + result.push_back(TypeInfo(Quantization::getName(), Quantization::getReadableName())); + return result; +} + +Factory::TypeInfo::TypeInfo(const char *name_, const char *human_name_): + name(name_), human_name(human_name_) +{ +} + +} + + diff -Nru gpick-0.2.4/source/transformation/Factory.h gpick-0.2.5/source/transformation/Factory.h --- gpick-0.2.4/source/transformation/Factory.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Factory.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMATION_FACTORY_H_ +#define TRANSFORMATION_FACTORY_H_ + +#include "Transformation.h" +#include +#include + +/** \file source/transformation/Factory.h + * \brief Class for transformation object creation. + */ + +namespace transformation { + +/** \class Factory + * \brief Transformation object creation management class. + */ +class Factory{ + public: + typedef struct TypeInfo{ + const char *name; + const char *human_name; + TypeInfo(const char *name, const char *human_name); + }TypeInfo; + + /** + * Create new transformation object. + * @param[in] type Name of transformation object type. + * @return New transformation object. + */ + static boost::shared_ptr create(const char *type); + + /** + * Get all transformation object types. + * @return Vector of transformation object type information structures. + */ + static std::vector getAllTypes(); +}; + +} + +#endif /* TRANSFORMATION_FACTORY_H_ */ + diff -Nru gpick-0.2.4/source/transformation/GammaModification.cpp gpick-0.2.5/source/transformation/GammaModification.cpp --- gpick-0.2.4/source/transformation/GammaModification.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/GammaModification.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "GammaModification.h" +#include "../MathUtil.h" +#include "../uiUtilities.h" +#include "../Internationalisation.h" +#include +#include +#include + +namespace transformation { + +static const char * transformation_name = "gamma_modification"; + +const char *GammaModification::getName() +{ + return transformation_name; +} + +const char *GammaModification::getReadableName() +{ + return _("Gamma modification"); +} + +void GammaModification::apply(Color *input, Color *output) +{ + Color linear_input, linear_output; + color_rgb_get_linear(input, &linear_input); + linear_output.rgb.red = pow(linear_input.rgb.red, value); + linear_output.rgb.green= pow(linear_input.rgb.green, value); + linear_output.rgb.blue = pow(linear_input.rgb.blue, value); + color_linear_get_rgb(&linear_output, output); + color_rgb_normalize(output); +} + +GammaModification::GammaModification():Transformation(transformation_name, getReadableName()) +{ + value = 1; +} + +GammaModification::GammaModification(float value_):Transformation(transformation_name, getReadableName()) +{ + value = value_; +} + +GammaModification::~GammaModification() +{ +} + +void GammaModification::serialize(struct dynvSystem *dynv) +{ + dynv_set_float(dynv, "value", value); + Transformation::serialize(dynv); +} + +void GammaModification::deserialize(struct dynvSystem *dynv) +{ + value = dynv_get_float_wd(dynv, "value", 1); +} + +boost::shared_ptr GammaModification::getConfig(){ + boost::shared_ptr config = boost::shared_ptr(new GammaModificationConfig(*this)); + return config; +} + +GammaModificationConfig::GammaModificationConfig(GammaModification &transformation){ + GtkWidget *table = gtk_table_new(2, 2, false); + GtkWidget *widget; + int table_y = 0; + + table_y=0; + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Value:"),0, 0.5, 0, 0), 0, 1, table_y, table_y + 1, GTK_FILL, GTK_FILL, 5, 5); + value = widget = gtk_spin_button_new_with_range(0, 100, 0.01); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), transformation.value); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 5, 0); + table_y++; + + main = table; + gtk_widget_show_all(main); + + g_object_ref(main); +} + +GammaModificationConfig::~GammaModificationConfig(){ + g_object_unref(main); +} + +GtkWidget* GammaModificationConfig::getWidget(){ + return main; +} + +void GammaModificationConfig::applyConfig(dynvSystem *dynv){ + dynv_set_float(dynv, "value", gtk_spin_button_get_value(GTK_SPIN_BUTTON(value))); +} + +} + diff -Nru gpick-0.2.4/source/transformation/GammaModification.h gpick-0.2.5/source/transformation/GammaModification.h --- gpick-0.2.4/source/transformation/GammaModification.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/GammaModification.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMATION_GAMMA_MODIFICATION_H_ +#define TRANSFORMATION_GAMMA_MODIFICATION_H_ + +#include "Transformation.h" + +namespace transformation { + +class GammaModification; + +class GammaModificationConfig: public Configuration{ + protected: + GtkWidget *main; + GtkWidget *value; + public: + GammaModificationConfig(GammaModification &transformation); + virtual ~GammaModificationConfig(); + + virtual GtkWidget* getWidget(); + virtual void applyConfig(dynvSystem *dynv); +}; + +class GammaModification: public Transformation{ + public: + static const char *getName(); + static const char *getReadableName(); + protected: + float value; + virtual void apply(Color *input, Color *output); + public: + GammaModification(); + GammaModification(float value); + virtual ~GammaModification(); + + virtual void serialize(struct dynvSystem *dynv); + virtual void deserialize(struct dynvSystem *dynv); + + virtual boost::shared_ptr getConfig(); + + friend class GammaModificationConfig; +}; + +} + +#endif /* TRANSFORMATION_GAMMA_MODIFICATION_H_ */ + + + diff -Nru gpick-0.2.4/source/transformation/Invert.cpp gpick-0.2.5/source/transformation/Invert.cpp --- gpick-0.2.4/source/transformation/Invert.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Invert.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Invert.h" + +namespace transformation { + +void Invert::apply(Color *input, Color *output) +{ + output->rgb.red = 1 - input->rgb.red; + output->rgb.green= 1 - input->rgb.green; + output->rgb.blue = 1 - input->rgb.blue; +} + +Invert::Invert():Transformation("invert", "Invert") +{ + +} + +Invert::~Invert() +{ + +} + +} + + diff -Nru gpick-0.2.4/source/transformation/Invert.h gpick-0.2.5/source/transformation/Invert.h --- gpick-0.2.4/source/transformation/Invert.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Invert.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMATION_INVERT_H_ +#define TRANSFORMATION_INVERT_H_ + +#include "Transformation.h" + +namespace transformation { + +class Invert : public Transformation{ + protected: + virtual void apply(Color *input, Color *output); + public: + Invert(); + virtual ~Invert(); +}; + +} + +#endif /* TRANSFORMATION_INVERT_H_ */ + diff -Nru gpick-0.2.4/source/transformation/Quantization.cpp gpick-0.2.5/source/transformation/Quantization.cpp --- gpick-0.2.4/source/transformation/Quantization.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Quantization.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * Copyright (c) 2012, David Gowers (Portions regarding adaptation of GammaModification.(cpp|h) to quantise colors instead.) + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Quantization.h" +#include "../MathUtil.h" +#include "../uiUtilities.h" +#include "../Internationalisation.h" +#include +#include +#include +#include + +namespace transformation { + +static const char * transformation_name = "quantization"; + +const char *Quantization::getName() +{ + return transformation_name; +} + +const char *Quantization::getReadableName() +{ + return _("Quantization"); +} + +void Quantization::apply(Color *input, Color *output) +{ + if (clip_top) { + float max_intensity = (value - 1) / value; + output->rgb.red = MIN(max_intensity, boost::math::round(input->rgb.red * value) / value); + output->rgb.green = MIN(max_intensity, boost::math::round(input->rgb.green * value) / value); + output->rgb.blue = MIN(max_intensity, boost::math::round(input->rgb.blue * value) / value); + }else{ + float actualmax = value - 1; + output->rgb.red = boost::math::round(input->rgb.red * actualmax) / actualmax; + output->rgb.green = boost::math::round(input->rgb.green * actualmax) / actualmax; + output->rgb.blue = boost::math::round(input->rgb.blue * actualmax) / actualmax; + } +} + +Quantization::Quantization():Transformation(transformation_name, getReadableName()) +{ + value = 16; +} + +Quantization::Quantization(float value_):Transformation(transformation_name, getReadableName()) +{ + value = value_; +} + +Quantization::~Quantization() +{ +} + +void Quantization::serialize(struct dynvSystem *dynv) +{ + dynv_set_float(dynv, "value", value); + dynv_set_bool(dynv, "clip-top", clip_top); + Transformation::serialize(dynv); +} + +void Quantization::deserialize(struct dynvSystem *dynv) +{ + value = dynv_get_float_wd(dynv, "value", 16); + clip_top = dynv_get_bool_wd(dynv, "clip-top", 0); +} + +boost::shared_ptr Quantization::getConfig(){ + boost::shared_ptr config = boost::shared_ptr(new QuantizationConfig(*this)); + return config; +} + +QuantizationConfig::QuantizationConfig(Quantization &transformation){ + GtkWidget *table = gtk_table_new(2, 3, false); + GtkWidget *widget; + int table_y = 0; + + table_y=0; + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Value:"),0, 0.5, 0, 0), 0, 1, table_y, table_y + 1, GTK_FILL, GTK_FILL, 5, 5); + value = widget = gtk_spin_button_new_with_range(2, 256, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), transformation.value); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 5, 0); + table_y++; + clip_top = widget = gtk_check_button_new_with_label(_("Clip top-end")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), transformation.clip_top); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y + 1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 5, 0); + + main = table; + gtk_widget_show_all(main); + + g_object_ref(main); +} + +QuantizationConfig::~QuantizationConfig(){ + g_object_unref(main); +} + +GtkWidget* QuantizationConfig::getWidget(){ + return main; +} + +void QuantizationConfig::applyConfig(dynvSystem *dynv){ + dynv_set_float(dynv, "value", gtk_spin_button_get_value(GTK_SPIN_BUTTON(value))); + dynv_set_bool(dynv, "clip-top", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(clip_top))); +} + +} + diff -Nru gpick-0.2.4/source/transformation/Quantization.h gpick-0.2.5/source/transformation/Quantization.h --- gpick-0.2.4/source/transformation/Quantization.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Quantization.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMATION_QUANTIZATION_H_ +#define TRANSFORMATION_QUANTIZATION_H_ + +#include "Transformation.h" + +namespace transformation { + +class Quantization; + +class QuantizationConfig: public Configuration{ + protected: + GtkWidget *main; + GtkWidget *value; + GtkWidget *clip_top; + public: + QuantizationConfig(Quantization &transformation); + virtual ~QuantizationConfig(); + + virtual GtkWidget* getWidget(); + virtual void applyConfig(dynvSystem *dynv); +}; + +class Quantization: public Transformation{ + public: + static const char *getName(); + static const char *getReadableName(); + protected: + float value; + bool clip_top; + virtual void apply(Color *input, Color *output); + public: + Quantization(); + Quantization(float value); + virtual ~Quantization(); + + virtual void serialize(struct dynvSystem *dynv); + virtual void deserialize(struct dynvSystem *dynv); + + virtual boost::shared_ptr getConfig(); + + friend class QuantizationConfig; +}; + +} + +#endif /* TRANSFORMATION_GAMMA_MODIFICATION_H_ */ + + + diff -Nru gpick-0.2.4/source/transformation/Transformation.cpp gpick-0.2.5/source/transformation/Transformation.cpp --- gpick-0.2.4/source/transformation/Transformation.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Transformation.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Transformation.h" + +namespace transformation { + +Transformation::Transformation(const char *name_, const char *readable_name_) +{ + name = name_; + readable_name = readable_name_; +} + +Transformation::~Transformation() +{ + +} + +void Transformation::apply(Color *input, Color *output) +{ + color_copy(input, output); +} + +std::string Transformation::getName() const +{ + return name; +} + +std::string Transformation::getReadableName() const +{ + return readable_name; +} + +void Transformation::serialize(struct dynvSystem *dynv) +{ + dynv_set_string(dynv, "name", name.c_str()); +} + +void Transformation::deserialize(struct dynvSystem *dynv) +{ + +} + +boost::shared_ptr Transformation::getConfig() +{ + return boost::shared_ptr(); +} + +} + diff -Nru gpick-0.2.4/source/transformation/Transformation.h gpick-0.2.5/source/transformation/Transformation.h --- gpick-0.2.4/source/transformation/Transformation.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/transformation/Transformation.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMATION_H_ +#define TRANSFORMATION_H_ + +#include "../Color.h" +#include "Configuration.h" +#include "../DynvHelpers.h" +#include +#include + +/** \file source/transformation/Transformation.h + * \brief Color transformation class. + */ + +namespace transformation { + +/** \class Transformation + * \brief Transformation object class. + */ +class Transformation{ + protected: + std::string name; /**< System name */ + std::string readable_name; /**< Human readable name */ + + /** + * Apply transformation to color. + * @param[in] input Source color in RGB color space. + * @param[out] output Destination color in RGB color space. + */ + virtual void apply(Color *input, Color *output); + public: + /** + * Transformation object constructor. + * @param[in] name Transformation object system name. + * @param[in] readable_name Transformation object human readable name. + */ + Transformation(const char *name, const char *readable_name); + + /** + * Transformation object destructor. + */ + virtual ~Transformation(); + + /** + * Serialize settings into configuration system. + * @param[in,out] dynv Configuration system. + */ + virtual void serialize(struct dynvSystem *dynv); + + /** + * Deserialize settings from configuration system. + * @param[in] dynv Configuration system. + */ + virtual void deserialize(struct dynvSystem *dynv); + + /** + * Get configuration for transformation object. + * @return Configuration for transformation object. + */ + virtual boost::shared_ptr getConfig(); + + /** + * Get transformation object system name. + * @return Transformation object system name. + */ + std::string getName() const; + + /** + * Get transformation object human readable name. + * @return Transformation object human readable name. + */ + std::string getReadableName() const; + + friend class Chain; +}; + +} + +#endif /* TRANSFORMATION_H_ */ + diff -Nru gpick-0.2.4/source/uiAbout.cpp gpick-0.2.5/source/uiAbout.cpp --- gpick-0.2.4/source/uiAbout.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiAbout.cpp 2013-01-05 15:43:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -18,6 +18,7 @@ #include "uiAbout.h" #include "version/Version.h" +#include "Internationalisation.h" const gchar* program_name = "Gpick"; @@ -41,7 +42,7 @@ void show_about_box(GtkWidget *widget){ const char *license = { -"Copyright \xc2\xa9 2009-2010, Albertas Vyšniauskas\n" +"Copyright \xc2\xa9 2009-2013, Albertas Vyšniauskas\n" "\n" "All rights reserved.\n" "\n" @@ -75,9 +76,16 @@ "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" }; - const char *program_authors = "Albertas Vyšniauskas "; + const char *program_authors = { +"Albertas Vyšniauskas \n" +/* Add yourself here if you helped Gpick project in any way (patch, translation, etc). + * Everything is optional, if you do not want, you do not have to disclose your e-mail + * address, real name or any other information. + * Please keep this list sorted alphabetically. + */ + }; - GtkWidget* dialog = gtk_dialog_new_with_buttons("About Gpick", GTK_WINDOW(gtk_widget_get_toplevel(widget)), GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GtkWidget* dialog = gtk_dialog_new_with_buttons(_("About Gpick"), GTK_WINDOW(gtk_widget_get_toplevel(widget)), GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL); @@ -110,15 +118,16 @@ gtk_box_pack_start(GTK_BOX(vbox2), name, false, false, 0); g_free(tmp_string); - GtkWidget *comments = gtk_label_new("Advanced color picker"); + GtkWidget *comments = gtk_label_new(_("Advanced color picker")); gtk_label_set_selectable(GTK_LABEL(comments), true); gtk_label_set_justify(GTK_LABEL(comments), GTK_JUSTIFY_CENTER); gtk_box_pack_start(GTK_BOX(vbox2), comments, false, false, 0); - tmp_string = g_markup_printf_escaped ("%s", "Copyrights \xc2\xa9 2009-2010, Albertas Vyšniauskas"); + tmp_string = g_markup_printf_escaped ("%s", _("Copyrights © 2009-2013, Albertas Vyšniauskas and Gpick development team")); GtkWidget *copyright = gtk_label_new(0); gtk_label_set_selectable(GTK_LABEL(copyright), true); gtk_label_set_justify(GTK_LABEL(copyright), GTK_JUSTIFY_CENTER); + gtk_label_set_line_wrap(GTK_LABEL(copyright), true); gtk_label_set_markup(GTK_LABEL(copyright), tmp_string); gtk_box_pack_start(GTK_BOX(vbox2), copyright, false, false, 0); g_free(tmp_string); @@ -129,10 +138,10 @@ GtkWidget *notebook = gtk_notebook_new(); gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), true); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(license), gtk_label_new("License")); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(program_authors), gtk_label_new("Credits")); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(expat_license), gtk_label_new("Expat License")); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(lua_license), gtk_label_new("Lua License")); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(license), gtk_label_new(_("License"))); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(program_authors), gtk_label_new(_("Credits"))); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(expat_license), gtk_label_new(_("Expat License"))); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(lua_license), gtk_label_new(_("Lua License"))); gtk_box_pack_start(GTK_BOX(vbox), notebook, true, true, 0); diff -Nru gpick-0.2.4/source/uiAbout.h gpick-0.2.5/source/uiAbout.h --- gpick-0.2.4/source/uiAbout.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiAbout.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/uiApp.cpp gpick-0.2.5/source/uiApp.cpp --- gpick-0.2.4/source/uiApp.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiApp.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -21,9 +21,9 @@ #include "GlobalStateStruct.h" +#include "Paths.h" #include "Converter.h" #include "CopyPaste.h" -#include "unique/Unique.h" #include "RegisterSources.h" @@ -38,10 +38,15 @@ #include "uiDialogMix.h" #include "uiDialogVariations.h" #include "uiDialogGenerate.h" +#include "uiDialogAutonumber.h" +#include "uiDialogSort.h" +#include "uiTransformations.h" #include "tools/PaletteFromImage.h" #include "tools/PaletteFromCssFile.h" +#include "dbus/Control.h" + #include "uiDialogOptions.h" #include "uiConverter.h" #include "uiStatusIcon.h" @@ -50,14 +55,18 @@ #include "FileFormat.h" #include "MathUtil.h" +#include "Internationalisation.h" + #include #include +#include #include #include #include #include #include +#include #include using namespace std; @@ -74,6 +83,7 @@ ColorSource *secondary_color_source; GtkWidget *secondary_source_widget; + GtkWidget *secondary_source_scrolled_viewpoint; GtkWidget *secondary_source_container; GtkWidget *color_list; @@ -84,11 +94,15 @@ uiStatusIcon* statusIcon; FloatingPicker floating_picker; + AppOptions options; + guint bus_id; struct dynvSystem *params; GlobalState* gs; char* current_filename; + bool imported; + GtkWidget *precision_loss_icon; gint x, y; gint width, height; @@ -180,6 +194,7 @@ static void destroy_cb(GtkWidget *widget, AppArgs *args){ g_signal_handlers_disconnect_matched(G_OBJECT(args->notebook), G_SIGNAL_MATCH_FUNC, 0, NULL, NULL, (void*)notebook_switch_cb, 0); //disconnect notebook switch callback, because destroying child widgets triggers it + //dynv_set_int32(args->params, "notebook_page", gtk_notebook_get_current_page(GTK_NOTEBOOK(args->notebook))); dynv_set_string(args->params, "color_source", args->color_source_index[gtk_notebook_get_current_page(GTK_NOTEBOOK(args->notebook))]->identificator); dynv_set_int32(args->params, "paned_position", gtk_paned_get_position(GTK_PANED(args->hpaned))); @@ -212,7 +227,14 @@ floating_picker_free(args->floating_picker); - gtk_main_quit(); + if (app_is_autoload_enabled(args)){ + gchar* autosave_file = build_config_path("autosave.gpa"); + palette_file_save(autosave_file, args->gs->colors); + g_free(autosave_file); + } + + color_list_remove_all(args->gs->colors); + gtk_main_quit(); } @@ -327,18 +349,27 @@ } static void updateProgramName(AppArgs *args){ - string prg_name; - if (args->current_filename==0){ - prg_name="New palette"; + stringstream prg_name; + if (args->current_filename == 0){ + prg_name << _("New palette"); + if (args->precision_loss_icon) + gtk_widget_hide(args->precision_loss_icon); }else{ - gchar* filename=g_path_get_basename(args->current_filename); - prg_name=filename; + gchar* filename = g_path_get_basename(args->current_filename); + if (args->imported){ + prg_name << filename << " " << _("(Imported)"); + if (args->precision_loss_icon) + gtk_widget_show(args->precision_loss_icon); + }else{ + prg_name << filename; + if (args->precision_loss_icon) + gtk_widget_hide(args->precision_loss_icon); + } g_free(filename); } - prg_name+=" - "; - prg_name+=program_name; + prg_name << " - " << program_name; - gtk_window_set_title(GTK_WINDOW(args->window), prg_name.c_str()); + gtk_window_set_title(GTK_WINDOW(args->window), prg_name.str().c_str()); } static void show_dialog_converter(GtkWidget *widget, AppArgs *args){ @@ -346,6 +377,11 @@ return; } +static void show_dialog_transformations(GtkWidget *widget, AppArgs *args){ + dialog_transformations_show(GTK_WINDOW(args->window), args->gs); + return; +} + static void show_dialog_options(GtkWidget *widget, AppArgs *args){ dialog_options_show(GTK_WINDOW(args->window), args->gs); return; @@ -359,12 +395,115 @@ updateProgramName(args); } -int app_load_file(AppArgs *args, const char *filename){ - if (palette_file_load(filename, args->gs->colors)==0){ - args->current_filename = g_strdup(filename); - updateRecentFileList(args, filename, false); +enum FileType{ + GPA, + GPL, + ASE, + UNKNOWN, +}; + +static FileType get_file_type_from_ext(const char *filename){ + const struct{ + FileType type; + const char *extension; + }extensions[] = { + {GPA, ".gpa"}, + {GPL, ".gpl"}, + {ASE, ".ase"}, + {UNKNOWN, 0}, + }; + const char *ext = g_strrstr(filename, "."); + if (ext){ + for (int i = 0; extensions[i].type != UNKNOWN; ++i){ + if (g_ascii_strcasecmp(ext, extensions[i].extension) == 0){ + return extensions[i].type; + } + } + } + return UNKNOWN; +} + +int app_save_file(AppArgs *args, const char *filename){ + int return_value = -1; + + if (filename == NULL){ + if (args->current_filename){ + filename = args->current_filename; + }else{ + return -1; + } + } + + FileType filetype; + switch (filetype = get_file_type_from_ext(filename)){ + case GPL: + return_value = palette_export_gpl(args->gs->colors, filename, false); + break; + case ASE: + return_value = palette_export_ase(args->gs->colors, filename, false); + break; + case UNKNOWN: + case GPA: + return_value = palette_file_save(filename, args->gs->colors); + break; + } + + if (return_value == 0){ + if (filetype == GPA || filetype == UNKNOWN){ + args->imported = false; + }else{ + args->imported = true; + } + if (filename != args->current_filename){ // do not touch current_filename if it is assigned to filename + if (args->current_filename) g_free(args->current_filename); + args->current_filename = g_strdup(filename); + } updateProgramName(args); + updateRecentFileList(args, filename, true); + return 0; }else{ + updateProgramName(args); + return -1; + } + return 0; +} + +int app_load_file(AppArgs *args, const char *filename, bool autoload){ + int return_value = -1; + int index; + bool imported = false; + + switch (get_file_type_from_ext(filename)){ + case GPL: + return_value = palette_import_gpl(args->gs->colors, filename); + imported = true; + break; + case ASE: + return_value = palette_import_ase(args->gs->colors, filename); + imported = true; + break; + case GPA: + case UNKNOWN: + return_value = palette_file_load(filename, args->gs->colors); + break; + } + + if (args->current_filename) g_free(args->current_filename); + args->current_filename = NULL; + + if (return_value == 0){ + if (imported){ + args->imported = true; + }else{ + args->imported = false; + } + if (!autoload){ + args->current_filename = g_strdup(filename); + updateRecentFileList(args, filename, false); + } + updateProgramName(args); + }else{ + updateProgramName(args); return -1; } return 0; @@ -375,23 +514,36 @@ return 0; } +static void menu_file_revert(GtkWidget *widget, AppArgs *args){ + string filename; + if (args->current_filename){ + filename = args->current_filename; + }else{ + return; + } + + color_list_remove_all(args->gs->colors); + + if (app_load_file(args, filename.c_str()) == 0){ + }else{ + GtkWidget* message; + message = gtk_message_dialog_new(GTK_WINDOW(args->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be opened")); + gtk_window_set_title(GTK_WINDOW(message), _("Open")); + gtk_dialog_run(GTK_DIALOG(message)); + gtk_widget_destroy(message); + } +} static void menu_file_open_last(GtkWidget *widget, AppArgs *args){ const char *filename = args->recent_files.begin()->c_str(); color_list_remove_all(args->gs->colors); - if (args->current_filename) g_free(args->current_filename); - args->current_filename = 0; - if (palette_file_load(filename, args->gs->colors) == 0){ - updateRecentFileList(args, filename, false); - args->current_filename = g_strdup(filename); - updateProgramName(args); + if (app_load_file(args, filename) == 0){ }else{ - updateProgramName(args); GtkWidget* message; - message = gtk_message_dialog_new(GTK_WINDOW(args->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "File could not be opened"); - gtk_window_set_title(GTK_WINDOW(message), "Open"); + message = gtk_message_dialog_new(GTK_WINDOW(args->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be opened")); + gtk_window_set_title(GTK_WINDOW(message), _("Open")); gtk_dialog_run(GTK_DIALOG(message)); gtk_widget_destroy(message); } @@ -404,29 +556,58 @@ const char *filename = (*i).c_str(); color_list_remove_all(args->gs->colors); - if (args->current_filename) g_free(args->current_filename); - args->current_filename = 0; - if (palette_file_load(filename, args->gs->colors) == 0){ - updateRecentFileList(args, filename, false); - args->current_filename = g_strdup(filename); - updateProgramName(args); + if (app_load_file(args, filename) == 0){ }else{ - updateProgramName(args); GtkWidget* message; - message = gtk_message_dialog_new(GTK_WINDOW(args->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "File could not be opened"); - gtk_window_set_title(GTK_WINDOW(message), "Open"); + message = gtk_message_dialog_new(GTK_WINDOW(args->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be opened")); + gtk_window_set_title(GTK_WINDOW(message), _("Open")); gtk_dialog_run(GTK_DIALOG(message)); gtk_widget_destroy(message); } } +static void add_file_filters (GtkWidget *dialog, FileType preselect){ + const struct{ + FileType type; + const char *label; + const char *filter; + }filters[] = { + {GPA, _("Gpick Palette (*.gpa)"), "*.gpa"}, + {GPL, _("GIMP/Inkscape Palette (*.gpl)"), "*.gpl"}, + {ASE, _("Adobe Swatch Exchange (*.ase)"), "*.ase"}, + {UNKNOWN, 0, 0}, + }; + GtkFileFilter *filter; + + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, _("All files")); + gtk_file_filter_add_pattern(filter, "*"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); + + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, _("All supported formats")); + for (gint i = 0; filters[i].type != UNKNOWN; ++i) { + gtk_file_filter_add_pattern(filter, filters[i].filter); + } + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); + gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); + + for (gint i = 0; filters[i].type != UNKNOWN; ++i) { + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, filters[i].label); + gtk_file_filter_add_pattern(filter, filters[i].filter); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); + if (preselect == filters[i].type){ + gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); + } + } +} static void menu_file_open(GtkWidget *widget, AppArgs *args){ GtkWidget *dialog; - GtkFileFilter *filter; - dialog = gtk_file_chooser_dialog_new ("Open File", GTK_WINDOW(gtk_widget_get_toplevel(widget)), + dialog = gtk_file_chooser_dialog_new(_("Open File"), GTK_WINDOW(gtk_widget_get_toplevel(widget)), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, @@ -437,11 +618,7 @@ const gchar* default_path = dynv_get_string_wd(args->params, "open.path", ""); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), default_path); - filter = gtk_file_filter_new(); - gtk_file_filter_set_name(filter, "Gpick palette *.gpa"); - gtk_file_filter_add_pattern(filter, "*.gpa"); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); - gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); + add_file_filters(dialog, UNKNOWN); gboolean finished=FALSE; @@ -456,19 +633,13 @@ g_free(path); color_list_remove_all(args->gs->colors); - if (args->current_filename) g_free(args->current_filename); - args->current_filename = 0; - if (palette_file_load(filename, args->gs->colors) == 0){ - updateRecentFileList(args, filename, false); - args->current_filename = g_strdup(filename); - updateProgramName(args); + if (app_load_file(args, filename) == 0){ finished = TRUE; }else{ - updateProgramName(args); GtkWidget* message; - message = gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "File could not be opened"); - gtk_window_set_title(GTK_WINDOW(dialog), "Open"); + message = gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be opened")); + gtk_window_set_title(GTK_WINDOW(dialog), _("Open")); gtk_dialog_run(GTK_DIALOG(message)); gtk_widget_destroy(message); } @@ -484,9 +655,8 @@ static void menu_file_save_as(GtkWidget *widget, AppArgs *args){ GtkWidget *dialog; - GtkFileFilter *filter; - dialog = gtk_file_chooser_dialog_new ("Save As", GTK_WINDOW(gtk_widget_get_toplevel(widget)), + dialog = gtk_file_chooser_dialog_new (_("Save As"), GTK_WINDOW(gtk_widget_get_toplevel(widget)), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK, @@ -499,11 +669,7 @@ const gchar* default_path = dynv_get_string_wd(args->params, "save.path", ""); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), default_path); - filter = gtk_file_filter_new(); - gtk_file_filter_set_name(filter, "Gpick palette *.gpa"); - gtk_file_filter_add_pattern(filter, "*.gpa"); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); - gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); + add_file_filters(dialog, UNKNOWN); gboolean finished=FALSE; @@ -517,16 +683,12 @@ dynv_set_string(args->params, "save.path", path); g_free(path); - if (palette_file_save(filename, args->gs->colors) == 0){ - if (args->current_filename) g_free(args->current_filename); - args->current_filename = g_strdup(filename); - updateProgramName(args); - updateRecentFileList(args, filename, true); + if (app_save_file(args, filename) == 0){ finished=TRUE; }else{ GtkWidget* message; - message=gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "File could not be saved"); - gtk_window_set_title(GTK_WINDOW(dialog), "Open"); + message=gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be saved")); + gtk_window_set_title(GTK_WINDOW(message), _("Save As")); gtk_dialog_run(GTK_DIALOG(message)); gtk_widget_destroy(message); } @@ -539,20 +701,24 @@ } static void menu_file_save(GtkWidget *widget, AppArgs *args) { + // If file has no name, "Save As" dialog is shown instead. if (args->current_filename == 0){ menu_file_save_as(widget, args); }else{ - if (palette_file_save(args->current_filename, args->gs->colors) == 0){ - updateRecentFileList(args, args->current_filename, true); + if (app_save_file(args, NULL) == 0){ }else{ - + GtkWidget* message; + message=gtk_message_dialog_new(GTK_WINDOW(args->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be saved")); + gtk_window_set_title(GTK_WINDOW(message), _("Save")); + gtk_dialog_run(GTK_DIALOG(message)); + gtk_widget_destroy(message); } } } -static gint32 color_list_selected(struct ColorObject* color_object, void *userdata){ +static PaletteListCallbackReturn color_list_selected(struct ColorObject* color_object, void *userdata){ color_list_add_color_object((struct ColorList *)userdata, color_object, 1); - return 0; + return PALETTE_LIST_CALLBACK_NO_UPDATE; } static void menu_file_export_all(GtkWidget *widget, gpointer data) { @@ -567,7 +733,10 @@ static void menu_file_export(GtkWidget *widget, gpointer data) { AppArgs* args=(AppArgs*)data; - struct ColorList *color_list = color_list_new(NULL); + struct dynvHandlerMap* handler_map = dynv_system_get_handler_map(args->gs->params); + struct ColorList *color_list = color_list_new(handler_map); + dynv_handler_map_release(handler_map); + palette_list_foreach_selected(args->color_list, color_list_selected, color_list); dialog_export_show(GTK_WINDOW(args->window), color_list, true, args->gs); color_list_destroy(color_list); @@ -599,7 +768,7 @@ GtkMenu *menu2 = GTK_MENU(gtk_menu_new()); GtkWidget *item; - item = gtk_menu_item_new_with_image ("Open Last File", gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("Open Last File"), gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu2), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (menu_file_open_last), args); @@ -632,6 +801,28 @@ show_about_box(args->window); } +static void view_palette_cb(GtkWidget *widget, AppArgs* args) { + if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))){ + g_object_ref(args->vpaned); + GtkWidget *vbox = gtk_widget_get_parent(GTK_WIDGET(args->vpaned)); + gtk_container_remove(GTK_CONTAINER(vbox), args->vpaned); + gtk_paned_pack1(GTK_PANED(args->hpaned), args->vpaned, false, false); + g_object_unref(args->vpaned); + gtk_widget_show(GTK_WIDGET(args->hpaned)); + + dynv_set_bool(args->params, "view.palette", true); + }else{ + gtk_widget_hide(GTK_WIDGET(args->hpaned)); + g_object_ref(args->vpaned); + gtk_container_remove(GTK_CONTAINER(args->hpaned), args->vpaned); + GtkWidget *vbox = gtk_widget_get_parent(GTK_WIDGET(args->hpaned)); + gtk_box_pack_start(GTK_BOX(vbox), args->vpaned, TRUE, TRUE, 5); + g_object_unref(args->vpaned); + + dynv_set_bool(args->params, "view.palette", false); + } +} + static void palette_from_image_cb(GtkWidget *widget, AppArgs* args) { tools_palette_from_image_show(GTK_WINDOW(args->window), args->gs); } @@ -644,6 +835,60 @@ delete items; } +static void activate_secondary_source(AppArgs *args, ColorSource *source){ + if (args->secondary_color_source){ + color_source_deactivate(args->secondary_color_source); + color_source_destroy(args->secondary_color_source); + args->secondary_color_source = 0; + args->secondary_source_widget = 0; + if (args->secondary_source_scrolled_viewpoint) + gtk_container_remove(GTK_CONTAINER(args->secondary_source_container), args->secondary_source_scrolled_viewpoint); + args->secondary_source_scrolled_viewpoint= 0; + if (!source) + gtk_widget_hide(args->secondary_source_container); + } + + if (source){ + string namespace_str = "gpick.secondary_view."; + namespace_str += source->identificator; + + struct dynvSystem *dynv_namespace = dynv_get_dynv(args->gs->params, namespace_str.c_str()); + source = color_source_implement(source, args->gs, dynv_namespace); + GtkWidget *new_widget = color_source_get_widget(source); + dynv_system_release(dynv_namespace); + + args->secondary_color_source = source; + args->secondary_source_widget = new_widget; + + if (source->needs_viewport){ + GtkWidget *scrolled_window = gtk_scrolled_window_new(0,0); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_NONE); + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), new_widget); + + args->secondary_source_scrolled_viewpoint = scrolled_window; + gtk_box_pack_start(GTK_BOX(args->secondary_source_container), args->secondary_source_scrolled_viewpoint, true, true, 0); + + gtk_widget_show(args->secondary_source_scrolled_viewpoint); + }else{ + gtk_box_pack_start(GTK_BOX(args->secondary_source_container), new_widget, true, true, 0); + gtk_widget_show(new_widget); + } + + gtk_widget_show(args->secondary_source_container); + color_source_activate(source); + + } +} + + +static void secondary_view_cb(GtkWidget *widget, AppArgs *args){ + if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))){ + ColorSource *source = static_cast(g_object_get_data(G_OBJECT(widget), "source")); + activate_secondary_source(args, source); + } +} + static void createMenu(GtkMenuBar *menu_bar, AppArgs *args, GtkAccelGroup *accel_group) { GtkMenu *menu; GtkWidget *item; @@ -655,24 +900,32 @@ FileMenuItems *items = new FileMenuItems(); if (gtk_stock_lookup(GTK_STOCK_NEW, &stock_item)){ - item = gtk_menu_item_new_with_image (stock_item.label, gtk_image_new_from_stock(stock_item.stock_id, GTK_ICON_SIZE_MENU)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - if (stock_item.keyval) gtk_widget_add_accelerator (item, "activate", accel_group, stock_item.keyval, stock_item.modifier, GTK_ACCEL_VISIBLE); - g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK(menu_file_new), args); + item = gtk_menu_item_new_with_image(stock_item.label, gtk_image_new_from_stock(stock_item.stock_id, GTK_ICON_SIZE_MENU)); + gtk_menu_shell_append(GTK_MENU_SHELL (menu), item); + if (stock_item.keyval) gtk_widget_add_accelerator(item, "activate", accel_group, stock_item.keyval, stock_item.modifier, GTK_ACCEL_VISIBLE); + g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK(menu_file_new), args); } if (gtk_stock_lookup(GTK_STOCK_OPEN, &stock_item)){ - item = gtk_menu_item_new_with_image (stock_item.label, gtk_image_new_from_stock(stock_item.stock_id, GTK_ICON_SIZE_MENU)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - if (stock_item.keyval) gtk_widget_add_accelerator (item, "activate", accel_group, stock_item.keyval, stock_item.modifier, GTK_ACCEL_VISIBLE); - g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK(menu_file_open), args); + item = gtk_menu_item_new_with_image(stock_item.label, gtk_image_new_from_stock(stock_item.stock_id, GTK_ICON_SIZE_MENU)); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + if (stock_item.keyval) gtk_widget_add_accelerator(item, "activate", accel_group, stock_item.keyval, stock_item.modifier, GTK_ACCEL_VISIBLE); + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(menu_file_open), args); } - item = gtk_menu_item_new_with_mnemonic ("_Recent files"); + item = gtk_menu_item_new_with_mnemonic(_("Recent _files")); items->recent_files = item; - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); + if (gtk_stock_lookup(GTK_STOCK_REVERT_TO_SAVED, &stock_item)){ + item = gtk_menu_item_new_with_image(stock_item.label, gtk_image_new_from_stock(stock_item.stock_id, GTK_ICON_SIZE_MENU)); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_r, GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_F5, GdkModifierType(0), GTK_ACCEL_VISIBLE); + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(menu_file_revert), args); + } + + gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new ()); if (gtk_stock_lookup(GTK_STOCK_SAVE, &stock_item)){ item = gtk_menu_item_new_with_image (stock_item.label, gtk_image_new_from_stock(stock_item.stock_id, GTK_ICON_SIZE_MENU)); @@ -690,21 +943,24 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_image_menu_item_new_with_mnemonic ("Ex_port..."); + item = gtk_image_menu_item_new_with_mnemonic(_("Ex_port...")); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_e, GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (menu_file_export_all), args); items->export_all = item; //gtk_widget_set_sensitive(item, (total_count >= 1)); - item = gtk_image_menu_item_new_with_mnemonic ("Expo_rt Selected..."); + item = gtk_image_menu_item_new_with_mnemonic(_("Expo_rt Selected...")); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_e, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK), GTK_ACCEL_VISIBLE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (menu_file_export), args); items->export_selected = item; //gtk_widget_set_sensitive(item, (selected_count >= 1)); - item = gtk_image_menu_item_new_with_mnemonic ("_Import..."); + item = gtk_image_menu_item_new_with_mnemonic(_("_Import...")); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_i, GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (menu_file_import), args); //gtk_widget_set_sensitive(item, 0); @@ -718,7 +974,7 @@ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK(destroy_cb), args); } - file_item = gtk_menu_item_new_with_mnemonic ("_File"); + file_item = gtk_menu_item_new_with_mnemonic(_("_File")); g_signal_connect (G_OBJECT (file_item), "activate", G_CALLBACK (menu_file_activate), args); g_object_set_data_full(G_OBJECT(file_item), "items", items, (GDestroyNotify)destroy_file_menu_items); gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_item),GTK_WIDGET( menu)); @@ -726,10 +982,14 @@ menu = GTK_MENU(gtk_menu_new()); - item = gtk_menu_item_new_with_image ("Edit _Converters...", gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image(_("Edit _Converters..."), gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (show_dialog_converter), args); + item = gtk_menu_item_new_with_image(_("Display _Filters..."), gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU)); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (show_dialog_transformations), args); + if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)){ item = gtk_menu_item_new_with_image (stock_item.label, gtk_image_new_from_stock(stock_item.stock_id, GTK_ICON_SIZE_MENU)); @@ -738,22 +998,69 @@ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK(show_dialog_options), args); } - file_item = gtk_menu_item_new_with_mnemonic ("_Edit"); + file_item = gtk_menu_item_new_with_mnemonic(_("_Edit")); gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_item),GTK_WIDGET( menu)); gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), file_item); + menu = GTK_MENU(gtk_menu_new()); + + GtkMenu *menu2 = GTK_MENU(gtk_menu_new()); + GSList *group = NULL; + + ColorSource *source = color_source_manager_get(args->csm, dynv_get_string_wd(args->params, "secondary_color_source", "")); + + item = gtk_radio_menu_item_new_with_label(group, _("None")); + group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item)); + if (source == NULL) + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), true); + g_object_set_data_full(G_OBJECT(item), "source", 0, (GDestroyNotify)NULL); + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(secondary_view_cb), args); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_N, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK), GTK_ACCEL_VISIBLE); + gtk_menu_shell_append(GTK_MENU_SHELL(menu2), item); + + + vector sources = color_source_manager_get_all(args->csm); + for (uint32_t i = 0; i < sources.size(); i++){ + if (!(sources[i]->single_instance_only)){ + item = gtk_radio_menu_item_new_with_label(group, sources[i]->hr_name); + group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item)); + if (source == sources[i]) + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), true); + g_object_set_data_full(G_OBJECT(item), "source", sources[i], (GDestroyNotify)NULL); + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(secondary_view_cb), args); + if (color_source_get_default_accelerator(sources[i])) + gtk_widget_add_accelerator(item, "activate", accel_group, color_source_get_default_accelerator(sources[i]), GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK), GTK_ACCEL_VISIBLE); + gtk_menu_shell_append(GTK_MENU_SHELL(menu2), item); + } + } + + item = gtk_menu_item_new_with_mnemonic(_("_Secondary View")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), GTK_WIDGET(menu2)); + + gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); + + item = gtk_check_menu_item_new_with_mnemonic(_("Palette")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), dynv_get_bool_wd(args->params, "view.palette", true)); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_p, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK), GTK_ACCEL_VISIBLE); + g_signal_connect(G_OBJECT(item), "toggled", G_CALLBACK(view_palette_cb), args); + + file_item = gtk_menu_item_new_with_mnemonic (_("_View")); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_item),GTK_WIDGET( menu)); + gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), file_item); menu = GTK_MENU(gtk_menu_new()); - item = gtk_menu_item_new_with_mnemonic("Palette From _Image..."); + item = gtk_menu_item_new_with_mnemonic(_("Palette From _Image...")); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(palette_from_image_cb), args); - //item = gtk_menu_item_new_with_mnemonic("Palette From _CSS file..."); + //item = gtk_menu_item_new_with_mnemonic(_("Palette From _CSS file...")); //gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); //g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(palette_from_css_file_cb), args); - file_item = gtk_menu_item_new_with_mnemonic("_Tools"); + file_item = gtk_menu_item_new_with_mnemonic(_("_Tools")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), GTK_WIDGET(menu)); gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file_item); @@ -768,7 +1075,7 @@ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK(show_about_box_cb), args); } - file_item = gtk_menu_item_new_with_mnemonic ("_Help"); + file_item = gtk_menu_item_new_with_mnemonic (_("_Help")); gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_item),GTK_WIDGET( menu)); gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), file_item); } @@ -881,9 +1188,9 @@ } } -gint32 color_list_mark_selected(struct ColorObject* color_object, void *userdata){ - color_object->selected=1; - return 0; +static PaletteListCallbackReturn color_list_mark_selected(struct ColorObject* color_object, void *userdata){ + color_object->selected = 1; + return PALETTE_LIST_CALLBACK_NO_UPDATE; } static void palette_popup_menu_remove_all(GtkWidget *widget, AppArgs* args) { @@ -895,6 +1202,113 @@ color_list_remove_selected(args->gs->colors); } +static PaletteListCallbackReturn color_list_clear_names(struct ColorObject* color_object, void *userdata){ + dynv_set_string(color_object->params, "name", ""); + return PALETTE_LIST_CALLBACK_UPDATE_NAME; +} + +static void palette_popup_menu_clear_names(GtkWidget *widget, AppArgs* args) { + palette_list_foreach_selected(args->color_list, color_list_clear_names, NULL); +} + +typedef struct AutonameState{ + ColorNames *color_names; + bool imprecision_postfix; +}AutonameState; + +static PaletteListCallbackReturn color_list_autoname(struct ColorObject* color_object, void *userdata){ + AutonameState *state=(AutonameState *)(userdata); + Color c; + color_object_get_color (color_object, &c); + dynv_set_string(color_object->params, "name", color_names_get(state->color_names, &c, state->imprecision_postfix).c_str()); + return PALETTE_LIST_CALLBACK_UPDATE_NAME; +} + +static void palette_popup_menu_autoname(GtkWidget *widget, AppArgs* args) { + AutonameState state; + state.color_names = args->gs->color_names; + state.imprecision_postfix = dynv_get_bool_wd(args->gs->params, "gpick.color_names.imprecision_postfix", true); + palette_list_foreach_selected(args->color_list, color_list_autoname, &state); +} + +typedef struct AutonumberState{ + std::string name; + uint32_t index; + uint32_t nplaces; + bool decreasing; + bool append; +}AutonumberState; + +static PaletteListCallbackReturn color_list_autonumber(struct ColorObject* color_object, void *userdata){ + AutonumberState *state = (AutonumberState*)userdata; + stringstream ss; + if (state->append == true){ + ss << dynv_get_string_wd(color_object->params, "name","") << " "; + } + ss << state->name << "-"; + ss.width(state->nplaces); + ss.fill('0'); + if (state->decreasing){ + ss << right << state->index; + state->index--; + } + else{ + ss << right << state->index++; + } + + dynv_set_string(color_object->params, "name", ss.str().c_str()); + return PALETTE_LIST_CALLBACK_UPDATE_NAME; +} + +static PaletteListCallbackReturn color_list_set_color (struct ColorObject* color_object, void *userdata){ + Color *source_color = (Color *)(userdata); + color_object_set_color (color_object, source_color); + return PALETTE_LIST_CALLBACK_UPDATE_ROW; +} + + + +static void palette_popup_menu_autonumber(GtkWidget *widget, AppArgs* args) { + AutonumberState state; + int response; + uint32_t selected_count = palette_list_get_selected_count(args->color_list); + + response = dialog_autonumber_show(GTK_WINDOW(args->window), selected_count, args->gs); + if (response == GTK_RESPONSE_OK){ + struct dynvSystem *params; + + params = dynv_get_dynv(args->gs->params, "gpick.autonumber"); + state.name = dynv_get_string_wd(params, "name", "autonum"); + state.nplaces = dynv_get_int32_wd(params, "nplaces", 1); + state.index = dynv_get_int32_wd(params, "startindex", 1); + state.decreasing = dynv_get_bool_wd(params, "decreasing", true); + state.append = dynv_get_bool_wd(params, "append", true); + + palette_list_foreach_selected(args->color_list, color_list_autonumber, &state); + dynv_system_release(params); + } +} + + +typedef struct ReplaceState{ + std::list::reverse_iterator iter; +} ReplaceState; + +static PaletteListCallbackReturn color_list_reverse_replace(struct ColorObject** color_object, void *userdata) +{ + ReplaceState *state = reinterpret_cast(userdata); + *color_object = color_object_ref(*(state->iter)); + state->iter++; + return PALETTE_LIST_CALLBACK_UPDATE_ROW; +} + +static void palette_popup_menu_reverse(GtkWidget *widget, AppArgs* args) { + struct ColorList *color_list = color_list_new(NULL); + ReplaceState state; + palette_list_foreach_selected(args->color_list, color_list_selected, color_list); + state.iter = color_list->colors.rbegin(); + palette_list_foreach_selected(args->color_list, color_list_reverse_replace, &state); +} gint32 palette_popup_menu_mix_list(Color* color, void *userdata){ *((GList**)userdata) = g_list_append(*((GList**)userdata), color); @@ -930,6 +1344,32 @@ color_list_destroy(color_list); } +typedef struct GroupAndSortState{ + std::list::iterator iter; +} GroupAndSortState; + +static PaletteListCallbackReturn color_list_group_and_sort_replace(struct ColorObject** color_object, void *userdata) +{ + GroupAndSortState *state = reinterpret_cast(userdata); + *color_object = color_object_ref(*(state->iter)); + state->iter++; + return PALETTE_LIST_CALLBACK_UPDATE_ROW; +} + +static void palette_popup_menu_group_and_sort(GtkWidget *widget, AppArgs* args) +{ + struct ColorList *color_list = color_list_new(NULL); + struct ColorList *sorted_color_list = color_list_new(NULL); + palette_list_foreach_selected(args->color_list, color_list_selected, color_list); + if (dialog_sort_show(GTK_WINDOW(args->window), color_list, sorted_color_list, args->gs)){ + GroupAndSortState state; + state.iter = sorted_color_list->colors.begin(); + palette_list_foreach_selected(args->color_list, color_list_group_and_sort_replace, &state); + } + color_list_destroy(color_list); + color_list_destroy(sorted_color_list); +} + static gboolean palette_popup_menu_show(GtkWidget *widget, GdkEventButton* event, AppArgs *args) { GtkWidget *menu; GtkWidget* item ; @@ -937,10 +1377,14 @@ menu = gtk_menu_new (); + GtkAccelGroup *accel_group = gtk_accel_group_new(); + gtk_menu_set_accel_group(GTK_MENU(menu), accel_group); + gint32 selected_count = palette_list_get_selected_count(args->color_list); gint32 total_count = palette_list_get_count(args->color_list); - item = gtk_menu_item_new_with_mnemonic ("_Copy to Clipboard"); + item = gtk_menu_item_new_with_mnemonic(_("_Copy to Clipboard")); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_c, GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_set_sensitive(item, (selected_count >= 1)); @@ -955,17 +1399,17 @@ gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); - item = gtk_menu_item_new_with_image ("_Mix Colors...", gtk_image_new_from_stock(GTK_STOCK_CONVERT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Mix Colors..."), gtk_image_new_from_stock(GTK_STOCK_CONVERT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK(palette_popup_menu_mix), args); gtk_widget_set_sensitive(item, (selected_count >= 2)); - item = gtk_menu_item_new_with_image ("_Variations...", gtk_image_new_from_stock(GTK_STOCK_CONVERT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Variations..."), gtk_image_new_from_stock(GTK_STOCK_CONVERT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK(palette_popup_menu_variations), args); gtk_widget_set_sensitive(item, (selected_count >= 1)); - item = gtk_menu_item_new_with_image ("_Generate...", gtk_image_new_from_stock(GTK_STOCK_CONVERT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Generate..."), gtk_image_new_from_stock(GTK_STOCK_CONVERT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK(palette_popup_menu_generate), args); gtk_widget_set_sensitive(item, (selected_count >= 1)); @@ -973,12 +1417,48 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); - item = gtk_menu_item_new_with_image ("_Remove", gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU)); + + item = gtk_menu_item_new_with_mnemonic (_("C_lear names")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (palette_popup_menu_clear_names), args); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_E, GdkModifierType(0), GTK_ACCEL_VISIBLE); + gtk_widget_set_sensitive(item, (selected_count >= 1)); + + item = gtk_menu_item_new_with_mnemonic (_("Autona_me")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (palette_popup_menu_autoname), args); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_N, GdkModifierType(0), GTK_ACCEL_VISIBLE); + gtk_widget_set_sensitive(item, (selected_count >= 1)); + + item = gtk_menu_item_new_with_mnemonic (_("Auto_number...")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (palette_popup_menu_autonumber), args); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_a, GdkModifierType(0), GTK_ACCEL_VISIBLE); + gtk_widget_set_sensitive(item, (selected_count >= 1)); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); + + item = gtk_menu_item_new_with_mnemonic(_("R_everse")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (palette_popup_menu_reverse), args); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_v, GdkModifierType(0), GTK_ACCEL_VISIBLE); + gtk_widget_set_sensitive(item, (selected_count >= 2)); + + item = gtk_menu_item_new_with_mnemonic(_("Group and _sort...")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(palette_popup_menu_group_and_sort), args); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_g, GdkModifierType(0), GTK_ACCEL_VISIBLE); + gtk_widget_set_sensitive(item, (selected_count >= 2)); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); + + item = gtk_menu_item_new_with_image (_("_Remove"), gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (palette_popup_menu_remove_selected), args); + gtk_widget_add_accelerator(item, "activate", accel_group, GDK_Delete, GdkModifierType(0), GTK_ACCEL_VISIBLE); gtk_widget_set_sensitive(item, (selected_count >= 1)); - item = gtk_menu_item_new_with_image ("Remove _All", gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("Remove _All"), gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect(G_OBJECT (item), "activate", G_CALLBACK (palette_popup_menu_remove_all), args); gtk_widget_set_sensitive(item, (total_count >= 1)); @@ -994,6 +1474,10 @@ } gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time); + + g_object_ref_sink(G_OBJECT(accel_group)); + g_object_unref(G_OBJECT(accel_group)); + g_object_ref_sink(menu); g_object_unref(menu); @@ -1017,6 +1501,57 @@ switch(event->keyval) { + case GDK_1: + case GDK_KP_1: + case GDK_2: + case GDK_KP_2: + case GDK_3: + case GDK_KP_3: + case GDK_4: + case GDK_KP_4: + case GDK_5: + case GDK_KP_5: + case GDK_6: + case GDK_KP_6: + { + struct ColorList *color_list = color_list_new(NULL); + palette_list_forfirst_selected(args->color_list, color_list_selected, color_list); + if (color_list_get_count(color_list) > 0){ + ColorSource *color_source = (ColorSource*)dynv_get_pointer_wd(args->gs->params, "CurrentColorSource", 0); + uint32_t color_index = 0; + switch(event->keyval) + { + case GDK_KP_1: + case GDK_1: color_index = 0; break; + case GDK_KP_2: + case GDK_2: color_index = 1; break; + case GDK_KP_3: + case GDK_3: color_index = 2; break; + case GDK_KP_4: + case GDK_4: color_index = 3; break; + case GDK_KP_5: + case GDK_5: color_index = 4; break; + case GDK_KP_6: + case GDK_6: color_index = 5; break; + } + + if ((event->state&modifiers)==GDK_CONTROL_MASK){ + struct ColorObject *source_color_object; + Color source_color; + color_source_get_nth_color(color_source, color_index, &source_color_object); + color_object_get_color (source_color_object, &source_color); + palette_list_forfirst_selected (args->color_list, color_list_set_color, &source_color); + } + else{ + color_source_set_nth_color(color_source, color_index, *color_list->colors.begin()); + } + } + color_list_destroy(color_list); + return true; + } + return false; + break; + case GDK_c: if ((event->state&modifiers)==GDK_CONTROL_MASK){ @@ -1039,10 +1574,40 @@ color_object_release(color_object); } return true; + }else{ + palette_popup_menu_reverse(widget, args); + return true; } return false; break; + case GDK_g: + palette_popup_menu_group_and_sort(widget, args); + return true; + break; + + case GDK_Delete: + palette_popup_menu_remove_selected(widget, args); + break; + + case GDK_a: + if ((event->state & GDK_CONTROL_MASK) == 0){ + palette_popup_menu_autonumber(widget, args); + return true; + } + break; + case GDK_e: + if ((event->state & GDK_CONTROL_MASK) == 0){ + palette_popup_menu_clear_names(widget, args); + return true; + } + break; + case GDK_n: + if ((event->state & GDK_CONTROL_MASK) == 0){ + palette_popup_menu_autoname(widget, args); + return true; + } + break; default: return false; break; @@ -1071,14 +1636,14 @@ return 0; } -static gint32 callback_color_list_on_get_positions(struct ColorObject* color_object, void *userdata){ - color_object->position=*((unsigned long*)userdata); +static PaletteListCallbackReturn callback_color_list_on_get_positions(struct ColorObject* color_object, void *userdata){ + color_object->position = *((unsigned long*)userdata); (*((unsigned long*)userdata))++; - return 0; + return PALETTE_LIST_CALLBACK_NO_UPDATE; } static int color_list_on_get_positions(struct ColorList* color_list){ - unsigned long item=0; + unsigned long item = 0; palette_list_foreach(((AppArgs*)color_list->userdata)->color_list, callback_color_list_on_get_positions, &item ); return 0; } @@ -1103,7 +1668,6 @@ if (x<0 || y<0 || x>gdk_screen_width() || y>gdk_screen_height()){ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); }else{ - //cout << "Moving to "<< x << " " << y << endl; gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_NONE); gtk_window_move(GTK_WINDOW(window), x, y); } @@ -1118,8 +1682,11 @@ static gboolean on_window_focus_change(GtkWidget *widget, GdkEventFocus *event, AppArgs* args) { if (event->in){ + + if (args->secondary_color_source) color_source_activate(args->secondary_color_source); if (args->current_color_source) color_source_activate(args->current_color_source); }else{ + if (args->secondary_color_source) color_source_deactivate(args->secondary_color_source); if (args->current_color_source) color_source_deactivate(args->current_color_source); } @@ -1155,67 +1722,63 @@ } } -static void activate_secondary_source(AppArgs *args, ColorSource *source){ - if (args->secondary_color_source){ - //gtk_container_remove(GTK_CONTAINER(args->secondary_source_container), args->secondary_source_widget); - color_source_deactivate(args->secondary_color_source); - color_source_destroy(args->secondary_color_source); - args->secondary_color_source = 0; - args->secondary_source_widget = 0; - } - - if (source){ - - string namespace_str = "gpick.secondary_view."; - namespace_str += source->identificator; - - struct dynvSystem *dynv_namespace = dynv_get_dynv(args->gs->params, namespace_str.c_str()); - source = color_source_implement(source, args->gs, dynv_namespace); - GtkWidget *new_widget = color_source_get_widget(source); - dynv_system_release(dynv_namespace); - - args->secondary_color_source = source; - args->secondary_source_widget = new_widget; - - gtk_box_pack_start(GTK_BOX(args->secondary_source_container), new_widget, true, true, 0); - - gtk_widget_show(new_widget); - color_source_activate(source); - - } +bool app_is_autoload_enabled(AppArgs *args){ + return dynv_get_bool_wd(args->params, "main.save_restore_palette", true); } -static void secondary_view_cb(GtkWidget *widget, AppArgs *args){ - ColorSource *source = static_cast(g_object_get_data(G_OBJECT(widget), "source")); - activate_secondary_source(args, source); +static bool app_on_control_activate_floating_picker(void *userdata) +{ + AppArgs *args = reinterpret_cast(userdata); + floating_picker_activate(args->floating_picker, false); + return true; } -static int unique_show_window(AppArgs* args){ +static bool app_on_single_instance_activate(void *userdata) +{ + AppArgs *args = reinterpret_cast(userdata); status_icon_set_visible(args->statusIcon, false); main_show_window(args->window, args->params); - return 0; + return true; } -AppArgs* app_create_main(){ +AppArgs* app_create_main(const AppOptions *options){ AppArgs* args=new AppArgs; + memcpy(&args->options, options, sizeof(AppOptions)); + + color_init(); GlobalState *gs = global_state_create(); args->gs = gs; global_state_init(args->gs, GLOBALSTATE_CONFIGURATION); - if (dynv_get_bool_wd(gs->params, "gpick.main.single_instance", false)){ - if (unique_init((unique_cb_t)unique_show_window, args)==0){ + args->bus_id = gpick_own_name(app_on_control_activate_floating_picker, app_on_single_instance_activate, args); - }else{ - delete args; - return 0; + bool cancel_startup = false; + + if (!cancel_startup && args->options.floating_picker_mode){ + if (gpick_control_activate_floating_picker()){ + cancel_startup = true; + } + } + if (!cancel_startup && dynv_get_bool_wd(gs->params, "gpick.main.single_instance", false)){ + if (gpick_single_instance_activate()){ + cancel_startup = true; } } + if (cancel_startup){ + delete args; + return 0; + } + args->current_filename = 0; + args->imported = false; + args->precision_loss_icon = 0; args->current_color_source = 0; args->secondary_color_source = 0; args->secondary_source_widget = 0; + args->secondary_source_scrolled_viewpoint= 0; + global_state_init(args->gs, GLOBALSTATE_ALL); @@ -1262,11 +1825,15 @@ gtk_box_pack_start (GTK_BOX(vbox_main), menu_bar, FALSE, FALSE, 0); hpaned = gtk_hpaned_new(); - gtk_box_pack_start (GTK_BOX(vbox_main), hpaned, TRUE, TRUE, 5); + bool color_list_visible = dynv_get_bool_wd(args->params, "view.palette", true); + vpaned = gtk_vpaned_new(); args->vpaned = vpaned; - gtk_paned_pack1(GTK_PANED(hpaned), vpaned, false, false); + if (color_list_visible) + gtk_paned_pack1(GTK_PANED(hpaned), vpaned, false, false); + else + gtk_box_pack_start(GTK_BOX(vbox_main), vpaned, TRUE, TRUE, 5); notebook = gtk_notebook_new(); g_signal_connect(G_OBJECT (notebook), "switch-page", G_CALLBACK(notebook_switch_cb), args); @@ -1275,9 +1842,17 @@ statusbar=gtk_statusbar_new(); dynv_set_pointer(args->gs->params, "StatusBar", statusbar); + gtk_paned_pack1(GTK_PANED(vpaned), notebook, false, false); - gtk_widget_show_all(vbox_main); + if (color_list_visible){ + gtk_box_pack_start(GTK_BOX(vbox_main), hpaned, TRUE, TRUE, 5); + gtk_widget_show_all(vbox_main); + }else{ + gtk_widget_show_all(vbox_main); + gtk_box_pack_start(GTK_BOX(vbox_main), hpaned, TRUE, TRUE, 5); + } + ColorSource *source; struct dynvSystem *dynv_namespace; @@ -1291,7 +1866,7 @@ args->color_source_index.push_back(source); args->floating_picker = floating_picker_new(args->window, args->gs, source); color_picker_set_floating_picker(source, args->floating_picker); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, gtk_label_new_with_mnemonic("Color pic_ker")); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, gtk_label_new_with_mnemonic(_("Color pic_ker"))); gtk_widget_show(widget); dynv_namespace = dynv_get_dynv(gs->params, "gpick.generate_scheme"); @@ -1300,50 +1875,17 @@ dynv_system_release(dynv_namespace); args->color_source[source->identificator] = source; args->color_source_index.push_back(source); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, gtk_label_new_with_mnemonic("Scheme _generation")); - gtk_widget_show(widget); - -/* source = generate_scheme_new(args->gs, &widget); - args->secondary_color_source = source; - gtk_paned_pack2(GTK_PANED(vpaned), widget, false, false); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, gtk_label_new_with_mnemonic(_("Scheme _generation"))); gtk_widget_show(widget); -*/ - widget = gtk_vbox_new(false, 0); - args->secondary_source_container = widget; - - GtkWidget *menubar = gtk_menu_bar_new(); - GtkWidget *menu; - GtkWidget *item, *file_item; - - menu = gtk_menu_new(); - - item = gtk_menu_item_new_with_label("None"); - g_object_set_data_full(G_OBJECT(item), "source", 0, (GDestroyNotify)NULL); - g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(secondary_view_cb), args); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - vector sources = color_source_manager_get_all(args->csm); - for (uint32_t i = 0; i < sources.size(); i++){ - if (!(sources[i]->single_instance_only)){ - item = gtk_menu_item_new_with_label(sources[i]->hr_name); - g_object_set_data_full(G_OBJECT(item), "source", sources[i], (GDestroyNotify)NULL); - g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(secondary_view_cb), args); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - } + { + widget = gtk_vbox_new(false, 0); + gtk_paned_pack2(GTK_PANED(vpaned), widget, false, false); + args->secondary_source_container = widget; + source = color_source_manager_get(args->csm, dynv_get_string_wd(args->params, "secondary_color_source", "")); + if (source) activate_secondary_source(args, source); } - file_item = gtk_menu_item_new_with_mnemonic("_View"); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), GTK_WIDGET(menu)); - gtk_menu_bar_append(GTK_MENU_BAR(menubar), file_item); - - gtk_box_pack_start(GTK_BOX(widget), menubar, false, true, 0); - - gtk_paned_pack2(GTK_PANED(vpaned), widget, false, false); - gtk_widget_show_all(widget); - - - source = color_source_manager_get(args->csm, dynv_get_string_wd(args->params, "secondary_color_source", "")); - if (source) activate_secondary_source(args, source); dynv_namespace = dynv_get_dynv(gs->params, "gpick.layout_preview"); @@ -1352,14 +1894,16 @@ dynv_system_release(dynv_namespace); args->color_source[source->identificator] = source; args->color_source_index.push_back(source); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, gtk_label_new_with_mnemonic("Lay_out preview")); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, gtk_label_new_with_mnemonic(_("Lay_out preview"))); gtk_widget_show(widget); - widget = palette_list_new(args->gs); + + GtkWidget *count_label = gtk_label_new(""); + widget = palette_list_new(args->gs, count_label); args->color_list = widget; gtk_widget_show(widget); - g_signal_connect(G_OBJECT(widget), "popup-menu", G_CALLBACK (on_palette_popup_menu), args); + g_signal_connect(G_OBJECT(widget), "popup-menu", G_CALLBACK (on_palette_popup_menu), args); g_signal_connect(G_OBJECT(widget), "button-press-event",G_CALLBACK (on_palette_button_press), args); g_signal_connect(G_OBJECT(widget), "key_press_event", G_CALLBACK (on_palette_list_key_press), args); @@ -1400,11 +1944,21 @@ gtk_button_set_focus_on_click(GTK_BUTTON(button), false); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(floating_picker_show_cb), args); gtk_widget_add_accelerator(button, "clicked", accel_group, GDK_p, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - gtk_widget_set_tooltip_text(button, "Pick colors (Ctrl+P)"); + gtk_widget_set_tooltip_text(button, _("Pick colors (Ctrl+P)")); gtk_container_add(GTK_CONTAINER(button), gtk_image_new_from_icon_name("gpick", GTK_ICON_SIZE_MENU)); gtk_box_pack_end(GTK_BOX(statusbar), button, false, false, 0); gtk_widget_show_all(button); + gtk_box_pack_end(GTK_BOX(statusbar), count_label, false, false, 0); + gtk_widget_show_all(count_label); + + widget = gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU); + gtk_widget_set_tooltip_text(widget, _("File is currently in a non-native format, possible loss of precision and/or metadata.")); + args->precision_loss_icon = widget; + if (args->imported) + gtk_widget_show(widget); + gtk_box_pack_end(GTK_BOX(statusbar), widget, false, false, 0); + gtk_widget_show(statusbar); @@ -1435,15 +1989,18 @@ gtk_widget_realize(args->window); - gtk_paned_set_position(GTK_PANED(args->hpaned), dynv_get_int32_wd(args->params, "paned_position", -1)); - gtk_paned_set_position(GTK_PANED(args->vpaned), dynv_get_int32_wd(args->params, "vertical_paned_position", -1)); - - if (dynv_get_bool_wd(args->params, "start_in_tray", false)){ + if (args->options.floating_picker_mode || dynv_get_bool_wd(args->params, "start_in_tray", false)){ status_icon_set_visible (args->statusIcon, true); }else{ main_show_window(args->window, args->params); } + gtk_paned_set_position(GTK_PANED(args->hpaned), dynv_get_int32_wd(args->params, "paned_position", -1)); + gtk_paned_set_position(GTK_PANED(args->vpaned), dynv_get_int32_wd(args->params, "vertical_paned_position", -1)); + + if (args->options.floating_picker_mode) + floating_picker_activate(args->floating_picker, false); + gtk_main(); { @@ -1464,12 +2021,14 @@ delete [] recent_array; } - unique_term(); + gpick_unown_name(args->bus_id); + status_icon_destroy(args->statusIcon); global_state_term(args->gs); dynv_system_release(args->params); global_state_destroy(args->gs); if (args->current_filename) g_free(args->current_filename); + color_source_manager_destroy(args->csm); delete args; return 0; diff -Nru gpick-0.2.4/source/uiApp.h gpick-0.2.5/source/uiApp.h --- gpick-0.2.4/source/uiApp.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiApp.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -41,10 +41,16 @@ typedef struct AppArgs AppArgs; -AppArgs* app_create_main(); -int app_load_file(AppArgs *args, const char *filename); +typedef struct AppOptions { + bool floating_picker_mode; +}AppOptions; + +AppArgs* app_create_main(const AppOptions *options); +int app_load_file(AppArgs *args, const char *filename, bool autoload = false); int app_run(AppArgs *args); int app_parse_geometry(AppArgs *args, const char *geometry); +bool app_is_autoload_enabled(AppArgs *args); + #endif /* UIAPP_H_ */ diff -Nru gpick-0.2.4/source/uiColorInput.cpp gpick-0.2.5/source/uiColorInput.cpp --- gpick-0.2.4/source/uiColorInput.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiColorInput.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -23,6 +23,13 @@ #include "uiUtilities.h" #include "GlobalStateStruct.h" #include "gtk/ColorWheel.h" +#include "Internationalisation.h" +#include "gtk/ColorComponent.h" +#include "gtk/ColorWidget.h" + +#include "ColorSpaceType.h" +#include + int dialog_color_input_show(GtkWindow* parent, GlobalState* gs, struct ColorObject* color_object, struct ColorObject** new_color_object){ @@ -35,7 +42,7 @@ converter_get_text(converter->function_name, color_object, 0, gs->params, &text); } - GtkWidget *dialog = gtk_dialog_new_with_buttons("Edit color", parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Edit color"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -43,14 +50,26 @@ gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); GtkWidget* vbox = gtk_vbox_new(false, 5); - //gtk_box_pack_start(GTK_BOX(vbox), gtk_color_wheel_new(), false, false, 0); GtkWidget* hbox = gtk_hbox_new(false, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox, false, false, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, true, true, 0); + + GtkWidget *widget; + widget = gtk_color_new(); + gtk_color_set_rounded(GTK_COLOR(widget), true); + gtk_color_set_hcenter(GTK_COLOR(widget), true); + gtk_color_set_roundness(GTK_COLOR(widget), 5); + + Color c; + color_object_get_color(color_object, &c); + gtk_color_set_color(GTK_COLOR(widget), &c, ""); + + gtk_box_pack_start(GTK_BOX(hbox), widget, false, true, 0); - gtk_box_pack_start(GTK_BOX(hbox), gtk_label_aligned_new("Color:",0,0.5,0,0), false, false, 0); + gtk_box_pack_start(GTK_BOX(hbox), gtk_label_aligned_new(_("Color:"),0,0.5,0,0), false, false, 0); GtkWidget* entry = gtk_entry_new(); + gtk_entry_set_activates_default(GTK_ENTRY(entry), true); gtk_box_pack_start(GTK_BOX(hbox), entry, true, true, 0); if (text){ @@ -61,6 +80,8 @@ gtk_widget_show_all(vbox); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { struct ColorObject* color_object; @@ -74,3 +95,84 @@ return -1; } +typedef struct ColorPickerComponentEditArgs{ + //ColorPickerArgs *color_picker; + GtkWidget* value[4]; + GtkColorComponentComp component; + int component_id; + struct dynvSystem *params; +}ColorPickerComponentEditArgs; + +void dialog_color_component_input_show(GtkWindow* parent, GtkColorComponent *color_component, int component_id, struct dynvSystem *params) +{ + GtkColorComponentComp component = gtk_color_component_get_component(GTK_COLOR_COMPONENT(color_component)); + + ColorPickerComponentEditArgs *args = new ColorPickerComponentEditArgs; + //args->color_picker = color_picker_args; + args->params = params; + args->component = component; + args->component_id = component_id; + memset(args->value, 0, sizeof(args->value)); + + GtkWidget *table; + + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Edit"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + gtk_window_set_default_size(GTK_WINDOW(dialog), dynv_get_int32_wd(args->params, "window.width", -1), dynv_get_int32_wd(args->params, "window.height", -1)); + + gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); + + table = gtk_table_new(2, 2, FALSE); + + Color raw_color; + gtk_color_component_get_raw_color(color_component, &raw_color); + + const ColorSpaceType *color_space_type = 0; + for (uint32_t i = 0; i < color_space_count_types(); i++){ + if (color_space_get_types()[i].comp_type == component){ + color_space_type = &color_space_get_types()[i]; + break; + } + } + + if (color_space_type){ + for (int i = 0; i < color_space_type->n_items; i++){ + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(color_space_type->items[i].name,0,0,0,0),0,1,i,i+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->value[i] = gtk_spin_button_new_with_range(color_space_type->items[i].min_value, color_space_type->items[i].max_value, color_space_type->items[i].step); + gtk_entry_set_activates_default(GTK_ENTRY(args->value[i]), true); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->value[i]), raw_color.ma[i] * color_space_type->items[i].raw_scale); + gtk_table_attach(GTK_TABLE(table), args->value[i],1,2,i,i+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + if (i == component_id) + gtk_widget_grab_focus(args->value[i]); + } + } + + gtk_widget_show_all(table); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); + + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK){ + if (color_space_type){ + for (int i = 0; i < color_space_type->n_items; i++){ + raw_color.ma[i] = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->value[i])) / color_space_type->items[i].raw_scale; + } + gtk_color_component_set_raw_color(color_component, &raw_color); + } + } + + gint width, height; + gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); + dynv_set_int32(args->params, "window.width", width); + dynv_set_int32(args->params, "window.height", height); + + gtk_widget_destroy(dialog); + + dynv_system_release(args->params); + delete args; +} + + diff -Nru gpick-0.2.4/source/uiColorInput.h gpick-0.2.5/source/uiColorInput.h --- gpick-0.2.4/source/uiColorInput.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiColorInput.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,8 +20,11 @@ #define UICOLORINPUT_H_ #include +#include "gtk/ColorComponent.h" #include "GlobalState.h" int dialog_color_input_show(GtkWindow* parent, GlobalState* gs, struct ColorObject* color_object, struct ColorObject** new_color_object); +void dialog_color_component_input_show(GtkWindow* parent, GtkColorComponent *color_component, int component_id, struct dynvSystem *params); + #endif /* UICOLORINPUT_H_ */ diff -Nru gpick-0.2.4/source/uiConverter.cpp gpick-0.2.5/source/uiConverter.cpp --- gpick-0.2.4/source/uiConverter.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiConverter.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,6 +22,7 @@ #include "uiUtilities.h" #include "DynvHelpers.h" #include "GlobalStateStruct.h" +#include "Internationalisation.h" #include using namespace std; @@ -52,7 +53,7 @@ c.rgb.green=0.50; c.rgb.blue=0.25; struct ColorObject *color_object=color_list_new_color_object(args->gs->colors, &c); - dynv_set_string(color_object->params, "name", "Test color"); + dynv_set_string(color_object->params, "name", _("Test color")); Converters *converters = static_cast(dynv_get_pointer_wdc(args->gs->params, "Converters", 0)); @@ -70,7 +71,7 @@ }else{ gtk_list_store_set(GTK_LIST_STORE(model), iter1, CONVERTERLIST_HUMAN_NAME, converter->human_readable, - CONVERTERLIST_EXAMPLE, "error", + CONVERTERLIST_EXAMPLE, _("error"), CONVERTERLIST_CONVERTER_PTR, converter, CONVERTERLIST_COPY, converter->copy, CONVERTERLIST_COPY_ENABLED, converter->serialize_available, @@ -141,7 +142,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable(col,1); - gtk_tree_view_column_set_title(col, "Function name"); + gtk_tree_view_column_set_title(col, _("Function name")); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", CONVERTERLIST_HUMAN_NAME); @@ -150,7 +151,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable(col,1); - gtk_tree_view_column_set_title(col, "Example"); + gtk_tree_view_column_set_title(col, _("Example")); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", CONVERTERLIST_EXAMPLE); @@ -159,7 +160,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_GROW_ONLY); - gtk_tree_view_column_set_title(col, "Copy"); + gtk_tree_view_column_set_title(col, _("Copy")); renderer = gtk_cell_renderer_toggle_new(); gtk_tree_view_column_pack_start(col, renderer, false); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); @@ -168,7 +169,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_GROW_ONLY); - gtk_tree_view_column_set_title(col, "Paste"); + gtk_tree_view_column_set_title(col, _("Paste")); renderer = gtk_cell_renderer_toggle_new(); gtk_tree_view_column_pack_start(col, renderer, false); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); @@ -192,7 +193,7 @@ args->gs = gs; args->params = dynv_get_dynv(args->gs->params, "gpick"); - GtkWidget *dialog = gtk_dialog_new_with_buttons("Converters", parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Converters"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -220,13 +221,13 @@ table_y=0; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Displays:",0,0.5,0,0), 0, 1, table_y, table_y+1, GtkAttachOptions(GTK_FILL), GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Displays:"),0,0.5,0,0), 0, 1, table_y, table_y+1, GtkAttachOptions(GTK_FILL), GTK_FILL, 0, 0); GtkWidget *display = converter_dropdown_new(args, 0); GtkTreeModel *model2=gtk_combo_box_get_model(GTK_COMBO_BOX(display)); gtk_table_attach(GTK_TABLE(table), display, 1, 2, table_y, table_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0); table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Color list:",0,0.5,0,0), 0, 1, table_y, table_y+1, GtkAttachOptions(GTK_FILL), GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Color list:"),0,0.5,0,0), 0, 1, table_y, table_y+1, GtkAttachOptions(GTK_FILL), GTK_FILL, 0, 0); GtkWidget *color_list = converter_dropdown_new(args, model2); gtk_table_attach(GTK_TABLE(table), color_list, 1, 2, table_y, table_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0); table_y++; diff -Nru gpick-0.2.4/source/uiConverter.h gpick-0.2.5/source/uiConverter.h --- gpick-0.2.4/source/uiConverter.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiConverter.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/uiDialogAutonumber.cpp gpick-0.2.5/source/uiDialogAutonumber.cpp --- gpick-0.2.4/source/uiDialogAutonumber.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/uiDialogAutonumber.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "uiDialogAutonumber.h" +#include "uiListPalette.h" +#include "uiUtilities.h" +#include "MathUtil.h" +#include "DynvHelpers.h" +#include "GlobalStateStruct.h" +#include "ColorRYB.h" +#include "Noise.h" +#include "GenerateScheme.h" +#include "Internationalisation.h" + +#include +#include +#include +using namespace std; + +typedef struct DialogAutonumberArgs{ + GtkWidget *name; + GtkWidget *nplaces; + GtkWidget *startindex; + GtkWidget *toggle_decreasing; + GtkWidget *toggle_append; + uint32_t selected_count; + + GtkWidget *sample; + + struct dynvSystem *params; + GlobalState* gs; +}DialogAutonumberArgs; + +static int default_nplaces (uint32_t selected_count){ + uint32_t places = 1; + uint32_t ncolors = selected_count; + // technically this can be implemented as `places = 1 + (int) (trunc(log (ncolors,10)));` + // however I don't know the exact function names, and this has minimal dependencies and acceptable speed. + while (ncolors > 10) { + ncolors = ncolors / 10; + places += 1; + } + return places; +} + +static void update(GtkWidget *widget, DialogAutonumberArgs *args ){ + uint32_t nplaces = gtk_spin_button_get_value (GTK_SPIN_BUTTON(args->nplaces)); + int startindex = gtk_spin_button_get_value (GTK_SPIN_BUTTON(args->startindex)); + const char *name = gtk_entry_get_text(GTK_ENTRY(args->name)); + stringstream ss; + ss << name << "-"; + ss.fill('0'); + ss.width(nplaces); + ss << right << startindex; + gtk_entry_set_text(GTK_ENTRY(args->sample), ss.str().c_str()); + dynv_set_string (args->params, "name", name); + dynv_set_bool (args->params, "append", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_append))); + dynv_set_bool (args->params, "decreasing", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_decreasing))); + dynv_set_int32 (args->params, "nplaces", nplaces); + dynv_set_int32 (args->params, "startindex", startindex); +} + +static void update_startindex(GtkWidget *widget, DialogAutonumberArgs *args ){ + int startindex = gtk_spin_button_get_value (GTK_SPIN_BUTTON(args->startindex)); + int newindex; + gdouble min, max; + gtk_spin_button_get_range(GTK_SPIN_BUTTON(args->startindex), &min, &max); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){ + if (startindex == 0){ + newindex = args->selected_count; + }else{ + newindex = args->selected_count + (startindex - 1); + } + min = args->selected_count; + }else{ + newindex = (startindex + 1) - args->selected_count; + min = 1; + } + gtk_spin_button_set_range(GTK_SPIN_BUTTON(args->startindex), min, max); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->startindex), newindex); + update(widget, args); +} + +int dialog_autonumber_show(GtkWindow* parent, uint32_t selected_count, GlobalState* gs){ +DialogAutonumberArgs *args = new DialogAutonumberArgs; + int return_val; + args->gs = gs; + args->params = dynv_get_dynv(args->gs->params, "gpick.autonumber"); + args->selected_count = selected_count; + + GtkWidget *table; + + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Autonumber colors"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + gtk_window_set_default_size(GTK_WINDOW(dialog), dynv_get_int32_wd(args->params, "window.width", -1), + dynv_get_int32_wd(args->params, "window.height", -1)); + + gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); + + gint table_y; + table = gtk_table_new(4, 4, FALSE); + table_y=0; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Name:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->name = gtk_entry_new(); + // dynv_get_str_wd? + gtk_entry_set_text (GTK_ENTRY(args->name), dynv_get_string_wd (args->params, "name", "autonum")); + + g_signal_connect (G_OBJECT (args->name), "changed", G_CALLBACK(update), args); + gtk_table_attach(GTK_TABLE(table), args->name,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + + table_y++; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Decimal places:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->nplaces = gtk_spin_button_new_with_range (1, 6, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->nplaces), dynv_get_int32_wd(args->params, "nplaces", default_nplaces (selected_count))); + gtk_table_attach(GTK_TABLE(table), args->nplaces,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect(G_OBJECT (args->nplaces), "value-changed", G_CALLBACK (update), args); + table_y++; + +gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Starting number:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->startindex = gtk_spin_button_new_with_range (1, 0x7fffffff, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->startindex), dynv_get_int32_wd(args->params, "startindex", 1)); + gtk_table_attach(GTK_TABLE(table), args->startindex,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect(G_OBJECT (args->startindex), "value-changed", G_CALLBACK (update), args); + table_y++; + + args->toggle_decreasing = gtk_check_button_new_with_mnemonic (_("_Decreasing")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(args->toggle_decreasing), dynv_get_bool_wd(args->params, "decreasing", false)); + gtk_table_attach(GTK_TABLE(table), args->toggle_decreasing,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect (G_OBJECT(args->toggle_decreasing), "toggled", G_CALLBACK (update_startindex), args); + table_y++; + + args->toggle_append = gtk_check_button_new_with_mnemonic (_("_Append")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(args->toggle_append), dynv_get_bool_wd(args->params, "append", false)); + gtk_table_attach(GTK_TABLE(table), args->toggle_append,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect (G_OBJECT(args->toggle_append), "toggled", G_CALLBACK (update), args); + table_y++; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Sample:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GtkAttachOptions(GTK_FILL | GTK_EXPAND),5,5); + args->sample = gtk_entry_new(); + gtk_entry_set_editable (GTK_ENTRY(args->sample), false); + gtk_widget_set_sensitive(args->sample, false); + + gtk_table_attach(GTK_TABLE(table), args->sample,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + + update(0, args); + + gtk_widget_show_all(table); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); + + return_val = gtk_dialog_run(GTK_DIALOG(dialog)); + + gint width, height; + gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); + dynv_set_int32(args->params, "window.width", width); + dynv_set_int32(args->params, "window.height", height); + + gtk_widget_destroy(dialog); + + dynv_system_release(args->params); + delete args; + return return_val; +} + diff -Nru gpick-0.2.4/source/uiDialogAutonumber.h gpick-0.2.5/source/uiDialogAutonumber.h --- gpick-0.2.4/source/uiDialogAutonumber.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/uiDialogAutonumber.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef UIDIALOGAUTONUMBER_H_ +#define UIDIALOGAUTONUMBER_H_ + +#include +#include +#include "GlobalState.h" + +int dialog_autonumber_show(GtkWindow* parent, uint32_t selected_count, GlobalState* gs); + +#endif /* UIDIALOGAUTONUMBER_H_ */ + diff -Nru gpick-0.2.4/source/uiDialogGenerate.cpp gpick-0.2.5/source/uiDialogGenerate.cpp --- gpick-0.2.4/source/uiDialogGenerate.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiDialogGenerate.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,8 +22,11 @@ #include "MathUtil.h" #include "DynvHelpers.h" #include "GlobalStateStruct.h" +#include "ToolColorNaming.h" #include "ColorRYB.h" #include "Noise.h" +#include "GenerateScheme.h" +#include "Internationalisation.h" #include #include @@ -47,33 +50,34 @@ GlobalState* gs; }DialogGenerateArgs; -typedef struct SchemeType{ - const char *name; - int32_t colors; - int32_t turn_types; - double turn[4]; -}SchemeType; - -const SchemeType scheme_types[]={ - {"Complementary", 1, 1, {180}}, - {"Analogous", 5, 1, {30}}, - {"Triadic", 2, 1, {120}}, - {"Split-Complementary", 2, 2, {150, 60}}, - {"Rectangle (tetradic)", 3, 2, {60, 120}}, - {"Square", 3, 1, {90}}, - {"Neutral", 5, 1, {15}}, - {"Clash", 2, 2, {90, 180}}, - {"Five-Tone", 4, 4, {115, 40, 50, 40}}, - {"Six-Tone", 5, 2, {30, 90}}, -}; - - typedef struct ColorWheelType{ const char *name; void (*hue_to_hsl)(double hue, Color* hsl); void (*rgbhue_to_hue)(double rgbhue, double *hue); }ColorWheelType; +class GenerateColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + int32_t m_ident; + int32_t m_schemetype; + public: + GenerateColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + } + + void assign(struct ColorObject *color_object, Color *color, const int32_t ident, const int32_t schemetype){ + m_ident = ident; + m_schemetype = schemetype; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << _("scheme") << " " << generate_scheme_get_scheme_type(m_schemetype)->name << " #" << m_ident << "[" << color_names_get(m_gs->color_names, color, false) << "]"; + return m_stream.str(); + } +}; + static void rgb_hue2hue(double hue, Color* hsl){ hsl->hsl.hue = hue; hsl->hsl.saturation = 1; @@ -113,12 +117,13 @@ static void calc( DialogGenerateArgs *args, bool preview, int limit){ - int32_t type=gtk_combo_box_get_active(GTK_COMBO_BOX(args->gen_type)); + int32_t type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->gen_type)); int32_t wheel_type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->wheel_type)); int32_t color_count = static_cast(gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_colors))); double chaos = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_chaos)); int32_t chaos_seed = static_cast(gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_chaos_seed))); bool reverse = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_reverse)); + GenerateColorNameAssigner name_assigner(args->gs); if (!preview){ dynv_set_int32(args->params, "type", type); @@ -177,10 +182,11 @@ color_hsl_to_rgb(&hsl, &r); struct ColorObject *color_object=color_list_new_color_object(color_list, &r); + name_assigner.assign (color_object, &r, i, type); color_list_add_color_object(color_list, color_object, 1); color_object_release(color_object); - hue_step = (scheme_types[type].turn[i%scheme_types[type].turn_types]) / (360.0) + hue_step = (generate_scheme_get_scheme_type(type)->turn[i % generate_scheme_get_scheme_type(type)->turn_types]) / (360.0) + chaos*(((random_get(random)&0xFFFFFFFF)/(gdouble)0xFFFFFFFF)-0.5); if (reverse){ @@ -207,7 +213,7 @@ GtkWidget *table; - GtkWidget *dialog = gtk_dialog_new_with_buttons("Generate colors", parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Generate colors"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -221,23 +227,23 @@ table = gtk_table_new(4, 4, FALSE); table_y=0; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Colors:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Colors:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->range_colors = gtk_spin_button_new_with_range (1, 72, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->range_colors), dynv_get_int32_wd(args->params, "colors", 1)); gtk_table_attach(GTK_TABLE(table), args->range_colors,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); g_signal_connect(G_OBJECT (args->range_colors), "value-changed", G_CALLBACK (update), args); table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Type:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Type:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->gen_type = gtk_combo_box_new_text(); - for (uint32_t i=0; igen_type), scheme_types[i].name); + for (uint32_t i = 0; i < generate_scheme_get_n_scheme_types(); i++){ + gtk_combo_box_append_text(GTK_COMBO_BOX(args->gen_type), _(generate_scheme_get_scheme_type(i)->name)); } gtk_combo_box_set_active(GTK_COMBO_BOX(args->gen_type), dynv_get_int32_wd(args->params, "type", 0)); g_signal_connect (G_OBJECT (args->gen_type), "changed", G_CALLBACK(update), args); gtk_table_attach(GTK_TABLE(table), args->gen_type,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Color wheel:",0,0.5,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Color wheel:"),0,0.5,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->wheel_type = gtk_combo_box_new_text(); for (uint32_t i=0; iwheel_type), color_wheel_types[i].name); @@ -248,13 +254,13 @@ table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Chaos:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Chaos:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->range_chaos = gtk_spin_button_new_with_range (0,1,0.001); gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->range_chaos), dynv_get_float_wd(args->params, "chaos", 0)); gtk_table_attach(GTK_TABLE(table), args->range_chaos,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); g_signal_connect (G_OBJECT (args->range_chaos), "value-changed", G_CALLBACK (update), args); - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Seed:",0,0,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Seed:"),0,0,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); args->range_chaos_seed = gtk_spin_button_new_with_range (0, 0xFFFF, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->range_chaos_seed), dynv_get_int32_wd(args->params, "chaos_seed", 0)); gtk_table_attach(GTK_TABLE(table), args->range_chaos_seed,3,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); @@ -262,7 +268,7 @@ table_y++; - args->toggle_reverse = gtk_check_button_new_with_mnemonic ("_Reverse"); + args->toggle_reverse = gtk_check_button_new_with_mnemonic (_("_Reverse")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(args->toggle_reverse), dynv_get_bool_wd(args->params, "reverse", false)); gtk_table_attach(GTK_TABLE(table), args->toggle_reverse,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); g_signal_connect (G_OBJECT(args->toggle_reverse), "toggled", G_CALLBACK (update), args); @@ -272,7 +278,7 @@ GtkWidget* preview_expander; struct ColorList* preview_color_list=NULL; - gtk_table_attach(GTK_TABLE(table), preview_expander=palette_list_preview_new(gs, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 4, table_y, table_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); + gtk_table_attach(GTK_TABLE(table), preview_expander=palette_list_preview_new(gs, true, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 4, table_y, table_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); table_y++; args->selected_color_list = selected_color_list; diff -Nru gpick-0.2.4/source/uiDialogGenerate.h gpick-0.2.5/source/uiDialogGenerate.h --- gpick-0.2.4/source/uiDialogGenerate.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiDialogGenerate.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/uiDialogMix.cpp gpick-0.2.5/source/uiDialogMix.cpp --- gpick-0.2.4/source/uiDialogMix.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiDialogMix.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,14 +22,19 @@ #include "MathUtil.h" #include "DynvHelpers.h" #include "GlobalStateStruct.h" +#include "ToolColorNaming.h" +#include "Internationalisation.h" +#ifndef _MSC_VER #include +#endif #include using namespace std; typedef struct DialogMixArgs{ GtkWidget *mix_type; GtkWidget *mix_steps; + GtkWidget *toggle_endpoints; struct ColorList *selected_color_list; struct ColorList *preview_color_list; @@ -38,14 +43,77 @@ GlobalState* gs; }DialogMixArgs; +class MixColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + const char *m_color_start; + const char *m_color_end; + int m_start_percent; + int m_end_percent; + int m_is_node; + public: + MixColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){ + } + + void assign(struct ColorObject *color_object, Color *color, const char *start_color_name, const char *end_color_name, int start_percent, int end_percent, bool is_node){ + m_color_start = start_color_name; + m_color_end = end_color_name; + m_start_percent = start_percent; + m_end_percent = end_percent; + m_is_node = is_node; + ToolColorNameAssigner::assign(color_object, color); + } + + void assign(struct ColorObject *color_object, Color *color, const char *item_name){ + m_color_start = item_name; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + if (m_is_node){ + if (m_end_percent == 100){ + m_stream << m_color_end << " " << _("mix node"); + }else{ + m_stream << m_color_start << " " << _("mix node"); + } + }else{ + m_stream << m_color_start << " " << m_start_percent << " " << _("mix") << " " << m_end_percent << " " << m_color_end; + } + return m_stream.str(); + } +}; + + +#define STORE_COLOR() struct ColorObject *color_object=color_list_new_color_object(color_list, &r); \ + float mixfactor = step_i/(float)(steps-1); \ + name_assigner.assign(color_object, &r, name_a, name_b, (int)((1.0 - mixfactor)*100), (int)(mixfactor*100), with_endpoints && (step_i == 0 || step_i == (max_step - 1))); \ + color_list_add_color_object(color_list, color_object, 1); \ + color_object_release(color_object) + +#define STORE_LINEARCOLOR() color_linear_get_rgb(&r, &r); \ + STORE_COLOR() + + + static void calc( DialogMixArgs *args, bool preview, int limit){ gint steps=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(args->mix_steps)); gint type=gtk_combo_box_get_active(GTK_COMBO_BOX(args->mix_type)); + bool with_endpoints=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_endpoints)); + gint start_step = 0; + gint max_step = steps; + MixColorNameAssigner name_assigner(args->gs); if (!preview){ dynv_set_int32(args->params, "type", type); dynv_set_int32(args->params, "steps", steps); + dynv_set_bool(args->params, "includeendpoints", with_endpoints); + } + + if (with_endpoints == false){ + start_step = 1; + max_step = steps - 1; } Color r; @@ -56,13 +124,6 @@ s.setf(ios::fixed,ios::floatfield); Color a,b; - matrix3x3 adaptation_matrix, working_space_matrix, working_space_matrix_inverted; - vector3 d50, d65; - vector3_set(&d50, 96.442, 100.000, 82.821); - vector3_set(&d65, 95.047, 100.000, 108.883); - color_get_chromatic_adaptation_matrix(&d50, &d65, &adaptation_matrix); - color_get_working_space_matrix(0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, &d65, &working_space_matrix); - matrix3x3_inverse(&working_space_matrix, &working_space_matrix_inverted); struct ColorList *color_list; if (preview) @@ -74,6 +135,9 @@ for (ColorList::iter i=args->selected_color_list->colors.begin(); i!=args->selected_color_list->colors.end(); ++i){ color_object_get_color(*i, &a); + if (type == 0) + color_rgb_get_linear(&a, &a); + const char* name_a = dynv_get_string_wd((*i)->params, "name", 0); j=i; ++j; @@ -85,22 +149,15 @@ } color_object_get_color(*j, &b); + if (type == 0) + color_rgb_get_linear(&b, &b); const char* name_b = dynv_get_string_wd((*j)->params, "name", 0); switch (type) { case 0: - for (step_i = 0; step_i < steps; ++step_i) { - r.rgb.red = mix_float(a.rgb.red, b.rgb.red, step_i/(float)(steps-1)); - r.rgb.green = mix_float(a.rgb.green, b.rgb.green, step_i/(float)(steps-1)); - r.rgb.blue = mix_float(a.rgb.blue, b.rgb.blue, step_i/(float)(steps-1)); - - s.str(""); - s<params, "name", s.str().c_str()); - color_list_add_color_object(color_list, color_object, 1); - color_object_release(color_object); + for (step_i = start_step; step_i < max_step; ++step_i) { + MIX_COMPONENTS(r.rgb, a.rgb, b.rgb, red, green, blue); + STORE_LINEARCOLOR(); } break; @@ -110,19 +167,10 @@ color_rgb_to_hsv(&a, &a_hsv); color_rgb_to_hsv(&b, &b_hsv); - for (step_i = 0; step_i < steps; ++step_i) { - r_hsv.hsv.hue = mix_float(a_hsv.hsv.hue, b_hsv.hsv.hue, step_i/(float)(steps-1)); - r_hsv.hsv.saturation = mix_float(a_hsv.hsv.saturation, b_hsv.hsv.saturation, step_i/(float)(steps-1)); - r_hsv.hsv.value = mix_float(a_hsv.hsv.value, b_hsv.hsv.value, step_i/(float)(steps-1)); - + for (step_i = start_step; step_i < max_step; ++step_i) { + MIX_COMPONENTS(r_hsv.hsv, a_hsv.hsv, b_hsv.hsv, hue, saturation, value); color_hsv_to_rgb(&r_hsv, &r); - - s.str(""); - s<params, "name", s.str().c_str()); - color_list_add_color_object(color_list, color_object, 1); + STORE_COLOR(); } } break; @@ -140,20 +188,13 @@ if (b_hsv.hsv.hue-a_hsv.hsv.hue>0.5) b_hsv.hsv.hue-=1; } - for (step_i = 0; step_i < steps; ++step_i) { - r_hsv.hsv.hue = mix_float(a_hsv.hsv.hue, b_hsv.hsv.hue, step_i/(float)(steps-1)); - r_hsv.hsv.saturation = mix_float(a_hsv.hsv.saturation, b_hsv.hsv.saturation, step_i/(float)(steps-1)); - r_hsv.hsv.value = mix_float(a_hsv.hsv.value, b_hsv.hsv.value, step_i/(float)(steps-1)); + for (step_i = start_step; step_i < max_step; ++step_i) { + MIX_COMPONENTS(r_hsv.hsv, a_hsv.hsv, b_hsv.hsv, hue, saturation, value); if (r_hsv.hsv.hue<0) r_hsv.hsv.hue+=1; - color_hsv_to_rgb(&r_hsv, &r); - - s.str(""); - s<params, "name", s.str().c_str()); - color_list_add_color_object(color_list, color_object, 1); + color_hsv_to_rgb(&r_hsv, &r); + STORE_COLOR(); } } break; @@ -161,23 +202,15 @@ case 3: { Color a_lab, b_lab, r_lab; - color_rgb_to_lab(&a, &a_lab, &d50, &working_space_matrix); - color_rgb_to_lab(&b, &b_lab, &d50, &working_space_matrix); + color_rgb_to_lab_d50(&a, &a_lab); + color_rgb_to_lab_d50(&b, &b_lab); - for (step_i = 0; step_i < steps; ++step_i) { - r_lab.lab.L = mix_float(a_lab.lab.L, b_lab.lab.L, step_i/(float)(steps-1)); - r_lab.lab.a = mix_float(a_lab.lab.a, b_lab.lab.a, step_i/(float)(steps-1)); - r_lab.lab.b = mix_float(a_lab.lab.b, b_lab.lab.b, step_i/(float)(steps-1)); + for (step_i = start_step; step_i < max_step; ++step_i) { + MIX_COMPONENTS(r_lab.lab, a_lab.lab, b_lab.lab, L, a, b); - color_lab_to_rgb(&r_lab, &r, &d50, &working_space_matrix_inverted); + color_lab_to_rgb_d50(&r_lab, &r); color_rgb_normalize(&r); - - s.str(""); - s<params, "name", s.str().c_str()); - color_list_add_color_object(color_list, color_object, 1); + STORE_COLOR(); } } break; @@ -199,7 +232,7 @@ GtkWidget *table; GtkWidget *mix_type, *mix_steps; - GtkWidget *dialog = gtk_dialog_new_with_buttons("Mix colors", parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Mix colors"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -213,12 +246,12 @@ table = gtk_table_new(3, 2, FALSE); table_y=0; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Type:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Type:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); mix_type = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), "RGB"); - gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), "HSV"); - gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), "HSV shortest hue distance"); - gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), "LAB"); + gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), _("RGB")); + gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), _("HSV")); + gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), _("HSV shortest hue distance")); + gtk_combo_box_append_text(GTK_COMBO_BOX(mix_type), _("LAB")); gtk_combo_box_set_active(GTK_COMBO_BOX(mix_type), dynv_get_int32_wd(args->params, "type", 0)); gtk_table_attach(GTK_TABLE(table), mix_type,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); table_y++; @@ -226,7 +259,7 @@ g_signal_connect (G_OBJECT (mix_type), "changed", G_CALLBACK (update), args); - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Steps:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Steps:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); mix_steps = gtk_spin_button_new_with_range (3,255,1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(mix_steps), dynv_get_int32_wd(args->params, "steps", 3)); gtk_table_attach(GTK_TABLE(table), mix_steps,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); @@ -234,9 +267,15 @@ args->mix_steps = mix_steps; g_signal_connect (G_OBJECT (mix_steps), "value-changed", G_CALLBACK (update), args); + args->toggle_endpoints = gtk_check_button_new_with_mnemonic (_("_Include Endpoints")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(args->toggle_endpoints), dynv_get_bool_wd(args->params, "includeendpoints", true)); + gtk_table_attach(GTK_TABLE(table), args->toggle_endpoints,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect (G_OBJECT(args->toggle_endpoints), "toggled", G_CALLBACK (update), args); + table_y++; + GtkWidget* preview_expander; struct ColorList* preview_color_list=NULL; - gtk_table_attach(GTK_TABLE(table), preview_expander=palette_list_preview_new(gs, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 2, table_y, table_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); + gtk_table_attach(GTK_TABLE(table), preview_expander=palette_list_preview_new(gs, true, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 2, table_y, table_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); table_y++; diff -Nru gpick-0.2.4/source/uiDialogMix.h gpick-0.2.5/source/uiDialogMix.h --- gpick-0.2.4/source/uiDialogMix.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiDialogMix.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/uiDialogOptions.cpp gpick-0.2.5/source/uiDialogOptions.cpp --- gpick-0.2.4/source/uiDialogOptions.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiDialogOptions.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -18,16 +18,36 @@ #include "uiDialogOptions.h" #include "uiUtilities.h" +#include "ToolColorNaming.h" #include "GlobalStateStruct.h" +#include "Internationalisation.h" #include "DynvHelpers.h" +#include + +using namespace std; + +static const struct{ + const char *label; + const char *setting; +}available_color_spaces[] = { + {"CMYK", "picker.color_space.cmyk"}, + {"HSL", "picker.color_space.hsl"}, + {"HSV", "picker.color_space.hsv"}, + {"LAB", "picker.color_space.lab"}, + {"LCH", "picker.color_space.lch"}, + {"RGB", "picker.color_space.rgb"}, + {0, 0}, +}; + typedef struct DialogOptionsArgs{ GtkWidget *minimize_to_tray; GtkWidget *close_to_tray; GtkWidget *start_in_tray; GtkWidget *refresh_rate; GtkWidget *single_instance; + GtkWidget *save_restore_palette; GtkWidget *add_on_release; GtkWidget *add_to_palette; GtkWidget *copy_to_clipboard; @@ -35,6 +55,12 @@ GtkWidget *copy_on_release; GtkWidget *zoom_size; GtkWidget *imprecision_postfix; + GtkWidget *tool_color_naming[3]; + GtkWidget *color_spaces[6]; + GtkWidget *out_of_gamut_mask; + + GtkWidget *lab_illuminant; + GtkWidget *lab_observer; struct dynvSystem *params; GlobalState* gs; @@ -47,6 +73,7 @@ dynv_set_bool(args->params, "main.close_to_tray", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->close_to_tray))); dynv_set_bool(args->params, "main.start_in_tray", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->start_in_tray))); dynv_set_bool(args->params, "main.single_instance", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->single_instance))); + dynv_set_bool(args->params, "main.save_restore_palette", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->save_restore_palette))); dynv_set_float(args->params, "picker.refresh_rate", gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->refresh_rate))); dynv_set_int32(args->params, "picker.zoom_size", gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->zoom_size))); @@ -55,8 +82,25 @@ dynv_set_bool(args->params, "picker.sampler.add_to_palette", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->add_to_palette))); dynv_set_bool(args->params, "picker.sampler.copy_to_clipboard", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->copy_to_clipboard))); dynv_set_bool(args->params, "picker.sampler.rotate_swatch_after_sample", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->rotate_swatch))); + dynv_set_bool(args->params, "picker.out_of_gamut_mask", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->out_of_gamut_mask))); dynv_set_bool(args->params, "color_names.imprecision_postfix", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->imprecision_postfix))); + const ToolColorNamingOption *color_naming_options = tool_color_naming_get_options(); + int i = 0; + while (color_naming_options[i].name){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->tool_color_naming[i]))){ + dynv_set_string(args->params, "color_names.tool_color_naming", color_naming_options[i].name); + break; + } + i++; + } + + for (int i = 0; available_color_spaces[i].label; i++){ + dynv_set_bool(args->params, available_color_spaces[i].setting, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->color_spaces[i]))); + } + + dynv_set_string(args->params, "picker.lab.illuminant", gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(args->lab_illuminant))); + dynv_set_string(args->params, "picker.lab.observer", gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(args->lab_observer))); } @@ -70,7 +114,7 @@ GtkWidget *table, *table_m, *widget; - GtkWidget *dialog = gtk_dialog_new_with_buttons("Options", parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Options"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -87,7 +131,7 @@ table_m = gtk_table_new(3, 1, FALSE); table_m_y = 0; - frame = gtk_frame_new("System"); + frame = gtk_frame_new(_("System")); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); table_m_y++; @@ -96,13 +140,18 @@ table_y=0; gtk_container_add(GTK_CONTAINER(frame), table); - args->single_instance = widget = gtk_check_button_new_with_mnemonic ("_Single instance"); + args->single_instance = widget = gtk_check_button_new_with_mnemonic (_("_Single instance")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "main.single_instance", false)); gtk_table_attach(GTK_TABLE(table), widget,0,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; + args->save_restore_palette = widget = gtk_check_button_new_with_mnemonic (_("Save/_Restore palette")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "main.save_restore_palette", true)); + gtk_table_attach(GTK_TABLE(table), widget,0,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); + table_y++; + - frame = gtk_frame_new("System tray"); + frame = gtk_frame_new(_("System tray")); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); table_m_y++; @@ -110,29 +159,29 @@ table_y=0; gtk_container_add(GTK_CONTAINER(frame), table); - args->minimize_to_tray = widget = gtk_check_button_new_with_mnemonic ("_Minimize to system tray"); + args->minimize_to_tray = widget = gtk_check_button_new_with_mnemonic (_("_Minimize to system tray")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "main.minimize_to_tray", false)); gtk_table_attach(GTK_TABLE(table), widget,0,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; - args->close_to_tray = widget = gtk_check_button_new_with_mnemonic ("_Close to system tray"); + args->close_to_tray = widget = gtk_check_button_new_with_mnemonic (_("_Close to system tray")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "main.close_to_tray", false)); gtk_table_attach(GTK_TABLE(table), widget,0,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; - args->start_in_tray = widget = gtk_check_button_new_with_mnemonic ("_Start in system tray"); + args->start_in_tray = widget = gtk_check_button_new_with_mnemonic (_("_Start in system tray")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "main.start_in_tray", false)); gtk_table_attach(GTK_TABLE(table), widget,0,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table_m, gtk_label_new_with_mnemonic("_Main")); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table_m, gtk_label_new_with_mnemonic(_("_Main"))); - table_m = gtk_table_new(3, 1, FALSE); + table_m = gtk_table_new(3, 2, FALSE); table_m_y = 0; - frame = gtk_frame_new("Display"); + frame = gtk_frame_new(_("Display")); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); table_m_y++; @@ -141,7 +190,7 @@ table_y=0; gtk_container_add(GTK_CONTAINER(frame), table); - gtk_table_attach(GTK_TABLE(table), gtk_label_mnemonic_aligned_new("_Refresh rate:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); + gtk_table_attach(GTK_TABLE(table), gtk_label_mnemonic_aligned_new(_("_Refresh rate:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); args->refresh_rate = widget = gtk_spin_button_new_with_range(1, 60, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->refresh_rate), dynv_get_float_wd(args->params, "picker.refresh_rate", 30)); gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,5); @@ -149,13 +198,13 @@ table_y++; - gtk_table_attach(GTK_TABLE(table), gtk_label_mnemonic_aligned_new("_Magnified area size:",0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); + gtk_table_attach(GTK_TABLE(table), gtk_label_mnemonic_aligned_new(_("_Magnified area size:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); args->zoom_size = widget = gtk_spin_button_new_with_range(75, 300, 15); gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->zoom_size), dynv_get_int32_wd(args->params, "picker.zoom_size", 150)); gtk_table_attach(GTK_TABLE(table), widget,1,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,5); table_y++; - frame = gtk_frame_new("Floating picker click behaviour"); + frame = gtk_frame_new(_("Floating picker click behaviour")); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); table_m_y++; @@ -163,18 +212,18 @@ table_y=0; gtk_container_add(GTK_CONTAINER(frame), table); - args->add_on_release = widget = gtk_check_button_new_with_mnemonic("_Add to palette"); + args->add_on_release = widget = gtk_check_button_new_with_mnemonic(_("_Add to palette")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "picker.sampler.add_on_release", false)); gtk_table_attach(GTK_TABLE(table), widget,0,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; - args->copy_on_release = widget = gtk_check_button_new_with_mnemonic("_Copy to clipboard"); + args->copy_on_release = widget = gtk_check_button_new_with_mnemonic(_("_Copy to clipboard")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "picker.sampler.copy_on_release", false)); gtk_table_attach(GTK_TABLE(table), widget,0,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; - frame = gtk_frame_new("'Spacebar' button behaviour"); + frame = gtk_frame_new(_("'Spacebar' button behaviour")); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); table_m_y++; @@ -182,29 +231,114 @@ table_y=0; gtk_container_add(GTK_CONTAINER(frame), table); - args->add_to_palette = widget = gtk_check_button_new_with_mnemonic("_Add to palette"); + args->add_to_palette = widget = gtk_check_button_new_with_mnemonic(_("_Add to palette")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "picker.sampler.add_to_palette", false)); gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; - args->copy_to_clipboard = widget = gtk_check_button_new_with_mnemonic("_Copy to clipboard"); + args->copy_to_clipboard = widget = gtk_check_button_new_with_mnemonic(_("_Copy to clipboard")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "picker.sampler.copy_to_clipboard", false)); gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; - args->rotate_swatch = widget = gtk_check_button_new_with_mnemonic("_Rotate swatch"); + args->rotate_swatch = widget = gtk_check_button_new_with_mnemonic(_("_Rotate swatch")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "picker.sampler.rotate_swatch_after_sample", false)); gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; + table_m_y = 0; + + frame = gtk_frame_new(_("Enabled color spaces")); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); + gtk_table_attach(GTK_TABLE(table_m), frame, 1, 2, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); + table_m_y++; + table = gtk_table_new(5, 3, FALSE); + table_y=0; + gtk_container_add(GTK_CONTAINER(frame), table); + + for (int i = 0; available_color_spaces[i].label; i++){ + args->color_spaces[i] = widget = gtk_check_button_new_with_label(available_color_spaces[i].label); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, available_color_spaces[i].setting, true)); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 3, 3); + table_y++; + } - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table_m, gtk_label_new_with_mnemonic("_Picker")); + frame = gtk_frame_new(_("Lab settings")); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); + gtk_table_attach(GTK_TABLE(table_m), frame, 1, 2, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); + table_m_y++; + table = gtk_table_new(5, 3, FALSE); + table_y=0; + gtk_container_add(GTK_CONTAINER(frame), table); + { + int selected; + const char *option; + + gtk_table_attach(GTK_TABLE(table), gtk_label_mnemonic_aligned_new(_("_Illuminant:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); + args->lab_illuminant = widget = gtk_combo_box_text_new(); + const char *illuminants[] = { + "A", + "C", + "D50", + "D55", + "D65", + "D75", + "F2", + "F7", + "F11", + 0, + }; + selected = 0; + option = dynv_get_string_wd(args->params, "picker.lab.illuminant", "D50"); + for (int i = 0; illuminants[i]; i++){ + if (string(illuminants[i]).compare(option) == 0) selected = i; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), illuminants[i]); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), selected); + gtk_table_attach(GTK_TABLE(table), widget,1,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,5); + table_y++; + + gtk_table_attach(GTK_TABLE(table), gtk_label_mnemonic_aligned_new(_("_Observer:"),0,0.5,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); + args->lab_observer = widget = gtk_combo_box_text_new(); + const char *observers[] = { + "2", + "10", + 0, + }; + selected = 0; + option = dynv_get_string_wd(args->params, "picker.lab.observer", "2"); + for (int i = 0; observers[i]; i++){ + if (string(observers[i]).compare(option) == 0) selected = i; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), observers[i]); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), selected); + gtk_table_attach(GTK_TABLE(table), widget,1,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,5); + table_y++; + + } + + frame = gtk_frame_new(_("Other settings")); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); + gtk_table_attach(GTK_TABLE(table_m), frame, 1, 2, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); + table_m_y++; + table = gtk_table_new(5, 3, FALSE); + table_y=0; + gtk_container_add(GTK_CONTAINER(frame), table); + + + args->out_of_gamut_mask = widget = gtk_check_button_new_with_mnemonic(_("_Mask out of gamut colors")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "picker.out_of_gamut_mask", true)); + gtk_table_attach(GTK_TABLE(table), widget, 1, 2, table_y, table_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 3, 3); + table_y++; + + + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table_m, gtk_label_new_with_mnemonic(_("_Picker"))); table_m = gtk_table_new(3, 1, FALSE); table_m_y = 0; - frame = gtk_frame_new("Color name generation"); + frame = gtk_frame_new(_("Color name generation")); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); table_m_y++; @@ -213,12 +347,38 @@ table_y=0; gtk_container_add(GTK_CONTAINER(frame), table); - args->imprecision_postfix = widget = gtk_check_button_new_with_mnemonic("_Imprecision postix"); + args->imprecision_postfix = widget = gtk_check_button_new_with_mnemonic(_("_Imprecision postfix")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->params, "color_names.imprecision_postfix", true)); gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); table_y++; - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table_m, gtk_label_new_with_mnemonic("_Color names")); + + frame = gtk_frame_new(_("Tool color naming")); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); + gtk_table_attach(GTK_TABLE(table_m), frame, 0, 1, table_m_y, table_m_y+1, GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL), 5, 5); + table_m_y++; + + table = gtk_table_new(5, 3, FALSE); + table_y=0; + gtk_container_add(GTK_CONTAINER(frame), table); + + GSList *group = NULL; + ToolColorNamingType color_naming_type = tool_color_naming_name_to_type(dynv_get_string_wd(args->params, "color_names.tool_color_naming", "tool_specific")); + const ToolColorNamingOption *color_naming_options = tool_color_naming_get_options(); + int i = 0; + while (color_naming_options[i].name){ + args->tool_color_naming[i] = widget = gtk_radio_button_new_with_mnemonic(group, _(color_naming_options[i].label)); + group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(widget)); + + if (color_naming_type == color_naming_options[i].type) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), true); + + gtk_table_attach(GTK_TABLE(table), widget,1,2,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,3,3); + table_y++; + i++; + } + + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table_m, gtk_label_new_with_mnemonic(_("_Color names"))); gtk_widget_show_all(notebook); diff -Nru gpick-0.2.4/source/uiDialogOptions.h gpick-0.2.5/source/uiDialogOptions.h --- gpick-0.2.4/source/uiDialogOptions.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiDialogOptions.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/uiDialogSort.cpp gpick-0.2.5/source/uiDialogSort.cpp --- gpick-0.2.4/source/uiDialogSort.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/uiDialogSort.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,645 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "uiDialogSort.h" +#include "uiListPalette.h" +#include "uiUtilities.h" +#include "MathUtil.h" +#include "DynvHelpers.h" +#include "GlobalStateStruct.h" +#include "ColorRYB.h" +#include "Noise.h" +#include "GenerateScheme.h" +#include "Internationalisation.h" + +#include +#include +#include +#include +#include +using namespace std; + +typedef struct DialogSortArgs{ + GtkWidget *group_type; + GtkWidget *group_sensitivity; + GtkWidget *max_groups; + GtkWidget *sort_type; + GtkWidget *toggle_reverse; + GtkWidget *toggle_reverse_groups; + + struct ColorList *sorted_color_list; + struct ColorList *selected_color_list; + struct ColorList *preview_color_list; + + struct dynvSystem *params; + GlobalState* gs; +}DialogSortArgs; + +typedef struct SortType{ + const char *name; + double (*get_value)(Color *color); +}SortType; + +typedef struct GroupType{ + const char *name; + double (*get_group)(Color *color); +}GroupType; + +static double sort_rgb_red(Color *color) +{ + return color->rgb.red; +} +static double sort_rgb_green(Color *color) +{ + return color->rgb.green; +} +static double sort_rgb_blue(Color *color) +{ + return color->rgb.blue; +} +static double sort_rgb_grayscale(Color *color) +{ + return (color->rgb.red + color->rgb.green + color->rgb.blue) / 3.0; +} +static double sort_hsl_hue(Color *color) +{ + Color hsl; + color_rgb_to_hsl(color, &hsl); + return hsl.hsl.hue; +} +static double sort_hsl_saturation(Color *color) +{ + Color hsl; + color_rgb_to_hsl(color, &hsl); + return hsl.hsl.saturation; +} +static double sort_hsl_lightness(Color *color) +{ + Color hsl; + color_rgb_to_hsl(color, &hsl); + return hsl.hsl.lightness; +} +static double sort_lab_lightness(Color *color) +{ + Color lab; + color_rgb_to_lab_d50(color, &lab); + return lab.lab.L; +} +static double sort_lab_a(Color *color) +{ + Color lab; + color_rgb_to_lab_d50(color, &lab); + return lab.lab.a; +} +static double sort_lab_b(Color *color) +{ + Color lab; + color_rgb_to_lab_d50(color, &lab); + return lab.lab.b; +} +static double sort_lch_lightness(Color *color) +{ + Color lch; + color_rgb_to_lch_d50(color, &lch); + return lch.lch.L; +} +static double sort_lch_chroma(Color *color) +{ + Color lch; + color_rgb_to_lch_d50(color, &lch); + return lch.lch.C; +} +static double sort_lch_hue(Color *color) +{ + Color lch; + color_rgb_to_lch_d50(color, &lch); + return lch.lch.h; +} + +const SortType sort_types[] = { + {N_("RGB Red"), sort_rgb_red}, + {N_("RGB Green"), sort_rgb_green}, + {N_("RGB Blue"), sort_rgb_blue}, + {N_("RGB Grayscale"), sort_rgb_grayscale}, + {N_("HSL Hue"), sort_hsl_hue}, + {N_("HSL Saturation"), sort_hsl_saturation}, + {N_("HSL Lightness"), sort_hsl_lightness}, + {N_("Lab Lightness"), sort_lab_lightness}, + {N_("Lab A"), sort_lab_a}, + {N_("Lab B"), sort_lab_b}, + {N_("LCh Lightness"), sort_lch_lightness}, + {N_("LCh Chroma"), sort_lch_chroma}, + {N_("LCh Hue"), sort_lch_hue}, +}; + +static double group_rgb_red(Color *color) +{ + return color->rgb.red; +} +static double group_rgb_green(Color *color) +{ + return color->rgb.green; +} +static double group_rgb_blue(Color *color) +{ + return color->rgb.blue; +} +static double group_rgb_grayscale(Color *color) +{ + return (color->rgb.red + color->rgb.green + color->rgb.blue) / 3.0; +} +static double group_hsl_hue(Color *color) +{ + Color hsl; + color_rgb_to_hsl(color, &hsl); + return hsl.hsl.hue; +} +static double group_hsl_saturation(Color *color) +{ + Color hsl; + color_rgb_to_hsl(color, &hsl); + return hsl.hsl.saturation; +} +static double group_hsl_lightness(Color *color) +{ + Color hsl; + color_rgb_to_hsl(color, &hsl); + return hsl.hsl.lightness; +} +static double group_lab_lightness(Color *color) +{ + Color lab; + color_rgb_to_lab_d50(color, &lab); + return lab.lab.L / 100.0; +} +static double group_lab_a(Color *color) +{ + Color lab; + color_rgb_to_lab_d50(color, &lab); + return (lab.lab.a + 145) / 290.0; +} +static double group_lab_b(Color *color) +{ + Color lab; + color_rgb_to_lab_d50(color, &lab); + return (lab.lab.b + 145) / 290.0; +} +static double group_lch_lightness(Color *color) +{ + Color lch; + color_rgb_to_lch_d50(color, &lch); + return lch.lch.L / 100.0; +} +static double group_lch_chroma(Color *color) +{ + Color lch; + color_rgb_to_lch_d50(color, &lch); + return lch.lch.C / 136.0; +} +static double group_lch_hue(Color *color) +{ + Color lch; + color_rgb_to_lch_d50(color, &lch); + return lch.lch.h / 360.0; +} + +const GroupType group_types[] = { + {N_("None"), NULL}, + {N_("RGB Red"), group_rgb_red}, + {N_("RGB Green"), group_rgb_green}, + {N_("RGB Blue"), group_rgb_blue}, + {N_("RGB Grayscale"), group_rgb_grayscale}, + {N_("HSL Hue"), group_hsl_hue}, + {N_("HSL Saturation"), group_hsl_saturation}, + {N_("HSL Lightness"), group_hsl_lightness}, + {N_("Lab Lightness"), group_lab_lightness}, + {N_("Lab A"), group_lab_a}, + {N_("Lab B"), group_lab_b}, + {N_("LCh Lightness"), group_lch_lightness}, + {N_("LCh Chroma"), group_lch_chroma}, + {N_("LCh Hue"), group_lch_hue}, +}; + + + +typedef struct Node{ + uint32_t n_values; + uint32_t n_values_in; + double value_sum; + double distance; + + Node *child[2]; + Node *parent; +}Node; + +typedef struct Range{ + double x; + double w; +}Range; + +static Node* node_new(Node *parent){ + Node *n = new Node; + n->value_sum = 0; + n->distance = 0; + n->n_values = 0; + n->n_values_in = 0; + n->parent = parent; + for (int i = 0; i < 2; i++){ + n->child[i] = 0; + } + return n; +} + +static void node_delete(Node *node){ + for (int i = 0; i < 2; i++){ + if (node->child[i]){ + node_delete(node->child[i]); + } + } + delete node; +} + +static Node* node_copy(Node *node, Node *parent){ + Node *n = node_new(0); + memcpy(n, node, sizeof(Node)); + n->parent = parent; + + for (int i = 0; i < 2; i++){ + if (node->child[i]){ + n->child[i] = node_copy(node->child[i], n); + }else{ + n->child[i] = 0; + } + } + return n; +} + +static uint32_t node_count_leafs(Node *node){ + uint32_t r = 0; + if (node->n_values_in) r++; + for (int i = 0; i < 2; i++){ + if (node->child[i]) + r += node_count_leafs(node->child[i]); + } + return r; +} + +static void node_leaf_callback(Node *node, void (*leaf_cb)(Node* node, void* userdata), void* userdata){ + if (node->n_values_in > 0) leaf_cb(node, userdata); + + for (int i = 0; i < 2; i++){ + if (node->child[i]) + node_leaf_callback(node->child[i], leaf_cb, userdata); + } +} + +static void node_prune(Node *node){ + for (int i = 0; i < 2; i++){ + if (node->child[i]){ + node_prune(node->child[i]); + node->child[i] = 0; + } + } + if (node->parent){ + node->parent->n_values_in += node->n_values_in; + node->parent->value_sum += node->value_sum; + } + node_delete(node); +} + +typedef struct PruneData{ + double threshold; + double min_distance; + uint32_t n_values; + uint32_t n_values_target; + + Node *prune_node; + uint32_t distant_nodes; +}PruneData; + +static bool node_prune_threshold(Node *node, PruneData *prune_data, bool leave_node){ + if (node->distance <= prune_data->threshold){ + uint32_t values_removed; + if (leave_node){ + values_removed = 0; + for (int i = 0; i < 2; i++){ + if (node->child[i]){ + values_removed += node_count_leafs(node->child[i]); + node_prune(node->child[i]); + node->child[i] = 0; + } + } + }else{ + values_removed = node_count_leafs(node); + node_prune(node); + } + prune_data->n_values -= values_removed; + return true; + } + if (node->distance < prune_data->min_distance){ + prune_data->min_distance = node->distance; + } + uint32_t n = node->n_values_in; + for (int i = 0; i < 2; i++){ + if (node->child[i]){ + if (node_prune_threshold(node->child[i], prune_data, false)){ + node->child[i] = 0; + } + } + } + if (node->n_values_in > 0 && n == 0) prune_data->n_values++; + return false; +} + +static void node_reduce(Node *node, double threshold, uintptr_t max_values){ + PruneData prune_data; + prune_data.n_values = node_count_leafs(node); + prune_data.n_values_target = max_values; + prune_data.threshold = threshold; + + prune_data.min_distance = node->distance; + node_prune_threshold(node, &prune_data, true); + prune_data.threshold = prune_data.min_distance; + + while (prune_data.n_values > max_values){ + prune_data.min_distance = node->distance; + if (node_prune_threshold(node, &prune_data, true)) break; + prune_data.threshold = prune_data.min_distance; + } +} + +static Node* node_find(Node *node, Range *range, double value) +{ + Range new_range; + new_range.w = range->w / 2; + int x; + if (value - range->x < new_range.w) + x = 0; + else + x = 1; + new_range.x = range->x + new_range.w * x; + if (node->child[x]){ + return node_find(node->child[x], &new_range, value); + }else return node; +} + +static void node_update(Node *node, Range *range, double value, uint32_t max_depth){ + Range new_range; + new_range.w = range->w / 2; + node->n_values++; + node->distance += (value - (range->x + new_range.w)) * (value - (range->x + new_range.w)); + + if (!max_depth){ + node->n_values_in++; + node->value_sum += value; + }else{ + int x; + if (value - range->x < new_range.w) + x = 0; + else + x = 1; + + new_range.x = range->x + new_range.w * x; + if (!node->child[x]) + node->child[x] = node_new(node); + + node->n_values++; + node_update(node->child[x], &new_range, value, max_depth - 1); + } +} + + +static void calc(DialogSortArgs *args, bool preview, int limit){ + int32_t group_type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->group_type)); + double group_sensitivity = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->group_sensitivity)); + int max_groups = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->max_groups)); + int32_t sort_type = gtk_combo_box_get_active(GTK_COMBO_BOX(args->sort_type)); + bool reverse = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_reverse)); + bool reverse_groups = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_reverse_groups)); + + if (!preview){ + dynv_set_int32(args->params, "group_type", group_type); + dynv_set_float(args->params, "group_sensitivity", group_sensitivity); + dynv_set_int32(args->params, "max_groups", max_groups); + dynv_set_int32(args->params, "sort_type", sort_type); + dynv_set_bool(args->params, "reverse", reverse); + dynv_set_bool(args->params, "reverse_groups", reverse_groups); + } + + struct ColorList *color_list; + if (preview) + color_list = args->preview_color_list; + else + color_list = args->sorted_color_list; + + typedef std::multimap SortedColors; + typedef std::map GroupedSortedColors; + GroupedSortedColors grouped_sorted_colors; + + typedef std::multimap SortedGroups; + SortedGroups sorted_groups; + + const GroupType *group = &group_types[group_type]; + const SortType *sort = &sort_types[sort_type]; + + Color in; + Node *group_nodes = node_new(0); + Range range; + range.x = 0; + range.w = 1; + int tmp_limit = limit; + if (group->get_group){ + for (ColorList::iter i = args->selected_color_list->colors.begin(); i != args->selected_color_list->colors.end(); ++i){ + color_object_get_color(*i, &in); + node_update(group_nodes, &range, group->get_group(&in), 8); + + if (preview){ + if (tmp_limit <= 0) + break; + tmp_limit--; + } + } + } + + node_reduce(group_nodes, group_sensitivity / 100.0, max_groups); + + tmp_limit = limit; + for (ColorList::iter i = args->selected_color_list->colors.begin(); i != args->selected_color_list->colors.end(); ++i){ + color_object_get_color(*i, &in); + + uintptr_t node_ptr = 0; + if (group->get_group){ + node_ptr = reinterpret_cast(node_find(group_nodes, &range, group->get_group(&in))); + } + grouped_sorted_colors[node_ptr].insert(std::pair(sort->get_value(&in), *i)); + + if (preview){ + if (tmp_limit <= 0) + break; + tmp_limit--; + } + } + + node_delete(group_nodes); + + for (GroupedSortedColors::iterator i = grouped_sorted_colors.begin(); i != grouped_sorted_colors.end(); ++i){ + color_object_get_color((*(*i).second.begin()).second, &in); + sorted_groups.insert(std::pair(sort->get_value(&in), (*i).first)); + } + + if (reverse_groups){ + for (SortedGroups::reverse_iterator i = sorted_groups.rbegin(); i != sorted_groups.rend(); ++i){ + GroupedSortedColors::iterator a, b; + a = grouped_sorted_colors.lower_bound((*i).second); + b = grouped_sorted_colors.upper_bound((*i).second); + for (GroupedSortedColors::iterator j = a; j != b; ++j){ + if (reverse){ + for (SortedColors::reverse_iterator k = (*j).second.rbegin(); k != (*j).second.rend(); ++k){ + color_list_add_color_object(color_list, (*k).second, true); + } + }else{ + for (SortedColors::iterator k = (*j).second.begin(); k != (*j).second.end(); ++k){ + color_list_add_color_object(color_list, (*k).second, true); + } + } + } + } + }else{ + for (SortedGroups::iterator i = sorted_groups.begin(); i != sorted_groups.end(); ++i){ + GroupedSortedColors::iterator a, b; + a = grouped_sorted_colors.lower_bound((*i).second); + b = grouped_sorted_colors.upper_bound((*i).second); + for (GroupedSortedColors::iterator j = a; j != b; ++j){ + if (reverse){ + for (SortedColors::reverse_iterator k = (*j).second.rbegin(); k != (*j).second.rend(); ++k){ + color_list_add_color_object(color_list, (*k).second, true); + } + }else{ + for (SortedColors::iterator k = (*j).second.begin(); k != (*j).second.end(); ++k){ + color_list_add_color_object(color_list, (*k).second, true); + } + } + } + } + } +} + +static void update(GtkWidget *widget, DialogSortArgs *args ){ + color_list_remove_all(args->preview_color_list); + calc(args, true, 100); +} + +bool dialog_sort_show(GtkWindow* parent, struct ColorList *selected_color_list, struct ColorList *sorted_color_list, GlobalState* gs) +{ + DialogSortArgs *args = new DialogSortArgs; + args->gs = gs; + args->params = dynv_get_dynv(args->gs->params, "gpick.group_and_sort"); + args->sorted_color_list = sorted_color_list; + + GtkWidget *table; + + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Group and sort"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + gtk_window_set_default_size(GTK_WINDOW(dialog), dynv_get_int32_wd(args->params, "window.width", -1), dynv_get_int32_wd(args->params, "window.height", -1)); + gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); + + gint table_y; + table = gtk_table_new(4, 4, FALSE); + table_y = 0; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Group type:"),0,0.5,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->group_type = gtk_combo_box_new_text(); + for (uint32_t i = 0; i < sizeof(group_types) / sizeof(GroupType); i++){ + gtk_combo_box_append_text(GTK_COMBO_BOX(args->group_type), _(group_types[i].name)); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(args->group_type), dynv_get_int32_wd(args->params, "group_type", 0)); + g_signal_connect(G_OBJECT(args->group_type), "changed", G_CALLBACK(update), args); + gtk_table_attach(GTK_TABLE(table), args->group_type,3,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + table_y++; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Grouping sensitivity:"),0,0,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->group_sensitivity = gtk_spin_button_new_with_range(0, 100, 0.01); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->group_sensitivity), dynv_get_float_wd(args->params, "group_sensitivity", 50)); + gtk_table_attach(GTK_TABLE(table), args->group_sensitivity,3,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect(G_OBJECT(args->group_sensitivity), "value-changed", G_CALLBACK(update), args); + table_y++; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Maximum number of groups:"),0,0,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->max_groups = gtk_spin_button_new_with_range(1, 255, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(args->max_groups), dynv_get_int32_wd(args->params, "max_groups", 10)); + gtk_table_attach(GTK_TABLE(table), args->max_groups,3,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect(G_OBJECT(args->max_groups), "value-changed", G_CALLBACK(update), args); + table_y++; + + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Sort type:"),0,0.5,0,0),2,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + args->sort_type = gtk_combo_box_new_text(); + for (uint32_t i = 0; i < sizeof(sort_types) / sizeof(SortType); i++){ + gtk_combo_box_append_text(GTK_COMBO_BOX(args->sort_type), _(sort_types[i].name)); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(args->sort_type), dynv_get_int32_wd(args->params, "sort_type", 0)); + g_signal_connect (G_OBJECT (args->sort_type), "changed", G_CALLBACK(update), args); + gtk_table_attach(GTK_TABLE(table), args->sort_type,3,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + table_y++; + + args->toggle_reverse_groups = gtk_check_button_new_with_mnemonic(_("_Reverse group order")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(args->toggle_reverse_groups), dynv_get_bool_wd(args->params, "reverse_groups", false)); + gtk_table_attach(GTK_TABLE(table), args->toggle_reverse_groups,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect (G_OBJECT(args->toggle_reverse_groups), "toggled", G_CALLBACK(update), args); + table_y++; + + args->toggle_reverse = gtk_check_button_new_with_mnemonic(_("_Reverse order inside groups")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(args->toggle_reverse), dynv_get_bool_wd(args->params, "reverse", false)); + gtk_table_attach(GTK_TABLE(table), args->toggle_reverse,1,4,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); + g_signal_connect (G_OBJECT(args->toggle_reverse), "toggled", G_CALLBACK(update), args); + table_y++; + + + GtkWidget* preview_expander; + struct ColorList* preview_color_list = NULL; + gtk_table_attach(GTK_TABLE(table), preview_expander = palette_list_preview_new(gs, true, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 4, table_y, table_y + 1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); + table_y++; + + args->selected_color_list = selected_color_list; + args->preview_color_list = preview_color_list; + + update(0, args); + + gtk_widget_show_all(table); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); + + bool retval = false; + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK){ + calc(args, false, 0); + retval = true; + } + + gint width, height; + gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); + dynv_set_int32(args->params, "window.width", width); + dynv_set_int32(args->params, "window.height", height); + dynv_set_bool(args->params, "show_preview", gtk_expander_get_expanded(GTK_EXPANDER(preview_expander))); + + gtk_widget_destroy(dialog); + + color_list_destroy(args->preview_color_list); + dynv_system_release(args->params); + delete args; + + return retval; +} + + diff -Nru gpick-0.2.4/source/uiDialogSort.h gpick-0.2.5/source/uiDialogSort.h --- gpick-0.2.4/source/uiDialogSort.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/uiDialogSort.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef UIDIALOGSORT_H_ +#define UIDIALOGSORT_H_ + +#include +#include "ColorList.h" +#include "GlobalState.h" + +bool dialog_sort_show(GtkWindow* parent, struct ColorList *selected_color_list, struct ColorList *sorted_color_list, GlobalState* gs); + +#endif /* UIDIALOGSORT_H_ */ + + diff -Nru gpick-0.2.4/source/uiDialogVariations.cpp gpick-0.2.5/source/uiDialogVariations.cpp --- gpick-0.2.4/source/uiDialogVariations.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiDialogVariations.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,6 +22,8 @@ #include "MathUtil.h" #include "DynvHelpers.h" #include "GlobalStateStruct.h" +#include "ToolColorNaming.h" +#include "Internationalisation.h" #include using namespace std; @@ -38,13 +40,35 @@ GlobalState* gs; }DialogVariationsArgs; + +class VariationsColorNameAssigner: public ToolColorNameAssigner { + protected: + stringstream m_stream; + const char *m_name; + uint32_t m_step_i; + public: + VariationsColorNameAssigner(GlobalState *gs):ToolColorNameAssigner(gs){} + + void assign(struct ColorObject *color_object, Color *color, const char *name, uint32_t step_i){ + m_name = name; + m_step_i = step_i; + ToolColorNameAssigner::assign(color_object, color); + } + + virtual std::string getToolSpecificName(struct ColorObject *color_object, Color *color){ + m_stream.str(""); + m_stream << m_name << " " << _("variation") << " " << m_step_i; + return m_stream.str(); + } +}; + static void calc( DialogVariationsArgs *args, bool preview, int limit){ - gint steps=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(args->range_steps)); - gfloat lightness_from=gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_lightness_from)); - gfloat lightness_to=gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_lightness_to)); - gfloat saturation_from=gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_saturation_from)); - gfloat saturation_to=gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_saturation_to)); - gboolean multiplication=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_multiplication)); + gint steps = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(args->range_steps)); + gfloat lightness_from = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_lightness_from)); + gfloat lightness_to = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_lightness_to)); + gfloat saturation_from = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_saturation_from)); + gfloat saturation_to = gtk_spin_button_get_value(GTK_SPIN_BUTTON(args->range_saturation_to)); + gboolean multiplication = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->toggle_multiplication)); if (!preview){ dynv_set_int32(args->params, "steps", steps); @@ -55,8 +79,6 @@ dynv_set_bool(args->params, "multiplication", multiplication); } - stringstream s; - Color r, hsl; gint step_i; @@ -66,6 +88,8 @@ else color_list = args->gs->colors; + VariationsColorNameAssigner name_assigner(args->gs); + for (ColorList::iter i=args->selected_color_list->colors.begin(); i!=args->selected_color_list->colors.end(); ++i){ Color in; color_object_get_color(*i, &in); @@ -74,7 +98,7 @@ for (step_i = 0; step_i < steps; ++step_i) { if (preview){ - if (limit<=0) return; + if (limit <= 0) return; limit--; } @@ -93,21 +117,12 @@ color_hsl_to_rgb(&hsl, &r); - s.str(""); - s<params, "name", s.str().c_str()); + struct ColorObject *color_object = color_list_new_color_object(color_list, &r); + name_assigner.assign(color_object, &r, name, step_i); color_list_add_color_object(color_list, color_object, 1); color_object_release(color_object); } - - //i=g_list_next(i); } - - //palette_list_free_color_list(colors); } static void update(GtkWidget *widget, DialogVariationsArgs *args ){ @@ -124,7 +139,7 @@ GtkWidget *range_lightness_from, *range_lightness_to, *range_steps; GtkWidget *range_saturation_from, *range_saturation_to; - GtkWidget *dialog = gtk_dialog_new_with_buttons("Variations", parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Variations"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -138,7 +153,7 @@ table = gtk_table_new(5, 3, FALSE); table_y=0; - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Lightness:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Lightness:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); range_lightness_from = gtk_spin_button_new_with_range (-100,100,0.001); gtk_spin_button_set_value(GTK_SPIN_BUTTON(range_lightness_from), dynv_get_float_wd(args->params, "lightness_from", 1)); @@ -153,7 +168,7 @@ args->range_lightness_to = range_lightness_to; g_signal_connect (G_OBJECT (range_lightness_to), "value-changed", G_CALLBACK (update), args); - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Saturation:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Saturation:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); range_saturation_from = gtk_spin_button_new_with_range (-100,100,0.001); gtk_spin_button_set_value(GTK_SPIN_BUTTON(range_saturation_from), dynv_get_float_wd(args->params, "saturation_from", 0)); @@ -168,7 +183,7 @@ args->range_saturation_to = range_saturation_to; g_signal_connect (G_OBJECT (range_saturation_to), "value-changed", G_CALLBACK (update), args); - gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new("Steps:",0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); + gtk_table_attach(GTK_TABLE(table), gtk_label_aligned_new(_("Steps:"),0,0,0,0),0,1,table_y,table_y+1,GtkAttachOptions(GTK_FILL),GTK_FILL,5,5); range_steps = gtk_spin_button_new_with_range (3,255,1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(range_steps), dynv_get_int32_wd(args->params, "steps", 3)); gtk_table_attach(GTK_TABLE(table), range_steps,1,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); @@ -176,7 +191,7 @@ args->range_steps = range_steps; g_signal_connect (G_OBJECT (range_steps), "value-changed", G_CALLBACK (update), args); - toggle_multiplication = gtk_check_button_new_with_mnemonic ("_Use multiplication"); + toggle_multiplication = gtk_check_button_new_with_mnemonic (_("_Use multiplication")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_multiplication), dynv_get_bool_wd(args->params, "multiplication", true)); gtk_table_attach(GTK_TABLE(table), toggle_multiplication,1,3,table_y,table_y+1,GtkAttachOptions(GTK_FILL | GTK_EXPAND),GTK_FILL,5,0); table_y++; @@ -185,7 +200,7 @@ GtkWidget* preview_expander; struct ColorList* preview_color_list=NULL; - gtk_table_attach(GTK_TABLE(table), preview_expander=palette_list_preview_new(gs, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 3, table_y, table_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); + gtk_table_attach(GTK_TABLE(table), preview_expander=palette_list_preview_new(gs, true, dynv_get_bool_wd(args->params, "show_preview", true), gs->colors, &preview_color_list), 0, 3, table_y, table_y+1 , GtkAttachOptions(GTK_FILL | GTK_EXPAND), GtkAttachOptions(GTK_FILL | GTK_EXPAND), 5, 5); table_y++; diff -Nru gpick-0.2.4/source/uiDialogVariations.h gpick-0.2.5/source/uiDialogVariations.h --- gpick-0.2.4/source/uiDialogVariations.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiDialogVariations.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/uiExport.cpp gpick-0.2.5/source/uiExport.cpp --- gpick-0.2.4/source/uiExport.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiExport.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -17,18 +17,23 @@ */ #include "uiExport.h" +#include "FileFormat.h" #include "uiUtilities.h" #include "uiListPalette.h" #include "Endian.h" #include "DynvHelpers.h" #include "GlobalStateStruct.h" +#include "Internationalisation.h" #include +#include #include #include #include #include +#include + using namespace std; @@ -37,9 +42,10 @@ color_object_get_color(color_object, &color); const char* name = dynv_get_string_wd(color_object->params, "name", ""); - (*(ofstream*)userdata) << int32_t(color.rgb.red*255) << "\t" - << int32_t(color.rgb.green*255) << "\t" - << int32_t(color.rgb.blue*255) << "\t" << name << endl; + (*(ofstream*)userdata) + << boost::math::iround(color.rgb.red*255) << "\t" + << boost::math::iround(color.rgb.green*255) << "\t" + << boost::math::iround(color.rgb.blue*255) << "\t" << name << endl; return 0; } @@ -68,7 +74,15 @@ } } -static int32_t palette_export_gpl(struct ColorList *color_list, const gchar* filename, gboolean selected){ +int32_t palette_import_gpa(struct ColorList *color_list, const gchar* filename){ + return palette_file_load (filename, color_list); +} + +int32_t palette_export_gpa(struct ColorList *color_list, const gchar* filename, gboolean selected){ + return palette_file_save (filename, color_list); +} + +int32_t palette_export_gpl(struct ColorList *color_list, const gchar* filename, gboolean selected){ ofstream f(filename, ios::out | ios::trunc); if (f.is_open()){ @@ -81,7 +95,7 @@ g_free(name); - vector ordered = get_ordered_list(color_list); + vector ordered = get_ordered_list(color_list); for (vector::iterator i=ordered.begin(); i!=ordered.end(); ++i){ palette_export_gpl_color(*i, &f); } @@ -107,7 +121,7 @@ x = x.substr(start, end - start + 1); } -static int32_t palette_import_gpl(struct ColorList *color_list, const gchar* filename){ +int32_t palette_import_gpl(struct ColorList *color_list, const gchar* filename){ ifstream f(filename, ios::in); if (f.is_open()){ int r = 0; @@ -116,19 +130,16 @@ if (f.good() && line=="GIMP Palette"){ do{ getline(f, line); - }while (f.good() && line!="#"); - - if (line=="#"){ - int r, g, b; - Color c; - struct ColorObject* color_object; - string strip_chars = " \t"; - - for(;;){ - getline(f, line); - if (!f.good()) break; - if (line[0]=='#') continue; + }while (f.good() && ((line.size() < 1) || (line[0] > '9') || (line[0] < '0'))); + int r, g, b; + Color c; + struct ColorObject* color_object; + string strip_chars = " \t"; + + for(;;){ + if (!f.good()) break; + if (line[0]!='#'){ stringstream ss(line); ss >> r >> g >> b; @@ -145,8 +156,9 @@ color_list_add_color_object(color_list, color_object, TRUE); color_object_release(color_object); } + getline(f, line); + } - }else r = -1; }else r = -1; f.close(); @@ -237,7 +249,7 @@ return 0; } -static int32_t palette_export_ase(struct ColorList *color_list, const gchar* filename, gboolean selected){ +int32_t palette_export_ase(struct ColorList *color_list, const gchar* filename, gboolean selected){ ofstream f(filename, ios::out | ios::trunc | ios::binary); if (f.is_open()){ f << "ASEF"; //magic header @@ -260,7 +272,7 @@ } -static int32_t palette_import_ase(struct ColorList *color_list, const gchar* filename){ +int32_t palette_import_ase(struct ColorList *color_list, const gchar* filename){ ifstream f(filename, ios::binary); if (f.is_open()){ char magic[4]; @@ -282,15 +294,6 @@ uint32_t block_size; int color_supported; - matrix3x3 adaptation_matrix, working_space_matrix; - vector3 d50, d65; - vector3_set(&d50, 96.442, 100.000, 82.821); // D50 illuminant tristimulus values - vector3_set(&d65, 95.047, 100.000, 108.883); // D65 illuminant tristimulus values - color_get_chromatic_adaptation_matrix(&d50, &d65, &adaptation_matrix); - // constants used below are sRGB working space red, green and blue primaries for D65 reference white - color_get_working_space_matrix(0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, &d65, &working_space_matrix); - matrix3x3_inverse(&working_space_matrix, &working_space_matrix); - for (uint32_t i=0; iparams, "gpick.import.path", ""); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), default_path); + const char* selected_filter = dynv_get_string_wd(gs->params, "gpick.import.filter", "all_supported"); + + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, _("All files")); + g_object_set_data(G_OBJECT(filter), "identification", (gpointer)"all"); + gtk_file_filter_add_pattern(filter, "*"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); + if (g_strcmp0(selected_filter, "all") == 0){ + gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); + } - const char* selected_filter = dynv_get_string_wd(gs->params, "gpick.import.filter", "*.gpl"); + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, _("All supported formats")); + g_object_set_data(G_OBJECT(filter), "identification", (gpointer)"all_supported"); + for (gint i = 0; formats[i].name; ++i) { + gtk_file_filter_add_pattern(filter, formats[i].pattern); + } + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); + if (g_strcmp0(selected_filter, "all_supported") == 0){ + gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); + } - for (gint i = 0; i != sizeof(formats) / sizeof(struct import_formats); ++i) { + for (gint i = 0; formats[i].name; ++i) { filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, formats[i].name); + g_object_set_data(G_OBJECT(filter), "identification", (gpointer)formats[i].pattern); gtk_file_filter_add_pattern(filter, formats[i].pattern); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); @@ -581,7 +626,7 @@ } } - gboolean finished=FALSE; + gboolean finished = false; while (!finished){ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { @@ -593,21 +638,40 @@ dynv_set_string(gs->params, "gpick.import.path", path); g_free(path); - const gchar *format_name = gtk_file_filter_get_name(gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog))); - for (gint i = 0; i != sizeof(formats) / sizeof(struct import_formats); ++i) { - if (g_strcmp0(formats[i].name, format_name)==0){ - struct ColorList *color_list_arg; - color_list_arg = gs->colors; - if (formats[i].import_function(color_list_arg, filename)==0){ - finished=TRUE; - }else{ - GtkWidget* message; - message=gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "File could not be imported"); - gtk_window_set_title(GTK_WINDOW(dialog), "Import"); - gtk_dialog_run(GTK_DIALOG(message)); - gtk_widget_destroy(message); + FileType type = get_file_type_from_ext(filename); + if (type == UNKNOWN){ + const gchar *format_name = gtk_file_filter_get_name(gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog))); + for (int i = 0; formats[i].name; ++i) { + if (g_strcmp0(formats[i].name, format_name) == 0){ + type = formats[i].type; + break; + } + } + } + + if (type == UNKNOWN){ + message = gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File format is not supported")); + gtk_window_set_title(GTK_WINDOW(message), _("Import")); + gtk_dialog_run(GTK_DIALOG(message)); + gtk_widget_destroy(message); + }else{ + for (int i = 0; formats[i].name; ++i) { + if (formats[i].type == type){ + struct ColorList *color_list_arg; + color_list_arg = gs->colors; + if (formats[i].import_function(color_list_arg, filename) == 0){ + finished = true; + }else{ + message = gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be imported")); + gtk_window_set_title(GTK_WINDOW(message), _("Import")); + gtk_dialog_run(GTK_DIALOG(message)); + gtk_widget_destroy(message); + } + + const char *identification = (const char*)g_object_get_data(G_OBJECT(gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog))), "identification"); + dynv_set_string(gs->params, "gpick.import.filter", identification); + break; } - dynv_set_string(gs->params, "gpick.import.filter", formats[i].pattern); } } diff -Nru gpick-0.2.4/source/uiExport.h gpick-0.2.5/source/uiExport.h --- gpick-0.2.4/source/uiExport.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiExport.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -20,8 +20,14 @@ #define UIEXPORT_H_ #include +#include #include "GlobalState.h" +int32_t palette_export_gpl(struct ColorList *color_list, const gchar* filename, gboolean selected); +int32_t palette_import_gpl(struct ColorList *color_list, const gchar* filename); +int32_t palette_export_ase(struct ColorList *color_list, const gchar* filename, gboolean selected); +int32_t palette_import_ase(struct ColorList *color_list, const gchar* filename); + int dialog_export_show(GtkWindow* parent, struct ColorList *selected_color_list, gboolean selected, GlobalState *gs); int dialog_import_show(GtkWindow* parent, struct ColorList *selected_color_list, GlobalState *gs); diff -Nru gpick-0.2.4/source/uiListPalette.cpp gpick-0.2.5/source/uiListPalette.cpp --- gpick-0.2.4/source/uiListPalette.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiListPalette.cpp 2013-02-28 17:43:59.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -25,11 +25,16 @@ #include "uiApp.h" #include "GlobalStateStruct.h" #include "DynvHelpers.h" +#include "Vector2.h" +#include "Internationalisation.h" + +#include #include #include #include +using namespace math; using namespace std; typedef struct ListPaletteArgs{ @@ -37,11 +42,15 @@ GtkWidget *treeview; gint scroll_timeout; + Vec2 last_click_position; + bool disable_selection; + GtkWidget* count_label; GlobalState* gs; }ListPaletteArgs; static void destroy_arguments(gpointer data); static struct ColorObject* get_color_object(struct DragDrop* dd); +static struct ColorObject** get_color_object_list(struct DragDrop* dd, uint32_t *colorobject_n); #define SCROLL_EDGE_SIZE 15 //SCROLL_EDGE_SIZE from gtktreeview.c @@ -50,6 +59,7 @@ static gboolean scroll_row_timeout(ListPaletteArgs *args); static void palette_list_vertical_autoscroll(GtkTreeView *treeview); +static void update_counts(ListPaletteArgs *args); static gboolean scroll_row_timeout(ListPaletteArgs *args){ palette_list_vertical_autoscroll(GTK_TREE_VIEW(args->treeview)); @@ -71,9 +81,106 @@ static bool drag_end(struct DragDrop* dd, GtkWidget *widget, GdkDragContext *context){ remove_scroll_timeout((ListPaletteArgs*)dd->userdata); + update_counts((ListPaletteArgs*)dd->userdata); return true; } +typedef struct SelectionBoundsArgs{ + int min_index; + int max_index; + int last_index; + bool discontinuous; +} SelectionBoundsArgs; + + +static void find_selection_bounds(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data){ + gint *indices = gtk_tree_path_get_indices(path); + SelectionBoundsArgs *args = (SelectionBoundsArgs *) data; + int index = indices[0]; // currently indices are all 1d. + int diff = index - args->last_index; + if ((args->last_index != 0x7fffffff) && (diff != 1) && (diff != -1)){ + args->discontinuous = true; + } + if (index > args->max_index){ + args->max_index = index; + } + if (index < args->min_index){ + args->min_index = index; + } + args->last_index = index; +} + +static boost::format format_ignore_arg_errors(const std::string &f_string) { + boost::format fmter(f_string); + fmter.exceptions(boost::io::all_error_bits ^ (boost::io::too_many_args_bit | boost::io::too_few_args_bit)); + return fmter; +} + +static void update_counts(ListPaletteArgs *args){ + stringstream s; + GtkTreeSelection *sel; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(args->treeview)); + SelectionBoundsArgs bounds; + int selected_count; + int total_colors; + + if (!args->count_label){ + return; + } + + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(args->treeview)); + selected_count = gtk_tree_selection_count_selected_rows(sel); + total_colors = gtk_tree_model_iter_n_children(model, NULL); + + bounds.discontinuous = false; + bounds.min_index = 0x7fffffff; + bounds.last_index = 0x7fffffff; + bounds.max_index = 0; + if (selected_count > 0){ + s.str(""); + s << "#"; + gtk_tree_selection_selected_foreach(sel, &find_selection_bounds, &bounds); + if (bounds.min_index < bounds.max_index){ + s << bounds.min_index; + if (bounds.discontinuous){ + s << ".."; + }else{ + s << "-"; + } + s << bounds.max_index; + }else{ + s << bounds.min_index; + } + +#ifdef ENABLE_NLS + string selected_color_count; + try{ + selected_color_count = (format_ignore_arg_errors(ngettext("%d color", "%d colors", selected_count)) % selected_count).str(); + }catch(const boost::io::format_error &e){ + selected_color_count = ngettext("%d color", "%d colors", selected_count); + } + s << " (" << selected_color_count << ")"; +#else + s << " (" << ((selected_count == 1) ? "color" : "colors") << ")"; +#endif + s << " " << _("selected") << ". "; + } + +#ifdef ENABLE_NLS + string total_color_count; + try{ + total_color_count = (format_ignore_arg_errors(ngettext("Total %d color", "Total %d colors", total_colors)) % total_colors).str(); + }catch(const boost::io::format_error &e){ + total_color_count = ngettext("Total %d color", "Total %d colors", total_colors); + } + s << total_color_count; +#else + s << "Total " << total_colors << " colors."; +#endif + + gtk_label_set_text(GTK_LABEL(args->count_label), s.str().c_str()); +} + static void palette_list_vertical_autoscroll(GtkTreeView *treeview){ GdkRectangle visible_rect; gint y; @@ -110,6 +217,20 @@ if (text) g_free(text); } +static void palette_list_entry_update_row(GtkListStore* store, GtkTreeIter *iter, struct ColorObject* color_object, ListPaletteArgs* args){ + Color color; + color_object_get_color(color_object, &color); + gchar* text = main_get_color_text(args->gs, &color, COLOR_TEXT_TYPE_COLOR_LIST); + const char* name = dynv_get_string_wd(color_object->params, "name", ""); + gtk_list_store_set(store, iter, 1, text, 2, name, -1); + if (text) g_free(text); +} + +static void palette_list_entry_update_name(GtkListStore* store, GtkTreeIter *iter, struct ColorObject* color_object){ + const char* name = dynv_get_string_wd(color_object->params, "name", ""); + gtk_list_store_set(store, iter, 2, name, -1); +} + static void palette_list_cell_edited(GtkCellRendererText *cell, gchar *path, gchar *new_text, gpointer user_data) { GtkTreeIter iter; GtkTreeModel *model=GTK_TREE_MODEL(user_data); @@ -139,6 +260,7 @@ ColorSource *color_source = (ColorSource*)dynv_get_pointer_wd(args->gs->params, "CurrentColorSource", 0); color_source_set_color(color_source, color_object); + update_counts(args); } static int palette_list_preview_on_insert(struct ColorList* color_list, struct ColorObject* color_object){ @@ -156,11 +278,16 @@ palette_list_remove_all_entries(widget); } -GtkWidget* palette_list_preview_new(GlobalState* gs, bool expanded, struct ColorList* color_list, struct ColorList** out_color_list){ +GtkWidget* palette_list_get_widget(struct ColorList *color_list){ + return (GtkWidget*)color_list->userdata; +} + +GtkWidget* palette_list_preview_new(GlobalState* gs, bool expander, bool expanded, struct ColorList* color_list, struct ColorList** out_color_list){ ListPaletteArgs* args = new ListPaletteArgs; args->gs = gs; args->scroll_timeout = 0; + args->count_label = NULL; GtkListStore *store; GtkCellRenderer *renderer; @@ -183,7 +310,7 @@ gtk_tree_view_column_add_attribute(col, renderer, "color", 0); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); - + gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), false); gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); g_object_unref(GTK_TREE_MODEL(store)); @@ -196,6 +323,7 @@ dragdrop_init(&dd, gs); dd.get_color_object = get_color_object; + dd.get_color_object_list = get_color_object_list; dd.drag_end = drag_end; dd.handler_map = dynv_system_get_handler_map(gs->colors->params); dd.userdata = args; @@ -220,14 +348,57 @@ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(scrolled_window), view); - GtkWidget *expander=gtk_expander_new("Preview"); - gtk_container_add(GTK_CONTAINER(expander), scrolled_window); - gtk_expander_set_expanded(GTK_EXPANDER(expander), expanded); + GtkWidget *main_widget = scrolled_window; + if (expander){ + GtkWidget *expander=gtk_expander_new(_("Preview")); + gtk_container_add(GTK_CONTAINER(expander), scrolled_window); + gtk_expander_set_expanded(GTK_EXPANDER(expander), expanded); + + main_widget = expander; + } g_object_set_data_full(G_OBJECT(view), "arguments", args, destroy_arguments); - g_signal_connect(G_OBJECT(view), "destroy", G_CALLBACK(destroy_cb), args); + g_signal_connect(G_OBJECT(view), "destroy", G_CALLBACK(destroy_cb), args); + + return main_widget; +} + +static struct ColorObject** get_color_object_list(struct DragDrop* dd, uint32_t *colorobject_n){ + + GtkTreeIter iter; + GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dd->widget)); + GtkTreeModel* model; + gint selected = gtk_tree_selection_count_selected_rows(selection); + if (selected <= 1){ + if (colorobject_n) *colorobject_n = selected; + return 0; + } + + GList *list = gtk_tree_selection_get_selected_rows(selection, &model); + + struct ColorObject** color_objects = new struct ColorObject*[selected]; + if (colorobject_n) *colorobject_n = selected; + + if (list){ + GList *i = list; + + struct ColorObject* color_object; + uint32_t j = 0; + while (i) { + gtk_tree_model_get_iter(model, &iter, (GtkTreePath*) (i->data)); + gtk_tree_model_get(model, &iter, 0, &color_object, -1); + + color_objects[j] = color_object_ref(color_object); + + i = g_list_next(i); + j++; + } - return expander; + g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); + g_list_free (list); + } + + return color_objects; } static struct ColorObject* get_color_object(struct DragDrop* dd){ @@ -259,6 +430,96 @@ return 0; } +static int set_color_object_list_at(struct DragDrop* dd, struct ColorObject** colorobjects, uint32_t colorobject_n, int x, int y, bool move){ + ListPaletteArgs* args = (ListPaletteArgs*)dd->userdata; + remove_scroll_timeout(args); + + GtkTreePath* path; + GtkTreeViewDropPosition pos; + GtkTreeIter iter, iter2; + + GtkTreeModel* model = gtk_tree_view_get_model(GTK_TREE_VIEW(dd->widget)); + bool copy = false; + bool path_is_valid = false; + + if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(dd->widget), x, y, &path, &pos)){ + gtk_tree_model_get_iter(model, &iter, path); + + if (pos==GTK_TREE_VIEW_DROP_BEFORE || pos==GTK_TREE_VIEW_DROP_INTO_OR_BEFORE){ + path_is_valid = true; + }else if (pos==GTK_TREE_VIEW_DROP_AFTER || pos==GTK_TREE_VIEW_DROP_INTO_OR_AFTER){ + path_is_valid = true; + }else{ + return -1; + } + } + + for (uint32_t i = 0; i != colorobject_n; i++){ + struct ColorObject *colorobject = 0; + if (pos==GTK_TREE_VIEW_DROP_BEFORE || pos==GTK_TREE_VIEW_DROP_INTO_OR_BEFORE){ + colorobject = colorobjects[i]; + }else if (pos==GTK_TREE_VIEW_DROP_AFTER || pos==GTK_TREE_VIEW_DROP_INTO_OR_AFTER){ + colorobject = colorobjects[colorobject_n - i - 1]; + }else{ + colorobject = colorobjects[i]; + } + + if (move){ + struct ColorObject *reference_color_object; + gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 0, &reference_color_object, -1); + if (reference_color_object == colorobject){ + // Reference item is going to be removed, so any further inserts + // will fail if the same iterator is used. Iterator is moved forward + // to avoid that. + if (pos==GTK_TREE_VIEW_DROP_BEFORE || pos==GTK_TREE_VIEW_DROP_INTO_OR_BEFORE){ + if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter)){ + path_is_valid = false; + } + }else if (pos==GTK_TREE_VIEW_DROP_AFTER || pos==GTK_TREE_VIEW_DROP_INTO_OR_AFTER){ + GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iter); + if (gtk_tree_path_prev(path)) { + if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path)){ + path_is_valid = false; + } + }else{ + path_is_valid = false; + } + gtk_tree_path_free(path); + } + } + + if (colorobject->refcnt != 1){ //only one reference, can't be in palette + color_list_remove_color_object(args->gs->colors, colorobject); + } + }else{ + colorobject = color_object_copy(colorobject); + copy = true; + } + + if (path_is_valid){ + + if (pos==GTK_TREE_VIEW_DROP_BEFORE || pos==GTK_TREE_VIEW_DROP_INTO_OR_BEFORE){ + gtk_list_store_insert_before(GTK_LIST_STORE(model), &iter2, &iter); + palette_list_entry_fill(GTK_LIST_STORE(model), &iter2, colorobject, args); + color_list_add_color_object(args->gs->colors, colorobject, false); + }else if (pos==GTK_TREE_VIEW_DROP_AFTER || pos==GTK_TREE_VIEW_DROP_INTO_OR_AFTER){ + gtk_list_store_insert_after(GTK_LIST_STORE(model), &iter2, &iter); + palette_list_entry_fill(GTK_LIST_STORE(model), &iter2, colorobject, args); + color_list_add_color_object(args->gs->colors, colorobject, false); + }else{ + if (copy) color_object_release(colorobject); + return -1; + } + + }else{ + color_list_add_color_object(args->gs->colors, colorobject, true); + if (copy) color_object_release(colorobject); + } + } + update_counts(args); + return 0; +} + static int set_color_object_at(struct DragDrop* dd, struct ColorObject* colorobject, int x, int y, bool move){ ListPaletteArgs* args = (ListPaletteArgs*)dd->userdata; @@ -272,7 +533,7 @@ bool copy = false; if (move){ - if (colorobject->refcnt!=1){ //only one reference, can't be in palette + if (colorobject->refcnt != 1){ //only one reference, can't be in palette color_list_remove_color_object(args->gs->colors, colorobject); } }else{ @@ -283,23 +544,40 @@ if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(dd->widget), x, y, &path, &pos)){ gtk_tree_model_get_iter(model, &iter, path); - if (pos==GTK_TREE_VIEW_DROP_BEFORE || pos==GTK_TREE_VIEW_DROP_INTO_OR_BEFORE){ + GdkModifierType mask; + gdk_window_get_pointer(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(dd->widget)), NULL, NULL, &mask); + + if ((mask & GDK_CONTROL_MASK) && (pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER || pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE)){ + Color color; + color_object_get_color(colorobject, &color); + + struct ColorObject* original_color_object; + gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 0, &original_color_object, -1); + + color_object_set_color(original_color_object, &color); + palette_list_entry_update_row(GTK_LIST_STORE(model), &iter, original_color_object, args); + + }else if (pos==GTK_TREE_VIEW_DROP_BEFORE || pos==GTK_TREE_VIEW_DROP_INTO_OR_BEFORE){ gtk_list_store_insert_before(GTK_LIST_STORE(model), &iter2, &iter); palette_list_entry_fill(GTK_LIST_STORE(model), &iter2, colorobject, args); + color_list_add_color_object(args->gs->colors, colorobject, false); }else if (pos==GTK_TREE_VIEW_DROP_AFTER || pos==GTK_TREE_VIEW_DROP_INTO_OR_AFTER){ gtk_list_store_insert_after(GTK_LIST_STORE(model), &iter2, &iter); palette_list_entry_fill(GTK_LIST_STORE(model), &iter2, colorobject, args); + color_list_add_color_object(args->gs->colors, colorobject, false); }else{ if (copy) color_object_release(colorobject); + update_counts(args); return -1; } - color_list_add_color_object(args->gs->colors, colorobject, false); if (copy) color_object_release(colorobject); }else{ color_list_add_color_object(args->gs->colors, colorobject, true); + update_counts(args); if (copy) color_object_release(colorobject); } + update_counts(args); return 0; } @@ -309,11 +587,15 @@ GtkTreeViewDropPosition pos; if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(dd->widget), x, y, &path, &pos)){ + GdkModifierType mask; + gdk_window_get_pointer(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(dd->widget)), NULL, NULL, &mask); - if (pos==GTK_TREE_VIEW_DROP_BEFORE || pos==GTK_TREE_VIEW_DROP_INTO_OR_BEFORE){ - pos=GTK_TREE_VIEW_DROP_BEFORE; - }else if (pos==GTK_TREE_VIEW_DROP_AFTER || pos==GTK_TREE_VIEW_DROP_INTO_OR_AFTER){ - pos=GTK_TREE_VIEW_DROP_AFTER; + if ((mask & GDK_CONTROL_MASK) && (pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER || pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE)){ + pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE; + }else if (pos == GTK_TREE_VIEW_DROP_BEFORE || pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE){ + pos = GTK_TREE_VIEW_DROP_BEFORE; + }else if (pos==GTK_TREE_VIEW_DROP_AFTER || pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER){ + pos = GTK_TREE_VIEW_DROP_AFTER; } gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(dd->widget), path, pos); @@ -330,10 +612,82 @@ delete args; } -GtkWidget* palette_list_new(GlobalState* gs){ +static gboolean disable_palette_selection_function(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, ListPaletteArgs *args) { + return args->disable_selection; +} + +static void disable_palette_selection(GtkWidget *widget, gboolean disable, int x, int y, ListPaletteArgs *args) { + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); + args->disable_selection = disable; + gtk_tree_selection_set_select_function(selection, (GtkTreeSelectionFunc)disable_palette_selection_function, args, NULL); + + args->last_click_position.x = x; + args->last_click_position.y = y; +} + +static gboolean on_palette_button_press(GtkWidget *widget, GdkEventButton *event, ListPaletteArgs *args) { + disable_palette_selection(widget, true, -1, -1, args); + + if (event->button != 1) + return false; + if (event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)) + return false; + + GtkTreePath *path = NULL; + if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), + event->x, event->y, + &path, + NULL, + NULL, NULL)) + return false; + + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); + if (gtk_tree_selection_path_is_selected(selection, path)) { + disable_palette_selection(widget, false, event->x, event->y, args); + } + if (path) + gtk_tree_path_free(path); + update_counts((ListPaletteArgs*)args); + return false; +} + +static gboolean on_palette_button_release(GtkWidget *widget, GdkEventButton *event, ListPaletteArgs *args) { + if (args->last_click_position != Vec2(-1, -1)) { + Vec2 click_pos = args->last_click_position; + disable_palette_selection(widget, true, -1, -1, args); + if (click_pos.x == event->x && click_pos.y == event->y) { + GtkTreePath *path = NULL; + GtkTreeViewColumn *column; + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), event->x, event->y, &path, &column, NULL, NULL)) { + gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), path, column, FALSE); + } + if (path) + gtk_tree_path_free(path); + } + } + update_counts((ListPaletteArgs*)args); + return false; +} + +static void on_palette_cursor_changed(GtkTreeView *treeview, ListPaletteArgs *args){ + update_counts(args); +} + +static gboolean on_palette_select_all(GtkTreeView *treeview, ListPaletteArgs *args){ + update_counts(args); + return FALSE; +} + +static gboolean on_palette_unselect_all(GtkTreeView *treeview, ListPaletteArgs *args){ + update_counts(args); + return FALSE; +} + +GtkWidget* palette_list_new(GlobalState* gs, GtkWidget* count_label){ ListPaletteArgs* args = new ListPaletteArgs; args->gs = gs; + args->count_label = count_label; args->scroll_timeout = 0; GtkListStore *store; @@ -351,7 +705,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable(col,1); - gtk_tree_view_column_set_title(col, "Color"); + gtk_tree_view_column_set_title(col, _("Color")); renderer = custom_cell_renderer_color_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "color", 0); @@ -360,7 +714,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable(col,1); - gtk_tree_view_column_set_title(col, "Color"); + gtk_tree_view_column_set_title(col, _("Color")); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", 1); @@ -369,7 +723,7 @@ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable(col,1); - gtk_tree_view_column_set_title(col, "Name"); + gtk_tree_view_column_set_title(col, _("Name")); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", 2); @@ -377,14 +731,20 @@ g_object_set(renderer, "editable", TRUE, NULL); g_signal_connect(renderer, "edited", (GCallback) palette_list_cell_edited, store); - gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL(store)); - g_object_unref (GTK_TREE_MODEL(store)); + gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), false); + gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); + g_object_unref(GTK_TREE_MODEL(store)); GtkTreeSelection *selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW(view) ); gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); - g_signal_connect (G_OBJECT (view), "row-activated", G_CALLBACK(palette_list_row_activated), args); + g_signal_connect(G_OBJECT(view), "row-activated", G_CALLBACK(palette_list_row_activated), args); + g_signal_connect(G_OBJECT(view), "button-press-event", G_CALLBACK(on_palette_button_press), args); + g_signal_connect(G_OBJECT(view), "button-release-event", G_CALLBACK(on_palette_button_release), args); + g_signal_connect(G_OBJECT(view), "cursor-changed", G_CALLBACK(on_palette_cursor_changed), args); + g_signal_connect_after(G_OBJECT(view), "select-all", G_CALLBACK(on_palette_select_all), args); + g_signal_connect_after(G_OBJECT(view), "unselect-all", G_CALLBACK(on_palette_unselect_all), args); ///gtk_tree_view_set_reorderable(GTK_TREE_VIEW (view), TRUE); gtk_drag_dest_set( view, GtkDestDefaults(GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT), 0, 0, GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK)); @@ -394,7 +754,9 @@ dragdrop_init(&dd, gs); dd.get_color_object = get_color_object; + dd.get_color_object_list = get_color_object_list; dd.set_color_object_at = set_color_object_at; + dd.set_color_object_list_at = set_color_object_list_at; dd.handler_map = dynv_system_get_handler_map(gs->colors->params); dd.test_at = test_at; dd.drag_end = drag_end; @@ -403,12 +765,17 @@ dragdrop_widget_attach(view, DragDropFlags(DRAGDROP_SOURCE | DRAGDROP_DESTINATION), &dd); g_object_set_data_full(G_OBJECT(view), "arguments", args, destroy_arguments); - g_signal_connect(G_OBJECT(view), "destroy", G_CALLBACK(destroy_cb), args); + g_signal_connect(G_OBJECT(view), "destroy", G_CALLBACK(destroy_cb), args); + + if (count_label){ + update_counts(args); + } return view; } void palette_list_remove_all_entries(GtkWidget* widget) { + ListPaletteArgs* args = (ListPaletteArgs*)g_object_get_data(G_OBJECT(widget), "arguments"); GtkTreeIter iter; GtkListStore *store; gboolean valid; @@ -424,6 +791,8 @@ } gtk_list_store_clear(GTK_LIST_STORE(store)); + + update_counts(args); } gint32 palette_list_get_selected_count(GtkWidget* widget) { @@ -468,17 +837,17 @@ } void palette_list_remove_selected_entries(GtkWidget* widget) { - + ListPaletteArgs* args = (ListPaletteArgs*)g_object_get_data(G_OBJECT(widget), "arguments"); GtkTreeIter iter; GtkListStore *store; gboolean valid; store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); + valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); struct ColorObject* color_object; - while (valid){ + while (valid){ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &color_object, -1); if (color_object->selected){ valid = gtk_list_store_remove(GTK_LIST_STORE(store), &iter); @@ -486,53 +855,11 @@ }else{ valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); } - } - -/* - GtkTreeSelection *selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW(widget) ); - GtkListStore *store; - GtkTreeIter iter; - - if (gtk_tree_selection_count_selected_rows(selection) == 0){ - return; - } - - store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); - - GList *list = gtk_tree_selection_get_selected_rows ( selection, 0 ); - GList *ref_list = NULL; - - GList *i = list; - while (i) { - ref_list = g_list_prepend(ref_list, gtk_tree_row_reference_new(GTK_TREE_MODEL(store), (GtkTreePath*) (i->data))); - i = g_list_next(i); } - i = ref_list; - GtkTreePath *path; - while (i) { - path = gtk_tree_row_reference_get_path((GtkTreeRowReference*) i->data); - if (path) { - gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path); - gtk_tree_path_free(path); - - struct ColorObject* c; - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &c, -1); - color_object_release(c); - - gtk_list_store_remove(GTK_LIST_STORE(store), &iter); - } - i = g_list_next(i); - } - g_list_foreach (ref_list, (GFunc)gtk_tree_row_reference_free, NULL); - g_list_free (ref_list); - - g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); - g_list_free (list); -*/ + update_counts(args); } - void palette_list_add_entry(GtkWidget* widget, struct ColorObject* color_object){ ListPaletteArgs* args = (ListPaletteArgs*)g_object_get_data(G_OBJECT(widget), "arguments"); @@ -543,19 +870,21 @@ gtk_list_store_append(store, &iter1); palette_list_entry_fill(store, &iter1, color_object, args); + update_counts(args); } int palette_list_remove_entry(GtkWidget* widget, struct ColorObject* r_color_object){ + ListPaletteArgs* args = (ListPaletteArgs*)g_object_get_data(G_OBJECT(widget), "arguments"); GtkTreeIter iter; GtkListStore *store; gboolean valid; store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); + valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); struct ColorObject* color_object; - while (valid){ + while (valid){ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &color_object, -1); if (color_object == r_color_object){ valid = gtk_list_store_remove(GTK_LIST_STORE(store), &iter); @@ -563,76 +892,135 @@ return 0; } valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); - } + } + update_counts(args); return -1; } -gint32 palette_list_foreach(GtkWidget* widget, gint32 (*callback)(struct ColorObject* color_object, void *userdata), void *userdata){ +static void execute_callback(GtkListStore *store, GtkTreeIter *iter, ListPaletteArgs* args, PaletteListCallback callback, void *userdata){ + + struct ColorObject* color_object; + gtk_tree_model_get(GTK_TREE_MODEL(store), iter, 0, &color_object, -1); + + PaletteListCallbackReturn r = callback(color_object, userdata); + switch (r){ + case PALETTE_LIST_CALLBACK_UPDATE_NAME: + palette_list_entry_update_name(store, iter, color_object); + break; + case PALETTE_LIST_CALLBACK_UPDATE_ROW: + palette_list_entry_update_row(store, iter, color_object, args); + break; + case PALETTE_LIST_CALLBACK_NO_UPDATE: + break; + } +} + +static void execute_replace_callback(GtkListStore *store, GtkTreeIter *iter, ListPaletteArgs* args, PaletteListReplaceCallback callback, void *userdata){ + + struct ColorObject *color_object, *orig_color_object; + gtk_tree_model_get(GTK_TREE_MODEL(store), iter, 0, &color_object, -1); + orig_color_object = color_object; + + color_object_ref(color_object); + PaletteListCallbackReturn r = callback(&color_object, userdata); + if (color_object != orig_color_object){ + gtk_list_store_set(store, iter, 0, color_object, -1); + } + switch (r){ + case PALETTE_LIST_CALLBACK_UPDATE_NAME: + palette_list_entry_update_name(store, iter, color_object); + break; + case PALETTE_LIST_CALLBACK_UPDATE_ROW: + palette_list_entry_update_row(store, iter, color_object, args); + break; + case PALETTE_LIST_CALLBACK_NO_UPDATE: + break; + } + color_object_release(color_object); +} + +gint32 palette_list_foreach(GtkWidget* widget, PaletteListCallback callback, void *userdata){ + ListPaletteArgs* args = (ListPaletteArgs*)g_object_get_data(G_OBJECT(widget), "arguments"); GtkTreeIter iter; GtkListStore *store; gboolean valid; - store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); + store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); + valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); struct ColorObject* color_object; - //gchar* color_name; - while (valid){ - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &color_object, -1); - callback(color_object, userdata); + while (valid){ + execute_callback(store, &iter, args, callback, userdata); valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); - } + } return 0; } -gint32 palette_list_foreach_selected(GtkWidget* widget, gint32 (*callback)(struct ColorObject* color_object, void *userdata), void *userdata){ - GtkTreeSelection *selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW(widget) ); + +gint32 palette_list_foreach_selected(GtkWidget* widget, PaletteListCallback callback, void *userdata){ + ListPaletteArgs* args = (ListPaletteArgs*)g_object_get_data(G_OBJECT(widget), "arguments"); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); GtkListStore *store; GtkTreeIter iter; - store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); + store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); - GList *list = gtk_tree_selection_get_selected_rows ( selection, 0 ); + GList *list = gtk_tree_selection_get_selected_rows(selection, 0); GList *i = list; - struct ColorObject* color_object; - //gchar* color_name; - while (i) { gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, (GtkTreePath*) (i->data)); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &color_object, -1); - callback(color_object, userdata); + execute_callback(store, &iter, args, callback, userdata); i = g_list_next(i); } - g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); - g_list_free (list); + g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); + g_list_free(list); return 0; } -gint32 palette_list_forfirst_selected(GtkWidget* widget, gint32 (*callback)(struct ColorObject* color_object, void *userdata), void *userdata){ - GtkTreeSelection *selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW(widget) ); +gint32 palette_list_foreach_selected(GtkWidget* widget, PaletteListReplaceCallback callback, void *userdata){ + ListPaletteArgs* args = (ListPaletteArgs*)g_object_get_data(G_OBJECT(widget), "arguments"); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); GtkListStore *store; GtkTreeIter iter; - store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); + store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); - GList *list = gtk_tree_selection_get_selected_rows ( selection, 0 ); + GList *list = gtk_tree_selection_get_selected_rows(selection, 0); GList *i = list; - struct ColorObject* color_object; - //gchar* color_name; + while (i) { + gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, (GtkTreePath*) (i->data)); + execute_replace_callback(store, &iter, args, callback, userdata); + i = g_list_next(i); + } + + g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); + g_list_free(list); + return 0; +} + +gint32 palette_list_forfirst_selected(GtkWidget* widget, PaletteListCallback callback, void *userdata) +{ + ListPaletteArgs* args = (ListPaletteArgs*)g_object_get_data(G_OBJECT(widget), "arguments"); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); + GtkListStore *store; + GtkTreeIter iter; + + store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); + + GList *list = gtk_tree_selection_get_selected_rows(selection, 0); + GList *i = list; if (i) { gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, (GtkTreePath*) (i->data)); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &color_object, -1); - callback(color_object, userdata); + execute_callback(store, &iter, args, callback, userdata); } - g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); - g_list_free (list); + g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); + g_list_free(list); return 0; } - diff -Nru gpick-0.2.4/source/uiListPalette.h gpick-0.2.5/source/uiListPalette.h --- gpick-0.2.4/source/uiListPalette.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiListPalette.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -25,18 +25,29 @@ #include "GlobalState.h" -GtkWidget* palette_list_new(GlobalState* gs); +GtkWidget* palette_list_new(GlobalState* gs, GtkWidget* count_label); void palette_list_add_entry(GtkWidget* widget, struct ColorObject *color_object); -GtkWidget* palette_list_preview_new(GlobalState* gs, bool expanded, struct ColorList* color_list, struct ColorList** out_color_list); +GtkWidget* palette_list_preview_new(GlobalState* gs, bool expander, bool expanded, struct ColorList* color_list, struct ColorList** out_color_list); +GtkWidget* palette_list_get_widget(struct ColorList *color_list); void palette_list_remove_all_entries(GtkWidget* widget); void palette_list_remove_selected_entries(GtkWidget* widget); int palette_list_remove_entry(GtkWidget* widget, struct ColorObject *color_object); -gint32 palette_list_foreach_selected(GtkWidget* widget, gint32 (*callback)(struct ColorObject* color_object, void *userdata), void *userdata); -gint32 palette_list_forfirst_selected(GtkWidget* widget, gint32 (*callback)(struct ColorObject* color_object, void *userdata), void *userdata); -gint32 palette_list_foreach(GtkWidget* widget, gint32 (*callback)(struct ColorObject* color_object, void *userdata), void *userdata); +enum PaletteListCallbackReturn{ + PALETTE_LIST_CALLBACK_NO_UPDATE = 0, + PALETTE_LIST_CALLBACK_UPDATE_ROW = 1, + PALETTE_LIST_CALLBACK_UPDATE_NAME = 2, +}; + +typedef PaletteListCallbackReturn (*PaletteListCallback)(struct ColorObject* color_object, void *userdata); +typedef PaletteListCallbackReturn (*PaletteListReplaceCallback)(struct ColorObject** color_object, void *userdata); + +gint32 palette_list_foreach_selected(GtkWidget* widget, PaletteListCallback callback, void *userdata); +gint32 palette_list_foreach_selected(GtkWidget* widget, PaletteListReplaceCallback callback, void *userdata); +gint32 palette_list_forfirst_selected(GtkWidget* widget, PaletteListCallback callback, void *userdata); +gint32 palette_list_foreach(GtkWidget* widget, PaletteListCallback callback, void *userdata); gint32 palette_list_get_selected_count(GtkWidget* widget); gint32 palette_list_get_count(GtkWidget* widget); diff -Nru gpick-0.2.4/source/uiStatusIcon.cpp gpick-0.2.5/source/uiStatusIcon.cpp --- gpick-0.2.4/source/uiStatusIcon.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiStatusIcon.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -26,6 +26,7 @@ #include "FloatingPicker.h" #include "Converter.h" #include "DynvHelpers.h" +#include "Internationalisation.h" #include using namespace math; @@ -63,14 +64,14 @@ menu = GTK_MENU(gtk_menu_new ()); - item = gtk_menu_item_new_with_image ("_Show Main Window", gtk_image_new_from_icon_name("gpick", GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Show Main Window"), gtk_image_new_from_icon_name("gpick", GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (status_icon_show_parent), si); gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new()); - item = gtk_menu_item_new_with_image ("_Quit", gtk_image_new_from_stock(GTK_STOCK_QUIT, GTK_ICON_SIZE_MENU)); + item = gtk_menu_item_new_with_image (_("_Quit"), gtk_image_new_from_stock(GTK_STOCK_QUIT, GTK_ICON_SIZE_MENU)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (status_icon_destroy_parent), si); diff -Nru gpick-0.2.4/source/uiStatusIcon.h gpick-0.2.5/source/uiStatusIcon.h --- gpick-0.2.4/source/uiStatusIcon.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiStatusIcon.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/uiTransformations.cpp gpick-0.2.5/source/uiTransformations.cpp --- gpick-0.2.4/source/uiTransformations.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/uiTransformations.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,412 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "uiTransformations.h" + +#include "Converter.h" +#include "uiUtilities.h" +#include "DynvHelpers.h" +#include "GlobalStateStruct.h" +#include "Internationalisation.h" + +#include "transformation/Chain.h" +#include "transformation/Factory.h" +#include "transformation/ColorVisionDeficiency.h" + +#include +using namespace std; + +typedef enum{ + TRANSFORMATIONS_HUMAN_NAME = 0, + TRANSFORMATIONS_TRANSFORMATION_PTR, + TRANSFORMATIONS_N_COLUMNS +}TransformationsColumns; + +typedef enum{ + AVAILABLE_TRANSFORMATIONS_HUMAN_NAME = 0, + AVAILABLE_TRANSFORMATIONS_NAME, + AVAILABLE_TRANSFORMATIONS_N_COLUMNS +}AvailableTransformationsColumns; + +typedef struct TransformationsArgs{ + GtkWidget *available_transformations; + GtkWidget *list; + GtkWidget *config_vbox; + GtkWidget *hpaned; + + GtkWidget *enabled; + + transformation::Transformation *transformation; + boost::shared_ptr configuration; + + struct dynvSystem *params; + struct dynvSystem *transformations_params; + GlobalState *gs; +}TransformationsArgs; + +static void configure_transformation(TransformationsArgs *args, transformation::Transformation *transformation); + +static void tranformations_update_row(GtkTreeModel *model, GtkTreeIter *iter1, transformation::Transformation *transformation, TransformationsArgs *args) { + gtk_list_store_set(GTK_LIST_STORE(model), iter1, + TRANSFORMATIONS_HUMAN_NAME, transformation->getReadableName().c_str(), + TRANSFORMATIONS_TRANSFORMATION_PTR, transformation, + -1); +} + +static void available_tranformations_update_row(GtkTreeModel *model, GtkTreeIter *iter1, transformation::Factory::TypeInfo *type_info, TransformationsArgs *args) { + gtk_list_store_set(GTK_LIST_STORE(model), iter1, + AVAILABLE_TRANSFORMATIONS_HUMAN_NAME, type_info->human_name, + AVAILABLE_TRANSFORMATIONS_NAME, type_info->name, + -1); +} + +static GtkWidget* available_transformations_list_new(TransformationsArgs *args) +{ + GtkListStore *store; + GtkCellRenderer *renderer; + GtkWidget *widget; + store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); + widget = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); + gtk_combo_box_set_add_tearoffs(GTK_COMBO_BOX(widget), 0); + + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget),renderer,0); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", AVAILABLE_TRANSFORMATIONS_HUMAN_NAME, NULL); + + g_object_unref(GTK_TREE_MODEL(store)); + + return widget; +} + +static void add_transformation_cb(GtkWidget *widget, TransformationsArgs *args) +{ + GtkTreeIter iter; + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(args->available_transformations), &iter)) { + GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(args->available_transformations)); + + gchar *name = 0; + gtk_tree_model_get(model, &iter, AVAILABLE_TRANSFORMATIONS_NAME, &name, -1); + + boost::shared_ptr tran = transformation::Factory::create(name); + if (tran){ + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + chain->add(tran); + + configure_transformation(args, tran.get()); + + model = gtk_tree_view_get_model(GTK_TREE_VIEW(args->list)); + gtk_list_store_append(GTK_LIST_STORE(model), &iter); + tranformations_update_row(model, &iter, tran.get(), args); + } + } +} + +static void remove_transformation_cb(GtkWidget *widget, TransformationsArgs *args) +{ + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(args->list)); + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(args->list)); + GtkTreeIter iter; + + if (gtk_tree_selection_count_selected_rows(selection) == 0){ + return; + } + + configure_transformation(args, NULL); + + GList *list = gtk_tree_selection_get_selected_rows(selection, 0); + GList *ref_list = NULL; + + GList *i = list; + while (i) { + ref_list = g_list_prepend(ref_list, gtk_tree_row_reference_new(model, (GtkTreePath*) (i->data))); + i = g_list_next(i); + } + + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + + i = ref_list; + GtkTreePath *path; + while (i) { + path = gtk_tree_row_reference_get_path((GtkTreeRowReference*)i->data); + if (path) { + gtk_tree_model_get_iter(model, &iter, path); + gtk_tree_path_free(path); + + transformation::Transformation *transformation; + gtk_tree_model_get(model, &iter, TRANSFORMATIONS_TRANSFORMATION_PTR, &transformation, -1); + + chain->remove(transformation); + + gtk_list_store_remove(GTK_LIST_STORE(model), &iter); + } + i = g_list_next(i); + } + g_list_foreach(ref_list, (GFunc)gtk_tree_row_reference_free, NULL); + g_list_free(ref_list); + + g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); + g_list_free(list); +} + +static GtkWidget* transformations_list_new(TransformationsArgs *args) +{ + GtkListStore *store; + GtkCellRenderer *renderer; + GtkTreeViewColumn *col; + GtkWidget *view; + + view = gtk_tree_view_new(); + args->list = view; + + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), 1); + + store = gtk_list_store_new(TRANSFORMATIONS_N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER); + + col = gtk_tree_view_column_new(); + gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_AUTOSIZE); + gtk_tree_view_column_set_resizable(col, 1); + gtk_tree_view_column_set_title(col, _("Name")); + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(col, renderer, true); + gtk_tree_view_column_add_attribute(col, renderer, "text", TRANSFORMATIONS_HUMAN_NAME); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); + + gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); + g_object_unref(GTK_TREE_MODEL(store)); + + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); + gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); + gtk_tree_view_set_reorderable(GTK_TREE_VIEW(view), true); + + return view; +} + +static void apply_configuration(TransformationsArgs *args){ + if (args->configuration && args->transformation){ + struct dynvHandlerMap *handler_map = dynv_system_get_handler_map(args->gs->params); + struct dynvSystem *dv = dynv_system_create(handler_map); + args->configuration->applyConfig(dv); + args->transformation->deserialize(dv); + dynv_handler_map_release(handler_map); + dynv_system_release(dv); + } +} + +static void configure_transformation(TransformationsArgs *args, transformation::Transformation *transformation) +{ + if (args->configuration){ + gtk_container_remove(GTK_CONTAINER(args->config_vbox), args->configuration->getWidget()); + apply_configuration(args); + args->configuration = boost::shared_ptr(); + } + if (transformation){ + args->configuration = transformation->getConfig(); + args->transformation = transformation; + gtk_box_pack_start(GTK_BOX(args->config_vbox), args->configuration->getWidget(), true, true, 0); + } +} + +static void transformation_chain_row_activated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, TransformationsArgs *args) { + GtkTreeModel* model; + GtkTreeIter iter; + + model = gtk_tree_view_get_model(tree_view); + gtk_tree_model_get_iter(model, &iter, path); + + transformation::Transformation *transformation; + gtk_tree_model_get(model, &iter, TRANSFORMATIONS_TRANSFORMATION_PTR, &transformation, -1); + configure_transformation(args, transformation); +} + + +void dialog_transformations_show(GtkWindow* parent, GlobalState* gs) +{ + TransformationsArgs *args = new TransformationsArgs; + args->gs = gs; + args->params = dynv_get_dynv(args->gs->params, "gpick"); + args->transformations_params = dynv_get_dynv(args->gs->params, "gpick.transformations"); + args->transformation = 0; + + GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Display filters"), parent, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + gtk_window_set_default_size(GTK_WINDOW(dialog), dynv_get_int32_wd(args->params, "transformations.window.width", -1), dynv_get_int32_wd(args->params, "transformations.window.height", -1)); + + gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); + + + GtkWidget *widget; + GtkWidget* vbox = gtk_vbox_new(false, 5); + GtkWidget *vbox2 = gtk_vbox_new(false, 5); + + args->enabled = widget = gtk_check_button_new_with_mnemonic (_("_Enabled")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->transformations_params, "enabled", false)); + gtk_box_pack_start(GTK_BOX(vbox), args->enabled, false, false, 0); + + + args->hpaned = gtk_hpaned_new(); + gtk_box_pack_start(GTK_BOX(vbox), args->hpaned, true, true, 0); + + + GtkWidget *list, *scrolled; + GtkTreeIter iter1; + GtkTreeModel *model; + + + args->available_transformations = list = available_transformations_list_new(args); + + + GtkWidget* hbox2 = gtk_hbox_new(false, 0); + gtk_box_pack_start(GTK_BOX(vbox2), hbox2, false, false, 0); + gtk_box_pack_start(GTK_BOX(hbox2), list, true, true, 0); + + GtkWidget *button = gtk_button_new_from_stock(GTK_STOCK_ADD); + gtk_box_pack_start(GTK_BOX(hbox2), button, false, false, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(add_transformation_cb), args); + + button = gtk_button_new_from_stock(GTK_STOCK_REMOVE); + gtk_box_pack_start(GTK_BOX(hbox2), button, false, false, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(remove_transformation_cb), args); + + model = gtk_combo_box_get_model(GTK_COMBO_BOX(list)); + vector types = transformation::Factory::getAllTypes(); + for (int i = 0; i != types.size(); i++){ + gtk_list_store_append(GTK_LIST_STORE(model), &iter1); + available_tranformations_update_row(model, &iter1, &types[i], args); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(list), 0); + + + args->list = list = transformations_list_new(args); + g_signal_connect(G_OBJECT(list), "row-activated", G_CALLBACK(transformation_chain_row_activated), args); + scrolled = gtk_scrolled_window_new(0, 0); + gtk_container_add(GTK_CONTAINER(scrolled), list); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_box_pack_start(GTK_BOX(vbox2), scrolled, true, true, 0); + + gtk_paned_pack1(GTK_PANED(args->hpaned), vbox2, false, false); + + args->config_vbox = gtk_vbox_new(false, 5); + gtk_paned_pack2(GTK_PANED(args->hpaned), args->config_vbox, false, false); + + transformation::Chain *chain = static_cast(dynv_get_pointer_wdc(args->gs->params, "TransformationChain", 0)); + + /*boost::shared_ptr color_vision_deficiency = boost::shared_ptr(new transformation::ColorVisionDeficiency(transformation::ColorVisionDeficiency::DEUTERANOMALY, 0.8)); + chain->clear(); + chain->add(color_vision_deficiency); + */ + + model = gtk_tree_view_get_model(GTK_TREE_VIEW(list)); + for (transformation::Chain::TransformationList::iterator i = chain->getAll().begin(); i != chain->getAll().end(); i++){ + gtk_list_store_append(GTK_LIST_STORE(model), &iter1); + tranformations_update_row(model, &iter1, (*i).get(), args); + } + + gtk_paned_set_position(GTK_PANED(args->hpaned), dynv_get_int32_wd(args->params, "paned_position", -1)); + + gtk_widget_show_all(vbox); + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox, true, true, 5); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { + + apply_configuration(args); + + GtkTreeIter iter; + GtkListStore *store; + gboolean valid; + + store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list))); + valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); + + + bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->enabled)); + dynv_set_bool(args->transformations_params, "enabled", enabled); + chain->setEnabled(enabled); + + unsigned int count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); + if (count > 0){ + struct dynvSystem** config_array = new struct dynvSystem*[count]; + unsigned int i = 0; + + struct dynvHandlerMap *handler_map = dynv_system_get_handler_map(args->gs->params); + + while (valid){ + transformation::Transformation* transformation; + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, TRANSFORMATIONS_TRANSFORMATION_PTR, &transformation, -1); + + struct dynvSystem *dv = dynv_system_create(handler_map); + transformation->serialize(dv); + config_array[i] = dv; + + valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); + ++i; + } + + dynv_handler_map_release(handler_map); + + dynv_set_dynv_array(args->transformations_params, "items", (const dynvSystem**)config_array, count); + + for (i = 0; i != count; i++){ + dynv_system_release(config_array[i]); + } + delete [] config_array; + }else{ + dynv_set_dynv_array(args->transformations_params, "items", 0, 0); + } + } + + chain->clear(); + chain->setEnabled(dynv_get_bool_wd(gs->params, "gpick.transformations.enabled", false)); + + struct dynvSystem** config_array; + uint32_t config_size; + + if ((config_array = (struct dynvSystem**)dynv_get_dynv_array_wd(gs->params, "gpick.transformations.items", 0, 0, &config_size))){ + for (uint32_t i = 0; i != config_size; i++){ + const char *name = dynv_get_string_wd(config_array[i], "name", 0); + if (name){ + boost::shared_ptr tran = transformation::Factory::create(name); + if (tran){ + tran->deserialize(config_array[i]); + chain->add(tran); + } + } + dynv_system_release(config_array[i]); + } + + delete [] config_array; + } + + gint width, height; + gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); + dynv_set_int32(args->params, "transformations.window.width", width); + dynv_set_int32(args->params, "transformations.window.height", height); + dynv_set_int32(args->params, "paned_position", gtk_paned_get_position(GTK_PANED(args->hpaned))); + + gtk_widget_destroy(dialog); + + dynv_system_release(args->transformations_params); + dynv_system_release(args->params); + delete args; +} + + + + diff -Nru gpick-0.2.4/source/uiTransformations.h gpick-0.2.5/source/uiTransformations.h --- gpick-0.2.4/source/uiTransformations.h 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/uiTransformations.h 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2009-2012, Albertas Vyšniauskas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef UI_TRANSFORMATIONS_H_ +#define UI_TRANSFORMATIONS_H_ + +#include +#include "GlobalState.h" + +void dialog_transformations_show(GtkWindow* parent, GlobalState* gs); + +#endif /* UI_TRANSFORMATIONS_H_ */ + diff -Nru gpick-0.2.4/source/uiUtilities.cpp gpick-0.2.5/source/uiUtilities.cpp --- gpick-0.2.4/source/uiUtilities.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiUtilities.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/uiUtilities.h gpick-0.2.5/source/uiUtilities.h --- gpick-0.2.4/source/uiUtilities.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/uiUtilities.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/unique/SConscript gpick-0.2.5/source/unique/SConscript --- gpick-0.2.4/source/unique/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/unique/SConscript 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!/usr/bin/env python - -import os -import sys - -Import('*') -local_env = env.Clone() - -if not local_env.GetOption('clean'): - local_env.ParseConfig('pkg-config --cflags $GTK_PC') - if local_env.has_key('UNIQUE_PC'): - local_env.ParseConfig('pkg-config --cflags $UNIQUE_PC') - if local_env.has_key('DBUSGLIB_PC'): - local_env.ParseConfig('pkg-config --cflags $DBUSGLIB_PC') - -sources = [] - -if 'UNIQUE_PC' in local_env: - sources.append('Unique.cpp') -elif 'DBUSGLIB_PC' in local_env: - sources.append('UniqueDBus.cpp') -else: - sources.append('UniqueDummy.cpp') - -objects = local_env.StaticObject(source = [sources]) - -Return('objects') diff -Nru gpick-0.2.4/source/unique/Unique.cpp gpick-0.2.5/source/unique/Unique.cpp --- gpick-0.2.4/source/unique/Unique.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/unique/Unique.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2009-2010, Albertas Vyšniauskas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "Unique.h" - -#include -#include - -static UniqueApp *unique_app=NULL; -static void* unique_user_data=NULL; - -static UniqueResponse user_callback (UniqueApp *app, gint command, UniqueMessageData *message_data, guint time_, int (*unique_callback)(void* user_data)){ - - if (command == UNIQUE_ACTIVATE){ - unique_callback(unique_user_data); - //gtk_window_set_startup_id(GTK_WINDOW (our_window), startup_id); - } - - return UNIQUE_RESPONSE_OK; -} - - -int unique_init(int (*unique_callback)(void* user_data), void* user_data){ - - unique_app = unique_app_new("org.gnome.gpick", NULL); - unique_user_data = user_data; - - if (unique_app_is_running(unique_app)){ - - unique_app_send_message(unique_app, UNIQUE_ACTIVATE, 0); - - g_object_unref(unique_app); - return 1; - }else{ - g_signal_connect(G_OBJECT (unique_app), "message-received", (GCallback) user_callback, (void*)unique_callback); - } - - return 0; -} - -int unique_term(){ - if (unique_app) g_object_unref(unique_app); - return 0; -} - - diff -Nru gpick-0.2.4/source/unique/Unique.h gpick-0.2.5/source/unique/Unique.h --- gpick-0.2.4/source/unique/Unique.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/unique/Unique.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2009-2010, Albertas Vyšniauskas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef UNIQUE_H_ -#define UNIQUE_H_ - -typedef int (*unique_cb_t)(void* user_data); - -int unique_init(unique_cb_t unique_cb, void* user_data); -int unique_term(); - -#endif /* UNIQUE_H_ */ diff -Nru gpick-0.2.4/source/unique/UniqueDBus.cpp gpick-0.2.5/source/unique/UniqueDBus.cpp --- gpick-0.2.4/source/unique/UniqueDBus.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/unique/UniqueDBus.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2009-2010, Albertas Vyšniauskas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "Unique.h" - -#include -#include -#include -#include - -#include -#include - -static DBusGProxy *proxy=NULL; -static int (*unique_callback)(void* user_data); -static void* unique_user_data; - -#define SINGLE_INSTANCE_FACTORY_TYPE (single_instance_factory_get_type ()) - -typedef struct _SingleInstanceFactory { - GObject object; -} SingleInstanceFactory; - -typedef struct _SingleInstanceFactoryClass { - GObjectClass object_class; -} SingleInstanceFactoryClass; - -static gboolean single_instance_activate (SingleInstanceFactory *factory, GError **error); - -#include "single_instance_server.h" - -static gboolean single_instance_activate (SingleInstanceFactory *factory, GError **error){ - unique_callback(unique_user_data); - return TRUE; -} - -static void -single_instance_factory_class_init (SingleInstanceFactoryClass *factory_class) -{ - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (factory_class), - &dbus_glib_single_instance_object_info); -} - -static void -single_instance_factory_init (SingleInstanceFactory *factory) -{ -} - -G_DEFINE_TYPE(SingleInstanceFactory, single_instance_factory, G_TYPE_OBJECT); - - -#include "single_instance_client.h" - -#define FACTORY_NAME "org.gpick.SingleInstanceFactory" -static int register_factory (void){ - DBusGConnection *connection=NULL; - - GError *error = NULL; - SingleInstanceFactory *factory; - guint32 request_name_ret; - - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (connection == NULL) { - g_printerr ("Error: %s\n", error->message); - g_error_free (error); - return -1; - } - - proxy = dbus_g_proxy_new_for_name (connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if (!org_freedesktop_DBus_request_name (proxy, FACTORY_NAME, - 0, &request_name_ret, &error)) { - g_printerr ("Error: %s\n", error->message); - g_error_free (error); - return -1; - } - - if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - //name already taken, - - proxy = dbus_g_proxy_new_for_name (connection, FACTORY_NAME, "/Factory", - "com.google.code.gpick.SingleInstance"); - - if (!com_google_code_gpick_SingleInstance_activate(proxy, &error)){ - g_printerr ("Error: %s\n", error->message); - g_error_free (error); - } - - return 1; - } - - factory = (SingleInstanceFactory*)g_object_new (SINGLE_INSTANCE_FACTORY_TYPE, NULL); - dbus_g_connection_register_g_object (connection, "/Factory", G_OBJECT (factory)); - return 0; -} - - -int unique_term(){ - if (proxy) g_object_unref(proxy); - return 0; -} - -int unique_init(int (*unique_callback)(void* user_data), void* user_data){ - - unique_user_data = user_data; - ::unique_callback = unique_callback; - - int r; - if ((r=register_factory()) == 0){ - return 0; - } - - return 1; -} - - - - - diff -Nru gpick-0.2.4/source/unique/UniqueDummy.cpp gpick-0.2.5/source/unique/UniqueDummy.cpp --- gpick-0.2.4/source/unique/UniqueDummy.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/unique/UniqueDummy.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2009-2010, Albertas Vyšniauskas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "Unique.h" - -#include - -int unique_init(int (*unique_callback)(void* user_data), void* user_data){ - return 0; -} - -int unique_term(){ - return 0; -} - - diff -Nru gpick-0.2.4/source/unique/single_instance.xml gpick-0.2.5/source/unique/single_instance.xml --- gpick-0.2.4/source/unique/single_instance.xml 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/unique/single_instance.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff -Nru gpick-0.2.4/source/unique/single_instance_client.h gpick-0.2.5/source/unique/single_instance_client.h --- gpick-0.2.4/source/unique/single_instance_client.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/unique/single_instance_client.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* Generated by dbus-binding-tool; do not edit! */ - -#include -#include - -G_BEGIN_DECLS - -#ifndef _DBUS_GLIB_ASYNC_DATA_FREE -#define _DBUS_GLIB_ASYNC_DATA_FREE -static -#ifdef G_HAVE_INLINE -inline -#endif -void -_dbus_glib_async_data_free (gpointer stuff) -{ - g_slice_free (DBusGAsyncData, stuff); -} -#endif - -#ifndef DBUS_GLIB_CLIENT_WRAPPERS_com_google_code_gpick_SingleInstance -#define DBUS_GLIB_CLIENT_WRAPPERS_com_google_code_gpick_SingleInstance - -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -com_google_code_gpick_SingleInstance_activate (DBusGProxy *proxy, GError **error) - -{ - return dbus_g_proxy_call (proxy, "Activate", error, G_TYPE_INVALID, G_TYPE_INVALID); -} - -typedef void (*com_google_code_gpick_SingleInstance_activate_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); - -static void -com_google_code_gpick_SingleInstance_activate_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); - (*(com_google_code_gpick_SingleInstance_activate_reply)data->cb) (proxy, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -com_google_code_gpick_SingleInstance_activate_async (DBusGProxy *proxy, com_google_code_gpick_SingleInstance_activate_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "Activate", com_google_code_gpick_SingleInstance_activate_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); -} -#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_com_google_code_gpick_SingleInstance */ - -G_END_DECLS diff -Nru gpick-0.2.4/source/unique/single_instance_server.h gpick-0.2.5/source/unique/single_instance_server.h --- gpick-0.2.4/source/unique/single_instance_server.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/unique/single_instance_server.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -/* Generated by dbus-binding-tool; do not edit! */ - - -#ifndef __dbus_glib_marshal_single_instance_MARSHAL_H__ -#define __dbus_glib_marshal_single_instance_MARSHAL_H__ - -#include - -G_BEGIN_DECLS - -#ifdef G_ENABLE_DEBUG -#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) -#define g_marshal_value_peek_char(v) g_value_get_char (v) -#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) -#define g_marshal_value_peek_int(v) g_value_get_int (v) -#define g_marshal_value_peek_uint(v) g_value_get_uint (v) -#define g_marshal_value_peek_long(v) g_value_get_long (v) -#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) -#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) -#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) -#define g_marshal_value_peek_enum(v) g_value_get_enum (v) -#define g_marshal_value_peek_flags(v) g_value_get_flags (v) -#define g_marshal_value_peek_float(v) g_value_get_float (v) -#define g_marshal_value_peek_double(v) g_value_get_double (v) -#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) -#define g_marshal_value_peek_param(v) g_value_get_param (v) -#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) -#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) -#define g_marshal_value_peek_object(v) g_value_get_object (v) -#else /* !G_ENABLE_DEBUG */ -/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. - * Do not access GValues directly in your code. Instead, use the - * g_value_get_*() functions - */ -#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int -#define g_marshal_value_peek_char(v) (v)->data[0].v_int -#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint -#define g_marshal_value_peek_int(v) (v)->data[0].v_int -#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint -#define g_marshal_value_peek_long(v) (v)->data[0].v_long -#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong -#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 -#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 -#define g_marshal_value_peek_enum(v) (v)->data[0].v_long -#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong -#define g_marshal_value_peek_float(v) (v)->data[0].v_float -#define g_marshal_value_peek_double(v) (v)->data[0].v_double -#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer -#endif /* !G_ENABLE_DEBUG */ - - -/* BOOLEAN:POINTER */ -extern void dbus_glib_marshal_single_instance_BOOLEAN__POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -void -dbus_glib_marshal_single_instance_BOOLEAN__POINTER (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) -{ - typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1, - gpointer arg_1, - gpointer data2); - register GMarshalFunc_BOOLEAN__POINTER callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - gboolean v_return; - - g_return_if_fail (return_value != NULL); - g_return_if_fail (n_param_values == 2); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback); - - v_return = callback (data1, - g_marshal_value_peek_pointer (param_values + 1), - data2); - - g_value_set_boolean (return_value, v_return); -} - -G_END_DECLS - -#endif /* __dbus_glib_marshal_single_instance_MARSHAL_H__ */ - -#include -static const DBusGMethodInfo dbus_glib_single_instance_methods[] = { - { (GCallback) single_instance_activate, dbus_glib_marshal_single_instance_BOOLEAN__POINTER, 0 }, -}; - -const DBusGObjectInfo dbus_glib_single_instance_object_info = { - 0, - dbus_glib_single_instance_methods, - 1, -"com.google.code.gpick.SingleInstance\0Activate\0S\0\0\0", -"\0", -"\0" -}; - diff -Nru gpick-0.2.4/source/version/SConscript gpick-0.2.5/source/version/SConscript --- gpick-0.2.4/source/version/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/version/SConscript 2013-01-05 16:04:19.000000000 +0000 @@ -5,12 +5,12 @@ Import('*') local_env = env.Clone() - -local_env.Append (CPPDEFINES = ['BUILD_DATE="%s"'%(env['GPICK_BUILD_DATE']), - 'BUILD_REVISION="%s"'%(env['GPICK_BUILD_REVISION']), - 'BUILD_PLATFORM="%s"'%(sys.platform), - 'BUILD_VERSION="%s"'%(env['GPICK_BUILD_VERSION']), -]) + +local_env.Append(CPPDEFINES = {'BUILD_DATE': env['GPICK_BUILD_DATE'], + 'BUILD_REVISION': env['GPICK_BUILD_REVISION'], + 'BUILD_PLATFORM': sys.platform, + 'BUILD_VERSION': env['GPICK_BUILD_VERSION'], +}) sources = local_env.Glob('*.cpp') objects = local_env.StaticObject([sources]) diff -Nru gpick-0.2.4/source/version/Version.cpp gpick-0.2.5/source/version/Version.cpp --- gpick-0.2.4/source/version/Version.cpp 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/version/Version.cpp 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/version/Version.h gpick-0.2.5/source/version/Version.h --- gpick-0.2.4/source/version/Version.h 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/version/Version.h 2013-01-01 16:10:52.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Albertas Vyšniauskas + * Copyright (c) 2009-2012, Albertas Vyšniauskas * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru gpick-0.2.4/source/winres/SConscript gpick-0.2.5/source/winres/SConscript --- gpick-0.2.4/source/winres/SConscript 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/winres/SConscript 2013-02-28 17:43:59.000000000 +0000 @@ -2,10 +2,28 @@ import os import sys +import re Import('*') local_env = env.Clone() -sources = local_env.Glob('*.rc') -objects = local_env.RES( sources ) +local_env.Append(RESOURCE_TEMPLATE_VARS = { + 'VERSION': env['GPICK_BUILD_VERSION'], + 'VERSION_COMMA': env['GPICK_BUILD_VERSION'].replace('.', ','), + 'REVISION': env['GPICK_BUILD_REVISION'], + 'BUILD_DATE': env['GPICK_BUILD_DATE'], +}) + +sources = local_env.Glob('*.rct') +resources = local_env.AlwaysBuild(local_env.ResourceTemplate(sources)) +objects = local_env.RES(resources) + +Command("gpick-icon.ico", File("gpick-icon.ico").srcnode(), Copy("$TARGET", "${SOURCE}")) +if not (env['TOOLCHAIN'] == 'msvc'): + Command("gpick.exe.manifest", File("gpick.exe.manifest").srcnode(), Copy("$TARGET", "${SOURCE}")) + +Depends(resources, 'gpick-icon.ico') +if not (env['TOOLCHAIN'] == 'msvc'): + Depends(resources, 'gpick.exe.manifest') + Return('objects') Binary files /tmp/yR5ToU1Wwf/gpick-0.2.4/source/winres/gpick-icon.ico and /tmp/nhh_qGkd8F/gpick-0.2.5/source/winres/gpick-icon.ico differ diff -Nru gpick-0.2.4/source/winres/gpick.exe.manifest gpick-0.2.5/source/winres/gpick.exe.manifest --- gpick-0.2.4/source/winres/gpick.exe.manifest 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/winres/gpick.exe.manifest 2013-01-01 16:10:52.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru gpick-0.2.4/source/winres/resources.rc gpick-0.2.5/source/winres/resources.rc --- gpick-0.2.4/source/winres/resources.rc 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/source/winres/resources.rc 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -1 ICON "gpick-icon.ico" diff -Nru gpick-0.2.4/source/winres/resources.rct gpick-0.2.5/source/winres/resources.rct --- gpick-0.2.4/source/winres/resources.rct 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/source/winres/resources.rct 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,27 @@ +1 ICON "gpick-icon.ico" + +1 VERSIONINFO +FILEVERSION %VERSION_COMMA% +PRODUCTVERSION %VERSION_COMMA% +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "Gpick developers" + VALUE "FileDescription", "Gpick - Advanced color picker" + VALUE "FileVersion", "%VERSION%" + VALUE "InternalName", "gpick" + VALUE "LegalCopyright", "New BSD License" + VALUE "OriginalFilename", "gpick.exe" + VALUE "ProductName", "Gpick" + VALUE "ProductVersion", "%VERSION%" + VALUE "Comments", "Revision %REVISION%, built at %BUILD_DATE%" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END diff -Nru gpick-0.2.4/tools/crossmingw.py gpick-0.2.5/tools/crossmingw.py --- gpick-0.2.4/tools/crossmingw.py 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/tools/crossmingw.py 2013-01-01 16:10:52.000000000 +0000 @@ -16,6 +16,7 @@ i486-mingw32msvc- i586-mingw32msvc- i686-mingw32msvc- + i686-w64-mingw32- """) def find(env): diff -Nru gpick-0.2.4/tools/flex.py gpick-0.2.5/tools/flex.py --- gpick-0.2.4/tools/flex.py 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/tools/flex.py 2013-01-01 16:10:52.000000000 +0000 @@ -1,13 +1,18 @@ from SCons.Script import * def addFlexBuilder(env): + + FlexAction = SCons.Action.Action("$FLEXCOM", "$FLEXCOMSTR") + + env["FLEX"] = env.Detect("flex") + env["FLEXCOM"] = "flex --header-file=${TARGET.base}.h -o $TARGET $SOURCE" def headerEmitter(target, source, env): bs = SCons.Util.splitext(str(source[0].name))[0] target.append(bs + '.h') return (target, source) - builder = Builder(action = 'flex --header-file=${TARGET.base}.h -o $TARGET $SOURCE', + builder = Builder(action = FlexAction, suffix = '.cpp', src_suffix = '.l', emitter = headerEmitter) diff -Nru gpick-0.2.4/tools/gettext.py gpick-0.2.5/tools/gettext.py --- gpick-0.2.4/tools/gettext.py 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/tools/gettext.py 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,56 @@ +from SCons.Script import * + +def addGettextBuilder(env): + + GettextAction = SCons.Action.Action("$GETTEXTCOM", "$GETTEXTCOMSTR") + + env["GETTEXT"] = env.Detect("msgfmt") + env["GETTEXTCOM"] = "$GETTEXT --check-format --check-domain -f -o $TARGET $SOURCE" + + builder = Builder( + action = GettextAction, + suffix = '.mo', + src_suffix = '.po', + single_source = True) + + env.Append(BUILDERS = {'Gettext': builder}) + + XgettextAction = SCons.Action.Action("$XGETTEXTCOM", "$XGETTEXTCOMSTR") + + env["XGETTEXT"] = env.Detect("xgettext") + env["XGETTEXTCOM"] = "$XGETTEXT --keyword=_ --from-code utf8 --package-name=gpick $XGETTEXT_FLAGS --output=$TARGET $SOURCES" + + builder = Builder( + action = XgettextAction, + suffix = '.pot', + src_suffix = '.cpp', + single_source = False) + + env.Append(BUILDERS = {'Xgettext': builder}) + + MsgmergeAction = SCons.Action.Action("$MSGMERGECOM", "$MSGMERGECOMSTR") + + env["MSGMERGE"] = env.Detect("msgmerge") + env["MSGMERGECOM"] = "$MSGMERGE $MSGMERGE_FLAGS --output-file=$TARGET $SOURCES" + + builder = Builder( + action = MsgmergeAction, + suffix = '.pot', + src_suffix = '.pot', + single_source = False) + + env.Append(BUILDERS = {'Msgmerge': builder}) + + MsgcatAction = SCons.Action.Action("$MSGCATCOM", "$MSGCATCOMSTR") + + env["MSGCAT"] = env.Detect("msgcat") + env["MSGCATCOM"] = "$MSGCAT $MSGCAT_FLAGS --output-file=$TARGET $SOURCES" + + builder = Builder( + action = MsgcatAction, + suffix = '.pot', + src_suffix = '.pot', + single_source = False) + + env.Append(BUILDERS = {'Msgcat': builder}) + diff -Nru gpick-0.2.4/tools/gpick.py gpick-0.2.5/tools/gpick.py --- gpick-0.2.4/tools/gpick.py 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/tools/gpick.py 2013-01-05 15:43:06.000000000 +0000 @@ -11,6 +11,8 @@ from lemon import * from flex import * +from gettext import * +from resource_template import * from SCons.Script import * from SCons.Util import * @@ -33,11 +35,20 @@ files.append (fullname) def CheckPKG(context, name): - context.Message( 'Checking for %s... ' % name ) + context.Message('Checking for library %s... ' % name) ret = context.TryAction('pkg-config --exists "%s"' % name)[0] - context.Result( ret ) + context.Result(ret) return ret +def CheckProgram(context, env, name, member_name): + context.Message('Checking for program %s... ' % name) + if env[member_name]: + context.Result(True) + return True + else: + context.Result(False) + return False + class GpickLibrary(NodeList): include_dirs = [] @@ -48,6 +59,8 @@ def AddCustomBuilders(self): addLemonBuilder(self) addFlexBuilder(self) + addGettextBuilder(self) + addResourceTemplateBuilder(self) def DefineLibrary(self, library_name, library): self.extern_libs[library_name] = library @@ -63,9 +76,24 @@ return lib - def ConfirmLibs(self, conf, libs): + def ConfirmPrograms(self, conf, programs): + conf.AddTests({'CheckProgram': CheckProgram}) - conf.AddTests({ 'CheckPKG' : CheckPKG }) + for evar, args in programs.iteritems(): + found = False + for name, member_name in args['checks'].iteritems(): + if conf.CheckProgram(self, name, member_name): + found = True; + break + if not found: + if 'required' in args: + if not args['required']==False: + self.Exit(1) + else: + self.Exit(1) + + def ConfirmLibs(self, conf, libs): + conf.AddTests({'CheckPKG': CheckPKG}) for evar, args in libs.iteritems(): found = False @@ -87,8 +115,21 @@ self.AddPostAction(i, Chmod(i, perm)) return dir + def InstallPermAutoDir(self, dir, relative_dir, source, perm): + for f in Flatten(source): + path = dir + if str(f.get_dir()).startswith(relative_dir): + path = os.path.join(path, str(f.get_dir())[len(relative_dir):]) + else: + path = os.path.join(path, str(f.get_dir())) + obj = self.Install(path, f) + for i in obj: + self.AddPostAction(i, Chmod(i, perm)) + return dir + InstallProgram = lambda self, dir, source: GpickEnvironment.InstallPerm(self, dir, source, 0755) InstallData = lambda self, dir, source: GpickEnvironment.InstallPerm(self, dir, source, 0644) + InstallDataAutoDir = lambda self, dir, relative_dir, source: GpickEnvironment.InstallPermAutoDir(self, dir, relative_dir, source, 0644) def GetSourceFiles(self, dir_exclude_pattern, file_exclude_pattern): dir_exclude_prog = re.compile(dir_exclude_pattern) @@ -99,15 +140,11 @@ def GetVersionInfo(self): try: - svn_revision = subprocess.Popen(['svnversion', '-n', self.GetLaunchDir()], shell=False, stdout=subprocess.PIPE).communicate()[0] - svn_revision = str(svn_revision) - if svn_revision=="exported": - svn_revision="" - svn_revision=svn_revision.replace(':','.') - svn_revision=svn_revision.rstrip('PSM') - revision=svn_revision; - except OSError, e: - revision = '' + revision = subprocess.Popen(['hg', 'log', '--template', '"{rev}:{node}\\n"', '-r', 'tip', self.GetLaunchDir()], shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] + match = re.search('([\d]+):([\d\w]+)', str(revision)) + revision = match.group(2) + except: + revision = 'not under version control system' self.Replace(GPICK_BUILD_REVISION = revision, GPICK_BUILD_DATE = time.strftime ("%Y-%m-%d"), diff -Nru gpick-0.2.4/tools/resource_template.py gpick-0.2.5/tools/resource_template.py --- gpick-0.2.4/tools/resource_template.py 1970-01-01 00:00:00.000000000 +0000 +++ gpick-0.2.5/tools/resource_template.py 2013-02-28 17:43:59.000000000 +0000 @@ -0,0 +1,28 @@ +from SCons.Script import * +from SCons.Tool.install import copyFunc + +import re + +def addResourceTemplateBuilder(env): + + def buildResourceFile(target, source, env): + source_dest = SCons.Util.splitext(str(target[0]))[0] + ".rc" + wfile = open(source_dest,"w") + data = open(str(File(source[0]).srcnode())).read() + for key, var in env['RESOURCE_TEMPLATE_VARS'].iteritems(): + data = re.sub("%" + key + "%", var, data) + wfile.write(data) + wfile.close() + return 0 + + def buildResourceFileString(target, source, env): + return "Preparing resource file %s" % os.path.basename(str(target[0])) + + builder = Builder( + action = SCons.Action.Action(buildResourceFile, buildResourceFileString), + suffix = '.rc', + src_suffix = '.rct', + ) + + env.Append(BUILDERS = {'ResourceTemplate': builder}) + diff -Nru gpick-0.2.4/version.py gpick-0.2.5/version.py --- gpick-0.2.4/version.py 2011-06-12 22:56:13.000000000 +0000 +++ gpick-0.2.5/version.py 2013-02-28 17:43:59.000000000 +0000 @@ -1 +1 @@ -GPICK_BUILD_VERSION='0.2.4' +GPICK_BUILD_VERSION='0.2.5'