| 116 | } |
| 117 | |
| 118 | napi_value UnregisterFunction(napi_env env, napi_callback_info info) { |
| 119 | size_t argc = 1; |
| 120 | napi_value args[1]; |
| 121 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); |
| 122 | |
| 123 | if (argc < 1) { |
| 124 | HM_LOGE("UnregisterFunction: Expected 1 argument"); |
| 125 | NAPI_RETURN_UNDEFINED(env); |
| 126 | } |
| 127 | |
| 128 | std::string name = napiGetString(env, args[0]); |
| 129 | |
| 130 | auto* engine = agenui::getAGenUIEngine(); |
| 131 | if (!engine) { |
| 132 | HM_LOGE("UnregisterFunction: Engine not initialized"); |
| 133 | NAPI_RETURN_UNDEFINED(env); |
| 134 | } |
| 135 | |
| 136 | engine->unregisterFunction(name); |
| 137 | |
| 138 | { |
| 139 | std::lock_guard<std::mutex> lock(g_platformFunctionsMutex); |
| 140 | auto it = getPlatformFunctions().find(name); |
| 141 | if (it != getPlatformFunctions().end()) { |
| 142 | getPlatformFunctions().erase(it); |
| 143 | HM_LOGI("UnregisterFunction: destroyed HarmonyPlatformFunction for %s", name.c_str()); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | NAPI_RETURN_UNDEFINED(env); |
| 148 | } |
| 149 | |
| 150 | napi_value RegisterComponent(napi_env env, napi_callback_info info) { |
| 151 | size_t argc = 2; |
nothing calls this directly
no test coverage detected