Reviewers: Mads Ager, Description: A helper function to speed up creation of V8 wrappers for DOM Nodes.
Please review this at http://codereview.chromium.org/141044 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M include/v8.h M src/api.cc Index: include/v8.h =================================================================== --- include/v8.h (revision 2242) +++ include/v8.h (working copy) @@ -1176,6 +1176,8 @@ public: uint32_t Length() const; + bool CloneElementAt(uint32_t index, Handle<Object>* result); + static Local<Array> New(int length = 0); static Array* Cast(Value* obj); private: Index: src/api.cc =================================================================== --- src/api.cc (revision 2242) +++ src/api.cc (working copy) @@ -3012,6 +3012,26 @@ } +bool Array::CloneElementAt(uint32_t index, Handle<Object>* result) { + ON_BAILOUT("v8::Array::CloneElementAt()", return false); + i::Handle<i::JSObject> self = Utils::OpenHandle(this); + if (!self->HasFastElements()) { + return false; + } + i::FixedArray* elms = self->elements(); + i::Object* paragon = elms->get(index); + if (!paragon->IsJSObject()) { + return false; + } + i::Object* cloned = i::Heap::CopyJSObject(i::JSObject::cast(paragon)); + if (cloned->IsFailure()) { + return false; + } + *result = Utils::ToLocal(i::Handle<i::JSObject>(i::JSObject::cast(cloned))); + return true; +} + + Local<String> v8::String::NewSymbol(const char* data, int length) { EnsureInitialized("v8::String::NewSymbol()"); LOG_API("String::NewSymbol(char)"); --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
