...
 
Commits (3)
......@@ -289,7 +289,7 @@ g_key_file_get_groups (key_file)
PPCODE:
groups = g_key_file_get_groups (key_file, &len);
if (len != 0) {
EXTEND(SP, len);
EXTEND(SP, (long) len);
for (i = 0; i < len; i++)
PUSHs (sv_2mortal (newSVGChar (groups[i])));
}
......@@ -637,7 +637,7 @@ g_key_file_get_string_list (key_file, group_name, key)
&retlen,
&err);
CROAK_ON_GERROR (err);
EXTEND (sp, retlen);
EXTEND (sp, (long) retlen);
for (i = 0; i < retlen; i++)
PUSHs (sv_2mortal (newSVGChar (retlist[i])));
g_strfreev (retlist);
......@@ -651,7 +651,7 @@ g_key_file_get_string_list (key_file, group_name, key)
&retlen,
&err);
CROAK_ON_GERROR (err);
EXTEND (sp, retlen);
EXTEND (sp, (long) retlen);
for (i = 0; i < retlen; i++)
PUSHs (sv_2mortal (boolSV (retlist[i])));
g_free (retlist);
......@@ -665,7 +665,7 @@ g_key_file_get_string_list (key_file, group_name, key)
&retlen,
&err);
CROAK_ON_GERROR (err);
EXTEND (sp, retlen);
EXTEND (sp, (long) retlen);
for (i = 0; i < retlen; i++)
PUSHs (sv_2mortal (newSViv (retlist[i])));
g_free (retlist);
......@@ -694,7 +694,7 @@ g_key_file_get_double_list (key_file, group_name, key)
&err);
if (err)
gperl_croak_gerror (NULL, err);
EXTEND (sp, retlen);
EXTEND (sp, (long) retlen);
for (i = 0; i < retlen; i++)
PUSHs (sv_2mortal (newSVnv (retlist[i])));
g_free (retlist);
......
......@@ -1608,7 +1608,7 @@ g_object_find_property (object_or_class_name, ...)
warn ("list_properties: %d properties\n", n_props);
#endif
if (n_props) {
EXTEND (SP, n_props);
EXTEND (SP, (int) n_props);
for (i = 0; i < n_props; i++)
PUSHs (sv_2mortal (newSVGParamSpec (props[i])));
......@@ -1642,7 +1642,7 @@ g_object_find_property (object_or_class_name, ...)
warn ("list_properties: %d properties\n", n_props);
#endif
if (n_props) {
EXTEND (SP, n_props);
EXTEND (SP, (int) n_props);
for (i = 0; i < n_props; i++)
PUSHs (sv_2mortal (newSVGParamSpec (props[i])));
......
......@@ -2654,7 +2654,7 @@ list_signals (class, package)
sigids = g_signal_list_ids (package_type, &num);
if (!num)
XSRETURN_EMPTY;
EXTEND(SP, num);
EXTEND(SP, (int) num);
for (i = 0; i < num; i++) {
g_signal_query (sigids[i], &siginfo);
PUSHs (sv_2mortal (newSVGSignalQuery (&siginfo)));
......
......@@ -149,6 +149,34 @@ SvGVariantType (SV * sv)
return gperl_get_boxed_check (sv, G_TYPE_VARIANT_TYPE);
}
/* --- GVariantDict ----------------------------------------------------------*/
#if GLIB_CHECK_VERSION (2, 40, 0)
/* --- typemap glue --- */
SV *
newSVGVariantDict (GVariantDict * dict)
{
return gperl_new_boxed (dict, G_TYPE_VARIANT_DICT, FALSE);
}
SV *
newSVGVariantDict_own (GVariantDict * dict)
{
return gperl_new_boxed (dict, G_TYPE_VARIANT_DICT, TRUE);
}
GVariantDict *
SvGVariantDict (SV * sv)
{
if (!gperl_sv_is_defined (sv))
return NULL;
return gperl_get_boxed_check (sv, G_TYPE_VARIANT_DICT);
}
#endif
/* -------------------------------------------------------------------------- */
/* --- helpers ---*/
......@@ -265,6 +293,9 @@ For a complete specification, see the documentation at
=for see_also Glib::VariantType
=cut
=for see_also Glib::VariantDict
=cut
BOOT:
gperl_register_fundamental_full (G_TYPE_VARIANT, "Glib::Variant",
&variant_wrapper_class);
......@@ -273,6 +304,9 @@ BOOT:
variant_type_wrapper_class.unwrap = unwrap_variant_type;
gperl_register_boxed (G_TYPE_VARIANT_TYPE, "Glib::VariantType",
&variant_type_wrapper_class);
#if GLIB_CHECK_VERSION (2, 40, 0)
gperl_register_boxed (G_TYPE_VARIANT_DICT, "Glib::VariantDict", NULL);
#endif
const GVariantType * g_variant_get_type (GVariant *value);
......@@ -521,23 +555,6 @@ DESTROY (GVariant * variant)
# --------------------------------------------------------------------------- #
# GLIB_AVAILABLE_IN_2_40 {
# GVariantDict * g_variant_dict_new (GVariant *from_asv);
# void g_variant_dict_init (GVariantDict *dict, GVariant *from_asv);
# gboolean g_variant_dict_lookup (GVariantDict *dict, const gchar *key, const gchar *format_string, ...);
# GVariant * g_variant_dict_lookup_value (GVariantDict *dict, const gchar *key, const GVariantType *expected_type);
# gboolean g_variant_dict_contains (GVariantDict *dict, const gchar *key);
# void g_variant_dict_insert (GVariantDict *dict, const gchar *key, const gchar *format_string, ...);
# void g_variant_dict_insert_value (GVariantDict *dict, const gchar *key, GVariant *value);
# gboolean g_variant_dict_remove (GVariantDict *dict, const gchar *key);
# void g_variant_dict_clear (GVariantDict *dict);
# GVariant * g_variant_dict_end (GVariantDict *dict);
# GVariantDict * g_variant_dict_ref (GVariantDict *dict);
# void g_variant_dict_unref (GVariantDict *dict);
# }
# --------------------------------------------------------------------------- #
# GVariantBuilder * g_variant_builder_new (const GVariantType *type);
# void g_variant_builder_unref (GVariantBuilder *builder);
# GVariantBuilder * g_variant_builder_ref (GVariantBuilder *builder);
......@@ -684,3 +701,27 @@ GVariantType_own * g_variant_type_new_tuple (class, SV *items);
GVariantType_own * g_variant_type_new_dict_entry (class, const GVariantType *key, const GVariantType *value);
C_ARGS:
key, value
# --------------------------------------------------------------------------- #
#if GLIB_CHECK_VERSION (2, 40, 0)
MODULE = Glib::Variant PACKAGE = Glib::VariantDict PREFIX = g_variant_dict_
GVariantDict_own * g_variant_dict_new (class, GVariant *from_asv);
C_ARGS:
from_asv
# gboolean g_variant_dict_lookup (GVariantDict *dict, const gchar *key, const gchar *format_string, ...);
GVariant_noinc * g_variant_dict_lookup_value (GVariantDict *dict, const gchar *key, const GVariantType *expected_type);
gboolean g_variant_dict_contains (GVariantDict *dict, const gchar *key);
# void g_variant_dict_insert (GVariantDict *dict, const gchar *key, const gchar *format_string, ...);
void g_variant_dict_insert_value (GVariantDict *dict, const gchar *key, GVariant *value);
gboolean g_variant_dict_remove (GVariantDict *dict, const gchar *key);
GVariant_noinc * g_variant_dict_end (GVariantDict *dict);
#endif
......@@ -119,4 +119,10 @@ if (ExtUtils::PkgConfig->atleast_version ('glib-2.0', '2.24.0')) {
newSVGVariantType
newSVGVariantType_own);
}
if (ExtUtils::PkgConfig->atleast_version ('glib-2.0', '2.40.0')) {
push @exports, qw(
SvGVariantDict
newSVGVariantDict
newSVGVariantDict_own);
}
1;
......@@ -378,6 +378,15 @@ const GVariantType * SvGVariantType (SV * sv);
#endif /* 2.24.0 */
#if GLIB_CHECK_VERSION (2, 40, 0)
typedef GVariantDict GVariantDict_own;
SV * newSVGVariantDict (GVariantDict * dict);
SV * newSVGVariantDict_own (GVariantDict * dict);
GVariantDict * SvGVariantDict (SV * sv);
#endif /* 2.40.0 */
/*
* --- GBytes -----------------------------------------------------------------
*/
......
......@@ -14,7 +14,7 @@ use constant {
};
if (Glib->CHECK_VERSION (2, 24, 0)) {
plan tests => 211;
plan tests => 223;
} else {
plan skip_all => 'Need libglib >= 2.24';
}
......@@ -338,3 +338,33 @@ note ('convenience constructor and accessor');
is_deeply ($v2->get ('a{si}'), [['äöü', 23], ['Perl', 42], ['💑', 2342]]);
}
}
note ('variant dict');
SKIP: {
skip 'dict', 12
unless Glib->CHECK_VERSION (2, 40, 0);
my $v = Glib::Variant->new ('a{sv}', {
'äöü' => Glib::Variant->new_uint16 (23),
'Perl' => Glib::Variant->new_uint32 (42),
'💑' => Glib::Variant->new_uint64 (2342)});
my $d = Glib::VariantDict->new ($v);
ok ($d->contains ('äöü'));
ok ($d->contains ('Perl'));
ok ($d->contains ('💑'));
is ($d->lookup_value ('äöü', 'q')->get_uint16 (), $v->lookup_value ('äöü', 'q')->get_uint16 ());
is ($d->lookup_value ('Perl', 'u')->get_uint32 (), $v->lookup_value ('Perl', 'u')->get_uint32 ());
is ($d->lookup_value ('💑', 't')->get_uint64 (), $v->lookup_value ('💑', 't')->get_uint64 ());
$d->insert_value ('GNU', Glib::Variant->new_string ('RMS'));
ok ($d->contains ('GNU'));
ok ($d->remove ('GNU'));
ok (not $d->contains ('GNU'));
my $d_v = $d->end ();
is ($d_v->lookup_value ('äöü', 'q')->get_uint16 (), $v->lookup_value ('äöü', 'q')->get_uint16 ());
is ($d_v->lookup_value ('Perl', 'u')->get_uint32 (), $v->lookup_value ('Perl', 'u')->get_uint32 ());
is ($d_v->lookup_value ('💑', 't')->get_uint64 (), $v->lookup_value ('💑', 't')->get_uint64 ());
}
......@@ -108,6 +108,10 @@ GVariantType * T_GPERL_GENERIC_WRAPPER
const GVariantType * T_GPERL_GENERIC_WRAPPER
GVariantType_own * T_GPERL_GENERIC_WRAPPER
GVariantDict * T_GPERL_GENERIC_WRAPPER
const GVariantDict * T_GPERL_GENERIC_WRAPPER
GVariantDict_own * T_GPERL_GENERIC_WRAPPER
GBytes * T_GPERL_GENERIC_WRAPPER
GBytes_own * T_GPERL_GENERIC_WRAPPER
......