aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2017-03-16 12:31:07 -0400
committerStefan Monnier2017-03-16 12:31:07 -0400
commitffbb46849990bf4bf952e01b78c9a1a0ca0d4432 (patch)
treeab2d6dbd1f93e8c42a8508342abfb379a4a14d9f
parent265a5d9791bf42da0bab7bdbef4352e8d734ef31 (diff)
downloademacs-ffbb46849990bf4bf952e01b78c9a1a0ca0d4432.tar.gz
emacs-ffbb46849990bf4bf952e01b78c9a1a0ca0d4432.zip
Add obarray-size and fix tests accordingly. Use obarrayp in cedet.
* lisp/obarray.el (obarray-size): New function. * lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-symbol) (semantic-lex-spp-save-table, semantic-lex-spp-macros): * lisp/cedet/semantic/bovine/c.el (semantic-c-describe-environment): Use obarrayp. * test/lisp/obarray-tests.el (obarray-make-default-test) (obarray-make-with-size-test): Use it.
-rw-r--r--lisp/cedet/semantic/bovine/c.el2
-rw-r--r--lisp/cedet/semantic/lex-spp.el14
-rw-r--r--lisp/obarray.el4
-rw-r--r--test/lisp/obarray-tests.el6
4 files changed, 16 insertions, 10 deletions
diff --git a/lisp/cedet/semantic/bovine/c.el b/lisp/cedet/semantic/bovine/c.el
index bef4b179b23..3200a5c1435 100644
--- a/lisp/cedet/semantic/bovine/c.el
+++ b/lisp/cedet/semantic/bovine/c.el
@@ -2253,7 +2253,7 @@ actually in their parent which is not accessible.")
2253 (princ " Your project symbol map is also derived from the EDE object:\n ") 2253 (princ " Your project symbol map is also derived from the EDE object:\n ")
2254 (princ (object-print ede-object))) 2254 (princ (object-print ede-object)))
2255 (princ "\n\n") 2255 (princ "\n\n")
2256 (if (arrayp semantic-lex-spp-project-macro-symbol-obarray) 2256 (if (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
2257 (let ((macros nil)) 2257 (let ((macros nil))
2258 (mapatoms 2258 (mapatoms
2259 #'(lambda (symbol) 2259 #'(lambda (symbol)
diff --git a/lisp/cedet/semantic/lex-spp.el b/lisp/cedet/semantic/lex-spp.el
index 8d6467e5ed0..cb33e483a6b 100644
--- a/lisp/cedet/semantic/lex-spp.el
+++ b/lisp/cedet/semantic/lex-spp.el
@@ -147,13 +147,13 @@ The search priority is:
147 ;; Do the check of the various tables. 147 ;; Do the check of the various tables.
148 (or 148 (or
149 ;; DYNAMIC 149 ;; DYNAMIC
150 (and (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray) 150 (and (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
151 (intern-soft name semantic-lex-spp-dynamic-macro-symbol-obarray)) 151 (intern-soft name semantic-lex-spp-dynamic-macro-symbol-obarray))
152 ;; PROJECT 152 ;; PROJECT
153 (and (arrayp semantic-lex-spp-project-macro-symbol-obarray) 153 (and (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
154 (intern-soft name semantic-lex-spp-project-macro-symbol-obarray)) 154 (intern-soft name semantic-lex-spp-project-macro-symbol-obarray))
155 ;; SYSTEM 155 ;; SYSTEM
156 (and (arrayp semantic-lex-spp-macro-symbol-obarray) 156 (and (obarrayp semantic-lex-spp-macro-symbol-obarray)
157 (intern-soft name semantic-lex-spp-macro-symbol-obarray)) 157 (intern-soft name semantic-lex-spp-macro-symbol-obarray))
158 ;; ... 158 ;; ...
159 ))) 159 )))
@@ -291,7 +291,7 @@ REPLACEMENT a string that would be substituted in for NAME."
291 "Return a list of spp macros and values. 291 "Return a list of spp macros and values.
292The return list is meant to be saved in a semanticdb table." 292The return list is meant to be saved in a semanticdb table."
293 (let (macros) 293 (let (macros)
294 (when (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray) 294 (when (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
295 (mapatoms 295 (mapatoms
296 #'(lambda (symbol) 296 #'(lambda (symbol)
297 (setq macros (cons (cons (symbol-name symbol) 297 (setq macros (cons (cons (symbol-name symbol)
@@ -304,17 +304,17 @@ The return list is meant to be saved in a semanticdb table."
304 "Return a list of spp macros as Lisp symbols. 304 "Return a list of spp macros as Lisp symbols.
305The value of each symbol is the replacement stream." 305The value of each symbol is the replacement stream."
306 (let (macros) 306 (let (macros)
307 (when (arrayp semantic-lex-spp-macro-symbol-obarray) 307 (when (obarrayp semantic-lex-spp-macro-symbol-obarray)
308 (mapatoms 308 (mapatoms
309 #'(lambda (symbol) 309 #'(lambda (symbol)
310 (setq macros (cons symbol macros))) 310 (setq macros (cons symbol macros)))
311 semantic-lex-spp-macro-symbol-obarray)) 311 semantic-lex-spp-macro-symbol-obarray))
312 (when (arrayp semantic-lex-spp-project-macro-symbol-obarray) 312 (when (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
313 (mapatoms 313 (mapatoms
314 #'(lambda (symbol) 314 #'(lambda (symbol)
315 (setq macros (cons symbol macros))) 315 (setq macros (cons symbol macros)))
316 semantic-lex-spp-project-macro-symbol-obarray)) 316 semantic-lex-spp-project-macro-symbol-obarray))
317 (when (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray) 317 (when (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
318 (mapatoms 318 (mapatoms
319 #'(lambda (symbol) 319 #'(lambda (symbol)
320 (setq macros (cons symbol macros))) 320 (setq macros (cons symbol macros)))
diff --git a/lisp/obarray.el b/lisp/obarray.el
index aaffe00a072..a4631859925 100644
--- a/lisp/obarray.el
+++ b/lisp/obarray.el
@@ -37,6 +37,10 @@
37 (make-vector size 0) 37 (make-vector size 0)
38 (signal 'wrong-type-argument '(size 0))))) 38 (signal 'wrong-type-argument '(size 0)))))
39 39
40(defun obarray-size (obarray)
41 "Return the number of slots of OBARRAY."
42 (length obarray))
43
40(defun obarrayp (object) 44(defun obarrayp (object)
41 "Return t if OBJECT is an obarray." 45 "Return t if OBJECT is an obarray."
42 (and (vectorp object) 46 (and (vectorp object)
diff --git a/test/lisp/obarray-tests.el b/test/lisp/obarray-tests.el
index 9a2d65d8b41..4908b883240 100644
--- a/test/lisp/obarray-tests.el
+++ b/test/lisp/obarray-tests.el
@@ -43,14 +43,16 @@
43(ert-deftest obarray-make-default-test () 43(ert-deftest obarray-make-default-test ()
44 (let ((table (obarray-make))) 44 (let ((table (obarray-make)))
45 (should (obarrayp table)) 45 (should (obarrayp table))
46 (should (equal (make-vector 59 0) table)))) 46 (should (eq (obarray-size table) obarray-default-size))))
47 47
48(ert-deftest obarray-make-with-size-test () 48(ert-deftest obarray-make-with-size-test ()
49 ;; FIXME: Actually, `wrong-type-argument' is not the right error to signal,
50 ;; so we shouldn't enforce this misbehavior in tests!
49 (should-error (obarray-make -1) :type 'wrong-type-argument) 51 (should-error (obarray-make -1) :type 'wrong-type-argument)
50 (should-error (obarray-make 0) :type 'wrong-type-argument) 52 (should-error (obarray-make 0) :type 'wrong-type-argument)
51 (let ((table (obarray-make 1))) 53 (let ((table (obarray-make 1)))
52 (should (obarrayp table)) 54 (should (obarrayp table))
53 (should (equal (make-vector 1 0) table)))) 55 (should (eq (obarray-size table) 1))))
54 56
55(ert-deftest obarray-get-test () 57(ert-deftest obarray-get-test ()
56 (let ((table (obarray-make 3))) 58 (let ((table (obarray-make 3)))