diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/v8/dom')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp | 30 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h | 6 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp index 8eccc66..1328b19 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp @@ -76,6 +76,36 @@ void V8ArrayBuffer::mimeTypeAttrSetter(v8::Local<v8::String> property, v8::Local privData->nativeObj->setMimeType(*localMimeType); } +v8::Handle<v8::Value> V8ArrayBuffer::md5Callback(const v8::Arguments& args) { + + v8::Local<v8::Object> self = args.Holder(); + struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0)); + if (false) { + } else if (args.Length() == 0) { + + std::string retVal = privData->nativeObj->md5(); + + return v8::String::New(retVal.c_str()); + } + throw V8Exception("Parameter mismatch while calling md5"); + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8ArrayBuffer::base64Callback(const v8::Arguments& args) { + + v8::Local<v8::Object> self = args.Holder(); + struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0)); + if (false) { + } else if (args.Length() == 0) { + + std::string retVal = privData->nativeObj->base64(); + + return v8::String::New(retVal.c_str()); + } + throw V8Exception("Parameter mismatch while calling base64"); + return v8::Undefined(); +} + v8::Handle<v8::Value> V8ArrayBuffer::sliceCallback(const v8::Arguments& args) { v8::Local<v8::Object> self = args.Holder(); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h index 5745095..14b92b0 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h @@ -41,6 +41,8 @@ public: V8_DESTRUCTOR(V8ArrayBufferPrivate); static bool hasInstance(v8::Handle<v8::Value>); + static v8::Handle<v8::Value> md5Callback(const v8::Arguments&); + static v8::Handle<v8::Value> base64Callback(const v8::Arguments&); static v8::Handle<v8::Value> sliceCallback(const v8::Arguments&); static v8::Handle<v8::Value> isViewCallback(const v8::Arguments&); @@ -76,6 +78,10 @@ public: instance->SetAccessor(v8::String::NewSymbol("mimeType"), V8ArrayBuffer::mimeTypeAttrGetter, V8ArrayBuffer::mimeTypeAttrSetter, v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + prototype->Set(v8::String::NewSymbol("md5"), + v8::FunctionTemplate::New(V8ArrayBuffer::md5Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("base64"), + v8::FunctionTemplate::New(V8ArrayBuffer::base64Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); prototype->Set(v8::String::NewSymbol("slice"), v8::FunctionTemplate::New(V8ArrayBuffer::sliceCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); prototype->Set(v8::String::NewSymbol("isView"), |