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

Function SetObject

test/object_reference.cc:177–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177void SetObject(const Napi::CallbackInfo& info) {
178 Env env = info.Env();
179 HandleScope scope(env);
180
181 weak = Weak(Object::New(env));
182 weak.SuppressDestruct();
183
184 persistent = Persistent(Object::New(env));
185 persistent.SuppressDestruct();
186
187 reference = Reference<Object>::New(Object::New(env), 2);
188 reference.SuppressDestruct();
189
190 Napi::Object configObject = info[0].As<Napi::Object>();
191
192 int keyType =
193 MaybeUnwrap(configObject.Get("keyType")).As<Napi::Number>().Uint32Value();
194 int valType =
195 MaybeUnwrap(configObject.Get("valType")).As<Napi::Number>().Uint32Value();
196 Napi::Value key = MaybeUnwrap(configObject.Get("key"));
197 Napi::Value val = MaybeUnwrap(configObject.Get("val"));
198
199 switch (keyType) {
200 case CPP_STR:
201 SetObjectWithCppStringKey(weak, key, val, valType);
202 SetObjectWithCppStringKey(persistent, key, val, valType);
203 SetObjectWithCppStringKey(reference, key, val, valType);
204 break;
205
206 case C_STR:
207 SetObjectWithCStringKey(weak, key, val, valType);
208 SetObjectWithCStringKey(persistent, key, val, valType);
209 SetObjectWithCStringKey(reference, key, val, valType);
210 break;
211
212 case INT:
213 SetObjectWithIntKey(weak, key, val, valType);
214 SetObjectWithIntKey(persistent, key, val, valType);
215 SetObjectWithIntKey(reference, key, val, valType);
216
217 default:
218 break;
219 }
220}
221
222void SetCastedObjects(const CallbackInfo& info) {
223 Env env = info.Env();

Callers

nothing calls this directly

Calls 9

WeakFunction · 0.85
PersistentFunction · 0.85
MaybeUnwrapFunction · 0.85
SetObjectWithCStringKeyFunction · 0.85
SetObjectWithIntKeyFunction · 0.85
EnvMethod · 0.80
SuppressDestructMethod · 0.80
GetMethod · 0.80

Tested by

no test coverage detected