[glibmm/use-dllexport-2-62: 3/8] tools: Allow generating Glib:Error class with decorations
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/use-dllexport-2-62: 3/8] tools: Allow generating Glib:Error class with decorations
- Date: Sun, 8 Mar 2020 17:51:45 +0000 (UTC)
commit 8725cbb3187ef0f6985f42b151887500bc39b2d6
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Thu Mar 5 15:35:43 2020 +0800
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.
Currently this only allows specifications that end with _API, and this also
decorates the `friend wrap_init() method in the generated Glib::Error class
tools/m4/gerror.m4 | 8 ++++----
tools/pm/Output.pm | 11 ++++++-----
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 51b4985c..78046ffc 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 ed630d2b..63dcd697 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -759,12 +759,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};
@@ -822,7 +822,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,
@@ -830,7 +830,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 bf2597f1..2e2121a8 100644
--- a/tools/pm/WrapParser.pm
+++ b/tools/pm/WrapParser.pm
@@ -1444,6 +1444,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,
- $argDeprecated, $deprecation_docs, $newin);
+ $argDeprecated, $deprecation_docs, $newin, $decl_prefix);
}
sub on_wrap_enum($)
@@ -1542,12 +1547,12 @@ sub on_wrap_gerror($)
# get the arguments
my ($cpp_type, $c_type, $domain, $ref_subst_in, $ref_subst_out, $gtype_func,
- $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($)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]