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

Side by Side Diff: src/api.cc

Issue 12297012: Runtime version of declarative native accessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed nits Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/api.h ('k') | src/factory.h » ('j') | no next file with comments »
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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 return Utils::ToLocal(obj); 1034 return Utils::ToLocal(obj);
1035 } 1035 }
1036 1036
1037 1037
1038 Local<AccessorSignature> AccessorSignature::New( 1038 Local<AccessorSignature> AccessorSignature::New(
1039 Handle<FunctionTemplate> receiver) { 1039 Handle<FunctionTemplate> receiver) {
1040 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); 1040 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver));
1041 } 1041 }
1042 1042
1043 1043
1044 template<typename Operation>
1045 static Local<Operation> NewDescriptor(
1046 Isolate* isolate,
1047 const i::DeclaredAccessorDescriptorData& data,
1048 Data* previous_descriptor
1049 ) {
1050 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
1051 i::Handle<i::DeclaredAccessorDescriptor> previous =
1052 i::Handle<i::DeclaredAccessorDescriptor>();
1053 if (previous_descriptor != NULL) {
1054 previous = Utils::OpenHandle(
1055 static_cast<DeclaredAccessorDescriptor*>(previous_descriptor));
1056 }
1057 i::Handle<i::DeclaredAccessorDescriptor> descriptor =
1058 i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous);
1059 return Local<Operation>(
1060 reinterpret_cast<Operation*>(*Utils::ToLocal(descriptor)));
1061 }
1062
1063
1064 Local<RawOperationDescriptor>
1065 ObjectOperationDescriptor::NewInternalFieldDereference(
1066 Isolate* isolate,
1067 int internal_field) {
1068 i::DeclaredAccessorDescriptorData data;
1069 data.type = i::kDescriptorObjectDereference;
1070 data.object_dereference_descriptor.internal_field = internal_field;
1071 return NewDescriptor<RawOperationDescriptor>(isolate, data, NULL);
1072 }
1073
1074
1075 Local<RawOperationDescriptor> RawOperationDescriptor::NewRawShift(
1076 Isolate* isolate,
1077 int16_t byte_offset) {
1078 i::DeclaredAccessorDescriptorData data;
1079 data.type = i::kDescriptorPointerShift;
1080 data.pointer_shift_descriptor.byte_offset = byte_offset;
1081 return NewDescriptor<RawOperationDescriptor>(isolate, data, this);
1082 }
1083
1084
1085 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewHandleDereference(
1086 Isolate* isolate) {
1087 i::DeclaredAccessorDescriptorData data;
1088 data.type = i::kDescriptorReturnObject;
1089 return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this);
1090 }
1091
1092
1093 Local<RawOperationDescriptor> RawOperationDescriptor::NewRawDereference(
1094 Isolate* isolate) {
1095 i::DeclaredAccessorDescriptorData data;
1096 data.type = i::kDescriptorPointerDereference;
1097 return NewDescriptor<RawOperationDescriptor>(isolate, data, this);
1098 }
1099
1100
1101 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewPointerCompare(
1102 Isolate* isolate,
1103 void* compare_value) {
1104 i::DeclaredAccessorDescriptorData data;
1105 data.type = i::kDescriptorPointerCompare;
1106 data.pointer_compare_descriptor.compare_value = compare_value;
1107 return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this);
1108 }
1109
1110
1111 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewPrimitiveValue(
1112 Isolate* isolate,
1113 DeclaredAccessorDescriptorDataType data_type,
1114 uint8_t bool_offset) {
1115 i::DeclaredAccessorDescriptorData data;
1116 data.type = i::kDescriptorPrimitiveValue;
1117 data.primitive_value_descriptor.data_type = data_type;
1118 data.primitive_value_descriptor.bool_offset = bool_offset;
1119 return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this);
1120 }
1121
1122
1123 template<typename T>
1124 static Local<DeclaredAccessorDescriptor> NewBitmaskCompare(
1125 Isolate* isolate,
1126 T bitmask,
1127 T compare_value,
1128 RawOperationDescriptor* operation) {
1129 i::DeclaredAccessorDescriptorData data;
1130 data.type = i::kDescriptorBitmaskCompare;
1131 data.bitmask_compare_descriptor.bitmask = bitmask;
1132 data.bitmask_compare_descriptor.compare_value = compare_value;
1133 data.bitmask_compare_descriptor.size = sizeof(T);
1134 return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, operation);
1135 }
1136
1137
1138 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewBitmaskCompare8(
1139 Isolate* isolate,
1140 uint8_t bitmask,
1141 uint8_t compare_value) {
1142 return NewBitmaskCompare(isolate, bitmask, compare_value, this);
1143 }
1144
1145
1146 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewBitmaskCompare16(
1147 Isolate* isolate,
1148 uint16_t bitmask,
1149 uint16_t compare_value) {
1150 return NewBitmaskCompare(isolate, bitmask, compare_value, this);
1151 }
1152
1153
1154 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewBitmaskCompare32(
1155 Isolate* isolate,
1156 uint32_t bitmask,
1157 uint32_t compare_value) {
1158 return NewBitmaskCompare(isolate, bitmask, compare_value, this);
1159 }
1160
1161
1044 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { 1162 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) {
1045 Handle<FunctionTemplate> types[1] = { type }; 1163 Handle<FunctionTemplate> types[1] = { type };
1046 return TypeSwitch::New(1, types); 1164 return TypeSwitch::New(1, types);
1047 } 1165 }
1048 1166
1049 1167
1050 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { 1168 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) {
1051 i::Isolate* isolate = i::Isolate::Current(); 1169 i::Isolate* isolate = i::Isolate::Current();
1052 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()"); 1170 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()");
1053 LOG_API(isolate, "TypeSwitch::New"); 1171 LOG_API(isolate, "TypeSwitch::New");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1213 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1096 i::Handle<i::CallHandlerInfo> obj = 1214 i::Handle<i::CallHandlerInfo> obj =
1097 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1215 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1098 SET_FIELD_WRAPPED(obj, set_callback, callback); 1216 SET_FIELD_WRAPPED(obj, set_callback, callback);
1099 if (data.IsEmpty()) data = v8::Undefined(); 1217 if (data.IsEmpty()) data = v8::Undefined();
1100 obj->set_data(*Utils::OpenHandle(*data)); 1218 obj->set_data(*Utils::OpenHandle(*data));
1101 Utils::OpenHandle(this)->set_call_code(*obj); 1219 Utils::OpenHandle(this)->set_call_code(*obj);
1102 } 1220 }
1103 1221
1104 1222
1105 static i::Handle<i::AccessorInfo> MakeAccessorInfo( 1223 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties(
1106 v8::Handle<String> name, 1224 i::Handle<i::AccessorInfo> obj,
1107 AccessorGetter getter, 1225 v8::Handle<String> name,
1108 AccessorSetter setter, 1226 v8::AccessControl settings,
1109 v8::Handle<Value> data, 1227 v8::PropertyAttribute attributes,
1110 v8::AccessControl settings, 1228 v8::Handle<AccessorSignature> signature) {
1111 v8::PropertyAttribute attributes,
1112 v8::Handle<AccessorSignature> signature) {
1113 i::Handle<i::ExecutableAccessorInfo> obj =
1114 FACTORY->NewExecutableAccessorInfo();
1115 SET_FIELD_WRAPPED(obj, set_getter, getter);
1116 SET_FIELD_WRAPPED(obj, set_setter, setter);
1117 if (data.IsEmpty()) data = v8::Undefined();
1118 obj->set_data(*Utils::OpenHandle(*data));
1119 obj->set_name(*Utils::OpenHandle(*name)); 1229 obj->set_name(*Utils::OpenHandle(*name));
1120 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); 1230 if (settings & ALL_CAN_READ) obj->set_all_can_read(true);
1121 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); 1231 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true);
1122 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); 1232 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true);
1123 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); 1233 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes));
1124 if (!signature.IsEmpty()) { 1234 if (!signature.IsEmpty()) {
1125 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); 1235 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature));
1126 } 1236 }
1127 return obj; 1237 return obj;
1128 } 1238 }
1129 1239
1130 1240
1131 void FunctionTemplate::AddInstancePropertyAccessor( 1241 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1132 v8::Handle<String> name, 1242 v8::Handle<String> name,
1133 AccessorGetter getter, 1243 AccessorGetter getter,
1134 AccessorSetter setter, 1244 AccessorSetter setter,
1135 v8::Handle<Value> data, 1245 v8::Handle<Value> data,
1136 v8::AccessControl settings, 1246 v8::AccessControl settings,
1137 v8::PropertyAttribute attributes, 1247 v8::PropertyAttribute attributes,
1138 v8::Handle<AccessorSignature> signature) { 1248 v8::Handle<AccessorSignature> signature) {
1139 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1249 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate();
1140 if (IsDeadCheck(isolate, 1250 i::Handle<i::ExecutableAccessorInfo> obj =
1141 "v8::FunctionTemplate::AddInstancePropertyAccessor()")) { 1251 isolate->factory()->NewExecutableAccessorInfo();
1142 return; 1252 SET_FIELD_WRAPPED(obj, set_getter, getter);
1143 } 1253 SET_FIELD_WRAPPED(obj, set_setter, setter);
1144 ENTER_V8(isolate); 1254 if (data.IsEmpty()) data = v8::Undefined();
1145 i::HandleScope scope(isolate); 1255 obj->set_data(*Utils::OpenHandle(*data));
1146 1256 return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1147 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data,
1148 settings, attributes,
1149 signature);
1150 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors(),
1151 isolate);
1152 if (list->IsUndefined()) {
1153 list = NeanderArray().value();
1154 Utils::OpenHandle(this)->set_property_accessors(*list);
1155 }
1156 NeanderArray array(list);
1157 array.add(obj);
1158 } 1257 }
1159 1258
1160 1259
1260 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1261 v8::Handle<String> name,
1262 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor,
1263 v8::AccessControl settings,
1264 v8::PropertyAttribute attributes,
1265 v8::Handle<AccessorSignature> signature) {
1266 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate();
1267 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>();
1268 i::Handle<i::DeclaredAccessorInfo> obj =
1269 isolate->factory()->NewDeclaredAccessorInfo();
1270 obj->set_descriptor(*Utils::OpenHandle(*descriptor));
1271 return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1272 }
1273
1274
1161 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { 1275 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
1162 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1276 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1163 if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()") 1277 if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()")
1164 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) 1278 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this))
1165 return Local<ObjectTemplate>(); 1279 return Local<ObjectTemplate>();
1166 ENTER_V8(isolate); 1280 ENTER_V8(isolate);
1167 if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) { 1281 if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) {
1168 Local<ObjectTemplate> templ = 1282 Local<ObjectTemplate> templ =
1169 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this)); 1283 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this));
1170 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ)); 1284 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ));
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 static void EnsureConstructor(ObjectTemplate* object_template) { 1442 static void EnsureConstructor(ObjectTemplate* object_template) {
1329 if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) { 1443 if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) {
1330 Local<FunctionTemplate> templ = FunctionTemplate::New(); 1444 Local<FunctionTemplate> templ = FunctionTemplate::New();
1331 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); 1445 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ);
1332 constructor->set_instance_template(*Utils::OpenHandle(object_template)); 1446 constructor->set_instance_template(*Utils::OpenHandle(object_template));
1333 Utils::OpenHandle(object_template)->set_constructor(*constructor); 1447 Utils::OpenHandle(object_template)->set_constructor(*constructor);
1334 } 1448 }
1335 } 1449 }
1336 1450
1337 1451
1452 static inline void AddPropertyToFunctionTemplate(
1453 i::Handle<i::FunctionTemplateInfo> cons,
1454 i::Handle<i::AccessorInfo> obj) {
1455 i::Handle<i::Object> list(cons->property_accessors(), cons->GetIsolate());
1456 if (list->IsUndefined()) {
1457 list = NeanderArray().value();
1458 cons->set_property_accessors(*list);
1459 }
1460 NeanderArray array(list);
1461 array.add(obj);
1462 }
1463
1464
1338 void ObjectTemplate::SetAccessor(v8::Handle<String> name, 1465 void ObjectTemplate::SetAccessor(v8::Handle<String> name,
1339 AccessorGetter getter, 1466 AccessorGetter getter,
1340 AccessorSetter setter, 1467 AccessorSetter setter,
1341 v8::Handle<Value> data, 1468 v8::Handle<Value> data,
1342 AccessControl settings, 1469 AccessControl settings,
1343 PropertyAttribute attribute, 1470 PropertyAttribute attribute,
1344 v8::Handle<AccessorSignature> signature) { 1471 v8::Handle<AccessorSignature> signature) {
1345 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1472 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1346 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return; 1473 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return;
1347 ENTER_V8(isolate); 1474 ENTER_V8(isolate);
1348 i::HandleScope scope(isolate); 1475 i::HandleScope scope(isolate);
1349 EnsureConstructor(this); 1476 EnsureConstructor(this);
1350 i::FunctionTemplateInfo* constructor = 1477 i::FunctionTemplateInfo* constructor =
1351 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1478 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1352 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1479 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1353 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, 1480 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data,
1354 getter, 1481 settings, attribute,
1355 setter, 1482 signature);
1356 data, 1483 AddPropertyToFunctionTemplate(cons, obj);
1357 settings,
1358 attribute,
1359 signature);
1360 } 1484 }
1361 1485
1362 1486
1487 bool ObjectTemplate::SetAccessor(Handle<String> name,
1488 Handle<DeclaredAccessorDescriptor> descriptor,
1489 AccessControl settings,
1490 PropertyAttribute attribute,
1491 Handle<AccessorSignature> signature) {
1492 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1493 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return false;
1494 ENTER_V8(isolate);
1495 i::HandleScope scope(isolate);
1496 EnsureConstructor(this);
1497 i::FunctionTemplateInfo* constructor =
1498 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1499 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1500 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(
1501 name, descriptor, settings, attribute, signature);
1502 if (obj.is_null()) return false;
1503 AddPropertyToFunctionTemplate(cons, obj);
1504 return true;
1505 }
1506
1507
1363 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, 1508 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter,
1364 NamedPropertySetter setter, 1509 NamedPropertySetter setter,
1365 NamedPropertyQuery query, 1510 NamedPropertyQuery query,
1366 NamedPropertyDeleter remover, 1511 NamedPropertyDeleter remover,
1367 NamedPropertyEnumerator enumerator, 1512 NamedPropertyEnumerator enumerator,
1368 Handle<Value> data) { 1513 Handle<Value> data) {
1369 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1514 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1370 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { 1515 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) {
1371 return; 1516 return;
1372 } 1517 }
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 3296
3152 3297
3153 bool v8::Object::Has(uint32_t index) { 3298 bool v8::Object::Has(uint32_t index) {
3154 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3299 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3155 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false); 3300 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false);
3156 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3301 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3157 return self->HasElement(index); 3302 return self->HasElement(index);
3158 } 3303 }
3159 3304
3160 3305
3306 static inline bool SetAccessor(Object* obj, i::Handle<i::AccessorInfo> info) {
3307 if (info.is_null()) return false;
3308 bool fast = Utils::OpenHandle(obj)->HasFastProperties();
3309 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(obj), info);
3310 if (result.is_null() || result->IsUndefined()) return false;
3311 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(obj), 0);
3312 return true;
3313 }
3314
3315
3161 bool Object::SetAccessor(Handle<String> name, 3316 bool Object::SetAccessor(Handle<String> name,
3162 AccessorGetter getter, 3317 AccessorGetter getter,
3163 AccessorSetter setter, 3318 AccessorSetter setter,
3164 v8::Handle<Value> data, 3319 v8::Handle<Value> data,
3165 AccessControl settings, 3320 AccessControl settings,
3166 PropertyAttribute attributes) { 3321 PropertyAttribute attributes) {
3167 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3322 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3168 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); 3323 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false);
3169 ENTER_V8(isolate); 3324 ENTER_V8(isolate);
3170 i::HandleScope scope(isolate); 3325 i::HandleScope scope(isolate);
3171 v8::Handle<AccessorSignature> signature; 3326 v8::Handle<AccessorSignature> signature;
3172 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, getter, setter, data, 3327 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, getter, setter, data,
3173 settings, attributes, 3328 settings, attributes,
3174 signature); 3329 signature);
3175 bool fast = Utils::OpenHandle(this)->HasFastProperties(); 3330 return v8::SetAccessor(this, info);
3176 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info);
3177 if (result.is_null() || result->IsUndefined()) return false;
3178 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(this), 0);
3179 return true;
3180 } 3331 }
3181 3332
3182 3333
3334 bool Object::SetAccessor(Handle<String> name,
3335 Handle<DeclaredAccessorDescriptor> descriptor,
3336 AccessControl settings,
3337 PropertyAttribute attributes) {
3338 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3339 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false);
3340 ENTER_V8(isolate);
3341 i::HandleScope scope(isolate);
3342 v8::Handle<AccessorSignature> signature;
3343 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(
3344 name, descriptor, settings, attributes, signature);
3345 return v8::SetAccessor(this, info);
3346 }
3347
3348
3183 bool v8::Object::HasOwnProperty(Handle<String> key) { 3349 bool v8::Object::HasOwnProperty(Handle<String> key) {
3184 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3350 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3185 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", 3351 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()",
3186 return false); 3352 return false);
3187 return Utils::OpenHandle(this)->HasLocalProperty( 3353 return Utils::OpenHandle(this)->HasLocalProperty(
3188 *Utils::OpenHandle(*key)); 3354 *Utils::OpenHandle(*key));
3189 } 3355 }
3190 3356
3191 3357
3192 bool v8::Object::HasRealNamedProperty(Handle<String> key) { 3358 bool v8::Object::HasRealNamedProperty(Handle<String> key) {
(...skipping 3714 matching lines...) Expand 10 before | Expand all | Expand 10 after
6907 7073
6908 v->VisitPointers(blocks_.first(), first_block_limit_); 7074 v->VisitPointers(blocks_.first(), first_block_limit_);
6909 7075
6910 for (int i = 1; i < blocks_.length(); i++) { 7076 for (int i = 1; i < blocks_.length(); i++) {
6911 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7077 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6912 } 7078 }
6913 } 7079 }
6914 7080
6915 7081
6916 } } // namespace v8::internal 7082 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698