gperl_type_get_property() default on unichar prop



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.

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?

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() ?

(Oh, and yes, this unichar num vs char came up with the possibility
before of switching all the $pspec->get_default_value funcs to using
g_param_value_set_default().  But that doesn't have to be addressed just
for this case of making the default handing in gperl_type_get_property()
work.)

package Foo;
use strict;
use warnings;
use Glib;
use Glib::Object::Subclass
  Glib::Object::,
  properties => [Glib::ParamSpec->unichar
                 ('uniprop',
                  'uniprop',
                  'Blurb.',
                  'x',  # default
                  Glib::G_PARAM_READWRITE)
                ];
use strict;
use warnings;
use Glib;

my $foo = Foo->new;
print $foo->get('uniprop'), "\n";
exit 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]