summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_argument/request_info_result.cpp
blob: 96f23d2396ed6e49c7344ad6a50fa602f170811d (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
//
// $Id$
//

// ============================================================================
//
// = LIBRARY
//    TAO IDL
//
// = FILENAME
//    request_info_result.cpp
//
// = DESCRIPTION
//    Visitor that generates the Dyanmic::ParameterList
//
// = AUTHOR
//    Kirthika Parameswaran  <kirthika@cs.wustl.edu>
//
// ============================================================================

#include "idl.h"
#include "be.h"
#include "be_visitor_argument.h"

ACE_RCSID(be_visitor_argument, request_info_result, "$Id$")


// ************************************************************
// be_visitor_args_request_info_result for generating the result as
// stored in the request info for interceptors
// ************************************************************

be_visitor_args_request_info_result::be_visitor_args_request_info_result (be_visitor_context *ctx)
  : be_visitor_args (ctx)
{
}

be_visitor_args_request_info_result::~be_visitor_args_request_info_result (void)
{
}

int be_visitor_args_request_info_result::visit_argument (be_argument *node)
{
  TAO_OutStream *os = this->ctx_->stream (); // get output stream
  this->ctx_->node (node); // save the argument node
  be_type *bt;
 
  os->indent ();
  *os << "this->result_val_ <<=";
  // Insertion into an Any has some special cases which need to be 
  // dealt with.

  // retrieve the type
  bt = be_type::narrow_from_decl (node->field_type ());
  if (!bt)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "be_visitor_args_::"
                         "visit_argument - "
                         "Bad return type\n"),
                        -1);
    }

  switch (bt->node_type ())
    {
    case AST_Decl::NT_pre_defined:
      {
        if (bt->accept (this) == -1)
          {
            ACE_ERROR_RETURN ((LM_ERROR,
                               "be_visitor_args_request_info_result::"
                               "visit_argument - "
                               "cannot accept visitor\n"),
                              -1);
          }
      
        *os <<"result_;" ;
        break;
      }
      
    case AST_Decl::NT_string:
      *os << "from_string (this->result_);" ;
      break;
      
    case AST_Decl::NT_wstring:
      *os << "from_wstring (this->result_);" ;
      break;
      
   default:
     *os << " this->result_;" << be_nl;

   }

  *os << be_nl;
  // Set the appropriate mode for each parameter.
  return 0;
}


int 
be_visitor_args_request_info_result::visit_predefined_type (be_predefined_type *node)
{
  TAO_OutStream *os = this->ctx_->stream (); // get output stream

  switch (node->pt ())
    {
    case AST_PredefinedType::PT_boolean:
      *os << "from_boolean (this->";
      break;
    case AST_PredefinedType::PT_char:
      *os << "from_char (this->";
      break;
    case AST_PredefinedType::PT_wchar:
      *os << "from_wchar (this->";
      break;
    case AST_PredefinedType::PT_octet:
      *os << "from_octet (this->";
      break;
            
    default:
      break;
    }

  return 0;

}