[perl-Glib] Fall back to Glib::ParamSpec->get_default_value() for all param types
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib] Fall back to Glib::ParamSpec->get_default_value() for all param types
- Date: Sun, 21 Nov 2010 20:38:09 +0000 (UTC)
commit 99644fc19c7adf7126d4bd5c89df3529a3b42d18
Author: Kevin Ryde <user42 zip com au>
Date: Sun Nov 21 21:35:55 2010 +0100
Fall back to Glib::ParamSpec->get_default_value() for all param types
Remove the specific get_default_value() accessors from all Glib::Param::*
classes and let the new general-purpose accessor do the work.
https://bugzilla.gnome.org/show_bug.cgi?id=548173
GParamSpec.xs | 192 +++-----------------------------------------------------
t/e.t | 8 ++-
2 files changed, 18 insertions(+), 182 deletions(-)
---
diff --git a/GParamSpec.xs b/GParamSpec.xs
index 1c8f536..ba7eb14 100644
--- a/GParamSpec.xs
+++ b/GParamSpec.xs
@@ -891,28 +891,6 @@ get_maximum (GParamSpec * pspec)
OUTPUT:
RETVAL
-
-=for apidoc Glib::Param::Char::get_default_value __hide__
-=cut
-
-=for apidoc Glib::Param::Long::get_default_value __hide__
-=cut
-
-IV
-get_default_value (GParamSpec * pspec)
- ALIAS:
- Glib::Param::Int::get_default_value = 1
- Glib::Param::Long::get_default_value = 2
- CODE:
- switch (ix) {
- case 0: RETVAL = G_PARAM_SPEC_CHAR (pspec)->default_value; break;
- case 1: RETVAL = G_PARAM_SPEC_INT (pspec)->default_value; break;
- case 2: RETVAL = G_PARAM_SPEC_LONG (pspec)->default_value; break;
- default: g_assert_not_reached (); RETVAL = 0;
- }
- OUTPUT:
- RETVAL
-
MODULE = Glib::ParamSpec PACKAGE = Glib::Param::UChar
## similarly, all unsigned integer types
@@ -988,28 +966,6 @@ get_maximum (GParamSpec * pspec)
OUTPUT:
RETVAL
-
-=for apidoc Glib::Param::UChar::get_default_value __hide__
-=cut
-
-=for apidoc Glib::Param::ULong::get_default_value __hide__
-=cut
-
-UV
-get_default_value (GParamSpec * pspec)
- ALIAS:
- Glib::Param::UInt::get_default_value = 1
- Glib::Param::ULong::get_default_value = 2
- CODE:
- switch (ix) {
- case 0: RETVAL = G_PARAM_SPEC_UCHAR (pspec)->default_value; break;
- case 1: RETVAL = G_PARAM_SPEC_UINT (pspec)->default_value; break;
- case 2: RETVAL = G_PARAM_SPEC_ULONG (pspec)->default_value; break;
- default: g_assert_not_reached (); RETVAL = 0;
- }
- OUTPUT:
- RETVAL
-
MODULE = Glib::ParamSpec PACKAGE = Glib::Param::Int64
=for object Glib::Param::Int64
@@ -1042,13 +998,6 @@ get_maximum (GParamSpec * pspec)
OUTPUT:
RETVAL
-gint64
-get_default_value (GParamSpec * pspec)
- CODE:
- RETVAL = G_PARAM_SPEC_INT64 (pspec)->default_value;
- OUTPUT:
- RETVAL
-
MODULE = Glib::ParamSpec PACKAGE = Glib::Param::UInt64
=for object Glib::Param::UInt64
@@ -1081,13 +1030,6 @@ get_maximum (GParamSpec * pspec)
OUTPUT:
RETVAL
-guint64
-get_default_value (GParamSpec * pspec)
- CODE:
- RETVAL = G_PARAM_SPEC_UINT64 (pspec)->default_value;
- OUTPUT:
- RETVAL
-
MODULE = Glib::ParamSpec PACKAGE = Glib::Param::Float
## and again for the floating-point types
@@ -1149,24 +1091,6 @@ get_maximum (GParamSpec * pspec)
OUTPUT:
RETVAL
-
-=for apidoc Glib::Param::Float::get_default_value __hide__
-=cut
-
-double
-get_default_value (GParamSpec * pspec)
- ALIAS:
- Glib::Param::Double::get_default_value = 1
- CODE:
- switch (ix) {
- case 0: RETVAL = G_PARAM_SPEC_FLOAT (pspec)->default_value; break;
- case 1: RETVAL = G_PARAM_SPEC_DOUBLE (pspec)->default_value; break;
- default: g_assert_not_reached (); RETVAL = 0.0;
- }
- OUTPUT:
- RETVAL
-
-
=for apidoc Glib::Param::Float::get_epsilon __hide__
=cut
@@ -1183,27 +1107,6 @@ get_epsilon (GParamSpec * pspec)
OUTPUT:
RETVAL
-MODULE = Glib::ParamSpec PACKAGE = Glib::Param::Boolean
-
-=for position post_hierarchy
-
-=head1 HIERARCHY
-
- Glib::ParamSpec
- +----Glib::Param::Boolean
-
-=cut
-
-=for see_also Glib::ParamSpec
-=cut
-
-gboolean
-get_default_value (GParamSpec * pspec_boolean)
- CODE:
- RETVAL = G_PARAM_SPEC_BOOLEAN (pspec_boolean)->default_value;
- OUTPUT:
- RETVAL
-
MODULE = Glib::ParamSpec PACKAGE = Glib::Param::Enum
=for position post_hierarchy
@@ -1227,17 +1130,6 @@ get_enum_class (GParamSpec * pspec_enum)
OUTPUT:
RETVAL
-SV *
-get_default_value (GParamSpec * pspec_enum)
- PREINIT:
- GParamSpecEnum * penum;
- CODE:
- penum = G_PARAM_SPEC_ENUM (pspec_enum);
- RETVAL = gperl_convert_back_enum (G_ENUM_CLASS_TYPE (penum->enum_class),
- penum->default_value);
- OUTPUT:
- RETVAL
-
MODULE = Glib::ParamSpec PACKAGE = Glib::Param::Flags
=for position post_hierarchy
@@ -1261,79 +1153,6 @@ get_flags_class (GParamSpec * pspec_flags)
OUTPUT:
RETVAL
-SV *
-get_default_value (GParamSpec * pspec_flags)
- PREINIT:
- GParamSpecFlags * pflags;
- CODE:
- pflags = G_PARAM_SPEC_FLAGS (pspec_flags);
- RETVAL = gperl_convert_back_flags
- (G_FLAGS_CLASS_TYPE (pflags->flags_class),
- pflags->default_value);
- OUTPUT:
- RETVAL
-
-MODULE = Glib::ParamSpec PACKAGE = Glib::Param::String
-
-=for position post_hierarchy
-
-=head1 HIERARCHY
-
- Glib::ParamSpec
- +----Glib::Param::String
-
-=cut
-
-=for see_also Glib::ParamSpec
-=cut
-
-gchar *
-get_default_value (GParamSpec * pspec_string)
- CODE:
- RETVAL = G_PARAM_SPEC_STRING (pspec_string)->default_value;
- OUTPUT:
- RETVAL
-
-## the others are fairly uninteresting.
-## string cset_first
-## string cset_nth
-## char substitutor
-## bool null_fold_if_empty
-## bool ensure_non_null
-
-MODULE = Glib::ParamSpec PACKAGE = Glib::Param::Unichar
-
-=for position post_hierarchy
-
-=head1 HIERARCHY
-
- Glib::ParamSpec
- +----Glib::Param::Unichar
-
-=cut
-
-=for see_also Glib::ParamSpec
-=cut
-
-gunichar
-get_default_value (GParamSpec * pspec_unichar)
- CODE:
- RETVAL = G_PARAM_SPEC_UNICHAR (pspec_unichar)->default_value;
- OUTPUT:
- RETVAL
-
-##MODULE = Glib::ParamSpec PACKAGE = Glib::Param::ValueArray
-
-##element_spec
-##fixed_n_elements
-
-## G_TYPE_PARAM_PARAM, "Glib::Param::Param" -- no members
-## G_TYPE_PARAM_BOXED, "Glib::Param::Boxed" -- no members
-## 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
-
-
MODULE = Glib::ParamSpec PACKAGE = Glib::Param::GType
#if GLIB_CHECK_VERSION(2, 10, 0)
@@ -1365,3 +1184,14 @@ get_is_a_type (GParamSpec * pspec_gtype)
RETVAL
#endif
+
+# These don't have their MODULE section since they have no or no interesting
+# members:
+## Glib::Param::Boolean
+## Glib::Param::String
+## Glib::Param::Unichar
+## Glib::Param::Param
+## Glib::Param::Boxed
+## Glib::Param::Pointer
+## Glib::Param::Object
+## Glib::Param::Override
diff --git a/t/e.t b/t/e.t
index 4892b91..9072a82 100644
--- a/t/e.t
+++ b/t/e.t
@@ -5,7 +5,7 @@
use strict;
use utf8;
use Glib ':constants';
-use Test::More tests => 305;
+use Test::More tests => 311;
# first register some types with which to play below.
@@ -149,6 +149,7 @@ $pspec = Glib::ParamSpec->boxed ('boxed', 'Boxed',
# we only know one boxed type at this point.
'Glib::Scalar', G_PARAM_READWRITE);
pspec_common_ok ($pspec, 'Boxed', G_PARAM_READWRITE, 'Glib::Scalar');
+is ($pspec->get_default_value, undef, 'Boxed default');
push @params, $pspec;
@@ -156,6 +157,7 @@ $pspec = Glib::ParamSpec->object ('object', 'Object',
'I object, Your Honor, that\'s pure conjecture!',
'Skeezle', G_PARAM_READWRITE);
pspec_common_ok ($pspec, 'Object', G_PARAM_READWRITE, 'Skeezle');
+is ($pspec->get_default_value, undef, 'Object default');
push @params, $pspec;
@@ -171,6 +173,7 @@ is ($pspec->get_blurb, '', 'Param blurb');
ok ($pspec->get_flags == G_PARAM_READWRITE, 'Param flags');
is ($pspec->get_value_type, 'Glib::Param::Enum', 'Param value type');
ok (! $pspec->get_owner_type, 'Param owner type');
+is ($pspec->get_default_value, undef, 'Param default');
push @params, $pspec;
@@ -204,6 +207,7 @@ $pspec = Glib::ParamSpec->IV ('iv', 'IV',
'This is the same as Int',
-20, 10, -5, G_PARAM_READWRITE);
isa_ok ($pspec, 'Glib::Param::Long', 'IV is actually Long');
+is ($pspec->get_default_value, -5, 'IV default');
push @params, $pspec;
@@ -211,6 +215,7 @@ $pspec = Glib::ParamSpec->UV ('uv', 'UV',
'This is the same as UInt',
10, 20, 15, G_PARAM_READWRITE);
isa_ok ($pspec, 'Glib::Param::ULong', 'UV is actually ULong');
+is ($pspec->get_default_value, 15, 'UV default');
push @params, $pspec;
@@ -219,6 +224,7 @@ $pspec = Glib::ParamSpec->scalar ('scalar', 'Scalar',
G_PARAM_READWRITE);
isa_ok ($pspec, 'Glib::Param::Boxed', 'Scalar is actually Boxed');
is ($pspec->get_value_type, 'Glib::Scalar', 'boxed holding scalar');
+is ($pspec->get_default_value, undef, 'Scalar default');
push @params, $pspec;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]