diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/ToNativeFromValue.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/runtime/ToNativeFromValue.h')
-rw-r--r-- | Source/JavaScriptCore/runtime/ToNativeFromValue.h | 16 |
1 files changed, 11 insertions, 5 deletions
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<typename Adaptor> +std::optional<typename Adaptor::Type> toNativeFromValueWithoutCoercion(JSValue value) +{ + if (!value.isNumber()) + return std::nullopt; + if (value.isInt32()) + return Adaptor::toNativeFromInt32WithoutCoercion(value.asInt32()); + return Adaptor::toNativeFromDoubleWithoutCoercion(value.asDouble()); +} +} // namespace JSC |