PIKApp/pdb/pdb.pl

520 lines
25 KiB
Perl
Raw Normal View History

2023-09-26 00:35:21 +02:00
# PIKA - Photo and Image Kooker Application
# Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
package Pika::CodeGen::pdb;
%arg_types = (
int32 => { name => 'INT32',
gtype => 'G_TYPE_INT',
type => 'gint ',
const_type => 'gint ',
init_value => '0',
get_value_func => '$var = g_value_get_int ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_INT ($value)',
set_value_func => 'g_value_set_int ($value, $var)',
take_value_func => 'g_value_set_int ($value, $var)' },
uchar => { name => 'UCHAR',
gtype => 'G_TYPE_UCHAR',
type => 'guchar ',
const_type => 'guchar ',
init_value => '0',
get_value_func => '$var = g_value_get_uchar ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_UCHAR ($value)',
set_value_func => 'g_value_set_uchar ($value, $var)',
take_value_func => 'g_value_set_uchar ($value, $var)' },
float => { name => 'FLOAT',
gtype => 'G_TYPE_DOUBLE',
type => 'gdouble ',
const_type => 'gdouble ',
init_value => '0.0',
get_value_func => '$var = g_value_get_double ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_DOUBLE ($value)',
set_value_func => 'g_value_set_double ($value, $var)',
take_value_func => 'g_value_set_double ($value, $var)' },
string => { name => 'STRING',
gtype => 'G_TYPE_STRING',
type => 'gchar *',
const_type => 'const gchar *',
init_value => 'NULL',
out_annotate => '(transfer full)',
get_value_func => '$var = g_value_get_string ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_STRING ($value)',
set_value_func => 'g_value_set_string ($value, $var)',
take_value_func => 'g_value_take_string ($value, $var)' },
strv => { name => 'STRV',
gtype => 'G_TYPE_STRV',
type => 'gchar **',
const_type => 'const gchar **',
init_value => 'NULL',
in_annotate => '(array zero-terminated=1)',
out_annotate => '(array zero-terminated=1) (transfer full)',
get_value_func => '$var = g_value_get_boxed ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_STRV ($value)',
set_value_func => 'g_value_set_boxed ($value, $var)',
take_value_func => 'g_value_take_boxed ($value, $var)' },
bytes => { name => 'BYTES',
gtype => 'G_TYPE_BYTES',
type => 'GBytes *',
const_type => 'GBytes *',
init_value => 'NULL',
out_annotate => '(transfer full)',
get_value_func => '$var = g_value_get_boxed ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_BYTES ($value)',
set_value_func => 'g_value_set_boxed ($value, $var)',
take_value_func => 'g_value_take_boxed ($value, $var)' },
int32array => { name => 'INT32ARRAY',
gtype => 'PIKA_TYPE_INT32_ARRAY',
type => 'gint32 *',
const_type => 'const gint32 *',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type gint32)',
out_annotate => '(element-type gint32) (transfer full)',
get_value_func => '$var = pika_value_get_int32_array ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_INT32_ARRAY ($value)',
set_value_func => 'pika_value_set_int32_array ($value, $var, $var_len)',
take_value_func => 'pika_value_take_int32_array ($value, $var, $var_len)' },
floatarray => { name => 'FLOATARRAY',
gtype => 'PIKA_TYPE_FLOAT_ARRAY',
type => 'gdouble *',
const_type => 'const gdouble *',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type gdouble)',
out_annotate => '(element-type gdouble) (transfer full)',
get_value_func => '$var = pika_value_get_float_array ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_FLOAT_ARRAY ($value)',
set_value_func => 'pika_value_set_float_array ($value, $var, $var_len)',
take_value_func => 'pika_value_take_float_array ($value, $var, $var_len)' },
colorarray => { name => 'COLORARRAY',
gtype => 'PIKA_TYPE_RGB_ARRAY',
type => 'PikaRGB *',
const_type => 'const PikaRGB *',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type PikaRGB)',
out_annotate => '(element-type PikaRGB) (transfer full)',
get_value_func => '$var = pika_value_get_rgb_array ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_RGB_ARRAY ($value)',
set_value_func => 'pika_value_set_rgb_array ($value, $var, $var_len)',
take_value_func => 'pika_value_take_rgb_array ($value, $var, $var_len)' },
imagearray => { name => 'IMAGEARRAY',
gtype => 'PIKA_TYPE_OBJECT_ARRAY',
type => 'PikaImage **',
const_type => 'const PikaImage **',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type PikaImage)',
out_annotate => '(element-type PikaImage) (transfer container)',
get_value_func => '$var = (const PikaImage **) pika_value_get_object_array ($value)',
dup_value_func => '{ PikaObjectArray *a = g_value_get_boxed (pika_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
set_value_func => 'pika_value_set_object_array ($value, PIKA_TYPE_IMAGE, (GObject **) $var, $var_len)',
take_value_func => 'pika_value_take_object_array ($value, PIKA_TYPE_IMAGE, (GObject **) $var, $var_len)' },
itemarray => { name => 'ITEMARRAY',
gtype => 'PIKA_TYPE_OBJECT_ARRAY',
type => 'PikaItem **',
const_type => 'const PikaItem **',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type PikaItem)',
out_annotate => '(element-type PikaItem) (transfer container)',
get_value_func => '$var = (const PikaItem **) pika_value_get_object_array ($value)',
dup_value_func => '{ PikaObjectArray *a = g_value_get_boxed (pika_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
set_value_func => 'pika_value_set_object_array ($value, PIKA_TYPE_ITEM, (GObject **) $var, $var_len)',
take_value_func => 'pika_value_take_object_array ($value, PIKA_TYPE_ITEM, (GObject **) $var, $var_len)' },
layerarray => { name => 'LAYERARRAY',
gtype => 'PIKA_TYPE_OBJECT_ARRAY',
type => 'PikaLayer **',
const_type => 'const PikaLayer **',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type PikaLayer)',
out_annotate => '(element-type PikaLayer) (transfer container)',
get_value_func => '$var = (const PikaLayer **) pika_value_get_object_array ($value)',
dup_value_func => '{ PikaObjectArray *a = g_value_get_boxed (pika_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
set_value_func => 'pika_value_set_object_array ($value, PIKA_TYPE_LAYER, (GObject **) $var, $var_len)',
take_value_func => 'pika_value_take_object_array ($value, PIKA_TYPE_LAYER, (GObject **) $var, $var_len)' },
channelarray => { name => 'CHANNELARRAY',
gtype => 'PIKA_TYPE_OBJECT_ARRAY',
type => 'PikaChannel **',
const_type => 'const PikaChannel **',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type PikaChannel)',
out_annotate => '(element-type PikaChannel) (transfer container)',
get_value_func => '$var = (const PikaChannel **) pika_value_get_object_array ($value)',
dup_value_func => '{ PikaObjectArray *a = g_value_get_boxed (pika_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
set_value_func => 'pika_value_set_object_array ($value, PIKA_TYPE_CHANNEL, (GObject **) $var, $var_len)',
take_value_func => 'pika_value_take_object_array ($value, PIKA_TYPE_CHANNEL, (GObject **) $var, $var_len)' },
vectorarray => { name => 'VECTORSARRAY',
gtype => 'PIKA_TYPE_OBJECT_ARRAY',
type => 'PikaVectors **',
const_type => 'const PikaVectors **',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type PikaVectors)',
out_annotate => '(element-type PikaVectors) (transfer container)',
get_value_func => '$var = (const PikaVectors **) pika_value_get_object_array ($value)',
dup_value_func => '{ PikaObjectArray *a = g_value_get_boxed (pika_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
set_value_func => 'pika_value_set_object_array ($value, PIKA_TYPE_VECTORS, (GObject **) $var, $var_len)',
take_value_func => 'pika_value_take_object_array ($value, PIKA_TYPE_VECTORS, (GObject **) $var, $var_len)' },
color => { name => 'COLOR',
gtype => 'PIKA_TYPE_RGB',
type => 'PikaRGB ',
const_type => 'PikaRGB ',
struct => 1,
init_value => '{ 0.0, 0.0, 0.0, 1.0 }',
get_value_func => 'pika_value_get_rgb ($value, &$var)',
dup_value_func => 'PIKA_VALUES_GET_RGB ($value, &$var)',
set_value_func => 'pika_value_set_rgb ($value, $var)',
take_value_func => 'pika_value_set_rgb ($value, &$var)',
headers => [ qw(<cairo.h> "libpikacolor/pikacolor.h") ] },
display => { name => 'DISPLAY',
gtype => 'PIKA_TYPE_DISPLAY',
type => 'PikaDisplay *',
const_type => 'PikaDisplay *',
app_type => 'PikaDisplay *',
app_const_type => 'PikaDisplay *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_DISPLAY ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)' },
image => { name => 'IMAGE',
gtype => 'PIKA_TYPE_IMAGE',
type => 'PikaImage *',
const_type => 'PikaImage *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_IMAGE ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikaimage.h") ] },
item => { name => 'ITEM',
gtype => 'PIKA_TYPE_ITEM',
type => 'PikaItem *',
const_type => 'PikaItem *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_ITEM ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikaitem.h") ] },
layer => { name => 'LAYER',
gtype => 'PIKA_TYPE_LAYER',
type => 'PikaLayer *',
const_type => 'PikaLayer *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_LAYER ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikalayer.h") ] },
text_layer => { name => 'TEXT_LAYER',
gtype => 'PIKA_TYPE_TEXT_LAYER',
type => 'PikaTextLayer *',
const_type => 'PikaTextLayer *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_TEXT_LAYER ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("text/pikatextlayer.h") ] },
channel => { name => 'CHANNEL',
gtype => 'PIKA_TYPE_CHANNEL',
type => 'PikaChannel *',
const_type => 'PikaChannel *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_CHANNEL ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikachannel.h") ] },
drawable => { name => 'DRAWABLE',
gtype => 'PIKA_TYPE_DRAWABLE',
type => 'PikaDrawable *',
const_type => 'PikaDrawable *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_DRAWABLE ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikadrawable.h") ] },
selection => { name => 'SELECTION',
gtype => 'PIKA_TYPE_SELECTION',
type => 'PikaSelection *',
const_type => 'PikaSelection *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_SELECTION ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikaselection.h") ] },
layer_mask => { name => 'CHANNEL',
gtype => 'PIKA_TYPE_LAYER_MASK',
type => 'PikaLayerMask *',
const_type => 'PikaLayerMask *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_LAYER_MASK ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikalayermask.h") ] },
vectors => { name => 'VECTORS',
gtype => 'PIKA_TYPE_VECTORS',
type => 'PikaVectors *',
const_type => 'PikaVectors *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_VECTORS ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("vectors/pikavectors.h") ] },
file => { name => 'FILE',
gtype => 'G_TYPE_FILE',
type => 'GFile *',
const_type => 'GFile *',
init_value => 'NULL',
out_annotate => '(transfer full)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_FILE ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)' },
parasite => { name => 'PARASITE',
gtype => 'PIKA_TYPE_PARASITE',
type => 'PikaParasite *',
const_type => 'const PikaParasite *',
init_value => 'NULL',
out_annotate => '(transfer full)',
get_value_func => '$var = g_value_get_boxed ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_PARASITE ($value)',
set_value_func => 'g_value_set_boxed ($value, $var)',
take_value_func => 'g_value_take_boxed ($value, $var)',
headers => [ qw("libpikabase/pikabase.h") ] },
param => { name => 'PARAM',
gtype => 'G_TYPE_PARAM_SPEC',
type => 'GParamSpec *',
const_type => 'GParamSpec *',
init_value => 'NULL',
out_annotate => '(transfer full)',
get_value_func => '$var = g_value_get_param ($value)',
dup_value_func => '$var = PIKA_VALUES_DUP_PARAM ($value)',
set_value_func => 'g_value_set_param ($value, $var)',
take_value_func => 'g_value_take_param ($value, $var)' },
# Special cases
enum => { name => 'ENUM',
gtype => 'G_TYPE_ENUM',
type => 'gint ',
const_type => 'gint ',
init_value => '0',
get_value_func => '$var = g_value_get_enum ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_ENUM ($value)',
set_value_func => 'g_value_set_enum ($value, $var)',
take_value_func => 'g_value_set_enum ($value, $var)' },
boolean => { name => 'BOOLEAN',
gtype => 'G_TYPE_BOOLEAN',
type => 'gboolean ',
const_type => 'gboolean ',
init_value => 'FALSE',
get_value_func => '$var = g_value_get_boolean ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_BOOLEAN ($value)',
set_value_func => 'g_value_set_boolean ($value, $var)',
take_value_func => 'g_value_set_boolean ($value, $var)' },
tattoo => { name => 'TATTOO',
gtype => 'G_TYPE_UINT',
type => 'guint ',
const_type => 'guint ',
init_value => '0',
get_value_func => '$var = g_value_get_uint ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_UINT ($value)',
set_value_func => 'g_value_set_uint ($value, $var)',
take_value_func => 'g_value_set_uint ($value, $var)' },
guide => { name => 'GUIDE',
gtype => 'G_TYPE_UINT',
type => 'guint ',
const_type => 'guint ',
init_value => '0',
get_value_func => '$var = g_value_get_uint ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_UINT ($value)',
set_value_func => 'g_value_set_uint ($value, $var)',
take_value_func => 'g_value_set_uint ($value, $var)' },
sample_point => { name => 'SAMPLE_POINT',
gtype => 'G_TYPE_UINT',
type => 'guint ',
const_type => 'guint ',
init_value => '0',
get_value_func => '$var = g_value_get_uint ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_UINT ($value)',
set_value_func => 'g_value_set_uint ($value, $var)',
take_value_func => 'g_value_set_uint ($value, $var)' },
unit => { name => 'UNIT',
gtype => 'PIKA_TYPE_UNIT',
type => 'PikaUnit ',
const_type => 'PikaUnit ',
init_value => 'PIKA_UNIT_PIXEL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_int ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_INT ($value)',
set_value_func => 'g_value_set_int ($value, $var)',
take_value_func => 'g_value_set_int ($value, $var)' },
resource => { name => 'RESOURCE',
gtype => 'PIKA_TYPE_RESOURCE',
type => 'PikaResource *',
const_type => 'PikaResource *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_RESOURCE ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikaresource.h") ] },
brush => { name => 'BRUSH',
gtype => 'PIKA_TYPE_BRUSH',
type => 'PikaBrush *',
const_type => 'PikaBrush *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_BRUSH ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikabrush.h") ] },
pattern => { name => 'PATTERN',
gtype => 'PIKA_TYPE_PATTERN',
type => 'PikaPattern *',
const_type => 'PikaPattern *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_PATTERN ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikapattern.h") ] },
gradient => { name => 'GRADIENT',
gtype => 'PIKA_TYPE_GRADIENT',
type => 'PikaGradient *',
const_type => 'PikaGradient *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_GRADIENT ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikagradient.h") ] },
palette => { name => 'PALETTE',
gtype => 'PIKA_TYPE_PALETTE',
type => 'PikaPalette *',
const_type => 'PikaPalette *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_PALETTE ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/pikapalette.h") ] },
font => { name => 'FONT',
gtype => 'PIKA_TYPE_FONT',
type => 'PikaFont *',
const_type => 'PikaFont *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = PIKA_VALUES_GET_FONT ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("text/pikafont.h") ] }
);
# Split out the parts of an arg constraint
sub arg_parse {
my $arg = shift;
if ($arg =~ /^enum (\w+)(.*)/) {
my ($name, $remove) = ($1, $2);
my @retvals = ('enum', $name);
if ($remove && $remove =~ m@ \(no @) {
chop $remove; ($remove = substr($remove, 5)) =~ s/ $//;
push @retvals, split(/,\s*/, $remove);
}
return @retvals;
}
elsif ($arg =~ /^unit(?: \(min (.*?)\))?/) {
my @retvals = ('unit');
push @retvals, $1 if $1;
return @retvals;
}
elsif ($arg =~ /^(?:([+-.\dA-Z_][^\s]*) \s* (<=|<))?
\s* (\w+) \s*
(?:(<=|<) \s* ([+-.\dA-Z_][^\s]*))?
/x) {
return ($3, $1, $2, $5, $4);
}
}
1;