| 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 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 my $interface = shift; | 1303 my $interface = shift; |
| 1304 my $propertyName = shift; | 1304 my $propertyName = shift; |
| 1305 | 1305 |
| 1306 my $interfaceName = $interface->name; | 1306 my $interfaceName = $interface->name; |
| 1307 | 1307 |
| 1308 AddToImplIncludes("bindings/v8/V8DOMActivityLogger.h"); | 1308 AddToImplIncludes("bindings/v8/V8DOMActivityLogger.h"); |
| 1309 | 1309 |
| 1310 my $code = ""; | 1310 my $code = ""; |
| 1311 if ($accessType eq "Method") { | 1311 if ($accessType eq "Method") { |
| 1312 $code .= <<END; | 1312 $code .= <<END; |
| 1313 V8PerContextData* contextData = V8PerContextData::from(args.GetIsolate()->Ge
tCurrentContext()); | 1313 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
| 1314 if (contextData && contextData->activityLogger()) { | 1314 if (contextData && contextData->activityLogger()) { |
| 1315 Vector<v8::Handle<v8::Value> > loggerArgs = toVectorOfArguments(args); | 1315 Vector<v8::Handle<v8::Value> > loggerArgs = toVectorOfArguments(info); |
| 1316 contextData->activityLogger()->log("${interfaceName}.${propertyName}", a
rgs.Length(), loggerArgs.data(), "${accessType}"); | 1316 contextData->activityLogger()->log("${interfaceName}.${propertyName}", i
nfo.Length(), loggerArgs.data(), "${accessType}"); |
| 1317 } | 1317 } |
| 1318 END | 1318 END |
| 1319 } elsif ($accessType eq "Setter") { | 1319 } elsif ($accessType eq "Setter") { |
| 1320 $code .= <<END; | 1320 $code .= <<END; |
| 1321 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); | 1321 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
| 1322 if (contextData && contextData->activityLogger()) { | 1322 if (contextData && contextData->activityLogger()) { |
| 1323 v8::Handle<v8::Value> loggerArg[] = { jsValue }; | 1323 v8::Handle<v8::Value> loggerArg[] = { jsValue }; |
| 1324 contextData->activityLogger()->log("${interfaceName}.${propertyName}", 1
, &loggerArg[0], "${accessType}"); | 1324 contextData->activityLogger()->log("${interfaceName}.${propertyName}", 1
, &loggerArg[0], "${accessType}"); |
| 1325 } | 1325 } |
| 1326 END | 1326 END |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 $code .= "\n"; | 2072 $code .= "\n"; |
| 2073 $implementation{nameSpaceInternal}->add($code); | 2073 $implementation{nameSpaceInternal}->add($code); |
| 2074 } | 2074 } |
| 2075 | 2075 |
| 2076 sub GenerateParametersCheckExpression | 2076 sub GenerateParametersCheckExpression |
| 2077 { | 2077 { |
| 2078 my $numParameters = shift; | 2078 my $numParameters = shift; |
| 2079 my $function = shift; | 2079 my $function = shift; |
| 2080 | 2080 |
| 2081 my @andExpression = (); | 2081 my @andExpression = (); |
| 2082 push(@andExpression, "args.Length() == $numParameters"); | 2082 push(@andExpression, "info.Length() == $numParameters"); |
| 2083 my $parameterIndex = 0; | 2083 my $parameterIndex = 0; |
| 2084 foreach my $parameter (@{$function->parameters}) { | 2084 foreach my $parameter (@{$function->parameters}) { |
| 2085 last if $parameterIndex >= $numParameters; | 2085 last if $parameterIndex >= $numParameters; |
| 2086 my $value = "args[$parameterIndex]"; | 2086 my $value = "info[$parameterIndex]"; |
| 2087 my $type = $parameter->type; | 2087 my $type = $parameter->type; |
| 2088 | 2088 |
| 2089 # Only DOMString or wrapper types are checked. | 2089 # Only DOMString or wrapper types are checked. |
| 2090 # For DOMString with StrictTypeChecking only Null, Undefined and Object | 2090 # For DOMString with StrictTypeChecking only Null, Undefined and Object |
| 2091 # are accepted for compatibility. Otherwise, no restrictions are made to | 2091 # are accepted for compatibility. Otherwise, no restrictions are made to |
| 2092 # match the non-overloaded behavior. | 2092 # match the non-overloaded behavior. |
| 2093 # FIXME: Implement WebIDL overload resolution algorithm. | 2093 # FIXME: Implement WebIDL overload resolution algorithm. |
| 2094 if ($type eq "DOMString") { | 2094 if ($type eq "DOMString") { |
| 2095 if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { | 2095 if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { |
| 2096 push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefin
ed() || ${value}->IsString() || ${value}->IsObject())"); | 2096 push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefin
ed() || ${value}->IsString() || ${value}->IsObject())"); |
| 2097 } | 2097 } |
| 2098 } elsif (IsCallbackInterface($parameter->type)) { | 2098 } elsif (IsCallbackInterface($parameter->type)) { |
| 2099 # For Callbacks only checks if the value is null or object. | 2099 # For Callbacks only checks if the value is null or object. |
| 2100 push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())
"); | 2100 push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())
"); |
| 2101 } elsif (GetArrayOrSequenceType($type)) { | 2101 } elsif (GetArrayOrSequenceType($type)) { |
| 2102 if ($parameter->isNullable) { | 2102 if ($parameter->isNullable) { |
| 2103 push(@andExpression, "(${value}->IsNull() || ${value}->IsArray()
)"); | 2103 push(@andExpression, "(${value}->IsNull() || ${value}->IsArray()
)"); |
| 2104 } else { | 2104 } else { |
| 2105 push(@andExpression, "(${value}->IsArray())"); | 2105 push(@andExpression, "(${value}->IsArray())"); |
| 2106 } | 2106 } |
| 2107 } elsif (IsWrapperType($type)) { | 2107 } elsif (IsWrapperType($type)) { |
| 2108 if ($parameter->isNullable) { | 2108 if ($parameter->isNullable) { |
| 2109 push(@andExpression, "(${value}->IsNull() || V8${type}::HasInsta
nce($value, args.GetIsolate(), worldType(args.GetIsolate())))"); | 2109 push(@andExpression, "(${value}->IsNull() || V8${type}::HasInsta
nce($value, info.GetIsolate(), worldType(info.GetIsolate())))"); |
| 2110 } else { | 2110 } else { |
| 2111 push(@andExpression, "(V8${type}::HasInstance($value, args.GetIs
olate(), worldType(args.GetIsolate())))"); | 2111 push(@andExpression, "(V8${type}::HasInstance($value, info.GetIs
olate(), worldType(info.GetIsolate())))"); |
| 2112 } | 2112 } |
| 2113 } | 2113 } |
| 2114 | 2114 |
| 2115 $parameterIndex++; | 2115 $parameterIndex++; |
| 2116 } | 2116 } |
| 2117 my $res = join(" && ", @andExpression); | 2117 my $res = join(" && ", @andExpression); |
| 2118 $res = "($res)" if @andExpression > 1; | 2118 $res = "($res)" if @andExpression > 1; |
| 2119 return $res; | 2119 return $res; |
| 2120 } | 2120 } |
| 2121 | 2121 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2174 | 2174 |
| 2175 my $name = $function->name; | 2175 my $name = $function->name; |
| 2176 my $interfaceName = $interface->name; | 2176 my $interfaceName = $interface->name; |
| 2177 my $implClassName = GetImplName($interface); | 2177 my $implClassName = GetImplName($interface); |
| 2178 | 2178 |
| 2179 my $conditionalString = GenerateConditionalString($function); | 2179 my $conditionalString = GenerateConditionalString($function); |
| 2180 my $leastNumMandatoryParams = 255; | 2180 my $leastNumMandatoryParams = 255; |
| 2181 my $code = ""; | 2181 my $code = ""; |
| 2182 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 2182 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 2183 $code .= <<END; | 2183 $code .= <<END; |
| 2184 static void ${name}Method${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8
::Value>& args) | 2184 static void ${name}Method${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8
::Value>& info) |
| 2185 { | 2185 { |
| 2186 END | 2186 END |
| 2187 $code .= GenerateFeatureObservation($function->extendedAttributes->{"Measure
As"}); | 2187 $code .= GenerateFeatureObservation($function->extendedAttributes->{"Measure
As"}); |
| 2188 $code .= GenerateDeprecationNotification($function->extendedAttributes->{"De
precateAs"}); | 2188 $code .= GenerateDeprecationNotification($function->extendedAttributes->{"De
precateAs"}); |
| 2189 | 2189 |
| 2190 foreach my $overload (@{$function->{overloads}}) { | 2190 foreach my $overload (@{$function->{overloads}}) { |
| 2191 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($overload); | 2191 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($overload); |
| 2192 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); | 2192 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); |
| 2193 $code .= " if ($parametersCheck) {\n"; | 2193 $code .= " if ($parametersCheck) {\n"; |
| 2194 my $overloadedIndexString = $overload->{overloadIndex}; | 2194 my $overloadedIndexString = $overload->{overloadIndex}; |
| 2195 $code .= " ${name}${overloadedIndexString}Method${forMainWorldSuf
fix}(args);\n"; | 2195 $code .= " ${name}${overloadedIndexString}Method${forMainWorldSuf
fix}(info);\n"; |
| 2196 $code .= " return;\n"; | 2196 $code .= " return;\n"; |
| 2197 $code .= " }\n"; | 2197 $code .= " }\n"; |
| 2198 } | 2198 } |
| 2199 if ($leastNumMandatoryParams >= 1) { | 2199 if ($leastNumMandatoryParams >= 1) { |
| 2200 $code .= " if (UNLIKELY(args.Length() < $leastNumMandatoryParams)) {\
n"; | 2200 $code .= " if (UNLIKELY(info.Length() < $leastNumMandatoryParams)) {\
n"; |
| 2201 $code .= " throwTypeError(ExceptionMessages::failedToExecute(\"$n
ame\", \"$interfaceName\", ExceptionMessages::notEnoughArguments($leastNumMandat
oryParams, args.Length())), args.GetIsolate());\n"; | 2201 $code .= " throwTypeError(ExceptionMessages::failedToExecute(\"$n
ame\", \"$interfaceName\", ExceptionMessages::notEnoughArguments($leastNumMandat
oryParams, info.Length())), info.GetIsolate());\n"; |
| 2202 $code .= " return;\n"; | 2202 $code .= " return;\n"; |
| 2203 $code .= " }\n"; | 2203 $code .= " }\n"; |
| 2204 } | 2204 } |
| 2205 $code .= <<END; | 2205 $code .= <<END; |
| 2206 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 2206 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 2207 END | 2207 END |
| 2208 $code .= "}\n\n"; | 2208 $code .= "}\n\n"; |
| 2209 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2209 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 2210 $implementation{nameSpaceInternal}->add($code); | 2210 $implementation{nameSpaceInternal}->add($code); |
| 2211 } | 2211 } |
| 2212 | 2212 |
| 2213 sub GenerateFunctionCallback | 2213 sub GenerateFunctionCallback |
| 2214 { | 2214 { |
| 2215 my $function = shift; | 2215 my $function = shift; |
| 2216 my $interface = shift; | 2216 my $interface = shift; |
| 2217 my $forMainWorldSuffix = shift; | 2217 my $forMainWorldSuffix = shift; |
| 2218 | 2218 |
| 2219 my $implClassName = GetImplName($interface); | 2219 my $implClassName = GetImplName($interface); |
| 2220 my $v8ClassName = GetV8ClassName($interface); | 2220 my $v8ClassName = GetV8ClassName($interface); |
| 2221 my $name = $function->name; | 2221 my $name = $function->name; |
| 2222 | 2222 |
| 2223 if ($name eq "") { | 2223 if ($name eq "") { |
| 2224 return; | 2224 return; |
| 2225 } | 2225 } |
| 2226 | 2226 |
| 2227 my $conditionalString = GenerateConditionalString($function); | 2227 my $conditionalString = GenerateConditionalString($function); |
| 2228 my $code = ""; | 2228 my $code = ""; |
| 2229 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 2229 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 2230 $code .= <<END; | 2230 $code .= <<END; |
| 2231 static void ${name}MethodCallback${forMainWorldSuffix}(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 2231 static void ${name}MethodCallback${forMainWorldSuffix}(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
| 2232 { | 2232 { |
| 2233 END | 2233 END |
| 2234 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n"; | 2234 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n"; |
| 2235 $code .= GenerateFeatureObservation($function->extendedAttributes->{"Measure
As"}); | 2235 $code .= GenerateFeatureObservation($function->extendedAttributes->{"Measure
As"}); |
| 2236 $code .= GenerateDeprecationNotification($function->extendedAttributes->{"De
precateAs"}); | 2236 $code .= GenerateDeprecationNotification($function->extendedAttributes->{"De
precateAs"}); |
| 2237 if (HasActivityLogging($forMainWorldSuffix, $function->extendedAttributes, "
Access")) { | 2237 if (HasActivityLogging($forMainWorldSuffix, $function->extendedAttributes, "
Access")) { |
| 2238 $code .= GenerateActivityLogging("Method", $interface, "${name}"); | 2238 $code .= GenerateActivityLogging("Method", $interface, "${name}"); |
| 2239 } | 2239 } |
| 2240 if (HasCustomMethod($function->extendedAttributes)) { | 2240 if (HasCustomMethod($function->extendedAttributes)) { |
| 2241 $code .= " ${v8ClassName}::${name}MethodCustom(args);\n"; | 2241 $code .= " ${v8ClassName}::${name}MethodCustom(info);\n"; |
| 2242 } else { | 2242 } else { |
| 2243 $code .= " ${implClassName}V8Internal::${name}Method${forMainWorldSuf
fix}(args);\n"; | 2243 $code .= " ${implClassName}V8Internal::${name}Method${forMainWorldSuf
fix}(info);\n"; |
| 2244 } | 2244 } |
| 2245 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; | 2245 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; |
| 2246 $code .= "}\n\n"; | 2246 $code .= "}\n\n"; |
| 2247 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2247 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 2248 $implementation{nameSpaceInternal}->add($code); | 2248 $implementation{nameSpaceInternal}->add($code); |
| 2249 } | 2249 } |
| 2250 | 2250 |
| 2251 sub GenerateFunction | 2251 sub GenerateFunction |
| 2252 { | 2252 { |
| 2253 my $function = shift; | 2253 my $function = shift; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2266 } | 2266 } |
| 2267 | 2267 |
| 2268 if (@{$function->{overloads}} > 1) { | 2268 if (@{$function->{overloads}} > 1) { |
| 2269 # Append a number to an overloaded method's name to make it unique: | 2269 # Append a number to an overloaded method's name to make it unique: |
| 2270 $name = $name . $function->{overloadIndex}; | 2270 $name = $name . $function->{overloadIndex}; |
| 2271 } | 2271 } |
| 2272 | 2272 |
| 2273 my $conditionalString = GenerateConditionalString($function); | 2273 my $conditionalString = GenerateConditionalString($function); |
| 2274 my $code = ""; | 2274 my $code = ""; |
| 2275 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 2275 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 2276 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC
allbackInfo<v8::Value>& args)\n"; | 2276 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC
allbackInfo<v8::Value>& info)\n"; |
| 2277 $code .= "{\n"; | 2277 $code .= "{\n"; |
| 2278 | 2278 |
| 2279 if ($name eq "addEventListener" || $name eq "removeEventListener") { | 2279 if ($name eq "addEventListener" || $name eq "removeEventListener") { |
| 2280 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; | 2280 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; |
| 2281 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; | 2281 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; |
| 2282 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" :
"remove"; | 2282 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" :
"remove"; |
| 2283 | 2283 |
| 2284 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2284 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 2285 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2285 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2286 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); | 2286 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
| 2287 AddToImplIncludes("core/frame/DOMWindow.h"); | 2287 AddToImplIncludes("core/frame/DOMWindow.h"); |
| 2288 $code .= <<END; | 2288 $code .= <<END; |
| 2289 EventTarget* impl = ${v8ClassName}::toNative(args.Holder()); | 2289 EventTarget* impl = ${v8ClassName}::toNative(info.Holder()); |
| 2290 if (DOMWindow* window = impl->toDOMWindow()) { | 2290 if (DOMWindow* window = impl->toDOMWindow()) { |
| 2291 ExceptionState es(args.GetIsolate()); | 2291 ExceptionState es(info.GetIsolate()); |
| 2292 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), es)) { | 2292 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), es)) { |
| 2293 es.throwIfNeeded(); | 2293 es.throwIfNeeded(); |
| 2294 return; | 2294 return; |
| 2295 } | 2295 } |
| 2296 | 2296 |
| 2297 if (!window->document()) | 2297 if (!window->document()) |
| 2298 return; | 2298 return; |
| 2299 } | 2299 } |
| 2300 | 2300 |
| 2301 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[
1], false, ListenerFind${lookupType}); | 2301 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[
1], false, ListenerFind${lookupType}); |
| 2302 if (listener) { | 2302 if (listener) { |
| 2303 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, st
ringResource, args[0]); | 2303 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, st
ringResource, info[0]); |
| 2304 impl->${implName}(stringResource, listener${passRefPtrHandling}, args[2]
->BooleanValue()); | 2304 impl->${implName}(stringResource, listener${passRefPtrHandling}, info[2]
->BooleanValue()); |
| 2305 if (!impl->toNode()) | 2305 if (!impl->toNode()) |
| 2306 ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], ${
v8ClassName}::eventListenerCacheIndex, args.GetIsolate()); | 2306 ${hiddenDependencyAction}HiddenDependency(info.Holder(), info[1], ${
v8ClassName}::eventListenerCacheIndex, info.GetIsolate()); |
| 2307 } | 2307 } |
| 2308 } | 2308 } |
| 2309 | 2309 |
| 2310 END | 2310 END |
| 2311 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2311 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 2312 $implementation{nameSpaceInternal}->add($code); | 2312 $implementation{nameSpaceInternal}->add($code); |
| 2313 return; | 2313 return; |
| 2314 } | 2314 } |
| 2315 | 2315 |
| 2316 $code .= GenerateArgumentsCountCheck($function, $interface); | 2316 $code .= GenerateArgumentsCountCheck($function, $interface); |
| 2317 | 2317 |
| 2318 if ($name eq "set" and IsConstructorTemplate($interface, "TypedArray")) { | 2318 if ($name eq "set" and IsConstructorTemplate($interface, "TypedArray")) { |
| 2319 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); | 2319 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); |
| 2320 $code .= <<END; | 2320 $code .= <<END; |
| 2321 setWebGLArrayHelper<$implClassName, ${v8ClassName}>(args); | 2321 setWebGLArrayHelper<$implClassName, ${v8ClassName}>(info); |
| 2322 } | 2322 } |
| 2323 | 2323 |
| 2324 END | 2324 END |
| 2325 $implementation{nameSpaceInternal}->add($code); | 2325 $implementation{nameSpaceInternal}->add($code); |
| 2326 return; | 2326 return; |
| 2327 } | 2327 } |
| 2328 | 2328 |
| 2329 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); | 2329 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); |
| 2330 | 2330 |
| 2331 if ($svgNativeType) { | 2331 if ($svgNativeType) { |
| 2332 my $nativeClassName = GetNativeType($interfaceName); | 2332 my $nativeClassName = GetNativeType($interfaceName); |
| 2333 if ($interfaceName =~ /List$/) { | 2333 if ($interfaceName =~ /List$/) { |
| 2334 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.H
older());\n"; | 2334 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(info.H
older());\n"; |
| 2335 } else { | 2335 } else { |
| 2336 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2336 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2337 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2337 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2338 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2338 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| 2339 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(ar
gs.Holder());\n"; | 2339 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(in
fo.Holder());\n"; |
| 2340 $code .= " if (wrapper->isReadOnly()) {\n"; | 2340 $code .= " if (wrapper->isReadOnly()) {\n"; |
| 2341 $code .= " setDOMException(NoModificationAllowedError, Except
ionMessages::failedToExecute(\"${name}\", \"${interfaceName}\", \"The object is
read-only.\"), args.GetIsolate());\n"; | 2341 $code .= " setDOMException(NoModificationAllowedError, Except
ionMessages::failedToExecute(\"${name}\", \"${interfaceName}\", \"The object is
read-only.\"), info.GetIsolate());\n"; |
| 2342 $code .= " return;\n"; | 2342 $code .= " return;\n"; |
| 2343 $code .= " }\n"; | 2343 $code .= " }\n"; |
| 2344 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac
eName); | 2344 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac
eName); |
| 2345 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; | 2345 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; |
| 2346 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; | 2346 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
| 2347 } | 2347 } |
| 2348 } elsif (!$function->isStatic) { | 2348 } elsif (!$function->isStatic) { |
| 2349 $code .= <<END; | 2349 $code .= <<END; |
| 2350 ${implClassName}* imp = ${v8ClassName}::toNative(args.Holder()); | 2350 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 2351 END | 2351 END |
| 2352 } | 2352 } |
| 2353 | 2353 |
| 2354 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); | 2354 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); |
| 2355 | 2355 |
| 2356 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} ||
($interface->extendedAttributes->{"CheckSecurity"} && !$function->extendedAttri
butes->{"DoNotCheckSecurity"}); | 2356 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} ||
($interface->extendedAttributes->{"CheckSecurity"} && !$function->extendedAttri
butes->{"DoNotCheckSecurity"}); |
| 2357 if ($raisesExceptions) { | 2357 if ($raisesExceptions) { |
| 2358 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2358 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2359 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2359 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2360 $code .= " ExceptionState es(args.GetIsolate());\n"; | 2360 $code .= " ExceptionState es(info.GetIsolate());\n"; |
| 2361 } | 2361 } |
| 2362 | 2362 |
| 2363 # Check domain security if needed | 2363 # Check domain security if needed |
| 2364 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende
dAttributes->{"DoNotCheckSecurity"}) { | 2364 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende
dAttributes->{"DoNotCheckSecurity"}) { |
| 2365 # We have not find real use cases yet. | 2365 # We have not find real use cases yet. |
| 2366 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2366 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 2367 $code .= <<END; | 2367 $code .= <<END; |
| 2368 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { | 2368 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { |
| 2369 es.throwIfNeeded(); | 2369 es.throwIfNeeded(); |
| 2370 return; | 2370 return; |
| 2371 } | 2371 } |
| 2372 END | 2372 END |
| 2373 } | 2373 } |
| 2374 | 2374 |
| 2375 if ($function->extendedAttributes->{"CheckSecurityForNode"}) { | 2375 if ($function->extendedAttributes->{"CheckSecurityForNode"}) { |
| 2376 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2376 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 2377 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get
ImplName($function) . "(es), es)) {\n"; | 2377 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get
ImplName($function) . "(es), es)) {\n"; |
| 2378 $code .= " v8SetReturnValueNull(args);\n"; | 2378 $code .= " v8SetReturnValueNull(info);\n"; |
| 2379 $code .= " es.throwIfNeeded();\n"; | 2379 $code .= " es.throwIfNeeded();\n"; |
| 2380 $code .= " return;\n"; | 2380 $code .= " return;\n"; |
| 2381 $code .= " }\n"; | 2381 $code .= " }\n"; |
| 2382 END | 2382 END |
| 2383 } | 2383 } |
| 2384 | 2384 |
| 2385 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, $forMainWorldSuffix); | 2385 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, $forMainWorldSuffix); |
| 2386 $code .= $parameterCheckString; | 2386 $code .= $parameterCheckString; |
| 2387 | 2387 |
| 2388 # Build the function call string. | 2388 # Build the function call string. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2407 $code .= $indent . "if (!currentState)\n"; | 2407 $code .= $indent . "if (!currentState)\n"; |
| 2408 $code .= $indent . " return" . ($returnVoid ? "" : " v8Undefined()")
. ";\n"; | 2408 $code .= $indent . " return" . ($returnVoid ? "" : " v8Undefined()")
. ";\n"; |
| 2409 $code .= $indent . "ScriptState& state = *currentState;\n"; | 2409 $code .= $indent . "ScriptState& state = *currentState;\n"; |
| 2410 push(@callWithArgs, "&state"); | 2410 push(@callWithArgs, "&state"); |
| 2411 } | 2411 } |
| 2412 if (ExtendedAttributeContains($callWith, "ExecutionContext")) { | 2412 if (ExtendedAttributeContains($callWith, "ExecutionContext")) { |
| 2413 $code .= $indent . "ExecutionContext* scriptContext = getExecutionContex
t();\n"; | 2413 $code .= $indent . "ExecutionContext* scriptContext = getExecutionContex
t();\n"; |
| 2414 push(@callWithArgs, "scriptContext"); | 2414 push(@callWithArgs, "scriptContext"); |
| 2415 } | 2415 } |
| 2416 if ($function and ExtendedAttributeContains($callWith, "ScriptArguments")) { | 2416 if ($function and ExtendedAttributeContains($callWith, "ScriptArguments")) { |
| 2417 $code .= $indent . "RefPtr<ScriptArguments> scriptArguments(createScript
Arguments(args, " . @{$function->parameters} . "));\n"; | 2417 $code .= $indent . "RefPtr<ScriptArguments> scriptArguments(createScript
Arguments(info, " . @{$function->parameters} . "));\n"; |
| 2418 push(@callWithArgs, "scriptArguments.release()"); | 2418 push(@callWithArgs, "scriptArguments.release()"); |
| 2419 AddToImplIncludes("bindings/v8/ScriptCallStackFactory.h"); | 2419 AddToImplIncludes("bindings/v8/ScriptCallStackFactory.h"); |
| 2420 AddToImplIncludes("core/inspector/ScriptArguments.h"); | 2420 AddToImplIncludes("core/inspector/ScriptArguments.h"); |
| 2421 } | 2421 } |
| 2422 if (ExtendedAttributeContains($callWith, "ActiveWindow")) { | 2422 if (ExtendedAttributeContains($callWith, "ActiveWindow")) { |
| 2423 push(@callWithArgs, "activeDOMWindow()"); | 2423 push(@callWithArgs, "activeDOMWindow()"); |
| 2424 } | 2424 } |
| 2425 if (ExtendedAttributeContains($callWith, "FirstWindow")) { | 2425 if (ExtendedAttributeContains($callWith, "FirstWindow")) { |
| 2426 push(@callWithArgs, "firstDOMWindow()"); | 2426 push(@callWithArgs, "firstDOMWindow()"); |
| 2427 } | 2427 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2443 if ($param->isOptional or $param->isVariadic) { | 2443 if ($param->isOptional or $param->isVariadic) { |
| 2444 $allowNonOptional = 0; | 2444 $allowNonOptional = 0; |
| 2445 } else { | 2445 } else { |
| 2446 die "An argument must not be declared to be optional unless all subs
equent arguments to the operation are also optional." if !$allowNonOptional; | 2446 die "An argument must not be declared to be optional unless all subs
equent arguments to the operation are also optional." if !$allowNonOptional; |
| 2447 $numMandatoryParams++; | 2447 $numMandatoryParams++; |
| 2448 } | 2448 } |
| 2449 } | 2449 } |
| 2450 | 2450 |
| 2451 my $argumentsCountCheckString = ""; | 2451 my $argumentsCountCheckString = ""; |
| 2452 if ($numMandatoryParams >= 1) { | 2452 if ($numMandatoryParams >= 1) { |
| 2453 $argumentsCountCheckString .= " if (UNLIKELY(args.Length() < $numMand
atoryParams)) {\n"; | 2453 $argumentsCountCheckString .= " if (UNLIKELY(info.Length() < $numMand
atoryParams)) {\n"; |
| 2454 $argumentsCountCheckString .= " throwTypeError(ExceptionMessages:
:failedToExecute(\"$functionName\", \"$interfaceName\", ExceptionMessages::notEn
oughArguments($numMandatoryParams, args.Length())), args.GetIsolate());\n"; | 2454 $argumentsCountCheckString .= " throwTypeError(ExceptionMessages:
:failedToExecute(\"$functionName\", \"$interfaceName\", ExceptionMessages::notEn
oughArguments($numMandatoryParams, info.Length())), info.GetIsolate());\n"; |
| 2455 $argumentsCountCheckString .= " return;\n"; | 2455 $argumentsCountCheckString .= " return;\n"; |
| 2456 $argumentsCountCheckString .= " }\n"; | 2456 $argumentsCountCheckString .= " }\n"; |
| 2457 } | 2457 } |
| 2458 return $argumentsCountCheckString; | 2458 return $argumentsCountCheckString; |
| 2459 } | 2459 } |
| 2460 | 2460 |
| 2461 sub GenerateParametersCheck | 2461 sub GenerateParametersCheck |
| 2462 { | 2462 { |
| 2463 my $function = shift; | 2463 my $function = shift; |
| 2464 my $interface = shift; | 2464 my $interface = shift; |
| 2465 my $forMainWorldSuffix = shift; | 2465 my $forMainWorldSuffix = shift; |
| 2466 my $style = shift || "new"; | 2466 my $style = shift || "new"; |
| 2467 | 2467 |
| 2468 my $functionName = $function->name; | 2468 my $functionName = $function->name; |
| 2469 my $interfaceName = $interface->name; | 2469 my $interfaceName = $interface->name; |
| 2470 my $implClassName = GetImplName($interface); | 2470 my $implClassName = GetImplName($interface); |
| 2471 | 2471 |
| 2472 my $parameterCheckString = ""; | 2472 my $parameterCheckString = ""; |
| 2473 my $paramIndex = 0; | 2473 my $paramIndex = 0; |
| 2474 my %replacements = (); | 2474 my %replacements = (); |
| 2475 | 2475 |
| 2476 foreach my $parameter (@{$function->parameters}) { | 2476 foreach my $parameter (@{$function->parameters}) { |
| 2477 my $humanFriendlyIndex = $paramIndex + 1; | 2477 my $humanFriendlyIndex = $paramIndex + 1; |
| 2478 my $nativeType = GetNativeType($parameter->type, $parameter->extendedAtt
ributes, "parameter"); | 2478 my $nativeType = GetNativeType($parameter->type, $parameter->extendedAtt
ributes, "parameter"); |
| 2479 | 2479 |
| 2480 # Optional arguments without [Default=...] should generate an early call
with fewer arguments. | 2480 # Optional arguments without [Default=...] should generate an early call
with fewer arguments. |
| 2481 # Optional Dictionary arguments always considered to have default of emp
ty dictionary. | 2481 # Optional Dictionary arguments always considered to have default of emp
ty dictionary. |
| 2482 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default
"} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { | 2482 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default
"} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { |
| 2483 $parameterCheckString .= <<END; | 2483 $parameterCheckString .= <<END; |
| 2484 if (UNLIKELY(args.Length() <= $paramIndex)) { | 2484 if (UNLIKELY(info.Length() <= $paramIndex)) { |
| 2485 END | 2485 END |
| 2486 $parameterCheckString .= GenerateFunctionCallString($function, $para
mIndex, " " x 2, $interface, $forMainWorldSuffix, %replacements); | 2486 $parameterCheckString .= GenerateFunctionCallString($function, $para
mIndex, " " x 2, $interface, $forMainWorldSuffix, %replacements); |
| 2487 $parameterCheckString .= <<END; | 2487 $parameterCheckString .= <<END; |
| 2488 return; | 2488 return; |
| 2489 } | 2489 } |
| 2490 END | 2490 END |
| 2491 } | 2491 } |
| 2492 | 2492 |
| 2493 my $parameterName = $parameter->name; | 2493 my $parameterName = $parameter->name; |
| 2494 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2494 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2495 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2495 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2496 if (IsCallbackInterface($parameter->type)) { | 2496 if (IsCallbackInterface($parameter->type)) { |
| 2497 my $v8ClassName = "V8" . $parameter->type; | 2497 my $v8ClassName = "V8" . $parameter->type; |
| 2498 AddToImplIncludes("$v8ClassName.h"); | 2498 AddToImplIncludes("$v8ClassName.h"); |
| 2499 if ($parameter->isOptional) { | 2499 if ($parameter->isOptional) { |
| 2500 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $
parameterName;\n"; | 2500 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $
parameterName;\n"; |
| 2501 $parameterCheckString .= " if (args.Length() > $paramIndex &&
!args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; | 2501 $parameterCheckString .= " if (info.Length() > $paramIndex &&
!info[$paramIndex]->IsNull() && !info[$paramIndex]->IsUndefined()) {\n"; |
| 2502 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc
tion()) {\n"; | 2502 $parameterCheckString .= " if (!info[$paramIndex]->IsFunc
tion()) {\n"; |
| 2503 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback pr
ovided as parameter $humanFriendlyIndex is not a function.\"), args.GetIsolate()
);\n"; | 2503 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback pr
ovided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate()
);\n"; |
| 2504 $parameterCheckString .= " return;\n"; | 2504 $parameterCheckString .= " return;\n"; |
| 2505 $parameterCheckString .= " }\n"; | 2505 $parameterCheckString .= " }\n"; |
| 2506 $parameterCheckString .= " $parameterName = ${v8ClassName
}::create(args[$paramIndex], getExecutionContext());\n"; | 2506 $parameterCheckString .= " $parameterName = ${v8ClassName
}::create(info[$paramIndex], getExecutionContext());\n"; |
| 2507 $parameterCheckString .= " }\n"; | 2507 $parameterCheckString .= " }\n"; |
| 2508 } else { | 2508 } else { |
| 2509 $parameterCheckString .= " if (args.Length() <= $paramIndex |
| "; | 2509 $parameterCheckString .= " if (info.Length() <= $paramIndex |
| "; |
| 2510 if ($parameter->isNullable) { | 2510 if ($parameter->isNullable) { |
| 2511 $parameterCheckString .= "!(args[$paramIndex]->IsFunction()
|| args[$paramIndex]->IsNull())"; | 2511 $parameterCheckString .= "!(info[$paramIndex]->IsFunction()
|| info[$paramIndex]->IsNull())"; |
| 2512 } else { | 2512 } else { |
| 2513 $parameterCheckString .= "!args[$paramIndex]->IsFunction()"; | 2513 $parameterCheckString .= "!info[$paramIndex]->IsFunction()"; |
| 2514 } | 2514 } |
| 2515 $parameterCheckString .= ") {\n"; | 2515 $parameterCheckString .= ") {\n"; |
| 2516 $parameterCheckString .= " throwTypeError(ExceptionMessag
es::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provid
ed as parameter $humanFriendlyIndex is not a function.\"), args.GetIsolate());\n
"; | 2516 $parameterCheckString .= " throwTypeError(ExceptionMessag
es::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provid
ed as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n
"; |
| 2517 $parameterCheckString .= " return;\n"; | 2517 $parameterCheckString .= " return;\n"; |
| 2518 $parameterCheckString .= " }\n"; | 2518 $parameterCheckString .= " }\n"; |
| 2519 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $
parameterName = "; | 2519 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $
parameterName = "; |
| 2520 $parameterCheckString .= "args[$paramIndex]->IsNull() ? 0 : " if
$parameter->isNullable; | 2520 $parameterCheckString .= "info[$paramIndex]->IsNull() ? 0 : " if
$parameter->isNullable; |
| 2521 $parameterCheckString .= "${v8ClassName}::create(args[$paramInde
x], getExecutionContext());\n"; | 2521 $parameterCheckString .= "${v8ClassName}::create(info[$paramInde
x], getExecutionContext());\n"; |
| 2522 } | 2522 } |
| 2523 } elsif ($parameter->extendedAttributes->{"Clamp"}) { | 2523 } elsif ($parameter->extendedAttributes->{"Clamp"}) { |
| 2524 my $nativeValue = "${parameterName}NativeValue"; | 2524 my $nativeValue = "${parameterName}NativeValue"; |
| 2525 my $idlType = $parameter->type; | 2525 my $idlType = $parameter->type; |
| 2526 $parameterCheckString .= " $nativeType $parameterName = 0;\n"
; | 2526 $parameterCheckString .= " $nativeType $parameterName = 0;\n"
; |
| 2527 $parameterCheckString .= " V8TRYCATCH_VOID(double, $nativeVal
ue, args[$paramIndex]->NumberValue());\n"; | 2527 $parameterCheckString .= " V8TRYCATCH_VOID(double, $nativeVal
ue, info[$paramIndex]->NumberValue());\n"; |
| 2528 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; | 2528 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; |
| 2529 $parameterCheckString .= " $parameterName = clampTo<$idlT
ype>($nativeValue);\n"; | 2529 $parameterCheckString .= " $parameterName = clampTo<$idlT
ype>($nativeValue);\n"; |
| 2530 } elsif ($parameter->type eq "SerializedScriptValue") { | 2530 } elsif ($parameter->type eq "SerializedScriptValue") { |
| 2531 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 2531 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
| 2532 $parameterCheckString .= " bool ${parameterName}DidThrow = false;
\n"; | 2532 $parameterCheckString .= " bool ${parameterName}DidThrow = false;
\n"; |
| 2533 $parameterCheckString .= " $nativeType $parameterName = Serialize
dScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow, args.Get
Isolate());\n"; | 2533 $parameterCheckString .= " $nativeType $parameterName = Serialize
dScriptValue::create(info[$paramIndex], 0, 0, ${parameterName}DidThrow, info.Get
Isolate());\n"; |
| 2534 $parameterCheckString .= " if (${parameterName}DidThrow)\n"; | 2534 $parameterCheckString .= " if (${parameterName}DidThrow)\n"; |
| 2535 $parameterCheckString .= " return;\n"; | 2535 $parameterCheckString .= " return;\n"; |
| 2536 } elsif ($parameter->isVariadic) { | 2536 } elsif ($parameter->isVariadic) { |
| 2537 my $nativeElementType = GetNativeType($parameter->type); | 2537 my $nativeElementType = GetNativeType($parameter->type); |
| 2538 if ($nativeElementType =~ />$/) { | 2538 if ($nativeElementType =~ />$/) { |
| 2539 $nativeElementType .= " "; | 2539 $nativeElementType .= " "; |
| 2540 } | 2540 } |
| 2541 | 2541 |
| 2542 my $argType = $parameter->type; | 2542 my $argType = $parameter->type; |
| 2543 if (IsWrapperType($argType)) { | 2543 if (IsWrapperType($argType)) { |
| 2544 $parameterCheckString .= " Vector<$nativeElementType> $parame
terName;\n"; | 2544 $parameterCheckString .= " Vector<$nativeElementType> $parame
terName;\n"; |
| 2545 $parameterCheckString .= " for (int i = $paramIndex; i < args
.Length(); ++i) {\n"; | 2545 $parameterCheckString .= " for (int i = $paramIndex; i < info
.Length(); ++i) {\n"; |
| 2546 $parameterCheckString .= " if (!V8${argType}::HasInstance
(args[i], args.GetIsolate(), worldType(args.GetIsolate()))) {\n"; | 2546 $parameterCheckString .= " if (!V8${argType}::HasInstance
(info[i], info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; |
| 2547 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $huma
nFriendlyIndex is not of type \'$argType\'.\"), args.GetIsolate());\n"; | 2547 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $huma
nFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; |
| 2548 $parameterCheckString .= " return;\n"; | 2548 $parameterCheckString .= " return;\n"; |
| 2549 $parameterCheckString .= " }\n"; | 2549 $parameterCheckString .= " }\n"; |
| 2550 $parameterCheckString .= " $parameterName.append(V8${argT
ype}::toNative(v8::Handle<v8::Object>::Cast(args[i])));\n"; | 2550 $parameterCheckString .= " $parameterName.append(V8${argT
ype}::toNative(v8::Handle<v8::Object>::Cast(info[i])));\n"; |
| 2551 $parameterCheckString .= " }\n"; | 2551 $parameterCheckString .= " }\n"; |
| 2552 } else { | 2552 } else { |
| 2553 $parameterCheckString .= " V8TRYCATCH_VOID(Vector<$nativeElem
entType>, $parameterName, toNativeArguments<$nativeElementType>(args, $paramInde
x));\n"; | 2553 $parameterCheckString .= " V8TRYCATCH_VOID(Vector<$nativeElem
entType>, $parameterName, toNativeArguments<$nativeElementType>(info, $paramInde
x));\n"; |
| 2554 } | 2554 } |
| 2555 } elsif ($nativeType =~ /^V8StringResource/) { | 2555 } elsif ($nativeType =~ /^V8StringResource/) { |
| 2556 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; | 2556 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; |
| 2557 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(args, $paramIndex)" : "args[$paramIndex]"; | 2557 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(info, $paramIndex)" : "info[$paramIndex]"; |
| 2558 my $stringResourceParameterName = $parameterName; | 2558 my $stringResourceParameterName = $parameterName; |
| 2559 my $isNullable = $parameter->isNullable && !IsRefPtrType($parameter-
>type); | 2559 my $isNullable = $parameter->isNullable && !IsRefPtrType($parameter-
>type); |
| 2560 if ($isNullable) { | 2560 if ($isNullable) { |
| 2561 $parameterCheckString .= " bool ${parameterName}IsNull = $jsV
alue->IsNull();\n"; | 2561 $parameterCheckString .= " bool ${parameterName}IsNull = $jsV
alue->IsNull();\n"; |
| 2562 $stringResourceParameterName .= "StringResource"; | 2562 $stringResourceParameterName .= "StringResource"; |
| 2563 } | 2563 } |
| 2564 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $stringResourcePa
rameterName, " ", "args.GetIsolate()"); | 2564 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $stringResourcePa
rameterName, " ", "info.GetIsolate()"); |
| 2565 $parameterCheckString .= " String $parameterName = $stringResourc
eParameterName;\n" if $isNullable; | 2565 $parameterCheckString .= " String $parameterName = $stringResourc
eParameterName;\n" if $isNullable; |
| 2566 if (IsEnumType($parameter->type)) { | 2566 if (IsEnumType($parameter->type)) { |
| 2567 my @enumValues = ValidEnumValues($parameter->type); | 2567 my @enumValues = ValidEnumValues($parameter->type); |
| 2568 my @validEqualities = (); | 2568 my @validEqualities = (); |
| 2569 foreach my $enumValue (@enumValues) { | 2569 foreach my $enumValue (@enumValues) { |
| 2570 push(@validEqualities, "string == \"$enumValue\""); | 2570 push(@validEqualities, "string == \"$enumValue\""); |
| 2571 } | 2571 } |
| 2572 my $enumValidationExpression = join(" || ", @validEqualities); | 2572 my $enumValidationExpression = join(" || ", @validEqualities); |
| 2573 $parameterCheckString .= " String string = $parameterName;\n
"; | 2573 $parameterCheckString .= " String string = $parameterName;\n
"; |
| 2574 $parameterCheckString .= " if (!($enumValidationExpression))
{\n"; | 2574 $parameterCheckString .= " if (!($enumValidationExpression))
{\n"; |
| 2575 $parameterCheckString .= " throwTypeError(ExceptionMessag
es::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFri
endlyIndex (\'\" + string + \"\') is not a valid enum value.\"), args.GetIsolate
());\n"; | 2575 $parameterCheckString .= " throwTypeError(ExceptionMessag
es::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFri
endlyIndex (\'\" + string + \"\') is not a valid enum value.\"), info.GetIsolate
());\n"; |
| 2576 $parameterCheckString .= " return;\n"; | 2576 $parameterCheckString .= " return;\n"; |
| 2577 $parameterCheckString .= " }\n"; | 2577 $parameterCheckString .= " }\n"; |
| 2578 } | 2578 } |
| 2579 } else { | 2579 } else { |
| 2580 # If the "StrictTypeChecking" extended attribute is present, and the
argument's type is an | 2580 # If the "StrictTypeChecking" extended attribute is present, and the
argument's type is an |
| 2581 # interface type, then if the incoming value does not implement that
interface, a TypeError | 2581 # interface type, then if the incoming value does not implement that
interface, a TypeError |
| 2582 # is thrown rather than silently passing NULL to the C++ code. | 2582 # is thrown rather than silently passing NULL to the C++ code. |
| 2583 # Per the Web IDL and ECMAScript specifications, incoming values can
always be converted | 2583 # Per the Web IDL and ECMAScript specifications, incoming values can
always be converted |
| 2584 # to both strings and numbers, so do not throw TypeError if the argu
ment is of these | 2584 # to both strings and numbers, so do not throw TypeError if the argu
ment is of these |
| 2585 # types. | 2585 # types. |
| 2586 if ($function->extendedAttributes->{"StrictTypeChecking"}) { | 2586 if ($function->extendedAttributes->{"StrictTypeChecking"}) { |
| 2587 my $argValue = "args[$paramIndex]"; | 2587 my $argValue = "info[$paramIndex]"; |
| 2588 my $argType = $parameter->type; | 2588 my $argType = $parameter->type; |
| 2589 if (IsWrapperType($argType)) { | 2589 if (IsWrapperType($argType)) { |
| 2590 $parameterCheckString .= " if (args.Length() > $paramInde
x && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue, args
.GetIsolate(), worldType(args.GetIsolate()))) {\n"; | 2590 $parameterCheckString .= " if (info.Length() > $paramInde
x && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue, info
.GetIsolate(), worldType(info.GetIsolate()))) {\n"; |
| 2591 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $huma
nFriendlyIndex is not of type \'$argType\'.\"), args.GetIsolate());\n"; | 2591 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $huma
nFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; |
| 2592 $parameterCheckString .= " return;\n"; | 2592 $parameterCheckString .= " return;\n"; |
| 2593 $parameterCheckString .= " }\n"; | 2593 $parameterCheckString .= " }\n"; |
| 2594 } | 2594 } |
| 2595 } | 2595 } |
| 2596 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; | 2596 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; |
| 2597 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(args, $paramIndex)" : "args[$paramIndex]"; | 2597 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(info, $paramIndex)" : "info[$paramIndex]"; |
| 2598 my $isNullable = $parameter->isNullable && !IsRefPtrType($parameter-
>type); | 2598 my $isNullable = $parameter->isNullable && !IsRefPtrType($parameter-
>type); |
| 2599 $parameterCheckString .= " bool ${parameterName}IsNull = $jsValue
->IsNull();\n" if $isNullable; | 2599 $parameterCheckString .= " bool ${parameterName}IsNull = $jsValue
->IsNull();\n" if $isNullable; |
| 2600 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $parameterName, "
", "args.GetIsolate()"); | 2600 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $parameterName, "
", "info.GetIsolate()"); |
| 2601 if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise') { | 2601 if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise') { |
| 2602 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN
ull() && !$parameterName.isObject()) {\n"; | 2602 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN
ull() && !$parameterName.isObject()) {\n"; |
| 2603 if ($functionName eq "Constructor") { | 2603 if ($functionName eq "Constructor") { |
| 2604 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToConstruct(\"$interfaceName\", \"parameter ${humanFriendlyIndex}
('${parameterName}') is not an object.\"), args.GetIsolate());\n"; | 2604 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToConstruct(\"$interfaceName\", \"parameter ${humanFriendlyIndex}
('${parameterName}') is not an object.\"), info.GetIsolate());\n"; |
| 2605 } else { | 2605 } else { |
| 2606 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter ${hum
anFriendlyIndex} ('${parameterName}') is not an object.\"), args.GetIsolate());\
n"; | 2606 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter ${hum
anFriendlyIndex} ('${parameterName}') is not an object.\"), info.GetIsolate());\
n"; |
| 2607 } | 2607 } |
| 2608 $parameterCheckString .= " return;\n"; | 2608 $parameterCheckString .= " return;\n"; |
| 2609 $parameterCheckString .= " }\n"; | 2609 $parameterCheckString .= " }\n"; |
| 2610 } | 2610 } |
| 2611 } | 2611 } |
| 2612 | 2612 |
| 2613 $paramIndex++; | 2613 $paramIndex++; |
| 2614 } | 2614 } |
| 2615 return ($parameterCheckString, $paramIndex, %replacements); | 2615 return ($parameterCheckString, $paramIndex, %replacements); |
| 2616 } | 2616 } |
| 2617 | 2617 |
| 2618 sub GenerateOverloadedConstructorCallback | 2618 sub GenerateOverloadedConstructorCallback |
| 2619 { | 2619 { |
| 2620 my $interface = shift; | 2620 my $interface = shift; |
| 2621 my $interfaceName = $interface->name; | 2621 my $interfaceName = $interface->name; |
| 2622 my $implClassName = GetImplName($interface); | 2622 my $implClassName = GetImplName($interface); |
| 2623 | 2623 |
| 2624 my $code = ""; | 2624 my $code = ""; |
| 2625 $code .= <<END; | 2625 $code .= <<END; |
| 2626 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) | 2626 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 2627 { | 2627 { |
| 2628 END | 2628 END |
| 2629 my $leastNumMandatoryParams = 255; | 2629 my $leastNumMandatoryParams = 255; |
| 2630 foreach my $constructor (@{$interface->constructors}) { | 2630 foreach my $constructor (@{$interface->constructors}) { |
| 2631 my $name = "constructor" . $constructor->overloadedIndex; | 2631 my $name = "constructor" . $constructor->overloadedIndex; |
| 2632 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($constructor); | 2632 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($constructor); |
| 2633 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); | 2633 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); |
| 2634 $code .= " if ($parametersCheck) {\n"; | 2634 $code .= " if ($parametersCheck) {\n"; |
| 2635 $code .= " ${implClassName}V8Internal::${name}(args);\n"; | 2635 $code .= " ${implClassName}V8Internal::${name}(info);\n"; |
| 2636 $code .= " return;\n"; | 2636 $code .= " return;\n"; |
| 2637 $code .= " }\n"; | 2637 $code .= " }\n"; |
| 2638 } | 2638 } |
| 2639 if ($leastNumMandatoryParams >= 1) { | 2639 if ($leastNumMandatoryParams >= 1) { |
| 2640 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2640 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2641 $code .= " if (UNLIKELY(args.Length() < $leastNumMandatoryParams)) {\
n"; | 2641 $code .= " if (UNLIKELY(info.Length() < $leastNumMandatoryParams)) {\
n"; |
| 2642 | 2642 |
| 2643 $code .= " throwTypeError(ExceptionMessages::failedToConstruct(\"
$interfaceName\", ExceptionMessages::notEnoughArguments($leastNumMandatoryParams
, args.Length())), args.GetIsolate());\n"; | 2643 $code .= " throwTypeError(ExceptionMessages::failedToConstruct(\"
$interfaceName\", ExceptionMessages::notEnoughArguments($leastNumMandatoryParams
, info.Length())), info.GetIsolate());\n"; |
| 2644 $code .= " return;\n"; | 2644 $code .= " return;\n"; |
| 2645 $code .= " }\n"; | 2645 $code .= " }\n"; |
| 2646 } | 2646 } |
| 2647 $code .= <<END; | 2647 $code .= <<END; |
| 2648 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 2648 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 2649 return; | 2649 return; |
| 2650 END | 2650 END |
| 2651 $code .= "}\n\n"; | 2651 $code .= "}\n\n"; |
| 2652 $implementation{nameSpaceInternal}->add($code); | 2652 $implementation{nameSpaceInternal}->add($code); |
| 2653 } | 2653 } |
| 2654 | 2654 |
| 2655 sub GenerateSingleConstructorCallback | 2655 sub GenerateSingleConstructorCallback |
| 2656 { | 2656 { |
| 2657 my $interface = shift; | 2657 my $interface = shift; |
| 2658 my $function = shift; | 2658 my $function = shift; |
| 2659 | 2659 |
| 2660 my $implClassName = GetImplName($interface); | 2660 my $implClassName = GetImplName($interface); |
| 2661 my $v8ClassName = GetV8ClassName($interface); | 2661 my $v8ClassName = GetV8ClassName($interface); |
| 2662 my $overloadedIndexString = ""; | 2662 my $overloadedIndexString = ""; |
| 2663 if ($function->overloadedIndex > 0) { | 2663 if ($function->overloadedIndex > 0) { |
| 2664 $overloadedIndexString .= $function->overloadedIndex; | 2664 $overloadedIndexString .= $function->overloadedIndex; |
| 2665 } | 2665 } |
| 2666 | 2666 |
| 2667 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; | 2667 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; |
| 2668 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { | 2668 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { |
| 2669 $raisesExceptions = 1; | 2669 $raisesExceptions = 1; |
| 2670 } | 2670 } |
| 2671 | 2671 |
| 2672 my @beforeArgumentList; | 2672 my @beforeArgumentList; |
| 2673 my @afterArgumentList; | 2673 my @afterArgumentList; |
| 2674 my $code = ""; | 2674 my $code = ""; |
| 2675 $code .= <<END; | 2675 $code .= <<END; |
| 2676 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v
8::Value>& args) | 2676 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v
8::Value>& info) |
| 2677 { | 2677 { |
| 2678 END | 2678 END |
| 2679 | 2679 |
| 2680 if ($function->overloadedIndex == 0) { | 2680 if ($function->overloadedIndex == 0) { |
| 2681 $code .= GenerateArgumentsCountCheck($function, $interface); | 2681 $code .= GenerateArgumentsCountCheck($function, $interface); |
| 2682 } | 2682 } |
| 2683 | 2683 |
| 2684 if ($raisesExceptions) { | 2684 if ($raisesExceptions) { |
| 2685 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2685 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2686 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2686 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2687 $code .= " ExceptionState es(args.GetIsolate());\n"; | 2687 $code .= " ExceptionState es(info.GetIsolate());\n"; |
| 2688 } | 2688 } |
| 2689 | 2689 |
| 2690 # FIXME: Currently [Constructor(...)] does not yet support optional argument
s without [Default=...] | 2690 # FIXME: Currently [Constructor(...)] does not yet support optional argument
s without [Default=...] |
| 2691 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, ""); | 2691 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, ""); |
| 2692 $code .= $parameterCheckString; | 2692 $code .= $parameterCheckString; |
| 2693 | 2693 |
| 2694 if ($interface->extendedAttributes->{"ConstructorCallWith"}) { | 2694 if ($interface->extendedAttributes->{"ConstructorCallWith"}) { |
| 2695 if ($interface->extendedAttributes->{"ConstructorCallWith"} eq "Executio
nContext") { | 2695 if ($interface->extendedAttributes->{"ConstructorCallWith"} eq "Executio
nContext") { |
| 2696 push(@beforeArgumentList, "context"); | 2696 push(@beforeArgumentList, "context"); |
| 2697 $code .= "\n"; | 2697 $code .= "\n"; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2715 push(@argumentList, $replacements{$parameter->name}); | 2715 push(@argumentList, $replacements{$parameter->name}); |
| 2716 } else { | 2716 } else { |
| 2717 push(@argumentList, $parameter->name); | 2717 push(@argumentList, $parameter->name); |
| 2718 } | 2718 } |
| 2719 $index++; | 2719 $index++; |
| 2720 } | 2720 } |
| 2721 | 2721 |
| 2722 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr
gumentList); | 2722 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr
gumentList); |
| 2723 $code .= "\n"; | 2723 $code .= "\n"; |
| 2724 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg
umentString});\n"; | 2724 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg
umentString});\n"; |
| 2725 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; | 2725 $code .= " v8::Handle<v8::Object> wrapper = info.Holder();\n"; |
| 2726 | 2726 |
| 2727 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { | 2727 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { |
| 2728 $code .= " if (es.throwIfNeeded())\n"; | 2728 $code .= " if (es.throwIfNeeded())\n"; |
| 2729 $code .= " return;\n"; | 2729 $code .= " return;\n"; |
| 2730 } | 2730 } |
| 2731 | 2731 |
| 2732 $code .= <<END; | 2732 $code .= <<END; |
| 2733 | 2733 |
| 2734 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${
v8ClassName}::wrapperTypeInfo, wrapper, args.GetIsolate(), WrapperConfiguration:
:Dependent); | 2734 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${
v8ClassName}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration:
:Dependent); |
| 2735 args.GetReturnValue().Set(wrapper); | 2735 info.GetReturnValue().Set(wrapper); |
| 2736 } | 2736 } |
| 2737 | 2737 |
| 2738 END | 2738 END |
| 2739 $implementation{nameSpaceInternal}->add($code); | 2739 $implementation{nameSpaceInternal}->add($code); |
| 2740 } | 2740 } |
| 2741 | 2741 |
| 2742 # The Web IDL specification states that Interface objects for interfaces MUST ha
ve a property named | 2742 # The Web IDL specification states that Interface objects for interfaces MUST ha
ve a property named |
| 2743 # "length" that returns the length of the shortest argument list of the entries
in the effective | 2743 # "length" that returns the length of the shortest argument list of the entries
in the effective |
| 2744 # overload set for constructors. In other words, use the lowest number of mandat
ory arguments among | 2744 # overload set for constructors. In other words, use the lowest number of mandat
ory arguments among |
| 2745 # all constructors. | 2745 # all constructors. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2763 return $leastConstructorLength; | 2763 return $leastConstructorLength; |
| 2764 } | 2764 } |
| 2765 | 2765 |
| 2766 sub GenerateConstructorCallback | 2766 sub GenerateConstructorCallback |
| 2767 { | 2767 { |
| 2768 my $interface = shift; | 2768 my $interface = shift; |
| 2769 | 2769 |
| 2770 my $implClassName = GetImplName($interface); | 2770 my $implClassName = GetImplName($interface); |
| 2771 my $v8ClassName = GetV8ClassName($interface); | 2771 my $v8ClassName = GetV8ClassName($interface); |
| 2772 my $code = ""; | 2772 my $code = ""; |
| 2773 $code .= "void ${v8ClassName}::constructorCallback(const v8::FunctionCallbac
kInfo<v8::Value>& args)\n"; | 2773 $code .= "void ${v8ClassName}::constructorCallback(const v8::FunctionCallbac
kInfo<v8::Value>& info)\n"; |
| 2774 $code .= "{\n"; | 2774 $code .= "{\n"; |
| 2775 $code .= " TRACE_EVENT_SCOPED_SAMPLING_STATE(\"Blink\", \"DOMConstructor\
");\n"; | 2775 $code .= " TRACE_EVENT_SCOPED_SAMPLING_STATE(\"Blink\", \"DOMConstructor\
");\n"; |
| 2776 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); | 2776 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); |
| 2777 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D
eprecateAs"}); | 2777 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D
eprecateAs"}); |
| 2778 $code .= GenerateConstructorHeader($interface->name); | 2778 $code .= GenerateConstructorHeader($interface->name); |
| 2779 if (HasCustomConstructor($interface)) { | 2779 if (HasCustomConstructor($interface)) { |
| 2780 $code .= " ${v8ClassName}::constructorCustom(args);\n"; | 2780 $code .= " ${v8ClassName}::constructorCustom(info);\n"; |
| 2781 } else { | 2781 } else { |
| 2782 $code .= " ${implClassName}V8Internal::constructor(args);\n"; | 2782 $code .= " ${implClassName}V8Internal::constructor(info);\n"; |
| 2783 } | 2783 } |
| 2784 $code .= "}\n\n"; | 2784 $code .= "}\n\n"; |
| 2785 $implementation{nameSpaceWebCore}->add($code); | 2785 $implementation{nameSpaceWebCore}->add($code); |
| 2786 } | 2786 } |
| 2787 | 2787 |
| 2788 sub GenerateConstructor | 2788 sub GenerateConstructor |
| 2789 { | 2789 { |
| 2790 my $interface = shift; | 2790 my $interface = shift; |
| 2791 | 2791 |
| 2792 if (@{$interface->constructors} == 1) { | 2792 if (@{$interface->constructors} == 1) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2813 push(@anyAttributeNames, $attribute->name); | 2813 push(@anyAttributeNames, $attribute->name); |
| 2814 if (!$attribute->extendedAttributes->{"Unserializable"}) { | 2814 if (!$attribute->extendedAttributes->{"Unserializable"}) { |
| 2815 push(@serializableAnyAttributeNames, $attribute->name); | 2815 push(@serializableAnyAttributeNames, $attribute->name); |
| 2816 } | 2816 } |
| 2817 } | 2817 } |
| 2818 } | 2818 } |
| 2819 | 2819 |
| 2820 AddToImplIncludes("bindings/v8/Dictionary.h"); | 2820 AddToImplIncludes("bindings/v8/Dictionary.h"); |
| 2821 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2821 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2822 $implementation{nameSpaceInternal}->add(<<END); | 2822 $implementation{nameSpaceInternal}->add(<<END); |
| 2823 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) | 2823 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 2824 { | 2824 { |
| 2825 if (args.Length() < 1) { | 2825 if (info.Length() < 1) { |
| 2826 throwTypeError(ExceptionMessages::failedToConstruct("$interfaceName", "A
n event name must be provided."), args.GetIsolate()); | 2826 throwTypeError(ExceptionMessages::failedToConstruct("$interfaceName", "A
n event name must be provided."), info.GetIsolate()); |
| 2827 return; | 2827 return; |
| 2828 } | 2828 } |
| 2829 | 2829 |
| 2830 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); | 2830 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); |
| 2831 END | 2831 END |
| 2832 | 2832 |
| 2833 foreach my $attrName (@anyAttributeNames) { | 2833 foreach my $attrName (@anyAttributeNames) { |
| 2834 $implementation{nameSpaceInternal}->add(" v8::Local<v8::Value> ${attr
Name};\n"); | 2834 $implementation{nameSpaceInternal}->add(" v8::Local<v8::Value> ${attr
Name};\n"); |
| 2835 } | 2835 } |
| 2836 | 2836 |
| 2837 $implementation{nameSpaceInternal}->add(<<END); | 2837 $implementation{nameSpaceInternal}->add(<<END); |
| 2838 ${implClassName}Init eventInit; | 2838 ${implClassName}Init eventInit; |
| 2839 if (args.Length() >= 2) { | 2839 if (info.Length() >= 2) { |
| 2840 V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate
())); | 2840 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate
())); |
| 2841 if (!fill${implClassName}Init(eventInit, options)) | 2841 if (!fill${implClassName}Init(eventInit, options)) |
| 2842 return; | 2842 return; |
| 2843 END | 2843 END |
| 2844 | 2844 |
| 2845 # Store 'any'-typed properties on the wrapper to avoid leaking them between
isolated worlds. | 2845 # Store 'any'-typed properties on the wrapper to avoid leaking them between
isolated worlds. |
| 2846 foreach my $attrName (@anyAttributeNames) { | 2846 foreach my $attrName (@anyAttributeNames) { |
| 2847 $implementation{nameSpaceInternal}->add(<<END); | 2847 $implementation{nameSpaceInternal}->add(<<END); |
| 2848 options.get("${attrName}", ${attrName}); | 2848 options.get("${attrName}", ${attrName}); |
| 2849 if (!${attrName}.IsEmpty()) | 2849 if (!${attrName}.IsEmpty()) |
| 2850 args.Holder()->SetHiddenValue(V8HiddenPropertyName::${attrName}(args
.GetIsolate()), ${attrName}); | 2850 info.Holder()->SetHiddenValue(V8HiddenPropertyName::${attrName}(info
.GetIsolate()), ${attrName}); |
| 2851 END | 2851 END |
| 2852 } | 2852 } |
| 2853 | 2853 |
| 2854 $implementation{nameSpaceInternal}->add(<<END); | 2854 $implementation{nameSpaceInternal}->add(<<END); |
| 2855 } | 2855 } |
| 2856 | 2856 |
| 2857 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); | 2857 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); |
| 2858 END | 2858 END |
| 2859 | 2859 |
| 2860 if (@serializableAnyAttributeNames) { | 2860 if (@serializableAnyAttributeNames) { |
| 2861 # If we're in an isolated world, create a SerializedScriptValue and stor
e it in the event for | 2861 # If we're in an isolated world, create a SerializedScriptValue and stor
e it in the event for |
| 2862 # later cloning if the property is accessed from another world. | 2862 # later cloning if the property is accessed from another world. |
| 2863 # The main world case is handled lazily (in Custom code). | 2863 # The main world case is handled lazily (in Custom code). |
| 2864 $implementation{nameSpaceInternal}->add(" if (isolatedWorldForIsolate
(args.GetIsolate())) {\n"); | 2864 $implementation{nameSpaceInternal}->add(" if (isolatedWorldForIsolate
(info.GetIsolate())) {\n"); |
| 2865 foreach my $attrName (@serializableAnyAttributeNames) { | 2865 foreach my $attrName (@serializableAnyAttributeNames) { |
| 2866 my $setter = "setSerialized" . FirstLetterToUpperCase($attrName); | 2866 my $setter = "setSerialized" . FirstLetterToUpperCase($attrName); |
| 2867 $implementation{nameSpaceInternal}->add(<<END); | 2867 $implementation{nameSpaceInternal}->add(<<END); |
| 2868 if (!${attrName}.IsEmpty()) | 2868 if (!${attrName}.IsEmpty()) |
| 2869 event->${setter}(SerializedScriptValue::createAndSwallowExceptions($
{attrName}, args.GetIsolate())); | 2869 event->${setter}(SerializedScriptValue::createAndSwallowExceptions($
{attrName}, info.GetIsolate())); |
| 2870 END | 2870 END |
| 2871 } | 2871 } |
| 2872 $implementation{nameSpaceInternal}->add(" }\n\n"); | 2872 $implementation{nameSpaceInternal}->add(" }\n\n"); |
| 2873 } | 2873 } |
| 2874 | 2874 |
| 2875 $implementation{nameSpaceInternal}->add(<<END); | 2875 $implementation{nameSpaceInternal}->add(<<END); |
| 2876 v8::Handle<v8::Object> wrapper = args.Holder(); | 2876 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 2877 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$
{v8ClassName}::wrapperTypeInfo, wrapper, args.GetIsolate(), WrapperConfiguration
::Dependent); | 2877 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$
{v8ClassName}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration
::Dependent); |
| 2878 v8SetReturnValue(args, wrapper); | 2878 v8SetReturnValue(info, wrapper); |
| 2879 } | 2879 } |
| 2880 END | 2880 END |
| 2881 | 2881 |
| 2882 my $code = ""; | 2882 my $code = ""; |
| 2883 $code .= <<END; | 2883 $code .= <<END; |
| 2884 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary&
options) | 2884 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary&
options) |
| 2885 { | 2885 { |
| 2886 END | 2886 END |
| 2887 | 2887 |
| 2888 if ($interface->parent) { | 2888 if ($interface->parent) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2947 $toEventTarget = "${v8ClassName}::toEventTarget"; | 2947 $toEventTarget = "${v8ClassName}::toEventTarget"; |
| 2948 } | 2948 } |
| 2949 | 2949 |
| 2950 $implementation{nameSpaceWebCore}->add(<<END); | 2950 $implementation{nameSpaceWebCore}->add(<<END); |
| 2951 const WrapperTypeInfo ${v8ClassName}Constructor::wrapperTypeInfo = { ${v8ClassNa
me}Constructor::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $t
oEventTarget, 0, ${v8ClassName}::installPerContextEnabledPrototypeProperties, 0,
WrapperTypeObjectPrototype }; | 2951 const WrapperTypeInfo ${v8ClassName}Constructor::wrapperTypeInfo = { ${v8ClassNa
me}Constructor::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $t
oEventTarget, 0, ${v8ClassName}::installPerContextEnabledPrototypeProperties, 0,
WrapperTypeObjectPrototype }; |
| 2952 | 2952 |
| 2953 END | 2953 END |
| 2954 | 2954 |
| 2955 my $code = ""; | 2955 my $code = ""; |
| 2956 $code .= <<END; | 2956 $code .= <<END; |
| 2957 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8:
:Value>& args) | 2957 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) |
| 2958 { | 2958 { |
| 2959 END | 2959 END |
| 2960 $code .= $maybeObserveFeature if $maybeObserveFeature; | 2960 $code .= $maybeObserveFeature if $maybeObserveFeature; |
| 2961 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; | 2961 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; |
| 2962 $code .= GenerateConstructorHeader($function->extendedAttributes->{"NamedCon
structor"}); | 2962 $code .= GenerateConstructorHeader($function->extendedAttributes->{"NamedCon
structor"}); |
| 2963 AddToImplIncludes("V8Document.h"); | 2963 AddToImplIncludes("V8Document.h"); |
| 2964 $code .= <<END; | 2964 $code .= <<END; |
| 2965 Document* document = currentDocument(); | 2965 Document* document = currentDocument(); |
| 2966 ASSERT(document); | 2966 ASSERT(document); |
| 2967 | 2967 |
| 2968 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp
lClassName} instance | 2968 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp
lClassName} instance |
| 2969 // may end up being the only node in the map and get garbage-collected prema
turely. | 2969 // may end up being the only node in the map and get garbage-collected prema
turely. |
| 2970 toV8(document, args.Holder(), args.GetIsolate()); | 2970 toV8(document, info.Holder(), info.GetIsolate()); |
| 2971 | 2971 |
| 2972 END | 2972 END |
| 2973 | 2973 |
| 2974 $code .= GenerateArgumentsCountCheck($function, $interface); | 2974 $code .= GenerateArgumentsCountCheck($function, $interface); |
| 2975 | 2975 |
| 2976 if ($raisesExceptions) { | 2976 if ($raisesExceptions) { |
| 2977 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2977 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2978 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2978 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2979 $code .= " ExceptionState es(args.GetIsolate());\n"; | 2979 $code .= " ExceptionState es(info.GetIsolate());\n"; |
| 2980 } | 2980 } |
| 2981 | 2981 |
| 2982 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface); | 2982 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface); |
| 2983 $code .= $parameterCheckString; | 2983 $code .= $parameterCheckString; |
| 2984 | 2984 |
| 2985 push(@beforeArgumentList, "*document"); | 2985 push(@beforeArgumentList, "*document"); |
| 2986 | 2986 |
| 2987 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { | 2987 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { |
| 2988 push(@afterArgumentList, "es"); | 2988 push(@afterArgumentList, "es"); |
| 2989 } | 2989 } |
| 2990 | 2990 |
| 2991 my @argumentList; | 2991 my @argumentList; |
| 2992 my $index = 0; | 2992 my $index = 0; |
| 2993 foreach my $parameter (@{$function->parameters}) { | 2993 foreach my $parameter (@{$function->parameters}) { |
| 2994 last if $index eq $paramIndex; | 2994 last if $index eq $paramIndex; |
| 2995 if ($replacements{$parameter->name}) { | 2995 if ($replacements{$parameter->name}) { |
| 2996 push(@argumentList, $replacements{$parameter->name}); | 2996 push(@argumentList, $replacements{$parameter->name}); |
| 2997 } else { | 2997 } else { |
| 2998 push(@argumentList, $parameter->name); | 2998 push(@argumentList, $parameter->name); |
| 2999 } | 2999 } |
| 3000 $index++; | 3000 $index++; |
| 3001 } | 3001 } |
| 3002 | 3002 |
| 3003 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr
gumentList); | 3003 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr
gumentList); |
| 3004 $code .= "\n"; | 3004 $code .= "\n"; |
| 3005 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC
onstructor(${argumentString});\n"; | 3005 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC
onstructor(${argumentString});\n"; |
| 3006 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; | 3006 $code .= " v8::Handle<v8::Object> wrapper = info.Holder();\n"; |
| 3007 | 3007 |
| 3008 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { | 3008 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { |
| 3009 $code .= " if (es.throwIfNeeded())\n"; | 3009 $code .= " if (es.throwIfNeeded())\n"; |
| 3010 $code .= " return;\n"; | 3010 $code .= " return;\n"; |
| 3011 } | 3011 } |
| 3012 | 3012 |
| 3013 $code .= <<END; | 3013 $code .= <<END; |
| 3014 | 3014 |
| 3015 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${
v8ClassName}Constructor::wrapperTypeInfo, wrapper, args.GetIsolate(), WrapperCon
figuration::Dependent); | 3015 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${
v8ClassName}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperCon
figuration::Dependent); |
| 3016 args.GetReturnValue().Set(wrapper); | 3016 info.GetReturnValue().Set(wrapper); |
| 3017 } | 3017 } |
| 3018 | 3018 |
| 3019 END | 3019 END |
| 3020 $implementation{nameSpaceWebCore}->add($code); | 3020 $implementation{nameSpaceWebCore}->add($code); |
| 3021 | 3021 |
| 3022 $code = <<END; | 3022 $code = <<END; |
| 3023 v8::Handle<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8::Isol
ate* isolate, WrapperWorldType currentWorldType) | 3023 v8::Handle<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8::Isol
ate* isolate, WrapperWorldType currentWorldType) |
| 3024 { | 3024 { |
| 3025 // This is only for getting a unique pointer which we can pass to privateTem
plate. | 3025 // This is only for getting a unique pointer which we can pass to privateTem
plate. |
| 3026 static int privateTemplateUniqueKey; | 3026 static int privateTemplateUniqueKey; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3046 $implementation{nameSpaceWebCore}->add($code); | 3046 $implementation{nameSpaceWebCore}->add($code); |
| 3047 } | 3047 } |
| 3048 | 3048 |
| 3049 sub GenerateConstructorHeader | 3049 sub GenerateConstructorHeader |
| 3050 { | 3050 { |
| 3051 my $constructorName = shift; | 3051 my $constructorName = shift; |
| 3052 | 3052 |
| 3053 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 3053 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 3054 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h"); | 3054 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h"); |
| 3055 my $content = <<END; | 3055 my $content = <<END; |
| 3056 if (!args.IsConstructCall()) { | 3056 if (!info.IsConstructCall()) { |
| 3057 throwTypeError(ExceptionMessages::failedToConstruct("$constructorName",
"Please use the 'new' operator, this DOM object constructor cannot be called as
a function."), args.GetIsolate()); | 3057 throwTypeError(ExceptionMessages::failedToConstruct("$constructorName",
"Please use the 'new' operator, this DOM object constructor cannot be called as
a function."), info.GetIsolate()); |
| 3058 return; | 3058 return; |
| 3059 } | 3059 } |
| 3060 | 3060 |
| 3061 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | 3061 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
| 3062 args.GetReturnValue().Set(args.Holder()); | 3062 info.GetReturnValue().Set(info.Holder()); |
| 3063 return; | 3063 return; |
| 3064 } | 3064 } |
| 3065 | 3065 |
| 3066 END | 3066 END |
| 3067 return $content; | 3067 return $content; |
| 3068 } | 3068 } |
| 3069 | 3069 |
| 3070 sub GenerateAttributeConfigurationArray | 3070 sub GenerateAttributeConfigurationArray |
| 3071 { | 3071 { |
| 3072 my $interface = shift; | 3072 my $interface = shift; |
| (...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5135 | 5135 |
| 5136 if ($replacements{$paramName}) { | 5136 if ($replacements{$paramName}) { |
| 5137 push @arguments, $replacements{$paramName}; | 5137 push @arguments, $replacements{$paramName}; |
| 5138 } elsif ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathN
SResolver") { | 5138 } elsif ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathN
SResolver") { |
| 5139 push @arguments, "$paramName.get()"; | 5139 push @arguments, "$paramName.get()"; |
| 5140 } elsif (IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceNam
e =~ /List$/) { | 5140 } elsif (IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceNam
e =~ /List$/) { |
| 5141 AddToImplIncludes("core/dom/ExceptionCode.h"); | 5141 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| 5142 push @arguments, "$paramName->propertyReference()"; | 5142 push @arguments, "$paramName->propertyReference()"; |
| 5143 $code .= <<END; | 5143 $code .= <<END; |
| 5144 if (!$paramName) { | 5144 if (!$paramName) { |
| 5145 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 5145 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 5146 return; | 5146 return; |
| 5147 } | 5147 } |
| 5148 END | 5148 END |
| 5149 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans
formList") { | 5149 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans
formList") { |
| 5150 push @arguments, "$paramName.get()"; | 5150 push @arguments, "$paramName.get()"; |
| 5151 } elsif ($parameter->isNullable && !IsRefPtrType($parameter->type)) { | 5151 } elsif ($parameter->isNullable && !IsRefPtrType($parameter->type)) { |
| 5152 push @arguments, "${paramName}IsNull ? 0 : &$paramName"; | 5152 push @arguments, "${paramName}IsNull ? 0 : &$paramName"; |
| 5153 } else { | 5153 } else { |
| 5154 push @arguments, $paramName; | 5154 push @arguments, $paramName; |
| 5155 } | 5155 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5181 | 5181 |
| 5182 if ($function->extendedAttributes->{"RaisesException"}) { | 5182 if ($function->extendedAttributes->{"RaisesException"}) { |
| 5183 $code .= $indent . "if (es.throwIfNeeded())\n"; | 5183 $code .= $indent . "if (es.throwIfNeeded())\n"; |
| 5184 $code .= $indent . " return;\n"; | 5184 $code .= $indent . " return;\n"; |
| 5185 } | 5185 } |
| 5186 | 5186 |
| 5187 if (ExtendedAttributeContains($callWith, "ScriptState")) { | 5187 if (ExtendedAttributeContains($callWith, "ScriptState")) { |
| 5188 $code .= $indent . "if (state.hadException()) {\n"; | 5188 $code .= $indent . "if (state.hadException()) {\n"; |
| 5189 $code .= $indent . " v8::Local<v8::Value> exception = state.exception
();\n"; | 5189 $code .= $indent . " v8::Local<v8::Value> exception = state.exception
();\n"; |
| 5190 $code .= $indent . " state.clearException();\n"; | 5190 $code .= $indent . " state.clearException();\n"; |
| 5191 $code .= $indent . " throwError(exception, args.GetIsolate());\n"; | 5191 $code .= $indent . " throwError(exception, info.GetIsolate());\n"; |
| 5192 $code .= $indent . " return;\n"; | 5192 $code .= $indent . " return;\n"; |
| 5193 $code .= $indent . "}\n"; | 5193 $code .= $indent . "}\n"; |
| 5194 } | 5194 } |
| 5195 | 5195 |
| 5196 if ($isSVGTearOffType) { | 5196 if ($isSVGTearOffType) { |
| 5197 AddToImplIncludes("V8$returnType.h"); | 5197 AddToImplIncludes("V8$returnType.h"); |
| 5198 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); | 5198 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); |
| 5199 my $svgNativeType = GetSVGTypeNeedingTearOff($returnType); | 5199 my $svgNativeType = GetSVGTypeNeedingTearOff($returnType); |
| 5200 # FIXME: Update for all ScriptWrappables. | 5200 # FIXME: Update for all ScriptWrappables. |
| 5201 if (IsDOMNodeType($interfaceName)) { | 5201 if (IsDOMNodeType($interfaceName)) { |
| 5202 if ($forMainWorldSuffix eq "ForMainWorld") { | 5202 if ($forMainWorldSuffix eq "ForMainWorld") { |
| 5203 $code .= $indent . "v8SetReturnValueForMainWorld(args, WTF::getP
tr(${svgNativeType}::create($return)));\n"; | 5203 $code .= $indent . "v8SetReturnValueForMainWorld(info, WTF::getP
tr(${svgNativeType}::create($return)));\n"; |
| 5204 } else { | 5204 } else { |
| 5205 $code .= $indent . "v8SetReturnValueFast(args, WTF::getPtr(${svg
NativeType}::create($return)), imp);\n"; | 5205 $code .= $indent . "v8SetReturnValueFast(info, WTF::getPtr(${svg
NativeType}::create($return)), imp);\n"; |
| 5206 } | 5206 } |
| 5207 } else { | 5207 } else { |
| 5208 $code .= $indent . "v8SetReturnValue${forMainWorldSuffix}(args, WTF:
:getPtr(${svgNativeType}::create($return)));\n"; | 5208 $code .= $indent . "v8SetReturnValue${forMainWorldSuffix}(info, WTF:
:getPtr(${svgNativeType}::create($return)));\n"; |
| 5209 } | 5209 } |
| 5210 return $code; | 5210 return $code; |
| 5211 } | 5211 } |
| 5212 | 5212 |
| 5213 # If the implementing class is a POD type, commit changes | 5213 # If the implementing class is a POD type, commit changes |
| 5214 if (IsSVGTypeNeedingTearOff($interfaceName) and not $interfaceName =~ /List$
/) { | 5214 if (IsSVGTypeNeedingTearOff($interfaceName) and not $interfaceName =~ /List$
/) { |
| 5215 $code .= $indent . "wrapper->commitChange();\n"; | 5215 $code .= $indent . "wrapper->commitChange();\n"; |
| 5216 } | 5216 } |
| 5217 | 5217 |
| 5218 $return .= ".release()" if ($returnIsRef); | 5218 $return .= ".release()" if ($returnIsRef); |
| 5219 | 5219 |
| 5220 my $nativeValue; | 5220 my $nativeValue; |
| 5221 # FIXME: Update for all ScriptWrappables. | 5221 # FIXME: Update for all ScriptWrappables. |
| 5222 if (IsDOMNodeType($interfaceName)) { | 5222 if (IsDOMNodeType($interfaceName)) { |
| 5223 $nativeValue = NativeToJSValue($function->type, $function->extendedAttri
butes, $return, $indent, "", "args.GetIsolate()", "args", "imp", $forMainWorldSu
ffix, "return"); | 5223 $nativeValue = NativeToJSValue($function->type, $function->extendedAttri
butes, $return, $indent, "", "info.GetIsolate()", "info", "imp", $forMainWorldSu
ffix, "return"); |
| 5224 } else { | 5224 } else { |
| 5225 $nativeValue = NativeToJSValue($function->type, $function->extendedAttri
butes, $return, $indent, "", "args.GetIsolate()", "args", 0, $forMainWorldSuffix
, "return"); | 5225 $nativeValue = NativeToJSValue($function->type, $function->extendedAttri
butes, $return, $indent, "", "info.GetIsolate()", "info", 0, $forMainWorldSuffix
, "return"); |
| 5226 } | 5226 } |
| 5227 | 5227 |
| 5228 $code .= $nativeValue . "\n" if $nativeValue; # Skip blank line for void re
turn type | 5228 $code .= $nativeValue . "\n" if $nativeValue; # Skip blank line for void re
turn type |
| 5229 | 5229 |
| 5230 return $code; | 5230 return $code; |
| 5231 } | 5231 } |
| 5232 | 5232 |
| 5233 sub GetNativeType | 5233 sub GetNativeType |
| 5234 { | 5234 { |
| 5235 my $type = shift; | 5235 my $type = shift; |
| (...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6273 | 6273 |
| 6274 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6274 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
| 6275 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6275 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
| 6276 return 1 if InheritsInterface($interface, "Document"); | 6276 return 1 if InheritsInterface($interface, "Document"); |
| 6277 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); | 6277 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); |
| 6278 | 6278 |
| 6279 return 0; | 6279 return 0; |
| 6280 } | 6280 } |
| 6281 | 6281 |
| 6282 1; | 6282 1; |
| OLD | NEW |