summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_argument/argument.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_visitor_argument/argument.cpp93
1 files changed, 91 insertions, 2 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp
index b20bc5f29b5..7bd31dbdffa 100644
--- a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp
@@ -12,7 +12,6 @@
*/
//=============================================================================
-
be_visitor_args::be_visitor_args (be_visitor_context *ctx)
: be_visitor_decl (ctx),
fixed_direction_ (-1)
@@ -42,7 +41,8 @@ be_visitor_args::type_name (be_type *node,
be_type *bt = 0;
- // Use the typedefed name if that is the one used in the IDL defn.
+ // Use the typedefed name if that is the one
+ // used in the IDL defn.
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
@@ -87,3 +87,92 @@ be_visitor_args::set_fixed_direction (AST_Argument::Direction direction)
{
this->fixed_direction_ = direction;
}
+
+int
+be_visitor_args::gen_pd_arg (be_predefined_type *node,
+ bool for_stub)
+{
+ TAO_CodeGen::CG_SUB_STATE ss = this->ctx_->sub_state ();
+ AST_Argument::Direction d = this->direction ();
+
+ bool in_arg = (d == AST_Argument::dir_IN);
+ bool out_arg = (d == AST_Argument::dir_OUT);
+ bool out_stream = (ss == TAO_CodeGen::TAO_CDR_OUTPUT);
+ bool in_stream = (ss == TAO_CodeGen::TAO_CDR_INPUT);
+
+ bool skip = (in_arg && for_stub && in_stream)
+ || (in_arg && !for_stub && out_stream)
+ || (out_arg && for_stub && out_stream)
+ || (out_arg && !for_stub && in_stream);
+
+ if (skip)
+ {
+ return 0;
+ }
+
+ TAO_OutStream *os = this->ctx_->stream ();
+ const char *var_call = "";
+ const char *any_deref = "";
+
+ AST_PredefinedType::PredefinedType pt = node->pt ();
+ bool is_any = (pt == AST_PredefinedType::PT_any);
+
+ if (for_stub)
+ {
+ if (in_stream && out_arg)
+ {
+ var_call = ".ptr ()";
+ any_deref = "*";
+ }
+ }
+ else if (out_stream)
+ {
+ var_call = ".in ()";
+
+ if (is_any && !out_arg)
+ {
+ var_call = "";
+ }
+ }
+ else if (!is_any)
+ {
+ var_call = ".out ()";
+ }
+
+ ACE_CString to_from_str = (in_stream
+ ? "::ACE_InputCDR::to_"
+ : "::ACE_OutputCDR::from_");
+
+ const char *to_from = to_from_str.c_str ();
+
+ be_argument *arg =
+ be_argument::narrow_from_decl (this->ctx_->node ());
+ const char *lname = arg->local_name ()->get_string ();
+
+ switch (pt)
+ {
+ case AST_PredefinedType::PT_any:
+ *os << any_deref; // No break.
+ case AST_PredefinedType::PT_pseudo:
+ case AST_PredefinedType::PT_object:
+ *os << lname << var_call;
+ break;
+ case AST_PredefinedType::PT_char:
+ *os << to_from << "char (" << lname << ")";
+ break;
+ case AST_PredefinedType::PT_wchar:
+ *os << to_from << "wchar (" << lname << ")";
+ break;
+ case AST_PredefinedType::PT_boolean:
+ *os << to_from << "boolean (" << lname << ")";
+ break;
+ case AST_PredefinedType::PT_octet:
+ *os << to_from << "octet (" << lname << ")";
+ break;
+ default:
+ *os << lname;
+ break;
+ }
+
+ return 0;
+} \ No newline at end of file