diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel')
4 files changed, 22 insertions, 11 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index e653607..fff3f9b 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -143,11 +143,13 @@ void V8DataModel::setEvent(const Event& event) { privData->dom = _dom; eventObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData)); eventObj.MakeWeak(0, Arabica::DOM::V8SCXMLEvent::jsDestructor); + if (event.dom) { eventObj->Set(v8::String::New("data"), getDocumentAsValue(event.dom)); } else if (event.content.length() > 0) { // _event.data is a string eventObj->Set(v8::String::New("data"), v8::String::New(event.content.c_str())); +// eventObj->Set(v8::String::New("data"), v8::Undefined()); } else { // _event.data is KVP Event eventCopy(event); @@ -168,10 +170,11 @@ void V8DataModel::setEvent(const Event& event) { if (eventCopy.data.compound.size() > 0) { eventObj->Set(v8::String::New("data"), getDataAsValue(eventCopy.data)); // set data part of _event } else { - // test 343 + // test 343 / test 488 eventObj->Set(v8::String::New("data"), v8::Undefined()); // set data part of _event } } + // we cannot make _event v8::ReadOnly as it will ignore subsequent setEvents global->Set(v8::String::New("_event"), eventObj); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp index fec2a94..86fcfef 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp @@ -18,6 +18,8 @@ v8::Handle<v8::Value> V8SCXMLEvent::originAttrGetter(v8::Local<v8::String> prope v8::Local<v8::Object> self = info.Holder(); struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + if (privData->nativeObj->origin.length() == 0) + return v8::Undefined(); return v8::String::New(privData->nativeObj->origin.c_str()); } @@ -25,6 +27,8 @@ v8::Handle<v8::Value> V8SCXMLEvent::origintypeAttrGetter(v8::Local<v8::String> p v8::Local<v8::Object> self = info.Holder(); struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + if (privData->nativeObj->origintype.length() == 0) + return v8::Undefined(); return v8::String::New(privData->nativeObj->origintype.c_str()); } @@ -48,17 +52,12 @@ v8::Handle<v8::Value> V8SCXMLEvent::domAttrGetter(v8::Local<v8::String> property } -v8::Handle<v8::Value> V8SCXMLEvent::sendidAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); - - return v8::String::New(privData->nativeObj->sendid.c_str()); -} - v8::Handle<v8::Value> V8SCXMLEvent::invokeidAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { v8::Local<v8::Object> self = info.Holder(); struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + if (privData->nativeObj->invokeid.length() == 0) + return v8::Undefined(); return v8::String::New(privData->nativeObj->invokeid.c_str()); } bool V8SCXMLEvent::hasInstance(v8::Handle<v8::Value> value) { diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h index f17856a..e7dbacc 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h @@ -46,7 +46,7 @@ public: static v8::Handle<v8::Value> originAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); static v8::Handle<v8::Value> origintypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); static v8::Handle<v8::Value> domAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> sendidAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> sendidCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); static v8::Handle<v8::Value> invokeidAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); static v8::Persistent<v8::FunctionTemplate> Tmpl; @@ -72,7 +72,7 @@ public: v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); instance->SetAccessor(v8::String::NewSymbol("dom"), V8SCXMLEvent::domAttrGetter, 0, v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("sendid"), V8SCXMLEvent::sendidAttrGetter, 0, + instance->SetAccessor(v8::String::NewSymbol("sendid"), V8SCXMLEvent::sendidCustomAttrGetter, 0, v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); instance->SetAccessor(v8::String::NewSymbol("invokeid"), V8SCXMLEvent::invokeidAttrGetter, 0, v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEventCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEventCustom.cpp index 05644b0..4eecb94 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEventCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEventCustom.cpp @@ -5,7 +5,7 @@ namespace DOM { v8::Handle<v8::Value> V8SCXMLEvent::typeCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { v8::Local<v8::Object> self = info.Holder(); - V8SCXMLEvent::V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEvent::V8SCXMLEventPrivate >(self->GetInternalField(0)); + V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); switch (privData->nativeObj->type) { case uscxml::Event::INTERNAL: @@ -23,5 +23,14 @@ v8::Handle<v8::Value> V8SCXMLEvent::typeCustomAttrGetter(v8::Local<v8::String> p return v8::String::New("unknown"); } +v8::Handle<v8::Value> V8SCXMLEvent::sendidCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + + if (privData->nativeObj->sendid.length() == 0 || privData->nativeObj->hideSendId) + return v8::Undefined(); + return v8::String::New(privData->nativeObj->sendid.c_str()); +} + } }
\ No newline at end of file |