summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_component/component_ami_rh_exh.cpp
blob: eb80e91432b02ba12421c2d5679ff7c7dd7ea0ef (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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

//=============================================================================
/**
 *  @file    component_ami_rh_exh.cpp
 *
 *  $Id$
 *
 *  Visitor generating code for AMI4CCM reply handler impl headers.
 *
 *
 *  @author Jeff Parsons
 */
//=============================================================================

be_visitor_component_ami_rh_exh::be_visitor_component_ami_rh_exh (
      be_visitor_context *ctx)
  : be_visitor_component_ami_rh_ex_base (ctx),
    export_macro_ (be_global->exec_export_macro ())
{
}

be_visitor_component_ami_rh_exh::~be_visitor_component_ami_rh_exh (void)
{
}

int
be_visitor_component_ami_rh_exh::visit_uses (be_uses *node)
{
  this->iface_ =
    be_interface::narrow_from_decl (node->uses_type ());

  this->init ();

  os_ << be_nl_2
      << "class " << this->export_macro_.c_str () << " "
      << this->class_name_ << "_i" << be_idt_nl
      << ": public ::" << this->scope_name_ << this->smart_scope_
      << this->class_name_ << be_uidt_nl
      << "{" << be_nl
      << "public:" << be_idt_nl
      << this->prefix_ << this->iface_name_ << this->suffix_
      << "_i (void);" << be_nl
      << "virtual ~" << this->prefix_ << this->iface_name_
      << this->suffix_ << "_i (void);";

  /// This overload of traverse_inheritance_graph() used here
  /// doesn't automatically prime the queues.
  this->iface_->get_insert_queue ().reset ();
  this->iface_->get_del_queue ().reset ();
  this->iface_->get_insert_queue ().enqueue_tail (this->iface_);

  Exec_ReplyHandler_Op_Attr_Generator op_attr_gen (this);

  int status =
    this->iface_->traverse_inheritance_graph (op_attr_gen,
                                              &os_,
                                              false,
                                              false);

  if (status == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("be_visitor_component_ami_rh_exh")
                         ACE_TEXT ("::visit_uses - ")
                         ACE_TEXT ("traverse_inheritance_graph() on ")
                         ACE_TEXT ("callback interface failed\n")),
                        -1);
    }

  os_ << be_uidt_nl
      << "};";

  return 0;
}

int
be_visitor_component_ami_rh_exh::visit_attribute (
  be_attribute *node)
{
  return this->gen_attr_op (node, false);
}

int
be_visitor_component_ami_rh_exh::visit_operation (
  be_operation *node)
{
  /// Skip these for the reply handler.
  if (node->is_sendc_ami ())
    {
      return 0;
    }

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

  /// We end up here also from the visit_scope() call on the
  /// connector. We want to skip the CCM-related operations
  /// that were added to the connector since it's a component.
  /// We want only the facet interface operations.
  if (d->node_type () != AST_Decl::NT_interface)
    {
      return  0;
    }

  os_ << be_nl_2
      << "virtual void" << be_nl
      << node->local_name ()->get_string () << " (";

  int count =
    node->count_arguments_with_direction (
      AST_Argument::dir_INOUT | AST_Argument::dir_OUT);

  bool vrt = node->void_return_type ();

  if (count == 0 && vrt)
    {
      os_ << "void);";

      return  0;
    }

  os_ << be_idt_nl;

  if (!vrt)
    {
      be_visitor_operation_rettype rt_visitor (this->ctx_);
      be_decl *rt =
        be_decl::narrow_from_decl (node->return_type ());

      if (rt->accept (&rt_visitor) == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("be_visitor_component_ami_rh_exh")
                             ACE_TEXT ("::visit_operation - ")
                             ACE_TEXT ("return type arg gen failed\n")),
                            -1);
        }

      os_ << " ami_return_val";

      if (count != 0)
        {
          os_ << "," << be_nl;
        }
    }

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

  os_ << ");" << be_uidt;

  this->gen_excep_op ("", node, false);

  return 0;
}

int
be_visitor_component_ami_rh_exh::visit_argument (
  be_argument *node)
{
  if (node->direction () == AST_Argument::dir_IN)
    {
      return 0;
    }

  be_visitor_args_arglist arg_visitor (this->ctx_);
  arg_visitor.set_fixed_direction (AST_Argument::dir_IN);

  if (arg_visitor.visit_argument (node) == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("be_visitor_component_ami_rh_exh")
                         ACE_TEXT ("::visit_argument - ")
                         ACE_TEXT ("be_visitor_args_arglist failed\n")),
                        -1);
    }

  return 0;
}