mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-21 06:45:32 -06:00
Merge branch 'develop' into feature/update-xunit-packages
This commit is contained in:
commit
197f48647a
77 changed files with 1448 additions and 903 deletions
|
|
@ -1,3 +1,4 @@
|
|||
image: Visual Studio 2017
|
||||
install:
|
||||
- choco install gitversion.portable -pre -y --version 4.0.0-beta0012
|
||||
before_build:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
|
||||
set PATH=%PATH%;C:\Qt\5.11.1\msvc2015_64\bin
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
set PATH=%PATH%;C:\Qt\5.11.2\msvc2017_64\bin
|
||||
set PATH=%PATH%;C:\Qt\Tools\QtCreator\bin
|
||||
|
||||
set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%\src\native\output
|
||||
|
|
|
|||
|
|
@ -36,17 +36,20 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
enum Q_DECL_EXPORT NetVariantTypeEnum {
|
||||
enum NetVariantTypeEnum {
|
||||
NetVariantTypeEnum_Invalid = 0,
|
||||
NetVariantTypeEnum_Bool = 1,
|
||||
NetVariantTypeEnum_Char = 2,
|
||||
NetVariantTypeEnum_Int = 3,
|
||||
NetVariantTypeEnum_UInt = 4,
|
||||
NetVariantTypeEnum_Double = 5,
|
||||
NetVariantTypeEnum_String = 6,
|
||||
NetVariantTypeEnum_DateTime = 7,
|
||||
NetVariantTypeEnum_Object = 8,
|
||||
NetVariantTypeEnum_JSValue = 9
|
||||
NetVariantTypeEnum_Bool,
|
||||
NetVariantTypeEnum_Char,
|
||||
NetVariantTypeEnum_Int,
|
||||
NetVariantTypeEnum_UInt,
|
||||
NetVariantTypeEnum_Long,
|
||||
NetVariantTypeEnum_ULong,
|
||||
NetVariantTypeEnum_Float,
|
||||
NetVariantTypeEnum_Double,
|
||||
NetVariantTypeEnum_String,
|
||||
NetVariantTypeEnum_DateTime,
|
||||
NetVariantTypeEnum_Object,
|
||||
NetVariantTypeEnum_JSValue,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,29 +4,27 @@
|
|||
#include <QmlNet/types/NetTypeManager.h>
|
||||
#include <QmlNet/qml/NetListModel.h>
|
||||
#include <QQmlEngine>
|
||||
#include <QDebug>
|
||||
|
||||
JsNetObject::JsNetObject()
|
||||
{
|
||||
JsNetObject::JsNetObject() = default;
|
||||
|
||||
}
|
||||
|
||||
QString JsNetObject::serialize(QJSValue value)
|
||||
QString JsNetObject::serialize(const QJSValue& value)
|
||||
{
|
||||
if(value.isNull() || value.isUndefined()) {
|
||||
qWarning("Net.serialize(): Instance parameter must not be null or undefined");
|
||||
qWarning() << "Net.serialize(): Instance parameter must not be null or undefined";
|
||||
return QString();
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> netVaraint = NetVariant::fromQJSValue(value);
|
||||
if(netVaraint->getVariantType() != NetVariantTypeEnum_Object) {
|
||||
qWarning("Net.serialize(): Parameter is not a .NET object");
|
||||
qWarning() << "Net.serialize(): Parameter is not a .NET object";
|
||||
return QString();
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> result = QSharedPointer<NetVariant>(new NetVariant());
|
||||
QSharedPointer<NetVariant> result(new NetVariant());
|
||||
bool serializationResult = QmlNet::serializeNetToString(netVaraint->getNetReference(), result);
|
||||
if(!serializationResult) {
|
||||
qWarning("Net.serialize(): Could not serialize object.");
|
||||
qWarning() << "Net.serialize(): Could not serialize object.";
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
|
@ -37,15 +35,15 @@ QVariant JsNetObject::cancelTokenSource()
|
|||
{
|
||||
QSharedPointer<NetTypeInfo> typeInfo = NetTypeManager::getTypeInfo("System.Threading.CancellationTokenSource");
|
||||
if(typeInfo == nullptr) {
|
||||
qWarning("Couldn't get cancellation token type for platform, please file a bug");
|
||||
qWarning() << "Couldn't get cancellation token type for platform, please file a bug";
|
||||
return QVariant();
|
||||
}
|
||||
QSharedPointer<NetReference> netReference = QmlNet::instantiateType(typeInfo);
|
||||
if(netReference == nullptr) {
|
||||
qWarning("Couldn't create cancellation token for platform, please file a bug");
|
||||
qWarning() << "Couldn't create cancellation token for platform, please file a bug";
|
||||
return QVariant();
|
||||
}
|
||||
QSharedPointer<NetVariant> netVariant = QSharedPointer<NetVariant>(new NetVariant());
|
||||
QSharedPointer<NetVariant> netVariant(new NetVariant());
|
||||
netVariant->setNetReference(netReference);
|
||||
return netVariant->toQVariant();
|
||||
}
|
||||
|
|
@ -55,22 +53,22 @@ void JsNetObject::gcCollect(int maxGeneration)
|
|||
QmlNet::gcCollect(maxGeneration);
|
||||
}
|
||||
|
||||
QVariant JsNetObject::toListModel(QJSValue value)
|
||||
QVariant JsNetObject::toListModel(const QJSValue& value)
|
||||
{
|
||||
if(value.isNull() || value.isUndefined()) {
|
||||
qWarning("Net.toListModel(): Instance parameter must not be null or undefined");
|
||||
qWarning() << "Net.toListModel(): Instance parameter must not be null or undefined";
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> netVaraint = NetVariant::fromQJSValue(value);
|
||||
if(netVaraint->getVariantType() != NetVariantTypeEnum_Object) {
|
||||
qWarning("Net.toListModel(): Parameter is not a .NET 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.");
|
||||
qWarning() << "Net.toListModel(): Parameter is not a type that can be wrapped by a list model.";
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
|
@ -80,36 +78,36 @@ QVariant JsNetObject::toListModel(QJSValue value)
|
|||
|
||||
void JsNetObject::toJsArray()
|
||||
{
|
||||
qWarning("Net.toJsArray(): Not supported anymore. Use Net.toListModel().");
|
||||
qWarning() << "Net.toJsArray(): Not supported anymore. Use Net.toListModel().";
|
||||
}
|
||||
|
||||
void JsNetObject::await(QJSValue task, QJSValue successCallback, QJSValue failureCallback)
|
||||
void JsNetObject::await(const QJSValue& task, const QJSValue& successCallback, const QJSValue& failureCallback)
|
||||
{
|
||||
if(task.isNull() || task.isUndefined()) {
|
||||
qWarning("Net.await(): No task object provided.");
|
||||
qWarning() << "Net.await(): No task object provided.";
|
||||
return;
|
||||
}
|
||||
|
||||
if(successCallback.isNull() || successCallback.isUndefined()) {
|
||||
qWarning("Net.await(): Not success callback given");
|
||||
qWarning() << "Net.await(): Not success callback given";
|
||||
return;
|
||||
}
|
||||
|
||||
if(!successCallback.isCallable()) {
|
||||
qWarning("Net.await(): Success callback invalid type.");
|
||||
qWarning() << "Net.await(): Success callback invalid type.";
|
||||
return;
|
||||
}
|
||||
|
||||
if(!failureCallback.isNull() && !failureCallback.isUndefined()) {
|
||||
if(!failureCallback.isCallable()) {
|
||||
qWarning("Net.await(): Failure callback invalid type.");
|
||||
qWarning() << "Net.await(): Failure callback invalid type.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> taskVariant = NetVariant::fromQJSValue(task);
|
||||
if(taskVariant->getVariantType() != NetVariantTypeEnum_Object) {
|
||||
qWarning("Net.await(): Task is invalid type.");
|
||||
qWarning() << "Net.await(): Task is invalid type.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ class JsNetObject : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
JsNetObject();
|
||||
Q_INVOKABLE QString serialize(QJSValue value);
|
||||
Q_INVOKABLE QString serialize(const QJSValue& value);
|
||||
Q_INVOKABLE QVariant cancelTokenSource();
|
||||
Q_INVOKABLE void gcCollect(int maxGeneration = 0);
|
||||
Q_INVOKABLE QVariant toListModel(QJSValue value);
|
||||
Q_INVOKABLE QVariant toListModel(const QJSValue& value);
|
||||
Q_INVOKABLE void toJsArray();
|
||||
Q_INVOKABLE void await(QJSValue task, QJSValue successCallback, QJSValue failureCallback = QJSValue());
|
||||
Q_INVOKABLE void await(const QJSValue& task, const QJSValue& successCallback, const QJSValue& failureCallback = QJSValue());
|
||||
};
|
||||
|
||||
#endif // JSNETOBJECT_H
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@
|
|||
#include <QmlNet/qml/NetJsValue.h>
|
||||
#include <QDebug>
|
||||
#include <QJSEngine>
|
||||
#include <utility>
|
||||
|
||||
NetJSValue::NetJSValue(QJSValue jsValue) :
|
||||
_jsValue(jsValue)
|
||||
_jsValue(std::move(jsValue))
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -22,17 +23,17 @@ 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();
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> NetJSValue::call(QSharedPointer<NetVariantList> parameters)
|
||||
QSharedPointer<NetVariant> NetJSValue::call(const QSharedPointer<NetVariantList>& parameters)
|
||||
{
|
||||
QJSValueList jsValueList;
|
||||
if(parameters != nullptr) {
|
||||
|
|
@ -45,7 +46,7 @@ QSharedPointer<NetVariant> NetJSValue::call(QSharedPointer<NetVariantList> param
|
|||
return NetVariant::fromQJSValue(_jsValue.call(jsValueList));
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> NetJSValue::getProperty(QString propertyName)
|
||||
QSharedPointer<NetVariant> NetJSValue::getProperty(const QString& propertyName)
|
||||
{
|
||||
QJSValue property = _jsValue.property(propertyName);
|
||||
return NetVariant::fromQJSValue(property);
|
||||
|
|
@ -57,7 +58,7 @@ QSharedPointer<NetVariant> NetJSValue::getItemAtIndex(quint32 arrayIndex)
|
|||
return NetVariant::fromQJSValue(property);
|
||||
}
|
||||
|
||||
void NetJSValue::setProperty(QString propertyName, QSharedPointer<NetVariant> variant)
|
||||
void NetJSValue::setProperty(const QString& propertyName, const QSharedPointer<NetVariant>& variant)
|
||||
{
|
||||
QJSValue value = QJSValue::NullValue;
|
||||
if(variant != nullptr) {
|
||||
|
|
@ -66,7 +67,7 @@ void NetJSValue::setProperty(QString propertyName, QSharedPointer<NetVariant> va
|
|||
_jsValue.setProperty(propertyName, value);
|
||||
}
|
||||
|
||||
void NetJSValue::setItemAtIndex(quint32 arrayIndex, QSharedPointer<NetVariant> variant)
|
||||
void NetJSValue::setItemAtIndex(quint32 arrayIndex, const QSharedPointer<NetVariant>& variant)
|
||||
{
|
||||
QJSValue value = QJSValue::NullValue;
|
||||
if(variant != nullptr) {
|
||||
|
|
@ -82,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) {
|
||||
|
|
@ -102,7 +111,7 @@ Q_DECL_EXPORT NetVariantContainer* net_js_value_call(NetJSValueContainer* jsValu
|
|||
}
|
||||
|
||||
Q_DECL_EXPORT NetVariantContainer* net_js_value_getProperty(NetJSValueContainer* jsValueContainer, LPWSTR propertyName) {
|
||||
QSharedPointer<NetVariant> result = jsValueContainer->jsValue->getProperty(QString::fromUtf16((const char16_t*)propertyName));
|
||||
QSharedPointer<NetVariant> result = jsValueContainer->jsValue->getProperty(QString::fromUtf16(static_cast<const char16_t*>(propertyName)));
|
||||
if(result == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -122,7 +131,7 @@ Q_DECL_EXPORT void net_js_value_setProperty(NetJSValueContainer* jsValueContaine
|
|||
if(valueContainer != nullptr) {
|
||||
value = valueContainer->variant;
|
||||
}
|
||||
jsValueContainer->jsValue->setProperty(QString::fromUtf16((const char16_t*)propertyName), value);
|
||||
jsValueContainer->jsValue->setProperty(QString::fromUtf16(static_cast<const char16_t*>(propertyName)), value);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_js_value_setItemAtIndex(NetJSValueContainer* jsValueContainer, quint32 arrayIndex, NetVariantContainer* valueContainer) {
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ public:
|
|||
NetJSValue(QJSValue jsValue);
|
||||
~NetJSValue();
|
||||
QJSValue getJsValue();
|
||||
bool isCallable();
|
||||
bool isArray();
|
||||
QSharedPointer<NetVariant> call(QSharedPointer<NetVariantList> parameters);
|
||||
QSharedPointer<NetVariant> getProperty(QString propertyName);
|
||||
bool isCallable() const;
|
||||
bool isArray() const;
|
||||
QSharedPointer<NetVariant> call(const QSharedPointer<NetVariantList>& parameters);
|
||||
QSharedPointer<NetVariant> getProperty(const QString& propertyName);
|
||||
QSharedPointer<NetVariant> getItemAtIndex(quint32 arrayIndex);
|
||||
void setProperty(QString propertyName, QSharedPointer<NetVariant> variant);
|
||||
void setItemAtIndex(quint32 arrayIndex, QSharedPointer<NetVariant> variant);
|
||||
void setProperty(const QString& propertyName, const QSharedPointer<NetVariant>& variant);
|
||||
void setItemAtIndex(quint32 arrayIndex, const QSharedPointer<NetVariant>& variant);
|
||||
private:
|
||||
QJSValue _jsValue;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,19 +2,20 @@
|
|||
#include <QmlNet/types/NetReference.h>
|
||||
#include <QmlNet/types/NetTypeArrayFacade.h>
|
||||
#include <QmlNet/qml/NetVariant.h>
|
||||
#include <QDebug>
|
||||
|
||||
NetListModel::NetListModel(
|
||||
QObject* parent,
|
||||
QSharedPointer<NetTypeArrayFacade> facade,
|
||||
QSharedPointer<NetReference> reference) :
|
||||
QAbstractListModel(parent),
|
||||
_facade(facade),
|
||||
_reference(reference)
|
||||
_facade(std::move(facade)),
|
||||
_reference(std::move(reference))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NetListModel* NetListModel::fromReference(QSharedPointer<NetReference> reference)
|
||||
NetListModel* NetListModel::fromReference(const QSharedPointer<NetReference>& reference)
|
||||
{
|
||||
QSharedPointer<NetTypeArrayFacade> facade = reference->getTypeInfo()->getArrayFacade();
|
||||
if(facade == nullptr) {
|
||||
|
|
@ -26,7 +27,7 @@ NetListModel* NetListModel::fromReference(QSharedPointer<NetReference> reference
|
|||
QVariant NetListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if(role != 0) {
|
||||
qWarning("invalid role id: %d", role);
|
||||
qWarning() << "invalid role id:" << role;
|
||||
return QVariant();
|
||||
}
|
||||
int length = static_cast<int>(_facade->getLength(_reference));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class NetListModel : public QAbstractListModel
|
|||
public:
|
||||
NetListModel(QObject* parent, QSharedPointer<NetTypeArrayFacade> facade, QSharedPointer<NetReference> reference);
|
||||
|
||||
static NetListModel* fromReference(QSharedPointer<NetReference> reference);
|
||||
static NetListModel* fromReference(const QSharedPointer<NetReference>& reference);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ extern "C" {
|
|||
|
||||
Q_DECL_EXPORT void net_test_helper_runQml(QQmlApplicationEngineContainer* qmlEngineContainer, LPWSTR qml) {
|
||||
QQmlComponent component(qmlEngineContainer->qmlEngine);
|
||||
QString qmlString = QString::fromUtf16((const char16_t*)qml);
|
||||
QString qmlString = QString::fromUtf16(static_cast<const char16_t*>(qml));
|
||||
component.setData(qmlString.toUtf8(), QUrl());
|
||||
QObject *object = component.create();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <QmlNet/qml/NetValueMetaObject.h>
|
||||
#include <QmlNet/types/NetSignalInfo.h>
|
||||
#include <QDebug>
|
||||
#include <utility>
|
||||
|
||||
NetValue::~NetValue()
|
||||
{
|
||||
|
|
@ -16,6 +17,9 @@ NetValue::~NetValue()
|
|||
delete collection;
|
||||
}
|
||||
}
|
||||
#ifdef QMLNET_TRACE
|
||||
qDebug("netvalue: destroyed: for: %s", qPrintable(instance->displayName()));
|
||||
#endif
|
||||
instance = nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -25,7 +29,7 @@ QSharedPointer<NetReference> NetValue::getNetReference()
|
|||
return instance;
|
||||
}
|
||||
|
||||
bool NetValue::activateSignal(QString signalName, QSharedPointer<NetVariantList> arguments)
|
||||
bool NetValue::activateSignal(const QString& signalName, const QSharedPointer<NetVariantList>& arguments)
|
||||
{
|
||||
int signalMethodIndex = -1;
|
||||
for(int x = 0; valueMeta->methodCount(); x++) {
|
||||
|
|
@ -38,12 +42,12 @@ bool NetValue::activateSignal(QString signalName, QSharedPointer<NetVariantList>
|
|||
|
||||
// If signal not found, dump the registered signals for debugging.
|
||||
if(signalMethodIndex < 0) {
|
||||
qDebug("Signal not found: %s", qPrintable(signalName));
|
||||
qDebug("Current signals:");
|
||||
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("\t%s", qPrintable(method.methodSignature()));
|
||||
qDebug().nospace() << "\t" << method.methodSignature();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -55,30 +59,30 @@ bool NetValue::activateSignal(QString signalName, QSharedPointer<NetVariantList>
|
|||
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<QVariant> variant = QSharedPointer<QVariant>(new QVariant(arguments->get(x)->toQVariant()));
|
||||
QSharedPointer<QVariant> variant(new QVariant(arguments->get(x)->toQVariant()));
|
||||
variantArgs.append(variant);
|
||||
voidArgs.push_back(static_cast<void*>(variant.data()));
|
||||
}
|
||||
}
|
||||
void** argsPointer = nullptr;
|
||||
if(voidArgs.size() > 0) {
|
||||
if(!voidArgs.empty()) {
|
||||
argsPointer = &voidArgs[0];
|
||||
}
|
||||
|
||||
// Activate the signal!
|
||||
valueMeta->activate(this, signalMethodIndex, argsPointer);
|
||||
NetValueMetaObject::activate(this, signalMethodIndex, argsPointer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NetValue* NetValue::forInstance(QSharedPointer<NetReference> instance)
|
||||
NetValue* NetValue::forInstance(const QSharedPointer<NetReference>& instance)
|
||||
{
|
||||
NetValue* result = new NetValue(instance, nullptr);
|
||||
QQmlEngine::setObjectOwnership(result, QQmlEngine::JavaScriptOwnership);
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<NetValue*> NetValue::getAllLiveInstances(QSharedPointer<NetReference> instance)
|
||||
QList<NetValue*> NetValue::getAllLiveInstances(const QSharedPointer<NetReference>& instance)
|
||||
{
|
||||
auto objectId = instance->getObjectId();
|
||||
NetValueCollection* collection = nullptr;
|
||||
|
|
@ -90,9 +94,13 @@ QList<NetValue*> NetValue::getAllLiveInstances(QSharedPointer<NetReference> inst
|
|||
return QList<NetValue*>();
|
||||
}
|
||||
|
||||
NetValue::NetValue(QSharedPointer<NetReference> instance, QObject *parent)
|
||||
NetValue::NetValue(const QSharedPointer<NetReference>& instance, QObject *parent)
|
||||
: instance(instance)
|
||||
{
|
||||
#ifdef QMLNET_TRACE
|
||||
qDebug("netvalue: created: for: %s", qPrintable(instance->displayName()));
|
||||
#endif
|
||||
|
||||
valueMeta = new NetValueMetaObject(this, instance);
|
||||
setParent(parent);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class NetValueMetaObject;
|
|||
|
||||
struct NetValueInterface
|
||||
{
|
||||
virtual ~NetValueInterface() {}
|
||||
virtual QSharedPointer<NetReference> getNetReference() = 0;
|
||||
};
|
||||
|
||||
|
|
@ -25,13 +26,13 @@ class NetValue : public QObject, NetValueInterface
|
|||
public:
|
||||
virtual ~NetValue();
|
||||
QSharedPointer<NetReference> getNetReference();
|
||||
bool activateSignal(QString signalName, QSharedPointer<NetVariantList> arguments);
|
||||
bool activateSignal(const QString& signalName, const QSharedPointer<NetVariantList>& arguments);
|
||||
|
||||
static NetValue* forInstance(QSharedPointer<NetReference> instance);
|
||||
static QList<NetValue*> getAllLiveInstances(QSharedPointer<NetReference> instance);
|
||||
static NetValue* forInstance(const QSharedPointer<NetReference>& instance);
|
||||
static QList<NetValue*> getAllLiveInstances(const QSharedPointer<NetReference>& instance);
|
||||
|
||||
protected:
|
||||
NetValue(QSharedPointer<NetReference> instance, QObject *parent);
|
||||
NetValue(const QSharedPointer<NetReference>& instance, QObject *parent);
|
||||
|
||||
private:
|
||||
QSharedPointer<NetReference> instance;
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
#include <QDebug>
|
||||
#include <private/qmetaobjectbuilder_p.h>
|
||||
|
||||
QMetaObject *metaObjectFor(QSharedPointer<NetTypeInfo> typeInfo)
|
||||
QMetaObject *metaObjectFor(const QSharedPointer<NetTypeInfo>& typeInfo)
|
||||
{
|
||||
if (typeInfo->metaObject) {
|
||||
return reinterpret_cast<QMetaObject *>(typeInfo->metaObject);
|
||||
return typeInfo->metaObject;
|
||||
}
|
||||
|
||||
typeInfo->ensureLoaded();
|
||||
|
|
@ -88,7 +88,7 @@ QMetaObject *metaObjectFor(QSharedPointer<NetTypeInfo> typeInfo)
|
|||
}
|
||||
|
||||
NetValueMetaObject::NetValueMetaObject(QObject *value,
|
||||
QSharedPointer<NetReference> instance) :
|
||||
const QSharedPointer<NetReference>& instance) :
|
||||
value(value),
|
||||
instance(instance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
#include <QmlNet/qml/NetValue.h>
|
||||
#include <private/qobject_p.h>
|
||||
|
||||
QMetaObject *metaObjectFor(QSharedPointer<NetTypeInfo> typeInfo);
|
||||
QMetaObject *metaObjectFor(const QSharedPointer<NetTypeInfo>& typeInfo);
|
||||
|
||||
class NetValueMetaObject : public QAbstractDynamicMetaObject
|
||||
{
|
||||
public:
|
||||
NetValueMetaObject(QObject* value, QSharedPointer<NetReference> instance);
|
||||
NetValueMetaObject(QObject* value, const QSharedPointer<NetReference>& instance);
|
||||
|
||||
protected:
|
||||
int metaCall(QMetaObject::Call c, int id, void **a);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ const char* NetValueTypePacker::getQmlType()
|
|||
return "QVariant";
|
||||
}
|
||||
|
||||
void NetValueTypePacker::pack(QSharedPointer<NetVariant> source, void* destination)
|
||||
void NetValueTypePacker::pack(const QSharedPointer<NetVariant>& source, void* destination)
|
||||
{
|
||||
QVariant* destinationVariant = static_cast<QVariant*>(destination);
|
||||
switch(source->getVariantType()) {
|
||||
case NetVariantTypeEnum_Invalid:
|
||||
destinationVariant->clear();
|
||||
destinationVariant->setValue(QVariant::fromValue(nullptr));
|
||||
break;
|
||||
case NetVariantTypeEnum_Bool:
|
||||
destinationVariant->setValue(source->getBool());
|
||||
|
|
@ -27,6 +27,15 @@ void NetValueTypePacker::pack(QSharedPointer<NetVariant> source, void* destinati
|
|||
case NetVariantTypeEnum_UInt:
|
||||
destinationVariant->setValue(source->getUInt());
|
||||
break;
|
||||
case NetVariantTypeEnum_Long:
|
||||
destinationVariant->setValue(source->getLong());
|
||||
break;
|
||||
case NetVariantTypeEnum_ULong:
|
||||
destinationVariant->setValue(source->getULong());
|
||||
break;
|
||||
case NetVariantTypeEnum_Float:
|
||||
destinationVariant->setValue(source->getFloat());
|
||||
break;
|
||||
case NetVariantTypeEnum_Double:
|
||||
destinationVariant->setValue(source->getDouble());
|
||||
break;
|
||||
|
|
@ -43,16 +52,15 @@ void NetValueTypePacker::pack(QSharedPointer<NetVariant> source, void* destinati
|
|||
destinationVariant->setValue(netValue);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning() << "Unsupported variant type: " << source->getVariantType();
|
||||
case NetVariantTypeEnum_JSValue:
|
||||
destinationVariant->setValue(source->getJsValue()->getJsValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NetValueTypePacker::unpack(QSharedPointer<NetVariant> destination, void* source, NetVariantTypeEnum prefType)
|
||||
void NetValueTypePacker::unpack(const QSharedPointer<NetVariant>& destination, void* source, NetVariantTypeEnum prefType)
|
||||
{
|
||||
QVariant* sourceVariant = static_cast<QVariant*>(source);
|
||||
bool ok = false;
|
||||
|
||||
if(sourceVariant->isNull()) {
|
||||
destination->clear();
|
||||
|
|
@ -60,75 +68,50 @@ void NetValueTypePacker::unpack(QSharedPointer<NetVariant> destination, void* so
|
|||
}
|
||||
|
||||
switch(prefType) {
|
||||
case NetVariantTypeEnum_Invalid:
|
||||
destination->clear();
|
||||
return;
|
||||
case NetVariantTypeEnum_Bool:
|
||||
destination->setBool(sourceVariant->toBool());
|
||||
return;
|
||||
case NetVariantTypeEnum_Char: {
|
||||
QString v = sourceVariant->toString();
|
||||
if(v.isNull() || v.isEmpty()) {
|
||||
qDebug() << "Can't set empty string to char, setting to null.";
|
||||
destination->setChar(QChar::Null);
|
||||
case NetVariantTypeEnum_Char:
|
||||
{
|
||||
const QString& v = sourceVariant->toString();
|
||||
if(v.length() == 1) {
|
||||
destination->setChar(v.at(0));
|
||||
} else {
|
||||
if(v.length() == 1) {
|
||||
destination->setChar(v.at(0));
|
||||
} else {
|
||||
qDebug() << "Can't set string to char that has more than one character.";
|
||||
destination->setChar(QChar::Null);
|
||||
}
|
||||
qDebug() << "Can't set string" << v << "to char.";
|
||||
destination->setChar(QChar::Null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case NetVariantTypeEnum_Int:
|
||||
{
|
||||
int result = sourceVariant->toInt(&ok);
|
||||
if(ok) {
|
||||
destination->setInt(result);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
destination->setInt(sourceVariant->value<qint32>());
|
||||
return;
|
||||
case NetVariantTypeEnum_UInt:
|
||||
{
|
||||
unsigned int result = sourceVariant->toUInt(&ok);
|
||||
if(ok) {
|
||||
destination->setUInt(result);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
destination->setUInt(sourceVariant->value<quint32>());
|
||||
return;
|
||||
case NetVariantTypeEnum_Long:
|
||||
destination->setLong(sourceVariant->value<qint64>());
|
||||
return;
|
||||
case NetVariantTypeEnum_ULong:
|
||||
destination->setULong(sourceVariant->value<quint64>());
|
||||
return;
|
||||
case NetVariantTypeEnum_Float:
|
||||
destination->setFloat(sourceVariant->toFloat());
|
||||
return;
|
||||
case NetVariantTypeEnum_Double:
|
||||
{
|
||||
double result = sourceVariant->toDouble(&ok);
|
||||
if(ok) {
|
||||
destination->setDouble(result);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
destination->setDouble(sourceVariant->toDouble());
|
||||
return;
|
||||
case NetVariantTypeEnum_String:
|
||||
{
|
||||
QString stringResult = sourceVariant->toString();
|
||||
destination->setString(&stringResult);
|
||||
destination->setString(sourceVariant->toString());
|
||||
return;
|
||||
}
|
||||
case NetVariantTypeEnum_DateTime:
|
||||
{
|
||||
QDateTime dateTimeResult = sourceVariant->toDateTime();
|
||||
if(!dateTimeResult.isValid()) {
|
||||
qDebug() << "Invalid date time";
|
||||
break;
|
||||
}
|
||||
if(dateTimeResult.isNull()) {
|
||||
destination->clear();
|
||||
break;
|
||||
}
|
||||
destination->setDateTime(dateTimeResult);
|
||||
destination->setDateTime(sourceVariant->toDateTime());
|
||||
return;
|
||||
}
|
||||
case NetVariantTypeEnum_Object:
|
||||
{
|
||||
if (sourceVariant->type() == static_cast<QVariant::Type>(QMetaType::QObjectStar)) {
|
||||
|
||||
if(sourceVariant->userType() == QMetaType::QObjectStar) {
|
||||
QObject* value = sourceVariant->value<QObject*>();
|
||||
NetValueInterface* netValue = qobject_cast<NetValueInterface*>(value);
|
||||
if(netValue) {
|
||||
|
|
@ -141,64 +124,81 @@ void NetValueTypePacker::unpack(QSharedPointer<NetVariant> destination, void* so
|
|||
case NetVariantTypeEnum_JSValue:
|
||||
{
|
||||
if(sourceVariant->userType() == qMetaTypeId<QJSValue>()) {
|
||||
QSharedPointer<NetJSValue> netJsValue = QSharedPointer<NetJSValue>(new NetJSValue(sourceVariant->value<QJSValue>()));
|
||||
QSharedPointer<NetJSValue> netJsValue(new NetJSValue(sourceVariant->value<QJSValue>()));
|
||||
destination->setJsValue(netJsValue);
|
||||
return;
|
||||
} else {
|
||||
// TODO: Try to convert other types to JS Value.
|
||||
}
|
||||
// TODO: Try to convert other types to JS Value.
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
NetVariant::fromQVariant(sourceVariant, destination);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class StringValueTypePacker : public NetValueTypePacker
|
||||
{
|
||||
public:
|
||||
const char* getQmlType()
|
||||
const char* getQmlType() override
|
||||
{
|
||||
return "QString";
|
||||
}
|
||||
void pack(QSharedPointer<NetVariant> source, void* destination)
|
||||
void pack(const QSharedPointer<NetVariant>& source, void* destination) override
|
||||
{
|
||||
Q_ASSERT(source->getVariantType() == NetVariantTypeEnum_String || source->getVariantType() == NetVariantTypeEnum_Invalid);
|
||||
QString* destinationString = static_cast<QString*>(destination);
|
||||
switch(source->getVariantType()){
|
||||
case NetVariantTypeEnum_Invalid:
|
||||
// Leave it empty
|
||||
destinationString->clear();
|
||||
break;
|
||||
case NetVariantTypeEnum_String:
|
||||
*destinationString = source->getString();
|
||||
break;
|
||||
default:
|
||||
qWarning("Attempting to set a variant id %d to a QString", source->getVariantType());
|
||||
qWarning() << "Attempting to set a variant id" << source->getVariantType() << "to a QString";
|
||||
break;
|
||||
}
|
||||
}
|
||||
void unpack(QSharedPointer<NetVariant> destination, void* source, NetVariantTypeEnum)
|
||||
void unpack(const QSharedPointer<NetVariant>& destination, void* source, NetVariantTypeEnum prefType) override
|
||||
{
|
||||
Q_ASSERT(prefType == NetVariantTypeEnum_String);
|
||||
QString* sourceString = static_cast<QString*>(source);
|
||||
destination->setString(sourceString);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
NetValueMetaObjectPacker::NetValueMetaObjectPacker()
|
||||
{
|
||||
NetValueTypePacker* variantPacker = new NetValueTypePacker();
|
||||
StringValueTypePacker* stringPacker = new StringValueTypePacker();
|
||||
packers[NetVariantTypeEnum_Invalid] = variantPacker;
|
||||
packers[NetVariantTypeEnum_Bool] = variantPacker;
|
||||
packers[NetVariantTypeEnum_Char] = variantPacker;
|
||||
packers[NetVariantTypeEnum_Int] = variantPacker;
|
||||
packers[NetVariantTypeEnum_UInt] = variantPacker;
|
||||
packers[NetVariantTypeEnum_Double] = variantPacker;
|
||||
packers[NetVariantTypeEnum_String] = stringPacker;
|
||||
packers[NetVariantTypeEnum_DateTime] = variantPacker;
|
||||
packers[NetVariantTypeEnum_Object] = variantPacker;
|
||||
packers[NetVariantTypeEnum_JSValue] = variantPacker;
|
||||
|
||||
//This is might not be pretty, but it does allow the compiler generate a warning if a value is missing.
|
||||
for (int typeInt = NetVariantTypeEnum_Invalid; typeInt <= NetVariantTypeEnum_JSValue; ++typeInt)
|
||||
{
|
||||
NetVariantTypeEnum type = NetVariantTypeEnum(typeInt);
|
||||
switch(type) {
|
||||
case NetVariantTypeEnum_Invalid:
|
||||
case NetVariantTypeEnum_Bool:
|
||||
case NetVariantTypeEnum_Char:
|
||||
case NetVariantTypeEnum_Int:
|
||||
case NetVariantTypeEnum_UInt:
|
||||
case NetVariantTypeEnum_Long:
|
||||
case NetVariantTypeEnum_ULong:
|
||||
case NetVariantTypeEnum_Float:
|
||||
case NetVariantTypeEnum_Double:
|
||||
case NetVariantTypeEnum_DateTime:
|
||||
case NetVariantTypeEnum_Object:
|
||||
case NetVariantTypeEnum_JSValue:
|
||||
packers[type] = variantPacker;
|
||||
break;
|
||||
case NetVariantTypeEnum_String:
|
||||
packers[type] = stringPacker;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetValueMetaObjectPacker* NetValueMetaObjectPacker::getInstance()
|
||||
|
|
@ -209,5 +209,6 @@ NetValueMetaObjectPacker* NetValueMetaObjectPacker::getInstance()
|
|||
|
||||
NetValueTypePacker* NetValueMetaObjectPacker::getPacker(NetVariantTypeEnum variantType)
|
||||
{
|
||||
Q_ASSERT(packers.contains(variantType));
|
||||
return packers[variantType];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ public:
|
|||
NetValueTypePacker() {}
|
||||
virtual ~NetValueTypePacker() {}
|
||||
virtual const char* getQmlType();
|
||||
virtual void pack(QSharedPointer<NetVariant> source, void* destination);
|
||||
virtual void unpack(QSharedPointer<NetVariant> destination, void* source, NetVariantTypeEnum prefType);
|
||||
virtual void pack(const QSharedPointer<NetVariant>& source, void* destination);
|
||||
virtual void unpack(const QSharedPointer<NetVariant>& destination, void* source, NetVariantTypeEnum prefType);
|
||||
};
|
||||
|
||||
#define NetMetaValuePack(type, source, destination) \
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <QmlNet/qml/NetValue.h>
|
||||
#include <QmlNet/qml/NetValueMetaObject.h>
|
||||
#include <QmlNet/types/Callbacks.h>
|
||||
#include <QQmlEngine>
|
||||
|
||||
template <int N>
|
||||
class NetValueType : public NetValue
|
||||
|
|
@ -20,6 +21,13 @@ public:
|
|||
static_cast<QMetaObject &>(staticMetaObject) = *metaObjectFor(typeInfo);
|
||||
}
|
||||
|
||||
static QObject *build(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine)
|
||||
Q_UNUSED(scriptEngine)
|
||||
return new NetValueType<N>();
|
||||
}
|
||||
|
||||
static QSharedPointer<NetTypeInfo> typeInfo;
|
||||
static QMetaObject staticMetaObject;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include <QDebug>
|
||||
#include <QJSEngine>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct NetReferenceQmlContainer
|
||||
{
|
||||
QSharedPointer<NetReference> netReference;
|
||||
|
|
@ -15,158 +17,167 @@ struct NetJsValueQmlContainer
|
|||
{
|
||||
QSharedPointer<NetJSValue> jsValue;
|
||||
};
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(NetReferenceQmlContainer)
|
||||
Q_DECLARE_METATYPE(NetJsValueQmlContainer)
|
||||
|
||||
NetVariant::NetVariant()
|
||||
namespace
|
||||
{
|
||||
|
||||
const int NetReferenceQmlContainerTypeId = qMetaTypeId<NetReferenceQmlContainer>();
|
||||
const int NetJsValueQmlContainerTypeId = qMetaTypeId<NetJsValueQmlContainer>();
|
||||
}
|
||||
|
||||
NetVariant::NetVariant() = default;
|
||||
|
||||
NetVariant::~NetVariant()
|
||||
{
|
||||
clearNetReference();
|
||||
}
|
||||
|
||||
NetVariantTypeEnum NetVariant::getVariantType()
|
||||
NetVariantTypeEnum NetVariant::getVariantType() const
|
||||
{
|
||||
switch(variant.type()) {
|
||||
case QVariant::Invalid:
|
||||
const int type = variant.userType();
|
||||
switch(type) {
|
||||
case QMetaType::UnknownType:
|
||||
return NetVariantTypeEnum_Invalid;
|
||||
case QVariant::Bool:
|
||||
case QMetaType::Bool:
|
||||
return NetVariantTypeEnum_Bool;
|
||||
case QVariant::Char:
|
||||
case QMetaType::QChar:
|
||||
return NetVariantTypeEnum_Char;
|
||||
case QVariant::Int:
|
||||
case qMetaTypeId<qint32>():
|
||||
return NetVariantTypeEnum_Int;
|
||||
case QVariant::UInt:
|
||||
case qMetaTypeId<quint32>():
|
||||
return NetVariantTypeEnum_UInt;
|
||||
case QVariant::Double:
|
||||
case qMetaTypeId<qint64>():
|
||||
return NetVariantTypeEnum_Long;
|
||||
case qMetaTypeId<quint64>():
|
||||
return NetVariantTypeEnum_ULong;
|
||||
case QMetaType::Float:
|
||||
return NetVariantTypeEnum_Float;
|
||||
case QMetaType::Double:
|
||||
return NetVariantTypeEnum_Double;
|
||||
case QVariant::String:
|
||||
case QMetaType::QString:
|
||||
return NetVariantTypeEnum_String;
|
||||
case QVariant::DateTime:
|
||||
case QMetaType::QDateTime:
|
||||
return NetVariantTypeEnum_DateTime;
|
||||
case QVariant::UserType:
|
||||
if(strcmp(variant.typeName(), "NetReferenceQmlContainer") == 0)
|
||||
return NetVariantTypeEnum_Object;
|
||||
if(strcmp(variant.typeName(), "NetJsValueQmlContainer") == 0)
|
||||
return NetVariantTypeEnum_JSValue;
|
||||
qWarning() << "Unknown user type for NetVariant: " << variant.typeName();
|
||||
return NetVariantTypeEnum_Invalid;
|
||||
default:
|
||||
qWarning() << "Unsupported qt variant type: " << variant.type();
|
||||
return NetVariantTypeEnum_Invalid;
|
||||
if(type == NetReferenceQmlContainerTypeId) {
|
||||
return NetVariantTypeEnum_Object;
|
||||
}
|
||||
else if(type == NetJsValueQmlContainerTypeId) {
|
||||
return NetVariantTypeEnum_JSValue;
|
||||
} else {
|
||||
qWarning() << "Unknown type for NetVariant: " << variant.typeName();
|
||||
return NetVariantTypeEnum_Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetVariant::setNetReference(QSharedPointer<NetReference> netReference)
|
||||
{
|
||||
clearNetReference();
|
||||
variant.setValue(NetReferenceQmlContainer{ netReference });
|
||||
variant.setValue(NetReferenceQmlContainer{ std::move(netReference) });
|
||||
}
|
||||
|
||||
QSharedPointer<NetReference> NetVariant::getNetReference()
|
||||
QSharedPointer<NetReference> NetVariant::getNetReference() const
|
||||
{
|
||||
if(getVariantType() == NetVariantTypeEnum_Object) {
|
||||
return variant.value<NetReferenceQmlContainer>().netReference;
|
||||
}
|
||||
return nullptr;
|
||||
return getValue<NetReferenceQmlContainer>().netReference;
|
||||
}
|
||||
|
||||
void NetVariant::setBool(bool value)
|
||||
{
|
||||
clearNetReference();
|
||||
variant.setValue(value);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
bool NetVariant::getBool()
|
||||
bool NetVariant::getBool() const
|
||||
{
|
||||
if(variant.canConvert(QMetaType::Bool))
|
||||
return variant.value<int>();
|
||||
|
||||
qDebug() << "Can't convert value to bool";
|
||||
|
||||
return false;
|
||||
return getValue<bool>();
|
||||
}
|
||||
|
||||
void NetVariant::setChar(QChar value)
|
||||
{
|
||||
clearNetReference();
|
||||
variant.setValue(value);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
QChar NetVariant::getChar()
|
||||
QChar NetVariant::getChar() const
|
||||
{
|
||||
return variant.toChar();
|
||||
return getValue<QChar>();
|
||||
}
|
||||
|
||||
void NetVariant::setInt(int value)
|
||||
void NetVariant::setInt(qint32 value)
|
||||
{
|
||||
clearNetReference();
|
||||
variant.setValue(value);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
int NetVariant::getInt()
|
||||
qint32 NetVariant::getInt() const
|
||||
{
|
||||
if(variant.canConvert(QMetaType::Int))
|
||||
return variant.value<int>();
|
||||
|
||||
qDebug() << "Can't convert value to int";
|
||||
|
||||
return 0;
|
||||
return getValue<qint32>();
|
||||
}
|
||||
|
||||
void NetVariant::setUInt(unsigned int value)
|
||||
void NetVariant::setUInt(quint32 value)
|
||||
{
|
||||
clearNetReference();
|
||||
variant.setValue(value);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
unsigned int NetVariant::getUInt()
|
||||
quint32 NetVariant::getUInt() const
|
||||
{
|
||||
bool ok = false;
|
||||
unsigned int result = variant.toUInt(&ok);
|
||||
return getValue<quint32>();
|
||||
}
|
||||
|
||||
if(!ok) {
|
||||
qDebug() << "Couldn't convert variant to unsigned int";
|
||||
}
|
||||
void NetVariant::setLong(qint64 value)
|
||||
{
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
return result;
|
||||
qint64 NetVariant::getLong() const
|
||||
{
|
||||
return getValue<qint64>();
|
||||
}
|
||||
|
||||
void NetVariant::setULong(quint64 value)
|
||||
{
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
quint64 NetVariant::getULong() const
|
||||
{
|
||||
return getValue<quint64>();
|
||||
}
|
||||
|
||||
void NetVariant::setFloat(float value)
|
||||
{
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
float NetVariant::getFloat() const
|
||||
{
|
||||
return getValue<float>();
|
||||
}
|
||||
|
||||
void NetVariant::setDouble(double value)
|
||||
{
|
||||
clearNetReference();
|
||||
variant.setValue(value);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
double NetVariant::getDouble()
|
||||
double NetVariant::getDouble() const
|
||||
{
|
||||
bool ok = false;
|
||||
double result = variant.toDouble(&ok);
|
||||
|
||||
if(!ok) {
|
||||
qDebug() << "Couldn't convert variant to double";
|
||||
}
|
||||
|
||||
return result;
|
||||
return getValue<double>();
|
||||
}
|
||||
|
||||
void NetVariant::setString(QString* value)
|
||||
void NetVariant::setString(const QString* value)
|
||||
{
|
||||
clearNetReference();
|
||||
if(value) {
|
||||
variant.setValue(*value);
|
||||
} else {
|
||||
variant.clear();
|
||||
}
|
||||
setValuePtr(value);
|
||||
}
|
||||
|
||||
QString NetVariant::getString()
|
||||
void NetVariant::setString(const QString& value)
|
||||
{
|
||||
if(variant.type() != QVariant::String) {
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
QString NetVariant::getString() const
|
||||
{
|
||||
if(variant.userType() != QMetaType::QString) {
|
||||
qDebug() << "Variant is not a string";
|
||||
return QString();
|
||||
}
|
||||
|
|
@ -174,33 +185,24 @@ QString NetVariant::getString()
|
|||
return variant.toString();
|
||||
}
|
||||
|
||||
void NetVariant::setDateTime(QDateTime& value)
|
||||
void NetVariant::setDateTime(const QDateTime& value)
|
||||
{
|
||||
clearNetReference();
|
||||
if(value.isNull()) {
|
||||
variant.clear();
|
||||
} else {
|
||||
variant.setValue(value);
|
||||
}
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
QDateTime NetVariant::getDateTime()
|
||||
QDateTime NetVariant::getDateTime() const
|
||||
{
|
||||
return variant.toDateTime();
|
||||
return getValue<QDateTime>();
|
||||
}
|
||||
|
||||
void NetVariant::setJsValue(QSharedPointer<NetJSValue> jsValue)
|
||||
{
|
||||
clearNetReference();
|
||||
variant.setValue(NetJsValueQmlContainer{ jsValue });
|
||||
setValue(NetJsValueQmlContainer{ std::move(jsValue) });
|
||||
}
|
||||
|
||||
QSharedPointer<NetJSValue> NetVariant::getJsValue()
|
||||
QSharedPointer<NetJSValue> NetVariant::getJsValue() const
|
||||
{
|
||||
if(getVariantType() == NetVariantTypeEnum_JSValue) {
|
||||
return variant.value<NetJsValueQmlContainer>().jsValue;
|
||||
}
|
||||
return nullptr;
|
||||
return getValue<NetJsValueQmlContainer>().jsValue;
|
||||
}
|
||||
|
||||
void NetVariant::clear()
|
||||
|
|
@ -228,8 +230,7 @@ QSharedPointer<NetVariant> NetVariant::fromQJSValue(const QJSValue& qJsValue)
|
|||
else if(qJsValue.isObject()) {
|
||||
result = QSharedPointer<NetVariant>(new NetVariant());
|
||||
result->setJsValue(QSharedPointer<NetJSValue>(new NetJSValue(qJsValue)));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result = QSharedPointer<NetVariant>(new NetVariant());
|
||||
QVariant variant = qJsValue.toVariant();
|
||||
result->variant = variant;
|
||||
|
|
@ -237,7 +238,7 @@ QSharedPointer<NetVariant> NetVariant::fromQJSValue(const QJSValue& qJsValue)
|
|||
return result;
|
||||
}
|
||||
|
||||
QJSValue NetVariant::toQJSValue(QJSEngine* jsEngine)
|
||||
QJSValue NetVariant::toQJSValue(QJSEngine* jsEngine) const
|
||||
{
|
||||
switch(getVariantType()) {
|
||||
case NetVariantTypeEnum_Object: {
|
||||
|
|
@ -253,120 +254,129 @@ QJSValue NetVariant::toQJSValue(QJSEngine* jsEngine)
|
|||
}
|
||||
}
|
||||
|
||||
void NetVariant::fromQVariant(const QVariant* variant, QSharedPointer<NetVariant> destination)
|
||||
void NetVariant::fromQVariant(const QVariant* variant, const QSharedPointer<NetVariant>& destination)
|
||||
{
|
||||
switch(variant->type()) {
|
||||
case QVariant::Invalid:
|
||||
const int type = variant->userType();
|
||||
switch(type) {
|
||||
case QMetaType::UnknownType:
|
||||
destination->clear();
|
||||
break;
|
||||
case QVariant::Bool:
|
||||
destination->setBool(variant->value<bool>());
|
||||
case QMetaType::Bool:
|
||||
case QMetaType::QChar:
|
||||
case qMetaTypeId<qint32>():
|
||||
case qMetaTypeId<quint32>():
|
||||
case qMetaTypeId<qint64>():
|
||||
case qMetaTypeId<quint64>():
|
||||
case QMetaType::Float:
|
||||
case QMetaType::Double:
|
||||
case QMetaType::QString:
|
||||
case QMetaType::QDateTime:
|
||||
destination->setValueVariant(*variant);
|
||||
break;
|
||||
case QVariant::Char:
|
||||
destination->setChar(variant->toChar());
|
||||
break;
|
||||
case QVariant::Int:
|
||||
destination->setInt(variant->value<int>());
|
||||
break;
|
||||
case QVariant::UInt:
|
||||
destination->setUInt(variant->value<unsigned int>());
|
||||
break;
|
||||
case QVariant::Double:
|
||||
destination->setDouble(variant->value<double>());
|
||||
break;
|
||||
case QVariant::String:
|
||||
{
|
||||
QString stringValue = variant->toString();
|
||||
destination->setString(&stringValue);
|
||||
break;
|
||||
}
|
||||
case QVariant::DateTime:
|
||||
{
|
||||
QDateTime dateTimeValue = variant->toDateTime();
|
||||
destination->setDateTime(dateTimeValue);
|
||||
case QMetaType::QObjectStar: {
|
||||
QObject* value = variant->value<QObject*>();
|
||||
NetValueInterface* netValue = qobject_cast<NetValueInterface*>(value);
|
||||
if(netValue) {
|
||||
destination->setNetReference(netValue->getNetReference());
|
||||
} else {
|
||||
qDebug() << "Unsupported variant type: " << variant->type() << variant->typeName();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
if(variant->userType() == qMetaTypeId<QJSValue>()) {
|
||||
if(type == qMetaTypeId<QJSValue>()) {
|
||||
// TODO: Either serialize this type to a string, to be deserialized in .NET, or
|
||||
// pass raw value to .NET to be dynamically invoked (using dynamic).
|
||||
// See qtdeclarative\src\plugins\qmltooling\qmldbg_debugger\qqmlenginedebugservice.cpp:184
|
||||
// for serialization methods.
|
||||
QSharedPointer<NetJSValue> netJsValue = QSharedPointer<NetJSValue>(new NetJSValue(variant->value<QJSValue>()));
|
||||
QSharedPointer<NetJSValue> netJsValue(new NetJSValue(variant->value<QJSValue>()));
|
||||
destination->setJsValue(netJsValue);
|
||||
break;
|
||||
}
|
||||
|
||||
if(variant->userType() == QMetaType::QObjectStar) {
|
||||
QObject* value = variant->value<QObject*>();
|
||||
NetValueInterface* netValue = qobject_cast<NetValueInterface*>(value);
|
||||
if(netValue) {
|
||||
destination->setNetReference(netValue->getNetReference());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "Unsupported variant type: " << variant->type();
|
||||
qDebug() << "Unsupported variant type: " << variant->type() << variant->typeName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> NetVariant::fromQVariant(const QVariant* variant)
|
||||
{
|
||||
QSharedPointer<NetVariant> result = QSharedPointer<NetVariant>(new NetVariant());
|
||||
QSharedPointer<NetVariant> result(new NetVariant());
|
||||
fromQVariant(variant, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariant NetVariant::toQVariant()
|
||||
QVariant NetVariant::toQVariant() const
|
||||
{
|
||||
QVariant result;
|
||||
switch(getVariantType()) {
|
||||
case NetVariantTypeEnum_JSValue:
|
||||
result = getJsValue()->getJsValue().toVariant();
|
||||
break;
|
||||
return getJsValue()->getJsValue().toVariant();
|
||||
case NetVariantTypeEnum_Object:
|
||||
result = QVariant::fromValue<QObject*>(NetValue::forInstance(getNetReference()));
|
||||
break;
|
||||
return QVariant::fromValue<QObject*>(NetValue::forInstance(getNetReference()));
|
||||
default:
|
||||
result = variant;
|
||||
break;
|
||||
return variant;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString NetVariant::getDisplayValue()
|
||||
QString NetVariant::getDisplayValue() const
|
||||
{
|
||||
QString result;
|
||||
switch(getVariantType()) {
|
||||
case NetVariantTypeEnum_JSValue:
|
||||
result = getJsValue()->getJsValue().toString();
|
||||
break;
|
||||
return getJsValue()->getJsValue().toString();
|
||||
case NetVariantTypeEnum_Object:
|
||||
result = getNetReference()->displayName();
|
||||
break;
|
||||
return getNetReference()->displayName();
|
||||
default:
|
||||
result = variant.toString();
|
||||
break;
|
||||
return variant.toString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void NetVariant::clearNetReference()
|
||||
{
|
||||
if(variant.canConvert<NetReferenceQmlContainer>())
|
||||
{
|
||||
if(variant.canConvert<NetReferenceQmlContainer>()) {
|
||||
variant.value<NetReferenceQmlContainer>().netReference.clear();
|
||||
variant.clear();
|
||||
}
|
||||
else if(variant.canConvert<NetJsValueQmlContainer>())
|
||||
{
|
||||
else if(variant.canConvert<NetJsValueQmlContainer>()) {
|
||||
variant.value<NetJsValueQmlContainer>().jsValue.clear();
|
||||
variant.clear();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NetVariant::setValue(const T& value)
|
||||
{
|
||||
clearNetReference();
|
||||
variant.setValue(value);
|
||||
}
|
||||
|
||||
void NetVariant::setValueVariant(const QVariant& value)
|
||||
{
|
||||
Q_ASSERT(value.userType() != QMetaType::QObjectStar);
|
||||
Q_ASSERT(value.userType() != qMetaTypeId<QJSValue>());
|
||||
Q_ASSERT(value.userType() < QMetaType::User);
|
||||
clearNetReference();
|
||||
variant = value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NetVariant::setValuePtr(const T* value)
|
||||
{
|
||||
if(value) {
|
||||
setValue(*value);
|
||||
} else {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NetVariant::getValue() const
|
||||
{
|
||||
if(!variant.canConvert(qMetaTypeId<T>())) {
|
||||
qDebug() << "Can't convert value" << variant << "from" << variant.typeName() << "to" << QMetaType::typeName(qMetaTypeId<T>());
|
||||
}
|
||||
return variant.value<T>();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
struct Q_DECL_EXPORT DateTimeContainer {
|
||||
|
|
@ -421,30 +431,54 @@ Q_DECL_EXPORT bool net_variant_getBool(NetVariantContainer* container) {
|
|||
return container->variant->getBool();
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_variant_setChar(NetVariantContainer* container, ushort value) {
|
||||
Q_DECL_EXPORT void net_variant_setChar(NetVariantContainer* container, quint16 value) {
|
||||
container->variant->setChar(value);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT ushort net_variant_getChar(NetVariantContainer* container) {
|
||||
return (ushort)container->variant->getChar().unicode();
|
||||
Q_DECL_EXPORT quint16 net_variant_getChar(NetVariantContainer* container) {
|
||||
return quint16(container->variant->getChar().unicode());
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_variant_setInt(NetVariantContainer* container, int value) {
|
||||
Q_DECL_EXPORT void net_variant_setInt(NetVariantContainer* container, qint32 value) {
|
||||
container->variant->setInt(value);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT int net_variant_getInt(NetVariantContainer* container) {
|
||||
Q_DECL_EXPORT qint32 net_variant_getInt(NetVariantContainer* container) {
|
||||
return container->variant->getInt();
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_variant_setUInt(NetVariantContainer* container, unsigned int value) {
|
||||
Q_DECL_EXPORT void net_variant_setUInt(NetVariantContainer* container, quint32 value) {
|
||||
container->variant->setUInt(value);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT unsigned int net_variant_getUInt(NetVariantContainer* container) {
|
||||
Q_DECL_EXPORT quint32 net_variant_getUInt(NetVariantContainer* container) {
|
||||
return container->variant->getUInt();
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_variant_setLong(NetVariantContainer* container, qint64 value) {
|
||||
container->variant->setLong(value);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT qint64 net_variant_getLong(NetVariantContainer* container) {
|
||||
return container->variant->getLong();
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_variant_setULong(NetVariantContainer* container, quint64 value) {
|
||||
container->variant->setULong(value);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT quint64 net_variant_getULong(NetVariantContainer* container) {
|
||||
return container->variant->getULong();
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_variant_setFloat(NetVariantContainer* container, float value) {
|
||||
container->variant->setFloat(value);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT float net_variant_getFloat(NetVariantContainer* container) {
|
||||
return container->variant->getFloat();
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_variant_setDouble(NetVariantContainer* container, double value) {
|
||||
container->variant->setDouble(value);
|
||||
}
|
||||
|
|
@ -457,48 +491,47 @@ Q_DECL_EXPORT void net_variant_setString(NetVariantContainer* container, LPWSTR
|
|||
if(value == nullptr) {
|
||||
container->variant->setString(nullptr);
|
||||
} else {
|
||||
QString temp = QString::fromUtf16((const char16_t*)value);
|
||||
container->variant->setString(&temp);
|
||||
container->variant->setString(QString::fromUtf16(static_cast<const char16_t*>(value)));
|
||||
}
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT QmlNetStringContainer* net_variant_getString(NetVariantContainer* container) {
|
||||
QString string = container->variant->getString();
|
||||
const QString& string = container->variant->getString();
|
||||
if(string.isNull()) {
|
||||
return nullptr;
|
||||
}
|
||||
return createString(string);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void net_variant_setDateTime(NetVariantContainer* container, DateTimeContainer* value) {
|
||||
Q_DECL_EXPORT void net_variant_setDateTime(NetVariantContainer* container, const DateTimeContainer* value) {
|
||||
if(value == nullptr || value->isNull) {
|
||||
QDateTime dt;
|
||||
container->variant->setDateTime(dt);
|
||||
container->variant->setDateTime(QDateTime());
|
||||
} else {
|
||||
QDateTime dt(QDate(value->year, value->month, value->day),
|
||||
QTime(value->hour, value->minute, value->second, value->msec),
|
||||
Qt::OffsetFromUTC, value->offsetSeconds);
|
||||
container->variant->setDateTime(dt);
|
||||
container->variant->setDateTime(QDateTime(QDate(value->year, value->month, value->day),
|
||||
QTime(value->hour, value->minute, value->second, value->msec),
|
||||
Qt::OffsetFromUTC, value->offsetSeconds));
|
||||
}
|
||||
}
|
||||
Q_DECL_EXPORT void net_variant_getDateTime(NetVariantContainer* container, DateTimeContainer* value) {
|
||||
QDateTime dt = container->variant->getDateTime();
|
||||
const QDateTime& dt = container->variant->getDateTime();
|
||||
if(dt.isNull()) {
|
||||
value->isNull = true;
|
||||
return;
|
||||
}
|
||||
if(!dt.isValid()) {
|
||||
qWarning("QDateTime is invalid");
|
||||
qWarning() << "QDateTime is invalid";
|
||||
value->isNull = true;
|
||||
return;
|
||||
}
|
||||
value->year = dt.date().year();
|
||||
value->month = dt.date().month();
|
||||
value->day = dt.date().day();
|
||||
value->hour = dt.time().hour();
|
||||
value->minute = dt.time().minute();
|
||||
value->second = dt.time().second();
|
||||
value->msec = dt.time().msec();
|
||||
const QDate& date = dt.date();
|
||||
const QTime& time = dt.time();
|
||||
value->year = date.year();
|
||||
value->month = date.month();
|
||||
value->day = date.day();
|
||||
value->hour = time.hour();
|
||||
value->minute = time.minute();
|
||||
value->second = time.second();
|
||||
value->msec = time.msec();
|
||||
value->offsetSeconds = dt.offsetFromUtc();
|
||||
}
|
||||
|
||||
|
|
@ -511,7 +544,7 @@ Q_DECL_EXPORT void net_variant_setJsValue(NetVariantContainer* container, NetJSV
|
|||
}
|
||||
|
||||
Q_DECL_EXPORT NetJSValueContainer* net_variant_getJsValue(NetVariantContainer* container) {
|
||||
QSharedPointer<NetJSValue> instance = container->variant->getJsValue();
|
||||
const QSharedPointer<NetJSValue>& instance = container->variant->getJsValue();
|
||||
if(instance == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,34 +12,52 @@ class NetVariant
|
|||
public:
|
||||
NetVariant();
|
||||
~NetVariant();
|
||||
NetVariantTypeEnum getVariantType();
|
||||
NetVariantTypeEnum getVariantType() const;
|
||||
void setNetReference(QSharedPointer<NetReference> netReference);
|
||||
QSharedPointer<NetReference> getNetReference();
|
||||
QSharedPointer<NetReference> getNetReference() const;
|
||||
void setBool(bool value);
|
||||
bool getBool();
|
||||
bool getBool() const;
|
||||
void setChar(QChar value);
|
||||
QChar getChar();
|
||||
void setInt(int value);
|
||||
int getInt();
|
||||
void setUInt(unsigned int value);
|
||||
unsigned int getUInt();
|
||||
QChar getChar() const;
|
||||
void setInt(qint32 value);
|
||||
qint32 getInt() const;
|
||||
void setUInt(quint32 value);
|
||||
quint32 getUInt() const;
|
||||
void setLong(qint64 value);
|
||||
qint64 getLong() const;
|
||||
void setULong(quint64 value);
|
||||
quint64 getULong() const;
|
||||
void setFloat(float value);
|
||||
float getFloat() const;
|
||||
void setDouble(double value);
|
||||
double getDouble();
|
||||
void setString(QString* value);
|
||||
QString getString();
|
||||
void setDateTime(QDateTime& value);
|
||||
QDateTime getDateTime();
|
||||
double getDouble() const;
|
||||
void setString(const QString* value);
|
||||
void setString(const QString& value);
|
||||
QString getString() const;
|
||||
void setDateTime(const QDateTime& value);
|
||||
QDateTime getDateTime() const;
|
||||
void setJsValue(QSharedPointer<NetJSValue> jsValue);
|
||||
QSharedPointer<NetJSValue> getJsValue();
|
||||
QSharedPointer<NetJSValue> getJsValue() const;
|
||||
void clear();
|
||||
static QSharedPointer<NetVariant> fromQJSValue(const QJSValue& qJsValue);
|
||||
QJSValue toQJSValue(QJSEngine* jsEngine);
|
||||
static void fromQVariant(const QVariant* variant, QSharedPointer<NetVariant> destination);
|
||||
QJSValue toQJSValue(QJSEngine* jsEngine) const;
|
||||
static void fromQVariant(const QVariant* variant, const QSharedPointer<NetVariant>& destination);
|
||||
static QSharedPointer<NetVariant> fromQVariant(const QVariant* variant);
|
||||
QVariant toQVariant();
|
||||
QString getDisplayValue();
|
||||
QVariant toQVariant() const;
|
||||
QString getDisplayValue() const;
|
||||
private:
|
||||
void clearNetReference();
|
||||
|
||||
template<typename T>
|
||||
void setValue(const T& value);
|
||||
void setValueVariant(const QVariant& value);
|
||||
|
||||
template<typename T>
|
||||
void setValuePtr(const T* value);
|
||||
|
||||
template<typename T>
|
||||
T getValue() const;
|
||||
|
||||
QVariant variant;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,14 @@
|
|||
#include <QmlNet/qml/NetVariantList.h>
|
||||
|
||||
NetVariantList::NetVariantList()
|
||||
{
|
||||
NetVariantList::NetVariantList() = default;
|
||||
|
||||
}
|
||||
|
||||
NetVariantList::~NetVariantList()
|
||||
{
|
||||
|
||||
}
|
||||
NetVariantList::~NetVariantList() = default;
|
||||
|
||||
int NetVariantList::count() {
|
||||
return variants.size();
|
||||
}
|
||||
|
||||
void NetVariantList::add(QSharedPointer<NetVariant> variant) {
|
||||
void NetVariantList::add(const QSharedPointer<NetVariant>& variant) {
|
||||
variants.append(variant);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public:
|
|||
NetVariantList();
|
||||
~NetVariantList();
|
||||
int count();
|
||||
void add(QSharedPointer<NetVariant> variant);
|
||||
void add(const QSharedPointer<NetVariant>& variant);
|
||||
QSharedPointer<NetVariant> get(int index);
|
||||
void remove(int index);
|
||||
void clear();
|
||||
|
|
|
|||
|
|
@ -28,9 +28,8 @@ Q_DECL_EXPORT QGuiApplicationContainer* qguiapplication_create(NetVariantListCon
|
|||
for(int x = 0; x < args->count(); x++) {
|
||||
QByteArray arg = args->get(x)->getString().toLatin1();
|
||||
result->args.append(arg);
|
||||
char* cstr = nullptr;
|
||||
cstr = new char [arg.size()+1];
|
||||
strcpy(cstr, arg.data());
|
||||
char* cstr = new char [size_t(arg.size())+1];
|
||||
memcpy(cstr, arg.data(), size_t(arg.size())+1);
|
||||
result->argsPointer.push_back(cstr);
|
||||
}
|
||||
result->argCount = result->args.size();
|
||||
|
|
@ -47,7 +46,7 @@ Q_DECL_EXPORT QGuiApplicationContainer* qguiapplication_create(NetVariantListCon
|
|||
|
||||
Q_DECL_EXPORT void qguiapplication_destroy(QGuiApplicationContainer* container) {
|
||||
for (auto i : container->argsPointer) {
|
||||
delete i;
|
||||
delete[] i;
|
||||
}
|
||||
container->callback.clear();
|
||||
if(container->ownsGuiApp) {
|
||||
|
|
@ -56,8 +55,8 @@ Q_DECL_EXPORT void qguiapplication_destroy(QGuiApplicationContainer* container)
|
|||
delete container;
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT int qguiapplication_exec(QGuiApplicationContainer* container) {
|
||||
return container->guiApp->exec();
|
||||
Q_DECL_EXPORT int qguiapplication_exec() {
|
||||
return QGuiApplication::exec();
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void qguiapplication_addTriggerCallback(QGuiApplicationContainer* container, guiThreadTriggerCb callback) {
|
||||
|
|
@ -68,8 +67,8 @@ Q_DECL_EXPORT void qguiapplication_requestTrigger(QGuiApplicationContainer* cont
|
|||
QMetaObject::invokeMethod(container->callback.data(), "trigger", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void qguiapplication_exit(QGuiApplicationContainer* container, int returnCode) {
|
||||
container->guiApp->exit(returnCode);
|
||||
Q_DECL_EXPORT void qguiapplication_exit(int returnCode) {
|
||||
QGuiApplication::exit(returnCode);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT QGuiApplication* qguiapplication_internalPointer(QGuiApplicationContainer* container) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,11 @@
|
|||
static int netValueTypeNumber = 0;
|
||||
|
||||
#define NETVALUETYPE_CASE(N) \
|
||||
case N: NetValueType<N>::init(typeInfo); return qmlRegisterType<NetValueType<N>>(uriString.toUtf8().data(), versionMajor, versionMinor, qmlNameString.toUtf8().data());
|
||||
case N: NetValueType<N>::init(typeInfo); return qmlRegisterType<NetValueType<(N)>>(uriString.toUtf8().data(), versionMajor, versionMinor, qmlNameString.toUtf8().data());
|
||||
|
||||
#define NETVALUETYPESINGLETON_CASE(N) \
|
||||
case N: NetValueType<N>::init(typeInfo); return qmlRegisterSingletonType<NetValueType<N>>(uriString.toUtf8().data(), versionMajor, versionMinor, typeNameString.toUtf8().data(), NetValueType<N>::build);
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
@ -44,19 +48,18 @@ Q_DECL_EXPORT void qqmlapplicationengine_destroy(QQmlApplicationEngineContainer*
|
|||
}
|
||||
|
||||
Q_DECL_EXPORT void qqmlapplicationengine_load(QQmlApplicationEngineContainer* container, LPWSTR path) {
|
||||
container->qmlEngine->load(QString::fromUtf16((const char16_t*)path));
|
||||
container->qmlEngine->load(QString::fromUtf16(static_cast<const char16_t*>(path)));
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void qqmlapplicationengine_loadData(QQmlApplicationEngineContainer* container, LPWSTR dataString) {
|
||||
container->qmlEngine->loadData(QByteArray::fromStdString(QString::fromUtf16((const char16_t*)dataString).toStdString()));
|
||||
container->qmlEngine->loadData(QByteArray::fromStdString(QString::fromUtf16(static_cast<const char16_t*>(dataString)).toStdString()));
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT int qqmlapplicationengine_registerType(NetTypeInfoContainer* typeContainer, LPWSTR uri, int versionMajor, int versionMinor, LPWSTR qmlName) {
|
||||
|
||||
QString uriString = QString::fromUtf16((const char16_t*)uri);
|
||||
QString qmlNameString = QString::fromUtf16((const char16_t*)qmlName);
|
||||
QString uriString = QString::fromUtf16(static_cast<const char16_t*>(uri));
|
||||
QString qmlNameString = QString::fromUtf16(static_cast<const char16_t*>(qmlName));
|
||||
QSharedPointer<NetTypeInfo> typeInfo = typeContainer->netTypeInfo;
|
||||
QString fullType = typeInfo->getFullTypeName();
|
||||
|
||||
switch (++netValueTypeNumber) {
|
||||
NETVALUETYPE_CASE(1)
|
||||
|
|
@ -109,7 +112,6 @@ Q_DECL_EXPORT int qqmlapplicationengine_registerType(NetTypeInfoContainer* typeC
|
|||
NETVALUETYPE_CASE(48)
|
||||
NETVALUETYPE_CASE(49)
|
||||
NETVALUETYPE_CASE(50)
|
||||
|
||||
NETVALUETYPE_CASE(51)
|
||||
NETVALUETYPE_CASE(52)
|
||||
NETVALUETYPE_CASE(53)
|
||||
|
|
@ -189,8 +191,152 @@ Q_DECL_EXPORT int qqmlapplicationengine_registerType(NetTypeInfoContainer* typeC
|
|||
return -1;
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT int qqmlapplicationengine_registerSingletonTypeQml(LPWCSTR url, LPWCSTR uri, int versionMajor, int versionMinor, LPWCSTR qmlName)
|
||||
{
|
||||
QString urlString = QString::fromUtf16(url);
|
||||
QString uriString = QString::fromUtf16(uri);
|
||||
QString qmlNameString = QString::fromUtf16(qmlName);
|
||||
return qmlRegisterSingletonType(urlString, uriString.toUtf8().data(), versionMajor, versionMinor, qmlNameString.toUtf8().data());
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT int qqmlapplicationengine_registerSingletonTypeNet(NetTypeInfoContainer* typeContainer, LPWCSTR uri, int versionMajor, int versionMinor, LPWCSTR typeName)
|
||||
{
|
||||
QSharedPointer<NetTypeInfo> typeInfo = typeContainer->netTypeInfo;
|
||||
QString typeNameString = QString::fromUtf16(typeName);
|
||||
QString uriString = QString::fromUtf16(uri);
|
||||
|
||||
switch (++netValueTypeNumber) {
|
||||
NETVALUETYPESINGLETON_CASE(1)
|
||||
NETVALUETYPESINGLETON_CASE(2)
|
||||
NETVALUETYPESINGLETON_CASE(3)
|
||||
NETVALUETYPESINGLETON_CASE(4)
|
||||
NETVALUETYPESINGLETON_CASE(5)
|
||||
NETVALUETYPESINGLETON_CASE(6)
|
||||
NETVALUETYPESINGLETON_CASE(7)
|
||||
NETVALUETYPESINGLETON_CASE(8)
|
||||
NETVALUETYPESINGLETON_CASE(9)
|
||||
NETVALUETYPESINGLETON_CASE(10)
|
||||
NETVALUETYPESINGLETON_CASE(11)
|
||||
NETVALUETYPESINGLETON_CASE(12)
|
||||
NETVALUETYPESINGLETON_CASE(13)
|
||||
NETVALUETYPESINGLETON_CASE(14)
|
||||
NETVALUETYPESINGLETON_CASE(15)
|
||||
NETVALUETYPESINGLETON_CASE(16)
|
||||
NETVALUETYPESINGLETON_CASE(17)
|
||||
NETVALUETYPESINGLETON_CASE(18)
|
||||
NETVALUETYPESINGLETON_CASE(19)
|
||||
NETVALUETYPESINGLETON_CASE(20)
|
||||
NETVALUETYPESINGLETON_CASE(21)
|
||||
NETVALUETYPESINGLETON_CASE(22)
|
||||
NETVALUETYPESINGLETON_CASE(23)
|
||||
NETVALUETYPESINGLETON_CASE(24)
|
||||
NETVALUETYPESINGLETON_CASE(25)
|
||||
NETVALUETYPESINGLETON_CASE(26)
|
||||
NETVALUETYPESINGLETON_CASE(27)
|
||||
NETVALUETYPESINGLETON_CASE(28)
|
||||
NETVALUETYPESINGLETON_CASE(29)
|
||||
NETVALUETYPESINGLETON_CASE(30)
|
||||
NETVALUETYPESINGLETON_CASE(31)
|
||||
NETVALUETYPESINGLETON_CASE(32)
|
||||
NETVALUETYPESINGLETON_CASE(33)
|
||||
NETVALUETYPESINGLETON_CASE(34)
|
||||
NETVALUETYPESINGLETON_CASE(35)
|
||||
NETVALUETYPESINGLETON_CASE(36)
|
||||
NETVALUETYPESINGLETON_CASE(37)
|
||||
NETVALUETYPESINGLETON_CASE(38)
|
||||
NETVALUETYPESINGLETON_CASE(39)
|
||||
NETVALUETYPESINGLETON_CASE(40)
|
||||
NETVALUETYPESINGLETON_CASE(41)
|
||||
NETVALUETYPESINGLETON_CASE(42)
|
||||
NETVALUETYPESINGLETON_CASE(43)
|
||||
NETVALUETYPESINGLETON_CASE(44)
|
||||
NETVALUETYPESINGLETON_CASE(45)
|
||||
NETVALUETYPESINGLETON_CASE(46)
|
||||
NETVALUETYPESINGLETON_CASE(47)
|
||||
NETVALUETYPESINGLETON_CASE(48)
|
||||
NETVALUETYPESINGLETON_CASE(49)
|
||||
NETVALUETYPESINGLETON_CASE(50)
|
||||
NETVALUETYPESINGLETON_CASE(51)
|
||||
NETVALUETYPESINGLETON_CASE(52)
|
||||
NETVALUETYPESINGLETON_CASE(53)
|
||||
NETVALUETYPESINGLETON_CASE(54)
|
||||
NETVALUETYPESINGLETON_CASE(55)
|
||||
NETVALUETYPESINGLETON_CASE(56)
|
||||
NETVALUETYPESINGLETON_CASE(57)
|
||||
NETVALUETYPESINGLETON_CASE(58)
|
||||
NETVALUETYPESINGLETON_CASE(59)
|
||||
NETVALUETYPESINGLETON_CASE(60)
|
||||
NETVALUETYPESINGLETON_CASE(61)
|
||||
NETVALUETYPESINGLETON_CASE(62)
|
||||
NETVALUETYPESINGLETON_CASE(63)
|
||||
NETVALUETYPESINGLETON_CASE(64)
|
||||
NETVALUETYPESINGLETON_CASE(65)
|
||||
NETVALUETYPESINGLETON_CASE(66)
|
||||
NETVALUETYPESINGLETON_CASE(67)
|
||||
NETVALUETYPESINGLETON_CASE(68)
|
||||
NETVALUETYPESINGLETON_CASE(69)
|
||||
NETVALUETYPESINGLETON_CASE(70)
|
||||
NETVALUETYPESINGLETON_CASE(71)
|
||||
NETVALUETYPESINGLETON_CASE(72)
|
||||
NETVALUETYPESINGLETON_CASE(73)
|
||||
NETVALUETYPESINGLETON_CASE(74)
|
||||
NETVALUETYPESINGLETON_CASE(75)
|
||||
NETVALUETYPESINGLETON_CASE(76)
|
||||
NETVALUETYPESINGLETON_CASE(77)
|
||||
NETVALUETYPESINGLETON_CASE(78)
|
||||
NETVALUETYPESINGLETON_CASE(79)
|
||||
NETVALUETYPESINGLETON_CASE(80)
|
||||
NETVALUETYPESINGLETON_CASE(81)
|
||||
NETVALUETYPESINGLETON_CASE(82)
|
||||
NETVALUETYPESINGLETON_CASE(83)
|
||||
NETVALUETYPESINGLETON_CASE(84)
|
||||
NETVALUETYPESINGLETON_CASE(85)
|
||||
NETVALUETYPESINGLETON_CASE(86)
|
||||
NETVALUETYPESINGLETON_CASE(87)
|
||||
NETVALUETYPESINGLETON_CASE(88)
|
||||
NETVALUETYPESINGLETON_CASE(89)
|
||||
NETVALUETYPESINGLETON_CASE(90)
|
||||
NETVALUETYPESINGLETON_CASE(91)
|
||||
NETVALUETYPESINGLETON_CASE(92)
|
||||
NETVALUETYPESINGLETON_CASE(93)
|
||||
NETVALUETYPESINGLETON_CASE(94)
|
||||
NETVALUETYPESINGLETON_CASE(95)
|
||||
NETVALUETYPESINGLETON_CASE(96)
|
||||
NETVALUETYPESINGLETON_CASE(97)
|
||||
NETVALUETYPESINGLETON_CASE(98)
|
||||
NETVALUETYPESINGLETON_CASE(99)
|
||||
NETVALUETYPESINGLETON_CASE(100)
|
||||
NETVALUETYPESINGLETON_CASE(101)
|
||||
NETVALUETYPESINGLETON_CASE(102)
|
||||
NETVALUETYPESINGLETON_CASE(103)
|
||||
NETVALUETYPESINGLETON_CASE(104)
|
||||
NETVALUETYPESINGLETON_CASE(105)
|
||||
NETVALUETYPESINGLETON_CASE(106)
|
||||
NETVALUETYPESINGLETON_CASE(107)
|
||||
NETVALUETYPESINGLETON_CASE(108)
|
||||
NETVALUETYPESINGLETON_CASE(109)
|
||||
NETVALUETYPESINGLETON_CASE(110)
|
||||
NETVALUETYPESINGLETON_CASE(111)
|
||||
NETVALUETYPESINGLETON_CASE(112)
|
||||
NETVALUETYPESINGLETON_CASE(113)
|
||||
NETVALUETYPESINGLETON_CASE(114)
|
||||
NETVALUETYPESINGLETON_CASE(115)
|
||||
NETVALUETYPESINGLETON_CASE(116)
|
||||
NETVALUETYPESINGLETON_CASE(118)
|
||||
NETVALUETYPESINGLETON_CASE(119)
|
||||
NETVALUETYPESINGLETON_CASE(120)
|
||||
NETVALUETYPESINGLETON_CASE(121)
|
||||
NETVALUETYPESINGLETON_CASE(122)
|
||||
NETVALUETYPESINGLETON_CASE(123)
|
||||
NETVALUETYPESINGLETON_CASE(124)
|
||||
NETVALUETYPESINGLETON_CASE(125)
|
||||
}
|
||||
qFatal("Too many registered types");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT void qqmlapplicationengine_addImportPath(QQmlApplicationEngineContainer* container, LPWSTR path) {
|
||||
QString pathString = QString::fromUtf16((const char16_t*)path);
|
||||
QString pathString = QString::fromUtf16(static_cast<const char16_t*>(path));
|
||||
container->qmlEngine->addImportPath(pathString);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
extern "C" {
|
||||
|
||||
Q_DECL_EXPORT bool qresource_registerResource(LPWSTR rccFileName, LPWSTR resourceRoot) {
|
||||
QString rccFileNameString = QString::fromUtf16((const char16_t*)rccFileName);
|
||||
QString resourceRootString = QString::fromUtf16((const char16_t*)resourceRoot);
|
||||
QString rccFileNameString = QString::fromUtf16(static_cast<const char16_t*>(rccFileName));
|
||||
QString resourceRootString = QString::fromUtf16(static_cast<const char16_t*>(resourceRoot));
|
||||
return QResource::registerResource(rccFileNameString, resourceRootString);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT bool qresource_unregisterResource(LPWSTR rccFileName, LPWSTR resourceRoot) {
|
||||
QString rccFileNameString = QString::fromUtf16((const char16_t*)rccFileName);
|
||||
QString resourceRootString = QString::fromUtf16((const char16_t*)resourceRoot);
|
||||
QString rccFileNameString = QString::fromUtf16(static_cast<const char16_t*>(rccFileName));
|
||||
QString resourceRootString = QString::fromUtf16(static_cast<const char16_t*>(resourceRoot));
|
||||
return QResource::unregisterResource(rccFileNameString, resourceRootString);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
#include <QmlNet/types/Callbacks.h>
|
||||
#include <utility>
|
||||
|
||||
namespace QmlNet {
|
||||
|
||||
typedef bool (*isTypeValidCb)(LPWSTR typeName);
|
||||
typedef void (*createLazyTypeInfoCb)(NetTypeInfoContainer* typeInfo);
|
||||
typedef void (*loadTypeInfoCb)(NetTypeInfoContainer* typeInfo);
|
||||
typedef void (*releaseNetReferenceCb)(uint64_t objectId);
|
||||
typedef void (*releaseNetDelegateGCHandleCb)(NetGCHandle* handle);
|
||||
typedef NetReferenceContainer* (*instantiateTypeCb)(NetTypeInfoContainer* type);
|
||||
typedef void (*readPropertyCb)(NetPropertyInfoContainer* property, NetReferenceContainer* target, NetVariantContainer* indexParameter, NetVariantContainer* result);
|
||||
typedef void (*writePropertyCb)(NetPropertyInfoContainer* property, NetReferenceContainer* target, NetVariantContainer* indexParameter, NetVariantContainer* value);
|
||||
typedef void (*invokeMethodCb)(NetMethodInfoContainer* method, NetReferenceContainer* target, NetVariantListContainer* parameters, NetVariantContainer* result);
|
||||
typedef void (*gcCollectCb)(int maxGeneration);
|
||||
typedef bool (*raiseNetSignalsCb)(NetReferenceContainer* target, LPWCSTR signalName, NetVariantListContainer* parameters);
|
||||
typedef void (*awaitTaskCb)(NetReferenceContainer* target, NetJSValueContainer* successCallback, NetJSValueContainer* failureCallback);
|
||||
typedef bool (*serializeNetToStringCb)(NetReferenceContainer* instance, NetVariantContainer* result);
|
||||
using isTypeValidCb = bool (*)(LPWSTR);
|
||||
using createLazyTypeInfoCb = void (*)(NetTypeInfoContainer *);
|
||||
using loadTypeInfoCb = void (*)(NetTypeInfoContainer *);
|
||||
using releaseNetReferenceCb = void (*)(uint64_t);
|
||||
using releaseNetDelegateGCHandleCb = void (*)(void *);
|
||||
using instantiateTypeCb = NetReferenceContainer *(*)(NetTypeInfoContainer *);
|
||||
using readPropertyCb = void (*)(NetPropertyInfoContainer *, NetReferenceContainer *, NetVariantContainer *, NetVariantContainer *);
|
||||
using writePropertyCb = void (*)(NetPropertyInfoContainer *, NetReferenceContainer *, NetVariantContainer *, NetVariantContainer *);
|
||||
using invokeMethodCb = void (*)(NetMethodInfoContainer *, NetReferenceContainer *, NetVariantListContainer *, NetVariantContainer *);
|
||||
using gcCollectCb = void (*)(int);
|
||||
using raiseNetSignalsCb = bool (*)(NetReferenceContainer *, LPWCSTR, NetVariantListContainer *);
|
||||
using awaitTaskCb = void (*)(NetReferenceContainer *, NetJSValueContainer *, NetJSValueContainer *);
|
||||
using serializeNetToStringCb = bool (*)(NetReferenceContainer *, NetVariantContainer *);
|
||||
|
||||
struct Q_DECL_EXPORT NetTypeInfoManagerCallbacks {
|
||||
isTypeValidCb isTypeValid;
|
||||
|
|
@ -36,8 +37,11 @@ static NetTypeInfoManagerCallbacks sharedCallbacks;
|
|||
|
||||
void buildTypeInfo(QSharedPointer<NetTypeInfo> typeInfo);
|
||||
|
||||
bool isTypeValid(QString type) {
|
||||
return sharedCallbacks.isTypeValid((LPWSTR)type.utf16());
|
||||
bool isTypeValid(const QString& type) {
|
||||
static_assert (std::is_pointer<LPWSTR>::value, "Check the cast below.");
|
||||
static_assert (!std::is_pointer<std::remove_pointer<LPWSTR>::type>::value, "Check the cast below.");
|
||||
static_assert (sizeof(std::remove_pointer<LPWSTR>::type) == sizeof(ushort), "Check the cast below.");
|
||||
return sharedCallbacks.isTypeValid(static_cast<LPWSTR>(const_cast<void*>(static_cast<const void*>(type.utf16()))));
|
||||
}
|
||||
|
||||
void releaseNetReference(uint64_t objectId) {
|
||||
|
|
@ -50,18 +54,18 @@ void releaseNetDelegateGCHandle(NetGCHandle* handle) {
|
|||
|
||||
void createLazyTypeInfo(QSharedPointer<NetTypeInfo> typeInfo) {
|
||||
NetTypeInfoContainer* container = new NetTypeInfoContainer();
|
||||
container->netTypeInfo = typeInfo;
|
||||
container->netTypeInfo = std::move(typeInfo);
|
||||
sharedCallbacks.createLazyTypeInfo(container);
|
||||
}
|
||||
|
||||
void loadTypeInfo(QSharedPointer<NetTypeInfo> typeInfo) {
|
||||
NetTypeInfoContainer* container = new NetTypeInfoContainer();
|
||||
container->netTypeInfo = typeInfo;
|
||||
container->netTypeInfo = std::move(typeInfo);
|
||||
sharedCallbacks.loadTypeInfo(container);
|
||||
}
|
||||
|
||||
QSharedPointer<NetReference> instantiateType(QSharedPointer<NetTypeInfo> type) {
|
||||
NetTypeInfoContainer* typeContainer = new NetTypeInfoContainer{ type }; // .NET will delete this type
|
||||
NetTypeInfoContainer* typeContainer = new NetTypeInfoContainer{ std::move(type) }; // .NET will delete this type
|
||||
NetReferenceContainer* resultContainer = sharedCallbacks.instantiateType(typeContainer);
|
||||
|
||||
QSharedPointer<NetReference> result;
|
||||
|
|
@ -78,43 +82,43 @@ QSharedPointer<NetReference> instantiateType(QSharedPointer<NetTypeInfo> type) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void readProperty(QSharedPointer<NetPropertyInfo> property, QSharedPointer<NetReference> target, QSharedPointer<NetVariant> indexParameter, QSharedPointer<NetVariant> result) {
|
||||
void readProperty(QSharedPointer<NetPropertyInfo> property, QSharedPointer<NetReference> target, const QSharedPointer<NetVariant>& indexParameter, QSharedPointer<NetVariant> result) {
|
||||
NetPropertyInfoContainer* propertyContainer = new NetPropertyInfoContainer();
|
||||
propertyContainer->property = property;
|
||||
propertyContainer->property = std::move(property);
|
||||
NetReferenceContainer* targetContainer = new NetReferenceContainer();
|
||||
targetContainer->instance = target;
|
||||
targetContainer->instance = std::move(target);
|
||||
NetVariantContainer* indexParameterContainer = nullptr;
|
||||
if(indexParameter != nullptr) {
|
||||
indexParameterContainer = new NetVariantContainer{indexParameter};
|
||||
}
|
||||
NetVariantContainer* valueContainer = new NetVariantContainer();
|
||||
valueContainer->variant = result;
|
||||
valueContainer->variant = std::move(result);
|
||||
sharedCallbacks.readProperty(propertyContainer, targetContainer, indexParameterContainer, valueContainer);
|
||||
// The callbacks dispose of the types.
|
||||
}
|
||||
|
||||
void writeProperty(QSharedPointer<NetPropertyInfo> property, QSharedPointer<NetReference> target, QSharedPointer<NetVariant> indexParameter, QSharedPointer<NetVariant> value) {
|
||||
void writeProperty(QSharedPointer<NetPropertyInfo> property, QSharedPointer<NetReference> target, const QSharedPointer<NetVariant>& indexParameter, QSharedPointer<NetVariant> value) {
|
||||
NetPropertyInfoContainer* propertyContainer = new NetPropertyInfoContainer();
|
||||
propertyContainer->property = property;
|
||||
propertyContainer->property = std::move(property);
|
||||
NetReferenceContainer* targetContainer = new NetReferenceContainer();
|
||||
targetContainer->instance = target;
|
||||
targetContainer->instance = std::move(target);
|
||||
NetVariantContainer* indexParameterContainer = nullptr;
|
||||
if(indexParameter != nullptr) {
|
||||
indexParameterContainer = new NetVariantContainer{indexParameter};
|
||||
}
|
||||
NetVariantContainer* resultContainer = new NetVariantContainer();
|
||||
resultContainer->variant = value;
|
||||
resultContainer->variant = std::move(value);
|
||||
sharedCallbacks.writeProperty(propertyContainer, targetContainer, indexParameterContainer, resultContainer);
|
||||
// The callbacks dispose of the types.
|
||||
}
|
||||
|
||||
void invokeNetMethod(QSharedPointer<NetMethodInfo> method, QSharedPointer<NetReference> target, QSharedPointer<NetVariantList> parameters, QSharedPointer<NetVariant> result) {
|
||||
void invokeNetMethod(QSharedPointer<NetMethodInfo> method, QSharedPointer<NetReference> target, QSharedPointer<NetVariantList> parameters, const QSharedPointer<NetVariant>& result) {
|
||||
NetMethodInfoContainer* methodContainer = new NetMethodInfoContainer();
|
||||
methodContainer->method = method;
|
||||
methodContainer->method = std::move(method);
|
||||
NetReferenceContainer* targetContainer = new NetReferenceContainer();
|
||||
targetContainer->instance = target;
|
||||
targetContainer->instance = std::move(target);
|
||||
NetVariantListContainer* parametersContainer = new NetVariantListContainer();
|
||||
parametersContainer->list = parameters;
|
||||
parametersContainer->list = std::move(parameters);
|
||||
NetVariantContainer* resultContainer = nullptr;
|
||||
if(result != nullptr) {
|
||||
// There is a return type.
|
||||
|
|
@ -129,18 +133,21 @@ void gcCollect(int maxGeneration) {
|
|||
sharedCallbacks.gcCollect(maxGeneration);
|
||||
}
|
||||
|
||||
bool raiseNetSignals(QSharedPointer<NetReference> target, QString signalName, QSharedPointer<NetVariantList> parameters) {
|
||||
NetReferenceContainer* targetContainer = new NetReferenceContainer{target};
|
||||
bool raiseNetSignals(QSharedPointer<NetReference> target, const QString& signalName, const QSharedPointer<NetVariantList>& parameters) {
|
||||
NetReferenceContainer* targetContainer = new NetReferenceContainer{std::move(target)};
|
||||
NetVariantListContainer* parametersContainer = nullptr;
|
||||
if(parameters != nullptr) {
|
||||
parametersContainer = new NetVariantListContainer{parameters};
|
||||
}
|
||||
return sharedCallbacks.raiseNetSignals(targetContainer, (LPWCSTR)signalName.utf16(), parametersContainer);
|
||||
static_assert (std::is_pointer<LPWCSTR>::value, "Check the cast below.");
|
||||
static_assert (!std::is_pointer<std::remove_pointer<LPWCSTR>::type>::value, "Check the cast below.");
|
||||
static_assert (sizeof(std::remove_pointer<LPWCSTR>::type) == sizeof(ushort), "Check the cast below.");
|
||||
return sharedCallbacks.raiseNetSignals(targetContainer, static_cast<LPWCSTR>(static_cast<const void*>(signalName.utf16())), parametersContainer);
|
||||
}
|
||||
|
||||
void awaitTask(QSharedPointer<NetReference> target, QSharedPointer<NetJSValue> successCallback, QSharedPointer<NetJSValue> failureCallback) {
|
||||
NetReferenceContainer* targetContainer = new NetReferenceContainer{target};
|
||||
NetJSValueContainer* sucessCallbackContainer = new NetJSValueContainer{successCallback};
|
||||
void awaitTask(QSharedPointer<NetReference> target, QSharedPointer<NetJSValue> successCallback, const QSharedPointer<NetJSValue>& failureCallback) {
|
||||
NetReferenceContainer* targetContainer = new NetReferenceContainer{std::move(target)};
|
||||
NetJSValueContainer* sucessCallbackContainer = new NetJSValueContainer{std::move(successCallback)};
|
||||
NetJSValueContainer* failureCallbackContainer = nullptr;
|
||||
if(failureCallback != nullptr) {
|
||||
failureCallbackContainer = new NetJSValueContainer{failureCallback};
|
||||
|
|
@ -150,8 +157,8 @@ void awaitTask(QSharedPointer<NetReference> target, QSharedPointer<NetJSValue> s
|
|||
|
||||
bool serializeNetToString(QSharedPointer<NetReference> instance, QSharedPointer<NetVariant> result)
|
||||
{
|
||||
return sharedCallbacks.serializeNetToString(new NetReferenceContainer{instance},
|
||||
new NetVariantContainer{result});
|
||||
return sharedCallbacks.serializeNetToString(new NetReferenceContainer{std::move(instance)},
|
||||
new NetVariantContainer{std::move(result)});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace QmlNet {
|
||||
|
||||
bool isTypeValid(QString type);
|
||||
bool isTypeValid(const QString& type);
|
||||
|
||||
void releaseNetReference(uint64_t objectId);
|
||||
|
||||
|
|
@ -25,17 +25,17 @@ void loadTypeInfo(QSharedPointer<NetTypeInfo> typeInfo);
|
|||
|
||||
QSharedPointer<NetReference> instantiateType(QSharedPointer<NetTypeInfo> type);
|
||||
|
||||
void readProperty(QSharedPointer<NetPropertyInfo> property, QSharedPointer<NetReference> target, QSharedPointer<NetVariant> indexParameter, QSharedPointer<NetVariant> result);
|
||||
void readProperty(QSharedPointer<NetPropertyInfo> property, QSharedPointer<NetReference> target, const QSharedPointer<NetVariant>& indexParameter, QSharedPointer<NetVariant> result);
|
||||
|
||||
void writeProperty(QSharedPointer<NetPropertyInfo> property, QSharedPointer<NetReference> target, QSharedPointer<NetVariant> indexParameter, QSharedPointer<NetVariant> value);
|
||||
void writeProperty(QSharedPointer<NetPropertyInfo> property, QSharedPointer<NetReference> target, const QSharedPointer<NetVariant>& indexParameter, QSharedPointer<NetVariant> value);
|
||||
|
||||
void invokeNetMethod(QSharedPointer<NetMethodInfo> method, QSharedPointer<NetReference> target, QSharedPointer<NetVariantList> parameters, QSharedPointer<NetVariant> result);
|
||||
void invokeNetMethod(QSharedPointer<NetMethodInfo> method, QSharedPointer<NetReference> target, QSharedPointer<NetVariantList> parameters, const QSharedPointer<NetVariant>& result);
|
||||
|
||||
void gcCollect(int generation);
|
||||
|
||||
bool raiseNetSignals(QSharedPointer<NetReference> target, QString signalName, QSharedPointer<NetVariantList> parameters);
|
||||
bool raiseNetSignals(QSharedPointer<NetReference> target, const QString& signalName, const QSharedPointer<NetVariantList>& parameters);
|
||||
|
||||
void awaitTask(QSharedPointer<NetReference> target, QSharedPointer<NetJSValue> successCallback, QSharedPointer<NetJSValue> failureCallback);
|
||||
void awaitTask(QSharedPointer<NetReference> target, QSharedPointer<NetJSValue> successCallback, const QSharedPointer<NetJSValue>& failureCallback);
|
||||
|
||||
bool serializeNetToString(QSharedPointer<NetReference> instance, QSharedPointer<NetVariant> result);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#include <QmlNet/types/NetMethodInfo.h>
|
||||
#include <QmlNet/qml/NetValueMetaObjectPacker.h>
|
||||
#include <QmlNetUtilities.h>
|
||||
#include <utility>
|
||||
|
||||
NetMethodInfoArguement::NetMethodInfoArguement(QString name,
|
||||
QSharedPointer<NetTypeInfo> type) :
|
||||
_name(name),
|
||||
_type(type)
|
||||
_name(std::move(name)),
|
||||
_type(std::move(type))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -23,9 +24,9 @@ NetMethodInfo::NetMethodInfo(QSharedPointer<NetTypeInfo> parentTypeInfo,
|
|||
QString methodName,
|
||||
QSharedPointer<NetTypeInfo> returnType,
|
||||
bool isStatic) :
|
||||
_parentTypeInfo(parentTypeInfo),
|
||||
_methodName(methodName),
|
||||
_returnType(returnType),
|
||||
_parentTypeInfo(std::move(parentTypeInfo)),
|
||||
_methodName(std::move(methodName)),
|
||||
_returnType(std::move(returnType)),
|
||||
_isStatic(isStatic)
|
||||
{
|
||||
}
|
||||
|
|
@ -47,7 +48,7 @@ bool NetMethodInfo::isStatic()
|
|||
|
||||
void NetMethodInfo::addParameter(QString name, QSharedPointer<NetTypeInfo> typeInfo)
|
||||
{
|
||||
_parameters.append(QSharedPointer<NetMethodInfoArguement>(new NetMethodInfoArguement(name, typeInfo)));
|
||||
_parameters.append(QSharedPointer<NetMethodInfoArguement>(new NetMethodInfoArguement(std::move(name), std::move(typeInfo))));
|
||||
}
|
||||
|
||||
int NetMethodInfo::getParameterCount()
|
||||
|
|
@ -121,7 +122,7 @@ Q_DECL_EXPORT NetMethodInfoContainer* method_info_create(NetTypeInfoContainer* p
|
|||
returnType = returnTypeContainer->netTypeInfo;
|
||||
}
|
||||
|
||||
NetMethodInfo* instance = new NetMethodInfo(parentType, QString::fromUtf16((const char16_t*)methodName), returnType, isStatic);
|
||||
NetMethodInfo* instance = new NetMethodInfo(parentType, QString::fromUtf16(static_cast<const char16_t*>(methodName)), returnType, isStatic);
|
||||
result->method = QSharedPointer<NetMethodInfo>(instance);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -155,7 +156,7 @@ Q_DECL_EXPORT bool method_info_isStatic(NetMethodInfoContainer* container)
|
|||
|
||||
Q_DECL_EXPORT void method_info_addParameter(NetMethodInfoContainer* container, LPWSTR name, NetTypeInfoContainer* typeInfoContainer)
|
||||
{
|
||||
container->method->addParameter(QString::fromUtf16((const char16_t*)name), typeInfoContainer->netTypeInfo);
|
||||
container->method->addParameter(QString::fromUtf16(static_cast<const char16_t*>(name)), typeInfoContainer->netTypeInfo);
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT int method_info_getParameterCount(NetMethodInfoContainer* container)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <QmlNet/types/NetPropertyInfo.h>
|
||||
#include <QmlNet/types/NetSignalInfo.h>
|
||||
#include <QmlNetUtilities.h>
|
||||
#include <utility>
|
||||
|
||||
NetPropertyInfo::NetPropertyInfo(QSharedPointer<NetTypeInfo> parentType,
|
||||
QString name,
|
||||
|
|
@ -8,12 +9,12 @@ NetPropertyInfo::NetPropertyInfo(QSharedPointer<NetTypeInfo> parentType,
|
|||
bool canRead,
|
||||
bool canWrite,
|
||||
QSharedPointer<NetSignalInfo> notifySignal) :
|
||||
_parentType(parentType),
|
||||
_name(name),
|
||||
_returnType(returnType),
|
||||
_parentType(std::move(parentType)),
|
||||
_name(std::move(name)),
|
||||
_returnType(std::move(returnType)),
|
||||
_canRead(canRead),
|
||||
_canWrite(canWrite),
|
||||
_notifySignal(notifySignal)
|
||||
_notifySignal(std::move(notifySignal))
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -50,7 +51,7 @@ QSharedPointer<NetSignalInfo> NetPropertyInfo::getNotifySignal()
|
|||
|
||||
void NetPropertyInfo::setNotifySignal(QSharedPointer<NetSignalInfo> signal)
|
||||
{
|
||||
_notifySignal = signal;
|
||||
_notifySignal = std::move(signal);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
@ -67,7 +68,7 @@ Q_DECL_EXPORT NetPropertyInfoContainer* property_info_create(NetTypeInfoContaine
|
|||
notifySignal = notifySignalContainer->signal;
|
||||
}
|
||||
NetPropertyInfo* instance = new NetPropertyInfo(parentTypeContainer->netTypeInfo,
|
||||
QString::fromUtf16((const char16_t*)name),
|
||||
QString::fromUtf16(static_cast<const char16_t*>(name)),
|
||||
returnType->netTypeInfo,
|
||||
canRead,
|
||||
canWrite,
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
#include <QmlNet/types/Callbacks.h>
|
||||
#include <QmlNet/qml/NetValue.h>
|
||||
#include <QDebug>
|
||||
#include <utility>
|
||||
|
||||
NetReference::NetReference(uint64_t objectId, QSharedPointer<NetTypeInfo> typeInfo) :
|
||||
objectId(objectId),
|
||||
typeInfo(typeInfo)
|
||||
typeInfo(std::move(typeInfo))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -69,8 +70,8 @@ Q_DECL_EXPORT bool net_instance_activateSignal(NetReferenceContainer* container,
|
|||
}
|
||||
|
||||
bool result = false;
|
||||
for(int x = 0; x < liveInstances.length(); x++) {
|
||||
result = result || liveInstances.at(x)->activateSignal(signalNameString, parameters);
|
||||
for(NetValue* liveInstance : liveInstances) {
|
||||
result = result || liveInstance->activateSignal(signalNameString, parameters);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
#include <QmlNet/types/NetSignalInfo.h>
|
||||
#include <QmlNet/qml/NetValueMetaObjectPacker.h>
|
||||
#include <QmlNetUtilities.h>
|
||||
#include <utility>
|
||||
|
||||
NetSignalInfo::NetSignalInfo(QSharedPointer<NetTypeInfo> parentType, QString name) :
|
||||
_parentType(parentType),
|
||||
_name(name)
|
||||
_parentType(std::move(parentType)),
|
||||
_name(std::move(name))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +62,7 @@ QString NetSignalInfo::getSlotSignature()
|
|||
|
||||
signature.append("_internal_slot_for_net_del(");
|
||||
|
||||
if(_parameters.size() > 0) {
|
||||
if(!_parameters.empty()) {
|
||||
for(int parameterIndex = 0; parameterIndex <= _parameters.size() - 1; parameterIndex++)
|
||||
{
|
||||
if(parameterIndex > 0) {
|
||||
|
|
@ -82,7 +83,7 @@ extern "C" {
|
|||
Q_DECL_EXPORT NetSignalInfoContainer* signal_info_create(NetTypeInfoContainer* parentTypeContainer, LPWSTR name)
|
||||
{
|
||||
NetSignalInfoContainer* result = new NetSignalInfoContainer();
|
||||
NetSignalInfo* instance = new NetSignalInfo(parentTypeContainer->netTypeInfo, QString::fromUtf16((const char16_t*)name));
|
||||
NetSignalInfo* instance = new NetSignalInfo(parentTypeContainer->netTypeInfo, QString::fromUtf16(static_cast<const char16_t*>(name)));
|
||||
result->signal = QSharedPointer<NetSignalInfo>(instance);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,16 @@
|
|||
#include <QmlNet/types/NetTypeArrayFacadeList.h>
|
||||
#include <QmlNet/types/NetTypeInfo.h>
|
||||
|
||||
NetTypeArrayFacade::NetTypeArrayFacade()
|
||||
{
|
||||
NetTypeArrayFacade::NetTypeArrayFacade() = default;
|
||||
|
||||
}
|
||||
|
||||
QSharedPointer<NetTypeArrayFacade> NetTypeArrayFacade::fromType(QSharedPointer<NetTypeInfo> type)
|
||||
QSharedPointer<NetTypeArrayFacade> NetTypeArrayFacade::fromType(const QSharedPointer<NetTypeInfo>& type)
|
||||
{
|
||||
if(type->isArray()) {
|
||||
QSharedPointer<NetTypeArrayFacade_Array> facade = QSharedPointer<NetTypeArrayFacade_Array>(new NetTypeArrayFacade_Array(type));
|
||||
if(facade->isIncomplete()) {
|
||||
return nullptr;
|
||||
}
|
||||
return facade.dynamicCast<NetTypeArrayFacade>();
|
||||
return facade.staticCast<NetTypeArrayFacade>();
|
||||
}
|
||||
|
||||
if(type->isList()) {
|
||||
|
|
@ -23,7 +20,7 @@ QSharedPointer<NetTypeArrayFacade> NetTypeArrayFacade::fromType(QSharedPointer<N
|
|||
if(facade->isIncomplete()) {
|
||||
return nullptr;
|
||||
}
|
||||
return facade.dynamicCast<NetTypeArrayFacade>();
|
||||
return facade.staticCast<NetTypeArrayFacade>();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
@ -34,32 +31,32 @@ bool NetTypeArrayFacade::isFixed()
|
|||
return false;
|
||||
}
|
||||
|
||||
uint NetTypeArrayFacade::getLength(QSharedPointer<NetReference>)
|
||||
uint NetTypeArrayFacade::getLength(const QSharedPointer<NetReference>&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade::getIndexed(QSharedPointer<NetReference>, uint)
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade::getIndexed(const QSharedPointer<NetReference>&, uint)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NetTypeArrayFacade::setIndexed(QSharedPointer<NetReference>, uint, QSharedPointer<NetVariant>)
|
||||
void NetTypeArrayFacade::setIndexed(const QSharedPointer<NetReference>&, uint, const QSharedPointer<NetVariant>&)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NetTypeArrayFacade::push(QSharedPointer<NetReference>, QSharedPointer<NetVariant>)
|
||||
void NetTypeArrayFacade::push(const QSharedPointer<NetReference>&, const QSharedPointer<NetVariant>&)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade::pop(QSharedPointer<NetReference>)
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade::pop(const QSharedPointer<NetReference>&)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NetTypeArrayFacade::deleteAt(QSharedPointer<NetReference>, uint)
|
||||
void NetTypeArrayFacade::deleteAt(const QSharedPointer<NetReference>&, uint)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ class NetTypeArrayFacade
|
|||
public:
|
||||
NetTypeArrayFacade();
|
||||
virtual ~NetTypeArrayFacade() {}
|
||||
static QSharedPointer<NetTypeArrayFacade> fromType(QSharedPointer<NetTypeInfo> type);
|
||||
static QSharedPointer<NetTypeArrayFacade> fromType(const QSharedPointer<NetTypeInfo>& type);
|
||||
virtual bool isFixed();
|
||||
virtual uint getLength(QSharedPointer<NetReference> reference);
|
||||
virtual QSharedPointer<NetVariant> getIndexed(QSharedPointer<NetReference> reference, uint index);
|
||||
virtual void setIndexed(QSharedPointer<NetReference> reference, uint index, QSharedPointer<NetVariant> value);
|
||||
virtual void push(QSharedPointer<NetReference> reference, QSharedPointer<NetVariant> value);
|
||||
virtual QSharedPointer<NetVariant> pop(QSharedPointer<NetReference> reference);
|
||||
virtual void deleteAt(QSharedPointer<NetReference> reference, uint index);
|
||||
virtual uint getLength(const QSharedPointer<NetReference>& reference);
|
||||
virtual QSharedPointer<NetVariant> getIndexed(const QSharedPointer<NetReference>& reference, uint index);
|
||||
virtual void setIndexed(const QSharedPointer<NetReference>& reference, uint index, const QSharedPointer<NetVariant>& value);
|
||||
virtual void push(const QSharedPointer<NetReference>& reference, const QSharedPointer<NetVariant>& value);
|
||||
virtual QSharedPointer<NetVariant> pop(const QSharedPointer<NetReference>& reference);
|
||||
virtual void deleteAt(const QSharedPointer<NetReference>& reference, uint index);
|
||||
};
|
||||
|
||||
#endif // NETTYPEARRAYFACADE_H
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include <QmlNet/qml/NetVariantList.h>
|
||||
#include <QmlNet/types/Callbacks.h>
|
||||
|
||||
NetTypeArrayFacade_Array::NetTypeArrayFacade_Array(QSharedPointer<NetTypeInfo> type) :
|
||||
NetTypeArrayFacade_Array::NetTypeArrayFacade_Array(const QSharedPointer<NetTypeInfo>& type) :
|
||||
_isIncomplete(false)
|
||||
{
|
||||
for(int x = 0; x < type->getPropertyCount(); x++) {
|
||||
|
|
@ -44,14 +44,14 @@ bool NetTypeArrayFacade_Array::isFixed()
|
|||
return true;
|
||||
}
|
||||
|
||||
uint NetTypeArrayFacade_Array::getLength(QSharedPointer<NetReference> reference)
|
||||
uint NetTypeArrayFacade_Array::getLength(const QSharedPointer<NetReference>& reference)
|
||||
{
|
||||
QSharedPointer<NetVariant> result = QSharedPointer<NetVariant>(new NetVariant());
|
||||
QSharedPointer<NetVariant> result(new NetVariant());
|
||||
QmlNet::readProperty(_lengthProperty, reference, nullptr, result);
|
||||
return static_cast<uint>(result->getInt());
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade_Array::getIndexed(QSharedPointer<NetReference> reference, uint index)
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade_Array::getIndexed(const QSharedPointer<NetReference>& reference, uint index)
|
||||
{
|
||||
QSharedPointer<NetVariantList> parameters = QSharedPointer<NetVariantList>(new NetVariantList());
|
||||
QSharedPointer<NetVariant> parameter = QSharedPointer<NetVariant>(new NetVariant());
|
||||
|
|
@ -62,7 +62,7 @@ QSharedPointer<NetVariant> NetTypeArrayFacade_Array::getIndexed(QSharedPointer<N
|
|||
return result;
|
||||
}
|
||||
|
||||
void NetTypeArrayFacade_Array::setIndexed(QSharedPointer<NetReference> reference, uint index, QSharedPointer<NetVariant> value)
|
||||
void NetTypeArrayFacade_Array::setIndexed(const QSharedPointer<NetReference>& reference, uint index, const QSharedPointer<NetVariant>& value)
|
||||
{
|
||||
QSharedPointer<NetVariantList> parameters = QSharedPointer<NetVariantList>(new NetVariantList());
|
||||
QSharedPointer<NetVariant> parameter = QSharedPointer<NetVariant>(new NetVariant());
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ class NetPropertyInfo;
|
|||
class NetTypeArrayFacade_Array : public NetTypeArrayFacade
|
||||
{
|
||||
public:
|
||||
NetTypeArrayFacade_Array(QSharedPointer<NetTypeInfo> type);
|
||||
NetTypeArrayFacade_Array(const QSharedPointer<NetTypeInfo>& type);
|
||||
bool isIncomplete();
|
||||
bool isFixed();
|
||||
uint getLength(QSharedPointer<NetReference> reference);
|
||||
QSharedPointer<NetVariant> getIndexed(QSharedPointer<NetReference> reference, uint index);
|
||||
void setIndexed(QSharedPointer<NetReference> reference, uint index, QSharedPointer<NetVariant> value);
|
||||
bool isFixed() override;
|
||||
uint getLength(const QSharedPointer<NetReference>& reference) override;
|
||||
QSharedPointer<NetVariant> getIndexed(const QSharedPointer<NetReference>& reference, uint index) override;
|
||||
void setIndexed(const QSharedPointer<NetReference>& reference, uint index, const QSharedPointer<NetVariant>& value) override;
|
||||
private:
|
||||
bool _isIncomplete;
|
||||
QSharedPointer<NetPropertyInfo> _lengthProperty;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include <QmlNet/qml/NetVariantList.h>
|
||||
#include <QmlNet/types/Callbacks.h>
|
||||
|
||||
NetTypeArrayFacade_List::NetTypeArrayFacade_List(QSharedPointer<NetTypeInfo> type) :
|
||||
NetTypeArrayFacade_List::NetTypeArrayFacade_List(const QSharedPointer<NetTypeInfo>& type) :
|
||||
_isIncomplete(false)
|
||||
{
|
||||
for(int x = 0; x < type->getPropertyCount(); x++) {
|
||||
|
|
@ -46,37 +46,37 @@ bool NetTypeArrayFacade_List::isFixed()
|
|||
return false;
|
||||
}
|
||||
|
||||
uint NetTypeArrayFacade_List::getLength(QSharedPointer<NetReference> reference)
|
||||
uint NetTypeArrayFacade_List::getLength(const QSharedPointer<NetReference>& reference)
|
||||
{
|
||||
QSharedPointer<NetVariant> result = QSharedPointer<NetVariant>(new NetVariant());
|
||||
QmlNet::readProperty(_lengthProperty, reference, nullptr, result);
|
||||
return static_cast<uint>(result->getInt());
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade_List::getIndexed(QSharedPointer<NetReference> reference, uint index)
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade_List::getIndexed(const QSharedPointer<NetReference>& reference, uint index)
|
||||
{
|
||||
QSharedPointer<NetVariant> result = QSharedPointer<NetVariant>(new NetVariant());
|
||||
QSharedPointer<NetVariant> indexParameter = QSharedPointer<NetVariant>(new NetVariant());
|
||||
indexParameter->setInt(index);
|
||||
indexParameter->setInt(qint32(index));
|
||||
QmlNet::readProperty(_itemProperty, reference, indexParameter, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void NetTypeArrayFacade_List::setIndexed(QSharedPointer<NetReference> reference, uint index, QSharedPointer<NetVariant> value)
|
||||
void NetTypeArrayFacade_List::setIndexed(const QSharedPointer<NetReference>& reference, uint index, const QSharedPointer<NetVariant>& value)
|
||||
{
|
||||
QSharedPointer<NetVariant> indexParameter = QSharedPointer<NetVariant>(new NetVariant());
|
||||
indexParameter->setInt(static_cast<int>(index));
|
||||
indexParameter->setInt(qint32(index));
|
||||
QmlNet::writeProperty(_itemProperty, reference, indexParameter, value);
|
||||
}
|
||||
|
||||
void NetTypeArrayFacade_List::push(QSharedPointer<NetReference> reference, QSharedPointer<NetVariant> value)
|
||||
void NetTypeArrayFacade_List::push(const QSharedPointer<NetReference>& reference, const QSharedPointer<NetVariant>& value)
|
||||
{
|
||||
QSharedPointer<NetVariantList> parameters = QSharedPointer<NetVariantList>(new NetVariantList());
|
||||
parameters->add(value);
|
||||
QmlNet::invokeNetMethod(_addMethod, reference, parameters, nullptr);
|
||||
}
|
||||
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade_List::pop(QSharedPointer<NetReference> reference)
|
||||
QSharedPointer<NetVariant> NetTypeArrayFacade_List::pop(const QSharedPointer<NetReference>& reference)
|
||||
{
|
||||
uint length = getLength(reference);
|
||||
QSharedPointer<NetVariant> item = getIndexed(reference, length - 1);
|
||||
|
|
@ -84,7 +84,7 @@ QSharedPointer<NetVariant> NetTypeArrayFacade_List::pop(QSharedPointer<NetRefere
|
|||
return item;
|
||||
}
|
||||
|
||||
void NetTypeArrayFacade_List::deleteAt(QSharedPointer<NetReference> reference, uint index)
|
||||
void NetTypeArrayFacade_List::deleteAt(const QSharedPointer<NetReference>& reference, uint index)
|
||||
{
|
||||
QSharedPointer<NetVariantList> parameters = QSharedPointer<NetVariantList>(new NetVariantList());
|
||||
QSharedPointer<NetVariant> parameter = QSharedPointer<NetVariant>(new NetVariant());
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@ class NetPropertyInfo;
|
|||
class NetTypeArrayFacade_List : public NetTypeArrayFacade
|
||||
{
|
||||
public:
|
||||
NetTypeArrayFacade_List(QSharedPointer<NetTypeInfo> type);
|
||||
NetTypeArrayFacade_List(const QSharedPointer<NetTypeInfo>& type);
|
||||
bool isIncomplete();
|
||||
bool isFixed();
|
||||
uint getLength(QSharedPointer<NetReference> reference);
|
||||
QSharedPointer<NetVariant> getIndexed(QSharedPointer<NetReference> reference, uint index);
|
||||
void setIndexed(QSharedPointer<NetReference> reference, uint index, QSharedPointer<NetVariant> value);
|
||||
void push(QSharedPointer<NetReference> reference, QSharedPointer<NetVariant> value);
|
||||
QSharedPointer<NetVariant> pop(QSharedPointer<NetReference> reference);
|
||||
void deleteAt(QSharedPointer<NetReference> reference, uint index);
|
||||
bool isFixed() override;
|
||||
uint getLength(const QSharedPointer<NetReference>& reference) override;
|
||||
QSharedPointer<NetVariant> getIndexed(const QSharedPointer<NetReference>& reference, uint index) override;
|
||||
void setIndexed(const QSharedPointer<NetReference>& reference, uint index, const QSharedPointer<NetVariant>& value) override;
|
||||
void push(const QSharedPointer<NetReference>& reference, const QSharedPointer<NetVariant>& value) override;
|
||||
QSharedPointer<NetVariant> pop(const QSharedPointer<NetReference>& reference) override;
|
||||
void deleteAt(const QSharedPointer<NetReference>& reference, uint index) override;
|
||||
private:
|
||||
bool _isIncomplete;
|
||||
QSharedPointer<NetPropertyInfo> _lengthProperty;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@
|
|||
#include <QmlNet/types/Callbacks.h>
|
||||
#include <QmlNet/types/NetTypeArrayFacade.h>
|
||||
#include <QmlNetUtilities.h>
|
||||
#include <utility>
|
||||
|
||||
using namespace QmlNet;
|
||||
|
||||
NetTypeInfo::NetTypeInfo(QString fullTypeName) :
|
||||
metaObject(nullptr),
|
||||
_fullTypeName(fullTypeName),
|
||||
_fullTypeName(std::move(fullTypeName)),
|
||||
_variantType(NetVariantTypeEnum_Invalid),
|
||||
_isArray(false),
|
||||
_isList(false),
|
||||
|
|
@ -21,9 +22,7 @@ NetTypeInfo::NetTypeInfo(QString fullTypeName) :
|
|||
}
|
||||
|
||||
|
||||
NetTypeInfo::~NetTypeInfo() {
|
||||
|
||||
}
|
||||
NetTypeInfo::~NetTypeInfo() = default;
|
||||
|
||||
QString NetTypeInfo::getFullTypeName() {
|
||||
return _fullTypeName;
|
||||
|
|
@ -34,7 +33,7 @@ QString NetTypeInfo::getClassName() {
|
|||
}
|
||||
|
||||
void NetTypeInfo::setClassName(QString className) {
|
||||
_className = className;
|
||||
_className = std::move(className);
|
||||
}
|
||||
|
||||
NetVariantTypeEnum NetTypeInfo::getPrefVariantType() {
|
||||
|
|
@ -65,7 +64,7 @@ void NetTypeInfo::setIsList(bool isList)
|
|||
_isList = isList;
|
||||
}
|
||||
|
||||
void NetTypeInfo::addMethod(QSharedPointer<NetMethodInfo> methodInfo) {
|
||||
void NetTypeInfo::addMethod(const QSharedPointer<NetMethodInfo>& methodInfo) {
|
||||
_methods.append(methodInfo);
|
||||
if(methodInfo->isStatic()) {
|
||||
_methodsStatic.append(methodInfo);
|
||||
|
|
@ -108,7 +107,7 @@ QSharedPointer<NetMethodInfo> NetTypeInfo::getStaticMethodInfo(int index)
|
|||
return _methodsStatic.at(index);
|
||||
}
|
||||
|
||||
void NetTypeInfo::addProperty(QSharedPointer<NetPropertyInfo> property) {
|
||||
void NetTypeInfo::addProperty(const QSharedPointer<NetPropertyInfo>& property) {
|
||||
_properties.append(property);
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +121,7 @@ QSharedPointer<NetPropertyInfo> NetTypeInfo::getProperty(int index) {
|
|||
return _properties.at(index);
|
||||
}
|
||||
|
||||
void NetTypeInfo::addSignal(QSharedPointer<NetSignalInfo> signal) {
|
||||
void NetTypeInfo::addSignal(const QSharedPointer<NetSignalInfo>& signal) {
|
||||
_signals.append(signal);
|
||||
}
|
||||
|
||||
|
|
@ -171,9 +170,13 @@ void NetTypeInfo::ensureLoaded() {
|
|||
|
||||
extern "C" {
|
||||
|
||||
static_assert (std::is_pointer<LPWSTR>::value, "Check fromUtf16 calls below.");
|
||||
static_assert (!std::is_pointer<std::remove_pointer<LPWSTR>::type>::value, "Check fromUtf16 calls below.");
|
||||
static_assert (sizeof(std::remove_pointer<LPWSTR>::type) == sizeof(ushort), "Check fromUtf16 calls below.");
|
||||
|
||||
Q_DECL_EXPORT NetTypeInfoContainer* type_info_create(LPWSTR fullTypeName) {
|
||||
NetTypeInfoContainer* result = new NetTypeInfoContainer();
|
||||
result->netTypeInfo = QSharedPointer<NetTypeInfo>(new NetTypeInfo(QString::fromUtf16((const char16_t*)fullTypeName)));
|
||||
result->netTypeInfo = QSharedPointer<NetTypeInfo>(new NetTypeInfo(QString::fromUtf16(static_cast<const char16_t*>(fullTypeName))));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +196,7 @@ Q_DECL_EXPORT QmlNetStringContainer* type_info_getClassName(NetTypeInfoContainer
|
|||
}
|
||||
|
||||
Q_DECL_EXPORT void type_info_setClassName(NetTypeInfoContainer* netTypeInfo, LPWSTR className) {
|
||||
netTypeInfo->netTypeInfo->setClassName(QString::fromUtf16((const char16_t*)className));
|
||||
netTypeInfo->netTypeInfo->setClassName(QString::fromUtf16(static_cast<const char16_t*>(className)));
|
||||
}
|
||||
|
||||
Q_DECL_EXPORT NetVariantTypeEnum type_info_getPrefVariantType(NetTypeInfoContainer* netTypeInfo) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public:
|
|||
bool isList();
|
||||
void setIsList(bool isList);
|
||||
|
||||
void addMethod(QSharedPointer<NetMethodInfo> methodInfo);
|
||||
void addMethod(const QSharedPointer<NetMethodInfo>& methodInfo);
|
||||
int getMethodCount();
|
||||
QSharedPointer<NetMethodInfo> getMethodInfo(int index);
|
||||
|
||||
|
|
@ -41,11 +41,11 @@ public:
|
|||
int getStaticMethodCount();
|
||||
QSharedPointer<NetMethodInfo> getStaticMethodInfo(int index);
|
||||
|
||||
void addProperty(QSharedPointer<NetPropertyInfo> property);
|
||||
void addProperty(const QSharedPointer<NetPropertyInfo>& property);
|
||||
int getPropertyCount();
|
||||
QSharedPointer<NetPropertyInfo> getProperty(int index);
|
||||
|
||||
void addSignal(QSharedPointer<NetSignalInfo> signal);
|
||||
void addSignal(const QSharedPointer<NetSignalInfo>& signal);
|
||||
int getSignalCount();
|
||||
QSharedPointer<NetSignalInfo> getSignal(int index);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
#include <QmlNet/types/NetTypeManager.h>
|
||||
#include <QmlNet/types/Callbacks.h>
|
||||
#include <QSharedPointer>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace QmlNet;
|
||||
|
||||
QMap<QString, QSharedPointer<NetTypeInfo>> NetTypeManager::types;
|
||||
|
||||
NetTypeManager::NetTypeManager() {
|
||||
}
|
||||
NetTypeManager::NetTypeManager() = default;
|
||||
|
||||
QSharedPointer<NetTypeInfo> NetTypeManager::getTypeInfo(QString typeName) {
|
||||
QSharedPointer<NetTypeInfo> NetTypeManager::getTypeInfo(const QString& typeName) {
|
||||
if(NetTypeManager::types.contains(typeName))
|
||||
return NetTypeManager::types.value(typeName);
|
||||
|
||||
if(!isTypeValid(typeName)) {
|
||||
qWarning("Invalid type name: %s", qUtf8Printable(typeName));
|
||||
qWarning() << "Invalid type name:" << typeName;
|
||||
return QSharedPointer<NetTypeInfo>();
|
||||
}
|
||||
|
||||
QSharedPointer<NetTypeInfo> typeInfo = QSharedPointer<NetTypeInfo>(new NetTypeInfo(typeName));
|
||||
NetTypeManager::types.insert(NetTypeManager::types.end(), typeName, typeInfo);
|
||||
QSharedPointer<NetTypeInfo> typeInfo(new NetTypeInfo(typeName));
|
||||
NetTypeManager::types.insert(typeName, typeInfo);
|
||||
|
||||
createLazyTypeInfo(typeInfo);
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ QSharedPointer<NetTypeInfo> NetTypeManager::getTypeInfo(QString typeName) {
|
|||
extern "C" {
|
||||
|
||||
Q_DECL_EXPORT NetTypeInfoContainer* type_manager_getTypeInfo(LPWSTR fullTypeName) {
|
||||
QSharedPointer<NetTypeInfo> typeInfo = NetTypeManager::getTypeInfo(QString::fromUtf16((const char16_t*)fullTypeName));
|
||||
QSharedPointer<NetTypeInfo> typeInfo = NetTypeManager::getTypeInfo(QString::fromUtf16(static_cast<const char16_t*>(fullTypeName)));
|
||||
if(typeInfo == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class NetTypeInfo;
|
|||
class NetTypeManager {
|
||||
public:
|
||||
NetTypeManager();
|
||||
static QSharedPointer<NetTypeInfo> getTypeInfo(QString typeName);
|
||||
static QSharedPointer<NetTypeInfo> getTypeInfo(const QString& typeName);
|
||||
private:
|
||||
static QMap<QString, QSharedPointer<NetTypeInfo>> types;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
QmlNetStringContainer* createString(QString& value)
|
||||
QmlNetStringContainer* createString(const QString& value)
|
||||
{
|
||||
if(value.isNull()) {
|
||||
return nullptr;
|
||||
|
|
@ -18,9 +18,9 @@ QmlNetStringContainer* createString(QString& value)
|
|||
void freeString(QmlNetStringContainer* container)
|
||||
{
|
||||
if(container) {
|
||||
if(container->container) {
|
||||
|
||||
delete container->container;
|
||||
}
|
||||
|
||||
delete container;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ struct QmlNetStringContainer {
|
|||
|
||||
extern "C" {
|
||||
|
||||
Q_DECL_EXPORT QmlNetStringContainer* createString(QString& value);
|
||||
Q_DECL_EXPORT QmlNetStringContainer* createString(const QString& value);
|
||||
Q_DECL_EXPORT void freeString(QmlNetStringContainer* container);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="5.4.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
|
||||
<PackageReference Include="Moq" Version="4.9.0" />
|
||||
<PackageReference Include="FluentAssertions" Version="5.5.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="Moq" Version="4.10.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace Qml.Net.Tests.Qml
|
|||
}
|
||||
}
|
||||
|
||||
protected void RegisterType<T>()
|
||||
protected virtual void RegisterType<T>()
|
||||
{
|
||||
if (_registeredTypes.Contains(typeof(T))) return;
|
||||
_registeredTypes.Add(typeof(T));
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Qml.Net.Tests.Qml
|
|||
variant.Instance.Instance.Should().Be(testObject);
|
||||
variant.VariantType.Should().Be(NetVariantType.Object);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Can_store_bool()
|
||||
{
|
||||
|
|
@ -42,7 +42,7 @@ namespace Qml.Net.Tests.Qml
|
|||
variant.Bool = false;
|
||||
variant.Bool.Should().BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Can_store_char()
|
||||
{
|
||||
|
|
@ -76,6 +76,39 @@ namespace Qml.Net.Tests.Qml
|
|||
variant.UInt.Should().Be(uint.MaxValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_store_long()
|
||||
{
|
||||
var variant = new NetVariant();
|
||||
variant.Long = -1;
|
||||
variant.VariantType.Should().Be(NetVariantType.Long);
|
||||
variant.Long.Should().Be(-1);
|
||||
variant.Long = long.MaxValue;
|
||||
variant.Long.Should().Be(long.MaxValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_store_ulong()
|
||||
{
|
||||
var variant = new NetVariant();
|
||||
variant.ULong = ulong.MinValue;
|
||||
variant.VariantType.Should().Be(NetVariantType.ULong);
|
||||
variant.ULong.Should().Be(ulong.MinValue);
|
||||
variant.ULong = ulong.MaxValue;
|
||||
variant.ULong.Should().Be(ulong.MaxValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_store_float()
|
||||
{
|
||||
var variant = new NetVariant();
|
||||
variant.Float = float.MinValue;
|
||||
variant.VariantType.Should().Be(NetVariantType.Float);
|
||||
variant.Float.Should().Be(float.MinValue);
|
||||
variant.Float = float.MaxValue;
|
||||
variant.Float.Should().Be(float.MaxValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_store_double()
|
||||
{
|
||||
|
|
@ -119,7 +152,7 @@ namespace Qml.Net.Tests.Qml
|
|||
value.Value.Millisecond.Should().Be(0);
|
||||
value.Value.Offset.Should().Be(TimeSpan.FromHours(5));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Can_clear_value()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ namespace Qml.Net.Tests.Qml
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public object TestObjectProperty { get; set; }
|
||||
|
||||
public virtual void TestObjectPropertyTest(string result)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class ObjectTestsQmlReturnType
|
||||
|
|
@ -96,5 +103,19 @@ namespace Qml.Net.Tests.Qml
|
|||
Mock.Verify(x => x.Overload(), Times.Once);
|
||||
Mock.Verify(x => x.Overload(It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_get_null()
|
||||
{
|
||||
Mock.Setup(x => x.TestObjectPropertyTest(It.IsAny<string>()));
|
||||
|
||||
RunQmlTest(
|
||||
"test",
|
||||
@"
|
||||
test.testObjectPropertyTest(typeof test.testObjectProperty)
|
||||
");
|
||||
|
||||
Mock.Verify(x => x.TestObjectPropertyTest("object"), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
src/net/Qml.Net.Tests/Qml/SingletonTests.cs
Normal file
37
src/net/Qml.Net.Tests/Qml/SingletonTests.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using Moq;
|
||||
using Qml.Net.Internal.Qml;
|
||||
using Xunit;
|
||||
|
||||
namespace Qml.Net.Tests.Qml
|
||||
{
|
||||
public class SingletonTests : BaseQmlTests<SingletonTests.SingletonTestObject>
|
||||
{
|
||||
public class SingletonTestObject
|
||||
{
|
||||
public virtual string Property { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_register_singleton()
|
||||
{
|
||||
NetTestHelper.RunQml(qmlApplicationEngine,
|
||||
@"
|
||||
import QtQuick 2.0
|
||||
import tests 1.0
|
||||
Item {
|
||||
id: test
|
||||
Component.onCompleted: function() {
|
||||
SingletonTestObject.property = ""test""
|
||||
}
|
||||
}");
|
||||
|
||||
Mock.VerifySet(x => x.Property = "test", Times.Once);
|
||||
}
|
||||
|
||||
protected override void RegisterType<T>()
|
||||
{
|
||||
Net.Qml.RegisterSingletonType<T>("tests");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<T>(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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -461,6 +458,12 @@ namespace Qml.Net.Internal
|
|||
return NetVariantType.Int;
|
||||
if (typeInfo == typeof(uint))
|
||||
return NetVariantType.UInt;
|
||||
if (typeInfo == typeof(long))
|
||||
return NetVariantType.Long;
|
||||
if (typeInfo == typeof(ulong))
|
||||
return NetVariantType.ULong;
|
||||
if (typeInfo == typeof(float))
|
||||
return NetVariantType.Float;
|
||||
if (typeInfo == typeof(double))
|
||||
return NetVariantType.Double;
|
||||
if (typeInfo == typeof(string))
|
||||
|
|
|
|||
|
|
@ -42,12 +42,18 @@ namespace Qml.Net.Internal
|
|||
destination.Bool = (bool)source;
|
||||
else if(type == typeof(char))
|
||||
destination.Char = (char)source;
|
||||
else if(type == typeof(float))
|
||||
destination.Float = (float)source;
|
||||
else if(type == typeof(double))
|
||||
destination.Double = (double)source;
|
||||
else if (type == typeof(int))
|
||||
destination.Int = (int)source;
|
||||
else if(type == typeof(uint))
|
||||
destination.UInt = (uint)source;
|
||||
else if (type == typeof(long))
|
||||
destination.Long = (long)source;
|
||||
else if(type == typeof(ulong))
|
||||
destination.ULong = (ulong)source;
|
||||
else if (type == typeof(string))
|
||||
destination.String = (string)source;
|
||||
else if (type == typeof(DateTimeOffset))
|
||||
|
|
@ -80,6 +86,15 @@ namespace Qml.Net.Internal
|
|||
case NetVariantType.UInt:
|
||||
destination = source.UInt;
|
||||
break;
|
||||
case NetVariantType.Long:
|
||||
destination = source.Long;
|
||||
break;
|
||||
case NetVariantType.ULong:
|
||||
destination = source.ULong;
|
||||
break;
|
||||
case NetVariantType.Float:
|
||||
destination = source.Float;
|
||||
break;
|
||||
case NetVariantType.Double:
|
||||
destination = source.Double;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -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<ICombined>("QmlNet");
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
throw new Exception("Couldn't find the native Qml.Net library.");
|
||||
}
|
||||
|
||||
var library = loader.LoadLibrary(result.Path);
|
||||
Callbacks = LoadInteropType<CallbacksInterop>(library, loader);
|
||||
NetTypeInfo = LoadInteropType<NetTypeInfoInterop>(library, loader);
|
||||
NetJsValue = LoadInteropType<NetJsValueInterop>(library, loader);
|
||||
NetMethodInfo = LoadInteropType<NetMethodInfoInterop>(library, loader);
|
||||
NetPropertyInfo = LoadInteropType<NetPropertyInfoInterop>(library, loader);
|
||||
NetTypeManager = LoadInteropType<NetTypeManagerInterop>(library, loader);
|
||||
QGuiApplication = LoadInteropType<QGuiApplicationInterop>(library, loader);
|
||||
QQmlApplicationEngine = LoadInteropType<QQmlApplicationEngineInterop>(library, loader);
|
||||
NetVariant = LoadInteropType<NetVariantInterop>(library, loader);
|
||||
NetReference = LoadInteropType<NetReferenceInterop>(library, loader);
|
||||
NetVariantList = LoadInteropType<NetVariantListInterop>(library, loader);
|
||||
NetTestHelper = LoadInteropType<NetTestHelperInterop>(library, loader);
|
||||
NetSignalInfo = LoadInteropType<NetSignalInfoInterop>(library, loader);
|
||||
QResource = LoadInteropType<QResourceInterop>(library, loader);
|
||||
NetDelegate = LoadInteropType<NetDelegateInterop>(library, loader);
|
||||
QQuickStyle = LoadInteropType<QQuickStyleInterop>(library, loader);
|
||||
QtInterop = LoadInteropType<QtInterop>(library, loader);
|
||||
Utilities = LoadInteropType<UtilitiesInterop>(library, loader);
|
||||
QtWebEngine = LoadInteropType<QtWebEngineInterop>(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<T>(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<NativeSymbolAttribute>().First().Entrypoint;
|
||||
var symbol = loader.LoadSymbol(library, entryName);
|
||||
property.SetValue(o, Marshal.GetDelegateForFunctionPointer(symbol, property.PropertyType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
9
src/net/Qml.Net/Internal/NativeSymbolAttribute.cs
Normal file
9
src/net/Qml.Net/Internal/NativeSymbolAttribute.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace Qml.Net.Internal
|
||||
{
|
||||
public class NativeSymbolAttribute : Attribute
|
||||
{
|
||||
public string Entrypoint { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using AdvancedDLSupport;
|
||||
using Qml.Net.Internal.Types;
|
||||
|
||||
namespace Qml.Net.Internal.Qml
|
||||
|
|
@ -54,6 +53,24 @@ namespace Qml.Net.Internal.Qml
|
|||
get => Interop.NetVariant.GetUInt(Handle);
|
||||
set => Interop.NetVariant.SetUInt(Handle, value);
|
||||
}
|
||||
|
||||
public long Long
|
||||
{
|
||||
get => Interop.NetVariant.GetLong(Handle);
|
||||
set => Interop.NetVariant.SetLong(Handle, value);
|
||||
}
|
||||
|
||||
public ulong ULong
|
||||
{
|
||||
get => Interop.NetVariant.GetULong(Handle);
|
||||
set => Interop.NetVariant.SetULong(Handle, value);
|
||||
}
|
||||
|
||||
public float Float
|
||||
{
|
||||
get => Interop.NetVariant.GetFloat(Handle);
|
||||
set => Interop.NetVariant.SetFloat(Handle, value);
|
||||
}
|
||||
|
||||
public double Double
|
||||
{
|
||||
|
|
@ -129,63 +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")]
|
||||
public SetLongDel SetLong { get; set; }
|
||||
public delegate void SetLongDel(IntPtr variant, long value);
|
||||
[NativeSymbol(Entrypoint = "net_variant_getLong")]
|
||||
public GetLongDel GetLong { get; set; }
|
||||
public delegate long GetLongDel(IntPtr variant);
|
||||
|
||||
[NativeSymbol(Entrypoint = "net_variant_setULong")]
|
||||
public SetULongDel SetULong { get; set; }
|
||||
public delegate void SetULongDel(IntPtr variant, ulong value);
|
||||
[NativeSymbol(Entrypoint = "net_variant_getULong")]
|
||||
public GetULongDel GetULong { get; set; }
|
||||
public delegate ulong GetULongDel(IntPtr variant);
|
||||
|
||||
[NativeSymbol(Entrypoint = "net_variant_setFloat")]
|
||||
public SetFloatDel SetFloat { get; set; }
|
||||
public delegate void SetFloatDel(IntPtr variant, float value);
|
||||
[NativeSymbol(Entrypoint = "net_variant_getFloat")]
|
||||
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)]
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,17 @@
|
|||
public enum NetVariantType
|
||||
{
|
||||
Invalid = 0,
|
||||
Bool = 1,
|
||||
Char = 2,
|
||||
Int = 3,
|
||||
UInt = 4,
|
||||
Double = 5,
|
||||
String = 6,
|
||||
DateTime = 7,
|
||||
Object = 8,
|
||||
JsValue = 9
|
||||
Bool,
|
||||
Char,
|
||||
Int,
|
||||
UInt,
|
||||
Long,
|
||||
ULong,
|
||||
Float,
|
||||
Double,
|
||||
String,
|
||||
DateTime,
|
||||
Object,
|
||||
JsValue,
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
@ -47,7 +46,7 @@ namespace Qml.Net
|
|||
|
||||
public int Exec()
|
||||
{
|
||||
return Interop.QGuiApplication.Exec(Handle);
|
||||
return Interop.QGuiApplication.Exec();
|
||||
}
|
||||
|
||||
public void Dispatch(Action action)
|
||||
|
|
@ -61,7 +60,7 @@ namespace Qml.Net
|
|||
|
||||
public void Exit(int returnCode = 0)
|
||||
{
|
||||
Interop.QGuiApplication.Exit(Handle, returnCode);
|
||||
Interop.QGuiApplication.Exit(returnCode);
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
|
|
@ -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(IntPtr app);
|
||||
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(IntPtr app, 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using AdvancedDLSupport;
|
||||
using Qml.Net.Internal;
|
||||
using Qml.Net.Internal.Behaviors;
|
||||
using Qml.Net.Internal.Qml;
|
||||
|
|
@ -102,32 +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")]
|
||||
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")]
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,8 @@
|
|||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AdvancedDLSupport" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
|
||||
<PackageReference Include="NetNativeLibLoader" Version="0.1.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using Qml.Net.Internal;
|
||||
using Qml.Net.Internal.Types;
|
||||
|
||||
namespace Qml.Net
|
||||
|
|
@ -8,5 +10,18 @@ namespace Qml.Net
|
|||
{
|
||||
return QQmlApplicationEngine.RegisterType(NetTypeManager.GetTypeInfo<T>(), uri, typeof(T).Name, versionMajor, versionMinor);
|
||||
}
|
||||
|
||||
public static int RegisterSingletonType(string url, string uri, int versionMajor, int versionMinor, string qmlName)
|
||||
{
|
||||
return Interop.QQmlApplicationEngine.RegisterSingletonTypeQml(url, uri, versionMajor, versionMinor, qmlName);
|
||||
}
|
||||
|
||||
public static int RegisterSingletonType<T>(string uri, int versionMajor = 1, int versionMinor = 0)
|
||||
{
|
||||
using (var type = NetTypeManager.GetTypeInfo<T>())
|
||||
{
|
||||
return Interop.QQmlApplicationEngine.RegisterSingletonTypeNet(type.Handle, uri, versionMajor, versionMinor, typeof(T).Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue