diff --git a/ThunkLibs/libX11/libX11_Guest.cpp b/ThunkLibs/libX11/libX11_Guest.cpp index 0df8e060e..8c66d91fc 100644 --- a/ThunkLibs/libX11/libX11_Guest.cpp +++ b/ThunkLibs/libX11/libX11_Guest.cpp @@ -9,6 +9,8 @@ $end_info$ #include #include +#include + // Include Xlibint.h and undefine some of its macros that clash with the standard library #include #undef min @@ -54,6 +56,25 @@ extern "C" { return rv; } + char* XGetIMValues(XIM ic, ...) { + fprintf(stderr, "XGetIMValues\n"); + va_list ap; + std::vector args; + va_start(ap, ic); + for (;;) { + auto arg = va_arg(ap, void*); + if (arg == 0) + break; + args.push_back(arg); + fprintf(stderr, "%p\n", arg); + } + + va_end(ap); + auto rv = fexfn_pack_XGetIMValues_internal(ic, args.size(), &args[0]); + fprintf(stderr, "RV: %p\n", rv); + return rv; + } + _XIC* XCreateIC(XIM im, ...) { fprintf(stderr, "XCreateIC\n"); va_list ap; diff --git a/ThunkLibs/libX11/libX11_Host.cpp b/ThunkLibs/libX11/libX11_Host.cpp index a5a635d30..f873424a0 100644 --- a/ThunkLibs/libX11/libX11_Host.cpp +++ b/ThunkLibs/libX11/libX11_Host.cpp @@ -9,8 +9,17 @@ $end_info$ #include #include + +// Include Xlibint.h and undefine some of its macros that clash with the standard library +#include +#undef min +#undef max + #include #include + +#include + #include "common/Host.h" #include @@ -45,7 +54,23 @@ char* fexfn_impl_libX11_XGetICValues_internal(XIC a_0, size_t count, unsigned lo case 6: return fexldr_ptr_libX11_XGetICValues(a_0, list[0], list[1], list[2], list[3], list[4], list[5], nullptr); break; case 7: return fexldr_ptr_libX11_XGetICValues(a_0, list[0], list[1], list[2], list[3], list[4], list[5], list[6], nullptr); break; default: - fprintf(stderr, "XCreateIC_internal FAILURE\n"); + fprintf(stderr, "XCreateICValues_internal FAILURE\n"); + return ErrorReply; + } +} + +char* fexfn_impl_libX11_XGetIMValues_internal(XIM a_0, size_t count, void **list) { + switch(count) { + case 0: return fexldr_ptr_libX11_XGetIMValues(a_0, nullptr); break; + case 1: return fexldr_ptr_libX11_XGetIMValues(a_0, list[0], nullptr); break; + case 2: return fexldr_ptr_libX11_XGetIMValues(a_0, list[0], list[1], nullptr); break; + case 3: return fexldr_ptr_libX11_XGetIMValues(a_0, list[0], list[1], list[2], nullptr); break; + case 4: return fexldr_ptr_libX11_XGetIMValues(a_0, list[0], list[1], list[2], list[3], nullptr); break; + case 5: return fexldr_ptr_libX11_XGetIMValues(a_0, list[0], list[1], list[2], list[3], list[4], nullptr); break; + case 6: return fexldr_ptr_libX11_XGetIMValues(a_0, list[0], list[1], list[2], list[3], list[4], list[5], nullptr); break; + case 7: return fexldr_ptr_libX11_XGetIMValues(a_0, list[0], list[1], list[2], list[3], list[4], list[5], list[6], nullptr); break; + default: + fprintf(stderr, "XCreateIMValues_internal FAILURE\n"); return ErrorReply; } } diff --git a/ThunkLibs/libX11/libX11_interface.cpp b/ThunkLibs/libX11/libX11_interface.cpp index 9f6e71fd7..702695541 100644 --- a/ThunkLibs/libX11/libX11_interface.cpp +++ b/ThunkLibs/libX11/libX11_interface.cpp @@ -4,6 +4,8 @@ #include #include +#include + #include #include @@ -442,6 +444,8 @@ template<> struct fex_gen_config { }; template<> struct fex_gen_config {}; +template<> struct fex_gen_config {}; + // TODO: Make returned function pointer guest-callable. For now, just pretend it already is. template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; template<> struct fex_gen_config {}; @@ -524,3 +528,64 @@ template<> struct fex_gen_config {}; template<> struct fex_gen_config {}; template<> struct fex_gen_config {}; template<> struct fex_gen_config {}; + +template<> struct fex_gen_config {}; +template<> struct fex_gen_config {}; +template<> struct fex_gen_config {}; +template<> struct fex_gen_config {}; +template<> struct fex_gen_config {}; +template<> struct fex_gen_config {}; +template<> struct fex_gen_config {}; + +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config { + using uniform_va_type = void*; +}; + +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; + + +// TODO: Should probably catch these with a custom handler +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; + +template<> struct fex_gen_config : fexgen::returns_guest_pointer {}; + +template<> struct fex_gen_config<_XRead32> {}; +template<> struct fex_gen_config<_XRead> {}; +template<> struct fex_gen_config<_XReadPad> {}; +template<> struct fex_gen_config<_XData32> {}; +template<> struct fex_gen_config<_XEatData> {}; +template<> struct fex_gen_config<_XEatDataWords> {}; +template<> struct fex_gen_config<_XGetAsyncReply> {}; +template<> struct fex_gen_config<_XSend> {}; +template<> struct fex_gen_config<_XFlush> {}; +template<> struct fex_gen_config<_XFlushGCCache> {}; +template<> struct fex_gen_config<_XAllocScratch> {}; +template<> struct fex_gen_config<_XGetRequest> {}; +template<> struct fex_gen_config<_XGetBitsPerPixel> {}; +template<> struct fex_gen_config<_XGetScanlinePad> {}; +template<> struct fex_gen_config<_XVIDtoVisual> {}; +template<> struct fex_gen_config<_XSetLastRequestRead> {}; +template<> struct fex_gen_config<_XDeqAsyncHandler> {}; +template<> struct fex_gen_config<_XAllocTemp> {}; +template<> struct fex_gen_config<_XFreeTemp> {}; +template<> struct fex_gen_config<_XUnknownNativeEvent> {}; +template<> struct fex_gen_config<_XIsEventCookie> {}; + +template<> struct fex_gen_config {}; + + + +// TODO: Vtable support... +template<> struct fex_gen_config<_XInitImageFuncPtrs> {};