Add unwrap

This commit is contained in:
Luis Blanco 2019-09-08 00:05:19 +03:00
parent fcabcff8cc
commit 572d89b067
1 changed files with 12 additions and 0 deletions

View File

@ -510,6 +510,7 @@ typedef void (*Es5SetterCallback)(const Napi::CallbackInfo& info);
#define DECLARE_ES5_CLASS(CLASS, NAME) \ #define DECLARE_ES5_CLASS(CLASS, NAME) \
private: \
static Napi::FunctionReference _ctorEs5; \ static Napi::FunctionReference _ctorEs5; \
static const char *_nameEs5; \ static const char *_nameEs5; \
static void CLASS::_finalizeEs5(napi_env e, void *dest, void* hint); \ static void CLASS::_finalizeEs5(napi_env e, void *dest, void* hint); \
@ -589,8 +590,19 @@ typedef void (*Es5SetterCallback)(const Napi::CallbackInfo& info);
setter \ setter \
) \ ) \
); \ ); \
}; \
public: \
inline static CLASS *unwrap(Napi::Object thatObj) { \
CLASS *that; \
napi_unwrap( \
thatObj.Env(), \
thatObj.Get(_nameEs5), \
reinterpret_cast<void**>(&that) \
); \
return that; \
}; };
#define JS_GET_THAT(CLASS) \ #define JS_GET_THAT(CLASS) \
CLASS *that; \ CLASS *that; \
Napi::Object thatObj = info.This().As<Napi::Object>(); \ Napi::Object thatObj = info.This().As<Napi::Object>(); \