mirror of https://github.com/GNOME/gimp.git
changed destdir for app-side PDB wrappers to app/pdb
2001-01-21 Sven Neumann <sven@gimp.org> * tools/pdbgen/app.pl: changed destdir for app-side PDB wrappers to app/pdb * app/Makefile.am: don't create libgimpim.a in app. * configure.in * app/pdb/Makefile.am * app/pdb/internal_procs.[ch] * app/pdb/procedural_db.[ch] * app/pdb/*_cmds.c: moved PDB functions into their own subdirectory. * app/internal_procs.[ch] * app/procedural_db.[ch] * app/*_cmds.c: removed here * app/app_procs.c * app/batch.c * app/bezier_select.c * app/brush_select.c * app/bucket_fill.c * app/colormap_dialog.c * app/fileops.c * app/gimage.c * app/gimage_mask.c * app/gimphelp.c * app/gradient_select.c * app/info_window.c * app/invert.c * app/lc_dialog.c * app/menus.c * app/nav_window.c * app/palette_import.c * app/paths_dialog.c * app/pattern_select.c * app/plug_in.h * app/text_tool.c * app/xcf.c * po/POTFILES.in: changed accordingly
This commit is contained in:
parent
6f06ed7478
commit
6a31b131d1
41
ChangeLog
41
ChangeLog
|
@ -1,3 +1,44 @@
|
|||
2001-01-21 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* tools/pdbgen/app.pl: changed destdir for app-side PDB wrappers to
|
||||
app/pdb
|
||||
|
||||
* app/Makefile.am: don't create libgimpim.a in app.
|
||||
|
||||
* configure.in
|
||||
* app/pdb/Makefile.am
|
||||
* app/pdb/internal_procs.[ch]
|
||||
* app/pdb/procedural_db.[ch]
|
||||
* app/pdb/*_cmds.c: moved PDB functions into their own subdirectory.
|
||||
|
||||
* app/internal_procs.[ch]
|
||||
* app/procedural_db.[ch]
|
||||
* app/*_cmds.c: removed here
|
||||
|
||||
* app/app_procs.c
|
||||
* app/batch.c
|
||||
* app/bezier_select.c
|
||||
* app/brush_select.c
|
||||
* app/bucket_fill.c
|
||||
* app/colormap_dialog.c
|
||||
* app/fileops.c
|
||||
* app/gimage.c
|
||||
* app/gimage_mask.c
|
||||
* app/gimphelp.c
|
||||
* app/gradient_select.c
|
||||
* app/info_window.c
|
||||
* app/invert.c
|
||||
* app/lc_dialog.c
|
||||
* app/menus.c
|
||||
* app/nav_window.c
|
||||
* app/palette_import.c
|
||||
* app/paths_dialog.c
|
||||
* app/pattern_select.c
|
||||
* app/plug_in.h
|
||||
* app/text_tool.c
|
||||
* app/xcf.c
|
||||
* po/POTFILES.in: changed accordingly
|
||||
|
||||
2001-01-21 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/Makefile.am
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = pdb
|
||||
|
||||
scriptdata =
|
||||
|
||||
if HAVE_GLIBC_REGEX
|
||||
|
@ -9,21 +11,6 @@ regex_sources = regexrepl.c regexrepl.h
|
|||
endif
|
||||
|
||||
bin_PROGRAMS = gimp
|
||||
noinst_LIBRARIES = libgimpim.a
|
||||
|
||||
libgimpim_a_SOURCES = \
|
||||
gimpdrawable.c \
|
||||
gimpdrawable.h \
|
||||
gimpimage.c \
|
||||
gimpimage.h \
|
||||
gimpmarshal.c \
|
||||
gimpmarshal.h \
|
||||
gimpobject.c \
|
||||
gimpobject.h \
|
||||
gimppreviewcache.h \
|
||||
gimppreviewcache.c \
|
||||
gimpset.c \
|
||||
gimpset.h
|
||||
|
||||
gimp_SOURCES = \
|
||||
about_dialog.c \
|
||||
|
@ -58,27 +45,22 @@ gimp_SOURCES = \
|
|||
brush_scale.h \
|
||||
brush_select.c \
|
||||
brush_select.h \
|
||||
brush_select_cmds.c \
|
||||
brushes_cmds.c \
|
||||
bucket_fill.c \
|
||||
bucket_fill.h \
|
||||
by_color_select.c \
|
||||
by_color_select.h \
|
||||
channel.c \
|
||||
channel.h \
|
||||
channel_cmds.c \
|
||||
channels_dialog.c \
|
||||
channels_dialog.h \
|
||||
channel_ops.c \
|
||||
channel_ops.h \
|
||||
channel_ops_cmds.c \
|
||||
clone.c \
|
||||
clone.h \
|
||||
color_area.c \
|
||||
color_area.h \
|
||||
color_balance.c \
|
||||
color_balance.h \
|
||||
color_cmds.c \
|
||||
color_notebook.c \
|
||||
color_notebook.h \
|
||||
color_panel.c \
|
||||
|
@ -99,7 +81,6 @@ gimp_SOURCES = \
|
|||
context_manager.h \
|
||||
convert.c \
|
||||
convert.h \
|
||||
convert_cmds.c \
|
||||
convolve.c \
|
||||
convolve.h \
|
||||
crop.c \
|
||||
|
@ -119,7 +100,6 @@ gimp_SOURCES = \
|
|||
dialog_handler.h \
|
||||
disp_callbacks.c \
|
||||
disp_callbacks.h \
|
||||
display_cmds.c \
|
||||
docindex.c \
|
||||
docindex.h \
|
||||
dodgeburn.c \
|
||||
|
@ -129,8 +109,6 @@ gimp_SOURCES = \
|
|||
drawable.c \
|
||||
drawable.h \
|
||||
drawable_pvt.h \
|
||||
drawable_cmds.c \
|
||||
edit_cmds.c \
|
||||
edit_selection.c \
|
||||
edit_selection.h \
|
||||
ellipse_select.c \
|
||||
|
@ -146,12 +124,10 @@ gimp_SOURCES = \
|
|||
fileops.c \
|
||||
fileops.h \
|
||||
fileopsP.h \
|
||||
fileops_cmds.c \
|
||||
flip_tool.c \
|
||||
flip_tool.h \
|
||||
floating_sel.c \
|
||||
floating_sel.h \
|
||||
floating_sel_cmds.c \
|
||||
file_new_dialog.c \
|
||||
file_new_dialog.h \
|
||||
free_select.c \
|
||||
|
@ -183,23 +159,34 @@ gimp_SOURCES = \
|
|||
gimpcontextpreview.h \
|
||||
gimpdnd.c \
|
||||
gimpdnd.h \
|
||||
gimpdrawable.c \
|
||||
gimpdrawable.h \
|
||||
gimphelp.c \
|
||||
gimphelp.h \
|
||||
gimphistogram.c \
|
||||
gimphistogram.h \
|
||||
gimpimage.c \
|
||||
gimpimage.h \
|
||||
gimplist.c \
|
||||
gimplist.h \
|
||||
gimplut.c \
|
||||
gimplut.h \
|
||||
gimpmarshal.c \
|
||||
gimpmarshal.h \
|
||||
gimpobject.c \
|
||||
gimpobject.h \
|
||||
gimppalette.c \
|
||||
gimppalette.h \
|
||||
gimpparasite.c \
|
||||
gimpparasite.h \
|
||||
gimppreviewcache.h \
|
||||
gimppreviewcache.c \
|
||||
gimpprogress.c \
|
||||
gimpprogress.h \
|
||||
gimprc.c \
|
||||
gimprc.h \
|
||||
gimprc_cmds.c \
|
||||
gimpset.c \
|
||||
gimpset.h \
|
||||
gimpui.c \
|
||||
gimpui.h \
|
||||
gimpunit.c \
|
||||
|
@ -210,26 +197,21 @@ gimp_SOURCES = \
|
|||
gradient_header.h \
|
||||
gradient_select.h \
|
||||
gradient_select.c \
|
||||
gradient_select_cmds.c \
|
||||
gradient.h \
|
||||
gradients_cmds.c \
|
||||
gtkwrapbox.c \
|
||||
gtkwrapbox.h \
|
||||
gtkhwrapbox.c \
|
||||
gtkhwrapbox.h \
|
||||
gtkvwrapbox.c \
|
||||
gtkvwrapbox.h \
|
||||
guides_cmds.c \
|
||||
gximage.c \
|
||||
gximage.h \
|
||||
help_cmds.c \
|
||||
histogramwidget.c \
|
||||
histogramwidget.h \
|
||||
histogram_tool.c \
|
||||
histogram_tool.h \
|
||||
hue_saturation.c \
|
||||
hue_saturation.h \
|
||||
image_cmds.c \
|
||||
image_map.c \
|
||||
image_map.h \
|
||||
image_new.c \
|
||||
|
@ -246,15 +228,12 @@ gimp_SOURCES = \
|
|||
ink.h \
|
||||
interface.c \
|
||||
interface.h \
|
||||
internal_procs.c \
|
||||
internal_procs.h \
|
||||
invert.c \
|
||||
invert.h \
|
||||
iscissors.c \
|
||||
iscissors.h \
|
||||
layer.c \
|
||||
layer.h \
|
||||
layer_cmds.c \
|
||||
layer_select.c \
|
||||
layer_select.h \
|
||||
layers_dialog.c \
|
||||
|
@ -275,8 +254,6 @@ gimp_SOURCES = \
|
|||
measure.h \
|
||||
menus.c \
|
||||
menus.h \
|
||||
message_cmds.c \
|
||||
misc_cmds.c \
|
||||
module_db.c \
|
||||
module_db.h \
|
||||
move.c \
|
||||
|
@ -289,7 +266,6 @@ gimp_SOURCES = \
|
|||
palette.h \
|
||||
palette_import.c \
|
||||
palette_import.h \
|
||||
palette_cmds.c \
|
||||
palette_select.c \
|
||||
palette_select.h \
|
||||
paletteP.h \
|
||||
|
@ -301,24 +277,20 @@ gimp_SOURCES = \
|
|||
paint_options.h \
|
||||
paintbrush.c \
|
||||
paintbrush.h \
|
||||
parasite_cmds.c \
|
||||
parasitelist.c \
|
||||
parasitelist.h \
|
||||
path.c \
|
||||
path.h \
|
||||
pathP.h \
|
||||
path_transform.h \
|
||||
paths_cmds.c \
|
||||
paths_dialog.c \
|
||||
paths_dialog.h \
|
||||
paths_dialogP.h \
|
||||
pattern_header.h \
|
||||
pattern_select.c \
|
||||
pattern_select.h \
|
||||
pattern_select_cmds.c \
|
||||
patterns.c \
|
||||
patterns.h \
|
||||
patterns_cmds.c \
|
||||
pencil.c \
|
||||
pencil.h \
|
||||
perspective_tool.c \
|
||||
|
@ -331,14 +303,10 @@ gimp_SOURCES = \
|
|||
pixmaps2.h \
|
||||
plug_in.c \
|
||||
plug_in.h \
|
||||
plug_in_cmds.c \
|
||||
posterize.c \
|
||||
posterize.h \
|
||||
preferences_dialog.c \
|
||||
preferences_dialog.h \
|
||||
procedural_db.c \
|
||||
procedural_db.h \
|
||||
procedural_db_cmds.c \
|
||||
qmask.c \
|
||||
qmask.h \
|
||||
rect_select.c \
|
||||
|
@ -360,7 +328,6 @@ gimp_SOURCES = \
|
|||
scroll.h \
|
||||
selection.c \
|
||||
selection.h \
|
||||
selection_cmds.c \
|
||||
selection_options.h \
|
||||
session.h \
|
||||
session.c \
|
||||
|
@ -372,7 +339,6 @@ gimp_SOURCES = \
|
|||
temp_buf.h \
|
||||
text_tool.c \
|
||||
text_tool.h \
|
||||
text_tool_cmds.c \
|
||||
threshold.c \
|
||||
threshold.h \
|
||||
tile.c \
|
||||
|
@ -391,18 +357,15 @@ gimp_SOURCES = \
|
|||
tool_options.h \
|
||||
tools.c \
|
||||
tools.h \
|
||||
tools_cmds.c \
|
||||
transform_core.c \
|
||||
transform_core.h \
|
||||
transform_tool.c \
|
||||
transform_tool.h \
|
||||
undo.c \
|
||||
undo.h \
|
||||
undo_cmds.c \
|
||||
undo_history.c \
|
||||
undo_types.h \
|
||||
unitrc.h \
|
||||
unit_cmds.c \
|
||||
user_install.c \
|
||||
user_install.h \
|
||||
wilber.h \
|
||||
|
@ -436,7 +399,7 @@ INCLUDES = \
|
|||
-I$(includedir)
|
||||
|
||||
gimp_LDADD = \
|
||||
libgimpim.a \
|
||||
pdb/libapppdb.la \
|
||||
$(top_builddir)/libgimp/libgimpi.a \
|
||||
$(GTK_LIBS) \
|
||||
$(GIMP_THREAD_LIBS) \
|
||||
|
|
|
@ -68,7 +68,6 @@
|
|||
#include "hue_saturation.h"
|
||||
#include "image_render.h"
|
||||
#include "interface.h"
|
||||
#include "internal_procs.h"
|
||||
#include "lc_dialog.h"
|
||||
#include "levels.h"
|
||||
#include "menus.h"
|
||||
|
@ -78,7 +77,6 @@
|
|||
#include "patterns.h"
|
||||
#include "plug_in.h"
|
||||
#include "module_db.h"
|
||||
#include "procedural_db.h"
|
||||
#include "session.h"
|
||||
#include "temp_buf.h"
|
||||
#include "tile_swap.h"
|
||||
|
@ -99,6 +97,8 @@
|
|||
#include "color_select.h"
|
||||
#include "gimpparasite.h"
|
||||
|
||||
#include "pdb/internal_procs.h"
|
||||
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpfeatures.h"
|
||||
#include "libgimp/gimpenv.h"
|
||||
|
|
46
app/batch.c
46
app/batch.c
|
@ -34,27 +34,29 @@
|
|||
#include "appenv.h"
|
||||
#include "app_procs.h"
|
||||
#include "batch.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
static void batch_run_cmd (char *cmd);
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
static void batch_run_cmd (gchar *cmd);
|
||||
static void batch_read (gpointer data,
|
||||
gint source,
|
||||
GdkInputCondition condition);
|
||||
static void batch_pserver (int run_mode,
|
||||
int flags,
|
||||
int extra);
|
||||
static void batch_pserver (gint run_mode,
|
||||
gint flags,
|
||||
gint extra);
|
||||
|
||||
|
||||
static ProcRecord *eval_proc;
|
||||
|
||||
void
|
||||
batch_init ()
|
||||
batch_init (void)
|
||||
{
|
||||
extern char **batch_cmds;
|
||||
extern gchar **batch_cmds;
|
||||
|
||||
int read_from_stdin;
|
||||
int i;
|
||||
int perl_server_already_running = 0;
|
||||
gboolean read_from_stdin;
|
||||
gboolean perl_server_already_running = FALSE;
|
||||
gint i;
|
||||
|
||||
eval_proc = procedural_db_lookup ("extension_script_fu_eval");
|
||||
|
||||
|
@ -67,7 +69,7 @@ batch_init ()
|
|||
* perl-server tremendously. This is also fully compatible with 1.0.
|
||||
*/
|
||||
{
|
||||
int run_mode, flags, extra;
|
||||
gint run_mode, flags, extra;
|
||||
|
||||
if (sscanf (batch_cmds[i], "(extension%*[-_]perl%*[-_]server %i %i %i)", &run_mode, &flags, &extra) == 3)
|
||||
{
|
||||
|
@ -108,11 +110,11 @@ batch_init ()
|
|||
|
||||
|
||||
static void
|
||||
batch_run_cmd (char *cmd)
|
||||
batch_run_cmd (gchar *cmd)
|
||||
{
|
||||
Argument *args;
|
||||
Argument *vals;
|
||||
int i;
|
||||
gint i;
|
||||
|
||||
if (g_strcasecmp (cmd, "(gimp-quit 0)") == 0)
|
||||
{
|
||||
|
@ -157,8 +159,10 @@ batch_read (gpointer data,
|
|||
GdkInputCondition condition)
|
||||
{
|
||||
static GString *string;
|
||||
char buf[32], *t;
|
||||
int nread, done;
|
||||
gchar buf[32];
|
||||
gchar *t;
|
||||
gint nread;
|
||||
gboolean done;
|
||||
|
||||
if (condition & GDK_INPUT_READ)
|
||||
{
|
||||
|
@ -208,14 +212,14 @@ batch_read (gpointer data,
|
|||
#endif /* !G_OS_WIN32 */
|
||||
|
||||
static void
|
||||
batch_pserver (int run_mode,
|
||||
int flags,
|
||||
int extra)
|
||||
batch_pserver (gint run_mode,
|
||||
gint flags,
|
||||
gint extra)
|
||||
{
|
||||
ProcRecord *pserver_proc;
|
||||
Argument *args;
|
||||
Argument *vals;
|
||||
int i;
|
||||
Argument *args;
|
||||
Argument *vals;
|
||||
gint i;
|
||||
|
||||
pserver_proc = procedural_db_lookup ("extension_perl_server");
|
||||
|
||||
|
|
|
@ -39,12 +39,13 @@
|
|||
#include "bezier_selectP.h"
|
||||
#include "paths_dialogP.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "selection_options.h"
|
||||
#include "tools.h"
|
||||
#include "tool_options.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -38,10 +38,11 @@
|
|||
#include "gimprc.h"
|
||||
#include "gimpui.h"
|
||||
#include "paint_options.h"
|
||||
#include "procedural_db.h"
|
||||
#include "session.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimphelpui.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -39,13 +39,14 @@
|
|||
#include "paint_options.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
#include "tile_manager.h"
|
||||
#include "tools.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
#include "gimpimage.h"
|
||||
#include "gimpset.h"
|
||||
#include "gimpui.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimphelpui.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include "lut_funcs.h"
|
||||
#include "pixel_processor.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
|
|
@ -35,11 +35,12 @@
|
|||
#include "paint_funcs.h"
|
||||
#include "paint_options.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tile_manager.h"
|
||||
#include "tile_manager_pvt.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -33,10 +33,11 @@
|
|||
#include "gximage.h"
|
||||
#include "info_dialog.h"
|
||||
#include "info_window.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scroll.h"
|
||||
#include "tools.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpunit.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -34,9 +34,10 @@
|
|||
#include "palette.h"
|
||||
#include "palette_import.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -39,10 +39,11 @@
|
|||
#include "gimpui.h"
|
||||
#include "gximage.h"
|
||||
#include "nav_window.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scroll.h"
|
||||
#include "scale.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpunit.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -39,10 +39,11 @@
|
|||
#include "gimpui.h"
|
||||
#include "gximage.h"
|
||||
#include "nav_window.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scroll.h"
|
||||
#include "scale.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpunit.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -80,7 +80,6 @@
|
|||
#include "layer.h"
|
||||
#include "menus.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
#include "temp_buf.h"
|
||||
#include "undo.h"
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "gdisplay.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "palette_import.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
#include "undo.h"
|
||||
|
||||
|
|
|
@ -35,11 +35,12 @@
|
|||
#include "paint_funcs.h"
|
||||
#include "paint_options.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tile_manager.h"
|
||||
#include "tile_manager_pvt.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include "lut_funcs.h"
|
||||
#include "pixel_processor.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "gimprc.h"
|
||||
#include "gimpui.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimphelpui.h"
|
||||
|
|
|
@ -49,9 +49,10 @@
|
|||
#include "gradient_header.h"
|
||||
#include "gradientP.h"
|
||||
#include "gradient_select.h"
|
||||
#include "procedural_db.h"
|
||||
#include "session.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -38,10 +38,11 @@
|
|||
#include "gimprc.h"
|
||||
#include "gimpui.h"
|
||||
#include "paint_options.h"
|
||||
#include "procedural_db.h"
|
||||
#include "session.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimphelpui.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
#include "gimpimage.h"
|
||||
#include "gimpset.h"
|
||||
#include "gimpui.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimphelpui.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
|
|
@ -49,9 +49,10 @@
|
|||
#include "gradient_header.h"
|
||||
#include "gradientP.h"
|
||||
#include "gradient_select.h"
|
||||
#include "procedural_db.h"
|
||||
#include "session.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -33,10 +33,11 @@
|
|||
#include "gximage.h"
|
||||
#include "info_dialog.h"
|
||||
#include "info_window.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scroll.h"
|
||||
#include "tools.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpunit.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "paths_dialog.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "preferences_dialog.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scale.h"
|
||||
#include "tools.h"
|
||||
#include "gdisplay.h"
|
||||
|
|
|
@ -34,9 +34,10 @@
|
|||
#include "palette.h"
|
||||
#include "palette_import.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
#include "paths_dialog.h"
|
||||
#include "paths_dialogP.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
|
|
@ -31,10 +31,11 @@
|
|||
#include "gimpui.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_select.h"
|
||||
#include "procedural_db.h"
|
||||
#include "session.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -33,10 +33,11 @@
|
|||
#include "gximage.h"
|
||||
#include "info_dialog.h"
|
||||
#include "info_window.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scroll.h"
|
||||
#include "tools.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpunit.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include "lut_funcs.h"
|
||||
#include "pixel_processor.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
|
|
@ -35,13 +35,15 @@
|
|||
#include "lc_dialog.h"
|
||||
#include "lc_dialogP.h"
|
||||
#include "layers_dialogP.h"
|
||||
#include "procedural_db.h"
|
||||
#include "session.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
#define MENU_THUMBNAIL_SIZE 24
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "paths_dialog.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "preferences_dialog.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scale.h"
|
||||
#include "tools.h"
|
||||
#include "gdisplay.h"
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "paths_dialog.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "preferences_dialog.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scale.h"
|
||||
#include "tools.h"
|
||||
#include "gdisplay.h"
|
||||
|
|
|
@ -39,10 +39,11 @@
|
|||
#include "gimpui.h"
|
||||
#include "gximage.h"
|
||||
#include "nav_window.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scroll.h"
|
||||
#include "scale.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpunit.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -34,9 +34,10 @@
|
|||
#include "palette.h"
|
||||
#include "palette_import.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
#include "paths_dialog.h"
|
||||
#include "paths_dialogP.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
|
|
@ -31,10 +31,11 @@
|
|||
#include "gimpui.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_select.h"
|
||||
#include "procedural_db.h"
|
||||
#include "session.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
.deps
|
||||
.libs
|
||||
*.lo
|
||||
libapppdb.la
|
|
@ -0,0 +1,58 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
noinst_LTLIBRARIES = libapppdb.la
|
||||
|
||||
libapppdb_la_SOURCES = \
|
||||
internal_procs.c \
|
||||
internal_procs.h \
|
||||
procedural_db.c \
|
||||
procedural_db.h \
|
||||
brush_select_cmds.c \
|
||||
brushes_cmds.c \
|
||||
channel_cmds.c \
|
||||
channel_ops_cmds.c \
|
||||
color_cmds.c \
|
||||
convert_cmds.c \
|
||||
display_cmds.c \
|
||||
drawable_cmds.c \
|
||||
edit_cmds.c \
|
||||
fileops_cmds.c \
|
||||
floating_sel_cmds.c \
|
||||
gimprc_cmds.c \
|
||||
gradient_select_cmds.c \
|
||||
gradients_cmds.c \
|
||||
guides_cmds.c \
|
||||
help_cmds.c \
|
||||
image_cmds.c \
|
||||
layer_cmds.c \
|
||||
message_cmds.c \
|
||||
misc_cmds.c \
|
||||
palette_cmds.c \
|
||||
parasite_cmds.c \
|
||||
paths_cmds.c \
|
||||
pattern_select_cmds.c \
|
||||
patterns_cmds.c \
|
||||
plug_in_cmds.c \
|
||||
procedural_db_cmds.c \
|
||||
selection_cmds.c \
|
||||
text_tool_cmds.c \
|
||||
tools_cmds.c \
|
||||
undo_cmds.c \
|
||||
unit_cmds.c
|
||||
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-DG_LOG_DOMAIN=\"Gimp-PDB\"
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/app \
|
||||
$(GTK_CFLAGS) \
|
||||
-I$(includedir)
|
||||
|
||||
.PHONY: files
|
||||
|
||||
files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
|
@ -0,0 +1,530 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "app_procs.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpparasite.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
GHashTable *procedural_ht = NULL;
|
||||
|
||||
/* Local functions */
|
||||
static guint procedural_db_hash_func (gconstpointer key);
|
||||
static void pdb_id_init (void);
|
||||
|
||||
|
||||
void
|
||||
procedural_db_init (void)
|
||||
{
|
||||
app_init_update_status (_("Procedural Database"), NULL, -1);
|
||||
|
||||
if (!procedural_ht)
|
||||
procedural_ht = g_hash_table_new (procedural_db_hash_func, g_str_equal);
|
||||
pdb_id_init ();
|
||||
}
|
||||
|
||||
static void
|
||||
procedural_db_free_entry (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (value)
|
||||
g_list_free (value);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_free (void)
|
||||
{
|
||||
if (procedural_ht)
|
||||
{
|
||||
g_hash_table_foreach (procedural_ht, procedural_db_free_entry, NULL);
|
||||
g_hash_table_destroy (procedural_ht);
|
||||
}
|
||||
|
||||
procedural_ht = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_register (ProcRecord *procedure)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
if (!procedural_ht)
|
||||
procedural_db_init ();
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) procedure->name);
|
||||
list = g_list_prepend (list, (gpointer) procedure);
|
||||
|
||||
g_hash_table_insert (procedural_ht,
|
||||
(gpointer) procedure->name,
|
||||
(gpointer) list);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_unregister (gchar *name)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
if (list)
|
||||
{
|
||||
list = g_list_remove (list, list->data);
|
||||
|
||||
if (list)
|
||||
g_hash_table_insert (procedural_ht,
|
||||
(gpointer) name,
|
||||
(gpointer) list);
|
||||
else
|
||||
g_hash_table_remove (procedural_ht,
|
||||
(gpointer) name);
|
||||
}
|
||||
}
|
||||
|
||||
ProcRecord *
|
||||
procedural_db_lookup (gchar *name)
|
||||
{
|
||||
GList *list;
|
||||
ProcRecord *procedure;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
if (list != NULL)
|
||||
procedure = (ProcRecord *) list->data;
|
||||
else
|
||||
procedure = NULL;
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_execute (gchar *name,
|
||||
Argument *args)
|
||||
{
|
||||
ProcRecord *procedure;
|
||||
Argument *return_args;
|
||||
GList *list;
|
||||
gint i;
|
||||
|
||||
return_args = NULL;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
|
||||
if (list == NULL)
|
||||
{
|
||||
g_message (_("PDB calling error %s not found"), name);
|
||||
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_args;
|
||||
}
|
||||
|
||||
while (list)
|
||||
{
|
||||
if ((procedure = (ProcRecord *) list->data) == NULL)
|
||||
{
|
||||
g_message (_("PDB calling error %s not found"), name);
|
||||
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_args;
|
||||
}
|
||||
list = list->next;
|
||||
|
||||
/* check the arguments */
|
||||
for (i = 0; i < procedure->num_args; i++)
|
||||
{
|
||||
if (args[i].arg_type != procedure->args[i].arg_type)
|
||||
{
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
|
||||
g_message (_("PDB calling error %s"), procedure->name);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
}
|
||||
|
||||
/* call the procedure */
|
||||
switch (procedure->proc_type)
|
||||
{
|
||||
case PDB_INTERNAL:
|
||||
return_args = (* procedure->exec_method.internal.marshal_func) (args);
|
||||
break;
|
||||
|
||||
case PDB_PLUGIN:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
case PDB_EXTENSION:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
case PDB_TEMPORARY:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((return_args[0].value.pdb_int != PDB_SUCCESS) &&
|
||||
(procedure->num_values > 0))
|
||||
memset (&return_args[1], 0, sizeof (Argument) * procedure->num_values);
|
||||
|
||||
/* Check if the return value is a PDB_PASS_THROUGH, in which case run the
|
||||
* next procedure in the list
|
||||
*/
|
||||
if (return_args[0].value.pdb_int != PDB_PASS_THROUGH)
|
||||
break;
|
||||
else if (list) /* Pass through, so destroy return values and run another procedure */
|
||||
procedural_db_destroy_args (return_args, procedure->num_values);
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_run_proc (gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...)
|
||||
{
|
||||
ProcRecord *proc;
|
||||
Argument *params;
|
||||
Argument *return_vals;
|
||||
va_list args;
|
||||
gint i;
|
||||
|
||||
if ((proc = procedural_db_lookup (name)) == NULL)
|
||||
{
|
||||
return_vals = g_new (Argument, 1);
|
||||
return_vals->arg_type = PDB_STATUS;
|
||||
return_vals->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
/* allocate the parameter array */
|
||||
params = g_new (Argument, proc->num_args);
|
||||
|
||||
va_start (args, nreturn_vals);
|
||||
|
||||
for (i = 0; i < proc->num_args; i++)
|
||||
{
|
||||
if (proc->args[i].arg_type != (params[i].arg_type = va_arg (args, PDBArgType)))
|
||||
{
|
||||
g_message (_("Incorrect arguments passed to procedural_db_run_proc:\n"
|
||||
"Argument %d to '%s' should be a %s, but got passed a %s"),
|
||||
i+1, proc->name,
|
||||
pdb_type_name (proc->args[i].arg_type),
|
||||
pdb_type_name (params[i].arg_type));
|
||||
g_free (params);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (proc->args[i].arg_type)
|
||||
{
|
||||
case PDB_INT32:
|
||||
case PDB_INT16:
|
||||
case PDB_INT8:
|
||||
case PDB_DISPLAY:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_FLOAT:
|
||||
params[i].value.pdb_float = (gdouble) va_arg (args, double);
|
||||
break;
|
||||
case PDB_STRING:
|
||||
case PDB_INT32ARRAY:
|
||||
case PDB_INT16ARRAY:
|
||||
case PDB_INT8ARRAY:
|
||||
case PDB_FLOATARRAY:
|
||||
case PDB_STRINGARRAY:
|
||||
case PDB_COLOR:
|
||||
params[i].value.pdb_pointer = va_arg (args, void *);
|
||||
break;
|
||||
case PDB_REGION:
|
||||
break;
|
||||
case PDB_IMAGE:
|
||||
case PDB_LAYER:
|
||||
case PDB_CHANNEL:
|
||||
case PDB_DRAWABLE:
|
||||
case PDB_SELECTION:
|
||||
case PDB_BOUNDARY:
|
||||
case PDB_PATH:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_PARASITE:
|
||||
params[i].value.pdb_pointer = va_arg (args, void *);
|
||||
break;
|
||||
case PDB_STATUS:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_END:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
|
||||
*nreturn_vals = proc->num_values;
|
||||
|
||||
return_vals = procedural_db_execute (name, params);
|
||||
|
||||
g_free (params);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success)
|
||||
{
|
||||
Argument *return_args;
|
||||
gint i;
|
||||
|
||||
return_args = g_new (Argument, procedure->num_values + 1);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[0].arg_type = PDB_STATUS;
|
||||
return_args[0].value.pdb_int = PDB_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_args[0].arg_type = PDB_STATUS;
|
||||
return_args[0].value.pdb_int = PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
||||
/* Set the arg types for the return values */
|
||||
for (i = 0; i < procedure->num_values; i++)
|
||||
return_args[i+1].arg_type = procedure->values[i].arg_type;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_destroy_args (Argument *args,
|
||||
int nargs)
|
||||
{
|
||||
gint i, j;
|
||||
gint prev_val = 0;
|
||||
gchar **strs;
|
||||
|
||||
if (!args)
|
||||
return;
|
||||
|
||||
for (i = 0; i < nargs; i++)
|
||||
{
|
||||
switch (args[i].arg_type)
|
||||
{
|
||||
case PDB_INT32:
|
||||
/* Keep this around in case we need to free an array of strings */
|
||||
prev_val = args[i].value.pdb_int;
|
||||
break;
|
||||
case PDB_INT16:
|
||||
case PDB_INT8:
|
||||
case PDB_FLOAT:
|
||||
break;
|
||||
case PDB_STRING:
|
||||
case PDB_INT32ARRAY:
|
||||
case PDB_INT16ARRAY:
|
||||
case PDB_INT8ARRAY:
|
||||
case PDB_FLOATARRAY:
|
||||
g_free (args[i].value.pdb_pointer);
|
||||
break;
|
||||
case PDB_STRINGARRAY:
|
||||
strs = (gchar **) args[i].value.pdb_pointer;
|
||||
for (j = 0; j < prev_val; j++)
|
||||
g_free (strs[j]);
|
||||
g_free (strs);
|
||||
break;
|
||||
case PDB_COLOR:
|
||||
g_free (args[i].value.pdb_pointer);
|
||||
break;
|
||||
case PDB_REGION:
|
||||
case PDB_DISPLAY:
|
||||
case PDB_IMAGE:
|
||||
case PDB_LAYER:
|
||||
case PDB_CHANNEL:
|
||||
case PDB_DRAWABLE:
|
||||
case PDB_SELECTION:
|
||||
case PDB_BOUNDARY:
|
||||
case PDB_PATH:
|
||||
case PDB_PARASITE:
|
||||
case PDB_STATUS:
|
||||
case PDB_END:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (args);
|
||||
}
|
||||
|
||||
/* We could just use g_str_hash() here ... that uses a different
|
||||
* hash function, though
|
||||
*/
|
||||
|
||||
static guint
|
||||
procedural_db_hash_func (gconstpointer key)
|
||||
{
|
||||
const gchar *string;
|
||||
guint result;
|
||||
int c;
|
||||
|
||||
/*
|
||||
* I tried a zillion different hash functions and asked many other
|
||||
* people for advice. Many people had their own favorite functions,
|
||||
* all different, but no-one had much idea why they were good ones.
|
||||
* I chose the one below (multiply by 9 and add new character)
|
||||
* because of the following reasons:
|
||||
*
|
||||
* 1. Multiplying by 10 is perfect for keys that are decimal strings,
|
||||
* and multiplying by 9 is just about as good.
|
||||
* 2. Times-9 is (shift-left-3) plus (old). This means that each
|
||||
* character's bits hang around in the low-order bits of the
|
||||
* hash value for ever, plus they spread fairly rapidly up to
|
||||
* the high-order bits to fill out the hash value. This seems
|
||||
* works well both for decimal and non-decimal strings.
|
||||
*
|
||||
* tclHash.c --
|
||||
*
|
||||
* Implementation of in-memory hash tables for Tcl and Tcl-based
|
||||
* applications.
|
||||
*
|
||||
* Copyright (c) 1991-1993 The Regents of the University of California.
|
||||
* Copyright (c) 1994 Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
string = (const gchar *) key;
|
||||
result = 0;
|
||||
while (1)
|
||||
{
|
||||
c = *string;
|
||||
string++;
|
||||
if (c == 0)
|
||||
break;
|
||||
result += (result << 3) + c;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* The id system's remnants ... */
|
||||
|
||||
|
||||
static gint next_image_id;
|
||||
/*
|
||||
static gint next_drawable_id;
|
||||
static gint next_display_id;
|
||||
*/
|
||||
|
||||
static GHashTable *image_hash;
|
||||
static GHashTable *drawable_hash;
|
||||
static GHashTable *display_hash;
|
||||
|
||||
static guint
|
||||
id_hash_func (gconstpointer id)
|
||||
{
|
||||
return *((guint*) id);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
id_cmp_func (gconstpointer id1,
|
||||
gconstpointer id2)
|
||||
{
|
||||
return (*((guint*) id1) == *((guint*) id2));
|
||||
}
|
||||
|
||||
static void
|
||||
add_cb (GimpSet *set,
|
||||
GimpImage *gimage,
|
||||
gpointer data)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = g_new (guint, 1);
|
||||
*id = next_image_id++;
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (gimage), "pdb_id", id);
|
||||
g_hash_table_insert (image_hash, id, gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_cb (GimpSet *set,
|
||||
GimpImage *image,
|
||||
gpointer data)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = (guint *) gtk_object_get_data (GTK_OBJECT (image), "pdb_id");
|
||||
|
||||
gtk_object_remove_data (GTK_OBJECT(image), "pdb_id");
|
||||
g_hash_table_remove (image_hash, id);
|
||||
g_free (id);
|
||||
}
|
||||
|
||||
static void
|
||||
pdb_id_init (void)
|
||||
{
|
||||
image_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
drawable_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
display_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "add",
|
||||
GTK_SIGNAL_FUNC (add_cb),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
|
||||
GTK_SIGNAL_FUNC (remove_cb),
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
pdb_image_to_id (GimpImage *gimage)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = (guint *) gtk_object_get_data (GTK_OBJECT (gimage), "pdb_id");
|
||||
|
||||
return id ? (gint) *id : -1;
|
||||
}
|
||||
|
||||
GimpImage *
|
||||
pdb_id_to_image (gint id)
|
||||
{
|
||||
return g_hash_table_lookup (image_hash, &id);
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROCEDURAL_DB_H__
|
||||
#define __PROCEDURAL_DB_H__
|
||||
|
||||
|
||||
struct _Argument
|
||||
{
|
||||
PDBArgType arg_type; /* argument type */
|
||||
|
||||
union _ArgValue
|
||||
{
|
||||
gint32 pdb_int; /* Integer type */
|
||||
gdouble pdb_float; /* Floating point type */
|
||||
gpointer pdb_pointer; /* Pointer type */
|
||||
} value;
|
||||
};
|
||||
|
||||
|
||||
/* Argument marshalling procedures */
|
||||
typedef Argument * (* ArgMarshal) (Argument *);
|
||||
|
||||
|
||||
/* Execution types */
|
||||
typedef struct _IntExec IntExec;
|
||||
typedef struct _PlugInExec PlugInExec;
|
||||
typedef struct _ExtExec ExtExec;
|
||||
typedef struct _TempExec TempExec;
|
||||
typedef struct _NetExec NetExec;
|
||||
|
||||
struct _IntExec
|
||||
{
|
||||
ArgMarshal marshal_func; /* Function called to marshal arguments */
|
||||
};
|
||||
|
||||
struct _PlugInExec
|
||||
{
|
||||
gchar *filename; /* Where is the executable on disk? */
|
||||
};
|
||||
|
||||
struct _ExtExec
|
||||
{
|
||||
gchar *filename; /* Where is the executable on disk? */
|
||||
};
|
||||
|
||||
struct _TempExec
|
||||
{
|
||||
void *plug_in; /* Plug-in that registered this temp proc */
|
||||
};
|
||||
|
||||
struct _NetExec
|
||||
{
|
||||
gchar *host; /* Host responsible for procedure execution */
|
||||
gint32 port; /* Port on host to send data to */
|
||||
};
|
||||
|
||||
|
||||
/* Structure for a procedure argument */
|
||||
|
||||
struct _ProcArg
|
||||
{
|
||||
PDBArgType arg_type; /* Argument type (int, char, char *, etc) */
|
||||
gchar *name; /* Argument name */
|
||||
gchar *description; /* Argument description */
|
||||
};
|
||||
|
||||
|
||||
/* Structure for a procedure */
|
||||
|
||||
struct _ProcRecord
|
||||
{
|
||||
/* Procedure information */
|
||||
gchar *name; /* Procedure name */
|
||||
gchar *blurb; /* Short procedure description */
|
||||
gchar *help; /* Detailed help instructions */
|
||||
gchar *author; /* Author field */
|
||||
gchar *copyright; /* Copyright field */
|
||||
gchar *date; /* Date field */
|
||||
|
||||
/* Procedure type */
|
||||
PDBProcType proc_type; /* Type of procedure--Internal, Plug-In, Extension */
|
||||
|
||||
/* Input arguments */
|
||||
gint32 num_args; /* Number of procedure arguments */
|
||||
ProcArg *args; /* Array of procedure arguments */
|
||||
|
||||
/* Output values */
|
||||
gint32 num_values; /* Number of return values */
|
||||
ProcArg *values; /* Array of return values */
|
||||
|
||||
/* Method of procedure execution */
|
||||
union _ExecMethod
|
||||
{
|
||||
IntExec internal; /* Execution information for internal procs */
|
||||
PlugInExec plug_in; /* ..................... for plug-ins */
|
||||
ExtExec extension; /* ..................... for extensions */
|
||||
TempExec temporary; /* ..................... for temp procs */
|
||||
} exec_method;
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
extern GHashTable *procedural_ht;
|
||||
|
||||
/* Functions */
|
||||
void procedural_db_init (void);
|
||||
void procedural_db_free (void);
|
||||
void procedural_db_register (ProcRecord *procedure);
|
||||
void procedural_db_unregister (gchar *name);
|
||||
ProcRecord * procedural_db_lookup (gchar *name);
|
||||
Argument * procedural_db_execute (gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
void pdb_add_image (GimpImage *gimage);
|
||||
gint pdb_image_to_id (GimpImage *gimage);
|
||||
GimpImage * pdb_id_to_image (gint id);
|
||||
void pdb_remove_image (GimpImage *image);
|
||||
|
||||
/* "type" should really be a PDBArgType, but we can cope with
|
||||
* out-of-range values.
|
||||
*/
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
|
||||
#endif /* __PROCEDURAL_DB_H__ */
|
|
@ -0,0 +1,530 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "app_procs.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpparasite.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
GHashTable *procedural_ht = NULL;
|
||||
|
||||
/* Local functions */
|
||||
static guint procedural_db_hash_func (gconstpointer key);
|
||||
static void pdb_id_init (void);
|
||||
|
||||
|
||||
void
|
||||
procedural_db_init (void)
|
||||
{
|
||||
app_init_update_status (_("Procedural Database"), NULL, -1);
|
||||
|
||||
if (!procedural_ht)
|
||||
procedural_ht = g_hash_table_new (procedural_db_hash_func, g_str_equal);
|
||||
pdb_id_init ();
|
||||
}
|
||||
|
||||
static void
|
||||
procedural_db_free_entry (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (value)
|
||||
g_list_free (value);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_free (void)
|
||||
{
|
||||
if (procedural_ht)
|
||||
{
|
||||
g_hash_table_foreach (procedural_ht, procedural_db_free_entry, NULL);
|
||||
g_hash_table_destroy (procedural_ht);
|
||||
}
|
||||
|
||||
procedural_ht = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_register (ProcRecord *procedure)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
if (!procedural_ht)
|
||||
procedural_db_init ();
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) procedure->name);
|
||||
list = g_list_prepend (list, (gpointer) procedure);
|
||||
|
||||
g_hash_table_insert (procedural_ht,
|
||||
(gpointer) procedure->name,
|
||||
(gpointer) list);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_unregister (gchar *name)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
if (list)
|
||||
{
|
||||
list = g_list_remove (list, list->data);
|
||||
|
||||
if (list)
|
||||
g_hash_table_insert (procedural_ht,
|
||||
(gpointer) name,
|
||||
(gpointer) list);
|
||||
else
|
||||
g_hash_table_remove (procedural_ht,
|
||||
(gpointer) name);
|
||||
}
|
||||
}
|
||||
|
||||
ProcRecord *
|
||||
procedural_db_lookup (gchar *name)
|
||||
{
|
||||
GList *list;
|
||||
ProcRecord *procedure;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
if (list != NULL)
|
||||
procedure = (ProcRecord *) list->data;
|
||||
else
|
||||
procedure = NULL;
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_execute (gchar *name,
|
||||
Argument *args)
|
||||
{
|
||||
ProcRecord *procedure;
|
||||
Argument *return_args;
|
||||
GList *list;
|
||||
gint i;
|
||||
|
||||
return_args = NULL;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
|
||||
if (list == NULL)
|
||||
{
|
||||
g_message (_("PDB calling error %s not found"), name);
|
||||
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_args;
|
||||
}
|
||||
|
||||
while (list)
|
||||
{
|
||||
if ((procedure = (ProcRecord *) list->data) == NULL)
|
||||
{
|
||||
g_message (_("PDB calling error %s not found"), name);
|
||||
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_args;
|
||||
}
|
||||
list = list->next;
|
||||
|
||||
/* check the arguments */
|
||||
for (i = 0; i < procedure->num_args; i++)
|
||||
{
|
||||
if (args[i].arg_type != procedure->args[i].arg_type)
|
||||
{
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
|
||||
g_message (_("PDB calling error %s"), procedure->name);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
}
|
||||
|
||||
/* call the procedure */
|
||||
switch (procedure->proc_type)
|
||||
{
|
||||
case PDB_INTERNAL:
|
||||
return_args = (* procedure->exec_method.internal.marshal_func) (args);
|
||||
break;
|
||||
|
||||
case PDB_PLUGIN:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
case PDB_EXTENSION:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
case PDB_TEMPORARY:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((return_args[0].value.pdb_int != PDB_SUCCESS) &&
|
||||
(procedure->num_values > 0))
|
||||
memset (&return_args[1], 0, sizeof (Argument) * procedure->num_values);
|
||||
|
||||
/* Check if the return value is a PDB_PASS_THROUGH, in which case run the
|
||||
* next procedure in the list
|
||||
*/
|
||||
if (return_args[0].value.pdb_int != PDB_PASS_THROUGH)
|
||||
break;
|
||||
else if (list) /* Pass through, so destroy return values and run another procedure */
|
||||
procedural_db_destroy_args (return_args, procedure->num_values);
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_run_proc (gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...)
|
||||
{
|
||||
ProcRecord *proc;
|
||||
Argument *params;
|
||||
Argument *return_vals;
|
||||
va_list args;
|
||||
gint i;
|
||||
|
||||
if ((proc = procedural_db_lookup (name)) == NULL)
|
||||
{
|
||||
return_vals = g_new (Argument, 1);
|
||||
return_vals->arg_type = PDB_STATUS;
|
||||
return_vals->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
/* allocate the parameter array */
|
||||
params = g_new (Argument, proc->num_args);
|
||||
|
||||
va_start (args, nreturn_vals);
|
||||
|
||||
for (i = 0; i < proc->num_args; i++)
|
||||
{
|
||||
if (proc->args[i].arg_type != (params[i].arg_type = va_arg (args, PDBArgType)))
|
||||
{
|
||||
g_message (_("Incorrect arguments passed to procedural_db_run_proc:\n"
|
||||
"Argument %d to '%s' should be a %s, but got passed a %s"),
|
||||
i+1, proc->name,
|
||||
pdb_type_name (proc->args[i].arg_type),
|
||||
pdb_type_name (params[i].arg_type));
|
||||
g_free (params);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (proc->args[i].arg_type)
|
||||
{
|
||||
case PDB_INT32:
|
||||
case PDB_INT16:
|
||||
case PDB_INT8:
|
||||
case PDB_DISPLAY:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_FLOAT:
|
||||
params[i].value.pdb_float = (gdouble) va_arg (args, double);
|
||||
break;
|
||||
case PDB_STRING:
|
||||
case PDB_INT32ARRAY:
|
||||
case PDB_INT16ARRAY:
|
||||
case PDB_INT8ARRAY:
|
||||
case PDB_FLOATARRAY:
|
||||
case PDB_STRINGARRAY:
|
||||
case PDB_COLOR:
|
||||
params[i].value.pdb_pointer = va_arg (args, void *);
|
||||
break;
|
||||
case PDB_REGION:
|
||||
break;
|
||||
case PDB_IMAGE:
|
||||
case PDB_LAYER:
|
||||
case PDB_CHANNEL:
|
||||
case PDB_DRAWABLE:
|
||||
case PDB_SELECTION:
|
||||
case PDB_BOUNDARY:
|
||||
case PDB_PATH:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_PARASITE:
|
||||
params[i].value.pdb_pointer = va_arg (args, void *);
|
||||
break;
|
||||
case PDB_STATUS:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_END:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
|
||||
*nreturn_vals = proc->num_values;
|
||||
|
||||
return_vals = procedural_db_execute (name, params);
|
||||
|
||||
g_free (params);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success)
|
||||
{
|
||||
Argument *return_args;
|
||||
gint i;
|
||||
|
||||
return_args = g_new (Argument, procedure->num_values + 1);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[0].arg_type = PDB_STATUS;
|
||||
return_args[0].value.pdb_int = PDB_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_args[0].arg_type = PDB_STATUS;
|
||||
return_args[0].value.pdb_int = PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
||||
/* Set the arg types for the return values */
|
||||
for (i = 0; i < procedure->num_values; i++)
|
||||
return_args[i+1].arg_type = procedure->values[i].arg_type;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_destroy_args (Argument *args,
|
||||
int nargs)
|
||||
{
|
||||
gint i, j;
|
||||
gint prev_val = 0;
|
||||
gchar **strs;
|
||||
|
||||
if (!args)
|
||||
return;
|
||||
|
||||
for (i = 0; i < nargs; i++)
|
||||
{
|
||||
switch (args[i].arg_type)
|
||||
{
|
||||
case PDB_INT32:
|
||||
/* Keep this around in case we need to free an array of strings */
|
||||
prev_val = args[i].value.pdb_int;
|
||||
break;
|
||||
case PDB_INT16:
|
||||
case PDB_INT8:
|
||||
case PDB_FLOAT:
|
||||
break;
|
||||
case PDB_STRING:
|
||||
case PDB_INT32ARRAY:
|
||||
case PDB_INT16ARRAY:
|
||||
case PDB_INT8ARRAY:
|
||||
case PDB_FLOATARRAY:
|
||||
g_free (args[i].value.pdb_pointer);
|
||||
break;
|
||||
case PDB_STRINGARRAY:
|
||||
strs = (gchar **) args[i].value.pdb_pointer;
|
||||
for (j = 0; j < prev_val; j++)
|
||||
g_free (strs[j]);
|
||||
g_free (strs);
|
||||
break;
|
||||
case PDB_COLOR:
|
||||
g_free (args[i].value.pdb_pointer);
|
||||
break;
|
||||
case PDB_REGION:
|
||||
case PDB_DISPLAY:
|
||||
case PDB_IMAGE:
|
||||
case PDB_LAYER:
|
||||
case PDB_CHANNEL:
|
||||
case PDB_DRAWABLE:
|
||||
case PDB_SELECTION:
|
||||
case PDB_BOUNDARY:
|
||||
case PDB_PATH:
|
||||
case PDB_PARASITE:
|
||||
case PDB_STATUS:
|
||||
case PDB_END:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (args);
|
||||
}
|
||||
|
||||
/* We could just use g_str_hash() here ... that uses a different
|
||||
* hash function, though
|
||||
*/
|
||||
|
||||
static guint
|
||||
procedural_db_hash_func (gconstpointer key)
|
||||
{
|
||||
const gchar *string;
|
||||
guint result;
|
||||
int c;
|
||||
|
||||
/*
|
||||
* I tried a zillion different hash functions and asked many other
|
||||
* people for advice. Many people had their own favorite functions,
|
||||
* all different, but no-one had much idea why they were good ones.
|
||||
* I chose the one below (multiply by 9 and add new character)
|
||||
* because of the following reasons:
|
||||
*
|
||||
* 1. Multiplying by 10 is perfect for keys that are decimal strings,
|
||||
* and multiplying by 9 is just about as good.
|
||||
* 2. Times-9 is (shift-left-3) plus (old). This means that each
|
||||
* character's bits hang around in the low-order bits of the
|
||||
* hash value for ever, plus they spread fairly rapidly up to
|
||||
* the high-order bits to fill out the hash value. This seems
|
||||
* works well both for decimal and non-decimal strings.
|
||||
*
|
||||
* tclHash.c --
|
||||
*
|
||||
* Implementation of in-memory hash tables for Tcl and Tcl-based
|
||||
* applications.
|
||||
*
|
||||
* Copyright (c) 1991-1993 The Regents of the University of California.
|
||||
* Copyright (c) 1994 Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
string = (const gchar *) key;
|
||||
result = 0;
|
||||
while (1)
|
||||
{
|
||||
c = *string;
|
||||
string++;
|
||||
if (c == 0)
|
||||
break;
|
||||
result += (result << 3) + c;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* The id system's remnants ... */
|
||||
|
||||
|
||||
static gint next_image_id;
|
||||
/*
|
||||
static gint next_drawable_id;
|
||||
static gint next_display_id;
|
||||
*/
|
||||
|
||||
static GHashTable *image_hash;
|
||||
static GHashTable *drawable_hash;
|
||||
static GHashTable *display_hash;
|
||||
|
||||
static guint
|
||||
id_hash_func (gconstpointer id)
|
||||
{
|
||||
return *((guint*) id);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
id_cmp_func (gconstpointer id1,
|
||||
gconstpointer id2)
|
||||
{
|
||||
return (*((guint*) id1) == *((guint*) id2));
|
||||
}
|
||||
|
||||
static void
|
||||
add_cb (GimpSet *set,
|
||||
GimpImage *gimage,
|
||||
gpointer data)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = g_new (guint, 1);
|
||||
*id = next_image_id++;
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (gimage), "pdb_id", id);
|
||||
g_hash_table_insert (image_hash, id, gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_cb (GimpSet *set,
|
||||
GimpImage *image,
|
||||
gpointer data)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = (guint *) gtk_object_get_data (GTK_OBJECT (image), "pdb_id");
|
||||
|
||||
gtk_object_remove_data (GTK_OBJECT(image), "pdb_id");
|
||||
g_hash_table_remove (image_hash, id);
|
||||
g_free (id);
|
||||
}
|
||||
|
||||
static void
|
||||
pdb_id_init (void)
|
||||
{
|
||||
image_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
drawable_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
display_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "add",
|
||||
GTK_SIGNAL_FUNC (add_cb),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
|
||||
GTK_SIGNAL_FUNC (remove_cb),
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
pdb_image_to_id (GimpImage *gimage)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = (guint *) gtk_object_get_data (GTK_OBJECT (gimage), "pdb_id");
|
||||
|
||||
return id ? (gint) *id : -1;
|
||||
}
|
||||
|
||||
GimpImage *
|
||||
pdb_id_to_image (gint id)
|
||||
{
|
||||
return g_hash_table_lookup (image_hash, &id);
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROCEDURAL_DB_H__
|
||||
#define __PROCEDURAL_DB_H__
|
||||
|
||||
|
||||
struct _Argument
|
||||
{
|
||||
PDBArgType arg_type; /* argument type */
|
||||
|
||||
union _ArgValue
|
||||
{
|
||||
gint32 pdb_int; /* Integer type */
|
||||
gdouble pdb_float; /* Floating point type */
|
||||
gpointer pdb_pointer; /* Pointer type */
|
||||
} value;
|
||||
};
|
||||
|
||||
|
||||
/* Argument marshalling procedures */
|
||||
typedef Argument * (* ArgMarshal) (Argument *);
|
||||
|
||||
|
||||
/* Execution types */
|
||||
typedef struct _IntExec IntExec;
|
||||
typedef struct _PlugInExec PlugInExec;
|
||||
typedef struct _ExtExec ExtExec;
|
||||
typedef struct _TempExec TempExec;
|
||||
typedef struct _NetExec NetExec;
|
||||
|
||||
struct _IntExec
|
||||
{
|
||||
ArgMarshal marshal_func; /* Function called to marshal arguments */
|
||||
};
|
||||
|
||||
struct _PlugInExec
|
||||
{
|
||||
gchar *filename; /* Where is the executable on disk? */
|
||||
};
|
||||
|
||||
struct _ExtExec
|
||||
{
|
||||
gchar *filename; /* Where is the executable on disk? */
|
||||
};
|
||||
|
||||
struct _TempExec
|
||||
{
|
||||
void *plug_in; /* Plug-in that registered this temp proc */
|
||||
};
|
||||
|
||||
struct _NetExec
|
||||
{
|
||||
gchar *host; /* Host responsible for procedure execution */
|
||||
gint32 port; /* Port on host to send data to */
|
||||
};
|
||||
|
||||
|
||||
/* Structure for a procedure argument */
|
||||
|
||||
struct _ProcArg
|
||||
{
|
||||
PDBArgType arg_type; /* Argument type (int, char, char *, etc) */
|
||||
gchar *name; /* Argument name */
|
||||
gchar *description; /* Argument description */
|
||||
};
|
||||
|
||||
|
||||
/* Structure for a procedure */
|
||||
|
||||
struct _ProcRecord
|
||||
{
|
||||
/* Procedure information */
|
||||
gchar *name; /* Procedure name */
|
||||
gchar *blurb; /* Short procedure description */
|
||||
gchar *help; /* Detailed help instructions */
|
||||
gchar *author; /* Author field */
|
||||
gchar *copyright; /* Copyright field */
|
||||
gchar *date; /* Date field */
|
||||
|
||||
/* Procedure type */
|
||||
PDBProcType proc_type; /* Type of procedure--Internal, Plug-In, Extension */
|
||||
|
||||
/* Input arguments */
|
||||
gint32 num_args; /* Number of procedure arguments */
|
||||
ProcArg *args; /* Array of procedure arguments */
|
||||
|
||||
/* Output values */
|
||||
gint32 num_values; /* Number of return values */
|
||||
ProcArg *values; /* Array of return values */
|
||||
|
||||
/* Method of procedure execution */
|
||||
union _ExecMethod
|
||||
{
|
||||
IntExec internal; /* Execution information for internal procs */
|
||||
PlugInExec plug_in; /* ..................... for plug-ins */
|
||||
ExtExec extension; /* ..................... for extensions */
|
||||
TempExec temporary; /* ..................... for temp procs */
|
||||
} exec_method;
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
extern GHashTable *procedural_ht;
|
||||
|
||||
/* Functions */
|
||||
void procedural_db_init (void);
|
||||
void procedural_db_free (void);
|
||||
void procedural_db_register (ProcRecord *procedure);
|
||||
void procedural_db_unregister (gchar *name);
|
||||
ProcRecord * procedural_db_lookup (gchar *name);
|
||||
Argument * procedural_db_execute (gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
void pdb_add_image (GimpImage *gimage);
|
||||
gint pdb_image_to_id (GimpImage *gimage);
|
||||
GimpImage * pdb_id_to_image (gint id);
|
||||
void pdb_remove_image (GimpImage *image);
|
||||
|
||||
/* "type" should really be a PDBArgType, but we can cope with
|
||||
* out-of-range values.
|
||||
*/
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
|
||||
#endif /* __PROCEDURAL_DB_H__ */
|
|
@ -0,0 +1,530 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "app_procs.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpparasite.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
GHashTable *procedural_ht = NULL;
|
||||
|
||||
/* Local functions */
|
||||
static guint procedural_db_hash_func (gconstpointer key);
|
||||
static void pdb_id_init (void);
|
||||
|
||||
|
||||
void
|
||||
procedural_db_init (void)
|
||||
{
|
||||
app_init_update_status (_("Procedural Database"), NULL, -1);
|
||||
|
||||
if (!procedural_ht)
|
||||
procedural_ht = g_hash_table_new (procedural_db_hash_func, g_str_equal);
|
||||
pdb_id_init ();
|
||||
}
|
||||
|
||||
static void
|
||||
procedural_db_free_entry (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (value)
|
||||
g_list_free (value);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_free (void)
|
||||
{
|
||||
if (procedural_ht)
|
||||
{
|
||||
g_hash_table_foreach (procedural_ht, procedural_db_free_entry, NULL);
|
||||
g_hash_table_destroy (procedural_ht);
|
||||
}
|
||||
|
||||
procedural_ht = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_register (ProcRecord *procedure)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
if (!procedural_ht)
|
||||
procedural_db_init ();
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) procedure->name);
|
||||
list = g_list_prepend (list, (gpointer) procedure);
|
||||
|
||||
g_hash_table_insert (procedural_ht,
|
||||
(gpointer) procedure->name,
|
||||
(gpointer) list);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_unregister (gchar *name)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
if (list)
|
||||
{
|
||||
list = g_list_remove (list, list->data);
|
||||
|
||||
if (list)
|
||||
g_hash_table_insert (procedural_ht,
|
||||
(gpointer) name,
|
||||
(gpointer) list);
|
||||
else
|
||||
g_hash_table_remove (procedural_ht,
|
||||
(gpointer) name);
|
||||
}
|
||||
}
|
||||
|
||||
ProcRecord *
|
||||
procedural_db_lookup (gchar *name)
|
||||
{
|
||||
GList *list;
|
||||
ProcRecord *procedure;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
if (list != NULL)
|
||||
procedure = (ProcRecord *) list->data;
|
||||
else
|
||||
procedure = NULL;
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_execute (gchar *name,
|
||||
Argument *args)
|
||||
{
|
||||
ProcRecord *procedure;
|
||||
Argument *return_args;
|
||||
GList *list;
|
||||
gint i;
|
||||
|
||||
return_args = NULL;
|
||||
|
||||
list = g_hash_table_lookup (procedural_ht, (gpointer) name);
|
||||
|
||||
if (list == NULL)
|
||||
{
|
||||
g_message (_("PDB calling error %s not found"), name);
|
||||
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_args;
|
||||
}
|
||||
|
||||
while (list)
|
||||
{
|
||||
if ((procedure = (ProcRecord *) list->data) == NULL)
|
||||
{
|
||||
g_message (_("PDB calling error %s not found"), name);
|
||||
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_args;
|
||||
}
|
||||
list = list->next;
|
||||
|
||||
/* check the arguments */
|
||||
for (i = 0; i < procedure->num_args; i++)
|
||||
{
|
||||
if (args[i].arg_type != procedure->args[i].arg_type)
|
||||
{
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_CALLING_ERROR;
|
||||
|
||||
g_message (_("PDB calling error %s"), procedure->name);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
}
|
||||
|
||||
/* call the procedure */
|
||||
switch (procedure->proc_type)
|
||||
{
|
||||
case PDB_INTERNAL:
|
||||
return_args = (* procedure->exec_method.internal.marshal_func) (args);
|
||||
break;
|
||||
|
||||
case PDB_PLUGIN:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
case PDB_EXTENSION:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
case PDB_TEMPORARY:
|
||||
return_args = plug_in_run (procedure, args, procedure->num_args, TRUE, FALSE, -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
return_args = g_new (Argument, 1);
|
||||
return_args->arg_type = PDB_STATUS;
|
||||
return_args->value.pdb_int = PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((return_args[0].value.pdb_int != PDB_SUCCESS) &&
|
||||
(procedure->num_values > 0))
|
||||
memset (&return_args[1], 0, sizeof (Argument) * procedure->num_values);
|
||||
|
||||
/* Check if the return value is a PDB_PASS_THROUGH, in which case run the
|
||||
* next procedure in the list
|
||||
*/
|
||||
if (return_args[0].value.pdb_int != PDB_PASS_THROUGH)
|
||||
break;
|
||||
else if (list) /* Pass through, so destroy return values and run another procedure */
|
||||
procedural_db_destroy_args (return_args, procedure->num_values);
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_run_proc (gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...)
|
||||
{
|
||||
ProcRecord *proc;
|
||||
Argument *params;
|
||||
Argument *return_vals;
|
||||
va_list args;
|
||||
gint i;
|
||||
|
||||
if ((proc = procedural_db_lookup (name)) == NULL)
|
||||
{
|
||||
return_vals = g_new (Argument, 1);
|
||||
return_vals->arg_type = PDB_STATUS;
|
||||
return_vals->value.pdb_int = PDB_CALLING_ERROR;
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
/* allocate the parameter array */
|
||||
params = g_new (Argument, proc->num_args);
|
||||
|
||||
va_start (args, nreturn_vals);
|
||||
|
||||
for (i = 0; i < proc->num_args; i++)
|
||||
{
|
||||
if (proc->args[i].arg_type != (params[i].arg_type = va_arg (args, PDBArgType)))
|
||||
{
|
||||
g_message (_("Incorrect arguments passed to procedural_db_run_proc:\n"
|
||||
"Argument %d to '%s' should be a %s, but got passed a %s"),
|
||||
i+1, proc->name,
|
||||
pdb_type_name (proc->args[i].arg_type),
|
||||
pdb_type_name (params[i].arg_type));
|
||||
g_free (params);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (proc->args[i].arg_type)
|
||||
{
|
||||
case PDB_INT32:
|
||||
case PDB_INT16:
|
||||
case PDB_INT8:
|
||||
case PDB_DISPLAY:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_FLOAT:
|
||||
params[i].value.pdb_float = (gdouble) va_arg (args, double);
|
||||
break;
|
||||
case PDB_STRING:
|
||||
case PDB_INT32ARRAY:
|
||||
case PDB_INT16ARRAY:
|
||||
case PDB_INT8ARRAY:
|
||||
case PDB_FLOATARRAY:
|
||||
case PDB_STRINGARRAY:
|
||||
case PDB_COLOR:
|
||||
params[i].value.pdb_pointer = va_arg (args, void *);
|
||||
break;
|
||||
case PDB_REGION:
|
||||
break;
|
||||
case PDB_IMAGE:
|
||||
case PDB_LAYER:
|
||||
case PDB_CHANNEL:
|
||||
case PDB_DRAWABLE:
|
||||
case PDB_SELECTION:
|
||||
case PDB_BOUNDARY:
|
||||
case PDB_PATH:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_PARASITE:
|
||||
params[i].value.pdb_pointer = va_arg (args, void *);
|
||||
break;
|
||||
case PDB_STATUS:
|
||||
params[i].value.pdb_int = (gint32) va_arg (args, int);
|
||||
break;
|
||||
case PDB_END:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
|
||||
*nreturn_vals = proc->num_values;
|
||||
|
||||
return_vals = procedural_db_execute (name, params);
|
||||
|
||||
g_free (params);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
Argument *
|
||||
procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success)
|
||||
{
|
||||
Argument *return_args;
|
||||
gint i;
|
||||
|
||||
return_args = g_new (Argument, procedure->num_values + 1);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[0].arg_type = PDB_STATUS;
|
||||
return_args[0].value.pdb_int = PDB_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_args[0].arg_type = PDB_STATUS;
|
||||
return_args[0].value.pdb_int = PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
||||
/* Set the arg types for the return values */
|
||||
for (i = 0; i < procedure->num_values; i++)
|
||||
return_args[i+1].arg_type = procedure->values[i].arg_type;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_destroy_args (Argument *args,
|
||||
int nargs)
|
||||
{
|
||||
gint i, j;
|
||||
gint prev_val = 0;
|
||||
gchar **strs;
|
||||
|
||||
if (!args)
|
||||
return;
|
||||
|
||||
for (i = 0; i < nargs; i++)
|
||||
{
|
||||
switch (args[i].arg_type)
|
||||
{
|
||||
case PDB_INT32:
|
||||
/* Keep this around in case we need to free an array of strings */
|
||||
prev_val = args[i].value.pdb_int;
|
||||
break;
|
||||
case PDB_INT16:
|
||||
case PDB_INT8:
|
||||
case PDB_FLOAT:
|
||||
break;
|
||||
case PDB_STRING:
|
||||
case PDB_INT32ARRAY:
|
||||
case PDB_INT16ARRAY:
|
||||
case PDB_INT8ARRAY:
|
||||
case PDB_FLOATARRAY:
|
||||
g_free (args[i].value.pdb_pointer);
|
||||
break;
|
||||
case PDB_STRINGARRAY:
|
||||
strs = (gchar **) args[i].value.pdb_pointer;
|
||||
for (j = 0; j < prev_val; j++)
|
||||
g_free (strs[j]);
|
||||
g_free (strs);
|
||||
break;
|
||||
case PDB_COLOR:
|
||||
g_free (args[i].value.pdb_pointer);
|
||||
break;
|
||||
case PDB_REGION:
|
||||
case PDB_DISPLAY:
|
||||
case PDB_IMAGE:
|
||||
case PDB_LAYER:
|
||||
case PDB_CHANNEL:
|
||||
case PDB_DRAWABLE:
|
||||
case PDB_SELECTION:
|
||||
case PDB_BOUNDARY:
|
||||
case PDB_PATH:
|
||||
case PDB_PARASITE:
|
||||
case PDB_STATUS:
|
||||
case PDB_END:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (args);
|
||||
}
|
||||
|
||||
/* We could just use g_str_hash() here ... that uses a different
|
||||
* hash function, though
|
||||
*/
|
||||
|
||||
static guint
|
||||
procedural_db_hash_func (gconstpointer key)
|
||||
{
|
||||
const gchar *string;
|
||||
guint result;
|
||||
int c;
|
||||
|
||||
/*
|
||||
* I tried a zillion different hash functions and asked many other
|
||||
* people for advice. Many people had their own favorite functions,
|
||||
* all different, but no-one had much idea why they were good ones.
|
||||
* I chose the one below (multiply by 9 and add new character)
|
||||
* because of the following reasons:
|
||||
*
|
||||
* 1. Multiplying by 10 is perfect for keys that are decimal strings,
|
||||
* and multiplying by 9 is just about as good.
|
||||
* 2. Times-9 is (shift-left-3) plus (old). This means that each
|
||||
* character's bits hang around in the low-order bits of the
|
||||
* hash value for ever, plus they spread fairly rapidly up to
|
||||
* the high-order bits to fill out the hash value. This seems
|
||||
* works well both for decimal and non-decimal strings.
|
||||
*
|
||||
* tclHash.c --
|
||||
*
|
||||
* Implementation of in-memory hash tables for Tcl and Tcl-based
|
||||
* applications.
|
||||
*
|
||||
* Copyright (c) 1991-1993 The Regents of the University of California.
|
||||
* Copyright (c) 1994 Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
string = (const gchar *) key;
|
||||
result = 0;
|
||||
while (1)
|
||||
{
|
||||
c = *string;
|
||||
string++;
|
||||
if (c == 0)
|
||||
break;
|
||||
result += (result << 3) + c;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* The id system's remnants ... */
|
||||
|
||||
|
||||
static gint next_image_id;
|
||||
/*
|
||||
static gint next_drawable_id;
|
||||
static gint next_display_id;
|
||||
*/
|
||||
|
||||
static GHashTable *image_hash;
|
||||
static GHashTable *drawable_hash;
|
||||
static GHashTable *display_hash;
|
||||
|
||||
static guint
|
||||
id_hash_func (gconstpointer id)
|
||||
{
|
||||
return *((guint*) id);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
id_cmp_func (gconstpointer id1,
|
||||
gconstpointer id2)
|
||||
{
|
||||
return (*((guint*) id1) == *((guint*) id2));
|
||||
}
|
||||
|
||||
static void
|
||||
add_cb (GimpSet *set,
|
||||
GimpImage *gimage,
|
||||
gpointer data)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = g_new (guint, 1);
|
||||
*id = next_image_id++;
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (gimage), "pdb_id", id);
|
||||
g_hash_table_insert (image_hash, id, gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_cb (GimpSet *set,
|
||||
GimpImage *image,
|
||||
gpointer data)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = (guint *) gtk_object_get_data (GTK_OBJECT (image), "pdb_id");
|
||||
|
||||
gtk_object_remove_data (GTK_OBJECT(image), "pdb_id");
|
||||
g_hash_table_remove (image_hash, id);
|
||||
g_free (id);
|
||||
}
|
||||
|
||||
static void
|
||||
pdb_id_init (void)
|
||||
{
|
||||
image_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
drawable_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
display_hash = g_hash_table_new (id_hash_func, id_cmp_func);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "add",
|
||||
GTK_SIGNAL_FUNC (add_cb),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
|
||||
GTK_SIGNAL_FUNC (remove_cb),
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
pdb_image_to_id (GimpImage *gimage)
|
||||
{
|
||||
guint *id;
|
||||
|
||||
id = (guint *) gtk_object_get_data (GTK_OBJECT (gimage), "pdb_id");
|
||||
|
||||
return id ? (gint) *id : -1;
|
||||
}
|
||||
|
||||
GimpImage *
|
||||
pdb_id_to_image (gint id)
|
||||
{
|
||||
return g_hash_table_lookup (image_hash, &id);
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROCEDURAL_DB_H__
|
||||
#define __PROCEDURAL_DB_H__
|
||||
|
||||
|
||||
struct _Argument
|
||||
{
|
||||
PDBArgType arg_type; /* argument type */
|
||||
|
||||
union _ArgValue
|
||||
{
|
||||
gint32 pdb_int; /* Integer type */
|
||||
gdouble pdb_float; /* Floating point type */
|
||||
gpointer pdb_pointer; /* Pointer type */
|
||||
} value;
|
||||
};
|
||||
|
||||
|
||||
/* Argument marshalling procedures */
|
||||
typedef Argument * (* ArgMarshal) (Argument *);
|
||||
|
||||
|
||||
/* Execution types */
|
||||
typedef struct _IntExec IntExec;
|
||||
typedef struct _PlugInExec PlugInExec;
|
||||
typedef struct _ExtExec ExtExec;
|
||||
typedef struct _TempExec TempExec;
|
||||
typedef struct _NetExec NetExec;
|
||||
|
||||
struct _IntExec
|
||||
{
|
||||
ArgMarshal marshal_func; /* Function called to marshal arguments */
|
||||
};
|
||||
|
||||
struct _PlugInExec
|
||||
{
|
||||
gchar *filename; /* Where is the executable on disk? */
|
||||
};
|
||||
|
||||
struct _ExtExec
|
||||
{
|
||||
gchar *filename; /* Where is the executable on disk? */
|
||||
};
|
||||
|
||||
struct _TempExec
|
||||
{
|
||||
void *plug_in; /* Plug-in that registered this temp proc */
|
||||
};
|
||||
|
||||
struct _NetExec
|
||||
{
|
||||
gchar *host; /* Host responsible for procedure execution */
|
||||
gint32 port; /* Port on host to send data to */
|
||||
};
|
||||
|
||||
|
||||
/* Structure for a procedure argument */
|
||||
|
||||
struct _ProcArg
|
||||
{
|
||||
PDBArgType arg_type; /* Argument type (int, char, char *, etc) */
|
||||
gchar *name; /* Argument name */
|
||||
gchar *description; /* Argument description */
|
||||
};
|
||||
|
||||
|
||||
/* Structure for a procedure */
|
||||
|
||||
struct _ProcRecord
|
||||
{
|
||||
/* Procedure information */
|
||||
gchar *name; /* Procedure name */
|
||||
gchar *blurb; /* Short procedure description */
|
||||
gchar *help; /* Detailed help instructions */
|
||||
gchar *author; /* Author field */
|
||||
gchar *copyright; /* Copyright field */
|
||||
gchar *date; /* Date field */
|
||||
|
||||
/* Procedure type */
|
||||
PDBProcType proc_type; /* Type of procedure--Internal, Plug-In, Extension */
|
||||
|
||||
/* Input arguments */
|
||||
gint32 num_args; /* Number of procedure arguments */
|
||||
ProcArg *args; /* Array of procedure arguments */
|
||||
|
||||
/* Output values */
|
||||
gint32 num_values; /* Number of return values */
|
||||
ProcArg *values; /* Array of return values */
|
||||
|
||||
/* Method of procedure execution */
|
||||
union _ExecMethod
|
||||
{
|
||||
IntExec internal; /* Execution information for internal procs */
|
||||
PlugInExec plug_in; /* ..................... for plug-ins */
|
||||
ExtExec extension; /* ..................... for extensions */
|
||||
TempExec temporary; /* ..................... for temp procs */
|
||||
} exec_method;
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
extern GHashTable *procedural_ht;
|
||||
|
||||
/* Functions */
|
||||
void procedural_db_init (void);
|
||||
void procedural_db_free (void);
|
||||
void procedural_db_register (ProcRecord *procedure);
|
||||
void procedural_db_unregister (gchar *name);
|
||||
ProcRecord * procedural_db_lookup (gchar *name);
|
||||
Argument * procedural_db_execute (gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
void pdb_add_image (GimpImage *gimage);
|
||||
gint pdb_image_to_id (GimpImage *gimage);
|
||||
GimpImage * pdb_id_to_image (gint id);
|
||||
void pdb_remove_image (GimpImage *image);
|
||||
|
||||
/* "type" should really be a PDBArgType, but we can cope with
|
||||
* out-of-range values.
|
||||
*/
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
|
||||
#endif /* __PROCEDURAL_DB_H__ */
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __PLUG_IN_H__
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "paint_funcs.h"
|
||||
#include "pixel_region.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
#include "selection.h"
|
||||
#include "text_tool.h"
|
||||
#include "tile.h"
|
||||
|
|
|
@ -39,12 +39,13 @@
|
|||
#include "bezier_selectP.h"
|
||||
#include "paths_dialogP.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "selection_options.h"
|
||||
#include "tools.h"
|
||||
#include "tool_options.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
|
|
@ -39,13 +39,14 @@
|
|||
#include "paint_options.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
#include "tile_manager.h"
|
||||
#include "tools.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -39,13 +39,14 @@
|
|||
#include "paint_options.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "procedural_db.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
#include "tile_manager.h"
|
||||
#include "tools.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "paint_funcs.h"
|
||||
#include "pixel_region.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
#include "selection.h"
|
||||
#include "text_tool.h"
|
||||
#include "tile.h"
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "paint_funcs.h"
|
||||
#include "pixel_region.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
#include "selection.h"
|
||||
#include "text_tool.h"
|
||||
#include "tile.h"
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
#include "gimpimage.h"
|
||||
#include "gimpset.h"
|
||||
#include "gimpui.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "libgimp/gimphelpui.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "gimprc.h"
|
||||
#include "gimpui.h"
|
||||
#include "plug_in.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimphelpui.h"
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "paths_dialog.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "preferences_dialog.h"
|
||||
#include "procedural_db.h"
|
||||
#include "scale.h"
|
||||
#include "tools.h"
|
||||
#include "gdisplay.h"
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "parasitelist.h"
|
||||
#include "path.h"
|
||||
#include "pathP.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tile.h"
|
||||
#include "tile_manager.h"
|
||||
#include "tile_manager_pvt.h"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue