emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/xelb 4063e38: Clean up backport code


From: Chris Feng
Subject: [elpa] externals/xelb 4063e38: Clean up backport code
Date: Mon, 21 Sep 2015 05:33:04 +0000

branch: externals/xelb
commit 4063e380d537ed3309915ec31a109eb644e8bdef
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    Clean up backport code
    
    * xelb.el: Add cl-generic as dependency.
    
    * xcb-types.el: Load cl-generic;
      Remove backport code for cl-defgeneric, cl-defmethod,
      cl-call-next-method, cl--slot-descriptor-name and
      cl--slot-descriptor-initform;
      Backport eieio-slot-descriptor-name.
    
    * xcb.el (xcb:disconnect):
    * xcb-types.el (xcb:marshal of xcb:-struct, xcb:-marshal-field)
      (xcb:unmarshal of xcb-struct, xcb:unmarshal of xcb:-union)
      (xcb:-unmarshal-field, xcb:marshal of xcb:-union):
    * xcb-icccm.el (xcb:unmarshal of xcb:icccm:-GetProperty-explicit~reply)
      (xcb:marshal of xcb:icccm:-ChangeProperty-explicit):
      Use eieio-slot-descriptor-name instead of cl--slot-descriptor-name;
      avoid using cl--slot-descriptor-initform.
    
    * xcb.el (xcb:connection): Provide default values for all slots.
    
    * README.org: Renamed from README.md; add note on cl-generic package.
---
 README.md => README.org |   11 +++++----
 xcb-icccm.el            |    5 ++-
 xcb-types.el            |   53 ++++++++++++++++++++++++----------------------
 xcb.el                  |   12 +++++-----
 xelb.el                 |    2 +-
 5 files changed, 44 insertions(+), 39 deletions(-)

diff --git a/README.md b/README.org
similarity index 50%
rename from README.md
rename to README.org
index 1c26009..c4bf3b3 100644
--- a/README.md
+++ b/README.org
@@ -1,10 +1,11 @@
-X protocol Emacs Lisp Binding
-=============================
+#+TITLE: X protocol Emacs Lisp Binding
 
 XELB (X protocol Emacs Lisp Binding) is a pure Elisp implementation of X11
 protocol based on the XML description files from XCB project.
 It features an object-oriented API and permits a certain degree of concurrency.
 It should enable you to implement some low-level X11 applications.
-Please refer to
-[xelb.el](https://github.com/ch11ng/xelb/blob/master/xelb.el)
-for more details.
+Please refer to 
[[https://github.com/ch11ng/xelb/blob/master/xelb.el][xelb.el]] for more 
details.
+
+*Note to Emacs 24 users*:
+If you install XELB from source (rather than GNU ELPA), be sure to install
+=cl-generic= package from GNU ELPA first.
diff --git a/xcb-icccm.el b/xcb-icccm.el
index 0c5af72..8cdb8d2 100644
--- a/xcb-icccm.el
+++ b/xcb-icccm.el
@@ -299,7 +299,7 @@ explicitly listed out."
     (unless value (setq value (make-vector (length slots) nil))) ;fallback
     ;; Set explicit fields from value field
     (dotimes (i (length value))
-      (setf (slot-value obj (cl--slot-descriptor-name (elt slots i)))
+      (setf (slot-value obj (eieio-slot-descriptor-name (elt slots i)))
             (elt value i)))
     retval))
 
@@ -317,7 +317,8 @@ whose fields are explicitly listed out."
     ;; Set data field from explicit fields
     (setf (slot-value obj 'data)
           (mapconcat (lambda (slot)
-                       (list (slot-value obj (cl--slot-descriptor-name slot))))
+                       (list (slot-value obj
+                                         (eieio-slot-descriptor-name slot))))
                      slots []))
     (cl-call-next-method obj)))
 
diff --git a/xcb-types.el b/xcb-types.el
index 88e21c6..774c862 100644
--- a/xcb-types.el
+++ b/xcb-types.el
@@ -50,22 +50,14 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'cl-generic)
 (require 'eieio)
 
 ;;;; Fix backward compatibility issues with Emacs < 25
 
-;; The `cl-generic' package on ELPA does not solve all problems
+;; Backport some new functions from Emacs 25
 
 (eval-and-compile
-  (unless (fboundp 'cl-defgeneric)
-    (defalias 'cl-defgeneric 'defgeneric))
-
-  (unless (fboundp 'cl-defmethod)
-    (defalias 'cl-defmethod 'defmethod))
-
-  (unless (fboundp 'cl-call-next-method)
-    (defalias 'cl-call-next-method 'call-next-method))
-
   (unless (fboundp 'eieio-class-slots)
     (eval-and-compile
       (defun eieio-class-slots (class)
@@ -78,9 +70,16 @@
             (setq result (nconc result (list (vector (elt names i)
                                                      (elt initforms i)
                                                      (elt types i))))))
-          result))
-      (defsubst cl--slot-descriptor-name (slot) (aref slot 0))
-      (defsubst cl--slot-descriptor-initform (slot) (aref slot 1))
+          result)))))
+
+(eval-and-compile
+  (unless (fboundp 'eieio-slot-descriptor-name)
+    (eval-and-compile
+      (defsubst eieio-slot-descriptor-name (slot) (aref slot 0)))))
+
+(eval-when-compile
+  (unless (fboundp 'cl--slot-descriptor-type)
+    (eval-when-compile
       (defsubst cl--slot-descriptor-type (slot) (aref slot 2)))))
 
 ;;;; Utility functions
@@ -312,7 +311,7 @@ Consider let-bind it rather than change its global value.")
       (dolist (slot slots)
         (setq type (cl--slot-descriptor-type slot))
         (unless (or (eq type 'fd) (eq type 'xcb:-ignore))
-          (setq name (cl--slot-descriptor-name slot))
+          (setq name (eieio-slot-descriptor-name slot))
           (setq value (slot-value obj name))
           (when (symbolp value)        ;see `eieio-default-eval-maybe'
             (setq value (symbol-value value)))
