Re: gperl_type_get_property() default on unichar prop
- From: Torsten Schoenfeld <kaffeetisch gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: gperl_type_get_property() default on unichar prop
- Date: Sun, 09 Nov 2008 21:58:57 +0100
Kevin Ryde wrote:
The program below gets a warning
Argument "\x{78}" isn't numeric in subroutine entry at foo.pl line 19.
I think it's because in get_default_property_value() the call out to
Glib::Param::Unichar::get_default_value() gives back a single-char
string 'x' but gperl_value_from_sv() used on that return expects a
number.
Hmm, tricky. The problem seems to be that there is a mismatch between the type
of the param spec (G_TYPE_PARAM_UNICHAR) and the GType used to store and marshal
values of it (G_TYPE_UINT). When we have the Glib::Param::Unichar object, we
know it's a unichar. But when we are dealing with values for properties
described by this param spec, we don't have this knowledge and instead only know
that we deal with a uint.
I'd be sorely tempted to say Glib::Param::Unichar::get_default_value()
is the odd man out and ought to be returning a number the same as
$obj->get_property or $obj->set_property give and return for a unichar
prop. But would changing that break anyone's program?
I think Glib::Param::Unichar::get_default_value() doesn't look so odd anymore
when you consider that it simply uses the gunichar typemap. Every other xsub
that returns or takes a gunichar automatically uses the same one-character
string representation.
Changing Glib::Param::Unichar::get_default_value() to return a plain number
would break users that directly call it.
The other temptation would be to switch get_default_property_value() to
using g_param_value_set_default(), since that latter does the right
thing on unichar pspecs. But would anyone have their own subclassed
$pspec->get_default_value() which would be lost by using only
g_param_value_set_default() ?
I don't know. The current get_default_property_value() certainly allows custom
param specs to provide their own get_default_value() and have it called when
appropriate.
The only possible solution that comes to mind is to attack this at the only
place that sees both the GParamSpec and the GValue:
get_default_property_value(). Maybe it could, upon a seeing a param spec of
type G_TYPE_PARAM_UNICHAR, mangle the SV returned by
Glib::Param::Unichar::get_default_value() before passing it to
gperl_value_from_sv()?
-Torsten
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]