diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-02-14 00:46:29 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-02-14 00:46:29 -0500 |
commit | 61b4c22c6eba96718327a0d208a8492d8bad76e0 (patch) | |
tree | 12b0c6b72e7d434209ac19c71c1b8b7986773157 /lisp/emacs-lisp/cl-preloaded.el | |
parent | 0d54f2f51c799cc372d9521233a8009adc4c3691 (diff) | |
download | emacs-61b4c22c6eba96718327a0d208a8492d8bad76e0.tar.gz |
* lisp/emacs-lisp/cl*.el: Use define-inline and move some code
* lisp/emacs-lisp/cl-lib.el: Move autoloaded code to cl-preload.
* lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Register as children
of the parent.
(cl--assertion-failed): New function.
(cl-assertion-failed): Move in from cl-lib.el.
* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Don't generate code to register
as children of its parents.
(cl--make-type-test, cl--compiler-macro-typep): Remove functions.
(cl-typep): Reimplement using define-inline.
(cl-assert): Use cl--assertion-failed.
(cl-struct-slot-value): Use define-inline.
Diffstat (limited to 'lisp/emacs-lisp/cl-preloaded.el')
-rw-r--r-- | lisp/emacs-lisp/cl-preloaded.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el index c9867b412a1..03045de509a 100644 --- a/lisp/emacs-lisp/cl-preloaded.el +++ b/lisp/emacs-lisp/cl-preloaded.el @@ -33,6 +33,10 @@ (if (boundp children-sym) (add-to-list children-sym tag) (set children-sym (list tag))) + (let* ((parent-class parent)) + (while parent-class + (add-to-list (intern (format "cl-struct-%s-tags" parent-class)) tag) + (setq parent-class (get parent-class 'cl-struct-include)))) ;; If the cl-generic support, we need to be able to check ;; if a vector is a cl-struct object, without knowing its particular type. ;; So we use the (otherwise) unused function slots of the tag symbol @@ -44,5 +48,27 @@ (if print-auto (put name 'cl-struct-print print-auto)) (if docstring (put name 'structure-documentation docstring))) +;; The `assert' macro from the cl package signals +;; `cl-assertion-failed' at runtime so always define it. +(define-error 'cl-assertion-failed (purecopy "Assertion failed")) + +(defun cl--assertion-failed (form &optional string sargs args) + (if debug-on-error + (debug `(cl-assertion-failed ,form ,string ,@sargs)) + (if string + (apply #'error string (append sargs args)) + (signal 'cl-assertion-failed `(,form ,@sargs))))) + +;; Make sure functions defined with cl-defsubst can be inlined even in +;; packages which do not require CL. We don't put an autoload cookie +;; directly on that function, since those cookies only go to cl-loaddefs. +(autoload 'cl--defsubst-expand "cl-macs") +;; Autoload, so autoload.el and font-lock can use it even when CL +;; is not loaded. +(put 'cl-defun 'doc-string-elt 3) +(put 'cl-defmacro 'doc-string-elt 3) +(put 'cl-defsubst 'doc-string-elt 3) +(put 'cl-defstruct 'doc-string-elt 2) + (provide 'cl-preloaded) ;;; cl-preloaded.el ends here |