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 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 } else { | 1501 } else { |
1502 my $reflect = $attribute->extendedAttributes->{"Reflect"}; | 1502 my $reflect = $attribute->extendedAttributes->{"Reflect"}; |
1503 my $url = $attribute->extendedAttributes->{"URL"}; | 1503 my $url = $attribute->extendedAttributes->{"URL"}; |
1504 if ($reflect && !$url && InheritsInterface($interface, "Node") && $attrT
ype eq "DOMString") { | 1504 if ($reflect && !$url && InheritsInterface($interface, "Node") && $attrT
ype eq "DOMString") { |
1505 # Generate super-compact call for regular attribute getter: | 1505 # Generate super-compact call for regular attribute getter: |
1506 my ($functionName, @arguments) = GetterExpression($interfaceName, $a
ttribute); | 1506 my ($functionName, @arguments) = GetterExpression($interfaceName, $a
ttribute); |
1507 my $getterExpression = "imp->${functionName}(" . join(", ", @argumen
ts) . ")"; | 1507 my $getterExpression = "imp->${functionName}(" . join(", ", @argumen
ts) . ")"; |
1508 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; | 1508 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; |
1509 if ($attribute->extendedAttributes->{"ReflectOnly"}) { | 1509 if ($attribute->extendedAttributes->{"ReflectOnly"}) { |
1510 $code .= " String resultValue = ${getterExpression};\n"; | 1510 $code .= " String resultValue = ${getterExpression};\n"; |
1511 $code .= GenerateReflectOnlyCheck($attribute->extendedAttributes
->{"ReflectOnly"}, " "); | 1511 $code .= GenerateReflectOnlyCheck($attribute->extendedAttributes
, " "); |
1512 $getterExpression = "resultValue"; | 1512 $getterExpression = "resultValue"; |
1513 } | 1513 } |
1514 $code .= " v8SetReturnValueString(info, ${getterExpression}, info
.GetIsolate());\n"; | 1514 $code .= " v8SetReturnValueString(info, ${getterExpression}, info
.GetIsolate());\n"; |
1515 $code .= "}\n"; | 1515 $code .= "}\n"; |
1516 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 1516 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
1517 $code .= "\n"; | 1517 $code .= "\n"; |
1518 $implementation{nameSpaceInternal}->add($code); | 1518 $implementation{nameSpaceInternal}->add($code); |
1519 return; | 1519 return; |
1520 # Skip the rest of the function! | 1520 # Skip the rest of the function! |
1521 } | 1521 } |
(...skipping 4175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5697 } | 5697 } |
5698 | 5698 |
5699 # long long and unsigned long long are not representable in ECMAScript. | 5699 # long long and unsigned long long are not representable in ECMAScript. |
5700 if ($type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTi
meStamp") { | 5700 if ($type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTi
meStamp") { |
5701 return "${indent}v8SetReturnValue(${getCallbackInfo}, static_cast<double
>($nativeValue));" if $isReturnValue; | 5701 return "${indent}v8SetReturnValue(${getCallbackInfo}, static_cast<double
>($nativeValue));" if $isReturnValue; |
5702 return "$indent$receiver v8::Number::New($getIsolate, static_cast<double
>($nativeValue));"; | 5702 return "$indent$receiver v8::Number::New($getIsolate, static_cast<double
>($nativeValue));"; |
5703 } | 5703 } |
5704 | 5704 |
5705 if ($type eq "DOMString" && $extendedAttributes->{"ReflectOnly"}) { | 5705 if ($type eq "DOMString" && $extendedAttributes->{"ReflectOnly"}) { |
5706 my $code = "${indent}String resultValue = ${nativeValue};\n"; | 5706 my $code = "${indent}String resultValue = ${nativeValue};\n"; |
5707 $code .= GenerateReflectOnlyCheck($extendedAttributes->{"ReflectOnly"},
${indent}); | 5707 $code .= GenerateReflectOnlyCheck($extendedAttributes, ${indent}); |
5708 return "${code}${indent}v8SetReturnValueString(${getCallbackInfo}, resul
tValue, $getIsolate);" if $isReturnValue; | 5708 return "${code}${indent}v8SetReturnValueString(${getCallbackInfo}, resul
tValue, $getIsolate);" if $isReturnValue; |
5709 return "${code}$indent$receiver resultValue"; | 5709 return "${code}$indent$receiver resultValue"; |
5710 } | 5710 } |
5711 | 5711 |
5712 my $conv = $extendedAttributes->{"TreatReturnedNullStringAs"}; | 5712 my $conv = $extendedAttributes->{"TreatReturnedNullStringAs"}; |
5713 if (($type eq "DOMString" || IsEnumType($type)) && $isReturnValue) { | 5713 if (($type eq "DOMString" || IsEnumType($type)) && $isReturnValue) { |
5714 my $functionSuffix = ""; | 5714 my $functionSuffix = ""; |
5715 if (defined $conv) { | 5715 if (defined $conv) { |
5716 if ($conv eq "Null") { | 5716 if ($conv eq "Null") { |
5717 $functionSuffix = "OrNull"; | 5717 $functionSuffix = "OrNull"; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6251 } else { | 6251 } else { |
6252 push(@checks, " COMPILE_ASSERT($value == ${implClassName}::$n
ame, TheValueOf${implClassName}_${name}DoesntMatchWithImplementation);\n"); | 6252 push(@checks, " COMPILE_ASSERT($value == ${implClassName}::$n
ame, TheValueOf${implClassName}_${name}DoesntMatchWithImplementation);\n"); |
6253 } | 6253 } |
6254 } | 6254 } |
6255 } | 6255 } |
6256 return @checks; | 6256 return @checks; |
6257 } | 6257 } |
6258 | 6258 |
6259 sub GenerateReflectOnlyCheck | 6259 sub GenerateReflectOnlyCheck |
6260 { | 6260 { |
6261 my $knownValueString = shift; | 6261 my $extendedAttributes = shift; |
6262 my $indent = shift; | 6262 my $indent = shift; |
6263 | 6263 |
| 6264 my $knownValueString = $extendedAttributes->{"ReflectOnly"}; |
6264 my @knownValues = split(quotemeta("|"), $knownValueString); | 6265 my @knownValues = split(quotemeta("|"), $knownValueString); |
6265 | 6266 |
| 6267 my $missingValueDefault = $extendedAttributes->{"ReflectMissing"}; |
| 6268 if ($missingValueDefault) { |
| 6269 if (!grep { $_ eq $missingValueDefault } @knownValues) { |
| 6270 die "Missing attribute value is not a known value " . $missingValueD
efault; |
| 6271 } |
| 6272 $missingValueDefault = "resultValue = \"${missingValueDefault}\""; |
| 6273 } else { |
| 6274 $missingValueDefault = ""; |
| 6275 } |
| 6276 |
| 6277 my $invalidValueDefault = $extendedAttributes->{"ReflectInvalid"}; |
| 6278 if ($invalidValueDefault) { |
| 6279 if (!grep { $_ eq $invalidValueDefault } @knownValues) { |
| 6280 die "Invalid attribute value is not a known value " . $invalidValueD
efault; |
| 6281 } |
| 6282 $invalidValueDefault = "\"${invalidValueDefault}\""; |
| 6283 } else { |
| 6284 $invalidValueDefault = "\"\""; |
| 6285 } |
| 6286 |
6266 # Attribute is limited to only known values: check that the attribute | 6287 # Attribute is limited to only known values: check that the attribute |
6267 # value is one of those..and if not, set it to the empty string. | 6288 # value is one of those..and if not, set it to the empty string. |
6268 # ( http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known
-values ) | 6289 # ( http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known
-values ) |
6269 # | 6290 # |
6270 my @normalizeAttributeCode = (); | 6291 my @normalizeAttributeCode = (); |
6271 my $code = ""; | 6292 my $code = ""; |
6272 foreach my $knownValue (@knownValues) { | 6293 foreach my $knownValue (@knownValues) { |
6273 push(@normalizeAttributeCode, "${indent}} else if (equalIgnoringCase(res
ultValue, \"$knownValue\")) {"); | 6294 push(@normalizeAttributeCode, "${indent}} else if (equalIgnoringCase(res
ultValue, \"$knownValue\")) {"); |
6274 push(@normalizeAttributeCode, "${indent} resultValue = \"$knownValue\
";"); | 6295 push(@normalizeAttributeCode, "${indent} resultValue = \"$knownValue\
";"); |
6275 } | 6296 } |
6276 my $normalizeAttributeValue = join("\n", @normalizeAttributeCode); | 6297 my $normalizeAttributeValue = join("\n", @normalizeAttributeCode); |
6277 $code .= <<END; | 6298 $code .= <<END; |
6278 ${indent}if (resultValue.isEmpty()) { | 6299 ${indent}if (resultValue.isEmpty()) { |
6279 ${indent} ; | 6300 ${indent} $missingValueDefault; |
6280 ${normalizeAttributeValue} | 6301 ${normalizeAttributeValue} |
6281 ${indent}} else { | 6302 ${indent}} else { |
6282 ${indent} resultValue = ""; | 6303 ${indent} resultValue = $invalidValueDefault; |
6283 ${indent}} | 6304 ${indent}} |
6284 END | 6305 END |
6285 return "${code}"; | 6306 return "${code}"; |
6286 } | 6307 } |
6287 | 6308 |
6288 sub ExtendedAttributeContains | 6309 sub ExtendedAttributeContains |
6289 { | 6310 { |
6290 my $extendedAttributeValue = shift; | 6311 my $extendedAttributeValue = shift; |
6291 return 0 unless $extendedAttributeValue; | 6312 return 0 unless $extendedAttributeValue; |
6292 my $keyword = shift; | 6313 my $keyword = shift; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6349 | 6370 |
6350 foreach my $parameter (@{$function->parameters}) { | 6371 foreach my $parameter (@{$function->parameters}) { |
6351 if ($parameter->type eq "SerializedScriptValue") { | 6372 if ($parameter->type eq "SerializedScriptValue") { |
6352 return 1; | 6373 return 1; |
6353 } | 6374 } |
6354 } | 6375 } |
6355 return 0; | 6376 return 0; |
6356 } | 6377 } |
6357 | 6378 |
6358 1; | 6379 1; |
OLD | NEW |