~ubuntu-branches/ubuntu/quantal/libglib-perl/quantal

« back to all changes in this revision

Viewing changes to GParamSpec.xs

  • Committer: Bazaar Package Importer
  • Author(s): Jeffrey Ratcliffe
  • Date: 2010-07-28 07:36:48 UTC
  • mfrom: (0.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100728073648-aiohmszaldj3bio4
Tags: 2:1.223-1
* New upstream release
* Bumped epoch to replace previous (unstable) release with this stable one.
* Standards-Version 3.9.1 (no changes)
* Add myself to Uploaders
* Update patched file paths, refresh all patches
* Updated watchfile to only report stable releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2003-2004, 2010 by the gtk2-perl team (see the file AUTHORS for
 
2
 * Copyright (C) 2003-2004 by the gtk2-perl team (see the file AUTHORS for
3
3
 * the full list)
4
4
 *
5
5
 * This library is free software; you can redistribute it and/or modify it
142
142
newSVGParamSpec (GParamSpec * pspec)
143
143
{
144
144
        const gchar * pv;
145
 
        HV * property;
 
145
        HV * property = newHV ();
146
146
        SV * sv;
147
147
        HV * stash;
148
148
        const char * package;
153
153
        g_param_spec_ref (pspec);
154
154
        g_param_spec_sink (pspec);
155
155
 
156
 
        property = newHV ();
157
156
        sv_magic ((SV*)property, 0, PERL_MAGIC_ext, (const char*)pspec, 0);
158
157
 
159
158
 
162
161
         * paramspec list returned from Glib::Object::list_properties())
163
162
         * we store a few select keys in the hash directly.
164
163
         */
165
 
        gperl_hv_take_sv_s (property, "name",
166
 
                            newSVpv (g_param_spec_get_name (pspec), 0));
 
164
        hv_store (property, "name",  4,
 
165
                  newSVpv (g_param_spec_get_name (pspec), 0), 0);
167
166
 
168
167
        /* map type names to package names, if possible */
169
168
        pv = gperl_package_from_type (pspec->value_type);
170
169
        if (!pv) pv = g_type_name (pspec->value_type);
171
 
        gperl_hv_take_sv_s (property, "type", newSVpv (pv, 0));
 
170
        hv_store (property, "type",  4, newSVpv (pv, 0), 0);
172
171
 
173
172
        pv = gperl_package_from_type (pspec->owner_type);
174
173
        if (!pv)
175
174
                pv = g_type_name (pspec->owner_type);
176
175
        if (pv)
177
 
                gperl_hv_take_sv_s (property, "owner_type", newSVpv (pv, 0));
 
176
                hv_store (property, "owner_type", 10, newSVpv (pv, 0), 0);
178
177
 
179
178
        pv = g_param_spec_get_blurb (pspec);
180
 
        if (pv) gperl_hv_take_sv_s (property, "descr", newSVpv (pv, 0));
181
 
        gperl_hv_take_sv_s (property, "flags", newSVGParamFlags (pspec->flags));
 
179
        if (pv) hv_store (property, "descr", 5, newSVpv (pv, 0), 0);
 
180
        hv_store (property, "flags", 5, newSVGParamFlags (pspec->flags), 0) ;
182
181
 
183
182
        /* wrap it, bless it, ship it. */
184
183
        sv = newRV_noinc ((SV*)property);
266
265
#if GLIB_CHECK_VERSION(2,4,0)
267
266
        gperl_register_param_spec (G_TYPE_PARAM_OVERRIDE, "Glib::Param::Override");
268
267
#endif
269
 
#if GLIB_CHECK_VERSION(2,10,0)
270
 
        gperl_register_param_spec (G_TYPE_PARAM_GTYPE, "Glib::Param::GType");
271
 
#endif
272
268
 
273
269
=for enum Glib::ParamFlags
274
270
=cut
491
487
        RETVAL
492
488
 
493
489
##  GParamSpec* g_param_spec_string (const gchar *name, const gchar *nick, const gchar *blurb, const gchar *default_value, GParamFlags flags) 
494
 
##
495
 
## "default_value" can be NULL.  Not actually described in the docs as
496
 
## of 2.18, but used that way in lots of the builtin classes
497
 
##
498
490
GParamSpec*
499
491
g_param_spec_string (class, name, nick, blurb, default_value, flags)
500
492
        const gchar *name
501
493
        const gchar *nick
502
494
        const gchar *blurb
503
 
        const gchar_ornull *default_value
 
495
        const gchar *default_value
504
496
        GParamFlags flags
505
497
    C_ARGS:
506
498
        name, nick, blurb, default_value, flags
579
571
###  GParamSpec* g_param_spec_value_array (const gchar *name, const gchar *nick, const gchar *blurb, GParamSpec *element_spec, GParamFlags flags) 
580
572
 
581
573
 
582
 
#if GLIB_CHECK_VERSION(2, 10, 0)
583
 
 
584
 
=for apidoc
585
 
=for arg is_a_type  The name of a class whose subtypes are allowed as values of the property.  Use C<undef> to allow any type.
586
 
=cut
587
 
GParamSpec*
588
 
g_param_spec_gtype (class, name, nick, blurb, is_a_type, flags)
589
 
        const gchar *name
590
 
        const gchar *nick
591
 
        const gchar *blurb
592
 
        const gchar_ornull *is_a_type
593
 
        GParamFlags flags
594
 
    C_ARGS:
595
 
        name, nick, blurb, is_a_type ? gperl_type_from_package (is_a_type) : G_TYPE_NONE, flags
596
 
 
597
 
#endif
598
 
 
599
574
 
600
575
####
601
576
#### accessors
1240
1215
## G_TYPE_PARAM_POINTER, "Glib::Param::Pointer" -- no members
1241
1216
## G_TYPE_PARAM_OBJECT, "Glib::Param::Object" -- no members
1242
1217
## G_TYPE_PARAM_OVERRIDE, "Glib::Param::Override" -- no public members
1243
 
 
1244
 
 
1245
 
MODULE = Glib::ParamSpec        PACKAGE = Glib::Param::GType
1246
 
 
1247
 
=for object Glib::Param::GType Wrapper for GType parameters in GLib
1248
 
=cut
1249
 
 
1250
 
#if GLIB_CHECK_VERSION(2, 10, 0)
1251
 
 
1252
 
=for section DESCRIPTION
1253
 
 
1254
 
=head1 DESCRIPTION
1255
 
 
1256
 
This object describes a parameter which holds the name of a class known to the
1257
 
GLib type system.  The name of the class is considered to be the common
1258
 
ancestor for valid values.  To create a param that allows any type name,
1259
 
specify C<undef> for the package name.  Beware, however, that although
1260
 
we say "any type name", this actually refers to any type registered
1261
 
with Glib; normal Perl packages will not work.
1262
 
 
1263
 
=cut
1264
 
 
1265
 
=for apidoc
1266
 
If C<undef>, then any class is allowed.
1267
 
=cut
1268
 
const gchar_ornull *
1269
 
get_is_a_type (GParamSpec * pspec_gtype)
1270
 
    CODE:
1271
 
        GParamSpecGType * p = G_PARAM_SPEC_GTYPE (pspec_gtype);
1272
 
        RETVAL = p->is_a_type == G_TYPE_NONE
1273
 
                ? NULL
1274
 
                : gperl_package_from_type (p->is_a_type);
1275
 
    OUTPUT:
1276
 
        RETVAL
1277
 
 
1278
 
#endif