summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_typecode/objref_typecode.cpp
blob: fdaf252ac5195d2b81d345260318c424fa0c1dac (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
// -*- C++ -*-

//=============================================================================
/**
 *  @file  objref_typecode.cpp
 *
 *  Object reference TypeCode generation visitor.
 *
 *  @author  Ossama Othman <ossama@dre.vanderbilt.edu>
 */
//=============================================================================

#include "typecode.h"

TAO::be_visitor_objref_typecode::be_visitor_objref_typecode (
  be_visitor_context * ctx)
  : be_visitor_typecode_defn (ctx)
{
}

int
TAO::be_visitor_objref_typecode::visit_interface (be_interface * node)
{
  if (!node->is_defined ())
    return this->gen_forward_declared_typecode (node);

  static char const abstract_interface[] = "abstract_interface";
  static char const component[]          = "component";
  static char const home[]               = "home";
  static char const local_interface[]    = "local_interface";
  static char const objref[]             = "objref";

  char const * kind = nullptr;

  if (dynamic_cast<be_component *> (node))
    kind = component;
  else if (node->home_equiv ())
    kind = home;
  else if (node->is_abstract ())
    kind = abstract_interface;
  else if (node->is_local ())
    kind = local_interface;
  else
    kind = objref;

  return this->visit_i (kind,
                        node->flat_name (),
                        node->repoID (),
                        node->original_local_name ()->get_string (),
                        node);
}

int
TAO::be_visitor_objref_typecode::visit_native (be_native * /* node */)
{
  return 0;
}

int
TAO::be_visitor_objref_typecode::visit_i (char const * kind,
                                          char const * flat_name,
                                          char const * repository_id,
                                          char const * original_local_name,
                                          be_type * node)
{
  TAO_OutStream & os = *this->ctx_->stream ();

  TAO_INSERT_COMMENT (&os);

  // Generate the TypeCode instantiation.
  os
    << "static TAO::TypeCode::Objref<char const *," << be_nl
    << "                             TAO::Null_RefCount_Policy>"
    << be_idt_nl
    << "_tao_tc_" << flat_name << " (" << be_idt_nl
    << "::CORBA::tk_" << kind << "," << be_nl
    << "\"" << repository_id << "\"," << be_nl
    << "\"" << original_local_name << "\");" << be_uidt_nl
    << be_uidt_nl;

  if (this->gen_typecode_ptr (node) != 0)
    return -1;

  return 0;
}