MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / installScriptApi

Method installScriptApi

app/src/DataModel/NotificationCenter.cpp:573–606  ·  view source on GitHub ↗

* @brief Installs notify* globals + Info/Warning/Critical constants into a Lua state. */

Source from the content-addressed store, hash-verified

571 * @brief Installs notify* globals + Info/Warning/Critical constants into a Lua state.
572 */
573void DataModel::NotificationCenter::installScriptApi(lua_State* L)
574{
575 Q_ASSERT(L);
576
577 lua_pushinteger(L, 0);
578 lua_setglobal(L, "Info");
579 lua_pushinteger(L, 1);
580 lua_setglobal(L, "Warning");
581 lua_pushinteger(L, 2);
582 lua_setglobal(L, "Critical");
583
584 const bool proActive = isProTierActive();
585
586 lua_CFunction fnNotify = proActive ? luaNotify : luaNotifyStub;
587 lua_CFunction fnInfo = proActive ? luaNotifyInfo : luaNotifyStub;
588 lua_CFunction fnWarning = proActive ? luaNotifyWarning : luaNotifyStub;
589 lua_CFunction fnCritical = proActive ? luaNotifyCritical : luaNotifyStub;
590 lua_CFunction fnClear = proActive ? luaNotifyClear : luaNotifyStub;
591
592 lua_pushcfunction(L, fnNotify);
593 lua_setglobal(L, "notify");
594
595 lua_pushcfunction(L, fnInfo);
596 lua_setglobal(L, "notifyInfo");
597
598 lua_pushcfunction(L, fnWarning);
599 lua_setglobal(L, "notifyWarning");
600
601 lua_pushcfunction(L, fnCritical);
602 lua_setglobal(L, "notifyCritical");
603
604 lua_pushcfunction(L, fnClear);
605 lua_setglobal(L, "notifyClear");
606}
607
608/**
609 * @brief Installs the __nc bridge (Pro only); the SDK prelude exposes notify* globals.

Callers

nothing calls this directly

Calls 3

lua_pushintegerFunction · 0.85
lua_setglobalFunction · 0.85
isProTierActiveFunction · 0.85

Tested by

no test coverage detected