MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / CreateTestObject

Function CreateTestObject

test/thunking_manual.cc:81–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79};
80
81static Napi::Value CreateTestObject(const Napi::CallbackInfo& info) {
82 Napi::Env env = info.Env();
83 Napi::Object item = Napi::Object::New(env);
84
85 // Make sure to check that the deleter gets called.
86 item["testMethod"] = Napi::Function::New(env, TestMethod, "testMethod");
87
88 item.DefineProperties({
89 // Make sure to check that the deleter gets called.
90 Napi::PropertyDescriptor::Accessor(env, item, "accessor_1", TestGetter),
91 // Make sure to check that the deleter gets called.
92 Napi::PropertyDescriptor::Accessor(
93 env, item, std::string("accessor_1_std_string"), TestGetter),
94 // Make sure to check that the deleter gets called.
95 Napi::PropertyDescriptor::Accessor(
96 env,
97 item,
98 Napi::String::New(info.Env(), "accessor_1_js_string"),
99 TestGetter),
100 // Make sure to check that the deleter gets called.
101 Napi::PropertyDescriptor::Accessor(
102 env, item, "accessor_2", TestGetter, TestSetter),
103 // Make sure to check that the deleter gets called.
104 Napi::PropertyDescriptor::Accessor(env,
105 item,
106 std::string("accessor_2_std_string"),
107 TestGetter,
108 TestSetter),
109 // Make sure to check that the deleter gets called.
110 Napi::PropertyDescriptor::Accessor(
111 env,
112 item,
113 Napi::String::New(env, "accessor_2_js_string"),
114 TestGetter,
115 TestSetter),
116 Napi::PropertyDescriptor::Value("TestClass", TestClass::NewClass(env)),
117 });
118
119 return item;
120}
121
122Napi::Object InitThunkingManual(Napi::Env env) {
123 Napi::Object exports = Napi::Object::New(env);

Callers

nothing calls this directly

Calls 3

EnvMethod · 0.80
DefinePropertiesMethod · 0.80
ValueClass · 0.50

Tested by

no test coverage detected