annotate lisp/oobr/br-c++-ft.el @ 134:34a5b81f86ba r20-2b1

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