OLD | NEW |
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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 | 639 |
640 $header{nameSpaceWebCore}->addHeader("\nclass Dictionary;") if IsConstructor
Template($interface, "Event"); | 640 $header{nameSpaceWebCore}->addHeader("\nclass Dictionary;") if IsConstructor
Template($interface, "Event"); |
641 | 641 |
642 my $nativeType = GetNativeTypeForConversions($interface); | 642 my $nativeType = GetNativeTypeForConversions($interface); |
643 if ($interface->extendedAttributes->{"NamedConstructor"}) { | 643 if ($interface->extendedAttributes->{"NamedConstructor"}) { |
644 $header{nameSpaceWebCore}->addHeader(<<END); | 644 $header{nameSpaceWebCore}->addHeader(<<END); |
645 | 645 |
646 class V8${nativeType}Constructor { | 646 class V8${nativeType}Constructor { |
647 public: | 647 public: |
648 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor
ldType); | 648 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor
ldType); |
649 static WrapperTypeInfo wrapperTypeInfo; | 649 static const WrapperTypeInfo wrapperTypeInfo; |
650 }; | 650 }; |
651 END | 651 END |
652 } | 652 } |
653 | 653 |
654 $header{class}->addHeader("class $v8ClassName {"); | 654 $header{class}->addHeader("class $v8ClassName {"); |
655 $header{class}->addFooter("};"); | 655 $header{class}->addFooter("};"); |
656 | 656 |
657 $header{classPublic}->add(<<END); | 657 $header{classPublic}->add(<<END); |
658 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp
e); | 658 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp
e); |
659 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | 659 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
660 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor
ldType); | 660 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor
ldType); |
661 static ${nativeType}* toNative(v8::Handle<v8::Object> object) | 661 static ${nativeType}* toNative(v8::Handle<v8::Object> object) |
662 { | 662 { |
663 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); | 663 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); |
664 } | 664 } |
665 static void derefObject(void*); | 665 static void derefObject(void*); |
666 static WrapperTypeInfo wrapperTypeInfo; | 666 static const WrapperTypeInfo wrapperTypeInfo; |
667 END | 667 END |
668 | 668 |
669 if (NeedsOpaqueRootForGC($interface)) { | 669 if (NeedsOpaqueRootForGC($interface)) { |
670 $header{classPublic}->add(" static void* opaqueRootForGC(void*, v8::I
solate*);\n"); | 670 $header{classPublic}->add(" static void* opaqueRootForGC(void*, v8::I
solate*);\n"); |
671 } | 671 } |
672 | 672 |
673 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 673 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
674 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject
(v8::Handle<v8::Object>);\n"); | 674 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject
(v8::Handle<v8::Object>);\n"); |
675 } | 675 } |
676 | 676 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); | 820 friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); |
821 static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8
::Handle<v8::Object> creationContext, v8::Isolate*); | 821 static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8
::Handle<v8::Object> creationContext, v8::Isolate*); |
822 END | 822 END |
823 } | 823 } |
824 | 824 |
825 $header{nameSpaceWebCore}->add(<<END); | 825 $header{nameSpaceWebCore}->add(<<END); |
826 | 826 |
827 template<> | 827 template<> |
828 class WrapperTypeTraits<${nativeType} > { | 828 class WrapperTypeTraits<${nativeType} > { |
829 public: | 829 public: |
830 static WrapperTypeInfo* wrapperTypeInfo() { return &${v8ClassName}::wrapperT
ypeInfo; } | 830 static const WrapperTypeInfo* wrapperTypeInfo() { return &${v8ClassName}::wr
apperTypeInfo; } |
831 }; | 831 }; |
832 END | 832 END |
833 | 833 |
834 my $customWrap = NeedsSpecialWrap($interface); | 834 my $customWrap = NeedsSpecialWrap($interface); |
835 if ($noToV8) { | 835 if ($noToV8) { |
836 die "Can't suppress toV8 for subclass\n" if $interface->parent; | 836 die "Can't suppress toV8 for subclass\n" if $interface->parent; |
837 } elsif ($noWrap) { | 837 } elsif ($noWrap) { |
838 die "Must have custom toV8\n" if !$customWrap; | 838 die "Must have custom toV8\n" if !$customWrap; |
839 $header{nameSpaceWebCore}->add(<<END); | 839 $header{nameSpaceWebCore}->add(<<END); |
840 class ${nativeType}; | 840 class ${nativeType}; |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2884 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 2884 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
2885 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject"; | 2885 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject"; |
2886 } | 2886 } |
2887 | 2887 |
2888 my $toEventTarget = "0"; | 2888 my $toEventTarget = "0"; |
2889 if (InheritsInterface($interface, "EventTarget")) { | 2889 if (InheritsInterface($interface, "EventTarget")) { |
2890 $toEventTarget = "${v8ClassName}::toEventTarget"; | 2890 $toEventTarget = "${v8ClassName}::toEventTarget"; |
2891 } | 2891 } |
2892 | 2892 |
2893 $implementation{nameSpaceWebCore}->add(<<END); | 2893 $implementation{nameSpaceWebCore}->add(<<END); |
2894 WrapperTypeInfo ${v8ClassName}Constructor::wrapperTypeInfo = { ${v8ClassName}Con
structor::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent
Target, 0, ${v8ClassName}::installPerContextEnabledPrototypeProperties, 0, Wrapp
erTypeObjectPrototype }; | 2894 const WrapperTypeInfo ${v8ClassName}Constructor::wrapperTypeInfo = { ${v8ClassNa
me}Constructor::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $t
oEventTarget, 0, ${v8ClassName}::installPerContextEnabledPrototypeProperties, 0,
WrapperTypeObjectPrototype }; |
2895 | 2895 |
2896 END | 2896 END |
2897 | 2897 |
2898 my $code = ""; | 2898 my $code = ""; |
2899 $code .= <<END; | 2899 $code .= <<END; |
2900 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8:
:Value>& args) | 2900 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8:
:Value>& args) |
2901 { | 2901 { |
2902 END | 2902 END |
2903 $code .= $maybeObserveFeature if $maybeObserveFeature; | 2903 $code .= $maybeObserveFeature if $maybeObserveFeature; |
2904 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; | 2904 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3085 # Constructor | 3085 # Constructor |
3086 if ($isConstructor) { | 3086 if ($isConstructor) { |
3087 my $constructorType = $attribute->type; | 3087 my $constructorType = $attribute->type; |
3088 $constructorType =~ s/Constructor$//; | 3088 $constructorType =~ s/Constructor$//; |
3089 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. | 3089 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. |
3090 # We do not generate the header file for NamedConstructor of class XXXX, | 3090 # We do not generate the header file for NamedConstructor of class XXXX, |
3091 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. | 3091 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. |
3092 if ($constructorType !~ /Constructor$/ || $attribute->extendedAttributes
->{"CustomConstructor"}) { | 3092 if ($constructorType !~ /Constructor$/ || $attribute->extendedAttributes
->{"CustomConstructor"}) { |
3093 AddToImplIncludes("V8${constructorType}.h"); | 3093 AddToImplIncludes("V8${constructorType}.h"); |
3094 } | 3094 } |
3095 $data = "&V8${constructorType}::wrapperTypeInfo"; | 3095 $data = "const_cast<WrapperTypeInfo*>(&V8${constructorType}::wrapperType
Info)"; |
3096 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter
"; | 3096 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter
"; |
3097 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrib
uteSetterCallback"; | 3097 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrib
uteSetterCallback"; |
3098 $getterForMainWorld = "0"; | 3098 $getterForMainWorld = "0"; |
3099 $setterForMainWorld = "0"; | 3099 $setterForMainWorld = "0"; |
3100 } else { | 3100 } else { |
3101 # Default Getter and Setter | 3101 # Default Getter and Setter |
3102 $getter = "${implClassName}V8Internal::${attrName}AttributeGetterCallbac
k"; | 3102 $getter = "${implClassName}V8Internal::${attrName}AttributeGetterCallbac
k"; |
3103 $setter = "${implClassName}V8Internal::${attrName}AttributeSetterCallbac
k"; | 3103 $setter = "${implClassName}V8Internal::${attrName}AttributeSetterCallbac
k"; |
3104 $getterForMainWorld = "${getter}ForMainWorld"; | 3104 $getterForMainWorld = "${getter}ForMainWorld"; |
3105 $setterForMainWorld = "${setter}ForMainWorld"; | 3105 $setterForMainWorld = "${setter}ForMainWorld"; |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4038 $code .= <<END; | 4038 $code .= <<END; |
4039 { | 4039 { |
4040 WebCore::initializeScriptWrappableForInterface(object); | 4040 WebCore::initializeScriptWrappableForInterface(object); |
4041 } | 4041 } |
4042 | 4042 |
4043 namespace WebCore { | 4043 namespace WebCore { |
4044 END | 4044 END |
4045 $implementation{nameSpaceWebCore}->addHeader($code); | 4045 $implementation{nameSpaceWebCore}->addHeader($code); |
4046 } | 4046 } |
4047 | 4047 |
4048 my $code = "WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8ClassNam
e}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget
, "; | 4048 my $code = "const WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8Cl
assName}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent
Target, "; |
4049 $code .= "$rootForGC, ${v8ClassName}::installPerContextEnabledPrototypePrope
rties, $parentClassInfo, $WrapperTypePrototype };\n"; | 4049 $code .= "$rootForGC, ${v8ClassName}::installPerContextEnabledPrototypePrope
rties, $parentClassInfo, $WrapperTypePrototype };\n"; |
4050 $implementation{nameSpaceWebCore}->addHeader($code); | 4050 $implementation{nameSpaceWebCore}->addHeader($code); |
4051 | 4051 |
4052 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); | 4052 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); |
4053 | 4053 |
4054 my $hasConstructors = 0; | 4054 my $hasConstructors = 0; |
4055 my $hasReplaceable = 0; | 4055 my $hasReplaceable = 0; |
4056 | 4056 |
4057 # Generate property accessors for attributes. | 4057 # Generate property accessors for attributes. |
4058 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 4058 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4264 } elsif (IsConstructorTemplate($interface, "Event")) { | 4264 } elsif (IsConstructorTemplate($interface, "Event")) { |
4265 GenerateEventConstructor($interface); | 4265 GenerateEventConstructor($interface); |
4266 } | 4266 } |
4267 } | 4267 } |
4268 if (IsConstructable($interface)) { | 4268 if (IsConstructable($interface)) { |
4269 GenerateConstructorCallback($interface); | 4269 GenerateConstructorCallback($interface); |
4270 } | 4270 } |
4271 | 4271 |
4272 my $access_check = ""; | 4272 my $access_check = ""; |
4273 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "
Window") { | 4273 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "
Window") { |
4274 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int
ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8:
:External::New(&${v8ClassName}::wrapperTypeInfo));"; | 4274 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int
ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8:
:External::New(const_cast<WrapperTypeInfo*>(&${v8ClassName}::wrapperTypeInfo)));
"; |
4275 } | 4275 } |
4276 | 4276 |
4277 # For the Window interface, generate the shadow object template | 4277 # For the Window interface, generate the shadow object template |
4278 # configuration method. | 4278 # configuration method. |
4279 if ($interfaceName eq "Window") { | 4279 if ($interfaceName eq "Window") { |
4280 $implementation{nameSpaceWebCore}->add(<<END); | 4280 $implementation{nameSpaceWebCore}->add(<<END); |
4281 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ,
v8::Isolate* isolate, WrapperWorldType currentWorldType) | 4281 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ,
v8::Isolate* isolate, WrapperWorldType currentWorldType) |
4282 { | 4282 { |
4283 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>(
), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy
pe); | 4283 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>(
), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy
pe); |
4284 | 4284 |
4285 // Install a security handler with V8. | 4285 // Install a security handler with V8. |
4286 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(&V8Window::wrapperTypeInfo)); | 4286 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(const_cast<WrapperTypeInfo*>(&V8W
indow::wrapperTypeInfo))); |
4287 templ->SetInternalFieldCount(V8Window::internalFieldCount); | 4287 templ->SetInternalFieldCount(V8Window::internalFieldCount); |
4288 } | 4288 } |
4289 END | 4289 END |
4290 } | 4290 } |
4291 | 4291 |
4292 if (!$parentClassTemplate) { | 4292 if (!$parentClassTemplate) { |
4293 $parentClassTemplate = "v8::Local<v8::FunctionTemplate>()"; | 4293 $parentClassTemplate = "v8::Local<v8::FunctionTemplate>()"; |
4294 } | 4294 } |
4295 | 4295 |
4296 # Generate the template configuration method | 4296 # Generate the template configuration method |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4439 # Special cases | 4439 # Special cases |
4440 if ($interfaceName eq "Window") { | 4440 if ($interfaceName eq "Window") { |
4441 $code .= <<END; | 4441 $code .= <<END; |
4442 | 4442 |
4443 proto->SetInternalFieldCount(V8Window::internalFieldCount); | 4443 proto->SetInternalFieldCount(V8Window::internalFieldCount); |
4444 desc->SetHiddenPrototype(true); | 4444 desc->SetHiddenPrototype(true); |
4445 instance->SetInternalFieldCount(V8Window::internalFieldCount); | 4445 instance->SetInternalFieldCount(V8Window::internalFieldCount); |
4446 // Set access check callbacks, but turned off initially. | 4446 // Set access check callbacks, but turned off initially. |
4447 // When a context is detached from a frame, turn on the access check. | 4447 // When a context is detached from a frame, turn on the access check. |
4448 // Turning on checks also invalidates inline caches of the object. | 4448 // Turning on checks also invalidates inline caches of the object. |
4449 instance->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Wind
ow::indexedSecurityCheckCustom, v8::External::New(&V8Window::wrapperTypeInfo), f
alse); | 4449 instance->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Wind
ow::indexedSecurityCheckCustom, v8::External::New(const_cast<WrapperTypeInfo*>(&
V8Window::wrapperTypeInfo)), false); |
4450 END | 4450 END |
4451 } | 4451 } |
4452 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerGl
obalScope" or $interfaceName eq "SharedWorkerGlobalScope") { | 4452 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerGl
obalScope" or $interfaceName eq "SharedWorkerGlobalScope") { |
4453 $code .= <<END; | 4453 $code .= <<END; |
4454 desc->SetHiddenPrototype(true); | 4454 desc->SetHiddenPrototype(true); |
4455 END | 4455 END |
4456 } | 4456 } |
4457 | 4457 |
4458 $code .= <<END; | 4458 $code .= <<END; |
4459 | 4459 |
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6197 my $interface = shift; | 6197 my $interface = shift; |
6198 | 6198 |
6199 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6199 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6200 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6200 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6201 return 1 if InheritsInterface($interface, "Document"); | 6201 return 1 if InheritsInterface($interface, "Document"); |
6202 | 6202 |
6203 return 0; | 6203 return 0; |
6204 } | 6204 } |
6205 | 6205 |
6206 1; | 6206 1; |
OLD | NEW |