IncludeJS  0.0.1
Build your own JavaScript runtime
engine_private_data.h
1 #ifndef INCLUDEJS_ENGINE_PRIVATE_DATA_H
2 #define INCLUDEJS_ENGINE_PRIVATE_DATA_H
3 
4 #include <includejs/engine_value.h>
5 
6 #include <map> // std::map
7 #include <memory> // std::unique_ptr
8 
9 namespace includejs {
10 
11 // Inspired by https://github.com/sourcemeta/jsontoolkit
13 struct INCLUDEJS_ENGINE_EXPORT PrivateObjectData {
14  std::unique_ptr<std::map<void *, Value::Function>> functions =
15  std::make_unique<std::map<void *, Value::Function>>();
16 
18 
19  auto data() -> void *;
20  auto set_data(void *new_data,
21  std::function<void(void *)> new_deleter) -> void;
22 
23 private:
24  void *data_ = nullptr;
25  std::function<void(void *)> deleter_;
26 
27  auto clear() -> void;
28 };
29 
30 } // namespace includejs
31 
32 #endif // INCLUDEJS_ENGINE_PRIVATE_DATA_H
Definition: engine_private_data.h:13