summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/ToNativeFromValue.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/ToNativeFromValue.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/runtime/ToNativeFromValue.h')
-rw-r--r--Source/JavaScriptCore/runtime/ToNativeFromValue.h16
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