summaryrefslogtreecommitdiffstats
path: root/tests/while-old.test
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-24 06:00:34 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-24 06:00:34 (GMT)
commitc6060d6e629b818850b39214f796339032378217 (patch)
treea0bb4d328d7747827e58cf06ee93807e3d75365e /tests/while-old.test
parentb3d458c88e93d44e5a0ea594e7da1ed66fd816a4 (diff)
downloadtcl-c6060d6e629b818850b39214f796339032378217.zip
tcl-c6060d6e629b818850b39214f796339032378217.tar.gz
tcl-c6060d6e629b818850b39214f796339032378217.tar.bz2
some wrong versions
Diffstat (limited to 'tests/while-old.test')
0 files changed, 0 insertions, 0 deletions
class='ctx'> }
-
+
EXIT_INTERPRETER:
monIter = _monitors.begin();
while(monIter != _monitors.end()) {
@@ -359,7 +354,7 @@ EXIT_INTERPRETER:
sendIter++;
}
}
-
+
monIter = _monitors.begin();
while(monIter != _monitors.end()) {
try {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index affd641..c24e3ec 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -57,9 +57,19 @@ boost::shared_ptr<DataModelImpl> V8DataModel::create(Interpreter* interpreter) {
docObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData));
context->Global()->Set(v8::String::New("document"), docObj);
- context->Global()->Set(v8::String::New("_sessionid"), v8::String::New(interpreter->getSessionId().c_str()), v8::ReadOnly);
- context->Global()->Set(v8::String::New("_name"), v8::String::New(interpreter->getName().c_str()), v8::ReadOnly);
- context->Global()->Set(v8::String::New("_ioprocessors"), v8::Object::New(), v8::ReadOnly);
+
+ context->Global()->SetAccessor(v8::String::New("_sessionid"),
+ V8DataModel::getAttribute,
+ V8DataModel::setWithException,
+ v8::String::New(interpreter->getSessionId().c_str()));
+ context->Global()->SetAccessor(v8::String::New("_name"),
+ V8DataModel::getAttribute,
+ V8DataModel::setWithException,
+ v8::String::New(interpreter->getName().c_str()));
+ context->Global()->SetAccessor(v8::String::New("_ioprocessors"),
+ V8DataModel::getIOProcessors,
+ V8DataModel::setWithException,
+ v8::External::New(reinterpret_cast<void*>(dm.get())));
dm->_contexts.push_back(context);
@@ -70,13 +80,31 @@ boost::shared_ptr<DataModelImpl> V8DataModel::create(Interpreter* interpreter) {
return dm;
}
-void V8DataModel::registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor) {
- v8::Locker locker;
- v8::HandleScope handleScope;
- v8::Context::Scope contextScope(_contexts.front());
- v8::Handle<v8::Object> global = _contexts.front()->Global();
- v8::Handle<v8::Object> ioProcessors = global->Get(v8::String::New("_ioprocessors"))->ToObject();
- ioProcessors->Set(v8::String::New(name.c_str()),getDataAsValue(ioprocessor.getDataModelVariables()));
+v8::Handle<v8::Value> V8DataModel::getAttribute(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
+ return info.Data();
+}
+
+void V8DataModel::setWithException(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
+ v8::String::AsciiValue data(property);
+ std::string msg = "Cannot set " + std::string(*data);
+ v8::ThrowException(v8::Exception::ReferenceError(v8::String::New(msg.c_str())));
+}
+
+v8::Handle<v8::Value> V8DataModel::getIOProcessors(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
+ V8DataModel* dataModel = Arabica::DOM::V8DOM::toClassPtr<V8DataModel>(info.Data());
+
+ if (dataModel->_ioProcessors.IsEmpty()) {
+ dataModel->_ioProcessors = v8::Persistent<v8::Object>::New(v8::Object::New());
+ //v8::Handle<v8::Object> ioProcessorObj = v8::Object::New();
+ std::map<std::string, IOProcessor> ioProcessors = dataModel->_interpreter->getIOProcessors();
+ std::map<std::string, IOProcessor>::const_iterator ioProcIter = ioProcessors.begin();
+ while(ioProcIter != ioProcessors.end()) {
+ dataModel->_ioProcessors->Set(v8::String::New(ioProcIter->first.c_str()),
+ dataModel->getDataAsValue(ioProcIter->second.getDataModelVariables()));
+ ioProcIter++;
+ }
+ }
+ return dataModel->_ioProcessors;
}
V8DataModel::~V8DataModel() {
@@ -281,10 +309,10 @@ void V8DataModel::eval(const std::string& expr) {
bool V8DataModel::isDeclared(const std::string& expr) {
/**
- * Undeclared variables can be checked by trying to access them and catching
+ * Undeclared variables can be checked by trying to access them and catching
* a reference error.
*/
-
+
v8::Locker locker;
v8::HandleScope handleScope;
v8::Context::Scope contextScope(_contexts.back());
@@ -292,14 +320,14 @@ bool V8DataModel::isDeclared(const std::string& expr) {
v8::TryCatch tryCatch;
v8::Handle<v8::String> source = v8::String::New(expr.c_str());
v8::Handle<v8::Script> script = v8::Script::Compile(source);
-
+
v8::Handle<v8::Value> result;
if (!script.IsEmpty())
result = script->Run();
-
+
if (result.IsEmpty())
return false;
-
+
return true;
}
@@ -374,6 +402,7 @@ void V8DataModel::throwExceptionEvent(const v8::TryCatch& tryCatch) {
assert(tryCatch.HasCaught());
Event exceptionEvent;
exceptionEvent.name = "error.execution";
+ exceptionEvent.type = Event::PLATFORM;
std::string exceptionString(*v8::String::AsciiValue(tryCatch.Exception()));
exceptionEvent.data.compound["exception"] = Data(exceptionString, Data::VERBATIM);;
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
index 441297d..6348cbc 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
@@ -33,10 +33,8 @@ public:
virtual void initialize();
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();
@@ -48,7 +46,7 @@ public:
virtual Data getStringAsData(const std::string& content);
virtual Data getValueAsData(const v8::Handle<v8::Value>& value);
virtual bool isDeclared(const std::string& expr);
-
+
virtual std::string evalAsString(const std::string& expr);
virtual bool evalAsBool(const std::string& expr);
virtual double evalAsNumber(const std::string& expr);
@@ -61,8 +59,13 @@ protected:
Arabica::DOM::V8DOM* _dom;
+ v8::Persistent<v8::Object> _ioProcessors;
+ static v8::Handle<v8::Value> getIOProcessors(v8::Local<v8::String> property, const v8::AccessorInfo& info);
+ static v8::Handle<v8::Value> getAttribute(v8::Local<v8::String> property, const v8::AccessorInfo& info);
+ static void setWithException(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
+
v8::Handle<v8::Value> evalAsValue(const std::string& expr);
- virtual v8::Handle<v8::Value> getDataAsValue(const Data& data);
+ v8::Handle<v8::Value> getDataAsValue(const Data& data);
void throwExceptionEvent(const v8::TryCatch& tryCatch);
};
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp.old
deleted file mode 100644
index 31372ed..0000000
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp.old
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "V8Document.h"
-#include "V8Element.h"
-#include "V8XPathResult.h"
-
-namespace uscxml {
-
-using namespace Arabica::DOM;
-using namespace Arabica::XPath;
-
-v8::Persistent<v8::FunctionTemplate> V8Document::Tmpl;
-
-v8::Handle<v8::Value> V8Document::createElementCallback(const v8::Arguments& args) {
- ASSERT_ARGS1(args, IsString);
- v8::String::AsciiValue tagName(args[0]);
-
- v8::Local<v8::Object> self = args.Holder();
- Document<std::string>* doc = V8DOM::toClassPtr<Document<std::string> >(self->GetInternalField(0));
- V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom;
-
- Element<std::string>* element = new Element<std::string>(doc->createElement(*tagName));
-
- v8::Handle<v8::Function> elemCtor = V8Element::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> elemObj = v8::Persistent<v8::Object>::New(elemCtor->NewInstance());
-
- elemObj->SetInternalField(0, V8DOM::toExternal(element));
- elemObj->SetInternalField(1, self->GetInternalField(1));
-
- elemObj.MakeWeak(0, V8Element::jsDestructor);
- return elemObj;
-}
-
-v8::Handle<v8::Value> V8Document::evaluateCallback(const v8::Arguments& args) {
- ASSERT_ARGS1(args, IsString);
- v8::String::AsciiValue xpathExpr(args[0]);
-
- v8::Local<v8::Object> self = args.Holder();
- Document<std::string>* doc = V8DOM::toClassPtr<Document<std::string> >(self->GetInternalField(0));
- V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom;
-
- Node<std::string>* context;
- if (args.Length() > 1) {
- context = V8DOM::toClassPtr<Node<std::string> >(args[1]->ToObject()->GetInternalField(0));
- } else {
- context = doc;
- }
-
- XPathValue<std::string>* xpathValue = new XPathValue<std::string>(dom->xpath->evaluate(*xpathExpr, *context));
-
- v8::Handle<v8::Function> xpathResultCtor = V8XPathResult::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> xpathResultObj = v8::Persistent<v8::Object>::New(xpathResultCtor->NewInstance());
-
- xpathResultObj->SetInternalField(0, V8DOM::toExternal(xpathValue));
- xpathResultObj->SetInternalField(1, self->GetInternalField(1));
-
- xpathResultObj.MakeWeak(0, V8XPathResult::jsDestructor);
- return xpathResultObj;
-}
-
-} \ No newline at end of file
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp.old
deleted file mode 100644
index 14b2eae..0000000
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp.old
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "V8Element.h"
-#include <DOM/Element.hpp>
-
-namespace uscxml {
-
-using namespace Arabica::DOM;
-
-v8::Persistent<v8::FunctionTemplate> V8Element::Tmpl;
-
-v8::Handle<v8::Value> V8Element::setAttributeCallback(const v8::Arguments& args) {
- ASSERT_ARGS2(args, IsString, IsString);
- v8::String::AsciiValue key(args[0]);
- v8::String::AsciiValue value(args[1]);
-
- v8::Local<v8::Object> self = args.Holder();
- Element<std::string>* elem = V8DOM::toClassPtr<Element<std::string> >(self->GetInternalField(0));
- V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom;
-
- elem->setAttribute(*key, *value);
-
- return v8::Undefined();
-}
-
-} \ No newline at end of file
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h.old
deleted file mode 100644