summaryrefslogtreecommitdiff
path: root/tools/Scanner/Protocol.lean
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2026-04-03 21:40:46 +0200
committerHannes Schulze <haschu0103@outlook.de>2026-04-03 21:40:46 +0200
commit09be9fb2701f0560aeb714f89fe0d1e750915ae0 (patch)
tree3d05703751e8cd4308cd1a02876ee4baf1cb61f9 /tools/Scanner/Protocol.lean
parent54d62ad2f3eb72d57683780b55dad2a97b1e2dcb (diff)
parse wayland protocols
Diffstat (limited to 'tools/Scanner/Protocol.lean')
-rw-r--r--tools/Scanner/Protocol.lean79
1 files changed, 79 insertions, 0 deletions
diff --git a/tools/Scanner/Protocol.lean b/tools/Scanner/Protocol.lean
new file mode 100644
index 0000000..6c9a838
--- /dev/null
+++ b/tools/Scanner/Protocol.lean
@@ -0,0 +1,79 @@
+namespace WaylandScanner
+
+structure Description where
+ summary : Option String
+ body : Option String
+ deriving Repr
+
+def Description.ofSummary (s : String) : Description :=
+ { summary := s
+ body := .none }
+
+structure EnumEntryDesc where
+ name : String
+ value : Int
+ description : Option Description
+ since : Nat
+ deprecatedSince : Option Nat
+ deriving Repr
+
+structure EnumDesc where
+ name : String
+ description : Option Description
+ since : Nat
+ bitfield : Bool
+ entries: Array EnumEntryDesc
+ deriving Repr
+
+inductive ArgumentType where
+| int
+| uInt
+| fixed
+| string
+| array
+| fd
+| newID
+| object
+deriving Repr
+
+structure ArgumentDesc where
+ name : String
+ type : ArgumentType
+ description : Option Description
+ interface : Option String
+ enum : Option String
+ allowNull : Bool
+ deriving Repr
+
+inductive MessageType where
+| normal
+| destructor
+deriving Repr
+
+structure MessageDesc where
+ name : String
+ opcode : Nat
+ description : Option Description
+ type : MessageType
+ since : Nat
+ deprecatedSince : Option Nat
+ arguments : Array ArgumentDesc
+ deriving Repr
+
+structure InterfaceDesc where
+ name : String
+ version : Nat
+ description : Option Description
+ enums : Array EnumDesc
+ requests : Array MessageDesc
+ events : Array MessageDesc
+ deriving Repr
+
+structure ProtocolDesc where
+ name : String
+ copyright : Option String
+ description : Option Description
+ interfaces : Array InterfaceDesc
+ deriving Repr
+
+end WaylandScanner