[glibmm] gmmproc: Add parameter return_value in _WRAP_VFUNC.



commit fc14e6c03db879bc3e0a7bac353c76948f482c10
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Sat Aug 31 09:38:08 2013 +0200

    gmmproc: Add parameter return_value in _WRAP_VFUNC.
    
    * tools/m4/vfunc.m4:
    * tools/pm/Output.pm:
    * tools/pm/WrapParser.pm: Add parameter return_value in _WRAP_VFUNC.
    Bug #705699.

 tools/m4/vfunc.m4      |   17 ++++++++++++-----
 tools/pm/Output.pm     |   13 +++++++++----
 tools/pm/WrapParser.pm |   17 +++++++++++++----
 3 files changed, 34 insertions(+), 13 deletions(-)
---
diff --git a/tools/m4/vfunc.m4 b/tools/m4/vfunc.m4
index 061ba5c..652aabc 100644
--- a/tools/m4/vfunc.m4
+++ b/tools/m4/vfunc.m4
@@ -22,8 +22,8 @@ dnl              $1      $2       $3        $4
 dnl _VFUNC_PCC(cppname,gtkname,cpprettype,crettype,
 dnl                         $5               $6           $7            $8         $9           $10      $11
 dnl                  `<cargs and names>',`<cnames>',`<cpparg names>',firstarg, refreturn_ctype, ifdef, 
errthrow,
-dnl                     $12           $13
-dnl                  slot_type, c_data_param_name)
+dnl                     $12           $13            $14
+dnl                  slot_type, c_data_param_name, return_value)
 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_(),
