Core: Add a basic extension for the JsExpander

This adds a "Utils" object to the Js runtime offered by the
JsExpander that adds some useful functions.

Mostly file name mangling and finding preferred extension
from the MIME type database.

Change-Id: I907dae7f295167667ac2ae81461bbff16dc98ef4
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Tobias Hunger
2014-09-16 15:58:32 +02:00
parent e014847cdd
commit f5d48bf39e
8 changed files with 232 additions and 5 deletions

View File

@@ -29,6 +29,7 @@
#include "jsexpander.h"
#include "corejsextensions.h"
#include "variablemanager.h"
#include <utils/qtcassert.h>
@@ -43,7 +44,11 @@ namespace Internal {
class JsExpanderPrivate {
public:
JsExpanderPrivate() : m_utilsExtension(new UtilsJsExtension) { }
~JsExpanderPrivate() { delete m_utilsExtension; }
QScriptEngine m_engine;
UtilsJsExtension *m_utilsExtension;
};
} // namespace Internal
@@ -98,6 +103,8 @@ JsExpander::JsExpander()
return result;
}
});
registerQObjectForJs(QLatin1String("Util"), d->m_utilsExtension);
}
JsExpander::~JsExpander()