perl-Glib r1061 - in trunk: . t
- From: tsch svn gnome org
- To: svn-commits-list gnome org
- Subject: perl-Glib r1061 - in trunk: . t
- Date: Sun, 18 Jan 2009 15:20:50 +0000 (UTC)
Author: tsch
Date: Sun Jan 18 15:20:50 2009
New Revision: 1061
URL: http://svn.gnome.org/viewvc/perl-Glib?rev=1061&view=rev
Log:
Add Glib::ParamSpec->value_cmp. Patch by Kevin Ryde.
Modified:
trunk/ChangeLog
trunk/GParamSpec.xs
trunk/t/e.t
Modified: trunk/GParamSpec.xs
==============================================================================
--- trunk/GParamSpec.xs (original)
+++ trunk/GParamSpec.xs Sun Jan 18 15:20:50 2009
@@ -659,6 +659,29 @@
g_value_unset (&v);
XSRETURN(retcount);
+=for
+Compares I<value1> with I<value2> according to I<pspec>, and returns -1, 0 or
++1, if value1 is found to be less than, equal to or greater than value2,
+respectively.
+=cut
+int
+g_param_values_cmp (GParamSpec * pspec, SV *value1, SV *value2)
+ PREINIT:
+ GValue v1 = { 0, };
+ GValue v2 = { 0, };
+ GType type;
+ CODE:
+ type = G_PARAM_SPEC_VALUE_TYPE (pspec);
+ g_value_init (&v1, type);
+ g_value_init (&v2, type);
+ gperl_value_from_sv (&v1, value1);
+ gperl_value_from_sv (&v2, value2);
+ RETVAL = g_param_values_cmp (pspec, &v1, &v2);
+ g_value_unset (&v1);
+ g_value_unset (&v2);
+ OUTPUT:
+ RETVAL
+
MODULE = Glib::ParamSpec PACKAGE = Glib::Param::Char
Modified: trunk/t/e.t
==============================================================================
--- trunk/t/e.t (original)
+++ trunk/t/e.t Sun Jan 18 15:20:50 2009
@@ -5,7 +5,7 @@
use strict;
use utf8;
use Glib ':constants';
-use Test::More tests => 240;
+use Test::More tests => 243;
# first register some types with which to play below.
@@ -217,7 +217,10 @@
my $x = $object->get ('param_spec');
is ($x, undef);
-# value_validate()
+
+
+#
+# value_validate() and value_cmp()
#
{ my $p = Glib::ParamSpec->int ('name','nick','blurb',
20, 50, 25, G_PARAM_READWRITE);
@@ -233,4 +236,8 @@
($modif, $newval) = $p->value_validate(-70);
ok ($modif, 'modify -70 to be in range');
is ($newval, 20, 'clamp -70 down to be in range');
+
+ is ($p->values_cmp(22, 33), -1);
+ is ($p->values_cmp(33, 22), 1);
+ is ($p->values_cmp(22, 22), 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]