From 48e3c7a412d5aeb3dcbe75bb4ccf35aa76ce2b86 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Wed, 27 Oct 1999 20:45:57 +0000 Subject: [PATCH] app/drawable_cmds.c The PDB procedures * app/drawable_cmds.c * tools/pdbgen/pdb/drawable.pdb: The PDB procedures gimp_drawable_is_[layer|channel|channel_mask] were not renamed, but changed all over the place. This made the rotate plug-ins fail. * app/procedural_db.c: Spit out a warning if a procedure wasn't found in the PDB. Actually free the hash_table entries on procedural_db_free(). --Sven --- ChangeLog | 12 +++++++ app/drawable_cmds.c | 66 +++++++++++++++++------------------ app/procedural_db.c | 25 ++++++++++++- tools/pdbgen/pdb/drawable.pdb | 10 +++--- 4 files changed, 74 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index aad12373bd..6102f37754 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Oct 27 22:39:56 MEST 1999 Sven Neumann + + * app/drawable_cmds.c + * tools/pdbgen/pdb/drawable.pdb: The PDB procedures + gimp_drawable_is_[layer|channel|channel_mask] were not renamed, + but changed all over the place. This made the rotate plug-ins + fail. + + * app/procedural_db.c: Spit out a warning if a procedure wasn't + found in the PDB. Actually free the hash_table entries on + procedural_db_free(). + Wed Oct 27 13:37:54 CEST 1999 Marc Lehmann * gimp_parasite_find users where not updated to the new syntax diff --git a/app/drawable_cmds.c b/app/drawable_cmds.c index 44dcf6c219..0866b0da95 100644 --- a/app/drawable_cmds.c +++ b/app/drawable_cmds.c @@ -42,9 +42,9 @@ static ProcRecord drawable_bytes_proc; static ProcRecord drawable_width_proc; static ProcRecord drawable_height_proc; static ProcRecord drawable_offsets_proc; -static ProcRecord drawable_layer_proc; -static ProcRecord drawable_layer_mask_proc; -static ProcRecord drawable_channel_proc; +static ProcRecord drawable_is_layer_proc; +static ProcRecord drawable_is_layer_mask_proc; +static ProcRecord drawable_is_channel_proc; static ProcRecord drawable_get_pixel_proc; static ProcRecord drawable_set_pixel_proc; static ProcRecord drawable_set_image_proc; @@ -68,9 +68,9 @@ register_drawable_procs (void) procedural_db_register (&drawable_width_proc); procedural_db_register (&drawable_height_proc); procedural_db_register (&drawable_offsets_proc); - procedural_db_register (&drawable_layer_proc); - procedural_db_register (&drawable_layer_mask_proc); - procedural_db_register (&drawable_channel_proc); + procedural_db_register (&drawable_is_layer_proc); + procedural_db_register (&drawable_is_layer_mask_proc); + procedural_db_register (&drawable_is_channel_proc); procedural_db_register (&drawable_get_pixel_proc); procedural_db_register (&drawable_set_pixel_proc); procedural_db_register (&drawable_set_image_proc); @@ -875,20 +875,20 @@ static ProcRecord drawable_offsets_proc = }; static Argument * -drawable_layer_invoker (Argument *args) +drawable_is_layer_invoker (Argument *args) { Argument *return_args; GimpDrawable *drawable; drawable = gimp_drawable_get_ID (args[0].value.pdb_int); - return_args = procedural_db_return_args (&drawable_layer_proc, TRUE); + return_args = procedural_db_return_args (&drawable_is_layer_proc, TRUE); return_args[1].value.pdb_int = drawable_layer (drawable) ? TRUE : FALSE; return return_args; } -static ProcArg drawable_layer_inargs[] = +static ProcArg drawable_is_layer_inargs[] = { { PDB_DRAWABLE, @@ -897,7 +897,7 @@ static ProcArg drawable_layer_inargs[] = } }; -static ProcArg drawable_layer_outargs[] = +static ProcArg drawable_is_layer_outargs[] = { { PDB_INT32, @@ -906,9 +906,9 @@ static ProcArg drawable_layer_outargs[] = } }; -static ProcRecord drawable_layer_proc = +static ProcRecord drawable_is_layer_proc = { - "gimp_drawable_layer", + "gimp_drawable_is_layer", "Returns whether the drawable is a layer.", "This procedure returns non-zero if the specified drawable is a layer.", "Spencer Kimball & Peter Mattis", @@ -916,27 +916,27 @@ static ProcRecord drawable_layer_proc = "1995-1996", PDB_INTERNAL, 1, - drawable_layer_inargs, + drawable_is_layer_inargs, 1, - drawable_layer_outargs, - { { drawable_layer_invoker } } + drawable_is_layer_outargs, + { { drawable_is_layer_invoker } } }; static Argument * -drawable_layer_mask_invoker (Argument *args) +drawable_is_layer_mask_invoker (Argument *args) { Argument *return_args; GimpDrawable *drawable; drawable = gimp_drawable_get_ID (args[0].value.pdb_int); - return_args = procedural_db_return_args (&drawable_layer_mask_proc, TRUE); + return_args = procedural_db_return_args (&drawable_is_layer_mask_proc, TRUE); return_args[1].value.pdb_int = drawable_layer_mask (drawable) ? TRUE : FALSE; return return_args; } -static ProcArg drawable_layer_mask_inargs[] = +static ProcArg drawable_is_layer_mask_inargs[] = { { PDB_DRAWABLE, @@ -945,7 +945,7 @@ static ProcArg drawable_layer_mask_inargs[] = } }; -static ProcArg drawable_layer_mask_outargs[] = +static ProcArg drawable_is_layer_mask_outargs[] = { { PDB_INT32, @@ -954,9 +954,9 @@ static ProcArg drawable_layer_mask_outargs[] = } }; -static ProcRecord drawable_layer_mask_proc = +static ProcRecord drawable_is_layer_mask_proc = { - "gimp_drawable_layer_mask", + "gimp_drawable_is_layer_mask", "Returns whether the drawable is a layer mask.", "This procedure returns non-zero if the specified drawable is a layer mask.", "Spencer Kimball & Peter Mattis", @@ -964,27 +964,27 @@ static ProcRecord drawable_layer_mask_proc = "1995-1996", PDB_INTERNAL, 1, - drawable_layer_mask_inargs, + drawable_is_layer_mask_inargs, 1, - drawable_layer_mask_outargs, - { { drawable_layer_mask_invoker } } + drawable_is_layer_mask_outargs, + { { drawable_is_layer_mask_invoker } } }; static Argument * -drawable_channel_invoker (Argument *args) +drawable_is_channel_invoker (Argument *args) { Argument *return_args; GimpDrawable *drawable; drawable = gimp_drawable_get_ID (args[0].value.pdb_int); - return_args = procedural_db_return_args (&drawable_channel_proc, TRUE); + return_args = procedural_db_return_args (&drawable_is_channel_proc, TRUE); return_args[1].value.pdb_int = drawable_channel (drawable) ? TRUE : FALSE; return return_args; } -static ProcArg drawable_channel_inargs[] = +static ProcArg drawable_is_channel_inargs[] = { { PDB_DRAWABLE, @@ -993,7 +993,7 @@ static ProcArg drawable_channel_inargs[] = } }; -static ProcArg drawable_channel_outargs[] = +static ProcArg drawable_is_channel_outargs[] = { { PDB_INT32, @@ -1002,9 +1002,9 @@ static ProcArg drawable_channel_outargs[] = } }; -static ProcRecord drawable_channel_proc = +static ProcRecord drawable_is_channel_proc = { - "gimp_drawable_channel", + "gimp_drawable_is_channel", "Returns whether the drawable is a channel.", "This procedure returns non-zero if the specified drawable is a channel.", "Spencer Kimball & Peter Mattis", @@ -1012,10 +1012,10 @@ static ProcRecord drawable_channel_proc = "1995-1996", PDB_INTERNAL, 1, - drawable_channel_inargs, + drawable_is_channel_inargs, 1, - drawable_channel_outargs, - { { drawable_channel_invoker } } + drawable_is_channel_outargs, + { { drawable_is_channel_invoker } } }; static Argument * diff --git a/app/procedural_db.c b/app/procedural_db.c index 906fe7169d..b4f8e4ba2a 100644 --- a/app/procedural_db.c +++ b/app/procedural_db.c @@ -47,11 +47,24 @@ procedural_db_init (void) pdb_id_init (); } +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_destroy (procedural_ht); + { + g_hash_table_foreach (procedural_ht, procedural_db_free_entry, NULL); + g_hash_table_destroy (procedural_ht); + } + procedural_ht = NULL; } @@ -119,6 +132,16 @@ procedural_db_execute (gchar *name, list = g_hash_table_lookup (procedural_ht, (gpointer) name); + if (list == NULL) + { + g_message (_("PDB calling error %s not found"), name); + + return_args = (Argument *) g_malloc (sizeof (Argument)); + 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) diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb index d3ce138916..627c34525c 100644 --- a/tools/pdbgen/pdb/drawable.pdb +++ b/tools/pdbgen/pdb/drawable.pdb @@ -309,15 +309,15 @@ HELP %invoke = ( code => 'drawable_offsets (drawable, &offset_x, &offset_y);' ); } -sub drawable_layer { +sub drawable_is_layer { &drawable_is_proc('layer'); } -sub drawable_layer_mask { +sub drawable_is_layer_mask { &drawable_is_proc('layer mask'); } -sub drawable_channel { +sub drawable_is_channel { &drawable_is_proc('channel'); } @@ -509,8 +509,8 @@ CODE drawable_mask_bounds drawable_image drawable_type drawable_has_alpha drawable_type_with_alpha drawable_is_rgb drawable_is_gray drawable_is_indexed drawable_bytes drawable_width - drawable_height drawable_offsets drawable_layer - drawable_layer_mask drawable_channel drawable_get_pixel + drawable_height drawable_offsets drawable_is_layer + drawable_is_layer_mask drawable_is_channel drawable_get_pixel drawable_set_pixel drawable_set_image drawable_thumbnail); %exports = (app => [@procs], lib => [@procs]);