MCPcopy Create free account
hub / github.com/AGenUI/AGenUI / UnregisterFunction

Function UnregisterFunction

platforms/harmony/agenui/src/main/cpp/napi_function.cpp:118–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118napi_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
150napi_value RegisterComponent(napi_env env, napi_callback_info info) {
151 size_t argc = 2;

Callers

nothing calls this directly

Calls 5

napiGetStringFunction · 0.85
getAGenUIEngineFunction · 0.85
endMethod · 0.80
c_strMethod · 0.80
unregisterFunctionMethod · 0.45

Tested by

no test coverage detected