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

Side by Side Diff: Source/bindings/tests/results/core/V8TestInterface.cpp

Issue 567503002: Add toDouble() helper, and use toFloat()/toDouble() for conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6 6
7 #include "config.h" 7 #include "config.h"
8 #if ENABLE(CONDITION) 8 #if ENABLE(CONDITION)
9 #include "V8TestInterface.h" 9 #include "V8TestInterface.h"
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 95 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
96 TestInterfaceImplementationV8Internal::doubleAttributeAttributeGetter(info); 96 TestInterfaceImplementationV8Internal::doubleAttributeAttributeGetter(info);
97 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 97 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
98 } 98 }
99 99
100 static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v 8::PropertyCallbackInfo<void>& info) 100 static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v 8::PropertyCallbackInfo<void>& info)
101 { 101 {
102 v8::Handle<v8::Object> holder = info.Holder(); 102 v8::Handle<v8::Object> holder = info.Holder();
103 ExceptionState exceptionState(ExceptionState::SetterContext, "doubleAttribut e", "TestInterface", holder, info.GetIsolate()); 103 ExceptionState exceptionState(ExceptionState::SetterContext, "doubleAttribut e", "TestInterface", holder, info.GetIsolate());
104 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 104 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
105 TONATIVE_VOID(double, cppValue, static_cast<double>(v8Value->NumberValue())) ; 105 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionSt ate), exceptionState);
106 if (!std::isfinite(cppValue)) { 106 if (!std::isfinite(cppValue)) {
107 exceptionState.throwTypeError("The provided double value is non-finite." ); 107 exceptionState.throwTypeError("The provided double value is non-finite." );
108 exceptionState.throwIfNeeded(); 108 exceptionState.throwIfNeeded();
109 return; 109 return;
110 } 110 }
111 impl->setDoubleAttribute(cppValue); 111 impl->setDoubleAttribute(cppValue);
112 } 112 }
113 113
114 static void doubleAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 114 static void doubleAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
115 { 115 {
(...skipping 14 matching lines...) Expand all
130 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 130 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
131 TestInterfaceImplementationV8Internal::floatAttributeAttributeGetter(info); 131 TestInterfaceImplementationV8Internal::floatAttributeAttributeGetter(info);
132 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 132 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
133 } 133 }
134 134
135 static void floatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8 ::PropertyCallbackInfo<void>& info) 135 static void floatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8 ::PropertyCallbackInfo<void>& info)
136 { 136 {
137 v8::Handle<v8::Object> holder = info.Holder(); 137 v8::Handle<v8::Object> holder = info.Holder();
138 ExceptionState exceptionState(ExceptionState::SetterContext, "floatAttribute ", "TestInterface", holder, info.GetIsolate()); 138 ExceptionState exceptionState(ExceptionState::SetterContext, "floatAttribute ", "TestInterface", holder, info.GetIsolate());
139 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 139 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
140 TONATIVE_VOID(float, cppValue, static_cast<float>(v8Value->NumberValue())); 140 TONATIVE_VOID_EXCEPTIONSTATE(float, cppValue, toFloat(v8Value, exceptionStat e), exceptionState);
141 if (!std::isfinite(cppValue)) { 141 if (!std::isfinite(cppValue)) {
142 exceptionState.throwTypeError("The provided float value is non-finite.") ; 142 exceptionState.throwTypeError("The provided float value is non-finite.") ;
143 exceptionState.throwIfNeeded(); 143 exceptionState.throwIfNeeded();
144 return; 144 return;
145 } 145 }
146 impl->setFloatAttribute(cppValue); 146 impl->setFloatAttribute(cppValue);
147 } 147 }
148 148
149 static void floatAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Loc al<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 149 static void floatAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Loc al<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
150 { 150 {
(...skipping 12 matching lines...) Expand all
163 static void unrestrictedDoubleAttributeAttributeGetterCallback(v8::Local<v8::Str ing>, const v8::PropertyCallbackInfo<v8::Value>& info) 163 static void unrestrictedDoubleAttributeAttributeGetterCallback(v8::Local<v8::Str ing>, const v8::PropertyCallbackInfo<v8::Value>& info)
164 { 164 {
165 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 165 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
166 TestInterfaceImplementationV8Internal::unrestrictedDoubleAttributeAttributeG etter(info); 166 TestInterfaceImplementationV8Internal::unrestrictedDoubleAttributeAttributeG etter(info);
167 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 167 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
168 } 168 }
169 169
170 static void unrestrictedDoubleAttributeAttributeSetter(v8::Local<v8::Value> v8Va lue, const v8::PropertyCallbackInfo<void>& info) 170 static void unrestrictedDoubleAttributeAttributeSetter(v8::Local<v8::Value> v8Va lue, const v8::PropertyCallbackInfo<void>& info)
171 { 171 {
172 v8::Handle<v8::Object> holder = info.Holder(); 172 v8::Handle<v8::Object> holder = info.Holder();
173 ExceptionState exceptionState(ExceptionState::SetterContext, "unrestrictedDo ubleAttribute", "TestInterface", holder, info.GetIsolate());
173 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 174 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
174 TONATIVE_VOID(double, cppValue, static_cast<double>(v8Value->NumberValue())) ; 175 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionSt ate), exceptionState);
175 impl->setUnrestrictedDoubleAttribute(cppValue); 176 impl->setUnrestrictedDoubleAttribute(cppValue);
176 } 177 }
177 178
178 static void unrestrictedDoubleAttributeAttributeSetterCallback(v8::Local<v8::Str ing>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 179 static void unrestrictedDoubleAttributeAttributeSetterCallback(v8::Local<v8::Str ing>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
179 { 180 {
180 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 181 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
181 TestInterfaceImplementationV8Internal::unrestrictedDoubleAttributeAttributeS etter(v8Value, info); 182 TestInterfaceImplementationV8Internal::unrestrictedDoubleAttributeAttributeS etter(v8Value, info);
182 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 183 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
183 } 184 }
184 185
185 static void unrestrictedFloatAttributeAttributeGetter(const v8::PropertyCallback Info<v8::Value>& info) 186 static void unrestrictedFloatAttributeAttributeGetter(const v8::PropertyCallback Info<v8::Value>& info)
186 { 187 {
187 v8::Handle<v8::Object> holder = info.Holder(); 188 v8::Handle<v8::Object> holder = info.Holder();
188 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 189 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
189 v8SetReturnValue(info, impl->unrestrictedFloatAttribute()); 190 v8SetReturnValue(info, impl->unrestrictedFloatAttribute());
190 } 191 }
191 192
192 static void unrestrictedFloatAttributeAttributeGetterCallback(v8::Local<v8::Stri ng>, const v8::PropertyCallbackInfo<v8::Value>& info) 193 static void unrestrictedFloatAttributeAttributeGetterCallback(v8::Local<v8::Stri ng>, const v8::PropertyCallbackInfo<v8::Value>& info)
193 { 194 {
194 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 195 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
195 TestInterfaceImplementationV8Internal::unrestrictedFloatAttributeAttributeGe tter(info); 196 TestInterfaceImplementationV8Internal::unrestrictedFloatAttributeAttributeGe tter(info);
196 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 197 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
197 } 198 }
198 199
199 static void unrestrictedFloatAttributeAttributeSetter(v8::Local<v8::Value> v8Val ue, const v8::PropertyCallbackInfo<void>& info) 200 static void unrestrictedFloatAttributeAttributeSetter(v8::Local<v8::Value> v8Val ue, const v8::PropertyCallbackInfo<void>& info)
200 { 201 {
201 v8::Handle<v8::Object> holder = info.Holder(); 202 v8::Handle<v8::Object> holder = info.Holder();
203 ExceptionState exceptionState(ExceptionState::SetterContext, "unrestrictedFl oatAttribute", "TestInterface", holder, info.GetIsolate());
202 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 204 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
203 TONATIVE_VOID(float, cppValue, static_cast<float>(v8Value->NumberValue())); 205 TONATIVE_VOID_EXCEPTIONSTATE(float, cppValue, toFloat(v8Value, exceptionStat e), exceptionState);
204 impl->setUnrestrictedFloatAttribute(cppValue); 206 impl->setUnrestrictedFloatAttribute(cppValue);
205 } 207 }
206 208
207 static void unrestrictedFloatAttributeAttributeSetterCallback(v8::Local<v8::Stri ng>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 209 static void unrestrictedFloatAttributeAttributeSetterCallback(v8::Local<v8::Stri ng>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
208 { 210 {
209 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 211 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
210 TestInterfaceImplementationV8Internal::unrestrictedFloatAttributeAttributeSe tter(v8Value, info); 212 TestInterfaceImplementationV8Internal::unrestrictedFloatAttributeAttributeSe tter(v8Value, info);
211 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 213 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
212 } 214 }
213 215
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 998
997 static void voidMethodTestInterfaceEmptyArgMethodCallback(const v8::FunctionCall backInfo<v8::Value>& info) 999 static void voidMethodTestInterfaceEmptyArgMethodCallback(const v8::FunctionCall backInfo<v8::Value>& info)
998 { 1000 {
999 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 1001 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
1000 TestInterfaceImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethod (info); 1002 TestInterfaceImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethod (info);
1001 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1003 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1002 } 1004 }
1003 1005
1004 static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8: :Value>& info) 1006 static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8: :Value>& info)
1005 { 1007 {
1008 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodD oubleArgFloatArg", "TestInterface", info.Holder(), info.GetIsolate());
1006 if (UNLIKELY(info.Length() < 2)) { 1009 if (UNLIKELY(info.Length() < 2)) {
1007 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("v oidMethodDoubleArgFloatArg", "TestInterface", 2, info.Length(), info.GetIsolate( )), info.GetIsolate()); 1010 setMinimumArityTypeError(exceptionState, 2, info.Length());
1011 exceptionState.throwIfNeeded();
1008 return; 1012 return;
1009 } 1013 }
1010 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); 1014 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
1011 double doubleArg; 1015 double doubleArg;
1012 float floatArg; 1016 float floatArg;
1013 { 1017 {
1014 v8::TryCatch block; 1018 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(doubleArg, toDouble(info[0], excep tionState), exceptionState);
1015 V8RethrowTryCatchScope rethrow(block);
1016 TONATIVE_VOID_INTERNAL(doubleArg, static_cast<double>(info[0]->NumberVal ue()));
1017 if (!std::isfinite(doubleArg)) { 1019 if (!std::isfinite(doubleArg)) {
1018 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute( "voidMethodDoubleArgFloatArg", "TestInterface", "double parameter 1 is non-finit e."), info.GetIsolate()); 1020 exceptionState.throwTypeError("double parameter 1 is non-finite.");
1021 exceptionState.throwIfNeeded();
1019 return; 1022 return;
1020 } 1023 }
1021 TONATIVE_VOID_INTERNAL(floatArg, static_cast<float>(info[1]->NumberValue ())); 1024 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(floatArg, toFloat(info[1], excepti onState), exceptionState);
1022 if (!std::isfinite(floatArg)) { 1025 if (!std::isfinite(floatArg)) {
1023 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute( "voidMethodDoubleArgFloatArg", "TestInterface", "float parameter 2 is non-finite ."), info.GetIsolate()); 1026 exceptionState.throwTypeError("float parameter 2 is non-finite.");
1027 exceptionState.throwIfNeeded();
1024 return; 1028 return;
1025 } 1029 }
1026 } 1030 }
1027 impl->voidMethodDoubleArgFloatArg(doubleArg, floatArg); 1031 impl->voidMethodDoubleArgFloatArg(doubleArg, floatArg);
1028 } 1032 }
1029 1033
1030 static void voidMethodDoubleArgFloatArgMethodCallback(const v8::FunctionCallback Info<v8::Value>& info) 1034 static void voidMethodDoubleArgFloatArgMethodCallback(const v8::FunctionCallback Info<v8::Value>& info)
1031 { 1035 {
1032 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 1036 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
1033 TestInterfaceImplementationV8Internal::voidMethodDoubleArgFloatArgMethod(inf o); 1037 TestInterfaceImplementationV8Internal::voidMethodDoubleArgFloatArgMethod(inf o);
1034 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1038 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1035 } 1039 }
1036 1040
1037 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(const v8:: FunctionCallbackInfo<v8::Value>& info) 1041 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(const v8:: FunctionCallbackInfo<v8::Value>& info)
1038 { 1042 {
1043 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodU nrestrictedDoubleArgUnrestrictedFloatArg", "TestInterface", info.Holder(), info. GetIsolate());
1039 if (UNLIKELY(info.Length() < 2)) { 1044 if (UNLIKELY(info.Length() < 2)) {
1040 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("v oidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", "TestInterface", 2, info.Le ngth(), info.GetIsolate()), info.GetIsolate()); 1045 setMinimumArityTypeError(exceptionState, 2, info.Length());
1046 exceptionState.throwIfNeeded();
1041 return; 1047 return;
1042 } 1048 }
1043 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); 1049 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
1044 double unrestrictedDoubleArg; 1050 double unrestrictedDoubleArg;
1045 float unrestrictedFloatArg; 1051 float unrestrictedFloatArg;
1046 { 1052 {
1047 v8::TryCatch block; 1053 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(unrestrictedDoubleArg, toDouble(in fo[0], exceptionState), exceptionState);
1048 V8RethrowTryCatchScope rethrow(block); 1054 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(unrestrictedFloatArg, toFloat(info [1], exceptionState), exceptionState);
1049 TONATIVE_VOID_INTERNAL(unrestrictedDoubleArg, static_cast<double>(info[0 ]->NumberValue()));
1050 TONATIVE_VOID_INTERNAL(unrestrictedFloatArg, static_cast<float>(info[1]- >NumberValue()));
1051 } 1055 }
1052 impl->voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg(unrestrictedDouble Arg, unrestrictedFloatArg); 1056 impl->voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg(unrestrictedDouble Arg, unrestrictedFloatArg);
1053 } 1057 }
1054 1058
1055 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback(co nst v8::FunctionCallbackInfo<v8::Value>& info) 1059 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback(co nst v8::FunctionCallbackInfo<v8::Value>& info)
1056 { 1060 {
1057 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 1061 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
1058 TestInterfaceImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrest rictedFloatArgMethod(info); 1062 TestInterfaceImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrest rictedFloatArgMethod(info);
1059 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1063 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1060 } 1064 }
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 if (block.HasCaught()) { 2181 if (block.HasCaught()) {
2178 PrivateScriptRunner::rethrowExceptionInPrivateScript(scriptState->isolat e(), exceptionState, block); 2182 PrivateScriptRunner::rethrowExceptionInPrivateScript(scriptState->isolat e(), exceptionState, block);
2179 block.ReThrow(); 2183 block.ReThrow();
2180 return false; 2184 return false;
2181 } 2185 }
2182 return true; 2186 return true;
2183 } 2187 }
2184 2188
2185 } // namespace blink 2189 } // namespace blink
2186 #endif // ENABLE(CONDITION) 2190 #endif // ENABLE(CONDITION)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698