From fef490a10ecf21f9b88c90d6233043172200d577 Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Thu, 22 Jun 2000 03:21:20 +0000 Subject: [PATCH] initial pass of getting all the libgimp wrappers autogenned. -Yosh --- ChangeLog | 19 ++++++++++++++ tools/pdbgen/lib.pl | 37 +++++++++++++++++++++------- tools/pdbgen/pdb/brushes.pdb | 2 +- tools/pdbgen/pdb/channel.pdb | 2 +- tools/pdbgen/pdb/color.pdb | 2 +- tools/pdbgen/pdb/drawable.pdb | 3 ++- tools/pdbgen/pdb/gimprc.pdb | 2 +- tools/pdbgen/pdb/gradient_select.pdb | 2 +- tools/pdbgen/pdb/image.pdb | 8 +++--- tools/pdbgen/pdb/layer.pdb | 6 ++--- tools/pdbgen/pdb/parasite.pdb | 28 +-------------------- tools/pdbgen/pdb/plug_in.pdb | 2 +- tools/pdbgen/pdb/procedural_db.pdb | 8 +++--- tools/pdbgen/pdb/selection.pdb | 4 +-- tools/pdbgen/pdb/text_tool.pdb | 2 ++ tools/pdbgen/pdb/unit.pdb | 7 +++--- 16 files changed, 77 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index 547ffe84aa..0efc22e2d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +Wed Jun 21 20:18:16 PDT 2000 Manish Singh + + * tools/pdbgen/lib.pl + * tools/pdbgen/pdb/brushes.pdb + * tools/pdbgen/pdb/channel.pdb + * tools/pdbgen/pdb/color.pdb + * tools/pdbgen/pdb/drawable.pdb + * tools/pdbgen/pdb/gimprc.pdb + * tools/pdbgen/pdb/gradient_select.pdb + * tools/pdbgen/pdb/image.pdb + * tools/pdbgen/pdb/layer.pdb + * tools/pdbgen/pdb/parasite.pdb + * tools/pdbgen/pdb/plug_in.pdb + * tools/pdbgen/pdb/procedural_db.pdb + * tools/pdbgen/pdb/selection.pdb + * tools/pdbgen/pdb/text_tool.pdb + * tools/pdbgen/pdb/unit.pdb: initial pass of getting all the libgimp + wrappers autogenned. + 2000-06-19 Simon Budig * app/layers_dialog.c: Layers can be renamed by pressing diff --git a/tools/pdbgen/lib.pl b/tools/pdbgen/lib.pl index ed962e01bc..1d62edcce9 100644 --- a/tools/pdbgen/lib.pl +++ b/tools/pdbgen/lib.pl @@ -58,7 +58,7 @@ sub generate { my @inargs = @{$proc->{inargs}} if exists $proc->{inargs}; my @outargs = @{$proc->{outargs}} if exists $proc->{outargs}; - my $funcname = "gimp_$name"; + my $funcname = "gimp_$name"; my $wrapped = ""; # The 'color' argument is special cased to accept and return the # individual color components. This is to maintain backwards @@ -107,6 +107,8 @@ sub generate { my $arg = $arg_types{$type}; my $id = exists $arg->{id_func} || $_->{type} =~ /guide/; + $wrapped = "_" if exists $_->{wrap}; + if (exists $_->{implicit_fill}) { $privatevars++; } @@ -153,7 +155,7 @@ CODE if ($rettype ne 'void' || $retcol || $retvoid) { my $once = 0; my $firstvar; - my @arraynums; + my @initnums; foreach (@outargs) { my ($type) = &arg_parse($_->{type}); @@ -163,10 +165,12 @@ CODE $return_marshal = "" unless $once++; + $wrapped = "_" if exists $_->{wrap}; + if (exists $_->{num}) { if (!exists $_->{no_lib}) { $arglist .= "gint \*$_->{name}, "; - push @arraynums, $_; + push @initnums, $_; } } elsif (exists $_->{retval} && $type ne 'color') { @@ -193,7 +197,7 @@ CODE $return_args .= " = NULL"; } elsif ($arg->{type} =~ /boolean/) { - $return_args .= " = TRUE"; + $return_args .= " = FALSE"; } else { # Default to 0 @@ -206,10 +210,25 @@ CODE $return_args .= "\n" . ' ' x 2 . "gint num_$var;"; } } + elsif ($retvoid) { + push @initnums, $_; + } } - foreach (@arraynums) { $return_marshal .= "\*$_->{name} = 0;\n " } - $return_marshal =~ s/\n $/\n\n /s if scalar(@arraynums); + if (scalar(@initnums)) { + foreach (@initnums) { + $return_marshal .= "\*$_->{name} = "; + my ($type) = &arg_parse($_->{type}); + for ($arg_types{$type}->{type}) { + /\*$/ && do { $return_marshal .= "NULL"; last }; + /boolean/ && do { $return_marshal .= "FALSE"; last }; + /double/ && do { $return_marshal .= "0.0"; last }; + $return_marshal .= "0"; + } + $return_marshal .= ";\n "; + } + $return_marshal =~ s/\n $/\n\n /s; + } $return_marshal .= <{protos}}, $proto; my $clist = $arglist; - my $padlen = length($funcname) + 2; + my $padlen = length($wrapped) + length($funcname) + 2; my $padtab = $padlen / 8; my $padspace = $padlen % 8; my $padding = "\t" x $padtab . ' ' x $padspace; $clist =~ s/\t/$padding/eg; @@ -366,7 +385,7 @@ CODE $out->{code} .= < 'mask_data', type => 'int8array', init => 1, desc => 'The brush mask data', - array => { name => 'length', init => 1, no_lib => 1, + array => { name => 'length', init => 1, desc => 'Length of brush mask data' } }; %invoke = ( diff --git a/tools/pdbgen/pdb/channel.pdb b/tools/pdbgen/pdb/channel.pdb index 388f9f45de..95e81c1432 100644 --- a/tools/pdbgen/pdb/channel.pdb +++ b/tools/pdbgen/pdb/channel.pdb @@ -137,7 +137,7 @@ HELP $inargs[0]->{desc} .= ' to which to add the channel'; @outargs = ( - { name => 'channel', type => 'channel', + { name => 'channel', type => 'channel', wrap => 1, desc => 'The newly created channel', init => 1 } ); diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index 851df7d0bd..862303f913 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -568,7 +568,7 @@ HELP } @outargs = ( - { name => 'mean', + { name => 'mean', void_ret => 1, desc => 'Mean itensity value' }, { name => 'std_dev', desc => 'Standard deviation of intensity values' }, diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb index 97d7b6f8b4..314c004ba0 100644 --- a/tools/pdbgen/pdb/drawable.pdb +++ b/tools/pdbgen/pdb/drawable.pdb @@ -456,11 +456,12 @@ HELP @outargs = ( &dim_args, { name => 'thumbnail_data', type => 'int8array', - desc => 'The thumbnail data', init => 1, retval => 1, + desc => 'The thumbnail data', init => 1, wrap => 1, array => { name => 'thumbnail_data_count', desc => 'The number of pixels in thumbnail data', alias => 'num_pixels', init => 1 } } ); + $outargs[0]->{void_ret} = 1; %invoke = ( headers => [ qw( "channel.h" "layer.h") ], diff --git a/tools/pdbgen/pdb/gimprc.pdb b/tools/pdbgen/pdb/gimprc.pdb index a1d58fe551..1fe024fd8b 100644 --- a/tools/pdbgen/pdb/gimprc.pdb +++ b/tools/pdbgen/pdb/gimprc.pdb @@ -107,7 +107,7 @@ HELP @inargs = ( ); @outargs = ( - { name => 'xres', type => 'float', + { name => 'xres', type => 'float', void_ret => 1, desc => 'X resolution', alias => 'xres' }, { name => 'yres', type => 'float', desc => 'Y resolution', alias => 'yres' }, diff --git a/tools/pdbgen/pdb/gradient_select.pdb b/tools/pdbgen/pdb/gradient_select.pdb index 7bbcf59302..071c559643 100644 --- a/tools/pdbgen/pdb/gradient_select.pdb +++ b/tools/pdbgen/pdb/gradient_select.pdb @@ -177,7 +177,7 @@ HELP desc => 'The gradient name', alias => 'g_strdup (gradient->name)', no_declare => 1 }, { name => 'grad_data', type => 'floatarray', alias => 'values', - desc => 'The gradient sample data', init => 1, + desc => 'The gradient sample data', init => 1, wrap => 1, array => { name => 'width', desc => 'The gradient sample width (r,g,b,a)', alias => 'sample_size * 4', no_declare => 1 } } diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb index da73032cfa..35431eb715 100644 --- a/tools/pdbgen/pdb/image.pdb +++ b/tools/pdbgen/pdb/image.pdb @@ -760,7 +760,7 @@ HELP @inargs = ( &std_image_arg ); @outargs = ( - { name => 'cmap', type => 'int8array', init => 1, + { name => 'cmap', type => 'int8array', init => 1, wrap => 1, desc => "The image's colormap", array => { name => 'num_bytes', init => 1, desc => 'Number of bytes in the colormap array: @@ -792,7 +792,7 @@ HELP @inargs = ( &std_image_arg, - { name => 'cmap', type => 'int8array', + { name => 'cmap', type => 'int8array', wrap => 1, desc => "The new colormap values", array => { name => 'num_bytes', type => '0 <= int32 <= 768', desc => 'Number of bytes in the colormap array: @@ -1182,6 +1182,7 @@ HELP $date = '1998'; push @outargs, { %{$outargs[0]} }; + $outargs[0]->{void_ret} = 1; my $count = 0; foreach $coord (qw(x y)) { @@ -1318,12 +1319,13 @@ HELP @outargs = ( &preview_dim_args, - { name => 'thumbnail_data', type => 'int8array', + { name => 'thumbnail_data', type => 'int8array', wrap => 1, desc => 'The thumbnail data', init => 1, array => { name => 'thumbnail_data_count', desc => 'The number of bytes in thumbnail data', alias => 'num_bytes', init => 1 } } ); + $outargs[0]->{void_ret} = 1; %invoke = ( headers => [ qw() ], diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb index e62a8477a9..5b5673e6eb 100644 --- a/tools/pdbgen/pdb/layer.pdb +++ b/tools/pdbgen/pdb/layer.pdb @@ -229,7 +229,7 @@ HELP $inargs[0]->{desc} .= ' to which to add the layer'; @outargs = ( - { name => 'layer', type => 'layer', + { name => 'layer', type => 'layer', wrap => 1, desc => 'The newly created layer', init => 1 } ); @@ -266,7 +266,7 @@ HELP $inargs[0]->{desc} .= ' to copy'; @outargs = ( - { name => 'layer_copy', type => 'layer', init => 1, + { name => 'layer_copy', type => 'layer', init => 1, wrap => 1, desc => 'The newly copied layer', alias => 'copy' } ); @@ -517,7 +517,7 @@ CODE2 &layer_accessors('mode', 'enum LayerModeEffects', 'combination mode', 0, 0); -&layer_accessors('linked', 'int32', 'linked state', 0, 0, +&layer_accessors('linked', 'boolean', 'linked state', 0, 0, <<'CODE'); $author = $copyright = 'Wolfgang Hofer'; $date = '1998'; diff --git a/tools/pdbgen/pdb/parasite.pdb b/tools/pdbgen/pdb/parasite.pdb index 513404b30a..3e1a2fe51b 100644 --- a/tools/pdbgen/pdb/parasite.pdb +++ b/tools/pdbgen/pdb/parasite.pdb @@ -129,7 +129,7 @@ sub parasite_list { $date = '1999'; @outargs = ( - { name => 'parasites', type => 'stringarray', + { name => 'parasites', type => 'stringarray', void_ret => 1, desc => 'The names of currently attached parasites', array => { desc => 'The number of attached parasites' } } ); @@ -140,13 +140,6 @@ sub parasite_list { @headers = qw("gimpparasite.h" "gimpdrawable.h" "gimpimage.h"); -$extra{lib}->{protos} = <<'CODE'; -void gimp_parasite_attach_new (gchar *name, - gint flags, - gint size, - gpointer data); -CODE - $extra{lib}->{code} = <<'CODE'; void gimp_parasite_attach_new (gchar *name, @@ -169,8 +162,6 @@ CODE ['image' , '&std_image_arg', 'gimage' ] ); -my %code; - foreach $type (@types) { foreach (@procs[0..3]) { my $desc = ($type->[0] =~ /^[aeiou]/ ? 'an ' : 'a ') . $type->[0]; @@ -196,25 +187,8 @@ SUB push @procs, "$type->[0]_$_"; } - - foreach (qw(protos code)) { - my $code = $extra{lib}->{$_}; - $code =~ s/\t/' ' x 8/eg; - $code =~ s/gimp/gimp_$type->[0]/g; - $code =~ s/^ {8}/' ' x (length($type->[0]) + 9)/meg; - while ($code =~ /^\t* {8}/m) { $code =~ s/^(\t*) {8}/$1\t/mg } - - $code{$_} .= $code; - } } - -foreach (qw(protos code)) { - $extra{lib}->{$_} .= $code{$_}; -} - -chop $extra{lib}->{code}; - %exports = (app => [@procs], lib => [@procs]); $desc = 'Parasite procedures'; diff --git a/tools/pdbgen/pdb/plug_in.pdb b/tools/pdbgen/pdb/plug_in.pdb index d6d08ed0c7..04517ce0ed 100644 --- a/tools/pdbgen/pdb/plug_in.pdb +++ b/tools/pdbgen/pdb/plug_in.pdb @@ -50,7 +50,7 @@ HELP { name => 'gdisplay', type => 'int32', desc => 'GDisplay to update progressbar in, or -1 for a seperate window', - implicit_fill => '_gdisp_ID', no_id_lookup => 1 } + implicit_fill => 'gimp_default_display ()', no_id_lookup => 1 } ); %invoke = ( diff --git a/tools/pdbgen/pdb/procedural_db.pdb b/tools/pdbgen/pdb/procedural_db.pdb index 1599bc09c6..486f1da241 100644 --- a/tools/pdbgen/pdb/procedural_db.pdb +++ b/tools/pdbgen/pdb/procedural_db.pdb @@ -69,7 +69,7 @@ HELP @outargs = ( { name => "${type}_type", type => 'enum PDBArgType (no PDB_END)', - desc => "The type of $long_type { %%desc%% }", + desc => "The type of $long_type { %%desc%% }", wrap => 1, alias => "${type}->arg_type", no_declare => 1 }, { name => "${type}_name", type => 'string', desc => "The name of the $long_type", @@ -170,7 +170,7 @@ HELP 'GIMP Extension' }>; @outargs = ( - { name => 'procedure_names', type => 'stringarray', + { name => 'procedure_names', type => 'stringarray', void_ret => 1, desc => 'The list of procedure names', alias => 'pdb_query.list_of_procs', no_declare => 1, array => { name => 'num_matches', @@ -216,7 +216,7 @@ HELP @inargs = ( &proc_name_arg ); @outargs = ( - { name => 'blurb', type => 'string', void_ret => 1, + { name => 'blurb', type => 'string', void_ret => 1, wrap => 1, desc => 'A short blurb' }, { name => 'help', type => 'string', desc => 'Detailed procedure help' }, @@ -275,6 +275,7 @@ HELP @outargs = ( &data_arg ); $outargs[0]->{alias} = 'data_copy'; $outargs[0]->{init} = 1; + $outargs[0]->{wrap} = 1; %invoke = ( vars => [ 'PDBData *data = NULL', 'GList *list' ], @@ -356,6 +357,7 @@ HELP @inargs = ( &data_ident_arg, &data_arg ); $inargs[1]->{alias} = 'data_src'; + $inargs[1]->{wrap} = 1; delete @{$inargs[1]->{array}}{qw(alias no_declare)}; %invoke = ( diff --git a/tools/pdbgen/pdb/selection.pdb b/tools/pdbgen/pdb/selection.pdb index 02c832d258..d73bda038d 100644 --- a/tools/pdbgen/pdb/selection.pdb +++ b/tools/pdbgen/pdb/selection.pdb @@ -69,7 +69,7 @@ HELP @inargs = ( &std_image_arg ); @outargs = ( - { name => 'non_empty', type => 'boolean', + { name => 'non_empty', type => 'boolean', void_ret => 1, desc => 'True if there is a selection', init => 1 } ); @@ -165,7 +165,7 @@ HELP &coord_args('off$_', '$_ offset for translation', \@inargs); @outargs = ( - { name => 'layer', type => 'layer', + { name => 'layer', type => 'layer', wrap => 1, desc => 'The floated layer', init => 1 } ); diff --git a/tools/pdbgen/pdb/text_tool.pdb b/tools/pdbgen/pdb/text_tool.pdb index 08cf020d0e..1b8e86fb41 100644 --- a/tools/pdbgen/pdb/text_tool.pdb +++ b/tools/pdbgen/pdb/text_tool.pdb @@ -167,6 +167,7 @@ HELP ); &extents_outargs; + $outargs[0]->{void_ret} = 1; %invoke = ( vars => [ 'gchar *real_fontname' ], @@ -243,6 +244,7 @@ HELP ); &extents_outargs; + $outargs[0]->{void_ret} = 1; %invoke = ( pass_through => 'text_get_extents_fontname', diff --git a/tools/pdbgen/pdb/unit.pdb b/tools/pdbgen/pdb/unit.pdb index e2bf453dd9..563789a7fe 100644 --- a/tools/pdbgen/pdb/unit.pdb +++ b/tools/pdbgen/pdb/unit.pdb @@ -26,7 +26,8 @@ sub unit_arg () {{ name => 'unit_id', type => 'unit', desc => "The unit's integer ID", - alias => 'unit' + alias => 'unit', + wrap => 1 }} sub unit_prop_proc { @@ -60,7 +61,7 @@ sub unit_get_number_of_units { @outargs = ( { name => 'num_units', type => 'int32', libdef => 'GIMP_UNIT_END', - desc => 'The number of units', + desc => 'The number of units', wrap => 1, alias => 'gimp_unit_get_number_of_units ()', no_declare => 1 } ); } @@ -77,7 +78,7 @@ HELP &pdb_misc; @inargs = ( - { name => 'identifier', type => 'string', + { name => 'identifier', type => 'string', wrap => 1, desc => "The new unit's identifier" }, { name => 'factor', type => 'float', desc => "The new unit's factor" },