diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-15 14:20:46 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-15 14:20:46 (GMT) |
commit | 4791f674234dea4aefd294f0bc246c9b23587fb8 (patch) | |
tree | 216fbf481ecc154494c2ba568fdb5f2e31a8131d /src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore | |
parent | 05401f856e6b9a5b469525df4d3eb12cc1f1dd1c (diff) | |
download | uscxml-4791f674234dea4aefd294f0bc246c9b23587fb8.zip uscxml-4791f674234dea4aefd294f0bc246c9b23587fb8.tar.gz uscxml-4791f674234dea4aefd294f0bc246c9b23587fb8.tar.bz2 |
Started JavaScriptCore datamodel
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp | 89 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h | 71 |
2 files changed, 160 insertions, 0 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp new file mode 100644 index 0000000..7c8ef08 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -0,0 +1,89 @@ +#include "uscxml/Common.h" +#include "JSCDataModel.h" +#include "uscxml/Message.h" +#include <glog/logging.h> + +#ifdef BUILD_AS_PLUGINS +#include <Pluma/Connector.hpp> +#endif + +namespace uscxml { + +#ifdef BUILD_AS_PLUGINS +PLUMA_CONNECTOR +bool connect(pluma::Host& host) { + host.add( new JSCDataModelProvider() ); + return true; +} +#endif + +JSCDataModel::JSCDataModel() { +} + +boost::shared_ptr<DataModelImpl> JSCDataModel::create(Interpreter* interpreter) { + boost::shared_ptr<JSCDataModel> dm = boost::shared_ptr<JSCDataModel>(new JSCDataModel()); + dm->_interpreter = interpreter; + + dm->setName(interpreter->getName()); + dm->setSessionId(interpreter->getSessionId()); + dm->eval("_ioprocessors = {};"); + + return dm; +} + +void JSCDataModel::registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor) { + assign("_ioprocessors['" + name + "']", ioprocessor.getDataModelVariables()); +} + +void JSCDataModel::setSessionId(const std::string& sessionId) { + _sessionId = sessionId; +} + +void JSCDataModel::setName(const std::string& name) { + _name = name; +} + +JSCDataModel::~JSCDataModel() { +} + +void JSCDataModel::pushContext() { +} + +void JSCDataModel::popContext() { +} + +void JSCDataModel::initialize() { +} + +void JSCDataModel::setEvent(const Event& event) { +} + +Data JSCDataModel::getStringAsData(const std::string& content) { +} + +Data JSCDataModel::getValueAsData(const JSC::Handle<JSC::Value>& value) { +} + +bool JSCDataModel::validate(const std::string& location, const std::string& schema) { + return true; +} + +uint32_t JSCDataModel::getLength(const std::string& expr) { +} + +void JSCDataModel::eval(const std::string& expr) { +} + +bool JSCDataModel::evalAsBool(const std::string& expr) { +} + +std::string JSCDataModel::evalAsString(const std::string& expr) { +} + +void JSCDataModel::assign(const std::string& location, const Data& data) { +} + +void JSCDataModel::assign(const std::string& location, const std::string& expr) { +} + +}
\ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h new file mode 100644 index 0000000..68aca1f --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h @@ -0,0 +1,71 @@ +#ifndef JSCDATAMODEL_H_KN8TWG0V +#define JSCDATAMODEL_H_KN8TWG0V + +#include "uscxml/Interpreter.h" +#include <list> +#include <JavaScriptCore/JavaScriptCore.h> + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +namespace uscxml { +class Event; +class Data; +} + +namespace uscxml { + +class JSCDataModel : public DataModelImpl { +public: + JSCDataModel(); + virtual ~JSCDataModel(); + virtual boost::shared_ptr<DataModelImpl> create(Interpreter* interpreter); + + virtual std::set<std::string> getNames() { + std::set<std::string> names; + names.insert("ecmascript"); + return names; + } + + virtual void initialize(); + virtual void setSessionId(const std::string& sessionId); + virtual void setName(const std::string& name); + virtual void setEvent(const Event& event); + + virtual void registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor); + + virtual bool validate(const std::string& location, const std::string& schema); + + virtual uint32_t getLength(const std::string& expr); + virtual void pushContext(); + virtual void popContext(); + + virtual void eval(const std::string& expr); + virtual void assign(const std::string& location, const std::string& expr); + virtual void assign(const std::string& location, const Data& data); + + virtual Data getStringAsData(const std::string& content); + virtual Data getValueAsData(const JSC::Handle<JSC::Value>& value); + + virtual std::string evalAsString(const std::string& expr); + virtual bool evalAsBool(const std::string& expr); + + +protected: + Interpreter* _interpreter; + + std::string _sessionId; + std::string _name; + + Event _event; + +}; + +#ifdef BUILD_AS_PLUGINS +PLUMA_INHERIT_PROVIDER(JSCDataModel, DataModel); +#endif + +} + +#endif /* end of include guard: JSCDATAMODEL_H_KN8TWG0V */ |