Commit 6239dddd authored by Kevin Cozens's avatar Kevin Cozens Committed by Kevin Cozens

With this commit we finally say goodbye to SIOD. This large set of changes

2006-10-15  Kevin Cozens  <kcozens@cvs.gnome.org>

	With this commit we finally say goodbye to SIOD. This large set of
	changes updates the Script-Fu plug-in to use the TinyScheme Scheme
	interpreter. These changes originated with changes originally made
	to Script-Fu which created Tiny-Fu (aka. the gimp-tiny-fu module).

	* plug-ins/script-fu/Makefile.am
	* plug-ins/script-fu/script-fu-console.c
	* plug-ins/script-fu/script-fu-interface.c
	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/script-fu-scripts.h
	* plug-ins/script-fu/script-fu-server.c
	* plug-ins/script-fu/script-fu-text-console.c
	* plug-ins/script-fu/script-fu.c: Updated with the changes made to
	these files as part of the work on the Tiny-Fu project.

	* plug-ins/script-fu/scheme-wrapper.c
	* plug-ins/script-fu/scheme-wrapper.h: Renamed from siod-wrapper.[ch]
	and updated based on differences to ts-wrapper.[ch] from gimp-tiny-fu.

	* plug-ins/script-fu/ftx/*
	* plug-ins/script-fu/re/*
	* plug-ins/script-fu/tinyscheme/*
	* plug-ins/script-fu/scripts/script-fu.init
	* plug-ins/script-fu/scripts/script-fu-compat.init
	* plug-ins/script-fu/scripts/contactsheet.scm
	* plug-ins/script-fu/scripts/script-fu-set-cmap.scm
	* plug-ins/script-fu/scripts/script-fu-util-setpt.scm
	* plug-ins/script-fu/scripts/ts-helloworld.scm: Added all of these
	files and directories from Tiny-Fu. Updated the Makefile.am files
	of ftx, re, and tinyscheme now they are in the GIMP source tree.

	* plug-ins/script-fu/scripts/*.scm: All scripts have been updated as
	needed to ensure they will work with the TinyScheme interpreter. Most
	of the files have been reformatted making it easier to see the syntax
	of Scheme and making them easier to read.

	* plug-ins/script-fu/scripts/Makefile.am: Updated script file lists.

	* plug-ins/script-fu/siod-wrapper.c
	* plug-ins/script-fu/siod-wrapper.h
	* plug-ins/script-fu/siod/*: Removed obsolete files.

	* configure.in: Updated list of files in AC_CONFIG_FILES. Changed
	--disable-script-fu to --without-script-fu which it should have
	been when originally added.

	* INSTALL: Updated to show change to --without-script-fu.
parent 9314c3ea
2006-10-15 Kevin Cozens <kcozens@cvs.gnome.org>
With this commit we finally say goodbye to SIOD. This large set of
changes updates the Script-Fu plug-in to use the TinyScheme Scheme
interpreter. These changes originated with changes originally made
to Script-Fu which created Tiny-Fu (aka. the gimp-tiny-fu module).
* plug-ins/script-fu/Makefile.am
* plug-ins/script-fu/script-fu-console.c
* plug-ins/script-fu/script-fu-interface.c
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/script-fu-scripts.h
* plug-ins/script-fu/script-fu-server.c
* plug-ins/script-fu/script-fu-text-console.c
* plug-ins/script-fu/script-fu.c: Updated with the changes made to
these files as part of the work on the Tiny-Fu project.
* plug-ins/script-fu/scheme-wrapper.c
* plug-ins/script-fu/scheme-wrapper.h: Renamed from siod-wrapper.[ch]
and updated based on differences to ts-wrapper.[ch] from gimp-tiny-fu.
* plug-ins/script-fu/ftx/*
* plug-ins/script-fu/re/*
* plug-ins/script-fu/tinyscheme/*
* plug-ins/script-fu/scripts/script-fu.init
* plug-ins/script-fu/scripts/script-fu-compat.init
* plug-ins/script-fu/scripts/contactsheet.scm
* plug-ins/script-fu/scripts/script-fu-set-cmap.scm
* plug-ins/script-fu/scripts/script-fu-util-setpt.scm
* plug-ins/script-fu/scripts/ts-helloworld.scm: Added all of these
files and directories from Tiny-Fu. Updated the Makefile.am files
of ftx, re, and tinyscheme now they are in the GIMP source tree.
* plug-ins/script-fu/scripts/*.scm: All scripts have been updated as
needed to ensure they will work with the TinyScheme interpreter. Most
of the files have been reformatted making it easier to see the syntax
of Scheme and making them easier to read.
* plug-ins/script-fu/scripts/Makefile.am: Updated script file lists.
* plug-ins/script-fu/siod-wrapper.c
* plug-ins/script-fu/siod-wrapper.h
* plug-ins/script-fu/siod/*: Removed obsolete files.
* configure.in: Updated list of files in AC_CONFIG_FILES. Changed
--disable-script-fu to --without-script-fu which it should have
been when originally added.
* INSTALL: Updated to show change to --without-script-fu.
2006-10-15 Michael Natterer <mitch@gimp.org>
* app/file/file-utils.c (file_utils_filename_to_uri): if the
......
......@@ -197,8 +197,8 @@ These are:
--disable-python. If for some reason you don't want to build the
Python based pygimp plug-in, you can use --disable-python.
--disable-script-fu. If for some reason you don't want to build the
Script-Fu plug-in, you can use --disable-script-fu.
--without-script-fu. If for some reason you don't want to build the
Script-Fu plug-in, you can use --without-script-fu.
The `make' command builds several things:
- A bunch of public libraries in the directories starting with 'libgimp'.
......
......@@ -1479,16 +1479,17 @@ AM_CONDITIONAL(BUILD_PYTHON, test "x$enable_python" != xno)
# Check whether script_fu should be built
#########################################
AC_ARG_ENABLE(script-fu,
AC_HELP_STRING([--disable-script-fu],
have_script_fu=yes
AC_ARG_WITH(script-fu,
AC_HELP_STRING([--without-script-fu],
[do not build the script-fu extension]))
if test "x$enable_script_fu" != "xno"; then
enable_script_fu="yes"
if test "x$have_script_fu" = "xyes"; then
have_script_fu="yes"
else
enable_script_fu="no (script-fu extension disabled)"
have_script_fu="no (script-fu extension disabled)"
fi
AM_CONDITIONAL(BUILD_SCRIPT_FU, test "x$enable_script_fu" == "xyes")
AM_CONDITIONAL(BUILD_SCRIPT_FU, test "x$have_script_fu" == "xyes")
###########################################################
......@@ -1737,7 +1738,9 @@ app/widgets/Makefile
app/xcf/Makefile
plug-ins/Makefile
plug-ins/script-fu/Makefile
plug-ins/script-fu/siod/Makefile
plug-ins/script-fu/ftx/Makefile
plug-ins/script-fu/re/Makefile
plug-ins/script-fu/tinyscheme/Makefile
plug-ins/script-fu/scripts/Makefile
plug-ins/script-fu/scripts/images/Makefile
plug-ins/xjt/Makefile
......@@ -1878,7 +1881,8 @@ Optional Plug-Ins:
PNG: $have_libpng
Print: $enable_print
PSP: $have_zlib
Script-Fu: $enable_script_fu
Python: $enable_python
Script-Fu: $have_script_fu
SVG: $have_librsvg
TIFF: $have_libtiff
TWAIN (MacOS X): $mac_twain_ok
......
......@@ -8,14 +8,27 @@ libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
libtinyscheme=tinyscheme/libtinyscheme.a
libftx=ftx/libftx.a
libre=re/libre.a
if OS_WIN32
mwindows = -mwindows
WINSOCK_LIBS = -lws2_32
endif
AM_CFLAGS = \
-DUSE_INTERFACE=1 \
-DUSE_STRCASECMP=1 \
-DUSE_STRLWR=1 \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
-I$(includedir)
AM_LDFLAGS = $(mwindows)
SUBDIRS = siod scripts
SUBDIRS = tinyscheme ftx re scripts
libexecdir = $(gimpplugindir)/plug-ins
......@@ -36,13 +49,8 @@ script_fu_SOURCES = \
script-fu-server.h \
script-fu-types.h \
script-fu-enums.h \
siod-wrapper.c \
siod-wrapper.h
INCLUDES = \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
-I$(includedir)
scheme-wrapper.c \
scheme-wrapper.h
if HAVE_GLIBC_REGEX
REGEXREPL =
......@@ -58,7 +66,9 @@ LDADD = \
$(libgimp) \
$(libgimpcolor) \
$(libgimpbase) \
siod/libsiod.a \
$(libtinyscheme) \
$(libftx) \
$(libre) \
$(REGEXREPL) \
$(GTK_LIBS) \
$(SOCKET_LIBS) \
......
......@@ -2,8 +2,8 @@
AM_CFLAGS = \
-DUSE_INTERFACE=1 \
-I$(top_srcdir) \
$(GIMP_CFLAGS)
-I.. \
$(GLIB_CFLAGS)
noinst_LIBRARIES = libftx.a
......
......@@ -2,8 +2,8 @@
AM_CFLAGS = \
-DUSE_INTERFACE=1 \
-I$(top_srcdir) \
$(GIMP_CFLAGS)
-I.. \
$(GLIB_CFLAGS)
noinst_LIBRARIES = libre.a
......
......@@ -16,6 +16,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#if 0
#define DEBUG_MARSHALL 0 /* No need to define this until you need it */
#define DEBUG_SCRIPTS 0
#endif
#include "config.h"
#include <string.h> /* memcpy, strcpy, strlen */
......@@ -24,7 +29,12 @@
#include "libgimp/gimp.h"
#include "siod/siod.h"
#include "tinyscheme/scheme-private.h"
#if USE_DL
#include "tinyscheme/dynload.h"
#endif
#include "ftx/ftx.h"
#include "re/re.h"
#include "script-fu-types.h"
......@@ -33,108 +43,253 @@
#include "script-fu-scripts.h"
#include "script-fu-server.h"
#include "siod-wrapper.h"
#include "scheme-wrapper.h"
static int siod_console_mode;
static int ts_console_mode;
/* global variables declared by the scheme interpreter */
extern FILE * siod_output;
extern int siod_verbose_level;
extern gchar siod_err_msg[];
extern void * siod_output_routine;
extern LISP repl_return_val;
extern void *ts_output_routine;
#undef cons
/* defined in regex.c. not exported by regex.h */
extern void init_regex (void);
struct
named_constant {
const char *name;
int value;
};
struct named_constant
script_constants[] = {
/* Useful misc stuff */
{ "TRUE", TRUE },
{ "FALSE", FALSE },
/* Tiny-Fu types */
{ "SF-IMAGE", SF_IMAGE },
{ "SF-DRAWABLE", SF_DRAWABLE },
{ "SF-LAYER", SF_LAYER },
{ "SF-CHANNEL", SF_CHANNEL },
{ "SF-COLOR", SF_COLOR },
{ "SF-TOGGLE", SF_TOGGLE },
{ "SF-VALUE", SF_VALUE },
{ "SF-STRING", SF_STRING },
{ "SF-FILENAME", SF_FILENAME },
{ "SF-DIRNAME", SF_DIRNAME },
{ "SF-ADJUSTMENT", SF_ADJUSTMENT },
{ "SF-FONT", SF_FONT },
{ "SF-PATTERN", SF_PATTERN },
{ "SF-BRUSH", SF_BRUSH },
{ "SF-GRADIENT", SF_GRADIENT },
{ "SF-OPTION", SF_OPTION },
{ "SF-PALETTE", SF_PALETTE },
{ "SF-TEXT", SF_TEXT },
{ "SF-ENUM", SF_ENUM },
/* defined in siodp.h but this file cannot be imported... */
extern long nlength (LISP obj);
extern LISP leval_define (LISP args, LISP env);
/* for SF_ADJUSTMENT */
{ "SF-SLIDER", SF_SLIDER },
{ "SF-SPINNER", SF_SPINNER },
{ NULL, 0 }
};
/* The following constants are deprecated. They are */
/* included to keep backwards compatability with */
/* older scripts used with version 2.0 of GIMP. */
struct named_constant
old_constants[] = {
{ "NORMAL", GIMP_NORMAL_MODE },
{ "DISSOLVE", GIMP_DISSOLVE_MODE },
{ "BEHIND", GIMP_BEHIND_MODE },
{ "MULTIPLY", GIMP_MULTIPLY_MODE },
{ "SCREEN", GIMP_SCREEN_MODE },
{ "OVERLAY", GIMP_OVERLAY_MODE },
{ "DIFFERENCE", GIMP_DIFFERENCE_MODE },
{ "ADDITION", GIMP_ADDITION_MODE },
{ "SUBTRACT", GIMP_SUBTRACT_MODE },
{ "DARKEN-ONLY", GIMP_DARKEN_ONLY_MODE },
{ "LIGHTEN-ONLY", GIMP_LIGHTEN_ONLY_MODE },
{ "HUE", GIMP_HUE_MODE },
{ "SATURATION", GIMP_SATURATION_MODE },
{ "COLOR", GIMP_COLOR_MODE },
{ "VALUE", GIMP_VALUE_MODE },
{ "DIVIDE", GIMP_DIVIDE_MODE },
{ "BLUR", GIMP_BLUR_CONVOLVE },
{ "SHARPEN", GIMP_SHARPEN_CONVOLVE },
{ "WHITE-MASK", GIMP_ADD_WHITE_MASK },
{ "BLACK-MASK", GIMP_ADD_BLACK_MASK },
{ "ALPHA-MASK", GIMP_ADD_ALPHA_MASK },
{ "ADD", GIMP_CHANNEL_OP_ADD },
{ "SUB", GIMP_CHANNEL_OP_SUBTRACT },
{ "REPLACE", GIMP_CHANNEL_OP_REPLACE },
{ "INTERSECT", GIMP_CHANNEL_OP_INTERSECT },
{ "FG-BG-RGB", GIMP_FG_BG_RGB_MODE },
{ "FG-BG-HSV", GIMP_FG_BG_HSV_MODE },
{ "FG-TRANS", GIMP_FG_TRANSPARENT_MODE },
{ "CUSTOM", GIMP_CUSTOM_MODE },
{ "FG-IMAGE-FILL", GIMP_FOREGROUND_FILL },
{ "BG-IMAGE-FILL", GIMP_BACKGROUND_FILL },
{ "WHITE-IMAGE-FILL", GIMP_WHITE_FILL },
{ "TRANS-IMAGE-FILL", GIMP_TRANSPARENT_FILL },
{ "APPLY", GIMP_MASK_APPLY },
{ "DISCARD", GIMP_MASK_DISCARD },
{ "HARD", GIMP_BRUSH_HARD },
{ "SOFT", GIMP_BRUSH_SOFT },
{ "CONTINUOUS", GIMP_PAINT_CONSTANT },
{ "INCREMENTAL", GIMP_PAINT_INCREMENTAL },
{ "HORIZONTAL", GIMP_ORIENTATION_HORIZONTAL },
{ "VERTICAL", GIMP_ORIENTATION_VERTICAL },
{ "UNKNOWN", GIMP_ORIENTATION_UNKNOWN },
{ "LINEAR", GIMP_GRADIENT_LINEAR },
{ "BILINEAR", GIMP_GRADIENT_BILINEAR },
{ "RADIAL", GIMP_GRADIENT_RADIAL },
{ "SQUARE", GIMP_GRADIENT_SQUARE },
{ "CONICAL-SYMMETRIC", GIMP_GRADIENT_CONICAL_SYMMETRIC },
{ "CONICAL-ASYMMETRIC", GIMP_GRADIENT_CONICAL_ASYMMETRIC },
{ "SHAPEBURST-ANGULAR", GIMP_GRADIENT_SHAPEBURST_ANGULAR },
{ "SHAPEBURST-SPHERICAL", GIMP_GRADIENT_SHAPEBURST_SPHERICAL },
{ "SHAPEBURST-DIMPLED", GIMP_GRADIENT_SHAPEBURST_DIMPLED },
{ "SPIRAL-CLOCKWISE", GIMP_GRADIENT_SPIRAL_CLOCKWISE },
{ "SPIRAL-ANTICLOCKWISE", GIMP_GRADIENT_SPIRAL_ANTICLOCKWISE },
{ "VALUE-LUT", GIMP_HISTOGRAM_VALUE },
{ "RED-LUT", GIMP_HISTOGRAM_RED },
{ "GREEN-LUT", GIMP_HISTOGRAM_GREEN },
{ "BLUE-LUT", GIMP_HISTOGRAM_BLUE },
{ "ALPHA-LUT", GIMP_HISTOGRAM_ALPHA },
{ "MIN-IMAGE-SIZE", GIMP_MIN_IMAGE_SIZE },
{ "MAX-IMAGE-SIZE", GIMP_MAX_IMAGE_SIZE },
{ "MIN-RESOLUTION", GIMP_MIN_RESOLUTION },
{ "MAX-RESOLUTION", GIMP_MAX_RESOLUTION },
{ NULL, 0 }
};
static scheme sc;
static FILE *ts_output;
static int ts_verbose_level;
/* wrapper functions */
FILE *
siod_get_output_file (void)
ts_get_output_file (void)
{
return siod_output;
return ts_output;
}
void
siod_set_output_file (FILE *file)
ts_set_output_file (FILE *file)
{
siod_output = file;
scheme_set_output_port_file (&sc, file);
ts_output = file;
}
void
siod_set_console_mode (int flag)
ts_set_console_mode (int flag)
{
siod_console_mode = flag;
ts_console_mode = flag;
}
int
siod_get_verbose_level (void)
ts_get_verbose_level (void)
{
return siod_verbose_level;
return ts_verbose_level;
}
void
ts_set_verbose_level (gint verbose_level)
{
ts_verbose_level = verbose_level;
}
void
siod_set_verbose_level (gint verbose_level)
ts_set_print_flag (gint print_flag)
{
siod_verbose_level = verbose_level;
sc.print_output = print_flag;
}
void
siod_print_welcome (void)
ts_print_welcome (void)
{
print_welcome ();
if (ts_verbose_level >= 2)
{
fprintf (ts_output, "Welcome to TinyScheme, Version 1.38\n");
fprintf (ts_output, "Copyright (c) Dimitrios Souflis\n");
}
}
gint
siod_interpret_string (const gchar *expr)
ts_interpret_string (const gchar *expr)
{
return repl_c_string ((char *) expr, 0, 0, 1);
port *pt=sc.outport->_object._port;
memset(sc.linebuff, '\0', LINESIZE);
pt->rep.string.curr = sc.linebuff;
/* Somewhere 'past_the_end' gets altered so it needs to be reset ~~~~~ */
pt->rep.string.past_the_end = &sc.linebuff[LINESIZE-1];
#if DEBUG_SCRIPTS
sc.print_output = 1;
sc.tracing = 1;
#endif
sc.vptr->load_string (&sc, (char *)expr);
return sc.retcode;
}
const gchar *
siod_get_error_msg (void)
const char *
ts_get_error_msg (void)
{
return siod_err_msg;
return sc.linebuff;
}
const gchar *
siod_get_success_msg (void)
ts_get_success_msg (void)
{
if (TYPEP (repl_return_val, tc_string))
return get_c_string (repl_return_val);
#if 0 /* ~~~~~ */
if (sc.vptr->is_string (repl_return_val))
return sc.vptr->string_value (repl_return_val);
else
#else
if (sc.linebuff[0])
return sc.linebuff;
else
#endif
return "Success";
}
void
siod_output_string (FILE *fp,
const gchar *format,
...)
ts_output_string (FILE *fp, char *string, int len)
{
gchar *buf;
va_list args;
gchar *buff;
va_start (args, format);
buf = g_strdup_vprintf (format, args);
va_end (args);
g_return_if_fail (len >= 0);
if (siod_console_mode && fp == stdout)
{
script_fu_output_to_console (buf);
}
else
{
fprintf (fp, buf);
fflush (fp);
}
if (len == 0)
return;
g_free (buf);
if (ts_console_mode && fp == stdout)
{
len = g_utf8_offset_to_pointer(string, (long)len) - string;
buff = g_strndup (string, len);
if (buff == NULL)
return; /* Should "No memory" be output here? */
script_fu_output_to_console (buff);
g_free (buff);
}
}
......@@ -144,45 +299,55 @@ static void init_procedures (void);
static gboolean register_scripts = FALSE;
void
siod_init (gboolean local_register_scripts)
tinyscheme_init (gboolean local_register_scripts)
{
gchar * siod_argv[] =
{
"siod",
"-h100000:10",
"-g0",
"-o1000",
"-s200000",
"-n2048",
"-v0",
};
char buff[80];
FILE *fin;
register_scripts = local_register_scripts;
siod_output_routine = siod_output_string;
ts_output_routine = ts_output_string;
/* init the interpreter */
process_cla (G_N_ELEMENTS (siod_argv), siod_argv, 1);
if (!scheme_init (&sc))
{
g_message ("Could not initialize TinyScheme!\n");
return;
}
init_storage ();
init_subrs ();
init_trace ();
init_regex ();
scheme_set_input_port_file (&sc, stdin);
ts_set_output_file (stdout);
/* Initialize the TinyScheme extensions */
init_ftx(&sc);
init_re(&sc);
/* register in the interpreter the gimp functions and types. */
init_procedures ();
init_constants ();
init_procedures ();
g_snprintf (buff, sizeof (buff),
"%s%s", gimp_data_directory (), "/scripts/script-fu.init");
fin = fopen (buff, "r");
if (fin == NULL)
fprintf (stderr, "Unable to read initialization file\n");
else
{
scheme_load_file (&sc, fin);
fclose (fin);
}
}
void
tinyscheme_deinit (void)
{
scheme_deinit (&sc);
}
static void convert_string (gchar *str);
static gint sputs_fcn (gchar *st,
gpointer dest);
static LISP lprin1s (LISP exp,
gchar *dest);
static LISP marshall_proc_db_call (LISP a);
static LISP script_fu_register_call (LISP a);
static LISP script_fu_menu_register_call (LISP a);
static LISP script_fu_quit_call (LISP a);
static void convert_string (gchar *str);
static pointer marshall_proc_db_call (scheme *sc, pointer a);
static pointer script_fu_register_call (scheme *sc, pointer a);
static pointer script_fu_menu_register_call (scheme *sc, pointer a);
static pointer script_fu_quit_call (scheme *sc, pointer a);
/*
......@@ -191,88 +356,6 @@ static LISP script_fu_quit_call (LISP a);
*/
static void
init_procedures (void)
{
gchar **proc_list;
gchar *proc_blurb;
gchar *proc_help;
gchar *proc_author;
gchar *proc_copyright;
gchar *proc_date;
GimpPDBProcType proc_type;
gint nparams;
gint nreturn_vals;
GimpParamDef *params;
GimpParamDef *return_vals;
gint num_procs;
gint i;
/* register the database execution procedure */
init_lsubr ("gimp-proc-db-call", marshall_proc_db_call);
init_lsubr ("script-fu-register", script_fu_register_call);
init_lsubr ("script-fu-menu-register", script_fu_menu_register_call);
init_lsubr ("script-fu-quit", script_fu_quit_call);
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
/* Register each procedure as a scheme func */
for (i = 0; i < num_procs; i++)
{
/* lookup the procedure */
if (gimp_procedural_db_proc_info (proc_list[i],
&proc_blurb,
&proc_help,
&proc_author,
&proc_copyright,
&proc_date,
&proc_type,