Here is the relevant part of e.t:t/e.t ...................... 1/243 # Failed test at t/e.t line 229. # got: '1' # expected: '2' # Failed test 'value 30 value unchanged' # at t/e.t line 231. # got: undef # expected: '30'
And here is a link to the full source of e.t# # value_validate() and value_cmp() # { my $p = Glib::ParamSpec->int ('name','nick','blurb', 20, 50, 25, G_PARAM_READWRITE); ok (! scalar ($p->value_validate('30')), "value 30 valid"); my @a = $p->value_validate('30'); is (@a, 2); ok (! $a[0], "value 30 bool no modify (array context)"); is ($a[1], 30, "value 30 value unchanged");
And I cant find a `Glib::ParamSpec` class anywhere. I'm guess that in someway this line in GParamSpec.xs:my $p = Glib::ParamSpec->int ('name','nick','blurb', 20, 50, 25, G_PARAM_READWRITE);
makes the ->int() available as a constructor but I'm not sure.gperl_register_param_spec (G_TYPE_PARAM_INT, "Glib::Param::Int");
MODULE = Glib::ParamSpec PACKAGE = Glib::ParamSpec PREFIX = g_pa +ram_ =for apidoc =signature bool = $paramspec->value_validate ($value) =signature (bool, newval) = $paramspec->value_validate ($value) In scalar context return true if $value must be modified to be valid for $paramspec, or false if it's valid already. In array context return also a new value which is $value made valid. $value must be the right type for $paramspec (with usual stringizing, numizing, etc). C<value_validate> checks the further restrictions such as minimum and maximum for a numeric type or allowed characters in a string. The "made valid" return is then for instance clamped to the min/max, or offending chars replaced by a substitutor. =cut void g_param_value_validate (GParamSpec * pspec, SV *value) PREINIT: GValue v = { 0, }; GType type; int modify, retcount=1; CODE: type = G_PARAM_SPEC_VALUE_TYPE (pspec); g_value_init (&v, type); gperl_value_from_sv (&v, value); modify = g_param_value_validate (pspec, &v); ST(0) = sv_2mortal (boolSV (modify)); if (GIMME_V == G_ARRAY) { /* If unmodified then can leave ST(1) "value" alone. If modified then expect that g_param_value_validate() will have made a new block of memory owned by the GValue and whi +ch will be freed at the g_value_unset(). For that reason ask _gperl_sv_from_value_internal() to "copy_boxed" to grab before it's freed. If g_param_value_validate() says modified but doesn't in fact modify but just leaves the GValue pointing into the input ST(1) "value" then we might prefer not to copy (but instead leave ST(1) as the return). Believe that shouldn't happen, ie. a value_validate vfunc shouldn't modify the input but rather if modifying something then it will put in new memory. Or alternately if it doesn't modify anything then it shouldn't say modified. (The Glib ref manual circa 2.27 doesn't have much guidance on this.) */ retcount = 2; if (modify) ST(1) = sv_2mortal (_gperl_sv_from_value_internal(&v,TRUE)); } g_value_unset (&v); XSRETURN(retcount);
In reply to XS Mentor Requested - debugging the Glib test suite by metaperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |