lua: add EventInterest convenience constructor for declaring interest on events

This commit is contained in:
George Kiagiadakis 2022-03-25 16:37:44 +02:00 committed by Julian Bouzas
parent 2cffd9177a
commit d72f31e803
2 changed files with 7 additions and 2 deletions

View file

@ -70,6 +70,11 @@ local function Constraint (spec)
return debug.setmetatable(spec, { __name = "Constraint" })
end
local function EventInterest(spec)
spec.type = "event"
return WpObjectInterest_new(spec)
end
local function dump_table(t, indent)
local indent_str = ""
indent = indent or 1
@ -201,6 +206,7 @@ SANDBOX_EXPORT = {
Interest = WpObjectInterest_new,
SessionItem = WpSessionItem_new,
Constraint = Constraint,
EventInterest = EventInterest,
Device = WpDevice_new,
SpaDevice = WpSpaDevice_new,
Node = WpNode_new,

View file

@ -22,8 +22,7 @@ local function check_results()
end
local common_interests = {
Interest {
type = "event",
EventInterest {
Constraint { "event.type", "=", "test-event" },
},
}