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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 Utils::OpenHandle(this)->set_call_code(*obj); | 1050 Utils::OpenHandle(this)->set_call_code(*obj); |
1051 } | 1051 } |
1052 | 1052 |
1053 | 1053 |
1054 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1054 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
1055 v8::Handle<String> name, | 1055 v8::Handle<String> name, |
1056 AccessorGetter getter, | 1056 AccessorGetter getter, |
1057 AccessorSetter setter, | 1057 AccessorSetter setter, |
1058 v8::Handle<Value> data, | 1058 v8::Handle<Value> data, |
1059 v8::AccessControl settings, | 1059 v8::AccessControl settings, |
1060 v8::PropertyAttribute attributes) { | 1060 v8::PropertyAttribute attributes, |
1061 v8::Handle<FunctionTemplate> constructor) { | |
1061 i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo(); | 1062 i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo(); |
1062 ASSERT(getter != NULL); | 1063 ASSERT(getter != NULL); |
1063 SET_FIELD_WRAPPED(obj, set_getter, getter); | 1064 SET_FIELD_WRAPPED(obj, set_getter, getter); |
1064 SET_FIELD_WRAPPED(obj, set_setter, setter); | 1065 SET_FIELD_WRAPPED(obj, set_setter, setter); |
1065 if (data.IsEmpty()) data = v8::Undefined(); | 1066 if (data.IsEmpty()) data = v8::Undefined(); |
1066 obj->set_data(*Utils::OpenHandle(*data)); | 1067 obj->set_data(*Utils::OpenHandle(*data)); |
1067 obj->set_name(*Utils::OpenHandle(*name)); | 1068 obj->set_name(*Utils::OpenHandle(*name)); |
1068 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 1069 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
1069 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 1070 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
1070 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); | 1071 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); |
1071 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 1072 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
1073 if (!constructor.IsEmpty()) { | |
Sven Panne
2012/06/04 07:50:32
Not exactly related to this CL, but we should real
Michael Starzinger
2012/06/04 09:11:15
Yes. However the IsEmpty method (on the external h
| |
1074 obj->set_compatible(*Utils::OpenHandle(*constructor)); | |
1075 } | |
1072 return obj; | 1076 return obj; |
1073 } | 1077 } |
1074 | 1078 |
1075 | 1079 |
1076 void FunctionTemplate::AddInstancePropertyAccessor( | 1080 void FunctionTemplate::AddInstancePropertyAccessor( |
1077 v8::Handle<String> name, | 1081 v8::Handle<String> name, |
1078 AccessorGetter getter, | 1082 AccessorGetter getter, |
1079 AccessorSetter setter, | 1083 AccessorSetter setter, |
1080 v8::Handle<Value> data, | 1084 v8::Handle<Value> data, |
1081 v8::AccessControl settings, | 1085 v8::AccessControl settings, |
1082 v8::PropertyAttribute attributes) { | 1086 v8::PropertyAttribute attributes, |
1087 v8::Handle<FunctionTemplate> constructor) { | |
1083 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1088 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1084 if (IsDeadCheck(isolate, | 1089 if (IsDeadCheck(isolate, |
1085 "v8::FunctionTemplate::AddInstancePropertyAccessor()")) { | 1090 "v8::FunctionTemplate::AddInstancePropertyAccessor()")) { |
1086 return; | 1091 return; |
1087 } | 1092 } |
1088 ENTER_V8(isolate); | 1093 ENTER_V8(isolate); |
1089 i::HandleScope scope(isolate); | 1094 i::HandleScope scope(isolate); |
1090 | 1095 |
1091 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, | 1096 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data, |
1092 getter, setter, data, | 1097 settings, attributes, |
1093 settings, attributes); | 1098 constructor); |
1094 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); | 1099 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); |
1095 if (list->IsUndefined()) { | 1100 if (list->IsUndefined()) { |
1096 list = NeanderArray().value(); | 1101 list = NeanderArray().value(); |
1097 Utils::OpenHandle(this)->set_property_accessors(*list); | 1102 Utils::OpenHandle(this)->set_property_accessors(*list); |
1098 } | 1103 } |
1099 NeanderArray array(list); | 1104 NeanderArray array(list); |
1100 array.add(obj); | 1105 array.add(obj); |
1101 } | 1106 } |
1102 | 1107 |
1103 | 1108 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1268 Utils::OpenHandle(object_template)->set_constructor(*constructor); | 1273 Utils::OpenHandle(object_template)->set_constructor(*constructor); |
1269 } | 1274 } |
1270 } | 1275 } |
1271 | 1276 |
1272 | 1277 |
1273 void ObjectTemplate::SetAccessor(v8::Handle<String> name, | 1278 void ObjectTemplate::SetAccessor(v8::Handle<String> name, |
1274 AccessorGetter getter, | 1279 AccessorGetter getter, |
1275 AccessorSetter setter, | 1280 AccessorSetter setter, |
1276 v8::Handle<Value> data, | 1281 v8::Handle<Value> data, |
1277 AccessControl settings, | 1282 AccessControl settings, |
1278 PropertyAttribute attribute) { | 1283 PropertyAttribute attribute, |
1284 v8::Handle<FunctionTemplate> construct) { | |
1279 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1285 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1280 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return; | 1286 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return; |
1281 ENTER_V8(isolate); | 1287 ENTER_V8(isolate); |
1282 i::HandleScope scope(isolate); | 1288 i::HandleScope scope(isolate); |
1283 EnsureConstructor(this); | 1289 EnsureConstructor(this); |
1284 i::FunctionTemplateInfo* constructor = | 1290 i::FunctionTemplateInfo* constructor = |
1285 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1291 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
1286 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1292 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1287 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, | 1293 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, |
1288 getter, | 1294 getter, |
1289 setter, | 1295 setter, |
1290 data, | 1296 data, |
1291 settings, | 1297 settings, |
1292 attribute); | 1298 attribute, |
1299 construct); | |
1293 } | 1300 } |
1294 | 1301 |
1295 | 1302 |
1296 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, | 1303 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, |
1297 NamedPropertySetter setter, | 1304 NamedPropertySetter setter, |
1298 NamedPropertyQuery query, | 1305 NamedPropertyQuery query, |
1299 NamedPropertyDeleter remover, | 1306 NamedPropertyDeleter remover, |
1300 NamedPropertyEnumerator enumerator, | 1307 NamedPropertyEnumerator enumerator, |
1301 Handle<Value> data) { | 1308 Handle<Value> data) { |
1302 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1309 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3072 bool Object::SetAccessor(Handle<String> name, | 3079 bool Object::SetAccessor(Handle<String> name, |
3073 AccessorGetter getter, | 3080 AccessorGetter getter, |
3074 AccessorSetter setter, | 3081 AccessorSetter setter, |
3075 v8::Handle<Value> data, | 3082 v8::Handle<Value> data, |
3076 AccessControl settings, | 3083 AccessControl settings, |
3077 PropertyAttribute attributes) { | 3084 PropertyAttribute attributes) { |
3078 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3085 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3079 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); | 3086 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); |
3080 ENTER_V8(isolate); | 3087 ENTER_V8(isolate); |
3081 i::HandleScope scope(isolate); | 3088 i::HandleScope scope(isolate); |
3082 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, | 3089 v8::Handle<FunctionTemplate> constructor; |
3083 getter, setter, data, | 3090 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, getter, setter, data, |
3084 settings, attributes); | 3091 settings, attributes, |
3092 constructor); | |
3085 bool fast = Utils::OpenHandle(this)->HasFastProperties(); | 3093 bool fast = Utils::OpenHandle(this)->HasFastProperties(); |
3086 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info); | 3094 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info); |
3087 if (result.is_null() || result->IsUndefined()) return false; | 3095 if (result.is_null() || result->IsUndefined()) return false; |
3088 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(this), 0); | 3096 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(this), 0); |
3089 return true; | 3097 return true; |
3090 } | 3098 } |
3091 | 3099 |
3092 | 3100 |
3093 bool v8::Object::HasOwnProperty(Handle<String> key) { | 3101 bool v8::Object::HasOwnProperty(Handle<String> key) { |
3094 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3102 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
(...skipping 3287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6382 | 6390 |
6383 | 6391 |
6384 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6392 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6385 HandleScopeImplementer* scope_implementer = | 6393 HandleScopeImplementer* scope_implementer = |
6386 reinterpret_cast<HandleScopeImplementer*>(storage); | 6394 reinterpret_cast<HandleScopeImplementer*>(storage); |
6387 scope_implementer->IterateThis(v); | 6395 scope_implementer->IterateThis(v); |
6388 return storage + ArchiveSpacePerThread(); | 6396 return storage + ArchiveSpacePerThread(); |
6389 } | 6397 } |
6390 | 6398 |
6391 } } // namespace v8::internal | 6399 } } // namespace v8::internal |
OLD | NEW |