diff options
author | Fred Hornsey <hornseyf@objectcomputing.com> | 2018-12-05 14:38:51 -0600 |
---|---|---|
committer | Fred Hornsey <hornseyf@objectcomputing.com> | 2018-12-05 14:38:51 -0600 |
commit | 3f0cbd96bdae207baf50ec7dd14a6e49b23d3f79 (patch) | |
tree | 2531afffa4df193c8b6d8b2996d3d2949931020d | |
parent | 1d9c5f7d66aee059354d85cccbfa389b001c0ba4 (diff) | |
download | ATCD-3f0cbd96bdae207baf50ec7dd14a6e49b23d3f79.tar.gz |
tao_idl: Util functions for geting anno. members
-rw-r--r-- | TAO/TAO_IDL/include/ast_annotation_appl.h | 2 | ||||
-rw-r--r-- | TAO/TAO_IDL/include/utl_annotations.h | 26 | ||||
-rw-r--r-- | TAO/TAO_IDL/util/utl_annotations.cpp | 46 |
3 files changed, 72 insertions, 2 deletions
diff --git a/TAO/TAO_IDL/include/ast_annotation_appl.h b/TAO/TAO_IDL/include/ast_annotation_appl.h index 5e9324f0aa8..75b6e0fa84d 100644 --- a/TAO/TAO_IDL/include/ast_annotation_appl.h +++ b/TAO/TAO_IDL/include/ast_annotation_appl.h @@ -104,8 +104,6 @@ private: AST_Annotation_Decl *annotation_decl_; }; -typedef ACE_Vector<AST_Annotation_Appl*> AST_Annotation_Appls; - struct Decl_Annotations_Pair { AST_Decl *decl; AST_Annotation_Appls *annotations; diff --git a/TAO/TAO_IDL/include/utl_annotations.h b/TAO/TAO_IDL/include/utl_annotations.h new file mode 100644 index 00000000000..5b542528266 --- /dev/null +++ b/TAO/TAO_IDL/include/utl_annotations.h @@ -0,0 +1,26 @@ +#ifndef UTL_ANNOTATIONS_HEADER +#define UTL_ANNOTATIONS_HEADER + +#include "TAO_IDL_FE_Export.h" + +#include "ast_annotation_appl.h" + +/** + * Given an AST_Annotation_Appls, find the last annotation that matches the + * given annotation declaration. Returns 0 if not found. + * + * "declaration" must be an absolutely scoped name or a pointer to the + * AST_Annotation_Decl. + */ +///{ +TAO_IDL_FE_Export AST_Annotation_Appl *UTL_find_annotation ( + AST_Annotation_Appls &annotations, AST_Annotation_Decl *annotation); +TAO_IDL_FE_Export AST_Annotation_Appl *UTL_find_annotation ( + AST_Annotation_Appls *annotations, AST_Annotation_Decl *annotation); +TAO_IDL_FE_Export AST_Annotation_Appl *UTL_find_annotation ( + AST_Annotation_Appls &annotations, const char *annotation); +TAO_IDL_FE_Export AST_Annotation_Appl *UTL_find_annotation ( + AST_Annotation_Appls *annotations, const char *annotation); +///} + +#endif diff --git a/TAO/TAO_IDL/util/utl_annotations.cpp b/TAO/TAO_IDL/util/utl_annotations.cpp new file mode 100644 index 00000000000..36dfa07c704 --- /dev/null +++ b/TAO/TAO_IDL/util/utl_annotations.cpp @@ -0,0 +1,46 @@ +#include "utl_annotations.h" + +AST_Annotation_Appl *UTL_find_annotation ( + AST_Annotation_Appls &annotations, AST_Annotation_Decl *annotation) +{ + AST_Annotation_Appl *result = 0; + if (annotation) + { + for (AST_Annotation_Appls::iterator i = annotations.begin (); + i != annotations.end (); ++i) + { + AST_Annotation_Appl *appl = *i; + if (appl && appl->annotation_decl () == annotation) + { + result = appl; + } + } + } + return result; +} + +AST_Annotation_Appl *UTL_find_annotation ( + AST_Annotation_Appls *annotations, AST_Annotation_Decl *annotation) +{ + return annotations ? UTL_find_annotation (*annotations, annotation) : 0; +} + +AST_Annotation_Appl *UTL_find_annotation ( + AST_Annotation_Appls &annotations, const char *annotation) +{ + AST_Annotation_Appl *result = 0; + if (annotation) + { + return UTL_find_annotation ( + annotations, + AST_Annotation_Decl::narrow_from_decl ( + idl_global->scopes ().bottom ()->lookup_by_name (annotation))); + } + return result; +} + +AST_Annotation_Appl *UTL_find_annotation ( + AST_Annotation_Appls *annotations, const char *annotation) +{ + return annotations ? UTL_find_annotation (*annotations, annotation) : 0; +} |