summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_predefined_type.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/TAO_IDL/be/be_predefined_type.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_predefined_type.cpp143
1 files changed, 143 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp
index 4541f60d37a..4ca417ca519 100644
--- a/TAO/TAO_IDL/be/be_predefined_type.cpp
+++ b/TAO/TAO_IDL/be/be_predefined_type.cpp
@@ -282,6 +282,149 @@ be_predefined_type::compute_tc_name (void)
}
}
+int
+be_predefined_type::gen_typecode (void)
+{
+ TAO_OutStream *cs; // output stream
+ TAO_NL nl; // end line
+ TAO_CodeGen *cg = TAO_CODEGEN::instance ();
+
+ // Macro to avoid "warning: unused parameter" type warning.
+ ACE_UNUSED_ARG (nl);
+
+ cs = cg->client_stubs ();
+ cs->indent (); // start from the current indentation level
+
+ switch (this->pt ())
+ {
+ case AST_PredefinedType::PT_void:
+ *cs << "CORBA::tk_void,\n\n";
+ break;
+ case AST_PredefinedType::PT_short:
+ *cs << "CORBA::tk_short,\n\n";
+ break;
+ case AST_PredefinedType::PT_ushort:
+ *cs << "CORBA::tk_ushort,\n\n";
+ break;
+ case AST_PredefinedType::PT_long:
+ *cs << "CORBA::tk_long,\n\n";
+ break;
+ case AST_PredefinedType::PT_ulong:
+ *cs << "CORBA::tk_ulong,\n\n";
+ break;
+ case AST_PredefinedType::PT_longlong:
+ *cs << "CORBA::tk_longlong,\n\n";
+ break;
+ case AST_PredefinedType::PT_ulonglong:
+ *cs << "CORBA::tk_ulonglong,\n\n";
+ break;
+ case AST_PredefinedType::PT_float:
+ *cs << "CORBA::tk_float,\n\n";
+ break;
+ case AST_PredefinedType::PT_double:
+ *cs << "CORBA::tk_double,\n\n";
+ break;
+ case AST_PredefinedType::PT_longdouble:
+ *cs << "CORBA::tk_longdouble,\n\n";
+ break;
+ case AST_PredefinedType::PT_boolean:
+ *cs << "CORBA::tk_boolean,\n\n";
+ break;
+ case AST_PredefinedType::PT_char:
+ *cs << "CORBA::tk_char,\n\n";
+ break;
+ case AST_PredefinedType::PT_octet:
+ *cs << "CORBA::tk_octet,\n\n";
+ break;
+ case AST_PredefinedType::PT_any:
+ *cs << "CORBA::tk_any,\n\n";
+ break;
+ case AST_PredefinedType::PT_wchar:
+ *cs << "CORBA::tk_wchar,\n\n";
+ break;
+ case AST_PredefinedType::PT_pseudo:
+ {
+ if (!ACE_OS::strcmp (this->local_name ()->get_string (), "TypeCode"))
+ *cs << "CORBA::tk_TypeCode,\n\n";
+ else
+ if (!ACE_OS::strcmp (this->local_name ()->get_string (), "Object"))
+ {
+ *cs << "CORBA::tk_objref,\n";
+ *cs << this->tc_encap_len () << ", // encapsulation length\n";
+ // now emit the encapsulation
+ this->gen_encapsulation ();
+ }
+ }
+ break;
+ }
+ return 0;
+}
+
+long
+be_predefined_type::tc_size (void)
+{
+ if (ACE_OS::strcmp (this->local_name ()->get_string (), "Object")) // not same
+ return 4; // for the enum value
+ else
+ return 4 + 4 + this->tc_encap_len ();
+}
+
+long
+be_predefined_type::tc_encap_len (void)
+{
+ if ((this->encap_len_ == -1) // not computed yet
+ && (!ACE_OS::strcmp (this->local_name ()->get_string (), "Object")))
+ // is a CORBA::Object
+ {
+ this->encap_len_ = 4; // holds the byte order flag
+
+ this->encap_len_ += this->repoID_encap_len (); // for repoID
+
+ // do the same thing for the local name
+ this->encap_len_ += this->name_encap_len ();
+ }
+
+ return this->encap_len_;
+}
+
+int
+be_predefined_type::gen_encapsulation (void)
+{
+ if ((this->pt () == AST_PredefinedType::PT_any)
+ || (this->pt () == AST_PredefinedType::PT_pseudo))
+ {
+ TAO_OutStream *cs; // output stream
+ TAO_NL nl; // end line
+ TAO_CodeGen *cg = TAO_CODEGEN::instance ();
+ long i, arrlen;
+ ACE_UINT32 *arr;
+
+ cs = cg->client_stubs ();
+ cs->indent (); // start from whatever indentation level we were at
+
+ // XXXASG - byte order must be based on what m/c we are generating code -
+ // TODO
+ *cs << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl;
+ // generate repoID
+ *cs << (ACE_OS::strlen (this->repoID ())+1) << ", ";
+ (void)this->tc_name2long (this->repoID (), arr, arrlen);
+ for (i=0; i < arrlen; i++)
+ {
+ cs->print ("ACE_NTOHL (0x%x), ", arr[i]);
+ }
+ *cs << " // repository ID = " << this->repoID () << nl;
+ // generate name
+ *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", ";
+ (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen);
+ for (i=0; i < arrlen; i++)
+ {
+ cs->print ("ACE_NTOHL (0x%x), ", arr[i]);
+ }
+ *cs << " // name = " << this->local_name () << ",\n";
+ }
+ return 0;
+}
+
// compute the size type of the node in question
int
be_predefined_type::compute_size_type (void)