[elpa] externals/xelb updated (8197598 -> b75641b)
ch11ng pushed a change to branch externals/xelb. from 8197598 Fix XGE and XKB events support new 878c611 Fix sequence number wrapping issues new b75641b Split connection filter Summary of changes: xcb.el | 183 ++-- 1 file changed, 97 insertions(+), 86 deletions(-)
[elpa] externals/xelb 878c611 1/2: Fix sequence number wrapping issues
branch: externals/xelb commit 878c6110fb6c5b75aa806794d8a0188aaf697344 Author: Chris Feng Commit: Chris Feng Fix sequence number wrapping issues * xcb.el (xcb:connection-timeout): Reduce timeout to 3. (xcb:connection): Merge slots 'error-sequence' and 'reply-sequence' into 'last-seen-sequence'. (xcb:-sequence-cmp16): Removed. * xcb.el (xcb:-SEQUENCE-SEGMENT-MASK): New constant representing the segment mask of a sequence number. (xcb:-convert-sequence): New method for converting 16-bit sequence number received from the server into that used in the client. (xcb:-connection-filter): Use this method. (xcb:-+request, xcb:-+request-checked, xcb:-+request-unchecked) (xcb:-+reply, xcb:-request-check, xcb:aux:sync): Avoid using 16-bit sequence number. (xcb:-cache-request): Force wrapping sequence numbers. (xcb:-+reqply, xcb:-request-check, xcb:aux:sync): Check sequence number wrapping. * xcb.el (xcb:aux:sync): Discard any reply or error. --- xcb.el | 104 +--- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/xcb.el b/xcb.el index a0c601a..b4e3474 100644 --- a/xcb.el +++ b/xcb.el @@ -67,7 +67,7 @@ (when xcb:debug-on `(message (concat "[XELB LOG] " ,format-string) ,@args))) -(defvar xcb:connection-timeout 10 "Connection timeout.") +(defvar xcb:connection-timeout 3 "Connection timeout.") X connection related @@ -91,24 +91,11 @@ (extension-first-error-alist :initform nil) (extension-first-event-alist :initform nil) (request-sequence :initform 0) - (error-sequence :initform 0) - (reply-sequence :initform 0) + (last-seen-sequence :initform 0) (xid :initform 0);last used X resource ID (extra-plist :initform nil)) ;for storing extra data (e.g. by extensions) :documentation "X connection.") -(defsubst xcb:-sequence-cmp16 (sequence1 sequence2) - "Compare 16-bit sequence numbers SEQUENCE1 and SEQUENCE2. - -Return a positive value if SEQUENCE1 is larger than SEQUENCE2, 0 if they are -equal. Otherwise a negative value would be returned." - (if (= sequence1 sequence2) - 0 -(let ((diff (- sequence1 sequence2))) - (if (< #x7FFF (abs diff)) - (- diff) ;overflowed -diff - (defclass xcb:auth-info () ((name :initarg :name :initform "" :type string) (data :initarg :data :initform "" :type string)) @@ -234,6 +221,26 @@ equal. Otherwise a negative value would be returned." (while (not (slot-value obj 'setup-data)) (accept-process-output process 1 nil 1) +(defconst xcb:-SEQUENCE-SEGMENT-MASK (lognot #x)) + +(cl-defmethod xcb:-convert-sequence ((obj xcb:connection) sequence16) + "Convert 16-bit sequence number SEQUENCE16 (read from a packet). + +The result would be 29 or 61 bits, depending on the machine." + (with-slots (request-sequence last-seen-sequence) obj +;; Assume there are no more than #x requests sent since the +;; request corresponding to this packet was made. Because errors +;; and replies are always read out in the process filter, this +;; assumption is quite safe. +(let ((sequence (logior (logand request-sequence +xcb:-SEQUENCE-SEGMENT-MASK) +sequence16))) + ;; `xcb:-cache-request' ensures sequence number never wraps. + (when (> sequence request-sequence) +(cl-decf sequence #x1)) + (setf last-seen-sequence sequence) + sequence))) + (defun xcb:-connection-filter (process message) "Filter function for an X connection. @@ -290,6 +297,7 @@ Concurrency is disabled as it breaks the orders of errors, replies and events." cache 2)) (plist (slot-value connection 'error-plist)) struct) + (setq sequence (xcb:-convert-sequence connection sequence)) (when (plist-member plist sequence) (setq struct (plist-get plist sequence)) (setf (slot-value connection 'error-plist) @@ -297,8 +305,7 @@ Concurrency is disabled as it breaks the orders of errors, replies and events." (push `(,(aref cache 1) . ,(substring cache 0 32)) struct - (setq cache (substring cache 32)) - (setf (slot-value connection 'error-sequence) sequence))) + (setq cache (substring cache 32 (1 ;reply (let* ((reply-words (funcall (if xcb:lsb #'xcb:-unpack-u4-lsb #'xcb:-unpack-u4) @@ -310,7 +317,8 @@ Concurrency is disabled as it breaks the orders of errors, replies and events." (xcb:-log "Reply received: %s" (substring
[elpa] externals/xelb b75641b 2/2: Split connection filter
branch: externals/xelb commit b75641bf62f9a92208c23f855cba66c676b4c04f Author: Chris Feng Commit: Chris Feng Split connection filter * xcb.el (xcb:-connection-filter, xcb:-connection-setup-filter): Split out connection setup code from the former into the latter. (xcb:-connect): Set process filter to `xcb:-connection-setup-filter'. --- xcb.el | 79 +++- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/xcb.el b/xcb.el index b4e3474..5a75714 100644 --- a/xcb.el +++ b/xcb.el @@ -200,7 +200,7 @@ (set-process-plist process (plist-put (process-plist process) 'connection obj)) (set-process-coding-system process 'binary 'binary) -(set-process-filter process 'xcb:-connection-filter) +(set-process-filter process #'xcb:-connection-setup-filter) (process-send-string;send setup packet process (apply #'unibyte-string @@ -223,6 +223,47 @@ (defconst xcb:-SEQUENCE-SEGMENT-MASK (lognot #x)) +(defun xcb:-connection-setup-filter (process message) + "Process filter used during connection setup." + (let* ((connection (plist-get (process-plist process) 'connection)) + (cache (vconcat (slot-value connection 'message-cache) message))) +(setf (slot-value connection 'message-cache) cache) +(unless (or (slot-value connection 'lock) +;; Shorter than the setup header. +(> 8 (length cache))) + (setf (slot-value connection 'lock) t) + (let ((data-len (+ 8 (* 4 (if xcb:lsb +(xcb:-unpack-u2-lsb cache 6) + (xcb:-unpack-u2 cache 6) +obj) +(when (>= (length cache) data-len) + (xcb:-log "Setup response: %s" cache) + (pcase (aref cache 0) +(0 + ;; Connection failed. + (setq obj (make-instance 'xcb:SetupFailed)) + (xcb:unmarshal obj cache) + (setq cache (substring cache data-len)) + (error "[XELB] Connection failed: %s" (slot-value obj 'reason))) +(1 + ;; Connection established. + (setf (slot-value connection 'message-cache) []) + (set-process-filter process #'xcb:-connection-filter) + (setq obj (make-instance 'xcb:Setup)) + (xcb:unmarshal obj cache) + (setq cache (substring cache data-len)) + (setf (slot-value connection 'setup-data) obj) + (setf (slot-value connection 'connected) t)) +(2 + ;; Authentication required. + (setq obj (make-instance 'xcb:SetupAuthenticate)) + (xcb:unmarshal obj cache) + (setq cache (substring cache data-len)) + (error "[XELB] Authentication not supported: %s" +(slot-value obj 'reason))) +(x (error "Unrecognized setup status: %d" x) + (setf (slot-value connection 'lock) nil + (cl-defmethod xcb:-convert-sequence ((obj xcb:connection) sequence16) "Convert 16-bit sequence number SEQUENCE16 (read from a packet). @@ -249,43 +290,9 @@ Concurrency is disabled as it breaks the orders of errors, replies and events." (cache (vconcat (slot-value connection 'message-cache) message)) (cache-length (length cache))) (setf (slot-value connection 'message-cache) cache) -(catch 'return - ;; Queue message when locked - (when (slot-value connection 'lock) -(throw 'return 'lock)) +(unless (slot-value connection 'lock) ;; Start parsing message (setf (slot-value connection 'lock) t) - ;; Connection setup - (unless (slot-value connection 'connected) -(when (<= 8 (length cache)) ;at least setup header is available - (let ((data-len (+ 8 (* 4 (funcall (if xcb:lsb #'xcb:-unpack-u2-lsb - #'xcb:-unpack-u2) - cache 6 -obj) -(when (>= (length cache) data-len) - (xcb:-log "Setup response: %s" cache) - (pcase (aref cache 0) -(0 ;failed - (setq obj (make-instance 'xcb:SetupFailed)) - (xcb:unmarshal obj cache) - (setq cache (substring cache data-len)) - (error "[XELB] Connection failed: %s" -(slot-value obj 'reason))) -(1 ;success - (setq obj (make-instance 'xcb:Setup)) - (xcb:unmarshal obj cache) - (setq cache (substring cache data-len)) - (setf (slot-value connection 'setup-data) obj) - (setf (slot-value connection 'connected) t)) -(2 ;authentication - (setq obj (make-instance
[elpa] master b24a4b1: [poker] Version 0.2, update copyright years and add todo
branch: master commit b24a4b18b8ca1bf225be7b8db16ff61028e633b1 Author: Mario Lang Commit: Mario Lang [poker] Version 0.2, update copyright years and add todo --- packages/poker/poker.el | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/poker/poker.el b/packages/poker/poker.el index a630baf..fbfa78c 100644 --- a/packages/poker/poker.el +++ b/packages/poker/poker.el @@ -1,10 +1,10 @@ ;;; poker.el --- Texas hold 'em poker -;; Copyright (C) 2014 Free Software Foundation, Inc. +;; Copyright (C) 2014, 2016 Free Software Foundation, Inc. ;; Author: Mario Lang ;; Maintainer: Mario Lang -;; Version: 0.1 +;; Version: 0.2 ;; Keywords: games ;; This program is free software; you can redistribute it and/or modify @@ -24,6 +24,12 @@ ;; poker.el provides Texas hold 'em poker gameplay for Emacs. +;;; Todo: + +;; * Provide a better user interface. A buffer should be used to keep +;; the state and visual representation of a table/game. +;; * Smarter AIs. + ;;; Requires: (require 'cl-lib)