Esempio n. 1
0
// AST Dumping.
void
UTL_IdList::dump (ACE_OSTREAM_TYPE &o)
{
  long first = true;
  long second = false;

  for (UTL_IdListActiveIterator i (this);
       !i.is_done ();
       i.next ())
    {
      if (!first)
        {
          o << "::";
        }
      else if (second)
        {
          first = second = false;
        }

      i.item ()->dump (o);

      if (first)
        {
          if (ACE_OS::strcmp (i.item ()->get_string (), "::") != 0)
            {
              first = false;
            }
          else
            {
              second = true;
            }
        }
    }
}
Esempio n. 2
0
void
be_util::gen_nested_namespace_begin (TAO_OutStream *os,
                                     be_module *node,
                                     bool skel)
{
  char *item_name = 0;
  bool first_level = true;

  for (UTL_IdListActiveIterator i (node->name ());
       !i.is_done ();
       i.next ())
    {
      item_name = i.item ()->get_string ();

      if (ACE_OS::strcmp (item_name, "") != 0)
        {
          // Leave the outermost root scope.
          *os << be_nl << "namespace ";

          if (first_level && skel)
            {
              // We are outermost module.
              *os << "POA_";
              first_level = false;
            }

          *os << item_name << be_nl
              << "{" << be_idt_nl;
        }
    }
}
Esempio n. 3
0
void
be_type::gen_fwd_helper_name (void)
{
  AST_Decl *parent = ScopeAsDecl (this->defined_in ());
  Identifier *segment = 0;
  char *tmp = 0;
  this->fwd_helper_name_.clear (true);

  if (parent != 0 && parent->node_type () != AST_Decl::NT_root)
    {
      for (UTL_IdListActiveIterator i (parent->name ());
           !i.is_done ();
           i.next ())
        {
          segment = i.item ();
          tmp = segment->get_string ();

          if (ACE_OS::strcmp (tmp, "") == 0)
            {
              continue;
            }

          this->fwd_helper_name_ += tmp;
          this->fwd_helper_name_ += "::";
        }
    }
  else
    {
      this->fwd_helper_name_= "";
    }

  this->fwd_helper_name_ += "tao_";
  this->fwd_helper_name_ += this->local_name ()->get_string ();
}
Esempio n. 4
0
void
be_util::gen_nested_namespace_end (TAO_OutStream *os,
                                   be_module *node)
{
  for (UTL_IdListActiveIterator i (node->name ());
       !i.is_done ();
       i.next ())
    {
      if (ACE_OS::strcmp (i.item ()->get_string (), "") != 0)
        {
          // Leave the outermost root scope.
          *os << be_uidt_nl << "}";
        }
    }
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
/*
 * Helper function for lookup_by_name. Iterates doing local lookups of
 * subsequent components of a scoped name
 */
static AST_Decl *
iter_lookup_by_name_local(AST_Decl *d, UTL_ScopedName *e,
                          idl_bool treat_as_ref)
{
   Identifier *s;
   AST_Typedef *td;
   UTL_IdListActiveIterator *i;
   UTL_Scope *sc;

   i = new UTL_IdListActiveIterator(e);

   for (i->next(); !(i->is_done()); )
   {
      s = i->item();
      /*
       * Update iterator before loop. This is needed for the check for
       * typedef, since we only want to look at the base type if there
       * actually are more components of the name to resolve.
       */
      i->next();
      /*
       * Next component in name was not found
       */

      if (d == NULL)
      {
         return NULL;
      }

      /*
       * If this is a typedef and we're not done, we should get the
       * base type to get the scope it defines (if any)
       */
      if (!(i->is_done()))
      {
         while (d != NULL && d->node_type() == AST_Decl::NT_typedef)
         {
            td = AST_Typedef::narrow_from_decl(d);

            if (td == NULL)
               return NULL;

            d = td->base_type();
         }

         if (d == NULL)
            return NULL;
      }

      /*
       * Try to convert the AST_Decl to a UTL_Scope
       */
      sc = DeclAsScope(d);

      if (sc == NULL)
         return NULL;

      /*
       * Look up the next element
       */
      d = sc->lookup_by_name_local (s);
   }

   /*
    * OK, done with the loop
    */ 
   return d;
}