-
Notifications
You must be signed in to change notification settings - Fork 3
/
event.go
33 lines (27 loc) · 792 Bytes
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: Unlicense OR MIT
// Package event contains types for event handling.
package event
import (
"github.com/kanryu/mado/internal/ops"
"github.com/kanryu/mado/op"
)
// Tag is the stable identifier for an event handler.
// For a handler h, the tag is typically &h.
type Tag interface{}
// Event is the marker interface for events.
type Event interface {
ImplementsEvent()
}
// Filter represents a filter for [Event] types.
type Filter interface {
ImplementsFilter()
}
// Op declares a tag for input routing at the current transformation
// and clip area hierarchy. It panics if tag is nil.
func Op(o *op.Ops, tag Tag) {
if tag == nil {
panic("Tag must be non-nil")
}
data := ops.Write1(&o.Internal, ops.TypeInputLen, tag)
data[0] = byte(ops.TypeInput)
}