Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

Issue 12251015: Merge 141034 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 } 2611 }
2612 2612
2613 sub GenerateImplementation 2613 sub GenerateImplementation
2614 { 2614 {
2615 my $object = shift; 2615 my $object = shift;
2616 my $interface = shift; 2616 my $interface = shift;
2617 my $interfaceName = $interface->name; 2617 my $interfaceName = $interface->name;
2618 my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interfac e); 2618 my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interfac e);
2619 my $v8InterfaceName = "V8$interfaceName"; 2619 my $v8InterfaceName = "V8$interfaceName";
2620 my $nativeType = GetNativeTypeForConversions($interface); 2620 my $nativeType = GetNativeTypeForConversions($interface);
2621 my $vtableNameGnu = GetGnuVTableNameForInterface($interface);
2622 my $vtableRefGnu = GetGnuVTableRefForInterface($interface);
2623 my $vtableRefWin = GetWinVTableRefForInterface($interface);
2621 2624
2622 # - Add default header template 2625 # - Add default header template
2623 push(@implContentHeader, GenerateImplementationContentHeader($interface)); 2626 push(@implContentHeader, GenerateImplementationContentHeader($interface));
2624 2627
2625 AddToImplIncludes("BindingState.h"); 2628 AddToImplIncludes("BindingState.h");
2626 AddToImplIncludes("ContextFeatures.h"); 2629 AddToImplIncludes("ContextFeatures.h");
2627 AddToImplIncludes("RuntimeEnabledFeatures.h"); 2630 AddToImplIncludes("RuntimeEnabledFeatures.h");
2628 AddToImplIncludes("V8Binding.h"); 2631 AddToImplIncludes("V8Binding.h");
2629 AddToImplIncludes("V8DOMWrapper.h"); 2632 AddToImplIncludes("V8DOMWrapper.h");
2630 2633
2631 AddIncludesForType($interfaceName); 2634 AddIncludesForType($interfaceName);
2632 2635
2633 my $toActive = $interface->extendedAttributes->{"ActiveDOMObject"} ? "${v8In terfaceName}::toActiveDOMObject" : "0"; 2636 my $toActive = $interface->extendedAttributes->{"ActiveDOMObject"} ? "${v8In terfaceName}::toActiveDOMObject" : "0";
2634 my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName} ::opaqueRootForGC" : "0"; 2637 my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName} ::opaqueRootForGC" : "0";
2635 2638
2636 # Find the super descriptor. 2639 # Find the super descriptor.
2637 my $parentClass = ""; 2640 my $parentClass = "";
2638 my $parentClassTemplate = ""; 2641 my $parentClassTemplate = "";
2639 foreach (@{$interface->parents}) { 2642 foreach (@{$interface->parents}) {
2640 my $parent = $_; 2643 my $parent = $_;
2641 AddToImplIncludes("V8${parent}.h"); 2644 AddToImplIncludes("V8${parent}.h");
2642 $parentClass = "V8" . $parent; 2645 $parentClass = "V8" . $parent;
2643 $parentClassTemplate = $parentClass . "::GetTemplate()"; 2646 $parentClassTemplate = $parentClass . "::GetTemplate()";
2644 last; 2647 last;
2645 } 2648 }
2649
2650 push(@implContentDecls, <<END) if $vtableNameGnu;
2651 #if ENABLE(BINDING_INTEGRITY)
2652 #if defined(OS_WIN)
2653 #pragma warning(disable: 4483)
2654 extern "C" { extern void (*const ${vtableRefWin}[])(); }
2655 #else
2656 extern "C" { extern void* ${vtableNameGnu}[]; }
2657 #endif
2658 #endif // ENABLE(BINDING_INTEGRITY)
2659
2660 END
2661
2646 push(@implContentDecls, "namespace WebCore {\n\n"); 2662 push(@implContentDecls, "namespace WebCore {\n\n");
2663
2664 push(@implContentDecls, <<END) if $vtableNameGnu;
2665 #if ENABLE(BINDING_INTEGRITY)
2666 inline void checkTypeOrDieTrying(${nativeType}* object)
2667 {
2668 void* actualVTablePointer = *(reinterpret_cast<void**>(object));
2669 #if defined(OS_WIN)
2670 void* expectedVTablePointer = reinterpret_cast<void*>(${vtableRefWin});
2671 #else
2672 void* expectedVTablePointer = ${vtableRefGnu};
2673 #endif
2674 if (actualVTablePointer != expectedVTablePointer)
2675 CRASH();
2676 }
2677 #endif // ENABLE(BINDING_INTEGRITY)
2678
2679 END
2680
2681
2647 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; 2682 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0";
2648 2683
2649 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot ype" : "WrapperTypeObjectPrototype"; 2684 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot ype" : "WrapperTypeObjectPrototype";
2650 2685
2651 push(@implContentDecls, "WrapperTypeInfo ${v8InterfaceName}::info = { ${v8In terfaceName}::GetTemplate, ${v8InterfaceName}::derefObject, $toActive, $rootForG C, ${v8InterfaceName}::installPerContextPrototypeProperties, $parentClassInfo, $ WrapperTypePrototype };\n\n"); 2686 push(@implContentDecls, "WrapperTypeInfo ${v8InterfaceName}::info = { ${v8In terfaceName}::GetTemplate, ${v8InterfaceName}::derefObject, $toActive, $rootForG C, ${v8InterfaceName}::installPerContextPrototypeProperties, $parentClassInfo, $ WrapperTypePrototype };\n\n");
2652 push(@implContentDecls, "namespace ${interfaceName}V8Internal {\n\n"); 2687 push(@implContentDecls, "namespace ${interfaceName}V8Internal {\n\n");
2653 2688
2654 push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n"); 2689 push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n");
2655 2690
2656 my $hasConstructors = 0; 2691 my $hasConstructors = 0;
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
3452 { 3487 {
3453 my $interface = shift; 3488 my $interface = shift;
3454 my $v8InterfaceName = shift; 3489 my $v8InterfaceName = shift;
3455 my $nativeType = shift; 3490 my $nativeType = shift;
3456 my $interfaceName = $interface->name; 3491 my $interfaceName = $interface->name;
3457 3492
3458 if ($interface->extendedAttributes->{"V8NoWrapperCache"} || $interface->exte ndedAttributes->{"SuppressToJSObject"}) { 3493 if ($interface->extendedAttributes->{"V8NoWrapperCache"} || $interface->exte ndedAttributes->{"SuppressToJSObject"}) {
3459 return; 3494 return;
3460 } 3495 }
3461 3496
3497 AddToImplIncludes("Frame.h");
3498
3462 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); 3499 my $createWrapperArgumentType = GetPassRefPtrType($nativeType);
3463 my $baseType = BaseInterfaceName($interface); 3500 my $baseType = BaseInterfaceName($interface);
3464 3501
3465 push(@implContent, <<END); 3502 push(@implContent, <<END);
3466 3503
3467 v8::Handle<v8::Object> ${v8InterfaceName}::createWrapper(${createWrapperArgument Type} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 3504 v8::Handle<v8::Object> ${v8InterfaceName}::createWrapper(${createWrapperArgument Type} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
3468 { 3505 {
3469 ASSERT(impl.get()); 3506 ASSERT(impl.get());
3470 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); 3507 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty());
3471 END 3508 END
3472 if ($baseType ne $interfaceName) { 3509
3473 push(@implContent, <<END); 3510 my $vtableNameGnu = GetGnuVTableNameForInterface($interface);
3511 push(@implContent, <<END) if $vtableNameGnu;
3512
3513 #if ENABLE(BINDING_INTEGRITY)
3514 checkTypeOrDieTrying(impl.get());
3515 #endif
3516 END
3517
3518 push(@implContent, <<END) if ($baseType ne $interfaceName);
3474 ASSERT(static_cast<void*>(static_cast<${baseType}*>(impl.get())) == static_c ast<void*>(impl.get())); 3519 ASSERT(static_cast<void*>(static_cast<${baseType}*>(impl.get())) == static_c ast<void*>(impl.get()));
3475 END 3520 END
3476 }
3477
3478 AddToImplIncludes("Frame.h");
3479 3521
3480 if ($codeGenerator->IsSubType($interface, "Document")) { 3522 if ($codeGenerator->IsSubType($interface, "Document")) {
3481 push(@implContent, <<END); 3523 push(@implContent, <<END);
3482 if (Frame* frame = impl->frame()) { 3524 if (Frame* frame = impl->frame()) {
3483 if (frame->script()->initializeMainWorld()) { 3525 if (frame->script()->initializeMainWorld()) {
3484 // initializeMainWorld may have created a wrapper for the object, re try from the start. 3526 // initializeMainWorld may have created a wrapper for the object, re try from the start.
3485 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper(impl.get() , isolate); 3527 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper(impl.get() , isolate);
3486 if (!wrapper.IsEmpty()) 3528 if (!wrapper.IsEmpty())
3487 return wrapper; 3529 return wrapper;
3488 } 3530 }
(...skipping 13 matching lines...) Expand all
3502 wrapperHandle.MarkIndependent(); 3544 wrapperHandle.MarkIndependent();
3503 return wrapper; 3545 return wrapper;
3504 } 3546 }
3505 END 3547 END
3506 } 3548 }
3507 3549
3508 sub GetNativeTypeForConversions 3550 sub GetNativeTypeForConversions
3509 { 3551 {
3510 my $interface = shift; 3552 my $interface = shift;
3511 my $interfaceName = $interface->name; 3553 my $interfaceName = $interface->name;
3554 $interfaceName = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) if $codeGenerator->IsSVGTypeNeedingTearOff($interfaceName);
3555 return $interfaceName;
3556 }
3512 3557
3513 $interfaceName = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) if $codeGenerator->IsSVGTypeNeedingTearOff($interfaceName); 3558 # See http://refspecs.linux-foundation.org/cxxabi-1.83.html.
3514 return $interfaceName;; 3559 sub GetGnuVTableRefForInterface
3560 {
3561 my $interface = shift;
3562 my $vtableName = GetGnuVTableNameForInterface($interface);
3563 if (!$vtableName) {
3564 return "0";
3565 }
3566 my $typename = GetNativeTypeForConversions($interface);
3567 my $offset = GetGnuVTableOffsetForType($typename);
3568 return "&" . $vtableName . "[" . $offset . "]";
3569 }
3570
3571 sub GetGnuVTableNameForInterface
3572 {
3573 my $interface = shift;
3574 my $typename = GetNativeTypeForConversions($interface);
3575 my $templatePosition = index($typename, "<");
3576 return "" if $templatePosition != -1;
3577 return "" if GetImplementationLacksVTableForInterface($interface);
3578 return "" if GetV8SkipVTableValidationForInterface($interface);
3579 return "_ZTV" . GetGnuMangledNameForInterface($interface);
3580 }
3581
3582 sub GetGnuMangledNameForInterface
3583 {
3584 my $interface = shift;
3585 my $typename = GetNativeTypeForConversions($interface);
3586 my $templatePosition = index($typename, "<");
3587 if ($templatePosition != -1) {
3588 return "";
3589 }
3590 my $mangledType = length($typename) . $typename;
3591 my $namespace = GetNamespaceForInterface($interface);
3592 my $mangledNamespace = "N" . length($namespace) . $namespace;
3593 return $mangledNamespace . $mangledType . "E";
3594 }
3595
3596 sub GetGnuVTableOffsetForType
3597 {
3598 my $typename = shift;
3599 if ($typename eq "SVGAElement"
3600 || $typename eq "SVGCircleElement"
3601 || $typename eq "SVGClipPathElement"
3602 || $typename eq "SVGDefsElement"
3603 || $typename eq "SVGEllipseElement"
3604 || $typename eq "SVGForeignObjectElement"
3605 || $typename eq "SVGGElement"
3606 || $typename eq "SVGImageElement"
3607 || $typename eq "SVGLineElement"
3608 || $typename eq "SVGPathElement"
3609 || $typename eq "SVGPolyElement"
3610 || $typename eq "SVGPolygonElement"
3611 || $typename eq "SVGPolylineElement"
3612 || $typename eq "SVGRectElement"
3613 || $typename eq "SVGSVGElement"
3614 || $typename eq "SVGStyledLocatableElement"
3615 || $typename eq "SVGStyledTransformableElement"
3616 || $typename eq "SVGSwitchElement"
3617 || $typename eq "SVGTextElement"
3618 || $typename eq "SVGTransformable"
3619 || $typename eq "SVGUseElement") {
3620 return "3";
3621 }
3622 return "2";
3623 }
3624
3625 # See http://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B_Name_Mangling.
3626 sub GetWinVTableRefForInterface
3627 {
3628 my $interface = shift;
3629 my $vtableName = GetWinVTableNameForInterface($interface);
3630 return 0 if !$vtableName;
3631 return "__identifier(\"" . $vtableName . "\")";
3632 }
3633
3634 sub GetWinVTableNameForInterface
3635 {
3636 my $interface = shift;
3637 my $typename = GetNativeTypeForConversions($interface);
3638 my $templatePosition = index($typename, "<");
3639 return "" if $templatePosition != -1;
3640 return "" if GetImplementationLacksVTableForInterface($interface);
3641 return "" if GetV8SkipVTableValidationForInterface($interface);
3642 return "??_7" . GetWinMangledNameForInterface($interface) . "6B@";
3643 }
3644
3645 sub GetWinMangledNameForInterface
3646 {
3647 my $interface = shift;
3648 my $typename = GetNativeTypeForConversions($interface);
3649 my $namespace = GetNamespaceForInterface($interface);
3650 return $typename . "@" . $namespace . "@@";
3651 }
3652
3653 sub GetNamespaceForInterface
3654 {
3655 my $interface = shift;
3656 return $interface->extendedAttributes->{"ImplementationNamespace"} || "WebCo re";
3657 }
3658
3659 sub GetImplementationLacksVTableForInterface
3660 {
3661 my $interface = shift;
3662 return $interface->extendedAttributes->{"ImplementationLacksVTable"};
3663 }
3664
3665 sub GetV8SkipVTableValidationForInterface
3666 {
3667 my $interface = shift;
3668 return $interface->extendedAttributes->{"V8SkipVTableValidation"};
3515 } 3669 }
3516 3670
3517 sub GenerateFunctionCallString() 3671 sub GenerateFunctionCallString()
3518 { 3672 {
3519 my $function = shift; 3673 my $function = shift;
3520 my $numberOfParameters = shift; 3674 my $numberOfParameters = shift;
3521 my $indent = shift; 3675 my $indent = shift;
3522 my $interfaceName = shift; 3676 my $interfaceName = shift;
3523 my %replacements = @_; 3677 my %replacements = @_;
3524 3678
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
4239 4393
4240 sub GetPassRefPtrType 4394 sub GetPassRefPtrType
4241 { 4395 {
4242 my $v8InterfaceName = shift; 4396 my $v8InterfaceName = shift;
4243 4397
4244 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; 4398 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : "";
4245 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; 4399 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>";
4246 } 4400 }
4247 4401
4248 1; 4402 1;
OLDNEW
« no previous file with comments | « Source/WebCore/Modules/webdatabase/SQLTransactionSync.idl ('k') | Source/WebCore/bindings/scripts/IDLAttributes.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698