about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-08-23 23:29:30 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-08-23 23:29:30 +0200
commit39f2b508f8e12e12505630d5db78adfbeeb9e7f9 (patch)
treebe5914483ebe6e5a309c4d3722e77a76db578a05 /src
parent5b5285940f8c08759da8e00f8656a88eb4e8dbd6 (diff)
downloadbox64-39f2b508f8e12e12505630d5db78adfbeeb9e7f9.tar.gz
box64-39f2b508f8e12e12505630d5db78adfbeeb9e7f9.zip
Added some more atk wrapped functions (for #101)
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt7
-rw-r--r--src/wrapped/generated/wrappedatktypes.h8
-rw-r--r--src/wrapped/generated/wrapper.c2
-rw-r--r--src/wrapped/generated/wrapper.h1
-rwxr-xr-xsrc/wrapped/wrappedatk.c139
-rwxr-xr-xsrc/wrapped/wrappedatk_private.h26
6 files changed, 169 insertions, 14 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 3ec85777..c94d18d7 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -357,6 +357,7 @@
 #() uFEpW
 #() uFEpu
 #() uFEpU
+#() uFEpp
 #() uFipu
 #() uFuip
 #() uFuuu
@@ -1524,6 +1525,12 @@
 wrappedalure:
 wrappedalut:
 wrappedatk:
+- vFp:
+  - atk_focus_tracker_init
+- uFp:
+  - atk_add_focus_tracker
+- uFpp:
+  - atk_add_key_event_listener
 wrappedatkbridge:
 wrappedatspi:
 wrappedbz2:
diff --git a/src/wrapped/generated/wrappedatktypes.h b/src/wrapped/generated/wrappedatktypes.h
index 0829d92c..56424c87 100644
--- a/src/wrapped/generated/wrappedatktypes.h
+++ b/src/wrapped/generated/wrappedatktypes.h
@@ -11,7 +11,13 @@
 #define ADDED_FUNCTIONS() 
 #endif
 
+typedef void (*vFp_t)(void*);
+typedef uint64_t (*uFp_t)(void*);
+typedef uint64_t (*uFpp_t)(void*, void*);
 
-#define SUPER() ADDED_FUNCTIONS()
+#define SUPER() ADDED_FUNCTIONS() \
+	GO(atk_focus_tracker_init, vFp_t) \
+	GO(atk_add_focus_tracker, uFp_t) \
+	GO(atk_add_key_event_listener, uFpp_t)
 
 #endif // __wrappedatkTYPES_H_
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index 9a903227..cc5a12ae 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -391,6 +391,7 @@ typedef int64_t (*IFSIi_t)(void*, int64_t, int64_t);
 typedef uint64_t (*uFEpW_t)(x64emu_t*, void*, uint16_t);
 typedef uint64_t (*uFEpu_t)(x64emu_t*, void*, uint64_t);
 typedef uint64_t (*uFEpU_t)(x64emu_t*, void*, uint64_t);
+typedef uint64_t (*uFEpp_t)(x64emu_t*, void*, void*);
 typedef uint64_t (*uFipu_t)(int64_t, void*, uint64_t);
 typedef uint64_t (*uFuip_t)(uint64_t, int64_t, void*);
 typedef uint64_t (*uFuuu_t)(uint64_t, uint64_t, uint64_t);
@@ -1917,6 +1918,7 @@ void IFSIi(x64emu_t *emu, uintptr_t fcn) { IFSIi_t fn = (IFSIi_t)fcn; R_RAX=(int
 void uFEpW(x64emu_t *emu, uintptr_t fcn) { uFEpW_t fn = (uFEpW_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (uint16_t)R_RSI); }
 void uFEpu(x64emu_t *emu, uintptr_t fcn) { uFEpu_t fn = (uFEpu_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI); }
 void uFEpU(x64emu_t *emu, uintptr_t fcn) { uFEpU_t fn = (uFEpU_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI); }
+void uFEpp(x64emu_t *emu, uintptr_t fcn) { uFEpp_t fn = (uFEpp_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (void*)R_RSI); }
 void uFipu(x64emu_t *emu, uintptr_t fcn) { uFipu_t fn = (uFipu_t)fcn; R_RAX=(uint64_t)fn((int64_t)R_RDI, (void*)R_RSI, (uint64_t)R_RDX); }
 void uFuip(x64emu_t *emu, uintptr_t fcn) { uFuip_t fn = (uFuip_t)fcn; R_RAX=(uint64_t)fn((uint64_t)R_RDI, (int64_t)R_RSI, (void*)R_RDX); }
 void uFuuu(x64emu_t *emu, uintptr_t fcn) { uFuuu_t fn = (uFuuu_t)fcn; R_RAX=(uint64_t)fn((uint64_t)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index f77fa105..865c9d91 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -390,6 +390,7 @@ void IFSIi(x64emu_t *emu, uintptr_t fnc);
 void uFEpW(x64emu_t *emu, uintptr_t fnc);
 void uFEpu(x64emu_t *emu, uintptr_t fnc);
 void uFEpU(x64emu_t *emu, uintptr_t fnc);
+void uFEpp(x64emu_t *emu, uintptr_t fnc);
 void uFipu(x64emu_t *emu, uintptr_t fnc);
 void uFuip(x64emu_t *emu, uintptr_t fnc);
 void uFuuu(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedatk.c b/src/wrapped/wrappedatk.c
index 9a9564e6..a7150d5b 100755
--- a/src/wrapped/wrappedatk.c
+++ b/src/wrapped/wrappedatk.c
@@ -11,12 +11,151 @@
 #include "bridge.h"
 #include "librarian/library_private.h"
 #include "x64emu.h"
+#include "emu/x64emu_private.h"
+#include "callback.h"
+#include "librarian.h"
+#include "box64context.h"
+#include "emu/x64emu_private.h"
+#include "myalign.h"
 
 const char* atkName = "libatk-1.0.so.0";
 #define LIBNAME atk
+static library_t* my_lib = NULL;
+
+#include "generated/wrappedatktypes.h"
+
+typedef struct atk_my_s {
+    // functions
+    #define GO(A, B)    B   A;
+    SUPER()
+    #undef GO
+} atk_my_t;
+
+void* getAtkMy(library_t* lib)
+{
+    my_lib = lib;
+    atk_my_t* my = (atk_my_t*)calloc(1, sizeof(atk_my_t));
+    #define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
+    SUPER()
+    #undef GO
+    return my;
+}
+#undef SUPER
+
+void freeAtkMy(void* lib)
+{
+    my_lib = NULL;
+    (void)lib;
+    //atk_my_t *my = (atk_my_t *)lib;
+}
+
+#define SUPER() \
+GO(0)   \
+GO(1)   \
+GO(2)   \
+GO(3)   \
+GO(4)
+
+// AtkEventListenerInit ...
+#define GO(A)   \
+static uintptr_t my_AtkEventListenerInit_fct_##A = 0;               \
+static void my_AtkEventListenerInit_##A()                           \
+{                                                                   \
+    RunFunction(my_context, my_AtkEventListenerInit_fct_##A, 0);    \
+}
+SUPER()
+#undef GO
+static void* find_AtkEventListenerInit_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_AtkEventListenerInit_fct_##A == (uintptr_t)fct) return my_AtkEventListenerInit_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_AtkEventListenerInit_fct_##A == 0) {my_AtkEventListenerInit_fct_##A = (uintptr_t)fct; return my_AtkEventListenerInit_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for atk AtkEventListenerInit callback\n");
+    return NULL;
+}
+// AtkEventListener ...
+#define GO(A)   \
+static uintptr_t my_AtkEventListener_fct_##A = 0;               \
+static void my_AtkEventListener_##A(void* a)                    \
+{                                                               \
+    RunFunction(my_context, my_AtkEventListener_fct_##A, 1, a); \
+}
+SUPER()
+#undef GO
+static void* find_AtkEventListener_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_AtkEventListener_fct_##A == (uintptr_t)fct) return my_AtkEventListener_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_AtkEventListener_fct_##A == 0) {my_AtkEventListener_fct_##A = (uintptr_t)fct; return my_AtkEventListener_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for atk AtkEventListener callback\n");
+    return NULL;
+}
+// AtkKeySnoopFunc ...
+#define GO(A)   \
+static uintptr_t my_AtkKeySnoopFunc_fct_##A = 0;                                \
+static int my_AtkKeySnoopFunc_##A(void* a, void* b)                             \
+{                                                                               \
+    return (int)RunFunction(my_context, my_AtkKeySnoopFunc_fct_##A, 2, a, b);   \
+}
+SUPER()
+#undef GO
+static void* find_AtkKeySnoopFunc_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_AtkKeySnoopFunc_fct_##A == (uintptr_t)fct) return my_AtkKeySnoopFunc_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_AtkKeySnoopFunc_fct_##A == 0) {my_AtkKeySnoopFunc_fct_##A = (uintptr_t)fct; return my_AtkKeySnoopFunc_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for atk AtkKeySnoopFunc callback\n");
+    return NULL;
+}
+
+#undef SUPER
+
+EXPORT void my_atk_focus_tracker_init(x64emu_t* emu, void* f)
+{
+    atk_my_t *my = (atk_my_t*)my_lib->priv.w.p2;
+
+    my->atk_focus_tracker_init(find_AtkEventListenerInit_Fct(f));
+}
+
+EXPORT uint32_t my_atk_add_focus_tracker(x64emu_t* emu, void* f)
+{
+    atk_my_t *my = (atk_my_t*)my_lib->priv.w.p2;
+
+    return my->atk_add_focus_tracker(find_AtkEventListener_Fct(f));
+}
+
+EXPORT uint32_t my_atk_add_key_event_listener(x64emu_t* emu, void* f, void* p)
+{
+    atk_my_t *my = (atk_my_t*)my_lib->priv.w.p2;
+
+    return my->atk_add_key_event_listener(find_AtkEventListener_Fct(f), p);
+}
 
 #define PRE_INIT    \
     if(box64_nogtk) \
         return -1;
 
+#define CUSTOM_INIT \
+    lib->priv.w.p2 = getAtkMy(lib); \
+    my_lib = lib;
+
+#define CUSTOM_FINI \
+    freeAtkMy(lib->priv.w.p2);  \
+    free(lib->priv.w.p2);       \
+
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedatk_private.h b/src/wrapped/wrappedatk_private.h
index c43c3104..84f0c775 100755
--- a/src/wrapped/wrappedatk_private.h
+++ b/src/wrapped/wrappedatk_private.h
@@ -10,9 +10,9 @@ GO(atk_action_get_n_actions, iFp)
 GO(atk_action_get_name, pFpi)
 GO(atk_action_get_type, iFv)
 GO(atk_action_set_description, pFpi)
-//GO(atk_add_focus_tracker, 
-//GO(atk_add_global_event_listener, 
-//GO(atk_add_key_event_listener, 
+GOM(atk_add_focus_tracker, uFEp)
+//GOM(atk_add_global_event_listener, uFEpp)
+GOM(atk_add_key_event_listener, uFEpp)
 //GO(atk_attribute_set_free, 
 //GOM(atk_component_add_focus_handler, uFpp)
 GO(atk_component_contains, iFpiii)
@@ -45,19 +45,19 @@ GO(atk_coord_type_get_type, iFv)
 //GO(atk_editable_text_paste_text, 
 //GO(atk_editable_text_set_run_attributes, 
 //GO(atk_editable_text_set_text_contents, 
-//GO(atk_focus_tracker_init, 
-//GO(atk_focus_tracker_notify, 
+GOM(atk_focus_tracker_init, vFEp)
+GO(atk_focus_tracker_notify, vFp)
 //GO(atk_get_binary_age, 
 GO(atk_get_default_registry, pFv)
-//GO(atk_get_focus_object, 
+GO(atk_get_focus_object, pFv)
 //GO(atk_get_interface_age, 
 //GO(atk_get_major_version, 
 //GO(atk_get_micro_version, 
 //GO(atk_get_minor_version, 
-//GO(atk_get_root, 
-//GO(atk_get_toolkit_name, 
-//GO(atk_get_toolkit_version, 
-//GO(atk_get_version, 
+GO(atk_get_root, pFv)
+GO(atk_get_toolkit_name, pFv)
+GO(atk_get_toolkit_version, pFv)
+GO(atk_get_version, pFv)
 //GO(atk_gobject_accessible_for_object, 
 //GO(atk_gobject_accessible_get_object, 
 //GO(atk_gobject_accessible_get_type, 
@@ -156,9 +156,9 @@ GO(atk_registry_set_factory_type, vFpii)
 //GO(atk_relation_type_get_name, 
 //GO(atk_relation_type_get_type, 
 //GO(atk_relation_type_register, 
-//GO(atk_remove_focus_tracker, 
-//GO(atk_remove_global_event_listener, 
-//GO(atk_remove_key_event_listener, 
+GO(atk_remove_focus_tracker, vFu)
+GO(atk_remove_global_event_listener, vFu)
+GO(atk_remove_key_event_listener, vFu)
 GO(atk_role_for_name, iFp)
 GO(atk_role_get_localized_name, pFp)
 GO(atk_role_get_name, pFp)