From 6ace3a1bb74b3f06210487795ac779ed8831f6f3 Mon Sep 17 00:00:00 2001 From: Paul Knopf Date: Sun, 23 Dec 2018 14:21:49 -0500 Subject: [PATCH] Removed the dependency of ADL. --- src/native/QmlNet/QmlNet/qml/NetJsValue.cpp | 14 +- src/native/QmlNet/QmlNet/qml/NetJsValue.h | 4 +- src/native/QmlNet/QmlNet/qml/NetValue.cpp | 7 + src/net/Qml.Net/Host.cs | 8 +- src/net/Qml.Net/Internal/DefaultCallbacks.cs | 3 - src/net/Qml.Net/Internal/Interop.cs | 266 +++++++++--------- .../LinuxDllImportLibraryPathResolver.cs | 8 +- .../MacDllImportLibraryPathResolver.cs | 8 +- .../Qml.Net/Internal/NativeSymbolAttribute.cs | 9 + src/net/Qml.Net/Internal/Qml/NetJsValue.cs | 33 ++- src/net/Qml.Net/Internal/Qml/NetTestHelper.cs | 6 +- src/net/Qml.Net/Internal/Qml/NetVariant.cs | 91 ++++-- .../Qml.Net/Internal/Qml/NetVariantList.cs | 26 +- src/net/Qml.Net/Internal/Types/Callbacks.cs | 23 +- src/net/Qml.Net/Internal/Types/NetDelegate.cs | 12 +- .../Qml.Net/Internal/Types/NetMethodInfo.cs | 43 ++- .../Qml.Net/Internal/Types/NetPropertyInfo.cs | 33 ++- .../Qml.Net/Internal/Types/NetReference.cs | 23 +- .../Qml.Net/Internal/Types/NetSignalInfo.cs | 25 +- src/net/Qml.Net/Internal/Types/NetTypeInfo.cs | 100 +++++-- .../Qml.Net/Internal/Types/NetTypeManager.cs | 6 +- .../WindowsDllImportLibraryPathResolver.cs | 10 +- src/net/Qml.Net/QGuiApplication.cs | 29 +- src/net/Qml.Net/QQmlApplicationEngine.cs | 39 ++- src/net/Qml.Net/QQuickStyle.cs | 15 +- src/net/Qml.Net/QResource.cs | 16 +- src/net/Qml.Net/Qml.Net.csproj | 3 +- src/net/Qml.Net/Qt.cs | 16 +- src/net/Qml.Net/QtWebEngine.cs | 6 +- src/net/Qml.Net/Utilities.cs | 6 +- 30 files changed, 524 insertions(+), 364 deletions(-) create mode 100644 src/net/Qml.Net/Internal/NativeSymbolAttribute.cs diff --git a/src/native/QmlNet/QmlNet/qml/NetJsValue.cpp b/src/native/QmlNet/QmlNet/qml/NetJsValue.cpp index 0bd712e7..60a0af08 100644 --- a/src/native/QmlNet/QmlNet/qml/NetJsValue.cpp +++ b/src/native/QmlNet/QmlNet/qml/NetJsValue.cpp @@ -23,12 +23,12 @@ QJSValue NetJSValue::getJsValue() return _jsValue; } -bool NetJSValue::isCallable() +bool NetJSValue::isCallable() const { return _jsValue.isCallable(); } -bool NetJSValue::isArray() +bool NetJSValue::isArray() const { return _jsValue.isArray(); } @@ -83,7 +83,15 @@ Q_DECL_EXPORT void net_js_value_destroy(NetJSValueContainer* jsValueContainer) { } Q_DECL_EXPORT bool net_js_value_isCallable(NetJSValueContainer* jsValueContainer) { - return jsValueContainer->jsValue->isCallable(); + // Weird bug here, maybe someone can help explain? + // If I were to make this method return "jsValueContainer->jsValue->isCallable()" + // directly, sometimes, in .NET the bool returned will be wrong. + // However, if I first set the bool on the stack, and return it, it (seems?) + // to always work. + // Also, this only seemed to happen after updating to Qt 5.12. + // I'm not sure what is going on here... + auto result = jsValueContainer->jsValue->isCallable(); + return result; } Q_DECL_EXPORT bool net_js_value_isArray(NetJSValueContainer* jsValueContainer) { diff --git a/src/native/QmlNet/QmlNet/qml/NetJsValue.h b/src/native/QmlNet/QmlNet/qml/NetJsValue.h index 7e9af9d6..9120d430 100644 --- a/src/native/QmlNet/QmlNet/qml/NetJsValue.h +++ b/src/native/QmlNet/QmlNet/qml/NetJsValue.h @@ -14,8 +14,8 @@ public: NetJSValue(QJSValue jsValue); ~NetJSValue(); QJSValue getJsValue(); - bool isCallable(); - bool isArray(); + bool isCallable() const; + bool isArray() const; QSharedPointer call(const QSharedPointer& parameters); QSharedPointer getProperty(const QString& propertyName); QSharedPointer getItemAtIndex(quint32 arrayIndex); diff --git a/src/native/QmlNet/QmlNet/qml/NetValue.cpp b/src/native/QmlNet/QmlNet/qml/NetValue.cpp index 1f0fbe84..213506a7 100644 --- a/src/native/QmlNet/QmlNet/qml/NetValue.cpp +++ b/src/native/QmlNet/QmlNet/qml/NetValue.cpp @@ -17,6 +17,9 @@ NetValue::~NetValue() delete collection; } } +#ifdef QMLNET_TRACE + qDebug("netvalue: destroyed: for: %s", qPrintable(instance->displayName())); +#endif instance = nullptr; } @@ -94,6 +97,10 @@ QList NetValue::getAllLiveInstances(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); diff --git a/src/net/Qml.Net/Host.cs b/src/net/Qml.Net/Host.cs index d09ba4db..ddd5f26b 100644 --- a/src/net/Qml.Net/Host.cs +++ b/src/net/Qml.Net/Host.cs @@ -1,14 +1,14 @@ using System; using System.Linq; using System.Runtime.InteropServices; -using AdvancedDLSupport; -using AdvancedDLSupport.Loaders; +using NetNativeLibLoader.Loader; +using NetNativeLibLoader.PathResolver; namespace Qml.Net { public static class Host { - internal class Loader : IPlatformLoader, ILibraryPathResolver + internal class Loader : IPlatformLoader, IPathResolver { public T LoadFunction(IntPtr library, string symbolName) { @@ -23,7 +23,7 @@ namespace Qml.Net public IntPtr LoadSymbol(IntPtr library, string symbolName) { - return new IntPtr(1); + return GetExportedSymbol(symbolName); } public bool CloseLibrary(IntPtr library) diff --git a/src/net/Qml.Net/Internal/DefaultCallbacks.cs b/src/net/Qml.Net/Internal/DefaultCallbacks.cs index 8867c18f..4a3a2641 100644 --- a/src/net/Qml.Net/Internal/DefaultCallbacks.cs +++ b/src/net/Qml.Net/Internal/DefaultCallbacks.cs @@ -3,9 +3,6 @@ using Qml.Net.Internal.Types; using System; using System.Collections; using System.Collections.Generic; -using System.Data.SqlTypes; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; diff --git a/src/net/Qml.Net/Internal/Interop.cs b/src/net/Qml.Net/Internal/Interop.cs index a4ecbd98..cbbd17a9 100644 --- a/src/net/Qml.Net/Internal/Interop.cs +++ b/src/net/Qml.Net/Internal/Interop.cs @@ -1,15 +1,13 @@ -using System; +using System; using System.IO; using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using AdvancedDLSupport; +using NetNativeLibLoader.Loader; +using NetNativeLibLoader.PathResolver; using Qml.Net.Internal.Qml; using Qml.Net.Internal.Types; -[assembly: InternalsVisibleTo("DLSupportDynamicAssembly")] - namespace Qml.Net.Internal { internal static class Interop @@ -22,86 +20,98 @@ namespace Qml.Net.Internal string qmlDirectory = null; string libDirectory = null; - ILibraryPathResolver pathResolver = null; + IPathResolver pathResolver = null; + IPlatformLoader loader = null; if (Host.GetExportedSymbol != null) { // We are loading exported functions from the currently running executable. - var member = (FieldInfo)typeof(NativeLibraryBase).GetMember("PlatformLoader", BindingFlags.Static | BindingFlags.NonPublic).First(); - member.SetValue(null, new Host.Loader()); pathResolver = new Host.Loader(); + loader = new Host.Loader(); } else { - var internalType = Type.GetType("AdvancedDLSupport.DynamicLinkLibraryPathResolver, AdvancedDLSupport"); - if (internalType != null) + pathResolver = new DynamicLinkLibraryPathResolver(); + loader = PlatformLoaderBase.SelectPlatformLoader(); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - pathResolver = (ILibraryPathResolver) Activator.CreateInstance(internalType, new object[] {true}); + // This custom path resolver attempts to do a DllImport to get the path that .NET decides. + // It may load a special dll from a NuGet package. + pathResolver = new WindowsDllImportLibraryPathResolver(pathResolver); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + pathResolver = new MacDllImportLibraryPathResolver(pathResolver); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + pathResolver = new LinuxDllImportLibraryPathResolver(pathResolver); + } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // This custom path resolver attempts to do a DllImport to get the path that .NET decides. - // It may load a special dll from a NuGet package. - pathResolver = new WindowsDllImportLibraryPathResolver(pathResolver); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - pathResolver = new MacDllImportLibraryPathResolver(pathResolver); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - pathResolver = new LinuxDllImportLibraryPathResolver(pathResolver); - } + var resolveResult = pathResolver.Resolve("QmlNet"); - var resolveResult = pathResolver.Resolve("QmlNet"); - - if (resolveResult.IsSuccess) + if (resolveResult.IsSuccess) + { + libDirectory = Path.GetDirectoryName(resolveResult.Path); + if (!string.IsNullOrEmpty(libDirectory)) { - libDirectory = Path.GetDirectoryName(resolveResult.Path); - if (!string.IsNullOrEmpty(libDirectory)) + // If this library has a plugins/qml directory below it, set it. + var potentialPlugisDirectory = Path.Combine(libDirectory, "plugins"); + if (Directory.Exists(potentialPlugisDirectory)) { - // If this library has a plugins/qml directory below it, set it. - var potentialPlugisDirectory = Path.Combine(libDirectory, "plugins"); - if (Directory.Exists(potentialPlugisDirectory)) - { - pluginsDirectory = potentialPlugisDirectory; - } - - var potentialQmlDirectory = Path.Combine(libDirectory, "qml"); - if (Directory.Exists(potentialQmlDirectory)) - { - qmlDirectory = potentialQmlDirectory; - } + pluginsDirectory = potentialPlugisDirectory; } + + var potentialQmlDirectory = Path.Combine(libDirectory, "qml"); + if (Directory.Exists(potentialQmlDirectory)) + { + qmlDirectory = potentialQmlDirectory; + } + } + } + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!string.IsNullOrEmpty(libDirectory) && Directory.Exists(libDirectory)) + { + // Even though we opened up the native dll correctly, we need to add + // the folder to the path. The reason is because QML plugins aren't + // in the same directory and have trouble finding dependencies + // that are within our lib folder. + Environment.SetEnvironmentVariable("PATH", + Environment.GetEnvironmentVariable("PATH") + $";{libDirectory}"); } } } + var result = pathResolver.Resolve("QmlNet"); - var builder = new NativeLibraryBuilder(pathResolver: pathResolver); - - var interop = builder.ActivateInterface("QmlNet"); + if (!result.IsSuccess) + { + throw new Exception("Couldn't find the native Qml.Net library."); + } + + var library = loader.LoadLibrary(result.Path); + Callbacks = LoadInteropType(library, loader); + NetTypeInfo = LoadInteropType(library, loader); + NetJsValue = LoadInteropType(library, loader); + NetMethodInfo = LoadInteropType(library, loader); + NetPropertyInfo = LoadInteropType(library, loader); + NetTypeManager = LoadInteropType(library, loader); + QGuiApplication = LoadInteropType(library, loader); + QQmlApplicationEngine = LoadInteropType(library, loader); + NetVariant = LoadInteropType(library, loader); + NetReference = LoadInteropType(library, loader); + NetVariantList = LoadInteropType(library, loader); + NetTestHelper = LoadInteropType(library, loader); + NetSignalInfo = LoadInteropType(library, loader); + QResource = LoadInteropType(library, loader); + NetDelegate = LoadInteropType(library, loader); + QQuickStyle = LoadInteropType(library, loader); + QtInterop = LoadInteropType(library, loader); + Utilities = LoadInteropType(library, loader); + QtWebEngine = LoadInteropType(library, loader); - Callbacks = interop; - NetTypeInfo = interop; - NetMethodInfo = interop; - NetPropertyInfo = interop; - NetTypeManager = interop; - QGuiApplication = interop; - QQmlApplicationEngine = interop; - NetVariant = interop; - NetReference = interop; - NetVariantList = interop; - NetTestHelper = interop; - NetSignalInfo = interop; - QResource = interop; - NetDelegate = interop; - NetJsValue = interop; - QQuickStyle = interop; - QtInterop = interop; - Utilities = interop; - QtWebEngine = interop; - if(!string.IsNullOrEmpty(pluginsDirectory)) { Qt.PutEnv("QT_PLUGIN_PATH", pluginsDirectory); @@ -111,87 +121,63 @@ namespace Qml.Net.Internal Qt.PutEnv("QML2_IMPORT_PATH", qmlDirectory); } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - if (!string.IsNullOrEmpty(libDirectory) && Directory.Exists(libDirectory)) - { - // Even though we opened up the native dll correctly, we need to add - // the folder to the path. The reason is because QML plugins aren't - // in the same directory and have trouble finding dependencies - // that are within our lib folder. - Environment.SetEnvironmentVariable("PATH", - Environment.GetEnvironmentVariable("PATH") + $";{libDirectory}"); - } - } - var cb = DefaultCallbacks.Callbacks(); Callbacks.RegisterCallbacks(ref cb); } - // ReSharper disable PossibleInterfaceMemberAmbiguity - // ReSharper disable MemberCanBePrivate.Global - internal interface ICombined : - // ReSharper restore MemberCanBePrivate.Global - // ReSharper restore PossibleInterfaceMemberAmbiguity - ICallbacksIterop, - INetTypeInfoInterop, - INetMethodInfoInterop, - INetPropertyInfoInterop, - INetTypeManagerInterop, - IQGuiApplicationInterop, - IQQmlApplicationEngine, - INetVariantInterop, - INetReferenceInterop, - INetVariantListInterop, - INetTestHelperInterop, - INetSignalInfoInterop, - IQResourceInterop, - INetDelegateInterop, - INetJsValueInterop, - IQQuickStyleInterop, - IQtInterop, - IUtilities, - IQtWebEngine - { + public static CallbacksInterop Callbacks { get; } + public static NetTypeInfoInterop NetTypeInfo { get; } + + public static NetMethodInfoInterop NetMethodInfo { get; } + + public static NetPropertyInfoInterop NetPropertyInfo { get; } + + public static NetTypeManagerInterop NetTypeManager { get; } + + public static QGuiApplicationInterop QGuiApplication { get; } + + public static QQmlApplicationEngineInterop QQmlApplicationEngine { get; } + + public static NetVariantInterop NetVariant { get; } + + public static NetReferenceInterop NetReference { get; } + + public static NetVariantListInterop NetVariantList { get; } + + public static NetTestHelperInterop NetTestHelper { get; } + + public static NetSignalInfoInterop NetSignalInfo { get; } + + public static QResourceInterop QResource { get; } + + public static NetDelegateInterop NetDelegate { get; } + + public static NetJsValueInterop NetJsValue { get; } + + public static QQuickStyleInterop QQuickStyle { get; } + + public static QtInterop QtInterop { get; } + + public static UtilitiesInterop Utilities { get; } + + public static QtWebEngineInterop QtWebEngine { get; } + + private static T LoadInteropType(IntPtr library, NetNativeLibLoader.Loader.IPlatformLoader loader) where T:new() + { + var result = new T(); + LoadDelegates(result, library, loader); + return result; } - public static ICallbacksIterop Callbacks { get; } - - public static INetTypeInfoInterop NetTypeInfo { get; } - - public static INetMethodInfoInterop NetMethodInfo { get; } - - public static INetPropertyInfoInterop NetPropertyInfo { get; } - - public static INetTypeManagerInterop NetTypeManager { get; } - - public static IQGuiApplicationInterop QGuiApplication { get; } - - public static IQQmlApplicationEngine QQmlApplicationEngine { get; } - - public static INetVariantInterop NetVariant { get; } - - public static INetReferenceInterop NetReference { get; } - - public static INetVariantListInterop NetVariantList { get; } - - public static INetTestHelperInterop NetTestHelper { get; } - - public static INetSignalInfoInterop NetSignalInfo { get; } - - public static IQResourceInterop QResource { get; } - - public static INetDelegateInterop NetDelegate { get; } - - public static INetJsValueInterop NetJsValue { get; } - - public static IQQuickStyleInterop QQuickStyle { get; } - - public static IQtInterop QtInterop { get; } - - public static IUtilities Utilities { get; } - - public static IQtWebEngine QtWebEngine { get; } + private static void LoadDelegates(object o, IntPtr library, NetNativeLibLoader.Loader.IPlatformLoader loader) + { + foreach (var property in o.GetType().GetProperties()) + { + var entryName = property.GetCustomAttributes().OfType().First().Entrypoint; + var symbol = loader.LoadSymbol(library, entryName); + property.SetValue(o, Marshal.GetDelegateForFunctionPointer(symbol, property.PropertyType)); + } + } } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/LinuxDllImportLibraryPathResolver.cs b/src/net/Qml.Net/Internal/LinuxDllImportLibraryPathResolver.cs index 54551962..a3efab20 100644 --- a/src/net/Qml.Net/Internal/LinuxDllImportLibraryPathResolver.cs +++ b/src/net/Qml.Net/Internal/LinuxDllImportLibraryPathResolver.cs @@ -2,15 +2,15 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; -using AdvancedDLSupport; +using NetNativeLibLoader.PathResolver; namespace Qml.Net.Internal { - public class LinuxDllImportLibraryPathResolver : ILibraryPathResolver + public class LinuxDllImportLibraryPathResolver : IPathResolver { - ILibraryPathResolver _original; + IPathResolver _original; - public LinuxDllImportLibraryPathResolver(ILibraryPathResolver original) + public LinuxDllImportLibraryPathResolver(IPathResolver original) { _original = original; } diff --git a/src/net/Qml.Net/Internal/MacDllImportLibraryPathResolver.cs b/src/net/Qml.Net/Internal/MacDllImportLibraryPathResolver.cs index bc875434..fc2c82d5 100644 --- a/src/net/Qml.Net/Internal/MacDllImportLibraryPathResolver.cs +++ b/src/net/Qml.Net/Internal/MacDllImportLibraryPathResolver.cs @@ -1,15 +1,15 @@ using System; using System.IO; using System.Runtime.InteropServices; -using AdvancedDLSupport; +using NetNativeLibLoader.PathResolver; namespace Qml.Net.Internal { - public class MacDllImportLibraryPathResolver : ILibraryPathResolver + public class MacDllImportLibraryPathResolver : IPathResolver { - ILibraryPathResolver _original; + IPathResolver _original; - public MacDllImportLibraryPathResolver(ILibraryPathResolver original) + public MacDllImportLibraryPathResolver(IPathResolver original) { _original = original; } diff --git a/src/net/Qml.Net/Internal/NativeSymbolAttribute.cs b/src/net/Qml.Net/Internal/NativeSymbolAttribute.cs new file mode 100644 index 00000000..1b568e15 --- /dev/null +++ b/src/net/Qml.Net/Internal/NativeSymbolAttribute.cs @@ -0,0 +1,9 @@ +using System; + +namespace Qml.Net.Internal +{ + public class NativeSymbolAttribute : Attribute + { + public string Entrypoint { get; set; } + } +} diff --git a/src/net/Qml.Net/Internal/Qml/NetJsValue.cs b/src/net/Qml.Net/Internal/Qml/NetJsValue.cs index 25199342..edae6663 100644 --- a/src/net/Qml.Net/Internal/Qml/NetJsValue.cs +++ b/src/net/Qml.Net/Internal/Qml/NetJsValue.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.Dynamic; -using System.Linq; using System.Runtime.InteropServices; -using AdvancedDLSupport; namespace Qml.Net.Internal.Qml { @@ -192,22 +189,34 @@ namespace Qml.Net.Internal.Qml } } - internal interface INetJsValueInterop + internal class NetJsValueInterop { [NativeSymbol(Entrypoint = "net_js_value_destroy")] - void Destroy(IntPtr jsValue); - + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr jsValue); + [NativeSymbol(Entrypoint = "net_js_value_isCallable")] - bool IsCallable(IntPtr jsValue); + public IsCallableDel IsCallable { get; set; } + public delegate bool IsCallableDel(IntPtr jsValue); + [NativeSymbol(Entrypoint = "net_js_value_isArray")] - bool IsArray(IntPtr jsValue); + public IsArrayDel IsArray { get; set; } + public delegate bool IsArrayDel(IntPtr jsValue); + [NativeSymbol(Entrypoint = "net_js_value_call")] - IntPtr Call(IntPtr jsValue, IntPtr parameters); + public CallDel Call { get; set; } + public delegate IntPtr CallDel(IntPtr jsValue, IntPtr parameters); + [NativeSymbol(Entrypoint = "net_js_value_getProperty")] - IntPtr GetProperty(IntPtr jsValue, [MarshalAs(UnmanagedType.LPWStr), CallerFree] string propertyName); + public GetPropertyDel GetProperty { get; set; } + public delegate IntPtr GetPropertyDel(IntPtr jsValue, [MarshalAs(UnmanagedType.LPWStr)] string propertyName); + [NativeSymbol(Entrypoint = "net_js_value_getItemAtIndex")] - IntPtr GetItemAtIndex(IntPtr jsValue, int arrayIndex); + public GetItemAtIndexDel GetItemAtIndex { get; set; } + public delegate IntPtr GetItemAtIndexDel(IntPtr jsValue, int arrayIndex); + [NativeSymbol(Entrypoint = "net_js_value_setProperty")] - void SetProperty(IntPtr jsValue, [MarshalAs(UnmanagedType.LPWStr), CallerFree] string propertyName, IntPtr value); + public SetPropertyDel SetProperty { get; set; } + public delegate void SetPropertyDel(IntPtr jsValue, [MarshalAs(UnmanagedType.LPWStr)] string propertyName, IntPtr value); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/Qml/NetTestHelper.cs b/src/net/Qml.Net/Internal/Qml/NetTestHelper.cs index 6276c0fd..e2e09dda 100644 --- a/src/net/Qml.Net/Internal/Qml/NetTestHelper.cs +++ b/src/net/Qml.Net/Internal/Qml/NetTestHelper.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; namespace Qml.Net.Internal.Qml { @@ -12,9 +11,10 @@ namespace Qml.Net.Internal.Qml } } - internal interface INetTestHelperInterop + internal class NetTestHelperInterop { [NativeSymbol(Entrypoint = "net_test_helper_runQml")] - void RunQml(IntPtr qmlEngine, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string qml); + public RunQmlDel RunQml { get; set; } + public delegate void RunQmlDel(IntPtr qmlEngine, [MarshalAs(UnmanagedType.LPWStr)]string qml); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/Qml/NetVariant.cs b/src/net/Qml.Net/Internal/Qml/NetVariant.cs index c9d3a2e2..bc7fc234 100644 --- a/src/net/Qml.Net/Internal/Qml/NetVariant.cs +++ b/src/net/Qml.Net/Internal/Qml/NetVariant.cs @@ -1,6 +1,5 @@ -using System; +using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; using Qml.Net.Internal.Types; namespace Qml.Net.Internal.Qml @@ -147,78 +146,108 @@ namespace Qml.Net.Internal.Qml } } - internal interface INetVariantInterop + internal class NetVariantInterop { [NativeSymbol(Entrypoint = "net_variant_create")] - IntPtr Create(); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(); + [NativeSymbol(Entrypoint = "net_variant_destroy")] - void Destroy(IntPtr variant); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_getVariantType")] - NetVariantType GetVariantType(IntPtr variant); + public GetVariantTypeDel GetVariantType { get; set; } + public delegate NetVariantType GetVariantTypeDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setNetReference")] - void SetNetReference(IntPtr variant, IntPtr instance); + public SetNetReferenceDel SetNetReference { get; set; } + public delegate void SetNetReferenceDel(IntPtr variant, IntPtr instance); + [NativeSymbol(Entrypoint = "net_variant_getNetReference")] - IntPtr GetNetReference(IntPtr variant); + public GetNetReferenceDel GetNetReference { get; set; } + public delegate IntPtr GetNetReferenceDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setBool")] - void SetBool(IntPtr variant, bool value); + public SetBoolDel SetBool { get; set; } + public delegate void SetBoolDel(IntPtr variant, bool value); [NativeSymbol(Entrypoint = "net_variant_getBool")] - bool GetBool(IntPtr variant); + public GetBoolDel GetBool { get; set; } + public delegate bool GetBoolDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setChar")] - void SetChar(IntPtr variant, ushort value); + public SetCharDel SetChar { get; set; } + public delegate void SetCharDel(IntPtr variant, ushort value); [NativeSymbol(Entrypoint = "net_variant_getChar")] - ushort GetChar(IntPtr variant); + public GetCharDel GetChar { get; set; } + public delegate ushort GetCharDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setInt")] - void SetInt(IntPtr variant, int value); + public SetIntDel SetInt { get; set; } + public delegate void SetIntDel(IntPtr variant, int value); [NativeSymbol(Entrypoint = "net_variant_getInt")] - int GetInt(IntPtr variant); + public GetIntDel GetInt { get; set; } + public delegate int GetIntDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setUInt")] - void SetUInt(IntPtr variant, uint value); + public SetUIntDel SetUInt { get; set; } + public delegate void SetUIntDel(IntPtr variant, uint value); [NativeSymbol(Entrypoint = "net_variant_getUInt")] - uint GetUInt(IntPtr variant); + public GetUIntDel GetUInt { get; set; } + public delegate uint GetUIntDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setLong")] - void SetLong(IntPtr variant, long value); + public SetLongDel SetLong { get; set; } + public delegate void SetLongDel(IntPtr variant, long value); [NativeSymbol(Entrypoint = "net_variant_getLong")] - long GetLong(IntPtr variant); + public GetLongDel GetLong { get; set; } + public delegate long GetLongDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setULong")] - void SetULong(IntPtr variant, ulong value); + public SetULongDel SetULong { get; set; } + public delegate void SetULongDel(IntPtr variant, ulong value); [NativeSymbol(Entrypoint = "net_variant_getULong")] - ulong GetULong(IntPtr variant); + public GetULongDel GetULong { get; set; } + public delegate ulong GetULongDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setFloat")] - void SetFloat(IntPtr variant, float value); + public SetFloatDel SetFloat { get; set; } + public delegate void SetFloatDel(IntPtr variant, float value); [NativeSymbol(Entrypoint = "net_variant_getFloat")] - float GetFloat(IntPtr variant); + public GetFloatDel GetFloat { get; set; } + public delegate float GetFloatDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setDouble")] - void SetDouble(IntPtr variant, double value); + public SetDoubleDel SetDouble { get; set; } + public delegate void SetDoubleDel(IntPtr variant, double value); [NativeSymbol(Entrypoint = "net_variant_getDouble")] - double GetDouble(IntPtr variant); + public GetDoubleDel GetDouble { get; set; } + public delegate double GetDoubleDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setString")] - void SetString(IntPtr variant, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string value); + public SetStringDel SetString { get; set; } + public delegate void SetStringDel(IntPtr variant, [MarshalAs(UnmanagedType.LPWStr)]string value); [NativeSymbol(Entrypoint = "net_variant_getString")] - IntPtr GetString(IntPtr variant); + public GetStringDel GetString { get; set; } + public delegate IntPtr GetStringDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_setDateTime")] - void SetDateTime(IntPtr variant, ref DateTimeContainer dateTime); + public SetDateTimeDel SetDateTime { get; set; } + public delegate void SetDateTimeDel(IntPtr variant, ref DateTimeContainer dateTime); [NativeSymbol(Entrypoint = "net_variant_getDateTime")] - void GetDateTime(IntPtr variant, ref DateTimeContainer dateTime); + public GetDateTimeDel GetDateTime { get; set; } + public delegate void GetDateTimeDel(IntPtr variant, ref DateTimeContainer dateTime); [NativeSymbol(Entrypoint = "net_variant_setJsValue")] - void SetJsValue(IntPtr variant, IntPtr jsValue); + public SetJsValueDel SetJsValue { get; set; } + public delegate void SetJsValueDel(IntPtr variant, IntPtr jsValue); [NativeSymbol(Entrypoint = "net_variant_getJsValue")] - IntPtr GetJsValue(IntPtr variant); + public GetJsValueDel GetJsValue { get; set; } + public delegate IntPtr GetJsValueDel(IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_clear")] - void Clear(IntPtr variant); + public ClearDel Clear { get; set; } + public delegate void ClearDel(IntPtr variant); } [StructLayout(LayoutKind.Sequential)] diff --git a/src/net/Qml.Net/Internal/Qml/NetVariantList.cs b/src/net/Qml.Net/Internal/Qml/NetVariantList.cs index 633d0553..d78e55e8 100644 --- a/src/net/Qml.Net/Internal/Qml/NetVariantList.cs +++ b/src/net/Qml.Net/Internal/Qml/NetVariantList.cs @@ -1,5 +1,4 @@ using System; -using AdvancedDLSupport; namespace Qml.Net.Internal.Qml { @@ -47,23 +46,30 @@ namespace Qml.Net.Internal.Qml } } - internal interface INetVariantListInterop + internal class NetVariantListInterop { [NativeSymbol(Entrypoint = "net_variant_list_create")] - IntPtr Create(); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(); [NativeSymbol(Entrypoint = "net_variant_list_destroy")] - void Destroy(IntPtr list); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr list); [NativeSymbol(Entrypoint = "net_variant_list_count")] - int Count(IntPtr list); - + public CountDel Count { get; set; } + public delegate int CountDel(IntPtr list); + [NativeSymbol(Entrypoint = "net_variant_list_add")] - void Add(IntPtr list, IntPtr variant); + public AddDel Add { get; set; } + public delegate void AddDel(IntPtr list, IntPtr variant); [NativeSymbol(Entrypoint = "net_variant_list_get")] - IntPtr Get(IntPtr list, int index); + public GetDel Get { get; set; } + public delegate IntPtr GetDel(IntPtr list, int index); [NativeSymbol(Entrypoint = "net_variant_list_remove")] - void Remove(IntPtr list, int index); + public RemoveDel Remove { get; set; } + public delegate void RemoveDel(IntPtr list, int index); [NativeSymbol(Entrypoint = "net_variant_list_clear")] - void Clear(IntPtr list); + public ClearDel Clear { get; set; } + public delegate void ClearDel(IntPtr list); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/Types/Callbacks.cs b/src/net/Qml.Net/Internal/Types/Callbacks.cs index b227cc60..9a795e1d 100644 --- a/src/net/Qml.Net/Internal/Types/Callbacks.cs +++ b/src/net/Qml.Net/Internal/Types/Callbacks.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.InteropServices; using System.Threading.Tasks; -using AdvancedDLSupport; namespace Qml.Net.Internal.Types { @@ -23,25 +22,31 @@ namespace Qml.Net.Internal.Types public IntPtr Serialize; } - internal interface ICallbacksIterop + internal class CallbacksInterop { [NativeSymbol(Entrypoint = "type_info_callbacks_registerCallbacks")] - void RegisterCallbacks(ref Callbacks callbacks); + public RegisterCallbacksDel RegisterCallbacks { get; set; } + public delegate void RegisterCallbacksDel(ref Callbacks callbacks); [NativeSymbol(Entrypoint = "type_info_callbacks_isTypeValid")] - bool IsTypeValid([MarshalAs(UnmanagedType.LPWStr), CallerFree]string typeName); + public IsTypeValidDel IsTypeValid { get; set; } + public delegate bool IsTypeValidDel([MarshalAs(UnmanagedType.LPWStr)]string typeName); [NativeSymbol(Entrypoint = "type_info_callbacks_releaseNetReferenceGCHandle")] - void ReleaseNetReference(UInt64 objectId); + public ReleaseNetReferenceDel ReleaseNetReference { get; set; } + public delegate void ReleaseNetReferenceDel(UInt64 objectId); [NativeSymbol(Entrypoint = "type_info_callbacks_releaseNetDelegateGCHandle")] - void ReleaseNetDelegateGCHandle(IntPtr handle); - + public ReleaseNetDelegateGCHandleDel ReleaseNetDelegateGCHandle { get; set; } + public delegate void ReleaseNetDelegateGCHandleDel(IntPtr handle); + [NativeSymbol(Entrypoint = "type_info_callbacks_instantiateType")] - IntPtr InstantiateType(IntPtr type); + public InstantiateTypeDel InstantiateType { get; set; } + public delegate IntPtr InstantiateTypeDel(IntPtr type); [NativeSymbol(Entrypoint = "type_info_callbacks_invokeMethod")] - void InvokeMethod(IntPtr method, IntPtr target, IntPtr variants, IntPtr result); + public InvokeMethodDel InvokeMethod { get; set; } + public delegate void InvokeMethodDel(IntPtr method, IntPtr target, IntPtr variants, IntPtr result); } internal interface ICallbacks diff --git a/src/net/Qml.Net/Internal/Types/NetDelegate.cs b/src/net/Qml.Net/Internal/Types/NetDelegate.cs index 2beb6dff..ba5a6f0d 100644 --- a/src/net/Qml.Net/Internal/Types/NetDelegate.cs +++ b/src/net/Qml.Net/Internal/Types/NetDelegate.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; namespace Qml.Net.Internal.Types { @@ -39,14 +38,17 @@ namespace Qml.Net.Internal.Types } } - internal interface INetDelegateInterop + internal class NetDelegateInterop { [NativeSymbol(Entrypoint = "delegate_create")] - IntPtr Create(IntPtr handle); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(IntPtr handle); [NativeSymbol(Entrypoint = "delegate_destroy")] - void Destroy(IntPtr del); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr del); [NativeSymbol(Entrypoint = "delegate_getHandle")] - IntPtr GetHandle(IntPtr del); + public GetHandleDel GetHandle { get; set; } + public delegate IntPtr GetHandleDel(IntPtr del); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/Types/NetMethodInfo.cs b/src/net/Qml.Net/Internal/Types/NetMethodInfo.cs index 03fce3b4..1682f7d3 100644 --- a/src/net/Qml.Net/Internal/Types/NetMethodInfo.cs +++ b/src/net/Qml.Net/Internal/Types/NetMethodInfo.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using AdvancedDLSupport; using Qml.Net.Internal; namespace Qml.Net.Internal.Types @@ -105,32 +104,50 @@ namespace Qml.Net.Internal.Types } } - internal interface INetMethodInfoInterop + internal class NetMethodInfoInterop { [NativeSymbol(Entrypoint = "method_info_parameter_destroy")] - void DestroyParameter(IntPtr parameter); + public DestroyParameterDel DestroyParameter { get; set; } + public delegate void DestroyParameterDel(IntPtr parameter); + [NativeSymbol(Entrypoint = "method_info_parameter_getName")] - IntPtr GetParameterName(IntPtr methodParameter); + public GetParameterNameDel GetParameterName { get; set; } + public delegate IntPtr GetParameterNameDel(IntPtr methodParameter); + [NativeSymbol(Entrypoint = "method_info_parameter_getType")] - IntPtr GetParameterType(IntPtr methodParameter); + public GetParameterTypeDel GetParameterType { get; set; } + public delegate IntPtr GetParameterTypeDel(IntPtr methodParameter); [NativeSymbol(Entrypoint = "method_info_create")] - IntPtr Create(IntPtr parentTypeInfo, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string methodName, IntPtr returnTypeInfo, bool isStatic); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(IntPtr parentTypeInfo, [MarshalAs(UnmanagedType.LPWStr)]string methodName, IntPtr returnTypeInfo, bool isStatic); + [NativeSymbol(Entrypoint = "method_info_destroy")] - void Destroy(IntPtr methodInfo); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr methodInfo); [NativeSymbol(Entrypoint = "method_info_getMethodName")] - IntPtr GetMethodName(IntPtr method); + public GetMethodNameDel GetMethodName { get; set; } + public delegate IntPtr GetMethodNameDel(IntPtr method); + [NativeSymbol(Entrypoint = "method_info_getReturnType")] - IntPtr GetReturnType(IntPtr method); + public GetReturnTypeDel GetReturnType { get; set; } + public delegate IntPtr GetReturnTypeDel(IntPtr method); + [NativeSymbol(Entrypoint = "method_info_isStatic")] - bool GetIsStatic(IntPtr method); + public GetIsStaticDel GetIsStatic { get; set; } + public delegate bool GetIsStaticDel(IntPtr method); [NativeSymbol(Entrypoint = "method_info_addParameter")] - void AddParameter(IntPtr method, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string name, IntPtr type); + public AddParameterDel AddParameter { get; set; } + public delegate void AddParameterDel(IntPtr method, [MarshalAs(UnmanagedType.LPWStr)]string name, IntPtr type); + [NativeSymbol(Entrypoint = "method_info_getParameterCount")] - int GetParameterCount(IntPtr method); + public GetParameterCountDel GetParameterCount { get; set; } + public delegate int GetParameterCountDel(IntPtr method); + [NativeSymbol(Entrypoint = "method_info_getParameter")] - IntPtr GetParameter(IntPtr method, int index); + public GetParameterDel GetParameter { get; set; } + public delegate IntPtr GetParameterDel(IntPtr method, int index); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/Types/NetPropertyInfo.cs b/src/net/Qml.Net/Internal/Types/NetPropertyInfo.cs index 9c7a0655..d8c8f0cf 100644 --- a/src/net/Qml.Net/Internal/Types/NetPropertyInfo.cs +++ b/src/net/Qml.Net/Internal/Types/NetPropertyInfo.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; using Qml.Net.Internal; namespace Qml.Net.Internal.Types @@ -73,37 +72,47 @@ namespace Qml.Net.Internal.Types } } - internal interface INetPropertyInfoInterop + internal class NetPropertyInfoInterop { [NativeSymbol(Entrypoint = "property_info_create")] - IntPtr Create(IntPtr parentType, - [MarshalAs(UnmanagedType.LPWStr), CallerFree]string methodName, + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(IntPtr parentType, + [MarshalAs(UnmanagedType.LPWStr)]string methodName, IntPtr returnType, bool canRead, bool canWrite, IntPtr notifySignal); + [NativeSymbol(Entrypoint = "property_info_destroy")] - void Destroy(IntPtr property); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr property); [NativeSymbol(Entrypoint = "property_info_getParentType")] - IntPtr GetParentType(IntPtr property); + public GetParentTypeDel GetParentType { get; set; } + public delegate IntPtr GetParentTypeDel(IntPtr property); [NativeSymbol(Entrypoint = "property_info_getPropertyName")] - IntPtr GetPropertyName(IntPtr property); + public GetPropertyNameDel GetPropertyName { get; set; } + public delegate IntPtr GetPropertyNameDel(IntPtr property); [NativeSymbol(Entrypoint = "property_info_getReturnType")] - IntPtr GetReturnType(IntPtr property); + public GetReturnTypeDel GetReturnType { get; set; } + public delegate IntPtr GetReturnTypeDel(IntPtr property); [NativeSymbol(Entrypoint = "property_info_canRead")] - bool GetCanRead(IntPtr property); + public GetCanReadDel GetCanRead { get; set; } + public delegate bool GetCanReadDel(IntPtr property); [NativeSymbol(Entrypoint = "property_info_canWrite")] - bool GetCanWrite(IntPtr property); + public GetCanWriteDel GetCanWrite { get; set; } + public delegate bool GetCanWriteDel(IntPtr property); [NativeSymbol(Entrypoint = "property_info_getNotifySignal")] - IntPtr GetNotifySignal(IntPtr property); + public GetNotifySignalDel GetNotifySignal { get; set; } + public delegate IntPtr GetNotifySignalDel(IntPtr property); [NativeSymbol(Entrypoint = "property_info_setNotifySignal")] - void SetNotifySignal(IntPtr property, IntPtr signal); + public SetNotifySignalDel SetNotifySignal { get; set; } + public delegate void SetNotifySignalDel(IntPtr property, IntPtr signal); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/Types/NetReference.cs b/src/net/Qml.Net/Internal/Types/NetReference.cs index 29b4e877..fc4cf22d 100644 --- a/src/net/Qml.Net/Internal/Types/NetReference.cs +++ b/src/net/Qml.Net/Internal/Types/NetReference.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Runtime.Serialization; -using AdvancedDLSupport; using Qml.Net.Internal; using Qml.Net.Internal.Qml; @@ -104,19 +101,27 @@ namespace Qml.Net.Internal.Types #endregion } - internal interface INetReferenceInterop + internal class NetReferenceInterop { [NativeSymbol(Entrypoint = "net_instance_create")] - IntPtr Create(UInt64 objectId, IntPtr type); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(UInt64 objectId, IntPtr type); + [NativeSymbol(Entrypoint = "net_instance_destroy")] - void Destroy(IntPtr instance); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr instance); + [NativeSymbol(Entrypoint = "net_instance_clone")] - IntPtr Clone(IntPtr instance); + public CloneDel Clone { get; set; } + public delegate IntPtr CloneDel(IntPtr instance); [NativeSymbol(Entrypoint = "net_instance_getObjectId")] - UInt64 GetObjectId(IntPtr instance); + public GetObjectIdDel GetObjectId { get; set; } + public delegate UInt64 GetObjectIdDel(IntPtr instance); + [NativeSymbol(Entrypoint = "net_instance_activateSignal")] - bool ActivateSignal(IntPtr instance, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string signalName, IntPtr variants); + public ActivateSignalDel ActivateSignal { get; set; } + public delegate bool ActivateSignalDel(IntPtr instance, [MarshalAs(UnmanagedType.LPWStr)]string signalName, IntPtr variants); } internal static class ObjectIdReferenceTracker diff --git a/src/net/Qml.Net/Internal/Types/NetSignalInfo.cs b/src/net/Qml.Net/Internal/Types/NetSignalInfo.cs index d23110f6..09afe34f 100644 --- a/src/net/Qml.Net/Internal/Types/NetSignalInfo.cs +++ b/src/net/Qml.Net/Internal/Types/NetSignalInfo.cs @@ -1,7 +1,5 @@ using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; -using Qml.Net.Internal; namespace Qml.Net.Internal.Types { @@ -41,23 +39,30 @@ namespace Qml.Net.Internal.Types } } - internal interface INetSignalInfoInterop + internal class NetSignalInfoInterop { [NativeSymbol(Entrypoint = "signal_info_create")] - IntPtr Create(IntPtr parentType, [MarshalAs(UnmanagedType.LPWStr), CallerFree] string name); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(IntPtr parentType, [MarshalAs(UnmanagedType.LPWStr)] string name); [NativeSymbol(Entrypoint = "signal_info_destroy")] - void Destroy(IntPtr signal); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr signal); [NativeSymbol(Entrypoint = "signal_info_getParentType")] - IntPtr GetParentType(IntPtr signal); + public GetParentTypeDel GetParentType { get; set; } + public delegate IntPtr GetParentTypeDel(IntPtr signal); [NativeSymbol(Entrypoint = "signal_info_getName")] - IntPtr GetName(IntPtr signal); + public GetNameDel GetName { get; set; } + public delegate IntPtr GetNameDel(IntPtr signal); [NativeSymbol(Entrypoint = "signal_info_addParameter")] - void AddParameter(IntPtr signal, NetVariantType type); + public AddParameterDel AddParameter { get; set; } + public delegate void AddParameterDel(IntPtr signal, NetVariantType type); [NativeSymbol(Entrypoint = "signal_info_getParameterCount")] - int GetParameterCount(IntPtr signal); + public GetParameterCountDel GetParameterCount { get; set; } + public delegate int GetParameterCountDel(IntPtr signal); [NativeSymbol(Entrypoint = "signal_info_getParameter")] - NetVariantType GetParameter(IntPtr signal, int index); + public GetParameterDel GetParameter { get; set; } + public delegate NetVariantType GetParameterDel(IntPtr signal, int index); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/Types/NetTypeInfo.cs b/src/net/Qml.Net/Internal/Types/NetTypeInfo.cs index 886e8fd3..e21d1f31 100644 --- a/src/net/Qml.Net/Internal/Types/NetTypeInfo.cs +++ b/src/net/Qml.Net/Internal/Types/NetTypeInfo.cs @@ -1,7 +1,5 @@ using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; -using Qml.Net.Internal; namespace Qml.Net.Internal.Types { @@ -119,72 +117,114 @@ namespace Qml.Net.Internal.Types } } - internal interface INetTypeInfoInterop + internal class NetTypeInfoInterop { [NativeSymbol(Entrypoint = "type_info_create")] - IntPtr Create([MarshalAs(UnmanagedType.LPWStr), CallerFree]string fullTypeName); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel([MarshalAs(UnmanagedType.LPWStr)]string fullTypeName); + [NativeSymbol(Entrypoint = "type_info_destroy")] - void Destroy(IntPtr netTypeInfo); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr netTypeInfo); [NativeSymbol(Entrypoint = "type_info_getFullTypeName")] - IntPtr GetFullTypeName(IntPtr netTypeInfo); + public GetFullTypeNameDel GetFullTypeName { get; set; } + public delegate IntPtr GetFullTypeNameDel(IntPtr netTypeInfo); [NativeSymbol(Entrypoint = "type_info_setClassName")] - void SetClassName(IntPtr netTypeInfo, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string className); + public SetClassNameDel SetClassName { get; set; } + public delegate void SetClassNameDel(IntPtr netTypeInfo, [MarshalAs(UnmanagedType.LPWStr)]string className); + [NativeSymbol(Entrypoint = "type_info_getClassName")] - IntPtr GetClassName(IntPtr netTypeInfo); + public GetClassNameDel GetClassName { get; set; } + public delegate IntPtr GetClassNameDel(IntPtr netTypeInfo); [NativeSymbol(Entrypoint = "type_info_setPrefVariantType")] - void SetPrefVariantType(IntPtr netTypeInfo, NetVariantType variantType); + public SetPrefVariantTypeDel SetPrefVariantType { get; set; } + public delegate void SetPrefVariantTypeDel(IntPtr netTypeInfo, NetVariantType variantType); + [NativeSymbol(Entrypoint = "type_info_getPrefVariantType")] - NetVariantType GetPrefVariantType(IntPtr netTypeInfo); + public GetPrefVariantTypeDel GetPrefVariantType { get; set; } + public delegate NetVariantType GetPrefVariantTypeDel(IntPtr netTypeInfo); [NativeSymbol(Entrypoint = "type_info_setIsArray")] - bool GetIsArray(IntPtr netTypeInfo); + public GetIsArrayDel GetIsArray { get; set; } + public delegate bool GetIsArrayDel(IntPtr netTypeInfo); + [NativeSymbol(Entrypoint = "type_info_getIsArray")] - void SetIsArray(IntPtr netTypeInfo, bool isArray); + public SetIsArrayDel SetIsArray { get; set; } + public delegate void SetIsArrayDel(IntPtr netTypeInfo, bool isArray); [NativeSymbol(Entrypoint = "type_info_setIsList")] - bool GetIsList(IntPtr netTypeInfo); + public GetIsListDel GetIsList { get; set; } + public delegate bool GetIsListDel(IntPtr netTypeInfo); + [NativeSymbol(Entrypoint = "type_info_getIsList")] - void SetIsList(IntPtr netTypeInfo, bool isList); + public SetIsListDel SetIsList { get; set; } + public delegate void SetIsListDel(IntPtr netTypeInfo, bool isList); [NativeSymbol(Entrypoint = "type_info_addMethod")] - void AddMethod(IntPtr typeInfo, IntPtr methodInfo); + public AddMethodDel AddMethod { get; set; } + public delegate void AddMethodDel(IntPtr typeInfo, IntPtr methodInfo); + [NativeSymbol(Entrypoint = "type_info_getMethodCount")] - int GetMethodCount(IntPtr typeInfo); + public GetMethodCountDel GetMethodCount { get; set; } + public delegate int GetMethodCountDel(IntPtr typeInfo); + [NativeSymbol(Entrypoint = "type_info_getMethodInfo")] - IntPtr GetMethodInfo(IntPtr typeInfo, int index); + public GetMethodInfoDel GetMethodInfo { get; set; } + public delegate IntPtr GetMethodInfoDel(IntPtr typeInfo, int index); [NativeSymbol(Entrypoint = "type_info_getLocalMethodCount")] - int GetLocalMethodCount(IntPtr typeInfo); + public GetLocalMethodCountDel GetLocalMethodCount { get; set; } + public delegate int GetLocalMethodCountDel(IntPtr typeInfo); + [NativeSymbol(Entrypoint = "type_info_getLocalMethodInfo")] - IntPtr GetLocalMethodInfo(IntPtr typeInfo, int index); + public GetLocalMethodInfoDel GetLocalMethodInfo { get; set; } + public delegate IntPtr GetLocalMethodInfoDel(IntPtr typeInfo, int index); [NativeSymbol(Entrypoint = "type_info_getStaticMethodCount")] - int GetStaticMethodCount(IntPtr typeInfo); + public GetStaticMethodCountDel GetStaticMethodCount { get; set; } + public delegate int GetStaticMethodCountDel(IntPtr typeInfo); + [NativeSymbol(Entrypoint = "type_info_getStaticMethodInfo")] - IntPtr GetStaticMethodInfo(IntPtr typeInfo, int index); + public GetStaticMethodInfoDel GetStaticMethodInfo { get; set; } + public delegate IntPtr GetStaticMethodInfoDel(IntPtr typeInfo, int index); [NativeSymbol(Entrypoint = "type_info_addProperty")] - void AddProperty(IntPtr typeInfo, IntPtr property); + public AddPropertyDel AddProperty { get; set; } + public delegate void AddPropertyDel(IntPtr typeInfo, IntPtr property); + [NativeSymbol(Entrypoint = "type_info_getPropertyCount")] - int GetPropertyCount(IntPtr typeInfo); + public GetPropertyCountDel GetPropertyCount { get; set; } + public delegate int GetPropertyCountDel(IntPtr typeInfo); + [NativeSymbol(Entrypoint = "type_info_getProperty")] - IntPtr GetProperty(IntPtr typeInfo, int index); + public GetPropertyDel GetProperty { get; set; } + public delegate IntPtr GetPropertyDel(IntPtr typeInfo, int index); [NativeSymbol(Entrypoint = "type_info_addSignal")] - void AddSignal(IntPtr typeInfo, IntPtr signal); + public AddSignalDel AddSignal { get; set; } + public delegate void AddSignalDel(IntPtr typeInfo, IntPtr signal); + [NativeSymbol(Entrypoint = "type_info_getSignalCount")] - int GetSignalCount(IntPtr typeInfo); + public GetSignalCountDel GetSignalCount { get; set; } + public delegate int GetSignalCountDel(IntPtr typeInfo); + [NativeSymbol(Entrypoint = "type_info_getSignal")] - IntPtr GetSignal(IntPtr typeInfo, int index); + public GetSignalDel GetSignal { get; set; } + public delegate IntPtr GetSignalDel(IntPtr typeInfo, int index); [NativeSymbol(Entrypoint = "type_info_isLoaded")] - bool IsLoaded(IntPtr typeInfo); + public IsLoadedDel IsLoaded { get; set; } + public delegate bool IsLoadedDel(IntPtr typeInfo); + [NativeSymbol(Entrypoint = "type_info_isLoading")] - bool IsLoading(IntPtr typeInfo); + public IsLoadingDel IsLoading { get; set; } + public delegate bool IsLoadingDel(IntPtr typeInfo); + [NativeSymbol(Entrypoint = "type_info_ensureLoaded")] - void EnsureLoaded(IntPtr typeInfo); + public EnsureLoadedDel EnsureLoaded { get; set; } + public delegate void EnsureLoadedDel(IntPtr typeInfo); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/Types/NetTypeManager.cs b/src/net/Qml.Net/Internal/Types/NetTypeManager.cs index a193063f..bd31a816 100644 --- a/src/net/Qml.Net/Internal/Types/NetTypeManager.cs +++ b/src/net/Qml.Net/Internal/Types/NetTypeManager.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; namespace Qml.Net.Internal.Types { @@ -23,9 +22,10 @@ namespace Qml.Net.Internal.Types } } - internal interface INetTypeManagerInterop + internal class NetTypeManagerInterop { [NativeSymbol(Entrypoint = "type_manager_getTypeInfo")] - IntPtr GetTypeInfo([MarshalAs(UnmanagedType.LPWStr), CallerFree]string fullTypeName); + public GetTypeInfoDel GetTypeInfo { get; set; } + public delegate IntPtr GetTypeInfoDel([MarshalAs(UnmanagedType.LPWStr)]string fullTypeName); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Internal/WindowsDllImportLibraryPathResolver.cs b/src/net/Qml.Net/Internal/WindowsDllImportLibraryPathResolver.cs index 3c113397..acb7e6d2 100644 --- a/src/net/Qml.Net/Internal/WindowsDllImportLibraryPathResolver.cs +++ b/src/net/Qml.Net/Internal/WindowsDllImportLibraryPathResolver.cs @@ -1,15 +1,15 @@ -using AdvancedDLSupport; -using System; +using System; using System.IO; using System.Runtime.InteropServices; +using NetNativeLibLoader.PathResolver; namespace Qml.Net.Internal { - internal class WindowsDllImportLibraryPathResolver : ILibraryPathResolver + internal class WindowsDllImportLibraryPathResolver : IPathResolver { - ILibraryPathResolver _original; + IPathResolver _original; - public WindowsDllImportLibraryPathResolver(ILibraryPathResolver original) + public WindowsDllImportLibraryPathResolver(IPathResolver original) { _original = original; } diff --git a/src/net/Qml.Net/QGuiApplication.cs b/src/net/Qml.Net/QGuiApplication.cs index 1bba8359..1b14f557 100644 --- a/src/net/Qml.Net/QGuiApplication.cs +++ b/src/net/Qml.Net/QGuiApplication.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Threading; -using AdvancedDLSupport; using Qml.Net.Internal; using Qml.Net.Internal.Qml; @@ -143,22 +142,34 @@ namespace Qml.Net } } - internal interface IQGuiApplicationInterop + internal class QGuiApplicationInterop { [NativeSymbol(Entrypoint = "qguiapplication_create")] - IntPtr Create(IntPtr args, IntPtr existingApp); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(IntPtr args, IntPtr existingApp); + [NativeSymbol(Entrypoint = "qguiapplication_destroy")] - void Destroy(IntPtr app); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr app); [NativeSymbol(Entrypoint = "qguiapplication_exec")] - int Exec(); + public ExecDel Exec { get; set; } + public delegate int ExecDel(); + [NativeSymbol(Entrypoint = "qguiapplication_addTriggerCallback")] - void AddTriggerCallback(IntPtr app, IntPtr callback); + public AddTriggerCallbackDel AddTriggerCallback { get; set; } + public delegate void AddTriggerCallbackDel(IntPtr app, IntPtr callback); + [NativeSymbol(Entrypoint = "qguiapplication_requestTrigger")] - void RequestTrigger(IntPtr app); + public RequestTriggerDel RequestTrigger { get; set; } + public delegate void RequestTriggerDel(IntPtr app); + [NativeSymbol(Entrypoint = "qguiapplication_exit")] - void Exit(int returnCode); + public ExitDel Exit { get; set; } + public delegate void ExitDel(int returnCode); + [NativeSymbol(Entrypoint = "qguiapplication_internalPointer")] - IntPtr InternalPointer(IntPtr app); + public InternalPointerDel InternalPointer { get; set; } + public delegate IntPtr InternalPointerDel(IntPtr app); } } \ No newline at end of file diff --git a/src/net/Qml.Net/QQmlApplicationEngine.cs b/src/net/Qml.Net/QQmlApplicationEngine.cs index 3e59aaed..1687079d 100644 --- a/src/net/Qml.Net/QQmlApplicationEngine.cs +++ b/src/net/Qml.Net/QQmlApplicationEngine.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; using Qml.Net.Internal; using Qml.Net.Internal.Behaviors; using Qml.Net.Internal.Qml; @@ -102,38 +101,50 @@ namespace Qml.Net } } - internal interface IQQmlApplicationEngine + internal class QQmlApplicationEngineInterop { [NativeSymbol(Entrypoint = "qqmlapplicationengine_create")] - IntPtr Create(IntPtr existingEngine); + public CreateDel Create { get; set; } + public delegate IntPtr CreateDel(IntPtr existingEngine); + [NativeSymbol(Entrypoint = "qqmlapplicationengine_destroy")] - void Destroy(IntPtr engine); + public DestroyDel Destroy { get; set; } + public delegate void DestroyDel(IntPtr engine); [NativeSymbol(Entrypoint = "qqmlapplicationengine_load")] - int Load(IntPtr engine, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string path); + public LoadDel Load { get; set; } + public delegate int LoadDel(IntPtr engine, [MarshalAs(UnmanagedType.LPWStr)]string path); [NativeSymbol(Entrypoint = "qqmlapplicationengine_loadData")] - int LoadData(IntPtr engine, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string path); + public LoadDataDel LoadData { get; set; } + public delegate int LoadDataDel(IntPtr engine, [MarshalAs(UnmanagedType.LPWStr)]string path); [NativeSymbol(Entrypoint = "qqmlapplicationengine_registerType")] - int RegisterType(IntPtr type, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string uri, int versionMajor, int versionMinor, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string qmlName); - + public RegisterTypeDel RegisterType { get; set; } + public delegate int RegisterTypeDel(IntPtr type, [MarshalAs(UnmanagedType.LPWStr)]string uri, int versionMajor, int versionMinor, [MarshalAs(UnmanagedType.LPWStr)]string qmlName); + [NativeSymbol(Entrypoint = "qqmlapplicationengine_registerSingletonTypeQml")] - int RegisterSingletonTypeQml([MarshalAs(UnmanagedType.LPWStr), CallerFree]string url, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string uri, int versionMajor, int versionMinor, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string qmlName); + public RegisterSingletonTypeQmlDel RegisterSingletonTypeQml { get; set; } + public delegate int RegisterSingletonTypeQmlDel([MarshalAs(UnmanagedType.LPWStr)]string url, [MarshalAs(UnmanagedType.LPWStr)]string uri, int versionMajor, int versionMinor, [MarshalAs(UnmanagedType.LPWStr)]string qmlName); [NativeSymbol(Entrypoint = "qqmlapplicationengine_registerSingletonTypeNet")] - int RegisterSingletonTypeNet(IntPtr type, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string uri, int versionMajor, int versionMinor, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string typeName); + public RegisterSingletonTypeNetDel RegisterSingletonTypeNet { get; set; } + public delegate int RegisterSingletonTypeNetDel(IntPtr type, [MarshalAs(UnmanagedType.LPWStr)]string uri, int versionMajor, int versionMinor, [MarshalAs(UnmanagedType.LPWStr)]string typeName); [NativeSymbol(Entrypoint = "qqmlapplicationengine_addImportPath")] - void AddImportPath(IntPtr engine, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string path); + public AddImportPathDel AddImportPath { get; set; } + public delegate void AddImportPathDel(IntPtr engine, [MarshalAs(UnmanagedType.LPWStr)]string path); [NativeSymbol(Entrypoint = "qqmlapplicationengine_internalPointer")] - IntPtr InternalPointer(IntPtr app); + public InternalPointerDel InternalPointer { get; set; } + public delegate IntPtr InternalPointerDel(IntPtr app); [NativeSymbol(Entrypoint = "qqmlapplicationengine_getContextProperty")] - IntPtr GetContextProperty(IntPtr app, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string name); + public GetContextPropertyDel GetContextProperty { get; set; } + public delegate IntPtr GetContextPropertyDel(IntPtr app, [MarshalAs(UnmanagedType.LPWStr)]string name); [NativeSymbol(Entrypoint = "qqmlapplicationengine_setContextProperty")] - void SetContextProperty(IntPtr app, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string path, IntPtr value); + public SetContextPropertyDel SetContextProperty { get; set; } + public delegate void SetContextPropertyDel(IntPtr app, [MarshalAs(UnmanagedType.LPWStr)]string path, IntPtr value); } } \ No newline at end of file diff --git a/src/net/Qml.Net/QQuickStyle.cs b/src/net/Qml.Net/QQuickStyle.cs index eb93dbe4..bef2ee52 100644 --- a/src/net/Qml.Net/QQuickStyle.cs +++ b/src/net/Qml.Net/QQuickStyle.cs @@ -1,14 +1,13 @@ using System.Runtime.InteropServices; -using AdvancedDLSupport; using Qml.Net.Internal; namespace Qml.Net { public class QQuickStyle { - public static void SetFallbackStyle(string style) - { - Interop.QQuickStyle.SetFallbackStyle(style); + public static void SetFallbackStyle(string style) + { + Interop.QQuickStyle.SetFallbackStyle(style); } public static void SetStyle(string style) @@ -17,12 +16,14 @@ namespace Qml.Net } } - internal interface IQQuickStyleInterop + internal class QQuickStyleInterop { [NativeSymbol(Entrypoint = "qquickstyle_setFallbackStyle")] - void SetFallbackStyle([MarshalAs(UnmanagedType.LPWStr), CallerFree]string style); + public SetFallbackStyleDel SetFallbackStyle { get; set; } + public delegate void SetFallbackStyleDel([MarshalAs(UnmanagedType.LPWStr)]string style); [NativeSymbol(Entrypoint = "qquickstyle_setStyle")] - void SetStyle([MarshalAs(UnmanagedType.LPWStr), CallerFree]string style); + public SetStyleDel SetStyle { get; set; } + public delegate void SetStyleDel([MarshalAs(UnmanagedType.LPWStr)]string style); } } \ No newline at end of file diff --git a/src/net/Qml.Net/QResource.cs b/src/net/Qml.Net/QResource.cs index ad298ddf..5c0e1523 100644 --- a/src/net/Qml.Net/QResource.cs +++ b/src/net/Qml.Net/QResource.cs @@ -1,5 +1,5 @@ using System.Runtime.InteropServices; -using AdvancedDLSupport; +using Qml.Net.Internal; namespace Qml.Net { @@ -10,17 +10,19 @@ namespace Qml.Net return Internal.Interop.QResource.RegisterResource(rccFileName, resourceRoot); } - public static bool UnregisterResource(string rccFileName, string resourceRoot = null) - { - return Internal.Interop.QResource.UnregisterResource(rccFileName, resourceRoot); + public static bool UnregisterResource(string rccFileName, string resourceRoot = null) + { + return Internal.Interop.QResource.UnregisterResource(rccFileName, resourceRoot); } } - internal interface IQResourceInterop + internal class QResourceInterop { [NativeSymbol(Entrypoint = "qresource_registerResource")] - bool RegisterResource([MarshalAs(UnmanagedType.LPWStr), CallerFree]string rccFileName, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string resourceRoot); + public RegisterResourceDel RegisterResource { get; set; } + public delegate bool RegisterResourceDel([MarshalAs(UnmanagedType.LPWStr)]string rccFileName, [MarshalAs(UnmanagedType.LPWStr)]string resourceRoot); [NativeSymbol(Entrypoint = "qresource_unregisterResource")] - bool UnregisterResource([MarshalAs(UnmanagedType.LPWStr), CallerFree]string rccFileName, [MarshalAs(UnmanagedType.LPWStr), CallerFree]string resourceRoot); + public UnregisterResourceDel UnregisterResource { get; set; } + public delegate bool UnregisterResourceDel([MarshalAs(UnmanagedType.LPWStr)]string rccFileName, [MarshalAs(UnmanagedType.LPWStr)]string resourceRoot); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Qml.Net.csproj b/src/net/Qml.Net/Qml.Net.csproj index fcbce69e..09c53e48 100644 --- a/src/net/Qml.Net/Qml.Net.csproj +++ b/src/net/Qml.Net/Qml.Net.csproj @@ -3,7 +3,8 @@ netstandard2.0 - + + \ No newline at end of file diff --git a/src/net/Qml.Net/Qt.cs b/src/net/Qml.Net/Qt.cs index 2acc3bca..081d7701 100644 --- a/src/net/Qml.Net/Qt.cs +++ b/src/net/Qml.Net/Qt.cs @@ -1,9 +1,6 @@ -using AdvancedDLSupport; -using Qml.Net.Internal; +using Qml.Net.Internal; using System; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; namespace Qml.Net { @@ -25,13 +22,16 @@ namespace Qml.Net } } - internal interface IQtInterop + internal class QtInterop { [NativeSymbol(Entrypoint = "qt_putenv")] - bool PutEnv([MarshalAs(UnmanagedType.LPStr), CallerFree]string name, [MarshalAs(UnmanagedType.LPStr), CallerFree]string value); + public PutEnvDel PutEnv { get; set; } + public delegate bool PutEnvDel([MarshalAs(UnmanagedType.LPStr)]string name, [MarshalAs(UnmanagedType.LPStr)]string value); [NativeSymbol(Entrypoint = "qt_getenv")] - IntPtr GetEnv(string name); + public GetEnvDel GetEnv { get; set; } + public delegate IntPtr GetEnvDel(string name); [NativeSymbol(Entrypoint = "qt_version")] - IntPtr QtVersion(); + public QtVersionDel QtVersion { get; set; } + public delegate IntPtr QtVersionDel(); } } diff --git a/src/net/Qml.Net/QtWebEngine.cs b/src/net/Qml.Net/QtWebEngine.cs index 5518edfa..b6deee3b 100644 --- a/src/net/Qml.Net/QtWebEngine.cs +++ b/src/net/Qml.Net/QtWebEngine.cs @@ -1,4 +1,3 @@ -using AdvancedDLSupport; using Qml.Net.Internal; namespace Qml.Net @@ -11,9 +10,10 @@ namespace Qml.Net } } - internal interface IQtWebEngine + internal class QtWebEngineInterop { [NativeSymbol(Entrypoint = "qtwebebengine_initialize")] - void Initialize(); + public InitializeDel Initialize { get; set; } + public delegate void InitializeDel(); } } \ No newline at end of file diff --git a/src/net/Qml.Net/Utilities.cs b/src/net/Qml.Net/Utilities.cs index 66dd0705..b7ae3aa4 100644 --- a/src/net/Qml.Net/Utilities.cs +++ b/src/net/Qml.Net/Utilities.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using AdvancedDLSupport; using Qml.Net.Internal; namespace Qml.Net @@ -28,9 +27,10 @@ namespace Qml.Net } } - internal interface IUtilities + internal class UtilitiesInterop { [NativeSymbol(Entrypoint = "freeString")] - void FreeString(IntPtr container); + public FreeStringDel FreeString { get; set; } + public delegate void FreeStringDel(IntPtr container); } } \ No newline at end of file