summaryrefslogtreecommitdiff
path: root/tools/m4/vfunc.m4
diff options
context:
space:
mode:
authorJosé Alburquerque <jaalburqu@svn.gnome.org>2012-09-06 00:01:23 -0400
committerJosé Alburquerque <jaalburqu@svn.gnome.org>2012-09-06 16:33:03 -0400
commit629eb04ecce6d8b617292710bf4862169b693cca (patch)
treed0bf4ea0ededdfd46dafcda5e534c86477fdf535 /tools/m4/vfunc.m4
parentd62e14c530c0eaeab7436ad947b5bfcc5ed1c885 (diff)
downloadglibmm-629eb04ecce6d8b617292710bf4862169b693cca.tar.gz
gmmproc: _WRAP_VFUNC: Handle virtual functions that throw GErrors.
* tools/pm/WrapParser.pm (on_wrap_vfunc): Modified so that _WRAP_VFUNC recognizes an optional "errthrow" parameter as is done in _WRAP_METHOD. (output_wrap_vfunc): Modified to tag the located virtual function definition as one that will be wrapped by a C++ method that throws the final C GError parameter. * tools/pm/Output.pm (output_wrap_vfunc_cc): Modified to pass an optional "errthrow" string to _VFUNC_CC and _VFUNC_PCC so that they can include the proper code for the getting and throwing of the GError. Also modified to pass the "errthrow" string to the convert_args_cpp_to_c() so that it process the C++ method as one throwing a Glib::Error. (convert_args_c_to_cpp): Modified to ignore the final GError if the C function has been marked as one that will be wrapped by a C++ method throwing the final C GError parameter. * tools/m4/vfunc.m4 (_VFUNC_PCC): Modified to recognize a final "errthrow" string parameter in which case code is inserted to declare a local parameter in which to store the C GError and then throw it as a Glib::Error if an error was received when the underlying C function is called in the virtual function callback. (_VFUNC_CC): Also modified to recognize a final "errthrow" string parameter inserting code to store and then throw a possibly obtained GError as a Glib::Error in the C++ virtual function when calling the underlying C virtual function.
Diffstat (limited to 'tools/m4/vfunc.m4')
-rw-r--r--tools/m4/vfunc.m435
1 files changed, 27 insertions, 8 deletions
diff --git a/tools/m4/vfunc.m4 b/tools/m4/vfunc.m4
index 93fccc1b..c361162e 100644
--- a/tools/m4/vfunc.m4
+++ b/tools/m4/vfunc.m4
@@ -18,10 +18,10 @@ ifelse(`$4',,,`#endif // $4
_POP()')
-dnl $1 $2 $3 $4
+dnl $1 $2 $3 $4
dnl _VFUNC_PCC(cppname,gtkname,cpprettype,crettype,
-dnl $5 $6 $7 $8 $9 $10
-dnl `<cargs and names>',`<cnames>',`<cpparg names>',firstarg, refreturn_ctype, ifdef)
+dnl $5 $6 $7 $8 $9 $10 $11
+dnl `<cargs and names>',`<cnames>',`<cpparg names>',firstarg, refreturn_ctype, ifdef, errthrow)
dnl
dnl Note: _get_current_wrapper_inline() could be used throughout for performance instead of _get_current_wrapper(),
dnl and is_derived_() instead of is_derived_(),
@@ -86,7 +86,15 @@ dnl g_assert(base != 0);
// Call the original underlying C function:
if(base && base->$2)
- ifelse($4,void,,`return ')(*base->$2)`'($6);
+ {
+ ifelse($4,void,,`$4 result = ')(*base->$2)`'($6);
+ifelse($11,errthrow,`dnl
+ if(*error)
+ ::Glib::Error::throw_exception(*error);
+')dnl
+ifelse($4,void,,` return result;
+')dnl
+ }
ifelse($4,void,,`dnl
@@ -98,8 +106,8 @@ ifelse(`$10',,,`#endif // $10
')dnl
_POP()')
-# $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)
+# $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
+# _VFUNC_CC(vfunc_name, gtkname, cpp_rettype, c_rettype, `<cppargs>', `<carg_names>', is_const, refreturn, $ifdef, $errthrow)
#
define(`_VFUNC_CC',`dnl
_PUSH(SECTION_CC_VFUNCS)
@@ -116,14 +124,25 @@ ifdef(`__BOOL_IS_INTERFACE__',`dnl
dnl g_assert(base != 0);
if(base && base->$2)
+ {
+ifelse($10,errthrow,`dnl
+ GError* gerror = 0;
+')dnl
ifelse($3,void,`dnl
(*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6));
+ }
',`dnl
ifelse($8,refreturn,`dnl Assume Glib::wrap() is correct if refreturn is requested.
- return Glib::wrap((*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6)), true);
+ $3 result(Glib::wrap((*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6)), true));
',`dnl
- return _CONVERT($4,$3,`(*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6))');
+ $3 result(_CONVERT($4,$3,`(*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6))'));
')dnl
+ifelse($10,errthrow,`dnl
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+')dnl
+ return result;
+ }
typedef $3 RType;
return RType`'();