annotate lisp/oobr/br-c++.el @ 215:1f0dabaa0855 r20-4b6

Import from CVS: tag r20-4b6
author cvs
date Mon, 13 Aug 2007 10:07:35 +0200
parents 4be1180a9e89
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: br-c++.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Support routines for C++ inheritance browsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: c, oop, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 7-Dec-89
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
12 ;; LAST-MOD: 21-Feb-97 at 17:21:28 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
14 ;; Copyright (C) 1989-1995, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; See the file BR-COPY for license information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; This file is part of the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Properly supports C++ multiple inheritance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; See 'c++-class-def-regexp' for regular expression that matches class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; definitions. You may want to modify it to your own tastes, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; example if you do not want to consider 'struct' definitions as classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; even though grammatically, they are.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (mapcar 'require '(br-lib hypb br-c-ft))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; User visible variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defvar c++-class-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 "\\(class\\|struct\\|union\\)[ \t\n]+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "*Keyword regexp preceding a C++ class declaration or definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defvar c++-lib-search-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "List of directories below which C++ Library source files are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 Subdirectories of Library source are also searched. A Library is a stable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 group of classes.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvar c++-sys-search-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "List of directories below which C++ System source files are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Subdirectories of System source are also searched. A System class is one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 that is not yet reusable and is likely to change before release.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defconst c++-narrow-view-to-class nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 "*Non-nil means narrow buffer to just the matching class definition when displayed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; Internal functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defun c++-get-classes-from-source (filename &optional skip-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 skip-tags-cleanup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "Scans FILENAME and returns cons of class list with parents-class alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Handles multiple inheritance. Assumes file existence and readability have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 already been checked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 With optional SKIP-TAGS non-nil, does not compute and store lookup tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 for member definitions. If SKIP-TAGS is nil, normally a cleanup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 function is called after scanning the members. SKIP-TAGS-CLEANUP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 non-nil suppresses this action."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (let ((no-kill (get-file-buffer filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 class-name-end classes class has-parents open-brace-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 parents parent-cons signatures)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (if no-kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (set-buffer no-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (funcall br-view-file-function filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (or skip-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (progn (setq signatures (c++-scan-features))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (goto-char (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (while (re-search-forward c++-class-def-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq has-parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (= ?: (char-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (match-beginning c++-class-def-derived-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 class-name-end (match-end c++-class-def-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; Now since we've saved all the match expressions we need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; from our last regexp match, we can call functions which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; change the match data below here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 class (c++-normalize-class-match t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 parent-cons (cons (if has-parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; Return parents as a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (c++-scan-parents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; Ensure class name not found within a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (if (c-within-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (progn (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq class nil parent-cons nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (setq classes (cons class classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 parents (cons parent-cons parents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (or skip-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; Scan members defined within class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (progn (goto-char class-name-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (search-forward "{" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (progn (setq open-brace-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; Move to class close brace but ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; any error if braces are unbalanced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; Let the compiler tell the user about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (if (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (progn (forward-sexp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (setq signatures
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 signatures
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (c++-scan-features-in-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 class open-brace-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (point)))))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if skip-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (c++-get-feature-tags buffer-file-name (c++-sort-features signatures))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (or skip-tags-cleanup (br-feature-tags-save)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (or no-kill (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (cons classes (delq nil parents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defun c++-class-definition-regexp (class &optional regexp-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "Return regexp to uniquely match the definition of CLASS name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 Optional REGEXP-FLAG non-nil means CLASS has already been quoted for use in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 regular expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let ((template-args-regexp (c++-template-args-regexp class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (concat "^[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (if template-args-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; Only match to a class definition with the same number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; template parameters as <class> since some modules use #ifdef
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; to define classes with the same name but a different number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; of template parameters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (format "\\(template[ \t\n\^M]*%s[ \t\n\^M]*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 template-args-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 c++-class-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (if regexp-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (c++-class-non-template-name class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (regexp-quote (c++-class-non-template-name class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 c++-class-name-after)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defun c++-template-args-regexp (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 "Return a regexp matching the number of template args in CLASS or nil when there are no such arguments."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (if (string-match "<[^!]+>\\'" class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (let* ((param "[^,<>]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (comma (concat "," param)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (format "<%s%s>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 param (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (function (lambda (c) (if (= c ?\,) comma)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (substring class (1+ (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (1- (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; Remove only *trailing* template identifiers when class name is looked up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defun c++-class-non-template-name (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "Return CLASS name sans any trailing <template> component.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 Does not remove whitespace from CLASS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (and (stringp class) (string-match "<[^!]+>\\'" class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (substring class 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defun c++-get-class-name (class-name template-signature rename-arguments-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "Return a possibly, parameterized class identifier built from CLASS-NAME and TEMPLATE-SIGNATURE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 If RENAME-ARGUMENTS-FLAG is non-nil, template class argument names are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 normalized also to T1,T2,T3, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 TEMPLATE-SIGNATURE may be of any of the following forms:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 template <class T>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 template <class T1, class T2>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 <class T1, class T2>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 <int = 0>."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (cond ((null template-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ((stringp template-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (let ((types) (start 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (while (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 c++-template-parameter-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 template-signature start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (setq start (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 types (cons (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 template-signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (match-beginning c++-template-parameter-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (match-end c++-template-parameter-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (if (null types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (setq class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (format "%s<%s>" class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (mapconcat 'identity (nreverse types) ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (if rename-arguments-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (c++-normalize-template-arguments class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 class-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (t (error "(c++-get-class-name): Second argument, '%s', must be a string or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 template-signature))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (defun c++-normalize-class-match (rename-arguments-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 "After a regexp match to a class definition, return the matching class name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 Class name is normalized for use in OO-Browser lookups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 If RENAME-ARGUMENTS-FLAG is non-nil, template class argument names are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 normalized also to T1,T2,T3, etc."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (c++-get-class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (buffer-substring (match-beginning c++-class-def-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (match-end c++-class-def-name-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if (match-beginning c++-class-def-template-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (match-beginning c++-class-def-template-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (match-end c++-class-def-template-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 rename-arguments-flag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defun c++-normalize-template-arguments (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Return class with any template arguments renamed to <T> or <T1,T2,T3>."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (setq class (br-delete-space class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (cond ((not (string-match "[<,][ \t\n\^M]*[^,>]*[,>]" class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; No type parameters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; Some type parameter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ((= ?> (aref class (1- (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; Class has only one type parameter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (hypb:replace-match-string c++-template-parameter-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 class "<T>" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; Class has two or more type parameters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (let ((count 1) (start 0) before after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (while (string-match "[<,][ \t\n\^M]*[^,>]*" class start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (setq before (substring class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 0 (1+ (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 after (substring class (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (format "%sT%d%s" before count after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; class may have just shrunk, so don't use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; match-data from above string-match below here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 start (- (length class) (length after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 count (1+ count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defun c++-scan-parents ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "Return list of parents names from a C++ class definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 Point must be after the colon that begins the parent list and before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 first parent entry when this function is called."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (let ((parent-list) (again t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (while (and again (re-search-forward c++-parent-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq again (= ?, (preceding-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 parent (c++-get-parent-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (buffer-substring (match-beginning c++-parent-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (match-end c++-parent-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 parent-list (cons parent parent-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (nreverse parent-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun c++-get-parent-name (parent-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; We need to handle class definitions like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; template <class T> class PtrList : private List<type-name> {}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; where the parent class is an instantiation of a parameterized class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; For now, we change the type name to <T> or <T1,T2,T3> when there are 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; parameters, for purposes of class name matching.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; Test cases:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; (mapcar 'c++-get-parent-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; '("par <class _T1=myclass , class _T2 = you >" "parent"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; "class<_T1,T2>" "class< __me , int>" "" "<template>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; "par<_template>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; Should yield:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; ("par<T1,T2>" "parent" "class<T1,T2>" "class<T1,T2>" "" "<template>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; "par<T>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if (string-match "<\\(.\\|\n\\)+>\\'" parent-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (let ((parent (substring parent-name 0 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (template (substring parent-name (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (setq parent (hypb:replace-match-string "\\s " parent "" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 parent-name (c++-get-class-name parent template t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 parent-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defun c++-get-parents-from-source (filename class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 "Scan source in FILENAME and return list of parents of CLASS-NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Assume file existence has already been checked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (or (null class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (car (car (br-rassoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (cdr (c++-get-classes-from-source filename t)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defun c++-select-path (paths-htable-elt &optional feature-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 "Select proper pathname from PATHS-HTABLE-ELT based upon value of optional FEATURE-P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 Selection is between path of class definition and path for features associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 with the class."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (let ((elt (cdr paths-htable-elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (if (consp elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if feature-p (cdr elt) (car elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; Both paths are the same.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun c++-set-case (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "Return string TYPE identifier for use as a class name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (defun c++-set-case-type (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "Return string CLASS-NAME for use as a type identifier."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defun c++-to-class-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "Assuming point is at start of class, move to start of line after end of class."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (forward-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (error (progn (or (re-search-forward "^}" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (goto-char (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun c++-to-comments-begin ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "Skip back from current point past any preceding blank lines and comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 Presumes no \"/*\" strings are nested within multi-line comments."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (let ((opoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (while (progn (setq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; To previous line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (if (= 0 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; If begins with "//" or ends with "*/", then is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ((looking-at "[ \t]*\\(//\\|$\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ((looking-at ".*\\*/[ \t]*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; Avoid //*** single line comments here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (re-search-backward "\\(^\\|[^/]\\)/\\*" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ((looking-at "[ \t]*$"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; Skip past whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (beginning-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;;; Internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defconst c++-template-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 "\\(template[ \t\n\^M]*<[^>;.{}]+>[ \t\n\^M]*\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "Regexp matching a template class or element definition or declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 Entire expression is an optional match, so it may be added as a conditional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 expression to other regexps.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (defconst c++-class-name-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (concat "^[ \t]*" c++-template-prefix c++-class-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 "Regexp preceding the class name in a class definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defconst c++-comment-regexp "\\([ \t\n]*//.*[\n]\\)*[ \t\n]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defconst c++-class-name-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (concat c++-comment-regexp "\\([{:]\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 "Regexp following the class name in a class definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 Last character matched is either the colon preceding the list of class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 parents, or the curly brace beginning the class body definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (defconst c++-identifier-chars "_~<>a-zA-Z0-9"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 "String of chars and char ranges that may be used within a C++ or G++ identifier.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defconst c++-template-identifier-chars "_a-zA-Z0-9"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "String of chars and char ranges that may be used within a standard C++ template identifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 This excludes the template arguments.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defconst c++-return-type-chars "_<>a-zA-Z0-9"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "String of chars and char ranges that may be used within a C++ or G++ return type identifier.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;; Modified on 3/28/95 to handle C++ names with multiple template
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;; parameters, e.g. class<T1,T2,T3>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defconst c++-identifier (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "\\([_~<a-zA-Z][" c++-template-identifier-chars "]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 "[ \t\n\^M]*<[^>;{}]+[ \t\n\^M>]*>\\|[_~<a-zA-Z]["
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 c++-identifier-chars "]*\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "Regular expression matching a C++ or G++ identifier.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (defconst c++-class-def-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (concat c++-class-name-before c++-identifier c++-class-name-after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "Regular expression used to match to class definitions in source text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 Class name identifier is grouping 'c++-class-def-name-grpn'. Optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 class template parameter signature is grouping 'c++-class-def-template-grpn'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ':' derived class indicator begins grouping 'c++-class-def-derived-grpn,'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 unless the class is not derived, in which case this grouping begins with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 '{'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defconst c++-class-def-template-grpn 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defconst c++-class-def-name-grpn 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (defconst c++-class-def-derived-grpn 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defconst c++-lang-prefix "c++-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "Prefix string that starts \"br-c++.el\" symbol names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (defconst c++-parent-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (concat c++-comment-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 "\\(\\(public\\|private\\|protected\\|virtual\\)[ \t\n]+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 "\\(\\(public\\|private\\|protected\\|virtual\\)[ \t\n]+\\)?\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 c++-identifier c++-comment-regexp "[,{;]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 "Parent identifier is group 'c++-parent-name-grpn'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (defconst c++-parent-name-grpn 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defconst c++-template-parameter-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 "[< \t\n\^M]+\\([^=<> \t\n\^M]+\\)[ \t\n\^M]*\\(=[^,>]+\\)?[,>]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 "Regexp matching a single C++ <template> specifier argument name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 For example in 'template <class T, int size = 0>', there are two parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 names, 'T' and 'size'. The parameter name is grouping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 'c++-template-parameter-grpn'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defconst c++-template-parameter-grpn 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; Ellemtel C++ recommendations specify that inline definition files should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; use the suffix ".icc" and other people use ".I" for such files, so those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; suffixes are included here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (defconst c++-src-file-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 "[^.]\\.\\([ch]xx\\|[chCH][chpCHP]?[pP]?\\|icc\\|I\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "Regular expression matching a unique part of C++ source or header file name and no others.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defvar c++-children-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 "Htable whose elements are of the form: (LIST-OF-CHILD-CLASSES . CLASS-NAME).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 Used to traverse C++ inheritance graph. 'br-build-children-htable' builds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 this list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (defvar c++-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 Used to traverse C++ inheritance graph. 'br-build-parents-htable' builds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 this list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (defvar c++-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . FILE-PATH).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 FILE-PATH gives the location of classes found in LIST-OF-CLASS-NAMES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 'br-build-paths-htable' builds this list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (defvar c++-lib-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 Only classes from stable software libraries are used to build the list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (defvar c++-lib-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . FILE-PATH).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 FILE-PATH gives the location of classes found in LIST-OF-CLASS-NAMES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Only classes from stable software libraries are used to build the list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (defvar c++-sys-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 Only classes from systems that are likely to change are used to build the list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (defvar c++-sys-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 "Alist whose elements are of the form: (LIST-OF-CLASS-NAMES . FILE-PATH).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 FILE-PATH gives the location of classes found in LIST-OF-CLASS-NAMES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 Only classes from systems that are likely to change are used to build the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (defvar c++-lib-prev-search-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "Used to check if 'c++-lib-classes-htable' must be regenerated.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (defvar c++-sys-prev-search-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 "Used to check if 'c++-sys-classes-htable' must be regenerated.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defvar c++-env-spec nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 "Non-nil value means Environment specification has been given but not yet built.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 Nil means current Environment has been built, though it may still require updating.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (provide 'br-c++)