fix header circular deps
This commit is contained in:
parent
21b3353e18
commit
3b72ab56aa
@ -1,5 +1,6 @@
|
||||
#include "context.h"
|
||||
#include "native_driver.h"
|
||||
#include "context_manager.h"
|
||||
|
||||
Context::Context(QString contextId, QString source, QString extra)
|
||||
{
|
||||
@ -8,6 +9,13 @@ Context::Context(QString contextId, QString source, QString extra)
|
||||
this->extra = extra;
|
||||
}
|
||||
|
||||
Context* Context::create(QString script, QString source, QString extra)
|
||||
{
|
||||
Context *context = ContextManager::getInstance()->createContext(script, source, extra);
|
||||
context->script = script;
|
||||
return context;
|
||||
}
|
||||
|
||||
InterfaceDriver* Context::getDriver()
|
||||
{
|
||||
if (driver == NULL)
|
||||
|
@ -17,10 +17,7 @@ private:
|
||||
public:
|
||||
Context(QString contextId, QString source, QString extra);
|
||||
|
||||
static Context* create(QString script, QString source, QString extra)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
static Context* create(QString script, QString source, QString extra);
|
||||
|
||||
InterfaceDriver* getDriver();
|
||||
};
|
||||
|
10
doric-Qt/doric/context_manager.cpp
Normal file
10
doric-Qt/doric/context_manager.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "context_manager.h"
|
||||
|
||||
Context *ContextManager::createContext(QString script, QString source, QString extra)
|
||||
{
|
||||
int contextId = counter->fetchAndAddOrdered(1);
|
||||
Context *context = new Context(QString::number(contextId), source, extra);
|
||||
contextMap->insert(QString::number(contextId), context);
|
||||
context->getDriver()->createContext(QString::number(contextId), script, source);
|
||||
return context;
|
||||
}
|
@ -29,13 +29,7 @@ public:
|
||||
return &instance;
|
||||
}
|
||||
|
||||
Context *createContext(QString script, QString source, QString extra) {
|
||||
int contextId = counter->fetchAndAddOrdered(1);
|
||||
Context *context = new Context(QString::number(contextId), source, extra);
|
||||
contextMap->insert(QString::number(contextId), context);
|
||||
context->getDriver()->createContext(QString::number(contextId), script, source);
|
||||
return context;
|
||||
}
|
||||
Context *createContext(QString script, QString source, QString extra);
|
||||
};
|
||||
|
||||
#endif // CONTEXTMANAGER_H
|
||||
|
@ -17,6 +17,7 @@ SOURCES += \
|
||||
async/async_result.cpp \
|
||||
async/settable_future.cpp \
|
||||
context.cpp \
|
||||
context_manager.cpp \
|
||||
engine/bridge_extension.cpp \
|
||||
engine/js_engine.cpp \
|
||||
engine/native_empty.cpp \
|
||||
|
@ -1,11 +1,5 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QDebug>
|
||||
|
||||
#include "engine/js_engine.h"
|
||||
#include "async/async_result.h"
|
||||
#include "context_manager.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -22,10 +16,5 @@ int main(int argc, char *argv[])
|
||||
}, Qt::QueuedConnection);
|
||||
engine.load(url);
|
||||
|
||||
JSEngine jsEngine;
|
||||
|
||||
QString script = Utils::readAssetFile("doric", "Snake.js");
|
||||
ContextManager::getInstance()->createContext(script, "", "");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
Reference in New Issue
Block a user