]> git.eshelyaron.com Git - emacs.git/commitdiff
Add obarray-size and fix tests accordingly. Use obarrayp in cedet.
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 16 Mar 2017 16:31:07 +0000 (12:31 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 16 Mar 2017 16:31:07 +0000 (12:31 -0400)
* 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.

lisp/cedet/semantic/bovine/c.el
lisp/cedet/semantic/lex-spp.el
lisp/obarray.el
test/lisp/obarray-tests.el

index bef4b179b23c37a3903c0983ee5d4d966fcb63ad..3200a5c14352ff8ef62a8e1b792a73a5e2bbcf4d 100644 (file)
@@ -2253,7 +2253,7 @@ actually in their parent which is not accessible.")
          (princ "      Your project symbol map is also derived from the EDE object:\n      ")
          (princ (object-print ede-object)))
        (princ "\n\n")
-       (if (arrayp semantic-lex-spp-project-macro-symbol-obarray)
+       (if (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
            (let ((macros nil))
              (mapatoms
               #'(lambda (symbol)
index 8d6467e5ed0cb8f14787f2ae5f81ffef5fe545c2..cb33e483a6b4e3b314b8ae18943b701686b8f894 100644 (file)
@@ -147,13 +147,13 @@ The search priority is:
    ;; Do the check of the various tables.
    (or
     ;; DYNAMIC
-    (and (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
+    (and (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
         (intern-soft name semantic-lex-spp-dynamic-macro-symbol-obarray))
     ;; PROJECT
-    (and (arrayp semantic-lex-spp-project-macro-symbol-obarray)
+    (and (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
         (intern-soft name semantic-lex-spp-project-macro-symbol-obarray))
     ;; SYSTEM
-    (and (arrayp semantic-lex-spp-macro-symbol-obarray)
+    (and (obarrayp semantic-lex-spp-macro-symbol-obarray)
         (intern-soft name semantic-lex-spp-macro-symbol-obarray))
     ;; ...
     )))
@@ -291,7 +291,7 @@ REPLACEMENT a string that would be substituted in for NAME."
   "Return a list of spp macros and values.
 The return list is meant to be saved in a semanticdb table."
   (let (macros)
-    (when (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
+    (when (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
       (mapatoms
        #'(lambda (symbol)
           (setq macros (cons (cons (symbol-name symbol)
@@ -304,17 +304,17 @@ The return list is meant to be saved in a semanticdb table."
   "Return a list of spp macros as Lisp symbols.
 The value of each symbol is the replacement stream."
   (let (macros)
-    (when (arrayp semantic-lex-spp-macro-symbol-obarray)
+    (when (obarrayp semantic-lex-spp-macro-symbol-obarray)
       (mapatoms
        #'(lambda (symbol)
           (setq macros (cons symbol macros)))
        semantic-lex-spp-macro-symbol-obarray))
-    (when (arrayp semantic-lex-spp-project-macro-symbol-obarray)
+    (when (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
       (mapatoms
        #'(lambda (symbol)
           (setq macros (cons symbol macros)))
        semantic-lex-spp-project-macro-symbol-obarray))
-    (when (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
+    (when (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
       (mapatoms
        #'(lambda (symbol)
           (setq macros (cons symbol macros)))
index aaffe00a07237688b53ef51e21a41faea034790a..a4631859925d4b3d7d7ea744d354ec341e39aeef 100644 (file)
         (make-vector size 0)
       (signal 'wrong-type-argument '(size 0)))))
 
+(defun obarray-size (obarray)
+  "Return the number of slots of OBARRAY."
+  (length obarray))
+
 (defun obarrayp (object)
   "Return t if OBJECT is an obarray."
   (and (vectorp object)
index 9a2d65d8b415c095f157af1cee995276d66ffe80..4908b8832401870a3e837c172e4a3a0e9f5d76a8 100644 (file)
 (ert-deftest obarray-make-default-test ()
   (let ((table (obarray-make)))
     (should (obarrayp table))
-    (should (equal (make-vector 59 0) table))))
+    (should (eq (obarray-size table) obarray-default-size))))
 
 (ert-deftest obarray-make-with-size-test ()
+  ;; FIXME: Actually, `wrong-type-argument' is not the right error to signal,
+  ;; so we shouldn't enforce this misbehavior in tests!
   (should-error (obarray-make -1) :type 'wrong-type-argument)
   (should-error (obarray-make 0) :type 'wrong-type-argument)
   (let ((table (obarray-make 1)))
     (should (obarrayp table))
-    (should (equal (make-vector 1 0) table))))
+    (should (eq (obarray-size table) 1))))
 
 (ert-deftest obarray-get-test ()
   (let ((table (obarray-make 3)))