[glibmm/gmmproc-refactor: 4/5] Another chaotic work.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/gmmproc-refactor: 4/5] Another chaotic work.
- Date: Wed, 26 Jan 2011 18:56:32 +0000 (UTC)
commit 0314eeadef1e5a603cec23d3f29ead2283c3b47b
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Wed Jan 26 16:11:39 2011 +0100
Another chaotic work.
tools/pm/Function.pm | 34 ++++++---------
tools/pm/FunctionBase.pm | 107 +++++++++++++++++++++++++++-------------------
tools/pm/GtkDefs.pm | 2 +-
tools/pm/Util.pm | 19 +-------
tools/pm/WrapParser.pm | 56 ++++++++++++------------
5 files changed, 108 insertions(+), 110 deletions(-)
---
diff --git a/tools/pm/Function.pm b/tools/pm/Function.pm
index d0537bb..60d4d41 100644
--- a/tools/pm/Function.pm
+++ b/tools/pm/Function.pm
@@ -3,22 +3,7 @@ package Function;
use strict;
use warnings;
use Util;
-use FunctionBase;
-
-BEGIN {
- use Exporter ();
- our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
-
- # set the version for version checking
- $VERSION = 1.00;
- @ISA = qw(FunctionBase);
- @EXPORT = qw(&func1 &func2 &func4);
- %EXPORT_TAGS = ( );
- # your exported package globals go here,
- # as well as any optionally exported functions
- @EXPORT_OK = qw($Var1 %Hashit &func3);
- }
-our @EXPORT_OK;
+use base qw (FunctionBase);
##################################################
### Function
@@ -41,6 +26,15 @@ our @EXPORT_OK;
# string entity_type. e.g. method or signal
# }
+sub new ($)
+{
+ my $type = shift;
+ my $class = ref ($type) or $type or "Function";
+ my $self = $class->SUPER->new ();
+
+ $self->{}
+}
+
sub new_empty()
{
my $self = {};
@@ -169,7 +163,7 @@ sub parse_param($$)
my $param_default_values = $$self{param_default_values};
# clean up space and handle empty case
- $line = string_trim($line);
+ $line = Util::string_trim($line);
$line =~ s/\s+/ /g; # Compress whitespace.
return if ($line =~ /^$/);
@@ -220,7 +214,7 @@ sub parse_param($$)
$name = sprintf("p%s", $#$param_types + 2)
}
- $type = string_trim($type);
+ $type = Util::string_trim($type);
push(@$param_types, $type);
push(@$param_names, $name);
@@ -272,7 +266,7 @@ sub parse_param($$)
$name = sprintf("p%s", $#$param_types + 2)
}
- $type = string_trim($type);
+ $type = Util::string_trim($type);
push(@$param_types, $type);
push(@$param_names, $name);
@@ -293,7 +287,7 @@ sub add_parameter_autoname($$)
sub add_parameter($$$)
{
my ($self, $type, $name) = @_;
- $type = string_unquote($type);
+ $type = Util::string_unquote($type);
$type =~ s/-/ /g;
my $param_names = $$self{param_names};
diff --git a/tools/pm/FunctionBase.pm b/tools/pm/FunctionBase.pm
index 00c1c05..f594645 100644
--- a/tools/pm/FunctionBase.pm
+++ b/tools/pm/FunctionBase.pm
@@ -4,74 +4,92 @@ use strict;
use warnings;
use Util;
-BEGIN {
- use Exporter ();
- our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
-
- # set the version for version checking
- $VERSION = 1.00;
- @ISA = qw(Exporter);
- @EXPORT = qw(&func1 &func2 &func4);
- %EXPORT_TAGS = ( );
- # your exported package globals go here,
- # as well as any optionally exported functions
- @EXPORT_OK = qw($Var1 %Hashit &func3);
- }
-our @EXPORT_OK;
-
##################################################
### FunctionBase
# Contains data and methods used by both Function (C++ declarations) and GtkDefs::Function (C defs descriptions)
# Note that GtkDefs::Signal inherits from GtkDefs::Function so it get these methods too.
#
-# class Function : FunctionBase
+# class FunctionBase
# {
# string array param_types;
# string array param_names;
-# string array param_documentation;
-# string return_documention;
# }
+my $g_p_t = 'param_types';
+my $g_p_n = 'param_names';
+
+sub new ($)
+{
+ my $type = shift;
+ my $class = ref ($type) or $type or "FunctionBase";
+ my $self =
+ {
+ $g_p_t => [];
+ $g_p_n => [];
+ };
+
+ bless ($self, $class);
+ return $self;
+}
+
+sub get_param_types ($)
+{
+ my $self = shift;
+
+ return $self->{$g_p_t};
+}
+
+sub set_param_types ($$)
+{
+ my $self = shift;
+ my $param_types = shift;
+
+ $self->{$g_p_t} = shift;
+}
+
+sub get_param_names ($)
+{
+ my $self = shift;
+
+ return $self->{$g_p_n};
+}
+
+sub set_param_names ($$)
+{
+ my $self = shift;
+ my $param_names = shift;
+
+ $self->{$g_p_n} = shift;
+}
# $string args_types_only($)
# comma-delimited argument types.
sub args_types_only($)
{
- my ($self) = @_;
+ my $self = shift;
- my $param_types = $$self{param_types};
- return join(", ", @$param_types);
+ return join(", ", @{$self->{$g_p_t}});
}
# $string args_names_only($)
sub args_names_only($)
{
- my ($self) = @_;
+ my $self = shift;
- my $param_names = $$self{param_names};
- return join(", ", @$param_names);
+ return join(", ", @{$self->{$g_p_n}});
}
# $string args_types_and_names($)
sub args_types_and_names($)
{
- my ($self) = @_;
-
- my $i;
-
- my $param_names = $$self{param_names};
- my $param_types = $$self{param_types};
+ my $self = shift;
+ my $param_types = $self->{$g_p_t};
+ my $param_names = $self->{$g_p_n};
my @out;
- #debugging:
- #if($#$param_types)
- #{
- # return "NOARGS";
- #}
-
- for ($i = 0; $i < $#$param_types + 1; $i++)
+ for (my $i = 0; $i < @{$param_types}; ++$i)
{
- my $str = sprintf("%s %s", $$param_types[$i], $$param_names[$i]);
+ my $str = $param_typessprintf("%s %s", $$param_types[$i], $$param_names[$i]);
push(@out, $str);
}
@@ -79,10 +97,11 @@ sub args_types_and_names($)
return $result;
}
+# TODO: is it used anywhere?
# $string args_names_only_without_object($)
sub args_names_only_without_object2($)
{
- my ($self) = @_;
+ my $self = shift;
my $param_names = $$self{param_names};
@@ -111,7 +130,7 @@ sub args_names_only_without_object2($)
# $string args_types_and_names_without_object($)
sub args_types_and_names_without_object($)
{
- my ($self) = @_;
+ my $self = shift;
my $param_names = $$self{param_names};
my $param_types = $$self{param_types};
@@ -126,11 +145,11 @@ sub args_types_and_names_without_object($)
return join(", ", @out);
}
-
+# TODO: is it used anywhere?
# $string args_names_only_without_object($)
sub args_names_only_without_object($)
{
- my ($self) = @_;
+ my $self = shift;
my $param_names = $$self{param_names};
@@ -158,7 +177,7 @@ sub args_names_only_without_object($)
sub dump($)
{
- my ($self) = @_;
+ my $self = shift;
my $param_types = $$self{param_types};
my $param_names = $$self{param_names};
@@ -186,7 +205,7 @@ sub dump($)
sub args_types_and_names_with_default_values($)
{
- my ($self) = @_;
+ my $self = shift;
my $i;
diff --git a/tools/pm/GtkDefs.pm b/tools/pm/GtkDefs.pm
index ba91490..9fbcf27 100644
--- a/tools/pm/GtkDefs.pm
+++ b/tools/pm/GtkDefs.pm
@@ -404,7 +404,7 @@ sub get_unwrapped ($)
push @targets, grep {$_->is_marked () == 1} values %{$self->{$g_p}};
# find the classes which used them.
- my @classes = join (" ", unique (map { $_->get_class ()} @targets));
+ my @classes = join (" ", Util::unique (map { $_->get_class ()} @targets));
# find methods which are in those classes which didn't get marked.
my @unwrapped = ();
diff --git a/tools/pm/Util.pm b/tools/pm/Util.pm
index c3076b4..edf48dc 100644
--- a/tools/pm/Util.pm
+++ b/tools/pm/Util.pm
@@ -22,26 +22,10 @@
# request them by module name.
#
package Util;
+
use strict;
use warnings;
-BEGIN {
- use Exporter ();
- our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
-
- # set the version for version checking
- $VERSION = 1.00;
- @ISA = qw(Exporter);
- @EXPORT = qw(&string_unquote &string_trim &string_canonical
- &trace &unique);
- %EXPORT_TAGS = ( );
-
- # your exported package globals go here,
- # as well as any optionally exported functions
- # EXPORT_OK = qw($Var1 %Hashit &func3);
- }
-our @EXPORT_OK;
-
#$ string_unquote($string)
# Removes leading and trailing quotes.
@@ -75,6 +59,7 @@ sub string_canonical($)
return $_;
}
+# TODO: is this function used anywhere?
#
# Back tracing utility.
# Prints the call stack.
diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm
index b2affbc..34799ee 100644
--- a/tools/pm/WrapParser.pm
+++ b/tools/pm/WrapParser.pm
@@ -441,7 +441,7 @@ sub on_namespace($)
if ($token eq '{')
{
- $arg = string_trim($arg);
+ $arg = Util::string_trim($arg);
if ($$self{first_namespace})
{
@@ -482,8 +482,8 @@ sub on_ignore_signal($)
{
my ($self) = @_;
my $str = $self->extract_bracketed_text();
- $str = string_trim($str);
- $str = string_unquote($str);
+ $str = Util::string_trim($str);
+ $str = Util::string_unquote($str);
my @args = split(/\s+|,/,$str);
foreach (@args)
{
@@ -512,8 +512,8 @@ sub on_class($$)
my $str = $self->extract_bracketed_text();
my ($class, $c_class) = split(',',$str);
- $class = string_trim($class);
- $c_class = string_trim($c_class);
+ $class = Util::string_trim($class);
+ $c_class = Util::string_trim($c_class);
$$self{class} = $class;
$$self{c_class} = $c_class;
@@ -884,7 +884,7 @@ sub on_wrap_method($)
# handle second argument:
my $argCFunctionName = $args[1];
- $argCFunctionName = string_trim($argCFunctionName);
+ $argCFunctionName = Util::string_trim($argCFunctionName);
#Get the c function's details:
@@ -907,7 +907,7 @@ sub on_wrap_method($)
my $ifdef;
while($#args >= 2) # If the optional ref/err/deprecated arguments are there.
{
- my $argRef = string_trim(pop @args);
+ my $argRef = Util::string_trim(pop @args);
#print "debug arg=$argRef\n";
if($argRef eq "refreturn")
{
@@ -927,7 +927,7 @@ sub on_wrap_method($)
if($1 ne "")
{
- $deprecation_docs = string_unquote(string_trim($1));
+ $deprecation_docs = Util::string_unquote(Util::string_trim($1));
}
}
elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
@@ -974,7 +974,7 @@ sub on_wrap_method_docs_only($)
# handle first argument
my $argCFunctionName = $args[0];
- $argCFunctionName = string_trim($argCFunctionName);
+ $argCFunctionName = Util::string_trim($argCFunctionName);
# Get the C function's details:
@@ -994,7 +994,7 @@ sub on_wrap_method_docs_only($)
# Extra ref needed?
while($#args >= 1) # If the optional ref/err arguments are there.
{
- my $argRef = string_trim(pop @args);
+ my $argRef = Util::string_trim(pop @args);
if($argRef eq "errthrow")
{
$$objCfunc{throw_any_errors} = 1;
@@ -1048,7 +1048,7 @@ sub on_wrap_ctor($)
# handle second argument:
my $argCFunctionName = $args[1];
- $argCFunctionName = string_trim($argCFunctionName);
+ $argCFunctionName = Util::string_trim($argCFunctionName);
#Get the C function's details:
if ($argCFunctionName =~ m/^\S+$/s)
@@ -1086,10 +1086,10 @@ sub on_implements_interface($$)
my $ifdef;
while($#args >= 1) # If the optional ref/err/deprecated arguments are there.
{
- my $argRef = string_trim(pop @args);
+ my $argRef = Util::string_trim(pop @args);
if($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
{
- $ifdef = $1;
+ $ifdef = $1;
}
}
my $objOutputter = $$self{objOutputter};
@@ -1126,8 +1126,8 @@ sub on_wrap_signal($$)
#Get the arguments:
my $argCppDecl = $args[0];
my $argCName = $args[1];
- $argCName = string_trim($argCName);
- $argCName = string_unquote($argCName);
+ $argCName = Util::string_trim($argCName);
+ $argCName = Util::string_unquote($argCName);
my $bCustomDefaultHandler = 0;
my $bNoDefaultHandler = 0;
@@ -1137,7 +1137,7 @@ sub on_wrap_signal($$)
while($#args >= 2) # If optional arguments are there.
{
- my $argRef = string_trim(pop @args);
+ my $argRef = Util::string_trim(pop @args);
if($argRef eq "custom_default_handler")
{
$bCustomDefaultHandler = 1;
@@ -1184,8 +1184,8 @@ sub on_wrap_vfunc($)
#Get the arguments:
my $argCppDecl = $args[0];
my $argCName = $args[1];
- $argCName = string_trim($argCName);
- $argCName = string_unquote($argCName);
+ $argCName = Util::string_trim($argCName);
+ $argCName = Util::string_unquote($argCName);
my $refreturn = 0;
my $refreturn_ctype = 0;
@@ -1194,7 +1194,7 @@ sub on_wrap_vfunc($)
# Extra ref needed?
while($#args >= 2) # If the optional ref/err arguments are there.
{
- my $argRef = string_trim(pop @args);
+ my $argRef = Util::string_trim(pop @args);
if($argRef eq "refreturn")
{ $refreturn = 1; }
@@ -1222,8 +1222,8 @@ sub on_wrap_enum($)
# get the arguments
my @args = string_split_commas($self->extract_bracketed_text());
- my $cpp_type = string_trim(shift(@args));
- my $c_type = string_trim(shift(@args));
+ my $cpp_type = Util::string_trim(shift(@args));
+ my $c_type = Util::string_trim(shift(@args));
# The remaining elements in @args could be flags or s#^FOO_## substitutions.
@@ -1240,9 +1240,9 @@ sub on_wrap_gerror($)
# get the arguments
my @args = string_split_commas($self->extract_bracketed_text());
- my $cpp_type = string_trim(shift(@args));
- my $c_enum = string_trim(shift(@args));
- my $domain = string_trim(shift(@args));
+ my $cpp_type = Util::string_trim(shift(@args));
+ my $c_enum = Util::string_trim(shift(@args));
+ my $domain = Util::string_trim(shift(@args));
# The remaining elements in @args could be flags or s#^FOO_## substitutions.
@@ -1262,8 +1262,8 @@ sub on_wrap_property($)
#Get the arguments:
my $argPropertyName = $args[0];
- $argPropertyName = string_trim($argPropertyName);
- $argPropertyName = string_unquote($argPropertyName);
+ $argPropertyName = Util::string_trim($argPropertyName);
+ $argPropertyName = Util::string_unquote($argPropertyName);
#Convert the property name to a canonical form, as it is inside gobject.
#Otherwise, gobject might not recognise the name,
@@ -1271,8 +1271,8 @@ sub on_wrap_property($)
$argPropertyName =~ tr/_/-/;
my $argCppType = $args[1];
- $argCppType = string_trim($argCppType);
- $argCppType = string_unquote($argCppType);
+ $argCppType = Util::string_trim($argCppType);
+ $argCppType = Util::string_unquote($argCppType);
my $filename = $$self{filename};
my $line_num = $$self{line_num};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]