[glibmm/glibmm-2-18] Modify extra defs generation utility to accept a custom is_a_pointer() function.
- From: José Alburquerque <jaalburqu src gnome org>
- To: svn-commits-list gnome org
- Subject: [glibmm/glibmm-2-18] Modify extra defs generation utility to accept a custom is_a_pointer() function.
- Date: Wed, 17 Jun 2009 00:07:40 -0400 (EDT)
commit f893534a4bb2baac268b63d66db7691bab68d1f9
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Wed Jun 17 00:06:52 2009 -0400
Modify extra defs generation utility to accept a custom is_a_pointer() function.
ChangeLog | 11 +++++++++
tools/extra_defs_gen/generate_extra_defs.cc | 27 ++++++++++++++---------
tools/extra_defs_gen/generate_extra_defs.h | 31 ++++++++++++++++++++++----
3 files changed, 53 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e587080..73d1b49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-06-16 José Alburquerque <jaalburqu svn gnome org>
+
+ * tools/extra_defs_gen/generate_extra_defs.cc:
+ * tools/extra_defs_gen/generate_extra_defs.h: Modify extra defs
+ generation utility to accept a custom defined function to determine if
+ a GType is a pointer. This was discussed in bug #562810 and I went
+ back and forth about applying it. I applied it, but later reverted it.
+ Now I find that it is difficult to keep patching the generated defs
+ files in gstreamermm. Since permission was granted, I'm re-applying it
+ once and for all.
+
2009-05-19 Siavash Safi <siavash siavashs org>
* tools/enum.pl: Fix --module option to work
diff --git a/tools/extra_defs_gen/generate_extra_defs.cc b/tools/extra_defs_gen/generate_extra_defs.cc
index 63f570a..89a85af 100644
--- a/tools/extra_defs_gen/generate_extra_defs.cc
+++ b/tools/extra_defs_gen/generate_extra_defs.cc
@@ -103,11 +103,16 @@ std::string get_properties(GType gtype)
return strResult;
}
-std::string get_type_name(GType gtype) //Adds a * if necessary.
+bool gtype_is_a_pointer(GType gtype)
+{
+ return (g_type_is_a(gtype, G_TYPE_OBJECT) || g_type_is_a(gtype, G_TYPE_BOXED));
+}
+
+std::string get_type_name(GType gtype, GTypeIsAPointerFunc is_a_pointer_func) //Adds a * if necessary.
{
std::string strTypeName = g_type_name(gtype);
- if( g_type_is_a(gtype, G_TYPE_OBJECT) || g_type_is_a(gtype, G_TYPE_BOXED) )
+ if (is_a_pointer_func && is_a_pointer_func(gtype))
strTypeName += "*"; //Add * to show that it's a pointer.
else if( g_type_is_a(gtype, G_TYPE_STRING) )
strTypeName = "gchar*"; //g_type_name() returns "gchararray".
@@ -115,9 +120,9 @@ std::string get_type_name(GType gtype) //Adds a * if necessary.
return strTypeName;
}
-std::string get_type_name_parameter(GType gtype)
+std::string get_type_name_parameter(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
{
- std::string strTypeName = get_type_name(gtype);
+ std::string strTypeName = get_type_name(gtype, is_a_pointer_func);
//All signal parameters that are registered as GTK_TYPE_STRING are actually const gchar*.
if(strTypeName == "gchar*")
@@ -126,13 +131,13 @@ std::string get_type_name_parameter(GType gtype)
return strTypeName;
}
-std::string get_type_name_signal(GType gtype)
+std::string get_type_name_signal(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
{
- return get_type_name_parameter(gtype); //At the moment, it needs the same stuff.
+ return get_type_name_parameter(gtype, is_a_pointer_func); //At the moment, it needs the same stuff.
}
-std::string get_signals(GType gtype)
+std::string get_signals(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
{
std::string strResult;
std::string strObjectName = g_type_name(gtype);
@@ -168,7 +173,7 @@ std::string get_signals(GType gtype)
g_signal_query(signal_id, &signalQuery);
//Return type:
- std::string strReturnTypeName = get_type_name_signal( signalQuery.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE ); //The type is mangled with a flag. Hacky.
+ std::string strReturnTypeName = get_type_name_signal( signalQuery.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE, is_a_pointer_func ); //The type is mangled with a flag. Hacky.
//bool bReturnTypeHasStaticScope = (signalQuery.return_type & G_SIGNAL_TYPE_STATIC_SCOPE) == G_SIGNAL_TYPE_STATIC_SCOPE;
strResult += " (return-type \"" + strReturnTypeName + "\")\n";
@@ -209,7 +214,7 @@ std::string get_signals(GType gtype)
pchNum = 0;
//Just like above, for the return type:
- std::string strTypeName = get_type_name_signal( typeParamMangled & ~G_SIGNAL_TYPE_STATIC_SCOPE ); //The type is mangled with a flag. Hacky.
+ 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;
strResult += " '(\"" + strTypeName + "\" \"" + strParamName + "\")\n";
@@ -234,14 +239,14 @@ std::string get_signals(GType gtype)
-std::string get_defs(GType gtype)
+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";
if(G_TYPE_IS_OBJECT(gtype) || G_TYPE_IS_INTERFACE(gtype))
{
- strDefs += get_signals(gtype);
+ strDefs += get_signals(gtype, is_a_pointer_func);
strDefs += get_properties(gtype);
}
diff --git a/tools/extra_defs_gen/generate_extra_defs.h b/tools/extra_defs_gen/generate_extra_defs.h
index 5f20945..2213f03 100644
--- a/tools/extra_defs_gen/generate_extra_defs.h
+++ b/tools/extra_defs_gen/generate_extra_defs.h
@@ -24,10 +24,31 @@
#include <iostream>
#include <string>
-std::string get_defs(GType gtype);
+/** Function pointer type for functions that determine if a GType is a pointer
+ * type.
+ */
+typedef bool (*GTypeIsAPointerFunc)(GType gtype);
+
+/** Default extra defs utility function to determine if a GType is a pointer
+ * type.
+ * @param gtype The GType.
+ * @return true if the GType is a GObject or a boxed type, false otherwise.
+ */
+bool gtype_is_a_pointer(GType gtype);
+
+std::string get_defs(GType gtype,
+ GTypeIsAPointerFunc is_a_pointer_func = gtype_is_a_pointer);
std::string get_properties(GType gtype);
-std::string get_type_name(GType gtype);
-std::string get_type_name_parameter(GType gtype);
-std::string get_type_name_signal(GType gtype);
-std::string get_signals(GType gtype);
+
+std::string get_type_name(GType gtype,
+ GTypeIsAPointerFunc is_a_pointer_func = gtype_is_a_pointer);
+
+std::string get_type_name_parameter(GType gtype,
+ GTypeIsAPointerFunc is_a_pointer_func = gtype_is_a_pointer);
+
+std::string get_type_name_signal(GType gtype,
+ GTypeIsAPointerFunc is_a_pointer_func = gtype_is_a_pointer);
+
+std::string get_signals(GType gtype,
+ GTypeIsAPointerFunc is_a_pointer_func = gtype_is_a_pointer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]