summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hornsey <hornseyf@objectcomputing.com>2018-10-11 12:07:49 -0500
committerFred Hornsey <hornseyf@objectcomputing.com>2018-10-11 12:07:49 -0500
commitcea90cecf7876229a0dafbdfdcbe6670c7c7908a (patch)
tree5fa30d893d4283613e328b41a49561f42d8a92ea
parent0da6fa4b0c674b903adcbbe3630d33c5b99e7b3d (diff)
downloadATCD-cea90cecf7876229a0dafbdfdcbe6670c7c7908a.tar.gz
tao_idl: improvments to annoation util code
-rw-r--r--TAO/TAO_IDL/ast/ast_annotation.cpp16
-rw-r--r--TAO/TAO_IDL/ast/ast_decl.cpp4
-rw-r--r--TAO/TAO_IDL/include/ast_annotation.h10
-rw-r--r--TAO/TAO_IDL/include/ast_decl.h9
-rw-r--r--TAO/TAO_IDL/include/utl_idlist.h11
-rw-r--r--TAO/TAO_IDL/util/utl_idlist.cpp57
6 files changed, 92 insertions, 15 deletions
diff --git a/TAO/TAO_IDL/ast/ast_annotation.cpp b/TAO/TAO_IDL/ast/ast_annotation.cpp
index c6ff1ba552e..b387505eb37 100644
--- a/TAO/TAO_IDL/ast/ast_annotation.cpp
+++ b/TAO/TAO_IDL/ast/ast_annotation.cpp
@@ -2,20 +2,22 @@
AST_Decl::NodeType const AST_Annotation::NT = AST_Decl::NT_annotation;
-AST_Annotation::AST_Annotation (UTL_ScopedName *name, AST_Annotation::Params *params)
- : AST_Decl (NT, name), name_ (name->copy ()), params_ (params)
+AST_Annotation::AST_Annotation (
+ UTL_ScopedName *name, AST_Annotation::Params *params)
+ : AST_Decl (NT, name), original_name_ (name->get_string_copy ()),
+ params_ (params)
{
}
AST_Annotation::~AST_Annotation ()
{
- delete name_;
+ delete [] original_name_;
}
void AST_Annotation::dump (ACE_OSTREAM_TYPE &o)
{
dump_i (o, "@");
- name_->dump (o);
+ dump_i (o, original_name_);
if (params_)
{
dump_i (o, "(");
@@ -41,9 +43,15 @@ void AST_Annotation::dump (ACE_OSTREAM_TYPE &o)
int AST_Annotation::ast_accept (ast_visitor *visitor)
{
+ ACE_UNUSED_ARG (visitor);
return 0;
}
void AST_Annotation::destroy ()
{
}
+
+const char *AST_Annotation::original_name () const
+{
+ return original_name_;
+}
diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp
index 3a53bb19a37..0281ed62247 100644
--- a/TAO/TAO_IDL/ast/ast_decl.cpp
+++ b/TAO/TAO_IDL/ast/ast_decl.cpp
@@ -141,6 +141,7 @@ AST_Decl::AST_Decl (NodeType nt,
repoID_ (0),
flat_name_ (0),
contains_wstring_ (-1),
+ annotations_ (0),
pd_imported (idl_global->imported ()),
pd_in_main_file (idl_global->in_main_file ()),
pd_defined_in (idl_global->scopes ().depth () > 0
@@ -158,8 +159,7 @@ AST_Decl::AST_Decl (NodeType nt,
typeid_set_ (false),
last_referenced_as_ (0),
prefix_scope_ (0),
- in_tmpl_mod_not_aliased_ (idl_global->in_tmpl_mod_no_alias ()),
- annotations_ (0)
+ in_tmpl_mod_not_aliased_ (idl_global->in_tmpl_mod_no_alias ())
{
// If this is the root node, the filename won't have been set yet.
UTL_String *fn = idl_global->filename ();
diff --git a/TAO/TAO_IDL/include/ast_annotation.h b/TAO/TAO_IDL/include/ast_annotation.h
index 5d938816cf3..71a76acd381 100644
--- a/TAO/TAO_IDL/include/ast_annotation.h
+++ b/TAO/TAO_IDL/include/ast_annotation.h
@@ -51,10 +51,16 @@ public:
static AST_Decl::NodeType const NT;
+ /*
+ * Get name of the annoation as written by the user
+ * to compare to builtin annoations.
+ */
+ const char* original_name () const;
+
private:
- /// Name of the Annotation
- UTL_ScopedName *name_;
+ /// Name of the Annotation as written
+ const char *original_name_;
/// Parameters List
Params *params_;
diff --git a/TAO/TAO_IDL/include/ast_decl.h b/TAO/TAO_IDL/include/ast_decl.h
index 754ba46d288..53e9c98b013 100644
--- a/TAO/TAO_IDL/include/ast_decl.h
+++ b/TAO/TAO_IDL/include/ast_decl.h
@@ -316,7 +316,7 @@ public:
/// Set and get annotations for this IDL element
///{
- void annotations (Annotations *annotations);
+ virtual void annotations (Annotations *annotations);
Annotations *annotations ();
///}
@@ -370,7 +370,6 @@ protected:
int contains_wstring_;
// If we are a scope, do we contain a wstring at some level?
-protected:
void dump_i (ACE_OSTREAM_TYPE &o, const char *s) const ;
void compute_repoID (void);
@@ -385,6 +384,9 @@ protected:
const char *node_type_to_string (NodeType nt);
// Convert a NodeType to a string for dumping.
+ /// Annotations applied to this IDL element
+ Annotations* annotations_;
+
private:
// Data
@@ -439,9 +441,6 @@ private:
bool in_tmpl_mod_not_aliased_;
// false by default - if true, we can't be referenced.
- /// Annotations applied to this IDL element
- Annotations* annotations_;
-
void compute_full_name (UTL_ScopedName *n);
// Compute the full name of an AST node.
diff --git a/TAO/TAO_IDL/include/utl_idlist.h b/TAO/TAO_IDL/include/utl_idlist.h
index 9f4927d0178..738047c5970 100644
--- a/TAO/TAO_IDL/include/utl_idlist.h
+++ b/TAO/TAO_IDL/include/utl_idlist.h
@@ -113,6 +113,17 @@ public:
int compare (UTL_IdList *other);
// Compares each component for equality.
+
+ /**
+ * Return a copy of the contatins as a string
+ */
+ char *get_string_copy ();
+
+ /**
+ * Return true if the list begins with "::"
+ */
+ bool is_absolute ();
+
private:
Identifier *pd_car_data;
};
diff --git a/TAO/TAO_IDL/util/utl_idlist.cpp b/TAO/TAO_IDL/util/utl_idlist.cpp
index 8a0e6344575..c2445916e77 100644
--- a/TAO/TAO_IDL/util/utl_idlist.cpp
+++ b/TAO/TAO_IDL/util/utl_idlist.cpp
@@ -198,8 +198,8 @@ UTL_IdList::compare (UTL_IdList *other)
void
UTL_IdList::dump (ACE_OSTREAM_TYPE &o)
{
- long first = true;
- long second = false;
+ bool first = true;
+ bool second = false;
for (UTL_IdListActiveIterator i (this);
!i.is_done ();
@@ -271,3 +271,56 @@ UTL_IdListActiveIterator::item (void)
return ((UTL_IdList *) source)->head ();
}
+
+char *
+UTL_IdList::get_string_copy ()
+{
+ /*
+ * Absolute Names have "::" as the first item in the idlist, so delimiters
+ * have to start be inserted depending on if the name is absolute or not
+ */
+ size_t delimiter_start = is_absolute () ? 1 : 0;
+
+ // Get buffer of the correct size
+ size_t n = 0;
+ size_t size = 1;
+ for (UTL_IdListActiveIterator i (this);
+ !i.is_done ();
+ i.next ())
+ {
+ if (n > delimiter_start)
+ {
+ size += 2; // For delimiter
+ }
+ const char *item = i.item ()->get_string ();
+ size += ACE_OS::strlen (item);
+ n++;
+ }
+ char *buffer = new char[size];
+ buffer[0] = '\0';
+
+ // Fill buffer
+ n = 0;
+ for (UTL_IdListActiveIterator i (this);
+ !i.is_done ();
+ i.next ())
+ {
+ if (n > delimiter_start)
+ {
+ ACE_OS::strncat (buffer, "::", 2);
+ }
+ const char *item = i.item ()->get_string ();
+ ACE_OS::strcat (buffer, item);
+ n++;
+ }
+
+ buffer[size - 1] = '\0';
+
+ return buffer;
+}
+
+bool
+UTL_IdList::is_absolute ()
+{
+ return !ACE_OS::strcmp (first_component ()->get_string (), "::");
+}