=?utf-8?q?=5Bperl-Glib-Object-Introspection=5D_SV_=E2=86=92_struct=3A_han?= =?utf-8?q?dle_raw_structs_from_unregistered_libraries?=
- From: Torsten SchÃnfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib-Object-Introspection] SV â struct: handle raw structs from unregistered libraries
- Date: Sun, 17 Feb 2013 12:52:08 +0000 (UTC)
commit c218895dea4d85feb60f60c0f52de605093aa097
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date: Sun Feb 17 13:51:03 2013 +0100
SV â struct: handle raw structs from unregistered libraries
GObjectIntrospection.xs | 6 ++++--
NEWS | 1 +
gperl-i11n-info.c | 3 ++-
gperl-i11n-marshal-interface.c | 2 +-
gperl-i11n-marshal-struct.c | 5 ++++-
5 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/GObjectIntrospection.xs b/GObjectIntrospection.xs
index c8d79fe..26341ee 100644
--- a/GObjectIntrospection.xs
+++ b/GObjectIntrospection.xs
@@ -612,7 +612,8 @@ _get_field (class, basename, namespace, field, invocant)
* {$package}::_i11n_gtype SV. It gets set for members of
* boxed unions. */
const gchar *package = get_package_for_basename (basename);
- invocant_type = find_union_member_gtype (package, namespace);
+ if (package)
+ invocant_type = find_union_member_gtype (package, namespace);
}
if (!g_type_is_a (invocant_type, G_TYPE_BOXED))
ccroak ("Unable to handle access to field '%s' for type '%s'",
@@ -654,7 +655,8 @@ _set_field (class, basename, namespace, field, invocant, new_value)
* {$package}::_i11n_gtype SV. It gets set for members of
* boxed unions. */
const gchar *package = get_package_for_basename (basename);
- invocant_type = find_union_member_gtype (package, namespace);
+ if (package)
+ invocant_type = find_union_member_gtype (package, namespace);
}
if (!g_type_is_a (invocant_type, G_TYPE_BOXED))
ccroak ("Unable to handle access to field '%s' for type '%s'",
diff --git a/NEWS b/NEWS
index d2ecbb9..b76dacc 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Overview of changes in Glib::Object::Introspection <next>
* Add support for array arguments to Perl callbacks.
* Allow Perl code to return Glib::Error objects.
* Register error domains.
+* Support conversion to raw structs from unregistered libraries.
Overview of changes in Glib::Object::Introspection 0.014
========================================================
diff --git a/gperl-i11n-info.c b/gperl-i11n-info.c
index 843afcc..2a4926a 100644
--- a/gperl-i11n-info.c
+++ b/gperl-i11n-info.c
@@ -199,7 +199,8 @@ get_package_for_basename (const gchar *basename)
get_hv ("Glib::Object::Introspection::_BASENAME_TO_PACKAGE", 0);
g_assert (basename_to_package);
svp = hv_fetch (basename_to_package, basename, strlen (basename), 0);
- g_assert (svp && gperl_sv_is_defined (*svp));
+ if (!svp || !gperl_sv_is_defined (*svp))
+ return NULL;
return SvPV_nolen (*svp);
}
diff --git a/gperl-i11n-marshal-interface.c b/gperl-i11n-marshal-interface.c
index 223bb14..c81fbe6 100644
--- a/gperl-i11n-marshal-interface.c
+++ b/gperl-i11n-marshal-interface.c
@@ -160,7 +160,7 @@ sv_to_interface (GIArgInfo * arg_info,
name = g_base_info_get_name (interface);
namespace = g_base_info_get_namespace (interface);
package = get_package_for_basename (namespace);
- parent_type = find_union_member_gtype (package, name);
+ parent_type = package ? find_union_member_gtype (package, name) : 0;
if (parent_type && parent_type != G_TYPE_NONE) {
arg->v_pointer = gperl_get_boxed_check (
sv, parent_type);
diff --git a/gperl-i11n-marshal-struct.c b/gperl-i11n-marshal-struct.c
index 1815bfc..5f14d0d 100644
--- a/gperl-i11n-marshal-struct.c
+++ b/gperl-i11n-marshal-struct.c
@@ -6,7 +6,8 @@ get_struct_package (GIBaseInfo* info)
const gchar *basename, *package, *name;
basename = g_base_info_get_namespace (info);
package = get_package_for_basename (basename);
- g_assert (package);
+ if (!package)
+ return NULL;
name = g_base_info_get_name (info);
return g_strconcat (package, "::", name, NULL);
}
@@ -41,6 +42,7 @@ struct_to_sv (GIBaseInfo* info,
dwarn (" disguised struct\n");
g_assert (!own);
package = get_struct_package (info);
+ g_assert (package);
sv = newSV (0);
sv_setref_pv (sv, package, pointer);
g_free (package);
@@ -112,6 +114,7 @@ sv_to_struct (GITransfer transfer,
gchar *package;
dwarn (" disguised struct\n");
package = get_struct_package (info);
+ g_assert (package);
if (!gperl_sv_is_ref (sv) || !sv_derived_from (sv, package))
ccroak ("Cannot convert scalar %p to an object of type %s",
sv, package);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]