Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2013-10-29 23:27:24 +0400
committerTrevor Norris <trev.norris@gmail.com>2013-10-30 02:09:44 +0400
commit93f75a86bf6c87aa897312740aab61282b0eff1d (patch)
tree18c33d405b8f22bfeeb1a35cba45fa3b9d9703ed /src/util-inl.h
parent4b84e42f67d7754574bf7d289524f6dffcb5e14a (diff)
src: use function to get internal pointer
Remove the NODE_{WRAP,UNWRAP} macros and instead use template functions.
Diffstat (limited to 'src/util-inl.h')
-rw-r--r--src/util-inl.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util-inl.h b/src/util-inl.h
index 1ea31d94db9..8257e5a9e18 100644
--- a/src/util-inl.h
+++ b/src/util-inl.h
@@ -24,6 +24,8 @@
#include "util.h"
+#include <assert.h>
+
namespace node {
template <class TypeName>
@@ -78,6 +80,21 @@ inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
length);
}
+template <typename TypeName>
+void WrapObject(v8::Local<v8::Object> object, TypeName* pointer) {
+ assert(!object.IsEmpty());
+ assert(object->InternalFieldCount() > 0);
+ object->SetAlignedPointerInInternalField(0, pointer);
+}
+
+template <typename TypeName>
+TypeName* UnwrapObject(v8::Local<v8::Object> object) {
+ assert(!object.IsEmpty());
+ assert(object->InternalFieldCount() > 0);
+ void* pointer = object->GetAlignedPointerFromInternalField(0);
+ return static_cast<TypeName*>(pointer);
+}
+
} // namespace node
#endif // SRC_UTIL_INL_H_