diff --git a/.all-contributorsrc b/.all-contributorsrc
new file mode 100644
index 00000000..56be9891
--- /dev/null
+++ b/.all-contributorsrc
@@ -0,0 +1,90 @@
+{
+ "projectName": "qmlnet",
+ "projectOwner": "qmlnet",
+ "repoType": "github",
+ "repoHost": "https://github.com",
+ "files": [
+ "README.md"
+ ],
+ "badgeTemplate": "[](#contributors)",
+ "imageSize": 100,
+ "commit": true,
+ "commitConvention": "none",
+ "contributors": [
+ {
+ "login": "devmil",
+ "name": "Michael Lamers",
+ "avatar_url": "https://avatars1.githubusercontent.com/u/6693130?v=4",
+ "profile": "http://www.devmil.de",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "TripleWhy",
+ "name": "TripleWhy",
+ "avatar_url": "https://avatars0.githubusercontent.com/u/2760830?v=4",
+ "profile": "https://ymueller.de",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "MaxMommersteeg",
+ "name": "Max",
+ "avatar_url": "https://avatars3.githubusercontent.com/u/9657173?v=4",
+ "profile": "https://github.com/MaxMommersteeg",
+ "contributions": [
+ "code",
+ "doc",
+ "financial"
+ ]
+ },
+ {
+ "login": "geigertom",
+ "name": "geigertom",
+ "avatar_url": "https://avatars0.githubusercontent.com/u/19152463?v=4",
+ "profile": "https://github.com/geigertom",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "jamesdavila",
+ "name": "James Davila",
+ "avatar_url": "https://avatars0.githubusercontent.com/u/1946041?v=4",
+ "profile": "https://github.com/jamesdavila",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "afillebrown",
+ "name": "Andy Fillebrown",
+ "avatar_url": "https://avatars2.githubusercontent.com/u/38264913?v=4",
+ "profile": "https://github.com/afillebrown",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "vadi2",
+ "name": "Vadim Peretokin",
+ "avatar_url": "https://avatars1.githubusercontent.com/u/110988?v=4",
+ "profile": "https://linkedin.com/in/vadimperetokin",
+ "contributions": [
+ "doc"
+ ]
+ },
+ {
+ "login": "Juhlinus",
+ "name": "Linus Juhlin",
+ "avatar_url": "https://avatars0.githubusercontent.com/u/12988164?v=4",
+ "profile": "https://github.com/Juhlinus",
+ "contributions": [
+ "doc"
+ ]
+ }
+ ],
+ "contributorsPerLine": 7
+}
diff --git a/.gitmodules b/.gitmodules
index 5a82fab5..fc02360a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "build/scripts/Buildary"]
path = build/scripts/Buildary
url = https://github.com/pauldotknopf/dotnet-buildary.git
+[submodule "src/native/QmlNet"]
+ path = src/native/QmlNet
+ url = https://github.com/qmlnet/qmlnet-native
diff --git a/.travis.yml b/.travis.yml
index feaf403e..238b2fdb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,16 +2,23 @@ language: csharp
mono: none
matrix:
include:
- - name: "Linux Qt 5.12.0"
- dotnet: 2.2
+ - name: "Linux Qt 5.15.1"
+ dotnet: 3.1
os: linux
dist: xenial
- - name: "OSX Qt 5.12.0"
- dotnet: 2.2.101
+ - name: "OSX Qt 5.15.1"
+ dotnet: 3.1.300
os: osx
osx_image: xcode9.4
if: tag IS blank
git:
depth: false
+before_install:
+ # to support running tests for .NET Core 2.1 LTS, install the runtime side-by-side
+ - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install dotnet-runtime-2.1 ; fi
+ # Copied from csharp.rb in the travis-build repo
+ - if [ "$TRAVIS_OS_NAME" = "osx" ]; then wget --retry-connrefused --waitretry=1 -O /tmp/dotnet.pkg https://download.visualstudio.microsoft.com/download/pr/bc303f50-ec1d-43b4-b846-51d5fc3c1a2d/4f0abfa496fba6a387dc80b450eb65b8/dotnet-runtime-2.1.18-osx-x64.pkg; fi
+ - if [ "$TRAVIS_OS_NAME" = "osx" ]; then sudo installer -package "/tmp/dotnet.pkg" -target "/" -verboseR; fi
+
script:
- ./build/travis.sh
\ No newline at end of file
diff --git a/README.md b/README.md
index 7deaf081..3fea237f 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
-# Qml.Net
+

