add files from main project
This commit is contained in:
19
doric/driver/driver.h
Normal file
19
doric/driver/driver.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef DRIVER_H
|
||||
#define DRIVER_H
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
class Driver {
|
||||
|
||||
public:
|
||||
virtual void createContext(int contextId, QString* script) = 0;
|
||||
virtual void destroyContext(int contextId) = 0;
|
||||
|
||||
virtual ~Driver() = default;
|
||||
};
|
||||
|
||||
#define DriverInterface "pub.doric.DriverInterface"
|
||||
|
||||
Q_DECLARE_INTERFACE(Driver, DriverInterface)
|
||||
|
||||
#endif // DRIVER_H
|
13
doric/driver/native_driver.cpp
Normal file
13
doric/driver/native_driver.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "native_driver.h"
|
||||
|
||||
NativeDriver::~NativeDriver() {
|
||||
qDebug() << "NativeDriver destructor";
|
||||
}
|
||||
|
||||
void NativeDriver::createContext(int contextId, QString *script) {
|
||||
jsEngine->prepareContext(contextId, script);
|
||||
}
|
||||
|
||||
void NativeDriver::destroyContext(int contextId) {
|
||||
jsEngine->destroyContext(contextId);
|
||||
}
|
33
doric/driver/native_driver.h
Normal file
33
doric/driver/native_driver.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef NATIVE_DRIVER_H
|
||||
#define NATIVE_DRIVER_H
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "driver.h"
|
||||
#include "engine/js_engine.h"
|
||||
|
||||
class NativeDriver : public Driver {
|
||||
Q_INTERFACES(Driver)
|
||||
|
||||
private:
|
||||
static NativeDriver *local_instance;
|
||||
NativeDriver() {
|
||||
qDebug() << "NativeDriver constructor";
|
||||
}
|
||||
|
||||
~NativeDriver() override;
|
||||
|
||||
JSEngine *jsEngine = new JSEngine();
|
||||
|
||||
public:
|
||||
static NativeDriver *getInstance() {
|
||||
static NativeDriver locla_s;
|
||||
return &locla_s;
|
||||
}
|
||||
|
||||
void createContext(int contextId, QString *script) override;
|
||||
|
||||
void destroyContext(int contextId) override;
|
||||
};
|
||||
|
||||
#endif // NATIVE_DRIVER_H
|
Reference in New Issue
Block a user