[perl-Glib-Object-Introspection] Slightly rearrange the callback data handling
- From: Torsten SchÃnfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib-Object-Introspection] Slightly rearrange the callback data handling
- Date: Fri, 7 Oct 2011 21:54:11 +0000 (UTC)
commit f169b9d5e0eba28918cb84bd9d0768ec3b8f514b
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date: Fri Oct 7 23:47:15 2011 +0200
Slightly rearrange the callback data handling
Specifically, separate it from the general 'void' handling so that we can also
try other things for 'void' args later if necessary.
GObjectIntrospection.xs | 4 ++--
gperl-i11n-marshal-arg.c | 4 +++-
gperl-i11n-marshal-callback.c | 24 ++++++++++--------------
gperl-i11n-marshal-interface.c | 4 ++--
4 files changed, 17 insertions(+), 19 deletions(-)
---
diff --git a/GObjectIntrospection.xs b/GObjectIntrospection.xs
index 0caa674..8453d52 100644
--- a/GObjectIntrospection.xs
+++ b/GObjectIntrospection.xs
@@ -153,8 +153,8 @@ static SV * arg_to_sv (GIArgument * arg,
GITransfer transfer,
GPerlI11nInvocationInfo *iinfo);
-static gpointer handle_callback_arg (GIArgInfo * arg_info, GITypeInfo * type_info, SV * sv, GPerlI11nInvocationInfo * invocation_info);
-static gpointer handle_void_arg (SV * sv, GPerlI11nInvocationInfo * invocation_info);
+static gpointer sv_to_callback (GIArgInfo * arg_info, GITypeInfo * type_info, SV * sv, GPerlI11nInvocationInfo * invocation_info);
+static gpointer sv_to_callback_data (SV * sv, GPerlI11nInvocationInfo * invocation_info);
static SV * struct_to_sv (GIBaseInfo* info, GIInfoType info_type, gpointer pointer, gboolean own);
static gpointer sv_to_struct (GITransfer transfer, GIBaseInfo * info, GIInfoType info_type, SV * sv);
diff --git a/gperl-i11n-marshal-arg.c b/gperl-i11n-marshal-arg.c
index 7bdd272..7d0e6ca 100644
--- a/gperl-i11n-marshal-arg.c
+++ b/gperl-i11n-marshal-arg.c
@@ -23,7 +23,9 @@ sv_to_arg (SV * sv,
switch (tag) {
case GI_TYPE_TAG_VOID:
- arg->v_pointer = handle_void_arg (sv, invocation_info);
+ arg->v_pointer = sv_to_callback_data (sv, invocation_info);
+ if (!arg->v_pointer)
+ ccroak ("encountered void pointer that is not callback user data");
break;
case GI_TYPE_TAG_BOOLEAN:
diff --git a/gperl-i11n-marshal-callback.c b/gperl-i11n-marshal-callback.c
index 4759a9c..587db6e 100644
--- a/gperl-i11n-marshal-callback.c
+++ b/gperl-i11n-marshal-callback.c
@@ -1,8 +1,8 @@
static gpointer
-handle_callback_arg (GIArgInfo * arg_info,
- GITypeInfo * type_info,
- SV * sv,
- GPerlI11nInvocationInfo * invocation_info)
+sv_to_callback (GIArgInfo * arg_info,
+ GITypeInfo * type_info,
+ SV * sv,
+ GPerlI11nInvocationInfo * invocation_info)
{
GPerlI11nCallbackInfo *callback_info;
@@ -59,24 +59,20 @@ handle_callback_arg (GIArgInfo * arg_info,
}
static gpointer
-handle_void_arg (SV * sv,
- GPerlI11nInvocationInfo * invocation_info)
+sv_to_callback_data (SV * sv,
+ GPerlI11nInvocationInfo * invocation_info)
{
- gpointer pointer = NULL;
- gboolean is_user_data = FALSE;
GSList *l;
+ if (!invocation_info)
+ return NULL;
for (l = invocation_info->callback_infos; l != NULL; l = l->next) {
GPerlI11nCallbackInfo *callback_info = l->data;
if (callback_info->data_pos == invocation_info->current_pos) {
- is_user_data = TRUE;
dwarn (" user data for callback %p\n",
callback_info);
attach_callback_data (callback_info, sv);
- pointer = callback_info;
- break; /* out of the for loop */
+ return callback_info;
}
}
- if (!is_user_data)
- ccroak ("encountered void pointer that is not callback user data");
- return pointer;
+ return NULL;
}
diff --git a/gperl-i11n-marshal-interface.c b/gperl-i11n-marshal-interface.c
index db76fea..773e0ee 100644
--- a/gperl-i11n-marshal-interface.c
+++ b/gperl-i11n-marshal-interface.c
@@ -123,8 +123,8 @@ sv_to_interface (GIArgInfo * arg_info,
}
case GI_INFO_TYPE_CALLBACK:
- arg->v_pointer = handle_callback_arg (arg_info, type_info, sv,
- invocation_info);
+ arg->v_pointer = sv_to_callback (arg_info, type_info, sv,
+ invocation_info);
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]