aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Olaechea <pirata@gmail.com>2020-03-30 00:52:23 -0500
committerJavier Olaechea <pirata@gmail.com>2020-03-30 00:52:38 -0500
commitf366e8f7ac46f7aa764f9eb82413dfabf040038a (patch)
treeda6e81e0c7f73435acf4a36be1e1ddf8678b397f
parent3d7439cb19b4c174fced778773b55a42b19c9dfb (diff)
downloadcl-xcb-f366e8f7ac46f7aa764f9eb82413dfabf040038a.tar.gz
Update documentation
Document what we need to do to compute the length of a slot.
-rw-r--r--HACKING8
-rw-r--r--src/xcb/mop.lisp13
2 files changed, 14 insertions, 7 deletions
diff --git a/HACKING b/HACKING
index 67acefd..6a71ad0 100644
--- a/HACKING
+++ b/HACKING
@@ -70,10 +70,10 @@ We can also define an alias for the type. e.j.
— RFC 1013
-+---------+--------------------------+---------------
-| op-code | request-size (in DWORDs) | data ...
-+---------+--------------------------+----------------
-| 1 byte | 2 bytes | at least 1 byte
++---------+----------+--------------------------+----
+| op-code | data byte| request-size (in DWORDs) | data ...
++---------+----------+--------------------------+-----
+| 1 byte | 1 byte | 2 bytes | at least 1 byte
== Conection
diff --git a/src/xcb/mop.lisp b/src/xcb/mop.lisp
index 2013c5c..a902db0 100644
--- a/src/xcb/mop.lisp
+++ b/src/xcb/mop.lisp
@@ -232,7 +232,14 @@
(item-count (slot-value object field-ref)))
(* type-size item-count )))
-;; First just list the types of the request
+;; Currently it just sums the type size of the slots. We need to
+;; account for the 32-bit header. If we are dealing with an extension
+;; request (opcodes from 128 to 255) the 'spare' byte will containing
+;; the minor opcode. Otherwise the first field is placed there if
+;; possible, that is the size of the first field is 8 bits. We also
+;; need to 'pad align' any variable length fields.
(defun compute-request-length (xcb-request)
- (loop :for slot :in (sb-mop:class-slots (class-of xcb-request))
- :sum (xcb-slot-size slot xcb-request)))
+ (ceiling
+ (loop :for slot :in (sb-mop:class-slots (class-of xcb-request))
+ :sum (xcb-slot-size slot xcb-request))
+ 4))