Skip to content
Closed
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
18 changes: 8 additions & 10 deletions src/base_object.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,9 +24,9 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include <type_traits> // std::remove_reference
#include "memory_tracker.h"
#include "v8.h"
#include <type_traits> // std::remove_reference

namespace node {

Expand DownExpand Up@@ -84,7 +84,7 @@ class BaseObject : public MemoryRetainer {
template <int Field>
static void InternalFieldGet(v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Value>& info);
template <int Field, bool (v8::Value::*typecheck)() const>
template <int Field, bool (v8::Value::*typecheck)() const>
static void InternalFieldSet(v8::Local<v8::String> property,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info);
Expand DownExpand Up@@ -156,13 +156,11 @@ inline T* Unwrap(v8::Local<v8::Value> obj) {
return BaseObject::FromJSObject<T>(obj);
}


#define ASSIGN_OR_RETURN_UNWRAP(ptr, obj, ...) \
do { \
*ptr = static_cast<typename std::remove_reference<decltype(*ptr)>::type>( \
BaseObject::FromJSObject(obj)); \
if (*ptr == nullptr) \
return __VA_ARGS__; \
#define ASSIGN_OR_RETURN_UNWRAP(ptr, obj, ...) \
do { \
*ptr = static_cast<typename std::remove_reference<decltype(*ptr)>::type>( \
BaseObject::FromJSObject(obj)); \
if (*ptr == nullptr) return __VA_ARGS__; \
} while (0)

// Implementation of a generic strong or weak pointer to a BaseObject.
Expand DownExpand Up@@ -198,7 +196,7 @@ class BaseObjectPtrImpl final {

private:
union {
BaseObject* target; // Used for strong pointers.
BaseObject* target; // Used for strong pointers.
BaseObject::PointerData* pointer_data; // Used for weak pointers.
} data_;

Expand Down