summaryrefslogtreecommitdiff
path: root/lib/Wayland/Protocols/RiverInputManagementV1/Header.lean
blob: 66e881fcbf7f2dc1a17bbe06c86f8d77feb7cb7d (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import Wayland.Display

namespace Wayland.Protocols

abbrev RiverInputManagerV1.name : InterfaceName := "river_input_manager_v1"
abbrev RiverInputDeviceV1.name : InterfaceName := "river_input_device_v1"

abbrev RiverInputManagerV1 : Type := Object RiverInputManagerV1.name
abbrev RiverInputDeviceV1 : Type := Object RiverInputDeviceV1.name

inductive RiverInputManagerV1.Error where
  | invalidDestroy

inductive RiverInputDeviceV1.Error where
  | invalidRepeatInfo
  | invalidScrollFactor
  | invalidMapToRectangle

inductive RiverInputDeviceV1.Type where
  | keyboard
  | pointer
  | touch
  | tablet

namespace RiverInputManagerV1.Error

instance : Marshallable RiverInputManagerV1.Error where
  marshal
    | .int,  .invalidDestroy => ArgumentMarshaller.marshalInt 0
    | .uint, .invalidDestroy => ArgumentMarshaller.marshalUInt 0
    | _, _ => throw "Marshalling unexpected type, expected int or uint."
  demarshal
    | .int => do
      match (← ArgumentDemarshaller.demarshalInt) with
        | 0 => pure .invalidDestroy
        | _ => throw "Invalid enum value."
    | .uint => do
      match (← ArgumentDemarshaller.demarshalUInt) with
        | 0 => pure .invalidDestroy
        | _ => throw "Invalid enum value."
    | _ => throw "Demarshalling unexpected type, expected int or uint."

end RiverInputManagerV1.Error

namespace RiverInputDeviceV1.Error

instance : Marshallable RiverInputDeviceV1.Error where
  marshal
    | .int,  .invalidRepeatInfo => ArgumentMarshaller.marshalInt 0
    | .uint, .invalidRepeatInfo => ArgumentMarshaller.marshalUInt 0
    | .int,  .invalidScrollFactor => ArgumentMarshaller.marshalInt 1
    | .uint, .invalidScrollFactor => ArgumentMarshaller.marshalUInt 1
    | .int,  .invalidMapToRectangle => ArgumentMarshaller.marshalInt 2
    | .uint, .invalidMapToRectangle => ArgumentMarshaller.marshalUInt 2
    | _, _ => throw "Marshalling unexpected type, expected int or uint."
  demarshal
    | .int => do
      match (← ArgumentDemarshaller.demarshalInt) with
        | 0 => pure .invalidRepeatInfo
        | 1 => pure .invalidScrollFactor
        | 2 => pure .invalidMapToRectangle
        | _ => throw "Invalid enum value."
    | .uint => do
      match (← ArgumentDemarshaller.demarshalUInt) with
        | 0 => pure .invalidRepeatInfo
        | 1 => pure .invalidScrollFactor
        | 2 => pure .invalidMapToRectangle
        | _ => throw "Invalid enum value."
    | _ => throw "Demarshalling unexpected type, expected int or uint."

end RiverInputDeviceV1.Error

namespace RiverInputDeviceV1.Type

instance : Marshallable RiverInputDeviceV1.Type where
  marshal
    | .int,  .keyboard => ArgumentMarshaller.marshalInt 0
    | .uint, .keyboard => ArgumentMarshaller.marshalUInt 0
    | .int,  .pointer => ArgumentMarshaller.marshalInt 1
    | .uint, .pointer => ArgumentMarshaller.marshalUInt 1
    | .int,  .touch => ArgumentMarshaller.marshalInt 2
    | .uint, .touch => ArgumentMarshaller.marshalUInt 2
    | .int,  .tablet => ArgumentMarshaller.marshalInt 3
    | .uint, .tablet => ArgumentMarshaller.marshalUInt 3
    | _, _ => throw "Marshalling unexpected type, expected int or uint."
  demarshal
    | .int => do
      match (← ArgumentDemarshaller.demarshalInt) with
        | 0 => pure .keyboard
        | 1 => pure .pointer
        | 2 => pure .touch
        | 3 => pure .tablet
        | _ => throw "Invalid enum value."
    | .uint => do
      match (← ArgumentDemarshaller.demarshalUInt) with
        | 0 => pure .keyboard
        | 1 => pure .pointer
        | 2 => pure .touch
        | 3 => pure .tablet
        | _ => throw "Invalid enum value."
    | _ => throw "Demarshalling unexpected type, expected int or uint."

end RiverInputDeviceV1.Type

end Wayland.Protocols