summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_component/context_ex_idl.cpp
blob: 909703f641c64eae391ea8132dc482981dc4b5a9 (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

//=============================================================================
/**
 *  @file    context_ex_idl.cpp
 *
 *  $Id$
 *
 *  Visitor generating code for the contect class
 *  in the CIAO executor IDL.
 *
 *
 *  @author Jeff Parsons
 */
//=============================================================================

be_visitor_context_ex_idl::be_visitor_context_ex_idl (
      be_visitor_context *ctx)
  : be_visitor_component_scope (ctx)
{
}

be_visitor_context_ex_idl::~be_visitor_context_ex_idl (
  void)
{
}

int
be_visitor_context_ex_idl::visit_component (be_component *node)
{
  node_ = node;

  os_ << be_nl << be_nl
      << "local interface CCM_"
      << node->original_local_name ()->get_string ()
      << "_Context" << be_idt_nl
      << ": ";

  AST_Component *base = node->base_component ();

  if (base == 0)
    {
      os_ << "::Components::SessionContext";
    }
  else
    {
      AST_Decl *scope =
        ScopeAsDecl (base->defined_in ());

      ACE_CString sname_str =
        IdentifierHelper::orig_sn (scope->name ());
      const char *sname = sname_str.c_str ();

      const char *lname =
        base->original_local_name ()->get_string ();

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

      os_ << global << sname << "::CCM_"
          << lname << "_Context";
    }

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

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

  os_ << be_uidt_nl
      << "};";

  return 0;
}

int
be_visitor_context_ex_idl::visit_connector (be_connector *node)
{
  return this->visit_component (node);
}

int
be_visitor_context_ex_idl::visit_uses (be_uses *node)
{
  be_type *impl = node->uses_type ();

  os_ << be_nl
      << "::";

  ACE_CString port_name (this->port_prefix_);
  port_name += node->local_name ()->get_string ();
  const char *lname = port_name.c_str ();

  // Note that we don't strip off the possible '_cxx_' when
  // adding the 'Connections' suffix. The front end will
  // create this implied IDL node with the '_cxx_' so lookup
  // will fail (when processing the *E.idl file) if we
  // strip it off here.
  if (node->is_multiple ())
    {
      os_ << IdentifierHelper::orig_sn (node_->name ()).c_str ()
          << "::" << lname << "Connections get_connections_"
          << lname << " ();";
    }
  else
    {
      os_ << IdentifierHelper::orig_sn (impl->name ()).c_str ()
          << " get_connection_" << lname << " ();";

    }

  if (be_global->ami4ccm_call_back ())
    {
      if (node->is_multiple ())
        {
          os_ << IdentifierHelper::orig_sn (node_->name ()).c_str ()
              << "::" << lname << "Connections get_connections_"
              << lname << " ();";
        }
      else
        {
          ACE_CString original_op_name (
            impl->name ()->last_component ()->get_string ());
          ACE_CString new_op_name = ACE_CString ("AMI_") + original_op_name;
          UTL_ScopedName *op_name =
            static_cast<UTL_ScopedName *> (impl->name ()->copy ());
          op_name->last_component ()->replace_string (new_op_name.c_str ());
          os_ << be_nl << "::" << IdentifierHelper::orig_sn (op_name).c_str ()
              << " get_connection_sendc_" << lname << " ();";
        }
    }

  return 0;
}

int
be_visitor_context_ex_idl::visit_publishes (be_publishes *node)
{
  be_eventtype *impl = node->publishes_type ();

  os_ << be_nl
      << "void push_" << node->local_name ()->get_string ()
      << " (in ::"
      << IdentifierHelper::orig_sn (impl->name ()).c_str ()
      << " e);";

  return 0;
}

int
be_visitor_context_ex_idl::visit_emits (be_emits *node)
{
  be_eventtype *impl = node->emits_type ();

  os_ << be_nl
      << "void push_" << node->local_name ()->get_string ()
      << " (in ::"
      << IdentifierHelper::orig_sn (impl->name ()).c_str ()
      << " e);";

  return  0;
}