public_ci.cpp

来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 1,432 行 · 第 1/3 页

CPP
1,432
字号
      << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl
      << "{" << be_idt_nl
      << "return this->u_." << ub->local_name () << "_->ptr ();" << be_uidt_nl
      << "}";

  return 0;
}

int
be_visitor_union_branch_public_ci::visit_valuetype (be_valuetype *node)
{
  be_union_branch *ub = this->ctx_->be_node_as_union_branch ();
  be_union *bu = this->ctx_->be_scope_as_union ();
  be_type *bt;

  // Check if we are visiting this node via a visit to a typedef node.
  if (this->ctx_->alias ())
    {
      bt = this->ctx_->alias ();
    }
  else
    {
      bt = node;
    }

  if (!ub || !bu)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_union_branch_public_ci::"
                         "visit_valuetype - "
                         "bad context information\n"),
                        -1);
    }

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

  // Set method.
  *os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
      << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;

  *os << "// Accessor to set the member." << be_nl
      << "ACE_INLINE" << be_nl
      << "void" << be_nl
      << bu->name () << "::" << ub->local_name () << " (" << bt->name ()
      << " *val)" << be_nl
      << "{" << be_idt_nl
      << "// Set the discriminant value." << be_nl
      << "this->_reset (";

  if (ub->label ()->label_kind () == AST_UnionLabel::UL_label)
    {
      ub->gen_label_value (os);

      *os << ", 0);" << be_nl
          << "this->disc_ = ";

      ub->gen_label_value (os);
    }
  // Default label.
  else
    {
      ub->gen_default_label_value (os, bu);

      *os << ", 0);" << be_nl
          << "this->disc_ = ";

      ub->gen_default_label_value (os, bu);
    }

  *os << ";" << be_nl
      << "CORBA::add_ref (val);" << be_nl
      << "typedef "
      << bt->nested_type_name (bu, "_var")
      << " OBJECT_FIELD;" << be_nl
      << "ACE_NEW (" << be_idt << be_idt_nl
      << "this->u_." << ub->local_name () << "_," << be_nl
      << "OBJECT_FIELD (val)" << be_uidt_nl
      << ");" << be_uidt << be_uidt_nl
      << "}" << be_nl << be_nl;

  // Get method.
  *os << "// Retrieve the member." << be_nl
      << "ACE_INLINE" << be_nl
      << bt->name () << "_ptr " << be_nl
      << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl
      << "{" << be_idt_nl
      << "return this->u_." << ub->local_name () << "_->ptr ();" << be_uidt_nl
      << "}";

  return 0;
}

int
be_visitor_union_branch_public_ci::visit_valuetype_fwd (be_valuetype_fwd *node)
{
  be_union_branch *ub = this->ctx_->be_node_as_union_branch ();
  be_union *bu = this->ctx_->be_scope_as_union ();
  be_type *bt;

  // Check if we are visiting this node via a visit to a typedef node.
  if (this->ctx_->alias ())
    {
      bt = this->ctx_->alias ();
    }
  else
    {
      bt = node;
    }

  if (!ub || !bu)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_union_branch_public_ci::"
                         "visit_valuetype_fwd - "
                         "bad context information\n"),
                        -1);
    }

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

  // Set method.
  *os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
      << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;

  *os << "// Accessor to set the member." << be_nl
      << "ACE_INLINE" << be_nl
      << "void" << be_nl
      << bu->name () << "::" << ub->local_name () << " (" << bt->name ()
      << " *val)" << be_nl
      << "{" << be_idt_nl
      << "// Set the discriminant value." << be_nl
      << "this->_reset (";

  if (ub->label ()->label_kind () == AST_UnionLabel::UL_label)
    {
      ub->gen_label_value (os);

      *os << ", 0);" << be_nl
          << "this->disc_ = ";

      ub->gen_label_value (os);
    }
  // Default label.
  else
    {
      ub->gen_default_label_value (os, bu);

      *os << ", 0);" << be_nl
          << "this->disc_ = ";

      ub->gen_default_label_value (os, bu);
    }

  *os << ";" << be_nl
      << "CORBA::add_ref (val);" << be_nl
      << "typedef "
      << bt->nested_type_name (bu, "_var")
      << " OBJECT_FIELD;" << be_nl
      << "ACE_NEW (" << be_idt << be_idt_nl
      << "this->u_." << ub->local_name () << "_," << be_nl
      << "OBJECT_FIELD (val)" << be_uidt_nl
      << ");" << be_uidt << be_uidt_nl
      << "}" << be_nl << be_nl;

  // Get method.
  *os << "// Retrieve the member." << be_nl
      << "ACE_INLINE" << be_nl
      << bt->name () << "_ptr " << be_nl
      << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl
      << "{" << be_idt_nl
      << "return this->u_." << ub->local_name () << "_->ptr ();" << be_uidt_nl
      << "}";

  return 0;
}

