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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 my %header; | 141 my %header; |
142 | 142 |
143 # Implementation code structure: | 143 # Implementation code structure: |
144 # Root ... Copyright | 144 # Root ... Copyright |
145 # Conditional ... #if FEATURE ... #endif (to be removed soon) | 145 # Conditional ... #if FEATURE ... #endif (to be removed soon) |
146 # Includes | 146 # Includes |
147 # NameSpaceWebCore | 147 # NameSpaceWebCore |
148 # NameSpaceInternal ... namespace ${implClassName}V8Internal in case of no
n-callback | 148 # NameSpaceInternal ... namespace ${implClassName}V8Internal in case of no
n-callback |
149 my %implementation; | 149 my %implementation; |
150 | 150 |
| 151 # Promise is not yet in the Web IDL spec but is going to be speced |
| 152 # as primitive types in the future. |
| 153 # Since V8 dosn't provide Promise primitive object currently, |
| 154 # primitiveTypeHash doesn't contain Promise. |
151 my %primitiveTypeHash = ("boolean" => 1, | 155 my %primitiveTypeHash = ("boolean" => 1, |
152 "void" => 1, | 156 "void" => 1, |
153 "Date" => 1, | 157 "Date" => 1, |
154 "byte" => 1, | 158 "byte" => 1, |
155 "octet" => 1, | 159 "octet" => 1, |
156 "short" => 1, | 160 "short" => 1, |
157 "long" => 1, | 161 "long" => 1, |
158 "long long" => 1, | 162 "long long" => 1, |
159 "unsigned short" => 1, | 163 "unsigned short" => 1, |
160 "unsigned long" => 1, | 164 "unsigned long" => 1, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 424 |
421 return if SkipIncludeHeader($type); | 425 return if SkipIncludeHeader($type); |
422 | 426 |
423 # Default includes | 427 # Default includes |
424 if ($type eq "EventListener" or $type eq "EventHandler") { | 428 if ($type eq "EventListener" or $type eq "EventHandler") { |
425 AddToImplIncludes("core/dom/EventListener.h"); | 429 AddToImplIncludes("core/dom/EventListener.h"); |
426 } elsif ($type eq "SerializedScriptValue") { | 430 } elsif ($type eq "SerializedScriptValue") { |
427 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 431 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
428 } elsif ($type eq "any" || IsCallbackFunctionType($type)) { | 432 } elsif ($type eq "any" || IsCallbackFunctionType($type)) { |
429 AddToImplIncludes("bindings/v8/ScriptValue.h"); | 433 AddToImplIncludes("bindings/v8/ScriptValue.h"); |
| 434 } elsif ($type eq "Promise") { |
| 435 AddToImplIncludes("bindings/v8/ScriptPromise.h"); |
430 } elsif (IsTypedArrayType($type)) { | 436 } elsif (IsTypedArrayType($type)) { |
431 AddToImplIncludes("bindings/v8/custom/V8${type}Custom.h"); | 437 AddToImplIncludes("bindings/v8/custom/V8${type}Custom.h"); |
432 } else { | 438 } else { |
433 AddToImplIncludes("V8${type}.h"); | 439 AddToImplIncludes("V8${type}.h"); |
434 } | 440 } |
435 } | 441 } |
436 | 442 |
437 sub HeaderFilesForInterface | 443 sub HeaderFilesForInterface |
438 { | 444 { |
439 my $interfaceName = shift; | 445 my $interfaceName = shift; |
(...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2451 if (IsWrapperType($argType)) { | 2457 if (IsWrapperType($argType)) { |
2452 $parameterCheckString .= " if (args.Length() > $paramInde
x && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue, args
.GetIsolate(), worldType(args.GetIsolate()))) {\n"; | 2458 $parameterCheckString .= " if (args.Length() > $paramInde
x && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue, args
.GetIsolate(), worldType(args.GetIsolate()))) {\n"; |
2453 $parameterCheckString .= " throwTypeError(args.GetIso
late());\n"; | 2459 $parameterCheckString .= " throwTypeError(args.GetIso
late());\n"; |
2454 $parameterCheckString .= " return;\n"; | 2460 $parameterCheckString .= " return;\n"; |
2455 $parameterCheckString .= " }\n"; | 2461 $parameterCheckString .= " }\n"; |
2456 } | 2462 } |
2457 } | 2463 } |
2458 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; | 2464 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; |
2459 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(args, $paramIndex)" : "args[$paramIndex]"; | 2465 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(args, $paramIndex)" : "args[$paramIndex]"; |
2460 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola
te()"); | 2466 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola
te()"); |
2461 if ($nativeType eq 'Dictionary') { | 2467 if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise') { |
2462 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN
ull() && !$parameterName.isObject()) {\n"; | 2468 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN
ull() && !$parameterName.isObject()) {\n"; |
2463 $parameterCheckString .= " throwTypeError(\"Not an object
.\", args.GetIsolate());\n"; | 2469 $parameterCheckString .= " throwTypeError(\"Not an object
.\", args.GetIsolate());\n"; |
2464 $parameterCheckString .= " return;\n"; | 2470 $parameterCheckString .= " return;\n"; |
2465 $parameterCheckString .= " }\n"; | 2471 $parameterCheckString .= " }\n"; |
2466 } | 2472 } |
2467 } | 2473 } |
2468 | 2474 |
2469 $paramIndex++; | 2475 $paramIndex++; |
2470 } | 2476 } |
2471 return ($parameterCheckString, $paramIndex, %replacements); | 2477 return ($parameterCheckString, $paramIndex, %replacements); |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3155 my $unionMemberVariable = $variableName . $i; | 3161 my $unionMemberVariable = $variableName . $i; |
3156 my $isNull = GenerateIsNullExpression($unionMemberType, $unionMember
Variable); | 3162 my $isNull = GenerateIsNullExpression($unionMemberType, $unionMember
Variable); |
3157 push @expression, $isNull; | 3163 push @expression, $isNull; |
3158 } | 3164 } |
3159 return join " && ", @expression; | 3165 return join " && ", @expression; |
3160 } | 3166 } |
3161 if (IsRefPtrType($type)) { | 3167 if (IsRefPtrType($type)) { |
3162 return "!${variableName}"; | 3168 return "!${variableName}"; |
3163 } elsif ($type eq "DOMString") { | 3169 } elsif ($type eq "DOMString") { |
3164 return "${variableName}.isNull()"; | 3170 return "${variableName}.isNull()"; |
| 3171 } elsif ($type eq "Promise") { |
| 3172 return "${variableName}.isNull()"; |
3165 } else { | 3173 } else { |
3166 return ""; | 3174 return ""; |
3167 } | 3175 } |
3168 } | 3176 } |
3169 | 3177 |
3170 sub GenerateIfElseStatement | 3178 sub GenerateIfElseStatement |
3171 { | 3179 { |
3172 my $type = shift; | 3180 my $type = shift; |
3173 my $outputVariableName = shift; | 3181 my $outputVariableName = shift; |
3174 my $conditions = shift; | 3182 my $conditions = shift; |
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5004 $mode = "WithUndefinedOrNullCheck"; | 5012 $mode = "WithUndefinedOrNullCheck"; |
5005 } elsif (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes->
{"TreatNullAs"} eq "NullString") or $extendedAttributes->{"Reflect"}) { | 5013 } elsif (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes->
{"TreatNullAs"} eq "NullString") or $extendedAttributes->{"Reflect"}) { |
5006 $mode = "WithNullCheck"; | 5014 $mode = "WithNullCheck"; |
5007 } | 5015 } |
5008 # FIXME: Add the case for 'elsif ($attributeOrParameter->extendedAttribu
tes->{"TreatUndefinedAs"} and $attributeOrParameter->extendedAttributes->{"Treat
UndefinedAs"} eq "NullString"))'. | 5016 # FIXME: Add the case for 'elsif ($attributeOrParameter->extendedAttribu
tes->{"TreatUndefinedAs"} and $attributeOrParameter->extendedAttributes->{"Treat
UndefinedAs"} eq "NullString"))'. |
5009 return "V8StringResource<$mode>"; | 5017 return "V8StringResource<$mode>"; |
5010 } | 5018 } |
5011 | 5019 |
5012 return "String" if $type eq "DOMString" or IsEnumType($type); | 5020 return "String" if $type eq "DOMString" or IsEnumType($type); |
5013 | 5021 |
| 5022 return "ScriptPromise" if $type eq "Promise"; |
| 5023 |
5014 return "Range::CompareHow" if $type eq "CompareHow"; | 5024 return "Range::CompareHow" if $type eq "CompareHow"; |
5015 return "DOMTimeStamp" if $type eq "DOMTimeStamp"; | 5025 return "DOMTimeStamp" if $type eq "DOMTimeStamp"; |
5016 return "double" if $type eq "Date"; | 5026 return "double" if $type eq "Date"; |
5017 return "ScriptValue" if $type eq "any" or IsCallbackFunctionType($type); | 5027 return "ScriptValue" if $type eq "any" or IsCallbackFunctionType($type); |
5018 return "Dictionary" if $type eq "Dictionary"; | 5028 return "Dictionary" if $type eq "Dictionary"; |
5019 | 5029 |
5020 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; | 5030 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; |
5021 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"
; | 5031 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"
; |
5022 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; | 5032 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; |
5023 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; | 5033 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5132 if ($type eq "Dictionary") { | 5142 if ($type eq "Dictionary") { |
5133 AddToImplIncludes("bindings/v8/Dictionary.h"); | 5143 AddToImplIncludes("bindings/v8/Dictionary.h"); |
5134 return "Dictionary($value, $getIsolate)"; | 5144 return "Dictionary($value, $getIsolate)"; |
5135 } | 5145 } |
5136 | 5146 |
5137 if ($type eq "any" || IsCallbackFunctionType($type)) { | 5147 if ($type eq "any" || IsCallbackFunctionType($type)) { |
5138 AddToImplIncludes("bindings/v8/ScriptValue.h"); | 5148 AddToImplIncludes("bindings/v8/ScriptValue.h"); |
5139 return "ScriptValue($value)"; | 5149 return "ScriptValue($value)"; |
5140 } | 5150 } |
5141 | 5151 |
| 5152 if ($type eq "Promise") { |
| 5153 AddToImplIncludes("bindings/v8/ScriptPromise.h"); |
| 5154 return "ScriptPromise($value)"; |
| 5155 } |
| 5156 |
5142 if ($type eq "NodeFilter") { | 5157 if ($type eq "NodeFilter") { |
5143 return "toNodeFilter($value, $getIsolate)"; | 5158 return "toNodeFilter($value, $getIsolate)"; |
5144 } | 5159 } |
5145 | 5160 |
5146 if ($type eq "MediaQueryListListener") { | 5161 if ($type eq "MediaQueryListListener") { |
5147 AddToImplIncludes("core/css/MediaQueryListListener.h"); | 5162 AddToImplIncludes("core/css/MediaQueryListListener.h"); |
5148 return "MediaQueryListListener::create(" . $value . ")"; | 5163 return "MediaQueryListListener::create(" . $value . ")"; |
5149 } | 5164 } |
5150 | 5165 |
5151 if ($type eq "EventTarget") { | 5166 if ($type eq "EventTarget") { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5263 | 5278 |
5264 sub IsWrapperType | 5279 sub IsWrapperType |
5265 { | 5280 { |
5266 my $type = shift; | 5281 my $type = shift; |
5267 return 0 if GetArrayType($type); | 5282 return 0 if GetArrayType($type); |
5268 return 0 if GetSequenceType($type); | 5283 return 0 if GetSequenceType($type); |
5269 return 0 if IsCallbackFunctionType($type); | 5284 return 0 if IsCallbackFunctionType($type); |
5270 return 0 if IsEnumType($type); | 5285 return 0 if IsEnumType($type); |
5271 return 0 if IsPrimitiveType($type); | 5286 return 0 if IsPrimitiveType($type); |
5272 return 0 if $type eq "DOMString"; | 5287 return 0 if $type eq "DOMString"; |
| 5288 return 0 if $type eq "Promise"; |
5273 return !$nonWrapperTypes{$type}; | 5289 return !$nonWrapperTypes{$type}; |
5274 } | 5290 } |
5275 | 5291 |
5276 sub IsCallbackInterface | 5292 sub IsCallbackInterface |
5277 { | 5293 { |
5278 my $type = shift; | 5294 my $type = shift; |
5279 return 0 unless IsWrapperType($type); | 5295 return 0 unless IsWrapperType($type); |
5280 return 0 if IsTypedArrayType($type); | 5296 return 0 if IsTypedArrayType($type); |
5281 | 5297 |
5282 my $idlFile = IDLFileForInterface($type) | 5298 my $idlFile = IDLFileForInterface($type) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5412 return "${indent}v8SetReturnValue(${getCallbackInfo}, static_cast<double
>($nativeValue));" if $isReturnValue; | 5428 return "${indent}v8SetReturnValue(${getCallbackInfo}, static_cast<double
>($nativeValue));" if $isReturnValue; |
5413 return "$indent$receiver v8::Number::New(static_cast<double>($nativeValu
e));"; | 5429 return "$indent$receiver v8::Number::New(static_cast<double>($nativeValu
e));"; |
5414 } | 5430 } |
5415 | 5431 |
5416 if (IsPrimitiveType($type)) { | 5432 if (IsPrimitiveType($type)) { |
5417 die "unexpected type $type" if not ($type eq "float" or $type eq "double
"); | 5433 die "unexpected type $type" if not ($type eq "float" or $type eq "double
"); |
5418 return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue});"
if $isReturnValue; | 5434 return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue});"
if $isReturnValue; |
5419 return "$indent$receiver v8::Number::New($nativeValue);"; | 5435 return "$indent$receiver v8::Number::New($nativeValue);"; |
5420 } | 5436 } |
5421 | 5437 |
5422 if ($nativeType eq "ScriptValue") { | 5438 if ($nativeType eq "ScriptValue" or $nativeType eq "ScriptPromise") { |
5423 return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue}.v8V
alue());" if $isReturnValue; | 5439 return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue}.v8V
alue());" if $isReturnValue; |
5424 return "$indent$receiver $nativeValue.v8Value();"; | 5440 return "$indent$receiver $nativeValue.v8Value();"; |
5425 } | 5441 } |
5426 | 5442 |
5427 my $conv = $extendedAttributes->{"TreatReturnedNullStringAs"}; | 5443 my $conv = $extendedAttributes->{"TreatReturnedNullStringAs"}; |
5428 if (($type eq "DOMString" || IsEnumType($type)) && $isReturnValue) { | 5444 if (($type eq "DOMString" || IsEnumType($type)) && $isReturnValue) { |
5429 my $functionSuffix = ""; | 5445 my $functionSuffix = ""; |
5430 if (defined $conv) { | 5446 if (defined $conv) { |
5431 if ($conv eq "Null") { | 5447 if ($conv eq "Null") { |
5432 $functionSuffix = "OrNull"; | 5448 $functionSuffix = "OrNull"; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5682 | 5698 |
5683 sub IsRefPtrType | 5699 sub IsRefPtrType |
5684 { | 5700 { |
5685 my $type = shift; | 5701 my $type = shift; |
5686 | 5702 |
5687 return 0 if $type eq "any"; | 5703 return 0 if $type eq "any"; |
5688 return 0 if IsPrimitiveType($type); | 5704 return 0 if IsPrimitiveType($type); |
5689 return 0 if GetArrayType($type); | 5705 return 0 if GetArrayType($type); |
5690 return 0 if GetSequenceType($type); | 5706 return 0 if GetSequenceType($type); |
5691 return 0 if $type eq "DOMString"; | 5707 return 0 if $type eq "DOMString"; |
| 5708 return 0 if $type eq "Promise"; |
5692 return 0 if IsCallbackFunctionType($type); | 5709 return 0 if IsCallbackFunctionType($type); |
5693 return 0 if IsEnumType($type); | 5710 return 0 if IsEnumType($type); |
5694 return 0 if IsUnionType($type); | 5711 return 0 if IsUnionType($type); |
5695 | 5712 |
5696 return 1; | 5713 return 1; |
5697 } | 5714 } |
5698 | 5715 |
5699 sub GetSVGTypeNeedingTearOff | 5716 sub GetSVGTypeNeedingTearOff |
5700 { | 5717 { |
5701 my $type = shift; | 5718 my $type = shift; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5998 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 6015 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
5999 $found = 1; | 6016 $found = 1; |
6000 } | 6017 } |
6001 return 1 if $found; | 6018 return 1 if $found; |
6002 }, 0); | 6019 }, 0); |
6003 | 6020 |
6004 return $found; | 6021 return $found; |
6005 } | 6022 } |
6006 | 6023 |
6007 1; | 6024 1; |
OLD | NEW |