Skip to content

Commit c3f6ea8

Browse files
committed
rename class, TJSContext -> TJSModule.
1 parent e016792 commit c3f6ea8

File tree

9 files changed

+33
-35
lines changed

9 files changed

+33
-35
lines changed

include/TJSContext

Lines changed: 0 additions & 1 deletion
This file was deleted.

include/headers.pri

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ HEADER_FILES = tabstractmodel.h tabstractuser.h tactioncontext.h tactioncontroll
66
greaterThan(QT_MAJOR_VERSION, 4) {
77
HEADER_CLASSES += ../include/TJSLoader
88
HEADER_FILES += tjsloader.h
9-
HEADER_CLASSES += ../include/TJSContext
10-
HEADER_FILES += tjscontext.h
9+
HEADER_CLASSES += ../include/TJSModule
10+
HEADER_FILES += tjsmodule.h
1111
HEADER_CLASSES += ../include/TJSInstance
1212
HEADER_FILES += tjsinstance.h
1313
HEADER_CLASSES += ../include/TReactComponent

include/tjscontext.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/corelib.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ greaterThan(QT_MAJOR_VERSION, 4) {
326326
SOURCES += tjsonutil.cpp
327327
HEADERS += tjsloader.h
328328
SOURCES += tjsloader.cpp
329-
HEADERS += tjscontext.h
330-
SOURCES += tjscontext.cpp
329+
HEADERS += tjsmodule.h
330+
SOURCES += tjsmodule.cpp
331331
HEADERS += tjsinstance.h
332332
SOURCES += tjsinstance.cpp
333333
HEADERS += treactcomponent.h

src/tjsloader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// #define tSystemError(fmt, ...) printf(fmt "\n", ## __VA_ARGS__)
1919
// #define tSystemDebug(fmt, ...) printf(fmt "\n", ## __VA_ARGS__)
2020

21-
static QMap<QString, TJSContext*> jsContexts;
21+
static QMap<QString, TJSModule*> jsContexts;
2222
static QStringList defaultSearchPaths;
2323
static QMutex gMutex(QMutex::Recursive);
2424

@@ -120,15 +120,15 @@ TJSLoader::TJSLoader(const QString &defaultMember, const QString &moduleName, Al
120120
if successful; otherwise returns null pointer.
121121
i.e. var \a defaultMember = require( \a moduleName );
122122
*/
123-
TJSContext *TJSLoader::load(bool reload)
123+
TJSModule *TJSLoader::load(bool reload)
124124
{
125125
if (module.isEmpty()) {
126126
return nullptr;
127127
}
128128

129129
QMutexLocker lock(&gMutex);
130130
QString key = member + QLatin1Char(';') + module;
131-
TJSContext *context = jsContexts.value(key);
131+
TJSModule *context = jsContexts.value(key);
132132

133133
if (reload && context) {
134134
jsContexts.remove(key);
@@ -137,7 +137,7 @@ TJSContext *TJSLoader::load(bool reload)
137137
}
138138

139139
if (!context) {
140-
context = new TJSContext();
140+
context = new TJSModule();
141141

142142
for (auto &p : importFiles) {
143143
// Imports as JavaScript
@@ -243,7 +243,7 @@ void TJSLoader::import(const QString &defaultMember, const QString &moduleName)
243243
}
244244

245245

246-
QJSValue TJSLoader::importTo(TJSContext *context, bool isMain) const
246+
QJSValue TJSLoader::importTo(TJSModule *context, bool isMain) const
247247
{
248248
if (!context) {
249249
return false;
@@ -324,7 +324,7 @@ void TJSLoader::setDefaultSearchPaths(const QStringList &paths)
324324
}
325325

326326

327-
void TJSLoader::replaceRequire(TJSContext *context, QString &content, const QDir &dir) const
327+
void TJSLoader::replaceRequire(TJSModule *context, QString &content, const QDir &dir) const
328328
{
329329
const QRegExp rx("require\\s*\\(\\s*[\"']([^\\(\\)\"' ,]+)[\"']\\s*\\)");
330330

src/tjsloader.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <QJSValue>
55
#include <TGlobal>
6-
#include <TJSContext>
6+
#include <TJSModule>
77
#include <TJSInstance>
88

99

@@ -18,7 +18,7 @@ class T_CORE_EXPORT TJSLoader
1818
TJSLoader(const QString &moduleName, AltJS alt = Default);
1919
TJSLoader(const QString &defaultMember, const QString &moduleName, AltJS alt = Default);
2020

21-
TJSContext *load(bool reload = false);
21+
TJSModule *load(bool reload = false);
2222
void import(const QString &moduleName);
2323
void import(const QString &defaultMember, const QString &moduleName);
2424
TJSInstance loadAsConstructor(const QJSValue &arg) const;
@@ -29,10 +29,10 @@ class T_CORE_EXPORT TJSLoader
2929
static QString compileJsx(const QString &jsx);
3030

3131
protected:
32-
QJSValue importTo(TJSContext *context, bool isMain) const;
32+
QJSValue importTo(TJSModule *context, bool isMain) const;
3333
QString search(const QString &moduleName, AltJS alt) const;
3434
QString absolutePath(const QString &moduleName, const QDir &dir, AltJS alt) const;
35-
void replaceRequire(TJSContext *context, QString &content, const QDir &dir) const;
35+
void replaceRequire(TJSModule *context, QString &content, const QDir &dir) const;
3636

3737
private:
3838
QString module;
@@ -41,7 +41,7 @@ class T_CORE_EXPORT TJSLoader
4141
QStringList searchPaths;
4242
QList<QPair<QString, QString>> importFiles;
4343

44-
friend class TJSContext;
44+
friend class TJSModule;
4545
};
4646

4747
#endif // TJSLOADER_H

src/tjsmodule.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#include <QJSEngine>
99
#include <QJSValue>
10+
#include <TJSModule>
1011
#include <TJSLoader>
11-
#include <TJSContext>
1212
#include <TJSInstance>
1313
#include "tsystemglobal.h"
1414

@@ -24,15 +24,15 @@ inline const char *prop(const QJSValue &val, const QString &name = QString())
2424
}
2525

2626

27-
TJSContext::TJSContext(QObject *parent)
27+
TJSModule::TJSModule(QObject *parent)
2828
: QObject(parent), jsEngine(new QJSEngine()), loadedFiles(), funcObj(nullptr),
2929
lastFunc(), mutex(QMutex::Recursive)
3030
{
3131
jsEngine->evaluate("exports={};module={};module.exports={};");
3232
}
3333

3434

35-
TJSContext::~TJSContext()
35+
TJSModule::~TJSModule()
3636
{
3737
if (funcObj) {
3838
delete funcObj;
@@ -41,7 +41,7 @@ TJSContext::~TJSContext()
4141
}
4242

4343

44-
QJSValue TJSContext::evaluate(const QString &program, const QString &fileName, int lineNumber)
44+
QJSValue TJSModule::evaluate(const QString &program, const QString &fileName, int lineNumber)
4545
{
4646
QMutexLocker locker(&mutex);
4747

@@ -54,14 +54,14 @@ QJSValue TJSContext::evaluate(const QString &program, const QString &fileName, i
5454
}
5555

5656

57-
QJSValue TJSContext::call(const QString &func, const QJSValue &arg)
57+
QJSValue TJSModule::call(const QString &func, const QJSValue &arg)
5858
{
5959
QJSValueList args = { arg };
6060
return call(func, args);
6161
}
6262

6363

64-
QJSValue TJSContext::call(const QString &func, const QJSValueList &args)
64+
QJSValue TJSModule::call(const QString &func, const QJSValueList &args)
6565
{
6666
QMutexLocker locker(&mutex);
6767
QJSValue ret;
@@ -104,14 +104,14 @@ QJSValue TJSContext::call(const QString &func, const QJSValueList &args)
104104
}
105105

106106

107-
TJSInstance TJSContext::callAsConstructor(const QString &constructorName, const QJSValue &arg)
107+
TJSInstance TJSModule::callAsConstructor(const QString &constructorName, const QJSValue &arg)
108108
{
109109
QJSValueList args = { arg };
110110
return callAsConstructor(constructorName, args);
111111
}
112112

113113

114-
TJSInstance TJSContext::callAsConstructor(const QString &constructorName, const QJSValueList &args)
114+
TJSInstance TJSModule::callAsConstructor(const QString &constructorName, const QJSValueList &args)
115115
{
116116
QMutexLocker locker(&mutex);
117117

@@ -126,14 +126,14 @@ TJSInstance TJSContext::callAsConstructor(const QString &constructorName, const
126126
}
127127

128128

129-
QJSValue TJSContext::import(const QString &moduleName)
129+
QJSValue TJSModule::import(const QString &moduleName)
130130
{
131131
TJSLoader loader(moduleName);
132132
return loader.importTo(this, false);
133133
}
134134

135135

136-
QJSValue TJSContext::import(const QString &defaultMember, const QString &moduleName)
136+
QJSValue TJSModule::import(const QString &defaultMember, const QString &moduleName)
137137
{
138138
TJSLoader loader(defaultMember, moduleName);
139139
return loader.importTo(this, false);

src/tjsmodule.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef TJSCONTEXT_H
2-
#define TJSCONTEXT_H
1+
#ifndef TJSMODULE_H
2+
#define TJSMODULE_H
33

44
#include <QString>
55
#include <QObject>
@@ -14,11 +14,11 @@ class QJSEngine;
1414
class TJSInstance;
1515

1616

17-
class T_CORE_EXPORT TJSContext : public QObject
17+
class T_CORE_EXPORT TJSModule : public QObject
1818
{
1919
public:
20-
TJSContext(QObject *parent = nullptr);
21-
virtual ~TJSContext();
20+
TJSModule(QObject *parent = nullptr);
21+
virtual ~TJSModule();
2222

2323
QJSValue evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
2424
QJSValue call(const QString &func, const QJSValue &arg);
@@ -38,10 +38,10 @@ class T_CORE_EXPORT TJSContext : public QObject
3838
QString moduleFilePath;
3939
QMutex mutex;
4040

41-
Q_DISABLE_COPY(TJSContext);
41+
Q_DISABLE_COPY(TJSModule);
4242

4343
friend class TJSLoader;
4444
friend class TReactComponent;
4545
};
4646

47-
#endif // TJSCONTEXT_H
47+
#endif // TJSMODULE_H

src/treactcomponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <QDir>
1212
#include <QTextStream>
1313
#include <TWebApplication>
14-
#include <TJSContext>
14+
#include <TJSModule>
1515
#include <TJSLoader>
1616
#include <TReactComponent>
1717
#include "tsystemglobal.h"

0 commit comments

Comments
 (0)