src: constify WITH_GENERIC_STREAM macro
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 7 Aug 2013 12:53:49 +0000 (14:53 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Wed, 7 Aug 2013 12:53:50 +0000 (14:53 +0200)
Make the pointer-to-wrap const (i.e. mutable but not assignable) to
prevent accidental reassignment in the macro body.

src/node_wrap.h

index c5fe0fc..8839a7a 100644 (file)
@@ -39,13 +39,13 @@ extern v8::Persistent<v8::FunctionTemplate> tcpConstructorTmpl;
 #define WITH_GENERIC_STREAM(obj, BODY)                    \
     do {                                                  \
       if (HasInstance(tcpConstructorTmpl, obj)) {         \
-        TCPWrap* wrap = TCPWrap::Unwrap(obj);             \
+        TCPWrap* const wrap = TCPWrap::Unwrap(obj);       \
         BODY                                              \
       } else if (HasInstance(ttyConstructorTmpl, obj)) {  \
-        TTYWrap* wrap = TTYWrap::Unwrap(obj);             \
+        TTYWrap* const wrap = TTYWrap::Unwrap(obj);       \
         BODY                                              \
       } else if (HasInstance(pipeConstructorTmpl, obj)) { \
-        PipeWrap* wrap = PipeWrap::Unwrap(obj);           \
+        PipeWrap* const wrap = PipeWrap::Unwrap(obj);     \
         BODY                                              \
       }                                                   \
     } while (0)