summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/corelib/jsextensions/jsextensions.cpp7
-rw-r--r--src/lib/corelib/jsextensions/jsextensions.h1
-rw-r--r--src/lib/corelib/jsextensions/utilitiesextension.cpp22
3 files changed, 30 insertions, 0 deletions
diff --git a/src/lib/corelib/jsextensions/jsextensions.cpp b/src/lib/corelib/jsextensions/jsextensions.cpp
index 1049d2d6b..6f49c26ed 100644
--- a/src/lib/corelib/jsextensions/jsextensions.cpp
+++ b/src/lib/corelib/jsextensions/jsextensions.cpp
@@ -74,5 +74,12 @@ bool JsExtensions::hasExtension(const QString &name)
return initializers().contains(name);
}
+QStringList JsExtensions::extensionNames()
+{
+ auto keys = initializers().keys();
+ std::sort(keys.begin(), keys.end());
+ return keys;
+}
+
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/jsextensions/jsextensions.h b/src/lib/corelib/jsextensions/jsextensions.h
index 1ff25a659..8977dbe8a 100644
--- a/src/lib/corelib/jsextensions/jsextensions.h
+++ b/src/lib/corelib/jsextensions/jsextensions.h
@@ -57,6 +57,7 @@ public:
static void setupExtensions(const QStringList &names, QScriptValue scope);
static QScriptValue loadExtension(QScriptEngine *engine, const QString &name);
static bool hasExtension(const QString &name);
+ static QStringList extensionNames();
};
} // namespace Internal
diff --git a/src/lib/corelib/jsextensions/utilitiesextension.cpp b/src/lib/corelib/jsextensions/utilitiesextension.cpp
index a8e5e7c1e..78f9c8401 100644
--- a/src/lib/corelib/jsextensions/utilitiesextension.cpp
+++ b/src/lib/corelib/jsextensions/utilitiesextension.cpp
@@ -39,6 +39,8 @@
#include "jsextensions_p.h"
+#include <api/languageinfo.h>
+#include <jsextensions/jsextensions.h>
#include <language/scriptengine.h>
#include <logging/translator.h>
#include <tools/architectures.h>
@@ -86,6 +88,9 @@ public:
static QScriptValue js_msvcCompilerInfo(QScriptContext *context, QScriptEngine *engine);
static QScriptValue js_versionCompare(QScriptContext *context, QScriptEngine *engine);
+
+ static QScriptValue js_qmlTypeInfo(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue js_builtinExtensionNames(QScriptContext *context, QScriptEngine *engine);
};
static void initializeJsExtensionUtilities(QScriptValue extensionObject)
@@ -122,6 +127,10 @@ static void initializeJsExtensionUtilities(QScriptValue extensionObject)
engine->newFunction(UtilitiesExtension::js_msvcCompilerInfo, 1));
environmentObj.setProperty(QStringLiteral("versionCompare"),
engine->newFunction(UtilitiesExtension::js_versionCompare, 2));
+ environmentObj.setProperty(QStringLiteral("qmlTypeInfo"),
+ engine->newFunction(UtilitiesExtension::js_qmlTypeInfo, 0));
+ environmentObj.setProperty(QStringLiteral("builtinExtensionNames"),
+ engine->newFunction(UtilitiesExtension::js_builtinExtensionNames, 0));
extensionObject.setProperty(QStringLiteral("Utilities"), environmentObj);
}
@@ -493,6 +502,19 @@ QScriptValue UtilitiesExtension::js_versionCompare(QScriptContext *context, QScr
QStringLiteral("versionCompare expects two arguments of type string"));
}
+QScriptValue UtilitiesExtension::js_qmlTypeInfo(QScriptContext *context, QScriptEngine *engine)
+{
+ Q_UNUSED(context);
+ return engine->toScriptValue(QString::fromUtf8(qbs::LanguageInfo().qmlTypeInfo()));
+}
+
+QScriptValue UtilitiesExtension::js_builtinExtensionNames(QScriptContext *context,
+ QScriptEngine *engine)
+{
+ Q_UNUSED(context);
+ return engine->toScriptValue(JsExtensions::extensionNames());
+}
+
} // namespace Internal
} // namespace qbs