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 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 my $function = shift; | 2177 my $function = shift; |
2178 | 2178 |
2179 my @andExpression = (); | 2179 my @andExpression = (); |
2180 push(@andExpression, "info.Length() == $numParameters"); | 2180 push(@andExpression, "info.Length() == $numParameters"); |
2181 my $parameterIndex = 0; | 2181 my $parameterIndex = 0; |
2182 foreach my $parameter (@{$function->parameters}) { | 2182 foreach my $parameter (@{$function->parameters}) { |
2183 last if $parameterIndex >= $numParameters; | 2183 last if $parameterIndex >= $numParameters; |
2184 my $value = "info[$parameterIndex]"; | 2184 my $value = "info[$parameterIndex]"; |
2185 my $type = $parameter->type; | 2185 my $type = $parameter->type; |
2186 | 2186 |
2187 # Only DOMString or wrapper types are checked. | 2187 # Only DOMString, wrapper types, and (to some degree) non-wrapper types |
| 2188 # are checked. |
| 2189 # |
| 2190 # FIXME: If distinguishing non-primitive type from primitive type, |
| 2191 # (e.g., sequence<DOMString> from DOMString or Dictionary from double) |
| 2192 # the non-primitive type must appear *first* in the IDL file, |
| 2193 # since we're not adding a check to primitive types. |
| 2194 # This can be avoided if compute overloads for whole overload set at |
| 2195 # once, rather than one method at a time, but that requires a complete |
| 2196 # rewrite of this algorithm. |
| 2197 # |
2188 # For DOMString with StrictTypeChecking only Null, Undefined and Object | 2198 # For DOMString with StrictTypeChecking only Null, Undefined and Object |
2189 # are accepted for compatibility. Otherwise, no restrictions are made to | 2199 # are accepted for compatibility. Otherwise, no restrictions are made to |
2190 # match the non-overloaded behavior. | 2200 # match the non-overloaded behavior. |
| 2201 # |
2191 # FIXME: Implement WebIDL overload resolution algorithm. | 2202 # FIXME: Implement WebIDL overload resolution algorithm. |
| 2203 # https://code.google.com/p/chromium/issues/detail?id=293561 |
2192 if ($type eq "DOMString") { | 2204 if ($type eq "DOMString") { |
2193 if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { | 2205 if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { |
2194 push(@andExpression, "isUndefinedOrNull(${value}) || ${value}->I
sString() || ${value}->IsObject()"); | 2206 push(@andExpression, "isUndefinedOrNull(${value}) || ${value}->I
sString() || ${value}->IsObject()"); |
2195 } | 2207 } |
2196 } elsif (IsCallbackInterface($parameter->type)) { | 2208 } elsif (IsCallbackInterface($parameter->type)) { |
2197 # For Callbacks only checks if the value is null or object. | 2209 # For Callbacks only checks if the value is null or function. |
2198 push(@andExpression, "${value}->IsNull() || ${value}->IsFunction()")
; | 2210 push(@andExpression, "${value}->IsNull() || ${value}->IsFunction()")
; |
2199 } elsif (GetArrayOrSequenceType($type)) { | 2211 } elsif (GetArrayOrSequenceType($type)) { |
2200 if ($parameter->isNullable) { | 2212 if ($parameter->isNullable) { |
2201 push(@andExpression, "${value}->IsNull() || ${value}->IsArray()"
); | 2213 push(@andExpression, "${value}->IsNull() || ${value}->IsArray()"
); |
2202 } else { | 2214 } else { |
2203 push(@andExpression, "${value}->IsArray()"); | 2215 push(@andExpression, "${value}->IsArray()"); |
2204 } | 2216 } |
2205 } elsif (IsWrapperType($type)) { | 2217 } elsif (IsWrapperType($type)) { |
2206 if ($parameter->isNullable) { | 2218 if ($parameter->isNullable) { |
2207 push(@andExpression, "${value}->IsNull() || V8${type}::hasInstan
ce($value, info.GetIsolate(), worldType(info.GetIsolate()))"); | 2219 push(@andExpression, "${value}->IsNull() || V8${type}::hasInstan
ce($value, info.GetIsolate(), worldType(info.GetIsolate()))"); |
2208 } else { | 2220 } else { |
2209 push(@andExpression, "V8${type}::hasInstance($value, info.GetIso
late(), worldType(info.GetIsolate()))"); | 2221 push(@andExpression, "V8${type}::hasInstance($value, info.GetIso
late(), worldType(info.GetIsolate()))"); |
2210 } | 2222 } |
| 2223 } elsif ($nonWrapperTypes{$type}) { |
| 2224 # Non-wrapper types are just objects: we don't distinguish type |
| 2225 if ($parameter->isNullable) { |
| 2226 push(@andExpression, "${value}->IsNull() || ${value}->IsObject()
"); |
| 2227 } else { |
| 2228 push(@andExpression, "${value}->IsObject()"); |
| 2229 } |
2211 } | 2230 } |
2212 | 2231 |
2213 $parameterIndex++; | 2232 $parameterIndex++; |
2214 } | 2233 } |
2215 @andExpression = map { "($_)" } @andExpression; | 2234 @andExpression = map { "($_)" } @andExpression; |
2216 my $res = "(" . join(" && ", @andExpression) . ")"; | 2235 my $res = "(" . join(" && ", @andExpression) . ")"; |
2217 return $res; | 2236 return $res; |
2218 } | 2237 } |
2219 | 2238 |
2220 # As per Web IDL specification, the length of a function Object is | 2239 # As per Web IDL specification, the length of a function Object is |
(...skipping 4172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6393 if ($parameter->type eq "SerializedScriptValue") { | 6412 if ($parameter->type eq "SerializedScriptValue") { |
6394 return 1; | 6413 return 1; |
6395 } elsif (IsIntegerType($parameter->type)) { | 6414 } elsif (IsIntegerType($parameter->type)) { |
6396 return 1; | 6415 return 1; |
6397 } | 6416 } |
6398 } | 6417 } |
6399 return 0; | 6418 return 0; |
6400 } | 6419 } |
6401 | 6420 |
6402 1; | 6421 1; |
OLD | NEW |