diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2020-03-05 15:35:43 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2020-03-07 23:06:35 +0800 |
commit | 08e7d748f9ab2882440ef6925e3e95ac509167f2 (patch) | |
tree | 7142fa5defcd356330d2405c8ce77e469dfc104f /tools | |
parent | f12e03b7b912334b9b9dddfc65ba5fa068168838 (diff) | |
download | glibmm-08e7d748f9ab2882440ef6925e3e95ac509167f2.tar.gz |
tools: Allow generating Glib:Error class with decorations
This allows one to export the generated Glib::Error class with decorations so
that one may be able to use this to export it using compiler directives.
This allows specifications that start with decl_prefix, and this also
decorates the `friend wrap_init() method in the generated Glib::Error class
Diffstat (limited to 'tools')
-rw-r--r-- | tools/m4/gerror.m4 | 8 | ||||
-rw-r--r-- | tools/pm/Output.pm | 11 | ||||
-rw-r--r-- | tools/pm/WrapParser.pm | 11 |
3 files changed, 18 insertions, 12 deletions
diff --git a/tools/m4/gerror.m4 b/tools/m4/gerror.m4 index 2f35e7e6..4de1d0ab 100644 --- a/tools/m4/gerror.m4 +++ b/tools/m4/gerror.m4 @@ -1,6 +1,6 @@ dnl -dnl _GERROR(cpp_type, c_type, domain, `element_list', `gtype_func', `class_docs', `enum_docs', 'deprecated') -dnl $1 $2 $3 $4 $5 $6 $7 $8 +dnl _GERROR(cpp_type, c_type, domain, `element_list', `gtype_func', `class_docs', `enum_docs', 'deprecated', `decl_prefix') +dnl $1 $2 $3 $4 $5 $6 $7 $8 $9 dnl m4_define(`_GERROR',`dnl @@ -17,7 +17,7 @@ ifelse(`$6',,,`dnl /** $6 */ ')dnl -class __CPPNAME__ : public Glib::Error +class $9 __CPPNAME__ : public Glib::Error { public: /** $7 @@ -36,7 +36,7 @@ private: static void throw_func(GError* gobject); - friend void wrap_init(); // uses throw_func() + friend $9 void wrap_init(); // uses throw_func() _IMPORT(SECTION_H_GERROR_PRIVATE) #endif //DOXYGEN_SHOULD_SKIP_THIS diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm index a7bdc8cf..7757d4e7 100644 --- a/tools/pm/Output.pm +++ b/tools/pm/Output.pm @@ -782,12 +782,12 @@ sub output_wrap_enum_docs_only($$$$$$$$$$$$) # void output_wrap_gerror($filename, $line_num, $cpp_type, $c_type, $domain, # $class_docs, $ref_subst_in, $ref_subst_out, $gtype_func, -# $deprecated, $deprecation_docs, $newin) -sub output_wrap_gerror($$$$$$$$$$$$$) +# $deprecated, $deprecation_docs, $newin, $decl_prefix) +sub output_wrap_gerror($$$$$$$$$$$$$$) { my ($self, $filename, $line_num, $cpp_type, $c_type, $domain, $class_docs, $ref_subst_in, $ref_subst_out, $gtype_func, - $deprecated, $deprecation_docs, $newin) = @_; + $deprecated, $deprecation_docs, $newin, $decl_prefix) = @_; my $objDefsParser = $$self{objDefsParser}; @@ -845,7 +845,7 @@ sub output_wrap_gerror($$$$$$$$$$$$$) # Prevent Doxygen from auto-linking to a class called Exception. $class_docs =~ s/([^%])(Exception class)/$1%$2/g; - my $str = sprintf("_GERROR(%s,%s,%s,\`%s\',\`%s\',\`%s\',\`%s\',\`%s\')dnl\n", + my $str = sprintf("_GERROR(%s,%s,%s,\`%s\',\`%s\',\`%s\',\`%s\',\`%s\',\`%s\')dnl\n", $cpp_type, $c_type, $domain, @@ -853,7 +853,8 @@ sub output_wrap_gerror($$$$$$$$$$$$$) $gtype_func, $class_docs, $enum_docs, - $deprecated + $deprecated, + $decl_prefix ); $self->append($str); diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm index 20af0f03..e6adaabe 100644 --- a/tools/pm/WrapParser.pm +++ b/tools/pm/WrapParser.pm @@ -1440,6 +1440,7 @@ sub on_wrap_any_enum($$) my $argDeprecated = ""; my $deprecation_docs = ""; my $newin = ""; + my $decl_prefix = ""; # $gtype_func: # 1. If an empty string, the M4 macro _ENUM or _GERROR calls _GET_TYPE_FUNC() @@ -1485,9 +1486,13 @@ sub on_wrap_any_enum($$) { $newin = string_unquote(string_trim($1)); } + elsif ($arg =~ /^decl_prefix(.*)/) #If decl_prefix is at the start. + { + $decl_prefix = string_unquote(string_trim($1)); + } } return ($cpp_type, $c_type, $domain, \@subst_in, \@subst_out, $gtype_func, - $conv_to_int, $argDeprecated, $deprecation_docs, $newin); + $conv_to_int, $argDeprecated, $deprecation_docs, $newin, $decl_prefix); } # void on_wrap_enum() @@ -1564,12 +1569,12 @@ sub on_wrap_gerror($) # get the arguments my ($cpp_type, $c_type, $domain, $ref_subst_in, $ref_subst_out, $gtype_func, undef, - $argDeprecated, $deprecation_docs, $newin) = $self->on_wrap_any_enum(1); + $argDeprecated, $deprecation_docs, $newin, $decl_prefix) = $self->on_wrap_any_enum(1); $$self{objOutputter}->output_wrap_gerror( $$self{filename}, $$self{line_num}, $cpp_type, $c_type, $domain, $class_docs, $ref_subst_in, $ref_subst_out, $gtype_func, - $argDeprecated, $deprecation_docs, $newin); + $argDeprecated, $deprecation_docs, $newin, $decl_prefix); } sub on_wrap_any_property($) |