From: Andrea Corallo Date: Sun, 4 Jun 2023 09:26:22 +0000 (+0200) Subject: * Have `comp-cstr-to-type-spec' handle comp-cstr-f as well X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ed24bfb04f5a878689e09914f1c4b28105ac85e;p=emacs.git * Have `comp-cstr-to-type-spec' handle comp-cstr-f as well * lisp/emacs-lisp/comp-cstr.el (comp--simple-cstr-to-type-spec): New function. (comp-cstr-to-type-spec): Make use of. --- diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 416ca7f11b0..c5b96a6b629 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -1181,8 +1181,8 @@ FN non-nil indicates we are parsing a function lambda list." :ret (comp-type-spec-to-cstr ret))) (_ (error "Invalid type specifier")))) -(defun comp-cstr-to-type-spec (cstr) - "Given CSTR return its type specifier." +(defun comp--simple-cstr-to-type-spec (cstr) + "Given a non comp-cstr-f CSTR return its type specifier." (let ((valset (comp-cstr-valset cstr)) (typeset (comp-cstr-typeset cstr)) (range (comp-cstr-range cstr)) @@ -1236,6 +1236,20 @@ FN non-nil indicates we are parsing a function lambda list." `(not ,final) final)))) +(defun comp-cstr-to-type-spec (cstr) + "Given CSTR return its type specifier." + (cl-etypecase cstr + (comp-cstr-f + `(function + ,(mapcar (lambda (x) + (cl-etypecase x + (comp-cstr (comp-cstr-to-type-spec x)) + (symbol x))) + (comp-cstr-f-args cstr)) + ,(comp--simple-cstr-to-type-spec (comp-cstr-f-ret cstr)))) + (comp-cstr + (comp--simple-cstr-to-type-spec cstr)))) + (provide 'comp-cstr) ;;; comp-cstr.el ends here