summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schmid <jhs@gnome.org>2006-09-19 20:12:41 +0000
committerMurray Cumming <murrayc@src.gnome.org>2006-09-19 20:12:41 +0000
commita51ef4846cc405d7de0d51798c01271fb015bef9 (patch)
tree9798166912f02648513ebbbe5efe1eaf1cad695a
parentd17130a948ad5adc91777a81b17d21ce2058ef10 (diff)
downloadglibmm-a51ef4846cc405d7de0d51798c01271fb015bef9.tar.gz
Change _IMPLEMENTS_INTERFACE to _IMPLEMENTS_INTERFACE_CC so we can have
2006-09-14 Johannes Schmid <jhs@gnome.org> * tools/m4/class_shared.m4: Change _IMPLEMENTS_INTERFACE to _IMPLEMENTS_INTERFACE_CC so we can have more control over it, by generating the _IMPLEMENTS_INTERFACE_CC from the WrapParser.pm. * tools/m4/method.m4: * tools/m4/signal.m4: * tools/m4/vfunc.m4: Added optional parameters that result in #ifdefs around methods, signals, vfuncs, etc. * tools/pm/Output.pm: Addef ifdef() and endif(). output_wrap_vfunc_h(), output_wrap_vfunc_cc(), output_wrap_default_signal_handler_h(), output_wrap_default_signal_handler_cc(), output_wrap_meth(), output_wrap_create(), output_wrap_sig_decl(): Support optional ifdefs around declarations and implementations, by calling ifdef() and endif(), or by passing the extra argument to the m4 macros. * tools/pm/WrapParser.pm: parse_and_build_output(): Parse _IMPLEMENTS_INTERFACE, and call the new on_implements_interface() method, which uses the new output_implements_interface() method, so it can have an optional ifdef parameter. on_wrap_method(), on_wrap_create(), on_wrap_vfunc(), output_wrap_signal(), output_wrap_vfunc(): Handle the optional ifdef (with a parameter) option for the _WRAP*() macros. This adds support for disabling certain features by using the new ifdef argument for methods, vfuncs, signals and interfaces.
-rw-r--r--ChangeLog29
-rw-r--r--tools/m4/class_shared.m47
-rw-r--r--tools/m4/method.m422
-rw-r--r--tools/m4/signal.m455
-rw-r--r--tools/m4/vfunc.m435
-rw-r--r--tools/pm/Output.pm113
-rw-r--r--tools/pm/WrapParser.pm71
7 files changed, 261 insertions, 71 deletions
diff --git a/ChangeLog b/ChangeLog
index a714a6e8..7367337c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2006-09-14 Johannes Schmid <jhs@gnome.org>
+
+ * tools/m4/class_shared.m4: Change _IMPLEMENTS_INTERFACE to
+ _IMPLEMENTS_INTERFACE_CC so we can have more control over it,
+ by generating the _IMPLEMENTS_INTERFACE_CC from the WrapParser.pm.
+ * tools/m4/method.m4:
+ * tools/m4/signal.m4:
+ * tools/m4/vfunc.m4: Added optional parameters that result in
+ #ifdefs around methods, signals, vfuncs, etc.
+ * tools/pm/Output.pm: Addef ifdef() and endif().
+ output_wrap_vfunc_h(), output_wrap_vfunc_cc(),
+ output_wrap_default_signal_handler_h(),
+ output_wrap_default_signal_handler_cc(),
+ output_wrap_meth(),
+ output_wrap_create(),
+ output_wrap_sig_decl(): Support optional ifdefs around
+ declarations and implementations, by calling ifdef() and endif(),
+ or by passing the extra argument to the m4 macros.
+ * tools/pm/WrapParser.pm: parse_and_build_output():
+ Parse _IMPLEMENTS_INTERFACE, and call the new on_implements_interface()
+ method, which uses the new output_implements_interface() method,
+ so it can have an optional ifdef parameter.
+ on_wrap_method(), on_wrap_create(), on_wrap_vfunc(), output_wrap_signal(),
+ output_wrap_vfunc(): Handle the optional ifdef (with a parameter) option
+ for the _WRAP*() macros.
+
+ This adds support for disabling certain features by using the new
+ "ifdef" argument for methods, vfuncs, signals and interfaces.
+
2006-08-18 Cedric Gustin <cedric.gustin@gmail.com>
* MSVC_Net2003/*.vcproj: Updated for glibmm-2.12.
diff --git a/tools/m4/class_shared.m4 b/tools/m4/class_shared.m4
index 6be0cbff..c3b80786 100644
--- a/tools/m4/class_shared.m4
+++ b/tools/m4/class_shared.m4
@@ -31,9 +31,14 @@ _IMPORT(SECTION_H_DEFAULT_SIGNAL_HANDLERS)
dnl
dnl
dnl
-define(`_IMPLEMENTS_INTERFACE',`dnl
+define(`_IMPLEMENTS_INTERFACE_CC',`dnl
_PUSH(SECTION_CC_IMPLEMENTS_INTERFACES)
+ifelse(`$2',,,`#ifdef $2'
+)dnl
$1`'::add_interface(get_type());
+ifelse(`$2',,,`
+#endif // $2
+')dnl
_POP()
')
diff --git a/tools/m4/method.m4 b/tools/m4/method.m4
index 1c99b93d..e5ed7282 100644
--- a/tools/m4/method.m4
+++ b/tools/m4/method.m4
@@ -9,12 +9,14 @@ dnl
dnl
dnl method
-dnl $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12
-dnl _METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,const,refreturn,errthrow,deprecated,constversion,arglist_without_types)
+dnl $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14
+dnl _METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,const,refreturn,errthrow,deprecated,constversion,ifdef, arglist_without_types)
define(`_METHOD',`dnl
_PUSH(SECTION_CC)
ifelse(`$10',,,`_DEPRECATE_IFDEF_START
')dnl
+ifelse(`$13',,,`#ifdef $13'
+)dnl
ifelse(`$9',,,`#ifdef GLIBMM_EXCEPTIONS_ENABLED'
)dnl
$3 __CPPNAME__::$1`'($5)ifelse(`$7',1,` const')
@@ -48,18 +50,24 @@ ifelse(`$3',void,,` return retvalue;')
')dnl End errthrow/refreturn
',` return const_cast<__CPPNAME__*>(this)->$1($12);')
}
+
+ifelse(`$13',,,`
+#endif // $13
+')dnl
ifelse(`$10',,,`_DEPRECATE_IFDEF_END
-')
+')dnl
_POP()')
dnl
dnl static method
-dnl $1 $2 $3 $4 $5 $6 $7 $8 $9
-dnl _STATIC_METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,refreturn,errthrow,deprecated))
+dnl $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
+dnl _STATIC_METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,refreturn,errthrow,deprecated,ifdef))
define(`_STATIC_METHOD',`dnl
_PUSH(SECTION_CC)
ifelse(`$9',,,`_DEPRECATE_IFDEF_START
')dnl
+ifelse(`$10',,,`#ifdef $10'
+)dnl
ifelse(`$8',,,`#ifdef GLIBMM_EXCEPTIONS_ENABLED
')dnl
$3 __CPPNAME__::$1($5)
@@ -89,6 +97,10 @@ ifelse(`$7',,,`dnl
ifelse(`$3',void,,` return retvalue;')
')dnl
}
+
+ifelse(`$10',,,`
+#endif // $10
+')dnl
ifelse(`$9',,,`_DEPRECATE_IFDEF_END
')
_POP()')
diff --git a/tools/m4/signal.m4 b/tools/m4/signal.m4
index 989e898e..952975f5 100644
--- a/tools/m4/signal.m4
+++ b/tools/m4/signal.m4
@@ -10,14 +10,23 @@ dnl $4 = cpp_signal_name,
dnl $5 = cpp_return_type,
dnl $6 = `<cpp_arg_types>',
dnl $7 = `<c_args_to_cpp>',
-dnl $8 = `custom_c_callback (boolean)')
-dnl $9 = `refdoc_comment')
+dnl $8 = `custom_c_callback (boolean)',
+dnl $9 = `refdoc_comment',
+dnl $10 = ifdef)
define(`_SIGNAL_PROXY',`
$9
+
+ifelse(`$10',,,`#ifdef $10'
+)dnl
Glib::SignalProxy`'_NUM($6)< $5`'_COMMA_PREFIX($6) > signal_$4`'();
+ifelse(`$10',,,`#endif // $10
+')dnl
dnl
_PUSH(SECTION_ANONYMOUS_NAMESPACE)
+
+ifelse(`$10',,,`#ifdef $10'
+)dnl
dnl
ifelse($2`'_NUM($3)`'$5`'_NUM($6),`void0void0',`dnl
dnl
@@ -103,11 +112,19 @@ static const Glib::SignalProxyInfo __CPPNAME__`'_signal_$4_info =
};
')dnl endif
+ifelse(`$10',,,`#endif // $10
+')dnl
+
_SECTION(SECTION_CC_SIGNALPROXIES)
+
+ifelse(`$10',,,`#ifdef $10'
+)dnl
Glib::SignalProxy`'_NUM($6)< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'()
{
return Glib::SignalProxy`'_NUM($6)< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info);
}
+ifelse(`$10',,,`#endif // $10
+')dnl
_POP()')
@@ -118,20 +135,30 @@ dnl Create a callback and set it in our derived G*Class.
dnl
define(`_SIGNAL_PH',`dnl
_PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
+ifelse(`$4',,,`#ifdef $4'
+)dnl
klass->$1 = `&'$1_callback;
+ifelse(`$4',,,`#endif // $4
+')dnl
_SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
+ifelse(`$4',,,`#ifdef $4'
+)dnl
static $2 $1_callback`'($3);
+ifelse(`$4',,,`#endif // $4
+')dnl
_POP()')
dnl $1 $2 $3 $4
dnl _SIGNAL_PCC(cppname,gname,cpprettype,crettype,
-dnl $5 $6 $7 $8
-dnl `<cargs and names>',`<cnames>',`<cpparg names>',firstarg)
+dnl $5 $6 $7 $8 $9
+dnl `<cargs and names>',`<cnames>',`<cpparg names>', firstarg, <ifndef>)
dnl
define(`_SIGNAL_PCC',`dnl
_PUSH(SECTION_PCC_DEFAULT_SIGNAL_HANDLERS)
+ifelse(`$9',,,`#ifdef $9'
+)dnl
$4 __CPPNAME__`'_Class::$2_callback`'($5)
{
dnl We cast twice to allow for multiple-inheritance casts, which might
@@ -186,23 +213,30 @@ ifelse($4,void,,`dnl
return RType`'();
')dnl
}
-
+ifelse(`$9',,,`#endif // $9
+')dnl
_POP()')
-dnl $1 $2 $3
-dnl _SIGNAL_H(signame,rettype,`<cppargs>')
+dnl $1 $2 $3 $4
+dnl _SIGNAL_H(signame, rettype, `<cppargs>', <ifdef>)
dnl
define(`_SIGNAL_H',`dnl
_PUSH(SECTION_H_DEFAULT_SIGNAL_HANDLERS)
+ifelse(`$4',,,`#ifdef $4'
+)dnl
virtual $2 on_$1`'($3);
+ifelse(`$4',,,`#endif // $4
+')dnl
_POP()')
-dnl $1 $2 $3 $4 $5 $6 $7 $8
-dnl _SIGNAL_CC(signame,gname,rettype,crettype,`<cppargs>',`<carg_names>', const, refreturn)
+dnl $1 $2 $3 $4 $5 $6 $7 $8 $9
+dnl _SIGNAL_CC(signame,gname,rettype,crettype,`<cppargs>',`<carg_names>', const, refreturn, <ifdef>)
dnl
define(`_SIGNAL_CC',`dnl
_PUSH(SECTION_CC_DEFAULT_SIGNAL_HANDLERS)
+ifelse(`$9',,,`#ifdef $9'
+)dnl
$3 __NAMESPACE__::__CPPNAME__::on_$1`'($5)
{
BaseClassType *const base = static_cast<BaseClassType*>(
@@ -227,6 +261,7 @@ ifelse($8,refreturn,`dnl Assume Glib::wrap() is correct if refreturn is requeste
return RType`'();
')dnl
}
-
+ifelse(`$9',,,`#endif // $9
+')dnl
_POP()')
diff --git a/tools/m4/vfunc.m4 b/tools/m4/vfunc.m4
index a6dad27f..dc3eba10 100644
--- a/tools/m4/vfunc.m4
+++ b/tools/m4/vfunc.m4
@@ -4,19 +4,29 @@ dnl Create a callback and set it in our derived G*Class.
dnl
define(`_VFUNC_PH',`dnl
_PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
+ifelse(`$4',,,`#ifdef $4'
+)dnl
klass->$1 = `&'$1_vfunc_callback;
+ifelse(`$4',,,`#endif // $4
+')dnl
_SECTION(SECTION_PH_VFUNCS)
+ifelse(`$4',,,`#ifdef $4'
+)dnl
static $2 $1_vfunc_callback`'($3);
+ifelse(`$4',,,`#endif // $4
+')dnl
_POP()')
dnl $1 $2 $3 $4
dnl _VFUNC_PCC(cppname,gtkname,cpprettype,crettype,
-dnl $5 $6 $7 $8 $9
-dnl `<cargs and names>',`<cnames>',`<cpparg names>',firstarg, refreturn_ctype)
+dnl $5 $6 $7 $8 $9 $10
+dnl `<cargs and names>',`<cnames>',`<cpparg names>',firstarg, refreturn_ctype, ifdef)
dnl
define(`_VFUNC_PCC',`dnl
_PUSH(SECTION_PCC_VFUNCS)
+ifelse(`$10',,,`#ifdef $10'
+)dnl
$4 __CPPNAME__`'_Class::$2_vfunc_callback`'($5)
{
dnl We cast twice to allow for multiple-inheritance casts, which might
@@ -75,14 +85,17 @@ ifelse($4,void,,`dnl
return RType`'();
')dnl
}
-
+ifelse(`$10',,,`#endif // $10
+')dnl
_POP()')
-# $1 $2 $3 $4 $5 $6 $7 $8
-# _VFUNC_CC(vfunc_name, gtkname, cpp_rettype, c_rettype, `<cppargs>', `<carg_names>', is_const, refreturn)
+# $1 $2 $3 $4 $5 $6 $7 $8 $9
+# _VFUNC_CC(vfunc_name, gtkname, cpp_rettype, c_rettype, `<cppargs>', `<carg_names>', is_const, refreturn, $ifdef)
#
define(`_VFUNC_CC',`dnl
_PUSH(SECTION_CC_VFUNCS)
+ifelse(`$9',,,`#ifdef $9'
+)dnl
$3 __NAMESPACE__::__CPPNAME__::$1`'($5) ifelse($7,1,const,)
{
BaseClassType *const base = static_cast<BaseClassType*>(
@@ -107,22 +120,26 @@ ifelse($8,refreturn,`dnl Assume Glib::wrap() is correct if refreturn is requeste
return RType`'();
')dnl
}
-
+ifelse(`$9',,,`#endif // $9
+')dnl
_POP()')
-# $1 $2 $3 $4
-# _VFUNC_H(vfunc_name, rettype, `<cppargs>', is_const)
+# $1 $2 $3 $4 $5
+# _VFUNC_H(vfunc_name, rettype, `<cppargs>', is_const, ifndef)
# Only used for custom vfuncs.
#
define(`_VFUNC_H',`dnl
_PUSH(SECTION_H_VFUNCS)
+ifelse(`$5',,,`#ifdef $5'
+)dnl
ifelse($4,`1',`dnl
virtual $2 $1`'($3) const;
',`dnl
virtual $2 $1`'($3);
')
-
+ifelse(`$5',,,`#endif // $5
+')dnl
_POP()')
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index b3ffe714..6b4a475f 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -78,13 +78,31 @@ sub error
printf STDERR "Output.pm: $format",@_;
}
+sub ifdef($$)
+{
+ my ($self, $ifdef) = @_;
+ if ($ifdef)
+ {
+ $self->append("\n#ifdef $ifdef\n");
+ }
+}
+
+sub endif($$)
+{
+ my ($self, $ifdef) = @_;
+ if ($ifdef)
+ {
+ $self->append("\n#endif // $ifdef\n");
+ }
+}
+
### Convert _WRAP to a virtual
# _VFUNC_H(signame,rettype,`<cppargs>')
# _VFUNC_PH(gtkname,crettype,cargs and names)
# void output_wrap_vfunc_h($filename, $line_num, $objCppfunc, $objCDefsFunc)
-sub output_wrap_vfunc_h($$$$$)
+sub output_wrap_vfunc_h($$$$$$)
{
- my ($self, $filename, $line_num, $objCppfunc, $objCDefsFunc) = @_;
+ my ($self, $filename, $line_num, $objCppfunc, $objCDefsFunc, $ifdef) = @_;
#Old code. We removed _VFUNC_H from the .m4 file
# my $str = sprintf("_VFUNC_H(%s,%s,\`%s\',%s)dnl\n",
@@ -102,24 +120,27 @@ sub output_wrap_vfunc_h($$$$$)
}
$self->append("#ifdef GLIBMM_VFUNCS_ENABLED\n");
+ $self->ifdef($ifdef);
$self->append(" $cppVfuncDecl;\n");
+ $self->endif($ifdef);
$self->append("#endif //GLIBMM_VFUNCS_ENABLED\n");
#The default callback, which will call *_vfunc, which will then call the base default callback.
#Declares the callback in the private *Class class and sets it in the class_init function.
- my $str = sprintf("_VFUNC_PH(%s,%s,\`%s\')dnl\n",
+ my $str = sprintf("_VFUNC_PH(%s,%s,\`%s\',%s)dnl\n",
$$objCDefsFunc{name},
$$objCDefsFunc{rettype},
$objCDefsFunc->args_types_and_names(),
+ $ifdef
);
$self->append($str);
}
# _VFUNC_CC(signame,gtkname,rettype,crettype,`<cppargs>',`<cargs>')
-sub output_wrap_vfunc_cc($$$$$$)
+sub output_wrap_vfunc_cc($$$$$$$)
{
- my ($self, $filename, $line_num, $objCppfunc, $objDefsSignal) = @_;
+ my ($self, $filename, $line_num, $objCppfunc, $objDefsSignal, $ifdef) = @_;
my $cname = $$objDefsSignal{name};
@@ -130,7 +151,7 @@ sub output_wrap_vfunc_cc($$$$$$)
my $refreturn = "";
$refreturn = "refreturn" if($$objCppfunc{rettype_needs_ref});
- my $str = sprintf("_VFUNC_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s)dnl\n",
+ my $str = sprintf("_VFUNC_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n",
$$objCppfunc{name},
$cname,
$$objCppfunc{rettype},
@@ -138,7 +159,8 @@ sub output_wrap_vfunc_cc($$$$$$)
$objCppfunc->args_types_and_names(),
convert_args_cpp_to_c($objCppfunc, $objDefsSignal, 0, $line_num), #$objCppfunc->args_names_only(),
$objCppfunc->get_is_const(),
- $refreturn);
+ $refreturn,
+ $ifdef);
$self->append($str);
@@ -147,7 +169,7 @@ sub output_wrap_vfunc_cc($$$$$$)
my $refreturn_ctype = "";
$refreturn_ctype = "refreturn_ctype" if($$objDefsSignal{rettype_needs_ref});
- my $str = sprintf("_VFUNC_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',%s,%s)dnl\n",
+ my $str = sprintf("_VFUNC_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',%s,%s,%s)dnl\n",
$$objCppfunc{name},
$cname,
$$objCppfunc{rettype},
@@ -156,23 +178,25 @@ sub output_wrap_vfunc_cc($$$$$$)
$objDefsSignal->args_names_only(),
convert_args_c_to_cpp($objDefsSignal, $objCppfunc, $line_num),
${$objDefsSignal->get_param_names()}[0],
- $refreturn_ctype);
+ $refreturn_ctype,
+ $ifdef);
$self->append($str);
}
### Convert _WRAP to a virtual
-# _SIGNAL_H(signame,rettype,`<cppargs>')
-# _SIGNAL_PH(gtkname,crettype,cargs and names)
-# void output_wrap_default_signal_handler_h($filename, $line_num, $objCppfunc, $objCDefsFunc, @args)
-sub output_wrap_default_signal_handler_h($$$$$$)
+# _SIGNAL_H(signame,rettype, ifdef, `<cppargs>')
+# _SIGNAL_PH(gtkname,crettype, ifdef, cargs and names)
+# void output_wrap_default_signal_handler_h($filename, $line_num, $objCppfunc, $objCDefsFunc, $ifdef. @args)
+sub output_wrap_default_signal_handler_h($$$$$$$)
{
- my ($self, $filename, $line_num, $objCppfunc, $objCDefsFunc, $bImplement) = @_;
+ my ($self, $filename, $line_num, $objCppfunc, $objCDefsFunc, $ifdef) = @_;
- my $str = sprintf("_SIGNAL_H(%s,%s,\`%s\')dnl\n",
+ my $str = sprintf("_SIGNAL_H(%s,%s,\`%s\',%s)dnl\n",
$$objCppfunc{name},
$$objCppfunc{rettype},
- $objCppfunc->args_types_and_names()
+ $objCppfunc->args_types_and_names(),
+ $ifdef
);
$self->append($str);
@@ -180,18 +204,19 @@ sub output_wrap_default_signal_handler_h($$$$$$)
#The default callback, which will call *_impl, which will then call the base default callback.
#Declares the callback in the private *Class class and sets it in the class_init function.
- $str = sprintf("_SIGNAL_PH(%s,%s,\`%s\')dnl\n",
+ $str = sprintf("_SIGNAL_PH(%s,%s,\`%s\',%s)dnl\n",
$$objCDefsFunc{name},
$$objCDefsFunc{rettype},
- $objCDefsFunc->args_types_and_names()
+ $objCDefsFunc->args_types_and_names(),
+ $ifdef
);
$self->append($str);
}
# _SIGNAL_CC(signame, gtkname, rettype, crettype,`<cppargs>',`<cargs>')
-sub output_wrap_default_signal_handler_cc($$$$$$$$)
+sub output_wrap_default_signal_handler_cc($$$$$$$$$)
{
- my ($self, $filename, $line_num, $objCppfunc, $objDefsSignal, $bImplement, $bCustomCCallback, $bRefreturn) = @_;
+ my ($self, $filename, $line_num, $objCppfunc, $objDefsSignal, $bImplement, $bCustomCCallback, $bRefreturn, $ifdef) = @_;
my $cname = $$objDefsSignal{name};
# $cname = $1 if ($args[3] =~ /"(.*)"/); #TODO: What's this about?
@@ -201,7 +226,7 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$)
my $refreturn = "";
$refreturn = "refreturn" if($bRefreturn eq 1);
- my $str = sprintf("_SIGNAL_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s, %s)dnl\n",
+ my $str = sprintf("_SIGNAL_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n",
$$objCppfunc{name},
$cname,
$$objCppfunc{rettype},
@@ -209,7 +234,8 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$)
$objCppfunc->args_types_and_names(),
convert_args_cpp_to_c($objCppfunc, $objDefsSignal, 0, $line_num), #$objCppfunc->args_names_only(),
$$objCppfunc{const},
- $refreturn);
+ $refreturn,
+ $ifdef);
$self->append($str);
}
@@ -227,7 +253,7 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$)
if($bCustomCCallback ne 1)
{
- my $str = sprintf("_SIGNAL_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',%s)dnl\n",
+ my $str = sprintf("_SIGNAL_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',\`%s\',%s)dnl\n",
$$objCppfunc{name},
$cname,
$$objCppfunc{rettype},
@@ -235,17 +261,18 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$)
$objDefsSignal->args_types_and_names(),
$objDefsSignal->args_names_only(),
convert_args_c_to_cpp($objDefsSignal, $objCppfunc, $line_num),
- ${$objDefsSignal->get_param_names()}[0]);
+ ${$objDefsSignal->get_param_names()}[0],
+ $ifdef);
$self->append($str);
}
}
### Convert _WRAP to a method
# _METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,const)
-# void output_wrap_meth($filename, $line_num, $objCppFunc, $objCDefsFunc, $cppMethodDecl, $documentation)
-sub output_wrap_meth($$$$$$)
+# void output_wrap_meth($filename, $line_num, $objCppFunc, $objCDefsFunc, $cppMethodDecl, $documentation, $ifdef)
+sub output_wrap_meth($$$$$$$)
{
- my ($self, $filename, $line_num, $objCppfunc, $objCDefsFunc, $cppMethodDecl, $documentation) = @_;
+ my ($self, $filename, $line_num, $objCppfunc, $objCDefsFunc, $cppMethodDecl, $documentation, $ifdef) = @_;
my $objDefsParser = $$self{objDefsParser};
# Allow the generated .h/.cc code to have an #ifndef around it, and add deprecation docs to the generated documentation.
@@ -264,6 +291,8 @@ sub output_wrap_meth($$$$$$)
# Doxygen documentation before the method declaration:
$self->output_wrap_meth_docs_only($filename, $line_num, $documentation);
+ $self->ifdef($ifdef);
+
if($$objCDefsFunc{throw_any_errors})
{
$self->append("#ifdef GLIBMM_EXCEPTIONS_ENABLED\n");
@@ -302,7 +331,10 @@ sub output_wrap_meth($$$$$$)
$self->append("\n#endif //GLIBMM_EXCEPTIONS_ENABLED\n");
}
+
+ $self->endif($ifdef);
+
if($deprecated ne "")
{
$self->append("\n_DEPRECATE_IFDEF_END\n");
@@ -329,7 +361,7 @@ sub output_wrap_meth($$$$$$)
#Implementation:
my $str;
if ($$objCppfunc{static}) {
- $str = sprintf("_STATIC_METHOD(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n",
+ $str = sprintf("_STATIC_METHOD(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s,%s)dnl\n",
$$objCppfunc{name},
$$objCDefsFunc{c_name},
$$objCppfunc{rettype},
@@ -338,9 +370,10 @@ sub output_wrap_meth($$$$$$)
convert_args_cpp_to_c($objCppfunc, $objCDefsFunc, 1, $line_num, $errthrow), #1 means it's static, so it has 'object'.
$refneeded,
$errthrow,
- $deprecated);
+ $deprecated,
+ $ifdef);
} else {
- $str = sprintf("_METHOD(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s,%s,%s,\`%s\')dnl\n",
+ $str = sprintf("_METHOD(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s,%s,%s,\`%s\',%s)dnl\n",
$$objCppfunc{name},
$$objCDefsFunc{c_name},
$$objCppfunc{rettype},
@@ -353,10 +386,9 @@ sub output_wrap_meth($$$$$$)
$deprecated,
$constversion,
$objCppfunc->args_names_only(),
+ $ifdef
);
}
-
-
$self->append($str);
}
@@ -417,13 +449,13 @@ sub output_wrap_create($$$)
# 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) = @_;
+ my ($self, $filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback, $ifdef) = @_;
# _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>',
# refdoc_comment)
- my $str = sprintf("_SIGNAL_PROXY(%s,%s,\`%s\',%s,%s,\`%s\',\`%s\',\`%s\')dnl\n",
+ my $str = sprintf("_SIGNAL_PROXY(%s,%s,\`%s\',%s,%s,\`%s\',\`%s\',\`%s\',%s,%s)dnl\n",
$signal_name,
$$objCSignal{rettype},
$objCSignal->args_types_and_names_without_object(),
@@ -432,7 +464,8 @@ sub output_wrap_sig_decl($$$$$$$)
$objCppfunc->args_types_only(),
convert_args_c_to_cpp($objCSignal, $objCppfunc, $line_num),
$bCustomCCallback, #When this is true, it will not write the *_callback implementation for you.
- $objCppfunc->get_refdoc_comment()
+ $objCppfunc->get_refdoc_comment(),
+ $ifdef
);
$self->append($str);
@@ -881,5 +914,15 @@ sub output_wrap_corba_method($$$$)
$self->append($str);
}
+sub output_implements_interface($$)
+{
+ my ($self, $interface, $ifdef) = @_;
+
+ my $str = sprintf("_IMPLEMENTS_INTERFACE_CC(%s, %s)dnl\n",
+ $interface,
+ $ifdef);
+
+ $self->append($str);
+}
1; # indicate proper module load.
diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm
index feaad435..fb156e33 100644
--- a/tools/pm/WrapParser.pm
+++ b/tools/pm/WrapParser.pm
@@ -119,6 +119,7 @@ sub parse_and_build_output($)
if ($token eq "_WRAP_ENUM") { $self->on_wrap_enum(); next;}
if ($token eq "_WRAP_GERROR") { $self->on_wrap_gerror(); next;}
+ if ($token eq "_IMPLEMENTS_INTERFACE") { $self->on_implements_interface(); next;}
my $prefix_class = "_CLASS_"; # e.g. _CLASS_GTKOBJECT
my $token_prefix = substr($token, 0, length($prefix_class));
@@ -759,6 +760,7 @@ sub on_wrap_method($)
# Extra stuff needed?
$$objCfunc{deprecated} = "";
my $deprecation_docs = "";
+ my $ifdef;
while(scalar(@args) > 2) # If the optional ref/err/deprecated arguments are there.
{
my $argRef = string_trim(pop @args);
@@ -784,12 +786,16 @@ sub on_wrap_method($)
$deprecation_docs = string_unquote(string_trim($1));
}
}
+ elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
+ {
+ $ifdef = $1;
+ }
}
my $commentblock = "";
$commentblock = DocsParser::lookup_documentation($argCFunctionName, $deprecation_docs);
- $objOutputter->output_wrap_meth($filename, $line_num, $objCppfunc, $objCfunc, $argCppMethodDecl, $commentblock);
+ $objOutputter->output_wrap_meth($filename, $line_num, $objCppfunc, $objCfunc, $argCppMethodDecl, $commentblock, $ifdef);
}
# void on_wrap_method_docs_only()
@@ -914,6 +920,38 @@ sub on_wrap_ctor($)
$objOutputter->output_wrap_ctor($filename, $line_num, $objCppfunc, $objCfunc, $argCppMethodDecl);
}
+sub on_implements_interface($$)
+{
+ my ($self) = @_;
+
+ if( !($self->check_for_eof()) )
+ {
+ return;
+ }
+
+ my $filename = $$self{filename};
+ my $line_num = $$self{line_num};
+
+ my $str = $self->extract_bracketed_text();
+ my @args = string_split_commas($str);
+
+ # handle first argument
+ my $interface = $args[0];
+
+ # Extra stuff needed?
+ my $ifdef;
+ while(scalar(@args) > 1) # If the optional ref/err/deprecated arguments are there.
+ {
+ my $argRef = string_trim(pop @args);
+ if($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
+ {
+ $ifdef = $1;
+ }
+ }
+ my $objOutputter = $$self{objOutputter};
+ $objOutputter->output_implements_interface($interface, $ifdef);
+}
+
sub on_wrap_create($)
{
my ($self) = @_;
@@ -951,6 +989,7 @@ sub on_wrap_signal($)
my $bNoDefaultHandler = 0;
my $bCustomCCallback = 0;
my $bRefreturn = 0;
+ my $ifdef;
while(scalar(@args) > 2) # If optional arguments are there.
{
@@ -974,10 +1013,15 @@ sub on_wrap_signal($)
{
$bRefreturn = 1;
}
+
+ elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
+ {
+ $ifdef = $1;
+ }
}
- $self->output_wrap_signal( $argCppDecl, $argCName, $$self{filename}, $$self{line_num}, $bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback, $bRefreturn);
+ $self->output_wrap_signal( $argCppDecl, $argCName, $$self{filename}, $$self{line_num}, $bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback, $bRefreturn, $ifdef);
}
# void on_wrap_vfunc()
@@ -1001,6 +1045,7 @@ sub on_wrap_vfunc($)
my $refreturn = 0;
my $refreturn_ctype = 0;
+ my $ifdef = "";
# Extra ref needed?
while(scalar(@args) > 2) # If the optional ref/err arguments are there.
@@ -1011,10 +1056,14 @@ sub on_wrap_vfunc($)
{ $refreturn = 1; }
elsif($argRef eq "refreturn_ctype")
{ $refreturn_ctype = 1; }
+ elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
+ {
+ $ifdef = $1;
+ }
}
$self->output_wrap_vfunc($argCppDecl, $argCName, $refreturn, $refreturn_ctype,
- $$self{filename}, $$self{line_num});
+ $$self{filename}, $$self{line_num}, $ifdef);
}
sub on_wrap_enum($)
@@ -1143,7 +1192,7 @@ sub output_wrap_check($$$$$$)
# Also used for vfunc.
sub output_wrap_signal($$$$$$$$)
{
- my ($self, $CppDecl, $signal_name, $filename, $line_num, $bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback, $bRefreturn) = @_;
+ my ($self, $CppDecl, $signal_name, $filename, $line_num, $bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback, $bRefreturn, $ifdef) = @_;
#Some checks:
$self->output_wrap_check($CppDecl, $signal_name, $filename, $line_num, "WRAP_SIGNAL");
@@ -1175,23 +1224,23 @@ sub output_wrap_signal($$$$$$$$)
}
}
- $objOutputter->output_wrap_sig_decl($filename, $line_num, $objCSignal, $objCppSignal, $signal_name, $bCustomCCallback);
+ $objOutputter->output_wrap_sig_decl($filename, $line_num, $objCSignal, $objCppSignal, $signal_name, $bCustomCCallback, $ifdef);
if($bNoDefaultHandler eq 0)
{
- $objOutputter->output_wrap_default_signal_handler_h($filename, $line_num, $objCppSignal, $objCSignal);
+ $objOutputter->output_wrap_default_signal_handler_h($filename, $line_num, $objCppSignal, $objCSignal, $ifdef);
my $bImplement = 1;
if($bCustomDefaultHandler) { $bImplement = 0; }
- $objOutputter->output_wrap_default_signal_handler_cc($filename, $line_num, $objCppSignal, $objCSignal, $bImplement, $bCustomCCallback, $bRefreturn);
+ $objOutputter->output_wrap_default_signal_handler_cc($filename, $line_num, $objCppSignal, $objCSignal, $bImplement, $bCustomCCallback, $bRefreturn, $ifdef);
}
}
# void output_wrap($CppDecl, $signal_name, $filename, $line_num)
# Also used for vfunc.
-sub output_wrap_vfunc($$$$$$$)
+sub output_wrap_vfunc($$$$$$$$)
{
- my ($self, $CppDecl, $vfunc_name, $refreturn, $refreturn_ctype, $filename, $line_num) = @_;
+ my ($self, $CppDecl, $vfunc_name, $refreturn, $refreturn_ctype, $filename, $line_num, $ifdef) = @_;
#Some checks:
$self->output_wrap_check($CppDecl, $vfunc_name, $filename, $line_num, "VFUNC");
@@ -1226,8 +1275,8 @@ sub output_wrap_vfunc($$$$$$$)
$$objCVfunc{rettype_needs_ref} = $refreturn_ctype;
- $objOutputter->output_wrap_vfunc_h($filename, $line_num, $objCppVfunc, $objCVfunc);
- $objOutputter->output_wrap_vfunc_cc($filename, $line_num, $objCppVfunc, $objCVfunc);
+ $objOutputter->output_wrap_vfunc_h($filename, $line_num, $objCppVfunc, $objCVfunc,$ifdef);
+ $objOutputter->output_wrap_vfunc_cc($filename, $line_num, $objCppVfunc, $objCVfunc, $ifdef);
}
# give some sort of weights to sorting attibutes