diff options
| author | Glenn Morris | 2007-11-22 06:20:53 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-11-22 06:20:53 +0000 |
| commit | ad95f32a98471c83bbb612925e3f3cbc4d30d08d (patch) | |
| tree | 5bbafe509db5a1067a3c2f01dc60fd63bf0e8074 | |
| parent | dc5786a52f0bac08baeef6d2ac4503b6c96e89e0 (diff) | |
| download | emacs-ad95f32a98471c83bbb612925e3f3cbc4d30d08d.tar.gz emacs-ad95f32a98471c83bbb612925e3f3cbc4d30d08d.zip | |
(check-declare-verify): Implement arglist checking for C files.
| -rw-r--r-- | lisp/emacs-lisp/check-declare.el | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-declare.el index 5da8691beed..c1cdb3a2e80 100644 --- a/lisp/emacs-lisp/check-declare.el +++ b/lisp/emacs-lisp/check-declare.el | |||
| @@ -34,8 +34,6 @@ | |||
| 34 | 34 | ||
| 35 | ;; 1. Handle defstructs (eg uniquify-item-base in desktop.el). | 35 | ;; 1. Handle defstructs (eg uniquify-item-base in desktop.el). |
| 36 | 36 | ||
| 37 | ;; 2. Argument checking for functions defined in C. | ||
| 38 | |||
| 39 | ;;; Code: | 37 | ;;; Code: |
| 40 | 38 | ||
| 41 | (defconst check-declare-warning-buffer "*Check Declarations Warnings*" | 39 | (defconst check-declare-warning-buffer "*Check Declarations Warnings*" |
| @@ -89,7 +87,7 @@ found to be true, otherwise a list of errors with elements of the form | |||
| 89 | \(FILE FN TYPE), where TYPE is a string giving details of the error." | 87 | \(FILE FN TYPE), where TYPE is a string giving details of the error." |
| 90 | (let ((m (format "Checking %s..." fnfile)) | 88 | (let ((m (format "Checking %s..." fnfile)) |
| 91 | (cflag (string-equal "c" (file-name-extension fnfile))) | 89 | (cflag (string-equal "c" (file-name-extension fnfile))) |
| 92 | re fn sig siglist arglist type errlist) | 90 | re fn sig siglist arglist type errlist minargs maxargs) |
| 93 | (message "%s" m) | 91 | (message "%s" m) |
| 94 | (or cflag | 92 | (or cflag |
| 95 | (file-exists-p fnfile) | 93 | (file-exists-p fnfile) |
| @@ -110,7 +108,18 @@ ine-derived-mode\\|ine-minor-mode\\|alias[ \t]+'\\)\\)\ | |||
| 110 | ;; (min . max) for a fixed number of arguments, or | 108 | ;; (min . max) for a fixed number of arguments, or |
| 111 | ;; arglists with optional elements. | 109 | ;; arglists with optional elements. |
| 112 | ;; (min) for arglists with &rest. | 110 | ;; (min) for arglists with &rest. |
| 113 | sig (cond ((string-equal (match-string 1) | 111 | sig (cond (cflag |
| 112 | (re-search-forward "," nil t 3) | ||
| 113 | (skip-chars-forward " \t\n") | ||
| 114 | ;; Assuming minargs and maxargs on same line. | ||
| 115 | (when (looking-at "\\([0-9]+\\)[ \t]*,[ \t]*\ | ||
| 116 | \\([0-9]+\\|MANY\\|UNEVALLED\\)") | ||
| 117 | (setq minargs (string-to-number (match-string 1)) | ||
| 118 | maxargs (match-string 2)) | ||
| 119 | (cons minargs (unless (string-match "[^0-9]" | ||
| 120 | maxargs) | ||
| 121 | (string-to-number maxargs))))) | ||
| 122 | ((string-equal (match-string 1) | ||
| 114 | "define-derived-mode") | 123 | "define-derived-mode") |
| 115 | '(0 . 0)) | 124 | '(0 . 0)) |
| 116 | ((string-equal (match-string 1) | 125 | ((string-equal (match-string 1) |
| @@ -133,9 +142,7 @@ ine-derived-mode\\|ine-minor-mode\\|alias[ \t]+'\\)\\)\ | |||
| 133 | (if (setq sig (assoc (cadr e) siglist)) | 142 | (if (setq sig (assoc (cadr e) siglist)) |
| 134 | ;; Recall we use t to mean no arglist specified, | 143 | ;; Recall we use t to mean no arglist specified, |
| 135 | ;; to distinguish from an empty arglist. | 144 | ;; to distinguish from an empty arglist. |
| 136 | ;; FIXME c arg checking not yet implemented. | 145 | (unless (or (eq arglist t) |
| 137 | (unless (or cflag | ||
| 138 | (eq arglist t) | ||
| 139 | (eq sig t)) | 146 | (eq sig t)) |
| 140 | (unless (equal (byte-compile-arglist-signature arglist) | 147 | (unless (equal (byte-compile-arglist-signature arglist) |
| 141 | (cdr sig)) | 148 | (cdr sig)) |