[glibmm] gmmproc: Make the output param feature work for single indirection.



commit e06484cfd320798bad86ae4363242dab4d7d644a
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date:   Wed Sep 26 00:26:02 2012 -0400

    gmmproc: Make the output param feature work for single indirection.
    
    	* tools/pm/Output.pm (convert_args_cpp_to_c): When inserting C object
    	initializations for C objects that will be used to set output
    	parameters, initialize the C object to a "default constructed" object
    	of the same type if there is single indirection and not zero to ensure
    	successful compilation in that case.
    	* tools/m4/method.m4: Whitespace correction of the body of generated
    	non-static methods.  This ensures each statement is on its own line
    	and that there are no blank lines to make methods as compact as
    	possible.
    
    	Bug #662371.

 ChangeLog          |   16 ++++++++++++++++
 tools/m4/method.m4 |   19 ++++++++++---------
 tools/pm/Output.pm |   14 +++++++++++++-
 3 files changed, 39 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1bbe519..9695a05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2012-09-25  Josà Alburquerque  <jaalburquerque gmail com>
+
+	gmmproc: Make the output param feature work for single indirection.
+
+	* tools/pm/Output.pm (convert_args_cpp_to_c): When inserting C object
+	initializations for C objects that will be used to set output
+	parameters, initialize the C object to a "default constructed" object
+	of the same type if there is single indirection and not zero to ensure
+	successful compilation in that case.
+	* tools/m4/method.m4: Whitespace correction of the body of generated
+	non-static methods.  This ensures each statement is on its own line
+	and that there are no blank lines to make methods as compact as
+	possible.
+
+	Bug #662371.
+
 2.33.13:
 
 2012-09-25  Murray Cumming  <murrayc murrayc com>
diff --git a/tools/m4/method.m4 b/tools/m4/method.m4
index 5dd7fd7..41a5e76 100644
--- a/tools/m4/method.m4
+++ b/tools/m4/method.m4
@@ -26,14 +26,13 @@ dnl Insert the declarations for C output parameters
 ')`'dnl
 ifelse(`$16',,dnl If no C++ output parameter is specified
 `ifelse(`$3',void,dnl If the C function returns voids:
-`  $2(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7);dnl
+`  $2(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7);
 dnl Insert the initializations for the C output parameters
 ifelse(`$8',,,`$8
 ')dnl
-'dnl If the C function returns non-void:
-,dnl Insert the declarations for C output parameters
+',dnl If the C function returns non-void:
 dnl Store the return if there are C output parameters.
-`ifelse(`$6',,`  return ',`  `$3' retvalue = ')_CONVERT($4,`$3',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)');dnl
+`ifelse(`$6',,`  return ',`  `$3' retvalue = ')_CONVERT($4,`$3',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)');
 dnl Insert the initializations for the C output parameters
 ifelse(`$8',,,`$8
 ')dnl
@@ -55,26 +54,28 @@ dnl Insert the declarations for C output parameters
 ifelse(`$6',,,`$6
 ')`'dnl
 ifelse(`$16',,dnl If no C++ output parameter is specified:
-`  ifelse(`$3',void,,``$3' retvalue = ')_CONVERT($4,`$3',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)');dnl
+`  ifelse(`$3',void,,``$3' retvalue = ')_CONVERT($4,`$3',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)');
 'dnl
 ,dnl A C++ output parameter is specified:
 `  _INITIALIZE($17,$4,`$16',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)',$18);
 'dnl
 )dnl
-ifelse(`$11',,,`
+ifelse(`$11',,,`dnl
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
 ')dnl
-ifelse(`$10',,,`
+ifelse(`$10',,,`dnl
   if(ifelse(`$16',,`retvalue',$16))
     ifelse(`$16',,`retvalue',$16)->reference(); //The function does not do a ref for us.
 ')dnl
 dnl Insert the initializations for the C output parameters
 ifelse(`$8',,,`$8
 ')`'dnl
-ifelse(`$3',void,,`  return retvalue;')dnl
+ifelse(`$3',void,,`  return retvalue;
+')dnl
 ')dnl End errthrow/refreturn
-',`  return const_cast<__CPPNAME__*>(this)->$1($14);')
+',`  return const_cast<__CPPNAME__*>(this)->$1($14);
+')dnl
 }
 
 ifelse(`$15',,,`
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 916b18c..bd8fb80 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -974,8 +974,20 @@ sub convert_args_cpp_to_c($$$$$)
       # Remove a possible final '*' from the output parameter type because it
       # will be passed by C reference (&name).
       $cOutputParamType =~ s/\*$//;
+ 
+      # Only initialize pointers to zero.  Otherwise, use the default
+      # constructor of the type.
+      my $initialization = "";
+      if($cOutputParamType =~ /\*$/)
+      {
+        $initialization = " = 0"; 
+      }
+      else
+      {
+        $initialization = " = $cOutputParamType()"; 
+      }
 
-      push(@declarations, "  $cOutputParamType $cOutputParamName = 0;");
+      push(@declarations, "  $cOutputParamType $cOutputParamName$initialization;");
 
       push(@conversions, "&" . $cOutputParamName);
 



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