Commit d831bdb3 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/pdb/procedural_db.h removed pdb_type_name() uglyness.

2005-05-14  Michael Natterer  <mitch@gimp.org>

	* app/pdb/procedural_db.h
	* tools/pdbgen/pdb/procedural_db.pdb: removed pdb_type_name()
	uglyness.

	* app/pdb/procedural_db.c: add private function
	procedural_db_type_name() instead which uses gimp_enum_get_value()
	and always returns a newly allocated string. Use it for the error
	messages.

	* app/pdb/procedural_db_cmds.c: regenerated.
parent 284076b0
2005-05-14 Michael Natterer <mitch@gimp.org>
* app/pdb/procedural_db.h
* tools/pdbgen/pdb/procedural_db.pdb: removed pdb_type_name()
uglyness.
* app/pdb/procedural_db.c: add private function
procedural_db_type_name() instead which uses gimp_enum_get_value()
and always returns a newly allocated string. Use it for the error
messages.
* app/pdb/procedural_db_cmds.c: regenerated.
2005-05-13 Michael Natterer <mitch@gimp.org>
* plug-ins/dbbrowser/gimpprocbrowser.c
......
......@@ -50,6 +50,13 @@ struct _PDBData
};
/* local function prototypes */
gchar * procedural_db_type_name (GimpPDBArgType type);
/* public functions */
void
procedural_db_init (Gimp *gimp)
{
......@@ -272,11 +279,18 @@ procedural_db_execute (Gimp *gimp,
{
if (args[i].arg_type != procedure->args[i].arg_type)
{
gchar *expected;
gchar *got;
expected = procedural_db_type_name (procedure->args[i].arg_type);
got = procedural_db_type_name (args[i].arg_type);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
procedure->name, i + 1,
pdb_type_name (procedure->args[i].arg_type),
pdb_type_name (args[i].arg_type));
procedure->name, i + 1, expected, got);
g_free (expected);
g_free (got);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -384,13 +398,21 @@ procedural_db_run_proc (Gimp *gimp,
if (proc->args[i].arg_type != params[i].arg_type)
{
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1,
pdb_type_name (proc->args[i].arg_type),
pdb_type_name (params[i].arg_type));
gchar *expected;
gchar *got;
expected = procedural_db_type_name (proc->args[i].arg_type);
got = procedural_db_type_name (params[i].arg_type);
g_free (params);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1, expected, got);
g_free (expected);
g_free (got);
*nreturn_vals = 0;
return NULL;
}
......@@ -642,3 +664,20 @@ procedural_db_get_data (Gimp *gimp,
return NULL;
}
/* private functions */
gchar *
procedural_db_type_name (GimpPDBArgType type)
{
const gchar *name;
if (! gimp_enum_get_value (GIMP_TYPE_PDB_ARG_TYPE, type,
&name, NULL, NULL, NULL))
{
return g_strdup_printf ("(PDB type %d unknown)", type);
}
return g_strdup (name);
}
......@@ -164,10 +164,4 @@ const guint8 * procedural_db_get_data (Gimp *gimp,
gint32 *bytes);
/* "type" should really be a GimpPDBArgType, 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__ */
......@@ -50,6 +50,13 @@ struct _PDBData
};
/* local function prototypes */
gchar * procedural_db_type_name (GimpPDBArgType type);
/* public functions */
void
procedural_db_init (Gimp *gimp)
{
......@@ -272,11 +279,18 @@ procedural_db_execute (Gimp *gimp,
{
if (args[i].arg_type != procedure->args[i].arg_type)
{
gchar *expected;
gchar *got;
expected = procedural_db_type_name (procedure->args[i].arg_type);
got = procedural_db_type_name (args[i].arg_type);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
procedure->name, i + 1,
pdb_type_name (procedure->args[i].arg_type),
pdb_type_name (args[i].arg_type));
procedure->name, i + 1, expected, got);
g_free (expected);
g_free (got);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -384,13 +398,21 @@ procedural_db_run_proc (Gimp *gimp,
if (proc->args[i].arg_type != params[i].arg_type)
{
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1,
pdb_type_name (proc->args[i].arg_type),
pdb_type_name (params[i].arg_type));
gchar *expected;
gchar *got;
expected = procedural_db_type_name (proc->args[i].arg_type);
got = procedural_db_type_name (params[i].arg_type);
g_free (params);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1, expected, got);
g_free (expected);
g_free (got);
*nreturn_vals = 0;
return NULL;
}
......@@ -642,3 +664,20 @@ procedural_db_get_data (Gimp *gimp,
return NULL;
}
/* private functions */
gchar *
procedural_db_type_name (GimpPDBArgType type)
{
const gchar *name;
if (! gimp_enum_get_value (GIMP_TYPE_PDB_ARG_TYPE, type,
&name, NULL, NULL, NULL))
{
return g_strdup_printf ("(PDB type %d unknown)", type);
}
return g_strdup (name);
}
......@@ -164,10 +164,4 @@ const guint8 * procedural_db_get_data (Gimp *gimp,
gint32 *bytes);
/* "type" should really be a GimpPDBArgType, 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__ */
......@@ -50,6 +50,13 @@ struct _PDBData
};
/* local function prototypes */
gchar * procedural_db_type_name (GimpPDBArgType type);
/* public functions */
void
procedural_db_init (Gimp *gimp)
{
......@@ -272,11 +279,18 @@ procedural_db_execute (Gimp *gimp,
{
if (args[i].arg_type != procedure->args[i].arg_type)
{
gchar *expected;
gchar *got;
expected = procedural_db_type_name (procedure->args[i].arg_type);
got = procedural_db_type_name (args[i].arg_type);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
procedure->name, i + 1,
pdb_type_name (procedure->args[i].arg_type),
pdb_type_name (args[i].arg_type));
procedure->name, i + 1, expected, got);
g_free (expected);
g_free (got);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -384,13 +398,21 @@ procedural_db_run_proc (Gimp *gimp,
if (proc->args[i].arg_type != params[i].arg_type)
{
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1,
pdb_type_name (proc->args[i].arg_type),
pdb_type_name (params[i].arg_type));
gchar *expected;
gchar *got;
expected = procedural_db_type_name (proc->args[i].arg_type);
got = procedural_db_type_name (params[i].arg_type);
g_free (params);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1, expected, got);
g_free (expected);
g_free (got);
*nreturn_vals = 0;
return NULL;
}
......@@ -642,3 +664,20 @@ procedural_db_get_data (Gimp *gimp,
return NULL;
}
/* private functions */
gchar *
procedural_db_type_name (GimpPDBArgType type)
{
const gchar *name;
if (! gimp_enum_get_value (GIMP_TYPE_PDB_ARG_TYPE, type,
&name, NULL, NULL, NULL))
{
return g_strdup_printf ("(PDB type %d unknown)", type);
}
return g_strdup (name);
}
......@@ -164,10 +164,4 @@ const guint8 * procedural_db_get_data (Gimp *gimp,
gint32 *bytes);
/* "type" should really be a GimpPDBArgType, 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__ */
......@@ -50,6 +50,13 @@ struct _PDBData
};
/* local function prototypes */
gchar * procedural_db_type_name (GimpPDBArgType type);
/* public functions */
void
procedural_db_init (Gimp *gimp)
{
......@@ -272,11 +279,18 @@ procedural_db_execute (Gimp *gimp,
{
if (args[i].arg_type != procedure->args[i].arg_type)
{
gchar *expected;
gchar *got;
expected = procedural_db_type_name (procedure->args[i].arg_type);
got = procedural_db_type_name (args[i].arg_type);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
procedure->name, i + 1,
pdb_type_name (procedure->args[i].arg_type),
pdb_type_name (args[i].arg_type));
procedure->name, i + 1, expected, got);
g_free (expected);
g_free (got);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -384,13 +398,21 @@ procedural_db_run_proc (Gimp *gimp,
if (proc->args[i].arg_type != params[i].arg_type)
{
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1,
pdb_type_name (proc->args[i].arg_type),
pdb_type_name (params[i].arg_type));
gchar *expected;
gchar *got;
expected = procedural_db_type_name (proc->args[i].arg_type);
got = procedural_db_type_name (params[i].arg_type);
g_free (params);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1, expected, got);
g_free (expected);
g_free (got);
*nreturn_vals = 0;
return NULL;
}
......@@ -642,3 +664,20 @@ procedural_db_get_data (Gimp *gimp,
return NULL;
}
/* private functions */
gchar *
procedural_db_type_name (GimpPDBArgType type)
{
const gchar *name;
if (! gimp_enum_get_value (GIMP_TYPE_PDB_ARG_TYPE, type,
&name, NULL, NULL, NULL))
{
return g_strdup_printf ("(PDB type %d unknown)", type);
}
return g_strdup (name);
}
......@@ -164,10 +164,4 @@ const guint8 * procedural_db_get_data (Gimp *gimp,
gint32 *bytes);
/* "type" should really be a GimpPDBArgType, 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__ */
......@@ -317,21 +317,6 @@ procedural_db_print_entry (gpointer key,
g_string_free (buf, TRUE);
}
/* This really doesn't belong here, but it depends on our generated type_str
* array.
*/
const char *
pdb_type_name (gint type)
{
if (type >= 0 && type <= GIMP_PDB_END)
return type_str[type];
else
return g_strdup_printf ("(PDB type %d unknown)", type);
/* Yeah, we leak the memory. But then you shouldn't try and
* get the name of a PDB type that doesn't exist, should you.
*/
}
static Argument *
procedural_db_temp_name_invoker (Gimp *gimp,
GimpContext *context,
......
......@@ -663,21 +663,6 @@ procedural_db_print_entry (gpointer key,
g_string_free (buf, TRUE);
}
/* This really doesn't belong here, but it depends on our generated type_str
* array.
*/
const char *
pdb_type_name (gint type)
{
if (type >= 0 && type <= GIMP_PDB_END)
return type_str[type];
else
return g_strdup_printf ("(PDB type %d unknown)", type);
/* Yeah, we leak the memory. But then you shouldn't try and
* get the name of a PDB type that doesn't exist, should you.
*/
}
CODE
@procs = qw(procedural_db_temp_name procedural_db_dump
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment