added a hack that allows to dynamically allocate the strings returned by a

2003-12-13  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/procedural_db.pdb: added a hack that allows to
	dynamically allocate the strings returned by a PDB query. Construct
	more useful "blurb" and "help" strings for deprecated procedures.

	* tools/pdbgen/pdb/image.pdb: did the same change manually for
	gimp_image_add,remove_layer_mask.

	* app/pdb/procedural_db_cmds.c
	* app/pdb/image_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2003-12-13 18:37:59 +00:00 committed by Michael Natterer
parent 57b67a92ed
commit 0c8d8e13d9
5 changed files with 60 additions and 30 deletions

View File

@ -1,3 +1,15 @@
2003-12-13 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/procedural_db.pdb: added a hack that allows to
dynamically allocate the strings returned by a PDB query. Construct
more useful "blurb" and "help" strings for deprecated procedures.
* tools/pdbgen/pdb/image.pdb: did the same change manually for
gimp_image_add,remove_layer_mask.
* app/pdb/procedural_db_cmds.c
* app/pdb/image_cmds.c: regenerated.
2003-12-13 DindinX <david@dindinx.org>
* plug-ins/libgimpoldpreview/gimpoldpreview.[ch]: fixed the header

View File

@ -2255,8 +2255,8 @@ static ProcArg image_add_layer_mask_inargs[] =
static ProcRecord image_add_layer_mask_proc =
{
"gimp_image_add_layer_mask",
"This procedure is deprecated! Use the procedure returned as 'help' instead.",
"gimp_layer_add_mask",
"This procedure is deprecated! Use 'gimp_layer_add_mask' instead.",
"This procedure is deprecated! Use 'gimp_layer_add_mask' instead.",
"",
"",
"",
@ -2317,8 +2317,8 @@ static ProcArg image_remove_layer_mask_inargs[] =
static ProcRecord image_remove_layer_mask_proc =
{
"gimp_image_remove_layer_mask",
"This procedure is deprecated! Use the procedure returned as 'help' instead.",
"gimp_layer_remove_mask",
"This procedure is deprecated! Use 'gimp_layer_remove_mask' instead.",
"This procedure is deprecated! Use 'gimp_layer_remove_mask' instead.",
"",
"",
"",

View File

@ -41,7 +41,7 @@
#endif
#define COMPAT_BLURB "This procedure is deprecated! Use the procedure returned as 'help' instead."
#define COMPAT_BLURB "This procedure is deprecated! Use '%s' instead."
/* Query structure */
@ -69,11 +69,13 @@ typedef struct _PDBStrings PDBStrings;
struct _PDBStrings
{
const gchar *blurb;
const gchar *help;
const gchar *author;
const gchar *copyright;
const gchar *date;
gboolean compat;
gchar *blurb;
gchar *help;
gchar *author;
gchar *copyright;
gchar *date;
};
static gchar *proc_type_str[] =
@ -148,10 +150,12 @@ get_pdb_strings (PDBStrings *strings,
ProcRecord *proc,
gboolean compat)
{
strings->compat = compat;
if (compat)
{
strings->blurb = COMPAT_BLURB;
strings->help = proc->name;
strings->blurb = g_strdup_printf (COMPAT_BLURB, proc->name);
strings->help = g_strdup (strings->blurb);
strings->author = NULL;
strings->copyright = NULL;
strings->date = NULL;
@ -205,6 +209,12 @@ procedural_db_query_entry (gpointer key,
pdb_query->num_procs);
pdb_query->list_of_procs[pdb_query->num_procs - 1] = g_strdup (proc_name);
}
if (strings.compat)
{
g_free (strings.blurb);
g_free (strings.help);
}
}
static gboolean
@ -574,11 +584,11 @@ procedural_db_proc_info_invoker (Gimp *gimp,
if (success)
{
return_args[1].value.pdb_pointer = g_strdup (strings.blurb);
return_args[2].value.pdb_pointer = g_strdup (strings.help);
return_args[3].value.pdb_pointer = g_strdup (strings.author);
return_args[4].value.pdb_pointer = g_strdup (strings.copyright);
return_args[5].value.pdb_pointer = g_strdup (strings.date);
return_args[1].value.pdb_pointer = strings.compat ? strings.blurb : g_strdup (strings.blurb);
return_args[2].value.pdb_pointer = strings.compat ? strings.help : g_strdup (strings.help);
return_args[3].value.pdb_pointer = strings.compat ? strings.author : g_strdup (strings.author);
return_args[4].value.pdb_pointer = strings.compat ? strings.copyright : g_strdup (strings.copyright);
return_args[5].value.pdb_pointer = strings.compat ? strings.date : g_strdup (strings.date);
return_args[6].value.pdb_int = proc->proc_type;
return_args[7].value.pdb_int = proc->num_args;
return_args[8].value.pdb_int = proc->num_values;

View File

@ -732,8 +732,7 @@ HELP
}
sub image_add_layer_mask {
$blurb = 'This procedure is deprecated! Use the procedure returned as \'help\' instead.';
$help = 'gimp_layer_add_mask';
$blurb = $help = 'This procedure is deprecated! Use \'gimp_layer_add_mask\' instead.';
$author = $copyright = $date = '';
@inargs = (
@ -757,8 +756,7 @@ CODE
}
sub image_remove_layer_mask {
$blurb = 'This procedure is deprecated! Use the procedure returned as \'help\' instead.';
$help = 'gimp_layer_remove_mask';
$blurb = $help = 'This procedure is deprecated! Use \'gimp_layer_remove_mask\' instead.';
$author = $copyright = $date = '';
@inargs = (

View File

@ -255,7 +255,7 @@ HELP
foreach (@outargs) {
if ($_->{type} eq 'string') {
$_->{alias} = "g_strdup (strings.$_->{name})";
$_->{alias} = "strings.compat ? strings.$_->{name} : g_strdup (strings.$_->{name})";
} else {
$_->{alias} = "proc->$_->{name}";
}
@ -390,7 +390,7 @@ HELP
@headers = qw(<string.h> "gimp-intl.h");
$extra{app}->{decls} = <<'CODE';
#define COMPAT_BLURB "This procedure is deprecated! Use the procedure returned as 'help' instead."
#define COMPAT_BLURB "This procedure is deprecated! Use '%s' instead."
/* Query structure */
@ -418,11 +418,13 @@ typedef struct _PDBStrings PDBStrings;
struct _PDBStrings
{
const gchar *blurb;
const gchar *help;
const gchar *author;
const gchar *copyright;
const gchar *date;
gboolean compat;
gchar *blurb;
gchar *help;
gchar *author;
gchar *copyright;
gchar *date;
};
static gchar *proc_type_str[] =
@ -459,10 +461,12 @@ get_pdb_strings (PDBStrings *strings,
ProcRecord *proc,
gboolean compat)
{
strings->compat = compat;
if (compat)
{
strings->blurb = COMPAT_BLURB;
strings->help = proc->name;
strings->blurb = g_strdup_printf (COMPAT_BLURB, proc->name);
strings->help = g_strdup (strings->blurb);
strings->author = NULL;
strings->copyright = NULL;
strings->date = NULL;
@ -516,6 +520,12 @@ procedural_db_query_entry (gpointer key,
pdb_query->num_procs);
pdb_query->list_of_procs[pdb_query->num_procs - 1] = g_strdup (proc_name);
}
if (strings.compat)
{
g_free (strings.blurb);
g_free (strings.help);
}
}
static gboolean