[glibmm] tools/extra_defs_gen/generate_extra_defs.cc: Update some comments



commit a64d45690e60e9c37af9d8220d5500a2999ae435
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Tue Apr 8 17:00:41 2014 +0200

    tools/extra_defs_gen/generate_extra_defs.cc: Update some comments
    
    * tools/extra_defs_gen/generate_extra_defs.cc: Change comments stating
    that get_properties() fails for GVolume. GVolume is an ordinary GInterface.
    If the first call is get_properties(G_TYPE_VOLUME), it fails if glib
    bug #465631 has not been fixed.

 tools/extra_defs_gen/generate_extra_defs.cc |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/tools/extra_defs_gen/generate_extra_defs.cc b/tools/extra_defs_gen/generate_extra_defs.cc
index 8229cd7..52a35fe 100644
--- a/tools/extra_defs_gen/generate_extra_defs.cc
+++ b/tools/extra_defs_gen/generate_extra_defs.cc
@@ -23,6 +23,9 @@
 #include "generate_extra_defs.h"
 #include <algorithm>
 
+// Until the glib bug https://bugzilla.gnome.org/show_bug.cgi?id=465631
+// is fixed, get_properties() must be called for a GObject before it's
+// called for a GInterface.
 std::string get_properties(GType gtype)
 {
   std::string strResult;
@@ -45,19 +48,21 @@ std::string get_properties(GType gtype)
   else if (G_TYPE_IS_INTERFACE(gtype))
   {
     gpointer pGInterface = g_type_default_interface_ref(gtype);
-    if(pGInterface) //We check because this fails for G_TYPE_VOLUME, for some reason.
+    if(pGInterface)
     {
       ppParamSpec = g_object_interface_list_properties(pGInterface, &iCount);
       g_type_default_interface_unref(pGInterface);
 
       if(!ppParamSpec)
       {
-        strResult +=  ";; Warning: g_object_interface_list_properties() returned NULL for " + 
std::string(g_type_name(gtype)) + "\n";
+        strResult += ";; Warning: g_object_interface_list_properties() returned NULL for " + 
std::string(g_type_name(gtype)) + "\n";
       }
     }
+    else
+      strResult += ";; Warning: g_type_default_interface_ref() returned NULL for " + 
std::string(g_type_name(gtype)) + "\n";
   }
 
-  //This extra check avoids an occasional crash, for instance for GVolume
+  //This extra check avoids an occasional crash
   if(!ppParamSpec)
     iCount = 0;
 
@@ -211,7 +216,7 @@ std::string get_signals(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
           GType typeParamMangled = pParameters[i];
 
           //Parameter name:
-          //TODO: How can we get the real parameter name?
+          //We can't get the real parameter name from the GObject system. It's not registered with 
g_signal_new().
           gchar* pchNum = g_strdup_printf("%d", i);
           std::string strParamName = "p" + std::string(pchNum);
           g_free(pchNum);
@@ -219,15 +224,15 @@ std::string get_signals(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
 
           //Just like above, for the return type:
           std::string strTypeName = get_type_name_signal( typeParamMangled & ~G_SIGNAL_TYPE_STATIC_SCOPE, 
is_a_pointer_func ); //The type is mangled with a flag. Hacky.
-          //bool bReturnTypeHasStaticScope = (typeParamMangled & G_SIGNAL_TYPE_STATIC_SCOPE) == 
G_SIGNAL_TYPE_STATIC_SCOPE;
+          //bool bTypeHasStaticScope = (typeParamMangled & G_SIGNAL_TYPE_STATIC_SCOPE) == 
G_SIGNAL_TYPE_STATIC_SCOPE;
 
           strResult += "    '(\"" + strTypeName + "\" \"" + strParamName + "\")\n";
         }
 
-        strResult += "  )\n"; //close (properties
+        strResult += "  )\n"; //close (parameters
       }
 
-      strResult += ")\n\n"; //close (define=signal
+      strResult += ")\n\n"; //close (define-signal
     }
   }
 
@@ -242,17 +247,20 @@ std::string get_signals(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
 }
 
 
-
 std::string get_defs(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
 {
   std::string strObjectName = g_type_name(gtype);
-  std::string strDefs = ";; From " + strObjectName + "\n\n";
+  std::string strDefs;
 
   if(G_TYPE_IS_OBJECT(gtype) || G_TYPE_IS_INTERFACE(gtype))
   {
+    strDefs = ";; From " + strObjectName + "\n\n";
     strDefs += get_signals(gtype, is_a_pointer_func);
     strDefs += get_properties(gtype);
   }
+  else
+    strDefs = ";; " + strObjectName +
+      " is neither a GObject nor a GInterface. Not checked for signals and properties.\n\n";
 
   return strDefs;
 }


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