summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp
blob: ff485166b9e8a0e8ba6b787f64dc0d465fea8db8 (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

//=============================================================================
/**
 *  @file    typecode_decl.cpp
 *
 *  Visitor generating code for TypeCode declaration for a type
 *
 *  @author Aniruddha Gokhale
 */
//=============================================================================

#include "typecode.h"

be_visitor_typecode_decl::be_visitor_typecode_decl (be_visitor_context *ctx)
  : be_visitor_decl (ctx)
{
  if (be_global->gen_anyop_files ())
    {
      // The context is always a copy, so this is ok.
      this->ctx_->stream (tao_cg->anyop_header ());
    }
}

be_visitor_typecode_decl::~be_visitor_typecode_decl ()
{
}

int
be_visitor_typecode_decl::visit_type (be_type *node)
{
  TAO_OutStream *os = this->ctx_->stream ();

  TAO_INSERT_COMMENT (os);

  // If -GA is used but anyop macro isn't set, defaults to stub macro.
  const char *export_macro = (be_global->gen_anyop_files ()
                              ? this->ctx_->non_null_export_macro ()
                              : be_global->stub_export_macro ());

  if (node->is_nested ())
    {
      // We have a scoped name.
      // Is our enclosing scope a module? We need this check because
      // for platforms that support namespaces, the TypeCode must be
      // declared extern.
      if (node->defined_in ()->scope_node_type () == AST_Decl::NT_module)
        {
          *os << "extern " << export_macro << " ";
        }
      else
        {
          *os << "static ";
        }

      *os << "::CORBA::TypeCode_ptr const "
          << node->tc_name ()->last_component ()
          << ";";
    }
  else
    {
      // We are in the ROOT scope.
      *os << "extern " << export_macro
          << " ::CORBA::TypeCode_ptr const "
          << node->tc_name ()->last_component ()
          << ";";
    }

  return 0;
}

int
be_visitor_typecode_decl::visit_array (be_array *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_enum (be_enum *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_exception (be_exception *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_interface (be_interface *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_component (be_component *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_connector (be_connector *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_home (be_home *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_sequence (be_sequence *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_structure (be_structure *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_typedef (be_typedef *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_union (be_union *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_valuebox (be_valuebox *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_valuetype (be_valuetype *node)
{
  return this->visit_type (node);
}

int
be_visitor_typecode_decl::visit_eventtype (be_eventtype *node)
{
  return this->visit_type (node);
}