diff options
Diffstat (limited to 'TAO/TAO_IDL/be/be_array.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_array.cpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_array.cpp b/TAO/TAO_IDL/be/be_array.cpp index dac2ad3fc56..34c77c9e340 100644 --- a/TAO/TAO_IDL/be/be_array.cpp +++ b/TAO/TAO_IDL/be/be_array.cpp @@ -218,6 +218,117 @@ be_array::gen_dimensions (TAO_OutStream *os, unsigned short slice) return 0; } +int +be_array::gen_typecode (void) +{ + TAO_OutStream *os; // output stream + + os = tao_cg->client_stubs (); + os->indent (); // start from whatever indentation level we were at + + *os << "CORBA::tk_array, // typecode kind" << be_nl; + *os << this->tc_encap_len () << ", // encapsulation length" << be_idt << "\n"; + // now emit the encapsulation + if (this->gen_encapsulation () == -1) + { + } + // *os << (this->dims () [0]) << "," << be_nl; + return 0; +} + +// generate encapsulation +// An encapsulation for ourselves will be necessary when we are part of some +// other IDL type and a typecode for that other type is being generated. This +// will comprise our typecode kind. IDL types with parameters will additionally +// have the encapsulation length and the entire typecode description + +int +be_array::gen_encapsulation (void) +{ + TAO_OutStream *os; // output stream + be_type *bt; // base type + unsigned long i; + + os = tao_cg->client_stubs (); + os->indent (); // start from the current indentation level + + // retrieve the base type + bt = be_type::narrow_from_decl (this->base_type ()); + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_array::gen_encapsulation - " + "bad base type\n"), + -1); + } + + for (i=0; i < (this->n_dims () - 1); i++) + { + unsigned long rem_encap_len; + + *os << "TAO_ENCAP_BYTE_ORDER, // byte order" << be_nl; + *os << "CORBA::tk_array, // typecode kind" << be_nl; + rem_encap_len + = (this->n_dims () - (i+1))*(4+4) + + (this->n_dims () - (i+2))*(4+4) + + bt->tc_size (); + *os << rem_encap_len << ", // encapsulation length" << be_idt_nl; + } + *os << "TAO_ENCAP_BYTE_ORDER, // byte order\n"; + if (bt->gen_typecode () == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_array::gen_encapsulation - " + "base type tyepcode gen failed\n"), + -1); + } + os->indent (); + for (i = (this->n_dims ()-1); i > 0; i--) + { + *os << this->dims ()[i] << "," << be_uidt_nl; + } + *os << this->dims ()[0] << be_uidt << ",\n"; + return 0; +} + +// compute typecode size +long +be_array::tc_size (void) +{ + // 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the + // actual encapsulation + return 4 + 4 + this->tc_encap_len (); +} + +long +be_array::tc_encap_len (void) +{ + // Suppose "N" is the number of dimensions, then for a N dimensional array, + // we will have N encapsulations. The innermost encapsulation will hold the + // typecode of the real base type. + // Thus, we will have N byte order flags and dimensions, and N-1 tk_array + // enumerations, encapsulation lengths, and dimensions. + + if (this->encap_len_ == -1) // not computed yet + { + be_type *bt; // base type + + bt = be_type::narrow_from_decl (this->base_type ()); + if (!bt) + { + ACE_ERROR ((LM_ERROR, + "be_array::tc_encap_len - bad base type\n")); + return 0; + } + this->encap_len_ = + this->n_dims () * (4+4) // N byte order flags and dims + + (this->n_dims ()-1)* (4+4); // N-1 of Enum and encap lengths + // to this you add the typecode size of the underlying type + this->encap_len_ += bt->tc_size (); + } + return this->encap_len_; +} + // compute the size type of the node in question int be_array::compute_size_type (void) |