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 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2132 | 2132 |
2133 if ($raisesExceptions) { | 2133 if ($raisesExceptions) { |
2134 push(@implContentInternals, " fail:\n"); | 2134 push(@implContentInternals, " fail:\n"); |
2135 push(@implContentInternals, " return setDOMException(ec, args.GetIsol ate());\n"); | 2135 push(@implContentInternals, " return setDOMException(ec, args.GetIsol ate());\n"); |
2136 } | 2136 } |
2137 | 2137 |
2138 push(@implContentInternals, "}\n"); | 2138 push(@implContentInternals, "}\n"); |
2139 push(@implContentInternals, "\n"); | 2139 push(@implContentInternals, "\n"); |
2140 } | 2140 } |
2141 | 2141 |
2142 sub GetConstructorLength | |
2143 { | |
2144 my $interface = shift; | |
2145 | |
2146 my $numberOfConstructorParameters = $interface->extendedAttributes->{"Constr uctorParameters"}; | |
2147 if (!defined $numberOfConstructorParameters) { | |
2148 if ($codeGenerator->IsConstructorTemplate($interface, "Event")) { | |
2149 $numberOfConstructorParameters = 2; | |
2150 } elsif ($codeGenerator->IsConstructorTemplate($interface, "TypedArray") ) { | |
2151 $numberOfConstructorParameters = 1; | |
2152 } elsif ($interface->extendedAttributes->{"Constructor"}) { | |
2153 my @constructors = @{$interface->constructors}; | |
2154 $numberOfConstructorParameters = 255; | |
2155 foreach my $constructor (@constructors) { | |
2156 my $currNumberOfParameters = @{$constructor->parameters}; | |
2157 if ($currNumberOfParameters < $numberOfConstructorParameters) { | |
2158 $numberOfConstructorParameters = $currNumberOfParameters; | |
haraken
2013/04/16 00:29:31
I'm not sure if this is correct. Per the spec, it
do-not-use
2013/04/16 07:26:23
Sorry, could you point me to the part where it say
do-not-use
2013/04/16 09:39:20
Actually, the latest Editor Draft matches the beha
| |
2159 } | |
2160 } | |
2161 } | |
2162 } | |
2163 | |
2164 return $numberOfConstructorParameters; | |
2165 } | |
2166 | |
2142 sub GenerateConstructorCallback | 2167 sub GenerateConstructorCallback |
2143 { | 2168 { |
2144 my $interface = shift; | 2169 my $interface = shift; |
2145 | 2170 |
2146 my $interfaceName = $interface->name; | 2171 my $interfaceName = $interface->name; |
2147 push(@implContent, "v8::Handle<v8::Value> V8${interfaceName}::constructorCal lback(const v8::Arguments& args)\n"); | 2172 push(@implContent, "v8::Handle<v8::Value> V8${interfaceName}::constructorCal lback(const v8::Arguments& args)\n"); |
2148 push(@implContent, "{\n"); | 2173 push(@implContent, "{\n"); |
2149 push(@implContent, GenerateFeatureObservation($interface->extendedAttributes ->{"MeasureAs"})); | 2174 push(@implContent, GenerateFeatureObservation($interface->extendedAttributes ->{"MeasureAs"})); |
2150 push(@implContent, GenerateConstructorHeader()); | 2175 push(@implContent, GenerateConstructorHeader()); |
2151 if (HasCustomConstructor($interface)) { | 2176 if (HasCustomConstructor($interface)) { |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3041 next if !IsStandardFunction($interface, $function); | 3066 next if !IsStandardFunction($interface, $function); |
3042 if (!$has_callbacks) { | 3067 if (!$has_callbacks) { |
3043 $has_callbacks = 1; | 3068 $has_callbacks = 1; |
3044 push(@implContent, "static const V8DOMConfiguration::BatchedMethod $ {v8InterfaceName}Methods[] = {\n"); | 3069 push(@implContent, "static const V8DOMConfiguration::BatchedMethod $ {v8InterfaceName}Methods[] = {\n"); |
3045 } | 3070 } |
3046 my $name = $function->signature->name; | 3071 my $name = $function->signature->name; |
3047 my $methodForMainWorld = "0"; | 3072 my $methodForMainWorld = "0"; |
3048 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { | 3073 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { |
3049 $methodForMainWorld = "${interfaceName}V8Internal::${name}MethodCall backForMainWorld"; | 3074 $methodForMainWorld = "${interfaceName}V8Internal::${name}MethodCall backForMainWorld"; |
3050 } | 3075 } |
3076 my $numParams = @{$function->parameters}; | |
3051 my $conditionalString = $codeGenerator->GenerateConditionalString($funct ion->signature); | 3077 my $conditionalString = $codeGenerator->GenerateConditionalString($funct ion->signature); |
3052 push(@implContent, "#if ${conditionalString}\n") if $conditionalString; | 3078 push(@implContent, "#if ${conditionalString}\n") if $conditionalString; |
3053 push(@implContent, <<END); | 3079 push(@implContent, <<END); |
3054 {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMain World}}, | 3080 {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMain World}, ${numParams}}, |
3055 END | 3081 END |
3056 push(@implContent, "#endif\n") if $conditionalString; | 3082 push(@implContent, "#endif\n") if $conditionalString; |
3057 $num_callbacks++; | 3083 $num_callbacks++; |
3058 } | 3084 } |
3059 push(@implContent, "};\n\n") if $has_callbacks; | 3085 push(@implContent, "};\n\n") if $has_callbacks; |
3060 | 3086 |
3061 # Setup constants | 3087 # Setup constants |
3062 my $has_constants = 0; | 3088 my $has_constants = 0; |
3063 my @constantsEnabledAtRuntime; | 3089 my @constantsEnabledAtRuntime; |
3064 if (@{$interface->constants}) { | 3090 if (@{$interface->constants}) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3179 END | 3205 END |
3180 } | 3206 } |
3181 | 3207 |
3182 AddToImplIncludes("wtf/UnusedParam.h"); | 3208 AddToImplIncludes("wtf/UnusedParam.h"); |
3183 push(@implContent, <<END); | 3209 push(@implContent, <<END); |
3184 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 3210 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
3185 END | 3211 END |
3186 | 3212 |
3187 if (IsConstructable($interface)) { | 3213 if (IsConstructable($interface)) { |
3188 push(@implContent, " desc->SetCallHandler(${v8InterfaceName}::constru ctorCallback);\n"); | 3214 push(@implContent, " desc->SetCallHandler(${v8InterfaceName}::constru ctorCallback);\n"); |
3215 my $constructorLength = GetConstructorLength($interface); | |
3216 push(@implContent, " desc->SetLength(${constructorLength});\n") if de fined $constructorLength; | |
haraken
2013/04/16 00:29:31
'if defined' is not needed.
| |
3189 } | 3217 } |
3190 | 3218 |
3191 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has _constants) { | 3219 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has _constants) { |
3192 push(@implContent, <<END); | 3220 push(@implContent, <<END); |
3193 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 3221 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
3194 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 3222 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
3195 UNUSED_PARAM(instance); // In some cases, it will not be used. | 3223 UNUSED_PARAM(instance); // In some cases, it will not be used. |
3196 UNUSED_PARAM(proto); // In some cases, it will not be used. | 3224 UNUSED_PARAM(proto); // In some cases, it will not be used. |
3197 END | 3225 END |
3198 } | 3226 } |
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4588 | 4616 |
4589 sub GetPassRefPtrType | 4617 sub GetPassRefPtrType |
4590 { | 4618 { |
4591 my $v8InterfaceName = shift; | 4619 my $v8InterfaceName = shift; |
4592 | 4620 |
4593 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; | 4621 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; |
4594 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; | 4622 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; |
4595 } | 4623 } |
4596 | 4624 |
4597 1; | 4625 1; |
OLD | NEW |