diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2023-05-07 22:13:56 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-07 16:13:56 +0200 |
| commit | 9f38e81735b10668d64974033b4bb5097219ee34 (patch) | |
| tree | 57827cc130a3e79a46c58f4e5ce8946c78f4131a /src/wrapped/wrappedgobject2.c | |
| parent | 47ecde75ec19a58f458c1131ec1968d11d58e7e1 (diff) | |
| download | box64-9f38e81735b10668d64974033b4bb5097219ee34.tar.gz box64-9f38e81735b10668d64974033b4bb5097219ee34.zip | |
[WRAPPER] Used RunFunctionFmt for better sign-extend handling (#768)
* [WRAPPER] Used RunFunctionFmt for better sign-extend handling * [WRAPPER] Fixed some typos * [WRAPPER] Use L for unsigned long for better portability * [WRAPPER] More replace from U to L
Diffstat (limited to 'src/wrapped/wrappedgobject2.c')
| -rwxr-xr-x | src/wrapped/wrappedgobject2.c | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/src/wrapped/wrappedgobject2.c b/src/wrapped/wrappedgobject2.c index 16f4e688..1295cedd 100755 --- a/src/wrapped/wrappedgobject2.c +++ b/src/wrapped/wrappedgobject2.c @@ -67,11 +67,11 @@ static int signal_cb(void* a, void* b, void* c, void* d, void* e) } printf_log(LOG_DEBUG, "gobject2 Signal called, sig=%p, handler=%p, NArgs=%d\n", sig, sig?(void*)sig->c_handler:NULL, i); switch(i) { - case 1: return (int)RunFunction(my_context, sig->c_handler, 1, sig->data); - case 2: return (int)RunFunction(my_context, sig->c_handler, 2, a, sig->data); - case 3: return (int)RunFunction(my_context, sig->c_handler, 3, a, b, sig->data); - case 4: return (int)RunFunction(my_context, sig->c_handler, 4, a, b, c, sig->data); - case 5: return (int)RunFunction(my_context, sig->c_handler, 5, a, b, c, d, sig->data); + case 1: return (int)RunFunctionFmt(my_context, sig->c_handler, "p", sig->data); + case 2: return (int)RunFunctionFmt(my_context, sig->c_handler, "pp", a, sig->data); + case 3: return (int)RunFunctionFmt(my_context, sig->c_handler, "ppp", a, b, sig->data); + case 4: return (int)RunFunctionFmt(my_context, sig->c_handler, "pppp", a, b, c, sig->data); + case 5: return (int)RunFunctionFmt(my_context, sig->c_handler, "ppppp", a, b, c, d, sig->data); } printf_log(LOG_NONE, "Warning, GObject2 signal callback but no data found!\n"); return 0; @@ -80,47 +80,47 @@ static int signal_cb_swapped(my_signal_t* sig, void* b, void* c, void* d) { // data is in front here... printf_log(LOG_DEBUG, "gobject2 swaped4 Signal called, sig=%p\n", sig); - return (int)RunFunction(my_context, sig->c_handler, 4, sig->data, b, c, d); + return (int)RunFunctionFmt(my_context, sig->c_handler, "pppp", sig->data, b, c, d); } static int signal_cb_5(void* a, void* b, void* c, void* d, my_signal_t* sig) { printf_log(LOG_DEBUG, "gobject2 5 Signal called, sig=%p\n", sig); - return (int)RunFunction(my_context, sig->c_handler, 5, a, b, c, d, sig->data); + return (int)RunFunctionFmt(my_context, sig->c_handler, "ppppp", a, b, c, d, sig->data); } static int signal_cb_swapped_5(my_signal_t* sig, void* b, void* c, void* d, void* e) { // data is in front here... printf_log(LOG_DEBUG, "gobject2 swaped5 Signal called, sig=%p\n", sig); - return (int)RunFunction(my_context, sig->c_handler, 5, sig->data, b, c, d, e); + return (int)RunFunctionFmt(my_context, sig->c_handler, "ppppp", sig->data, b, c, d, e); } static int signal_cb_6(void* a, void* b, void* c, void* d, void* e, my_signal_t* sig) { printf_log(LOG_DEBUG, "gobject2 6 Signal called, sig=%p\n", sig); - return (int)RunFunction(my_context, sig->c_handler, 6, a, b, c, d, e, sig->data); + return (int)RunFunctionFmt(my_context, sig->c_handler, "pppppp", a, b, c, d, e, sig->data); } static int signal_cb_swapped_6(my_signal_t* sig, void* b, void* c, void* d, void* e, void* f) { // data is in front here... printf_log(LOG_DEBUG, "gobject2 swaped6 Signal called, sig=%p\n", sig); - return (int)RunFunction(my_context, sig->c_handler, 6, sig->data, b, c, d, e, f); + return (int)RunFunctionFmt(my_context, sig->c_handler, "pppppp", sig->data, b, c, d, e, f); } static int signal_cb_8(void* a, void* b, void* c, void* d, void* e, void* f, void* g, my_signal_t* sig) { printf_log(LOG_DEBUG, "gobject2 8 Signal called, sig=%p\n", sig); - return (int)RunFunction(my_context, sig->c_handler, 8, a, b, c, d, e, f, g, sig->data); + return (int)RunFunctionFmt(my_context, sig->c_handler, "pppppppp", a, b, c, d, e, f, g, sig->data); } static int signal_cb_swapped_8(my_signal_t* sig, void* b, void* c, void* d, void* e, void* f, void* g, void* h) { // data is in front here... printf_log(LOG_DEBUG, "gobject2 swaped8 Signal called, sig=%p\n", sig); - return (int)RunFunction(my_context, sig->c_handler, 8, sig->data, b, c, d, e, f, g, h); + return (int)RunFunctionFmt(my_context, sig->c_handler, "pppppppp", sig->data, b, c, d, e, f, g, h); } static void signal_delete(my_signal_t* sig, void* b) { uintptr_t d = sig->destroy; if(d) { - RunFunction(my_context, d, 2, sig->data, b); + RunFunctionFmt(my_context, d, "pp", sig->data, b); } printf_log(LOG_DEBUG, "gobject2 Signal deleted, sig=%p, destroy=%p\n", sig, (void*)d); free(sig); @@ -267,10 +267,10 @@ GO(11) \ GO(12) \ #define GO(A) \ -static uintptr_t my_copy_fct_##A = 0; \ -static void* my_copy_##A(void* data) \ -{ \ - return (void*)RunFunction(my_context, my_copy_fct_##A, 1, data);\ +static uintptr_t my_copy_fct_##A = 0; \ +static void* my_copy_##A(void* data) \ +{ \ + return (void*)RunFunctionFmt(my_context, my_copy_fct_##A, "p", data); \ } SUPER() #undef GO @@ -288,10 +288,10 @@ static void* findCopyFct(void* fct) } #define GO(A) \ -static uintptr_t my_free_fct_##A = 0; \ -static void my_free_##A(void* data) \ -{ \ - RunFunction(my_context, my_free_fct_##A, 1, data);\ +static uintptr_t my_free_fct_##A = 0; \ +static void my_free_##A(void* data) \ +{ \ + RunFunctionFmt(my_context, my_free_fct_##A, "p", data); \ } SUPER() #undef GO @@ -309,10 +309,10 @@ static void* findFreeFct(void* fct) } // GSignalAccumulator #define GO(A) \ -static uintptr_t my_accumulator_fct_##A = 0; \ -static int my_accumulator_##A(void* ihint, void* return_accu, void* handler_return, void* data) \ -{ \ - return RunFunction(my_context, my_accumulator_fct_##A, 4, ihint, return_accu, handler_return, data);\ +static uintptr_t my_accumulator_fct_##A = 0; \ +static int my_accumulator_##A(void* ihint, void* return_accu, void* handler_return, void* data) \ +{ \ + return RunFunctionFmt(my_context, my_accumulator_fct_##A, "pppp", ihint, return_accu, handler_return, data); \ } SUPER() #undef GO @@ -332,10 +332,10 @@ static void* findAccumulatorFct(void* fct) // GClosureMarshal #define GO(A) \ -static uintptr_t my_marshal_fct_##A = 0; \ +static uintptr_t my_marshal_fct_##A = 0; \ static void my_marshal_##A(void* closure, void* return_value, uint32_t n, void* values, void* hint, void* data) \ { \ - RunFunction(my_context, my_marshal_fct_##A, 6, closure, return_value, n, values, hint, data); \ + RunFunctionFmt(my_context, my_marshal_fct_##A, "ppuppp", closure, return_value, n, values, hint, data); \ } SUPER() #undef GO @@ -355,10 +355,10 @@ static void* findMarshalFct(void* fct) // GClosureNotify #define GO(A) \ -static uintptr_t my_GClosureNotify_fct_##A = 0; \ -static int my_GClosureNotify_func_##A(void* a, void* b) \ -{ \ - return RunFunction(my_context, my_GClosureNotify_fct_##A, 2, a, b);\ +static uintptr_t my_GClosureNotify_fct_##A = 0; \ +static int my_GClosureNotify_func_##A(void* a, void* b) \ +{ \ + return RunFunctionFmt(my_context, my_GClosureNotify_fct_##A, "pp", a, b); \ } SUPER() #undef GO @@ -378,10 +378,10 @@ static void* findGClosureNotify_Fct(void* fct) // GValueTransform #define GO(A) \ -static uintptr_t my_valuetransform_fct_##A = 0; \ -static void my_valuetransform_##A(void* src, void* dst) \ -{ \ - RunFunction(my_context, my_valuetransform_fct_##A, 2, src, dst);\ +static uintptr_t my_valuetransform_fct_##A = 0; \ +static void my_valuetransform_##A(void* src, void* dst) \ +{ \ + RunFunctionFmt(my_context, my_valuetransform_fct_##A, "pp", src, dst); \ } SUPER() #undef GO @@ -401,10 +401,10 @@ static void* findValueTransformFct(void* fct) // GDestroyFunc ... #define GO(A) \ -static uintptr_t my_destroyfunc_fct_##A = 0; \ -static int my_destroyfunc_##A(void* a, void* b) \ -{ \ - return RunFunction(my_context, my_destroyfunc_fct_##A, 2, a, b);\ +static uintptr_t my_destroyfunc_fct_##A = 0; \ +static int my_destroyfunc_##A(void* a, void* b) \ +{ \ + return RunFunctionFmt(my_context, my_destroyfunc_fct_##A, "pp", a, b); \ } SUPER() #undef GO @@ -424,10 +424,10 @@ static void* findDestroyFct(void* fct) // GWeakNotify #define GO(A) \ -static uintptr_t my_weaknotifyfunc_fct_##A = 0; \ -static int my_weaknotifyfunc_##A(void* a, void* b) \ -{ \ - return RunFunction(my_context, my_weaknotifyfunc_fct_##A, 2, a, b);\ +static uintptr_t my_weaknotifyfunc_fct_##A = 0; \ +static int my_weaknotifyfunc_##A(void* a, void* b) \ +{ \ + return RunFunctionFmt(my_context, my_weaknotifyfunc_fct_##A, "pp", a, b); \ } SUPER() #undef GO @@ -447,10 +447,10 @@ static void* findWeakNotifyFct(void* fct) // GCallback (generic function with 6 arguments, hopefully it's enough) #define GO(A) \ -static uintptr_t my_GCallback_fct_##A = 0; \ -static void* my_GCallback_##A(void* a, void* b, void* c, void* d, void* e, void* f) \ -{ \ - return (void*)RunFunction(my_context, my_GCallback_fct_##A, 6, a, b, c, d, e, f); \ +static uintptr_t my_GCallback_fct_##A = 0; \ +static void* my_GCallback_##A(void* a, void* b, void* c, void* d, void* e, void* f) \ +{ \ + return (void*)RunFunctionFmt(my_context, my_GCallback_fct_##A, "pppppp", a, b, c, d, e, f); \ } SUPER() #undef GO @@ -481,32 +481,32 @@ typedef struct my_GParamSpecTypeInfo_s { int (*values_cmp) (void* pspec, void* value1, void* value2); } my_GParamSpecTypeInfo_t; -#define GO(A) \ +#define GO(A) \ static my_GParamSpecTypeInfo_t my_GParamSpecTypeInfo_##A = {0}; \ static my_GParamSpecTypeInfo_t *ref_GParamSpecTypeInfo_##A = NULL; SUPER() #undef GO // then the static functions callback that may be used with the structure, but dispatch also have a callback... #define GO(A) \ -static uintptr_t fct_funcs_instance_init_##A = 0; \ -static void my_funcs_instance_init_##A(void* pspec) { \ - RunFunction(my_context, fct_funcs_instance_init_##A, 1, pspec); \ +static uintptr_t fct_funcs_instance_init_##A = 0; \ +static void my_funcs_instance_init_##A(void* pspec) { \ + RunFunctionFmt(my_context, fct_funcs_instance_init_##A, "p", pspec); \ } \ -static uintptr_t fct_funcs_finalize_##A = 0; \ -static void my_funcs_finalize_##A(void* pspec) { \ - RunFunction(my_context, fct_funcs_finalize_##A, 1, pspec); \ +static uintptr_t fct_funcs_finalize_##A = 0; \ +static void my_funcs_finalize_##A(void* pspec) { \ + RunFunctionFmt(my_context, fct_funcs_finalize_##A, "p", pspec); \ } \ -static uintptr_t fct_funcs_value_set_default_##A = 0; \ -static void my_funcs_value_set_default_##A(void* pspec, void* value) { \ - RunFunction(my_context, fct_funcs_value_set_default_##A, 2, pspec, value); \ +static uintptr_t fct_funcs_value_set_default_##A = 0; \ +static void my_funcs_value_set_default_##A(void* pspec, void* value) { \ + RunFunctionFmt(my_context, fct_funcs_value_set_default_##A, "pp", pspec, value); \ } \ -static uintptr_t fct_funcs_value_validate_##A = 0; \ -static int my_funcs_value_validate_##A(void* pspec, void* value) { \ - return (int)RunFunction(my_context, fct_funcs_value_validate_##A, 2, pspec, value); \ +static uintptr_t fct_funcs_value_validate_##A = 0; \ +static int my_funcs_value_validate_##A(void* pspec, void* value) { \ + return (int)RunFunctionFmt(my_context, fct_funcs_value_validate_##A, "pp", pspec, value); \ } \ -static uintptr_t fct_funcs_values_cmp_##A = 0; \ +static uintptr_t fct_funcs_values_cmp_##A = 0; \ static int my_funcs_values_cmp_##A(void* pspec, void* value1, void* value2) { \ - return (int)RunFunction(my_context, fct_funcs_values_cmp_##A, 3, pspec, value1, value2); \ + return (int)RunFunctionFmt(my_context, fct_funcs_values_cmp_##A, "ppp", pspec, value1, value2); \ } SUPER() @@ -540,10 +540,10 @@ static my_GParamSpecTypeInfo_t* findFreeGParamSpecTypeInfo(my_GParamSpecTypeInfo // GInterfaceInitFunc #define GO(A) \ -static uintptr_t my_GInterfaceInitFunc_fct_##A = 0; \ -static void my_GInterfaceInitFunc_##A(void* src, void* dst) \ -{ \ - RunFunction(my_context, my_GInterfaceInitFunc_fct_##A, 2, src, dst);\ +static uintptr_t my_GInterfaceInitFunc_fct_##A = 0; \ +static void my_GInterfaceInitFunc_##A(void* src, void* dst) \ +{ \ + RunFunctionFmt(my_context, my_GInterfaceInitFunc_fct_##A, "pp", src, dst); \ } SUPER() #undef GO @@ -562,10 +562,10 @@ static void* findGInterfaceInitFuncFct(void* fct) } // GInterfaceFinalizeFunc #define GO(A) \ -static uintptr_t my_GInterfaceFinalizeFunc_fct_##A = 0; \ -static void my_GInterfaceFinalizeFunc_##A(void* src, void* dst) \ -{ \ - RunFunction(my_context, my_GInterfaceFinalizeFunc_fct_##A, 2, src, dst);\ +static uintptr_t my_GInterfaceFinalizeFunc_fct_##A = 0; \ +static void my_GInterfaceFinalizeFunc_##A(void* src, void* dst) \ +{ \ + RunFunctionFmt(my_context, my_GInterfaceFinalizeFunc_fct_##A, "pp", src, dst); \ } SUPER() #undef GO @@ -584,10 +584,10 @@ static void* findGInterfaceFinalizeFuncFct(void* fct) } // compare #define GO(A) \ -static uintptr_t my_compare_fct_##A = 0; \ -static int my_compare_##A(void* a, void* b, void* data) \ -{ \ - return RunFunction(my_context, my_compare_fct_##A, 3, a, b, data); \ +static uintptr_t my_compare_fct_##A = 0; \ +static int my_compare_##A(void* a, void* b, void* data) \ +{ \ + return RunFunctionFmt(my_context, my_compare_fct_##A, "ppp", a, b, data); \ } SUPER() #undef GO @@ -623,7 +623,7 @@ EXPORT int my_g_boxed_type_register_static(x64emu_t* emu, void* name, void* boxe EXPORT uint32_t my_g_signal_new(x64emu_t* emu, void* name, size_t itype, int flags, uint32_t offset, void* acc, void* accu_data, void* marsh, size_t rtype, uint32_t n, void** b) { printf_log(LOG_DEBUG, "g_signal_new for \"%s\", with offset=%d and %d args\n", (const char*)name, offset, n); - + void* cb_acc = findAccumulatorFct(acc); void* cb_marsh = findMarshalFct(marsh); my_add_signal_offset(itype, offset, n); // register the signal for later use @@ -644,7 +644,7 @@ EXPORT uint32_t my_g_signal_new(x64emu_t* emu, void* name, size_t itype, int fla EXPORT uint32_t my_g_signal_newv(x64emu_t* emu, void* name, size_t itype, int flags, void* closure, void* acc, void* accu_data, void* marsh, size_t rtype, uint32_t n, void* types) { printf_log(LOG_DEBUG, "g_signal_newv for \"%s\", with %d args\n", (const char*)name, n); - + return my->g_signal_newv(name, itype, flags, closure, findAccumulatorFct(acc), accu_data, findMarshalFct(marsh), rtype, n, types); } @@ -732,7 +732,7 @@ EXPORT void my_g_value_register_transform_func(x64emu_t* emu, size_t src, size_t static int my_signal_emission_hook(void* ihint, uint32_t n, void* values, my_signal_t* sig) { printf_log(LOG_DEBUG, "gobject2 Signal Emission Hook called, sig=%p\n", sig); - return (int)RunFunction(my_context, sig->c_handler, 4, ihint, n, values, sig->data); + return (int)RunFunctionFmt(my_context, sig->c_handler, "pupp", ihint, n, values, sig->data); } EXPORT unsigned long my_g_signal_add_emission_hook(x64emu_t* emu, uint32_t signal, void* detail, void* f, void* data, void* notify) { |