-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
src: bundle persistent-to-local methods as class #24276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,27 +201,30 @@ template <typename Inner, typename Outer> | |
| constexpr ContainerOfHelper<Inner, Outer> ContainerOf(Inner Outer::*field, | ||
| Inner* pointer); | ||
|
|
||
| // If persistent.IsWeak() == false, then do not call persistent.Reset() | ||
| // while the returned Local<T> is still in scope, it will destroy the | ||
| // reference to the object. | ||
| template <class TypeName> | ||
| inline v8::Local<TypeName> PersistentToLocal( | ||
| v8::Isolate* isolate, | ||
| const Persistent<TypeName>& persistent); | ||
|
|
||
| // Unchecked conversion from a non-weak Persistent<T> to Local<T>, | ||
| // use with care! | ||
| // | ||
| // Do not call persistent.Reset() while the returned Local<T> is still in | ||
| // scope, it will destroy the reference to the object. | ||
| template <class TypeName> | ||
| inline v8::Local<TypeName> StrongPersistentToLocal( | ||
| const Persistent<TypeName>& persistent); | ||
|
|
||
| template <class TypeName> | ||
| inline v8::Local<TypeName> WeakPersistentToLocal( | ||
| v8::Isolate* isolate, | ||
| const Persistent<TypeName>& persistent); | ||
| class PersistentToLocal { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be put into
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P.S. why not move the implementations here? They are all single lines (some could even be You can do feature detection with either // Wordaround a GCC4.9 bug that C++14 N3652 was not implemented
// Refs: https://www.gnu.org/software/gcc/projects/cxx-status.html#cxx14
// Refs: https://isocpp.org/files/papers/N3652.html
#if __cpp_constexpr < 201304
# define constexpr
#endif
.
.
.
#undef constexpr
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't that bring more complexity than necessary? (the constexpr approach) How is it different from doing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A little bit, yes. So up to author. BTW I think there's a CONSTEXPR macro defined by V8 based of this condition, so we could reuse.
It's compile time only, 0 run time cost, only benefits. (only cost is the above mentioned code complexity)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You mean as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bnoordhuis I tried adding them as |
||
| public: | ||
| // If persistent.IsWeak() == false, then do not call persistent.Reset() | ||
| // while the returned Local<T> is still in scope, it will destroy the | ||
| // reference to the object. | ||
| template <class TypeName> | ||
| static inline v8::Local<TypeName> Default( | ||
| v8::Isolate* isolate, | ||
| const Persistent<TypeName>& persistent); | ||
|
|
||
| // Unchecked conversion from a non-weak Persistent<T> to Local<T>, | ||
| // use with care! | ||
| // | ||
| // Do not call persistent.Reset() while the returned Local<T> is still in | ||
| // scope, it will destroy the reference to the object. | ||
| template <class TypeName> | ||
| static inline v8::Local<TypeName> Strong( | ||
| const Persistent<TypeName>& persistent); | ||
|
|
||
| template <class TypeName> | ||
| static inline v8::Local<TypeName> Weak( | ||
| v8::Isolate* isolate, | ||
| const Persistent<TypeName>& persistent); | ||
| }; | ||
|
|
||
| // Convenience wrapper around v8::String::NewFromOneByte(). | ||
| inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.