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 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 for (int i = 0; i < argc; i++) { | 983 for (int i = 0; i < argc; i++) { |
984 if (!argv[i].IsEmpty()) | 984 if (!argv[i].IsEmpty()) |
985 args->set(i, *Utils::OpenHandle(*argv[i])); | 985 args->set(i, *Utils::OpenHandle(*argv[i])); |
986 } | 986 } |
987 obj->set_args(*args); | 987 obj->set_args(*args); |
988 } | 988 } |
989 return Utils::ToLocal(obj); | 989 return Utils::ToLocal(obj); |
990 } | 990 } |
991 | 991 |
992 | 992 |
| 993 Local<AccessorSignature> AccessorSignature::New( |
| 994 Handle<FunctionTemplate> receiver) { |
| 995 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
| 996 } |
| 997 |
| 998 |
993 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { | 999 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { |
994 Handle<FunctionTemplate> types[1] = { type }; | 1000 Handle<FunctionTemplate> types[1] = { type }; |
995 return TypeSwitch::New(1, types); | 1001 return TypeSwitch::New(1, types); |
996 } | 1002 } |
997 | 1003 |
998 | 1004 |
999 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { | 1005 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { |
1000 i::Isolate* isolate = i::Isolate::Current(); | 1006 i::Isolate* isolate = i::Isolate::Current(); |
1001 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()"); | 1007 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()"); |
1002 LOG_API(isolate, "TypeSwitch::New"); | 1008 LOG_API(isolate, "TypeSwitch::New"); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 Utils::OpenHandle(this)->set_call_code(*obj); | 1056 Utils::OpenHandle(this)->set_call_code(*obj); |
1051 } | 1057 } |
1052 | 1058 |
1053 | 1059 |
1054 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1060 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
1055 v8::Handle<String> name, | 1061 v8::Handle<String> name, |
1056 AccessorGetter getter, | 1062 AccessorGetter getter, |
1057 AccessorSetter setter, | 1063 AccessorSetter setter, |
1058 v8::Handle<Value> data, | 1064 v8::Handle<Value> data, |
1059 v8::AccessControl settings, | 1065 v8::AccessControl settings, |
1060 v8::PropertyAttribute attributes) { | 1066 v8::PropertyAttribute attributes, |
| 1067 v8::Handle<AccessorSignature> signature) { |
1061 i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo(); | 1068 i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo(); |
1062 ASSERT(getter != NULL); | 1069 ASSERT(getter != NULL); |
1063 SET_FIELD_WRAPPED(obj, set_getter, getter); | 1070 SET_FIELD_WRAPPED(obj, set_getter, getter); |
1064 SET_FIELD_WRAPPED(obj, set_setter, setter); | 1071 SET_FIELD_WRAPPED(obj, set_setter, setter); |
1065 if (data.IsEmpty()) data = v8::Undefined(); | 1072 if (data.IsEmpty()) data = v8::Undefined(); |
1066 obj->set_data(*Utils::OpenHandle(*data)); | 1073 obj->set_data(*Utils::OpenHandle(*data)); |
1067 obj->set_name(*Utils::OpenHandle(*name)); | 1074 obj->set_name(*Utils::OpenHandle(*name)); |
1068 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 1075 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
1069 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 1076 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
1070 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); | 1077 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); |
1071 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 1078 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
| 1079 if (!signature.IsEmpty()) { |
| 1080 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); |
| 1081 } |
1072 return obj; | 1082 return obj; |
1073 } | 1083 } |
1074 | 1084 |
1075 | 1085 |
1076 void FunctionTemplate::AddInstancePropertyAccessor( | 1086 void FunctionTemplate::AddInstancePropertyAccessor( |
1077 v8::Handle<String> name, | 1087 v8::Handle<String> name, |
1078 AccessorGetter getter, | 1088 AccessorGetter getter, |
1079 AccessorSetter setter, | 1089 AccessorSetter setter, |
1080 v8::Handle<Value> data, | 1090 v8::Handle<Value> data, |
1081 v8::AccessControl settings, | 1091 v8::AccessControl settings, |
1082 v8::PropertyAttribute attributes) { | 1092 v8::PropertyAttribute attributes, |
| 1093 v8::Handle<AccessorSignature> signature) { |
1083 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1094 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1084 if (IsDeadCheck(isolate, | 1095 if (IsDeadCheck(isolate, |
1085 "v8::FunctionTemplate::AddInstancePropertyAccessor()")) { | 1096 "v8::FunctionTemplate::AddInstancePropertyAccessor()")) { |
1086 return; | 1097 return; |
1087 } | 1098 } |
1088 ENTER_V8(isolate); | 1099 ENTER_V8(isolate); |
1089 i::HandleScope scope(isolate); | 1100 i::HandleScope scope(isolate); |
1090 | 1101 |
1091 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, | 1102 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data, |
1092 getter, setter, data, | 1103 settings, attributes, |
1093 settings, attributes); | 1104 signature); |
1094 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); | 1105 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); |
1095 if (list->IsUndefined()) { | 1106 if (list->IsUndefined()) { |
1096 list = NeanderArray().value(); | 1107 list = NeanderArray().value(); |
1097 Utils::OpenHandle(this)->set_property_accessors(*list); | 1108 Utils::OpenHandle(this)->set_property_accessors(*list); |
1098 } | 1109 } |
1099 NeanderArray array(list); | 1110 NeanderArray array(list); |
1100 array.add(obj); | 1111 array.add(obj); |
1101 } | 1112 } |
1102 | 1113 |
1103 | 1114 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 Utils::OpenHandle(object_template)->set_constructor(*constructor); | 1279 Utils::OpenHandle(object_template)->set_constructor(*constructor); |
1269 } | 1280 } |
1270 } | 1281 } |
1271 | 1282 |
1272 | 1283 |
1273 void ObjectTemplate::SetAccessor(v8::Handle<String> name, | 1284 void ObjectTemplate::SetAccessor(v8::Handle<String> name, |
1274 AccessorGetter getter, | 1285 AccessorGetter getter, |
1275 AccessorSetter setter, | 1286 AccessorSetter setter, |
1276 v8::Handle<Value> data, | 1287 v8::Handle<Value> data, |
1277 AccessControl settings, | 1288 AccessControl settings, |
1278 PropertyAttribute attribute) { | 1289 PropertyAttribute attribute, |
| 1290 v8::Handle<AccessorSignature> signature) { |
1279 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1291 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1280 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return; | 1292 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return; |
1281 ENTER_V8(isolate); | 1293 ENTER_V8(isolate); |
1282 i::HandleScope scope(isolate); | 1294 i::HandleScope scope(isolate); |
1283 EnsureConstructor(this); | 1295 EnsureConstructor(this); |
1284 i::FunctionTemplateInfo* constructor = | 1296 i::FunctionTemplateInfo* constructor = |
1285 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1297 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
1286 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1298 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1287 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, | 1299 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, |
1288 getter, | 1300 getter, |
1289 setter, | 1301 setter, |
1290 data, | 1302 data, |
1291 settings, | 1303 settings, |
1292 attribute); | 1304 attribute, |
| 1305 signature); |
1293 } | 1306 } |
1294 | 1307 |
1295 | 1308 |
1296 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, | 1309 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, |
1297 NamedPropertySetter setter, | 1310 NamedPropertySetter setter, |
1298 NamedPropertyQuery query, | 1311 NamedPropertyQuery query, |
1299 NamedPropertyDeleter remover, | 1312 NamedPropertyDeleter remover, |
1300 NamedPropertyEnumerator enumerator, | 1313 NamedPropertyEnumerator enumerator, |
1301 Handle<Value> data) { | 1314 Handle<Value> data) { |
1302 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1315 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, | 3085 bool Object::SetAccessor(Handle<String> name, |
3073 AccessorGetter getter, | 3086 AccessorGetter getter, |
3074 AccessorSetter setter, | 3087 AccessorSetter setter, |
3075 v8::Handle<Value> data, | 3088 v8::Handle<Value> data, |
3076 AccessControl settings, | 3089 AccessControl settings, |
3077 PropertyAttribute attributes) { | 3090 PropertyAttribute attributes) { |
3078 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3091 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3079 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); | 3092 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); |
3080 ENTER_V8(isolate); | 3093 ENTER_V8(isolate); |
3081 i::HandleScope scope(isolate); | 3094 i::HandleScope scope(isolate); |
3082 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, | 3095 v8::Handle<AccessorSignature> signature; |
3083 getter, setter, data, | 3096 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, getter, setter, data, |
3084 settings, attributes); | 3097 settings, attributes, |
| 3098 signature); |
3085 bool fast = Utils::OpenHandle(this)->HasFastProperties(); | 3099 bool fast = Utils::OpenHandle(this)->HasFastProperties(); |
3086 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info); | 3100 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info); |
3087 if (result.is_null() || result->IsUndefined()) return false; | 3101 if (result.is_null() || result->IsUndefined()) return false; |
3088 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(this), 0); | 3102 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(this), 0); |
3089 return true; | 3103 return true; |
3090 } | 3104 } |
3091 | 3105 |
3092 | 3106 |
3093 bool v8::Object::HasOwnProperty(Handle<String> key) { | 3107 bool v8::Object::HasOwnProperty(Handle<String> key) { |
3094 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3108 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
(...skipping 3287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6382 | 6396 |
6383 | 6397 |
6384 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6398 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6385 HandleScopeImplementer* scope_implementer = | 6399 HandleScopeImplementer* scope_implementer = |
6386 reinterpret_cast<HandleScopeImplementer*>(storage); | 6400 reinterpret_cast<HandleScopeImplementer*>(storage); |
6387 scope_implementer->IterateThis(v); | 6401 scope_implementer->IterateThis(v); |
6388 return storage + ArchiveSpacePerThread(); | 6402 return storage + ArchiveSpacePerThread(); |
6389 } | 6403 } |
6390 | 6404 |
6391 } } // namespace v8::internal | 6405 } } // namespace v8::internal |
OLD | NEW |