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

removed support for invoke->pass_through.

2006-03-22  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/app.pl: removed support for invoke->pass_through.

	* tools/pdbgen/pdb/fileops.pdb: added a C utility function and
	call it from both register_load_handler() and
	register_magic_load_handler() instead of letting the generated
	invokers call each other.

	* app/pdb/fileops_cmds.c: regenerated.
parent dfc1fbde
2006-03-22 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/app.pl: removed support for invoke->pass_through.
* tools/pdbgen/pdb/fileops.pdb: added a C utility function and
call it from both register_load_handler() and
register_magic_load_handler() instead of letting the generated
invokers call each other.
* app/pdb/fileops_cmds.c: regenerated.
2006-03-22 Michael Natterer <mitch@gimp.org>
 
* tools/pdbgen/pdb/buffer.pdb
......
......@@ -84,6 +84,55 @@ register_fileops_procs (Gimp *gimp)
procedural_db_register (gimp, &register_thumbnail_loader_proc);
}
static gboolean
fileops_register_magic_load_handler (Gimp *gimp,
const gchar *procedure_name,
const gchar *extensions,
const gchar *prefixes,
const gchar *magics)
{
ProcRecord *proc;
PlugInProcDef *file_proc;
gchar *canonical;
gboolean success = FALSE;
canonical = gimp_canonicalize_identifier (procedure_name);
proc = procedural_db_lookup (gimp, canonical);
if (proc && ((proc->num_args < 3) ||
(proc->num_values < 1) ||
(proc->args[0].arg_type != GIMP_PDB_INT32) ||
(proc->args[1].arg_type != GIMP_PDB_STRING) ||
(proc->args[2].arg_type != GIMP_PDB_STRING) ||
(proc->values[0].arg_type != GIMP_PDB_IMAGE)))
{
g_message ("load handler \"%s\" does not take the standard load handler args",
canonical);
goto done;
}
file_proc = plug_ins_file_register_magic (gimp, canonical,
extensions, prefixes, magics);
if (! file_proc)
{
g_message ("attempt to register nonexistent load handler \"%s\"",
canonical);
goto done;
}
if (! g_slist_find (gimp->load_procs, file_proc))
gimp->load_procs = g_slist_prepend (gimp->load_procs, file_proc);
success = TRUE;
done:
g_free (canonical);
return success;
}
static Argument *
file_load_invoker (Gimp *gimp,
GimpContext *context,
......@@ -687,45 +736,9 @@ register_magic_load_handler_invoker (Gimp *gimp,
if (success)
{
ProcRecord *proc;
PlugInProcDef *file_proc;
gchar *canonical;
success = FALSE;
canonical = gimp_canonicalize_identifier (procedure_name);
proc = procedural_db_lookup (gimp, canonical);
if (proc && ((proc->num_args < 3) ||
(proc->num_values < 1) ||
(proc->args[0].arg_type != GIMP_PDB_INT32) ||
(proc->args[1].arg_type != GIMP_PDB_STRING) ||
(proc->args[2].arg_type != GIMP_PDB_STRING) ||
(proc->values[0].arg_type != GIMP_PDB_IMAGE)))
{
g_message ("load handler \"%s\" does not take the standard load handler args",
canonical);
goto done;
}
file_proc = plug_ins_file_register_magic (gimp, canonical,
extensions, prefixes, magics);
if (! file_proc)
{
g_message ("attempt to register nonexistent load handler \"%s\"",
canonical);
goto done;
}
if (! g_slist_find (gimp->load_procs, file_proc))
gimp->load_procs = g_slist_prepend (gimp->load_procs, file_proc);
success = TRUE;
done:
g_free (canonical);
success = fileops_register_magic_load_handler (gimp,
procedure_name,
extensions, prefixes, magics);
}
return procedural_db_return_args (&register_magic_load_handler_proc, success);
......@@ -779,16 +792,27 @@ register_load_handler_invoker (Gimp *gimp,
GimpProgress *progress,
Argument *args)
{
int i;
Argument argv[4];
gboolean success = TRUE;
gchar *procedure_name;
gchar *extensions;
gchar *prefixes;
for (i = 0; i < 3; i++)
argv[i] = args[i];
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
argv[3].arg_type = GIMP_PDB_STRING;
argv[3].value.pdb_pointer = NULL;
extensions = (gchar *) args[1].value.pdb_pointer;
prefixes = (gchar *) args[2].value.pdb_pointer;
if (success)
{
success = fileops_register_magic_load_handler (gimp,
procedure_name,
extensions, prefixes, NULL);
}
return register_magic_load_handler_invoker (gimp, context, progress, argv);
return procedural_db_return_args (&register_load_handler_proc, success);
}
static ProcArg register_load_handler_inargs[] =
......
......@@ -463,89 +463,6 @@ CODE
$code .= "\n" if length($code);
$code .= &format_code_frag($custom, 0) . "}\n";
}
elsif (exists $proc->{invoke}->{pass_through}) {
my $invoke = $proc->{invoke};
my $argc = 0;
$argc += @{$invoke->{pass_args}} if exists $invoke->{pass_args};
$argc += @{$invoke->{make_args}} if exists $invoke->{make_args};
my %pass; my @passgroup;
my $before = 0; my $contig = 0; my $pos = -1;
if (exists $invoke->{pass_args}) {
foreach (@{$invoke->{pass_args}}) {
$pass{$_}++;
$_ - 1 == $before ? $contig = 1 : $pos++;
push @{$passgroup[$pos]}, $_;
$before = $_;
}
}
$code .= ' ' x 2 . "int i;\n" if $contig;
$code .= ' ' x 2 . "Argument argv[$argc];\n";
my $tempproc; $pos = 0;
foreach (@{$proc->{inargs}}) {
$_->{argpos} = $pos++;
push @{$tempproc->{inargs}}, $_ if !exists $pass{$_->{argpos}};
}
$code .= &declare_args($tempproc, $out, 0, qw(inargs)) . "\n";
my $marshal = "";
foreach (@{$tempproc->{inargs}}) {
my $argproc; $argproc->{inargs} = [ $_ ];
$marshal .= &marshal_inargs($argproc, $_->{argpos});
chop $marshal;
}
$marshal .= "\n" if $marshal;
if ($success) {
$marshal .= <<CODE;
if (!success)
return procedural_db_return_args (\&${name}_proc, FALSE);
CODE
}
$marshal = substr($marshal, 1) if $marshal;
$code .= $marshal;
foreach (@passgroup) {
$code .= ($#$_ ? <<LOOP : <<CODE) . "\n";
for (i = $_->[0]; i < @{[ $_->[$#$_] + 1 ]}; i++)
argv[i] = args[i];
LOOP
argv[$_->[0]] = args[$_->[0]];
CODE
}
if (exists $invoke->{make_args}) {
$pos = 0;
foreach (@{$invoke->{make_args}}) {
while (exists $pass{$pos}) { $pos++ }
my $arg = $arg_types{(&arg_parse($_->{type}))[0]};
my $type = &arg_ptype($arg);
$code .= <<CODE;
argv[$pos].arg_type = GIMP_PDB_$arg->{name};
CODE
my $frag = $_->{code};
$frag =~ s/%%arg%%/"argv[$pos].value.pdb_$type"/e;
$code .= &format_code_frag($frag, 0);
$pos++;
}
$code .= "\n";
}
$code .= <<CODE;
return $invoke->{pass_through}_invoker (gimp, context, progress, argv);
}
CODE
}
else {
my $invoker = "";
......
......@@ -428,45 +428,9 @@ HELP
%invoke = (
code => <<'CODE'
{
ProcRecord *proc;
PlugInProcDef *file_proc;
gchar *canonical;
success = FALSE;
canonical = gimp_canonicalize_identifier (procedure_name);
proc = procedural_db_lookup (gimp, canonical);
if (proc && ((proc->num_args < 3) ||
(proc->num_values < 1) ||
(proc->args[0].arg_type != GIMP_PDB_INT32) ||
(proc->args[1].arg_type != GIMP_PDB_STRING) ||
(proc->args[2].arg_type != GIMP_PDB_STRING) ||
(proc->values[0].arg_type != GIMP_PDB_IMAGE)))
{
g_message ("load handler \"%s\" does not take the standard load handler args",
canonical);
goto done;
}
file_proc = plug_ins_file_register_magic (gimp, canonical,
extensions, prefixes, magics);
if (! file_proc)
{
g_message ("attempt to register nonexistent load handler \"%s\"",
canonical);
goto done;
}
if (! g_slist_find (gimp->load_procs, file_proc))
gimp->load_procs = g_slist_prepend (gimp->load_procs, file_proc);
success = TRUE;
done:
g_free (canonical);
success = fileops_register_magic_load_handler (gimp,
procedure_name,
extensions, prefixes, magics);
}
CODE
);
......@@ -493,10 +457,15 @@ HELP
can load (i.e. "http:,ftp:")' }
);
%invoke = (
pass_through => 'register_magic_load_handler',
pass_args => [ 0..2 ],
make_args => [ { type => 'string', code => '%%arg%% = NULL;' } ]
code => <<'CODE'
{
success = fileops_register_magic_load_handler (gimp,
procedure_name,
extensions, prefixes, NULL);
}
CODE
);
}
......@@ -637,6 +606,59 @@ CODE
);
}
$extra{app}->{code} = <<'CODE';
static gboolean
fileops_register_magic_load_handler (Gimp *gimp,
const gchar *procedure_name,
const gchar *extensions,
const gchar *prefixes,
const gchar *magics)
{
ProcRecord *proc;
PlugInProcDef *file_proc;
gchar *canonical;
gboolean success = FALSE;
canonical = gimp_canonicalize_identifier (procedure_name);
proc = procedural_db_lookup (gimp, canonical);
if (proc && ((proc->num_args < 3) ||
(proc->num_values < 1) ||
(proc->args[0].arg_type != GIMP_PDB_INT32) ||
(proc->args[1].arg_type != GIMP_PDB_STRING) ||
(proc->args[2].arg_type != GIMP_PDB_STRING) ||
(proc->values[0].arg_type != GIMP_PDB_IMAGE)))
{
g_message ("load handler \"%s\" does not take the standard load handler args",
canonical);
goto done;
}
file_proc = plug_ins_file_register_magic (gimp, canonical,
extensions, prefixes, magics);
if (! file_proc)
{
g_message ("attempt to register nonexistent load handler \"%s\"",
canonical);
goto done;
}
if (! g_slist_find (gimp->load_procs, file_proc))
gimp->load_procs = g_slist_prepend (gimp->load_procs, file_proc);
success = TRUE;
done:
g_free (canonical);
return success;
}
CODE
@headers = qw(<sys/types.h> <unistd.h> <gdk-pixbuf/gdk-pixbuf.h>
"libgimpbase/gimpbase.h" "libgimpconfig/gimpconfig.h"
"libgimpthumb/gimpthumb.h"
......
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