Example #1
0
int
be_visitor_enum_any_op_cs::visit_enum (be_enum *node)
{
  if (node->cli_stub_any_op_gen () || node->imported ())
    {
      return 0;
    }

  TAO_OutStream *os = this->ctx_->stream ();

  *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
      << "// " << __FILE__ << ":" << __LINE__ << be_nl;

  *os << be_global->core_versioning_begin () << be_nl;

  // Since we don't generate CDR stream operators for types that
  // explicitly contain a local interface (at some level), we
  // must override these Any template class methods to avoid
  // calling the non-existent operators. The zero return value
  // will eventually cause CORBA::MARSHAL to be raised if this
  // type is inserted into an Any and then marshaled.
  if (node->is_local ())
    {
      *os << "namespace TAO" << be_nl
          << "{" << be_idt_nl
          << "template<>" << be_nl
          << "::CORBA::Boolean" << be_nl
          << "Any_Basic_Impl_T<" << node->name ()
          << ">::marshal_value (TAO_OutputCDR &)" << be_nl
          << "{" << be_idt_nl
          << "return false;" << be_uidt_nl
          << "}";

      *os << be_nl_2
          << "template<>" << be_nl
          << "::CORBA::Boolean" << be_nl
          << "Any_Basic_Impl_T<" << node->name ()
          << ">::demarshal_value (TAO_InputCDR &)" << be_nl
          << "{" << be_idt_nl
          << "return false;" << be_uidt_nl
          << "}" << be_uidt_nl
          << "}" << be_nl_2;
    }


  *os << be_global->core_versioning_end () << be_nl;

  be_module *module = 0;
  if (node->is_nested ())
    {
      AST_Decl *d = node;
      AST_Decl::NodeType nt = d->node_type ();

      while (nt != AST_Decl::NT_root)
        {
          if (nt == AST_Decl::NT_module)
            {
              module = be_module::narrow_from_decl (d);
              break;
            }
          else
            {
              d = ScopeAsDecl (d->defined_in ());
              nt = d->node_type ();
            }
        }

      if (module != 0)
        {
          // Some compilers handle "any" operators in a namespace corresponding
          // to their module, others do not.
          *os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n";

          be_util::gen_nested_namespace_begin (os, module);


          // Generate the Any <<= and >>= operator declarations
          // Any <<= and >>= operators.
          *os << "void operator<<= (" << be_idt << be_idt_nl
              << "::CORBA::Any &_tao_any," << be_nl
              << "::" << node->name () << " _tao_elem" << be_uidt_nl
              << ")" << be_uidt_nl
              << "{" << be_idt_nl
              << "TAO::Any_Basic_Impl_T< ::" << node->name () << ">::insert ("
              << be_idt << be_idt_nl
              << "_tao_any," << be_nl
              << "::" << node->tc_name () << "," << be_nl
              << "_tao_elem" << be_uidt_nl
              << ");" << be_uidt << be_uidt_nl
              << "}" << be_nl_2;

          *os << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl
              << "const ::CORBA::Any &_tao_any," << be_nl
              << "::" << node->name () << " &_tao_elem" << be_uidt_nl
              << ")" << be_uidt_nl
              << "{" << be_idt_nl
              << "return" << be_idt_nl
              << "TAO::Any_Basic_Impl_T< ::" << node->name () << ">::extract ("
              << be_idt << be_idt_nl
              << "_tao_any," << be_nl
              << "::" << node->tc_name () << "," << be_nl
              << "_tao_elem " << be_uidt_nl
              << ");" << be_uidt << be_uidt << be_uidt_nl
              << "}";

          be_util::gen_nested_namespace_end (os, module);

          // Emit #else.
          *os << be_nl_2
              << "#else\n";
        }
    }

  *os << be_global->core_versioning_begin () << be_nl;

  // Generate the Any <<= and >>= operator declarations
  // Any <<= and >>= operators.
  *os << "void operator<<= (" << be_idt << be_idt_nl
      << "::CORBA::Any &_tao_any," << be_nl
      << node->name () << " _tao_elem" << be_uidt_nl
      << ")" << be_uidt_nl
      << "{" << be_idt_nl
      << "TAO::Any_Basic_Impl_T<" << node->name () << ">::insert ("
      << be_idt << be_idt_nl
      << "_tao_any," << be_nl
      << node->tc_name () << "," << be_nl
      << "_tao_elem" << be_uidt_nl
      << ");" << be_uidt << be_uidt_nl
      << "}" << be_nl_2;

  *os << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl
      << "const ::CORBA::Any &_tao_any," << be_nl
      << node->name () << " &_tao_elem" << be_uidt_nl
      << ")" << be_uidt_nl
      << "{" << be_idt_nl
      << "return" << be_idt_nl
      << "TAO::Any_Basic_Impl_T<" << node->name () << ">::extract ("
      << be_idt << be_idt_nl
      << "_tao_any," << be_nl
      << node->tc_name () << "," << be_nl
      << "_tao_elem " << be_uidt_nl
      << ");" << be_uidt << be_uidt << be_uidt_nl
      << "}";

  *os << be_global->core_versioning_end () << be_nl;

  if (module != 0)
    {
      *os << "\n\n#endif";
    }

  node->cli_stub_any_op_gen (1);
  return 0;
}
Example #2
0
UTL_NameList *
AST_Factory::fe_add_exceptions (UTL_NameList *t)
{
  UTL_ScopedName *nl_n = 0;
  AST_Type *fe = 0;
  AST_Decl *d = 0;

  this->pd_exceptions = 0;

  for (UTL_NamelistActiveIterator nl_i (t);
       !nl_i.is_done ();
       nl_i.next ())
    {
      nl_n = nl_i.item ();

      d = this->defined_in ()->lookup_by_name (nl_n, true);

      if (d == 0)
        {
          idl_global->err ()->lookup_error (nl_n);
          return 0;
        }

      AST_Decl::NodeType nt = d->node_type ();

      if (nt != AST_Decl::NT_except
          && nt != AST_Decl::NT_param_holder)
        {
          idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES,
                                      this);
          return 0;
        }

      fe = AST_Type::narrow_from_decl (d);

      UTL_ExceptList *el = 0;
      ACE_NEW_RETURN (el,
                      UTL_ExceptList (fe, 0),
                      0);

      if (this->pd_exceptions == 0)
        {
          this->pd_exceptions = el;
        }
      else
        {
          this->pd_exceptions->nconc (el);
        }

      this->pd_n_exceptions++;
    }

  // This return value is never used, it's easier to
  // destroy it here and return 0 than to destroy it
  // each place it is passed in.
  t->destroy ();
  delete t;
  t = 0;

  return t;
}
Example #3
0
// NOTE: No attempt is made to ensure that exceptions are mentioned
//       only once..
UTL_NameList *
AST_Operation::fe_add_exceptions (UTL_NameList *t)
{
  if (0 == t)
    {
      return 0;
    }

  UTL_ScopedName *nl_n = 0;
  AST_Type *fe = 0;
  AST_Decl *d = 0;

  this->pd_exceptions = 0;

  for (UTL_NamelistActiveIterator nl_i (t); !nl_i.is_done (); nl_i.next ())
    {
      nl_n = nl_i.item ();
      d = this->lookup_by_name (nl_n, true);

      if (d == 0)
        {
          idl_global->err ()->lookup_error (nl_n);
          return 0;
        }

      AST_Decl::NodeType nt = d->node_type ();

      switch (nt)
        {
          case AST_Decl::NT_except:
            break;
          case AST_Decl::NT_param_holder:
            {
              AST_Param_Holder *ph =
                AST_Param_Holder::narrow_from_decl (d);

              nt = ph->info ()->type_;

              if (nt != AST_Decl::NT_except
                  && nt != AST_Decl::NT_type)
                {
                  idl_global->err ()->mismatched_template_param (
                    ph->info ()->name_.c_str ());
                }

              break;
            }
          case AST_Decl::NT_typedef:
            {
              AST_Typedef *td =
                AST_Typedef::narrow_from_decl (d);

              nt = td->primitive_base_type ()->node_type ();

              if (nt != AST_Decl::NT_except)
                {
                  idl_global->err ()->error1 (
                    UTL_Error::EIDL_ILLEGAL_RAISES,
                    this);
                }

              break;
            }
          case AST_Decl::NT_native:
            {
              // This is the only use case for this node type.
              int compare =
                ACE_OS::strcmp (d->local_name ()->get_string (),
                                "UserExceptionBase");

              if (compare != 0)
                {
                  idl_global->err ()->error1 (
                    UTL_Error::EIDL_ILLEGAL_RAISES,
                    this);
                }

              break;
            }
          default:
            idl_global->err ()->error1 (
              UTL_Error::EIDL_ILLEGAL_RAISES,
              this);

            break;
        };

      bool oneway_op =
        (this->flags () == AST_Operation::OP_oneway);

      fe = AST_Type::narrow_from_decl (d);

      if (oneway_op && fe != 0)
        {
          idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES,
                                      this);
        }

      if (fe == 0)
        {
          idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES,
                                      this);
          return 0;
        }

      if (this->pd_exceptions == 0)
        {
          ACE_NEW_RETURN (this->pd_exceptions,
                          UTL_ExceptList (fe,
                                          0),
                          0);
        }
      else
        {
          UTL_ExceptList *el = 0;
          ACE_NEW_RETURN (el,
                          UTL_ExceptList (fe,
                                          0),
                          0);

          this->pd_exceptions->nconc (el);
        }
    }

  // This return value is never used, it's easier to
  // destroy it here and return 0 than to destroy it
  // each place it is passed in.
  t->destroy ();
  delete t;
  t = 0;
  return 0;
}
Example #4
0
void
FE_ComponentHeader::compile_supports (UTL_NameList *supports)
{
  if (supports == 0)
    {
      return;
    }

  AST_Decl *d = 0;
  UTL_ScopedName *item = 0;
  AST_Interface *iface = 0;
  AST_Type *t = 0;
  long j = 0;
  long k = 0;

  // Compute expanded flattened non-repeating list of interfaces
  // which this one inherits from.

  for (UTL_NamelistActiveIterator l (supports); !l.is_done (); l.next ())
    {
      item = l.item ();

      // Check that scope stack is valid.
      if (idl_global->scopes ().top () == 0)
        {
          idl_global->err ()->lookup_error (item);

          // This is probably the result of bad IDL.
          // We will crash if we continue from here.
          throw Bailout ();
        }

      // Look it up.
      UTL_Scope *s = idl_global->scopes ().top ();

      d = s->lookup_by_name  (item, true);

      if (d == 0)
        {
          AST_Decl *sad = ScopeAsDecl (s);

          if (sad->node_type () == AST_Decl::NT_module)
            {
              AST_Module *m = AST_Module::narrow_from_decl (sad);

              d = m->look_in_prev_mods_local (item->last_component ());
            }
        }

      // Not found?
      if (d == 0)
        {
          idl_global->err ()->lookup_error (item);

          // This is probably the result of bad IDL.
          // We will crash if we continue from here.
          throw Bailout ();
        }

      // Remove typedefs, if any.
      if (d->node_type () == AST_Decl::NT_typedef)
        {
          d = AST_Typedef::narrow_from_decl (d)->primitive_base_type ();
        }

      AST_Decl::NodeType nt = d->node_type ();
      t = AST_Type::narrow_from_decl (d);

      if (nt == AST_Decl::NT_interface)
        {
          iface = AST_Interface::narrow_from_decl (d);

          // Undefined interface?
          if (!iface->is_defined ())
            {
              idl_global->err ()->inheritance_fwd_error (
                this->interface_name_,
                iface);

              continue;
            }

          // Local interface? (illegal for components to support).
          if (iface->is_local ())
            {
              idl_global->err ()->unconstrained_interface_expected (
                this->name (),
                iface->name ());

              continue;
           }
        }
      else if (nt == AST_Decl::NT_param_holder)
        {
          AST_Param_Holder *ph =
            AST_Param_Holder::narrow_from_decl (d);

          nt = ph->info ()->type_;

          if (nt != AST_Decl::NT_type
              && nt != AST_Decl::NT_interface)
            {
              idl_global->err ()->mismatched_template_param (
                ph->info ()->name_.c_str ());

              continue;
            }
        }
      else
        {
          idl_global->err ()->interface_expected (d);
          continue;
        }

      // OK, see if we have to add this to the list of interfaces
      // inherited from.
      this->compile_one_inheritance (t);
    }

  // OK, install in interface header.
  // First the flat list (all ancestors).
  if (this->iused_flat_ > 0)
    {
      ACE_NEW (this->inherits_flat_,
               AST_Interface *[this->iused_flat_]);

      for (j = 0; j < this->iused_flat_; ++j)
        {
          this->inherits_flat_[j] = this->iseen_flat_[j];
        }

      this->n_inherits_flat_ = this->iused_flat_;
    }
Example #5
0
int
be_visitor_connector_dds_exs::visit_connector (be_connector *node)
{
  if (node->imported ())
    {
      return 0;
    }

  if (!this->begin (node))
    {
      return -1;
    }

  // If we have a connector within a templated module
  if (! this->t_args_.is_empty ())
    {
      os_ << be_nl
          << this->node_->local_name () << "_exec_i::"
          << this->node_->local_name () << "_exec_i (void)"
          << be_idt_nl
          << ": " << this->base_tname_ << "_Connector_T";

      os_ << " <" << be_idt << be_idt_nl;

      os_ << "CCM_" << this->node_->flat_name ()
          << "_Traits," << be_nl;

      size_t slot = 1UL;

      for (FE_Utils::T_ARGLIST::CONST_ITERATOR i (this->t_args_);
          !i.done ();
          i.advance (), ++slot)
        {
          AST_Decl **item = 0;
          i.next (item);
          AST_Decl *d = *item;

          if (this->is_dds_type (node, d))
            {
              os_ << d->flat_name ()
                  << "_DDS_Traits";
            }
          else
            {
              os_ << d->name ();
            }

          bool needs_bool = false;
          bool is_fixed = false;
          FE_Utils::T_Param_Info *param = 0;

          if (this->t_params_->get (param, slot - 1) != 0)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("be_visitor_connector_dds_exh::")
                                 ACE_TEXT ("visit_connector - ")
                                 ACE_TEXT ("template param fetch failed\n ")),
                                -1);
            }

          if (d->node_type () == AST_Decl::NT_typedef)
            {
              /// Strip away all layers of typedef before narrowing.
              AST_Typedef *td = AST_Typedef::narrow_from_decl (d);
              d = td->primitive_base_type ();
            }

          /// No need to check if this is 0, but must narrow
          /// to call virtual function size_type() below.
          AST_Type *t = AST_Type::narrow_from_decl (d);

          switch (param->type_)
            {
              case AST_Decl::NT_type:
              case AST_Decl::NT_struct:
              case AST_Decl::NT_union:
                needs_bool = true;
                is_fixed = (t->size_type () == AST_Type::FIXED);
                break;
              default:
                break;
            }

          if (needs_bool)
            {
              os_ << "," << be_nl
                  << (is_fixed ? "true" : "false");
            }

          if (slot < this->t_args_.size ())
            {
              os_ << "," << be_nl;
            }
        }

      os_ << "> ()"
          << be_uidt << be_uidt << be_uidt_nl
          << "{" << be_nl
          << "}";

      os_ << be_nl_2
          << this->node_->local_name () << "_exec_i::~"
          << this->node_->local_name () << "_exec_i (void)" << be_nl
          << "{" << be_nl
          << "}";

      this->gen_exec_entrypoint_defn ();

    }

  os_ << be_uidt_nl
      << "}";

  return 0;
}
Example #6
0
// This serves for structs and unions.
void
AST_Structure::fwd_redefinition_helper (AST_Structure *&i,
                                        UTL_Scope *s)
{
  if (i == 0)
    {
      return;
    }

  // Fwd redefinition should be in the same scope, so local
  // lookup is all that's needed.
  AST_Decl *d =
    s->lookup_by_name_local (i->local_name (), false);

  AST_Structure *fd = 0;

  if (d != 0)
    {
      // Full definition must have the same prefix as the forward declaration.
      if (ACE_OS::strcmp (i->prefix (), d->prefix ()) != 0)
        {
          idl_global->err ()->error1 (UTL_Error::EIDL_PREFIX_CONFLICT,
                                      i);

          return;
        }

      AST_Decl::NodeType nt = d->node_type ();

      // If this interface has been forward declared in a previous opening
      // of the module it's defined in, the lookup will find the
      // forward declaration.
      if (nt == AST_Decl::NT_struct_fwd
          || nt == AST_Decl::NT_union_fwd)
        {
          AST_StructureFwd *fwd_def =
            AST_StructureFwd::narrow_from_decl (d);

          fd = fwd_def->full_definition ();
        }
      // In all other cases, the lookup will find an interface node.
      else if (nt == AST_Decl::NT_struct
               || nt == AST_Decl::NT_union)
        {
          fd = AST_Structure::narrow_from_decl (d);
        }

      // Successful?
      if (fd == 0)
        {
          // Should we give an error here?
          // No, look in fe_add_interface.
        }
      // If it is a forward declared interface..
      else if (!fd->is_defined ())
        {
          // Check if redefining in same scope. If a module is reopened,
          // a new pointer in created, and the first term below will be
          // true. In that case, the scoped names must be compared.
          if (fd->defined_in () != s
              && i->name ()->compare (fd->name ()) != 0)
            {
              idl_global->err ()->error2 (UTL_Error::EIDL_SCOPE_CONFLICT,
                                          i,
                                          fd);
            }
          // All OK, do the redefinition.
          else
            {
              AST_Decl::NodeType fd_nt = fd->node_type ();
              AST_Decl::NodeType i_nt = i->node_type ();

              // Only redefinition of the same kind.
              if (i_nt != fd_nt)
                {
                  idl_global->err ()->error2 (UTL_Error::EIDL_REDEF,
                                              i,
                                              fd);
                  return;
                }

              fd->redefine (i);
              AST_StructureFwd *fwd = fd->fwd_decl ();

              if (0 != fwd)
                {
                  // So the fwd decl won't destroy us at cleanup time.
                  // Unlike interfaces, valuetypes and components, it's
                  // ok to do this here, since fwd declared structs
                  // and unions must be defined in the same translation
                  // unit.
                  fwd->set_as_defined ();
                }

              // Use full definition node.
              i->destroy ();
              delete i;
              i = fd;
            }
        }
    }
}
Example #7
0
/*
 * Add this AST_Value node (a value type declaration) to this scope
 */
