diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-01 19:18:36 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-01 19:18:36 (GMT) |
commit | fd0778237785840ec754f98e847a524590cbf61c (patch) | |
tree | ebf4609be11843f9657810515d47faa3873c2db8 /src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp | |
parent | 99d2c52f1068b2dd4bd16b8c1c8231beeb94a649 (diff) | |
download | uscxml-fd0778237785840ec754f98e847a524590cbf61c.zip uscxml-fd0778237785840ec754f98e847a524590cbf61c.tar.gz uscxml-fd0778237785840ec754f98e847a524590cbf61c.tar.bz2 |
More work on TypedArrays
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp index d9ab828..7cd90f9 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp @@ -5,63 +5,80 @@ namespace DOM { v8::Persistent<v8::FunctionTemplate> V8Storage::Tmpl; - v8::Handle<v8::Value> V8Storage::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { v8::Local<v8::Object> self = info.Holder(); struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0)); return v8::Integer::New(privData->nativeObj->getLength()); } + v8::Handle<v8::Value> V8Storage::keyCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in key"); v8::Local<v8::Object> self = args.Holder(); struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0)); - unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + if (false) { + } else if (args.Length() == 1 && + args[0]->IsUint32()) { + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); - std::string retVal = privData->nativeObj->key(localIndex); + std::string retVal = privData->nativeObj->key(localIndex); - return v8::String::New(retVal.c_str()); + return v8::String::New(retVal.c_str()); + } + throw V8Exception("Parameter mismatch while calling key"); + return v8::Undefined(); } v8::Handle<v8::Value> V8Storage::getItemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getItem"); v8::Local<v8::Object> self = args.Holder(); struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localKey(args[0]); + if (false) { + } else if (args.Length() == 1 && + args[0]->IsString()) { + v8::String::AsciiValue localKey(args[0]); - std::string retVal = privData->nativeObj->getItem(*localKey); + std::string retVal = privData->nativeObj->getItem(*localKey); - return v8::String::New(retVal.c_str()); + return v8::String::New(retVal.c_str()); + } + throw V8Exception("Parameter mismatch while calling getItem"); + return v8::Undefined(); } v8::Handle<v8::Value> V8Storage::setItemCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in setItem"); v8::Local<v8::Object> self = args.Holder(); struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localKey(args[0]); - v8::String::AsciiValue localValue(args[1]); - - privData->nativeObj->setItem(*localKey, *localValue); - + if (false) { + } else if (args.Length() == 2 && + args[0]->IsString() && + args[1]->IsString()) { + v8::String::AsciiValue localKey(args[0]); + v8::String::AsciiValue localValue(args[1]); + + privData->nativeObj->setItem(*localKey, *localValue); + + return v8::Undefined(); + } + throw V8Exception("Parameter mismatch while calling setItem"); return v8::Undefined(); } v8::Handle<v8::Value> V8Storage::removeItemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in removeItem"); v8::Local<v8::Object> self = args.Holder(); struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localKey(args[0]); + if (false) { + } else if (args.Length() == 1 && + args[0]->IsString()) { + v8::String::AsciiValue localKey(args[0]); - privData->nativeObj->removeItem(*localKey); + privData->nativeObj->removeItem(*localKey); + return v8::Undefined(); + } + throw V8Exception("Parameter mismatch while calling removeItem"); return v8::Undefined(); } @@ -69,12 +86,16 @@ v8::Handle<v8::Value> V8Storage::clearCallback(const v8::Arguments& args) { v8::Local<v8::Object> self = args.Holder(); struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0)); + if (false) { + } else if (args.Length() == 0) { - privData->nativeObj->clear(); + privData->nativeObj->clear(); + return v8::Undefined(); + } + throw V8Exception("Parameter mismatch while calling clear"); return v8::Undefined(); } - bool V8Storage::hasInstance(v8::Handle<v8::Value> value) { return getTmpl()->HasInstance(value); } |