| 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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 void V8::ClearWeak(i::Object** obj) { | 669 void V8::ClearWeak(i::Object** obj) { |
| 670 i::GlobalHandles::ClearWeakness(obj); | 670 i::GlobalHandles::ClearWeakness(obj); |
| 671 } | 671 } |
| 672 | 672 |
| 673 | 673 |
| 674 void V8::DisposeGlobal(i::Object** obj) { | 674 void V8::DisposeGlobal(i::Object** obj) { |
| 675 i::GlobalHandles::Destroy(obj); | 675 i::GlobalHandles::Destroy(obj); |
| 676 } | 676 } |
| 677 | 677 |
| 678 | 678 |
| 679 int V8::Eternalize(i::Isolate* isolate, i::Object** handle) { | 679 void V8::Eternalize(Isolate* v8_isolate, Value* value, int* index) { |
| 680 return isolate->eternal_handles()->Create(isolate, *handle); | 680 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 681 i::Object* object = *Utils::OpenHandle(value); |
| 682 isolate->eternal_handles()->Create(isolate, object, index); |
| 681 } | 683 } |
| 682 | 684 |
| 683 | 685 |
| 684 i::Object** V8::GetEternal(i::Isolate* isolate, int index) { | 686 Local<Value> V8::GetEternal(Isolate* v8_isolate, int index) { |
| 685 return isolate->eternal_handles()->Get(index).location(); | 687 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 688 return Utils::ToLocal(isolate->eternal_handles()->Get(index)); |
| 686 } | 689 } |
| 687 | 690 |
| 688 | 691 |
| 689 // --- H a n d l e s --- | 692 // --- H a n d l e s --- |
| 690 | 693 |
| 691 | 694 |
| 692 HandleScope::HandleScope() { | 695 HandleScope::HandleScope() { |
| 693 Initialize(reinterpret_cast<Isolate*>(i::Isolate::Current())); | 696 Initialize(reinterpret_cast<Isolate*>(i::Isolate::Current())); |
| 694 } | 697 } |
| 695 | 698 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 | 951 |
| 949 | 952 |
| 950 // --- T e m p l a t e --- | 953 // --- T e m p l a t e --- |
| 951 | 954 |
| 952 | 955 |
| 953 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { | 956 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { |
| 954 that->set_tag(i::Smi::FromInt(type)); | 957 that->set_tag(i::Smi::FromInt(type)); |
| 955 } | 958 } |
| 956 | 959 |
| 957 | 960 |
| 958 void Template::Set(v8::Handle<String> name, v8::Handle<Data> value, | 961 static void TemplateSet(i::Isolate* isolate, |
| 962 v8::Template* templ, |
| 963 int length, |
| 964 v8::Handle<v8::Data>* data) { |
| 965 i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate); |
| 966 if (list->IsUndefined()) { |
| 967 list = NeanderArray().value(); |
| 968 Utils::OpenHandle(templ)->set_property_list(*list); |
| 969 } |
| 970 NeanderArray array(list); |
| 971 array.add(Utils::OpenHandle(*v8::Integer::New(length))); |
| 972 for (int i = 0; i < length; i++) { |
| 973 i::Handle<i::Object> value = data[i].IsEmpty() ? |
| 974 i::Handle<i::Object>(isolate->factory()->undefined_value()) : |
| 975 Utils::OpenHandle(*data[i]); |
| 976 array.add(value); |
| 977 } |
| 978 } |
| 979 |
| 980 |
| 981 void Template::Set(v8::Handle<String> name, |
| 982 v8::Handle<Data> value, |
| 959 v8::PropertyAttribute attribute) { | 983 v8::PropertyAttribute attribute) { |
| 960 i::Isolate* isolate = i::Isolate::Current(); | 984 i::Isolate* isolate = i::Isolate::Current(); |
| 961 if (IsDeadCheck(isolate, "v8::Template::Set()")) return; | 985 if (IsDeadCheck(isolate, "v8::Template::Set()")) return; |
| 962 ENTER_V8(isolate); | 986 ENTER_V8(isolate); |
| 963 i::HandleScope scope(isolate); | 987 i::HandleScope scope(isolate); |
| 964 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list(), isolate); | 988 const int kSize = 3; |
| 965 if (list->IsUndefined()) { | 989 v8::Handle<v8::Data> data[kSize] = { |
| 966 list = NeanderArray().value(); | 990 name, |
| 967 Utils::OpenHandle(this)->set_property_list(*list); | 991 value, |
| 968 } | 992 v8::Integer::New(attribute)}; |
| 969 NeanderArray array(list); | 993 TemplateSet(isolate, this, kSize, data); |
| 970 array.add(Utils::OpenHandle(*name)); | |
| 971 array.add(Utils::OpenHandle(*value)); | |
| 972 array.add(Utils::OpenHandle(*v8::Integer::New(attribute))); | |
| 973 } | 994 } |
| 974 | 995 |
| 975 | 996 |
| 997 void Template::SetAccessorProperty( |
| 998 v8::Local<v8::String> name, |
| 999 v8::Local<FunctionTemplate> getter, |
| 1000 v8::Local<FunctionTemplate> setter, |
| 1001 v8::PropertyAttribute attribute, |
| 1002 v8::AccessControl access_control) { |
| 1003 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1004 if (IsDeadCheck(isolate, "v8::Template::SetAccessor()")) return; |
| 1005 ENTER_V8(isolate); |
| 1006 ASSERT(!name.IsEmpty()); |
| 1007 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); |
| 1008 i::HandleScope scope(isolate); |
| 1009 const int kSize = 5; |
| 1010 v8::Handle<v8::Data> data[kSize] = { |
| 1011 name, |
| 1012 getter, |
| 1013 setter, |
| 1014 v8::Integer::New(attribute), |
| 1015 v8::Integer::New(access_control)}; |
| 1016 TemplateSet(isolate, this, kSize, data); |
| 1017 } |
| 1018 |
| 1019 |
| 976 // --- F u n c t i o n T e m p l a t e --- | 1020 // --- F u n c t i o n T e m p l a t e --- |
| 977 static void InitializeFunctionTemplate( | 1021 static void InitializeFunctionTemplate( |
| 978 i::Handle<i::FunctionTemplateInfo> info) { | 1022 i::Handle<i::FunctionTemplateInfo> info) { |
| 979 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); | 1023 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); |
| 980 info->set_flag(0); | 1024 info->set_flag(0); |
| 981 } | 1025 } |
| 982 | 1026 |
| 983 | 1027 |
| 984 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { | 1028 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { |
| 985 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1029 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 998 | 1042 |
| 999 | 1043 |
| 1000 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { | 1044 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { |
| 1001 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1045 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1002 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; | 1046 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; |
| 1003 ENTER_V8(isolate); | 1047 ENTER_V8(isolate); |
| 1004 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); | 1048 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); |
| 1005 } | 1049 } |
| 1006 | 1050 |
| 1007 | 1051 |
| 1008 // TODO(dcarney): Remove this abstraction when old callbacks are removed. | 1052 Local<FunctionTemplate> FunctionTemplate::New( |
| 1009 class CallHandlerHelper { | 1053 FunctionCallback callback, |
| 1010 public: | |
| 1011 static inline void Set(Local<FunctionTemplate> function_template, | |
| 1012 InvocationCallback callback, | |
| 1013 v8::Handle<Value> data) { | |
| 1014 function_template->SetCallHandlerInternal(callback, data); | |
| 1015 } | |
| 1016 static inline void Set(Local<FunctionTemplate> function_template, | |
| 1017 FunctionCallback callback, | |
| 1018 v8::Handle<Value> data) { | |
| 1019 function_template->SetCallHandler(callback, data); | |
| 1020 } | |
| 1021 }; | |
| 1022 | |
| 1023 | |
| 1024 template<typename Callback> | |
| 1025 static Local<FunctionTemplate> FunctionTemplateNew( | |
| 1026 Callback callback, | |
| 1027 v8::Handle<Value> data, | 1054 v8::Handle<Value> data, |
| 1028 v8::Handle<Signature> signature, | 1055 v8::Handle<Signature> signature, |
| 1029 int length) { | 1056 int length) { |
| 1030 i::Isolate* isolate = i::Isolate::Current(); | 1057 i::Isolate* isolate = i::Isolate::Current(); |
| 1031 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); | 1058 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); |
| 1032 LOG_API(isolate, "FunctionTemplate::New"); | 1059 LOG_API(isolate, "FunctionTemplate::New"); |
| 1033 ENTER_V8(isolate); | 1060 ENTER_V8(isolate); |
| 1034 i::Handle<i::Struct> struct_obj = | 1061 i::Handle<i::Struct> struct_obj = |
| 1035 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); | 1062 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); |
| 1036 i::Handle<i::FunctionTemplateInfo> obj = | 1063 i::Handle<i::FunctionTemplateInfo> obj = |
| 1037 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); | 1064 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); |
| 1038 InitializeFunctionTemplate(obj); | 1065 InitializeFunctionTemplate(obj); |
| 1039 int next_serial_number = isolate->next_serial_number(); | 1066 int next_serial_number = isolate->next_serial_number(); |
| 1040 isolate->set_next_serial_number(next_serial_number + 1); | 1067 isolate->set_next_serial_number(next_serial_number + 1); |
| 1041 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); | 1068 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); |
| 1042 if (callback != 0) { | 1069 if (callback != 0) { |
| 1043 if (data.IsEmpty()) data = v8::Undefined(); | 1070 if (data.IsEmpty()) data = v8::Undefined(); |
| 1044 CallHandlerHelper::Set(Utils::ToLocal(obj), callback, data); | 1071 Utils::ToLocal(obj)->SetCallHandler(callback, data); |
| 1045 } | 1072 } |
| 1046 obj->set_length(length); | 1073 obj->set_length(length); |
| 1047 obj->set_undetectable(false); | 1074 obj->set_undetectable(false); |
| 1048 obj->set_needs_access_check(false); | 1075 obj->set_needs_access_check(false); |
| 1049 | 1076 |
| 1050 if (!signature.IsEmpty()) | 1077 if (!signature.IsEmpty()) |
| 1051 obj->set_signature(*Utils::OpenHandle(*signature)); | 1078 obj->set_signature(*Utils::OpenHandle(*signature)); |
| 1052 return Utils::ToLocal(obj); | 1079 return Utils::ToLocal(obj); |
| 1053 } | 1080 } |
| 1054 | 1081 |
| 1055 | 1082 |
| 1056 Local<FunctionTemplate> FunctionTemplate::New( | |
| 1057 InvocationCallback callback, | |
| 1058 v8::Handle<Value> data, | |
| 1059 v8::Handle<Signature> signature, | |
| 1060 int length) { | |
| 1061 return FunctionTemplateNew(callback, data, signature, length); | |
| 1062 } | |
| 1063 | |
| 1064 | |
| 1065 Local<FunctionTemplate> FunctionTemplate::New( | |
| 1066 FunctionCallback callback, | |
| 1067 v8::Handle<Value> data, | |
| 1068 v8::Handle<Signature> signature, | |
| 1069 int length) { | |
| 1070 return FunctionTemplateNew(callback, data, signature, length); | |
| 1071 } | |
| 1072 | |
| 1073 | |
| 1074 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, | 1083 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, |
| 1075 int argc, Handle<FunctionTemplate> argv[]) { | 1084 int argc, Handle<FunctionTemplate> argv[]) { |
| 1076 i::Isolate* isolate = i::Isolate::Current(); | 1085 i::Isolate* isolate = i::Isolate::Current(); |
| 1077 EnsureInitializedForIsolate(isolate, "v8::Signature::New()"); | 1086 EnsureInitializedForIsolate(isolate, "v8::Signature::New()"); |
| 1078 LOG_API(isolate, "Signature::New"); | 1087 LOG_API(isolate, "Signature::New"); |
| 1079 ENTER_V8(isolate); | 1088 ENTER_V8(isolate); |
| 1080 i::Handle<i::Struct> struct_obj = | 1089 i::Handle<i::Struct> struct_obj = |
| 1081 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); | 1090 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); |
| 1082 i::Handle<i::SignatureInfo> obj = | 1091 i::Handle<i::SignatureInfo> obj = |
| 1083 i::Handle<i::SignatureInfo>::cast(struct_obj); | 1092 i::Handle<i::SignatureInfo>::cast(struct_obj); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 return 0; | 1262 return 0; |
| 1254 } | 1263 } |
| 1255 | 1264 |
| 1256 | 1265 |
| 1257 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ | 1266 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ |
| 1258 i::Handle<i::Object> foreign = FromCData(cdata); \ | 1267 i::Handle<i::Object> foreign = FromCData(cdata); \ |
| 1259 (obj)->setter(*foreign); \ | 1268 (obj)->setter(*foreign); \ |
| 1260 } while (false) | 1269 } while (false) |
| 1261 | 1270 |
| 1262 | 1271 |
| 1263 template<typename Callback> | 1272 void FunctionTemplate::SetCallHandler(FunctionCallback callback, |
| 1264 static void FunctionTemplateSetCallHandler(FunctionTemplate* function_template, | 1273 v8::Handle<Value> data) { |
| 1265 Callback callback_in, | 1274 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1266 v8::Handle<Value> data) { | |
| 1267 i::Isolate* isolate = Utils::OpenHandle(function_template)->GetIsolate(); | |
| 1268 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return; | 1275 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return; |
| 1269 ENTER_V8(isolate); | 1276 ENTER_V8(isolate); |
| 1270 i::HandleScope scope(isolate); | 1277 i::HandleScope scope(isolate); |
| 1271 i::Handle<i::Struct> struct_obj = | 1278 i::Handle<i::Struct> struct_obj = |
| 1272 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1279 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
| 1273 i::Handle<i::CallHandlerInfo> obj = | 1280 i::Handle<i::CallHandlerInfo> obj = |
| 1274 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1281 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
| 1275 FunctionCallback callback = | |
| 1276 i::CallbackTable::Register(isolate, callback_in); | |
| 1277 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1282 SET_FIELD_WRAPPED(obj, set_callback, callback); |
| 1278 if (data.IsEmpty()) data = v8::Undefined(); | 1283 if (data.IsEmpty()) data = v8::Undefined(); |
| 1279 obj->set_data(*Utils::OpenHandle(*data)); | 1284 obj->set_data(*Utils::OpenHandle(*data)); |
| 1280 Utils::OpenHandle(function_template)->set_call_code(*obj); | 1285 Utils::OpenHandle(this)->set_call_code(*obj); |
| 1281 } | 1286 } |
| 1282 | 1287 |
| 1283 void FunctionTemplate::SetCallHandler(InvocationCallback callback, | |
| 1284 v8::Handle<Value> data) { | |
| 1285 FunctionTemplateSetCallHandler(this, callback, data); | |
| 1286 } | |
| 1287 | |
| 1288 void FunctionTemplate::SetCallHandlerInternal(InvocationCallback callback, | |
| 1289 v8::Handle<Value> data) { | |
| 1290 FunctionTemplateSetCallHandler(this, callback, data); | |
| 1291 } | |
| 1292 | |
| 1293 void FunctionTemplate::SetCallHandler(FunctionCallback callback, | |
| 1294 v8::Handle<Value> data) { | |
| 1295 FunctionTemplateSetCallHandler(this, callback, data); | |
| 1296 } | |
| 1297 | 1288 |
| 1298 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( | 1289 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( |
| 1299 i::Handle<i::AccessorInfo> obj, | 1290 i::Handle<i::AccessorInfo> obj, |
| 1300 v8::Handle<String> name, | 1291 v8::Handle<String> name, |
| 1301 v8::AccessControl settings, | 1292 v8::AccessControl settings, |
| 1302 v8::PropertyAttribute attributes, | 1293 v8::PropertyAttribute attributes, |
| 1303 v8::Handle<AccessorSignature> signature) { | 1294 v8::Handle<AccessorSignature> signature) { |
| 1304 obj->set_name(*Utils::OpenHandle(*name)); | 1295 obj->set_name(*Utils::OpenHandle(*name)); |
| 1305 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 1296 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
| 1306 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 1297 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
| 1307 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); | 1298 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); |
| 1308 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 1299 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
| 1309 if (!signature.IsEmpty()) { | 1300 if (!signature.IsEmpty()) { |
| 1310 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); | 1301 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); |
| 1311 } | 1302 } |
| 1312 return obj; | 1303 return obj; |
| 1313 } | 1304 } |
| 1314 | 1305 |
| 1315 | 1306 |
| 1316 template<typename Getter, typename Setter> | 1307 template<typename Getter, typename Setter> |
| 1317 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1308 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
| 1318 v8::Handle<String> name, | 1309 v8::Handle<String> name, |
| 1319 Getter getter_in, | 1310 Getter getter, |
| 1320 Setter setter_in, | 1311 Setter setter, |
| 1321 v8::Handle<Value> data, | 1312 v8::Handle<Value> data, |
| 1322 v8::AccessControl settings, | 1313 v8::AccessControl settings, |
| 1323 v8::PropertyAttribute attributes, | 1314 v8::PropertyAttribute attributes, |
| 1324 v8::Handle<AccessorSignature> signature) { | 1315 v8::Handle<AccessorSignature> signature) { |
| 1325 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); | 1316 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); |
| 1326 i::Handle<i::ExecutableAccessorInfo> obj = | 1317 i::Handle<i::ExecutableAccessorInfo> obj = |
| 1327 isolate->factory()->NewExecutableAccessorInfo(); | 1318 isolate->factory()->NewExecutableAccessorInfo(); |
| 1328 AccessorGetterCallback getter = | |
| 1329 i::CallbackTable::Register(isolate, getter_in); | |
| 1330 SET_FIELD_WRAPPED(obj, set_getter, getter); | 1319 SET_FIELD_WRAPPED(obj, set_getter, getter); |
| 1331 AccessorSetterCallback setter = | |
| 1332 i::CallbackTable::Register(isolate, setter_in); | |
| 1333 SET_FIELD_WRAPPED(obj, set_setter, setter); | 1320 SET_FIELD_WRAPPED(obj, set_setter, setter); |
| 1334 if (data.IsEmpty()) data = v8::Undefined(); | 1321 if (data.IsEmpty()) data = v8::Undefined(); |
| 1335 obj->set_data(*Utils::OpenHandle(*data)); | 1322 obj->set_data(*Utils::OpenHandle(*data)); |
| 1336 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); | 1323 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); |
| 1337 } | 1324 } |
| 1338 | 1325 |
| 1339 | 1326 |
| 1340 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1327 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
| 1341 v8::Handle<String> name, | 1328 v8::Handle<String> name, |
| 1342 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor, | 1329 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 | 1387 |
| 1401 void FunctionTemplate::ReadOnlyPrototype() { | 1388 void FunctionTemplate::ReadOnlyPrototype() { |
| 1402 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1389 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1403 if (IsDeadCheck(isolate, "v8::FunctionTemplate::ReadOnlyPrototype()")) { | 1390 if (IsDeadCheck(isolate, "v8::FunctionTemplate::ReadOnlyPrototype()")) { |
| 1404 return; | 1391 return; |
| 1405 } | 1392 } |
| 1406 ENTER_V8(isolate); | 1393 ENTER_V8(isolate); |
| 1407 Utils::OpenHandle(this)->set_read_only_prototype(true); | 1394 Utils::OpenHandle(this)->set_read_only_prototype(true); |
| 1408 } | 1395 } |
| 1409 | 1396 |
| 1410 template< | 1397 |
| 1411 typename Getter, | 1398 void FunctionTemplate::RemovePrototype() { |
| 1412 typename Setter, | 1399 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1413 typename Query, | 1400 if (IsDeadCheck(isolate, "v8::FunctionTemplate::RemovePrototype()")) { |
| 1414 typename Deleter, | |
| 1415 typename Enumerator> | |
| 1416 static void SetNamedInstancePropertyHandler( | |
| 1417 i::Handle<i::FunctionTemplateInfo> function_template, | |
| 1418 Getter getter_in, | |
| 1419 Setter setter_in, | |
| 1420 Query query_in, | |
| 1421 Deleter remover_in, | |
| 1422 Enumerator enumerator_in, | |
| 1423 Handle<Value> data) { | |
| 1424 i::Isolate* isolate = function_template->GetIsolate(); | |
| 1425 if (IsDeadCheck(isolate, | |
| 1426 "v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { | |
| 1427 return; | 1401 return; |
| 1428 } | 1402 } |
| 1429 ENTER_V8(isolate); | 1403 ENTER_V8(isolate); |
| 1430 i::HandleScope scope(isolate); | 1404 Utils::OpenHandle(this)->set_remove_prototype(true); |
| 1431 i::Handle<i::Struct> struct_obj = | |
| 1432 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | |
| 1433 i::Handle<i::InterceptorInfo> obj = | |
| 1434 i::Handle<i::InterceptorInfo>::cast(struct_obj); | |
| 1435 | |
| 1436 NamedPropertyGetterCallback getter = | |
| 1437 i::CallbackTable::Register(isolate, getter_in); | |
| 1438 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | |
| 1439 NamedPropertySetterCallback setter = | |
| 1440 i::CallbackTable::Register(isolate, setter_in); | |
| 1441 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); | |
| 1442 NamedPropertyQueryCallback query = | |
| 1443 i::CallbackTable::Register(isolate, query_in); | |
| 1444 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); | |
| 1445 NamedPropertyDeleterCallback remover = | |
| 1446 i::CallbackTable::Register(isolate, remover_in); | |
| 1447 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); | |
| 1448 NamedPropertyEnumeratorCallback enumerator = | |
| 1449 i::CallbackTable::Register(isolate, enumerator_in); | |
| 1450 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); | |
| 1451 | |
| 1452 if (data.IsEmpty()) data = v8::Undefined(); | |
| 1453 obj->set_data(*Utils::OpenHandle(*data)); | |
| 1454 function_template->set_named_property_handler(*obj); | |
| 1455 } | 1405 } |
| 1456 | 1406 |
| 1457 | 1407 |
| 1458 template< | |
| 1459 typename Getter, | |
| 1460 typename Setter, | |
| 1461 typename Query, | |
| 1462 typename Deleter, | |
| 1463 typename Enumerator> | |
| 1464 static void SetIndexedInstancePropertyHandler( | |
| 1465 i::Handle<i::FunctionTemplateInfo> function_template, | |
| 1466 Getter getter_in, | |
| 1467 Setter setter_in, | |
| 1468 Query query_in, | |
| 1469 Deleter remover_in, | |
| 1470 Enumerator enumerator_in, | |
| 1471 Handle<Value> data) { | |
| 1472 i::Isolate* isolate = function_template->GetIsolate(); | |
| 1473 if (IsDeadCheck(isolate, | |
| 1474 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) { | |
| 1475 return; | |
| 1476 } | |
| 1477 ENTER_V8(isolate); | |
| 1478 i::HandleScope scope(isolate); | |
| 1479 i::Handle<i::Struct> struct_obj = | |
| 1480 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | |
| 1481 i::Handle<i::InterceptorInfo> obj = | |
| 1482 i::Handle<i::InterceptorInfo>::cast(struct_obj); | |
| 1483 | |
| 1484 IndexedPropertyGetterCallback getter = | |
| 1485 i::CallbackTable::Register(isolate, getter_in); | |
| 1486 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | |
| 1487 IndexedPropertySetterCallback setter = | |
| 1488 i::CallbackTable::Register(isolate, setter_in); | |
| 1489 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); | |
| 1490 IndexedPropertyQueryCallback query = | |
| 1491 i::CallbackTable::Register(isolate, query_in); | |
| 1492 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); | |
| 1493 IndexedPropertyDeleterCallback remover = | |
| 1494 i::CallbackTable::Register(isolate, remover_in); | |
| 1495 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); | |
| 1496 IndexedPropertyEnumeratorCallback enumerator = | |
| 1497 i::CallbackTable::Register(isolate, enumerator_in); | |
| 1498 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); | |
| 1499 | |
| 1500 if (data.IsEmpty()) data = v8::Undefined(); | |
| 1501 obj->set_data(*Utils::OpenHandle(*data)); | |
| 1502 function_template->set_indexed_property_handler(*obj); | |
| 1503 } | |
| 1504 | |
| 1505 | |
| 1506 template<typename Callback> | |
| 1507 static void SetInstanceCallAsFunctionHandler( | |
| 1508 i::Handle<i::FunctionTemplateInfo> function_template, | |
| 1509 Callback callback_in, | |
| 1510 Handle<Value> data) { | |
| 1511 i::Isolate* isolate = function_template->GetIsolate(); | |
| 1512 if (IsDeadCheck(isolate, | |
| 1513 "v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) { | |
| 1514 return; | |
| 1515 } | |
| 1516 ENTER_V8(isolate); | |
| 1517 i::HandleScope scope(isolate); | |
| 1518 i::Handle<i::Struct> struct_obj = | |
| 1519 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | |
| 1520 i::Handle<i::CallHandlerInfo> obj = | |
| 1521 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | |
| 1522 FunctionCallback callback = | |
| 1523 i::CallbackTable::Register(isolate, callback_in); | |
| 1524 SET_FIELD_WRAPPED(obj, set_callback, callback); | |
| 1525 if (data.IsEmpty()) data = v8::Undefined(); | |
| 1526 obj->set_data(*Utils::OpenHandle(*data)); | |
| 1527 function_template->set_instance_call_handler(*obj); | |
| 1528 } | |
| 1529 | |
| 1530 | |
| 1531 // --- O b j e c t T e m p l a t e --- | 1408 // --- O b j e c t T e m p l a t e --- |
| 1532 | 1409 |
| 1533 | 1410 |
| 1534 Local<ObjectTemplate> ObjectTemplate::New() { | 1411 Local<ObjectTemplate> ObjectTemplate::New() { |
| 1535 return New(Local<FunctionTemplate>()); | 1412 return New(Local<FunctionTemplate>()); |
| 1536 } | 1413 } |
| 1537 | 1414 |
| 1538 | 1415 |
| 1539 Local<ObjectTemplate> ObjectTemplate::New( | 1416 Local<ObjectTemplate> ObjectTemplate::New( |
| 1540 v8::Handle<FunctionTemplate> constructor) { | 1417 v8::Handle<FunctionTemplate> constructor) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1479 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1603 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( | 1480 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( |
| 1604 name, getter, setter, data, settings, attribute, signature); | 1481 name, getter, setter, data, settings, attribute, signature); |
| 1605 if (obj.is_null()) return false; | 1482 if (obj.is_null()) return false; |
| 1606 AddPropertyToFunctionTemplate(cons, obj); | 1483 AddPropertyToFunctionTemplate(cons, obj); |
| 1607 return true; | 1484 return true; |
| 1608 } | 1485 } |
| 1609 | 1486 |
| 1610 | 1487 |
| 1611 void ObjectTemplate::SetAccessor(v8::Handle<String> name, | 1488 void ObjectTemplate::SetAccessor(v8::Handle<String> name, |
| 1612 AccessorGetter getter, | |
| 1613 AccessorSetter setter, | |
| 1614 v8::Handle<Value> data, | |
| 1615 AccessControl settings, | |
| 1616 PropertyAttribute attribute, | |
| 1617 v8::Handle<AccessorSignature> signature) { | |
| 1618 ObjectTemplateSetAccessor( | |
| 1619 this, name, getter, setter, data, settings, attribute, signature); | |
| 1620 } | |
| 1621 | |
| 1622 | |
| 1623 void ObjectTemplate::SetAccessor(v8::Handle<String> name, | |
| 1624 AccessorGetterCallback getter, | 1489 AccessorGetterCallback getter, |
| 1625 AccessorSetterCallback setter, | 1490 AccessorSetterCallback setter, |
| 1626 v8::Handle<Value> data, | 1491 v8::Handle<Value> data, |
| 1627 AccessControl settings, | 1492 AccessControl settings, |
| 1628 PropertyAttribute attribute, | 1493 PropertyAttribute attribute, |
| 1629 v8::Handle<AccessorSignature> signature) { | 1494 v8::Handle<AccessorSignature> signature) { |
| 1630 ObjectTemplateSetAccessor( | 1495 ObjectTemplateSetAccessor( |
| 1631 this, name, getter, setter, data, settings, attribute, signature); | 1496 this, name, getter, setter, data, settings, attribute, signature); |
| 1632 } | 1497 } |
| 1633 | 1498 |
| 1634 | 1499 |
| 1635 bool ObjectTemplate::SetAccessor(Handle<String> name, | 1500 bool ObjectTemplate::SetAccessor(Handle<String> name, |
| 1636 Handle<DeclaredAccessorDescriptor> descriptor, | 1501 Handle<DeclaredAccessorDescriptor> descriptor, |
| 1637 AccessControl settings, | 1502 AccessControl settings, |
| 1638 PropertyAttribute attribute, | 1503 PropertyAttribute attribute, |
| 1639 Handle<AccessorSignature> signature) { | 1504 Handle<AccessorSignature> signature) { |
| 1640 void* null = NULL; | 1505 void* null = NULL; |
| 1641 return ObjectTemplateSetAccessor( | 1506 return ObjectTemplateSetAccessor( |
| 1642 this, name, descriptor, null, null, settings, attribute, signature); | 1507 this, name, descriptor, null, null, settings, attribute, signature); |
| 1643 } | 1508 } |
| 1644 | 1509 |
| 1645 | 1510 |
| 1646 template< | |
| 1647 typename Getter, | |
| 1648 typename Setter, | |
| 1649 typename Query, | |
| 1650 typename Deleter, | |
| 1651 typename Enumerator> | |
| 1652 static void ObjectTemplateSetNamedPropertyHandler( | |
| 1653 ObjectTemplate* object_template, | |
| 1654 Getter getter, | |
| 1655 Setter setter, | |
| 1656 Query query, | |
| 1657 Deleter remover, | |
| 1658 Enumerator enumerator, | |
| 1659 Handle<Value> data) { | |
| 1660 i::Isolate* isolate = Utils::OpenHandle(object_template)->GetIsolate(); | |
| 1661 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { | |
| 1662 return; | |
| 1663 } | |
| 1664 ENTER_V8(isolate); | |
| 1665 i::HandleScope scope(isolate); | |
| 1666 EnsureConstructor(object_template); | |
| 1667 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | |
| 1668 Utils::OpenHandle(object_template)->constructor()); | |
| 1669 i::Handle<i::FunctionTemplateInfo> cons(constructor); | |
| 1670 SetNamedInstancePropertyHandler(cons, | |
| 1671 getter, | |
| 1672 setter, | |
| 1673 query, | |
| 1674 remover, | |
| 1675 enumerator, | |
| 1676 data); | |
| 1677 } | |
| 1678 | |
| 1679 | |
| 1680 void ObjectTemplate::SetNamedPropertyHandler( | |
| 1681 NamedPropertyGetter getter, | |
| 1682 NamedPropertySetter setter, | |
| 1683 NamedPropertyQuery query, | |
| 1684 NamedPropertyDeleter remover, | |
| 1685 NamedPropertyEnumerator enumerator, | |
| 1686 Handle<Value> data) { | |
| 1687 ObjectTemplateSetNamedPropertyHandler( | |
| 1688 this, getter, setter, query, remover, enumerator, data); | |
| 1689 } | |
| 1690 | |
| 1691 | |
| 1692 void ObjectTemplate::SetNamedPropertyHandler( | 1511 void ObjectTemplate::SetNamedPropertyHandler( |
| 1693 NamedPropertyGetterCallback getter, | 1512 NamedPropertyGetterCallback getter, |
| 1694 NamedPropertySetterCallback setter, | 1513 NamedPropertySetterCallback setter, |
| 1695 NamedPropertyQueryCallback query, | 1514 NamedPropertyQueryCallback query, |
| 1696 NamedPropertyDeleterCallback remover, | 1515 NamedPropertyDeleterCallback remover, |
| 1697 NamedPropertyEnumeratorCallback enumerator, | 1516 NamedPropertyEnumeratorCallback enumerator, |
| 1698 Handle<Value> data) { | 1517 Handle<Value> data) { |
| 1699 ObjectTemplateSetNamedPropertyHandler( | 1518 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1700 this, getter, setter, query, remover, enumerator, data); | 1519 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { |
| 1520 return; |
| 1521 } |
| 1522 ENTER_V8(isolate); |
| 1523 i::HandleScope scope(isolate); |
| 1524 EnsureConstructor(this); |
| 1525 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
| 1526 Utils::OpenHandle(this)->constructor()); |
| 1527 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1528 i::Handle<i::Struct> struct_obj = |
| 1529 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
| 1530 i::Handle<i::InterceptorInfo> obj = |
| 1531 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
| 1532 |
| 1533 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
| 1534 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); |
| 1535 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); |
| 1536 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); |
| 1537 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); |
| 1538 |
| 1539 if (data.IsEmpty()) data = v8::Undefined(); |
| 1540 obj->set_data(*Utils::OpenHandle(*data)); |
| 1541 cons->set_named_property_handler(*obj); |
| 1701 } | 1542 } |
| 1702 | 1543 |
| 1703 | 1544 |
| 1704 void ObjectTemplate::MarkAsUndetectable() { | 1545 void ObjectTemplate::MarkAsUndetectable() { |
| 1705 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1546 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1706 if (IsDeadCheck(isolate, "v8::ObjectTemplate::MarkAsUndetectable()")) return; | 1547 if (IsDeadCheck(isolate, "v8::ObjectTemplate::MarkAsUndetectable()")) return; |
| 1707 ENTER_V8(isolate); | 1548 ENTER_V8(isolate); |
| 1708 i::HandleScope scope(isolate); | 1549 i::HandleScope scope(isolate); |
| 1709 EnsureConstructor(this); | 1550 EnsureConstructor(this); |
| 1710 i::FunctionTemplateInfo* constructor = | 1551 i::FunctionTemplateInfo* constructor = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1739 info->set_data(*Utils::OpenHandle(*data)); | 1580 info->set_data(*Utils::OpenHandle(*data)); |
| 1740 | 1581 |
| 1741 i::FunctionTemplateInfo* constructor = | 1582 i::FunctionTemplateInfo* constructor = |
| 1742 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1583 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
| 1743 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1584 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1744 cons->set_access_check_info(*info); | 1585 cons->set_access_check_info(*info); |
| 1745 cons->set_needs_access_check(turned_on_by_default); | 1586 cons->set_needs_access_check(turned_on_by_default); |
| 1746 } | 1587 } |
| 1747 | 1588 |
| 1748 | 1589 |
| 1749 template< | |
| 1750 typename Getter, | |
| 1751 typename Setter, | |
| 1752 typename Query, | |
| 1753 typename Deleter, | |
| 1754 typename Enumerator> | |
| 1755 void ObjectTemplateSetIndexedPropertyHandler( | |
| 1756 ObjectTemplate* object_template, | |
| 1757 Getter getter, | |
| 1758 Setter setter, | |
| 1759 Query query, | |
| 1760 Deleter remover, | |
| 1761 Enumerator enumerator, | |
| 1762 Handle<Value> data) { | |
| 1763 i::Isolate* isolate = Utils::OpenHandle(object_template)->GetIsolate(); | |
| 1764 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetIndexedPropertyHandler()")) { | |
| 1765 return; | |
| 1766 } | |
| 1767 ENTER_V8(isolate); | |
| 1768 i::HandleScope scope(isolate); | |
| 1769 EnsureConstructor(object_template); | |
| 1770 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | |
| 1771 Utils::OpenHandle(object_template)->constructor()); | |
| 1772 i::Handle<i::FunctionTemplateInfo> cons(constructor); | |
| 1773 SetIndexedInstancePropertyHandler(cons, | |
| 1774 getter, | |
| 1775 setter, | |
| 1776 query, | |
| 1777 remover, | |
| 1778 enumerator, | |
| 1779 data); | |
| 1780 } | |
| 1781 | |
| 1782 | |
| 1783 void ObjectTemplate::SetIndexedPropertyHandler( | |
| 1784 IndexedPropertyGetter getter, | |
| 1785 IndexedPropertySetter setter, | |
| 1786 IndexedPropertyQuery query, | |
| 1787 IndexedPropertyDeleter remover, | |
| 1788 IndexedPropertyEnumerator enumerator, | |
| 1789 Handle<Value> data) { | |
| 1790 ObjectTemplateSetIndexedPropertyHandler( | |
| 1791 this, getter, setter, query, remover, enumerator, data); | |
| 1792 } | |
| 1793 | |
| 1794 | |
| 1795 void ObjectTemplate::SetIndexedPropertyHandler( | 1590 void ObjectTemplate::SetIndexedPropertyHandler( |
| 1796 IndexedPropertyGetterCallback getter, | 1591 IndexedPropertyGetterCallback getter, |
| 1797 IndexedPropertySetterCallback setter, | 1592 IndexedPropertySetterCallback setter, |
| 1798 IndexedPropertyQueryCallback query, | 1593 IndexedPropertyQueryCallback query, |
| 1799 IndexedPropertyDeleterCallback remover, | 1594 IndexedPropertyDeleterCallback remover, |
| 1800 IndexedPropertyEnumeratorCallback enumerator, | 1595 IndexedPropertyEnumeratorCallback enumerator, |
| 1801 Handle<Value> data) { | 1596 Handle<Value> data) { |
| 1802 ObjectTemplateSetIndexedPropertyHandler( | 1597 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1803 this, getter, setter, query, remover, enumerator, data); | 1598 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetIndexedPropertyHandler()")) { |
| 1599 return; |
| 1600 } |
| 1601 ENTER_V8(isolate); |
| 1602 i::HandleScope scope(isolate); |
| 1603 EnsureConstructor(this); |
| 1604 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
| 1605 Utils::OpenHandle(this)->constructor()); |
| 1606 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1607 i::Handle<i::Struct> struct_obj = |
| 1608 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
| 1609 i::Handle<i::InterceptorInfo> obj = |
| 1610 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
| 1611 |
| 1612 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
| 1613 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); |
| 1614 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); |
| 1615 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); |
| 1616 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); |
| 1617 |
| 1618 if (data.IsEmpty()) data = v8::Undefined(); |
| 1619 obj->set_data(*Utils::OpenHandle(*data)); |
| 1620 cons->set_indexed_property_handler(*obj); |
| 1804 } | 1621 } |
| 1805 | 1622 |
| 1806 | 1623 |
| 1807 template<typename Callback> | 1624 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, |
| 1808 static void ObjectTemplateSetCallAsFunctionHandler( | 1625 Handle<Value> data) { |
| 1809 ObjectTemplate* object_template, | 1626 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1810 Callback callback, | |
| 1811 Handle<Value> data) { | |
| 1812 i::Isolate* isolate = Utils::OpenHandle(object_template)->GetIsolate(); | |
| 1813 if (IsDeadCheck(isolate, | 1627 if (IsDeadCheck(isolate, |
| 1814 "v8::ObjectTemplate::SetCallAsFunctionHandler()")) { | 1628 "v8::ObjectTemplate::SetCallAsFunctionHandler()")) { |
| 1815 return; | 1629 return; |
| 1816 } | 1630 } |
| 1817 ENTER_V8(isolate); | 1631 ENTER_V8(isolate); |
| 1818 i::HandleScope scope(isolate); | 1632 i::HandleScope scope(isolate); |
| 1819 EnsureConstructor(object_template); | 1633 EnsureConstructor(this); |
| 1820 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1634 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
| 1821 Utils::OpenHandle(object_template)->constructor()); | 1635 Utils::OpenHandle(this)->constructor()); |
| 1822 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1636 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1823 SetInstanceCallAsFunctionHandler(cons, callback, data); | 1637 i::Handle<i::Struct> struct_obj = |
| 1638 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
| 1639 i::Handle<i::CallHandlerInfo> obj = |
| 1640 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
| 1641 SET_FIELD_WRAPPED(obj, set_callback, callback); |
| 1642 if (data.IsEmpty()) data = v8::Undefined(); |
| 1643 obj->set_data(*Utils::OpenHandle(*data)); |
| 1644 cons->set_instance_call_handler(*obj); |
| 1824 } | 1645 } |
| 1825 | 1646 |
| 1826 | 1647 |
| 1827 void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback, | |
| 1828 Handle<Value> data) { | |
| 1829 return ObjectTemplateSetCallAsFunctionHandler(this, callback, data); | |
| 1830 } | |
| 1831 | |
| 1832 | |
| 1833 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, | |
| 1834 Handle<Value> data) { | |
| 1835 return ObjectTemplateSetCallAsFunctionHandler(this, callback, data); | |
| 1836 } | |
| 1837 | |
| 1838 | |
| 1839 int ObjectTemplate::InternalFieldCount() { | 1648 int ObjectTemplate::InternalFieldCount() { |
| 1840 if (IsDeadCheck(Utils::OpenHandle(this)->GetIsolate(), | 1649 if (IsDeadCheck(Utils::OpenHandle(this)->GetIsolate(), |
| 1841 "v8::ObjectTemplate::InternalFieldCount()")) { | 1650 "v8::ObjectTemplate::InternalFieldCount()")) { |
| 1842 return 0; | 1651 return 0; |
| 1843 } | 1652 } |
| 1844 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); | 1653 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); |
| 1845 } | 1654 } |
| 1846 | 1655 |
| 1847 | 1656 |
| 1848 void ObjectTemplate::SetInternalFieldCount(int value) { | 1657 void ObjectTemplate::SetInternalFieldCount(int value) { |
| (...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3792 if (info.is_null()) return false; | 3601 if (info.is_null()) return false; |
| 3793 bool fast = Utils::OpenHandle(obj)->HasFastProperties(); | 3602 bool fast = Utils::OpenHandle(obj)->HasFastProperties(); |
| 3794 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(obj), info); | 3603 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(obj), info); |
| 3795 if (result.is_null() || result->IsUndefined()) return false; | 3604 if (result.is_null() || result->IsUndefined()) return false; |
| 3796 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(obj), 0); | 3605 if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(obj), 0); |
| 3797 return true; | 3606 return true; |
| 3798 } | 3607 } |
| 3799 | 3608 |
| 3800 | 3609 |
| 3801 bool Object::SetAccessor(Handle<String> name, | 3610 bool Object::SetAccessor(Handle<String> name, |
| 3802 AccessorGetter getter, | |
| 3803 AccessorSetter setter, | |
| 3804 v8::Handle<Value> data, | |
| 3805 AccessControl settings, | |
| 3806 PropertyAttribute attributes) { | |
| 3807 return ObjectSetAccessor( | |
| 3808 this, name, getter, setter, data, settings, attributes); | |
| 3809 } | |
| 3810 | |
| 3811 | |
| 3812 bool Object::SetAccessor(Handle<String> name, | |
| 3813 AccessorGetterCallback getter, | 3611 AccessorGetterCallback getter, |
| 3814 AccessorSetterCallback setter, | 3612 AccessorSetterCallback setter, |
| 3815 v8::Handle<Value> data, | 3613 v8::Handle<Value> data, |
| 3816 AccessControl settings, | 3614 AccessControl settings, |
| 3817 PropertyAttribute attributes) { | 3615 PropertyAttribute attributes) { |
| 3818 return ObjectSetAccessor( | 3616 return ObjectSetAccessor( |
| 3819 this, name, getter, setter, data, settings, attributes); | 3617 this, name, getter, setter, data, settings, attributes); |
| 3820 } | 3618 } |
| 3821 | 3619 |
| 3822 | 3620 |
| (...skipping 4298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8121 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize])); | 7919 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize])); |
| 8122 | 7920 |
| 8123 v->VisitPointers(blocks_.first(), first_block_limit_); | 7921 v->VisitPointers(blocks_.first(), first_block_limit_); |
| 8124 | 7922 |
| 8125 for (int i = 1; i < blocks_.length(); i++) { | 7923 for (int i = 1; i < blocks_.length(); i++) { |
| 8126 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 7924 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
| 8127 } | 7925 } |
| 8128 } | 7926 } |
| 8129 | 7927 |
| 8130 | 7928 |
| 8131 v8::Handle<v8::Value> InvokeAccessorGetter( | |
| 8132 v8::Local<v8::String> property, | |
| 8133 const v8::AccessorInfo& info, | |
| 8134 v8::AccessorGetter getter) { | |
| 8135 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | |
| 8136 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( | |
| 8137 getter)); | |
| 8138 // Leaving JavaScript. | |
| 8139 VMState<EXTERNAL> state(isolate); | |
| 8140 ExternalCallbackScope call_scope(isolate, getter_address); | |
| 8141 return getter(property, info); | |
| 8142 } | |
| 8143 | |
| 8144 | |
| 8145 void InvokeAccessorGetterCallback( | 7929 void InvokeAccessorGetterCallback( |
| 8146 v8::Local<v8::String> property, | 7930 v8::Local<v8::String> property, |
| 8147 const v8::PropertyCallbackInfo<v8::Value>& info, | 7931 const v8::PropertyCallbackInfo<v8::Value>& info, |
| 8148 v8::AccessorGetterCallback getter) { | 7932 v8::AccessorGetterCallback getter) { |
| 8149 // Leaving JavaScript. | 7933 // Leaving JavaScript. |
| 8150 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7934 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8151 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( | 7935 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( |
| 8152 getter)); | 7936 getter)); |
| 8153 VMState<EXTERNAL> state(isolate); | 7937 VMState<EXTERNAL> state(isolate); |
| 8154 ExternalCallbackScope call_scope(isolate, getter_address); | 7938 ExternalCallbackScope call_scope(isolate, getter_address); |
| 8155 return getter(property, info); | 7939 return getter(property, info); |
| 8156 } | 7940 } |
| 8157 | 7941 |
| 8158 | 7942 |
| 8159 v8::Handle<v8::Value> InvokeInvocationCallback( | |
| 8160 const v8::Arguments& args, | |
| 8161 v8::InvocationCallback callback) { | |
| 8162 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate()); | |
| 8163 Address callback_address = | |
| 8164 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | |
| 8165 VMState<EXTERNAL> state(isolate); | |
| 8166 ExternalCallbackScope call_scope(isolate, callback_address); | |
| 8167 return callback(args); | |
| 8168 } | |
| 8169 | |
| 8170 | |
| 8171 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, | 7943 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, |
| 8172 v8::FunctionCallback callback) { | 7944 v8::FunctionCallback callback) { |
| 8173 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7945 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8174 Address callback_address = | 7946 Address callback_address = |
| 8175 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7947 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8176 VMState<EXTERNAL> state(isolate); | 7948 VMState<EXTERNAL> state(isolate); |
| 8177 ExternalCallbackScope call_scope(isolate, callback_address); | 7949 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8178 return callback(info); | 7950 return callback(info); |
| 8179 } | 7951 } |
| 8180 | 7952 |
| 8181 | 7953 |
| 8182 } } // namespace v8::internal | 7954 } } // namespace v8::internal |
| OLD | NEW |