Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_operation / argument_invoke.cpp
bloba1423254492c392dae1e04c7ca870dd094323570
2 //=============================================================================
3 /**
4 * @file argument_invoke.cpp
6 * Visitor to pass arguments to the CDR operators. This one helps in
7 * generating the && and the , at the right place. This one is for the
8 * client stub side.
10 * @author Aniruddha Gokhale
12 //=============================================================================
14 #include "operation.h"
16 // ************************************************************
17 // operation visitor to handle the passing of arguments to the CDR operators
18 // ************************************************************
20 be_visitor_operation_argument_invoke::be_visitor_operation_argument_invoke (
21 be_visitor_context
22 *ctx)
23 : be_visitor_operation_argument (ctx),
24 last_arg_printed_ (be_visitor_operation_argument_invoke::TAO_ARG_NONE)
28 be_visitor_operation_argument_invoke::~be_visitor_operation_argument_invoke ()
32 int
33 be_visitor_operation_argument_invoke::pre_process (be_decl *bd)
35 TAO_OutStream *os = this->ctx_->stream ();
37 be_argument *arg = dynamic_cast<be_argument*> (bd);
39 if (!arg)
41 ACE_ERROR_RETURN ((LM_ERROR,
42 "(%N:%l) "
43 "be_visitor_operation_argument_invoke"
44 "::pre_process - "
45 "Bad argument node\n"),
46 -1);
49 switch (arg->direction ())
51 case AST_Argument::dir_IN:
52 if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
54 if (this->last_arg_printed_ !=
55 be_visitor_operation_argument_invoke::TAO_ARG_NONE)
56 *os << " &&" << be_nl;
58 else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
60 // nothing
62 break;
63 case AST_Argument::dir_INOUT:
64 if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
66 if (this->last_arg_printed_ !=
67 be_visitor_operation_argument_invoke::TAO_ARG_NONE)
68 *os << " &&" << be_nl;
70 else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
72 if (this->last_arg_printed_ !=
73 be_visitor_operation_argument_invoke::TAO_ARG_NONE)
74 *os << " &&" << be_nl;
76 break;
77 case AST_Argument::dir_OUT:
78 if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
80 // nothing
82 else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
84 if (this->last_arg_printed_ !=
85 be_visitor_operation_argument_invoke::TAO_ARG_NONE)
86 *os << " &&" << be_nl;
88 break;
91 return 0;
94 int
95 be_visitor_operation_argument_invoke::post_process (be_decl *bd)
97 be_argument *arg = dynamic_cast<be_argument*> (bd);
99 if (!arg)
101 ACE_ERROR_RETURN ((LM_ERROR,
102 "(%N:%l) "
103 "be_visitor_operation_argument_invoke"
104 "::post_process - "
105 "Bad argument node\n"),
106 -1);
109 switch (this->ctx_->sub_state ())
111 case TAO_CodeGen::TAO_CDR_OUTPUT:
112 switch (arg->direction ())
114 case AST_Argument::dir_IN:
115 // only these arguments get printed
116 this->last_arg_printed_ =
117 be_visitor_operation_argument_invoke::TAO_ARG_IN;
118 break;
119 case AST_Argument::dir_INOUT:
120 // only these arguments get printed
121 this->last_arg_printed_ =
122 be_visitor_operation_argument_invoke::TAO_ARG_INOUT;
123 break;
124 case AST_Argument::dir_OUT:
125 // these arguments don't get printed for the << operator on the stub
126 break;
128 break;
129 case TAO_CodeGen::TAO_CDR_INPUT:
130 switch (arg->direction ())
132 case AST_Argument::dir_IN:
133 // these arguments don't get printed for the >> on the stub
134 break;
135 case AST_Argument::dir_INOUT:
136 // only these arguments get printed
137 this->last_arg_printed_ =
138 be_visitor_operation_argument_invoke::TAO_ARG_INOUT;
139 break;
140 case AST_Argument::dir_OUT:
141 // only these arguments get printed
142 this->last_arg_printed_ =
143 be_visitor_operation_argument_invoke::TAO_ARG_OUT;
144 break;
146 break;
147 default:
148 ACE_ERROR_RETURN ((LM_ERROR,
149 "(%N:%l) "
150 "be_visitor_operation_argument_invoke"
151 "::post_process - "
152 "Bad sub state\n"),
153 -1);
156 return 0;