From 47ff8e3afb6d47133dbe00e7d0ece32cdb848166 Mon Sep 17 00:00:00 2001 From: King Koopa Date: Sat, 9 May 2015 13:23:55 +0300 Subject: [PATCH] Added SaveToPersistent(Handle, ...) and GetFromPersistent(Handle) --- nan.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nan.h b/nan.h index 22ea5211..303d6639 100644 --- a/nan.h +++ b/nan.h @@ -1352,18 +1352,30 @@ class NanCallback { NanNew(persistentHandle)->Set(NanNew(key), value); } + NAN_INLINE void SaveToPersistent( + const v8::Handle &key, const v8::Local &value) { + NanScope(); + NanNew(persistentHandle)->Set(key, value); + } + NAN_INLINE void SaveToPersistent( uint32_t index, const v8::Local &value) { NanScope(); NanNew(persistentHandle)->Set(index, value); } - v8::Local GetFromPersistent(const char *key) const { + NAN_INLINE v8::Local GetFromPersistent(const char *key) const { NanEscapableScope(); return NanEscapeScope(NanNew(persistentHandle)->Get(NanNew(key))); } - v8::Local GetFromPersistent(uint32_t index) const { + NAN_INLINE v8::Local + GetFromPersistent(const v8::Local &key) const { + NanEscapableScope(); + return NanEscapeScope(NanNew(persistentHandle)->Get(key)); + } + + NAN_INLINE v8::Local GetFromPersistent(uint32_t index) const { NanEscapableScope(); return NanEscapeScope(NanNew(persistentHandle)->Get(index)); }