[glibmm] gmmproc: Add optional argument err_return_value in _WRAP_VFUNC



commit 71d272a1926260ad3ee8abd38875066b139801b8
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Jun 2 08:59:49 2016 +0200

    gmmproc: Add optional argument err_return_value in _WRAP_VFUNC
    
    * tools/m4/vfunc.m4:
    * tools/pm/Output.pm:
    * tools/pm/WrapParser.pm: Add the optional argument err_return_value in
    _WRAP_VFUNC. This return value, if specified, applies only when the C++ vfunc
    throws an exception, which is propagated to the C callback function.

 tools/m4/vfunc.m4      |   16 ++++++++--------
 tools/pm/Output.pm     |    4 +++-
 tools/pm/WrapParser.pm |   21 +++++++++++++++++----
 3 files changed, 28 insertions(+), 13 deletions(-)
---
diff --git a/tools/m4/vfunc.m4 b/tools/m4/vfunc.m4
index 5b6f114..e1609a9 100644
--- a/tools/m4/vfunc.m4
+++ b/tools/m4/vfunc.m4
@@ -24,8 +24,8 @@ dnl                   $5               $6           $7            $8
 dnl            `<cargs and names>',`<cnames>',`<cpparg names>',firstarg,
 dnl                $9               $10        $11     $12
 dnl             refreturn_ctype, keep_return, ifdef, errthrow,
-dnl               $13           $14            $15             $16
-dnl            slot_type, c_data_param_name, return_value, exception_handler)
+dnl               $13           $14            $15             $16               $17
+dnl            slot_type, c_data_param_name, return_value, err_return_value, exception_handler)
 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_(),
