1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include "napi.h"
#include "test_helper.h"
using namespace Napi;
Value GetPropertyWithNapiValue(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
Name key = info[1].As<Name>();
return MaybeUnwrapOr(obj.Get(static_cast<napi_value>(key)), Value());
}
Value GetPropertyWithNapiWrapperValue(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
Name key = info[1].As<Name>();
return MaybeUnwrapOr(obj.Get(key), Value());
}
Value GetPropertyWithUint32(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
Number key = info[1].As<Number>();
return MaybeUnwrap(obj.Get(key.Uint32Value()));
}
Value GetPropertyWithCStyleString(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
String jsKey = info[1].As<String>();
return MaybeUnwrapOr(obj.Get(jsKey.Utf8Value().c_str()), Value());
}
Value GetPropertyWithCppStyleString(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
String jsKey = info[1].As<String>();
return MaybeUnwrapOr(obj.Get(jsKey.Utf8Value()), Value());
}
|