annotate lisp/oobr/br-c++-ft.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 4103f0995bd7
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++-ft.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: C++ OO-Browser class and member functions.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; ORG: Motorola Inc.
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: 03-Oct-90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; LAST-MOD: 5-May-95 at 15:59:53 by Bob Weiner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; Copyright (C) 1990-1995 Free Software Foundation, Inc.
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 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (require 'br-c++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar c++-cpp-include-dirs '("/usr/include/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 "*Ordered list of include directories by default searched by C preprocessor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 Each directory must end with a directory separator. See also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 'c++-include-dirs'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defvar c++-include-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "*Ordered list of directories to search for C++ include files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Each directory must end with a directory separator. Directories normally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 searched by the C++ pre-processor should be set instead in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 'c++-cpp-include-dirs'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Modified on 3/28/95 to handle C++ names with multiple template
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; parameters, e.g. class<T1,T2,T3>. Unfortunately for our pattern matcher,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; we also have to allow spaces within the template parameters section. We
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; consciously do not allow newlines within the parameters section to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; grabbing too much of the expression that follows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defconst c++-return-type-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (concat "[\[<a-zA-Z]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "[]" c++-template-identifier-chars "]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "\\(::[]" c++-template-identifier-chars "]+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "[ \t\n\^M]*<[" c++-return-type-chars " ,]+>[ \t\n\^M]*[*&]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "\\|[\[<a-zA-Z][]" c++-return-type-chars "]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 "\\(::[\[<a-zA-Z][]" c++-return-type-chars "]+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "[ \t\n\^M]*[*&]*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defconst c++-type-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (concat "\\(::\\|[\[<a-zA-Z][]" c++-template-identifier-chars "]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "[ \t\n\^M]*<[^>;{}]+>[ \t\n\^M]*[*&]*::"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 "\\|[\[<a-zA-Z][]" c++-identifier-chars "]*[ \t\n\^M]*[*&]*::\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defconst c++-type-tag-separator "@"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "String that separates a tag's type from its normalized definition form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 This should be a single character which is unchanged when quoted for use as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 literal in a regular expression.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defconst c++-tag-fields-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; The \\\\? below is necessary because we sometimes use this expression to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; test against a string that has ben regexp-quoted and some of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; characters in br-feature-type-regexp will then be preceded by \\.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (format "\\`\\([^%s \n]+\\)%s\\\\?\\(%s \\)\\([^%s\n]+\\)%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 c++-type-tag-separator c++-type-tag-separator br-feature-type-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 c++-type-tag-separator c++-type-tag-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 "Regexp matching the fields of a C++ feature tag line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Group 1 is the class of the feature. Group 2 is the prefix preceding the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 feature when displayed within a listing buffer. Group 3 is the feature name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 The feature definition signature begins at the end of the regexp match,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 i.e. (match-end 0), and goes to the end of the string or line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun c++-add-default-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; Add to 'system' class table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (if br-c-tags-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (c-add-default-classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; Even if this flag is nil, the Environment still contains C function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; tag entries, so add this default class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (br-add-class "[function]" br-null-path nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defun c++-member-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Prints whether entity at point is a C++ member definition or declaration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (let ((name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 "Is " (if (c++-feature-def-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (progn (setq name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (buffer-substring (match-beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 c++-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (match-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 c++-feature-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "not ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 "a def. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "Is " (if (and (c++-skip-to-statement) (c++-feature-decl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (progn (setq name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (buffer-substring (match-beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 c++-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (match-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 c++-feature-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "not ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 "a member decl. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (if name (concat " Name = " name)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defun c++-feature-implementors (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "Return unsorted list of C++ feature tags which implement feature NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 This includes classes which define the interface for NAME as a pure virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (c++-feature-matches (concat "^" (regexp-quote name) "$")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defun c++-feature-locate-p (feature-tag &optional regexp-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 "Leaves point at the start of FEATURE-TAG's definition in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 Assumes caller has moved point to the beginning of the buffer or to the point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 of desired search start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 Optional REGEXP-FLAG means FEATURE-TAG is a regular expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; Match to function definitions, not declarations, except for pure virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; functions and friends which are declared, not defined, and so end with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; ';'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; First move to the proper class implementation if feature-tag does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; include a <class>:: part and this is not a [default-class], so that if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; two classes in the same file have the same feature signature, we still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; end up at the right one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (if (string-match c++-tag-fields-regexp feature-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (let ((class (substring feature-tag (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (setq feature-tag (substring feature-tag (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (if regexp-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (if (not (string-match "\\`\\\\\\[\\|::" feature-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (re-search-forward (c++-class-definition-regexp class t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if (not (string-match "\\`\\[\\|::" feature-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (re-search-forward (c++-class-definition-regexp class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 nil t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (let ((found) (start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; Now look for feature expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (or regexp-flag (setq feature-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (c++-feature-signature-to-regexp feature-tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (while (and (re-search-forward feature-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq start (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (not (setq found (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (c-within-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (progn (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 t)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (progn (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (c++-to-comments-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (recenter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (defun c++-feature-name-to-regexp (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 "Converts routine NAME into a regular expression matching the routine's name tag."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (setq name (c++-feature-signature-to-regexp name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (aset name (1- (length name)) ?\() ;; Match only to functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun c++-feature-signature-to-name (signature &optional with-class for-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "Extracts the feature name from SIGNATURE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 The feature's class name is dropped from signature unless optional WITH-CLASS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 is non-nil. If optional FOR-DISPLAY is non-nil, a feature type character is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 prepended to the name for display in a browser listing."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (let ((name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; member
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ((string-match c++-tag-fields-regexp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (setq name (substring signature (match-beginning (if for-display 2 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (if with-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (setq name (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (substring signature (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 "::" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; Remove any trailing whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (br-delete-space name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; unknown
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (t ;; Remove any trailing whitespace and add display prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (setq name (br-delete-space signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if for-display (c++-feature-add-prefix name "" signature) name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun c++-feature-signature-to-regexp (signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Given a C++ SIGNATURE, return regexp used to match to its definition."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq signature (regexp-quote signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (let ((prefix-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if (string-match c++-tag-fields-regexp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (prog1 (substring signature (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (setq signature (substring signature (match-end 0)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (if (string-match "[^<>*& \t]+\\(<[^>]+>\\)::" signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; Method from a template class. Match to a method with the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; number of template parameters, regardless of parameter names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (let ((pre (substring signature 0 (match-beginning 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (mid (substring signature (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (post (substring signature (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (setq signature (concat pre (c++-template-args-regexp mid) post))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (let ((pat) (i 0) (c) (len (length signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (setq c (aref signature i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 pat (cond ((= c ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; Allow for possible single line comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;; following any whitespace, e.g. following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;; each routine argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (concat pat "[ \t\n\^M]*\\(//.*\\)?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (concat pat (char-to-string c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (setq pat (concat prefix-info pat)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (defun c++-feature-tree-command-p (class-or-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 "Display definition of CLASS-OR-SIGNATURE if a signature and return t, else return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (if (c++-routine-p class-or-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if (br-in-browser) (br-to-view-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (br-feature-found-p (br-feature-file class-or-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 class-or-signature))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun c++-list-features (class &optional indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 "Return sorted list of C++ feature tags lexically defined in CLASS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let ((obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (features)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (class-tag (concat "\n" class c++-type-tag-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 feature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (if (or (null indent) (<= indent 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; Include all features.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (while (search-forward class-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq features (cons (br-feature-current) features)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;; Omit friend features which are not inherited since indent > 2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (let ((friend-regexp (format "%s%% " c++-type-tag-separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (while (search-forward class-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (setq feature (br-feature-current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (or (string-match friend-regexp feature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq features (cons feature features))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (set-buffer obuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (c++-sort-features (nreverse features))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun c++-routine-p (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (string-match "([^\)]*)" str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun c++-scan-features ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "Return reverse ordered list of C++ routine definitions in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 Assume point is at beginning of widened buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (let ((routines) class name rout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (while (re-search-forward c++-routine-def nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (setq class ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 name (buffer-substring (match-beginning c++-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (match-end c++-feature-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; This code is very subtle but it does the right thing so don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; change it unless you know exactly what you are doing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if (not (match-beginning c++-feature-scope-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; This is a non-class function since we did not find a ::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; scoping operator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq class "[function]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; Is a member function, but this may set class = "" since prior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; regexp grouping may have grabbed the type. Be careful to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; handle this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (setq class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (match-beginning c++-feature-scope-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (- (match-end c++-feature-scope-grpn) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (and (string-equal class "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (match-beginning c++-feature-type-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (setq class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (match-beginning c++-feature-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (match-end c++-feature-type-grpn)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (setq rout (buffer-substring (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (if (c-within-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; Move point to precede feature opening brace or pure virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; function declaration semicolon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (= (following-char) ?\{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; Move to end of feature but ignore any error if braces are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; unbalanced. Let the compiler tell the user about this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; Ignore matches to class constructs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (if (string-match c++-class-name-before rout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (setq rout (c++-feature-normalize rout class name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 routines (cons rout routines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 routines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (defun c++-sort-features (routine-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (sort routine-list 'c++-feature-lessp))
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++-to-definition (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "If point is within a declaration, try to move to its definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 With OTHER-WIN non-nil, show it in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ((c++-include-file other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ((br-check-for-class (c++-class-decl-p) other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ((c++-feature other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ((and (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (br-check-for-class (c++-find-class-name) other-win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (t (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "(OO-Browser): Select a C++ declaration to move to its definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defun c++-class-decl-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 "Return nil unless point is within a class declaration, referenced by another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 class. Commented declarations also return nil. When value is non-nil, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 the class name from the declaration. Leave point at start of statement for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 visual clarity."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (c++-skip-to-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (let ((class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (and (looking-at c++-class-decl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (setq class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (match-beginning c++-class-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (match-end c++-class-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if (match-beginning c++-decl-template-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (setq class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (c++-get-class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (match-beginning c++-decl-template-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (match-end c++-decl-template-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (not (c-within-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (not (looking-at "[ \t]*//")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (defun c++-feature (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 "Move point to definition of member given by declaration at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 Return nil if point is not within a member declaration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;; If '{' follows the feature declaration, then feature is defined right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;; here, within the class definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (let ((feature-def) (ftr) (class) (ftr-pat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (cond ((c++-feature-def-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (recenter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ((c++-view-friend other-win t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;; Now look for feature definition in code (non-header) files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ((progn (setq feature-def (c++-feature-def-pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ftr (car (cdr (cdr feature-def)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 class (car (cdr feature-def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ftr-pat (car feature-def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (c++-locate-feature ftr class ftr-pat other-win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ((c++-feature-decl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (message "(OO-Browser): '%s' feature definition not found." ftr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (defun c++-view-friend (&optional other-win sig-at-point-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 "With point on a friend listing entry, view its source code definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 With optional OTHER-WIN non-nil, display in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 With optional SIG-AT-POINT-FLAG non-nil, assume point is within a friend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 signature in a source buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (let ((tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (if (not sig-at-point-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (br-feature-get-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (and (looking-at c++-friend-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (looking-at c++-friend-in-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (let ((friend (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (class (c++-get-class-name-from-source)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (c++-feature-normalize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 friend class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (c++-feature-signature-to-name friend) t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (cond ((or (null tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;; Not a friend entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (/= ?% (aref (c++-feature-signature-to-name tag nil t) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ((= ?\{ (aref tag (1- (length tag))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;; Friend is defined where declared.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (br-feature nil 'view tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ((string-match (format " class \\(%s\\) ?;$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 c++-return-type-identifier) tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; friend class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (br-view nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (c++-normalize-template-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (substring tag (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (if sig-at-point-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 nil ;; Other feature location code will handle this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (br-feature nil t tag) ;; Move point to friend declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (c++-feature other-win))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defun c++-feature-add-prefix (feature-name class signature &optional friend-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 "Add a browser listing display prefix to FEATURE-NAME from CLASS based on feature's SIGNATURE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (concat (cond (friend-flag "% ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ((string-match c++-pure-virtual-function-regexp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 "> ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ((or (= ?~ (aref feature-name 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (equal feature-name (c++-class-non-template-name class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (br-member feature-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 '("operator new" "operator delete")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 "+ ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (t "- "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 feature-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (defun c++-feature-decl ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if (looking-at c++-class-decl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (looking-at c++-feature-decl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defun c++-feature-def-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 "Return nil unless point is within a member definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Commented member definitions also return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Leaves point at start of statement for visual clarity."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (c++-skip-to-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (and (not (c-within-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (save-excursion (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (not (looking-at "[ \t]*//")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (not (looking-at c++-class-decl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (looking-at (concat c++-at-feature-regexp "[{;,]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (let ((end-punct))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (or (= ?{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (setq end-punct (save-excursion (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (preceding-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;; If ends with a '[;,]' then must not have func parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; nor simply be a scoped name in order to be a def.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;; If it begins with 'virtual', ends with "= 0" and has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; parens, then is a deferred virtual function declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (if (match-end c++-feature-parens-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (narrow-to-region (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (if (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "\\(^\\|[ \t]+\\)virtual[ \t].*=[ \t]*0[ \t]*[,;]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (progn (message "(OO-Browser): Pure virtual function, definition deferred to descendants.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (or (null (match-end c++-feature-scope-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (not (equal (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (match-beginning c++-feature-scope-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (match-end c++-feature-name-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (char-to-string end-punct))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (match-end 0)))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun c++-feature-def-pat ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 "Return (list <feature-def-pat> <feature-class> <feature-name>) associated with declaration at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (and (c++-skip-to-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (c++-feature-decl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; Don't regexp-quote member-name yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (let* ((member-name (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (match-beginning c++-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (match-end c++-feature-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (member-modifiers (if (match-end c++-feature-mod-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (br-quote-match c++-feature-mod-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (scoped-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (member-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (concat (and (match-end c++-feature-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; Handle possible regexp bug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (match-beginning c++-feature-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (match-beginning c++-feature-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (concat (br-quote-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 c++-feature-type-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (if (match-end c++-feature-scope-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (progn (setq scoped-name t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (match-beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 c++-feature-scope-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (- (match-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 c++-feature-scope-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (if (equal class "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (setq class nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (func-args (if (match-end c++-feature-parens-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (cons (match-beginning c++-feature-parens-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (match-end c++-feature-parens-grpn))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (base-cl-args (match-end c++-feature-parens-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (friend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (and member-type (string-match "[ \t]+$" member-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (setq member-type (substring member-type 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;; Allow for different whitespace between declaration and definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;; when * or & is part of name and/or type, e.g. "char* id" and "char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; *id".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (if (and (stringp member-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (string-match "[*&]+$" member-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (setq member-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (concat (substring member-type 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 "[ \t\n]*" (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (substring member-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (match-beginning 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (if (string-match "^[*&]+" member-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (setq member-name (substring member-name (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 member-type (concat member-type "[ \t\n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (substring member-name 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 "[ \t\n]*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (and (stringp member-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (not (equal member-type ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (setq member-type (concat member-type "[ \t\n]*"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (let ((pre-member-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 c++-template-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 "\\(\\(auto\\|inline\\|overload\\|static\\|virtual\\)[ \t\n]+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (if member-modifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (let ((def-mods "") (mod))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (while (string-match "\\([a-z]+\\)[ \t\n]+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 member-modifiers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (setq mod (substring member-modifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 member-modifiers (substring member-modifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (if (not friend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (setq friend (string-equal mod "friend")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (if (equal (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 c++-type-def-modifier mod) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (setq def-mods (concat def-mods "\\(" mod
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 "[ \t\n]+\\)?"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 def-mods))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (if (equal (string-match "virtual" member-type) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 nil member-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (post-member-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 ;; Point at beginning of line may imply a non-member func.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (if (or scoped-name (not (bolp))) "::")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (progn (cond (scoped-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (friend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (if member-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (setq class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (string-match c++-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 member-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (if class (setq class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 member-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (match-end 0))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;; Class name is not part of declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ;; nor a 'friend' declaration, so look
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; for declaration within a class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; definition and locate the class name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;; If not within a class, assume
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ;; declaration is global.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (setq class (c++-get-class-name-from-source))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (br-regexp-quote member-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 "[ \t\n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (if func-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (concat "\\(" (c++-func-args-regexp func-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 "\\|" (c++-func-args-string func-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; If is a constructor member function, then can have some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; arguments for base class constructors after a ':'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ;; but preceding the '{'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 "[ \t\n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (and base-cl-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (equal member-name class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 "\\(:[^;{}]*\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 c++-comment-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (` (lambda (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (concat "^" (br-regexp-quote class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (, (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 c++-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 br-feature-type-regexp " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (br-regexp-quote member-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 c++-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 pre-member-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (br-regexp-quote class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (, post-member-regexp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 class member-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (defun c++-feature-lessp (routine1 routine2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (string-lessp (c++-feature-signature-to-name routine1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (c++-feature-signature-to-name routine2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (defun c++-feature-matches (regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 "Return an unsorted list of feature tags whose names match in part or whole to REGEXP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;; Ensure match to feature names only; also handle "^" and "$" meta-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (setq regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (concat (format "^[^%s \n]+%s%s "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 c++-type-tag-separator c++-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 br-feature-type-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (if (equal (substring regexp 0 1) "^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (progn (setq regexp (substring regexp 1)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 c++-identifier-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (if (equal (substring regexp -1) "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (substring regexp 0 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (concat regexp c++-identifier-chars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 c++-type-tag-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (let ((features))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (while (re-search-forward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (setq features (cons (br-feature-current) features)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 features)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (defun c++-feature-normalize (routine class name &optional friend-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (setq class (br-delete-space class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 name (c++-feature-add-prefix name class routine friend-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 routine (concat class c++-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 name c++-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (br-delete-space routine)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (let* ((len (length routine))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (normal-feature (make-string len ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (n 0) (i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (space-list '(?\ ?\t ?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (space-regexp "[ \t\n\^M]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 chr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (setq chr (aref routine i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; Convert sequences of space characters to a single space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ((memq chr space-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (aset normal-feature n ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (string-match space-regexp routine i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (setq i (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq i (1+ i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 n (1+ n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; Remove // style comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ((and (= chr ?/)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (< (1+ i) len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (= (aref routine (1+ i)) ?/))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (setq i (+ i 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (while (and (< i len) (/= (aref routine i) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (t ;; Normal character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (aset normal-feature n chr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (setq i (1+ i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 n (1+ n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (substring normal-feature 0 n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (defun c++-feature-tag-class (signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 "Extract the class name from SIGNATURE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (cond ((string-match c++-type-tag-separator signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (substring signature 0 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 ((string-match "\\([^ \t]+\\)::" signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (substring signature (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (t "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (defun c++-feature-tags-lookup (class-list ftr-pat &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 "Display routine definition derived from CLASS-LIST, matching FTR-PAT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 Use routine tags table to locate a match. Caller must use 'set-buffer'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 to restore prior buffer when a match is not found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (let ((classes class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (found-ftr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (ftr-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (ftr-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (if (or (null class-list) (equal class-list '(nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (while (and (not found-ftr) classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (setq class (car classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 ftr-regexp (funcall ftr-pat class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ftr-path (br-feature-def-file ftr-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 found-ftr (if ftr-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (br-edit-feature (br-feature-current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 ftr-path other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 classes (if found-ftr nil (cdr classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (if found-ftr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (or class t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (c++-feature-tags-lookup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (apply 'append (mapcar (function (lambda (cl) (br-get-parents cl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 class-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ftr-pat)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (defun c++-files-with-source (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 "Use CLASS to compute set of files that match to a C++ source file regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 Return as a list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (let ((file (if class (br-class-path class) buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (and file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (let* ((src-file-regexp (concat "^" (br-filename-head file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 c++-code-file-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (dir (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (files (directory-files dir nil src-file-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (mapcar (function (lambda (f) (concat dir f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 files)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (defun c++-find-ancestors-feature (class-list ftr-pat &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 "Scan ancestors of CLASS-LIST and show routine definition matching FTR-PAT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;; If no class, search for non-member function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (or class-list (setq class-list '(nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (let ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (if (and br-feature-tags-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (file-exists-p br-feature-tags-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (file-readable-p br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (c++-feature-tags-lookup class-list ftr-pat other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; Only works if features are in same directory as class def.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (c++-scan-ancestors-feature class-list ftr-pat other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (set-buffer obuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (defun c++-find-class-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 "Return current word as a potential class name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (let* ((start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (ignore "\]\[ \t\n;,.\(\){}*&-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (pat (concat "^" ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (skip-chars-backward ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (skip-chars-backward pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (skip-chars-forward (concat pat ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (buffer-substring start (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (defun c++-func-args-regexp (func-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (let* ((space "\\\\\\s-*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (tmp-buf-nm "*br-c++-tmp*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (tmp-buf (progn (if (get-buffer tmp-buf-nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (kill-buffer tmp-buf-nm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (get-buffer-create tmp-buf-nm))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (or tmp-buf (error "OO-Browser: (c++-func-args-regexp) - Can't create tmp-buf."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 ;; Fill tmp-buffer with all func-args, including parens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (copy-to-buffer tmp-buf (car func-args) (cdr func-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (set-buffer tmp-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (let ((quoted-args (br-regexp-quote (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (insert quoted-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (if (looking-at "(\\s-*)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (replace-match "(\\\\s-*)" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ;; Replace all "\( +" with "\(" temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (br-buffer-replace "\\(^\\|[^\\]\\)\([ \t\n]+" "\\1\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 ;; Replace all "+ \)" with "\)" temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (br-buffer-replace "[ \t\n]+\)" "\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 ;; Replace all "...\)" with "...@" temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (br-buffer-replace "\\\\\\.\\\\\\.\\\\\\.\)" "@@@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ;; Optionalize right hand side of argument assignments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (br-buffer-replace "\\([^=,\( \t\n]+\\)\\([ \t\n]*=[^,\)]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (concat "\\1\\\\( "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (br-regexp-quote c++-arg-identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 "\\\\)? \\\\(\\2\\\\)?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ;; Replace all "\)" with "optional <c++-identifier> \)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (br-buffer-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 "\\([\(,][^=\)]+\\)\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (concat "\\1\\\\( " (br-regexp-quote c++-arg-identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 "\\\\)?\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ;; Replace all "," with "optional <c++-identifier>,"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (br-buffer-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 "\\([\(,][^=,]+\\),"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (concat "\\1\\\\( " (br-regexp-quote c++-arg-identifier) "\\\\)?,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ;; Replace all " *, *" with "<spc>,<spc>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (br-buffer-replace "[ \t\n]*,[ \t\n]*" (concat space "," space))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;; Replace all " +" with "<spc>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (br-buffer-replace "[ \t\n]+" space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 ;; Replace all "\(" with "\(<spc>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (br-buffer-replace "\\(^\\|[^\\]\\)\(" (concat "\\1\(" space))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;; Replace all "\)" with "<spc>\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (br-buffer-replace "\\([^\\]\\)\)" (concat "\\1" space "\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; Replace all & and quoted \\* with "<spc>[*&]+<spc>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (br-buffer-replace "\\(&\\|\\\\\\*\\)+" (concat space "\\1" space))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 ;; Replace all "<spc>" with "[ \t\n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (br-buffer-replace "\\\\s-\\*" "[ \t\n]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 ;; Replace all "@@@" with any # of args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (br-buffer-replace "@@@" "[^\)]*\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;; Return final buffer as a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (prog1 (buffer-substring (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (kill-buffer tmp-buf-nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (set-buffer obuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (defun c++-func-args-string (func-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (let* ((space "\\\\\\s-*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (tmp-buf-nm "*br-c++-tmp*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (tmp-buf (progn (if (get-buffer tmp-buf-nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (kill-buffer tmp-buf-nm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (get-buffer-create tmp-buf-nm))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (or tmp-buf (error "OO-Browser: (c++-func-args-string) - Can't create tmp-buf."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ;; Fill tmp-buffer with all func-args, including parens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (copy-to-buffer tmp-buf (car func-args) (cdr func-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (set-buffer tmp-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (let ((quoted-args (br-regexp-quote (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (insert quoted-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (if (looking-at "(\\s-*)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (replace-match "(\\\\s-*)" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; Replace all "\( +" with "\(" temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (br-buffer-replace "\\(^\\|[^\\]\\)\([ \t\n]+" "\\1\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;; Replace all "+ \)" with "\)" temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (br-buffer-replace "[ \t\n]+\)" "\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ;; Replace all "...\)" with "@@@" temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (br-buffer-replace "\\\\\\.\\\\\\.\\\\\\.\)" "@@@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ;; Optionalize right hand side of argument assignments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (br-buffer-replace "\\([^=,\( \t\n]+\\)\\([ \t\n]+=[^,\)]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (concat "\\1\\\\(\\2\\\\)?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 ;; If an arg consists of 2 or more words, replace last with <identifier>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (br-buffer-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 "\\([\(,][^=,\)]*[^ \t\n=,\)]+[ \t\n]+\\)[^ \t\n=,\)]+\\([ \t\n]*[,\)]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (concat "\\1" (br-regexp-quote c++-arg-identifier) "\\2"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;; If an arg consists of only 1 word, add a second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (br-buffer-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 "\\([\(,][ \t\n]*\\)\\([^ \t\n=,\)]+\\)\\([ \t\n]*[,\)]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (concat "\\1\\2 " (br-regexp-quote c++-arg-identifier) "\\3"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;; Replace all " *, *" with "<spc>,<spc>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (br-buffer-replace "[ \t\n]*,[ \t\n]*" (concat space "," space))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ;; Replace all " +" with "<spc>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (br-buffer-replace "[ \t\n]+" space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; Replace all "\(" with "\(<spc>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (br-buffer-replace "\\(^\\|[^\\]\\)\(" (concat "\\1\(" space))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ;; Replace all "\)" with "<spc>\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (br-buffer-replace "\\([^\\]\\)\)" (concat "\\1" space "\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;; Replace all & and quoted \\* with "<spc>[*&]+<spc>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (br-buffer-replace "\\(&\\|\\\\\\*\\)+" (concat space "\\1" space))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 ;; Replace all "<spc>" with "[ \t\n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (br-buffer-replace "\\\\s-\\*" "[ \t\n]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;; Replace all "@@@" with any # of args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (br-buffer-replace "@@@" "[^\)]*\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;; Return final buffer as a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (prog1 (buffer-substring (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (kill-buffer tmp-buf-nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (set-buffer obuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (defun c++-get-class-name-from-source ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 "Return class name from closest class definition preceding point or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (let ((opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (if (re-search-backward c++-class-def-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (progn (goto-char (match-beginning c++-class-def-derived-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (setq class (c++-normalize-class-match nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;; Ensure that declaration occurs within class definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (forward-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (and (> (point) opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 class))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (defun c++-get-feature-tags (routine-file &optional routine-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 "Scan C++ ROUTINE-FILE and hold routine tags in 'br-feature-tags-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 Assume ROUTINE-FILE has already been read into a buffer and that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 'br-feature-tags-init' has been called. Optional ROUTINE-LIST can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 provided so that a non-standard scan function can be used before calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 this function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (let ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (or routine-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (setq routine-list (c++-sort-features (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (c++-scan-features)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;; Delete any prior routine tags associated with routine-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (if (search-forward routine-file nil 'end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (progn (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (search-forward "\^L" nil 'end 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (delete-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (if routine-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (progn (insert "\^L\n" routine-file "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (mapcar (function (lambda (tag) (insert tag "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 routine-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (set-buffer obuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (defun c++-include-file (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 "If point is on an include file line, try to display file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 Return non-nil iff an include file line, even if file is not found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 Look for include file in 'c++-cpp-include-dirs' and in directory list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 'c++-include-dirs'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (if (looking-at c++-include-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (let ((incl-type (string-to-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (1+ (match-beginning 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (file (buffer-substring (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (dir-list c++-include-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (setq dir-list (if (= incl-type ?<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (append dir-list c++-cpp-include-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (cons (file-name-directory buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 dir-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (while dir-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (setq path (concat (car dir-list) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 dir-list (if (setq found (file-exists-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (cdr dir-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;; If not found in normal include dirs, check all Env paths also.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (if (not found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (let ((paths (delq nil (hash-map 'cdr br-paths-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (while paths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (setq path (car paths))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (if (string-equal (file-name-nondirectory path) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (setq found t paths nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (setq paths (cdr paths))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 ;; If found, display file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (if (file-readable-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (funcall br-edit-file-function path other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (if (not (fboundp 'br-lang-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (c++-mode-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (br-major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (message "(OO-Browser): Include file '%s' unreadable." path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (message "(OO-Browser): Include file '%s' not found." file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (defun c++-locate-feature (ftr class ftr-pat &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;; 'class' may = nil, implying non-member function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (or class (setq class "[function]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (let ((def-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (if (and ftr-pat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (setq def-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (c++-find-ancestors-feature (list class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 ftr-pat other-win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (progn (if (and class (not (equal class def-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 "Member `%s` of class '%s' inherited from class '%s'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ftr class def-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (defun c++-scan-ancestors-feature (class-list ftr-pat &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 "Display routine definition derived from CLASS-LIST, matching FTR-PAT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 Scan files with same base name as class file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (let ((classes class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (found-ftr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (code-def-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (ftr-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (if (null class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (while (and (not found-ftr) classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (setq class (car classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 code-def-files (c++-files-with-source class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ftr-regexp (funcall ftr-pat class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (while (and (setq file (car code-def-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (not (setq found-ftr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (br-feature-found-p file ftr-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 nil other-win t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (setq code-def-files (cdr code-def-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (setq classes (if found-ftr nil (cdr classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (if found-ftr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (or class t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (c++-scan-ancestors-feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (apply 'append (mapcar (function (lambda (cl) (br-get-parents cl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 class-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ftr-pat)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (defun c++-scan-features-in-class (class start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 "Return reverse ordered list of C++ routine definitions within CLASS def.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 START and END give buffer region to search."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (setq class (br-delete-space class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (let ((routines) rout name type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ;; Get member definitions and pure virtual declarations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (while (re-search-forward c++-routine-def-in-class nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (setq start (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 name (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (match-beginning c++-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (match-end c++-feature-name-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 type (if (match-beginning c++-feature-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (match-beginning c++-feature-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (match-end c++-feature-type-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 rout (buffer-substring (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 ;; Do this after done getting groupings from the search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 type (if type (br-delete-space type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 ;; This is necessary to remove a possible double expression match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 ;; where there is a blank line within the match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (if (string-match "[\n\^M]\\([ \t]*[\n\^M]\\)+" rout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (progn (setq rout (substring rout (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (goto-char (+ start (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (if (c-within-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 ;; Move point to precede feature opening brace or pure virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 ;; function declaration semicolon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (if (= (following-char) ?\{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;; Move to end of feature but ignore any error if braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 ;; are unbalanced. Let the compiler tell the user about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 ;; this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (if (string-match c++-friend-regexp rout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 ;; skip friends until later
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 ;; Handle type conversion ops: operator int() { return i; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (if (equal type "operator") (setq name (concat type " " name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 type nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (setq rout (c++-feature-normalize rout class name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 routines (cons rout routines))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 ;; Get friend declarations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (while (re-search-forward c++-friend-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (if (not (looking-at c++-friend-in-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (setq start (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 name (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (match-beginning c++-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (match-end c++-feature-name-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 type (if (match-beginning c++-feature-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (match-beginning c++-feature-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (match-end c++-feature-type-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 rout (buffer-substring (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 ;; Do this after done getting groupings from the search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 type (if type (br-delete-space type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 ;; This is necessary to remove a possible double expression match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 ;; where there is a blank line within the match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (if (string-match "[\n\^M]\\([ \t]*[\n\^M]\\)+" rout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (progn (setq rout (substring rout (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (goto-char (+ start (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (if (c-within-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 ;; Handle type conversion ops: operator int() { return i; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (if (equal type "operator") (setq name (concat type " " name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 type nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (setq rout (c++-feature-normalize rout class name t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 routines (cons rout routines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;; Move to next entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (or (= (forward-line 1) 0) (end-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 routines))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (defun c++-skip-past-comments ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 "Skip over comments immediately following point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (cond ((looking-at "//")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (equal (forward-line 1) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 ((looking-at "/\\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (re-search-forward "\\*/" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (defun c++-skip-to-statement ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (if (re-search-backward "\\(^\\|[;{}]\\)[ \t]*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (progn (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (defconst c++-code-file-regexp "\\.\\(cxx\\|[cC][cC]?P?\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 "Regular expression matching a unique part of C++ source (non-header) file name and no others.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (defconst c++-include-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 "[ \t/*]*#[ \t]*include[ \t]+\\([\"<]\\)\\([^\">]+\\)[\">]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 "Regexp to match to C++ include file lines. File name is grouping 2. Type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 of include, user-specified via double quote, or system-related starting with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 '<' is given by grouping 1.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (defconst c++-type-def-modifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 "\\(auto\\|const\\|inline\\|mutable\\|register\\|static\\|typedef\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (defconst c++-type-modifier-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (concat "\\(\\(auto\\|const\\|explicit\\|extern[ \t\n\^M]+\"[^\"]+\"\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 "extern\\|friend\\|inline\\|mutable\\|overload\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 "register\\|static\\|typedef\\|virtual\\)[ \t\n\^M]+\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (defconst c++-member-modifier-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 "\\(\\([ \t\n\^M]+const\\|[ \t\n\^M]+mutable\\)?\\([ \t\n\^M]*[=:][^;{]+\\)?\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (defconst c++-type-identifier-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 ;; It is critical that the final part of this expression, [*& \t\n\^M]+,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 ;; stay exactly as it is or certain feature definitions may be missed or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 ;; segmented improperly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 ;; If you remove the '*&', "Int &operator=(int j) {}", will not be found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 ;; because the & will be missed. If you change the '+' to a '*', "main()"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 ;; will show up as "- n" in listing buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (concat "\\(\\(" c++-return-type-identifier "\\)[*& \t\n\^M]+\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (defconst c++-function-identifier (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 "[_~<a-zA-Z][^][ \t:;.,~{}()]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 "Regular expression matching a C++ or G++ function name.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 ;; Old def = "operator[ \t]*[^]) \t:;.,?~{}][^[( \t:;.,~^!|?{}]?[=*]?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 ;; Final optional expression is to handle new C++ array operators, e.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;; void operator delete [] (void*);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (defconst c++-operator-identifier "operator[ \t\n\^M]*[^ \t\n\^M:;.,?~{}]+\\([ \t\n\^M]*\\[\\]\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 "Regular expression matching a C++ or G++ operator name.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (defconst c++-feature-decl-or-def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (concat c++-template-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 "\\(" c++-type-modifier-keyword "*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 c++-type-identifier-group "\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 "\\(" c++-type-identifier "[ \t\n\^M]*\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 "\\(" c++-operator-identifier "\\|" c++-function-identifier "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 "[*&]?" c++-identifier "\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; This old version of the next line matched to things such as:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;; enum name {};. Since we don't deal with attributes yet and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;; since such matches improperly end up in the [function] default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ;; class, we only accept matches with () in them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;; "[ \t\n\^M]*\\(\\[[^{;]+\\|([^{;]*)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 "[ \t\n\^M]*\\(([^{;]*)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 c++-member-modifier-keyword "?\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 "Regexp matching a C++ member declaration or definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 Member modifier keywords are grouped expression 'c++-feature-mode-grpn'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 Member type is grouped expression 'c++-feature-type-grpn', unless scoping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 type name, grouped expression 'c++-feature-scope-grpn' is non-nil, in which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 case, grouping 'c++-feature-scope-grpn' is the type plus \"::\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 Member name is group 'c++-feature-name-grpn'. Function parentheses, if any,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 are group 'c++-feature-parens-grpn'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (defconst c++-feature-mod-grpn 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (defconst c++-feature-type-grpn 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (defconst c++-feature-scope-grpn 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (defconst c++-feature-name-grpn 11)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (defconst c++-feature-parens-grpn 14)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (defconst c++-at-feature-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (concat c++-feature-decl-or-def c++-comment-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 "See documentation of 'c++-feature-decl-or-def' for grouping expressions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (defconst c++-feature-decl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (concat c++-at-feature-regexp ";")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 "See documentation of 'c++-feature-decl-or-def' for grouping expressions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (defconst c++-friend-in-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (concat "[ \t]*" c++-at-feature-regexp "[{;]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 "See documentation of 'c++-feature-decl-or-def' for grouping expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 This doesn't limit matches to friends. See 'c++-friend-regexp' for that.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (defconst c++-friend-regexp "^[^(){}\n\^M]*[ \t]friend[ \t\n\^M]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 "Regexp matching a C++ friend declaration or definition at the start of a line or the start of a string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (defconst c++-routine-def-terminator-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 ;; Also matches to pure virtual function declarations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 "\\({\\|[ \t\n\^M]*=[ \t]*0[ \t]*;\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (defconst c++-routine-def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (concat "^" c++-at-feature-regexp c++-routine-def-terminator-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 "See documentation of 'c++-feature-decl-or-def' for grouping expressions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (defconst c++-routine-def-in-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (concat "^[ \t]*" c++-at-feature-regexp c++-routine-def-terminator-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 "See documentation of 'c++-feature-decl-or-def' for grouping expressions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (defconst c++-class-modifier-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 "\\(\\(friend\\|public\\|protected\\)[ \t\n\^M]+\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (defconst c++-class-decl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (concat c++-class-modifier-keyword "?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 c++-template-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 c++-class-keyword c++-identifier "[ \t]*[;,]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 "Regexp matching a C++ class declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 Template match, if any, is grouping 'c++-decl-template-grpn'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 Class name is grouping 'c++-class-name-grpn'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (defconst c++-decl-template-grpn 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (defconst c++-class-name-grpn 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (defconst c++-arg-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (concat "[_a-zA-Z][" c++-identifier-chars "]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 "Regular expression matching a C++ or G++ function argument identifier.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (defconst c++-pure-virtual-function-regexp "\)[^=]*=[ \t]*0[ \t]*;\\'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 "Regexp matching the trailing part of a C++ pure virtual function signature.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (provide 'br-c++-ft)