summaryrefslogtreecommitdiff
path: root/lib/Wayland/Protocols/RiverXkbConfigV1/Header.lean
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Wayland/Protocols/RiverXkbConfigV1/Header.lean')
-rw-r--r--lib/Wayland/Protocols/RiverXkbConfigV1/Header.lean92
1 files changed, 92 insertions, 0 deletions
diff --git a/lib/Wayland/Protocols/RiverXkbConfigV1/Header.lean b/lib/Wayland/Protocols/RiverXkbConfigV1/Header.lean
new file mode 100644
index 0000000..b63f35f
--- /dev/null
+++ b/lib/Wayland/Protocols/RiverXkbConfigV1/Header.lean
@@ -0,0 +1,92 @@
+import Wayland.Display
+
+namespace Wayland.Protocols
+
+abbrev RiverXkbConfigV1.name : InterfaceName := "river_xkb_config_v1"
+abbrev RiverXkbKeymapV1.name : InterfaceName := "river_xkb_keymap_v1"
+abbrev RiverXkbKeyboardV1.name : InterfaceName := "river_xkb_keyboard_v1"
+
+abbrev RiverXkbConfigV1 : Type := Object RiverXkbConfigV1.name
+abbrev RiverXkbKeymapV1 : Type := Object RiverXkbKeymapV1.name
+abbrev RiverXkbKeyboardV1 : Type := Object RiverXkbKeyboardV1.name
+
+inductive RiverXkbConfigV1.Error where
+ | invalidDestroy
+ | invalidFormat
+
+inductive RiverXkbConfigV1.KeymapFormat where
+ | textV1
+ | textV2
+
+inductive RiverXkbKeyboardV1.Error where
+ | invalidKeymap
+
+namespace RiverXkbConfigV1.Error
+
+instance : Marshallable RiverXkbConfigV1.Error where
+ marshal
+ | .int, .invalidDestroy => ArgumentMarshaller.marshalInt 0
+ | .uint, .invalidDestroy => ArgumentMarshaller.marshalUInt 0
+ | .int, .invalidFormat => ArgumentMarshaller.marshalInt 1
+ | .uint, .invalidFormat => ArgumentMarshaller.marshalUInt 1
+ | _, _ => throw "Marshalling unexpected type, expected int or uint."
+ demarshal
+ | .int => do
+ match (← ArgumentDemarshaller.demarshalInt) with
+ | 0 => pure .invalidDestroy
+ | 1 => pure .invalidFormat
+ | _ => throw "Invalid enum value."
+ | .uint => do
+ match (← ArgumentDemarshaller.demarshalUInt) with
+ | 0 => pure .invalidDestroy
+ | 1 => pure .invalidFormat
+ | _ => throw "Invalid enum value."
+ | _ => throw "Demarshalling unexpected type, expected int or uint."
+
+end RiverXkbConfigV1.Error
+
+namespace RiverXkbConfigV1.KeymapFormat
+
+instance : Marshallable RiverXkbConfigV1.KeymapFormat where
+ marshal
+ | .int, .textV1 => ArgumentMarshaller.marshalInt 1
+ | .uint, .textV1 => ArgumentMarshaller.marshalUInt 1
+ | .int, .textV2 => ArgumentMarshaller.marshalInt 2
+ | .uint, .textV2 => ArgumentMarshaller.marshalUInt 2
+ | _, _ => throw "Marshalling unexpected type, expected int or uint."
+ demarshal
+ | .int => do
+ match (← ArgumentDemarshaller.demarshalInt) with
+ | 1 => pure .textV1
+ | 2 => pure .textV2
+ | _ => throw "Invalid enum value."
+ | .uint => do
+ match (← ArgumentDemarshaller.demarshalUInt) with
+ | 1 => pure .textV1
+ | 2 => pure .textV2
+ | _ => throw "Invalid enum value."
+ | _ => throw "Demarshalling unexpected type, expected int or uint."
+
+end RiverXkbConfigV1.KeymapFormat
+
+namespace RiverXkbKeyboardV1.Error
+
+instance : Marshallable RiverXkbKeyboardV1.Error where
+ marshal
+ | .int, .invalidKeymap => ArgumentMarshaller.marshalInt 0
+ | .uint, .invalidKeymap => ArgumentMarshaller.marshalUInt 0
+ | _, _ => throw "Marshalling unexpected type, expected int or uint."
+ demarshal
+ | .int => do
+ match (← ArgumentDemarshaller.demarshalInt) with
+ | 0 => pure .invalidKeymap
+ | _ => throw "Invalid enum value."
+ | .uint => do
+ match (← ArgumentDemarshaller.demarshalUInt) with
+ | 0 => pure .invalidKeymap
+ | _ => throw "Invalid enum value."
+ | _ => throw "Demarshalling unexpected type, expected int or uint."
+
+end RiverXkbKeyboardV1.Error
+
+end Wayland.Protocols \ No newline at end of file