| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 } | 479 } |
| 480 | 480 |
| 481 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | 481 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
| 482 v8SetReturnValue(info, info.Holder()); | 482 v8SetReturnValue(info, info.Holder()); |
| 483 return; | 483 return; |
| 484 } | 484 } |
| 485 | 485 |
| 486 TestTypedefsV8Internal::constructor(info); | 486 TestTypedefsV8Internal::constructor(info); |
| 487 } | 487 } |
| 488 | 488 |
| 489 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestTypedefsTemplate(v8::Hand
le<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldTyp
e currentWorldType) | 489 static void configureV8TestTypedefsTemplate(v8::Handle<v8::FunctionTemplate> fun
ctionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType) |
| 490 { | 490 { |
| 491 functionTemplate->ReadOnlyPrototype(); | 491 functionTemplate->ReadOnlyPrototype(); |
| 492 | 492 |
| 493 v8::Local<v8::Signature> defaultSignature; | 493 v8::Local<v8::Signature> defaultSignature; |
| 494 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestTypedefs", v8::Local<v8::FunctionTemplate>(), V8TestTypedefs::internal
FieldCount, | 494 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestTypedefs", v8::Local<v8::FunctionTemplate>(), V8TestTypedefs::internal
FieldCount, |
| 495 V8TestTypedefsAttributes, WTF_ARRAY_LENGTH(V8TestTypedefsAttributes), | 495 V8TestTypedefsAttributes, WTF_ARRAY_LENGTH(V8TestTypedefsAttributes), |
| 496 0, 0, | 496 0, 0, |
| 497 V8TestTypedefsMethods, WTF_ARRAY_LENGTH(V8TestTypedefsMethods), | 497 V8TestTypedefsMethods, WTF_ARRAY_LENGTH(V8TestTypedefsMethods), |
| 498 isolate, currentWorldType); | 498 isolate, currentWorldType); |
| 499 functionTemplate->SetCallHandler(V8TestTypedefs::constructorCallback); | 499 functionTemplate->SetCallHandler(V8TestTypedefs::constructorCallback); |
| 500 functionTemplate->SetLength(2); | 500 functionTemplate->SetLength(2); |
| 501 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 501 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
| 502 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 502 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
| 503 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "Te
stSubObj", v8::String::kInternalizedString), TestTypedefsV8Internal::TestTypedef
sConstructorGetter, 0, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&
V8TestSubObj::wrapperTypeInfo)), static_cast<v8::PropertyAttribute>(v8::DontEnum
), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAU
LT)); | 503 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "Te
stSubObj", v8::String::kInternalizedString), TestTypedefsV8Internal::TestTypedef
sConstructorGetter, 0, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&
V8TestSubObj::wrapperTypeInfo)), static_cast<v8::PropertyAttribute>(v8::DontEnum
), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAU
LT)); |
| 504 | 504 |
| 505 // Custom toString template | 505 // Custom toString template |
| 506 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); | 506 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); |
| 507 return functionTemplate; | |
| 508 } | 507 } |
| 509 | 508 |
| 510 v8::Handle<v8::FunctionTemplate> V8TestTypedefs::domTemplate(v8::Isolate* isolat
e, WrapperWorldType currentWorldType) | 509 v8::Handle<v8::FunctionTemplate> V8TestTypedefs::domTemplate(v8::Isolate* isolat
e, WrapperWorldType currentWorldType) |
| 511 { | 510 { |
| 512 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 511 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 513 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 512 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); |
| 514 if (result != data->templateMap(currentWorldType).end()) | 513 if (result != data->templateMap(currentWorldType).end()) |
| 515 return result->value.newLocal(isolate); | 514 return result->value.newLocal(isolate); |
| 516 | 515 |
| 517 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 516 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 518 v8::EscapableHandleScope handleScope(isolate); | 517 v8::EscapableHandleScope handleScope(isolate); |
| 519 v8::Local<v8::FunctionTemplate> templ = | 518 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
| 520 ConfigureV8TestTypedefsTemplate(data->rawDOMTemplate(&wrapperTypeInfo, c
urrentWorldType), isolate, currentWorldType); | 519 configureV8TestTypedefsTemplate(templ, isolate, currentWorldType); |
| 521 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 520 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 522 return handleScope.Escape(templ); | 521 return handleScope.Escape(templ); |
| 523 } | 522 } |
| 524 | 523 |
| 525 bool V8TestTypedefs::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso
late, WrapperWorldType currentWorldType) | 524 bool V8TestTypedefs::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso
late, WrapperWorldType currentWorldType) |
| 526 { | 525 { |
| 527 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 526 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); |
| 528 } | 527 } |
| 529 | 528 |
| 530 bool V8TestTypedefs::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Is
olate* isolate) | 529 bool V8TestTypedefs::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Is
olate* isolate) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 559 fromInternalPointer(object)->deref(); | 558 fromInternalPointer(object)->deref(); |
| 560 } | 559 } |
| 561 | 560 |
| 562 template<> | 561 template<> |
| 563 v8::Handle<v8::Value> toV8NoInline(TestTypedefs* impl, v8::Handle<v8::Object> cr
eationContext, v8::Isolate* isolate) | 562 v8::Handle<v8::Value> toV8NoInline(TestTypedefs* impl, v8::Handle<v8::Object> cr
eationContext, v8::Isolate* isolate) |
| 564 { | 563 { |
| 565 return toV8(impl, creationContext, isolate); | 564 return toV8(impl, creationContext, isolate); |
| 566 } | 565 } |
| 567 | 566 |
| 568 } // namespace WebCore | 567 } // namespace WebCore |
| OLD | NEW |