Lines Matching defs:ctx
90 static void InitCallbackContext(napi_env env, const ApiCallInfo &in, ApiReplyInfo &out, EventCallbackContext &ctx)
120 ctx.env = env;
121 ctx.observerId = observerId;
122 ctx.callbackId = callbackId;
123 ctx.observerRef = findObserver->second;
124 ctx.callbackRef = findCallback->second;
125 ctx.elmentInfo = move(elementInfo);
126 ctx.releaseObserver = in.paramList_.at(INDEX_TWO).get<bool>();
127 ctx.releaseCallback = in.paramList_.at(INDEX_THREE).get<bool>();
145 auto ctx = reinterpret_cast<EventCallbackContext *>(work->data);
149 napi_get_global(ctx->env, &global);
150 napi_get_named_property(ctx->env, global, "JSON", &jsonProp);
151 napi_get_named_property(ctx->env, jsonProp, "parse", &parseFunc);
153 napi_create_string_utf8(ctx->env, ctx->elmentInfo.dump().c_str(), NAPI_AUTO_LENGTH, argv);
154 napi_call_function(ctx->env, jsonProp, parseFunc, 1, argv, argv);
156 napi_get_reference_value(ctx->env, ctx->callbackRef, &jsCallback);
157 napi_call_function(ctx->env, nullptr, jsCallback, 1, argv, argv);
160 napi_is_exception_pending(ctx->env, &hasError);
164 if (ctx->releaseObserver) {
165 LOG_D("Unref jsObserver: %{public}s", ctx->observerId.c_str());
166 napi_delete_reference(ctx->env, ctx->observerRef);
167 g_jsRefs.erase(ctx->observerId);
169 if (ctx->releaseCallback) {
170 LOG_D("Unref jsCallback: %{public}s", ctx->callbackId.c_str());
171 napi_delete_reference(ctx->env, ctx->callbackRef);
172 g_jsRefs.erase(ctx->callbackId);
175 delete ctx;