-A Qml integration with .NET
+[](http://www.nuget.org/packages/Qml.Net/) [](https://travis-ci.com/qmlnet/qmlnet) [](https://ci.appveyor.com/project/pauldotknopf/qmlnet/) [](https://gitter.im/qmlnet/Lobby) [](#contributors) [](https://paypal.me/pauldotknopf)
-[](http://www.nuget.org/packages/Qml.Net/)
-[](https://travis-ci.com/qmlnet/qmlnet) [](https://ci.appveyor.com/project/pauldotknopf/qmlnet/branch/develop)
-[](https://gitter.im/qmlnet/Lobby) [](https://paypal.me/pauldotknopf)
+
+
+A Qt/Qml integration with .NET
Supported platforms/runtimes:
* Runtimes:
@@ -17,133 +17,157 @@ Supported platforms/runtimes:
* OSX
* Windows
+# First look
+
+
+
+# Elevator pitch
+
+* Proven in production.
+* Established GUI/control framework, used in many industries, from desktop to embedded.
+* Excellent community with many open-sourced controls available.
+* Native rendering, done in native code. No expensive PInvoke calls for rendering/animations/etc. The only interop between .NET and Qt is the data models used to drive the GUI.
+
# Documentation
-https://qmlnet.github.io/
+WIP: https://qmlnet.github.io/
# Getting started
```bash
dotnet add package Qml.Net
-```
-
-**Windows**
-
-```bash
dotnet add package Qml.Net.WindowsBinaries
-```
-
-**OSX**
-
-```bash
dotnet add package Qml.Net.OSXBinaries
-```
-
-**Linux**
-
-```bash
dotnet add package Qml.Net.LinuxBinaries
-```
+```
-Checkout the [examples](https://github.com/qmlnet/qmlnet-examples) for some inspiration.
+**Note for Linux users**: Package `libc6-dev` is required to be installed because it contains `libdl.so` that is needed.
+
+# Examples
+Checkout the [examples](https://github.com/qmlnet/qmlnet-examples) on how to do many things with Qml.Net.
# Quick overview
**Define a .NET type (POCO)**
```c#
-[Signal("customSignal", NetVariantType.String)] // You can define signals that Qml can listen to.
-public class QmlType
+//QmlType.cs
+using Qml.Net;
+using System.Threading.Tasks;
+
+namespace QmlQuickOverview
{
- ///
- /// Properties are exposed to Qml.
- ///
- [NotifySignal("stringPropertyChanged")] // For Qml binding/MVVM.
- public string StringProperty { get; set; }
+ [Signal("customSignal", NetVariantType.String)] // You can define signals that Qml can listen to.
+ public class QmlType
+ {
+ ///
+ /// Properties are exposed to Qml.
+ ///
+ [NotifySignal("stringPropertyChanged")] // For Qml binding/MVVM.
+ public string StringProperty { get; set; }
- ///
- /// Methods can return .NET types.
- /// The returned type can be invoked from Qml (properties/methods/events/etc).
- ///
- ///
- public QmlType CreateNetObject()
- {
- return new QmlType();
- }
-
- ///
- /// Qml can pass .NET types to .NET methods.
- ///
- ///
- public void TestMethod(QmlType parameter)
- {
- }
-
- ///
- /// Async methods can be invoked with continuations happening on Qt's main thread.
- ///
- public async Task TestAsync()
- {
- // On the UI thread
- await Task.Run(() =>
+ ///
+ /// Methods can return .NET types.
+ /// The returned type can be invoked from Qml (properties/methods/events/etc).
+ ///
+ ///
+ public QmlType CreateNetObject()
{
- // On the background thread
- });
- // On the UI thread
- return "async result!"
- }
-
- ///
- /// Qml can also pass Qml/C++ objects that can be invoked from .NET
- ///
- ///
- public void TestMethodWithQObject(dynamic o)
- {
- string result = o.PropertyDefinedInCpp;
- o.MethodDefinedInCpp(result);
+ return new QmlType();
+ }
+
+ ///
+ /// Qml can pass .NET types to .NET methods.
+ ///
+ ///
+ public void TestMethod(QmlType parameter)
+ {
+ }
- // You can also listen to signals on QObjects.
- var qObject = o as INetQObject.
- var handler = qObject.AttachSignal("signalName", parameters => {
- // parameters is a list of arguements passed to the signal.
- });
- handle.Dispose() // When you are done listening to signal.
+ ///
+ /// Async methods can be invoked with continuations happening on Qt's main thread.
+ ///
+ public async Task TestAsync()
+ {
+ // On the UI thread
+ await Task.Run(() =>
+ {
+ // On the background thread
+ });
+ // On the UI thread
+ return "async result!";
+ }
- // You can also listen to when a property changes (notify signal).
- var handler = qObject.AttachNotifySignal("propertySignal", parameters => {
- // parameters is a list of arguements passed to the signal.
- });
- handle.Dispose() // When you are done listening to signal.
- }
-
- ///
- /// .NET can activate signals to send notifications to Qml.
- ///
- public void ActivateCustomSignal(string message)
- {
- this.ActivateSignal("customSignal", message)
+ ///
+ /// Qml can also pass Qml/C++ objects that can be invoked from .NET
+ ///
+ ///
+ public void TestMethodWithQObject(dynamic o)
+ {
+ string result = o.propertyDefinedInCpp;
+ o.methodDefinedInCpp(result);
+
+ // You can also listen to signals on QObjects.
+ var qObject = o as INetQObject;
+ var handler = qObject.AttachSignal("signalName", parameters => {
+ // parameters is a list of arguements passed to the signal.
+ });
+ handler.Dispose(); // When you are done listening to signal.
+
+ // You can also listen to when a property changes (notify signal).
+ handler = qObject.AttachNotifySignal("property", parameters => {
+ // parameters is a list of arguements passed to the signal.
+ });
+ handler.Dispose(); // When you are done listening to signal.
+ }
+
+ ///
+ /// .NET can activate signals to send notifications to Qml.
+ ///
+ public void ActivateCustomSignal(string message)
+ {
+ this.ActivateSignal("customSignal", message);
+ }
}
}
+
```
**Register your new type with Qml.**
```c#
-using (var app = new QGuiApplication(args))
+//QmlExample.cs
+using Qml.Net;
+using Qml.Net.Runtimes;
+
+namespace QmlQuickOverview
{
- using (var engine = new QQmlApplicationEngine())
+ class QmlExample
{
- // Register our new type to be used in Qml
- QQmlApplicationEngine.RegisterType("test", 1, 1);
- engine.Load("main.qml");
- return app.Exec();
+ static int Main(string[] args)
+ {
+ RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();
+
+ using (var app = new QGuiApplication(args))
+ {
+ using (var engine = new QQmlApplicationEngine())
+ {
+ // Register our new type to be used in Qml
+ Qml.Net.Qml.RegisterType("test", 1, 1);
+ engine.Load("Main.qml");
+ return app.Exec();
+ }
+ }
+ }
}
}
+
```
**Use the .NET type in Qml**
```js
+//Main.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
@@ -205,8 +229,35 @@ ApplicationWindow {
- [x] Dynamically compiled delegates for increased performance.
- [x] Passing ```QObject``` types to .NET with support for interacting with signals/slots/properties on them.
-# Not implemented (but planned)
+There aren't really any important features missing that are needed for prime-time. This product is currently used on embedded devices in the medical industry.
-- [ ] Compiling Qml resource files and bundling them within .NET.
-- [ ] .NET Events to signals
-- [ ] Qml debugger for VS and VS Code.
+# Running Unit Tests
+
+The unit tests can be found in [src/native/Qml.Net.Tests](src/net/Qml.Net.Tests).
+
+They can be run directly from Visual Studio, or by using the `dotnet test` command line tool.
+
+Since the tests rely on the native QmlNet library, you have to ensure the library is in the `PATH` (on Windows) or otherwise discoverable. If you are trying to run tests against the native library built from the same repository, you can put the `src/native/output` folder into your `PATH` or `LD_LIBRARY_PATH` after running the `build.bat` or `build.sh` script.
+
+## Contributors ✨
+
+Thanks goes to these wonderful people!
+
+
+
+
+
+
diff --git a/appveyor.yml b/appveyor.yml
index f361ba77..92867245 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,10 +1,10 @@
-image: Visual Studio 2017
+image: Visual Studio 2019
before_build:
- - ps: Invoke-WebRequest -Uri https://github.com/qmlnet/qt-runtimes/releases/download/releases/qt-5.12.2-ad0689c-win-x64-dev.tar.gz -OutFile C:\qmlnet-qt.tar.gz
+ - ps: Invoke-WebRequest -Uri https://github.com/qmlnet/qt-runtimes/releases/download/releases/qt-5.15.1-7fc8b10-win-x64-dev.tar.gz -OutFile C:\qmlnet-qt.tar.gz
- cmd: 7z x C:\qmlnet-qt.tar.gz -oC:\
- cmd: 7z x C:\qmlnet-qt.tar -oC:\qmlnet-qt
- cmd: rm -r C:\Tools\GitVersion\
- - cmd: dotnet tool install -g GitVersion.Tool --version 4.0.1-beta1-58
+ - cmd: dotnet tool install -g GitVersion.Tool --version 5.3.4
- cmd: dotnet gitversion > version.json
- cmd: git submodule update --init
build_script:
diff --git a/build/appveyor.bat b/build/appveyor.bat
index 364d7877..fbe26f97 100644
--- a/build/appveyor.bat
+++ b/build/appveyor.bat
@@ -1,4 +1,4 @@
-call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
+call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
set PATH=%PATH%;C:\qmlnet-qt\qt\bin
set PATH=%PATH%;C:\qmlnet-qt\Tools\QtCreator\bin
diff --git a/build/scripts/Build.csproj b/build/scripts/Build.csproj
index e5870d50..3f3c3fb3 100644
--- a/build/scripts/Build.csproj
+++ b/build/scripts/Build.csproj
@@ -1,3 +1,6 @@
-
\ No newline at end of file
+
+ netcoreapp3.1
+
+
diff --git a/build/scripts/Buildary b/build/scripts/Buildary
index 02b50181..6df06b3f 160000
--- a/build/scripts/Buildary
+++ b/build/scripts/Buildary
@@ -1 +1 @@
-Subproject commit 02b50181ced2459ec3f5f7ee2cce1ffad4fe01b3
+Subproject commit 6df06b3ffa16f164adc18f8064917bf0c1a1229b
diff --git a/build/scripts/Program.cs b/build/scripts/Program.cs
index 7f34130e..18bc595d 100644
--- a/build/scripts/Program.cs
+++ b/build/scripts/Program.cs
@@ -18,14 +18,14 @@ namespace Build
{
static class Program
{
- static Task Main(string[] args)
+ static void Main(string[] args)
{
- var options = ParseOptions(args);
+ var options = ParseOptions(args);
var nugetApiKey = Environment.GetEnvironmentVariable("PRIVATE_NUGET_KEY");
var nugetSource = "https://www.myget.org/F/qmlnet/api/v3/index.json";
var gitversion = GetGitVersion(ExpandPath("./"));
- var commandBuildArgs = $"--configuration {options.Configuration} /p:Platform=\"Any CPU\"";
+ var commandBuildArgs = $"--configuration {options.Config} /p:Platform=\"Any CPU\"";
var commandBuildArgsWithVersion = commandBuildArgs;
if (!string.IsNullOrEmpty(gitversion.PreReleaseTag))
{
@@ -139,15 +139,7 @@ namespace Build
Target("ci", DependsOn("update-version", "build", "test", "deploy", "publish"));
- return Run(options);
- }
-
- // ReSharper disable ClassNeverInstantiated.Local
- class Options : RunnerOptions
- // ReSharper restore ClassNeverInstantiated.Local
- {
- [PowerArgs.ArgShortcut("config"), PowerArgs.ArgDefaultValue("Release")]
- public string Configuration { get; set; }
+ Execute(options);
}
}
}
diff --git a/build/travis.linux.sh b/build/travis.linux.sh
index 81dcf12e..e513008a 100755
--- a/build/travis.linux.sh
+++ b/build/travis.linux.sh
@@ -1,12 +1,14 @@
#!/usr/bin/env bash
+set -x
+
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
QT_DIR=$SCRIPT_DIR/Qt
sudo apt-get install -y libgl1-mesa-dev
mkdir -p $QT_DIR
-wget -O- -q https://github.com/qmlnet/qt-runtimes/releases/download/releases/qt-5.12.2-ad0689c-linux-x64-dev.tar.gz | tar xpz -C $QT_DIR
+wget -O- -q https://github.com/qmlnet/qt-runtimes/releases/download/releases/qt-5.15.1-7fc8b10-linux-x64-dev.tar.gz | tar xpz -C $QT_DIR
export PATH=$QT_DIR/qt/bin:$PATH
export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/src/native/output:$QT_DIR/qt/lib
diff --git a/build/travis.osx.sh b/build/travis.osx.sh
index fc32ab73..f6253ca2 100755
--- a/build/travis.osx.sh
+++ b/build/travis.osx.sh
@@ -5,7 +5,7 @@ SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
QT_DIR=$SCRIPT_DIR/Qt
mkdir -p $QT_DIR
-wget -O- -q https://github.com/qmlnet/qt-runtimes/releases/download/releases/qt-5.12.2-ad0689c-osx-x64-dev.tar.gz | tar xpz -C $QT_DIR
+wget -O- -q https://github.com/qmlnet/qt-runtimes/releases/download/releases/qt-5.15.1-7fc8b10-osx-x64-dev.tar.gz | tar xpz -C $QT_DIR
export PATH=$QT_DIR/qt/bin:$PATH
export DYLD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/src/native/output:$QT_DIR/qt/lib
diff --git a/build/travis.sh b/build/travis.sh
index f5ce4d02..091e922d 100755
--- a/build/travis.sh
+++ b/build/travis.sh
@@ -1,10 +1,11 @@
#!/usr/bin/env bash
set -e
+set -x
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# Before we run the build, get gitversion and generate a version.json.
-dotnet tool install -g GitVersion.Tool --version 4.0.1-beta1-58
+dotnet tool install -g GitVersion.Tool --version 5.3.4
export PATH="$PATH:$HOME/.dotnet/tools"
dotnet gitversion > version.json
diff --git a/samples/hosting/net/Program.cs b/samples/hosting/net/Program.cs
index ea29e3f8..536dee32 100644
--- a/samples/hosting/net/Program.cs
+++ b/samples/hosting/net/Program.cs
@@ -28,7 +28,7 @@ namespace NetHost
// Phase 6
// Register any .NET types that will be used.
- QQmlApplicationEngine.RegisterType("test");
+ Qml.Net.Qml.RegisterType("test", 1, 0);
// Phase 7
// This callback passes control back to C++ to perform
diff --git a/src/native/QmlNet b/src/native/QmlNet
new file mode 160000
index 00000000..e2ff9671
--- /dev/null
+++ b/src/native/QmlNet
@@ -0,0 +1 @@
+Subproject commit e2ff96713b659ed295710f4e94cef96b2f7e020a
diff --git a/src/native/QmlNet/Hosting.pri b/src/native/QmlNet/Hosting.pri
deleted file mode 100644
index df87f25e..00000000
--- a/src/native/QmlNet/Hosting.pri
+++ /dev/null
@@ -1,23 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += $$PWD/Hosting/coreclrhost.h \
- $$PWD/Hosting/CoreHost.h
-
-SOURCES += \
- $$PWD/Hosting/CoreHost.cpp
-
-unix {
- LIBS += -ldl
-}
-
-# These settings are needed to get symbols
-# for the current running process.
-macx {
- # nothing needed for OSX
-}
-unix:!macx {
- QMAKE_LFLAGS += -fPIC -rdynamic
-}
-win32 {
- QMAKE_LFLAGS += /FIXED:NO
-}
diff --git a/src/native/QmlNet/Hosting/CoreHost.cpp b/src/native/QmlNet/Hosting/CoreHost.cpp
deleted file mode 100644
index 41dacd33..00000000
--- a/src/native/QmlNet/Hosting/CoreHost.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#ifdef _WIN32
-#include
-#else
-#include
-#endif
-
-#ifdef __APPLE__
-#define HOSTFXR_DLL_NAME "libhostfxr.dylib"
-#elif _WIN32
-#define HOSTFXR_DLL_NAME "hostfxr.dll"
-#else
-#define HOSTFXR_DLL_NAME "libhostfxr.so"
-#endif
-
-static QString nativeModule;
-
-static void* getExportedFunction(const char* symbolName) {
-#ifdef _WIN32
- HMODULE library = GetModuleHandle(nativeModule.isNull() || nativeModule.isEmpty() ? nullptr
- : nativeModule.toLocal8Bit());
- FARPROC symbol = GetProcAddress(library, symbolName);
- return (void*)symbol;
-#else
- void* dll = dlopen(nativeModule.isNull() || nativeModule.isEmpty() ? nullptr : nativeModule.toLocal8Bit(),
- RTLD_LAZY);
- void* result = dlsym(dll, symbolName);
- dlclose(dll);
- return result;
-#endif
-}
-
-QList CoreHost::getPotientialDotnetRoots()
-{
- QList result;
-#ifdef _WIN32
- result.push_back("C:\\Program Files\\dotnet");
-#else
- result.push_back("/usr/local/share/dotnet");
- result.push_back("/usr/share/dotnet");
- result.push_back("/opt/dotnet");
-#endif
-
- QByteArray dotnetRoot = qgetenv("DOTNET_ROOT");
- if(!dotnetRoot.isEmpty()) {
- // We are overriding the roots, forcing ourselves to look in a particular spot.
- result.clear();
- result.push_back(dotnetRoot);
- }
-
- return result;
-}
-
-CoreHost::HostFxrContext CoreHost::findHostFxr()
-{
- HostFxrContext result;
- result.success = false;
-
- QList roots = getPotientialDotnetRoots();
-
- for(QString root : roots) {
- qDebug("looking for %s in root %s", HOSTFXR_DLL_NAME, qPrintable(root));
- if(!root.endsWith(QDir::separator())) {
- root.append(QDir::separator());
- }
-
- QFileInfo rootInfo(root);
- if(!rootInfo.exists()) {
- qDebug("%s doesn't exist", qPrintable(rootInfo.path()));
- continue;
- }
-
- QString host = root;
- host.append("host");
- host.append(QDir::separator());
- QFileInfo hostInfo(host);
- if(!hostInfo.exists()) {
- qDebug("%s doesn't exist", qPrintable(host));
- continue;
- }
-
- QString fxr = host;
- fxr.append("fxr");
- fxr.append(QDir::separator());
- QFileInfo fxrInfo(fxr);
- if(!fxrInfo.exists()) {
- qDebug("%s doesn't exist.", qPrintable(fxr));
- continue;
- }
-
- QString currentFxrLib;
- QVersionNumber currentFxrLibVersion;
-
- QDir fxrDir = fxrInfo.dir();
- fxrDir.setFilter(QDir::Dirs | QDir::NoDot | QDir::NoDotDot);
- QDirIterator it(fxrDir, QDirIterator::Subdirectories);
- while(it.hasNext()) {
- QString fxrVersion = it.next();
- QFileInfo fxrVersionInfo(fxrVersion);
-
- fxrVersion.append(QDir::separator());
- fxrVersion.append(HOSTFXR_DLL_NAME);
-
- QFileInfo fxrLibInfo(fxrVersion);
- if(!fxrLibInfo.exists()) {
- qDebug("%s doesn't exist", qPrintable(fxrLibInfo.absoluteFilePath()));
- continue;
- }
-
- QVersionNumber version = QVersionNumber::fromString(fxrVersionInfo.fileName());
- if(currentFxrLibVersion.isNull() || version > currentFxrLibVersion) {
- qDebug("found potentional file %s with version %s", qPrintable(fxrLibInfo.absoluteFilePath()), qPrintable((version.toString())));
- currentFxrLibVersion = version;
- currentFxrLib = fxrLibInfo.absoluteFilePath();
- } else {
- qDebug("ignore file %s with version %s", qPrintable(fxrLibInfo.absoluteFilePath()), qPrintable((version.toString())));
- }
- }
-
- if(!currentFxrLib.isEmpty()) {
- qDebug("returning hostfx lib: %s", qPrintable(currentFxrLib));
- result.success = true;
- result.hostFxrLib = currentFxrLib;
- result.dotnetRoot = root;
- return result;
- }
- }
-
- return result;
-}
-
-int CoreHost::run(QGuiApplication& app, QQmlApplicationEngine& engine, runCallback runCallback, RunContext runContext)
-{
- nativeModule = runContext.nativeModule;
-
- QList execArgs;
- execArgs.push_back(runContext.entryPoint);
- execArgs.push_back("exec");
- execArgs.push_back(runContext.managedExe);
-
- QString appPtr;
- appPtr.sprintf("%llu", (quintptr)&app);
- QString enginePtr;
- enginePtr.sprintf("%llu", (quintptr)&engine);
- QString callbackPtr;
- callbackPtr.sprintf("%llu", (quintptr)runCallback);
- QString exportedSymbolPointer;
- exportedSymbolPointer.sprintf("%llu", (quintptr)getExportedFunction);
-
- execArgs.push_back(appPtr);
- execArgs.push_back(enginePtr);
- execArgs.push_back(callbackPtr);
- execArgs.push_back(exportedSymbolPointer);
-
- for (QString arg : runContext.args) {
- execArgs.push_back(arg);
- }
-
- std::vector hostFxrArgs;
-
-#ifdef _WIN32
-
- for (QString arg : execArgs) {
- hostFxrArgs.push_back(arg.utf16());
- }
-
-#else
-
- QList execArgs8bit;
- for (QString arg : execArgs) {
- execArgs8bit.push_back(arg.toLocal8Bit());
- }
- for (QByteArray arg : execArgs8bit) {
- hostFxrArgs.push_back(arg);
- }
-
-#endif
-
- hostfxr_main_ptr hostfxr_main = nullptr;
-
-#ifdef _WIN32
-
- HMODULE dll = LoadLibraryA(qPrintable(runContext.hostFxrContext.hostFxrLib));
- if(dll == nullptr) {
- qCritical("Couldn't load lib at %s", qPrintable(runContext.hostFxrContext.hostFxrLib));
- return LoadHostFxrResult::Failed;
- }
-
- hostfxr_main = reinterpret_cast(GetProcAddress(dll, "hostfxr_main"));
-
-#else
-
- void* dll = dlopen(qPrintable(runContext.hostFxrContext.hostFxrLib), RTLD_NOW | RTLD_LOCAL);
- if(dll == nullptr) {
- qCritical("Couldn't load lib at %s", qPrintable(runContext.hostFxrContext.hostFxrLib));
- return LoadHostFxrResult::Failed;
- }
-
- hostfxr_main = reinterpret_cast(dlsym(dll, "hostfxr_main"));
-
-#endif
-
- if(hostfxr_main == nullptr) {
- qCritical("Couldn't load 'hostfxr_main' from %s", qPrintable(runContext.hostFxrContext.hostFxrLib));
- return -1;
- }
-
- int result = hostfxr_main(static_cast(hostFxrArgs.size()), &hostFxrArgs[0]);
-
-#ifdef _WIN32
- FreeLibrary(dll);
-#else
- dlclose(dll);
-#endif
-
- return result;
-}
diff --git a/src/native/QmlNet/Hosting/CoreHost.h b/src/native/QmlNet/Hosting/CoreHost.h
deleted file mode 100644
index d32394c2..00000000
--- a/src/native/QmlNet/Hosting/CoreHost.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef COREHOST_H
-#define COREHOST_H
-
-#include
-#include
-#include
-#include
-
-#ifdef _WIN32
-#define CORECLR_DOTNET_EXE_NAME "dotnet.exe"
-#else
-#define CORECLR_DOTNET_EXE_NAME "dotnet"
-#endif
-
-class CoreHost : public QObject
-{
- Q_OBJECT
-public:
- struct HostFxrContext {
- bool success;
- QString dotnetRoot;
- QString hostFxrLib;
- };
- struct RunContext {
- HostFxrContext hostFxrContext;
- QString entryPoint;
- QString managedExe;
- QList args;
- QString nativeModule;
- };
-
- enum LoadHostFxrResult
- {
- Loaded,
- AlreadyLoaded,
- Failed
- };
- typedef int (*runCallback)(QGuiApplication* app, QQmlApplicationEngine* engine);
-
- static QList getPotientialDotnetRoots();
- static HostFxrContext findHostFxr();
- static int run(QGuiApplication& app, QQmlApplicationEngine& engine, runCallback runCallback, RunContext runContext);
-};
-
-#endif
diff --git a/src/native/QmlNet/Hosting/coreclrhost.h b/src/native/QmlNet/Hosting/coreclrhost.h
deleted file mode 100644
index 1392fe68..00000000
--- a/src/native/QmlNet/Hosting/coreclrhost.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-// APIs for hosting CoreCLR
-//
-
-#ifndef CORECLR_HOST_H
-#define CORECLR_HOST_H
-
-#ifdef _WIN32
-typedef unsigned short CORECLR_CHAR_TYPE;
-#else
-typedef char CORECLR_CHAR_TYPE;
-#endif
-
-// For each hosting API, we define a function prototype and a function pointer
-// The prototype is useful for implicit linking against the dynamic coreclr
-// library and the pointer for explicit dynamic loading (dlopen, LoadLibrary)
-#define CORECLR_HOSTING_API(function, ...) \
- extern "C" int function(__VA_ARGS__); \
- typedef int (*function##_ptr)(__VA_ARGS__)
-
-CORECLR_HOSTING_API(coreclr_initialize,
- const char* exePath,
- const char* appDomainFriendlyName,
- int propertyCount,
- const char** propertyKeys,
- const char** propertyValues,
- void** hostHandle,
- unsigned int* domainId);
-
-CORECLR_HOSTING_API(coreclr_shutdown,
- void* hostHandle,
- unsigned int domainId);
-
-CORECLR_HOSTING_API(coreclr_shutdown_2,
- void* hostHandle,
- unsigned int domainId,
- int* latchedExitCode);
-
-CORECLR_HOSTING_API(coreclr_create_delegate,
- void* hostHandle,
- unsigned int domainId,
- const char* entryPointAssemblyName,
- const char* entryPointTypeName,
- const char* entryPointMethodName,
- void** delegate);
-
-CORECLR_HOSTING_API(coreclr_execute_assembly,
- void* hostHandle,
- unsigned int domainId,
- int argc,
- const char** argv,
- const char* managedAssemblyPath,
- unsigned int* exitCode);
-
-// hostfxr
-CORECLR_HOSTING_API(hostfxr_get_native_search_directories,
- const int argc,
- const char* argv[],
- char buffer[],
- int buffer_size,
- int* required_buffer_size);
-
-CORECLR_HOSTING_API(hostfxr_main_startupinfo,
- const int argc,
- const char* argv[],
- const char* host_path,
- const char* dotnet_root,
- const char* app_path);
-
-CORECLR_HOSTING_API(hostfxr_main,
- const int argc,
- const CORECLR_CHAR_TYPE* argv[]);
-
-#undef CORECLR_HOSTING_API
-
-#endif // CORECLR_HOST_H
diff --git a/src/native/QmlNet/QmlNet.cpp b/src/native/QmlNet/QmlNet.cpp
deleted file mode 100644
index 457d7791..00000000
--- a/src/native/QmlNet/QmlNet.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include
-
-extern "C" {
-
-long Q_DECL_EXPORT qml_net_getVersion()
-{
- // TODO: Return a proper version
- return 0;
-}
-
-}
diff --git a/src/native/QmlNet/QmlNet.h b/src/native/QmlNet/QmlNet.h
deleted file mode 100644
index 399e0266..00000000
--- a/src/native/QmlNet/QmlNet.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef QMLNET_GLOBAL_H
-#define QMLNET_GLOBAL_H
-
-#include
-
-#define NetGCHandle void
-
-#if _MSC_VER
- typedef const wchar_t* BCSTR;
- typedef const char* LPCSTR;
- typedef const char16_t* LPWCSTR;
- typedef char16_t* LPWSTR;
-#endif
-
-#if !_MSC_VER
- #define __declspec(dllexport)
- #define __stdcall
-
- typedef char16_t* BSTR;
- typedef const char16_t* BCSTR;
-
- typedef char* LPSTR;
- typedef const char* LPCSTR;
-
- typedef char16_t* LPWSTR;
- typedef const char16_t* LPWCSTR;
-
- #if UNICODE
- #define LPTSTR(value) (LPTSTR)u ##value;
- typedef LPWSTR LPTSTR;
- typedef LPWCSTR LPTCSTR;
- #else
- #define LPTSTR(value) value;
- typedef LPSTR LPTSTR;
- typedef LPCSTR LPTCSTR;
- #endif
-#endif
-
-enum NetVariantTypeEnum {
- NetVariantTypeEnum_Invalid = 0,
- NetVariantTypeEnum_Bool,
- NetVariantTypeEnum_Char,
- NetVariantTypeEnum_Int,
- NetVariantTypeEnum_UInt,
- NetVariantTypeEnum_Long,
- NetVariantTypeEnum_ULong,
- NetVariantTypeEnum_Float,
- NetVariantTypeEnum_Double,
- NetVariantTypeEnum_String,
- NetVariantTypeEnum_DateTime,
- NetVariantTypeEnum_Object,
- NetVariantTypeEnum_JSValue,
- NetVariantTypeEnum_QObject
-};
-
-
-#endif // QMLNET_GLOBAL_H
diff --git a/src/native/QmlNet/QmlNet.pri b/src/native/QmlNet/QmlNet.pri
deleted file mode 100644
index 73ab6b36..00000000
--- a/src/native/QmlNet/QmlNet.pri
+++ /dev/null
@@ -1,22 +0,0 @@
-QT += gui qml core-private quickcontrols2 widgets testlib
-
-CONFIG(enable-webengine) {
- QT += webengine
- DEFINES += QMLNET_WEBENGINE
-}
-
-CONFIG(qmlnet-trace) {
- DEFINES += QMLNET_TRACE
-}
-
-INCLUDEPATH += $$PWD
-
-HEADERS += $$PWD/QmlNet.h \
- $$PWD/QmlNetUtilities.h
-
-include (QmlNet/types/types.pri)
-include (QmlNet/qml/qml.pri)
-
-SOURCES += \
- $$PWD/QmlNet.cpp \
- $$PWD/QmlNetUtilities.cpp
diff --git a/src/native/QmlNet/QmlNet.pro b/src/native/QmlNet/QmlNet.pro
deleted file mode 100644
index e944e2e5..00000000
--- a/src/native/QmlNet/QmlNet.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2017-05-31T14:08:15
-#
-#-------------------------------------------------
-
-CONFIG += c++11
-CONFIG += plugin
-
-TARGET = QmlNet
-TEMPLATE = lib
-
-DEFINES += QMLNET_LIBRARY
-DEFINES += QT_DEPRECATED_WARNINGS
-
-include(QmlNet.pri)
-
-target.path = $$(PREFIX)/
-INSTALLS += target
diff --git a/src/native/QmlNet/QmlNet.user b/src/native/QmlNet/QmlNet.user
deleted file mode 100644
index 603f0f3d..00000000
--- a/src/native/QmlNet/QmlNet.user
+++ /dev/null
@@ -1,333 +0,0 @@
-
-
-
-
-
- EnvironmentId
- {e94916b6-9204-4c46-abdd-7020f311ebbb}
-
-
- ProjectExplorer.Project.ActiveTarget
- 0
-
-
- ProjectExplorer.Project.EditorSettings
-
- true
- false
- true
-
- Cpp
-
- CppGlobal
-
-
-
- QmlJS
-
- QmlJSGlobal
-
-
- 2
- UTF-8
- false
- 4
- false
- 80
- true
- true
- 1
- true
- false
- 0
- true
- true
- 0
- 8
- true
- 1
- true
- true
- true
- false
-
-
-
- ProjectExplorer.Project.PluginSettings
-
-
-
- ProjectExplorer.Project.Target.0
-
- Desktop Qt 5.11.1 clang 64bit
- Desktop Qt 5.11.1 clang 64bit
- qt.qt5.5111.clang_64_kit
- 0
- 0
- 0
-
- /Users/pknopf/Git/net-core-qml/src/native/build-QtNetCoreQml-Desktop_Qt_5_11_1_clang_64bit-Debug
-
-
- true
- qmake
-
- QtProjectManager.QMakeBuildStep
- true
-
- false
- false
- false
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- -w
- -r
-
- false
-
-
-
- 2
- Build
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- -w
- -r
-
- true
- clean
-
-
- 1
- Clean
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- Debug
- Debug
- Qt4ProjectManager.Qt4BuildConfiguration
- 2
- true
-
-
- /Users/pknopf/Git/net-core-qml/src/native/build-QtNetCoreQml-Desktop_Qt_5_11_1_clang_64bit-Release
-
-
- true
- qmake
-
- QtProjectManager.QMakeBuildStep
- false
-
- false
- false
- true
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- -w
- -r
-
- false
-
-
-
- 2
- Build
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- -w
- -r
-
- true
- clean
-
-
- 1
- Clean
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- Release
- Release
- Qt4ProjectManager.Qt4BuildConfiguration
- 0
- true
-
-
- /Users/pknopf/Git/net-core-qml/src/native/build-QtNetCoreQml-Desktop_Qt_5_11_1_clang_64bit-Profile
-
-
- true
- qmake
-
- QtProjectManager.QMakeBuildStep
- true
-
- false
- true
- true
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- -w
- -r
-
- false
-
-
-
- 2
- Build
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- -w
- -r
-
- true
- clean
-
-
- 1
- Clean
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- Profile
- Profile
- Qt4ProjectManager.Qt4BuildConfiguration
- 0
- true
-
- 3
-
-
- 0
- Deploy
-
- ProjectExplorer.BuildSteps.Deploy
-
- 1
- Deploy Configuration
-
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
-
- false
- false
- 1000
-
- true
-
- false
- false
- false
- false
- true
- 0.01
- 10
- true
- 1
- 25
-
- 1
- true
- false
- true
- valgrind
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
- 2
-
- /Users/pknopf/git/net-core-qml/src/net/Qt.NetCore.Sandbox/bin/Debug/netcoreapp2.2/Qt.NetCore.Sandbox.dll
- /usr/local/share/dotnet/dotnet
- /Users/pknopf/git/net-core-qml/src/net/Qt.NetCore.Sandbox
- Run /usr/local/share/dotnet/dotnet
-
- ProjectExplorer.CustomExecutableRunConfiguration
- 3768
- false
- true
- false
- false
- false
-
- 1
-
-
-
- ProjectExplorer.Project.TargetCount
- 1
-
-
- ProjectExplorer.Project.Updater.FileVersion
- 18
-
-
- Version
- 18
-
-
diff --git a/src/native/QmlNet/QmlNet/qml/JsNetObject.cpp b/src/native/QmlNet/QmlNet/qml/JsNetObject.cpp
deleted file mode 100644
index 6a8d0ed6..00000000
--- a/src/native/QmlNet/QmlNet/qml/JsNetObject.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-JsNetObject::JsNetObject() = default;
-
-QString JsNetObject::serialize(const QJSValue& value)
-{
- if(value.isNull() || value.isUndefined()) {
- qWarning() << "Net.serialize(): Instance parameter must not be null or undefined";
- return QString();
- }
-
- QSharedPointer netVaraint = NetVariant::fromQJSValue(value);
- if(netVaraint->getVariantType() != NetVariantTypeEnum_Object) {
- qWarning() << "Net.serialize(): Parameter is not a .NET object";
- return QString();
- }
-
- QSharedPointer result(new NetVariant());
- bool serializationResult = QmlNet::serializeNetToString(netVaraint->getNetReference(), result);
- if(!serializationResult) {
- qWarning() << "Net.serialize(): Could not serialize object.";
- return QString();
- }
-
- return result->getString();
-}
-
-QVariant JsNetObject::cancelTokenSource()
-{
- QSharedPointer typeInfo = NetTypeManager::getTypeInfo("System.Threading.CancellationTokenSource");
- if(typeInfo == nullptr) {
- qWarning() << "Couldn't get cancellation token type for platform, please file a bug";
- return QVariant();
- }
- QSharedPointer netReference = QmlNet::instantiateType(typeInfo);
- if(netReference == nullptr) {
- qWarning() << "Couldn't create cancellation token for platform, please file a bug";
- return QVariant();
- }
- QSharedPointer netVariant(new NetVariant());
- netVariant->setNetReference(netReference);
- return netVariant->toQVariant();
-}
-
-void JsNetObject::gcCollect(int maxGeneration)
-{
- QmlNet::gcCollect(maxGeneration);
-}
-
-QVariant JsNetObject::toListModel(const QJSValue& value)
-{
- if(value.isNull() || value.isUndefined()) {
- qWarning() << "Net.toListModel(): Instance parameter must not be null or undefined";
- return QVariant();
- }
-
- QSharedPointer netVaraint = NetVariant::fromQJSValue(value);
- if(netVaraint->getVariantType() != NetVariantTypeEnum_Object) {
- qWarning() << "Net.toListModel(): Parameter is not a .NET object";
- return QVariant();
- }
-
- NetListModel* listModel = NetListModel::fromReference(netVaraint->getNetReference());
- if(listModel == nullptr) {
- qWarning() << "Net.toListModel(): Parameter is not a type that can be wrapped by a list model.";
- return QVariant();
- }
-
- QQmlEngine::setObjectOwnership(listModel, QQmlEngine::JavaScriptOwnership);
- return QVariant::fromValue(listModel);
-}
-
-Q_INVOKABLE QVariant JsNetObject::listForEach(const QJSValue& value, QJSValue callback)
-{
- if(value.isNull() || value.isUndefined()) {
- qWarning() << "Net.listForEach(): Instance parameter must not be null or undefined";
- return QVariant();
- }
-
- if(callback.isNull() || callback.isUndefined()) {
- qWarning() << "Net.listForEach(): Callback must not be null or undefined";
- return QVariant();
- }
-
- if(!callback.isCallable()) {
- qWarning() << "Net.listForEach(): Callback is not a function";
- return QVariant();
- }
-
- QSharedPointer netVaraint = NetVariant::fromQJSValue(value);
- if(netVaraint->getVariantType() != NetVariantTypeEnum_Object) {
- qWarning() << "Net.listForEach(): Parameter is not a .NET object";
- return QVariant();
- }
-
- QSharedPointer netReference = netVaraint->getNetReference();
-
- QSharedPointer facade = netReference->getTypeInfo()->getArrayFacade();
- if(facade == nullptr) {
- qWarning() << "Net.listForEach(): Parameter is not a type that be enumerated.";
- return QVariant();
- }
-
- uint count = facade->getLength(netReference);
-
- for(uint x = 0; x < count; x++) {
- QSharedPointer item = facade->getIndexed(netReference, x);
- QJSValueList args;
- args.push_back(item->toQJSValue());
- args.push_back(sharedQmlEngine()->toScriptValue(QVariant::fromValue(x)));
- callback.call(args);
- }
-
- return QVariant::fromValue(count);
-}
-
-void JsNetObject::toJsArray()
-{
- qWarning() << "Net.toJsArray(): Not supported anymore. Use Net.toListModel().";
-}
-
-void JsNetObject::await(const QJSValue& task, const QJSValue& successCallback, const QJSValue& failureCallback)
-{
- if(task.isNull() || task.isUndefined()) {
- qWarning() << "Net.await(): No task object provided.";
- return;
- }
-
- if(successCallback.isNull() || successCallback.isUndefined()) {
- qWarning() << "Net.await(): Not success callback given";
- return;
- }
-
- if(!successCallback.isCallable()) {
- qWarning() << "Net.await(): Success callback invalid type.";
- return;
- }
-
- if(!failureCallback.isNull() && !failureCallback.isUndefined()) {
- if(!failureCallback.isCallable()) {
- qWarning() << "Net.await(): Failure callback invalid type.";
- return;
- }
- }
-
- QSharedPointer taskVariant = NetVariant::fromQJSValue(task);
- if(taskVariant->getVariantType() != NetVariantTypeEnum_Object) {
- qWarning() << "Net.await(): Task is invalid type.";
- return;
- }
-
- QSharedPointer successCallbackVariant = NetVariant::fromQJSValue(successCallback);
- QSharedPointer failureCallbackVariant = NetVariant::fromQJSValue(failureCallback);
- QmlNet::awaitTask(taskVariant->getNetReference(),
- successCallbackVariant->getJsValue(),
- failureCallbackVariant != nullptr ? failureCallbackVariant->getJsValue() : nullptr);
-}
diff --git a/src/native/QmlNet/QmlNet/qml/JsNetObject.h b/src/native/QmlNet/QmlNet/qml/JsNetObject.h
deleted file mode 100644
index c6db1c0c..00000000
--- a/src/native/QmlNet/QmlNet/qml/JsNetObject.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef JSNETOBJECT_H
-#define JSNETOBJECT_H
-
-#include
-#include
-#include
-#include
-
-class JsNetObject : public QObject
-{
- Q_OBJECT
-public:
- JsNetObject();
- Q_INVOKABLE QString serialize(const QJSValue& value);
- Q_INVOKABLE QVariant cancelTokenSource();
- Q_INVOKABLE void gcCollect(int maxGeneration = 0);
- Q_INVOKABLE QVariant toListModel(const QJSValue& value);
- Q_INVOKABLE QVariant listForEach(const QJSValue& value, QJSValue callback);
- Q_INVOKABLE void toJsArray();
- Q_INVOKABLE void await(const QJSValue& task, const QJSValue& successCallback, const QJSValue& failureCallback = QJSValue());
-};
-
-#endif // JSNETOBJECT_H
diff --git a/src/native/QmlNet/QmlNet/qml/NetJsValue.cpp b/src/native/QmlNet/QmlNet/qml/NetJsValue.cpp
deleted file mode 100644
index 8af1c871..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetJsValue.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-NetJSValue::NetJSValue(QJSValue jsValue) :
- _jsValue(std::move(jsValue))
-{
-
-}
-
-NetJSValue::~NetJSValue()
-{
- _jsValue.isCallable();
-}
-
-QJSValue NetJSValue::getJsValue()
-{
- return _jsValue;
-}
-
-bool NetJSValue::isCallable() const
-{
- return _jsValue.isCallable();
-}
-
-bool NetJSValue::isArray() const
-{
- return _jsValue.isArray();
-}
-
-QSharedPointer NetJSValue::call(const QSharedPointer& parameters)
-{
- QJSValueList jsValueList;
- if(parameters != nullptr) {
- for(int x = 0; x < parameters->count(); x++) {
- QSharedPointer netVariant = parameters->get(x);
- jsValueList.append(netVariant->toQJSValue());
- }
- }
-
- return NetVariant::fromQJSValue(_jsValue.call(jsValueList));
-}
-
-QSharedPointer NetJSValue::getProperty(const QString& propertyName)
-{
- QJSValue property = _jsValue.property(propertyName);
- return NetVariant::fromQJSValue(property);
-}
-
-QSharedPointer NetJSValue::getItemAtIndex(quint32 arrayIndex)
-{
- QJSValue property = _jsValue.property(arrayIndex);
- return NetVariant::fromQJSValue(property);
-}
-
-void NetJSValue::setProperty(const QString& propertyName, const QSharedPointer& variant)
-{
- QJSValue value = QJSValue::NullValue;
- if(variant != nullptr) {
- value = variant->toQJSValue();
- }
- _jsValue.setProperty(propertyName, value);
-}
-
-void NetJSValue::setItemAtIndex(quint32 arrayIndex, const QSharedPointer& variant)
-{
- QJSValue value = QJSValue::NullValue;
- if(variant != nullptr) {
- value = variant->toQJSValue();
- }
- _jsValue.setProperty(arrayIndex, value);
-}
-
-extern "C" {
-
-Q_DECL_EXPORT void net_js_value_destroy(NetJSValueContainer* jsValueContainer) {
- delete jsValueContainer;
-}
-
-Q_DECL_EXPORT uchar net_js_value_isCallable(NetJSValueContainer* jsValueContainer) {
- auto result = jsValueContainer->jsValue->isCallable();
- if (result) {
- return 1;
- } else {
- return 0;
- }
-}
-
-Q_DECL_EXPORT uchar net_js_value_isArray(NetJSValueContainer* jsValueContainer) {
- auto result = jsValueContainer->jsValue->isArray();
- if (result) {
- return 1;
- } else {
- return 0;
- }
-}
-
-Q_DECL_EXPORT NetVariantContainer* net_js_value_call(NetJSValueContainer* jsValueContainer, NetVariantListContainer* parametersContainer) {
- QSharedPointer parameters;
- if(parametersContainer != nullptr) {
- parameters = parametersContainer->list;
- }
- QSharedPointer result = jsValueContainer->jsValue->call(parameters);
- if(result != nullptr) {
- return new NetVariantContainer{result};
- }
- return nullptr;
-}
-
-Q_DECL_EXPORT NetVariantContainer* net_js_value_getProperty(NetJSValueContainer* jsValueContainer, LPWSTR propertyName) {
- QSharedPointer result = jsValueContainer->jsValue->getProperty(QString::fromUtf16(static_cast(propertyName)));
- if(result == nullptr) {
- return nullptr;
- }
- return new NetVariantContainer{result};
-}
-
-Q_DECL_EXPORT NetVariantContainer* net_js_value_getItemAtIndex(NetJSValueContainer* jsValueContainer, quint32 arrayIndex) {
- QSharedPointer result = jsValueContainer->jsValue->getItemAtIndex(arrayIndex);
- if(result == nullptr) {
- return nullptr;
- }
- return new NetVariantContainer{result};
-}
-
-Q_DECL_EXPORT void net_js_value_setProperty(NetJSValueContainer* jsValueContainer, LPWSTR propertyName, NetVariantContainer* valueContainer) {
- QSharedPointer value;
- if(valueContainer != nullptr) {
- value = valueContainer->variant;
- }
- jsValueContainer->jsValue->setProperty(QString::fromUtf16(static_cast(propertyName)), value);
-}
-
-Q_DECL_EXPORT void net_js_value_setItemAtIndex(NetJSValueContainer* jsValueContainer, quint32 arrayIndex, NetVariantContainer* valueContainer) {
- QSharedPointer value;
- if(valueContainer != nullptr) {
- value = valueContainer->variant;
- }
- jsValueContainer->jsValue->setItemAtIndex(arrayIndex, value);
-}
-
-}
diff --git a/src/native/QmlNet/QmlNet/qml/NetJsValue.h b/src/native/QmlNet/QmlNet/qml/NetJsValue.h
deleted file mode 100644
index 9120d430..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetJsValue.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef NETJSVALUE_H
-#define NETJSVALUE_H
-
-#include
-#include
-#include
-
-class NetVariant;
-class NetVariantList;
-
-class NetJSValue
-{
-public:
- NetJSValue(QJSValue jsValue);
- ~NetJSValue();
- QJSValue getJsValue();
- bool isCallable() const;
- bool isArray() const;
- QSharedPointer call(const QSharedPointer& parameters);
- QSharedPointer getProperty(const QString& propertyName);
- QSharedPointer getItemAtIndex(quint32 arrayIndex);
- void setProperty(const QString& propertyName, const QSharedPointer& variant);
- void setItemAtIndex(quint32 arrayIndex, const QSharedPointer& variant);
-private:
- QJSValue _jsValue;
-};
-
-struct NetJSValueContainer {
- QSharedPointer jsValue;
-};
-
-#endif // NETJSVALUE_H
diff --git a/src/native/QmlNet/QmlNet/qml/NetListModel.cpp b/src/native/QmlNet/QmlNet/qml/NetListModel.cpp
deleted file mode 100644
index 41a32d81..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetListModel.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-NetListModel::NetListModel(
- QObject* parent,
- QSharedPointer facade,
- QSharedPointer reference) :
- QAbstractListModel(parent),
- _facade(std::move(facade)),
- _reference(std::move(reference))
-{
-
-}
-
-NetListModel* NetListModel::fromReference(const QSharedPointer& reference)
-{
- QSharedPointer facade = reference->getTypeInfo()->getArrayFacade();
- if(facade == nullptr) {
- return nullptr;
- }
- return new NetListModel(nullptr, facade, reference);
-}
-
-QVariant NetListModel::data(const QModelIndex &index, int role) const
-{
- if(role != 0) {
- qWarning() << "invalid role id:" << role;
- return QVariant();
- }
- int length = static_cast(_facade->getLength(_reference));
- if (index.row() < 0 || index.row() >= length)
- return QVariant();
-
- QSharedPointer result = _facade->getIndexed(_reference, static_cast(index.row()));
- if(result == nullptr) {
- return QVariant();
- }
- return result->toQVariant();
-}
-
-int NetListModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return static_cast(_facade->getLength(_reference));
-}
-
-QHash NetListModel::roleNames() const
-{
- QHash roles;
- roles[0] = "modelData";
- return roles;
-}
-
-QVariant NetListModel::at(int index)
-{
- if(index < 0) {
- return QVariant();
- }
- int length = static_cast(_facade->getLength(_reference));
- if(index >= length) {
- return QVariant();
- }
- QSharedPointer result = _facade->getIndexed(_reference, static_cast(index));
- if(result == nullptr) {
- return QVariant();
- }
- return result->toQVariant();
-}
-
-int NetListModel::length()
-{
- return static_cast(_facade->getLength(_reference));
-}
diff --git a/src/native/QmlNet/QmlNet/qml/NetListModel.h b/src/native/QmlNet/QmlNet/qml/NetListModel.h
deleted file mode 100644
index 0c244da7..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetListModel.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef NETLISTMODEL_H
-#define NETLISTMODEL_H
-
-#include
-#include
-
-class NetTypeArrayFacade;
-class NetReference;
-
-class NetListModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- NetListModel(QObject* parent, QSharedPointer facade, QSharedPointer reference);
-
- static NetListModel* fromReference(const QSharedPointer& reference);
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QHash roleNames() const;
-
- Q_INVOKABLE QVariant at(int index);
- Q_INVOKABLE int length();
-
-private:
- QSharedPointer _facade;
- QSharedPointer _reference;
-};
-
-#endif // NETLISTMODEL_H
diff --git a/src/native/QmlNet/QmlNet/qml/NetQObject.cpp b/src/native/QmlNet/QmlNet/qml/NetQObject.cpp
deleted file mode 100644
index 2b210f98..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetQObject.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-NetQObject::NetQObject(QObject* qObject, bool ownsObject) :
- _qObject(qObject),
- _ownsObject(ownsObject)
-{
-
-}
-
-NetQObject::~NetQObject()
-{
- if(_ownsObject) {
- _qObject->deleteLater();
- }
-}
-
-QObject* NetQObject::getQObject()
-{
- return _qObject;
-}
-
-QSharedPointer NetQObject::getProperty(QString propertyName, bool* wasSuccess)
-{
- QSharedPointer netVariant;
- QByteArray propertyNameLocal = propertyName.toLocal8Bit();
-
- if(_qObject->metaObject()->indexOfProperty(propertyNameLocal.data()) == -1) {
- if(wasSuccess) {
- *wasSuccess = false;
- }
- return nullptr;
- }
-
- QVariant result = _qObject->property(propertyNameLocal.data());
- if(!result.isNull()) {
- netVariant = QSharedPointer(new NetVariant());
- NetVariant::fromQVariant(&result, netVariant);
- }
- if(wasSuccess) {
- *wasSuccess = true;
- }
- return netVariant;
-}
-
-void NetQObject::setProperty(QString propertyName, QSharedPointer value, bool* wasSuccess)
-{
- bool result;
- if(value == nullptr) {
- result = _qObject->setProperty(propertyName.toLocal8Bit().data(), QVariant());
- } else {
- result = _qObject->setProperty(propertyName.toLocal8Bit().data(), value->toQVariant());
- }
- if(wasSuccess) {
- *wasSuccess = result;
- }
-}
-
-QSharedPointer NetQObject::invokeMethod(QString methodName, QSharedPointer parameters, bool* wasSuccess)
-{
- int parameterCount = 0;
- if(parameters != nullptr) {
- parameterCount = parameters->count();
- }
-
- // Find the best method
- int methodIndex = -1;
- QMetaMethod method;
- for(int x = 0; x < _qObject->metaObject()->methodCount(); x++) {
- method = _qObject->metaObject()->method(x);
- if(method.methodType() == QMetaMethod::Slot || method.methodType() == QMetaMethod::Method) {
- if(methodName.compare(method.name()) == 0) {
- // make sure number of parameters match
- if(method.parameterCount() == parameterCount) {
- methodIndex = x;
- break;
- }
- }
- }
- }
-
- if(methodIndex == -1) {
- if(wasSuccess) {
- *wasSuccess = false;
- }
- return nullptr;
- }
-
- if(parameterCount > 10) {
- qWarning() << "Attempting to invoke a method with too many parameters: current: " << parameters->count() << " expected: <=10";
- if(wasSuccess) {
- *wasSuccess = false;
- }
- return nullptr;
- }
-
- NetQObjectArg returnValue(method.returnType());
- NetQObjectArg val0;
- NetQObjectArg val1;
- NetQObjectArg val2;
- NetQObjectArg val3;
- NetQObjectArg val4;
- NetQObjectArg val5;
- NetQObjectArg val6;
- NetQObjectArg val7;
- NetQObjectArg val8;
- NetQObjectArg val9;
-
- if(parameterCount >= 1) {
- val0 = NetQObjectArg(method.parameterType(0), parameters->get(0));
- }
- if(parameterCount >= 2) {
- val0 = NetQObjectArg(method.parameterType(1), parameters->get(1));
- }
- if(parameterCount >= 3) {
- val0 = NetQObjectArg(method.parameterType(2), parameters->get(2));
- }
- if(parameterCount >= 4) {
- val0 = NetQObjectArg(method.parameterType(3), parameters->get(3));
- }
- if(parameterCount >= 5) {
- val0 = NetQObjectArg(method.parameterType(4), parameters->get(4));
- }
- if(parameterCount >= 6) {
- val0 = NetQObjectArg(method.parameterType(5), parameters->get(5));
- }
- if(parameterCount >= 7) {
- val0 = NetQObjectArg(method.parameterType(6), parameters->get(6));
- }
- if(parameterCount >= 8) {
- val0 = NetQObjectArg(method.parameterType(7), parameters->get(7));
- }
- if(parameterCount >= 9) {
- val0 = NetQObjectArg(method.parameterType(8), parameters->get(8));
- }
- if(parameterCount >= 10) {
- val0 = NetQObjectArg(method.parameterType(9), parameters->get(9));
- }
-
- if(!method.invoke(_qObject,
- Qt::DirectConnection,
- returnValue.genericReturnArguemnet(),
- val0.genericArgument(),
- val1.genericArgument(),
- val2.genericArgument(),
- val3.genericArgument(),
- val4.genericArgument(),
- val5.genericArgument(),
- val6.genericArgument(),
- val7.genericArgument(),
- val8.genericArgument(),
- val9.genericArgument())) {
- if(wasSuccess) {
- *wasSuccess = false;
- }
- return nullptr;
- }
-
- if(wasSuccess) {
- *wasSuccess = true;
- }
-
- returnValue.unpack();
- return returnValue.getNetVariant();
-}
-
-QSharedPointer NetQObject::attachSignal(QString signalName, QSharedPointer delegate, bool* wasSucessful)
-{
- int signalMethodIndex = -1;
- QMetaMethod signalMethod;
- for(int x = 0; x <_qObject->metaObject()->methodCount(); x++) {
- signalMethod = _qObject->metaObject()->method(x);
- if(signalMethod.methodType() == QMetaMethod::Signal) {
- if(signalName.compare(signalMethod.name()) == 0) {
- signalMethodIndex = x;
- break;
- }
- }
- }
-
- // If signal not found, dump the registered signals for debugging.
- if(signalMethodIndex < 0) {
- if(wasSucessful) {
- *wasSucessful = false;
- }
- return nullptr;
- }
-
- QSharedPointer signalConnection = QSharedPointer(new NetQObjectSignalConnection(delegate, _qObject));
- QMetaObject::Connection connection = QObject::connect(_qObject,
- signalMethod,
- signalConnection.data(),
- signalConnection->getSignalHandler());
-
- if(!connection) {
- if(wasSucessful) {
- *wasSucessful = false;
- }
- return nullptr;
- }
-
- if(wasSucessful) {
- *wasSucessful = true;
- }
-
- return signalConnection;
-}
-
-QSharedPointer NetQObject::attachNotifySignal(QString propertyName, QSharedPointer delegate, bool* wasSuccessful)
-{
- int propertyIndex = _qObject->metaObject()->indexOfProperty(propertyName.toLocal8Bit().data());
- if(propertyIndex == -1) {
- if(wasSuccessful) {
- *wasSuccessful = false;
- }
- return nullptr;
- }
-
- QMetaProperty property = _qObject->metaObject()->property(propertyIndex);
-
- if(property.notifySignalIndex() == -1) {
- if(wasSuccessful) {
- *wasSuccessful = false;
- }
- return nullptr;
- }
-
- QSharedPointer signalConnection = QSharedPointer(new NetQObjectSignalConnection(delegate, _qObject));
- QMetaObject::Connection connection = QObject::connect(_qObject,
- property.notifySignal(),
- signalConnection.data(),
- signalConnection->getSignalHandler());
-
- if(!connection) {
- if(wasSuccessful) {
- *wasSuccessful = false;
- }
- return nullptr;
- }
-
- if(wasSuccessful) {
- *wasSuccessful = true;
- }
-
- return signalConnection;
-}
-
-extern "C" {
-
-Q_DECL_EXPORT void net_qobject_destroy(NetQObjectContainer* qObjectContainer)
-{
- delete qObjectContainer;
-}
-
-Q_DECL_EXPORT NetVariantContainer* net_qobject_getProperty(NetQObjectContainer* qObjectContainer, LPWCSTR propertyName, uchar* result)
-{
- bool wasSuccesful = false;
- auto value = qObjectContainer->qObject->getProperty(QString::fromUtf16(propertyName), &wasSuccesful);
- if(wasSuccesful) {
- *result = 1;
- } else {
- *result = 0;
- }
- if(value == nullptr) {
- return nullptr;
- }
- return new NetVariantContainer{ value };
-}
-
-Q_DECL_EXPORT void net_qobject_setProperty(NetQObjectContainer* qObjectContainer, LPWCSTR propertyName, NetVariantContainer* netVariantContainer, uchar* result)
-{
- bool wasSuccesful = false;
- if(netVariantContainer == nullptr) {
- qObjectContainer->qObject->setProperty(QString::fromUtf16(propertyName), nullptr, &wasSuccesful);
- } else {
- qObjectContainer->qObject->setProperty(QString::fromUtf16(propertyName), netVariantContainer->variant, &wasSuccesful);
- }
- if(wasSuccesful) {
- *result = 1;
- } else {
- *result = 0;
- }
-}
-
-Q_DECL_EXPORT NetVariantContainer* net_qobject_invokeMethod(NetQObjectContainer* qObjectContainer, LPWCSTR methodName, NetVariantListContainer* parametersContainer, uchar* result)
-{
- QSharedPointer parameters = nullptr;
- if(parametersContainer != nullptr) {
- parameters = parametersContainer->list;
- }
- bool wasSuccesful = false;
- auto value = qObjectContainer->qObject->invokeMethod(QString::fromUtf16(methodName), parameters, &wasSuccesful);
- if(wasSuccesful) {
- *result = 1;
- } else {
- *result = 0;
- }
- if(value == nullptr) {
- return nullptr;
- }
- return new NetVariantContainer { value };
-}
-
-Q_DECL_EXPORT NetQObjectSignalConnectionContainer* net_qobject_attachSignal(NetQObjectContainer* qObjectContainer, LPWCSTR signalName, NetReferenceContainer* delegate, uchar* result)
-{
- bool wasSuccesful = false;
- auto signalConnection = qObjectContainer->qObject->attachSignal(QString::fromUtf16(signalName), delegate->instance, &wasSuccesful);
- if(wasSuccesful) {
- *result = 1;
- } else {
- *result = 0;
- }
- if(signalConnection == nullptr) {
- return nullptr;
- }
- return new NetQObjectSignalConnectionContainer { signalConnection };
-}
-
-Q_DECL_EXPORT NetQObjectSignalConnectionContainer* net_qobject_attachNotifySignal(NetQObjectContainer* qObjectContainer, LPWCSTR propertyName, NetReferenceContainer* delegate, uchar* result)
-{
- bool wasSuccesful = false;
- auto signalConnection = qObjectContainer->qObject->attachNotifySignal(QString::fromUtf16(propertyName), delegate->instance, &wasSuccesful);
- if(wasSuccesful) {
- *result = 1;
- } else {
- *result = 0;
- }
- if(signalConnection == nullptr) {
- return nullptr;
- }
- return new NetQObjectSignalConnectionContainer { signalConnection };
-}
-
-Q_DECL_EXPORT void net_qobject_signal_handler_destroy(NetQObjectSignalConnectionContainer* signalContainer)
-{
- delete signalContainer;
-}
-
-}
diff --git a/src/native/QmlNet/QmlNet/qml/NetQObject.h b/src/native/QmlNet/QmlNet/qml/NetQObject.h
deleted file mode 100644
index 4fefb843..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetQObject.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef NETQOBJECT_H
-#define NETQOBJECT_H
-
-#include
-#include
-
-class NetVariant;
-class NetVariantList;
-class NetQObjectSignalConnection;
-class NetReference;
-
-class NetQObject
-{
-public:
- NetQObject(QObject* qObject, bool ownsObject = false);
- ~NetQObject();
- QObject* getQObject();
- QSharedPointer getProperty(QString propertyName, bool* wasSuccess);
- void setProperty(QString propertyName, QSharedPointer value, bool* wasSuccess);
- QSharedPointer invokeMethod(QString methodName, QSharedPointer parameters, bool* wasSuccess);
- QSharedPointer attachSignal(QString signalName, QSharedPointer delegate, bool* wasSuccess);
- QSharedPointer attachNotifySignal(QString propertyName, QSharedPointer delegate, bool* wasSuccess);
-private:
- QObject* _qObject;
- bool _ownsObject;
-};
-
-struct NetQObjectContainer {
- QSharedPointer qObject;
-};
-
-#endif // NETQOBJECT_H
diff --git a/src/native/QmlNet/QmlNet/qml/NetQObjectArg.cpp b/src/native/QmlNet/QmlNet/qml/NetQObjectArg.cpp
deleted file mode 100644
index 865ea10f..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetQObjectArg.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-#include
-#include
-#include
-
-NetQObjectArg::NetQObjectArg() :
- _metaTypeId(QMetaType::Void),
- _data(nullptr)
-{
- pack();
-}
-
-NetQObjectArg::NetQObjectArg(const int metaTypeId, QSharedPointer netVariant) :
- _metaTypeId(metaTypeId),
- _data(nullptr),
- _netVariant(netVariant)
-{
- pack();
-}
-
-NetQObjectArg::~NetQObjectArg()
-{
-}
-
-QGenericArgument NetQObjectArg::genericArgument()
-{
- if(_metaTypeId == QMetaType::Void) {
- return QGenericArgument();
- }
- if(_metaTypeId == QMetaType::QVariant) {
- return QGenericArgument("QVariant", &_variant);
- }
- return QGenericArgument(_variant.typeName(), _variant.data());
-}
-
-QGenericReturnArgument NetQObjectArg::genericReturnArguemnet()
-{
- if(_metaTypeId == QMetaType::Void) {
- return QGenericReturnArgument();
- }
- if(_metaTypeId == QMetaType::QVariant) {
- return QGenericReturnArgument("QVariant", &_variant);
- }
- return QGenericReturnArgument(_variant.typeName(), _variant.data());
-}
-
-QSharedPointer NetQObjectArg::getNetVariant()
-{
- return _netVariant;
-}
-
-void NetQObjectArg::pack()
-{
- if(_netVariant == nullptr) {
- switch(_metaTypeId) {
- case QMetaType::Void:
- break;
- case QMetaType::QVariant:
- _variant = QVariant();
- break;
- default:
- _variant = QVariant(_metaTypeId, nullptr);
- break;
- }
- return;
- }
-
- switch(_metaTypeId) {
- case QMetaType::Void:
- break;
- case QMetaType::QVariant:
- _variant = _netVariant->toQVariant();
- break;
- case QMetaType::Bool:
- _variant = QVariant::fromValue(_netVariant->getBool());
- break;
- case QMetaType::QChar:
- _variant = QVariant::fromValue(_netVariant->getChar());
- break;
- case qMetaTypeId():
- _variant = QVariant::fromValue(_netVariant->getInt());
- break;
- case qMetaTypeId():
- _variant = QVariant::fromValue(_netVariant->getUInt());
- break;
- case qMetaTypeId():
- _variant = QVariant::fromValue(_netVariant->getLong());
- break;
- case qMetaTypeId():
- _variant = QVariant::fromValue(_netVariant->getULong());
- break;
- case QMetaType::Long:
- _variant = QVariant::fromValue(static_cast(_netVariant->getLong()));
- break;
- case QMetaType::ULong:
- _variant = QVariant::fromValue(static_cast(_netVariant->getULong()));
- break;
- case QMetaType::Float:
- _variant = QVariant::fromValue(_netVariant->getFloat());
- break;
- case QMetaType::Double:
- _variant = QVariant::fromValue(_netVariant->getDouble());
- break;
- case QMetaType::QString:
- _variant = QVariant::fromValue(_netVariant->getString());
- break;
- case QMetaType::QDateTime:
- _variant = QVariant::fromValue(_netVariant->getDateTime());
- break;
- case QMetaType::QObjectStar:
- switch(_netVariant->getVariantType()) {
- case NetVariantTypeEnum_Invalid:
- _variant = QVariant::fromValue(nullptr);
- break;
- case NetVariantTypeEnum_Object:
- case NetVariantTypeEnum_QObject:
- _variant = _netVariant->toQVariant();
- break;
- default:
- qWarning() << "Unabled to convert " << _netVariant->getVariantType() << " to QObject*";
- break;
- }
- break;
- default:
- qWarning() << "Unsupported type: " << QMetaType::typeName(_metaTypeId);
- _variant = QVariant(_metaTypeId, nullptr);
- break;
- }
-}
-
-void NetQObjectArg::unpack()
-{
- if(_metaTypeId == QMetaType::Void) {
- return;
- }
- if(_netVariant == nullptr) {
- _netVariant = QSharedPointer(new NetVariant());
- }
- NetVariant::fromQVariant(&_variant, _netVariant);
-}
diff --git a/src/native/QmlNet/QmlNet/qml/NetQObjectArg.h b/src/native/QmlNet/QmlNet/qml/NetQObjectArg.h
deleted file mode 100644
index 42981a85..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetQObjectArg.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef NETQOBJECTARG_H
-#define NETQOBJECTARG_H
-
-#include
-#include
-
-class NetVariant;
-
-class NetQObjectArg
-{
-public:
- NetQObjectArg();
- NetQObjectArg(int metaTypeId, QSharedPointer netVariant = nullptr);
- ~NetQObjectArg();
- QGenericArgument genericArgument();
- QGenericReturnArgument genericReturnArguemnet();
- QSharedPointer getNetVariant();
- void pack();
- void unpack();
-private:
- int _metaTypeId;
- void* _data;
- int test;
- QVariant _variant;
- QSharedPointer _netVariant;
-};
-
-#endif // NETQOBJECTARG_H
diff --git a/src/native/QmlNet/QmlNet/qml/NetQObjectSignalConnection.cpp b/src/native/QmlNet/QmlNet/qml/NetQObjectSignalConnection.cpp
deleted file mode 100644
index 8b8a7fa5..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetQObjectSignalConnection.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-NetQObjectSignalConnectionBase::NetQObjectSignalConnectionBase()
-{
-
-}
-
-NetQObjectSignalConnectionBase::~NetQObjectSignalConnectionBase()
-{
-
-}
-
-QMetaMethod NetQObjectSignalConnectionBase::getSignalHandler()
-{
- return metaObject()->method(metaObject()->methodOffset());
-}
-
-void NetQObjectSignalConnectionBase::signalRaised()
-{
- // Dummy, handled in NetQObjectSignalConnection::qt_metacall()
-}
-
-NetQObjectSignalConnection::NetQObjectSignalConnection(QSharedPointer delegate,
- QObject* qObject)
- : _delegate(delegate),
- _qObject(qObject)
-{
-
-}
-
-NetQObjectSignalConnection::~NetQObjectSignalConnection()
-{
-
-}
-
-int NetQObjectSignalConnection::qt_metacall(QMetaObject::Call c, int id, void** a)
-{
- if(c == QMetaObject::InvokeMetaMethod) {
- int offset = this->metaObject()->methodOffset();
- if(id < offset) {
- return QObject::qt_metacall(c, id, a);
- }
-
- if(this->metaObject()->indexOfSlot("signalRaised()") == id) {
- QMetaMethod signal = _qObject->metaObject()->method(senderSignalIndex());
-
- // Convert signal args to QVariantList
- QSharedPointer netParameters = QSharedPointer(new NetVariantList());
- for (int i = 0; i < signal.parameterCount(); ++i) {
- QVariant arg = QVariant(signal.parameterType(i), a[i+1]);
- netParameters->add(NetVariant::fromQVariant(&arg));
- }
-
- QmlNet::invokeDelegate(_delegate, netParameters);
-
- return -1;
- }
- }
-
- return id;
-}
diff --git a/src/native/QmlNet/QmlNet/qml/NetQObjectSignalConnection.h b/src/native/QmlNet/QmlNet/qml/NetQObjectSignalConnection.h
deleted file mode 100644
index 7d36534f..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetQObjectSignalConnection.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef NETQOBJECTSIGNALCONNECTION_H
-#define NETQOBJECTSIGNALCONNECTION_H
-
-#include
-#include
-
-class NetReference;
-
-class NetQObjectSignalConnectionBase : public QObject
-{
- Q_OBJECT
-public:
- NetQObjectSignalConnectionBase();
- ~NetQObjectSignalConnectionBase();
- QMetaMethod getSignalHandler();
-public slots:
- void signalRaised();
-};
-
-class NetQObjectSignalConnection : public NetQObjectSignalConnectionBase
-{
-public:
- NetQObjectSignalConnection(QSharedPointer delegate, QObject* qObject);
- ~NetQObjectSignalConnection() override;
- int qt_metacall(QMetaObject::Call c, int id, void** a) override;
-private:
- QSharedPointer _delegate;
- QObject* _qObject;
-};
-
-struct NetQObjectSignalConnectionContainer {
- QSharedPointer signalConnection;
-};
-
-#endif // NETQOBJECTSIGNALCONNECTION_H
diff --git a/src/native/QmlNet/QmlNet/qml/NetTestHelper.cpp b/src/native/QmlNet/QmlNet/qml/NetTestHelper.cpp
deleted file mode 100644
index 55b36851..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetTestHelper.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-#include
-#include
-#include
-
-TestQObject::TestQObject()
- : QObject(nullptr),
- _writeOnly(0),
- _readAndWrite(0),
- _propWithSignal(0)
-{
-
-}
-
-TestQObject::~TestQObject()
-{
-
-}
-
-int TestQObject::getReadOnly()
-{
- return 3;
-}
-
-void TestQObject::setWriteOnly(int value)
-{
- _writeOnly = value;
-}
-
-int TestQObject::getReadAndWrite()
-{
- return _readAndWrite;
-}
-
-void TestQObject::setReadAndWrite(int value)
-{
- _readAndWrite = value;
-}
-
-int TestQObject::getPropWithSignal()
-{
- return _propWithSignal;
-}
-
-void TestQObject::setPropWithSignal(int value)
-{
- if(value == _propWithSignal) {
- return;
- }
- _propWithSignal = value;
- emit propWithSignalChanged(value);
-}
-
-QVariant TestQObject::getVariantProperty()
-{
- return _variantValue;
-}
-
-void TestQObject::setVariantProperty(QVariant value)
-{
- _variantValue = value;
-}
-
-void TestQObject::testSlot()
-{
- emit testSignal();
-}
-
-void TestQObject::testSlotWithArg(int arg)
-{
- emit testSignalWithArg(arg);
-}
-
-QVariant TestQObject::testVariantReturn()
-{
- return getVariantProperty();
-}
-
-bool TestQObject::testSlotBool(bool value)
-{
- emit testSignalBool(value);
- return value;
-}
-
-QChar TestQObject::testSlotChar(QChar value)
-{
- emit testSignalChar(value);
- return value;
-}
-
-int TestQObject::testSlotInt(int value)
-{
- emit testSignalInt(value);
- return value;
-}
-
-uint TestQObject::testSlotUInt(uint value)
-{
- emit testSignalUInt(value);
- return value;
-}
-
-long TestQObject::testSlotLong(long value)
-{
- emit testSignalLong(value);
- return value;
-}
-
-ulong TestQObject::testSlotULong(ulong value)
-{
- emit testSignalULong(value);
- return value;
-}
-
-float TestQObject::testSlotFloat(float value)
-{
- emit testSignalFloat(value);
- return value;
-}
-
-double TestQObject::testSlotDouble(double value)
-{
- emit testSignalDouble(value);
- return value;
-}
-
-QString TestQObject::testSlotString(QString value)
-{
- emit testSignalString(value);
- return value;
-}
-
-QDateTime TestQObject::testSlotDateTime(QDateTime value)
-{
- emit testSignalDateTime(value);
- return value;
-}
-
-QObject* TestQObject::testSlotQObject(QObject* value)
-{
- emit testSignalQObject(value);
- return value;
-}
-
-qint32 TestQObject::testSlotQInt32(qint32 value)
-{
- emit testSignalQInt32(value);
- return value;
-}
-
-quint32 TestQObject::testSlotQUInt32(quint32 value)
-{
- emit testSignalQUInt32(value);
- return value;
-}
-
-qint64 TestQObject::testSlotQInt64(qint64 value)
-{
- emit testSignalQInt64(value);
- return value;
-}
-
-quint64 TestQObject::testSlotQUInt64(quint64 value)
-{
- emit testSignalQUInt64(value);
- return value;
-}
-
-extern "C" {
-
-Q_DECL_EXPORT void net_test_helper_runQml(QQmlApplicationEngineContainer* qmlEngineContainer, LPWSTR qml) {
- QQmlComponent component(qmlEngineContainer->qmlEngine);
- QString qmlString = QString::fromUtf16(static_cast(qml));
- component.setData(qmlString.toUtf8(), QUrl());
-
- QObject *object = component.create();
-
- if(object == nullptr) {
- qWarning() << "Couldn't create qml object.";
- return;
- }
-
- QSharedPointer testQObject = QSharedPointer(new TestQObject());
- object->setProperty("testQObject", QVariant::fromValue(testQObject.data()));
- QMetaObject::invokeMethod(object, "runTest");
-
- delete object;
-}
-
-}
diff --git a/src/native/QmlNet/QmlNet/qml/NetTestHelper.h b/src/native/QmlNet/QmlNet/qml/NetTestHelper.h
deleted file mode 100644
index b889f93c..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetTestHelper.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef NETTESTHELPER_H
-#define NETTESTHELPER_H
-
-#include
-#include
-#include
-
-class TestQObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int readOnly READ getReadOnly)
- Q_PROPERTY(int writeOnly WRITE setWriteOnly)
- Q_PROPERTY(int readAndWrite READ getReadAndWrite WRITE setReadAndWrite)
- Q_PROPERTY(int propWithSignal READ getPropWithSignal WRITE setPropWithSignal NOTIFY propWithSignalChanged)
- Q_PROPERTY(QVariant variantProperty READ getVariantProperty WRITE setVariantProperty)
-public:
- TestQObject();
- ~TestQObject();
- int getReadOnly();
- void setWriteOnly(int value);
- int getReadAndWrite();
- void setReadAndWrite(int value);
- int getPropWithSignal();
- void setPropWithSignal(int value);
- QVariant getVariantProperty();
- void setVariantProperty(QVariant value);
-
-signals:
- void propWithSignalChanged(int value);
- void testSignal();
- void testSignalWithArg(int arg);
- void testSignalBool(bool value);
- void testSignalChar(QChar value);
- void testSignalInt(int value);
- void testSignalUInt(uint value);
- void testSignalLong(long value);
- void testSignalULong(ulong value);
- void testSignalFloat(float value);
- void testSignalDouble(double value);
- void testSignalString(QString value);
- void testSignalDateTime(QDateTime value);
- void testSignalQObject(QObject* qObject);
- void testSignalQInt32(qint32 value);
- void testSignalQUInt32(quint32 value);
- void testSignalQInt64(qint64 value);
- void testSignalQUInt64(quint64 value);
-
-public slots:
- void testSlot();
- void testSlotWithArg(int arg);
- QVariant testVariantReturn();
- bool testSlotBool(bool value);
- QChar testSlotChar(QChar value);
- int testSlotInt(int value);
- uint testSlotUInt(uint value);
- long testSlotLong(long value);
- ulong testSlotULong(ulong value);
- float testSlotFloat(float value);
- double testSlotDouble(double value);
- QString testSlotString(QString value);
- QDateTime testSlotDateTime(QDateTime value);
- QObject* testSlotQObject(QObject* value);
- qint32 testSlotQInt32(qint32 value);
- quint32 testSlotQUInt32(quint32 value);
- qint64 testSlotQInt64(qint64 value);
- quint64 testSlotQUInt64(quint64 value);
-private:
- int _writeOnly;
- int _readAndWrite;
- int _propWithSignal;
- QVariant _variantValue;
-};
-
-#endif // NETTESTHELPER_H
diff --git a/src/native/QmlNet/QmlNet/qml/NetValue.cpp b/src/native/QmlNet/QmlNet/qml/NetValue.cpp
deleted file mode 100644
index 81219a49..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetValue.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-NetValue::~NetValue()
-{
- auto objectId = instance->getObjectId();
- auto hit = objectIdNetValuesMap.find(objectId);
- if(hit != objectIdNetValuesMap.end()) {
- NetValueCollection* collection = hit.value();
- collection->netValues.removeOne(this);
- if(collection->netValues.length() == 0) {
- objectIdNetValuesMap.remove(objectId);
- delete collection;
- }
- }
-
- if(this->instance->getTypeInfo()->hasObjectDestroyed()){
- QmlNet::callObjectDestroyed(instance);
- }
-
-#ifdef QMLNET_TRACE
- qDebug("netvalue: destroyed: for: %s", qPrintable(instance->displayName()));
-#endif
- instance = nullptr;
-}
-
-
-QSharedPointer NetValue::getNetReference()
-{
- return instance;
-}
-
-bool NetValue::activateSignal(const QString& signalName, const QSharedPointer& arguments)
-{
- int signalMethodIndex = -1;
- for(int x = 0; valueMeta->methodCount(); x++) {
- QByteArray methodName = valueMeta->method(x).name();
- if(signalName.compare(methodName) == 0) {
- signalMethodIndex = x;
- break;
- }
- }
-
- // If signal not found, dump the registered signals for debugging.
- if(signalMethodIndex < 0) {
- qDebug() << "Signal not found:" << signalName;
- qDebug() << "Current signals:";
- for (int i = 0; i < metaObject()->methodCount(); i++) {
- QMetaMethod method = metaObject()->method(i);
- if (method.methodType() == QMetaMethod::Signal) {
- qDebug().nospace() << "\t" << method.methodSignature();
- }
- }
- return false;
- }
-
- // Build the types needed to activate the signal
- QList> variantArgs;
- std::vector voidArgs;
- voidArgs.push_back(nullptr); // For the return type, which is nothing for signals.
- if(arguments != nullptr) {
- for(int x = 0 ; x < arguments->count(); x++) {
- QSharedPointer variant(new QVariant(arguments->get(x)->toQVariant()));
- variantArgs.append(variant);
- voidArgs.push_back(static_cast(variant.data()));
- }
- }
- void** argsPointer = nullptr;
- if(!voidArgs.empty()) {
- argsPointer = &voidArgs[0];
- }
-
- // Activate the signal!
- NetValueMetaObject::activate(this, signalMethodIndex, argsPointer);
-
- return true;
-}
-
-NetValue* NetValue::forInstance(const QSharedPointer& instance)
-{
- NetValue* result = new NetValue(instance, nullptr);
- QQmlEngine::setObjectOwnership(result, QQmlEngine::JavaScriptOwnership);
- return result;
-}
-
-QList NetValue::getAllLiveInstances(const QSharedPointer& instance)
-{
- auto objectId = instance->getObjectId();
- NetValueCollection* collection = nullptr;
- auto hit = objectIdNetValuesMap.find(objectId);
- if(hit != objectIdNetValuesMap.end()) {
- collection = hit.value();
- return collection->netValues;
- }
- return QList();
-}
-
-void NetValue::classBegin()
-{
-
-}
-
-void NetValue::componentComplete()
-{
- if(this->instance->getTypeInfo()->hasComponentCompleted()){
- QmlNet::callComponentCompleted(instance);
- }
-}
-
-NetValue::NetValue(const QSharedPointer& instance, QObject *parent)
- : instance(instance)
-{
-#ifdef QMLNET_TRACE
- qDebug("netvalue: created: for: %s", qPrintable(instance->displayName()));
-#endif
-
- valueMeta = new NetValueMetaObject(this, instance);
- setParent(parent);
-
- auto objectId = instance->getObjectId();
- NetValueCollection* collection = nullptr;
- auto hit = objectIdNetValuesMap.find(objectId);
- if(hit != objectIdNetValuesMap.end()) {
- collection = hit.value();
- } else {
- collection = new NetValueCollection();
- objectIdNetValuesMap.insert(objectId, collection);
- }
- collection->netValues.append(this);
-
- QList> types;
-
- auto type = instance->getTypeInfo();
-
- while(type != nullptr) {
- types.insert(0, type);
- type = NetTypeManager::getBaseType(type);
- }
-
- for(QSharedPointer type : types) {
- for(int index = 0; index <= type->getSignalCount() - 1; index++) {
- QSharedPointer signalInfo = type->getSignal(index);
-
- QString signalSig = signalInfo->getSignature();
- QString slotSig = signalInfo->getSlotSignature();
-
- int signalIndex = valueMeta->indexOfSignal(signalSig.toLatin1().data());
- int slotIndex = valueMeta->indexOfSlot(slotSig.toLatin1().data());
-
- QMetaMethod signalMethod = valueMeta->method(signalIndex);
- QMetaMethod slotMethod = valueMeta->method(slotIndex);
-
- QObject::connect(this, signalMethod,
- this, slotMethod);
- }
- }
-}
-
-QMap NetValue::objectIdNetValuesMap = QMap();
diff --git a/src/native/QmlNet/QmlNet/qml/NetValue.h b/src/native/QmlNet/QmlNet/qml/NetValue.h
deleted file mode 100644
index 423620ee..00000000
--- a/src/native/QmlNet/QmlNet/qml/NetValue.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef NETVALUE_H
-#define NETVALUE_H
-
-#include