AST_BoxedValue *AST_Module::fe_add_boxed_valuetype(AST_BoxedValue *v)
{
   AST_Decl *predef;
   AST_Interface *fwd;

   /*
    * Already defined?
    */

   if ((predef = lookup_for_add (v)) != NULL)
   {
      /*
       * Treat fwd declared interfaces specially
       */

      if (predef->node_type() == AST_Decl::NT_value)
      {
         fwd = AST_Value::narrow_from_decl(predef);

         if (fwd == NULL)
            return NULL;

         if (!fwd->is_defined())
         { /* Forward declared and not defined yet */

            if (fwd->defined_in() != this)
            {
               idl_global->err()
               ->error3(UTL_Error::EIDL_SCOPE_CONFLICT, fwd, v, this);
               return NULL;
            }
         }

         /*
          * OK, not illegal redef of forward declaration. Now check whether
          * it has been referenced already
          */
         else if (referenced(predef))
         {
            idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, v, this, predef);
            return NULL;
         }
      }
      else if (!can_be_redefined(predef))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, v, this, predef);
         return NULL;
      }
      else if (referenced(predef))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, v, this, predef);
         return NULL;
      }
      else if (v->has_ancestor(predef))
      {
         idl_global->err()->redefinition_in_scope(v, predef);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope(v);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced(v, I_FALSE);

   return v;
}
Example #8
0
typename FULL_DECL::FWD_TYPE *
UTL_Scope::fe_add_fwd_intf_decl (typename FULL_DECL::FWD_TYPE *t)
{
  AST_Decl *d = 0;

  // Already defined and cannot be redefined? Or already used?
  if ((d = this->lookup_for_add (t)) != 0)
    {
      AST_Decl::NodeType nt = d->node_type ();

      // There used to be another check here ANDed with the one below:
      // d->defined_in () == this. But lookup_for_add() calls only
      // lookup_by_name_local(), which does not bump up the scope,
      // and look_in_prev_mods() for modules. If look_in_prev_mods()
      // finds something, the scopes will NOT be the same pointer
      // value, but the result is what we want.
      if (nt == FULL_DECL::NT)
        {
          FULL_DECL *itf = FULL_DECL::narrow_from_decl (d);

          if (itf == 0)
            {
              return 0;
            }

          // If the lookup found the full_definition member of another
          // interface_fwd, don't reset this full_definition. Otherwise
          // reset the member and set is_defined_ on i so it itf won't
          // get destroyed twice.
          if (itf->is_defined ())
            {
              if (!t->is_defined ())
                {
                  FULL_DECL *prev_fd =
                    FULL_DECL::narrow_from_decl (t->full_definition ());

                  prev_fd->destroy ();
                  // No need to delete prev_fd, the call to
                  // set_full_definition() below will do it.
                }

              t->set_full_definition (itf);
              t->set_as_defined ();
            }
        }

      if (!FE_Utils::can_be_redefined (d, t)) {

          idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
                                      t,
                                      ScopeAsDecl (this),
                                      d);
          return 0;
        }

      // No need to call referenced() for forward declared interafces,
      // they can be redeclared after referencing.

      if (t->has_ancestor (d))
        {
          idl_global->err ()->redefinition_in_scope  (t, d);
          return 0;
        }
    }

  // Add it to scope
  this->add_to_scope (t);

  // Add it to set of locally referenced symbols
  this->add_to_referenced (t,
                           false,
                           t->local_name ());

  return t;
}
Example #9
0
DECL *
UTL_Scope::fe_add_full_intf_decl (DECL *t)
{
  if (t->redef_clash ())
    {
      return 0;
    }

  AST_Decl *predef = 0;
  DECL *fwd = 0;

  // Already defined?
  if ((predef = this->lookup_for_add (t)) != 0)
    {
      // Treat fwd declared interfaces specially
      if (predef->node_type () == DECL::NT)
        {
          fwd = DECL::narrow_from_decl (predef);

          if (fwd == 0)
            {
              return 0;
            }

          // Forward declared and not defined yet.
          if (!fwd->is_defined ())
            {
              if (fwd->defined_in () != this)
                {
                  idl_global->err ()->error3 (UTL_Error::EIDL_SCOPE_CONFLICT,
                                              fwd,
                                              t,
                                              ScopeAsDecl (this));

                  return 0;
                }
            }
          // OK, not illegal redef of forward declaration. Now check whether.
          // it has been referenced already.
          else if (this->referenced (predef, t->local_name ()))
            {
              idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE,
                                          t,
                                          ScopeAsDecl (this),
                                          predef);

              return 0;
            }

        }
      else if (!FE_Utils::can_be_redefined (predef, t))
        {
          idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
                                      t,
                                      ScopeAsDecl (this),
                                      predef);

          return 0;
        }
      else if (referenced (predef, t->local_name ()) && !t->is_defined ())
        {
          idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE,
                                      t,
                                      ScopeAsDecl (this),
                                      predef);

          return 0;
        }
      else if (t->has_ancestor (predef))
        {
          idl_global->err ()->redefinition_in_scope (t, predef);

          return 0;
        }
    }

  // Add it to scope
  this->add_to_scope (t);

  // We do this for interfaces, valuetypes and components in
  // a different place than we do for structs and unions,
  // since fwd declared structs and unions must be defined in
  // the same translation unit.
  AST_InterfaceFwd *fd = t->fwd_decl ();

  if (0 != fd)
    {
      fd->set_as_defined ();
    }

  // Add it to set of locally referenced symbols
  this->add_to_referenced (t,
                           false,
                           t->local_name ());
  return t;
}
Example #10
0
AST_Decl *UTL_Scope::call_add()
{
   AST_Decl *result = NULL;
   AST_Decl *decl;

   UTL_ScopeActiveIterator *i;
   UTL_Scope *scope;

   i = new UTL_ScopeActiveIterator(this, UTL_Scope::IK_decls);

   while (!(i->is_done()))
   {
      decl = i->item();
      scope = 0;

      switch (decl->node_type())
      {

      case AST_Decl::NT_argument:
         result = add_argument(AST_Argument::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_array:
         result = add_array(AST_Array::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_attr:
         result = add_attribute(AST_Attribute::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_const:
         result = add_constant(AST_Constant::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_enum:
         scope = AST_Enum::narrow_from_decl(decl);
         result = add_enum(AST_Enum::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_enum_val:
         result = add_enum_val(AST_EnumVal::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_except:
         scope = AST_Exception::narrow_from_decl(decl);
         result = add_exception(AST_Exception::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_field:
         result = add_field(AST_Field::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_interface:
         scope = AST_Interface::narrow_from_decl(decl);
         result = add_interface(AST_Interface::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_interface_fwd:
         result = add_interface_fwd(AST_InterfaceFwd::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_module:
         scope = AST_Module::narrow_from_decl(decl);
         result = add_module(AST_Module::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_op:
         result = add_operation(AST_Operation::narrow_from_decl(decl));
         scope = AST_Operation::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_pre_defined:
         result =
         add_predefined_type(AST_PredefinedType::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_sequence:
         result = add_sequence(AST_Sequence::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_string:
         result = add_string(AST_String::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_struct:
         result = add_structure(AST_Structure::narrow_from_decl(decl));
         scope = AST_Structure::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_typedef:
         result = add_typedef(AST_Typedef::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_union:
         result = add_union(AST_Union::narrow_from_decl(decl));
         scope = AST_Union::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_union_branch:
         result = add_union_branch(AST_UnionBranch::narrow_from_decl(decl));
         break;
         //   case AST_Decl::NT_opaque:
         //  result = add_opaque(AST_Opaque::narrow_from_decl(decl));
         // break;

      case AST_Decl::NT_value:
         result = add_valuetype (AST_Value::narrow_from_decl (decl));
         scope = AST_Value::narrow_from_decl (decl);
         break;

      case AST_Decl::NT_value_fwd:
         result = add_valuetype_fwd(AST_ValueFwd::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_state_member:
         result = add_state_member(AST_StateMember::narrow_from_decl(decl));
         break;

      default:
         return NULL;
      }

      if (scope)
         scope->call_add();

      i->next();
   }

   delete i;
   return result;
}
Example #11
0
int
be_visitor_interface_sh::gen_abstract_ops_helper (
  be_interface *node,
  be_interface *base,
  TAO_OutStream *os)
{
  if (!base->is_abstract ())
    {
      return 0;
    }

  AST_Decl *d = 0;
  be_visitor_context ctx;
  ctx.stream (os);
  ctx.state (TAO_CodeGen::TAO_ROOT_SH);

  for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next ())
    {
      d = si.item ();

      if (d == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("be_visitor_interface_sh::")
                             ACE_TEXT ("gen_abstract_ops_helper - ")
                             ACE_TEXT ("bad node in this scope\n")),
                            -1);
        }

      UTL_ScopedName item_new_name (d->local_name (),
                                    0);

      if (d->node_type () == AST_Decl::NT_op)
        {
          be_operation *op = be_operation::narrow_from_decl (d);
          be_visitor_operation_sh op_visitor (&ctx);
          op_visitor.visit_operation (op);
        }
      else if (d->node_type () == AST_Decl::NT_attr)
        {
          AST_Attribute *attr = AST_Attribute::narrow_from_decl (d);
          be_attribute new_attr (attr->readonly (),
                                 attr->field_type (),
                                 &item_new_name,
                                 attr->is_local (),
                                 attr->is_abstract ());
          new_attr.set_defined_in (node);

          UTL_ExceptList *get_exceptions = attr->get_get_exceptions ();

          if (0 != get_exceptions)
            {
              new_attr.be_add_get_exceptions (get_exceptions->copy ());
            }

          UTL_ExceptList *set_exceptions = attr->get_set_exceptions ();

          if (0 != set_exceptions)
            {
              new_attr.be_add_set_exceptions (set_exceptions->copy ());
            }

          be_visitor_attribute attr_visitor (&ctx);
          attr_visitor.visit_attribute (&new_attr);
          ctx.attribute (0);
          new_attr.destroy ();
        }
    }

  return 0;
}
Example #12
0
/*
 * Look up a String * in local scope only
 */
AST_Decl * UTL_Scope::lookup_by_name_local (Identifier *e)
{
   UTL_ScopeListIterator si;
   // UTL_Scope * s;
   AST_Decl *d = NULL;

   if (DEBUG_SCOPES)
   {
      cout << "UTL_Scope::lookup_by_name_local(";

      if (e)
         e->dump(cout);
      else
         cout << "NAME_IS_NIL";

      cout << ") in ";

      if (pd_scoped_name)
         pd_scoped_name->dump(cout);
      else
         cout << "SCOPE_NAME_IS_NIL";

      cout << endl;
   }

   assert(pd_combined_scope);

   if (pd_combined_scope->pd_combined_decls && e)
   {
      AST_InterfaceFwd *fwd;
      AST_ValueFwd *vfwd;
      UtlMap<Identifier, AST_Decl*>::iterator iterDecl =
         pd_combined_scope->pd_combined_decls->find(*e);

      if (iterDecl.valid())
      {
         d = *iterDecl;

         if (d->node_type() == AST_Decl::NT_interface_fwd)
         {
            /*
             * Special case for forward declared interfaces. Look through the
             * forward declaration and retrieve the full definition
             */
            fwd = AST_InterfaceFwd::narrow_from_decl(d);

            if (fwd == NULL)
               d = NULL;
            else
               d = fwd->full_definition();
         }
         else if (d->node_type() == AST_Decl::NT_value_fwd)
         {
            /*
             * Special case for forward declared interfaces. Look through the
             * forward declaration and retrieve the full definition
             */
            vfwd = AST_ValueFwd::narrow_from_decl(d);

            if (vfwd == NULL)
               d = NULL;
            else
               d = vfwd->full_definition();
         }
      }
   }

   return d;
}
Example #13
0
bool idl_mapping_java::gen_interf(UTL_ScopedName *name, bool local,
                                  const std::vector<AST_Interface *> &inherits,
                                  const std::vector<AST_Interface *> &inherits_flat,
                                  const std::vector<AST_Attribute *> &attrs,
                                  const std::vector<AST_Operation *> &ops, const char *repoid)
{
  JavaName jn(name);
  JavaName jn_ops(jn, "Operations");
  JavaName jn_stub(jn, local ? "TAOPeer" : "Stub", true);

  string extends = jn.clazz_ + "Operations, "
                   + (inherits.size() ? "" : "org.omg.CORBA.Object");
  string extends_ops;

  for (size_t i = 0; i < inherits.size(); ++i) {
    extends += type(inherits[i]);
    extends_ops += type(inherits[i]) + "Operations";

    if (i != inherits.size() - 1) {
      extends += ", ";
      extends_ops += ", ";
    }
  }

  string extends_stub = string("i2jrt.TAO") +
                        (local ? "Local" : "") + "Object";

  string allRepoIds = '"' + string(repoid) + '"',
                      body_ops, body_stub =
                        "  protected " + jn_stub.clazz_ + "(long ptr) {\n"
                        "    super(ptr);\n"
                        "  }\n\n";

  for (size_t i = 0; i < attrs.size(); ++i) {
    AST_Attribute *attr = attrs[i];

    string signature = attr_signature_r(attr);
    body_ops +=
      "  " + signature + ";\n";
    body_stub +=
      "  public native " + signature + ";\n\n";

    if (!attr->readonly()) {
      string signature = attr_signature_w(attr);
      body_ops +=
        "  " + signature + ";\n";
      body_stub +=
        "  public native " + signature + ";\n\n";
    }
  }

  for (size_t i = 0; i < ops.size(); ++i) {
    string signature = op_signature(ops[i]);
    body_ops +=
      "  " + signature + ";\n";
    body_stub +=
      "  public native " + signature + ";\n\n";
  }

  for (size_t i = 0; i < inherits_flat.size(); ++i) {
    AST_Interface *base = inherits_flat[i];
    allRepoIds += ", \"" + string(base->repoID()) + '"';

    UTL_ScopeActiveIterator it(base, UTL_Scope::IK_decls);

    for (; !it.is_done(); it.next()) {
      AST_Decl *item = it.item();

      if (item->node_type() == AST_Decl::NT_attr) {
        AST_Attribute *attr = AST_Attribute::narrow_from_decl(item);

        string signature = attr_signature_r(attr);
        body_stub +=
          "  public native " + signature + ";\n\n";

        if (!attr->readonly()) {
          string signature = attr_signature_w(attr);
          body_stub +=
            "  public native " + signature + ";\n\n";
        }

      } else if (item->node_type() == AST_Decl::NT_op) {
        AST_Operation *op = AST_Operation::narrow_from_decl(item);
        body_stub +=
          "  public native " + op_signature(op) + ";\n\n";
      }
    }
  }

  bool ok(true);

  if (local) {
    JavaName jn_lb(jn, "LocalBase", true);
    string lb =
      "  private String[] _type_ids = {" + allRepoIds + "};\n\n"
      "  public String[] _ids() { return (String[])_type_ids.clone(); }\n";
    ok = java_class_gen(jn_lb, JABSTRACT_CLASS, lb.c_str(),
                        "org.omg.CORBA.LocalObject", jn.clazz_.c_str());
  }

  return ok && java_class_gen(jn, JINTERFACE, "", extends.c_str())
         && java_class_gen(jn_ops, JINTERFACE, body_ops.c_str(),
                           extends_ops.c_str())
         && java_class_gen(jn_stub, JCLASS, body_stub.c_str(),
                           extends_stub.c_str(), jn.clazz_.c_str())
         && gen_helper(jn, repoid, true) && gen_holder(jn);

  //FUTURE: server side
}
Example #14
0
int
be_visitor_connector_dds_exh::visit_connector (be_connector *node)
{
  if (node->imported ())
    {
      return 0;
    }

  if (!this->begin (node))
    {
      return -1;
    }

  // If we have a connector within a templated module
  if (! this->t_args_.is_empty ())
    {
      // Generate all needed dds_traits
      for (FE_Utils::T_ARGLIST::CONST_ITERATOR i (this->t_args_);
          !i.done ();
          i.advance ())
        {
          AST_Decl **item = 0;
          i.next (item);
          AST_Decl *d = *item;

          if (this->is_dds_type (node, d))
            {
              this->gen_dds_traits (d);
            }
        }

      // Generate connector traits
      this->gen_connector_traits ();

      os_ << be_nl_2
          << "class " << this->export_macro_.c_str () << " "
          << this->node_->local_name () << "_exec_i" << be_idt_nl
          << ": public " << this->base_tname_ << "_Connector_T";

      os_ << " <" << be_idt << be_idt_nl;

      os_ << "CCM_" << this->node_->flat_name ()
          << "_Traits," << be_nl;

      size_t slot = 1UL;

      for (FE_Utils::T_ARGLIST::CONST_ITERATOR i (this->t_args_);
          !i.done ();
          i.advance (), ++slot)
        {
          AST_Decl **item = 0;
          i.next (item);
          AST_Decl *d = *item;

          if (this->is_dds_type (node, d))
            {
              os_ << d->flat_name ()
                  << "_DDS_Traits";
            }
          else
            {
              os_ << d->name ();
            }

          bool needs_bool = false;
          bool is_fixed = false;
          FE_Utils::T_Param_Info *param = 0;

          if (this->t_params_->get (param, slot - 1) != 0)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("be_visitor_connector_dds_exh::")
                                 ACE_TEXT ("visit_connector - ")
                                 ACE_TEXT ("template param fetch failed\n ")),
                                -1);
            }

          if (d->node_type () == AST_Decl::NT_typedef)
            {
              /// Strip away all layers of typedef before narrowing.
              AST_Typedef *td = AST_Typedef::narrow_from_decl (d);
              d = td->primitive_base_type ();
            }

          /// No need to check if this is 0, but must narrow
          /// to call virtual function size_type() below.
          AST_Type *t = AST_Type::narrow_from_decl (d);

          switch (param->type_)
            {
              case AST_Decl::NT_type:
              case AST_Decl::NT_struct:
              case AST_Decl::NT_union:
                needs_bool = true;
                is_fixed = (t->size_type () == AST_Type::FIXED);
                break;
              default:
                break;
            }

          if (needs_bool)
            {
              os_ << "," << be_nl
                  << (is_fixed ? "true" : "false");
            }

          if (slot < this->t_args_.size ())
            {
              os_ << "," << be_nl;
            }
        }

      os_ << ">";

      os_ << be_uidt << be_uidt << be_uidt_nl
          << "{" << be_nl
          << "public:" << be_idt_nl
          << this->node_->local_name () << "_exec_i (void);" << be_nl
          << "virtual ~" << this->node_->local_name ()
          << "_exec_i (void);" << be_uidt_nl
          << "};";

      this->gen_exec_entrypoint_decl ();

    }

  os_ << be_uidt_nl
      << "}";

  /// Unset the flags in the port interfaces list. This is
  /// also done in visit_mirror_port(), but we must also do
  /// it here to catch a port interface that didn't come to
  /// us from an extended port or mirror port.
  for (ACE_Unbounded_Queue<be_interface *>::ITERATOR iter (
        this->port_ifaces_);
      !iter.done ();
      iter.advance ())
    {
      be_interface **item = 0;
      iter.next (item);

      (*item)->dds_connector_traits_done (false);
    }

  return 0;
}
be_valuetype *
be_visitor_amh_pre_proc::create_exception_holder (be_interface *node)
{
  // AMH exception holders require both of these.
  idl_global->valuetype_seen_ = true;

  idl_global->valuefactory_seen_ = true;

  const int inherit_count = 0;
  AST_Type **p_intf = 0;

  UTL_ScopedName *excep_holder_name =
    node->compute_name ("AMH_",
                        "ExceptionHolder");

  UTL_Scope *s = node->defined_in ();
  idl_global->scopes ().push (s);

  be_valuetype *excep_holder = 0;
  ACE_NEW_RETURN (excep_holder,
                  be_valuetype (excep_holder_name,
                                p_intf,
                                inherit_count,
                                0,
                                0,
                                0,
                                0,
                                0,
                                0,
                                0,
                                0,
                                0),
                  0);

  idl_global->scopes ().pop ();

  excep_holder->set_name (excep_holder_name);
  excep_holder->set_defined_in (node->defined_in ());

  // Set repo id to 0, so it will be recomputed on the next access,
  // and set the prefix to the node's prefix. All this is
  // necessary in case the node's prefix was modified after
  // its declaration.
  excep_holder->AST_Decl::repoID (0);
  excep_holder->prefix (const_cast<char*> (node->prefix ()));

  excep_holder->gen_fwd_helper_name ();

  // Now our customized valuetype is created, we have to
  // add now the operations and attributes to the scope.

  // initialize an iterator to iterate thru our scope
  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next ())
    {
      AST_Decl *d = si.item ();

      if (d == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_amh_pre_proc::"
                             "visit_interface - "
                             "bad node in this scope\n"),
                            0);
        }

      be_decl *op = be_decl::narrow_from_decl (d);
      AST_Decl::NodeType nt = d->node_type ();

      if (nt == AST_Decl::NT_attr)
        {
          AST_Attribute *attribute = AST_Attribute::narrow_from_decl (d);

          if (attribute == 0)
            {
              return 0;
            }

          this->create_raise_operation (op,
                                        excep_holder,
                                        GET_OPERATION);

          if (!attribute->readonly ())
            {
              this->create_raise_operation (op,
                                            excep_holder,
                                            SET_OPERATION);
            }
        }
      else if (nt == AST_Decl::NT_op)
        {
          this->create_raise_operation (op,
                                        excep_holder,
                                        NORMAL);
        }
      else
        {
          continue;
        }
    }

  return excep_holder;
}
/*
 * Compute the list of top-level interfaces this one inherits from
 */
void
FE_InterfaceHeader::compile_inheritance(UTL_NameList *nl)
{
   UTL_NamelistActiveIterator *l = new UTL_NamelistActiveIterator(nl);
   AST_Decl *d;
   AST_Interface *i;
   long k;

   iused = 0;
   /*
    * Compute expanded flattened non-repeating list of interfaces
    * which this one inherits from
    */

   while (!(l->is_done()))
   {
      /*
       * Check that scope stack is valid
       */

      if (idl_global->scopes()->top() == NULL)
      {
         idl_global->err()->lookup_error(l->item());
         return ;
      }

      /*
       * Look it up
       */
      d = idl_global->scopes()->top()->lookup_by_name(l->item(), I_TRUE);

      /*
       * Not found?
       */
      if (d == NULL)
      {
         idl_global->err()->lookup_error(l->item());
         return ;
      }

      /*
       * Not an interface?
       */
      while (d->node_type() == AST_Decl::NT_typedef)
         d = AST_Typedef::narrow_from_decl(d)->base_type();

      if (d->node_type() != AST_Decl::NT_interface)
      {
         idl_global->err()->inheritance_error(pd_interface_name, d);
         return ;
      }

      /*
       * OK, cast to an interface
       */
      i = AST_Interface::narrow_from_decl(d);

      if (i == NULL)
      {
         idl_global->err()->inheritance_error(pd_interface_name, d);
         return;
      }

      /*
       * Forward declared interface?
       */
      if (!i->is_defined())
      {
         idl_global->err()->inheritance_fwd_error(pd_interface_name, i);
         return ;
      }

      /*
       * OK, see if we have to add this to the list of interfaces
       * inherited from
       */
      compile_one_inheritance(i);

      /*
       * Next element in header list
       */
      l->next();
   }

   delete l;
   /*
    * OK, install in interface header
    */
   pd_inherits = new AST_Interface * [iused];

   for (k = 0; k < iused; k++)
      pd_inherits[k] = iseen[k];

   pd_n_inherits = iused;
}
Example #17
0
int
be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node)
{
  if (node->cli_stub_any_op_gen ()
      || node->imported ()
      || (node->is_local ()
          && !be_global->gen_local_iface_anyops ()))
    {
      return 0;
    }

  if (idl_global->dcps_sequence_type_defined (node->full_name ()))
    {
      return 0;
    }

  TAO_OutStream *os = this->ctx_->stream ();

  *os << be_nl_2
      << "// TAO_IDL - Generated from" << be_nl
      << "// " << __FILE__ << ":" << __LINE__ << be_nl_2;

  *os << be_global->core_versioning_begin () << be_nl;

  // These are no-ops for now, so we just generate them and return
  if (be_global->alt_mapping () && node->max_size ()->ev ()->u.ulval == 0)
    {
      be_type *bt =
        be_type::narrow_from_decl (node->base_type ());

      if (bt->node_type () == AST_Decl::NT_typedef)
        {
          be_typedef *td = be_typedef::narrow_from_decl (bt);
          bt = td->primitive_base_type ();
        }

      enum type_category
      {
        ANY_VALUE,
        ANY_OBJREF,
        ANY_ARRAY
      };

      type_category tc = ANY_VALUE;

      if (bt->node_type () == AST_Decl::NT_array)
        {
          tc = ANY_ARRAY;
        }
      else if (be_interface::narrow_from_decl (bt) != 0
               && be_valuetype::narrow_from_decl (bt) == 0)
        {
          tc = ANY_OBJREF;
        }

      *os << be_nl
          << "void operator<<= (" << be_idt_nl
          << "::CORBA::Any &_tao_any," << be_nl
          << "const std::vector<" << bt->full_name ()
          << "> &_tao_elem)" << be_uidt_nl
          << "{" << be_idt_nl
          << "TAO::";

      switch (tc)
        {
        case ANY_OBJREF:
          *os << "insert_objref_vector<"
              << bt->full_name () << "_ptr> (";

          break;
        case ANY_ARRAY:
          *os << "insert_array_vector<"
              << bt->full_name () << "_forany> (";

          break;
        default:
          *os << "insert_value_vector<"
              << bt->full_name () << "> (";

          break;
        }

      *os << be_idt_nl
          << "_tao_any," << be_nl
          << "_tao_elem);" << be_uidt << be_uidt_nl
          << "}";

      *os << be_nl_2
          << "::CORBA::Boolean operator>>= (" << be_idt_nl
          << "const ::CORBA::Any &_tao_any," << be_nl
          << "std::vector<" << bt->full_name ()
          << "> &_tao_elem)" << be_uidt_nl
          << "{" << be_idt_nl
          << "return" << be_idt_nl
          << "TAO::";

      switch (tc)
        {
        case ANY_OBJREF:
          *os << "extract_objref_vector<"
              << bt->full_name () << "_ptr> (";

          break;
        case ANY_ARRAY:
          *os << "extract_array_vector<"
              << bt->full_name () << "_forany> (";

          break;
        default:
          *os << "extract_value_vector<"
              << bt->full_name () << "> (";

          break;
        }

      *os << be_idt_nl
          << "_tao_any," << be_nl
          << "_tao_elem);" << be_uidt << be_uidt << be_uidt_nl
          << "}";

      *os << be_nl
          << be_global->core_versioning_end () << be_nl;

      node->cli_stub_any_op_gen (true);
      return 0;
    }

  // Since we don't generate CDR stream operators for types that
  // explicitly contain a local interface (at some level), we
  // must override these Any template class methods to avoid
  // calling the non-existent operators. The zero return value
  // will eventually cause CORBA::MARSHAL to be raised if this
  // type is inserted into an Any and then marshaled.
  if (node->is_local ())
    {
      *os << "namespace TAO" << be_nl
          << "{" << be_idt_nl
          << "template<>" << be_nl
          << "::CORBA::Boolean" << be_nl
          << "Any_Dual_Impl_T<" << node->name ()
          << ">::marshal_value (TAO_OutputCDR &)" << be_nl
          << "{" << be_idt_nl
          << "return false;" << be_uidt_nl
          << "}";

      *os << be_nl_2
          << "template<>" << be_nl
          << "::CORBA::Boolean" << be_nl
          << "Any_Dual_Impl_T<" << node->name ()
          << ">::demarshal_value (TAO_InputCDR &)" << be_nl
          << "{" << be_idt_nl
          << "return false;" << be_uidt_nl
          << "}" << be_uidt_nl
          << "}" << be_nl;
    }

  *os << be_global->core_versioning_end () << be_nl;

  // If this is non-zero, we want to call its tc_name()
  // for the TypeCode to pass to the Any operator impls.
  be_typedef *td = this->ctx_->tdef ();

  be_module *module = 0;
  if (node->is_nested ())
    {
      AST_Decl *d = node;
      AST_Decl::NodeType nt = d->node_type ();

      while (nt != AST_Decl::NT_root)
        {
          if (nt == AST_Decl::NT_module)
            {
              module = be_module::narrow_from_decl (d);
              break;
            }
          else
            {
              d = ScopeAsDecl (d->defined_in ());
              nt = d->node_type ();
            }
        }

      if (module != 0)
        {
          // Some compilers handle "any" operators in a namespace
          // corresponding to their module, others do not.
          *os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n";

          be_util::gen_nested_namespace_begin (os, module);

          // Copying insertion.
          *os << be_nl
              << "// Copying insertion." << be_nl
              << "void operator<<= (" << be_idt << be_idt_nl
              << "::CORBA::Any &_tao_any," << be_nl
              << "const ::" << node->name () << " &_tao_elem" << be_uidt_nl
              << ")" << be_uidt_nl
              << "{" << be_idt_nl

              << "TAO::Any_Dual_Impl_T< ::" << node->name () << ">::insert_copy ("
              << be_idt << be_idt_nl
              << "_tao_any," << be_nl
              << "::" << node->name () << "::_tao_any_destructor," << be_nl
              << "::" << (td != 0 ? td->tc_name () : node->tc_name ()) << "," << be_nl
              << "_tao_elem" << be_uidt_nl
              << ");" << be_uidt << be_uidt << be_uidt_nl
              << "}" << be_nl_2;

          // Non-copying insertion.
          *os << "// Non-copying insertion." << be_nl
              << "void operator<<= (" << be_idt << be_idt_nl
              << "::CORBA::Any &_tao_any," << be_nl
              << "::" << node->name () << " *_tao_elem)" << be_uidt
              << be_uidt_nl
              << "{" << be_idt_nl
              << "TAO::Any_Dual_Impl_T< ::" << node->name () << ">::insert ("
              << be_idt << be_idt_nl
              << "_tao_any," << be_nl
              << "::" << node->name () << "::_tao_any_destructor," << be_nl
              << "::" << (td != 0 ? td->tc_name () : node->tc_name ()) << "," << be_nl
              << "_tao_elem" << be_uidt_nl
              << ");" << be_uidt << be_uidt_nl
              << "}" << be_nl_2;

          // Extraction to non-const pointer (deprecated, just calls the other).
          *os << "// Extraction to non-const pointer (deprecated)." << be_nl
              << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl
              << "const ::CORBA::Any &_tao_any," << be_nl
              << "::" << node->name () << " *&_tao_elem)" << be_uidt
              << be_uidt_nl
              << "{" << be_idt_nl
              << "return _tao_any >>= const_cast<" << be_idt << be_idt_nl
              << "const ::" << node->name () << " *&> (" << be_nl
              << "_tao_elem" << be_uidt_nl
              << ");" << be_uidt << be_uidt_nl
              << "}" << be_nl_2;

          // Extraction to const pointer.
          *os << "// Extraction to const pointer." << be_nl
              << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl
              << "const ::CORBA::Any &_tao_any," << be_nl
              << "const ::" << node->name () << " *&_tao_elem)" << be_uidt
              << be_uidt_nl
              << "{" << be_idt_nl
              << "return" << be_idt_nl
              << "TAO::Any_Dual_Impl_T< ::" << node->name () << ">::extract ("
              << be_idt << be_idt_nl
              << "_tao_any," << be_nl
              << "::"  <<  node->name () << "::_tao_any_destructor," << be_nl
              << "::" << (td != 0 ? td->tc_name () : node->tc_name ()) << "," << be_nl
              << "_tao_elem" << be_uidt_nl
              << ");" << be_uidt << be_uidt << be_uidt_nl
              << "}";

          be_util::gen_nested_namespace_end (os, module);

          // Emit #else.
          *os << be_nl_2
              << "#else\n\n";
        }
    }

  *os << be_global->core_versioning_begin () << be_nl;

  // Copying insertion.
  *os << be_nl
      << "// Copying insertion." << be_nl
      << "void operator<<= (" << be_idt << be_idt_nl
      << "::CORBA::Any &_tao_any," << be_nl
      << "const " << node->name () << " &_tao_elem)" << be_uidt
      << be_uidt_nl
      << "{" << be_idt_nl

      << "TAO::Any_Dual_Impl_T<" << node->name () << ">::insert_copy ("
      << be_idt << be_idt_nl
      << "_tao_any," << be_nl
      << node->name () << "::_tao_any_destructor," << be_nl
      << (td != 0 ? td->tc_name () : node->tc_name ()) << "," << be_nl
      << "_tao_elem" << be_uidt_nl
      << ");" << be_uidt << be_uidt << be_uidt_nl
      << "}" << be_nl_2;

  // Non-copying insertion.
  *os << "// Non-copying insertion." << be_nl
      << "void operator<<= (" << be_idt << be_idt_nl
      << "::CORBA::Any &_tao_any," << be_nl
      << node->name () << " *_tao_elem)" << be_uidt
      << be_uidt_nl
      << "{" << be_idt_nl
      << "TAO::Any_Dual_Impl_T<" << node->name () << ">::insert ("
      << be_idt << be_idt_nl
      << "_tao_any," << be_nl
      << node->name () << "::_tao_any_destructor," << be_nl
      << (td != 0 ? td->tc_name () : node->tc_name ()) << "," << be_nl
      << "_tao_elem" << be_uidt_nl
      << ");" << be_uidt << be_uidt_nl
      << "}" << be_nl_2;

  // Extraction to non-const pointer (deprecated, just calls the other).
  *os << "// Extraction to non-const pointer (deprecated)." << be_nl
      << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl
      << "const ::CORBA::Any &_tao_any," << be_nl
      << node->name () << " *&_tao_elem)" << be_uidt
      << be_uidt_nl
      << "{" << be_idt_nl
      << "return _tao_any >>= const_cast<" << be_idt << be_idt_nl
      << "const " << node->name () << " *&> (" << be_nl
      << "_tao_elem" << be_uidt_nl
      << ");" << be_uidt << be_uidt_nl
      << "}" << be_nl_2;

  // Extraction to const pointer.
  *os << "// Extraction to const pointer." << be_nl
      << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl
      << "const ::CORBA::Any &_tao_any," << be_nl
      << "const " << node->name () << " *&_tao_elem)" << be_uidt
      << be_uidt_nl
      << "{" << be_idt_nl
      << "return" << be_idt_nl
      << "TAO::Any_Dual_Impl_T<" << node->name () << ">::extract ("
      << be_idt << be_idt_nl
      << "_tao_any," << be_nl
      << node->name () << "::_tao_any_destructor," << be_nl
      << (td != 0 ? td->tc_name () : node->tc_name ()) << "," << be_nl
      << "_tao_elem);" << be_uidt
      << be_uidt << be_uidt << be_uidt_nl
      << "}";

  *os << be_global->core_versioning_end () << be_nl;

  if (module != 0)
    {
      *os << "\n\n#endif";
    }

  node->cli_stub_any_op_gen (true);
  return 0;
}
Example #18
0
be_valuetype::FactoryStyle
be_valuetype::determine_factory_style (void)
{
  FactoryStyle factory_style = FS_UNKNOWN;


  if (this->is_abstract ())
    {
      return FS_NO_FACTORY;
    }

  // Check whether we have at least one operation or not.
  bool have_operation = this->have_operation ();
  bool have_factory = 0;

  // Try only our own scope.
  if (this->nmembers () > 0)
    {
      // Initialize an iterator to iterate thru our scope
      // Continue until each element is visited.
      for (UTL_ScopeActiveIterator si (this,
                                       UTL_Scope::IK_decls);
           !si.is_done ();
           si.next())
        {
          AST_Decl *d = si.item ();

          if (!d)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("be_valuetype::")
                                 ACE_TEXT ("determine_factory_style")
                                 ACE_TEXT ("bad node in this scope\n")),
                                factory_style);

            }

          AST_Decl::NodeType node_type = d->node_type ();

          if (node_type == AST_Decl::NT_factory)
            {
              have_factory = 1;
              break;
            }

        } // end of for loop
    } // end of if

  if (!have_operation && !have_factory)
    {
      factory_style = FS_CONCRETE_FACTORY;
    }
  else if (have_operation && !have_factory)
    {
      factory_style = FS_NO_FACTORY;
    }
  else
    {
      factory_style = FS_ABSTRACT_FACTORY;
    }

  return factory_style;
}
Example #19
0
int
be_visitor_interface_cs::gen_abstract_ops_helper (be_interface *node,
                                                  be_interface *base,
                                                  TAO_OutStream *os)
{
  // If the derived interface is local, the abstract parent's operation
  // was generated as pure virtual.
  if (!base->is_abstract () || node->is_local ())
    {
      return 0;
    }

  AST_Decl *d = 0;
  be_visitor_context ctx;
  ctx.stream (os);

  for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next ())
    {
      d = si.item ();

      if (d == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_interface_cs::"
                             "gen_abstract_ops_helper - "
                             "bad node in this scope\n"),
                            -1);
        }

      if (d->node_type () == AST_Decl::NT_op)
        {
          UTL_ScopedName *item_new_name  = 0;
          ACE_NEW_RETURN (item_new_name,
                          UTL_ScopedName (d->local_name ()->copy (),
                                          0),
                          -1);

          UTL_ScopedName *new_op_name =
            (UTL_ScopedName *)node->name ()->copy ();
          new_op_name->nconc (item_new_name);

          be_operation *op = be_operation::narrow_from_decl (d);
          UTL_ScopedName *old_op_name =
            (UTL_ScopedName *) op->name ()->copy ();
          op->set_name (new_op_name);
          op->set_defined_in (node);
          op->is_abstract (node->is_abstract ());

          ctx.state (TAO_CodeGen::TAO_OPERATION_CS);
          be_visitor_operation_cs op_visitor (&ctx);
          op_visitor.visit_operation (op);

          op->set_name (old_op_name);
          op->set_defined_in (base);
          op->is_abstract (base->is_abstract ());
        }
    }

  return 0;
}
Example #20
0
bool
be_valuetype::have_operation (void)
{
  // Check whatever scope we get for operations/attributes.

  bool have_operation = false;

  // Operations are either operations or attributes of:
  // -its own
  // -derived (abstract VT | VT | abstract iface | iface)
  //

  // First try our own scope.
  if (this->nmembers () > 0)
    {
      // Initialize an iterator to iterate thru our scope
      // Continue until each element is checked.
      for (UTL_ScopeActiveIterator si (this,
                                       UTL_Scope::IK_decls);
           !si.is_done ();
           si.next())
        {
          AST_Decl *d = si.item ();

          if (!d)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("be_valuetype::")
                                 ACE_TEXT ("has_operation")
                                 ACE_TEXT ("bad node in this scope\n")),
                                0);

            }

          AST_Decl::NodeType nt = d->node_type();

          if (nt == AST_Decl::NT_op || nt == AST_Decl::NT_attr)
            {
              have_operation = true;
              break;
            }
        } // end of for loop
    } // end of if

  if (! have_operation)
    {
      // Now traverse inheritance tree.
      long i;  // loop index
      long n_inherits = this->n_inherits ();
      AST_Type **inherits = this->inherits ();

      for (i = 0; i < n_inherits; ++i)
        {
          be_valuetype *vt = be_valuetype::narrow_from_decl (inherits[i]);

          if (vt != 0 && vt->have_operation ())
            {
              have_operation = true;
              break;
            }
        }
    }

  if (! have_operation)
    {
      // Check for operations on supported interfaces
      AST_Type * supported = this->supports_concrete ();

      if (supported != 0)
        {
          be_interface *intf =
            be_interface::narrow_from_decl (supported);

          if (intf != 0)
            {
              have_operation =
                be_valuetype::have_supported_op (intf);
            }
        }
    }

  return have_operation;
}
Example #21
0
int
be_visitor_interface_ss::gen_abstract_ops_helper (
  be_interface *node,
  be_interface *base,
  TAO_OutStream *os)
{
  if (!base->is_abstract ())
    {
      return 0;
    }

  AST_Decl *d = 0;
  be_visitor_context ctx;
  ctx.stream (os);
  ctx.state (TAO_CodeGen::TAO_ROOT_SS);

  for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next ())
    {
      d = si.item ();

      if (d == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("be_visitor_interface_ss::")
                             ACE_TEXT ("gen_abstract_ops_helper - ")
                             ACE_TEXT ("bad node in this scope\n")),
                            -1);
        }

      AST_Decl::NodeType nt = d->node_type ();

      UTL_ScopedName *item_new_name = 0;
      UTL_ScopedName *new_name = 0;

      if (AST_Decl::NT_op == nt || AST_Decl::NT_attr == nt)
        {
          ACE_NEW_RETURN (item_new_name,
                          UTL_ScopedName (d->local_name ()->copy (),
                                          0),
                          -1);

          new_name = (UTL_ScopedName *) node->name ()->copy ();
          new_name->nconc (item_new_name);
        }
      else
        {
          continue;
        }

      // We pass the node's is_abstract flag to the operation
      // constructor so we will get the right generated operation
      // body if we are regenerating an operation from an
      // abstract interface in a concrete interface or component.
      if (AST_Decl::NT_op == nt)
        {
          be_operation *op = be_operation::narrow_from_decl (d);
          UTL_ScopedName *old_name =
            (UTL_ScopedName *) op->name ()->copy ();
          op->set_name (new_name);
          op->set_defined_in (node);
          op->is_abstract (node->is_abstract ());

          be_visitor_operation_ss op_visitor (&ctx);
          op_visitor.visit_operation (op);

          op->set_name (old_name);
          op->set_defined_in (base);
          op->is_abstract (base->is_abstract ());
        }
      else if (AST_Decl::NT_attr == nt)
        {
          AST_Attribute *attr =
            AST_Attribute::narrow_from_decl (d);
          be_attribute new_attr (attr->readonly (),
                                 attr->field_type (),
                                 0,
                                 attr->is_local (),
                                 attr->is_abstract ());
          new_attr.set_defined_in (node);
          new_attr.set_name (new_name);

          UTL_ExceptList *get_exceptions =
            attr->get_get_exceptions ();

          if (0 != get_exceptions)
            {
              new_attr.be_add_get_exceptions (get_exceptions->copy ());
            }

          UTL_ExceptList *set_exceptions =
            attr->get_set_exceptions ();

          if (0 != set_exceptions)
            {
              new_attr.be_add_set_exceptions (set_exceptions->copy ());
            }

          be_visitor_attribute attr_visitor (&ctx);
          attr_visitor.visit_attribute (&new_attr);
          ctx.attribute (0);
          new_attr.destroy ();
        }
    }

  return 0;
}
Example #22
0
bool
be_valuetype::have_supported_op (be_interface * node)
{
  bool have_supported_op = false;

  if (node->nmembers () == 0)
    {
      return false;
    }

  // Initialize an iterator for supported interface elements
  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next())
    {
      AST_Decl *d = si.item ();

      if (d == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("be_valuetype::")
                             ACE_TEXT ("have_supported_op")
                             ACE_TEXT ("bad node in this scope\n")),
                            0);
        }

      AST_Decl::NodeType nt = d->node_type ();

      // Check the type of each element in the supported interface
      if (nt == AST_Decl::NT_op || nt == AST_Decl::NT_attr)
        {
          have_supported_op = true;
          break;
        }
    } // end for loop

  if (! have_supported_op)
    {
      // Now traverse inheritance tree.
      long i;  // loop index
      long n_inherits = node->n_inherits ();
      AST_Type **inherits = node->inherits ();

      for (i = 0; i < n_inherits; ++i)
        {
          be_interface * intf =
            be_interface::narrow_from_decl (inherits[i]);

          if (intf != 0)
            {
              have_supported_op =
                be_valuetype::have_supported_op (intf);

              if (have_supported_op)
                {
                  break;
                }
            }
        }
    }

  return have_supported_op;
}
Example #23
0
int
be_visitor_ami4ccm_rh_ex_idl::visit_interface (be_interface *node)
{
  os_ << be_nl
      << "// TAO_IDL - Generated from" << be_nl
      << "// " << __FILE__ << ":" << __LINE__;

  os_ << be_nl_2
      << "local interface AMI4CCM_"
      << node->original_local_name ()
      << "ReplyHandler" << be_idt_nl
      << ": ";

  long n_parents = node->n_inherits ();

  if (n_parents == 0)
    {
      os_ << "::CCM_AMI::ReplyHandler";
    }
  else
    {
      os_ << be_idt;

      for (long i = 0; i < n_parents; ++i)
        {
          if (i != 0)
            {
              os_ << "," << be_nl;
            }

          AST_Type *parent = node->inherits ()[i];

          AST_Decl *d = ScopeAsDecl (parent->defined_in ());

          bool global = (d->node_type () == AST_Decl::NT_root);

          os_ << (global ? "" : "::") << d->full_name ()
              << "::AMI4CCM_" << parent->original_local_name ()
              << "ReplyHandler";
        }

      os_ << be_uidt;
    }

  os_ << be_uidt_nl
      << "{" << be_idt;

  if (this->visit_scope (node) == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("be_visitor_ami4ccm_rh_ex_idl")
                         ACE_TEXT ("::visit_interface - ")
                         ACE_TEXT ("visit_scope() failed\n")),
                        -1);
    }

  os_ << be_uidt_nl
      << "};";

  return 0;
}
Example #24
0
// Look up a branch in an enum which is the discriminator type for this
// union, based on the label value which must be an enumerator in that
// enum.
AST_UnionBranch *
AST_Union::lookup_enum (AST_UnionBranch *b)
{
  AST_UnionLabel *label = b->label();
  AST_Expression *lv = label->label_val ();
  AST_Enum *e = AST_Enum::narrow_from_decl (this->pd_disc_type);
  AST_Decl *d = 0;
  AST_UnionBranch       *fb = 0;

  if (e == 0)
    {
      return 0;
    }

  if (lv == 0)
    {
      return b;
    }

  // Expecting a symbol label.
  if (lv->ec () != AST_Expression::EC_symbol)
    {
      idl_global->err ()->enum_val_expected (this,
                                             label);
      return b;
    }

  // See if the symbol defines a constant in the discriminator enum.
  UTL_ScopedName *sn = lv->n ();
  d = e->lookup_by_name (sn,
                         true);

  if (d == 0 || d->defined_in () != e)
    {
      idl_global->err ()->enum_val_lookup_failure (this,
                                                   e,
                                                   sn);
      return b;
    }

  // OK, now see if this symbol is already used as the label of
  // some other branch.
  for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_decls);
       !i.is_done();
       i.next ())
    {
      d = i.item ();

      if (d->node_type () == AST_Decl::NT_union_branch)
        {
          fb = AST_UnionBranch::narrow_from_decl (d);

          if (fb == 0)
            {
              continue;
            }

          if (fb->label() != 0
              && fb->label ()->label_kind () == AST_UnionLabel::UL_label
              && fb->label ()->label_val ()->compare (lv))
            {
              idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH,
                                          this,
                                          b);
              return b;
            }
        }
    }

  return 0;
}
Example #25
0
// Visit the Constant node and its scope.
int
be_visitor_constant_ch::visit_constant (be_constant *node)
{
  if (node->cli_hdr_gen () || node->imported ())
    {
      return 0;
    }

  TAO_OutStream *os = this->ctx_->stream ();

  *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
      << "// " << __FILE__ << ":" << __LINE__;

  // If we are defined in the outermost scope, then the value is assigned
  // to us here itself, else it will be in the *.cpp file.

  AST_Decl::NodeType nt = AST_Decl::NT_pre_defined;
  AST_Decl *tdef = node->constant_value ()->get_tdef ();
  AST_Decl::NodeType bnt = AST_Decl::NT_pre_defined;
  AST_Expression::ExprType etype = node->et ();
  AST_Decl::NodeType snt = node->defined_in ()->scope_node_type ();

  if (tdef != 0)
    {
      nt = tdef->node_type ();
      be_typedef *td = be_typedef:: narrow_from_decl (tdef);
      bnt = td->base_node_type ();
    }

  *os << be_nl_2;

  if (! node->is_nested ())
    {
      *os << "const ";

      if (etype == AST_Expression::EV_enum)
        {
          *os << node->enum_full_name ();
        }
      else if (nt == AST_Decl::NT_typedef)
        {
          *os << tdef->name ();
        }
      else
        {
          *os << node->exprtype_to_string ();
        }

      *os << " " << node->local_name ();
    }
  // We are nested inside an interface or a valuetype.
  else
    {
      if (snt != AST_Decl::NT_module)
        {
          *os << "static ";
        }
      else if (!be_global->gen_inline_constants ())
        {
          *os << "extern " << be_global->stub_export_macro () << " ";
        }

      *os << "const ";

      if (etype == AST_Expression::EV_enum)
        {
          *os << node->enum_full_name ();
        }
      else if (nt == AST_Decl::NT_typedef)
        {
          if (bnt == AST_Decl::NT_string || bnt == AST_Decl::NT_wstring)
            {
              *os << node->exprtype_to_string ();
            }
          else
            {
              *os << tdef->name ();
            }
        }
      else
        {
          *os << node->exprtype_to_string ();
        }

      *os << " " << node->local_name ();
    }

  // If this is true, can't generate inline constants.
  bool forbidden_in_class = (snt != AST_Decl::NT_root
                             && snt != AST_Decl::NT_module
                             && (etype == AST_Expression::EV_string
                                 || etype == AST_Expression::EV_wstring
                                 || etype == AST_Expression::EV_float
                                 || etype == AST_Expression::EV_double
                                 || etype == AST_Expression::EV_longdouble));

  if (!node->is_nested ()
      || (be_global->gen_inline_constants () && !forbidden_in_class))
    {
      *os << " = " << node->constant_value ();
    }

  *os << ";";

  node->cli_hdr_gen (true);
  return 0;
}
/*
 * Compute the list of top-level values this one inherits from
 */
