Lines Matching refs:ctxt

71     aCtx->ctxt = std::move(contextBase);
75 auto ctxt = aCtx->ctxt;
77 if (ctxt->callbackRef == nullptr) {
79 napi_create_promise(ctxt->env, &ctxt->deferred, &promise);
83 napi_get_undefined(ctxt->env, &promise);
87 napi_create_string_utf8(ctxt->env, name.c_str(), NAPI_AUTO_LENGTH, &resource);
89 napi_create_async_work(ctxt->env, nullptr, resource, onExecute, onComplete, reinterpret_cast<void *>(aCtx),
91 auto status = napi_queue_async_work(ctxt->env, aCtx->work);
100 void NapiQueue::GenerateOutput(ContextBase *ctxt)
104 LOG_DEBUG(UDMF_KITS_NAPI, "GenerateOutput ctxt->status = %{public}d", ctxt->status);
105 if (ctxt->status == napi_ok) {
106 napi_get_undefined(ctxt->env, &result[RESULT_ERROR]);
107 if (ctxt->output == nullptr) {
108 napi_get_undefined(ctxt->env, &ctxt->output);
110 result[RESULT_DATA] = ctxt->output;
114 if (ctxt->jsCode != 0 && ctxt->jsCode != -1) {
115 napi_create_string_utf8(ctxt->env, std::to_string(ctxt->jsCode).c_str(), NAPI_AUTO_LENGTH, &code);
117 if (ctxt->jsCode == -1) {
119 napi_create_string_utf8(ctxt->env, jsCode.c_str(), NAPI_AUTO_LENGTH, &code);
121 napi_create_string_utf8(ctxt->env, ctxt->error.c_str(), NAPI_AUTO_LENGTH, &message);
122 napi_create_error(ctxt->env, code, message, &result[RESULT_ERROR]);
123 napi_get_undefined(ctxt->env, &result[RESULT_DATA]);
125 if (ctxt->deferred != nullptr) {
127 if (ctxt->status == napi_ok) {
129 napi_resolve_deferred(ctxt->env, ctxt->deferred, result[RESULT_DATA]);
132 napi_reject_deferred(ctxt->env, ctxt->deferred, result[RESULT_ERROR]);
136 napi_get_reference_value(ctxt->env, ctxt->callbackRef, &callback);
140 napi_call_function(ctxt->env, nullptr, callback, RESULT_ALL, result, &callbackResult);
150 LOG_DEBUG(UDMF_KITS_NAPI, "napi_async_execute_callback ctxt->status = %{public}d", actxt->ctxt->status);
151 if (actxt->execute && actxt->ctxt->status == napi_ok) {
163 LOG_DEBUG(UDMF_KITS_NAPI, "napi_async_complete_callback status = %{public}d, ctxt->status = %{public}d", status,
164 actxt->ctxt->status);
165 if ((status != napi_ok) && (actxt->ctxt->status == napi_ok)) {
167 actxt->ctxt->status = status;
169 if ((actxt->complete) && (status == napi_ok) && (actxt->ctxt->status == napi_ok)) {
171 actxt->complete(actxt->ctxt->output);
173 GenerateOutput(actxt->ctxt.get());
175 napi_delete_reference(env, actxt->ctxt->callbackRef);