diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-03-05 03:28:45 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-04-06 03:06:35 +0300 |
commit | 6576b9b9d0f3de931e5e867a7b4b43319b187955 (patch) | |
tree | 11b377c01fb4c2910f66efd41847f3dfbc773eb2 /src/base_object-inl.h | |
parent | c2aedd0310f2efdeb2ae69e14ae9950880bde24a (diff) |
src: make creating per-binding data structures easier
Enable the state associated with the individual bindings, e.g. fs or
http2, to be moved out of the Environment class, in order for these
to be more modular and for Environment to be come less of a collection
of random data fields.
Do this by using a BaseObject as the data for callbacks, which can hold
the per-binding state. By default, no per-binding state is available,
although that can be configured when setting up the binding.
PR-URL: https://github.com/nodejs/node/pull/32538
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/base_object-inl.h')
-rw-r--r-- | src/base_object-inl.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/base_object-inl.h b/src/base_object-inl.h index fc2611444c1..60ccf81cc55 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -100,15 +100,16 @@ Environment* BaseObject::env() const { return env_; } -BaseObject* BaseObject::FromJSObject(v8::Local<v8::Object> obj) { - CHECK_GT(obj->InternalFieldCount(), 0); +BaseObject* BaseObject::FromJSObject(v8::Local<v8::Value> value) { + v8::Local<v8::Object> obj = value.As<v8::Object>(); + DCHECK_GE(obj->InternalFieldCount(), BaseObject::kSlot); return static_cast<BaseObject*>( obj->GetAlignedPointerFromInternalField(BaseObject::kSlot)); } template <typename T> -T* BaseObject::FromJSObject(v8::Local<v8::Object> object) { +T* BaseObject::FromJSObject(v8::Local<v8::Value> object) { return static_cast<T*>(FromJSObject(object)); } |