summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hornsey <hornseyf@objectcomputing.com>2018-11-28 18:17:40 -0600
committerFred Hornsey <hornseyf@objectcomputing.com>2018-11-28 18:17:40 -0600
commitf34da7a658ccfa94718480b02d84abf5f27a4fed (patch)
treebec9d355779e378c2a6064a6f0d20c35649e21ea
parent2ff6c3fd080f8c1bc31910b80bc80c49b6dc24c0 (diff)
downloadATCD-f34da7a658ccfa94718480b02d84abf5f27a4fed.tar.gz
tao_idl: Access Annotations From Typedef Chains
-rw-r--r--TAO/TAO_IDL/ast/ast_decl.cpp11
-rw-r--r--TAO/TAO_IDL/ast/ast_typedef.cpp39
-rw-r--r--TAO/TAO_IDL/include/ast_decl.h7
-rw-r--r--TAO/TAO_IDL/include/ast_typedef.h10
4 files changed, 66 insertions, 1 deletions
diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp
index 6dea30ae484..e12813d44f0 100644
--- a/TAO/TAO_IDL/ast/ast_decl.cpp
+++ b/TAO/TAO_IDL/ast/ast_decl.cpp
@@ -1662,3 +1662,14 @@ AST_Decl::should_be_dumped () const
bool is_builtin = builtin ();
return !is_builtin || (is_builtin && idl_global->dump_builtins_);
}
+
+AST_Annotation_Appls &
+AST_Decl::annotations ()
+{
+ if (!annotation_appls_)
+ {
+ annotation_appls_ = new AST_Annotation_Appls;
+ }
+
+ return *annotation_appls_;
+}
diff --git a/TAO/TAO_IDL/ast/ast_typedef.cpp b/TAO/TAO_IDL/ast/ast_typedef.cpp
index b539c8d53dc..760bf9b55c7 100644
--- a/TAO/TAO_IDL/ast/ast_typedef.cpp
+++ b/TAO/TAO_IDL/ast/ast_typedef.cpp
@@ -89,12 +89,17 @@ AST_Typedef::AST_Typedef (AST_Type *bt,
n),
AST_Field (AST_Decl::NT_typedef,
bt,
- n)
+ n),
+ cached_annotations_ (0)
{
}
AST_Typedef::~AST_Typedef (void)
{
+ if (!cached_annotations_)
+ {
+ delete cached_annotations_;
+ }
}
// Given a typedef node, traverse the chain of base types until they are no
@@ -193,3 +198,35 @@ AST_Typedef::destroy (void)
}
IMPL_NARROW_FROM_DECL(AST_Typedef)
+
+AST_Annotation_Appls &
+AST_Typedef::annotations ()
+{
+ if (!cached_annotations_)
+ {
+ cached_annotations_ = new AST_Annotation_Appls;
+
+ if (base_type ())
+ {
+ AST_Annotation_Appls &next = base_type ()->annotations ();
+ for (size_t i = 0; i < next.size (); i++)
+ {
+ cached_annotations_->push_back (next[i]);
+ }
+ }
+
+ /*
+ * Done after so it's easier for later annotations to override
+ * older ones.
+ */
+ if (annotation_appls ()) {
+ AST_Annotation_Appls &appls = *annotation_appls ();
+ for (size_t i = 0; i < appls.size (); i++)
+ {
+ cached_annotations_->push_back (appls[i]);
+ }
+ }
+ }
+
+ return *cached_annotations_;
+}
diff --git a/TAO/TAO_IDL/include/ast_decl.h b/TAO/TAO_IDL/include/ast_decl.h
index b38dd61d0da..787dc029c20 100644
--- a/TAO/TAO_IDL/include/ast_decl.h
+++ b/TAO/TAO_IDL/include/ast_decl.h
@@ -384,6 +384,13 @@ public:
*/
virtual bool should_be_dumped () const;
+ /**
+ * Get Annotation Vector Reference.
+ * If this is a typedef, it includes recursively acquired annotations from
+ * the possible chain of direct typedefs.
+ */
+ virtual AST_Annotation_Appls &annotations ();
+
protected:
// These are not private because they're used by
// be_predefined_type' constructor and can be called
diff --git a/TAO/TAO_IDL/include/ast_typedef.h b/TAO/TAO_IDL/include/ast_typedef.h
index b14fef60d63..ea1f28cba3b 100644
--- a/TAO/TAO_IDL/include/ast_typedef.h
+++ b/TAO/TAO_IDL/include/ast_typedef.h
@@ -118,9 +118,19 @@ public:
virtual bool dump_annotations_inline () const { return true; }
+ /**
+ * Recursively acquired annotations from typedefs.
+ */
+ virtual AST_Annotation_Appls &annotations ();
+
protected:
virtual int compute_size_type (void);
// Compute the size type if it is unknown.
+
+ /**
+ * Cache of Recursively acquired annotations from typedefs.
+ */
+ AST_Annotation_Appls *cached_annotations_;
};
#endif // _AST_TYPEDEF_AST_TYPEDEF_HH