-;;; semantic/bovine/c.el --- Semantic details for C
+;;; semantic/bovine/c.el --- Semantic details for C -*- lexical-binding: t; -*-
;; Copyright (C) 1999-2021 Free Software Foundation, Inc.
"Reset the C preprocessor symbol map based on all input variables."
(when (and semantic-mode
(featurep 'semantic/bovine/c))
- (remove-hook 'mode-local-init-hook 'semantic-c-reset-preprocessor-symbol-map)
+ (remove-hook 'mode-local-init-hook
+ #'semantic-c-reset-preprocessor-symbol-map)
;; Initialize semantic-lex-spp-macro-symbol-obarray with symbols.
(setq-mode-local c-mode
semantic-lex-spp-macro-symbol-obarray
;; Make sure the preprocessor symbols are set up when mode-local kicks
;; in.
-(add-hook 'mode-local-init-hook 'semantic-c-reset-preprocessor-symbol-map)
+(add-hook 'mode-local-init-hook #'semantic-c-reset-preprocessor-symbol-map)
(defcustom semantic-lex-c-preprocessor-symbol-map nil
"Table of C Preprocessor keywords used by the Semantic C lexer.
(skip-chars-forward " \t")
(if (eolp)
nil
- (let* ((name (buffer-substring-no-properties
- (match-beginning 1) (match-end 1)))
+ (let* (;; (name (buffer-substring-no-properties
+ ;; (match-beginning 1) (match-end 1)))
(beginning-of-define (match-end 1))
(with-args (save-excursion
(goto-char (match-end 0))
(error nil))))
(let ((eval-form (condition-case err
- (eval parsedtokelist)
+ (eval parsedtokelist t)
(error
(semantic-push-parser-warning
(format "Hideif forms produced an error. Assuming false.\n%S" err)
(equal eval-form 0)));; ifdef line resulted in false
;; The if indicates to skip this preprocessor section
- (let ((pt nil))
+ (let () ;; (pt nil)
(semantic-push-parser-warning (format "Skip %s" (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
(point-at-bol) (point-at-eol))
(beginning-of-line)
- (setq pt (point))
+ ;; (setq pt (point))
;; This skips only a section of a conditional. Once that section
;; is opened, encountering any new #else or related conditional
;; should be skipped.
(semantic-lex-init)
(semantic-clear-toplevel-cache)
(remove-hook 'semantic-lex-reset-functions
- 'semantic-lex-spp-reset-hook t)
+ #'semantic-lex-spp-reset-hook t)
)
;; Get the macro symbol table right.
(setq semantic-lex-spp-dynamic-macro-symbol-obarray spp-syms)
;; Notify about the debug
(setq semantic-c-debug-mode-init-last-mode mm)
- (add-hook 'post-command-hook 'semantic-c-debug-mode-init-pch)))
+ (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."
now.
")
- (remove-hook 'post-command-hook 'semantic-c-debug-mode-init-pch)))
+ (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."
(when (not (semantic-tag-p tag)) (signal 'wrong-type-argument (list 'semantic-tag-p tag)))
(let ((allhits nil)
(scope nil)
- (refs nil))
+ ) ;; (refs nil)
(save-excursion
(semantic-go-to-tag tag db)
(setq scope (semantic-calculate-scope))
(reverse newparents)))
(setq allhits (semantic--analyze-refs-full-lookup tag scope t)))
- (setq refs (semantic-analyze-references (semantic-tag-name tag)
- :tag tag
- :tagdb db
- :scope scope
- :rawsearchdata allhits)))))
+ ;; (setq refs
+ (semantic-analyze-references (semantic-tag-name tag)
+ :tag tag
+ :tagdb db
+ :scope scope
+ :rawsearchdata allhits)))) ;;)
(defun semantic-c-reconstitute-token (tokenpart declmods typedecl)
"Reconstitute a token TOKENPART with DECLMODS and TYPEDECL.
((semantic-tag-p templatespec)
(semantic-format-tag-abbreviate templatespec))
((listp templatespec)
- (mapconcat 'semantic-format-tag-abbreviate templatespec ", "))))
+ (mapconcat #'semantic-format-tag-abbreviate templatespec ", "))))
-(defun semantic-c-template-string (token &optional parent color)
+(defun semantic-c-template-string (token &optional parent _color)
"Return a string representing the TEMPLATE attribute of TOKEN.
This string is prefixed with a space, or is the empty string.
Argument PARENT specifies a parent type.
(let ((t2 (semantic-c-tag-template-specifier token))
(t1 (semantic-c-tag-template token))
;; @todo - Need to account for a parent that is a template
- (pt1 (if parent (semantic-c-tag-template parent)))
- (pt2 (if parent (semantic-c-tag-template-specifier parent)))
+ (_pt1 (if parent (semantic-c-tag-template parent)))
+ (_pt2 (if parent (semantic-c-tag-template-specifier parent)))
)
(cond (t2 ;; we have a template with specifier
(concat " <"
(member "virtual" (semantic-tag-modifiers tag))))
(t (semantic-tag-abstract-p-default tag parent))))
-(defun semantic-c-dereference-typedef (type scope &optional type-declaration)
+(defun semantic-c-dereference-typedef (type _scope &optional type-declaration)
"If TYPE is a typedef, get TYPE's type by name or tag, and return.
SCOPE is not used, and TYPE-DECLARATION is used only if TYPE is not a typedef."
(if (and (eq (semantic-tag-class type) 'type)
(concat (semantic-tag-name type)
"<" (semantic-c--template-name-1 (cdr spec-list)) ">"))
-(defun semantic-c-dereference-template (type scope &optional type-declaration)
+(defun semantic-c-dereference-template (type _scope &optional type-declaration)
"Dereference any template specifiers in TYPE within SCOPE.
If TYPE is a template, return a TYPE copy with the templates types
instantiated as specified in TYPE-DECLARATION."
(list type type-declaration))
;;; Patch here by "Raf" for instantiating templates.
-(defun semantic-c-dereference-member-of (type scope &optional type-declaration)
+(defun semantic-c-dereference-member-of (type _scope &optional type-declaration)
"Dereference through the `->' operator of TYPE.
Uses the return type of the `->' operator if it is contained in TYPE.
SCOPE is the current local scope to perform searches in.
namespace declaration. This function checks the namespaces in
SCOPE for such statements."
(let ((scopetypes (oref scope scopetypes))
- typename currentns tmp usingname result namespaces)
+ typename currentns result namespaces) ;; usingname tmp
(when (and (semantic-tag-p type-declaration)
(or (null type) (semantic-tag-prototype-p type)))
(setq typename (semantic-analyze-split-name (semantic-tag-name type-declaration)))
nil if NAMESPACE is not an alias."
(when (eq (semantic-tag-get-attribute namespace :kind) 'alias)
(let ((typename (semantic-analyze-split-name (semantic-tag-name type)))
- ns nstype originaltype newtype)
+ ns nstype originaltype) ;; newtype
;; Make typename unqualified
- (if (listp typename)
- (setq typename (last typename))
- (setq typename (list typename)))
+ (setq typename (if (listp typename)
+ (last typename)
+ (list typename)))
(when
(and
;; Get original namespace and make sure TYPE exists there.
(semantic-tag-get-attribute nstype :members))))
;; Construct new type with name in original namespace.
(setq ns (semantic-analyze-split-name ns))
- (setq newtype
- (semantic-tag-clone
- (car originaltype)
- (semantic-analyze-unsplit-name
- (if (listp ns)
- (append ns typename)
- (append (list ns) typename)))))))))
+ ;; (setq newtype
+ (semantic-tag-clone
+ (car originaltype)
+ (semantic-analyze-unsplit-name
+ (if (listp ns)
+ (append ns typename)
+ (append (list ns) typename)))))))) ;; )
;; This searches a type in a namespace, following through all using
;; statements.
"Check if TYPE is accessible in NAMESPACE through a using statement.
Returns the original type from the namespace where it is defined,
or nil if it cannot be found."
- (let (usings result usingname usingtype unqualifiedname members shortname tmp)
+ (let (usings result usingname usingtype unqualifiedname members) ;; shortname tmp
;; Get all using statements from NAMESPACE.
(when (and (setq usings (semantic-tag-get-attribute namespace :members))
(setq usings (semantic-find-tags-by-class 'using usings)))
(define-mode-local-override semantic-analyze-unsplit-name c-mode (namelist)
"Assemble the list of names NAMELIST into a namespace name."
- (mapconcat 'identity namelist "::"))
+ (mapconcat #'identity namelist "::"))
(define-mode-local-override semantic-ctxt-scoped-types c++-mode (&optional point)
"Return a list of tags of CLASS type based on POINT.
(semantic-get-local-variables))))
(setq tagreturn
(append tagreturn
- (mapcar 'semantic-tag-type tmp))))))
+ (mapcar #'semantic-tag-type tmp))))))
;; Return the stuff
tagreturn))
have to be wrapped in that namespace."
(let ((inctable (semanticdb-find-table-for-include-default includetag table))
(inside-ns (semantic-tag-get-attribute includetag :inside-ns))
- tags newtags namespaces prefix parenttable newtable)
+ tags newtags namespaces parenttable newtable) ;; prefix
(if (or (null inside-ns)
(not inctable)
(not (slot-boundp inctable 'tags)))
"Set up a buffer for semantic parsing of the C language."
(semantic-c-by--install-parser)
(setq semantic-lex-syntax-modifications '((?> ".")
- (?< ".")
- )
- )
+ (?< ".")))
(setq semantic-lex-analyzer #'semantic-c-lexer)
- (add-hook 'semantic-lex-reset-functions 'semantic-lex-spp-reset-hook nil t)
- (when (eq major-mode 'c++-mode)
+ (add-hook 'semantic-lex-reset-functions #'semantic-lex-spp-reset-hook nil t)
+ (when (derived-mode-p 'c++-mode)
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("__cplusplus" . "")))
)
(defun semantic-c-describe-environment ()
"Describe the Semantic features of the current C environment."
(interactive)
- (if (not (member 'c-mode (mode-local-equivalent-mode-p major-mode)))
+ (if (not (derived-mode-p 'c-mode))
(error "Not useful to query C mode in %s mode" major-mode))
(let ((gcc (when (boundp 'semantic-gcc-setup-data)
semantic-gcc-setup-data))
This can be done by using `semantic-lex-push-token'."
(declare (debug (&define name stringp form def-body)))
`(eval-and-compile
- (defvar ,name nil ,doc)
- (defun ,name nil)
- ;; Do this part separately so that re-evaluation rebuilds this code.
- (setq ,name '(,condition ,@forms))
+ ;; This is the real info used by `define-lex' (via semantic-lex-one-token).
+ (defconst ,name '(,condition ,@forms) ,doc)
;; Build a single lexical analyzer function, so the doc for
;; function help is automatically provided, and perhaps the
;; function could be useful for testing and debugging one
;; analyzer.
- (fset ',name (lambda () ,doc
- (let ((semantic-lex-token-stream nil)
- (semantic-lex-end-point (point))
- (semantic-lex-analysis-bounds
- (cons (point) (point-max)))
- (semantic-lex-current-depth 0)
- (semantic-lex-maximum-depth
- semantic-lex-depth)
- )
- (when ,condition ,@forms)
- semantic-lex-token-stream)))
- ))
+ (defun ,name ()
+ ,doc
+ (let ((semantic-lex-token-stream nil)
+ (semantic-lex-end-point (point))
+ (semantic-lex-analysis-bounds (cons (point) (point-max)))
+ (semantic-lex-current-depth 0)
+ (semantic-lex-maximum-depth semantic-lex-depth))
+ (when ,condition ,@forms)
+ semantic-lex-token-stream))))
(defmacro define-lex-regex-analyzer (name doc regexp &rest forms)
"Create a lexical analyzer with NAME and DOC that will match REGEXP.