glibmm r768 - in branches/glibmm-2-18: . tools/extra_defs_gen
- From: jaalburqu svn gnome org
- To: svn-commits-list gnome org
- Subject: glibmm r768 - in branches/glibmm-2-18: . tools/extra_defs_gen
- Date: Tue, 16 Dec 2008 18:05:05 +0000 (UTC)
Author: jaalburqu
Date: Tue Dec 16 18:05:04 2008
New Revision: 768
URL: http://svn.gnome.org/viewvc/glibmm?rev=768&view=rev
Log:
2008-12-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 custom defined function to determine if
GType is a pointer.
Modified:
branches/glibmm-2-18/ChangeLog
branches/glibmm-2-18/tools/extra_defs_gen/generate_extra_defs.cc
branches/glibmm-2-18/tools/extra_defs_gen/generate_extra_defs.h
Modified: branches/glibmm-2-18/tools/extra_defs_gen/generate_extra_defs.cc
==============================================================================
--- branches/glibmm-2-18/tools/extra_defs_gen/generate_extra_defs.cc (original)
+++ branches/glibmm-2-18/tools/extra_defs_gen/generate_extra_defs.cc Tue Dec 16 18:05:04 2008
@@ -100,11 +100,16 @@
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".
@@ -112,9 +117,9 @@
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*")
@@ -123,13 +128,13 @@
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);
@@ -165,7 +170,7 @@
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";
@@ -206,7 +211,7 @@
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";
@@ -231,14 +236,14 @@
-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);
}
Modified: branches/glibmm-2-18/tools/extra_defs_gen/generate_extra_defs.h
==============================================================================
--- branches/glibmm-2-18/tools/extra_defs_gen/generate_extra_defs.h (original)
+++ branches/glibmm-2-18/tools/extra_defs_gen/generate_extra_defs.h Tue Dec 16 18:05:04 2008
@@ -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]