Lines Matching refs:env
24 napi_value HtmlNapi::Constructor(napi_env env)
38 return NapiDataUtils::DefineClass(env, "HTML", properties, count, HtmlNapi::New);
41 napi_value HtmlNapi::New(napi_env env, napi_callback_info info)
45 ctxt->GetCbInfoSync(env, info);
46 ASSERT_ERR(ctxt->env, ctxt->status == napi_ok, Status::E_ERROR, ctxt->error);
49 ASSERT_ERR(ctxt->env, html != nullptr, Status::E_ERROR, "no memory for html!");
51 ASSERT_CALL(env, napi_wrap(env, ctxt->self, html, Destructor, nullptr, nullptr), html);
55 void HtmlNapi::NewInstance(napi_env env, std::shared_ptr<UnifiedRecord> in, napi_value &out)
58 ASSERT_CALL_VOID(env, napi_new_instance(env, Constructor(env), 0, nullptr, &out));
60 ASSERT_ERR_VOID(env, html != nullptr, Status::E_ERROR, "no memory for html!");
62 ASSERT_CALL_DELETE(env, napi_wrap(env, out, html, Destructor, nullptr, nullptr), html);
65 void HtmlNapi::Destructor(napi_env env, void *data, void *hint)
73 HtmlNapi *HtmlNapi::GetHtml(napi_env env, napi_callback_info info, std::shared_ptr<ContextBase> ctxt)
76 ctxt->GetCbInfoSync(env, info);
77 ASSERT_ERR(ctxt->env, ctxt->status == napi_ok, Status::E_ERROR, ctxt->error);
81 napi_value HtmlNapi::GetPlainContent(napi_env env, napi_callback_info info)
85 auto html = GetHtml(env, info, ctxt);
87 ctxt->env, (html != nullptr && html->value_ != nullptr), Status::E_ERROR, "invalid object!");
88 ctxt->status = NapiDataUtils::SetValue(env, html->value_->GetPlainContent(), ctxt->output);
89 ASSERT_ERR(ctxt->env, ctxt->status == napi_ok, Status::E_ERROR, "set plain content failed!");
93 napi_value HtmlNapi::SetPlainContent(napi_env env, napi_callback_info info)
98 auto input = [env, ctxt, &plainContent](size_t argc, napi_value *argv) {
101 ctxt->status = NapiDataUtils::GetValue(env, argv[0], plainContent);
105 ctxt->GetCbInfoSync(env, info, input);
106 ASSERT_ERR(ctxt->env, ctxt->status == napi_ok, Status::E_ERROR, ctxt->error);
109 ctxt->env, (html != nullptr && html->value_ != nullptr), Status::E_ERROR, "invalid object!");
114 napi_value HtmlNapi::GetHtmlContent(napi_env env, napi_callback_info info)
118 auto html = GetHtml(env, info, ctxt);
120 ctxt->env, (html != nullptr && html->value_ != nullptr), Status::E_ERROR, "invalid object!");
121 ctxt->status = NapiDataUtils::SetValue(env, html->value_->GetHtmlContent(), ctxt->output);
122 ASSERT_ERR(ctxt->env, ctxt->status == napi_ok, Status::E_ERROR, "set html failed!");
126 napi_value HtmlNapi::SetHtmlContent(napi_env env, napi_callback_info info)
131 auto input = [env, ctxt, &htmlContent](size_t argc, napi_value *argv) {
134 ctxt->status = NapiDataUtils::GetValue(env, argv[0], htmlContent);
138 ctxt->GetCbInfoSync(env, info, input);
139 ASSERT_ERR(ctxt->env, ctxt->status == napi_ok, Status::E_ERROR, ctxt->error);
142 ctxt->env, (html != nullptr && html->value_ != nullptr), Status::E_ERROR, "invalid object!");