;;; semantic/bovine/c.el --- Semantic details for C
;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;; 2008, 2009 Free Software Foundation, Inc.
+;; 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
(defcustom-mode-local-semantic-dependency-system-include-path
c-mode semantic-c-dependency-system-include-path
'("/usr/include")
- "The system include path used by the C langauge.")
+ "The system include path used by the C language.")
(defcustom semantic-default-c-path nil
"Default set of include paths for C code.
)
(defcustom semantic-c-member-of-autocast 't
- "Non-nil means classes with a '->' operator will cast to it's return type.
+ "Non-nil means classes with a '->' operator will cast to its return type.
For Examples:
(define-lex-spp-macro-declaration-analyzer semantic-lex-cpp-define
"A #define of a symbol with some value.
Record the symbol in the semantic preprocessor.
-Return the the defined symbol as a special spp lex token."
+Return the defined symbol as a special spp lex token."
"^\\s-*#\\s-*define\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" 1
(goto-char (match-end 0))
(skip-chars-forward " \t")
(define-lex-spp-macro-undeclaration-analyzer semantic-lex-cpp-undef
"A #undef of a symbol.
Remove the symbol from the semantic preprocessor.
-Return the the defined symbol as a special spp lex token."
+Return the defined symbol as a special spp lex token."
"^\\s-*#\\s-*undef\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" 1)
\f
the second namespace in use, then it should not be included.
If you are having problems with smart completion and STL templates,
-it may that this is set incorrectly. After changing the value
+it may be that this is set incorrectly. After changing the value
of this flag, you will need to delete any semanticdb cache files
that may have been incorrectly parsed."
:group 'semantic
(define-mode-local-override semantic-parse-region c-mode
(start end &optional nonterminal depth returnonerror)
- "Calls 'semantic-parse-region-default', except in a macro expansion.
+ "Calls `semantic-parse-region-default', except in a macro expansion.
MACRO expansion mode is handled through the nature of Emacs's non-lexical
binding of variables.
START, END, NONTERMINAL, DEPTH, and RETURNONERRORS are the same
(symtext (semantic-lex-token-text lexicaltoken))
(macros (get-text-property 0 'macros symtext))
)
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(erase-buffer)
(when (not (eq major-mode mode))
(save-match-data
;; Protect against user hooks throwing errors.
(condition-case nil
(funcall mode)
- (error nil))
-
- ;; Hack in mode-local
- (activate-mode-local-bindings)
- ;; CHEATER! The following 3 lines are from
- ;; `semantic-new-buffer-fcn', but we don't want to turn
- ;; on all the other annoying modes for this little task.
- (setq semantic-new-buffer-fcn-was-run t)
- (semantic-lex-init)
- (semantic-clear-toplevel-cache)
- (remove-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook
- t)
- ))
+ (error
+ (if (y-or-n-p
+ (format "There was an error initializing %s in buffer \"%s\". Debug your hooks? "
+ mode (buffer-name)))
+ (semantic-c-debug-mode-init mode)
+ (message "Macro parsing state may be broken...")
+ (sit-for 1))))
+ ) ; save match data
+
+ ;; Hack in mode-local
+ (activate-mode-local-bindings)
+ ;; CHEATER! The following 3 lines are from
+ ;; `semantic-new-buffer-fcn', but we don't want to turn
+ ;; on all the other annoying modes for this little task.
+ (setq semantic-new-buffer-fcn-was-run t)
+ (semantic-lex-init)
+ (semantic-clear-toplevel-cache)
+ (remove-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook
+ t)
+ )
;; Get the macro symbol table right.
(setq semantic-lex-spp-dynamic-macro-symbol-obarray spp-syms)
;; (message "%S" macros)
)
stream))
+(defvar semantic-c-debug-mode-init-last-mode nil
+ "The most recent mode needing debugging.")
+
+(defun semantic-c-debug-mode-init (mm)
+ "Debug mode init for major mode MM after we're done parsing now."
+ (interactive (list semantic-c-debug-mode-init-last-mode))
+ (if (called-interactively-p 'interactive)
+ ;; Do the debug.
+ (progn
+ (switch-to-buffer (get-buffer-create "*MODE HACK TEST*"))
+ (let ((debug-on-error t))
+ (funcall mm)))
+
+ ;; Notify about the debug
+ (setq semantic-c-debug-mode-init-last-mode mm)
+
+ (add-hook 'post-command-hook 'semantic-c-debug-mode-init-pch)))
+
+(defun semantic-c-debug-mode-init-pch ()
+ "Notify user about needing to debug their major mode hooks."
+ (let ((mm semantic-c-debug-mode-init-last-mode))
+ (switch-to-buffer-other-window
+ (get-buffer-create "*MODE HACK TEST*"))
+ (erase-buffer)
+ (insert "A failure occurred while parsing your buffers.
+
+The failure occurred while attempting to initialize " (symbol-name mm) " in a
+buffer not associated with a file. To debug this problem, type
+
+M-x semantic-c-debug-mode-init
+
+now.
+")
+ (remove-hook 'post-command-hook 'semantic-c-debug-mode-init-pch)))
+
(defun semantic-expand-c-tag (tag)
"Expand TAG into a list of equivalent tags, or nil."
(let ((return-list nil)
"At parse time, assign a class or struct name text here.
It is picked up by `semantic-c-reconstitute-token' to determine
if something is a constructor. Value should be:
- ( TYPENAME . TYPEOFTYPE)
+ (TYPENAME . TYPEOFTYPE)
where typename is the name of the type, and typeoftype is \"class\"
or \"struct\".")
(define-mode-local-override semantic-format-tag-uml-prototype
c-mode (token &optional parent color)
- "Return an uml string describing TOKEN for C and C++.
+ "Return an UML string describing TOKEN for C and C++.
Optional PARENT and COLOR as specified with
`semantic-abbreviate-tag-default'."
;; If we have special template things, append.
(defun semantic-c-dereference-namespace (type scope &optional type-declaration)
"Dereference namespace which might hold an 'alias' for TYPE.
Such an alias can be created through 'using' statements in a
-namespace declaration. This function checks the namespaces in
+namespace declaration. This function checks the namespaces in
SCOPE for such statements."
(let ((scopetypes (oref scope scopetypes))
typename currentns tmp usingname result namespaces)
(list type type-declaration))
(define-mode-local-override semantic-analyze-type-constants c-mode (type)
- "When TYPE is a tag for an enum, return it's parts.
+ "When TYPE is a tag for an enum, return its parts.
These are constants which are of type TYPE."
(if (and (eq (semantic-tag-class type) 'type)
(string= (semantic-tag-type type) "enum"))
(semantic-idle-summary-current-symbol-info-default))))
(defvar-mode-local c-mode semantic-orphaned-member-metaparent-type "struct"
- "When lost memberes are found in the class hierarchy generator, use a struct.")
+ "When lost members are found in the class hierarchy generator, use a struct.")
(defvar-mode-local c-mode semantic-symbol->name-assoc-list
'((type . "Types")
"Separator characters between something of a given type, and a field.")
(defvar-mode-local c-mode semantic-command-separation-character ";"
- "Commen separation character for C")
+ "Command separation character for C.")
(defvar-mode-local c-mode senator-step-at-tag-classes '(function variable)
"Tag classes where senator will stop at the end.")
(princ "\n")
))
+ (when (arrayp semantic-lex-spp-project-macro-symbol-obarray)
+ (princ "\n Project symbol map:\n")
+ (princ " Your project symbol map is derived from the EDE object:\n ")
+ (princ (object-print ede-object))
+ (princ "\n\n")
+ (let ((macros nil))
+ (mapatoms
+ #'(lambda (symbol)
+ (setq macros (cons symbol macros)))
+ semantic-lex-spp-project-macro-symbol-obarray)
+ (dolist (S macros)
+ (princ " ")
+ (princ (symbol-name S))
+ (princ " = ")
+ (princ (symbol-value S))
+ (princ "\n")
+ )))
+
(princ "\n\n Use: M-x semantic-lex-spp-describe RET\n")
(princ "\n to see the complete macro table.\n")
;; Local variables:
;; generated-autoload-file: "../loaddefs.el"
-;; generated-autoload-feature: semantic/loaddefs
;; generated-autoload-load-name: "semantic/bovine/c"
;; End:
+;; arch-tag: 263951a8-0f18-445d-8e73-eb8f9ac8e2a3
;;; semantic/bovine/c.el ends here