OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 AccessorNameSetterCallback setter, | 1232 AccessorNameSetterCallback setter, |
1233 v8::Handle<Value> data, | 1233 v8::Handle<Value> data, |
1234 AccessControl settings, | 1234 AccessControl settings, |
1235 PropertyAttribute attribute, | 1235 PropertyAttribute attribute, |
1236 v8::Handle<AccessorSignature> signature) { | 1236 v8::Handle<AccessorSignature> signature) { |
1237 TemplateSetAccessor( | 1237 TemplateSetAccessor( |
1238 this, name, getter, setter, data, settings, attribute, signature); | 1238 this, name, getter, setter, data, settings, attribute, signature); |
1239 } | 1239 } |
1240 | 1240 |
1241 | 1241 |
1242 void ObjectTemplate::SetNamedPropertyHandler( | 1242 template <typename Getter, typename Setter, typename Query, typename Deleter, |
1243 NamedPropertyGetterCallback getter, | 1243 typename Enumerator> |
1244 NamedPropertySetterCallback setter, | 1244 static void ObjectTemplateSetNamedPropertyHandler(ObjectTemplate* templ, |
1245 NamedPropertyQueryCallback query, | 1245 Getter getter, Setter setter, |
1246 NamedPropertyDeleterCallback remover, | 1246 Query query, Deleter remover, |
1247 NamedPropertyEnumeratorCallback enumerator, | 1247 Enumerator enumerator, |
1248 Handle<Value> data) { | 1248 Handle<Value> data, |
1249 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1249 bool can_intercept_symbols) { |
| 1250 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate(); |
1250 ENTER_V8(isolate); | 1251 ENTER_V8(isolate); |
1251 i::HandleScope scope(isolate); | 1252 i::HandleScope scope(isolate); |
1252 EnsureConstructor(isolate, this); | 1253 EnsureConstructor(isolate, templ); |
1253 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1254 i::FunctionTemplateInfo* constructor = |
1254 Utils::OpenHandle(this)->constructor()); | 1255 i::FunctionTemplateInfo::cast(Utils::OpenHandle(templ)->constructor()); |
1255 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1256 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1256 i::Handle<i::Struct> struct_obj = | 1257 i::Handle<i::Struct> struct_obj = |
1257 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | 1258 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
1258 i::Handle<i::InterceptorInfo> obj = | 1259 i::Handle<i::InterceptorInfo> obj = |
1259 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 1260 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
1260 | 1261 |
1261 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | 1262 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
1262 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); | 1263 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); |
1263 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); | 1264 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); |
1264 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); | 1265 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); |
1265 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); | 1266 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); |
| 1267 obj->set_flags(0); |
| 1268 obj->set_can_intercept_symbols(can_intercept_symbols); |
1266 | 1269 |
1267 if (data.IsEmpty()) { | 1270 if (data.IsEmpty()) { |
1268 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1271 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1269 } | 1272 } |
1270 obj->set_data(*Utils::OpenHandle(*data)); | 1273 obj->set_data(*Utils::OpenHandle(*data)); |
1271 cons->set_named_property_handler(*obj); | 1274 cons->set_named_property_handler(*obj); |
1272 } | 1275 } |
1273 | 1276 |
1274 | 1277 |
| 1278 void ObjectTemplate::SetNamedPropertyHandler( |
| 1279 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter, |
| 1280 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover, |
| 1281 NamedPropertyEnumeratorCallback enumerator, Handle<Value> data) { |
| 1282 ObjectTemplateSetNamedPropertyHandler(this, getter, setter, query, remover, |
| 1283 enumerator, data, false); |
| 1284 } |
| 1285 |
| 1286 |
| 1287 void ObjectTemplate::SetHandler( |
| 1288 const NamedPropertyHandlerConfiguration& config) { |
| 1289 ObjectTemplateSetNamedPropertyHandler(this, config.getter, config.setter, |
| 1290 config.query, config.deleter, |
| 1291 config.enumerator, config.data, true); |
| 1292 } |
| 1293 |
| 1294 |
1275 void ObjectTemplate::MarkAsUndetectable() { | 1295 void ObjectTemplate::MarkAsUndetectable() { |
1276 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1296 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1277 ENTER_V8(isolate); | 1297 ENTER_V8(isolate); |
1278 i::HandleScope scope(isolate); | 1298 i::HandleScope scope(isolate); |
1279 EnsureConstructor(isolate, this); | 1299 EnsureConstructor(isolate, this); |
1280 i::FunctionTemplateInfo* constructor = | 1300 i::FunctionTemplateInfo* constructor = |
1281 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1301 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
1282 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1302 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1283 cons->set_undetectable(true); | 1303 cons->set_undetectable(true); |
1284 } | 1304 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 i::Handle<i::Struct> struct_obj = | 1352 i::Handle<i::Struct> struct_obj = |
1333 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | 1353 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
1334 i::Handle<i::InterceptorInfo> obj = | 1354 i::Handle<i::InterceptorInfo> obj = |
1335 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 1355 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
1336 | 1356 |
1337 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | 1357 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
1338 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); | 1358 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); |
1339 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); | 1359 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); |
1340 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); | 1360 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); |
1341 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); | 1361 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); |
| 1362 obj->set_flags(0); |
1342 | 1363 |
1343 if (data.IsEmpty()) { | 1364 if (data.IsEmpty()) { |
1344 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1365 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1345 } | 1366 } |
1346 obj->set_data(*Utils::OpenHandle(*data)); | 1367 obj->set_data(*Utils::OpenHandle(*data)); |
1347 cons->set_indexed_property_handler(*obj); | 1368 cons->set_indexed_property_handler(*obj); |
1348 } | 1369 } |
1349 | 1370 |
1350 | 1371 |
1351 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, | 1372 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, |
(...skipping 6305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7657 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7678 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7658 Address callback_address = | 7679 Address callback_address = |
7659 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7680 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7660 VMState<EXTERNAL> state(isolate); | 7681 VMState<EXTERNAL> state(isolate); |
7661 ExternalCallbackScope call_scope(isolate, callback_address); | 7682 ExternalCallbackScope call_scope(isolate, callback_address); |
7662 callback(info); | 7683 callback(info); |
7663 } | 7684 } |
7664 | 7685 |
7665 | 7686 |
7666 } } // namespace v8::internal | 7687 } } // namespace v8::internal |
OLD | NEW |