home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / browser2.zip / br-struc.el < prev    next >
Text File  |  1995-02-17  |  6KB  |  164 lines

  1. ;;; CLASS BROWSER FOR C++
  2. ;;; $Id: br-struc.el,v 3.1 1995/02/17 18:19:36 mmann Exp $
  3. ;;;
  4. ;;; **********************************************************************
  5. ;;; Copyright (C) 1993, 1994 Gerd Moellmann. All rights reserved.
  6. ;;; Altenbergstr. 6, D-40235 Duesseldorf, Germany
  7. ;;; 100025.3303@COMPUSERVE.COM
  8. ;;; Suggestions, comments and requests for improvements are welcome.
  9. ;;; **********************************************************************
  10. ;;;
  11. ;;; This version works with both Emacs version 18 and 19, and I want
  12. ;;; to keep it that way. It requires the CL-19 Common Lisp compatibility
  13. ;;; package for Emacs 18 and 19.
  14. ;;;
  15. ;;; This file contains the structure definitions for the browser package.
  16. ;;; These structures must be the same as those generated by EROWSE.
  17. ;;; 
  18.  
  19. ;;: This file may be made part of the Emacs distribution at the option
  20. ;;; of the FSF.
  21.  
  22. ;; This code is distributed in the hope that it will be useful,
  23. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  24. ;; accepts responsibility to anyone for the consequences of using it
  25. ;; or for whether it serves any particular purpose or works at all,
  26. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  27. ;; License for full details.
  28.  
  29. ;; Everyone is granted permission to copy, modify and redistribute
  30. ;; this code, but only under the conditions described in the
  31. ;; GNU Emacs General Public License.   A copy of this license is
  32. ;; supposed to have been given to you along with GNU Emacs so you
  33. ;; can know your rights and responsibilities.  It should be in a
  34. ;; file named COPYING.  Among other things, the copyright notice
  35. ;; and this notice must be preserved on all copies.
  36.  
  37. (require 'cl-19 "cl")
  38. (require 'backquote)
  39. (require 'br-macro)
  40.  
  41. (proclaim '(optimize (speed 3) (safety 0)))
  42.  
  43.  
  44. ;;;
  45. ;;; A @HEADER structure is the first in a file produced by EBROWSE.
  46. ;;; It contains
  47. ;;; - a version number that is compared against the version number
  48. ;;;   of the Lisp package when the file is loaded.
  49. ;;; - the name of the file containing regular expressions, if any.
  50. ;;;   If this name is NIL, regular expressions are stored within
  51. ;;;   the Lisp database.
  52. ;;; - a free slot that is filled out after the tree is loaded. This
  53. ;;;   slot MEMBER-OBARRAY is set to an obarray with an entry for
  54. ;;;   each member in the tree.
  55. ;;;   
  56.  
  57. (defstruct tree-header
  58.   version                               ;version string
  59.   command-line-options                  ;command line used to generate tree
  60.   regexp-file                           ;file containing regexps or NIL
  61.   member-obarray)                       ;filled out later
  62.  
  63.  
  64. ;;;
  65. ;;; Following the TREE-HEADER structure, the BROWSE file contains a
  66. ;;; number of TREE structures, each one describing one root class of
  67. ;;; the class hierarchy with all its subclasses.
  68. ;;;
  69.  
  70. (defstruct tree
  71.   class                                 ;CLASS struct describing the class
  72.   subclasses                            ;list of TREEs for subclasses
  73.   member-variables                      ;list of MEMBERs structs
  74.   member-functions                      ;
  75.   static-variables                      ;
  76.   static-functions                      ;
  77.   friends                               ;
  78.   types                                 ;
  79.   superclasses                          ;list of TREEs for superclasses
  80.   mark)                                 ;marked?
  81.  
  82.  
  83. ;;;
  84. ;;; A common structure definining an occurrance of some name in
  85. ;;; the source files. 
  86. ;;;
  87.  
  88. (defstruct browse 
  89.   name                                  ;class or member name
  90.   file                                  ;file in which to search
  91.   pattern                               ;regexp to search for
  92.   point)                                ;start point for search
  93.  
  94.  
  95. ;;;
  96. ;;; This is the structure stored in the CLASS slot of a TREE structure.
  97. ;;; It describes the location of the class declaration.
  98. ;;;
  99.  
  100. (defstruct (class (:include browse))
  101.   source-file)
  102.  
  103.  
  104. ;;;
  105. ;;; This is the structure describing a single member. The TREE structure
  106. ;;; contains various lists of MEMBERS for the different types of
  107. ;;; members.
  108. ;;;
  109.  
  110. (defstruct (member (:include browse))
  111.   flags
  112.   definition-file
  113.   definition-pattern
  114.   definition-point
  115.   hash)
  116.  
  117.  
  118. ;;;
  119. ;;; Some macros to access the FLAGS slot of a MEMBER.
  120. ;;;
  121.  
  122. (defmacro member-visibility (member)
  123.   "Get state of `public', `protected', and `private'."
  124.   (` (logand (member-flags (, member)) 7)))
  125.  
  126. (defmacro member-inline-p (member)
  127.   "Is member marked as `inline'?"
  128.   (` (/= 0 (logand (member-flags (, member)) 16))))
  129.  
  130. (defmacro member-virtual-p (member)
  131.   "Is member marked as `virtual'?"
  132.   (` (/= 0 (logand (member-flags (, member)) 32))))
  133.  
  134. (defmacro member-const-p (member)
  135.   "Is member marked as `const'?"
  136.   (` (/= 0 (logand (member-flags (, member)) 64))))
  137.  
  138. (defmacro member-pure-p (member)
  139.   "Is member marked as `pure virtual'?"
  140.   (` (/= 0 (logand (member-flags (, member)) 128))))
  141.  
  142. ;;;
  143. ;;; Build a list of superclasses for TREE by searching the subclass
  144. ;;; lists incrementally. This function must be used instead of
  145. ;;; TREE-SUPERCLASSES to access the superclass list.
  146. ;;; 
  147.  
  148. (defun browse-superclasses (tree)
  149.   (or (tree-superclasses tree)
  150.       (setf (tree-superclasses tree)
  151.             (loop with to-search = (list tree)
  152.                   with result = nil
  153.                   as search = (pop to-search)
  154.                   while search finally return result
  155.                   do (dotrees (ti @tree-obarray)
  156.                        (when (memq search (tree-subclasses ti))
  157.                          (unless (memq ti result)
  158.                            (setf result (nconc result (list ti))))
  159.                          (push ti to-search)))))))
  160.  
  161. (provide 'br-struc)
  162.  
  163. ;;; end of `br-struc.el'.
  164.