diff options
author | Oleg Efimov <efimovov@gmail.com> | 2012-05-21 21:09:40 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-05-21 23:29:06 +0200 |
commit | 45de259b436ab1bbeb15d7f582f29e795f162202 (patch) | |
tree | 827b00eca41c2495d34466d2bf39c99c2daf58fa /src/node_internals.h | |
parent | 81a4edcf6afc1180b80a516db894db400ce04b1a (diff) | |
download | android-node-v8-45de259b436ab1bbeb15d7f582f29e795f162202.tar.gz android-node-v8-45de259b436ab1bbeb15d7f582f29e795f162202.tar.bz2 android-node-v8-45de259b436ab1bbeb15d7f582f29e795f162202.zip |
Make UNWRAP macro generic.
Diffstat (limited to 'src/node_internals.h')
-rw-r--r-- | src/node_internals.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/node_internals.h b/src/node_internals.h index 8d073927b8..80aa4e5366 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -22,6 +22,8 @@ #ifndef SRC_NODE_INTERNALS_H_ #define SRC_NODE_INTERNALS_H_ +#include <stdlib.h> + #include "v8.h" namespace node { @@ -81,6 +83,17 @@ inline static v8::Handle<v8::Value> ThrowRangeError(const char* errmsg) { THROW_ERROR(v8::Exception::RangeError); } +#define UNWRAP(type) \ + assert(!args.Holder().IsEmpty()); \ + assert(args.Holder()->InternalFieldCount() > 0); \ + type* wrap = \ + static_cast<type*>(args.Holder()->GetPointerFromInternalField(0)); \ + if (!wrap) { \ + fprintf(stderr, #type ": Aborting due to unwrap failure at %s:%d\n", \ + __FILE__, __LINE__); \ + abort(); \ + } + } // namespace node #endif // SRC_NODE_INTERNALS_H_ |