lua: add wp_plugin_find binding

This commit is contained in:
George Kiagiadakis
2021-01-26 16:36:31 +02:00
parent c78373b1fc
commit 13a56a7472
2 changed files with 18 additions and 0 deletions

View File

@@ -85,6 +85,20 @@ static const luaL_Reg log_funcs[] = {
{ NULL, NULL }
};
/* WpPlugin */
static int
plugin_find (lua_State *L)
{
const char *name = luaL_checkstring (L, 1);
WpPlugin *plugin = wp_plugin_find (get_wp_core (L), name);
if (plugin)
wplua_pushobject (L, plugin);
else
lua_pushnil (L);
return 1;
}
/* WpObject */
static void
@@ -791,6 +805,9 @@ wp_lua_scripting_api_init (lua_State *L)
luaL_newlib (L, log_funcs);
lua_setglobal (L, "WpDebug");
lua_pushcfunction (L, plugin_find);
lua_setglobal (L, "WpPlugin_find");
wplua_register_type_methods (L, WP_TYPE_OBJECT,
NULL, object_methods);
wplua_register_type_methods (L, WP_TYPE_GLOBAL_PROXY,

View File

@@ -110,6 +110,7 @@ SANDBOX_EXPORT = {
Features = Features,
Feature = Feature,
Log = WpDebug,
Plugin = WpPlugin_find,
ObjectManager = WpObjectManager_new,
Interest = WpObjectInterest_new,
SessionItem = WpSessionItem_new,