[gobject-introspection/ebassi/rebased-girffi-exec-fix: 3/8] girffi.h: add g_callable_info_get_closure_native_address() API
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/ebassi/rebased-girffi-exec-fix: 3/8] girffi.h: add g_callable_info_get_closure_native_address() API
- Date: Tue, 23 Nov 2021 23:06:13 +0000 (UTC)
commit 2a4dede7c2fdc3e6a6a5b063449ab3a8c58c11c0
Author: Sergei Trofimovich <slyfox gentoo org>
Date: Sat Jul 17 18:19:17 2021 +0100
girffi.h: add g_callable_info_get_closure_native_address() API
Commit 6bab939bf ("girffi.c: fix return value for g_callable_info_prepare_closure()")
effectively changes semantics of return value from code pointer to data pinter (closure).
`gjs` (and probably other software) relies on old (incorrect) semantics of
g_callable_info_prepare_closure(): https://gitlab.gnome.org/GNOME/gjs/-/issues/428
This change exposes the API that allows extracting directly
callacble code pointer. `gjs` will have to adapt to the new API.
Signed-off-by: Sergei Trofimovich <slyfox gentoo org>
girepository/girffi.c | 17 +++++++++++++++++
girepository/girffi.h | 5 +++++
2 files changed, 22 insertions(+)
---
diff --git a/girepository/girffi.c b/girepository/girffi.c
index b3b92195..12770203 100644
--- a/girepository/girffi.c
+++ b/girepository/girffi.c
@@ -349,6 +349,7 @@ g_function_invoker_destroy (GIFunctionInvoker *invoker)
typedef struct {
ffi_closure ffi_closure;
gpointer writable_self;
+ gpointer native_address;
} GIClosureWrapper;
/**
@@ -386,6 +387,7 @@ g_callable_info_prepare_closure (GICallableInfo *callable_info,
return NULL;
}
closure->writable_self = closure;
+ closure->native_address = exec_ptr;
atypes = g_callable_info_get_ffi_arg_types (callable_info, &n_args);
status = ffi_prep_cif (cif, FFI_DEFAULT_ABI, n_args,
@@ -409,6 +411,21 @@ g_callable_info_prepare_closure (GICallableInfo *callable_info,
return &closure->ffi_closure;
}
+/**
+ * g_callable_info_get_closure_native_address:
+ * @callable_info: a callable info from a typelib
+ * @closure: ffi closure
+ *
+ * Gets callable code from ffi_closure prepared by g_callable_info_prepare_closure()
+ */
+gpointer *
+g_callable_info_get_closure_native_address (GICallableInfo *callable_info,
+ ffi_closure *closure)
+{
+ GIClosureWrapper *wrapper = (GIClosureWrapper *)closure;
+ return wrapper->native_address;
+}
+
/**
* g_callable_info_free_closure:
* @callable_info: a callable info from a typelib
diff --git a/girepository/girffi.h b/girepository/girffi.h
index d8a57369..c6cb5e91 100644
--- a/girepository/girffi.h
+++ b/girepository/girffi.h
@@ -95,6 +95,11 @@ ffi_closure * g_callable_info_prepare_closure (GICallableInfo *callabl
ffi_cif *cif,
GIFFIClosureCallback callback,
gpointer user_data);
+
+GI_AVAILABLE_IN_1_70
+gpointer * g_callable_info_get_closure_native_address (GICallableInfo *callable_info,
+ ffi_closure *closure);
+
GI_AVAILABLE_IN_ALL
void g_callable_info_free_closure (GICallableInfo *callable_info,
ffi_closure *closure);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]