[glibmm] gmmproc: _WRAP_METHOD: Allow multi-word parameter types (unsigned int)
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] gmmproc: _WRAP_METHOD: Allow multi-word parameter types (unsigned int)
- Date: Sat, 28 Jun 2014 08:33:34 +0000 (UTC)
commit f5d402464a62948492198001d282f2b9965a9dcb
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sat Jun 28 10:22:29 2014 +0200
gmmproc: _WRAP_METHOD: Allow multi-word parameter types (unsigned int)
* tools/pm/Function.pm: parse_param(): Allow multi-word parameter types,
as in _WRAP_METHOD(void set_button(unsigned int button = 0),
gtk_gesture_single_set_button).
Affects _WRAP_METHOD, _WRAP_SIGNAL, _WRAP_CTOR, _WRAP_CREATE, _WRAP_VFUNC.
tools/pm/Function.pm | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/tools/pm/Function.pm b/tools/pm/Function.pm
index 592e3f4..728187b 100644
--- a/tools/pm/Function.pm
+++ b/tools/pm/Function.pm
@@ -179,15 +179,14 @@ sub num_args #($)
}
# parses C++ parameter lists.
-# forms a list of types, names, and initial values
-# (we don't currently use values)
+# forms a list of types, names, and default values
sub parse_param($$)
{
my ($self, $line) = @_;
-
my $type = "";
my $name = "";
+ my $name_pos = -1;
my $value = "";
my $id = 0;
my $has_value = 0;
@@ -254,6 +253,7 @@ sub parse_param($$)
}
elsif ( $_ eq "=" ) #Default value
{
+ $str[$name_pos] = "" if ($name_pos >= 0);
$type = join("", @str); #The type is everything before the = character.
@str = (); #Wipe it so that it will only contain the default value, which comes next.
$has_value = 1;
@@ -267,6 +267,7 @@ sub parse_param($$)
}
else
{
+ $str[$name_pos] = "" if ($name_pos >= 0);
$type = join("", @str);
}
@@ -291,6 +292,7 @@ sub parse_param($$)
$value = "";
$has_value = 0;
$name = "";
+ $name_pos = -1;
$flags = 0;
$curr_param++;
@@ -308,16 +310,16 @@ sub parse_param($$)
next;
}
+ # The last identifier before ',', '=', or '{.*}' is the parameter name.
+ # E.g. int name, unsigned long int name = 42, const unsigned int& name.
+ # The name must be preceded by at least one other identifier (the type).
+ # 'const ' is treated specially, as it can't by itself denote the type.
$id++;
- $name = $_ if ($id == 2);
- push(@str, $_) if ($id == 1);
-
- if ($id > 2)
+ push(@str, $_);
+ if ($id >= 2)
{
- print STDERR "Can't parse $line.\n";
- print STDERR " arg type so far: $type\n";
- print STDERR " arg name so far: $name\n";
- print STDERR " arg default value so far: $value\n";
+ $name = $_;
+ $name_pos = $#str;
}
}
@@ -328,6 +330,7 @@ sub parse_param($$)
}
else
{
+ $str[$name_pos] = "" if ($name_pos >= 0);
$type = join("", @str);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]