@@ -103,17 +103,20 @@ ifelse($4,void,,`    return retval;
   }
 
 ifelse($4,void,,`dnl
-
+ifelse(`$14', `',`dnl
   typedef $4 RType;
   return RType`'();
+',`dnl
+  return _CONVERT($3,$4,`$14');
+')dnl
 ')dnl
 }
 ifelse(`$10',,,`#endif // $10
 ')dnl
 _POP()')
 
-#               $1        $2          $3         $4          $5             $6          $7        $8        
$9        $10         $11        $12          $13
-# _VFUNC_CC(vfunc_name, gtkname, cpp_rettype, c_rettype, `<cppargs>', `<carg_names>', is_const, refreturn, 
$ifdef, $errthrow, $slot_type, $slot_name, $no_slot_copy)
+#               $1        $2          $3         $4          $5             $6          $7        $8        
$9        $10         $11        $12          $13           $14
+# _VFUNC_CC(vfunc_name, gtkname, cpp_rettype, c_rettype, `<cppargs>', `<carg_names>', is_const, refreturn, 
$ifdef, $errthrow, $slot_type, $slot_name, $no_slot_copy, $returnValue)
 #
 define(`_VFUNC_CC',`dnl
 _PUSH(SECTION_CC_VFUNCS)
@@ -161,8 +164,12 @@ ifelse($10,errthrow,`dnl
     return retval;
   }
 
+ifelse(`$14', `',`dnl
   typedef $3 RType;
   return RType`'();
+',`dnl
+  return $14;
+')dnl
 ')dnl
 }
 ifelse(`$9',,,`#endif // $9
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 8ad75d0..1f0421b 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -170,6 +170,7 @@ sub output_wrap_vfunc_cc($$$$$$$$)
   {
     my $refreturn = "";
     $refreturn = "refreturn" if($$objCppfunc{rettype_needs_ref});
+    my $returnValue = $$objCppfunc{return_value};
 
     my ($conversions, $declarations, $initializations) =
       convert_args_cpp_to_c($objCppfunc, $objCFunc, 0, $line_num, $errthrow);
@@ -177,7 +178,7 @@ sub output_wrap_vfunc_cc($$$$$$$$)
     my $no_slot_copy = "";
     $no_slot_copy = "no_slot_copy" if ($$objCppfunc{no_slot_copy});
 
-    my $str = sprintf("_VFUNC_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s,%s,%s,%s,%s)dnl\n",
+    my $str = sprintf("_VFUNC_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s,%s,%s,%s,%s,%s)dnl\n",
       $$objCppfunc{name},
       $cname,
       $$objCppfunc{rettype},
@@ -190,7 +191,8 @@ sub output_wrap_vfunc_cc($$$$$$$$)
       $errthrow,
       $$objCppfunc{slot_type},
       $$objCppfunc{slot_name},
-      $no_slot_copy);
+      $no_slot_copy,
+      $returnValue);
 
     $self->append($str);
   }
@@ -206,7 +208,9 @@ sub output_wrap_vfunc_cc($$$$$$$$)
     my $conversions =
      convert_args_c_to_cpp($objCFunc, $objCppfunc, $line_num);
 
-    my $str = sprintf("_VFUNC_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',%s,%s,%s,%s,%s,%s)dnl\n",
+    my $returnValue = $$objCppfunc{return_value};
+
+    my $str = sprintf("_VFUNC_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',%s,%s,%s,%s,%s,%s,%s)dnl\n",
       $$objCppfunc{name},
       $cname,
       $$objCppfunc{rettype},
@@ -219,7 +223,8 @@ sub output_wrap_vfunc_cc($$$$$$$$)
       $ifdef,
       $errthrow,
       $$objCppfunc{slot_type},
-      $$objCppfunc{c_data_param_name});
+      $$objCppfunc{c_data_param_name},
+      $returnValue);
 
     $self->append($str);
   }
diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm
index f87efd6..d956fd2 100644
--- a/tools/pm/WrapParser.pm
+++ b/tools/pm/WrapParser.pm
@@ -1242,6 +1242,7 @@ sub on_wrap_vfunc($)
 
   my $refreturn = 0;
   my $refreturn_ctype = 0;
+  my $returnValue = "";
   my $custom_vfunc = 0;
   my $custom_vfunc_callback = 0;
   my $ifdef = "";
@@ -1263,6 +1264,13 @@ sub on_wrap_vfunc($)
     {
       $refreturn_ctype = 1;
     }
+    # Return value, if neither the underlying C class defines the vfunc
+    # nor the C++ vfunc is overridden in a user-defined subclass.
+    # (Default is the default value of the return type, e.g. false or 0.)
+    elsif($argRef =~ /^return_value\s+(.*)/)
+    {
+      $returnValue = $1;
+    }
     elsif($argRef eq "custom_vfunc")
     {
       $custom_vfunc = 1;
@@ -1303,7 +1311,7 @@ sub on_wrap_vfunc($)
   $self->output_wrap_vfunc($argCppDecl, $argCName, $$self{filename}, $$self{line_num},
                            $refreturn, $refreturn_ctype, $custom_vfunc,
                            $custom_vfunc_callback, $ifdef, $errthrow,
-                           $slot_name, $slot_callback, $no_slot_copy);
+                           $slot_name, $slot_callback, $no_slot_copy, $returnValue);
 }
 
 sub on_wrap_enum($)
@@ -1500,12 +1508,12 @@ sub output_wrap_signal($$$$$$$$$$$)
 # void output_wrap_vfunc($CppDecl, $vfunc_name, $filename, $line_num,
 #                  $refreturn, $refreturn_ctype,
 #                  $custom_vfunc, $custom_vfunc_callback, $ifdef, $errthrow,
-#                  $slot_name, $slot_callback, $no_slot_copy)
-sub output_wrap_vfunc($$$$$$$$$$$$)
+#                  $slot_name, $slot_callback, $no_slot_copy, $returnValue)
+sub output_wrap_vfunc($$$$$$$$$$$$$)
 {
   my ($self, $CppDecl, $vfunc_name, $filename, $line_num, $refreturn, $refreturn_ctype,
       $custom_vfunc, $custom_vfunc_callback, $ifdef, $errthrow,
-      $slot_name, $slot_callback, $no_slot_copy) = @_;
+      $slot_name, $slot_callback, $no_slot_copy, $returnValue) = @_;
 
   #Some checks:
   return if ($self->output_wrap_check($CppDecl, $vfunc_name, $filename, $line_num, '_WRAP_VFUNC'));
@@ -1536,6 +1544,7 @@ sub output_wrap_vfunc($$$$$$$$$$$$)
   # These macros are defined in vfunc.m4:
 
   $$objCppVfunc{rettype_needs_ref} = $refreturn;
+  $$objCppVfunc{return_value} = $returnValue;
   $$objCppVfunc{name} .= "_vfunc"; #All vfuncs should have the "_vfunc" suffix, and a separate easily-named 
invoker method.
 
   # Store the slot information in the vfunc if specified.


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