Chromium Code Reviews| 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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 static v8::Handle<v8::Value> ${name}MethodCustom(const v8::Arguments&); | 692 static v8::Handle<v8::Value> ${name}MethodCustom(const v8::Arguments&); |
| 693 END | 693 END |
| 694 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString; | 694 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString; |
| 695 } | 695 } |
| 696 if ($attrExt->{"EnabledPerContext"}) { | 696 if ($attrExt->{"EnabledPerContext"}) { |
| 697 push(@enabledPerContextFunctions, $function); | 697 push(@enabledPerContextFunctions, $function); |
| 698 } | 698 } |
| 699 } | 699 } |
| 700 | 700 |
| 701 if (IsConstructable($interface)) { | 701 if (IsConstructable($interface)) { |
| 702 $header{classPublic}->add(" static v8::Handle<v8::Value> constructorC allback(const v8::Arguments&);\n"); | 702 $header{classPublic}->add(" static void constructorCallback(const v8: :FunctionCallbackInfo<v8::Value>&);\n"); |
| 703 END | 703 END |
| 704 } | 704 } |
| 705 if (HasCustomConstructor($interface)) { | 705 if (HasCustomConstructor($interface)) { |
| 706 $header{classPublic}->add(" static v8::Handle<v8::Value> constructorC ustom(const v8::Arguments&);\n"); | 706 $header{classPublic}->add(" static void constructorCustom(const v8::F unctionCallbackInfo<v8::Value>&);\n"); |
| 707 } | 707 } |
| 708 | 708 |
| 709 my @enabledPerContextAttributes; | 709 my @enabledPerContextAttributes; |
| 710 foreach my $attribute (@{$interface->attributes}) { | 710 foreach my $attribute (@{$interface->attributes}) { |
| 711 my $name = $attribute->signature->name; | 711 my $name = $attribute->signature->name; |
| 712 my $attrExt = $attribute->signature->extendedAttributes; | 712 my $attrExt = $attribute->signature->extendedAttributes; |
| 713 my $conditionalString = GenerateConditionalString($attribute->signature) ; | 713 my $conditionalString = GenerateConditionalString($attribute->signature) ; |
| 714 if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) { | 714 if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) { |
| 715 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString; | 715 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString; |
| 716 $header{classPublic}->add(<<END); | 716 $header{classPublic}->add(<<END); |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2115 } | 2115 } |
| 2116 return v8Undefined(); | 2116 return v8Undefined(); |
| 2117 } | 2117 } |
| 2118 | 2118 |
| 2119 END | 2119 END |
| 2120 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2120 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 2121 $implementation{nameSpaceInternal}->add($code); | 2121 $implementation{nameSpaceInternal}->add($code); |
| 2122 return; | 2122 return; |
| 2123 } | 2123 } |
| 2124 | 2124 |
| 2125 $code .= GenerateArgumentsCountCheck($function, $interface); | 2125 $code .= GenerateArgumentsCountCheckOldStyle($function, $interface); |
| 2126 | 2126 |
| 2127 if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { | 2127 if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { |
| 2128 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); | 2128 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); |
| 2129 $code .= <<END; | 2129 $code .= <<END; |
| 2130 return setWebGLArrayHelper<$implClassName, ${v8ClassName}>(args); | 2130 return setWebGLArrayHelper<$implClassName, ${v8ClassName}>(args); |
| 2131 } | 2131 } |
| 2132 | 2132 |
| 2133 END | 2133 END |
| 2134 $implementation{nameSpaceInternal}->add($code); | 2134 $implementation{nameSpaceInternal}->add($code); |
| 2135 return; | 2135 return; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2183 $code .= " ExceptionCode ec = 0;\n"; | 2183 $code .= " ExceptionCode ec = 0;\n"; |
| 2184 } | 2184 } |
| 2185 | 2185 |
| 2186 if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { | 2186 if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { |
| 2187 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2187 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 2188 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function->signature) . "(ec)))\n"; | 2188 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function->signature) . "(ec)))\n"; |
| 2189 $code .= " return v8::Handle<v8::Value>(v8Null(args.GetIsolate()) );\n"; | 2189 $code .= " return v8::Handle<v8::Value>(v8Null(args.GetIsolate()) );\n"; |
| 2190 END | 2190 END |
| 2191 } | 2191 } |
| 2192 | 2192 |
| 2193 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix); | 2193 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heckOldStyle($function, $interface, $forMainWorldSuffix); |
| 2194 $code .= $parameterCheckString; | 2194 $code .= $parameterCheckString; |
| 2195 | 2195 |
| 2196 # Build the function call string. | 2196 # Build the function call string. |
| 2197 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, %replacements); | 2197 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, %replacements); |
| 2198 $code .= "}\n\n"; | 2198 $code .= "}\n\n"; |
| 2199 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2199 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 2200 $implementation{nameSpaceInternal}->add($code); | 2200 $implementation{nameSpaceInternal}->add($code); |
| 2201 } | 2201 } |
| 2202 | 2202 |
| 2203 sub GenerateCallWith | 2203 sub GenerateCallWith |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 2229 } | 2229 } |
| 2230 if (ExtendedAttributeContains($callWith, "ActiveWindow")) { | 2230 if (ExtendedAttributeContains($callWith, "ActiveWindow")) { |
| 2231 push(@callWithArgs, "activeDOMWindow()"); | 2231 push(@callWithArgs, "activeDOMWindow()"); |
| 2232 } | 2232 } |
| 2233 if (ExtendedAttributeContains($callWith, "FirstWindow")) { | 2233 if (ExtendedAttributeContains($callWith, "FirstWindow")) { |
| 2234 push(@callWithArgs, "firstDOMWindow()"); | 2234 push(@callWithArgs, "firstDOMWindow()"); |
| 2235 } | 2235 } |
| 2236 return ([@callWithArgs], $code); | 2236 return ([@callWithArgs], $code); |
| 2237 } | 2237 } |
| 2238 | 2238 |
| 2239 sub GenerateArgumentsCountCheckOldStyle | |
| 2240 { | |
| 2241 my $function = shift; | |
| 2242 my $interface = shift; | |
| 2243 GenerateArgumentsCountCheck($function, $interface, "old"); | |
| 2244 } | |
| 2245 | |
| 2239 sub GenerateArgumentsCountCheck | 2246 sub GenerateArgumentsCountCheck |
| 2240 { | 2247 { |
| 2241 my $function = shift; | 2248 my $function = shift; |
| 2242 my $interface = shift; | 2249 my $interface = shift; |
| 2250 my $style = shift || "new"; | |
| 2243 | 2251 |
| 2244 my $numMandatoryParams = 0; | 2252 my $numMandatoryParams = 0; |
| 2245 my $allowNonOptional = 1; | 2253 my $allowNonOptional = 1; |
| 2246 foreach my $param (@{$function->parameters}) { | 2254 foreach my $param (@{$function->parameters}) { |
| 2247 if ($param->isOptional or $param->isVariadic) { | 2255 if ($param->isOptional or $param->isVariadic) { |
| 2248 $allowNonOptional = 0; | 2256 $allowNonOptional = 0; |
| 2249 } else { | 2257 } else { |
| 2250 die "An argument must not be declared to be optional unless all subs equent arguments to the operation are also optional." if !$allowNonOptional; | 2258 die "An argument must not be declared to be optional unless all subs equent arguments to the operation are also optional." if !$allowNonOptional; |
| 2251 $numMandatoryParams++; | 2259 $numMandatoryParams++; |
| 2252 } | 2260 } |
| 2253 } | 2261 } |
| 2254 | 2262 |
| 2255 my $argumentsCountCheckString = ""; | 2263 my $argumentsCountCheckString = ""; |
| 2256 if ($numMandatoryParams >= 1) { | 2264 if ($numMandatoryParams >= 1) { |
| 2257 $argumentsCountCheckString .= " if (args.Length() < $numMandatoryPara ms)\n"; | 2265 if ("old" eq $style) { |
|
jochen (gone - plz use gerrit)
2013/05/23 14:20:19
nit $style eq "old"
| |
| 2258 $argumentsCountCheckString .= " return throwNotEnoughArgumentsErr or(args.GetIsolate());\n"; | 2266 $argumentsCountCheckString .= " if (args.Length() < $numMandatory Params)\n"; |
| 2267 $argumentsCountCheckString .= " return throwNotEnoughArgument sError(args.GetIsolate());\n"; | |
| 2268 } else { | |
| 2269 $argumentsCountCheckString .= " if (args.Length() < $numMandatory Params) {\n"; | |
| 2270 $argumentsCountCheckString .= " throwNotEnoughArgumentsError( args.GetIsolate());\n"; | |
| 2271 $argumentsCountCheckString .= " return;\n"; | |
| 2272 $argumentsCountCheckString .= " }\n"; | |
| 2273 } | |
| 2259 } | 2274 } |
| 2260 return $argumentsCountCheckString; | 2275 return $argumentsCountCheckString; |
| 2261 } | 2276 } |
| 2262 | 2277 |
| 2278 sub GenerateParametersCheckOldStyle | |
| 2279 { | |
| 2280 my $function = shift; | |
| 2281 my $interface = shift; | |
| 2282 my $forMainWorldSuffix = shift; | |
| 2283 GenerateParametersCheck($function, $interface, $forMainWorldSuffix, "old"); | |
| 2284 } | |
| 2285 | |
| 2263 sub GenerateParametersCheck | 2286 sub GenerateParametersCheck |
| 2264 { | 2287 { |
| 2265 my $function = shift; | 2288 my $function = shift; |
| 2266 my $interface = shift; | 2289 my $interface = shift; |
| 2267 my $forMainWorldSuffix = shift; | 2290 my $forMainWorldSuffix = shift; |
| 2291 my $style = shift || "new"; | |
| 2292 | |
| 2293 my $isOld = "old" eq $style; | |
|
jochen (gone - plz use gerrit)
2013/05/23 14:20:19
same here
| |
| 2294 my $trySuffix = "_VOID"; | |
| 2295 if ($isOld) { | |
| 2296 $trySuffix = ""; | |
| 2297 } | |
| 2268 | 2298 |
| 2269 my $parameterCheckString = ""; | 2299 my $parameterCheckString = ""; |
| 2270 my $paramIndex = 0; | 2300 my $paramIndex = 0; |
| 2271 my %replacements = (); | 2301 my %replacements = (); |
| 2272 | 2302 |
| 2273 foreach my $parameter (@{$function->parameters}) { | 2303 foreach my $parameter (@{$function->parameters}) { |
| 2274 my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); | 2304 my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); |
| 2275 | 2305 |
| 2276 # Optional arguments without [Default=...] should generate an early call with fewer arguments. | 2306 # Optional arguments without [Default=...] should generate an early call with fewer arguments. |
| 2277 # Optional arguments with [Optional=...] should not generate the early c all. | 2307 # Optional arguments with [Optional=...] should not generate the early c all. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2292 } | 2322 } |
| 2293 | 2323 |
| 2294 my $parameterName = $parameter->name; | 2324 my $parameterName = $parameter->name; |
| 2295 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2325 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| 2296 if (IsCallbackInterface($parameter->type)) { | 2326 if (IsCallbackInterface($parameter->type)) { |
| 2297 my $v8ClassName = "V8" . $parameter->type; | 2327 my $v8ClassName = "V8" . $parameter->type; |
| 2298 AddToImplIncludes("$v8ClassName.h"); | 2328 AddToImplIncludes("$v8ClassName.h"); |
| 2299 if ($parameter->isOptional) { | 2329 if ($parameter->isOptional) { |
| 2300 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; | 2330 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; |
| 2301 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; | 2331 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; |
| 2302 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion())\n"; | 2332 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n"; |
| 2303 $parameterCheckString .= " return throwTypeError(0, a rgs.GetIsolate());\n"; | 2333 if ($isOld) { |
| 2334 $parameterCheckString .= " return throwTypeError( 0, args.GetIsolate());\n"; | |
| 2335 } else { | |
| 2336 $parameterCheckString .= " throwTypeError(0, args .GetIsolate());\n"; | |
| 2337 $parameterCheckString .= " return;\n"; | |
| 2338 } | |
| 2339 $parameterCheckString .= " }\n"; | |
| 2304 $parameterCheckString .= " $parameterName = ${v8ClassName }::create(args[$paramIndex], getScriptExecutionContext());\n"; | 2340 $parameterCheckString .= " $parameterName = ${v8ClassName }::create(args[$paramIndex], getScriptExecutionContext());\n"; |
| 2305 $parameterCheckString .= " }\n"; | 2341 $parameterCheckString .= " }\n"; |
| 2306 } else { | 2342 } else { |
| 2307 $parameterCheckString .= " if (args.Length() <= $paramIndex | | !args[$paramIndex]->IsFunction())\n"; | 2343 $parameterCheckString .= " if (args.Length() <= $paramIndex | | !args[$paramIndex]->IsFunction())\n"; |
| 2308 $parameterCheckString .= " return throwTypeError(0, args. GetIsolate());\n"; | 2344 $parameterCheckString .= " return throwTypeError(0, args. GetIsolate());\n"; |
| 2309 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName = ${v8ClassName}::create(args[$paramIndex], getScriptExecutionCont ext());\n"; | 2345 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName = ${v8ClassName}::create(args[$paramIndex], getScriptExecutionCont ext());\n"; |
| 2310 } | 2346 } |
| 2311 } elsif ($parameter->extendedAttributes->{"Clamp"}) { | 2347 } elsif ($parameter->extendedAttributes->{"Clamp"}) { |
| 2312 my $nativeValue = "${parameterName}NativeValue"; | 2348 my $nativeValue = "${parameterName}NativeValue"; |
| 2313 my $paramType = $parameter->type; | 2349 my $paramType = $parameter->type; |
| 2314 $parameterCheckString .= " $paramType $parameterName = 0;\n"; | 2350 $parameterCheckString .= " $paramType $parameterName = 0;\n"; |
| 2315 $parameterCheckString .= " V8TRYCATCH(double, $nativeValue, a rgs[$paramIndex]->NumberValue());\n"; | 2351 $parameterCheckString .= " V8TRYCATCH$trySuffix(double, $nati veValue, args[$paramIndex]->NumberValue());\n"; |
| 2316 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; | 2352 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; |
| 2317 $parameterCheckString .= " $parameterName = clampTo<$para mType>($nativeValue);\n"; | 2353 $parameterCheckString .= " $parameterName = clampTo<$para mType>($nativeValue);\n"; |
| 2318 } elsif ($parameter->type eq "SerializedScriptValue") { | 2354 } elsif ($parameter->type eq "SerializedScriptValue") { |
| 2319 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 2355 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
| 2320 $parameterCheckString .= " bool ${parameterName}DidThrow = false; \n"; | 2356 $parameterCheckString .= " bool ${parameterName}DidThrow = false; \n"; |
| 2321 $parameterCheckString .= " $nativeType $parameterName = Serialize dScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow, args.Get Isolate());\n"; | 2357 $parameterCheckString .= " $nativeType $parameterName = Serialize dScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow, args.Get Isolate());\n"; |
| 2322 $parameterCheckString .= " if (${parameterName}DidThrow)\n"; | 2358 $parameterCheckString .= " if (${parameterName}DidThrow) {\n"; |
| 2323 $parameterCheckString .= " return v8Undefined();\n"; | 2359 if ($isOld) { |
| 2360 $parameterCheckString .= " return v8Undefined();\n"; | |
| 2361 } else { | |
| 2362 $parameterCheckString .= " return;\n"; | |
| 2363 } | |
| 2364 $parameterCheckString .= " }\n"; | |
| 2324 } elsif ($parameter->isVariadic) { | 2365 } elsif ($parameter->isVariadic) { |
| 2325 my $nativeElementType = GetNativeType($parameter->type); | 2366 my $nativeElementType = GetNativeType($parameter->type); |
| 2326 if ($nativeElementType =~ />$/) { | 2367 if ($nativeElementType =~ />$/) { |
| 2327 $nativeElementType .= " "; | 2368 $nativeElementType .= " "; |
| 2328 } | 2369 } |
| 2329 | 2370 |
| 2330 my $argType = $parameter->type; | 2371 my $argType = $parameter->type; |
| 2331 if (IsWrapperType($argType)) { | 2372 if (IsWrapperType($argType)) { |
| 2332 $parameterCheckString .= " Vector<$nativeElementType> $parame terName;\n"; | 2373 $parameterCheckString .= " Vector<$nativeElementType> $parame terName;\n"; |
| 2333 $parameterCheckString .= " for (int i = $paramIndex; i < args .Length(); ++i) {\n"; | 2374 $parameterCheckString .= " for (int i = $paramIndex; i < args .Length(); ++i) {\n"; |
| 2334 $parameterCheckString .= " if (!V8${argType}::HasInstance (args[i], args.GetIsolate(), worldType(args.GetIsolate())))\n"; | 2375 $parameterCheckString .= " if (!V8${argType}::HasInstance (args[i], args.GetIsolate(), worldType(args.GetIsolate()))) {\n"; |
| 2335 $parameterCheckString .= " return throwTypeError(0, a rgs.GetIsolate());\n"; | 2376 if ($isOld) { |
| 2377 $parameterCheckString .= " return throwTypeError( 0, args.GetIsolate());\n"; | |
| 2378 } else { | |
| 2379 $parameterCheckString .= " throwTypeError(0, args .GetIsolate());\n"; | |
| 2380 $parameterCheckString .= " return;\n"; | |
| 2381 } | |
| 2382 $parameterCheckString .= " }\n"; | |
| 2336 $parameterCheckString .= " $parameterName.append(V8${argT ype}::toNative(v8::Handle<v8::Object>::Cast(args[i])));\n"; | 2383 $parameterCheckString .= " $parameterName.append(V8${argT ype}::toNative(v8::Handle<v8::Object>::Cast(args[i])));\n"; |
| 2337 $parameterCheckString .= " }\n"; | 2384 $parameterCheckString .= " }\n"; |
| 2338 } else { | 2385 } else { |
| 2339 $parameterCheckString .= " V8TRYCATCH(Vector<$nativeElementTy pe>, $parameterName, toNativeArguments<$nativeElementType>(args, $paramIndex));\ n"; | 2386 $parameterCheckString .= " V8TRYCATCH$trySuffix(Vector<$nativ eElementType>, $parameterName, toNativeArguments<$nativeElementType>(args, $para mIndex));\n"; |
| 2340 } | 2387 } |
| 2341 } elsif ($nativeType =~ /^V8StringResource/) { | 2388 } elsif ($nativeType =~ /^V8StringResource/) { |
| 2342 my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : ""; | 2389 my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : ""; |
| 2343 my $value = JSValueToNative($parameter, $parameter->isOptional && $d efault eq "NullString" ? "argumentOrNull(args, $paramIndex)" : "args[$paramIndex ]", "args.GetIsolate()"); | 2390 my $value = JSValueToNative($parameter, $parameter->isOptional && $d efault eq "NullString" ? "argumentOrNull(args, $paramIndex)" : "args[$paramIndex ]", "args.GetIsolate()"); |
| 2344 $parameterCheckString .= " " . ConvertToV8StringResource($paramet er, $nativeType, $parameterName, $value) . "\n"; | 2391 my $suffix = $isOld ? "" : "VOID"; |
| 2392 $parameterCheckString .= " " . ConvertToV8StringResource($paramet er, $nativeType, $parameterName, $value, $suffix) . "\n"; | |
| 2345 if (IsEnumType($parameter->type)) { | 2393 if (IsEnumType($parameter->type)) { |
| 2346 my @enumValues = ValidEnumValues($parameter->type); | 2394 my @enumValues = ValidEnumValues($parameter->type); |
| 2347 my @validEqualities = (); | 2395 my @validEqualities = (); |
| 2348 foreach my $enumValue (@enumValues) { | 2396 foreach my $enumValue (@enumValues) { |
| 2349 push(@validEqualities, "string == \"$enumValue\""); | 2397 push(@validEqualities, "string == \"$enumValue\""); |
| 2350 } | 2398 } |
| 2351 my $enumValidationExpression = join(" || ", @validEqualities); | 2399 my $enumValidationExpression = join(" || ", @validEqualities); |
| 2352 $parameterCheckString .= " String string = $parameterName;\n "; | 2400 $parameterCheckString .= " String string = $parameterName;\n "; |
| 2353 $parameterCheckString .= " if (!($enumValidationExpression)) \n"; | 2401 $parameterCheckString .= " if (!($enumValidationExpression)) {\n"; |
| 2354 $parameterCheckString .= " return throwTypeError(0, args .GetIsolate());\n"; | 2402 if ($isOld) { |
| 2403 $parameterCheckString .= " return throwTypeError(0, a rgs.GetIsolate());\n"; | |
| 2404 } else { | |
| 2405 $parameterCheckString .= " throwTypeError(0, args.Get Isolate());\n"; | |
| 2406 $parameterCheckString .= " return;\n"; | |
| 2407 } | |
| 2408 $parameterCheckString .= " }\n"; | |
| 2355 } | 2409 } |
| 2356 } else { | 2410 } else { |
| 2357 # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an | 2411 # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an |
| 2358 # interface type, then if the incoming value does not implement that interface, a TypeError | 2412 # interface type, then if the incoming value does not implement that interface, a TypeError |
| 2359 # is thrown rather than silently passing NULL to the C++ code. | 2413 # is thrown rather than silently passing NULL to the C++ code. |
| 2360 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted | 2414 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted |
| 2361 # to both strings and numbers, so do not throw TypeError if the argu ment is of these | 2415 # to both strings and numbers, so do not throw TypeError if the argu ment is of these |
| 2362 # types. | 2416 # types. |
| 2363 if ($function->signature->extendedAttributes->{"StrictTypeChecking"} ) { | 2417 if ($function->signature->extendedAttributes->{"StrictTypeChecking"} ) { |
| 2364 my $argValue = "args[$paramIndex]"; | 2418 my $argValue = "args[$paramIndex]"; |
| 2365 my $argType = $parameter->type; | 2419 my $argType = $parameter->type; |
| 2366 if (IsWrapperType($argType)) { | 2420 if (IsWrapperType($argType)) { |
| 2367 $parameterCheckString .= " if (args.Length() > $paramInde x && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue, args .GetIsolate(), worldType(args.GetIsolate())))\n"; | 2421 $parameterCheckString .= " if (args.Length() > $paramInde x && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue, args .GetIsolate(), worldType(args.GetIsolate()))) {\n"; |
| 2368 $parameterCheckString .= " return throwTypeError(0, a rgs.GetIsolate());\n"; | 2422 if ($isOld) { |
| 2423 $parameterCheckString .= " return throwTypeError( 0, args.GetIsolate());\n"; | |
| 2424 } else { | |
| 2425 $parameterCheckString .= " throwTypeError(0, args .GetIsolate());\n"; | |
| 2426 $parameterCheckString .= " return;\n"; | |
| 2427 } | |
| 2428 $parameterCheckString .= " }\n"; | |
| 2369 } | 2429 } |
| 2370 } | 2430 } |
| 2371 my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : ""; | 2431 my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : ""; |
| 2372 my $value = JSValueToNative($parameter, $parameter->isOptional && $d efault eq "NullString" ? "argumentOrNull(args, $paramIndex)" : "args[$paramIndex ]", "args.GetIsolate()"); | 2432 my $value = JSValueToNative($parameter, $parameter->isOptional && $d efault eq "NullString" ? "argumentOrNull(args, $paramIndex)" : "args[$paramIndex ]", "args.GetIsolate()"); |
| 2373 if ($parameter->extendedAttributes->{"EnforceRange"}) { | 2433 if ($parameter->extendedAttributes->{"EnforceRange"}) { |
| 2374 $parameterCheckString .= " V8TRYCATCH_WITH_TYPECHECK($nativeT ype, $parameterName, $value, args.GetIsolate());\n"; | 2434 $parameterCheckString .= " V8TRYCATCH_WITH_TYPECHECK$trySuffi x($nativeType, $parameterName, $value, args.GetIsolate());\n"; |
| 2375 } else { | 2435 } else { |
| 2376 $parameterCheckString .= " V8TRYCATCH($nativeType, $parameter Name, $value);\n"; | 2436 $parameterCheckString .= " V8TRYCATCH$trySuffix($nativeType, $parameterName, $value);\n"; |
| 2377 } | 2437 } |
| 2378 if ($nativeType eq 'Dictionary') { | 2438 if ($nativeType eq 'Dictionary') { |
| 2379 $parameterCheckString .= " if (!$parameterName.isUndefinedOrNu ll() && !$parameterName.isObject())\n"; | 2439 $parameterCheckString .= " if (!$parameterName.isUndefinedOrNu ll() && !$parameterName.isObject()) {\n"; |
| 2380 $parameterCheckString .= " return throwTypeError(\"Not an object.\", args.GetIsolate());\n"; | 2440 if ($isOld) { |
| 2441 $parameterCheckString .= " return throwTypeError(\"No t an object.\", args.GetIsolate());\n"; | |
| 2442 } else { | |
| 2443 $parameterCheckString .= " throwTypeError(\"Not an ob ject.\", args.GetIsolate());\n"; | |
| 2444 $parameterCheckString .= " return;\n"; | |
| 2445 } | |
| 2446 $parameterCheckString .= " }\n"; | |
| 2381 } | 2447 } |
| 2382 } | 2448 } |
| 2383 | 2449 |
| 2384 if ($parameter->extendedAttributes->{"IsIndex"}) { | 2450 if ($parameter->extendedAttributes->{"IsIndex"}) { |
| 2385 $parameterCheckString .= " if (UNLIKELY($parameterName < 0))\n"; | 2451 $parameterCheckString .= " if (UNLIKELY($parameterName < 0)) {\n" ; |
| 2386 $parameterCheckString .= " return setDOMException(INDEX_SIZE_ ERR, args.GetIsolate());\n"; | 2452 if ($isOld) { |
| 2453 $parameterCheckString .= " return setDOMException(INDEX_S IZE_ERR, args.GetIsolate());\n"; | |
| 2454 } else { | |
| 2455 $parameterCheckString .= " setDOMException(INDEX_SIZE_ERR , args.GetIsolate());\n"; | |
| 2456 $parameterCheckString .= " return;\n"; | |
| 2457 } | |
| 2458 $parameterCheckString .= " }\n"; | |
| 2387 } | 2459 } |
| 2388 | 2460 |
| 2389 $paramIndex++; | 2461 $paramIndex++; |
| 2390 } | 2462 } |
| 2391 return ($parameterCheckString, $paramIndex, %replacements); | 2463 return ($parameterCheckString, $paramIndex, %replacements); |
| 2392 } | 2464 } |
| 2393 | 2465 |
| 2394 sub GenerateOverloadedConstructorCallback | 2466 sub GenerateOverloadedConstructorCallback |
| 2395 { | 2467 { |
| 2396 my $interface = shift; | 2468 my $interface = shift; |
| 2397 my $implClassName = GetImplName($interface); | 2469 my $implClassName = GetImplName($interface); |
| 2398 | 2470 |
| 2471 | |
|
jochen (gone - plz use gerrit)
2013/05/23 14:20:19
why the empty line?
| |
| 2399 my $code = ""; | 2472 my $code = ""; |
| 2400 $code .= <<END; | 2473 $code .= <<END; |
| 2401 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2474 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) |
| 2402 { | 2475 { |
| 2403 END | 2476 END |
| 2404 my $leastNumMandatoryParams = 255; | 2477 my $leastNumMandatoryParams = 255; |
| 2405 foreach my $constructor (@{$interface->constructors}) { | 2478 foreach my $constructor (@{$interface->constructors}) { |
| 2406 my $name = "constructor" . $constructor->{overloadedIndex}; | 2479 my $name = "constructor" . $constructor->{overloadedIndex}; |
| 2407 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC heck($constructor); | 2480 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC heck($constructor); |
| 2408 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); | 2481 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); |
| 2409 $code .= " if ($parametersCheck)\n"; | 2482 $code .= " if ($parametersCheck) {\n"; |
| 2410 $code .= " return ${implClassName}V8Internal::${name}(args);\n"; | 2483 $code .= " ${implClassName}V8Internal::${name}(args);\n"; |
| 2484 $code .= " return;\n"; | |
| 2485 $code .= " }\n"; | |
| 2411 } | 2486 } |
| 2412 if ($leastNumMandatoryParams >= 1) { | 2487 if ($leastNumMandatoryParams >= 1) { |
| 2413 $code .= " if (args.Length() < $leastNumMandatoryParams)\n"; | 2488 $code .= " if (args.Length() < $leastNumMandatoryParams) {\n"; |
| 2414 $code .= " return throwNotEnoughArgumentsError(args.GetIsolate()) ;\n"; | 2489 $code .= " throwNotEnoughArgumentsError(args.GetIsolate());\n"; |
| 2490 $code .= " return;"; | |
| 2491 $code .= " }\n"; | |
| 2415 } | 2492 } |
| 2416 $code .= <<END; | 2493 $code .= <<END; |
| 2417 return throwTypeError(0, args.GetIsolate()); | 2494 throwTypeError(0, args.GetIsolate()); |
| 2495 return; | |
| 2418 END | 2496 END |
| 2419 $code .= "}\n\n"; | 2497 $code .= "}\n\n"; |
| 2420 $implementation{nameSpaceInternal}->add($code); | 2498 $implementation{nameSpaceInternal}->add($code); |
| 2421 } | 2499 } |
| 2422 | 2500 |
| 2423 sub GenerateSingleConstructorCallback | 2501 sub GenerateSingleConstructorCallback |
| 2424 { | 2502 { |
| 2425 my $interface = shift; | 2503 my $interface = shift; |
| 2426 my $function = shift; | 2504 my $function = shift; |
| 2427 | 2505 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2441 if ($parameter->extendedAttributes->{"IsIndex"}) { | 2519 if ($parameter->extendedAttributes->{"IsIndex"}) { |
| 2442 $raisesExceptions = 1; | 2520 $raisesExceptions = 1; |
| 2443 } | 2521 } |
| 2444 } | 2522 } |
| 2445 } | 2523 } |
| 2446 | 2524 |
| 2447 my @beforeArgumentList; | 2525 my @beforeArgumentList; |
| 2448 my @afterArgumentList; | 2526 my @afterArgumentList; |
| 2449 my $code = ""; | 2527 my $code = ""; |
| 2450 $code .= <<END; | 2528 $code .= <<END; |
| 2451 static v8::Handle<v8::Value> constructor${overloadedIndexString}(const v8::Argum ents& args) | 2529 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args) |
| 2452 { | 2530 { |
| 2453 END | 2531 END |
| 2454 | 2532 |
| 2455 if ($function->{overloadedIndex} == 0) { | 2533 if ($function->{overloadedIndex} == 0) { |
| 2456 $code .= GenerateArgumentsCountCheck($function, $interface); | 2534 $code .= GenerateArgumentsCountCheck($function, $interface); |
| 2457 } | 2535 } |
| 2458 | 2536 |
| 2459 if ($raisesExceptions) { | 2537 if ($raisesExceptions) { |
| 2460 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2538 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| 2461 $code .= " ExceptionCode ec = 0;\n"; | 2539 $code .= " ExceptionCode ec = 0;\n"; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 2488 } | 2566 } |
| 2489 $index++; | 2567 $index++; |
| 2490 } | 2568 } |
| 2491 | 2569 |
| 2492 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); | 2570 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); |
| 2493 $code .= "\n"; | 2571 $code .= "\n"; |
| 2494 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n"; | 2572 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n"; |
| 2495 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; | 2573 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; |
| 2496 | 2574 |
| 2497 if ($interface->extendedAttributes->{"RaisesException"}) { | 2575 if ($interface->extendedAttributes->{"RaisesException"}) { |
| 2498 $code .= " if (ec)\n"; | 2576 $code .= " if (ec) {\n"; |
| 2499 $code .= " return setDOMException(ec, args.GetIsolate());\n"; | 2577 $code .= " setDOMException(ec, args.GetIsolate());\n"; |
| 2578 $code .= " return;\n"; | |
| 2579 $code .= " }\n"; | |
| 2500 } | 2580 } |
| 2501 | 2581 |
| 2502 $code .= <<END; | 2582 $code .= <<END; |
| 2503 | 2583 |
| 2504 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2584 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
| 2505 return wrapper; | 2585 args.GetReturnValue().Set(wrapper); |
| 2506 } | 2586 } |
| 2507 | 2587 |
| 2508 END | 2588 END |
| 2509 $implementation{nameSpaceInternal}->add($code); | 2589 $implementation{nameSpaceInternal}->add($code); |
| 2510 } | 2590 } |
| 2511 | 2591 |
| 2512 # The Web IDL specification states that Interface objects for interfaces MUST ha ve a property named | 2592 # The Web IDL specification states that Interface objects for interfaces MUST ha ve a property named |
| 2513 # "length" that returns the length of the shortest argument list of the entries in the effective | 2593 # "length" that returns the length of the shortest argument list of the entries in the effective |
| 2514 # overload set for constructors. In other words, use the lowest number of mandat ory arguments among | 2594 # overload set for constructors. In other words, use the lowest number of mandat ory arguments among |
| 2515 # all constructors. | 2595 # all constructors. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 2533 return $leastConstructorLength; | 2613 return $leastConstructorLength; |
| 2534 } | 2614 } |
| 2535 | 2615 |
| 2536 sub GenerateConstructorCallback | 2616 sub GenerateConstructorCallback |
| 2537 { | 2617 { |
| 2538 my $interface = shift; | 2618 my $interface = shift; |
| 2539 | 2619 |
| 2540 my $implClassName = GetImplName($interface); | 2620 my $implClassName = GetImplName($interface); |
| 2541 my $v8ClassName = GetV8ClassName($interface); | 2621 my $v8ClassName = GetV8ClassName($interface); |
| 2542 my $code = ""; | 2622 my $code = ""; |
| 2543 $code .= "v8::Handle<v8::Value> ${v8ClassName}::constructorCallback(const v8 ::Arguments& args)\n"; | 2623 $code .= "void ${v8ClassName}::constructorCallback(const v8::FunctionCallbac kInfo<v8::Value>& args)\n"; |
| 2544 $code .= "{\n"; | 2624 $code .= "{\n"; |
| 2545 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"}); | 2625 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"}); |
| 2546 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D eprecateAs"}); | 2626 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D eprecateAs"}); |
| 2547 $code .= GenerateConstructorHeader(); | 2627 $code .= GenerateConstructorHeader(); |
| 2548 if (HasCustomConstructor($interface)) { | 2628 if (HasCustomConstructor($interface)) { |
| 2549 $code .= " return ${v8ClassName}::constructorCustom(args);\n"; | 2629 $code .= " ${v8ClassName}::constructorCustom(args);\n"; |
| 2550 } else { | 2630 } else { |
| 2551 $code .= " return ${implClassName}V8Internal::constructor(args);\n"; | 2631 $code .= " ${implClassName}V8Internal::constructor(args);\n"; |
| 2552 } | 2632 } |
| 2553 $code .= "}\n\n"; | 2633 $code .= "}\n\n"; |
| 2554 $implementation{nameSpaceWebCore}->add($code); | 2634 $implementation{nameSpaceWebCore}->add($code); |
| 2555 } | 2635 } |
| 2556 | 2636 |
| 2557 sub GenerateConstructor | 2637 sub GenerateConstructor |
| 2558 { | 2638 { |
| 2559 my $interface = shift; | 2639 my $interface = shift; |
| 2560 | 2640 |
| 2561 if (@{$interface->constructors} == 1) { | 2641 if (@{$interface->constructors} == 1) { |
| 2562 GenerateSingleConstructorCallback($interface, @{$interface->constructors }[0]); | 2642 GenerateSingleConstructorCallback($interface, @{$interface->constructors }[0]); |
| 2563 } else { | 2643 } else { |
| 2564 foreach my $constructor (@{$interface->constructors}) { | 2644 foreach my $constructor (@{$interface->constructors}) { |
| 2565 GenerateSingleConstructorCallback($interface, $constructor); | 2645 GenerateSingleConstructorCallback($interface, $constructor); |
| 2566 } | 2646 } |
| 2567 GenerateOverloadedConstructorCallback($interface); | 2647 GenerateOverloadedConstructorCallback($interface); |
| 2568 } | 2648 } |
| 2569 } | 2649 } |
| 2570 | 2650 |
| 2571 sub GenerateEventConstructor | 2651 sub GenerateEventConstructor |
| 2572 { | 2652 { |
| 2573 my $interface = shift; | 2653 my $interface = shift; |
| 2574 my $implClassName = GetImplName($interface); | 2654 my $implClassName = GetImplName($interface); |
| 2575 my $v8ClassName = GetV8ClassName($interface); | 2655 my $v8ClassName = GetV8ClassName($interface); |
| 2576 | 2656 |
| 2577 AddToImplIncludes("bindings/v8/Dictionary.h"); | 2657 AddToImplIncludes("bindings/v8/Dictionary.h"); |
| 2578 $implementation{nameSpaceInternal}->add(<<END); | 2658 $implementation{nameSpaceInternal}->add(<<END); |
| 2579 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2659 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) |
| 2580 { | 2660 { |
| 2581 if (args.Length() < 1) | 2661 if (args.Length() < 1) { |
| 2582 return throwNotEnoughArgumentsError(args.GetIsolate()); | 2662 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 2663 return; | |
| 2664 } | |
| 2583 | 2665 |
| 2584 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]); | 2666 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); |
| 2585 ${implClassName}Init eventInit; | 2667 ${implClassName}Init eventInit; |
| 2586 if (args.Length() >= 2) { | 2668 if (args.Length() >= 2) { |
| 2587 V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate())); | 2669 V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate ())); |
| 2588 if (!fill${implClassName}Init(eventInit, options)) | 2670 if (!fill${implClassName}Init(eventInit, options)) |
| 2589 return v8Undefined(); | 2671 return; |
| 2590 } | 2672 } |
| 2591 | 2673 |
| 2592 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); | 2674 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); |
| 2593 | 2675 |
| 2594 v8::Handle<v8::Object> wrapper = args.Holder(); | 2676 v8::Handle<v8::Object> wrapper = args.Holder(); |
| 2595 V8DOMWrapper::associateObjectWithWrapper(event.release(), &${v8ClassName}::i nfo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2677 V8DOMWrapper::associateObjectWithWrapper(event.release(), &${v8ClassName}::i nfo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
| 2596 return wrapper; | 2678 args.GetReturnValue().Set(wrapper); |
| 2597 } | 2679 } |
| 2598 END | 2680 END |
| 2599 | 2681 |
| 2600 my $code = ""; | 2682 my $code = ""; |
| 2601 $code .= <<END; | 2683 $code .= <<END; |
| 2602 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options) | 2684 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options) |
| 2603 { | 2685 { |
| 2604 END | 2686 END |
| 2605 | 2687 |
| 2606 foreach my $interfaceBase (@{$interface->parents}) { | 2688 foreach my $interfaceBase (@{$interface->parents}) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2631 { | 2713 { |
| 2632 my $interface = shift; | 2714 my $interface = shift; |
| 2633 my $implClassName = GetImplName($interface); | 2715 my $implClassName = GetImplName($interface); |
| 2634 my $v8ClassName = GetV8ClassName($interface); | 2716 my $v8ClassName = GetV8ClassName($interface); |
| 2635 | 2717 |
| 2636 my $viewType = GetTypeNameOfExternalTypedArray($interface); | 2718 my $viewType = GetTypeNameOfExternalTypedArray($interface); |
| 2637 my $type = $interface->extendedAttributes->{"TypedArray"}; | 2719 my $type = $interface->extendedAttributes->{"TypedArray"}; |
| 2638 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); | 2720 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); |
| 2639 | 2721 |
| 2640 $implementation{nameSpaceInternal}->add(<<END); | 2722 $implementation{nameSpaceInternal}->add(<<END); |
| 2641 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2723 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) |
| 2642 { | 2724 { |
| 2643 return constructWebGLArray<$implClassName, ${v8ClassName}, $type>(args, &${v 8ClassName}::info, $viewType); | 2725 constructWebGLArray<$implClassName, ${v8ClassName}, $type>(args, &${v8ClassN ame}::info, $viewType); |
| 2644 } | 2726 } |
| 2645 | 2727 |
| 2646 END | 2728 END |
| 2647 } | 2729 } |
| 2648 | 2730 |
| 2649 sub GenerateNamedConstructor | 2731 sub GenerateNamedConstructor |
| 2650 { | 2732 { |
| 2651 my $function = shift; | 2733 my $function = shift; |
| 2652 my $interface = shift; | 2734 my $interface = shift; |
| 2653 | 2735 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 2682 } | 2764 } |
| 2683 | 2765 |
| 2684 AddToImplIncludes("core/page/Frame.h"); | 2766 AddToImplIncludes("core/page/Frame.h"); |
| 2685 $implementation{nameSpaceWebCore}->add(<<END); | 2767 $implementation{nameSpaceWebCore}->add(<<END); |
| 2686 WrapperTypeInfo ${v8ClassName}Constructor::info = { ${v8ClassName}Constructor::G etTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, 0, ${v8ClassName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectProtot ype }; | 2768 WrapperTypeInfo ${v8ClassName}Constructor::info = { ${v8ClassName}Constructor::G etTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, 0, ${v8ClassName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectProtot ype }; |
| 2687 | 2769 |
| 2688 END | 2770 END |
| 2689 | 2771 |
| 2690 my $code = ""; | 2772 my $code = ""; |
| 2691 $code .= <<END; | 2773 $code .= <<END; |
| 2692 static v8::Handle<v8::Value> ${v8ClassName}ConstructorCallback(const v8::Argumen ts& args) | 2774 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args) |
|
haraken
2013/05/23 15:04:38
Are you going to use FunctionCallbackInfo for DOM
dcarney
2013/05/24 08:11:48
No.
Unification is not easy, since they are very
| |
| 2693 { | 2775 { |
| 2694 END | 2776 END |
| 2695 $code .= $maybeObserveFeature if $maybeObserveFeature; | 2777 $code .= $maybeObserveFeature if $maybeObserveFeature; |
| 2696 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; | 2778 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; |
| 2697 $code .= GenerateConstructorHeader(); | 2779 $code .= GenerateConstructorHeader(); |
| 2698 AddToImplIncludes("V8Document.h"); | 2780 AddToImplIncludes("V8Document.h"); |
| 2699 $code .= <<END; | 2781 $code .= <<END; |
| 2700 Document* document = currentDocument(); | 2782 Document* document = currentDocument(); |
| 2701 | 2783 |
| 2702 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance | 2784 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 2732 } | 2814 } |
| 2733 $index++; | 2815 $index++; |
| 2734 } | 2816 } |
| 2735 | 2817 |
| 2736 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); | 2818 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); |
| 2737 $code .= "\n"; | 2819 $code .= "\n"; |
| 2738 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; | 2820 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; |
| 2739 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; | 2821 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; |
| 2740 | 2822 |
| 2741 if ($interface->extendedAttributes->{"RaisesException"}) { | 2823 if ($interface->extendedAttributes->{"RaisesException"}) { |
| 2742 $code .= " if (ec)\n"; | 2824 $code .= " if (ec) {\n"; |
| 2743 $code .= " return setDOMException(ec, args.GetIsolate());\n"; | 2825 $code .= " setDOMException(ec, args.GetIsolate());\n"; |
| 2826 $code .= " return;\n"; | |
| 2827 $code .= " }\n"; | |
| 2744 } | 2828 } |
| 2745 | 2829 |
| 2746 $code .= <<END; | 2830 $code .= <<END; |
| 2747 | 2831 |
| 2748 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2832 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
| 2749 return wrapper; | 2833 args.GetReturnValue().Set(wrapper); |
|
haraken
2013/05/23 15:04:38
Can't we write this as args.SetReturnValue(wrapper
dcarney
2013/05/24 08:11:48
The ReturnValue is mean to be stack passable, and
| |
| 2750 } | 2834 } |
| 2751 | 2835 |
| 2752 END | 2836 END |
| 2753 $implementation{nameSpaceWebCore}->add($code); | 2837 $implementation{nameSpaceWebCore}->add($code); |
| 2754 | 2838 |
| 2755 $code = <<END; | 2839 $code = <<END; |
| 2756 v8::Persistent<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8:: Isolate* isolate, WrapperWorldType currentWorldType) | 2840 v8::Persistent<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8:: Isolate* isolate, WrapperWorldType currentWorldType) |
| 2757 { | 2841 { |
| 2758 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; | 2842 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; |
| 2759 if (!cachedTemplate.IsEmpty()) | 2843 if (!cachedTemplate.IsEmpty()) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2772 } | 2856 } |
| 2773 | 2857 |
| 2774 END | 2858 END |
| 2775 $implementation{nameSpaceWebCore}->add($code); | 2859 $implementation{nameSpaceWebCore}->add($code); |
| 2776 } | 2860 } |
| 2777 | 2861 |
| 2778 sub GenerateConstructorHeader | 2862 sub GenerateConstructorHeader |
| 2779 { | 2863 { |
| 2780 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h"); | 2864 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h"); |
| 2781 my $content = <<END; | 2865 my $content = <<END; |
| 2782 if (!args.IsConstructCall()) | 2866 if (!args.IsConstructCall()) { |
| 2783 return throwTypeError("DOM object constructor cannot be called as a func tion.", args.GetIsolate()); | 2867 throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate()); |
| 2868 return; | |
| 2869 } | |
| 2784 | 2870 |
| 2785 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) | 2871 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
| 2786 return args.Holder(); | 2872 args.GetReturnValue().Set(args.Holder()); |
| 2873 return; | |
| 2874 } | |
| 2787 | 2875 |
| 2788 END | 2876 END |
| 2789 return $content; | 2877 return $content; |
| 2790 } | 2878 } |
| 2791 | 2879 |
| 2792 sub GenerateBatchedAttributeData | 2880 sub GenerateBatchedAttributeData |
| 2793 { | 2881 { |
| 2794 my $interface = shift; | 2882 my $interface = shift; |
| 2795 my $attributes = shift; | 2883 my $attributes = shift; |
| 2796 my $code = ""; | 2884 my $code = ""; |
| (...skipping 2603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5400 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5488 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 5401 $found = 1; | 5489 $found = 1; |
| 5402 } | 5490 } |
| 5403 return 1 if $found; | 5491 return 1 if $found; |
| 5404 }, 0); | 5492 }, 0); |
| 5405 | 5493 |
| 5406 return $found; | 5494 return $found; |
| 5407 } | 5495 } |
| 5408 | 5496 |
| 5409 1; | 5497 1; |
| OLD | NEW |