| OLD | NEW |
| 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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 return Utils::ToLocal(obj); | 1030 return Utils::ToLocal(obj); |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 | 1033 |
| 1034 Local<AccessorSignature> AccessorSignature::New( | 1034 Local<AccessorSignature> AccessorSignature::New( |
| 1035 Handle<FunctionTemplate> receiver) { | 1035 Handle<FunctionTemplate> receiver) { |
| 1036 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); | 1036 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 | 1039 |
| 1040 template<typename Operation> |
| 1041 static Local<Operation> NewDescriptor( |
| 1042 Isolate* isolate, |
| 1043 const i::DeclaredAccessorDescriptorData& data, |
| 1044 Data* previous_descriptor |
| 1045 ) { |
| 1046 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 1047 i::Handle<i::DeclaredAccessorDescriptor> previous = |
| 1048 i::Handle<i::DeclaredAccessorDescriptor>(); |
| 1049 if (previous_descriptor != NULL) { |
| 1050 previous = Utils::OpenHandle( |
| 1051 static_cast<DeclaredAccessorDescriptor*>(previous_descriptor)); |
| 1052 } |
| 1053 i::Handle<i::DeclaredAccessorDescriptor> descriptor = |
| 1054 i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous); |
| 1055 return Local<Operation>( |
| 1056 reinterpret_cast<Operation*>(*Utils::ToLocal(descriptor))); |
| 1057 } |
| 1058 |
| 1059 |
| 1060 Local<RawOperationDescriptor> ObjectOperationDescriptor::New( |
| 1061 Isolate* isolate, |
| 1062 int internal_field) { |
| 1063 i::DeclaredAccessorDescriptorData data; |
| 1064 data.type = i::kDescriptorObjectDereference; |
| 1065 data.object_dereference_descriptor.internal_field = internal_field; |
| 1066 return NewDescriptor<RawOperationDescriptor>(isolate, data, NULL); |
| 1067 } |
| 1068 |
| 1069 |
| 1070 Local<RawOperationDescriptor> RawOperationDescriptor::NewRawShift( |
| 1071 Isolate* isolate, |
| 1072 int16_t byte_offset) { |
| 1073 i::DeclaredAccessorDescriptorData data; |
| 1074 data.type = i::kDescriptorPointerShift; |
| 1075 data.pointer_shift_descriptor.byte_offset = byte_offset; |
| 1076 return NewDescriptor<RawOperationDescriptor>(isolate, data, this); |
| 1077 } |
| 1078 |
| 1079 |
| 1080 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewHandleDereference( |
| 1081 Isolate* isolate) { |
| 1082 i::DeclaredAccessorDescriptorData data; |
| 1083 data.type = i::kDescriptorReturnObject; |
| 1084 return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this); |
| 1085 } |
| 1086 |
| 1087 |
| 1088 Local<RawOperationDescriptor> RawOperationDescriptor::NewRawDereference( |
| 1089 Isolate* isolate) { |
| 1090 i::DeclaredAccessorDescriptorData data; |
| 1091 data.type = i::kDescriptorPointerDereference; |
| 1092 return NewDescriptor<RawOperationDescriptor>(isolate, data, this); |
| 1093 } |
| 1094 |
| 1095 |
| 1096 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewPointerCompare( |
| 1097 Isolate* isolate, |
| 1098 void* compare_value) { |
| 1099 i::DeclaredAccessorDescriptorData data; |
| 1100 data.type = i::kDescriptorPointerCompare; |
| 1101 data.pointer_compare_descriptor.compare_value = compare_value; |
| 1102 return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this); |
| 1103 } |
| 1104 |
| 1105 |
| 1106 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewPrimitiveValue( |
| 1107 Isolate* isolate, |
| 1108 DeclaredAccessorDescriptorDataType data_type, |
| 1109 uint8_t bool_offset) { |
| 1110 i::DeclaredAccessorDescriptorData data; |
| 1111 data.type = i::kDescriptorPrimitiveValue; |
| 1112 data.primitive_value_descriptor.data_type = data_type; |
| 1113 data.primitive_value_descriptor.bool_offset = bool_offset; |
| 1114 return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this); |
| 1115 } |
| 1116 |
| 1117 |
| 1118 template<typename T> |
| 1119 static Local<DeclaredAccessorDescriptor> NewBitmaskCompare( |
| 1120 Isolate* isolate, |
| 1121 T bitmask, |
| 1122 T compare_value, |
| 1123 RawOperationDescriptor* operation) { |
| 1124 i::DeclaredAccessorDescriptorData data; |
| 1125 data.type = i::kDescriptorBitmaskCompare; |
| 1126 data.bitmask_compare_descriptor.bitmask = bitmask; |
| 1127 data.bitmask_compare_descriptor.compare_value = compare_value; |
| 1128 data.bitmask_compare_descriptor.size = sizeof(T); |
| 1129 return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, operation); |
| 1130 } |
| 1131 |
| 1132 |
| 1133 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewBitmaskCompare8( |
| 1134 Isolate* isolate, |
| 1135 uint8_t bitmask, |
| 1136 uint8_t compare_value) { |
| 1137 return NewBitmaskCompare(isolate, bitmask, compare_value, this); |
| 1138 } |
| 1139 |
| 1140 |
| 1141 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewBitmaskCompare16( |
| 1142 Isolate* isolate, |
| 1143 uint16_t bitmask, |
| 1144 uint16_t compare_value) { |
| 1145 return NewBitmaskCompare(isolate, bitmask, compare_value, this); |
| 1146 } |
| 1147 |
| 1148 |
| 1149 Local<DeclaredAccessorDescriptor> RawOperationDescriptor::NewBitmaskCompare32( |
| 1150 Isolate* isolate, |
| 1151 uint32_t bitmask, |
| 1152 uint32_t compare_value) { |
| 1153 return NewBitmaskCompare(isolate, bitmask, compare_value, this); |
| 1154 } |
| 1155 |
| 1156 |
| 1040 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { | 1157 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { |
| 1041 Handle<FunctionTemplate> types[1] = { type }; | 1158 Handle<FunctionTemplate> types[1] = { type }; |
| 1042 return TypeSwitch::New(1, types); | 1159 return TypeSwitch::New(1, types); |
| 1043 } | 1160 } |
| 1044 | 1161 |
| 1045 | 1162 |
| 1046 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { | 1163 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { |
| 1047 i::Isolate* isolate = i::Isolate::Current(); | 1164 i::Isolate* isolate = i::Isolate::Current(); |
| 1048 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()"); | 1165 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()"); |
| 1049 LOG_API(isolate, "TypeSwitch::New"); | 1166 LOG_API(isolate, "TypeSwitch::New"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1208 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
| 1092 i::Handle<i::CallHandlerInfo> obj = | 1209 i::Handle<i::CallHandlerInfo> obj = |
| 1093 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1210 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
| 1094 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1211 SET_FIELD_WRAPPED(obj, set_callback, callback); |
| 1095 if (data.IsEmpty()) data = v8::Undefined(); | 1212 if (data.IsEmpty()) data = v8::Undefined(); |
| 1096 obj->set_data(*Utils::OpenHandle(*data)); | 1213 obj->set_data(*Utils::OpenHandle(*data)); |
| 1097 Utils::OpenHandle(this)->set_call_code(*obj); | 1214 Utils::OpenHandle(this)->set_call_code(*obj); |
| 1098 } | 1215 } |
| 1099 | 1216 |
| 1100 | 1217 |
| 1101 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1218 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( |
| 1102 v8::Handle<String> name, | 1219 i::Handle<i::AccessorInfo> obj, |
| 1103 AccessorGetter getter, | 1220 v8::Handle<String> name, |
| 1104 AccessorSetter setter, | 1221 v8::AccessControl settings, |
| 1105 v8::Handle<Value> data, | 1222 v8::PropertyAttribute attributes, |
| 1106 v8::AccessControl settings, | 1223 v8::Handle<AccessorSignature> signature) { |
| 1107 v8::PropertyAttribute attributes, | |
| 1108 v8::Handle<AccessorSignature> signature) { | |
| 1109 i::Handle<i::ExecutableAccessorInfo> obj = | |
| 1110 FACTORY->NewExecutableAccessorInfo(); | |
| 1111 SET_FIELD_WRAPPED(obj, set_getter, getter); | |
| 1112 SET_FIELD_WRAPPED(obj, set_setter, setter); | |
| 1113 if (data.IsEmpty()) data = v8::Undefined(); | |
| 1114 obj->set_data(*Utils::OpenHandle(*data)); | |
| 1115 obj->set_name(*Utils::OpenHandle(*name)); | 1224 obj->set_name(*Utils::OpenHandle(*name)); |
| 1116 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 1225 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
| 1117 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 1226 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
| 1118 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); | 1227 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); |
| 1119 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 1228 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
| 1120 if (!signature.IsEmpty()) { | 1229 if (!signature.IsEmpty()) { |
| 1121 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); | 1230 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); |
| 1122 } | 1231 } |
| 1123 return obj; | 1232 return obj; |
| 1124 } | 1233 } |
| 1125 | 1234 |
| 1126 | 1235 |
| 1127 void FunctionTemplate::AddInstancePropertyAccessor( | 1236 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
| 1128 v8::Handle<String> name, | 1237 v8::Handle<String> name, |
| 1129 AccessorGetter getter, | 1238 AccessorGetter getter, |
| 1130 AccessorSetter setter, | 1239 AccessorSetter setter, |
| 1131 v8::Handle<Value> data, | 1240 v8::Handle<Value> data, |
| 1132 v8::AccessControl settings, | 1241 v8::AccessControl settings, |
| 1133 v8::PropertyAttribute attributes, | 1242 v8::PropertyAttribute attributes, |
| 1134 v8::Handle<AccessorSignature> signature) { | 1243 v8::Handle<AccessorSignature> signature) { |
| 1135 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1244 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); |
| 1136 if (IsDeadCheck(isolate, | 1245 i::Handle<i::ExecutableAccessorInfo> obj = |
| 1137 "v8::FunctionTemplate::AddInstancePropertyAccessor()")) { | 1246 isolate->factory()->NewExecutableAccessorInfo(); |
| 1138 return; | 1247 SET_FIELD_WRAPPED(obj, set_getter, getter); |
| 1139 } | 1248 SET_FIELD_WRAPPED(obj, set_setter, setter); |
| 1140 ENTER_V8(isolate); | 1249 if (data.IsEmpty()) data = v8::Undefined(); |
| 1141 i::HandleScope scope(isolate); | 1250 obj->set_data(*Utils::OpenHandle(*data)); |
| 1142 | 1251 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); |
| 1143 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data, | |
| 1144 settings, attributes, | |
| 1145 signature); | |
| 1146 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); | |
| 1147 if (list->IsUndefined()) { | |
| 1148 list = NeanderArray().value(); | |
| 1149 Utils::OpenHandle(this)->set_property_accessors(*list); | |
| 1150 } | |
| 1151 NeanderArray array(list); | |
| 1152 array.add(obj); | |
| 1153 } | 1252 } |
| 1154 | 1253 |
| 1155 | 1254 |
| 1255 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
| 1256 v8::Handle<String> name, |
| 1257 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor, |
| 1258 v8::AccessControl settings, |
| 1259 v8::PropertyAttribute attributes, |
| 1260 v8::Handle<AccessorSignature> signature) { |
| 1261 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); |
| 1262 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>(); |
| 1263 i::Handle<i::DeclaredAccessorInfo> obj = |
| 1264 isolate->factory()->NewDeclaredAccessorInfo(); |
| 1265 obj->set_descriptor(*Utils::OpenHandle(*descriptor)); |
| 1266 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); |
| 1267 } |
| 1268 |
| 1269 |
| 1156 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { | 1270 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { |
| 1157 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1271 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1158 if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()") | 1272 if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()") |
| 1159 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) | 1273 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) |
| 1160 return Local<ObjectTemplate>(); | 1274 return Local<ObjectTemplate>(); |
| 1161 ENTER_V8(isolate); | 1275 ENTER_V8(isolate); |
| 1162 if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) { | 1276 if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) { |
| 1163 Local<ObjectTemplate> templ = | 1277 Local<ObjectTemplate> templ = |
| 1164 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this)); | 1278 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this)); |
| 1165 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ)); | 1279 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ)); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 static void EnsureConstructor(ObjectTemplate* object_template) { | 1437 static void EnsureConstructor(ObjectTemplate* object_template) { |
| 1324 if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) { | 1438 if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) { |
| 1325 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 1439 Local<FunctionTemplate> templ = FunctionTemplate::New(); |
| 1326 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); | 1440 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); |
| 1327 constructor->set_instance_template(*Utils::OpenHandle(object_template)); | 1441 constructor->set_instance_template(*Utils::OpenHandle(object_template)); |
| 1328 Utils::OpenHandle(object_template)->set_constructor(*constructor); | 1442 Utils::OpenHandle(object_template)->set_constructor(*constructor); |
| 1329 } | 1443 } |
| 1330 } | 1444 } |
| 1331 | 1445 |
| 1332 | 1446 |
| 1447 static inline void AddPropertyToFunctionTemplate( |
| 1448 i::Handle<i::FunctionTemplateInfo> cons, |
| 1449 i::Handle<i::AccessorInfo> obj) { |
| 1450 i::Handle<i::Object> list(cons->property_accessors()); |
| 1451 if (list->IsUndefined()) { |
| 1452 list = NeanderArray().value(); |
| 1453 cons->set_property_accessors(*list); |
| 1454 } |
| 1455 NeanderArray array(list); |
| 1456 array.add(obj); |
| 1457 } |
| 1458 |
| 1459 |
| 1333 void ObjectTemplate::SetAccessor(v8::Handle<String> name, | 1460 void ObjectTemplate::SetAccessor(v8::Handle<String> name, |
| 1334 AccessorGetter getter, | 1461 AccessorGetter getter, |
| 1335 AccessorSetter setter, | 1462 AccessorSetter setter, |
| 1336 v8::Handle<Value> data, | 1463 v8::Handle<Value> data, |
| 1337 AccessControl settings, | 1464 AccessControl settings, |
| 1338 PropertyAttribute attribute, | 1465 PropertyAttribute attributes, |
| 1339 v8::Handle<AccessorSignature> signature) { | 1466 v8::Handle<AccessorSignature> signature) { |
| 1340 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1467 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1341 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return; | 1468 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return; |
| 1342 ENTER_V8(isolate); | 1469 ENTER_V8(isolate); |
| 1343 i::HandleScope scope(isolate); | 1470 i::HandleScope scope(isolate); |
| 1344 EnsureConstructor(this); | 1471 EnsureConstructor(this); |
| 1345 i::FunctionTemplateInfo* constructor = | 1472 i::FunctionTemplateInfo* constructor = |
| 1346 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1473 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
| 1347 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1474 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1348 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, | 1475 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data, |
| 1349 getter, | 1476 settings, attributes, |
| 1350 setter, | 1477 signature); |
| 1351 data, | 1478 AddPropertyToFunctionTemplate(cons, obj); |
| 1352 settings, | |
| 1353 attribute, | |
| 1354 signature); | |
| 1355 } | 1479 } |
| 1356 | 1480 |
| 1357 | 1481 |
| 1482 bool ObjectTemplate::SetAccessor(Handle<String> name, |
| 1483 Handle<DeclaredAccessorDescriptor> descriptor, |
| 1484 AccessControl settings, |
| 1485 PropertyAttribute attributes, |
| 1486 Handle<AccessorSignature> signature) { |
| 1487 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1488 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return false; |
| 1489 ENTER_V8(isolate); |
| 1490 i::HandleScope scope(isolate); |
| 1491 EnsureConstructor(this); |
| 1492 i::FunctionTemplateInfo* constructor = |
| 1493 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
| 1494 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1495 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( |
| 1496 name, descriptor, settings, attributes, signature); |
| 1497 if (obj.is_null()) return false; |
| 1498 AddPropertyToFunctionTemplate(cons, obj); |
| 1499 return true; |
| 1500 } |
| 1501 |
| 1502 |
| 1358 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, | 1503 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, |
| 1359 NamedPropertySetter setter, | 1504 NamedPropertySetter setter, |
| 1360 NamedPropertyQuery query, | 1505 NamedPropertyQuery query, |
| 1361 NamedPropertyDeleter remover, | 1506 NamedPropertyDeleter remover, |
| 1362 NamedPropertyEnumerator enumerator, | 1507 NamedPropertyEnumerator enumerator, |
| 1363 Handle<Value> data) { | 1508 Handle<Value> data) { |
| 1364 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1509 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1365 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { | 1510 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { |
| 1366 return; | 1511 return; |
| 1367 } | 1512 } |
| (...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3142 | 3287 |
| 3143 | 3288 |
| 3144 bool v8::Object::Has(uint32_t index) { | 3289 bool v8::Object::Has(uint32_t index) { |
| 3145 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3290 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3146 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false); | 3291 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false); |
| 3147 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3292 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 3148 return self->HasElement(index); | 3293 return self->HasElement(index); |
| 3149 } | 3294 } |
| 3150 | 3295 |
| 3151 | 3296 |
| 3297 static inline bool SetAccessor(Object* obj, i::Handle<i::AccessorInfo> info) { |
| 3298 if (info.is_null()) return false; |
| 3299 bool fast = Utils::OpenHandle(obj)->HasFastProperties(); |
| 3300 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(obj), info); |
| 3301 if (result.is_null() || result->IsUndefined()) return false; |
| 3302 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(obj), 0); |
| 3303 return true; |
| 3304 } |
| 3305 |
| 3306 |
| 3152 bool Object::SetAccessor(Handle<String> name, | 3307 bool Object::SetAccessor(Handle<String> name, |
| 3153 AccessorGetter getter, | 3308 AccessorGetter getter, |
| 3154 AccessorSetter setter, | 3309 AccessorSetter setter, |
| 3155 v8::Handle<Value> data, | 3310 v8::Handle<Value> data, |
| 3156 AccessControl settings, | 3311 AccessControl settings, |
| 3157 PropertyAttribute attributes) { | 3312 PropertyAttribute attributes) { |
| 3158 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3313 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3159 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); | 3314 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); |
| 3160 ENTER_V8(isolate); | 3315 ENTER_V8(isolate); |
| 3161 i::HandleScope scope(isolate); | 3316 i::HandleScope scope(isolate); |
| 3162 v8::Handle<AccessorSignature> signature; | 3317 v8::Handle<AccessorSignature> signature; |
| 3163 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, getter, setter, data, | 3318 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, getter, setter, data, |
| 3164 settings, attributes, | 3319 settings, attributes, |
| 3165 signature); | 3320 signature); |
| 3166 bool fast = Utils::OpenHandle(this)->HasFastProperties(); | 3321 return v8::SetAccessor(this, info); |
| 3167 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info); | |
| 3168 if (result.is_null() || result->IsUndefined()) return false; | |
| 3169 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(this), 0); | |
| 3170 return true; | |
| 3171 } | 3322 } |
| 3172 | 3323 |
| 3173 | 3324 |
| 3325 bool Object::SetAccessor(Handle<String> name, |
| 3326 Handle<DeclaredAccessorDescriptor> descriptor, |
| 3327 AccessControl settings, |
| 3328 PropertyAttribute attributes) { |
| 3329 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3330 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); |
| 3331 ENTER_V8(isolate); |
| 3332 i::HandleScope scope(isolate); |
| 3333 v8::Handle<AccessorSignature> signature; |
| 3334 i::Handle<i::AccessorInfo> info = MakeAccessorInfo( |
| 3335 name, descriptor, settings, attributes, signature); |
| 3336 return v8::SetAccessor(this, info); |
| 3337 } |
| 3338 |
| 3339 |
| 3174 bool v8::Object::HasOwnProperty(Handle<String> key) { | 3340 bool v8::Object::HasOwnProperty(Handle<String> key) { |
| 3175 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3341 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3176 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", | 3342 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", |
| 3177 return false); | 3343 return false); |
| 3178 return Utils::OpenHandle(this)->HasLocalProperty( | 3344 return Utils::OpenHandle(this)->HasLocalProperty( |
| 3179 *Utils::OpenHandle(*key)); | 3345 *Utils::OpenHandle(*key)); |
| 3180 } | 3346 } |
| 3181 | 3347 |
| 3182 | 3348 |
| 3183 bool v8::Object::HasRealNamedProperty(Handle<String> key) { | 3349 bool v8::Object::HasRealNamedProperty(Handle<String> key) { |
| (...skipping 3520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6704 | 6870 |
| 6705 v->VisitPointers(blocks_.first(), first_block_limit_); | 6871 v->VisitPointers(blocks_.first(), first_block_limit_); |
| 6706 | 6872 |
| 6707 for (int i = 1; i < blocks_.length(); i++) { | 6873 for (int i = 1; i < blocks_.length(); i++) { |
| 6708 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 6874 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
| 6709 } | 6875 } |
| 6710 } | 6876 } |
| 6711 | 6877 |
| 6712 | 6878 |
| 6713 } } // namespace v8::internal | 6879 } } // namespace v8::internal |
| OLD | NEW |