Skip to content

Commit

Permalink
initial commit of the interop engine + new flutter module + fixes for…
Browse files Browse the repository at this point in the history
… minor issues

this commit introduces the new experimental `interop` module, which is used to allow the use of `therecipe/qt` from languages other than go or javascript.
as a start, there was support for the dart language added (currently only in combination with a custom flutter embedder engine, but plain dart support should follow soon).
the interop module makes great use of the qml/js interop functions and logic that were written to make `https://github.com/therecipe/entry` possible.
additional languages that are planned to be supported in the near future are: swift, kotlin and haxe (maybe with support for the c#, python and java targets, but if this isn't possible in some clean way then these languages will receive standalone bindings as well).
people using `therecipe/qt` from these new languages should then be able to use flutter (and dart) in combination with qt (and go/js) through this binding and also be able to easily communicate across the language barriers with the help of the interop functions.
the interop engine theoretically also makes a cgo-less `therecipe/qt` usage possible, which could be used to workaround the ever growing annoyances that are experienced when using cgo projects in combination with go modules.
the code for the custom flutter embedder that was created to make the flutter/dart binding work can be found in the `flutter` module. it currently only supports debug builds for the desktop targets, but if there is enough interest, then it shouldn't be too difficult to make release builds there, and on the mobile targets work as well (or even on "embedded" systems such as an raspberry pi for that matter).
an example repo how to use the new flutter/dart binding, will be published in the next few days.
  • Loading branch information
therecipe committed Jun 1, 2020
1 parent bb0c051 commit 4e7b870
Show file tree
Hide file tree
Showing 83 changed files with 9,572 additions and 154 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Mfile*
*/minimal_*
*/*.d.ts

interop/moc*

/internal/binding/dump/*
/internal/binding/runtime/moc*
/internal/cmd/moc/test/**/moc*
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
Introduction
------------

[Qt](https://en.wikipedia.org/wiki/Qt_(software)) is a cross-platform application framework that is used for developing application software that can be run on various software and hardware platforms with little or no change in the underlying codebase.
[Qt](https://en.wikipedia.org/wiki/Qt_(software)) is a free and open-source widget toolkit for creating graphical user interfaces as well as cross-platform applications that run on various software and hardware platforms with little or no change in the underlying codebase.

[Go](https://en.wikipedia.org/wiki/Go_(programming_language)) (often referred to as golang) is a programming language created at Google.
[Go](https://en.wikipedia.org/wiki/Go_(programming_language)), also known as Golang, is a programming language designed at Google.

This package allows you to write Qt applications entirely in Go and makes deploying them later very easy.
[therecipe/qt](https://github.com/therecipe/qt) allows you to write Qt applications entirely in Go or JavaScript.

[Gallery](https://github.com/therecipe/qt/wiki/Gallery) of example applications making use of this package.
Beside the language bindings provided, `therecipe/qt` also greatly simplifies the deployment of Qt applications to various software and hardware platforms.

[WebAssembly Demo (new)](https://therecipe.github.io/entry) | *[repo](https://github.com/therecipe/entry)*
At the time of writing, almost all Qt functions and classes are accessible from Go and JavaScript, and you should be able to find everything you need to build fully featured Qt applications.

[WebAssembly Demo (old)](https://therecipe.github.io/widgets_playground) | *[repo](https://github.com/therecipe/widgets_playground)*
Impressions
-----------

Status
------
[Gallery](https://github.com/therecipe/qt/wiki/Gallery) of example applications.

Almost all Qt functions and classes are accessible from Go and you should be able to find everything you need to build fully featured applications.
[JavaScript Demo](https://therecipe.github.io/entry) | *[source](https://github.com/therecipe/entry)*

Installation
------------

The following instructions assume that you already installed [Go](https://golang.org/dl/)

##### Windows [(more info)](https://github.com/therecipe/qt/wiki/Installation-on-Windows)

```powershell
Expand All @@ -43,7 +45,7 @@ export GO111MODULE=off; go get -v github.com/therecipe/qt/cmd/... && $(go env GO
Resources
---------

- [General Installation](https://github.com/therecipe/qt/wiki/Installation)
- [Installation](https://github.com/therecipe/qt/wiki/Installation)
- [Getting Started](https://github.com/therecipe/qt/wiki/Getting-Started)
- [Wiki](https://github.com/therecipe/qt/wiki)
- [Qt Documentation](https://doc.qt.io/qt-5/classes.html)
Expand Down Expand Up @@ -76,4 +78,4 @@ License

This package is released under [LGPLv3](https://opensource.org/licenses/LGPL-3.0)

Qt is available under multiple [licenses](https://www.qt.io/licensing)
Qt itself is licensed and available under multiple [licenses](https://www.qt.io/licensing).
21 changes: 14 additions & 7 deletions androidextras/androidextras.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func NewQAndroidActivityResultReceiverFromPointer(ptr unsafe.Pointer) (n *QAndro
return
}

func (ptr *QAndroidActivityResultReceiver) DestroyQAndroidActivityResultReceiver() {}
func (ptr *QAndroidActivityResultReceiver) DestroyQAndroidActivityResultReceiver() {
}

func (ptr *QAndroidActivityResultReceiver) ConnectHandleActivityResult(f func(receiverRequestCode int, resultCode int, data *QAndroidJniObject)) {

Expand Down Expand Up @@ -111,7 +112,8 @@ func NewQAndroidBinderFromPointer(ptr unsafe.Pointer) (n *QAndroidBinder) {
return
}

func (ptr *QAndroidBinder) DestroyQAndroidBinder() {}
func (ptr *QAndroidBinder) DestroyQAndroidBinder() {
}

//go:generate stringer -type=QAndroidBinder__CallType
//QAndroidBinder::CallType
Expand Down Expand Up @@ -180,7 +182,8 @@ func NewQAndroidIntentFromPointer(ptr unsafe.Pointer) (n *QAndroidIntent) {
return
}

func (ptr *QAndroidIntent) DestroyQAndroidIntent() {}
func (ptr *QAndroidIntent) DestroyQAndroidIntent() {
}

func NewQAndroidIntent() *QAndroidIntent {

Expand Down Expand Up @@ -1070,7 +1073,8 @@ func NewQAndroidParcelFromPointer(ptr unsafe.Pointer) (n *QAndroidParcel) {
return
}

func (ptr *QAndroidParcel) DestroyQAndroidParcel() {}
func (ptr *QAndroidParcel) DestroyQAndroidParcel() {
}

func NewQAndroidParcel() *QAndroidParcel {

Expand Down Expand Up @@ -1162,7 +1166,8 @@ func NewQAndroidServiceFromPointer(ptr unsafe.Pointer) (n *QAndroidService) {
return
}

func (ptr *QAndroidService) DestroyQAndroidService() {}
func (ptr *QAndroidService) DestroyQAndroidService() {
}

func NewQAndroidService(argc int, argv []string) *QAndroidService {

Expand Down Expand Up @@ -1324,7 +1329,8 @@ func NewQAndroidServiceConnectionFromPointer(ptr unsafe.Pointer) (n *QAndroidSer
return
}

func (ptr *QAndroidServiceConnection) DestroyQAndroidServiceConnection() {}
func (ptr *QAndroidServiceConnection) DestroyQAndroidServiceConnection() {
}

func NewQAndroidServiceConnection() *QAndroidServiceConnection {

Expand Down Expand Up @@ -1403,7 +1409,8 @@ func NewQtAndroidFromPointer(ptr unsafe.Pointer) (n *QtAndroid) {
return
}

func (ptr *QtAndroid) DestroyQtAndroid() {}
func (ptr *QtAndroid) DestroyQtAndroid() {
}

//go:generate stringer -type=QtAndroid__BindFlag
//QtAndroid::BindFlag
Expand Down
2 changes: 1 addition & 1 deletion androidextras/androidextras_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func cGoUnpackBytes(s C.struct_QtAndroidExtras_PackedString) []byte {
defer cGoFreePacked(s.ptr)
if int(s.len) == -1 {
gs := C.GoString(s.data)
return *(*[]byte)(unsafe.Pointer(&gs))
return []byte(gs)
}
return C.GoBytes(unsafe.Pointer(s.data), C.int(s.len))
}
Expand Down
2 changes: 1 addition & 1 deletion bluetooth/bluetooth.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func cGoUnpackBytes(s C.struct_QtBluetooth_PackedString) []byte {
defer cGoFreePacked(s.ptr)
if int(s.len) == -1 {
gs := C.GoString(s.data)
return *(*[]byte)(unsafe.Pointer(&gs))
return []byte(gs)
}
return C.GoBytes(unsafe.Pointer(s.data), C.int(s.len))
}
Expand Down
2 changes: 1 addition & 1 deletion charts/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func cGoUnpackBytes(s C.struct_QtCharts_PackedString) []byte {
defer cGoFreePacked(s.ptr)
if int(s.len) == -1 {
gs := C.GoString(s.data)
return *(*[]byte)(unsafe.Pointer(&gs))
return []byte(gs)
}
return C.GoBytes(unsafe.Pointer(s.data), C.int(s.len))
}
Expand Down
20 changes: 20 additions & 0 deletions core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12297,6 +12297,26 @@ long long QLibrary_LoadHints(void* ptr)
return static_cast<QLibrary*>(ptr)->loadHints();
}

void* QLibrary_Resolve(void* ptr, char* symbol)
{
return reinterpret_cast<void*>(static_cast<QLibrary*>(ptr)->resolve(const_cast<const char*>(symbol)));
}

void* QLibrary_QLibrary_Resolve2(struct QtCore_PackedString fileName, char* symbol)
{
return reinterpret_cast<void*>(QLibrary::resolve(QString::fromUtf8(fileName.data, fileName.len), const_cast<const char*>(symbol)));
}

void* QLibrary_QLibrary_Resolve3(struct QtCore_PackedString fileName, int verNum, char* symbol)
{
return reinterpret_cast<void*>(QLibrary::resolve(QString::fromUtf8(fileName.data, fileName.len), verNum, const_cast<const char*>(symbol)));
}

void* QLibrary_QLibrary_Resolve4(struct QtCore_PackedString fileName, struct QtCore_PackedString version, char* symbol)
{
return reinterpret_cast<void*>(QLibrary::resolve(QString::fromUtf8(fileName.data, fileName.len), QString::fromUtf8(version.data, version.len), const_cast<const char*>(symbol)));
}

void QLibrary_SetFileName(void* ptr, struct QtCore_PackedString fileName)
{
static_cast<QLibrary*>(ptr)->setFileName(QString::fromUtf8(fileName.data, fileName.len));
Expand Down
Loading

0 comments on commit 4e7b870

Please sign in to comment.