diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2018-11-07 15:09:40 +0300 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-11-13 07:27:40 +0300 |
commit | 0603c0a53fc7051260f3f3d3de9582bc3e6af7c9 (patch) | |
tree | eec06e49b87c3f3668c10a2ce6bbb0e55d9a14a7 /src/util-inl.h | |
parent | bda4643242159bb74f187614854485d9cfc31bca (diff) |
src: bundle persistent-to-local methods as class
Create a class `PersistentToLocal` which contains three methods,
`Strong`, `Weak`, and `Default`:
* `Strong` returns a `Local` from a strong persistent reference,
* `Weak` returns a `Local` from a weak persistent reference, and
* `Default` decides based on `IsWeak()` which of the above two to call.
These replace `node::StrongPersistentToLocal()`,
`node::WeakPersistentToLocal()`, and `node::PersistentToLocal()`,
respectively.
PR-URL: https://github.com/nodejs/node/pull/24276
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'src/util-inl.h')
-rw-r--r-- | src/util-inl.h | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/src/util-inl.h b/src/util-inl.h index 0edf77496e9..acd370e2358 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -165,31 +165,6 @@ constexpr ContainerOfHelper<Inner, Outer> ContainerOf(Inner Outer::*field, return ContainerOfHelper<Inner, Outer>(field, pointer); } -template <class TypeName> -inline v8::Local<TypeName> PersistentToLocal( - v8::Isolate* isolate, - const Persistent<TypeName>& persistent) { - if (persistent.IsWeak()) { - return WeakPersistentToLocal(isolate, persistent); - } else { - return StrongPersistentToLocal(persistent); - } -} - -template <class TypeName> -inline v8::Local<TypeName> StrongPersistentToLocal( - const Persistent<TypeName>& persistent) { - return *reinterpret_cast<v8::Local<TypeName>*>( - const_cast<Persistent<TypeName>*>(&persistent)); -} - -template <class TypeName> -inline v8::Local<TypeName> WeakPersistentToLocal( - v8::Isolate* isolate, - const Persistent<TypeName>& persistent) { - return v8::Local<TypeName>::New(isolate, persistent); -} - inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, const char* data, int length) { |