Skip to content
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

core: set PROVIDER type as Persistent class id #1730

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/async-wrap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ inline AsyncWrap::AsyncWrap(Environment* env,
v8::Handle<v8::Object> object,
ProviderType provider,
AsyncWrap* parent)
: BaseObject(env, object), bits_(static_cast<uint32_t>(provider) << 1) {
: BaseObject(env, object, provider),
bits_(static_cast<uint32_t>(provider) << 1) {
// Check user controlled flag to see if the init callback should run.
if (!env->using_asyncwrap())
return;
Expand Down
7 changes: 6 additions & 1 deletion src/base-object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@

namespace node {

inline BaseObject::BaseObject(Environment* env, v8::Local<v8::Object> handle)
inline BaseObject::BaseObject(Environment* env,
v8::Local<v8::Object> handle,
const uint16_t p_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I suggest you call it class_id? p_id leaves the reader guessing.

: handle_(env->isolate(), handle),
env_(env) {
CHECK_EQ(false, handle.IsEmpty());
// Shift value 8 bits over to try avoiding conflict with anything else.
if (p_id != 0)
handle_.SetWrapperClassId(p_id << 8);
}


Expand Down
4 changes: 3 additions & 1 deletion src/base-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class Environment;

class BaseObject {
public:
BaseObject(Environment* env, v8::Local<v8::Object> handle);
BaseObject(Environment* env,
v8::Local<v8::Object> handle,
const uint16_t p_id = 0);
virtual ~BaseObject();

// Returns the wrapped object. Returns an empty handle when
Expand Down