gimp/tools/pdbgen/pdb.pl

140 lines
4.6 KiB
Perl
Raw Normal View History

# The GIMP -- an image manipulation program
1999-03-20 07:04:16 +08:00
# Copyright (C) 1998-1999 Manish Singh <yosh@gimp.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package Gimp::CodeGen::pdb;
%arg_types = (
int32 => { name => 'INT32', type => 'gint32 ' },
int16 => { name => 'INT16', type => 'gint16 ' },
int8 => { name => 'INT8' , type => 'gint8 ' },
float => { name => 'FLOAT' , type => 'gdouble ' },
string => { name => 'STRING', type => 'gchar *' },
1999-03-11 02:56:56 +08:00
int32array => { name => 'INT32ARRAY' , type => 'gint32 *' , array => 1 },
int16array => { name => 'INT16ARRAY' , type => 'gint16 *' , array => 1 },
int8array => { name => 'INT8ARRAY' , type => 'gint8 *' , array => 1 },
floatarray => { name => 'FLOATARRAY' , type => 'gdouble *', array => 1 },
stringarray => { name => 'STRINGARRAY', type => 'gchar **' , array => 1 },
color => { name => 'COLOR' , type => 'guchar *' },
1999-03-18 07:08:08 +08:00
display => { name => 'DISPLAY',
type => 'GDisplay *',
1999-03-21 10:14:08 +08:00
headers => [ qw("gdisplay.h") ],
1999-03-18 07:08:08 +08:00
id_func => 'gdisplay_get_ID',
1999-03-21 10:14:08 +08:00
id_ret_func => '$var->ID' },
1999-03-18 07:08:08 +08:00
image => { name => 'IMAGE',
type => 'GimpImage *',
1999-03-21 10:14:08 +08:00
headers => [ qw("procedural_db.h") ],
1999-03-18 07:08:08 +08:00
id_func => 'pdb_id_to_image',
1999-03-21 10:14:08 +08:00
id_ret_func => 'pdb_image_to_id ($var)' },
1999-03-18 07:08:08 +08:00
layer => { name => 'LAYER',
type => 'GimpLayer *',
1999-03-21 10:14:08 +08:00
headers => [ qw("drawable.h" "layer.h") ],
1999-03-18 07:08:08 +08:00
id_func => 'layer_get_ID',
1999-03-21 10:14:08 +08:00
id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' },
1999-03-18 07:08:08 +08:00
channel => { name => 'CHANNEL',
type => 'Channel *',
1999-03-21 10:14:08 +08:00
headers => [ qw("drawable.h" "channel.h") ],
1999-03-18 07:08:08 +08:00
id_func => 'channel_get_ID',
1999-03-21 10:14:08 +08:00
id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' },
1999-03-18 07:08:08 +08:00
drawable => { name => 'DRAWABLE',
type => 'GimpDrawable *',
1999-03-21 10:14:08 +08:00
headers => [ qw("drawable.h") ],
1999-03-18 07:08:08 +08:00
id_func => 'gimp_drawable_get_ID',
1999-03-21 10:14:08 +08:00
id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' },
1999-03-18 07:08:08 +08:00
selection => { name => 'SELECTION',
type => 'Channel *',
1999-03-21 10:14:08 +08:00
headers => [ qw("drawable.h" "channel.h") ],
1999-03-18 07:08:08 +08:00
id_func => 'channel_get_ID',
1999-03-21 10:14:08 +08:00
id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' },
parasite => { name => 'PARASITE', type => 'Parasite *',
headers => [ qw("libgimp/parasite.h") ] },
boundary => { name => 'BOUNDARY', type => 'gpointer ' }, # ??? FIXME
path => { name => 'PATH' , type => 'gpointer ' }, # ??? FIXME
status => { name => 'STATUS' , type => 'gpointer ' }, # ??? FIXME
# Special cases
enum => { name => 'INT32', type => 'gint32 ' },
boolean => { name => 'INT32', type => 'gboolean ' },
1999-04-23 14:55:37 +08:00
tattoo => { name => 'INT32', type => 'gint32 ' },
1999-04-04 13:59:08 +08:00
unit => { name => 'INT32', type => 'GUnit ' },
1999-03-20 07:04:16 +08:00
region => { name => 'REGION', type => 'gpointer ' } # not supported
);
# Split out the parts of an arg constraint
sub arg_parse {
1999-04-04 13:59:08 +08:00
my %premap = (
'<' => '<=',
'>' => '>=',
'<=' => '<',
'>=' => '>'
);
my %postmap = (
'<' => '>=',
'>' => '<=',
'<=' => '>',
'>=' => '<'
1999-03-18 07:08:08 +08:00
);
my $arg = shift;
1999-03-18 07:08:08 +08:00
if ($arg =~ /^enum (\w+)(.*)/) {
my ($name, $remove) = ($1, $2);
my @retvals = ('enum', $name);
1999-03-28 14:36:11 +08:00
if ($remove && $remove =~ m@ \(no @) {
chop $remove; ($remove = substr($remove, 5)) =~ s/ $//;
1999-03-18 07:08:08 +08:00
push @retvals, split(/,\s*/, $remove);
}
return @retvals;
}
1999-04-04 13:59:08 +08:00
elsif ($arg =~ /^(?:([+-.\d][^\s]*) \s* (<=|<))?
1999-03-21 10:14:08 +08:00
\s* (\w+) \s*
1999-04-04 13:59:08 +08:00
(?:(<=|<) \s* ([+-.\d][^\s]*))?
1999-03-20 07:04:16 +08:00
/x) {
1999-04-04 13:59:08 +08:00
return ($3, $1, $2 ? $premap{$2} : $2, $5, $4 ? $postmap{$4} : $4);
}
}
# Return the marshaller data type
sub arg_ptype {
my $arg = shift;
do {
if (exists $arg->{id_func}) { 'int' }
elsif ($arg->{type} =~ /\*/) { 'pointer' }
elsif ($arg->{type} =~ /boolean/) { 'int' }
1999-04-04 13:59:08 +08:00
elsif ($arg->{type} =~ /GUnit/) { 'int' }
elsif ($arg->{type} =~ /int/) { 'int' }
1999-03-21 10:14:08 +08:00
elsif ($arg->{type} =~ /double/) { 'float' }
else { 'pointer' }
};
}
# Return the alias if defined, otherwise the name
sub arg_vname { exists $_[0]->{alias} ? $_[0]->{alias} : $_[0]->{name} }
1999-03-11 02:56:56 +08:00
sub arg_numtype () { 'gint32 ' }
1999-04-04 13:59:08 +08:00
1;