int
be_visitor_union_branch_public_ci::visit_predefined_type (
    be_predefined_type *node
  )
{
  be_union_branch *ub = this->ctx_->be_node_as_union_branch ();
  be_union *bu = this->ctx_->be_scope_as_union ();
  be_type *bt;

  // Check if we are visiting this node via a visit to a typedef node.
  if (this->ctx_->alias ())
    {
      bt = this->ctx_->alias ();
    }
  else
    {
      bt = node;
    }

  if (!ub || !bu)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_union_branch_public_ci::"
                         "visit_interface - "
                         "bad context information\n"),
                        -1);
    }

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

  // Set method.
  *os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
      << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;

  *os << "// Accessor to set the member." << be_nl
      << "ACE_INLINE" << be_nl
      << "void" << be_nl
      << bu->name () << "::" << ub->local_name () << " (";
  

  AST_PredefinedType::PredefinedType pt = node->pt ();

  if (pt == AST_PredefinedType::PT_pseudo
      || pt == AST_PredefinedType::PT_object)
    {
      *os << "const "
          << bt->name ()
          << "_ptr";
    }
  else if (pt == AST_PredefinedType::PT_any)
    {
      *os << "const "
          << bt->name ()
          << " &";
    }
  else 
    {
      *os << bt->name ();
    }

  *os << " val)" << be_nl
      << "{" << be_idt_nl
      << "// Set the discriminant value." << be_nl
      << "this->_reset (";

  if (ub->label ()->label_kind () == AST_UnionLabel::UL_label)
    {
      ub->gen_label_value (os);

      *os << ", 0);" << be_nl
          << "this->disc_ = ";

      ub->gen_label_value (os);
    }
  else
  // We have an explicit default case.
    {
      ub->gen_default_label_value (os, bu);

      *os << ", 0);" << be_nl
          << "this->disc_ = ";

      ub->gen_default_label_value (os, bu);
    }

  *os << ";" << be_nl;

  switch (pt)
    {
      case AST_PredefinedType::PT_object:
        *os << "typedef CORBA::Object_var OBJECT_FIELD;" << be_nl
            << "ACE_NEW (" << be_idt << be_idt_nl
            << "this->u_." << ub->local_name () << "_," << be_nl
            << "OBJECT_FIELD (CORBA::Object::_duplicate (val))"
            << be_uidt_nl
            << ");" << be_uidt << be_uidt_nl;

        break;
      case AST_PredefinedType::PT_pseudo:
        *os << "this->u_." << ub->local_name () << "_ = "
            << bt->name () << "::_duplicate (val);" << be_uidt_nl;

        break;
      case AST_PredefinedType::PT_any:
        *os << "ACE_NEW (" << be_idt << be_idt_nl
            << "this->u_." << ub->local_name ()
            << "_," << be_nl
            << bt->name () << " (val)" << be_uidt_nl
            << ");" << be_uidt << be_uidt_nl;

        break;
      case AST_PredefinedType::PT_void:
        break;
      default:
        *os << "// Set the value." << be_nl
            << "this->u_." << ub->local_name ()
            << "_ = val;" << be_uidt_nl;

        break;
    }

  *os << "}" << be_nl << be_nl;

  switch (pt)
    {
    case AST_PredefinedType::PT_object:
      // Get method.
      *os << "// Retrieve the member." << be_nl
          << "ACE_INLINE" << be_nl
          << bt->name () << "_ptr" << be_nl
          << bu->name () << "::" << ub->local_name ()
          << " (void) const" << be_nl
          << "{" << be_idt_nl;
      *os << "return this->u_." << ub->local_name ()
          << "_->ptr ();" << be_uidt_nl;
      *os << "}";

      break;
    case AST_PredefinedType::PT_pseudo:
      // Get method.
      *os << "// Retrieve the member." << be_nl
          << "ACE_INLINE" << be_nl
          << bt->name () << "_ptr" << be_nl
          << bu->name () << "::" << ub->local_name ()
          << " (void) const" << be_nl
          << "{" << be_idt_nl;
      *os << "return this->u_." << ub->local_name ()
          << "_;" << be_uidt_nl;
      *os << "}";

      break;
    case AST_PredefinedType::PT_any:
      // Get method with read-only access.
      *os << "// Retrieve the member." << be_nl
          << "ACE_INLINE" << be_nl
          << "const " << bt->name () << " &" << be_nl
          << bu->name () << "::" << ub->local_name ()
          << " (void) const" << be_nl
          << "{" << be_idt_nl
          << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl
          << "}" << be_nl << be_nl;

      // Get method with read/write access
      *os << "// Retrieve the member." << be_nl
          << "ACE_INLINE" << be_nl
          << bt->name () << " &" << be_nl
          << bu->name () << "::" << ub->local_name ()
          << " (void)" << be_nl
          << "{" << be_idt_nl
          << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl
          << "}";
      break;
    case AST_PredefinedType::PT_void:
      break;
    default:
      // Get method.
      *os << "// Retrieve the member." << be_nl
          << "ACE_INLINE" << be_nl
          << bt->name () << be_nl
          << bu->name () << "::" << ub->local_name ()
          << " (void) const" << be_nl
          << "{" << be_idt_nl
          << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl
          << "}";

      break;
    }

  return 0;
}

