electron/native_mate/mate/persistent_dictionary.h

37 lines
1,022 B
C
Raw Normal View History

2014-09-09 06:12:59 +00:00
// Copyright 2014 Cheng Zhao. All rights reserved.
// Use of this source code is governed by MIT license that can be found in the
// LICENSE file.
#ifndef NATIVE_MATE_PERSISTENT_DICTIONARY_H_
#define NATIVE_MATE_PERSISTENT_DICTIONARY_H_
#include "native_mate/dictionary.h"
#include "native_mate/scoped_persistent.h"
namespace mate {
// Like Dictionary, but stores object in persistent handle so you can keep it
// safely on heap.
class PersistentDictionary : public Dictionary {
public:
PersistentDictionary();
2015-05-22 11:11:02 +00:00
PersistentDictionary(v8::Isolate* isolate, v8::Local<v8::Object> object);
2014-09-09 06:12:59 +00:00
virtual ~PersistentDictionary();
2015-05-22 11:11:02 +00:00
v8::Local<v8::Object> GetHandle() const override;
2014-09-09 06:12:59 +00:00
private:
scoped_refptr<RefCountedPersistent<v8::Object> > handle_;
};
template<>
struct Converter<PersistentDictionary> {
static bool FromV8(v8::Isolate* isolate,
2015-05-22 11:11:02 +00:00
v8::Local<v8::Value> val,
2014-09-09 06:12:59 +00:00
PersistentDictionary* out);
};
} // namespace mate
#endif // NATIVE_MATE_PERSISTENT_DICTIONARY_H_