| 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 545 |
| 546 # FIXME: Expose indexed getter of WebKitCSSMixFunctionValue by removing this
special case | 546 # FIXME: Expose indexed getter of WebKitCSSMixFunctionValue by removing this
special case |
| 547 # because CSSValueList(which is parent of WebKitCSSMixFunctionValue) has ind
exed property getter. | 547 # because CSSValueList(which is parent of WebKitCSSMixFunctionValue) has ind
exed property getter. |
| 548 if ($interface->name eq "WebKitCSSMixFunctionValue") { | 548 if ($interface->name eq "WebKitCSSMixFunctionValue") { |
| 549 return 0; | 549 return 0; |
| 550 } | 550 } |
| 551 | 551 |
| 552 return GetSpecialAccessorFunctionForType($interface, "getter", "unsigned lon
g", 1); | 552 return GetSpecialAccessorFunctionForType($interface, "getter", "unsigned lon
g", 1); |
| 553 } | 553 } |
| 554 | 554 |
| 555 sub GetIndexedSetterFunction |
| 556 { |
| 557 my $interface = shift; |
| 558 |
| 559 return GetSpecialAccessorFunctionForType($interface, "setter", "unsigned lon
g", 2); |
| 560 } |
| 561 |
| 562 sub GetIndexedDeleterFunction |
| 563 { |
| 564 my $interface = shift; |
| 565 |
| 566 return GetSpecialAccessorFunctionForType($interface, "deleter", "unsigned lo
ng", 1); |
| 567 } |
| 568 |
| 555 sub GetNamedGetterFunction | 569 sub GetNamedGetterFunction |
| 556 { | 570 { |
| 557 my $interface = shift; | 571 my $interface = shift; |
| 558 return GetSpecialAccessorFunctionForType($interface, "getter", "DOMString",
1); | 572 return GetSpecialAccessorFunctionForType($interface, "getter", "DOMString",
1); |
| 559 } | 573 } |
| 560 | 574 |
| 561 sub GetNamedSetterFunction | 575 sub GetNamedSetterFunction |
| 562 { | 576 { |
| 563 my $interface = shift; | 577 my $interface = shift; |
| 564 return GetSpecialAccessorFunctionForType($interface, "setter", "DOMString",
2); | 578 return GetSpecialAccessorFunctionForType($interface, "setter", "DOMString",
2); |
| 565 } | 579 } |
| 566 | 580 |
| 581 sub GetNamedDeleterFunction |
| 582 { |
| 583 my $interface = shift; |
| 584 return GetSpecialAccessorFunctionForType($interface, "deleter", "DOMString",
1); |
| 585 } |
| 586 |
| 567 sub GetSpecialAccessorFunctionForType | 587 sub GetSpecialAccessorFunctionForType |
| 568 { | 588 { |
| 569 my $interface = shift; | 589 my $interface = shift; |
| 570 my $special = shift; | 590 my $special = shift; |
| 571 my $firstParameterType = shift; | 591 my $firstParameterType = shift; |
| 572 my $numberOfParameters = shift; | 592 my $numberOfParameters = shift; |
| 573 | 593 |
| 574 foreach my $function (@{$interface->functions}) { | 594 foreach my $function (@{$interface->functions}) { |
| 575 my $specials = $function->signature->specials; | 595 my $specials = $function->signature->specials; |
| 576 my $specialExists = grep { $_ eq $special } @$specials; | 596 my $specialExists = grep { $_ eq $special } @$specials; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 695 |
| 676 if ($interfaceName eq "DOMWindow") { | 696 if ($interfaceName eq "DOMWindow") { |
| 677 $header{classPublic}->add(<<END); | 697 $header{classPublic}->add(<<END); |
| 678 static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolat
e*, WrapperWorldType); | 698 static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolat
e*, WrapperWorldType); |
| 679 END | 699 END |
| 680 } | 700 } |
| 681 | 701 |
| 682 my @enabledPerContextFunctions; | 702 my @enabledPerContextFunctions; |
| 683 foreach my $function (@{$interface->functions}) { | 703 foreach my $function (@{$interface->functions}) { |
| 684 my $name = $function->signature->name; | 704 my $name = $function->signature->name; |
| 705 next if $name eq ""; |
| 685 my $attrExt = $function->signature->extendedAttributes; | 706 my $attrExt = $function->signature->extendedAttributes; |
| 686 | 707 |
| 687 if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $functi
on->{overloadIndex} == 1) { | 708 if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $functi
on->{overloadIndex} == 1) { |
| 688 my $conditionalString = GenerateConditionalString($function->signatu
re); | 709 my $conditionalString = GenerateConditionalString($function->signatu
re); |
| 689 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio
nalString; | 710 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio
nalString; |
| 690 $header{classPublic}->add(<<END); | 711 $header{classPublic}->add(<<END); |
| 691 static v8::Handle<v8::Value> ${name}MethodCustom(const v8::Arguments&); | 712 static v8::Handle<v8::Value> ${name}MethodCustom(const v8::Arguments&); |
| 692 END | 713 END |
| 693 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co
nditionalString; | 714 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co
nditionalString; |
| 694 } | 715 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 $header{classPublic}->add(<<END); | 977 $header{classPublic}->add(<<END); |
| 957 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + $
{customFieldCounter}; | 978 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + $
{customFieldCounter}; |
| 958 END | 979 END |
| 959 } | 980 } |
| 960 | 981 |
| 961 sub GenerateHeaderNamedAndIndexedPropertyAccessors | 982 sub GenerateHeaderNamedAndIndexedPropertyAccessors |
| 962 { | 983 { |
| 963 my $interface = shift; | 984 my $interface = shift; |
| 964 | 985 |
| 965 my $indexedGetterFunction = GetIndexedGetterFunction($interface); | 986 my $indexedGetterFunction = GetIndexedGetterFunction($interface); |
| 966 my $hasCustomIndexedGetter = $interface->extendedAttributes->{"CustomIndexed
Getter"}; | 987 my $hasCustomIndexedGetter = $indexedGetterFunction ? $indexedGetterFunction
->signature->extendedAttributes->{"Custom"} : 0; |
| 967 my $hasIndexedGetter = $indexedGetterFunction || $hasCustomIndexedGetter; | |
| 968 | 988 |
| 969 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed
Setter"}; | 989 my $indexedSetterFunction = GetIndexedSetterFunction($interface); |
| 990 my $hasCustomIndexedSetter = $indexedSetterFunction ? $indexedSetterFunction
->signature->extendedAttributes->{"Custom"} : 0; |
| 991 |
| 992 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface); |
| 993 my $hasCustomIndexedDeleters = $indexedDeleterFunction ? $indexedDeleterFunc
tion->signature->extendedAttributes->{"Custom"} : 0; |
| 970 | 994 |
| 971 my $namedGetterFunction = GetNamedGetterFunction($interface); | 995 my $namedGetterFunction = GetNamedGetterFunction($interface); |
| 972 my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGett
er"}; | 996 my $hasCustomNamedGetter = $namedGetterFunction ? $namedGetterFunction->sign
ature->extendedAttributes->{"Custom"} : 0; |
| 973 my $hasNamedGetter = $namedGetterFunction || $hasCustomNamedGetter; | |
| 974 | 997 |
| 975 my $namedSetterFunction = GetNamedSetterFunction($interface); | 998 my $namedSetterFunction = GetNamedSetterFunction($interface); |
| 976 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSett
er"}; | 999 my $hasCustomNamedSetter = $namedSetterFunction ? $namedSetterFunction->sign
ature->extendedAttributes->{"Custom"} : 0; |
| 977 my $hasNamedSetter = $namedSetterFunction || $hasCustomNamedSetter; | |
| 978 | 1000 |
| 979 my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProper
ty"}; | 1001 my $namedDeleterFunction = GetNamedDeleterFunction($interface); |
| 1002 my $hasCustomNamedDeleters = $namedDeleterFunction ? $namedSetterFunction->s
ignature->extendedAttributes->{"Custom"} : 0; |
| 980 | 1003 |
| 981 my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateP
roperty"}; | 1004 my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateP
roperty"}; |
| 982 | 1005 |
| 983 if ($hasIndexedGetter) { | 1006 if ($indexedGetterFunction) { |
| 984 $header{classPublic}->add(<<END); | 1007 $header{classPublic}->add(<<END); |
| 985 static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::Acces
sorInfo&); | 1008 static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::Acces
sorInfo&); |
| 986 END | 1009 END |
| 987 } | 1010 } |
| 988 | 1011 |
| 989 if ($hasCustomIndexedSetter) { | 1012 if ($indexedSetterFunction) { |
| 990 $header{classPublic}->add(<<END); | 1013 $header{classPublic}->add(<<END); |
| 991 static v8::Handle<v8::Value> indexedPropertySetter(uint32_t, v8::Local<v8::V
alue>, const v8::AccessorInfo&); | 1014 static v8::Handle<v8::Value> indexedPropertySetter(uint32_t, v8::Local<v8::V
alue>, const v8::AccessorInfo&); |
| 992 END | 1015 END |
| 993 } | 1016 } |
| 994 if ($hasCustomDeleters) { | 1017 if ($indexedDeleterFunction) { |
| 995 $header{classPublic}->add(<<END); | 1018 $header{classPublic}->add(<<END); |
| 996 static v8::Handle<v8::Boolean> indexedPropertyDeleter(uint32_t, const v8::Ac
cessorInfo&); | 1019 static v8::Handle<v8::Boolean> indexedPropertyDeleter(uint32_t, const v8::Ac
cessorInfo&); |
| 997 END | 1020 END |
| 998 } | 1021 } |
| 999 if ($hasNamedGetter) { | 1022 if ($namedGetterFunction) { |
| 1000 $header{classPublic}->add(<<END); | 1023 $header{classPublic}->add(<<END); |
| 1001 static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String>, cons
t v8::AccessorInfo&); | 1024 static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String>, cons
t v8::AccessorInfo&); |
| 1002 END | 1025 END |
| 1003 } | 1026 } |
| 1004 if ($hasNamedSetter) { | 1027 if ($namedSetterFunction) { |
| 1005 $header{classPublic}->add(<<END); | 1028 $header{classPublic}->add(<<END); |
| 1006 static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8::
Local<v8::Value>, const v8::AccessorInfo&); | 1029 static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8::
Local<v8::Value>, const v8::AccessorInfo&); |
| 1007 END | 1030 END |
| 1008 } | 1031 } |
| 1009 if ($hasCustomDeleters) { | 1032 if ($namedDeleterFunction) { |
| 1010 $header{classPublic}->add(<<END); | 1033 $header{classPublic}->add(<<END); |
| 1011 static v8::Handle<v8::Boolean> namedPropertyDeleter(v8::Local<v8::String>, c
onst v8::AccessorInfo&); | 1034 static v8::Handle<v8::Boolean> namedPropertyDeleter(v8::Local<v8::String>, c
onst v8::AccessorInfo&); |
| 1012 END | 1035 END |
| 1013 } | 1036 } |
| 1014 if ($hasCustomEnumerator) { | 1037 if ($hasCustomEnumerator) { |
| 1015 $header{classPublic}->add(<<END); | 1038 $header{classPublic}->add(<<END); |
| 1016 static v8::Handle<v8::Array> namedPropertyEnumerator(const v8::AccessorInfo&
); | 1039 static v8::Handle<v8::Array> namedPropertyEnumerator(const v8::AccessorInfo&
); |
| 1017 static v8::Handle<v8::Integer> namedPropertyQuery(v8::Local<v8::String>, con
st v8::AccessorInfo&); | 1040 static v8::Handle<v8::Integer> namedPropertyQuery(v8::Local<v8::String>, con
st v8::AccessorInfo&); |
| 1018 END | 1041 END |
| 1019 } | 1042 } |
| (...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3039 } | 3062 } |
| 3040 if (IsRefPtrType($type)) { | 3063 if (IsRefPtrType($type)) { |
| 3041 return "!${variableName}"; | 3064 return "!${variableName}"; |
| 3042 } elsif ($type eq "DOMString") { | 3065 } elsif ($type eq "DOMString") { |
| 3043 return "${variableName}.isNull()"; | 3066 return "${variableName}.isNull()"; |
| 3044 } else { | 3067 } else { |
| 3045 return ""; | 3068 return ""; |
| 3046 } | 3069 } |
| 3047 } | 3070 } |
| 3048 | 3071 |
| 3049 sub GenerateImplementationIndexedProperty | 3072 sub GenerateImplementationIndexedPropertyAccessors |
| 3050 { | 3073 { |
| 3051 my $interface = shift; | 3074 my $interface = shift; |
| 3052 my $interfaceName = $interface->name; | 3075 my $interfaceName = $interface->name; |
| 3053 my $implClassName = GetImplName($interface); | 3076 my $implClassName = GetImplName($interface); |
| 3054 my $v8ClassName = GetV8ClassName($interface); | 3077 my $v8ClassName = GetV8ClassName($interface); |
| 3055 | 3078 |
| 3056 my $indexedGetterFunction = GetIndexedGetterFunction($interface); | 3079 my $indexedGetterFunction = GetIndexedGetterFunction($interface); |
| 3057 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed
Setter"}; | 3080 my $hasCustomIndexedGetter = $indexedGetterFunction ? $indexedGetterFunction
->signature->extendedAttributes->{"Custom"} : 0; |
| 3058 my $hasCustomIndexedGetter = $interface->extendedAttributes->{"CustomIndexed
Getter"}; | 3081 if ($indexedGetterFunction && !$hasCustomIndexedGetter) { |
| 3059 | 3082 GenerateImplementationIndexedPropertyGetter($interface, $indexedGetterFu
nction); |
| 3060 if (!$indexedGetterFunction && !$hasCustomIndexedGetter) { | |
| 3061 return ""; | |
| 3062 } | 3083 } |
| 3063 | 3084 |
| 3064 my $hasEnumerator = 1; | 3085 # FIXME: Support generated indexed setter bindings. |
| 3086 my $indexedSetterFunction = GetIndexedSetterFunction($interface); |
| 3087 my $hasCustomIndexedSetter = $indexedSetterFunction ? $indexedSetterFunction
->signature->extendedAttributes->{"Custom"} : 0; |
| 3088 |
| 3089 # FIXME: Support generated named deleter bindings. |
| 3090 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface); |
| 3091 my $hasCustomIndexedDeleter = $indexedDeleterFunction ? $indexedDeleterFunct
ion->signature->extendedAttributes->{"Custom"} : 0; |
| 3092 |
| 3093 # FIXME: Support generated named enumerator bindings. |
| 3094 my $hasEnumerator = $indexedGetterFunction; |
| 3065 # FIXME: Remove the special cases. Interfaces that have indexedPropertyGette
r should have indexedPropertyEnumerator. | 3095 # FIXME: Remove the special cases. Interfaces that have indexedPropertyGette
r should have indexedPropertyEnumerator. |
| 3066 $hasEnumerator = 0 if $interfaceName eq "WebKitCSSKeyframesRule"; | 3096 $hasEnumerator = 0 if $interfaceName eq "WebKitCSSKeyframesRule"; |
| 3067 $hasEnumerator = 0 if $interfaceName eq "HTMLAppletElement"; | 3097 $hasEnumerator = 0 if $interfaceName eq "HTMLAppletElement"; |
| 3068 $hasEnumerator = 0 if $interfaceName eq "HTMLEmbedElement"; | 3098 $hasEnumerator = 0 if $interfaceName eq "HTMLEmbedElement"; |
| 3069 $hasEnumerator = 0 if $interfaceName eq "HTMLObjectElement"; | 3099 $hasEnumerator = 0 if $interfaceName eq "HTMLObjectElement"; |
| 3070 $hasEnumerator = 0 if $interfaceName eq "DOMWindow"; | 3100 $hasEnumerator = 0 if $interfaceName eq "DOMWindow"; |
| 3071 $hasEnumerator = 0 if $interfaceName eq "Storage"; | 3101 $hasEnumerator = 0 if $interfaceName eq "Storage"; |
| 3072 | 3102 |
| 3073 AddToImplIncludes("bindings/v8/V8Collection.h"); | |
| 3074 | 3103 |
| 3075 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"}; | 3104 # FIXME: Support generated named query bindings. |
| 3105 my $indexedQueryFunction = 0; |
| 3106 # If there is an enumerator, there MUST be a query method to properly commun
icate property attributes. |
| 3107 my $hasQuery = $indexedQueryFunction || $hasEnumerator; |
| 3108 |
| 3076 my $setOn = "Instance"; | 3109 my $setOn = "Instance"; |
| 3077 | 3110 |
| 3078 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba
cks) and it's used on DOMWindow | 3111 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba
cks) and it's used on DOMWindow |
| 3079 # instead of deleters or enumerators. In addition, the getter should be set
on prototype template, to | 3112 # instead of deleters or enumerators. In addition, the getter should be set
on prototype template, to |
| 3080 # get implementation straight out of the DOMWindow prototype regardless of w
hat prototype is actually set | 3113 # get implementation straight out of the DOMWindow prototype regardless of w
hat prototype is actually set |
| 3081 # on the object. | 3114 # on the object. |
| 3082 if ($interfaceName eq "DOMWindow") { | 3115 if ($interfaceName eq "DOMWindow") { |
| 3083 $setOn = "Prototype"; | 3116 $setOn = "Prototype"; |
| 3084 } | 3117 } |
| 3085 | 3118 |
| 3086 my $code = ""; | 3119 my $code = ""; |
| 3087 $code .= " desc->${setOn}Template()->SetIndexedPropertyHandler(${v8ClassN
ame}::indexedPropertyGetter"; | 3120 if ($indexedGetterFunction || $indexedSetterFunction || $indexedDeleterFunct
ion || $hasEnumerator || $hasQuery) { |
| 3088 $code .= $hasCustomIndexedSetter ? ", ${v8ClassName}::indexedPropertySetter"
: ", 0"; | 3121 $code .= " desc->${setOn}Template()->SetIndexedPropertyHandler(${v8Cl
assName}::indexedPropertyGetter"; |
| 3089 $code .= ", 0"; # IndexedPropertyQuery -- not being used at the moment. | 3122 $code .= $indexedSetterFunction ? ", ${v8ClassName}::indexedPropertySett
er" : ", 0"; |
| 3090 $code .= $hasDeleter ? ", ${v8ClassName}::indexedPropertyDeleter" : ", 0"; | 3123 $code .= ", 0"; # IndexedPropertyQuery -- not being used at the moment. |
| 3091 $code .= ", nodeCollectionIndexedPropertyEnumerator<${implClassName}>" if $h
asEnumerator; | 3124 $code .= $indexedDeleterFunction ? ", ${v8ClassName}::indexedPropertyDel
eter" : ", 0"; |
| 3092 $code .= ");\n"; | 3125 $code .= ", nodeCollectionIndexedPropertyEnumerator<${implClassName}>" i
f $hasEnumerator; |
| 3126 $code .= ");\n"; |
| 3127 } |
| 3093 | 3128 |
| 3094 if ($indexedGetterFunction && !$hasCustomIndexedGetter) { | 3129 return $code; |
| 3095 my $returnType = $indexedGetterFunction->signature->type; | 3130 } |
| 3096 my $nativeType = GetNativeType($returnType); | 3131 |
| 3097 my $methodName = GetImplName($indexedGetterFunction->signature); | 3132 sub GenerateImplementationIndexedPropertyGetter |
| 3098 AddToImplIncludes("bindings/v8/V8Collection.h"); | 3133 { |
| 3099 my $nativeValue = "element"; | 3134 my $interface = shift; |
| 3100 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); | 3135 my $indexedGetterFunction = shift; |
| 3101 my $isNull = GenerateIsNullExpression($returnType, "element"); | 3136 my $implClassName = GetImplName($interface); |
| 3102 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->signatur
e->type, $indexedGetterFunction->signature->extendedAttributes, $nativeValue, "
", "return", "info.Holder()", "info.GetIsolate()", "info", "collection"); | 3137 my $v8ClassName = GetV8ClassName($interface); |
| 3103 my $raisesExceptions = $indexedGetterFunction->signature->extendedAttrib
utes->{"RaisesException"}; | 3138 my $methodName = GetImplName($indexedGetterFunction->signature); |
| 3104 my $methodCallCode = GenerateMethodCall($returnType, "element", "collect
ion->${methodName}", "index", $raisesExceptions); | 3139 |
| 3105 my $getterCode = "v8::Handle<v8::Value> ${v8ClassName}::indexedPropertyG
etter(uint32_t index, const v8::AccessorInfo& info)\n"; | 3140 AddToImplIncludes("bindings/v8/V8Collection.h"); |
| 3106 $getterCode .= "{\n"; | 3141 my $returnType = $indexedGetterFunction->signature->type; |
| 3107 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()))
;\n"; | 3142 my $nativeType = GetNativeType($returnType); |
| 3108 $getterCode .= " ${implClassName}* collection = toNative(info.Holder(
));\n"; | 3143 my $nativeValue = "element"; |
| 3109 if ($raisesExceptions) { | 3144 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); |
| 3110 $getterCode .= " ExceptionCode ec = 0;\n"; | 3145 my $isNull = GenerateIsNullExpression($returnType, "element"); |
| 3111 } | 3146 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->signature->t
ype, $indexedGetterFunction->signature->extendedAttributes, $nativeValue, " "
, "return", "info.Holder()", "info.GetIsolate()", "info", "collection"); |
| 3112 $getterCode .= $methodCallCode . "\n"; | 3147 my $raisesExceptions = $indexedGetterFunction->signature->extendedAttributes
->{"RaisesException"}; |
| 3113 if ($raisesExceptions) { | 3148 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection-
>${methodName}", "index", $raisesExceptions); |
| 3114 $getterCode .= " if (ec)\n"; | 3149 my $getterCode = "v8::Handle<v8::Value> ${v8ClassName}::indexedPropertyGette
r(uint32_t index, const v8::AccessorInfo& info)\n"; |
| 3115 $getterCode .= " return setDOMException(ec, info.GetIsolate()
);\n"; | 3150 $getterCode .= "{\n"; |
| 3116 } | 3151 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n"
; |
| 3117 if (IsUnionType($returnType)) { | 3152 $getterCode .= " ${implClassName}* collection = toNative(info.Holder());\
n"; |
| 3118 $getterCode .= "${returnJSValueCode}\n"; | 3153 if ($raisesExceptions) { |
| 3119 $getterCode .= " return v8Undefined();\n"; | 3154 $getterCode .= " ExceptionCode ec = 0;\n"; |
| 3120 } else { | |
| 3121 $getterCode .= " if (${isNull})\n"; | |
| 3122 $getterCode .= " return v8Undefined();\n"; | |
| 3123 $getterCode .= $returnJSValueCode . "\n"; | |
| 3124 } | |
| 3125 $getterCode .= "}\n\n"; | |
| 3126 $implementation{nameSpaceWebCore}->add($getterCode); | |
| 3127 } | 3155 } |
| 3128 return $code; | 3156 $getterCode .= $methodCallCode . "\n"; |
| 3157 if ($raisesExceptions) { |
| 3158 $getterCode .= " if (ec)\n"; |
| 3159 $getterCode .= " return setDOMException(ec, info.GetIsolate());\n
"; |
| 3160 } |
| 3161 if (IsUnionType($returnType)) { |
| 3162 $getterCode .= "${returnJSValueCode}\n"; |
| 3163 $getterCode .= " return v8Undefined();\n"; |
| 3164 } else { |
| 3165 $getterCode .= " if (${isNull})\n"; |
| 3166 $getterCode .= " return v8Undefined();\n"; |
| 3167 $getterCode .= $returnJSValueCode . "\n"; |
| 3168 } |
| 3169 $getterCode .= "}\n\n"; |
| 3170 $implementation{nameSpaceWebCore}->add($getterCode); |
| 3129 } | 3171 } |
| 3130 | 3172 |
| 3131 sub GenerateImplementationNamedPropertyAccessors | 3173 sub GenerateImplementationNamedPropertyAccessors |
| 3132 { | 3174 { |
| 3133 my $interface = shift; | 3175 my $interface = shift; |
| 3134 | 3176 |
| 3135 my $interfaceName = $interface->name; | 3177 my $interfaceName = $interface->name; |
| 3136 my $implClassName = GetImplName($interface); | 3178 my $implClassName = GetImplName($interface); |
| 3137 my $v8ClassName = GetV8ClassName($interface); | 3179 my $v8ClassName = GetV8ClassName($interface); |
| 3138 | 3180 |
| 3139 my $namedGetterFunction = GetNamedGetterFunction($interface); | 3181 my $namedGetterFunction = GetNamedGetterFunction($interface); |
| 3140 my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGett
er"}; | 3182 my $hasCustomNamedGetter = $namedGetterFunction ? $namedGetterFunction->sign
ature->extendedAttributes->{"Custom"} : 0; |
| 3141 my $hasGetter = $namedGetterFunction || $hasCustomNamedGetter; | 3183 my $hasGetter = $namedGetterFunction; |
| 3142 if ($namedGetterFunction && !$hasCustomNamedGetter) { | 3184 if ($namedGetterFunction && !$hasCustomNamedGetter) { |
| 3143 GenerateImplementationNamedPropertyGetter($interface, $namedGetterFuncti
on); | 3185 GenerateImplementationNamedPropertyGetter($interface, $namedGetterFuncti
on); |
| 3144 } | 3186 } |
| 3145 | 3187 |
| 3146 my $namedSetterFunction = GetNamedSetterFunction($interface); | 3188 my $namedSetterFunction = GetNamedSetterFunction($interface); |
| 3147 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSett
er"}; | 3189 my $hasCustomNamedSetter = $namedSetterFunction ? $namedSetterFunction->sign
ature->extendedAttributes->{"Custom"} : 0; |
| 3148 my $hasSetter = $namedSetterFunction || $hasCustomNamedSetter; | 3190 my $hasSetter = $namedSetterFunction; |
| 3149 if ($namedSetterFunction && !$hasCustomNamedSetter) { | 3191 if ($namedSetterFunction && !$hasCustomNamedSetter) { |
| 3150 GenerateImplementationNamedPropertySetter($interface, $namedSetterFuncti
on); | 3192 GenerateImplementationNamedPropertySetter($interface, $namedSetterFuncti
on); |
| 3151 } | 3193 } |
| 3152 | 3194 |
| 3153 # FIXME: Support generated named deleter bindings. | 3195 # FIXME: Support generated named deleter bindings. |
| 3154 my $namedDeleterFunction = 0; | 3196 my $namedDeleterFunction = GetNamedDeleterFunction($interface); |
| 3155 my $hasCustomNamedDeleter = $interface->extendedAttributes->{"CustomDeletePr
operty"}; | 3197 my $hasCustomNamedDeleters = $namedDeleterFunction ? $namedSetterFunction->s
ignature->extendedAttributes->{"Custom"} : 0; |
| 3156 my $hasDeleter = $namedDeleterFunction || $hasCustomNamedDeleter; | 3198 my $hasDeleter = $namedDeleterFunction; |
| 3157 | 3199 |
| 3158 # FIXME: Support generated named enumerator bindings. | 3200 # FIXME: Support generated named enumerator bindings. |
| 3159 my $namedEnumeratorFunction = 0; | 3201 my $namedEnumeratorFunction = 0; |
| 3160 my $hasCustomNamedEnumerator = $interface->extendedAttributes->{"CustomEnume
rateProperty"}; | 3202 my $hasCustomNamedEnumerator = $interface->extendedAttributes->{"CustomEnume
rateProperty"}; |
| 3161 my $hasEnumerator = $namedEnumeratorFunction || $hasCustomNamedEnumerator; | 3203 my $hasEnumerator = $namedEnumeratorFunction || $hasCustomNamedEnumerator; |
| 3162 | 3204 |
| 3163 # FIXME: Support generated named query bindings. | 3205 # FIXME: Support generated named query bindings. |
| 3164 my $namedQueryFunction = 0; | 3206 my $namedQueryFunction = 0; |
| 3165 # If there is an enumerator, there MUST be a query method to properly commun
icate property attributes. | 3207 # If there is an enumerator, there MUST be a query method to properly commun
icate property attributes. |
| 3166 my $hasQuery = $namedQueryFunction || $hasEnumerator; | 3208 my $hasQuery = $namedQueryFunction || $hasEnumerator; |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3786 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 3828 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 3787 $code .= " if (${enable_function}()) {\n"; | 3829 $code .= " if (${enable_function}()) {\n"; |
| 3788 $code .= <<END; | 3830 $code .= <<END; |
| 3789 static const V8DOMConfiguration::BatchedConstant constData = {"${name}",
static_cast<signed int>(${value})}; | 3831 static const V8DOMConfiguration::BatchedConstant constData = {"${name}",
static_cast<signed int>(${value})}; |
| 3790 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1,
isolate); | 3832 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1,
isolate); |
| 3791 END | 3833 END |
| 3792 $code .= " }\n"; | 3834 $code .= " }\n"; |
| 3793 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; | 3835 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; |
| 3794 } | 3836 } |
| 3795 | 3837 |
| 3796 $code .= GenerateImplementationIndexedProperty($interface); | 3838 $code .= GenerateImplementationIndexedPropertyAccessors($interface); |
| 3797 $code .= GenerateImplementationNamedPropertyAccessors($interface); | 3839 $code .= GenerateImplementationNamedPropertyAccessors($interface); |
| 3798 $code .= GenerateImplementationLegacyCall($interface); | 3840 $code .= GenerateImplementationLegacyCall($interface); |
| 3799 $code .= GenerateImplementationMasqueradesAsUndefined($interface); | 3841 $code .= GenerateImplementationMasqueradesAsUndefined($interface); |
| 3800 | 3842 |
| 3801 # Define our functions with Set() or SetAccessor() | 3843 # Define our functions with Set() or SetAccessor() |
| 3802 my $total_functions = 0; | 3844 my $total_functions = 0; |
| 3803 foreach my $function (@normalFunctions) { | 3845 foreach my $function (@normalFunctions) { |
| 3804 # Only one accessor is needed for overloaded methods: | 3846 # Only one accessor is needed for overloaded methods: |
| 3805 next if $function->{overloadIndex} > 1; | 3847 next if $function->{overloadIndex} > 1; |
| 3806 next if $function->signature->name eq ""; | 3848 next if $function->signature->name eq ""; |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5448 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5490 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 5449 $found = 1; | 5491 $found = 1; |
| 5450 } | 5492 } |
| 5451 return 1 if $found; | 5493 return 1 if $found; |
| 5452 }, 0); | 5494 }, 0); |
| 5453 | 5495 |
| 5454 return $found; | 5496 return $found; |
| 5455 } | 5497 } |
| 5456 | 5498 |
| 5457 1; | 5499 1; |
| OLD | NEW |