int
be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node)
{
  be_union_branch *ub = this->ctx_->be_node_as_union_branch ();
  be_union *bu = this->ctx_->be_scope_as_union ();
  be_type *bt;

  // Check if we are visiting this node via a visit to a typedef node.
  if (this->ctx_->alias ())
    {
      bt = this->ctx_->alias ();
    }
  else
    {
      bt = node;
    }

  if (!ub || !bu)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_union_branch_public_ci::"
                         "visit_sequence - "
                         "bad context information\n"),
                        -1);
    }

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

  // If bt is not a typedef and is defined inside the union.
  if (bt->node_type () != AST_Decl::NT_typedef
      && bt->is_child (bu))
    {
      // Instantiate a visitor context with a copy of our context. This info
      // will be modified based on what type of node we are visiting.
      be_visitor_context ctx (*this->ctx_);

      // Set the node to be the node being visited. Scope is still the same.
      ctx.node (node);

      // First generate inline operations for this anonymous sequence type.
      be_visitor_sequence_ci visitor (&ctx);

      if (node->accept (&visitor) == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_union_branch_public_ci::"
                             "visit_sequence - "
                             "codegen failed\n"),
                            -1);
        }
    }

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

  // (1) Set from a const.
  *os << "// Accessor to set the member." << be_nl
      << "ACE_INLINE" << be_nl 
      << "void" << be_nl
      << bu->name () << "::" << ub->local_name ()
      << " (const " << bt->name () << " &val)" << be_nl
      << "{" << be_idt_nl
      << "// Set the discriminant value." << be_nl
      << "this->_reset (";

  if (ub->label ()->label_kind () == AST_UnionLabel::UL_label)
    {
      ub->gen_label_value (os);

      *os << ", 0);" << be_nl
          << "this->disc_ = ";

      ub->gen_label_value (os);
    }
  else
  // We have an explicit default case.
    {
      ub->gen_default_label_value (os, bu);

      *os << ", 0);" << be_nl
          << "this->disc_ = ";

      ub->gen_default_label_value (os, bu);
    }

  *os << ";" << be_nl
      << "ACE_NEW (" << be_idt << be_idt_nl
      << "this->u_." << ub->local_name () << "_," << be_nl
      << bt->name () << " (val)" << be_uidt_nl
      << ");" << be_uidt << be_uidt_nl
      << "}" << be_nl << be_nl;

  // Readonly get method.
  *os << "// Readonly get method." << be_nl
      << "ACE_INLINE" << be_nl
      << "const " << bt->name () << " &" << be_nl
      << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl
      << "{" << be_idt_nl
      << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl
      << "}" << be_nl << be_nl;

  // Read/write get method.
  *os << "// Read/write get method." << be_nl
      << "ACE_INLINE" << be_nl
      << bt->name () << " &" << be_nl
      << bu->name () << "::" << ub->local_name () << " (void)" << be_nl
      << "{" << be_idt_nl
      << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl
      << "}";

  return 0;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?