LCOV - code coverage report
Current view: top level - lisp - obarray.el (source / functions) Hit Total Coverage
Test: tramp-tests-after.info Lines: 6 11 54.5 %
Date: 2017-08-30 10:12:24 Functions: 3 7 42.9 %

          Line data    Source code
       1             : ;;; obarray.el --- obarray functions -*- lexical-binding: t -*-
       2             : 
       3             : ;; Copyright (C) 2015-2017 Free Software Foundation, Inc.
       4             : 
       5             : ;; Maintainer: emacs-devel@gnu.org
       6             : ;; Keywords: obarray functions
       7             : ;; Package: emacs
       8             : 
       9             : ;; This file is part of GNU Emacs.
      10             : 
      11             : ;; GNU Emacs is free software: you can redistribute it and/or modify
      12             : ;; it under the terms of the GNU General Public License as published by
      13             : ;; the Free Software Foundation, either version 3 of the License, or
      14             : ;; (at your option) any later version.
      15             : 
      16             : ;; GNU Emacs is distributed in the hope that it will be useful,
      17             : ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             : ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             : ;; GNU General Public License for more details.
      20             : 
      21             : ;; You should have received a copy of the GNU General Public License
      22             : ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
      23             : 
      24             : ;;; Commentary:
      25             : 
      26             : ;; This file provides function for working with obarrays.
      27             : 
      28             : ;;; Code:
      29             : 
      30             : (defconst obarray-default-size 59
      31             :   "The value 59 is an arbitrary prime number that gives a good hash.")
      32             : 
      33             : (defun obarray-make (&optional size)
      34             :   "Return a new obarray of size SIZE or `obarray-default-size'."
      35           7 :   (let ((size (or size obarray-default-size)))
      36           7 :     (if (< 0 size)
      37           7 :         (make-vector size 0)
      38           7 :       (signal 'wrong-type-argument '(size 0)))))
      39             : 
      40             : (defun obarray-size (ob)
      41             :   "Return the number of slots of obarray OB."
      42           0 :   (length ob))
      43             : 
      44             : (defun obarrayp (object)
      45             :   "Return t if OBJECT is an obarray."
      46           0 :   (and (vectorp object)
      47           0 :        (< 0 (length object))))
      48             : 
      49             : ;; Don’t use obarray as a variable name to avoid shadowing.
      50             : (defun obarray-get (ob name)
      51             :   "Return symbol named NAME if it is contained in obarray OB.
      52             : Return nil otherwise."
      53         151 :   (intern-soft name ob))
      54             : 
      55             : (defun obarray-put (ob name)
      56             :   "Return symbol named NAME from obarray OB.
      57             : Creates and adds the symbol if doesn't exist."
      58           8 :   (intern name ob))
      59             : 
      60             : (defun obarray-remove (ob name)
      61             :   "Remove symbol named NAME if it is contained in obarray OB.
      62             : Return t on success, nil otherwise."
      63           0 :   (unintern name ob))
      64             : 
      65             : (defun obarray-map (fn ob)
      66             :   "Call function FN on every symbol in obarray OB and return nil."
      67           0 :   (mapatoms fn ob))
      68             : 
      69             : (provide 'obarray)
      70             : ;;; obarray.el ends here

Generated by: LCOV version 1.12