wplua: split the functionality of the load functions into smaller functions

The load functions used to do 3 things:
- push the sandbox function on the stack
- load the file and push it as a function on the stack
- call the sandbox (or the file)

Now there are separate functions to do these 3:
- wplua_push_sandbox
- wplua_load_*
- wplua_pcall
This commit is contained in:
George Kiagiadakis
2022-03-30 18:22:21 +03:00
parent a2472542a9
commit e1d0240bc9
6 changed files with 98 additions and 62 deletions

View File

@@ -1427,7 +1427,8 @@ wp_lua_scripting_api_init (lua_State *L)
wplua_register_type_methods (L, WP_TYPE_IMPL_MODULE,
impl_module_new, NULL);
wplua_load_uri (L, URI_API, 0, 0, &error);
if (G_UNLIKELY (error))
if (!wplua_load_uri (L, URI_API, &error) ||
!wplua_pcall (L, 0, 0, &error)) {
wp_critical ("Failed to load api: %s", error->message);
}
}