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

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

Issue 23440058: Improve generated TypeError exception messages in bindings. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 | Annotate | Revision Log
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 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2635 my $interface = shift; 2635 my $interface = shift;
2636 2636
2637 my $implClassName = GetImplName($interface); 2637 my $implClassName = GetImplName($interface);
2638 my $v8ClassName = GetV8ClassName($interface); 2638 my $v8ClassName = GetV8ClassName($interface);
2639 my $code = ""; 2639 my $code = "";
2640 $code .= "void ${v8ClassName}::constructorCallback(const v8::FunctionCallbac kInfo<v8::Value>& args)\n"; 2640 $code .= "void ${v8ClassName}::constructorCallback(const v8::FunctionCallbac kInfo<v8::Value>& args)\n";
2641 $code .= "{\n"; 2641 $code .= "{\n";
2642 $code .= " TRACE_EVENT_SCOPED_SAMPLING_STATE(\"Blink\", \"DOMConstructor\ ");\n"; 2642 $code .= " TRACE_EVENT_SCOPED_SAMPLING_STATE(\"Blink\", \"DOMConstructor\ ");\n";
2643 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"}); 2643 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"});
2644 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D eprecateAs"}); 2644 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D eprecateAs"});
2645 $code .= GenerateConstructorHeader(); 2645 $code .= GenerateConstructorHeader($implClassName);
2646 if (HasCustomConstructor($interface)) { 2646 if (HasCustomConstructor($interface)) {
2647 $code .= " ${v8ClassName}::constructorCustom(args);\n"; 2647 $code .= " ${v8ClassName}::constructorCustom(args);\n";
2648 } else { 2648 } else {
2649 $code .= " ${implClassName}V8Internal::constructor(args);\n"; 2649 $code .= " ${implClassName}V8Internal::constructor(args);\n";
2650 } 2650 }
2651 $code .= "}\n\n"; 2651 $code .= "}\n\n";
2652 $implementation{nameSpaceWebCore}->add($code); 2652 $implementation{nameSpaceWebCore}->add($code);
2653 } 2653 }
2654 2654
2655 sub GenerateConstructor 2655 sub GenerateConstructor
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2818 2818
2819 END 2819 END
2820 2820
2821 my $code = ""; 2821 my $code = "";
2822 $code .= <<END; 2822 $code .= <<END;
2823 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args) 2823 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args)
2824 { 2824 {
2825 END 2825 END
2826 $code .= $maybeObserveFeature if $maybeObserveFeature; 2826 $code .= $maybeObserveFeature if $maybeObserveFeature;
2827 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; 2827 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature;
2828 $code .= GenerateConstructorHeader(); 2828 $code .= GenerateConstructorHeader($implClassName);
2829 AddToImplIncludes("V8Document.h"); 2829 AddToImplIncludes("V8Document.h");
2830 $code .= <<END; 2830 $code .= <<END;
2831 Document* document = currentDocument(); 2831 Document* document = currentDocument();
2832 ASSERT(document); 2832 ASSERT(document);
2833 2833
2834 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance 2834 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance
2835 // may end up being the only node in the map and get garbage-collected prema turely. 2835 // may end up being the only node in the map and get garbage-collected prema turely.
2836 toV8(document, args.Holder(), args.GetIsolate()); 2836 toV8(document, args.Holder(), args.GetIsolate());
2837 2837
2838 END 2838 END
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 2907
2908 return scope.Close(result); 2908 return scope.Close(result);
2909 } 2909 }
2910 2910
2911 END 2911 END
2912 $implementation{nameSpaceWebCore}->add($code); 2912 $implementation{nameSpaceWebCore}->add($code);
2913 } 2913 }
2914 2914
2915 sub GenerateConstructorHeader 2915 sub GenerateConstructorHeader
2916 { 2916 {
2917 my $name = shift;
2918
2919 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
2917 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h"); 2920 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h");
2918 my $content = <<END; 2921 my $content = <<END;
2919 if (!args.IsConstructCall()) { 2922 if (!args.IsConstructCall()) {
2920 throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate()); 2923 throwTypeError(ExceptionMessages::failedToConstruct("$name", "Please use the 'new' operator, this DOM object constructor cannot be called as a function. "), args.GetIsolate());
2921 return; 2924 return;
2922 } 2925 }
2923 2926
2924 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { 2927 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
2925 args.GetReturnValue().Set(args.Holder()); 2928 args.GetReturnValue().Set(args.Holder());
2926 return; 2929 return;
2927 } 2930 }
2928 2931
2929 END 2932 END
2930 return $content; 2933 return $content;
(...skipping 3133 matching lines...) Expand 10 before | Expand all | Expand 10 after
6064 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6067 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
6065 $found = 1; 6068 $found = 1;
6066 } 6069 }
6067 return 1 if $found; 6070 return 1 if $found;
6068 }, 0); 6071 }, 0);
6069 6072
6070 return $found; 6073 return $found;
6071 } 6074 }
6072 6075
6073 1; 6076 1;
OLDNEW
« no previous file with comments | « LayoutTests/fast/mediastream/constructors-expected.txt ('k') | Source/bindings/tests/results/V8Float64Array.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698