[Top][All Lists]

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

[elpa] externals/xelb 0494421: Eliminate a compile warning with `xcb:def

From: Chris Feng
Subject: [elpa] externals/xelb 0494421: Eliminate a compile warning with `xcb:deftypealias'
Date: Sun, 23 Sep 2018 08:59:19 -0400 (EDT)

branch: externals/xelb
commit 0494421c858aefbdf544ead22b6037b4877342da
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    Eliminate a compile warning with `xcb:deftypealias'
    * xcb-types.el (xcb:deftypealias): Use variable property instead of
    `defvaralias'/`indirect-variable' to store the fundamental type.
 el_client.el |  2 +-
 xcb-types.el | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/el_client.el b/el_client.el
index ae68a47..f15677a 100644
--- a/el_client.el
+++ b/el_client.el
@@ -156,7 +156,7 @@ an `xelb-auto-padding' attribute."
 (defun xelb-type-size (type &optional slot)
   "Return size of TYPE in bytes."
-  (pcase (indirect-variable type)
+  (pcase (or (get type 'xcb--typealias) type)
     (`xcb:-ignore 0)
     ((or `xcb:-u1 `xcb:-i1 `xcb:void) 1)
     ((or `xcb:-u2 `xcb:-i2) 2)
diff --git a/xcb-types.el b/xcb-types.el
index f8ee0b9..988e26b 100644
--- a/xcb-types.el
+++ b/xcb-types.el
@@ -411,12 +411,16 @@ FORMAT-STRING is a string specifying the message to 
output, as in
 ;; typedef in C
 (defmacro xcb:deftypealias (new-type old-type)
-  "Define NEW-TYPE as an alias of type OLD-TYPE."
+  "Define NEW-TYPE as an alias of type OLD-TYPE.
+Also the fundamental type is stored in 'the xcb--typealias' variable
+property (for internal use only)."
      ;; FIXME: `new-type' should probably just not be eval'd at all,
      ;; but that requires changing all callers not to quote their arg.
      (cl-deftype ,(eval new-type t) nil ,old-type)
-     (defvaralias ,new-type ,old-type)))
+     (put ,new-type 'xcb--typealias
+          (or (get ,old-type 'xcb--typealias) ,old-type))))
 ;; 1/2/4 B signed/unsigned integer
 (cl-deftype xcb:-i1 () t)
@@ -500,7 +504,7 @@ and value VALUE.
 The optional POS argument indicates current byte index of the field (used by
 `xcb:-pad-align' type)."
-  (pcase (indirect-variable type)
+  (pcase (or (get type 'xcb--typealias) type)
     (`xcb:-u1 (xcb:-pack-u1 value))
     (`xcb:-i1 (xcb:-pack-i1 value))
@@ -611,7 +615,7 @@ The optional argument CTX is for <paramref>.
 This method returns a list of two components, with the first being the result
 and the second the consumed length."
-  (pcase (indirect-variable type)
+  (pcase (or (get type 'xcb--typealias) type)
     (`xcb:-u1 (list (aref data offset) 1))
     (`xcb:-i1 (let ((result (aref data offset)))
                 (list (if (< result 128) result (- result 255)) 1)))

reply via email to

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