Commit 8326a03e authored by Torsten Schönfeld's avatar Torsten Schönfeld

Add Glib::Object::Introspection::GValueWrapper::get_value

To obtain the actual value of the wrapped GValue.  This is necessary
when a functions expects an already set-up GValue and then modifies it
to return a value.  Like Gtk3::Container::child_get_property.
parent ecb1ad30
......@@ -1039,6 +1039,16 @@ new (class, const gchar *type_package, SV *perl_value)
OUTPUT:
RETVAL
SV *
get_value (SV *sv)
PREINIT:
GValue *v;
CODE:
v = SvGValueWrapper (sv);
RETVAL = gperl_sv_from_value (v);
OUTPUT:
RETVAL
void
DESTROY (SV *sv)
PREINIT:
......
......@@ -673,12 +673,21 @@ wrapper for a function that expects a GValue, do this:
...
my $type = ...; # somehow get the package name that
# corresponds to the correct GType
my $real_value =
my $wrapper =
Glib::Object::Introspection::GValueWrapper->new ($type, $value);
# now use Glib::Object::Introspection->invoke and
# substitute $real_value where you'd use $value
# substitute $wrapper where you'd use $value
...
If you need to call a function that expects an already set-up GValue and
modifies it, use C<get_value> on the wrapper afterwards to obtain the value.
For example:
my $wrapper =
Glib::Object::Introspection::GValueWrapper->new ('Glib::Boolean', 0);
$box->child_get_property ($label, 'expand', $gvalue);
my $value = $gvalue->get_value
=head2 Handling extendable enumerations
If you need to handle extendable enumerations for which more than the
......
......@@ -5,10 +5,20 @@ BEGIN { require './t/inc/setup.pl' };
use strict;
use warnings;
plan tests => 2;
plan tests => 3;
SKIP: {
skip 'SV → GValue not implemented', 1;
is (Regress::test_int_value_arg (23), 23);
{
my $wrapper = Glib::Object::Introspection::GValueWrapper->new ('Glib::Int', 23);
is (Regress::test_int_value_arg ($wrapper), 23);
}
is (Regress::test_value_return (23), 23);
SKIP: {
skip 'more GValue tests', 1
unless check_gi_version (1, 38, 0);
my $wrapper = Glib::Object::Introspection::GValueWrapper->new ('Glib::Int', 42);
GI::gvalue_in_with_modification ($wrapper);
is ($wrapper->get_value, 24);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment