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 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 if ($raisesExceptions) { | 2196 if ($raisesExceptions) { |
2197 $code .= " fail:\n"; | 2197 $code .= " fail:\n"; |
2198 $code .= " return setDOMException(ec, args.GetIsolate());\n"; | 2198 $code .= " return setDOMException(ec, args.GetIsolate());\n"; |
2199 } | 2199 } |
2200 | 2200 |
2201 $code .= "}\n"; | 2201 $code .= "}\n"; |
2202 $code .= "\n"; | 2202 $code .= "\n"; |
2203 AddToImplContentInternals($code); | 2203 AddToImplContentInternals($code); |
2204 } | 2204 } |
2205 | 2205 |
| 2206 # The Web IDL specification states that Interface objects for interfaces MUST ha
ve a property named |
| 2207 # "length" that returns the length of the shortest argument list of the entries
in the effective |
| 2208 # overload set for constructors. In other words, use the lowest number of mandat
ory arguments among |
| 2209 # all constructors. |
| 2210 sub GetInterfaceLength |
| 2211 { |
| 2212 my $interface = shift; |
| 2213 |
| 2214 my $leastNumMandatoryParams = 0; |
| 2215 if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGener
ator->IsConstructorTemplate($interface, "TypedArray")) { |
| 2216 $leastNumMandatoryParams = 1; |
| 2217 } elsif ($interface->extendedAttributes->{"Constructor"} || $interface->exte
ndedAttributes->{"CustomConstructor"}) { |
| 2218 my @constructors = @{$interface->constructors}; |
| 2219 my @customConstructors = @{$interface->customConstructors}; |
| 2220 $leastNumMandatoryParams = 255; |
| 2221 foreach my $constructor (@constructors, @customConstructors) { |
| 2222 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParamet
ersCheck($constructor); |
| 2223 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryPara
ms < $leastNumMandatoryParams); |
| 2224 } |
| 2225 } |
| 2226 |
| 2227 return $leastNumMandatoryParams; |
| 2228 } |
| 2229 |
2206 sub GenerateConstructorCallback | 2230 sub GenerateConstructorCallback |
2207 { | 2231 { |
2208 my $interface = shift; | 2232 my $interface = shift; |
2209 | 2233 |
2210 my $interfaceName = $interface->name; | 2234 my $interfaceName = $interface->name; |
2211 my $code = ""; | 2235 my $code = ""; |
2212 $code .= "v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(cons
t v8::Arguments& args)\n"; | 2236 $code .= "v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(cons
t v8::Arguments& args)\n"; |
2213 $code .= "{\n"; | 2237 $code .= "{\n"; |
2214 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); | 2238 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); |
2215 $code .= GenerateConstructorHeader(); | 2239 $code .= GenerateConstructorHeader(); |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3173 next if !IsStandardFunction($interface, $function); | 3197 next if !IsStandardFunction($interface, $function); |
3174 if (!$has_callbacks) { | 3198 if (!$has_callbacks) { |
3175 $has_callbacks = 1; | 3199 $has_callbacks = 1; |
3176 $code .= "static const V8DOMConfiguration::BatchedMethod ${v8Interfa
ceName}Methods[] = {\n"; | 3200 $code .= "static const V8DOMConfiguration::BatchedMethod ${v8Interfa
ceName}Methods[] = {\n"; |
3177 } | 3201 } |
3178 my $name = $function->signature->name; | 3202 my $name = $function->signature->name; |
3179 my $methodForMainWorld = "0"; | 3203 my $methodForMainWorld = "0"; |
3180 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { | 3204 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { |
3181 $methodForMainWorld = "${interfaceName}V8Internal::${name}MethodCall
backForMainWorld"; | 3205 $methodForMainWorld = "${interfaceName}V8Internal::${name}MethodCall
backForMainWorld"; |
3182 } | 3206 } |
| 3207 # numMandatoryParams is used to set the "length" property of the Functio
n object. |
| 3208 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($function); |
3183 my $conditionalString = $codeGenerator->GenerateConditionalString($funct
ion->signature); | 3209 my $conditionalString = $codeGenerator->GenerateConditionalString($funct
ion->signature); |
3184 $code .= "#if ${conditionalString}\n" if $conditionalString; | 3210 $code .= "#if ${conditionalString}\n" if $conditionalString; |
3185 $code .= <<END; | 3211 $code .= <<END; |
3186 {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMain
World}}, | 3212 {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMain
World}, ${numMandatoryParams}}, |
3187 END | 3213 END |
3188 $code .= "#endif\n" if $conditionalString; | 3214 $code .= "#endif\n" if $conditionalString; |
3189 $num_callbacks++; | 3215 $num_callbacks++; |
3190 } | 3216 } |
3191 $code .= "};\n\n" if $has_callbacks; | 3217 $code .= "};\n\n" if $has_callbacks; |
3192 AddToImplContent($code); | 3218 AddToImplContent($code); |
3193 | 3219 |
3194 # Setup constants | 3220 # Setup constants |
3195 my $has_constants = 0; | 3221 my $has_constants = 0; |
3196 my @constantsEnabledAtRuntime; | 3222 my @constantsEnabledAtRuntime; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 END | 3340 END |
3315 } | 3341 } |
3316 | 3342 |
3317 AddToImplIncludes("wtf/UnusedParam.h"); | 3343 AddToImplIncludes("wtf/UnusedParam.h"); |
3318 $code .= <<END; | 3344 $code .= <<END; |
3319 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 3345 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
3320 END | 3346 END |
3321 | 3347 |
3322 if (IsConstructable($interface)) { | 3348 if (IsConstructable($interface)) { |
3323 $code .= " desc->SetCallHandler(${v8InterfaceName}::constructorCallba
ck);\n"; | 3349 $code .= " desc->SetCallHandler(${v8InterfaceName}::constructorCallba
ck);\n"; |
| 3350 my $interfaceLength = GetInterfaceLength($interface); |
| 3351 $code .= " desc->SetLength(${interfaceLength});\n"; |
3324 } | 3352 } |
3325 | 3353 |
3326 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has
_constants) { | 3354 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has
_constants) { |
3327 $code .= <<END; | 3355 $code .= <<END; |
3328 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 3356 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
3329 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 3357 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
3330 UNUSED_PARAM(instance); // In some cases, it will not be used. | 3358 UNUSED_PARAM(instance); // In some cases, it will not be used. |
3331 UNUSED_PARAM(proto); // In some cases, it will not be used. | 3359 UNUSED_PARAM(proto); // In some cases, it will not be used. |
3332 END | 3360 END |
3333 } | 3361 } |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4732 | 4760 |
4733 sub GetPassRefPtrType | 4761 sub GetPassRefPtrType |
4734 { | 4762 { |
4735 my $v8InterfaceName = shift; | 4763 my $v8InterfaceName = shift; |
4736 | 4764 |
4737 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; | 4765 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; |
4738 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; | 4766 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; |
4739 } | 4767 } |
4740 | 4768 |
4741 1; | 4769 1; |
OLD | NEW |