From a636fad51e862d52c7bdb527c91300c85ed3c254 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 10 Mar 2015 16:08:30 -0700 Subject: [PATCH] Add converter for unsigned long --- native_mate/converter.cc | 14 ++++++++++++++ native_mate/converter.h | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/native_mate/converter.cc b/native_mate/converter.cc index e5e7c52467..cc66b8d390 100644 --- a/native_mate/converter.cc +++ b/native_mate/converter.cc @@ -31,6 +31,20 @@ bool Converter::FromV8(Isolate* isolate, Handle val, bool* out) { return true; } +Handle Converter::ToV8(Isolate* isolate, + unsigned long val) { + return MATE_INTEGER_NEW(isolate, val); +} + +bool Converter::FromV8(Isolate* isolate, Handle val, + unsigned long* out) { + if (!val->IsNumber()) + return false; + *out = val->IntegerValue(); + return true; +} + + Handle Converter::ToV8(Isolate* isolate, int32_t val) { return MATE_INTEGER_NEW(isolate, val); } diff --git a/native_mate/converter.h b/native_mate/converter.h index 86a1cc4cd0..37d86f82bf 100644 --- a/native_mate/converter.h +++ b/native_mate/converter.h @@ -33,6 +33,15 @@ struct Converter { bool* out); }; +template<> +struct Converter { + static v8::Handle ToV8(v8::Isolate* isolate, + unsigned long val); + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, + unsigned long* out); +}; + template<> struct Converter { static v8::Handle ToV8(v8::Isolate* isolate,