Skip to content

Commit

Permalink
[WRAPPER] Added a few glib2 wrapped functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Dec 20, 2024
1 parent 15f9089 commit 80db017
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/wrapped/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3823,8 +3823,10 @@ wrappedglib2:
- g_main_context_get_poll_func
- g_private_new
- g_ptr_array_new_with_free_func
- g_sequence_new
- g_set_print_handler
- g_set_printerr_handler
- g_tree_new
- vFpp:
- g_array_set_clear_func
- g_array_sort
Expand Down Expand Up @@ -3881,6 +3883,7 @@ wrappedglib2:
- g_queue_foreach
- g_slist_foreach
- g_static_private_set
- g_tree_foreach
- vFppV:
- g_string_append_printf
- g_string_printf
Expand Down Expand Up @@ -3926,6 +3929,7 @@ wrappedglib2:
- vFpupp:
- g_datalist_id_set_data_full
- vFpppp:
- g_queue_insert_sorted
- g_source_set_callback
- iFpLpV:
- g_snprintf
Expand All @@ -3951,8 +3955,11 @@ wrappedglib2:
- pFpppp:
- g_hash_table_new_full
- g_list_insert_sorted_with_data
- g_sequence_insert_sorted
- g_sequence_lookup
- g_slist_insert_sorted_with_data
- g_thread_try_new
- g_tree_new_full
- vFpiLpp:
- g_qsort_with_data
- vFpuipV:
Expand Down
7 changes: 7 additions & 0 deletions src/wrapped/generated/wrappedglib2types.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ typedef int32_t (*iFpppuppppppp_t)(void*, void*, void*, uint32_t, void*, void*,
GO(g_main_context_get_poll_func, pFp_t) \
GO(g_private_new, pFp_t) \
GO(g_ptr_array_new_with_free_func, pFp_t) \
GO(g_sequence_new, pFp_t) \
GO(g_set_print_handler, pFp_t) \
GO(g_set_printerr_handler, pFp_t) \
GO(g_tree_new, pFp_t) \
GO(g_array_set_clear_func, vFpp_t) \
GO(g_array_sort, vFpp_t) \
GO(g_completion_set_compare, vFpp_t) \
Expand Down Expand Up @@ -115,6 +117,7 @@ typedef int32_t (*iFpppuppppppp_t)(void*, void*, void*, uint32_t, void*, void*,
GO(g_queue_foreach, vFppp_t) \
GO(g_slist_foreach, vFppp_t) \
GO(g_static_private_set, vFppp_t) \
GO(g_tree_foreach, vFppp_t) \
GO(g_string_append_printf, vFppV_t) \
GO(g_string_printf, vFppV_t) \
GO(g_variant_builder_add, vFppV_t) \
Expand Down Expand Up @@ -147,6 +150,7 @@ typedef int32_t (*iFpppuppppppp_t)(void*, void*, void*, uint32_t, void*, void*,
GO(g_log, vFpipV_t) \
GO(g_logv, vFpipA_t) \
GO(g_datalist_id_set_data_full, vFpupp_t) \
GO(g_queue_insert_sorted, vFpppp_t) \
GO(g_source_set_callback, vFpppp_t) \
GO(g_snprintf, iFpLpV_t) \
GO(g_vsnprintf, iFpLpA_t) \
Expand All @@ -161,8 +165,11 @@ typedef int32_t (*iFpppuppppppp_t)(void*, void*, void*, uint32_t, void*, void*,
GO(g_thread_create, pFppip_t) \
GO(g_hash_table_new_full, pFpppp_t) \
GO(g_list_insert_sorted_with_data, pFpppp_t) \
GO(g_sequence_insert_sorted, pFpppp_t) \
GO(g_sequence_lookup, pFpppp_t) \
GO(g_slist_insert_sorted_with_data, pFpppp_t) \
GO(g_thread_try_new, pFpppp_t) \
GO(g_tree_new_full, pFpppp_t) \
GO(g_qsort_with_data, vFpiLpp_t) \
GO(g_set_error, vFpuipV_t) \
GO(g_child_watch_add_full, uFiippp_t) \
Expand Down
57 changes: 57 additions & 0 deletions src/wrapped/wrappedglib2.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,28 @@ static void* findTimeOutFct(void* fct)
printf_log(LOG_NONE, "Warning, no more slot for glib2 TimeOut callback\n");
return NULL;
}
// GTraverseFunc ...
#define GO(A) \
static uintptr_t my_GTraverseFunc_fct_##A = 0; \
static int my_GTraverseFunc_##A(void* a, void* b, void* c) \
{ \
return (int)RunFunctionFmt(my_GTraverseFunc_fct_##A, "ppp", a, b, c); \
}
SUPER()
#undef GO
static void* findGTraverseFuncFct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_GTraverseFunc_fct_##A == (uintptr_t)fct) return my_GTraverseFunc_##A;
SUPER()
#undef GO
#define GO(A) if(my_GTraverseFunc_fct_##A == 0) {my_GTraverseFunc_fct_##A = (uintptr_t)fct; return my_GTraverseFunc_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for glib2 GTraverseFunc callback\n");
return NULL;
}

#undef SUPER

Expand Down Expand Up @@ -1479,6 +1501,41 @@ EXPORT void my_g_assertion_message_cmpnum(void* domain, void* file, int32_t line
}
#endif

EXPORT void* my_g_sequence_new(x64emu_t* emu, void* d)
{
return my->g_sequence_new(findGDestroyNotifyFct(d));
}

EXPORT void* my_g_sequence_lookup(x64emu_t* emu, void* seq, void* data, void* f, void* cmp_data)
{
return my->g_sequence_lookup(seq, data, findGCompareDataFuncFct(f), cmp_data);
}

EXPORT void* my_g_sequence_insert_sorted(x64emu_t* emu, void* seq, void* data, void* f, void* cmp_data)
{
return my->g_sequence_insert_sorted(seq, data, findGCompareDataFuncFct(f), cmp_data);
}

EXPORT void* my_g_tree_new(x64emu_t* emu, void* f)
{
return my->g_tree_new(findGCompareFuncFct(f));
}

EXPORT void* my_g_tree_new_full(x64emu_t* emu, void* f, void* data, void* d1, void* d2)
{
return my->g_tree_new_full(findGCompareFuncFct(f), data, findGDestroyNotifyFct(d1), findGDestroyNotifyFct(d2));
}

EXPORT void my_g_tree_foreach(x64emu_t* emu, void* tree, void* f, void* data)
{
my->g_tree_foreach(tree, findGTraverseFuncFct(f), data);
}

EXPORT void my_g_queue_insert_sorted(x64emu_t* emu, void* queue, void* data, void* f, void* user_data)
{
my->g_queue_insert_sorted(queue, data, findGCompareDataFuncFct(f), user_data);
}

#define PRE_INIT \
if(box64_nogtk) \
return -1;
Expand Down
16 changes: 9 additions & 7 deletions src/wrapped/wrappedglib2_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ GO(g_date_time_compare, iFpp)
GO(g_date_time_difference, lFpp)
GO(g_date_time_equal, iFpp)
GO(g_date_time_format, pFpp)
GO(g_date_time_format_iso8601, pFp)
GO(g_date_time_get_day_of_month, iFp)
GO(g_date_time_get_day_of_week, iFp)
GO(g_date_time_get_day_of_year, iFp)
Expand Down Expand Up @@ -708,6 +709,7 @@ GO(g_mem_chunk_new, pFpiLi)
GO(g_mem_chunk_print, vFp)
GO(g_mem_chunk_reset, vFp)
GO(g_memdup, pFpu)
GO(g_memdup2, pFpL)
GO(g_mem_is_system_malloc, iFv)
GO(g_mem_profile, vFv)
//GOM(g_mem_set_vtable, vFEp)
Expand Down Expand Up @@ -859,7 +861,7 @@ GO(g_queue_insert_after, vFppp)
GO(g_queue_insert_after_link, vFppp) // 2.62+
GO(g_queue_insert_before, vFppp)
GO(g_queue_insert_before_link, vFppp) // 2.62+
//GOM(g_queue_insert_sorted, vFEpppp)
GOM(g_queue_insert_sorted, vFEpppp)
GO(g_queue_is_empty, iFp)
GO(g_queue_link_index, iFpp)
GO(g_queue_new, pFv)
Expand Down Expand Up @@ -988,7 +990,7 @@ GO(g_sequence_get_end_iter, pFp)
GO(g_sequence_get_iter_at_pos, pFpi)
GO(g_sequence_get_length, iFp)
GO(g_sequence_insert_before, pFpp)
//GOM(g_sequence_insert_sorted, pFpppp)
GOM(g_sequence_insert_sorted, pFEpppp)
//GOM(g_sequence_insert_sorted_iter, pFpppp)
GO(g_sequence_iter_compare, iFpp)
GO(g_sequence_iter_get_position, iFp)
Expand All @@ -998,11 +1000,11 @@ GO(g_sequence_iter_is_end, iFp)
GO(g_sequence_iter_move, pFpi)
GO(g_sequence_iter_next, pFp)
GO(g_sequence_iter_prev, pFp)
//GOM(g_sequence_lookup, pFpppp)
GOM(g_sequence_lookup, pFEpppp)
//GOM(g_sequence_lookup_iter, pFpppp)
GO(g_sequence_move, vFpp)
GO(g_sequence_move_range, vFppp)
//GOM(g_sequence_new, pFp)
GOM(g_sequence_new, pFEp)
GO(g_sequence_prepend, pFpp)
GO(g_sequence_range_get_midpoint, pFpp)
GO(g_sequence_remove, vFp)
Expand Down Expand Up @@ -1326,13 +1328,13 @@ GO(g_trash_stack_peek, pFp)
GO(g_trash_stack_pop, pFp)
GO(g_trash_stack_push, vFpp)
GO(g_tree_destroy, vFp)
//GOM(g_tree_foreach, vFppp)
GOM(g_tree_foreach, vFEppp)
GO(g_tree_height, iFp)
GO(g_tree_insert, vFppp)
GO(g_tree_lookup, pFpp)
GO(g_tree_lookup_extended, iFpppp)
//GOM(g_tree_new, pFp)
//GOM(g_tree_new_full, pFpppp)
GOM(g_tree_new, pFEp)
GOM(g_tree_new_full, pFEpppp)
//GOM(g_tree_new_with_data, pFpp)
GO(g_tree_nnodes, iFp)
GO(g_tree_ref, pFp)
Expand Down

0 comments on commit 80db017

Please sign in to comment.