lua: add wp_plugin_find binding
This commit is contained in:
@@ -85,6 +85,20 @@ static const luaL_Reg log_funcs[] = {
|
|||||||
{ NULL, NULL }
|
{ 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 */
|
/* WpObject */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -791,6 +805,9 @@ wp_lua_scripting_api_init (lua_State *L)
|
|||||||
luaL_newlib (L, log_funcs);
|
luaL_newlib (L, log_funcs);
|
||||||
lua_setglobal (L, "WpDebug");
|
lua_setglobal (L, "WpDebug");
|
||||||
|
|
||||||
|
lua_pushcfunction (L, plugin_find);
|
||||||
|
lua_setglobal (L, "WpPlugin_find");
|
||||||
|
|
||||||
wplua_register_type_methods (L, WP_TYPE_OBJECT,
|
wplua_register_type_methods (L, WP_TYPE_OBJECT,
|
||||||
NULL, object_methods);
|
NULL, object_methods);
|
||||||
wplua_register_type_methods (L, WP_TYPE_GLOBAL_PROXY,
|
wplua_register_type_methods (L, WP_TYPE_GLOBAL_PROXY,
|
||||||
|
@@ -110,6 +110,7 @@ SANDBOX_EXPORT = {
|
|||||||
Features = Features,
|
Features = Features,
|
||||||
Feature = Feature,
|
Feature = Feature,
|
||||||
Log = WpDebug,
|
Log = WpDebug,
|
||||||
|
Plugin = WpPlugin_find,
|
||||||
ObjectManager = WpObjectManager_new,
|
ObjectManager = WpObjectManager_new,
|
||||||
Interest = WpObjectInterest_new,
|
Interest = WpObjectInterest_new,
|
||||||
SessionItem = WpSessionItem_new,
|
SessionItem = WpSessionItem_new,
|
||||||
|
Reference in New Issue
Block a user