event-hook: rewrite the hook priorities enum
Hooks need to have a priority relative to the event they are executed on, so it does not make much sense to have all kinds of different priorities based also on the event type and/or the module where they are defined. Also, it wouldn't be acceptable to have such an enumeration on the public API.
This commit is contained in:

committed by
Julian Bouzas

parent
e2b9cb0b5e
commit
24db3fe24a
@@ -1875,11 +1875,8 @@ simple_event_hook_new (lua_State *L)
|
||||
priority_type = lua_gettable (L, 1);
|
||||
if (priority_type == LUA_TNUMBER)
|
||||
priority = lua_tointeger (L, -1);
|
||||
else if (priority_type == LUA_TSTRING)
|
||||
priority = wplua_lua_to_enum (L, -1,
|
||||
WP_TYPE_EVENT_HOOK_DEFAULT_PRIORITY_TYPE);
|
||||
else
|
||||
luaL_error (L, "SimpleEventHook: expected 'priority' as number or string");
|
||||
luaL_error (L, "SimpleEventHook: expected 'priority' as number");
|
||||
lua_pop (L, 1);
|
||||
|
||||
lua_pushliteral (L, "type");
|
||||
@@ -2061,11 +2058,8 @@ async_event_hook_new (lua_State *L)
|
||||
priority_type = lua_gettable(L, 1);
|
||||
if (priority_type == LUA_TNUMBER)
|
||||
priority = lua_tointeger (L, -1);
|
||||
else if (priority_type == LUA_TSTRING)
|
||||
priority = wplua_lua_to_enum(L, -1,
|
||||
WP_TYPE_EVENT_HOOK_DEFAULT_PRIORITY_TYPE);
|
||||
else
|
||||
luaL_error(L, "AsyncEventHook: expected 'priority' as number or string");
|
||||
luaL_error(L, "AsyncEventHook: expected 'priority' as number");
|
||||
lua_pop (L, 1);
|
||||
|
||||
lua_pushliteral (L, "type");
|
||||
|
@@ -191,11 +191,24 @@ local Feature = {
|
||||
},
|
||||
}
|
||||
|
||||
local HookPriority = {
|
||||
LOWEST = -500,
|
||||
ULTRA_LOW = -300,
|
||||
VERY_LOW = -200,
|
||||
LOW = -100,
|
||||
NORMAL = 0,
|
||||
HIGH = 100,
|
||||
VERY_HIGH = 200,
|
||||
ULTRA_HIGH = 300,
|
||||
HIGHEST = 500,
|
||||
}
|
||||
|
||||
SANDBOX_EXPORT = {
|
||||
Debug = Debug,
|
||||
Id = Id,
|
||||
Features = Features,
|
||||
Feature = Feature,
|
||||
HookPriority = HookPriority,
|
||||
GLib = GLib,
|
||||
I18n = I18n,
|
||||
Log = WpLog,
|
||||
|
Reference in New Issue
Block a user