Ejemplo n.º 1
0
int
be_visitor_event_source_desc::visit_publishes (
  be_publishes *node)
{
  AST_Type *obj = node->publishes_type ();
  const char *port_name =
    node->local_name ()->get_string ();

  os_ << be_nl_2;

  os_ << "{" << be_idt_nl
      << "ACE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
      << "                  mon," << be_nl
      << "                  this->context_->"
      << port_name << "_lock_," << be_nl
      << "                  0);" << be_nl_2;

  os_ << "::CIAO::Servant::describe_pub_event_source<"
      << be_idt_nl
      << "::" << obj->full_name () << "Consumer_var> ("
      << be_idt_nl
      << "\"" << port_name << "\"," << be_nl
      << "\"" << obj->repoID () << "\"," << be_nl
      << "this->context_->ciao_publishes_"
      << port_name << "_," << be_nl
      << "safe_retval," << be_nl
      << slot_++ << "UL);" << be_uidt << be_uidt;

  os_ << be_uidt_nl
      << "}";

  return 0;
}
Ejemplo n.º 2
0
int
be_visitor_receptacle_desc::visit_uses (be_uses *node)
{
  ACE_CString prefix (this->ctx_->port_prefix ());
  prefix += node->local_name ()->get_string ();
  const char *port_name = prefix.c_str ();

  AST_Type *obj = node->uses_type ();
  bool const is_multiple = node->is_multiple ();

  os_ << be_nl_2;

  ACE_CString sname_str (comp_->full_name ());
  const char *sname = sname_str.c_str ();

  const char *global = (sname_str == "" ? "" : "::");

  if (!is_multiple)
    {
      os_ << obj->full_name () << "_var ciao_"
          << port_name << " = " << be_idt_nl
          << "this->context_->get_connection_"
          << port_name << " ();" << be_uidt_nl;
    }
  else
    {
      os_ << "::" << sname << global << port_name << "Connections_var ciao_"
          << port_name << " = " << be_idt_nl
          << "this->context_->get_connections_"
          << port_name << " ();" << be_uidt_nl;
    }

  os_ << "::CIAO::Servant::describe_"
      << (is_multiple ? "multiplex" : "simplex")
      << "_receptacle<" << be_idt_nl;

  if (!is_multiple)
    {
      os_ << "::" << obj->full_name () << "> (" << be_idt_nl;
    }
  else
    {
      os_ << "::" << sname << global << port_name << "Connections> (" << be_idt_nl;
    }

  os_ << "\"" << port_name << "\"," << be_nl
      << "\"" << obj->repoID () << "\"," << be_nl;

  os_  << "ciao_" << port_name << ".in ()," << be_nl;

  os_ << "safe_retval," << be_nl
      << slot_++ << "UL);" << be_uidt << be_uidt;

  return 0;
}
Ejemplo n.º 3
0
int
be_visitor_emitter_desc::visit_emits (be_emits *node)
{
  AST_Type *obj = node->emits_type ();
  const char *port_name =
    node->local_name ()->get_string ();

  os_ << be_nl_2
      << "::CIAO::Servant::describe_emit_event_source<"
      << be_idt_nl
      << "::" << obj->full_name () << "Consumer_var> ("
      << be_idt_nl
      << "\"" << port_name << "\"," << be_nl
      << "\"" << obj->repoID () << "\"," << be_nl
      << "this->context_->ciao_emits_" << port_name
      << "_consumer_," << be_nl
      << "safe_retval," << be_nl
      << slot_++ << "UL);" << be_uidt << be_uidt;

  return 0;
}
Ejemplo n.º 4
0
int
be_visitor_servant_svs::visit_consumes (be_consumes *node)
{
  AST_Type  *obj = node->consumes_type ();
  const char *port_name = node->local_name ()->get_string ();

  const char *comp_lname = node_->local_name ();
  ACE_CString comp_sname_str (
    ScopeAsDecl (node_->defined_in ())->full_name ());
  const char *comp_sname = comp_sname_str.c_str ();
  const char *global = (comp_sname_str == "" ? "" : "::");

  const char *lname = obj->local_name ()->get_string ();
  const char *fname = obj->full_name ();

  os_ << be_nl_2
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant (" << be_idt << be_idt_nl
      << global << comp_sname << "::CCM_" << comp_lname
      << "_ptr executor," << be_nl
      << global << comp_sname << "::CCM_" << comp_lname
      << "_Context_ptr c)" << be_uidt_nl
      << ": executor_ ( " << global << comp_sname << "::CCM_"
      << comp_lname << "::_duplicate (executor))," << be_idt_nl
      << "ctx_ ( " << global << comp_sname
      << "::CCM_" << comp_lname
      << "_Context::_duplicate (c))" << be_uidt << be_uidt_nl
      << "{" << be_nl
      << "}";

  os_ << be_nl_2
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::~" << lname << "Consumer_"
      << port_name << "_Servant (void)" << be_nl
      << "{" << be_nl
      << "}";

  os_ << be_nl_2
      << "::CORBA::Object_ptr" << be_nl
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::_get_component (void)" << be_nl
      << "{" << be_idt_nl;

  if (ACE_OS::strcmp (be_global->ciao_container_type (), "Session") == 0)
    {
      os_ << "return this->ctx_->get_CCM_object ();";
    }
  else
    {
      os_ << "return ::CORBA::Object::_nil ();";
    }

  os_ << be_uidt_nl << "}";

  os_ << be_nl_2
      << "void" << be_nl
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::push_" << lname
      << " (" << be_idt_nl
      << "::" << fname << " * evt)" << be_uidt_nl
      << "{" << be_idt_nl
      << "this->executor_->push_" << port_name
      << " (evt);" << be_uidt_nl
      << "}";

  os_ << be_nl_2
      << "/// Inherited from ::Components::EventConsumerBase."
      << be_nl
      << "void" << be_nl
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::push_event (" << be_idt_nl
      << "::Components::EventBase * ev)" << be_uidt_nl
      << "{" << be_idt_nl
      << "::" << fname << " * ev_type =" << be_idt_nl
      << "::" << fname << "::_downcast (ev);"
      << be_uidt_nl << be_nl
      << "if (ev_type != 0)" << be_idt_nl
      << "{" << be_idt_nl
      << "this->push_" << lname << " (ev_type);" << be_nl
      << "return;" << be_uidt_nl
      << "}" << be_uidt_nl << be_nl
      << "throw ::Components::BadEventType ();" << be_uidt_nl
      << "}";

  if (!be_global->gen_lwccm ())
    {
      os_ << be_nl_2
          << "::" << fname << "Consumer_ptr" << be_nl
          << node_->local_name () << "_Servant::get_consumer_"
          << port_name << " (void)" << be_nl
          << "{" << be_idt_nl
          << "return" << be_idt_nl
          << "::" << fname << "Consumer::_duplicate (" << be_idt_nl
          << "this->consumes_" << port_name << "_.in ());"
          << be_uidt << be_uidt << be_uidt_nl
          << "}";
    }

  os_ << be_nl_2
      << "void" << be_nl
      << node_->local_name () << "_Servant::setup_consumer_"
      << port_name << "_i (void)" << be_nl
      << "{" << be_idt_nl
      << "ACE_CString obj_id (this->ins_name_);" << be_nl
      << "obj_id += \"_" << port_name << "\";" << be_nl_2
      << "::CIAO::Container_var cnt_safe =" << be_idt_nl
      << "::CIAO::Container::_duplicate ("
      << "this->container_.in ());" << be_uidt_nl << be_nl
      << "if (::CORBA::is_nil (cnt_safe.in ()))" << be_idt_nl
      << "{" << be_idt_nl << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
      << "}" << be_uidt_nl << be_nl
      << "PortableServer::POA_var POA = cnt_safe->the_port_POA ();" << be_nl
      << node_->local_name () << "_Servant::" << lname
      << "Consumer_" << port_name << "_Servant *"
      << port_name << "_servant_impl = " << be_idt_nl
      << "new "   << node_->local_name () << "_Servant::" << lname
      << "Consumer_" << port_name << "_Servant (" << be_idt_nl
      << " this->executor_, this->context_);" << be_uidt_nl << be_uidt_nl << be_nl
      << "PortableServer::ServantBase_var safe_base_servant ("
      << port_name << "_servant_impl);" << be_nl
      << "PortableServer::ObjectId_var " << port_name << "_servant_oid =" << be_idt_nl
      << "PortableServer::string_to_ObjectId (obj_id.c_str());" << be_uidt_nl << be_nl
      << "POA->activate_object_with_id(" << be_idt_nl
      << port_name << "_servant_oid.in()," << be_nl
      <<  port_name << "_servant_impl);" << be_uidt_nl << be_nl

      << "::CORBA::Object_var " << port_name << "_servant_impl_obj = " << be_idt_nl
      << "cnt_safe->generate_reference ( " << be_idt_nl
      << "obj_id.c_str ()," << be_nl
      << "\"";

      ACE_CString work (obj->repoID ());
      ACE_CString result (work.substr (0, work.rfind (':')));
      result += "Consumer:1.0";

      os_ << result.c_str ();

      os_ << "\"," << be_nl
      << "::CIAO::Container_Types::FACET_CONSUMER_t);"
      << be_uidt_nl << be_uidt_nl
      << "::Components::EventConsumerBase_var ecb =" << be_idt_nl
      << "::Components::EventConsumerBase::_narrow ("
      << port_name << "_servant_impl_obj.in ());"
      << be_uidt_nl << be_nl
      << "this->add_consumer (\"" << port_name << "\", ecb.in ());"
      << be_uidt_nl
      << "}";

  return 0;
}
Ejemplo n.º 5
0
int
be_visitor_servant_svs::visit_provides (be_provides *node)
{
  if (node->provides_type ()->is_local ()) // @TODO || be_global->gen_lwccm ())
    {
      return 0;
    }

  ACE_CString prefix (this->ctx_->port_prefix ());
  prefix += node->local_name ()->get_string ();
  const char *port_name = prefix.c_str ();

  AST_Type *obj = node->provides_type ();
  const char *obj_name = obj->full_name ();
  AST_Decl *scope = ScopeAsDecl (obj->defined_in ());
  ACE_CString sname_str (scope->full_name ());
  const char *sname = sname_str.c_str ();

  // Avoid '_cxx_' prefix.
  const char *lname =
    obj->original_local_name ()->get_string ();

  const char *global = (sname_str == "" ? "" : "::");
  const char *prefix_connector = (sname_str == "" ? "" : "_");

  if (!be_global->gen_lwccm ())
    {
      os_ << be_nl_2
          << "::" << obj_name << "_ptr" << be_nl
          << node_->local_name () << "_Servant::provide_"
          << port_name << " (void)" << be_nl
          << "{" << be_idt_nl;

      os_ << "return" << be_idt_nl
          <<  "::" << obj_name << "::_duplicate (this->provide_"
          << port_name << "_.in ());" << be_uidt << be_uidt_nl
          << "}";
    }

  os_ << be_nl_2
        << "void" << be_nl
        << node_->local_name () << "_Servant::setup_"
        << port_name << "_i (void)" << be_nl
        << "{" << be_idt_nl
        << "ACE_CString obj_id (this->ins_name_);" << be_nl
        << "obj_id += \"_" << port_name << "\";" << be_nl_2
        << "::CIAO::Container_var cnt_safe =" << be_idt_nl
        << "::CIAO::Container::_duplicate ("
        << "this->container_.in ());" << be_uidt_nl << be_nl
        << "if (::CORBA::is_nil (cnt_safe.in ()))" << be_idt_nl
        << "{" << be_idt_nl << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
        << "}" << be_uidt_nl << be_nl
        << "PortableServer::POA_var POA = cnt_safe->the_port_POA ();" << be_nl
        << "::CORBA::Object_var tmp =" << be_idt_nl
        << "this->get_facet_executor (\"" << port_name << "\");"<< be_uidt_nl << be_nl
        << global << sname << "::CCM_" << lname << "_var tmp_var = " << be_idt_nl
        << global << sname <<"::CCM_" << lname
        << "::_narrow (tmp.in());" << be_uidt_nl << be_nl
        << "typedef " << global << "CIAO_FACET" << prefix_connector
        << scope->flat_name () << "::" << obj->local_name () << "_Servant_T <" << be_idt_nl
        << "POA_" << sname << global << obj->local_name ()
        << "," << be_nl << global << sname <<"::CCM_" << lname << "," << be_nl
        << global << "Components::" << be_global->ciao_container_type ()
        << "Context>" << be_idt_nl << lname
        << "_type;" << be_uidt_nl << be_uidt_nl
        << lname << "_type *" << port_name << "_servant_impl = 0;" << be_nl
        << "ACE_NEW_THROW_EX (" << be_idt_nl
        << port_name << "_servant_impl," << be_nl
        << lname << "_type (" << be_idt_nl
        << "tmp_var.in(), " << be_nl
        << "this->context_)," << be_uidt_nl
        << "CORBA::NO_MEMORY ());" << be_uidt_nl << be_nl
        << "PortableServer::ServantBase_var safe_base_servant ("
        << port_name << "_servant_impl);" << be_nl << be_nl
        << "PortableServer::ObjectId_var " << port_name << "_servant_oid =" << be_idt_nl
        << "PortableServer::string_to_ObjectId (obj_id.c_str());" << be_uidt_nl << be_nl
        << "POA->activate_object_with_id(" << port_name << "_servant_oid.in(),"
        <<  port_name << "_servant_impl);" << be_nl
        << "::CORBA::Object_var " << port_name << "_servant_impl_obj = " << be_idt_nl
        << "cnt_safe->generate_reference ( " << be_idt_nl
        << "obj_id.c_str ()," << be_nl
        << "\"" << obj->repoID () << "\"," << be_nl
        << "::CIAO::Container_Types::FACET_CONSUMER_t);"
        << be_uidt_nl << be_uidt_nl
        << "this->add_facet (\"" << port_name << "\", " << port_name << "_servant_impl_obj.in ());"
        << be_uidt_nl
        << "}";

  return 0;
}
Ejemplo n.º 6
0
int
ifr_adding_visitor_operation::visit_operation (AST_Operation *node)
{
  try
    {
      // If this operation is already in the repository (for example, if
      // we are processing the IDL file a second time inadvertently), we
      // just return 0. The IDL file must be legal, otherwise the IDL
      // compiler front end would have told us.

      CORBA::Contained_var prev_def =
        be_global->repository ()->lookup_id (node->repoID ());

      if (!CORBA::is_nil (prev_def.in ()))
        {
          return 0;
        }

      // Build the parameter list. Our overridden version of visit_argument
      // will look up each parameter and add its repository entry to
      // our params_ member.

      CORBA::ULong length = static_cast<CORBA::ULong> (node->argument_count ());

      this->params_.length (length);

      if (this->visit_scope (node) == -1)
        {
          ORBSVCS_ERROR_RETURN ((
              LM_ERROR,
              ACE_TEXT ("(%N:%l) ifr_adding_visitor_operation::")
              ACE_TEXT ("visit_operation -")
              ACE_TEXT (" visit_scope failed\n")
            ),
            -1
          );
        }

      this->index_ = 0;

      // Build the exception list.

      UTL_ExceptList *excepts = node->exceptions ();

      if (excepts != 0)
        {
          length = static_cast<CORBA::ULong> (excepts->length ());
        }
      else
        {
          length = 0;
        }

      CORBA::ExceptionDefSeq exceptions (length);
      exceptions.length (length);

      AST_Type *ex = 0;
      CORBA::ULong i = 0;

      for (UTL_ExceptlistActiveIterator ex_iter (excepts);
           !ex_iter.is_done ();
           ex_iter.next (), ++i)
        {
          ex = ex_iter.item ();

          prev_def =
            be_global->repository ()->lookup_id (ex->repoID ());

          exceptions[i] =
            CORBA::ExceptionDef::_narrow (prev_def.in ());
        }

      // Build the context list.

      UTL_StrList *ctx_list = node->context ();

      if (ctx_list != 0)
        {
          length = static_cast<CORBA::ULong> (ctx_list->length ());
        }
      else
        {
          length = 0;
        }

      CORBA::ContextIdSeq contexts (length);
      contexts.length (length);

      UTL_StrlistActiveIterator ctx_iter (ctx_list);
      UTL_String *str = 0;
      i = 0;

      while (!ctx_iter.is_done ())
        {
          str = ctx_iter.item ();

          contexts[i++] = str->get_string ();

          ctx_iter.next ();
        }

      // Get the return type.

      AST_Type *return_type = node->return_type ();

      // Updates ir_current_.
      this->get_referenced_type (return_type);

      // Is the operation oneway?
      CORBA::OperationMode mode = node->flags () == AST_Operation::OP_oneway
                                 ? CORBA::OP_ONEWAY
                                 : CORBA::OP_NORMAL;

      // Create the repository entry.

      CORBA::Container_ptr current_scope =
        CORBA::Container::_nil ();

      if (be_global->ifr_scopes ().top (current_scope) == 0)
        {
          AST_Decl *op_scope = ScopeAsDecl (node->defined_in ());
          AST_Decl::NodeType nt = op_scope->node_type ();

          if (nt == AST_Decl::NT_interface)
            {
              CORBA::InterfaceDef_var iface =
                CORBA::InterfaceDef::_narrow (current_scope);

              CORBA::OperationDef_var new_def =
                iface->create_operation (node->repoID (),
                                         node->local_name ()->get_string (),
                                         node->version (),
                                         this->ir_current_.in (),
                                         mode,
                                         this->params_,
                                         exceptions,
                                         contexts);
            }
          else
            {
              CORBA::ValueDef_var vtype =
                CORBA::ValueDef::_narrow (current_scope);

              CORBA::OperationDef_var new_def =
                vtype->create_operation (node->repoID (),
                                         node->local_name ()->get_string (),
                                         node->version (),
                                         this->ir_current_.in (),
                                         mode,
                                         this->params_,
                                         exceptions,
                                         contexts);
            }
        }
      else
        {
          ORBSVCS_ERROR_RETURN ((
              LM_ERROR,
              ACE_TEXT ("(%N:%l) ifr_adding_visitor_operation::")
              ACE_TEXT ("visit_operation -")
              ACE_TEXT (" scope stack is empty\n")
            ),
            -1
          );
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        ACE_TEXT (
          "ifr_adding_visitor_operation::visit_operation"));

      return -1;
    }

  return 0;
}