Function: semantic-c-dereference-namespace

semantic-c-dereference-namespace is a byte-compiled function defined in c.el.gz.

Signature

(semantic-c-dereference-namespace TYPE SCOPE &optional TYPE-DECLARATION)

Documentation

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 SCOPE for such statements.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/bovine/c.el.gz
;; David Engster: The following three functions deal with namespace
;; aliases and types which are member of a namespace through a using
;; statement. For examples, see the file semantic/tests/testusing.cpp,
;; tests 5 and following.

(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
SCOPE for such statements."
  (let ((scopetypes (oref scope scopetypes))
	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)))
      ;; If we already have that TYPE in SCOPE, we do nothing
      (unless (semantic-deep-find-tags-by-name (or (car-safe typename) typename) scopetypes)
	(if (stringp typename)
	    ;; The type isn't fully qualified, so we have to search in all namespaces in SCOPE.
	    (setq namespaces (semantic-find-tags-by-type "namespace" scopetypes))
	  ;; This is a fully qualified name, so we only have to search one namespace.
	  (setq namespaces (semanticdb-typecache-find (car typename)))
	  ;; Make sure it's really a namespace.
	  (if (string= (semantic-tag-type namespaces) "namespace")
	      (setq namespaces (list namespaces))
	    (setq namespaces nil)))
	(setq result nil)
	;; Iterate over all the namespaces we have to check.
	(while (and namespaces
		    (null result))
	  (setq currentns (car namespaces))
	  ;; Check if this is namespace is an alias and dereference it if necessary.
	  (setq result (semantic-c-dereference-namespace-alias type-declaration currentns))
	  (unless result
	    ;; Otherwise, check if we can reach the type through 'using' statements.
	    (setq result
		  (semantic-c-check-type-namespace-using type-declaration currentns)))
	  (setq namespaces (cdr namespaces)))))
    (if result
	;; we have found the original type
	(list result result)
      (list type type-declaration))))