forked from BitBoxSwiss/bitbox-wallet-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend/qt: revert d68b673, restore custom libserver.h
Using the auto-generated server/libsever.h directly does not work after all, at least not when upgrading to Qt 6.2 on Windows with MSVC. cgo uses mingw gcc and produces C99 code in the header. The MSVC compiler does not accept this any longer: ``` typedef _Fcomplex GoComplex64; typedef _Dcomplex GoComplex128; ``` Something about syntax error, I guess _FComplex is not available when compiling this as C++ with MSVC. Not clear why it worked with Qt 5.15 - probably the compiler flags have changed in Qt 6.2. The custom libserver.h contains the same as the auto-generated one, but reduced to the declarations we actually need, not all the Go C preamble stuff that causes the compat problems with MSVC.
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef BACKEND_H | ||
#define BACKEND_H | ||
#include <string.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
// Workaround to be able to use `const char*` as a param type in the exported Go functions. | ||
typedef const char cchar_t; | ||
|
||
typedef void (*pushNotificationsCallback) (const char*); | ||
static void pushNotify(pushNotificationsCallback f, const char* msg) { | ||
f(msg); | ||
} | ||
|
||
typedef void (*responseCallback) (int, const char*); | ||
static void respond(responseCallback f, int queryID, const char* msg) { | ||
f(queryID, msg); | ||
} | ||
|
||
typedef void (*notifyUserCallback) (const char*); | ||
static void notifyUser(notifyUserCallback f, const char* msg) { | ||
f(msg); | ||
} | ||
|
||
typedef char* (*getSaveFilenameCallback) (const char*); | ||
static char* getSaveFilename(getSaveFilenameCallback f, const char* suggestedfilename) { | ||
return f(suggestedfilename); | ||
} | ||
|
||
// equivalent to C.free but suitable for releasing a memory malloc'ed | ||
// in a non-posix portable environment, incompatible with cgo. | ||
// this is especially important on windows where the standard C runtime | ||
// memory management used by cgo and mingw is different from win32 API used | ||
// when compiling C++ code with MSVC. hence, the memory allocated with malloc | ||
// in C++ must always be freed by this function in Go instead of C.free. | ||
typedef void (*cppHeapFree) (void* ptr); | ||
static void customHeapFree(cppHeapFree f, void* ptr) { | ||
f(ptr); | ||
} | ||
|
||
#endif | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern void backendCall(int queryID, cchar_t* s); | ||
extern void handleURI(cchar_t* uri); | ||
extern void serve(cppHeapFree cppHeapFreeFn, pushNotificationsCallback pushNotificationsFn, responseCallback responseFn, notifyUserCallback notifyUserFn, cchar_t* preferredLocale, getSaveFilenameCallback getSaveFilenameFn); | ||
extern void systemOpen(cchar_t* url); | ||
extern void goLog(cchar_t* msg); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters