summaryrefslogtreecommitdiff
path: root/src/node.h
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2009-12-13 08:58:12 +0100
committerRyan Dahl <ry@tinyclouds.org>2009-12-29 21:12:29 +0100
commit3377a30fb844a9804b895e20d702bbfc865fb70e (patch)
treedce22468ca8a54b2b43c2d307c665598523fab98 /src/node.h
parente2569c402fc2b1b4f60c71c616a321134e7aa0ca (diff)
downloadnode-3377a30fb844a9804b895e20d702bbfc865fb70e.tar.gz
Move cb_persist functions out of dns module
Diffstat (limited to 'src/node.h')
-rw-r--r--src/node.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/node.h b/src/node.h
index fd872a096..44cf0dbd5 100644
--- a/src/node.h
+++ b/src/node.h
@@ -58,5 +58,24 @@ ssize_t DecodeWrite(char *buf,
v8::Local<v8::Object> BuildStatsObject(struct stat * s);
+static inline v8::Persistent<v8::Function>* cb_persist(
+ const v8::Local<v8::Value> &v) {
+ v8::Persistent<v8::Function> *fn = new v8::Persistent<v8::Function>();
+ *fn = v8::Persistent<v8::Function>::New(v8::Local<v8::Function>::Cast(v));
+ return fn;
+}
+
+static inline v8::Persistent<v8::Function>* cb_unwrap(void *data) {
+ v8::Persistent<v8::Function> *cb =
+ reinterpret_cast<v8::Persistent<v8::Function>*>(data);
+ assert((*cb)->IsFunction());
+ return cb;
+}
+
+static inline void cb_destroy(v8::Persistent<v8::Function> * cb) {
+ cb->Dispose();
+ delete cb;
+}
+
} // namespace node
#endif // SRC_NODE_H_