Skip to content

Commit

Permalink
Merge remote-tracking branch 'benma/libserver'
Browse files Browse the repository at this point in the history
  • Loading branch information
benma committed Mar 5, 2024
2 parents 0f7362d + d68b673 commit 192e22d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 69 deletions.
3 changes: 2 additions & 1 deletion frontends/qt/BitBox.pro
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ SOURCES += \
main.cpp \
filedialog.cpp

HEADERS += libserver.h webclass.h filedialog.h
# server/libserver.h is generated by building server.go, see the Makefiles in server/.
HEADERS += server/libserver.h webclass.h filedialog.h

unix:macx {
# Those frameworks are needed for Go's http/net packages.
Expand Down
63 changes: 0 additions & 63 deletions frontends/qt/libserver.h

This file was deleted.

2 changes: 1 addition & 1 deletion frontends/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include <string.h>

#include "filedialog.h"
#include "libserver.h"
#include "server/libserver.h"
#include "webclass.h"

#define APPNAME "BitBoxApp"
Expand Down
11 changes: 8 additions & 3 deletions frontends/qt/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ static char* getSaveFilename(getSaveFilenameCallback f, const char* suggestedfil
return f(suggestedfilename);
}
// see frontends/qt/libserver.h for doc comments
// 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);
Expand Down Expand Up @@ -85,7 +90,7 @@ func (communication *nativeCommunication) PushNotify(msg string) {
}

//export backendCall
func backendCall(queryID C.int, s *C.char) {
func backendCall(queryID C.int, s *C.cchar_t) {
bridgecommon.BackendCall(int(queryID), C.GoString(s))
}

Expand All @@ -104,7 +109,7 @@ func serve(
pushNotificationsFn C.pushNotificationsCallback,
responseFn C.responseCallback,
notifyUserFn C.notifyUserCallback,
preferredLocale *C.char,
preferredLocale *C.cchar_t,
getSaveFilenameFn C.getSaveFilenameCallback,
) {
log := logging.Get().WithGroup("server")
Expand Down
2 changes: 1 addition & 1 deletion frontends/qt/webclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <QApplication>

#include "libserver.h"
#include "server/libserver.h"

class WebClass : public QObject
{
Expand Down

0 comments on commit 192e22d

Please sign in to comment.