summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ss.cpp
blob: b529196273cd9fdf7f12f089479ea141ab1bc1e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

//=============================================================================
/**
 *  @file    valuetype_ss.cpp
 *
 *  Visitor generating code for Interfaces in the server skeletons file.
 *
 *  @author Aniruddha Gokhale
 */
//=============================================================================

#include "valuetype.h"
#include "nr_extern.h"

// ************************************************************
// Interface visitor for server skeletons.
// ************************************************************

be_visitor_valuetype_ss::be_visitor_valuetype_ss (be_visitor_context *ctx)
  : be_visitor_valuetype (ctx)
{
}

be_visitor_valuetype_ss::~be_visitor_valuetype_ss ()
{
}

int
be_visitor_valuetype_ss::visit_valuetype (be_valuetype *node)
{
  if (node->srv_skel_gen () || node->imported () || node->is_abstract ())
    {
      return 0;
    }

  AST_Type *concrete = node->supports_concrete ();

  // We generate a skeleton class only if the valuetype supports a
  // non-abstract interface.
  if (concrete == nullptr)
    {
      return 0;
    }

  // Generate the normal skeleton as usual.

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

  os->indent ();

  ACE_CString full_skel_name_holder =
    this->generate_full_skel_name (node);

  const char *full_skel_name = full_skel_name_holder.c_str ();

  TAO_INSERT_COMMENT (os);

  // Find if we are at the top scope or inside some module,
  // pre-compute the prefix that must be added to the local name in
  // each case.
  const char *local_name_prefix = "";

  if (!node->is_nested ())
    {
      local_name_prefix = "POA_";
    }

  ACE_CString node_local_name_holder =
    this->generate_local_name (node);

  const char *node_local_name = node_local_name_holder.c_str ();

  *os << full_skel_name << "::"
      << local_name_prefix << node_local_name
      << " ()" << be_nl
      << "{}" << be_nl_2;

// @@@ (JP) I'm commenting out the copy constructor for now. The
// declaration in the skeleton header file has been made private. These
// valuetypes (only if a concrete interface is supported) inherit
// from the stub-side valuetype, which has a private umimplemented
// copy constructor. This makes it impossible to call all the base
// class copy constructors, which some compilers require. If there
// is no fallout from this change, this code will be removed, if
// there is a problem, we'll have to reevaluate the approach.
/*
  *os << full_skel_name << "::"
      << local_name_prefix << node_local_name << " ("
      << "const " << local_name_prefix << node_local_name << "& rhs)";

  *os << be_idt_nl
      << ": TAO_Abstract_ServantBase (rhs)," << be_nl
      << "  TAO_ServantBase (rhs)," << be_idt_nl;

  if (concrete->is_nested ())
    {
      AST_Decl *scope = ScopeAsDecl (concrete->defined_in ());

      *os << "POA_" << scope->name () << "::"
          << concrete->local_name () << " (rhs)," << be_nl;
    }
  else
    {
      be_interface *bd = dynamic_cast<be_interface*> (concrete);
      *os << bd->full_skel_name () << " (rhs)," << be_nl;
    }

  *os << "ValueBase (rhs)" << be_uidt << be_uidt_nl
      << "{}" << be_nl_2;
*/

  *os << full_skel_name << "::~"
      << local_name_prefix << node_local_name
      << " ()" << be_nl
      << "{}";

  return 0;
}

int
be_visitor_valuetype_ss::visit_eventtype (be_eventtype *node)
{
  return this->visit_valuetype (node);
}

ACE_CString
be_visitor_valuetype_ss::generate_local_name (be_valuetype *node)
{
  return ACE_CString (node->local_name ());
}

ACE_CString
be_visitor_valuetype_ss::generate_full_skel_name (be_valuetype *node)
{
  return ACE_CString (node->full_skel_name ());
}