Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: src/api.cc

Issue 1073953004: Expose Object::DefineOwnProperty on the API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | src/v8natives.js » ('j') | src/v8natives.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 3424 matching lines...) Expand 10 before | Expand all | Expand 10 after
3435 } 3435 }
3436 3436
3437 3437
3438 bool v8::Object::ForceSet(v8::Handle<Value> key, v8::Handle<Value> value, 3438 bool v8::Object::ForceSet(v8::Handle<Value> key, v8::Handle<Value> value,
3439 v8::PropertyAttribute attribs) { 3439 v8::PropertyAttribute attribs) {
3440 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 3440 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
3441 return ForceSet(context, key, value, attribs).FromMaybe(false); 3441 return ForceSet(context, key, value, attribs).FromMaybe(false);
3442 } 3442 }
3443 3443
3444 3444
3445 MaybeLocal<Value> v8::Object::DefineObjectProperty(
3446 Local<Context> context, Local<Value> key, Local<Value> value,
3447 PropertyAttribute attribute) {
3448 PREPARE_FOR_EXECUTION(context, "v8::Object::DefineObjectProperty()", Value);
3449 auto obj = Utils::OpenHandle(this);
dcarney 2015/04/15 08:31:17 most of these got renamed to 'self'
jochen (gone - plz use gerrit) 2015/04/15 08:35:18 done
3450 auto key_name = Utils::OpenHandle(*key);
3451 auto i_value = Utils::OpenHandle(*value);
3452 i::Handle<i::Object> configurable =
3453 handle(attribute & DontDelete ? isolate->heap()->false_value()
3454 : isolate->heap()->true_value(),
3455 isolate);
3456 auto enumerable = handle(attribute & DontEnum ? isolate->heap()->false_value()
3457 : isolate->heap()->true_value(),
3458 isolate);
3459 auto writable = handle(attribute & ReadOnly ? isolate->heap()->false_value()
3460 : isolate->heap()->true_value(),
3461 isolate);
3462 i::Handle<i::Object> args[] = {obj, key_name, i_value,
3463 configurable, enumerable, writable};
3464 i::Handle<i::Object> result;
3465 has_pending_exception =
3466 !CallV8HeapFunction(isolate, "DefineObjectPropertyFromAPI",
3467 isolate->factory()->undefined_value(),
3468 arraysize(args), args).ToHandle(&result);
3469 RETURN_ON_FAILED_EXECUTION(Value);
3470 RETURN_ESCAPED(Utils::ToLocal(result));
3471 }
3472
3473
3445 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { 3474 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) {
3446 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), 3475 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)),
3447 value, DontEnum); 3476 value, DontEnum);
3448 } 3477 }
3449 3478
3450 3479
3451 namespace { 3480 namespace {
3452 3481
3453 i::MaybeHandle<i::Object> DeleteObjectProperty( 3482 i::MaybeHandle<i::Object> DeleteObjectProperty(
3454 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, 3483 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver,
(...skipping 4654 matching lines...) Expand 10 before | Expand all | Expand 10 after
8109 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8138 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8110 Address callback_address = 8139 Address callback_address =
8111 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8140 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8112 VMState<EXTERNAL> state(isolate); 8141 VMState<EXTERNAL> state(isolate);
8113 ExternalCallbackScope call_scope(isolate, callback_address); 8142 ExternalCallbackScope call_scope(isolate, callback_address);
8114 callback(info); 8143 callback(info);
8115 } 8144 }
8116 8145
8117 8146
8118 } } // namespace v8::internal 8147 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/v8natives.js » ('j') | src/v8natives.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698