Skip to content

Commit

Permalink
Added SaveToPersistent(Handle<String>, ...) and GetFromPersistent(Han…
Browse files Browse the repository at this point in the history
…dle<String>)
  • Loading branch information
kkoopa committed May 9, 2015
1 parent 49f2333 commit 47ff8e3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -1352,18 +1352,30 @@ class NanCallback {
NanNew(persistentHandle)->Set(NanNew(key), value);
}

NAN_INLINE void SaveToPersistent(
const v8::Handle<v8::String> &key, const v8::Local<v8::Value> &value) {
NanScope();
NanNew(persistentHandle)->Set(key, value);
}

NAN_INLINE void SaveToPersistent(
uint32_t index, const v8::Local<v8::Value> &value) {
NanScope();
NanNew(persistentHandle)->Set(index, value);
}

v8::Local<v8::Value> GetFromPersistent(const char *key) const {
NAN_INLINE v8::Local<v8::Value> GetFromPersistent(const char *key) const {
NanEscapableScope();
return NanEscapeScope(NanNew(persistentHandle)->Get(NanNew(key)));
}

v8::Local<v8::Value> GetFromPersistent(uint32_t index) const {
NAN_INLINE v8::Local<v8::Value>
GetFromPersistent(const v8::Local<v8::String> &key) const {
NanEscapableScope();
return NanEscapeScope(NanNew(persistentHandle)->Get(key));
}

NAN_INLINE v8::Local<v8::Value> GetFromPersistent(uint32_t index) const {
NanEscapableScope();
return NanEscapeScope(NanNew(persistentHandle)->Get(index));
}
Expand Down

0 comments on commit 47ff8e3

Please sign in to comment.