[glibmm/gmmproc-refactor] Fix a bunch of mistakes in Normal and Reffed convertors.



commit 7fbc4c55e0ea51a8144b947b2aa86e52a91b53f9
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Sun Jul 22 17:26:08 2012 +0200

    Fix a bunch of mistakes in Normal and Reffed convertors.

 tools/pm/Common/TypeInfo/Convertors/Normal.pm |   22 ++++++++++++++++++++--
 tools/pm/Common/TypeInfo/Convertors/Reffed.pm |    8 ++++----
 2 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/tools/pm/Common/TypeInfo/Convertors/Normal.pm b/tools/pm/Common/TypeInfo/Convertors/Normal.pm
index ef92519..40d9876 100644
--- a/tools/pm/Common/TypeInfo/Convertors/Normal.pm
+++ b/tools/pm/Common/TypeInfo/Convertors/Normal.pm
@@ -32,16 +32,34 @@ sub convert
   {
     when (Common::TypeInfo::Global::C_CXX ())
     {
+      if ($from_details->match_sigil (['c*'], Common::TypeDetails::Base::ACCESS_MODIFIERS))
+      {
+        if ($to_details->match_sigil ([''], Common::TypeDetails::Base::ACCESS_MODIFIERS))
+        {
+          my $base = $from_details->get_value_details ()->get_base ();
+
+          return 'Glib::wrap(const_cast< ' . $base . '* >(' . $subst . '), ' . (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? 'false' : 'true') . ')';
+        }
+      }
+
       if ($from_details->match_sigil (['*']) and $to_details->match_sigil (['']))
       {
-          return join ('', 'Glib::wrap(', $subst, ', ', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? 'true' : 'false'), ')');
+          return join ('', 'Glib::wrap(', $subst, ', ', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? 'false' : 'true'), ')');
       }
     }
     when (Common::TypeInfo::Global::CXX_C ())
     {
+      if ($from_details->match_sigil (['c&'], Common::TypeDetails::Base::ACCESS_MODIFIERS))
+      {
+        if ($to_details->match_sigil (['*'], Common::TypeDetails::Base::ACCESS_MODIFIERS))
+        {
+          return 'const_cast< ' . $to_details->get_string () . ' >(Glib::unwrap' . (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '_copy' : '') . '(' . $subst . '))';
+        }
+      }
+
       if ($from_details->match_sigil (['&']) and $to_details->match_sigil (['*']))
       {
-        return join ('', 'Glib::unwrap', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '' : '_copy'), '(', $subst, ')');
+        return join ('', 'Glib::unwrap', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '_copy' : ''), '(', $subst, ')');
       }
     }
     when (Common::TypeInfo::Global::C_CXX_CONTAINER ())
diff --git a/tools/pm/Common/TypeInfo/Convertors/Reffed.pm b/tools/pm/Common/TypeInfo/Convertors/Reffed.pm
index 470bdb0..2f1103d 100644
--- a/tools/pm/Common/TypeInfo/Convertors/Reffed.pm
+++ b/tools/pm/Common/TypeInfo/Convertors/Reffed.pm
@@ -40,7 +40,7 @@ sub convert ($$$$$$)
       {
         if ($from_details->match_sigil (['*'], Common::TypeDetails::Base::ACCESS_MODIFIERS) and $to_details->match_sigil (['<>&', '<>', '<c>&', '<c>'], Common::TypeDetails::Base::ACCESS_MODIFIERS))
         {
-          return join ('', 'Glib::wrap(', $subst, ', ', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? 'true' : 'false'), ')');
+          return join ('', 'Glib::wrap(', $subst, ', ', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? 'false' : 'true'), ')');
         }
       }
     }
@@ -56,20 +56,20 @@ sub convert ($$$$$$)
         {
           if ($to_details->match_sigil (['*c']))
           {
-            return join ('', 'Glib::unwrap', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '' : '_copy'), '(', $subst, ')');
+            return join ('', 'Glib::unwrap', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '_copy' : ''), '(', $subst, ')');
           }
           elsif ($to_details->match_sigil (['*'], Common::TypeDetails::Base::ACCESS_MODIFIERS))
           {
             my $c_value_details = $to_details->get_value_details ();
             my $c_base = $c_value_details->get_base ();
 
-            return join ('', 'const_cast< ', $c_base, ' >(Glib::unwrap', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '' : '_copy'), '(', $subst, '))');
+            return join ('', 'const_cast< ', $c_base, ' >(Glib::unwrap', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '_copy' : ''), '(', $subst, '))');
           }
         }
 
         if ($from_details->match_sigil (['<>&', '<>', '<>c&', '<>c'], Common::TypeDetails::Base::ACCESS_MODIFIERS) and $to_details->match_sigil (['*', 'c*'], Common::TypeDetails::Base::ACCESS_MODIFIERS))
         {
-          return join ('', 'Glib::unwrap', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '' : '_copy'), '(', $subst, ')');
+          return join ('', 'Glib::unwrap', (($transfer > Common::TypeInfo::Common::TRANSFER_NONE) ? '_copy' : ''), '(', $subst, ')');
         }
       }
     }



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