From 9b4aa355e3817f5c5a8c5e5c78b92ce43db72f45 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Mon, 4 Nov 2013 16:24:36 -0800 Subject: [PATCH] src: add comments about implicit dependencies --- src/base-object.h | 5 +++++ src/node_crypto.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/base-object.h b/src/base-object.h index 8b3f6da594..3a18a4fde4 100644 --- a/src/base-object.h +++ b/src/base-object.h @@ -40,6 +40,11 @@ class BaseObject { inline Environment* env() const; + // The handle_ must have an internal field count > 0, and the first + // index is reserved for a pointer to this class. This is an + // implicit requirement, but Node does not have a case where it's + // required that MakeWeak() be called and the internal field not + // be set. template inline void MakeWeak(Type* ptr); diff --git a/src/node_crypto.h b/src/node_crypto.h index 3f7f7b35bd..afeddd92cb 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -120,6 +120,8 @@ class SecureContext : public BaseObject { } }; +// SSLWrap implicitly depends on the inheriting class' handle having an +// internal pointer to the Base class. template class SSLWrap { public: @@ -217,6 +219,9 @@ class SSLWrap { friend class SecureContext; }; +// Connection inherits from AsyncWrap because SSLWrap makes calls to +// MakeCallback, but SSLWrap doesn't store the handle itself. Instead it +// assumes that any args.This() called will be the handle from Connection. class Connection : public SSLWrap, public AsyncWrap { public: ~Connection() {