@@ -89,15 +89,15 @@ ifelse($10,keep_return,`dnl
 ')dnl end refreturn_ctype
 ')dnl end void
       }
-ifelse($16,,,`dnl if (exception_handler)
+ifelse($17,,,`dnl if (exception_handler)
       catch(...)
       {
         try
         {
 ifelse($9,refreturn_ctype,`dnl
-          return Glib::unwrap_copy`'(obj->$16`'());
+          return Glib::unwrap_copy`'(obj->$17`'());
 ', `dnl
-          return _CONVERT($3, $4, `obj->$16`'()');
+          return _CONVERT($3, $4, `obj->$17`'()');
 ')dnl
         }
 ')dnl end exception_handler
@@ -108,11 +108,11 @@ ifelse($12,errthrow,`dnl
 ifelse($4,void,`dnl
         return;
 ',`dnl
-ifelse(`$15', `',`dnl
+ifelse(`$16', `',`dnl
         using RType = $4;
         return RType`'();
 ',`dnl
-        return _CONVERT($3,$4,`$15');
+        return _CONVERT($3,$4,`$16');
 ')dnl
 ')dnl
       }
@@ -121,7 +121,7 @@ ifelse(`$15', `',`dnl
       {
         Glib::exception_handlers_invoke`'();
       }
-ifelse($16,,,`dnl if (exception_handler)
+ifelse($17,,,`dnl if (exception_handler)
       }
 ')dnl
     }
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 6af2775..b920791 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -240,9 +240,10 @@ sub output_wrap_vfunc_cc($$$$$$$$)
      convert_args_c_to_cpp($objCFunc, $objCppfunc, $line_num);
 
     my $returnValue = $$objCppfunc{return_value};
+    my $errReturnValue = $$objCppfunc{err_return_value};
     my $exceptionHandler = $$objCppfunc{exception_handler};
 
-    my $str = sprintf("_VFUNC_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',%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,%s,%s,%s,%s,%s,%s,%s)dnl\n",
       $$objCppfunc{name},
       $cname,
       $$objCppfunc{rettype},
@@ -258,6 +259,7 @@ sub output_wrap_vfunc_cc($$$$$$$$)
       $$objCppfunc{slot_type},
       $$objCppfunc{c_data_param_name},
       $returnValue,
+      $errReturnValue,
       $exceptionHandler);
 
     $self->append($str);
diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm
index 9a03e73..3f71ece 100644
--- a/tools/pm/WrapParser.pm
+++ b/tools/pm/WrapParser.pm
@@ -1325,6 +1325,7 @@ sub on_wrap_vfunc($)
   my $keep_return = 0;
   my $refreturn_ctype = 0;
   my $returnValue = "";
+  my $errReturnValue = "";
   my $exceptionHandler = "";
   my $custom_vfunc = 0;
   my $custom_vfunc_callback = 0;
@@ -1360,6 +1361,14 @@ sub on_wrap_vfunc($)
     {
       $returnValue = $1;
     }
+    # Return value, if the C++ vfunc throws an exception which is propagated
+    # to the C callback.
+    # (Default is the default value of the return type or, if return_value
+    # is specified, the return_value.)
+    elsif($argRef =~ /^err_return_value\s+(.*)/)
+    {
+      $errReturnValue = $1;
+    }
     # If exception handler is not defined, then Glib::exception_handlers_invoke
     # method will be used for exception handling.
     elsif($argRef =~ /^exception_handler\s+(.*)/)
@@ -1402,11 +1411,13 @@ sub on_wrap_vfunc($)
       $no_slot_copy = 1;
     }
   }
+  $errReturnValue = $returnValue if ($returnValue ne "" and $errReturnValue eq "");
 
   $self->output_wrap_vfunc($argCppDecl, $argCName, $$self{filename}, $$self{line_num},
                            $refreturn, $keep_return, $refreturn_ctype, $custom_vfunc,
                            $custom_vfunc_callback, $ifdef, $errthrow,
-                           $slot_name, $slot_callback, $no_slot_copy, $returnValue, $exceptionHandler);
+                           $slot_name, $slot_callback, $no_slot_copy,
+                           $returnValue, $errReturnValue, $exceptionHandler);
 }
 
 # Common part of _WRAP_ENUM(), _WRAP_ENUM_DOCS_ONLY() and _WRAP_GERROR().
@@ -1689,12 +1700,13 @@ sub output_wrap_signal($$$$$$$$$$$$$$$$$)
 # void output_wrap_vfunc($CppDecl, $vfunc_name, $filename, $line_num,
 #                  $refreturn, $keep_return, $refreturn_ctype,
 #                  $custom_vfunc, $custom_vfunc_callback, $ifdef, $errthrow,
-#                  $slot_name, $slot_callback, $no_slot_copy, $returnValue, $exceptionHandler)
-sub output_wrap_vfunc($$$$$$$$$$$$$$$$$)
+#                  $slot_name, $slot_callback, $no_slot_copy, $returnValue,
+#                  $errReturnValue, $exceptionHandler)
+sub output_wrap_vfunc($$$$$$$$$$$$$$$$$$)
 {
   my ($self, $CppDecl, $vfunc_name, $filename, $line_num, $refreturn, $keep_return, $refreturn_ctype,
       $custom_vfunc, $custom_vfunc_callback, $ifdef, $errthrow,
-      $slot_name, $slot_callback, $no_slot_copy, $returnValue, $exceptionHandler) = @_;
+      $slot_name, $slot_callback, $no_slot_copy, $returnValue, $errReturnValue, $exceptionHandler) = @_;
 
   #Some checks:
   return if ($self->output_wrap_check($CppDecl, $vfunc_name, $filename, $line_num, '_WRAP_VFUNC'));
@@ -1727,6 +1739,7 @@ sub output_wrap_vfunc($$$$$$$$$$$$$$$$$)
   $$objCppVfunc{rettype_needs_ref} = $refreturn;
   $$objCppVfunc{keep_return} = $keep_return;
   $$objCppVfunc{return_value} = $returnValue;
+  $$objCppVfunc{err_return_value} = $errReturnValue;
   $$objCppVfunc{exception_handler} = $exceptionHandler;
   $$objCppVfunc{name} .= "_vfunc"; #All vfuncs should have the "_vfunc" suffix, and a separate easily-named 
invoker method.
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]