Commit 04029518 authored by antonm@chromium.org's avatar antonm@chromium.org

A helper function to speed up creation of V8 wrappers for DOM Nodes.

Review URL: http://codereview.chromium.org/141044

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2260 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 54e4562e
......@@ -1176,6 +1176,12 @@ class V8EXPORT Array : public Object {
public:
uint32_t Length() const;
/**
* Clones an element at index |index|. Returns an empty
* handle if cloning fails (for any reason).
*/
Local<Object> CloneElementAt(uint32_t index);
static Local<Array> New(int length = 0);
static Array* Cast(Value* obj);
private:
......
......@@ -3012,6 +3012,26 @@ uint32_t v8::Array::Length() const {
}
Local<Object> Array::CloneElementAt(uint32_t index) {
ON_BAILOUT("v8::Array::CloneElementAt()", return Local<Object>());
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
if (!self->HasFastElements()) {
return Local<Object>();
}
i::FixedArray* elms = self->elements();
i::Object* paragon = elms->get(index);
if (!paragon->IsJSObject()) {
return Local<Object>();
}
i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon));
EXCEPTION_PREAMBLE();
i::Handle<i::JSObject> result = i::Copy(paragon_handle);
has_pending_exception = result.is_null();
EXCEPTION_BAILOUT_CHECK(Local<Object>());
return Utils::ToLocal(result);
}
Local<String> v8::String::NewSymbol(const char* data, int length) {
EnsureInitialized("v8::String::NewSymbol()");
LOG_API("String::NewSymbol(char)");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment