[glibmm] gmmproc: _WRAP_CTOR: Handle *_new() functions with a final GError**.
- From: Josà Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] gmmproc: _WRAP_CTOR: Handle *_new() functions with a final GError**.
- Date: Fri, 9 Nov 2012 15:32:45 +0000 (UTC)
commit c40bed9a3c496f7d84071094e6e3c3c337b6acb8
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date: Fri Nov 9 10:31:40 2012 -0500
gmmproc: _WRAP_CTOR: Handle *_new() functions with a final GError**.
* tools/pm/WrapParser.pm (on_wrap_ctor): Add code to parse an
additional "errthrow" optional option in a _WRAP_CTOR() macro.
* tools/pm/Output.pm (output_wrap_ctor): Pass the "errorthrow" option
along as a string to:
(get_ctor_properties): Ignore the final GError** parameter of the C
*_new() function because it does not form part of the property list
that the constructor to has to set.
Bug #687959.
ChangeLog | 14 ++++++++++++++
tools/pm/Output.pm | 33 ++++++++++++++++++++++++---------
tools/pm/WrapParser.pm | 16 ++++++++++++++++
3 files changed, 54 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2ee1854..e6b339e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-11-08 Josà Alburquerque <jaalburquerque gmail com>
+
+ gmmproc: _WRAP_CTOR: Handle *_new() functions with a final GError**.
+
+ * tools/pm/WrapParser.pm (on_wrap_ctor): Add code to parse an
+ additional "errthrow" optional option in a _WRAP_CTOR() macro.
+ * tools/pm/Output.pm (output_wrap_ctor): Pass the "errorthrow" option
+ along as a string to:
+ (get_ctor_properties): Ignore the final GError** parameter of the C
+ *_new() function because it does not form part of the property list
+ that the constructor to has to set.
+
+ Bug #687959.
+
2012-11-07 Josà Alburquerque <jaalburquerque gmail com>
DesktopAppInfo: Add some new getter methods.
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 071ae97..1efad7b 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -470,12 +470,18 @@ sub output_wrap_ctor($$$$$)
#TODO: Add explicit.
$self->append(" explicit " . $objCppfunc->get_declaration($arg_list) . "\n");
+ my $errthrow = "";
+ if($$objCDefsFunc{throw_any_errors})
+ {
+ $errthrow = "errthrow";
+ }
+
#Implementation:
my $str = sprintf("_CTOR_IMPL(%s,%s,\`%s\',\`%s\')dnl\n",
$$objCppfunc{name},
$$objCDefsFunc{c_name},
$objCppfunc->args_types_and_names($arg_list),
- get_ctor_properties($objCppfunc, $objCDefsFunc, $line_num, $arg_list)
+ get_ctor_properties($objCppfunc, $objCDefsFunc, $line_num, $errthrow, $arg_list)
);
$self->append($str);
@@ -1099,15 +1105,21 @@ sub convert_args_c_to_cpp($$$)
}
-# generates the XXX in g_object_new(get_type(), XXX): A list of property names and values.
-# Uses the cpp arg name as the property name.
-# The optional index specifies which arg list out of the possible combination
-# of arguments based on whether any arguments are optional. index = 0 ==> all
-# the arguments.
-# $string get_ctor_properties($objCppfunc, $objCDefsFunc, $wrap_line_number, $index = 0)
-sub get_ctor_properties($$$$$)
+# generates the XXX in g_object_new(get_type(), XXX): A list of property names
+# and values. Uses the cpp arg name as the property name.
+#
+# - The optional index specifies which arg list out of the possible combination
+# of arguments based on whether any arguments are optional. index = 0 ==> all
+# the arguments.
+#
+# - The errthrow parameter tells if the C new function has a final GError**
+# parameter. That parameter is ignored since it will not form part of the
+# property list.
+#
+# $string get_ctor_properties($objCppfunc, $objCDefsFunc, $wrap_line_number, $errthrow, $index = 0)
+sub get_ctor_properties($$$$$$)
{
- my ($objCppfunc, $objCDefsFunc, $wrap_line_number, $index) = @_;
+ my ($objCppfunc, $objCDefsFunc, $wrap_line_number, $errthrow, $index) = @_;
$index = 0 unless defined $index;
@@ -1122,6 +1134,9 @@ sub get_ctor_properties($$$$$)
my $num_args = scalar(@{$c_param_types});
+ # If the C function has a final GError** parameter, ignore it.
+ $num_args-- if ($errthrow eq "errthrow");
+
my $num_cpp_args = scalar(@{$cpp_param_types});
if ( $num_cpp_args != $num_args )
{
diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm
index ca100e8..4ce03a7 100644
--- a/tools/pm/WrapParser.pm
+++ b/tools/pm/WrapParser.pm
@@ -1071,6 +1071,22 @@ sub on_wrap_ctor($)
}
}
+ # Handle options (presently only "errthrow" is recognized).
+ $$objCfunc{throw_any_errors} = 0;
+ while($#args >= 2)
+ {
+ my $argRef = string_trim(pop @args);
+ if($argRef eq "errthrow")
+ {
+ $$objCfunc{throw_any_errors} = 1;
+ }
+ else
+ {
+ print STDERR "$filename:$line_num:_WRAP_CTOR: Invalid option '$argRef'.\n";
+ return;
+ }
+ }
+
$objOutputter->output_wrap_ctor($filename, $line_num, $objCppfunc, $objCfunc, $argCppMethodDecl);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]