TreeFrogFramework 2.10
Loading...
Searching...
No Matches
tjsmodule.h
Go to the documentation of this file.
1#pragma once
2#include <QDir>
3#include <QJSValue>
4#include <QMap>
5#include <QMutex>
6#include <QObject>
7#include <QString>
8#include <QStringList>
9#include <TGlobal>
10
11class QJSEngine;
12class TJSInstance;
13
14
15class T_CORE_EXPORT TJSModule : public QObject {
16public:
17 TJSModule(QObject *parent = nullptr);
18 virtual ~TJSModule();
19
20 QJSValue evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
21 QJSValue call(const QString &func, const QJSValue &arg);
22 QJSValue call(const QString &func, const QJSValueList &args = QJSValueList());
23 TJSInstance callAsConstructor(const QString &constructorName, const QJSValue &arg);
24 TJSInstance callAsConstructor(const QString &constructorName, const QJSValueList &args = QJSValueList());
25 QString modulePath() const { return _modulePath; }
26
27 QJSValue import(const QString &moduleName);
28 QJSValue import(const QString &defaultMember, const QString &moduleName);
29
30private:
31 QJSEngine *_jsEngine;
32 QMap<QString, QString> _loadedFiles;
33 QJSValue *_funcObj;
34 QString _lastFunc;
35 QString _modulePath;
36 QRecursiveMutex _mutex;
37
40
41 friend class TJSLoader;
42 friend class TReactComponent;
43};
The TJSInstance class acts as a instance for JavaScript data types.
Definition tjsinstance.h:7
The TJSLoader class loads a JavaScript module in server side.
Definition tjsloader.h:8
The TJSModule class represents a module for evaluating JavaScript code.
Definition tjsmodule.h:15
QString modulePath() const
Definition tjsmodule.h:25
#define T_CORE_EXPORT
Definition tdeclexport.h:28
#define T_DISABLE_COPY(Class)
Definition tdeclexport.h:37
#define T_DISABLE_MOVE(Class)
Definition tdeclexport.h:41