DeprecatedScriptPlugin => ExampleScriptPlugin

This commit is contained in:
humbletim 2019-07-25 21:47:56 -04:00
parent d334a2e5e2
commit 52d2938be3
3 changed files with 11 additions and 13 deletions

View file

@ -1,5 +1,5 @@
//
// DeprecatedScriptPlugin.h
// ExampleScriptPlugin.h
// plugins/KasenAPIExample/src
//
// Created by Kasen IO on 2019.07.14 | realities.dev | kasenvr@gmail.com
@ -10,8 +10,8 @@
//
// Supporting file containing all QtScript specific integration.
#ifndef DEPRECATED_SCRIPT_PLUGIN_H
#define DEPRECATED_SCRIPT_PLUGIN_H
#ifndef EXAMPLE_SCRIPT_PLUGIN_H
#define EXAMPLE_SCRIPT_PLUGIN_H
#if DEV_BUILD
#pragma message("QtScript is deprecated see: doc.qt.io/qt-5/topics-scripting.html")
@ -22,16 +22,14 @@
#include <QCoreApplication>
#include <shared/ScriptInitializerMixin.h>
namespace deprecated {
namespace example {
extern const QLoggingCategory& logger;
inline void setGlobalInstance(QScriptEngine* engine, const QString& name, QObject* object) {
auto value = engine->newQObject(object, QScriptEngine::QtOwnership);
engine->globalObject().setProperty(name, value);
if (1 || getenv("DEBUG")) {
qCDebug(logger) << "(via ScriptInitializers)...setGlobalInstance" << name << engine->property("fileName");
}
qCDebug(logger) << "setGlobalInstance" << name << engine->property("fileName");
}
class ScriptPlugin : public QObject {
@ -53,6 +51,6 @@ public slots:
inline QString toString() const { return QString("[%1 version=%2]").arg(objectName()).arg(_version); }
};
} // namespace deprecated
} // namespace example
#endif

View file

@ -10,7 +10,7 @@
//
// Example of prototyping new JS APIs by leveraging the existing plugin system.
#include "DeprecatedScriptPlugin.h"
#include "ExampleScriptPlugin.h"
#include <QCoreApplication>
#include <QtCore/QJsonObject>
@ -25,11 +25,11 @@ namespace custom_api_example {
QLoggingCategory logger{ "custom_api_example" };
class KasenAPIExample : public deprecated::ScriptPlugin {
class KasenAPIExample : public example::ScriptPlugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID "KasenAPIExample" FILE "plugin.json")
public:
KasenAPIExample() : deprecated::ScriptPlugin("KasenAPIExample", "0.0.0") {
KasenAPIExample() : example::ScriptPlugin("KasenAPIExample", "0.0.1") {
qCInfo(logger) << "plugin loaded" << qApp << toString() << QThread::currentThread();
}
@ -134,6 +134,6 @@ private:
}
const QLoggingCategory& deprecated::logger{ custom_api_example::logger };
const QLoggingCategory& example::logger{ custom_api_example::logger };
#include "KasenAPIExample.moc"

View file

@ -4,7 +4,7 @@
"package": {
"author": "Revofire",
"homepage": "www.realities.dev",
"version": "0.0.0",
"version": "0.0.1",
"engines": {
"hifi-interface": ">= 0.83.0",
"hifi-assignment-client": ">= 0.83.0"