diff options
author | Sergei Trofimovich <slyfox@gentoo.org> | 2021-07-17 18:19:17 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2021-11-23 23:04:26 +0000 |
commit | 2a4dede7c2fdc3e6a6a5b063449ab3a8c58c11c0 (patch) | |
tree | 463ade7892e43e3fd2ca988cdecbc82ef4ae2cd7 | |
parent | 62c3c955547599a58786f20497748569c148379e (diff) | |
download | gobject-introspection-2a4dede7c2fdc3e6a6a5b063449ab3a8c58c11c0.tar.gz |
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>
-rw-r--r-- | girepository/girffi.c | 17 | ||||
-rw-r--r-- | girepository/girffi.h | 5 |
2 files changed, 22 insertions, 0 deletions
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, @@ -410,6 +412,21 @@ g_callable_info_prepare_closure (GICallableInfo *callable_info, } /** + * 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 * @closure: ffi closure 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); |