Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: Source/bindings/scripts/deprecated_code_generator_v8.pm

Issue 23479016: Introduce Promise mapping to the IDL generator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 return if SkipIncludeHeader($type); 421 return if SkipIncludeHeader($type);
422 422
423 # Default includes 423 # Default includes
424 if ($type eq "EventListener" or $type eq "EventHandler") { 424 if ($type eq "EventListener" or $type eq "EventHandler") {
425 AddToImplIncludes("core/dom/EventListener.h"); 425 AddToImplIncludes("core/dom/EventListener.h");
426 } elsif ($type eq "SerializedScriptValue") { 426 } elsif ($type eq "SerializedScriptValue") {
427 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); 427 AddToImplIncludes("bindings/v8/SerializedScriptValue.h");
428 } elsif ($type eq "any" || IsCallbackFunctionType($type)) { 428 } elsif ($type eq "any" || IsCallbackFunctionType($type)) {
429 AddToImplIncludes("bindings/v8/ScriptValue.h"); 429 AddToImplIncludes("bindings/v8/ScriptValue.h");
430 } elsif ($type eq "Promise") {
431 AddToImplIncludes("bindings/v8/ScriptPromise.h");
432 } elsif ($type eq "PromiseResolver") {
433 AddToImplIncludes("bindings/v8/ScriptPromiseResolver.h");
430 } elsif (IsTypedArrayType($type)) { 434 } elsif (IsTypedArrayType($type)) {
431 AddToImplIncludes("bindings/v8/custom/V8${type}Custom.h"); 435 AddToImplIncludes("bindings/v8/custom/V8${type}Custom.h");
432 } else { 436 } else {
433 AddToImplIncludes("V8${type}.h"); 437 AddToImplIncludes("V8${type}.h");
434 } 438 }
435 } 439 }
436 440
437 sub HeaderFilesForInterface 441 sub HeaderFilesForInterface
438 { 442 {
439 my $interfaceName = shift; 443 my $interfaceName = shift;
(...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 if (IsWrapperType($argType)) { 2455 if (IsWrapperType($argType)) {
2452 $parameterCheckString .= " if (args.Length() > $paramInde x && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue, args .GetIsolate(), worldType(args.GetIsolate()))) {\n"; 2456 $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"; 2457 $parameterCheckString .= " throwTypeError(args.GetIso late());\n";
2454 $parameterCheckString .= " return;\n"; 2458 $parameterCheckString .= " return;\n";
2455 $parameterCheckString .= " }\n"; 2459 $parameterCheckString .= " }\n";
2456 } 2460 }
2457 } 2461 }
2458 my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : ""; 2462 my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : "";
2459 my $jsValue = $parameter->isOptional && $default eq "NullString" ? " argumentOrNull(args, $paramIndex)" : "args[$paramIndex]"; 2463 my $jsValue = $parameter->isOptional && $default eq "NullString" ? " argumentOrNull(args, $paramIndex)" : "args[$paramIndex]";
2460 $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola te()"); 2464 $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola te()");
2461 if ($nativeType eq 'Dictionary') { 2465 if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise' or $nativeType eq 'ScriptPromiseResolver') {
2462 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN ull() && !$parameterName.isObject()) {\n"; 2466 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN ull() && !$parameterName.isObject()) {\n";
2463 $parameterCheckString .= " throwTypeError(\"Not an object .\", args.GetIsolate());\n"; 2467 $parameterCheckString .= " throwTypeError(\"Not an object .\", args.GetIsolate());\n";
2464 $parameterCheckString .= " return;\n"; 2468 $parameterCheckString .= " return;\n";
2465 $parameterCheckString .= " }\n"; 2469 $parameterCheckString .= " }\n";
2466 } 2470 }
2467 } 2471 }
2468 2472
2469 $paramIndex++; 2473 $paramIndex++;
2470 } 2474 }
2471 return ($parameterCheckString, $paramIndex, %replacements); 2475 return ($parameterCheckString, $paramIndex, %replacements);
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 my $unionMemberVariable = $variableName . $i; 3158 my $unionMemberVariable = $variableName . $i;
3155 my $isNull = GenerateIsNullExpression($unionMemberType, $unionMember Variable); 3159 my $isNull = GenerateIsNullExpression($unionMemberType, $unionMember Variable);
3156 push @expression, $isNull; 3160 push @expression, $isNull;
3157 } 3161 }
3158 return join " && ", @expression; 3162 return join " && ", @expression;
3159 } 3163 }
3160 if (IsRefPtrType($type)) { 3164 if (IsRefPtrType($type)) {
3161 return "!${variableName}"; 3165 return "!${variableName}";
3162 } elsif ($type eq "DOMString") { 3166 } elsif ($type eq "DOMString") {
3163 return "${variableName}.isNull()"; 3167 return "${variableName}.isNull()";
3168 } elsif ($type eq "Promise" or $type eq "PromiseResolver") {
3169 return "${variableName}.isNull()";
3164 } else { 3170 } else {
3165 return ""; 3171 return "";
3166 } 3172 }
3167 } 3173 }
3168 3174
3169 sub GenerateIfElseStatement 3175 sub GenerateIfElseStatement
3170 { 3176 {
3171 my $type = shift; 3177 my $type = shift;
3172 my $outputVariableName = shift; 3178 my $outputVariableName = shift;
3173 my $conditions = shift; 3179 my $conditions = shift;
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
5003 $mode = "WithUndefinedOrNullCheck"; 5009 $mode = "WithUndefinedOrNullCheck";
5004 } elsif (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes-> {"TreatNullAs"} eq "NullString") or $extendedAttributes->{"Reflect"}) { 5010 } elsif (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes-> {"TreatNullAs"} eq "NullString") or $extendedAttributes->{"Reflect"}) {
5005 $mode = "WithNullCheck"; 5011 $mode = "WithNullCheck";
5006 } 5012 }
5007 # FIXME: Add the case for 'elsif ($attributeOrParameter->extendedAttribu tes->{"TreatUndefinedAs"} and $attributeOrParameter->extendedAttributes->{"Treat UndefinedAs"} eq "NullString"))'. 5013 # FIXME: Add the case for 'elsif ($attributeOrParameter->extendedAttribu tes->{"TreatUndefinedAs"} and $attributeOrParameter->extendedAttributes->{"Treat UndefinedAs"} eq "NullString"))'.
5008 return "V8StringResource<$mode>"; 5014 return "V8StringResource<$mode>";
5009 } 5015 }
5010 5016
5011 return "String" if $type eq "DOMString" or IsEnumType($type); 5017 return "String" if $type eq "DOMString" or IsEnumType($type);
5012 5018
5019 return "ScriptPromise" if $type eq "Promise";
5020 return "ScriptPromiseResolver" if $type eq "PromiseResolver";
5021
5013 return "Range::CompareHow" if $type eq "CompareHow"; 5022 return "Range::CompareHow" if $type eq "CompareHow";
5014 return "DOMTimeStamp" if $type eq "DOMTimeStamp"; 5023 return "DOMTimeStamp" if $type eq "DOMTimeStamp";
5015 return "double" if $type eq "Date"; 5024 return "double" if $type eq "Date";
5016 return "ScriptValue" if $type eq "any" or IsCallbackFunctionType($type); 5025 return "ScriptValue" if $type eq "any" or IsCallbackFunctionType($type);
5017 return "Dictionary" if $type eq "Dictionary"; 5026 return "Dictionary" if $type eq "Dictionary";
5018 5027
5019 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; 5028 return "RefPtr<DOMStringList>" if $type eq "DOMStringList";
5020 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener" ; 5029 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener" ;
5021 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; 5030 return "RefPtr<NodeFilter>" if $type eq "NodeFilter";
5022 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; 5031 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue";
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5131 if ($type eq "Dictionary") { 5140 if ($type eq "Dictionary") {
5132 AddToImplIncludes("bindings/v8/Dictionary.h"); 5141 AddToImplIncludes("bindings/v8/Dictionary.h");
5133 return "Dictionary($value, $getIsolate)"; 5142 return "Dictionary($value, $getIsolate)";
5134 } 5143 }
5135 5144
5136 if ($type eq "any" || IsCallbackFunctionType($type)) { 5145 if ($type eq "any" || IsCallbackFunctionType($type)) {
5137 AddToImplIncludes("bindings/v8/ScriptValue.h"); 5146 AddToImplIncludes("bindings/v8/ScriptValue.h");
5138 return "ScriptValue($value)"; 5147 return "ScriptValue($value)";
5139 } 5148 }
5140 5149
5150 if ($type eq "Promise") {
5151 AddToImplIncludes("bindings/v8/ScriptPromise.h");
5152 return "ScriptPromise($value)";
5153 }
5154
5155 if ($type eq "PromiseResolver") {
5156 AddToImplIncludes("bindings/v8/ScriptPromiseResolver.h");
5157 return "ScriptPromiseResolver($value, $getIsolate)";
5158 }
5159
5141 if ($type eq "NodeFilter") { 5160 if ($type eq "NodeFilter") {
5142 return "toNodeFilter($value, $getIsolate)"; 5161 return "toNodeFilter($value, $getIsolate)";
5143 } 5162 }
5144 5163
5145 if ($type eq "MediaQueryListListener") { 5164 if ($type eq "MediaQueryListListener") {
5146 AddToImplIncludes("core/css/MediaQueryListListener.h"); 5165 AddToImplIncludes("core/css/MediaQueryListListener.h");
5147 return "MediaQueryListListener::create(" . $value . ")"; 5166 return "MediaQueryListListener::create(" . $value . ")";
5148 } 5167 }
5149 5168
5150 if ($type eq "EventTarget") { 5169 if ($type eq "EventTarget") {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5262 5281
5263 sub IsWrapperType 5282 sub IsWrapperType
5264 { 5283 {
5265 my $type = shift; 5284 my $type = shift;
5266 return 0 if GetArrayType($type); 5285 return 0 if GetArrayType($type);
5267 return 0 if GetSequenceType($type); 5286 return 0 if GetSequenceType($type);
5268 return 0 if IsCallbackFunctionType($type); 5287 return 0 if IsCallbackFunctionType($type);
5269 return 0 if IsEnumType($type); 5288 return 0 if IsEnumType($type);
5270 return 0 if IsPrimitiveType($type); 5289 return 0 if IsPrimitiveType($type);
5271 return 0 if $type eq "DOMString"; 5290 return 0 if $type eq "DOMString";
5291 return 0 if $type eq "Promise";
5292 return 0 if $type eq "PromiseResolver";
5272 return !$nonWrapperTypes{$type}; 5293 return !$nonWrapperTypes{$type};
5273 } 5294 }
5274 5295
5275 sub IsCallbackInterface 5296 sub IsCallbackInterface
5276 { 5297 {
5277 my $type = shift; 5298 my $type = shift;
5278 return 0 unless IsWrapperType($type); 5299 return 0 unless IsWrapperType($type);
5279 return 0 if IsTypedArrayType($type); 5300 return 0 if IsTypedArrayType($type);
5280 5301
5281 my $idlFile = IDLFileForInterface($type) 5302 my $idlFile = IDLFileForInterface($type)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
5411 return "${indent}v8SetReturnValue(${getCallbackInfo}, static_cast<double >($nativeValue));" if $isReturnValue; 5432 return "${indent}v8SetReturnValue(${getCallbackInfo}, static_cast<double >($nativeValue));" if $isReturnValue;
5412 return "$indent$receiver v8::Number::New(static_cast<double>($nativeValu e));"; 5433 return "$indent$receiver v8::Number::New(static_cast<double>($nativeValu e));";
5413 } 5434 }
5414 5435
5415 if (IsPrimitiveType($type)) { 5436 if (IsPrimitiveType($type)) {
5416 die "unexpected type $type" if not ($type eq "float" or $type eq "double "); 5437 die "unexpected type $type" if not ($type eq "float" or $type eq "double ");
5417 return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue});" if $isReturnValue; 5438 return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue});" if $isReturnValue;
5418 return "$indent$receiver v8::Number::New($nativeValue);"; 5439 return "$indent$receiver v8::Number::New($nativeValue);";
5419 } 5440 }
5420 5441
5421 if ($nativeType eq "ScriptValue") { 5442 if ($nativeType eq "ScriptValue" or $nativeType eq "ScriptPromise" or $nativ eType eq "ScriptPromiseResolver") {
5422 return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue}.v8V alue());" if $isReturnValue; 5443 return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue}.v8V alue());" if $isReturnValue;
5423 return "$indent$receiver $nativeValue.v8Value();"; 5444 return "$indent$receiver $nativeValue.v8Value();";
5424 } 5445 }
5425 5446
5426 my $conv = $extendedAttributes->{"TreatReturnedNullStringAs"}; 5447 my $conv = $extendedAttributes->{"TreatReturnedNullStringAs"};
5427 if (($type eq "DOMString" || IsEnumType($type)) && $isReturnValue) { 5448 if (($type eq "DOMString" || IsEnumType($type)) && $isReturnValue) {
5428 my $functionSuffix = ""; 5449 my $functionSuffix = "";
5429 if (defined $conv) { 5450 if (defined $conv) {
5430 if ($conv eq "Null") { 5451 if ($conv eq "Null") {
5431 $functionSuffix = "OrNull"; 5452 $functionSuffix = "OrNull";
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
5681 5702
5682 sub IsRefPtrType 5703 sub IsRefPtrType
5683 { 5704 {
5684 my $type = shift; 5705 my $type = shift;
5685 5706
5686 return 0 if $type eq "any"; 5707 return 0 if $type eq "any";
5687 return 0 if IsPrimitiveType($type); 5708 return 0 if IsPrimitiveType($type);
5688 return 0 if GetArrayType($type); 5709 return 0 if GetArrayType($type);
5689 return 0 if GetSequenceType($type); 5710 return 0 if GetSequenceType($type);
5690 return 0 if $type eq "DOMString"; 5711 return 0 if $type eq "DOMString";
5712 return 0 if $type eq "Promise";
5713 return 0 if $type eq "PromiseResolver";
5691 return 0 if IsCallbackFunctionType($type); 5714 return 0 if IsCallbackFunctionType($type);
5692 return 0 if IsEnumType($type); 5715 return 0 if IsEnumType($type);
5693 return 0 if IsUnionType($type); 5716 return 0 if IsUnionType($type);
5694 5717
5695 return 1; 5718 return 1;
5696 } 5719 }
5697 5720
5698 sub GetSVGTypeNeedingTearOff 5721 sub GetSVGTypeNeedingTearOff
5699 { 5722 {
5700 my $type = shift; 5723 my $type = shift;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
5997 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6020 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
5998 $found = 1; 6021 $found = 1;
5999 } 6022 }
6000 return 1 if $found; 6023 return 1 if $found;
6001 }, 0); 6024 }, 0);
6002 6025
6003 return $found; 6026 return $found;
6004 } 6027 }
6005 6028
6006 1; 6029 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698