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

Side by Side Diff: Source/bindings/core/v8/V8Binding.cpp

Issue 460923002: Decouple arity errors creation from throwing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « Source/bindings/core/v8/V8Binding.h ('k') | Source/bindings/core/v8/custom/V8ElementCustom.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "wtf/text/AtomicString.h" 66 #include "wtf/text/AtomicString.h"
67 #include "wtf/text/CString.h" 67 #include "wtf/text/CString.h"
68 #include "wtf/text/StringBuffer.h" 68 #include "wtf/text/StringBuffer.h"
69 #include "wtf/text/StringHash.h" 69 #include "wtf/text/StringHash.h"
70 #include "wtf/text/WTFString.h" 70 #include "wtf/text/WTFString.h"
71 #include "wtf/unicode/CharacterNames.h" 71 #include "wtf/unicode/CharacterNames.h"
72 #include "wtf/unicode/Unicode.h" 72 #include "wtf/unicode/Unicode.h"
73 73
74 namespace blink { 74 namespace blink {
75 75
76 void throwArityTypeErrorForMethod(const char* method, const char* type, const ch ar* valid, unsigned provided, v8::Isolate* isolate) 76 void setArityTypeError(ExceptionState& exceptionState, const char* valid, unsign ed provided)
77 { 77 {
78 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute(method, type, ExceptionMessages::invalidArity(valid, provided)), isolate); 78 exceptionState.throwTypeError(ExceptionMessages::invalidArity(valid, provide d));
79 } 79 }
80 80
81 void throwArityTypeErrorForConstructor(const char* type, const char* valid, unsi gned provided, v8::Isolate* isolate) 81 v8::Local<v8::Value> createMinimumArityTypeErrorForMethod(const char* method, co nst char* type, unsigned expected, unsigned providedLeastNumMandatoryParams, v8: :Isolate* isolate)
82 { 82 {
83 V8ThrowException::throwTypeError(ExceptionMessages::failedToConstruct(type, ExceptionMessages::invalidArity(valid, provided)), isolate); 83 return V8ThrowException::createTypeError(ExceptionMessages::failedToExecute( method, type, ExceptionMessages::notEnoughArguments(expected, providedLeastNumMa ndatoryParams)), isolate);
84 } 84 }
85 85
86 void throwArityTypeError(ExceptionState& exceptionState, const char* valid, unsi gned provided) 86 v8::Local<v8::Value> createMinimumArityTypeErrorForConstructor(const char* type, unsigned expected, unsigned providedLeastNumMandatoryParams, v8::Isolate* isola te)
87 { 87 {
88 exceptionState.throwTypeError(ExceptionMessages::invalidArity(valid, provide d)); 88 return V8ThrowException::createTypeError(ExceptionMessages::failedToConstruc t(type, ExceptionMessages::notEnoughArguments(expected, providedLeastNumMandator yParams)), isolate);
89 exceptionState.throwIfNeeded();
90 } 89 }
91 90
92 void throwMinimumArityTypeErrorForMethod(const char* method, const char* type, u nsigned expected, unsigned providedLeastNumMandatoryParams, v8::Isolate* isolate ) 91 void setMinimumArityTypeError(ExceptionState& exceptionState, unsigned expected, unsigned providedLeastNumMandatoryParams)
93 {
94 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute(method, type, ExceptionMessages::notEnoughArguments(expected, providedLeastNumMandatoryP arams)), isolate);
95 }
96
97 void throwMinimumArityTypeErrorForConstructor(const char* type, unsigned expecte d, unsigned providedLeastNumMandatoryParams, v8::Isolate* isolate)
98 {
99 V8ThrowException::throwTypeError(ExceptionMessages::failedToConstruct(type, ExceptionMessages::notEnoughArguments(expected, providedLeastNumMandatoryParams) ), isolate);
100 }
101
102 void throwMinimumArityTypeError(ExceptionState& exceptionState, unsigned expecte d, unsigned providedLeastNumMandatoryParams)
103 { 92 {
104 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(expected , providedLeastNumMandatoryParams)); 93 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(expected , providedLeastNumMandatoryParams));
105 exceptionState.throwIfNeeded();
106 } 94 }
107 95
108 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 96 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
109 virtual void* Allocate(size_t size) OVERRIDE 97 virtual void* Allocate(size_t size) OVERRIDE
110 { 98 {
111 void* data; 99 void* data;
112 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :ZeroInitialize, data); 100 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :ZeroInitialize, data);
113 return data; 101 return data;
114 } 102 }
115 103
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(Executio nContext* context, v8::Handle<v8::Function> function, v8::Isolate* isolate) 903 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(Executio nContext* context, v8::Handle<v8::Function> function, v8::Isolate* isolate)
916 { 904 {
917 int scriptId = 0; 905 int scriptId = 0;
918 String resourceName; 906 String resourceName;
919 int lineNumber = 1; 907 int lineNumber = 1;
920 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe r); 908 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe r);
921 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin eNumber); 909 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin eNumber);
922 } 910 }
923 911
924 } // namespace blink 912 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8Binding.h ('k') | Source/bindings/core/v8/custom/V8ElementCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698