diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2017-09-13 08:51:25 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2017-09-13 08:51:25 +0200 |
commit | fb4f669c20a534fc0f877266c0957091027253e0 (patch) | |
tree | 8612e84ac98748ea3900929b3845000eecb89ff3 | |
parent | de304e3377754823dc2f1b43f7b59df91fe48fee (diff) | |
download | glibmm-fb4f669c20a534fc0f877266c0957091027253e0.tar.gz |
gmmproc: Write signal flags to generated documentation
Bug 785895
-rw-r--r-- | tools/pm/Function.pm | 11 | ||||
-rw-r--r-- | tools/pm/GtkDefs.pm | 34 | ||||
-rw-r--r-- | tools/pm/Output.pm | 2 | ||||
-rw-r--r-- | tools/pm/WrapParser.pm | 17 |
4 files changed, 54 insertions, 10 deletions
diff --git a/tools/pm/Function.pm b/tools/pm/Function.pm index 6f84631a..f962216a 100644 --- a/tools/pm/Function.pm +++ b/tools/pm/Function.pm @@ -376,12 +376,12 @@ sub add_parameter($$$) return $self; } -# $string get_refdoc_comment($existing_signal_docs) +# $string get_refdoc_comment($existing_signal_docs, $signal_flags) # Generate a readable prototype for signals and merge the prototype into the # existing Doxygen comment block. -sub get_refdoc_comment($$) +sub get_refdoc_comment($$$) { - my ($self, $documentation) = @_; + my ($self, $documentation, $signal_flags) = @_; my $str = " /**\n"; @@ -402,6 +402,11 @@ sub get_refdoc_comment($$) $str .= ")</tt>\n"; $str .= " *\n"; + if ($signal_flags) + { + $str .= " * Flags: $signal_flags\n *\n"; + } + if($documentation ne "") { # Remove the initial '/** ' from the existing docs and merge it. diff --git a/tools/pm/GtkDefs.pm b/tools/pm/GtkDefs.pm index f1234f87..c50af4ae 100644 --- a/tools/pm/GtkDefs.pm +++ b/tools/pm/GtkDefs.pm @@ -713,8 +713,9 @@ BEGIN { @GtkDefs::Signal::ISA=qw(GtkDefs::Function); } # # string rettype; # -# string when. e.g. first, last, or both. +# string flags. e.g. Run Last, No Hooks # string entity_type. e.g. vfunc or signal +# bool detailed; # optional # bool deprecated; # optional # } @@ -741,7 +742,7 @@ sub new $$self{rettype} = "none"; $$self{param_types} = []; $$self{param_names} = []; - $$self{when} = ""; + $$self{flags} = ""; $$self{class} = ""; # snarf down lisp fields @@ -760,9 +761,26 @@ sub new $$self{rettype} =~ s/-/ /g; #e.g. replace const-gchar* with const gchar*. Otherwise it will be used in code. } - if($def =~ s/\(when "(\S+)"\)//) + if ($def =~ s/\(flags "(.*?)"\)//) { - $$self{when} = $1; + $$self{flags} = $1; + } + elsif ($def =~ s/\(when "(\S+)"\)//) + { + # "when" is a deprecated alternative to "flags". + # when eq "none", "first", "last", or "both". + if ($1 eq "first") + { + $$self{flags} = "Run First"; + } + elsif ($1 eq "last") + { + $$self{flags} = "Run Last"; + } + elsif ($1 eq "both") + { + $$self{flags} = "Run First, Run Last"; + } } if($$self{rettype} eq "none") @@ -770,6 +788,7 @@ sub new $$self{rettype} = "void" } + $$self{detailed} = ($1 eq "#t") if ($def =~ s/\(detailed (\S+)\)//); $$self{deprecated} = ($1 eq "#t") if ($def =~ s/\(deprecated (\S+)\)//); # signals always have a parameter @@ -790,6 +809,13 @@ sub new return $self; } +# bool get_detailed() +sub get_detailed($) +{ + my ($self) = @_; + return $$self{detailed}; # undef, 0 or 1 +} + # bool get_deprecated() sub get_deprecated($) { diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm index 65d37cac..80ebfc17 100644 --- a/tools/pm/Output.pm +++ b/tools/pm/Output.pm @@ -630,7 +630,7 @@ sub output_wrap_sig_decl($$$$$$$$$$$$$$) # Create a merged Doxygen comment block for the signal from the looked up # docs (the block will also contain a prototype of the slot as an example). - my $doxycomment = $objCppfunc->get_refdoc_comment($documentation); + my $doxycomment = $objCppfunc->get_refdoc_comment($documentation, $$objCSignal{flags}); # If there was already a previous doxygen comment, we want to merge this # one with the previous so it is one big comment. If diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm index 0e95c8fb..cb3337ad 100644 --- a/tools/pm/WrapParser.pm +++ b/tools/pm/WrapParser.pm @@ -1662,7 +1662,7 @@ sub output_wrap_signal($$$$$$$$$$$$$$$$$) $objCSignal = GtkDefs::lookup_signal($$self{c_class}, $signal_name); # Check for failed lookup. - if($objCSignal eq 0) + if (!$objCSignal) { print STDERR "$signal_name\n"; $objOutputter->output_wrap_failed($signal_name, @@ -1671,6 +1671,19 @@ sub output_wrap_signal($$$$$$$$$$$$$$$$$) } } + # Check detailed. + my $defs_detailed = $objCSignal->get_detailed(); + if ($defs_detailed && !$detail_name) + { + print STDERR "Warning, $main::source: The $signal_name signal" . + " is marked 'detailed' in the .defs file, but not in _WRAP_SIGNAL.\n"; + } + elsif (!$defs_detailed && $detail_name) + { + print STDERR "Warning, $main::source: The $signal_name signal" . + " is marked 'detailed' in _WRAP_SIGNAL, but not in the .defs file.\n"; + } + Output::check_deprecation($$self{deprecated}, $objCSignal->get_deprecated(), $deprecated, $signal_name, "signal", "SIGNAL"); @@ -1679,7 +1692,7 @@ sub output_wrap_signal($$$$$$$$$$$$$$$$$) $deprecated, $deprecation_docs, $newin, $exceptionHandler, $detail_name, $bTwoSignalMethods); - if($bNoDefaultHandler eq 0) + if (!$bNoDefaultHandler) { $objOutputter->output_wrap_default_signal_handler_h($filename, $line_num, $objCppSignal, $objCSignal, $ifdef, $deprecated, $exceptionHandler); |