Function: semantic-expand-c-tag-namelist

semantic-expand-c-tag-namelist is a byte-compiled function defined in c.el.gz.

Signature

(semantic-expand-c-tag-namelist TAG)

Documentation

Expand TAG whose name is a list into a list of tags, or nil.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/bovine/c.el.gz
(defun semantic-expand-c-tag-namelist (tag)
  "Expand TAG whose name is a list into a list of tags, or nil."
  (cond ((semantic-tag-of-class-p tag 'variable)
	 ;; The name part comes back in the form of:
	 ;; ( NAME NUMSTARS BITS ARRAY ASSIGN )
	 (let ((vl nil)
	       (basety (semantic-tag-type tag))
	       (ty "")
	       (mods (semantic-tag-get-attribute tag :typemodifiers))
	       (suffix "")
	       (lst (semantic-tag-name tag))
	       (default nil)
	       (cur nil))
	   ;; Open up each name in the name list.
	   (while lst
	     (setq suffix "" ty "")
	     (setq cur (car lst))
	     (if (nth 2 cur)
		 (setq suffix (concat ":" (nth 2 cur))))
	     (if (= (length basety) 1)
		 (setq ty (car basety))
	       (setq ty basety))
	     (setq default (nth 4 cur))
	     (setq vl (cons
		       (semantic-tag-new-variable
			(car cur)	;name
			ty		;type
			(if (and default
				 (listp (cdr default)))
			    (buffer-substring-no-properties
			     (car default) (car (cdr default))))
			:constant-flag (semantic-tag-variable-constant-p tag)
			:suffix suffix
			:typemodifiers mods
			:dereference (length (nth 3 cur))
			:pointer (nth 1 cur)
			:reference (semantic-tag-get-attribute tag :reference)
			:documentation (semantic-tag-docstring tag) ;doc
			)
		       vl))
	     (semantic--tag-copy-properties tag (car vl))
	     (semantic--tag-set-overlay (car vl)
					(semantic-tag-overlay tag))
	     (setq lst (cdr lst)))
	   ;; Return the list
	   (nreverse vl)))
	((semantic-tag-of-class-p tag 'type)
	 ;; We may someday want to add an extra check for a type
	 ;; of type "typedef".
	 ;; Each elt of NAME is ( STARS NAME )
	 (let ((vl nil)
	       (names (semantic-tag-name tag))
	       (super (semantic-tag-get-attribute tag :superclasses))
	       (addlast nil))

	   (when (and (semantic-tag-of-type-p tag "typedef")
		      (semantic-tag-of-class-p super 'type)
		      (semantic-tag-type-members super))
	     ;; This is a typedef of a real type.  Extract
	     ;; the super class, and stick it into the tags list.
	     (setq addlast super)

	     ;; Clone super and remove the members IFF super has a name.
	     ;; Note: anonymous struct/enums that are typedef'd shouldn't
	     ;; exist in the top level type list, so they will appear only
	     ;; in the :typedef slot of the typedef.
	     (setq super (semantic-tag-clone super))
	     (if (not (string= (semantic-tag-name super) ""))
		 (semantic-tag-put-attribute super :members nil)
	       (setq addlast nil))

	     ;; Add in props to the full superclass.
	     (when addlast
	       (semantic--tag-copy-properties tag addlast)
	       (semantic--tag-set-overlay addlast (semantic-tag-overlay tag)))
	     )

	   (while names

	     (setq vl (cons (semantic-tag-new-type
			     (nth 1 (car names)) ; name
			     "typedef"
			     (semantic-tag-type-members tag)
			     nil
			     :pointer
			     (let ((stars (car (car (car names)))))
			       (if (= stars 0) nil stars))
			     ;; This specifies what the typedef
			     ;; is expanded out as.  Just the
			     ;; name shows up as a parent of this
			     ;; typedef.
			     :typedef super
			     ;;(semantic-tag-type-superclasses tag)
			     :documentation
			     (semantic-tag-docstring tag))
			    vl))
	     (semantic--tag-copy-properties tag (car vl))
	     (semantic--tag-set-overlay (car vl) (semantic-tag-overlay tag))
	     (setq names (cdr names)))

	   ;; Add typedef superclass last.
	   (when addlast (setq vl (cons addlast vl)))

	   vl))
	((and (listp (car tag))
	      (semantic-tag-of-class-p (car tag) 'variable))
	 ;; Argument lists come in this way.  Append all the expansions!
	 (let ((vl nil))
	   (while tag
	     (setq vl (append (semantic-tag-components (car vl))
			      vl)
		   tag (cdr tag)))
	   vl))
	(t nil)))