void
FE_ValueInheritanceSpec::compile_value_inheritance(UTL_NameList *nl)
{
   UTL_NamelistActiveIterator *l = new UTL_NamelistActiveIterator(nl);
   AST_Decl *d;
   AST_Value *i;
   long k;
   long count = 0;
   bool present;

   while (!(l->is_done()))
   {
      count++;
      l->next();
   }

   delete l;

   // count is an upper bound on inherited values
   pd_inherits = new AST_Value * [count];

   l = new UTL_NamelistActiveIterator(nl);

   /*
    * Compute expanded flattened non-repeating list of values
    * which this one inherits from
    */

   while (!(l->is_done()))
   {
      /*
       * Check that scope stack is valid
       */

      if (idl_global->scopes()->top() == NULL)
      {
         idl_global->err()->lookup_error(l->item());
         return ;
      }

      /*
       * Look it up
       */
      d = idl_global->scopes()->top()->lookup_by_name(l->item(), I_TRUE);

      /*
       * Not found?
       */
      if (d == NULL)
      {
         idl_global->err()->lookup_error(l->item());
         return ;
      }

      /*
       * Not a value?
       */

      while (d->node_type() == AST_Decl::NT_typedef)
         d = AST_Typedef::narrow_from_decl(d)->base_type();

      if (d->node_type() != AST_Decl::NT_value)
      {
         idl_global->err()->value_inheritance_error(d);
         return ;
      }

      /*
       * OK, cast to an value
       */
      i = AST_Value::narrow_from_decl(d);

      if (i == NULL)
         idl_global->err()->value_inheritance_error(d);

      /*
       * Forward declared value?
       */
      if (!i->is_defined())
      {
         idl_global->err()->value_inheritance_fwd_error(i);
         return ;
      }

      /*
       * OK, see if we have to add this to the list of values
       * inherited from
       */
      present = FALSE;

      for (k = 0; k < pd_n_inherits; k++)
      {
         present = (pd_inherits[k] == i);

         if (present)
         {
            break;
         }
      }

      if (!present)
      {
         pd_inherits[pd_n_inherits++] = i;
      }

      /*
       * Next element in header list
       */
      l->next();
   }

   delete l;
}
Example #27
0
be_interface *
be_visitor_ami_pre_proc::create_reply_handler (be_interface *node)
{
  // We're at global scope here so we need to fool the scope stack
  // for a minute so the correct repo id can be calculated at
  // interface construction time.
  UTL_Scope *s = node->defined_in ();
  idl_global->scopes ().push (s);

  // Create the reply handler name.
  ACE_CString reply_handler_local_name;

  this->generate_name (reply_handler_local_name,
                       "AMI_",
                       node->name ()->last_component ()->get_string(),
                       "Handler");

  UTL_ScopedName *reply_handler_name =
    static_cast<UTL_ScopedName *> (node->name ()->copy ());

  reply_handler_name->last_component ()->replace_string (
    reply_handler_local_name.c_str ());

  long n_parents = 0;
  AST_Type **p_intf =
    this->create_inheritance_list (node, n_parents);

  if (p_intf == 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                        "(%N:%l) be_visitor_ami_pre_proc::visit_interface - "
                        "bad inheritance list\n"),
                        0);
    }

  be_interface *reply_handler = 0;
  ACE_NEW_RETURN (reply_handler,
                  be_interface (reply_handler_name, // name
                                p_intf,             // list of inherited
                                n_parents,          // number of inherited
                                0,                  // list of all ancestors
                                0,                  // number of ancestors
                                0,                  // non-local
                                0),                 // non-abstract
                  0);

  // Back to reality.
  idl_global->scopes ().pop ();

  reply_handler->set_name (reply_handler_name);
  reply_handler->set_defined_in (s);

  /// Store here for convenient retrieval later.
  node->ami_handler (reply_handler);

  // Set repo id to 0, so it will be recomputed on the next access,
  // and set the prefix to the node's prefix. All this is
  // necessary in case the node's prefix was modified after
  // its declaration.
  reply_handler->AST_Decl::repoID (0);
  reply_handler->prefix (const_cast<char*> (node->prefix ()));

  reply_handler->gen_fwd_helper_name ();

  // Now our customized reply handler is created, we have to
  // add the operations and attributes to the scope.
  // Imported nodes get admitted here, so they can get
  // the reply handler operations added, in case they are
  // needed in the inheritance graph traversal for a
  // child reply handler. However, no exception holder
  // stuff is executed for an imported node.
  if (node->nmembers () > 0)
    {
      this->elem_number_ = 0;
      // Initialize an iterator to iterate thru our scope.

      for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
           !si.is_done ();
           si.next ())
        {
          AST_Decl *d = si.item ();

          if (!d)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "(%N:%l) be_visitor_ami_pre_proc::visit_interface - "
                                 "bad node in this scope\n"),
                                0);
            }

          if (d->node_type () == AST_Decl::NT_attr)
            {
              be_attribute *attribute = be_attribute::narrow_from_decl (d);

              if (attribute)
                {
                  be_operation *get_operation =
                    this->generate_get_operation (attribute);

                  this->create_reply_handler_operation (get_operation,
                                                        reply_handler);

                  this->create_excep_operation (get_operation,
                                                reply_handler);

                  get_operation->destroy ();
                  delete get_operation;
                  get_operation = 0;

                  if (!attribute->readonly ())
                    {
                      be_operation *set_operation =
                        this->generate_set_operation (attribute);

                      this->create_reply_handler_operation (set_operation,
                                                            reply_handler);

                      this->create_excep_operation (set_operation,
                                                    reply_handler);

                      set_operation->destroy ();
                      delete set_operation;
                      set_operation = 0;
                    }
                }
            }
          else
            {
              be_operation* operation = be_operation::narrow_from_decl (d);

              if (operation)
                {
                  this->create_reply_handler_operation (operation,
                                                        reply_handler);

                  this->create_excep_operation (operation,
                                                reply_handler);
                }
            }
        } // end of while loop
    } // end of if

  reply_handler->is_ami_rh (true);
  reply_handler->is_ami4ccm_rh (true);

  return reply_handler;
}
int
be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node,
                                               be_interface *response_handler,
                                               be_valuetype *exception_holder)
{
  // Now our customized valuetype is created, we have to
  // add now the operations and attributes to the scope.

  this->elem_number_ = 0;

  // Initialize an iterator to iterate thru our scope.
  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next ())
    {
      AST_Decl *d = si.item ();

      if (!d)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_amh_pre_proc::"
                             "add_rh_node_members - "
                             "bad node in this scope\n"),
                            0);
        }

      AST_Decl::NodeType nt = d->node_type ();
      int status = 0;

      if (nt == AST_Decl::NT_attr)
        {
          be_attribute *attr = be_attribute::narrow_from_decl (d);

          if (attr != 0)
            {
              status =
                this->create_response_handler_attribute (attr,
                                                         response_handler,
                                                         exception_holder);

              if (status == -1)
                {
                  ACE_ERROR_RETURN ((LM_ERROR,
                                    "(%N:%l) be_visitor_amh_pre_proc::"
                                    "add_rh_node_members - "
                                    "attribute creation failed\n"),
                                    0);
                }
            }
        }
      else if (nt == AST_Decl::NT_op)
        {
          be_operation* operation = be_operation::narrow_from_decl (d);

          if (operation != 0)
            {
              status =
                this->create_response_handler_operation (operation,
                                                         response_handler,
                                                         exception_holder);

              if (status == -1)
                {
                  ACE_ERROR_RETURN ((LM_ERROR,
                                    "(%N:%l) be_visitor_amh_pre_proc::"
                                    "add_rh_node_members - "
                                    "operation creation failed\n"),
                                    0);
                }
            }
        }
      else
        {
          continue;
        }
    }

  return 1;
}
Example #29
0
int
be_visitor_interface_any_op_cs::visit_interface (be_interface *node)
{
  if (node->cli_stub_any_op_gen ()
      || node->imported ()
      || (node->is_local () && !be_global->gen_local_iface_anyops ()))
    {
      return 0;
    }

  TAO_OutStream *os = this->ctx_->stream ();

  *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
      << "// " << __FILE__ << ":" << __LINE__;

  // All template specializations must be generated before the instantiations
  // in the operators.

  *os << be_global->core_versioning_begin () << be_nl;

  if (! node->is_abstract ())
    {
      *os << be_nl_2
          << "namespace TAO" << be_nl
          << "{" << be_idt_nl
          << "template<>" << be_nl
          << "::CORBA::Boolean" << be_nl
          << "Any_Impl_T<" << node->name () << ">::to_object ("
          << be_idt <<  be_idt_nl
          << "::CORBA::Object_ptr &_tao_elem) const" << be_uidt
          << be_uidt_nl
          << "{" << be_idt_nl
          << "_tao_elem = ::CORBA::Object::_duplicate (this->value_);" << be_nl
          << "return true;" << be_uidt_nl
          << "}" << be_uidt_nl
          << "}";
    }

  if (node->is_abstract () || node->has_mixed_parentage ())
    {
      *os << be_nl_2
          << "namespace TAO" << be_nl
          << "{" << be_idt_nl
          << "template<>" << be_nl
          << "::CORBA::Boolean" << be_nl
          << "Any_Impl_T<" << node->name ()
          << ">::to_abstract_base ("
          << be_idt <<  be_idt_nl
          << "::CORBA::AbstractBase_ptr &_tao_elem) const" << be_uidt
          << be_uidt_nl
          << "{" << be_idt_nl
          << "_tao_elem = ::CORBA::AbstractBase::_duplicate (this->value_);"
          << be_nl
          << "return true;" << be_uidt_nl
          << "}" << be_uidt_nl
          << "}";
    }

  // Since we don't generate CDR stream operators for types that
  // explicitly contain a local interface (at some level), we
  // must override these Any template class methods to avoid
  // calling the non-existent operators. The zero return value
  // will eventually cause CORBA::MARSHAL to be raised if this
  // type is inserted into an Any and then marshaled.
  if (node->is_local ())
    {
      *os << be_nl_2
          << "namespace TAO" << be_nl
          << "{" << be_idt_nl
          << "template<>" << be_nl
          << "::CORBA::Boolean" << be_nl
          << "Any_Impl_T<" << node->name ()
          << ">::marshal_value (TAO_OutputCDR &)" << be_nl
          << "{" << be_idt_nl
          << "return false;" << be_uidt_nl
          << "}";

      *os << be_nl_2
          << "template<>" << be_nl
          << "::CORBA::Boolean" << be_nl
          << "Any_Impl_T<" << node->name ()
          << ">::demarshal_value (TAO_InputCDR &)" << be_nl
          << "{" << be_idt_nl
          << "return false;" << be_uidt_nl
          << "}" << be_uidt_nl
          << "}";
    }

  *os << be_global->core_versioning_end () << be_nl;

  be_module *module = 0;

  if (node->is_nested ())
    {
      AST_Decl *d = node;
      AST_Decl::NodeType nt = d->node_type ();

      while (nt != AST_Decl::NT_root)
        {
          if (nt == AST_Decl::NT_module)
            {
              module = be_module::narrow_from_decl (d);
              break;
            }
          else
            {
              d = ScopeAsDecl (d->defined_in ());
              nt = d->node_type ();
            }
        }

      if (module != 0)
        {
          // Some compilers handle "any" operators in a namespace corresponding
          // to their module, others do not.
          *os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n";

          be_util::gen_nested_namespace_begin (os, module);

          // emit  nested variation of any operators
          *os << be_nl_2
              << "/// Copying insertion." << be_nl
              << "void" << be_nl
              << "operator<<= (" << be_idt << be_idt_nl
              << "::CORBA::Any &_tao_any," << be_nl
              << node->local_name () << "_ptr _tao_elem)" << be_uidt << be_uidt_nl
              << "{" << be_idt_nl
              << node->local_name () << "_ptr _tao_objptr =" << be_idt_nl
              << node->local_name () << "::_duplicate (_tao_elem);" << be_uidt_nl
              << "_tao_any <<= &_tao_objptr;" << be_uidt_nl
              << "}" << be_nl_2;

          *os << "/// Non-copying insertion." << be_nl
              << "void" << be_nl
              << "operator<<= (" << be_idt << be_idt_nl
              << "::CORBA::Any &_tao_any," << be_nl
              << node->local_name () << "_ptr *_tao_elem)" << be_uidt << be_uidt_nl
              << "{" << be_idt_nl
              << "TAO::Any_Impl_T<" << node->local_name () << ">::insert ("
              << be_idt << be_idt_nl
              << "_tao_any," << be_nl
              << node->local_name () << "::_tao_any_destructor," << be_nl
              << node->tc_name ()->last_component () << "," << be_nl
              << "*_tao_elem);" << be_uidt
              << be_uidt << be_uidt_nl
              << "}" << be_nl_2;

          *os << "::CORBA::Boolean" << be_nl
              << "operator>>= (" << be_idt << be_idt_nl
              << "const ::CORBA::Any &_tao_any," << be_nl
              << node->local_name () << "_ptr &_tao_elem)" << be_uidt << be_uidt_nl
              << "{" << be_idt_nl
              << "return" << be_idt_nl
              << "TAO::Any_Impl_T<" << node->local_name () << ">::extract ("
              << be_idt << be_idt_nl
              << "_tao_any," << be_nl
              << node->local_name () << "::_tao_any_destructor," << be_nl
              << node->tc_name ()->last_component () << "," << be_nl
              << "_tao_elem);" << be_uidt << be_uidt
              << be_uidt << be_uidt_nl
              << "}";

          be_util::gen_nested_namespace_end (os, module);

          // Emit #else.
          *os << be_nl_2
              << "#else\n";
        }
    }

  *os << be_global->core_versioning_begin () << be_nl;

  *os << be_nl_2
      << "/// Copying insertion." << be_nl
      << "void" << be_nl
      << "operator<<= (" << be_idt << be_idt_nl
      << "::CORBA::Any &_tao_any," << be_nl
      << node->full_name () << "_ptr _tao_elem)" << be_uidt << be_uidt_nl
      << "{" << be_idt_nl
      << node->full_name () << "_ptr _tao_objptr =" << be_idt_nl
      << node->full_name () << "::_duplicate (_tao_elem);" << be_uidt_nl
      << "_tao_any <<= &_tao_objptr;" << be_uidt_nl
      << "}" << be_nl_2;

  *os << "/// Non-copying insertion." << be_nl
      << "void" << be_nl
      << "operator<<= (" << be_idt << be_idt_nl
      << "::CORBA::Any &_tao_any," << be_nl
      << node->full_name () << "_ptr *_tao_elem)" << be_uidt << be_uidt_nl
      << "{" << be_idt_nl
      << "TAO::Any_Impl_T<" << node->name () << ">::insert ("
      << be_idt << be_idt_nl
      << "_tao_any," << be_nl
      << node->name () << "::_tao_any_destructor," << be_nl
      << node->tc_name () << "," << be_nl
      << "*_tao_elem);" << be_uidt
      << be_uidt << be_uidt_nl
      << "}" << be_nl_2;

  *os << "::CORBA::Boolean" << be_nl
      << "operator>>= (" << be_idt << be_idt_nl
      << "const ::CORBA::Any &_tao_any," << be_nl
      << node->full_name () << "_ptr &_tao_elem)" << be_uidt << be_uidt_nl
      << "{" << be_idt_nl
      << "return" << be_idt_nl
      << "TAO::Any_Impl_T<" << node->name () << ">::extract ("
      << be_idt << be_idt_nl
      << "_tao_any," << be_nl
      << node->name () << "::_tao_any_destructor," << be_nl
      << node->tc_name () << "," << be_nl
      << "_tao_elem);" << be_uidt
      << be_uidt << be_uidt << be_uidt_nl
      << "}" << be_nl;

  *os << be_global->core_versioning_end () << be_nl;

  if (module != 0)
    {
      *os << "\n\n#endif";
    }

  // All we have to do is to visit the scope and generate code.
  if (this->visit_scope (node) == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_interface::visit_interface - "
                         "codegen for scope failed\n"), -1);
    }

  node->cli_stub_any_op_gen (1);
  return 0;
}
Example #30
0
void
be_component::scan (UTL_Scope *s)
{
  if (s == 0)
    {
      return;
    }

  AST_Extended_Port *ep = 0;
  AST_Mirror_Port *mp = 0;
  AST_Uses *u = 0;
  AST_Provides *p = 0;
  AST_Attribute *a = 0;
  AST_Decl::NodeType my_nt;
  AST_Decl::NodeType scope_nt;

  for (UTL_ScopeActiveIterator i (s, UTL_Scope::IK_both);
       !i.is_done ();
       i.next ())
    {
      AST_Decl *d = i.item ();

      switch (d->node_type ())
        {
          case AST_Decl::NT_provides:
            ++this->n_provides_;
            p = AST_Provides::narrow_from_decl (d);

            if (!p->provides_type ()->is_local ())
              {
                ++this->n_remote_provides_;
              }

            continue;
          case AST_Decl::NT_uses:
            ++this->n_uses_;
            u = AST_Uses::narrow_from_decl (d);

            if (u->is_multiple ())
              {
                this->has_uses_multiple_ = true;
              }

            if (!u->uses_type ()->is_local ())
              {
                ++this->n_remote_uses_;
              }

            continue;
          case AST_Decl::NT_publishes:
            ++this->n_publishes_;
            continue;
          case AST_Decl::NT_consumes:
            ++this->n_consumes_;
            continue;
          case AST_Decl::NT_emits:
            ++this->n_emits_;
            continue;
          case AST_Decl::NT_ext_port:
            ep = AST_Extended_Port::narrow_from_decl (d);
            this->scan (ep->port_type ());
            continue;
          case AST_Decl::NT_mirror_port:
            mp = AST_Mirror_Port::narrow_from_decl (d);
            this->mirror_scan (mp->port_type ());
            continue;
          case AST_Decl::NT_attr:
            a = AST_Attribute::narrow_from_decl (d);;

            if (!a->readonly ())
              {
                my_nt = this->node_type ();
                scope_nt =
                  ScopeAsDecl (a->defined_in ())->node_type ();

                /// Attributes coming from a porttype appear
                /// only on connectors.
                if (my_nt == AST_Decl::NT_component
                    && scope_nt == AST_Decl::NT_porttype)
                  {
                    continue;
                  }

                this->has_rw_attributes_ = true;
              }

            continue;
          default:
            continue;
        }
    }

  AST_Component *c = AST_Component::narrow_from_scope (s);
  AST_Interface *iface = 0;

  if (c != 0)
    {
      for (long i = 0; i < c->n_supports (); ++i)
        {
          // See if the supported interfaces (if any) have attributes.
          // If CORBA::Object is supported, DeclAsScope will evaluate
          // to 0 and the call to scan() will return immediately.
          this->scan (DeclAsScope (c->supports ()[i]));
        }

      // Check the base component. If there is none, the arg to scan()
      // will be 0 and the call will return immediately.
      this->scan (c->base_component ());
    }
  else if ((iface = AST_Interface::narrow_from_scope (s)) != 0)
    {
      for (long i = 0; i < iface->n_inherits (); ++i)
        {
          // Will pick up a chain of inheritance,
          // no need to use inherits_flat().
          this->scan (DeclAsScope (iface->inherits ()[i]));
        }
    }
}