Skip to content

Commit 9b4aa35

Browse files
committed
src: add comments about implicit dependencies
1 parent d120d92 commit 9b4aa35

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/base-object.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class BaseObject {
4040

4141
inline Environment* env() const;
4242

43+
// The handle_ must have an internal field count > 0, and the first
44+
// index is reserved for a pointer to this class. This is an
45+
// implicit requirement, but Node does not have a case where it's
46+
// required that MakeWeak() be called and the internal field not
47+
// be set.
4348
template <typename Type>
4449
inline void MakeWeak(Type* ptr);
4550

src/node_crypto.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class SecureContext : public BaseObject {
120120
}
121121
};
122122

123+
// SSLWrap implicitly depends on the inheriting class' handle having an
124+
// internal pointer to the Base class.
123125
template <class Base>
124126
class SSLWrap {
125127
public:
@@ -217,6 +219,9 @@ class SSLWrap {
217219
friend class SecureContext;
218220
};
219221

222+
// Connection inherits from AsyncWrap because SSLWrap makes calls to
223+
// MakeCallback, but SSLWrap doesn't store the handle itself. Instead it
224+
// assumes that any args.This() called will be the handle from Connection.
220225
class Connection : public SSLWrap<Connection>, public AsyncWrap {
221226
public:
222227
~Connection() {

0 commit comments

Comments
 (0)