[glibmm] gmmproc: Fix _WRAP_SIGNAL with 'ifdef' and 'deprecated'.
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] gmmproc: Fix _WRAP_SIGNAL with 'ifdef' and 'deprecated'.
- Date: Fri, 16 Aug 2013 06:38:32 +0000 (UTC)
commit 118f894606a1016a15f48a1659ebb29a95f4cdf5
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Thu Aug 15 20:48:18 2013 +0200
gmmproc: Fix _WRAP_SIGNAL with 'ifdef' and 'deprecated'.
* tools/pm/Output.pm: Since 2012-09-18 convert_args_cpp_to_c() returns an
array. Use only the first array element ($conversions) when _SIGNAL_CC is
written.
* tools/pm/WrapParser.pm: _WRAP_SIGNAL: Fix the merge of a doxygen comment
in a .hg file with a comment from the .defs file. Write #if[n]def directives
before the merged comment. (Was in the middle of the comment.)
tools/pm/Output.pm | 41 +++++++++++++++++++------------
tools/pm/WrapParser.pm | 63 +++++++++++++++++++++--------------------------
2 files changed, 53 insertions(+), 51 deletions(-)
---
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 2da2bf8..8ad75d0 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -272,6 +272,9 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$$)
my $refreturn = "";
$refreturn = "refreturn" if($bRefreturn eq 1);
+ my ($conversions, $declarations, $initializations) =
+ convert_args_cpp_to_c($objCppfunc, $objDefsSignal, 0, $line_num);
+
# The default signal handler is a virtual function.
# It's not hidden by deprecation, since that would break ABI.
my $str = sprintf("_SIGNAL_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n",
@@ -280,7 +283,7 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$$)
$$objCppfunc{rettype},
$$objDefsSignal{rettype},
$objCppfunc->args_types_and_names(),
- convert_args_cpp_to_c($objCppfunc, $objDefsSignal, 0, $line_num), #$objCppfunc->args_names_only(),
+ $conversions,
$$objCppfunc{const},
$refreturn,
$ifdef);
@@ -301,6 +304,9 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$$)
if($bCustomCCallback ne 1)
{
+ my $conversions =
+ convert_args_c_to_cpp($objDefsSignal, $objCppfunc, $line_num);
+
#This is hidden by deprecation.
my $str = sprintf("_SIGNAL_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',\`%s\',%s,%s)dnl\n",
$$objCppfunc{name},
@@ -309,7 +315,7 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$$)
$$objDefsSignal{rettype},
$objDefsSignal->args_types_and_names(),
$objDefsSignal->args_names_only(),
- convert_args_c_to_cpp($objDefsSignal, $objCppfunc, $line_num),
+ $conversions,
${$objDefsSignal->get_param_names()}[0],
$ifdef,
$deprecated);
@@ -561,11 +567,11 @@ sub output_wrap_create($$$)
}
}
-# void output_wrap_sig_decl($filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback,
$ifdef, $merge_doxycomment_with_previous, $deprecated, $deprecation_docs)
+# void output_wrap_sig_decl($filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback,
$ifdef, $commentblock, $deprecated, $deprecation_docs)
# custom_signalproxy_name is "" when no type conversion is required - a normal templates SignalProxy will be
used instead.
sub output_wrap_sig_decl($$$$$$$$$$)
{
- my ($self, $filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback, $ifdef,
$merge_doxycomment_with_previous, $deprecated, $deprecation_docs) = @_;
+ my ($self, $filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback, $ifdef,
$commentblock, $deprecated, $deprecation_docs) = @_;
# _SIGNAL_PROXY(c_signal_name, c_return_type, `<c_arg_types_and_names>',
# cpp_signal_name, cpp_return_type, `<cpp_arg_types>',`<c_args_to_cpp>',
@@ -585,38 +591,41 @@ sub output_wrap_sig_decl($$$$$$$$$$)
my $doxycomment = $objCppfunc->get_refdoc_comment($documentation);
# If there was already a previous doxygen comment, we want to merge this
- # one with the previous so it is one big comment. If it were two separate
- # comments, doxygen would ignore the first one. If
- # $merge_doxycomment_with_previous is nonzero, the first comment is
- # already open but not yet closed.
- if($merge_doxycomment_with_previous)
+ # one with the previous so it is one big comment. If
+ # $commentblock is not emtpy, it contains the previous doxygen comment without
+ # opening and closing tokens (/** and */).
+ if($commentblock ne "")
{
# Strip leading whitespace
$doxycomment =~ s/^\s+//;
- # We don't have something to add, so just close the comment.
+ # We don't have something to add, so just use $commentblock with
+ # opening and closing tokens added.
if($doxycomment eq "")
{
- $doxycomment = " */";
+ $doxycomment = ' /**' . $commentblock . "\n */";
}
else
{
- # Append the new comment, but remove the first three leading characters
- # (which are /**) that mark the beginning of the comment.
+ # Merge the two comments, but remove the first three characters from the
+ # second comment (/**) that mark the beginning of the comment.
$doxycomment = substr($doxycomment, 3);
$doxycomment =~ s/^\s+//;
- $doxycomment = " " . $doxycomment;
+ $doxycomment = ' /**' . $commentblock . "\n *\n " . $doxycomment;
}
}
- my $str = sprintf("_SIGNAL_PROXY(%s,%s,\`%s\',%s,%s,\`%s\',\`%s\',\`%s\',\`%s\',%s)dnl\n",
+ my $conversions =
+ convert_args_c_to_cpp($objCSignal, $objCppfunc, $line_num);
+
+ my $str = sprintf("_SIGNAL_PROXY(%s,%s,\`%s\',%s,%s,\`%s\',\`%s\',\`%s\',%s,\`%s\',%s)dnl\n",
$signal_name,
$$objCSignal{rettype},
$objCSignal->args_types_and_names_without_object(),
$$objCppfunc{name},
$$objCppfunc{rettype},
$objCppfunc->args_types_only(),
- convert_args_c_to_cpp($objCSignal, $objCppfunc, $line_num),
+ $conversions,
$bCustomCCallback, #When this is true, it will not write the *_callback implementation for you.
$deprecated,
$doxycomment,
diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm
index cd39097..f87efd6 100644
--- a/tools/pm/WrapParser.pm
+++ b/tools/pm/WrapParser.pm
@@ -114,7 +114,7 @@ sub parse_and_build_output($)
if ($token eq "_WRAP_METHOD") { $self->on_wrap_method(); next;}
if ($token eq "_WRAP_METHOD_DOCS_ONLY") { $self->on_wrap_method_docs_only(); next;}
if ($token eq "_WRAP_CORBA_METHOD") { $self->on_wrap_corba_method(); next;} #Used in libbonobo*mm.
- if ($token eq "_WRAP_SIGNAL") { $self->on_wrap_signal(0); next;}
+ if ($token eq "_WRAP_SIGNAL") { $self->on_wrap_signal(); next;}
if ($token eq "_WRAP_PROPERTY") { $self->on_wrap_property(); next;}
if ($token eq "_WRAP_VFUNC") { $self->on_wrap_vfunc(); next;}
if ($token eq "_WRAP_CTOR") { $self->on_wrap_ctor(); next;}
@@ -333,40 +333,26 @@ sub on_comment_doxygen($)
if ($_ eq "*/")
{
- push (@out,"\'*");
+ push (@out,"\'*/");
$objOutputter->append(join("", @out));
- # Find next non-whitespace token, but remember whitespace so that we
- # can print it if the next real token is not _WRAP_SIGNAL
+ # Extract all following whitespace tokens.
my @whitespace;
my $next_token = $self->peek_token();
while ($next_token !~ /\S/)
{
push(@whitespace, $self->extract_token());
- $next_token = $self->peek_token();
- }
-
- # If the next token is a signal, do not close this comment, to merge
- # this doxygen comment with the one from the signal.
- if($next_token eq '_WRAP_SIGNAL')
- {
- # Extract token and process
- $self->extract_token();
- # Tell wrap_signal to merge automatically generated comment with
- # already existing comment. This is why we do not close the comment
- # here.
- $self->on_wrap_signal(1);
- }
- else
- {
- # Something other than signal follows, so close comment normally
- $objOutputter->append("/");
- # And append whitespace we ignored so far
- $objOutputter->append(join("", @whitespace));
- # Do not extract the token so that parse_and_build_output() will
- # process it.
+ $next_token = $self->peek_token();
}
-
+ # Do not extract the following non-whitespace token so that
+ # parse_and_build_output() will process it.
+
+ # Append whitespace.
+ # extract_preceding_documentation() expects to find a preceding
+ # doxygen comment, if any, as two array elements, one with the whole
+ # comment, the following (possibly empty) with the following
+ # whitespace.
+ $objOutputter->append(join("", @whitespace));
last;
}
@@ -821,10 +807,10 @@ sub extract_preceding_documentation ($)
my $comment = '';
- if ($#$out >= 2)
+ if ($#$out >= 1)
{
- # steal the last three tokens
- my @back = splice(@$out, -3);
+ # steal the last two tokens
+ my @back = splice(@$out, -2);
local $_ = join('', @back);
# Check for /*[*!] ... */ or //[/!] comments. The closing */ _must_
@@ -1160,13 +1146,20 @@ sub on_wrap_create($)
sub on_wrap_signal($$)
{
- my ($self, $merge_doxycomment_with_previous) = @_;
+ my ($self) = @_;
if( !($self->check_for_eof()) )
{
return;
}
+ my $commentblock = $self->extract_preceding_documentation();
+ # Remove leading and trailing m4 quotes, if any.
+ # M4 quotes will be added around the whole comment, after $commentblock has
+ # possibly been merged with a second comment block.
+ $commentblock =~ s/^`//;
+ $commentblock =~ s/'$//;
+
my $str = $self->extract_bracketed_text();
my @args = string_split_commas($str);
@@ -1225,7 +1218,7 @@ sub on_wrap_signal($$)
$self->output_wrap_signal($argCppDecl, $argCName, $$self{filename}, $$self{line_num},
$bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback,
- $bRefreturn, $ifdef, $merge_doxycomment_with_previous, $argDeprecated,
$deprecation_docs);
+ $bRefreturn, $ifdef, $commentblock, $argDeprecated, $deprecation_docs);
}
# void on_wrap_vfunc()
@@ -1450,12 +1443,12 @@ sub output_wrap_check($$$$$$)
# void output_wrap($CppDecl, $signal_name, $filename, $line_num, $bCustomDefaultHandler,
# $bNoDefaultHandler, $bCustomCCallback, $bRefreturn, $ifdef,
-# $merge_doxycomment_with_previous, $deprecated, $deprecation_docs)
+# $commentblock, $deprecated, $deprecation_docs)
sub output_wrap_signal($$$$$$$$$$$)
{
my ($self, $CppDecl, $signal_name, $filename, $line_num, $bCustomDefaultHandler,
$bNoDefaultHandler, $bCustomCCallback, $bRefreturn, $ifdef,
- $merge_doxycomment_with_previous, $deprecated, $deprecation_docs) = @_;
+ $commentblock, $deprecated, $deprecation_docs) = @_;
#Some checks:
return if ($self->output_wrap_check($CppDecl, $signal_name,
@@ -1488,7 +1481,7 @@ sub output_wrap_signal($$$$$$$$$$$)
}
$objOutputter->output_wrap_sig_decl($filename, $line_num, $objCSignal, $objCppSignal,
- $signal_name, $bCustomCCallback, $ifdef, $merge_doxycomment_with_previous,
+ $signal_name, $bCustomCCallback, $ifdef, $commentblock,
$deprecated, $deprecation_docs);
if($bNoDefaultHandler eq 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]