Re: GLib/perl and GArray, GType



muppet <scott asofyet org> writes:

GParamSpecGType

I'd thought vaguely to try that from perl too (though that's not
actually question the here is it?) and got as far as the couple of lines
below.  I forget how it bombed.  I ended up with a string property class
name instead, which is fine for within perl (and I even wasn't sure if
specifying a class for sub-objects was a terrific idea anyway ... you
can imagine a constructor func or something being more flexible ...).

# pspec which holds a gtype
# can hold in a string instead ....
#

--- GParamSpec.xs       18 Oct 2005 05:26:09 +1000      1.23
+++ GParamSpec.xs       26 Apr 2008 15:01:47 +1000      
@@ -260,6 +260,9 @@
 #if GLIB_CHECK_VERSION(2,4,0)
        gperl_register_param_spec (G_TYPE_PARAM_OVERRIDE, "Glib::Param::Override");
 #endif
+#if GLIB_CHECK_VERSION(2,10,0)
+       gperl_register_param_spec (G_TYPE_PARAM_GTYPE, "Glib::Param::Type");
+#endif
 
 =for enum Glib::ParamFlags
 =cut
@@ -565,6 +568,31 @@
 #### value arrays.
 ###  GParamSpec* g_param_spec_value_array (const gchar *name, const gchar *nick, const gchar *blurb, 
GParamSpec *element_spec, GParamFlags flags) 
 
+#if GLIB_CHECK_VERSION (2, 10, 0)
+
+## GParamSpec* g_param_spec_gtype (const gchar *name, const gchar *nick, const gchar *blurb, GType 
is_a_type, GParamFlags flags)
+GParamSpec*
+type (class, name, nick, blurb, is_a_type, flags)
+      const gchar *name
+      const gchar *nick
+      const gchar *blurb
+      const char *is_a_type
+      GParamFlags flags
+    PREINIT:
+       GType type;
+    CODE:
+       if (is_a_type) {    
+           type = gperl_type_from_package (is_a_type);
+           if (!type)
+               croak ("type %s is not registered with Glib-Perl", is_a_type);
+       } else {
+           type = G_TYPE_NONE;
+       }
+       RETVAL = g_param_spec_gtype (name, nick, blurb, type, flags);
+    OUTPUT:
+       RETVAL
+
+#endif
 
 
 ####
@@ -1052,3 +1080,6 @@
 ## G_TYPE_PARAM_POINTER, "Glib::Param::Pointer" -- no members
 ## G_TYPE_PARAM_OBJECT, "Glib::Param::Object" -- no members
 ## G_TYPE_PARAM_OVERRIDE, "Glib::Param::Override" -- no public members
+#if GLIB_CHECK_VERSION(2,10,0)
+## G_TYPE_PARAM_GTYPE, "Glib::Param::Type" -- no public members
+#endif


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