@@ -387,7 +386,7 @@ The optional POS argument indicates current byte index of 
the field (used by
            (dolist (name name-list)
              (catch 'break
                (dolist (slot slots) ;better way to find the slot type?
-                 (when (eq name (cl--slot-descriptor-name slot))
+                 (when (eq name (eieio-slot-descriptor-name slot))
                    (setq slot-type (cl--slot-descriptor-type slot))
                    (throw 'break nil))))
              (setq result
@@ -406,14 +405,16 @@ The optional POS argument indicates current byte index of 
the field (used by
 The optional argument CTX is for <paramref>."
   (let ((slots (eieio-class-slots (eieio-object-class obj)))
         (result 0)
-        tmp type)
+        slot-name tmp type)
     (dolist (slot slots)
       (setq type (cl--slot-descriptor-type slot))
       (unless (or (eq type 'fd) (eq type 'xcb:-ignore))
-        (setq tmp (xcb:-unmarshal-field obj type byte-array 0
-                                        (cl--slot-descriptor-initform slot)
+        (setq slot-name (eieio-slot-descriptor-name slot)
+              tmp (xcb:-unmarshal-field obj type byte-array 0
+                                        (when (slot-boundp obj slot-name)
+                                          (eieio-oref-default obj slot-name))
                                         ctx))
-        (setf (slot-value obj (cl--slot-descriptor-name slot)) (car tmp))
+        (setf (slot-value obj slot-name) (car tmp))
         (setq byte-array (substring byte-array (cadr tmp)))
         (setq result (+ result (cadr tmp)))))
     result))
@@ -515,7 +516,7 @@ and the second the consumed length."
            (dolist (name name-list)
              (catch 'break
                (dolist (slot slots) ;better way to find the slot type?
-                 (when (eq name (cl--slot-descriptor-name slot))
+                 (when (eq name (eieio-slot-descriptor-name slot))
                    (setq slot-type (cl--slot-descriptor-type slot))
                    (throw 'break nil))))
              (setq tmp (xcb:-unmarshal-field obj slot-type data offset nil))
@@ -605,7 +606,7 @@ This result is converted from the first bounded slot."
     (while (and (not result) slots)
       (setq slot (pop slots))
       (setq type (cl--slot-descriptor-type slot)
-            name (cl--slot-descriptor-name slot))
+            name (eieio-slot-descriptor-name slot))
       (unless (or (not (slot-boundp obj name))
                   (eq type 'xcb:-ignore)
                   ;; Dealing with `xcb:-list' type
@@ -622,14 +623,16 @@ This result is converted from the first bounded slot."
 
 The optional argument CTX is for <paramref>."
   (let ((slots (eieio-class-slots (eieio-object-class obj)))
-        consumed tmp type)
+        slot-name consumed tmp type)
     (dolist (slot slots)
       (setq type (cl--slot-descriptor-type slot))
       (unless (eq type 'xcb:-ignore)
-        (setq tmp (xcb:-unmarshal-field obj type byte-array 0
-                                        (cl--slot-descriptor-initform slot)
+        (setq slot-name (eieio-slot-descriptor-name slot)
+              tmp (xcb:-unmarshal-field obj type byte-array 0
+                                        (when (slot-boundp obj slot-name)
+                                          (eieio-oref-default obj slot-name))
                                         ctx))
-        (setf (slot-value obj (cl--slot-descriptor-name slot)) (car tmp))
+        (setf (slot-value obj (eieio-slot-descriptor-name slot)) (car tmp))
         (setq consumed (cadr tmp))))
     consumed))                          ;consume byte-array only once
 
diff --git a/xcb.el b/xcb.el
index 87f353c..38619ae 100644
--- a/xcb.el
+++ b/xcb.el
@@ -74,11 +74,11 @@
 
 ;;;###autoload
 (defclass xcb:connection ()
-  ((process :initarg :process)
+  ((process :initarg :process :initform nil)
    (connected :initform nil)  ;non-nil indicates connected to X server
-   (display :initarg :display)
-   (auth-info :initarg :auth-info)
-   (socket :initarg :socket)
+   (display :initarg :display :initform nil)
+   (auth-info :initarg :auth-info :initform nil)
+   (socket :initarg :socket :initform nil)
    (lock :initform nil)
    (setup-data :initform nil)           ;X connection setup data
    (request-cache :initform [])         ;cache for outgoing requests
@@ -324,8 +324,8 @@ Concurrency is disabled as it breaks the orders of errors, 
replies and events."
   ;; Reset every slot to its default value
   (let ((slots (eieio-class-slots 'xcb:connection)))
     (dolist (slot slots)
-      (setf (slot-value obj (cl--slot-descriptor-name slot))
-            (cl--slot-descriptor-initform slot)))))
+      (setf (slot-value obj (eieio-slot-descriptor-name slot))
+            (eieio-oref-default obj (eieio-slot-descriptor-name slot))))))
 
 ;;;; Other routines
 
diff --git a/xelb.el b/xelb.el
index 81dc82d..9f331fd 100644
--- a/xelb.el
+++ b/xelb.el
@@ -5,7 +5,7 @@
 ;; Author: Chris Feng <address@hidden>
 ;; Maintainer: Chris Feng <address@hidden>
 ;; Version: 0
-;; Package-Requires: ((emacs "24.4"))
+;; Package-Requires: ((emacs "24.4") (cl-generic "0.2"))
 ;; Keywords: unix
 ;; URL: https://github.com/ch11ng/xelb
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]