From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/JavaScriptCore/runtime/ToNativeFromValue.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Source/JavaScriptCore/runtime/ToNativeFromValue.h') diff --git a/Source/JavaScriptCore/runtime/ToNativeFromValue.h b/Source/JavaScriptCore/runtime/ToNativeFromValue.h index 1d871a607..fd6184327 100644 --- a/Source/JavaScriptCore/runtime/ToNativeFromValue.h +++ b/Source/JavaScriptCore/runtime/ToNativeFromValue.h @@ -23,8 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ToNativeFromValue_h -#define ToNativeFromValue_h +#pragma once #include "JSCJSValue.h" @@ -48,7 +47,14 @@ typename Adaptor::Type toNativeFromValue(ExecState* exec, JSValue value) return Adaptor::toNativeFromDouble(value.toNumber(exec)); } -} // namespace JSC - -#endif // ToNativeFromValue_h +template +std::optional toNativeFromValueWithoutCoercion(JSValue value) +{ + if (!value.isNumber()) + return std::nullopt; + if (value.isInt32()) + return Adaptor::toNativeFromInt32WithoutCoercion(value.asInt32()); + return Adaptor::toNativeFromDoubleWithoutCoercion(value.asDouble()); +} +} // namespace JSC -- cgit v1.2.1