[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/record dbb4691 13/13: Enable legacy defstruct comp
From: |
Lars Brinkhoff |
Subject: |
[Emacs-diffs] scratch/record dbb4691 13/13: Enable legacy defstruct compatibility. |
Date: |
Mon, 20 Mar 2017 16:11:10 -0400 (EDT) |
branch: scratch/record
commit dbb469132f3ac698f163e3cf337c039dd79acef5
Author: Lars Brinkhoff <address@hidden>
Commit: Lars Brinkhoff <address@hidden>
Enable legacy defstruct compatibility.
* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Pass `blue-sky' to
cl-struct-define to signal use of record objects.
* lisp/emacs-lisp/cl-preloaded.el (cl--struct-get-class): Likewise.
(cl-struct-define): Enable legacy defstruct compatibility.
---
lisp/emacs-lisp/cl-macs.el | 4 ++--
lisp/emacs-lisp/cl-preloaded.el | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index c282938..a5a0769 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2847,8 +2847,8 @@ non-nil value, that slot cannot be set via `setf'.
;; struct as a parent.
(eval-and-compile
(cl-struct-define ',name ,docstring ',include-name
- ',type ,(eq named t) ',descs ',tag-symbol ',tag
- ',print-auto))
+ ',(or type 'blue-sky) ,(eq named t) ',descs
+ ',tag-symbol ',tag ',print-auto))
',name)))
;;; Add cl-struct support to pcase
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
index 7432dd4..a2ce1c3 100644
--- a/lisp/emacs-lisp/cl-preloaded.el
+++ b/lisp/emacs-lisp/cl-preloaded.el
@@ -79,6 +79,8 @@
(let ((tag (intern (format "cl-struct-%s" name)))
(type-and-named (get name 'cl-struct-type))
(descs (get name 'cl-struct-slots)))
+ (if (null (car type-and-named))
+ (setq type-and-named (cons 'blue-sky (cdr type-and-named))))
(cl-struct-define name nil (get name 'cl-struct-include)
(unless (and (eq (car type-and-named) 'vector)
(null (cadr type-and-named))
@@ -110,6 +112,13 @@
;;;###autoload
(defun cl-struct-define (name docstring parent type named slots children-sym
tag print)
+ (if (null type)
+ ;; Legacy defstruct, using tagged vectors. Enable backward
+ ;; compatibility.
+ (setq old-struct-compat t))
+ (if (eq type 'blue-sky)
+ ;; Defstruct using record objects.
+ (setq type nil))
(cl-assert (or type (not named)))
(if (boundp children-sym)
(add-to-list children-sym tag)
- [Emacs-diffs] scratch/record 457791b 04/13: Test cases., (continued)
- [Emacs-diffs] scratch/record 457791b 04/13: Test cases., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 29d7fef 03/13: Make EIEIO use records., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record fff19c5 06/13: Use sizeof to get length of cl-struct prefix., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 6450a4c 07/13: Better doc string for `old-struct-compat'., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 953ceab 10/13: Fix cl-print-object to find the object class the new way., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 18e3aac 01/13: Add record objects with user-defined types., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record f6e4882 11/13: Make a note that CHECK_RECORD_TYPE is a work in progress., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 9122e24 12/13: Signal errors from APIs., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record be8079b 05/13: Backward compatibility with pre-existing struct instances., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 91584a7 09/13: Make it possible to compare records with `equal'., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record dbb4691 13/13: Enable legacy defstruct compatibility.,
Lars Brinkhoff <=
- [Emacs-diffs] scratch/record db8ff08 08/13: Better doc strings for `make-record', `record', and `copy-record'., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 5d4f89f 02/13: Update cl-defstruct to use records., Lars Brinkhoff, 2017/03/20