mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 13:23:07 +02:00
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>
This commit is contained in:
parent
6a8dce273a
commit
5e053279b5
17
girffi.c
17
girffi.c
@ -349,6 +349,7 @@ g_function_invoker_destroy (GIFunctionInvoker *invoker)
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
ffi_closure ffi_closure;
|
ffi_closure ffi_closure;
|
||||||
gpointer writable_self;
|
gpointer writable_self;
|
||||||
|
gpointer native_address;
|
||||||
} GIClosureWrapper;
|
} GIClosureWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -386,6 +387,7 @@ g_callable_info_prepare_closure (GICallableInfo *callable_info,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
closure->writable_self = closure;
|
closure->writable_self = closure;
|
||||||
|
closure->native_address = exec_ptr;
|
||||||
|
|
||||||
atypes = g_callable_info_get_ffi_arg_types (callable_info, &n_args);
|
atypes = g_callable_info_get_ffi_arg_types (callable_info, &n_args);
|
||||||
status = ffi_prep_cif (cif, FFI_DEFAULT_ABI, 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;
|
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:
|
* g_callable_info_free_closure:
|
||||||
* @callable_info: a callable info from a typelib
|
* @callable_info: a callable info from a typelib
|
||||||
|
5
girffi.h
5
girffi.h
@ -95,6 +95,11 @@ ffi_closure * g_callable_info_prepare_closure (GICallableInfo *callabl
|
|||||||
ffi_cif *cif,
|
ffi_cif *cif,
|
||||||
GIFFIClosureCallback callback,
|
GIFFIClosureCallback callback,
|
||||||
gpointer user_data);
|
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
|
GI_AVAILABLE_IN_ALL
|
||||||
void g_callable_info_free_closure (GICallableInfo *callable_info,
|
void g_callable_info_free_closure (GICallableInfo *callable_info,
|
||||||
ffi_closure *closure);
|
ffi_closure *closure);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user