PSDL_Struct_Visitor.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // PSDL_Struct_Visitor.cpp,v 1.7 2006/04/19 10:21:13 jwillemsen Exp
00003 
00004 #include "PSDL_Struct_Visitor.h"
00005 #include "PSDL_Stream.h"
00006 #include "PSDL_y.h"
00007 #include "tao/CORBA_String.h"
00008 
00009 ACE_RCSID (PSS, PSDL_Struct_Visitor, "PSDL_Struct_Visitor.cpp,v 1.7 2006/04/19 10:21:13 jwillemsen Exp")
00010 
00011 TAO_PSDL_Struct_Visitor::TAO_PSDL_Struct_Visitor (void)
00012   : identifiers_count_ (0),
00013     struct_name_ ()
00014 {
00015 }
00016 
00017 TAO_PSDL_Struct_Visitor::~TAO_PSDL_Struct_Visitor (void)
00018 {
00019 }
00020 
00021 int
00022 TAO_PSDL_Struct_Visitor::visit_identifier (TAO_PSDL_Identifier *identifier)
00023 {
00024   // The first time it will enter this function is to get the name of
00025   // the struct. And, then on, for the members in the structure.
00026   // so this->identifiers_[0] will be the name of the struct.
00027   if (this->identifiers_.size () == 0)
00028     {
00029       this->identifiers_.size (1);
00030       this->count_ = 0;
00031     }
00032 
00033   if (this->identifiers_.size () < this->count_ + 1)
00034     this->identifiers_.size (this->count_ + 1);
00035 
00036   this->identifiers_ [this->count_] = identifier->value ();
00037   ++this->count_;
00038 
00039   return 0;
00040 }
00041 
00042 int
00043 TAO_PSDL_Struct_Visitor::visit_type_spec (TAO_PSDL_Type_Spec *type_spec)
00044 {
00045   if (type_spec->type_of_type_spec ()->accept (this) == -1)
00046     return -1;
00047 
00048   ACE_CString type;
00049   // Get a pointer to PSDL_Stream of the stub header.
00050   TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh ();
00051 
00052   if (this->base_type (this->identifiers_[this->identifiers_count_], type))
00053     {
00054       // If this is a predefined type like long or char *
00055       if (ACE_OS::strcmp (type.c_str (), "char *") == 0)
00056         {
00057           ps_sh->indent ();
00058           *ps_sh << " TAO::String_Manager ";
00059         }
00060       else
00061         {
00062           *ps_sh << " "
00063                  << this->version_for_stub (type) << " ";
00064         }
00065     }
00066   else
00067     {
00068       *ps_sh << "ACE_NESTED_CLASS ("
00069            << TAO_PSDL_Scope::instance ()->get_name_space ()
00070            << ", " << this->identifiers_ [this->identifiers_count_] << ") ";
00071     }
00072 
00073   ++this->identifiers_count_;
00074   return 0;
00075 }
00076 
00077 int
00078 TAO_PSDL_Struct_Visitor::visit_declarator (TAO_PSDL_Declarator *declarator)
00079 {
00080   if (declarator->type_of_declarator ()->accept (this) == -1)
00081     return -1;
00082 
00083   // Get a pointer to PSDL_Stream of the stub header.
00084   TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh ();
00085 
00086   *ps_sh << this->identifiers_ [this->identifiers_count_].c_str ()
00087        << ";\n";
00088 
00089   ++this->identifiers_count_;
00090   return 0;
00091 }
00092 
00093 int
00094 TAO_PSDL_Struct_Visitor::visit_predefined_type (TAO_PSDL_Predefined_Type *predefined_type)
00095 {
00096   // Get a pointer to PSDL_Stream of the stub header.
00097   TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh ();
00098 
00099   // Reset the indentation.
00100   ps_sh->reset ();
00101 
00102   if (predefined_type->type_of_variable_one () != 0)
00103     {
00104       if (predefined_type->type_of_variable_one ()->accept (this) == -1)
00105         return -1;
00106 
00107       this->struct_name_ = CORBA::string_dup (this->identifiers_ [0].c_str ());
00108 
00109       *ps_sh << "struct " << this->struct_name_
00110            << ";\n";
00111 
00112       *ps_sh << "class " << this->struct_name_
00113            << "_var;";
00114 
00115       ps_sh->nl ();
00116       ps_sh->nl ();
00117 
00118       *ps_sh << "struct " << this->struct_name_;
00119       ps_sh->nl ();
00120 
00121       *ps_sh << "{";
00122       ps_sh->nl ();
00123 
00124       ps_sh->nl ();
00125 
00126       *ps_sh << "typedef " << this->struct_name_ << "_var _var_type;\n";
00127 
00128       ps_sh->nl ();
00129 
00130       ps_sh->nl ();
00131 
00132       *ps_sh << "static void _tao_any_destructor (void*);";
00133 
00134       ps_sh->nl ();
00135       ps_sh->nl ();
00136     }
00137 
00138   if (predefined_type->type_of_variable_two () != 0)
00139     {
00140       // Resetting the counter to be used while printing out the
00141       // type_spec and declarator informations. See the corresponding
00142       // visit_* methods.
00143 
00144       if (this->count_ > 0)
00145         this->identifiers_count_ = 1;
00146 
00147       if (predefined_type->type_of_variable_two ()->accept (this) == -1)
00148         return -1;
00149 
00150       *ps_sh << "\n};\n\n";
00151 
00152       this->print_class_for_structure (this->struct_name_);
00153     }
00154 
00155   if (predefined_type->type_one () != 0)
00156     {
00157       // If the member declarations in the structure include any
00158       // predefined types like long, save them and increment the counter.
00159       if (this->identifiers_.size () < this->count_ + 1)
00160         this->identifiers_.size (this->count_ + 1);
00161 
00162       this->identifiers_ [this->count_] =
00163         TAO_PSDL_Scope::instance ()->convert_str (predefined_type->type_one ());
00164 
00165       ++this->count_;
00166     }
00167 
00168   return 0;
00169 }
00170 
00171 void
00172 TAO_PSDL_Struct_Visitor::gen_code_for_si (void)
00173 {
00174   TAO_PSDL_Stream *ps_si = TAO_PSDL_Scope::instance ()->get_si ();
00175 
00176   ps_si->reset ();
00177   ps_si->indent (); // start from current indentation level
00178 
00179   // Generate the typecode information here
00180   *ps_si << "static const CORBA::Long _oc_";
00181 
00182   // Flat name generation.
00183   *ps_si << this->struct_name_;
00184   *ps_si << "[] =";
00185   ps_si->nl ();
00186   *ps_si << "{";
00187   ps_si->nl ();
00188 
00189   // Some invocation call to put in the stuff that goes between
00190   // braces.
00191   *ps_si << "TAO_ENCAP_BYTE_ORDER";
00192   ps_si->nl ();
00193   *ps_si << "// Typecode related information should go in here";
00194   ps_si->nl ();
00195 
00196   *ps_si << "};";
00197   ps_si->nl ();
00198   ps_si->nl ();
00199 
00200   *ps_si << "static CORBA::TypeCode _tc_TAO_tc_";
00201   *ps_si << this->struct_name_;
00202   *ps_si << " (";
00203   ps_si->nl ();
00204   ps_si->incr_indent (0);
00205   *ps_si << "CORBA::tk_struct,";
00206   ps_si->nl ();
00207   *ps_si << "sizeof (_oc_" << this->struct_name_ << "),";
00208   ps_si->nl ();
00209   *ps_si << "(char *) &_oc_";
00210   *ps_si << this->struct_name_ << ",";
00211   ps_si->nl ();
00212   *ps_si << "0,";
00213   ps_si->nl ();
00214   *ps_si << "sizeof (" << this->struct_name_ << ")";
00215   ps_si->nl ();
00216   *ps_si << ");";
00217   ps_si->decr_indent ();
00218 
00219   ps_si->nl ();
00220   ps_si->nl ();
00221   *ps_si << "::CORBA::TypeCode_ptr _tc_" << this->struct_name_ << " =";
00222   ps_si->nl ();
00223   ps_si->incr_indent (0);
00224 
00225   *ps_si << "&_tc_TAO_tc_" << this->struct_name_ << ";";
00226   ps_si->decr_indent ();
00227   ps_si->nl ();
00228   ps_si->nl ();
00229 
00230   *ps_si << "void ";
00231   *ps_si << this->struct_name_
00232          << "::_tao_any_destructor (void *_tao_void_pointer)";
00233   ps_si->nl ();
00234 
00235   *ps_si << "{";
00236   ps_si->nl ();
00237   ps_si->incr_indent (0);
00238 
00239   *ps_si << this->struct_name_ << " *tmp = "
00240          << "ACE_static_cast ("
00241          << this->struct_name_
00242          << "*, _tao_void_pointer);";
00243 
00244   ps_si->nl ();
00245   *ps_si << "delete tmp;";
00246   ps_si->decr_indent ();
00247   ps_si->nl ();
00248   ps_si->decr_indent ();
00249   *ps_si <<"}";
00250   ps_si->nl ();
00251   ps_si->nl ();
00252 
00253   // Copying Insertion
00254 
00255   *ps_si << "// Copying insertion.";
00256   ps_si->nl ();
00257 
00258   *ps_si << "void operator<<= (";
00259 
00260   ps_si->incr_indent (0); ps_si->nl ();
00261 
00262   *ps_si << "CORBA::Any &_tao_any,"; ps_si->nl ();
00263   *ps_si << "const " << this->struct_name_ << " &_tao_elem"; ps_si->nl ();
00264 
00265   ps_si->decr_indent ();
00266 
00267   *ps_si << ")"; ps_si->nl ();
00268 
00269   *ps_si << "{";
00270   ps_si->incr_indent (0); ps_si->nl ();
00271   *ps_si << "TAO_OutputCDR stream;"; ps_si->nl ();
00272 
00273   *ps_si << "if (stream << _tao_elem)"; ps_si->nl ();
00274   *ps_si << "{";
00275 
00276   ps_si->incr_indent (0); ps_si->nl ();
00277 
00278   *ps_si << "_tao_any._tao_replace (";
00279 
00280   ps_si->incr_indent (0); ps_si->nl ();
00281 
00282   *ps_si << "_tc_" << this->struct_name_ << ","; ps_si->nl ();
00283   *ps_si << "TAO_ENCAP_BYTE_ORDER,"; ps_si->nl ();
00284   *ps_si << "stream.begin ()";
00285 
00286   ps_si->decr_indent (0); ps_si->nl ();
00287   *ps_si << ");";
00288 
00289   ps_si->decr_indent (0); ps_si->nl ();
00290   *ps_si << "}";
00291 
00292   ps_si->decr_indent (0); ps_si->nl ();
00293   *ps_si << "}";
00294 
00295   ps_si->nl ();
00296 
00297   ps_si->reset ();
00298   ps_si->nl ();
00299 
00300   *ps_si << "// Non-copying insertion."; ps_si->nl ();
00301   *ps_si << "void operator<<= (";
00302   ps_si->incr_indent (0); ps_si->nl ();
00303 
00304   *ps_si << "CORBA::Any &_tao_any,"; ps_si->nl ();
00305   *ps_si << this->struct_name_ << " *_tao_elem";
00306 
00307   ps_si->nl ();
00308   *ps_si << ")";
00309 
00310   ps_si->decr_indent (0);  ps_si->nl ();
00311 
00312   *ps_si << "{";
00313   ps_si->incr_indent (0); ps_si->nl ();
00314 
00315   *ps_si << "TAO_OutputCDR stream;"; ps_si->nl ();
00316 
00317   *ps_si << "if (stream << *_tao_elem)"; ps_si->nl ();
00318 
00319   *ps_si << "{";
00320   ps_si->incr_indent (0); ps_si->nl ();
00321 
00322   *ps_si << "_tao_any._tao_replace (";
00323   ps_si->incr_indent (0);ps_si->nl ();
00324 
00325   *ps_si << "_tc_" << this->struct_name_ << ","; ps_si->nl ();
00326   *ps_si << "TAO_ENCAP_BYTE_ORDER,"; ps_si->nl ();
00327   *ps_si << "stream.begin (),"; ps_si->nl ();
00328   *ps_si << "1,"; ps_si->nl ();
00329   *ps_si << "_tao_elem,"; ps_si->nl ();
00330   *ps_si << this->struct_name_ << "::_tao_any_destructor";
00331 
00332   ps_si->decr_indent (0); ps_si->nl ();
00333   *ps_si << ");";
00334 
00335   ps_si->decr_indent (0); ps_si->nl ();
00336   *ps_si << "}";
00337 
00338   ps_si->decr_indent (0); ps_si->nl ();
00339   *ps_si << "}"; ps_si->nl ();
00340 
00341   ps_si->reset ();
00342   ps_si->nl ();
00343 
00344   *ps_si << "// Extraction to const pointer."; ps_si->nl ();
00345 
00346   *ps_si << "CORBA::Boolean operator>>= (";
00347   ps_si->incr_indent (0); ps_si->nl ();
00348 
00349   *ps_si << "const CORBA::Any &_tao_any,"; ps_si->nl ();
00350   *ps_si << "const " << this->struct_name_ << " *&_tao_elem"; ps_si->nl ();
00351 
00352   *ps_si << ")";
00353   ps_si->decr_indent (0); ps_si->nl ();
00354 
00355   *ps_si << "{";
00356   ps_si->incr_indent (0);  ps_si->nl ();
00357 
00358   *ps_si << "_tao_elem = 0;"; ps_si->nl ();
00359 
00360   *ps_si << "ACE_TRY_NEW_ENV"; ps_si->nl ();
00361 
00362   *ps_si << "{";
00363   ps_si->incr_indent (0); ps_si->nl ();
00364 
00365   *ps_si << "CORBA::TypeCode_var type = _tao_any.type ();"; ps_si->nl ();
00366   *ps_si << "CORBA::Boolean result ="; ps_si->nl ();
00367 
00368   *ps_si << "type->equivalent (";
00369   ps_si->incr_indent (0); ps_si->nl ();
00370 
00371   *ps_si << "_tc_" << this->struct_name_ << ""; ps_si->nl ();
00372   *ps_si << "ACE_ENV_ARG_PARAMETER";
00373 
00374   ps_si->decr_indent (0); ps_si->nl ();
00375 
00376   *ps_si << ");"; ps_si->nl ();
00377   *ps_si << "ACE_TRY_CHECK;"; ps_si->nl ();
00378 
00379   *ps_si << "if (result == 0)"; ps_si->nl ();
00380 
00381   *ps_si << "{";
00382   ps_si->incr_indent (0); ps_si->nl ();
00383 
00384   *ps_si << "return 0; // not equivalent";
00385 
00386   ps_si->decr_indent (0); ps_si->nl ();
00387   *ps_si << "}"; ps_si->nl ();
00388 
00389   *ps_si << "if (_tao_any.any_owns_data ())"; ps_si->nl ();
00390   *ps_si << "{";
00391   ps_si->incr_indent (0); ps_si->nl ();
00392 
00393   *ps_si << "_tao_elem = ACE_static_cast (";
00394   ps_si->incr_indent (0); ps_si->nl ();
00395 
00396   *ps_si << "const " << this->struct_name_ << "*,"; ps_si->nl ();
00397   *ps_si << "_tao_any.value ()";
00398 
00399   ps_si->decr_indent (0); ps_si->nl ();
00400   *ps_si << ");"; ps_si->nl ();
00401 
00402   *ps_si << "return 1;"; ps_si->nl ();
00403 
00404   ps_si->decr_indent (0); ps_si->nl ();
00405   *ps_si << "}"; ps_si->nl ();
00406 
00407   *ps_si << "else"; ps_si->nl ();
00408   *ps_si << "{";
00409   ps_si->incr_indent (0); ps_si->nl ();
00410 
00411   *ps_si << this->struct_name_ << " *tmp;"; ps_si->nl ();
00412 
00413   *ps_si << "ACE_NEW_RETURN (";
00414   ps_si->incr_indent (0); ps_si->nl ();
00415 
00416   *ps_si << "tmp,"; ps_si->nl ();
00417   *ps_si << this->struct_name_ << ","; ps_si->nl ();
00418   *ps_si << "0"; ps_si->nl ();
00419   ps_si->decr_indent (0); ps_si->nl ();
00420   *ps_si << ");"; ps_si->nl ();
00421   *ps_si << ""; ps_si->nl ();
00422 
00423   *ps_si << "TAO_InputCDR stream (";
00424   ps_si->incr_indent (0); ps_si->nl ();
00425 
00426   *ps_si << "_tao_any._tao_get_cdr (),"; ps_si->nl ();
00427   *ps_si << "_tao_any._tao_byte_order ()";
00428 
00429   ps_si->decr_indent (0); ps_si->nl ();
00430   *ps_si << ");"; ps_si->nl ();
00431 
00432   *ps_si << "if (stream >> *tmp)"; ps_si->nl ();
00433   *ps_si << "{";
00434   ps_si->incr_indent (0); ps_si->nl ();
00435 
00436   *ps_si << "((CORBA::Any *)&_tao_any)->_tao_replace (";
00437   ps_si->incr_indent (0); ps_si->nl ();
00438   *ps_si << "_tc_" << this->struct_name_ << ","; ps_si->nl ();
00439   *ps_si << "1,"; ps_si->nl ();
00440   *ps_si << "static_cast<void *> (tmp),"; ps_si->nl ();
00441   *ps_si << this->struct_name_ << "::_tao_any_destructor";
00442 
00443   ps_si->decr_indent (0); ps_si->nl ();
00444   *ps_si << ");"; ps_si->nl ();
00445 
00446   *ps_si << "_tao_elem = tmp;"; ps_si->nl ();
00447   *ps_si << "return 1;";
00448 
00449   ps_si->decr_indent (0); ps_si->nl ();
00450   *ps_si << "}"; ps_si->nl ();
00451 
00452   *ps_si << "else"; ps_si->nl ();
00453 
00454   *ps_si << "{";
00455   ps_si->incr_indent (0); ps_si->nl ();
00456 
00457   *ps_si << "delete tmp;";
00458 
00459   ps_si->decr_indent (0); ps_si->nl ();
00460   *ps_si << "}";
00461 
00462   ps_si->decr_indent (0); ps_si->nl ();
00463   *ps_si << "}";
00464 
00465   ps_si->decr_indent (0); ps_si->nl ();
00466   *ps_si << "}"; ps_si->nl ();
00467 
00468   *ps_si << "ACE_CATCHANY"; ps_si->nl ();
00469   *ps_si << "{";
00470   ps_si->nl ();
00471   *ps_si << "}"; ps_si->nl ();
00472 
00473   *ps_si << "ACE_ENDTRY;"; ps_si->nl ();
00474   *ps_si << "return 0;"; ps_si->nl ();
00475   ps_si->decr_indent (0); ps_si->nl ();
00476   *ps_si << "}";
00477 
00478   ps_si->reset ();
00479   ps_si->nl (); ps_si->nl ();
00480 
00481   return;
00482 }
00483 
00484 void
00485 TAO_PSDL_Struct_Visitor::print_class_for_structure (ACE_CString struct_name)
00486 {
00487   // Get a pointer to PSDL_Stream of the stub header.
00488   TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh ();
00489 
00490   *ps_sh << "class " << struct_name.c_str () << "_var\n";
00491   *ps_sh << "{\n";
00492 
00493   *ps_sh << "public:\n";
00494   *ps_sh << "   " << struct_name << "_var (void);\n";
00495   *ps_sh << "   " << struct_name << "_var (" << struct_name
00496          << " *);\n";
00497   *ps_sh << "   " << struct_name << "_var (const " << struct_name
00498        << "_var &);\n";
00499   *ps_sh << "   ~" << struct_name << "_var (void"
00500        << ");\n";
00501 
00502     ps_sh->nl ();
00503 
00504 
00505   *ps_sh << "   " << struct_name << "_var"
00506        << " &operator= (" << struct_name
00507        << " *);\n";
00508 
00509   *ps_sh << "   " << struct_name << "_var"
00510        << " &operator= (const " << struct_name
00511        << "_var &);\n";
00512 
00513   *ps_sh << "   " << struct_name
00514        << " *operator-> (void);\n";
00515 
00516   *ps_sh << "   const " << struct_name
00517        << " *operator-> (void) const;\n";
00518 
00519     ps_sh->nl ();
00520 
00521 
00522   *ps_sh << "   operator const "
00523        << struct_name << "&() const;\n";
00524 
00525   *ps_sh << "   operator "
00526        << struct_name << "&();\n";
00527 
00528   *ps_sh << "   operator "
00529        << struct_name << "&() const;\n";
00530 
00531   *ps_sh << "   // Variable-size types only.\n";
00532 
00533   *ps_sh << "   operator "
00534        << struct_name << "*&();\n";
00535 
00536   *ps_sh << "  // in inout, out, _retn\n";
00537   *ps_sh << "  const " << struct_name << "&in (void) const;\n";
00538   *ps_sh << "  " << struct_name << " &inout (void);\n";
00539   *ps_sh << "  " << struct_name << " *&out (void);\n";
00540   *ps_sh << "  " << struct_name << " *_retn (void);\n";
00541   *ps_sh << "  " << struct_name << " *ptr (void) const;\n";
00542 
00543   *ps_sh << "private:\n";
00544   *ps_sh << "  " << struct_name << " *ptr_;\n";
00545 
00546   *ps_sh << "};\n";
00547 
00548   *ps_sh << "class  " << struct_name << "_out \n";
00549   *ps_sh << "{\n";
00550   *ps_sh << "  public:\n";
00551   *ps_sh << "    " << struct_name << "_out ("
00552          << struct_name << " *&);\n";
00553   *ps_sh << "    " << struct_name << "_out ("
00554          << struct_name << "_var &);\n";
00555   *ps_sh << "    " << struct_name << "_out (const "
00556          << struct_name << "_out &);\n";
00557   *ps_sh << "    " << struct_name << "_out &operator= (const "
00558          << struct_name << "_out &);\n";
00559   *ps_sh << "    " << struct_name << "_out &operator= ("
00560          << struct_name << " *);\n";
00561   *ps_sh << "    operator " << struct_name << " *&();\n";
00562   *ps_sh << "    " << struct_name << " *&ptr (void);\n";
00563   *ps_sh << "    " << struct_name << " *operator-> (void);\n";
00564   ps_sh->nl ();
00565 
00566   *ps_sh << "  private:\n";
00567   *ps_sh << "    " << struct_name << " *&ptr_;\n";
00568   *ps_sh << "    // Assignment from T_var not allowed.\n";
00569   *ps_sh << "    void operator= (const " << struct_name << "_var &);\n";
00570   *ps_sh << "  };\n";
00571 
00572   *ps_sh << "TAO_NAMESPACE_STORAGE_CLASS ::CORBA::TypeCode_ptr"
00573          << " _tc_" << struct_name << ";";
00574   ps_sh->nl ();
00575   ps_sh->nl ();
00576 
00577   *ps_sh << " void operator<<= (CORBA::Any &, const " << struct_name << " &);"
00578          << "// copying version";
00579   ps_sh->nl ();
00580 
00581   *ps_sh << " void operator<<= (CORBA::Any &, " << struct_name << "*);"
00582          << "// noncopying version";
00583   ps_sh->nl ();
00584 
00585   *ps_sh << " CORBA::Boolean operator>>= "
00586          << "(const CORBA::Any &, " << struct_name << " *&);"
00587          << "// deprecated";
00588   ps_sh->nl ();
00589 
00590   *ps_sh << " CORBA::Boolean operator>>= "
00591          << "(const CORBA::Any &, const " << struct_name << " *&);";
00592   ps_sh->nl ();
00593 
00594   ps_sh->nl ();
00595 
00596   *ps_sh << "#ifndef __ACE_INLINE__";
00597   ps_sh->incr_indent (0);
00598   ps_sh->nl ();
00599   ps_sh->nl ();
00600 
00601   *ps_sh << " CORBA::Boolean operator<< "
00602          << "(TAO_OutputCDR &, const " << struct_name << " &);";
00603   ps_sh->nl ();
00604 
00605   *ps_sh << " CORBA::Boolean operator>> (TAO_InputCDR &, " << struct_name << " &);";
00606 
00607   ps_sh->decr_indent (0);
00608   ps_sh->nl ();
00609   ps_sh->nl ();
00610 
00611   *ps_sh << "#endif /* __ACE_INLINE__ */";
00612 
00613   ps_sh->nl ();
00614   ps_sh->nl ();
00615 }
00616 
00617 void
00618 TAO_PSDL_Struct_Visitor::gen_code_for_sinline (void)
00619 {
00620   TAO_PSDL_Stream *ps_sin = TAO_PSDL_Scope::instance ()->get_sinline ();
00621 
00622   if (ps_sin == 0)
00623   {
00624           ACE_DEBUG ((LM_DEBUG,
00625                                   "Null pointer to the psdl inline file\n"));
00626   }
00627   ps_sin->reset ();
00628 
00629   *ps_sin << "// ********************************************************";
00630   ps_sin->nl ();
00631   *ps_sin << "// Inline operations for class " << this->struct_name_ << "_var"; ps_sin->nl ();
00632   *ps_sin << "// ********************************************************";
00633   ps_sin->nl ();
00634 
00635   ps_sin->nl ();
00636 
00637   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00638   *ps_sin << this->struct_name_ << "_var::" << this->struct_name_ << "_var (void) // default constructor";
00639 
00640   ps_sin->incr_indent (0);
00641   ps_sin->nl ();
00642 
00643   *ps_sin << ": ptr_ (0)";
00644 
00645   ps_sin->decr_indent (0);
00646   ps_sin->nl ();
00647 
00648   *ps_sin << "{}";
00649 
00650   ps_sin->nl ();
00651   ps_sin->nl ();
00652 
00653   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00654   *ps_sin << this->struct_name_ << "_var::" << this->struct_name_ << "_var (" << this->struct_name_ << " *p)";
00655 
00656   ps_sin->incr_indent (0);
00657   ps_sin->nl ();
00658 
00659   *ps_sin << ": ptr_ (p)";
00660 
00661   ps_sin->decr_indent (0);
00662   ps_sin->nl ();
00663 
00664   *ps_sin << "{}";
00665 
00666   ps_sin->nl ();
00667   ps_sin->nl ();
00668 
00669   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00670   *ps_sin << this->struct_name_ << "_var::" << this->struct_name_ << "_var (const ::" << this->struct_name_ << "_var &p) // copy constructor"; ps_sin->nl ();
00671   *ps_sin << "{";
00672 
00673   ps_sin->incr_indent (0);
00674   ps_sin->nl ();
00675 
00676   *ps_sin << "if (p.ptr_)";
00677 
00678   ps_sin->incr_indent (0);
00679   ps_sin->nl ();
00680 
00681   *ps_sin << "ACE_NEW (this->ptr_, ::" << this->struct_name_ << " (*p.ptr_));";
00682 
00683   ps_sin->decr_indent (0);
00684   ps_sin->nl ();
00685 
00686   *ps_sin << "else";
00687 
00688   ps_sin->incr_indent (0);
00689   ps_sin->nl ();
00690 
00691   *ps_sin << "this->ptr_ = 0;";
00692 
00693   ps_sin->decr_indent (0);
00694   ps_sin->decr_indent (0);
00695   ps_sin->nl ();
00696 
00697   *ps_sin << "}";
00698 
00699   ps_sin->nl ();
00700   ps_sin->nl ();
00701 
00702   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00703   *ps_sin << this->struct_name_ << "_var::~" << this->struct_name_ << "_var (void) // destructor"; ps_sin->nl ();
00704   *ps_sin << "{";
00705 
00706   ps_sin->incr_indent (0);
00707   ps_sin->nl ();
00708 
00709   *ps_sin << "delete this->ptr_;";
00710 
00711   ps_sin->decr_indent (0);
00712   ps_sin->nl ();
00713 
00714   *ps_sin << "}";
00715 
00716   ps_sin->nl ();
00717   ps_sin->nl ();
00718 
00719   *ps_sin << "ACE_INLINE " << this->struct_name_ << "_var &"; ps_sin->nl ();
00720   *ps_sin << this->struct_name_ << "_var::operator= (" << this->struct_name_ << " *p)"; ps_sin->nl ();
00721   *ps_sin << "{";
00722 
00723   ps_sin->incr_indent (0);
00724   ps_sin->nl ();
00725 
00726   *ps_sin << "delete this->ptr_;"; ps_sin->nl ();
00727   *ps_sin << "this->ptr_ = p;"; ps_sin->nl ();
00728   *ps_sin << "return *this;";
00729 
00730   ps_sin->decr_indent (0);
00731   ps_sin->nl ();
00732   *ps_sin << "}";
00733 
00734   ps_sin->nl ();
00735   ps_sin->nl ();
00736 
00737   *ps_sin << "ACE_INLINE ::" << this->struct_name_ << "_var &"; ps_sin->nl ();
00738   *ps_sin << this->struct_name_ << "_var::operator= (const ::" << this->struct_name_ << "_var &p)"; ps_sin->nl ();
00739   *ps_sin << "{";
00740 
00741   ps_sin->incr_indent (0);
00742   ps_sin->nl ();
00743 
00744   *ps_sin << "if (this != &p)";
00745 
00746   ps_sin->incr_indent (0);
00747   ps_sin->nl ();
00748 
00749   *ps_sin << "{";
00750 
00751   ps_sin->incr_indent (0);
00752   ps_sin->nl ();
00753 
00754   *ps_sin << "if (p.ptr_ == 0)";
00755 
00756   ps_sin->incr_indent (0);
00757   ps_sin->nl ();
00758 
00759   *ps_sin << "{";
00760 
00761   ps_sin->incr_indent (0);
00762   ps_sin->nl ();
00763 
00764   *ps_sin << "delete this->ptr_;"; ps_sin->nl ();
00765   *ps_sin << "this->ptr_ = 0;";
00766 
00767   ps_sin->decr_indent (0);
00768   ps_sin->nl ();
00769   *ps_sin << "}";
00770 
00771   ps_sin->decr_indent (0); ps_sin->nl ();
00772 
00773   *ps_sin << "else";
00774 
00775   ps_sin->incr_indent (0);
00776   ps_sin->nl ();
00777   *ps_sin << "{";
00778 
00779   ps_sin->incr_indent (0);
00780   ps_sin->nl ();
00781 
00782   *ps_sin << this->struct_name_ << " *deep_copy =";
00783   ps_sin->incr_indent (0); ps_sin->nl ();
00784   *ps_sin << "new " << this->struct_name_ << " (*p.ptr_);";
00785 
00786   ps_sin->decr_indent (0);ps_sin->nl ();
00787 
00788   ps_sin->nl ();
00789 
00790   *ps_sin << "if (deep_copy != 0)";
00791 
00792   ps_sin->incr_indent (0); ps_sin->nl ();
00793   *ps_sin << "{";
00794 
00795   ps_sin->incr_indent (0); ps_sin->nl ();
00796   *ps_sin << this->struct_name_ << " *tmp = deep_copy;"; ps_sin->nl ();
00797   *ps_sin << "deep_copy = this->ptr_;"; ps_sin->nl ();
00798   *ps_sin << "this->ptr_ = tmp;"; ps_sin->nl ();
00799   *ps_sin << "delete deep_copy;";
00800 
00801   ps_sin->decr_indent (0);ps_sin->nl ();
00802   *ps_sin << "}";
00803 
00804   ps_sin->decr_indent (0);
00805   ps_sin->decr_indent (0);ps_sin->nl ();
00806   *ps_sin << "}";
00807 
00808   ps_sin->decr_indent (0); ps_sin->nl ();
00809   *ps_sin << "}";
00810 
00811   ps_sin->decr_indent (0);
00812   ps_sin->nl ();
00813   ps_sin->nl ();
00814 
00815   *ps_sin << "return *this;";
00816 
00817   ps_sin->decr_indent (0);
00818   ps_sin->decr_indent (0);
00819   ps_sin->nl ();
00820   *ps_sin << "}";
00821 
00822   ps_sin->nl ();
00823   ps_sin->nl ();
00824 
00825   *ps_sin << "ACE_INLINE const ::" << this->struct_name_ << " *"; ps_sin->nl ();
00826   *ps_sin << this->struct_name_ << "_var::operator-> (void) const"; ps_sin->nl ();
00827   *ps_sin << "{";
00828 
00829   ps_sin->incr_indent (0); ps_sin->nl ();
00830   *ps_sin << "return this->ptr_;";
00831 
00832   ps_sin->decr_indent (0); ps_sin->nl ();
00833   *ps_sin << "}";
00834 
00835   ps_sin->nl ();
00836   ps_sin->nl ();
00837 
00838   *ps_sin << "ACE_INLINE ::" << this->struct_name_ << " *"; ps_sin->nl ();
00839   *ps_sin << this->struct_name_ << "_var::operator-> (void)"; ps_sin->nl ();
00840   *ps_sin << "{";
00841 
00842   ps_sin->incr_indent (0); ps_sin->nl ();
00843   *ps_sin << "return this->ptr_;";
00844 
00845   ps_sin->decr_indent (0); ps_sin->nl ();
00846   *ps_sin << "}";
00847 
00848   ps_sin->nl ();
00849   ps_sin->nl ();
00850 
00851   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00852   *ps_sin << this->struct_name_ << "_var::operator const ::" << this->struct_name_ << " &() const // cast"; ps_sin->nl ();
00853   *ps_sin << "{";
00854 
00855   ps_sin->incr_indent (0); ps_sin->nl ();
00856   *ps_sin << "return *this->ptr_;";
00857 
00858   ps_sin->decr_indent (0); ps_sin->nl ();
00859   *ps_sin << "}";
00860 
00861   ps_sin->nl ();
00862   ps_sin->nl ();
00863 
00864   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00865   *ps_sin << this->struct_name_ << "_var::operator ::" << this->struct_name_ << " &() // cast "; ps_sin->nl ();
00866   *ps_sin << "{";
00867 
00868   ps_sin->incr_indent (0); ps_sin->nl ();
00869   *ps_sin << "return *this->ptr_;";
00870 
00871   ps_sin->decr_indent (0); ps_sin->nl ();
00872   *ps_sin << "}";
00873 
00874   ps_sin->nl ();
00875   ps_sin->nl ();
00876 
00877   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00878   *ps_sin << this->struct_name_ << "_var::operator ::" << this->struct_name_ << " &() const // cast "; ps_sin->nl ();
00879   *ps_sin << "{";
00880 
00881   ps_sin->incr_indent (0); ps_sin->nl ();
00882   *ps_sin << "return *this->ptr_;";
00883 
00884   ps_sin->decr_indent (0); ps_sin->nl ();
00885   *ps_sin << "}";
00886 
00887   ps_sin->nl ();
00888   ps_sin->nl ();
00889 
00890   *ps_sin << "// variable-size types only"; ps_sin->nl ();
00891   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00892   *ps_sin << this->struct_name_ << "_var::operator ::" << this->struct_name_ << " *&() // cast "; ps_sin->nl ();
00893   *ps_sin << "{";
00894   ps_sin->incr_indent (0); ps_sin->nl ();
00895 
00896   *ps_sin << "return this->ptr_;";
00897 
00898   ps_sin->decr_indent (0); ps_sin->nl ();
00899   *ps_sin << "}";
00900 
00901   ps_sin->nl ();
00902   ps_sin->nl ();
00903 
00904   *ps_sin << "ACE_INLINE const ::" << this->struct_name_ << " &"; ps_sin->nl ();
00905   *ps_sin << this->struct_name_ << "_var::in (void) const"; ps_sin->nl ();
00906   *ps_sin << "{";
00907 
00908   ps_sin->incr_indent (0); ps_sin->nl ();
00909   *ps_sin << "return *this->ptr_;";
00910 
00911   ps_sin->decr_indent (0); ps_sin->nl ();
00912   *ps_sin << "}";
00913 
00914   ps_sin->nl ();
00915   ps_sin->nl ();
00916 
00917   *ps_sin << "ACE_INLINE ::" << this->struct_name_ << " &"; ps_sin->nl ();
00918   *ps_sin << this->struct_name_ << "_var::inout (void)"; ps_sin->nl ();
00919   *ps_sin << "{";
00920 
00921   ps_sin->incr_indent (0); ps_sin->nl ();
00922   *ps_sin << "return *this->ptr_;";
00923 
00924   ps_sin->decr_indent (0); ps_sin->nl ();
00925   *ps_sin << "}";
00926 
00927   ps_sin->nl ();
00928   ps_sin->nl ();
00929 
00930   *ps_sin << "// mapping for variable size "; ps_sin->nl ();
00931   *ps_sin << "ACE_INLINE ::" << this->struct_name_ << " *&"; ps_sin->nl ();
00932   *ps_sin << this->struct_name_ << "_var::out (void)"; ps_sin->nl ();
00933   *ps_sin << "{";
00934 
00935   ps_sin->incr_indent (0); ps_sin->nl ();
00936   *ps_sin << "delete this->ptr_;"; ps_sin->nl ();
00937   *ps_sin << "this->ptr_ = 0;"; ps_sin->nl ();
00938   *ps_sin << "return this->ptr_;";
00939 
00940   ps_sin->decr_indent (0); ps_sin->nl ();
00941   *ps_sin << "}";
00942 
00943   ps_sin->nl ();
00944   ps_sin->nl ();
00945 
00946   *ps_sin << "ACE_INLINE ::" << this->struct_name_ << " *"; ps_sin->nl ();
00947   *ps_sin << this->struct_name_ << "_var::_retn (void)"; ps_sin->nl ();
00948   *ps_sin << "{";
00949 
00950   ps_sin->incr_indent (0); ps_sin->nl ();
00951 
00952   *ps_sin << "::" << this->struct_name_ << " *tmp = this->ptr_;"; ps_sin->nl ();
00953   *ps_sin << "this->ptr_ = 0;"; ps_sin->nl ();
00954   *ps_sin << "return tmp;";
00955 
00956   ps_sin->decr_indent (0); ps_sin->nl ();
00957   *ps_sin << "}";
00958 
00959   ps_sin->nl ();
00960   ps_sin->nl ();
00961 
00962   *ps_sin << "ACE_INLINE ::" << this->struct_name_ << " *"; ps_sin->nl ();
00963   *ps_sin << this->struct_name_ << "_var::ptr (void) const"; ps_sin->nl ();
00964 
00965   *ps_sin << "{";
00966   ps_sin->incr_indent (0); ps_sin->nl ();
00967 
00968   *ps_sin << "return this->ptr_;";
00969 
00970   ps_sin->decr_indent (0); ps_sin->nl ();
00971   *ps_sin << "}";
00972 
00973   ps_sin->nl ();
00974   ps_sin->nl ();
00975 
00976   *ps_sin << "// ************************************************************";
00977   ps_sin->nl ();
00978   *ps_sin << "// Inline operations for class " << this->struct_name_ << "_out";
00979   ps_sin->nl ();
00980   *ps_sin << "// ************************************************************"; ps_sin->nl ();
00981 
00982   ps_sin->nl ();
00983 
00984   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
00985   *ps_sin << this->struct_name_ << "_out::" << this->struct_name_ << "_out (::" << this->struct_name_ << " *&p)";
00986 
00987   ps_sin->incr_indent (0); ps_sin->nl ();
00988   *ps_sin << ": ptr_ (p)";
00989   ps_sin->decr_indent (0); ps_sin->nl ();
00990 
00991   *ps_sin << "{";
00992   ps_sin->incr_indent (0); ps_sin->nl ();
00993 
00994   *ps_sin << "this->ptr_ = 0;";
00995 
00996   ps_sin->decr_indent (0); ps_sin->nl ();
00997   *ps_sin << "}";
00998 
00999   ps_sin->nl ();
01000   ps_sin->nl ();
01001 
01002   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
01003   *ps_sin << this->struct_name_ << "_out::" << this->struct_name_ << "_out (" << this->struct_name_ << "_var &p) // constructor from _var";
01004 
01005   ps_sin->incr_indent (0); ps_sin->nl ();
01006   *ps_sin << ": ptr_ (p.out ())";
01007   ps_sin->decr_indent (0); ps_sin->nl ();
01008 
01009   *ps_sin << "{";
01010   ps_sin->incr_indent (0);ps_sin->nl ();
01011 
01012   *ps_sin << "delete this->ptr_;"; ps_sin->nl ();
01013   *ps_sin << "this->ptr_ = 0;";
01014 
01015   ps_sin->decr_indent (0); ps_sin->nl ();
01016   *ps_sin << "}";
01017 
01018   ps_sin->nl ();
01019   ps_sin->nl ();
01020 
01021   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
01022   *ps_sin << this->struct_name_ << "_out::" << this->struct_name_ << "_out (const ::" << this->struct_name_ << "_out &p) // copy constructor";
01023 
01024   ps_sin->incr_indent (0); ps_sin->nl ();
01025   *ps_sin << ": ptr_ (ACE_const_cast (" << this->struct_name_ << "_out&, p).ptr_)";
01026   ps_sin->decr_indent (0); ps_sin->nl ();
01027   *ps_sin << "{}";
01028 
01029   ps_sin->nl ();
01030   ps_sin->nl ();
01031 
01032   *ps_sin << "ACE_INLINE " << this->struct_name_ << "_out &"; ps_sin->nl ();
01033   *ps_sin << this->struct_name_ << "_out::operator= (const ::" << this->struct_name_ << "_out &p)"; ps_sin->nl ();
01034 
01035   *ps_sin << "{";
01036   ps_sin->incr_indent (0);ps_sin->nl ();
01037 
01038   *ps_sin << "this->ptr_ = ACE_const_cast (" << this->struct_name_ << "_out&, p).ptr_;"; ps_sin->nl ();
01039   *ps_sin << "return *this;";
01040 
01041   ps_sin->decr_indent (0); ps_sin->nl ();
01042   *ps_sin << "}";
01043 
01044   ps_sin->nl ();
01045   ps_sin->nl ();
01046 
01047   *ps_sin << "ACE_INLINE " << this->struct_name_ << "_out &"; ps_sin->nl ();
01048   *ps_sin << this->struct_name_ << "_out::operator= (" << this->struct_name_ << " *p)"; ps_sin->nl ();
01049   *ps_sin << "{";
01050 
01051   ps_sin->incr_indent (0); ps_sin->nl ();
01052   *ps_sin << "this->ptr_ = p;"; ps_sin->nl ();
01053   *ps_sin << "return *this;";
01054 
01055   ps_sin->decr_indent (0); ps_sin->nl ();
01056   *ps_sin << "}";
01057 
01058   ps_sin->nl ();
01059   ps_sin->nl ();
01060 
01061   *ps_sin << "ACE_INLINE"; ps_sin->nl ();
01062   *ps_sin << this->struct_name_ << "_out::operator ::" << this->struct_name_ << " *&() // cast"; ps_sin->nl ();
01063   *ps_sin << "{";
01064   ps_sin->incr_indent (0); ps_sin->nl ();
01065   *ps_sin << "return this->ptr_;";
01066   ps_sin->decr_indent (0); ps_sin->nl ();
01067   *ps_sin << "}";
01068 
01069   ps_sin->nl ();
01070   ps_sin->nl ();
01071 
01072   *ps_sin << "ACE_INLINE ::" << this->struct_name_ << " *&"; ps_sin->nl ();
01073   *ps_sin << this->struct_name_ << "_out::ptr (void) // ptr"; ps_sin->nl ();
01074   *ps_sin << "{";
01075   ps_sin->incr_indent (0); ps_sin->nl ();
01076   *ps_sin << "return this->ptr_;";
01077   ps_sin->decr_indent (0); ps_sin->nl ();
01078   *ps_sin << "}";
01079 
01080   ps_sin->nl ();
01081   ps_sin->nl ();
01082 
01083   *ps_sin << "ACE_INLINE ::" << this->struct_name_ << " *"; ps_sin->nl ();
01084   *ps_sin << this->struct_name_ << "_out::operator-> (void)"; ps_sin->nl ();
01085   *ps_sin << "{";
01086   ps_sin->incr_indent (0); ps_sin->nl ();
01087   *ps_sin << "return this->ptr_;";
01088   ps_sin->decr_indent (0); ps_sin->nl ();
01089   *ps_sin << "}";
01090 
01091   ps_sin->nl ();
01092   ps_sin->nl ();
01093 
01094   *ps_sin << "ACE_INLINE CORBA::Boolean operator<< "
01095           << "(TAO_OutputCDR &strm, const " << this->struct_name_ << " &_tao_aggregate)";
01096   ps_sin->nl ();
01097   *ps_sin << "{";
01098 
01099   ps_sin->incr_indent (0); ps_sin->nl ();
01100 
01101   *ps_sin << "if (";
01102   ps_sin->incr_indent (0); ps_sin->nl ();
01103 
01104   *ps_sin << "(strm << _tao_aggregate.name.in ()) &&"; ps_sin->nl ();
01105   *ps_sin << "(strm << _tao_aggregate.obj_ref.in ())";
01106 
01107   ps_sin->decr_indent (0); ps_sin->nl ();
01108   *ps_sin << ")";
01109 
01110   ps_sin->incr_indent (0); ps_sin->nl ();
01111   *ps_sin << "return 1;";
01112 
01113   ps_sin->decr_indent (0); ps_sin->nl ();
01114   *ps_sin << "else";
01115 
01116   ps_sin->incr_indent (0); ps_sin->nl ();
01117   *ps_sin << "return 0;";
01118 
01119 
01120   ps_sin->decr_indent (0);
01121   ps_sin->decr_indent (0);ps_sin->nl ();
01122   *ps_sin << "}";
01123 
01124   ps_sin->nl ();
01125   ps_sin->nl ();
01126 
01127   *ps_sin << "ACE_INLINE CORBA::Boolean operator>> "
01128           << "(TAO_InputCDR &strm, " << this->struct_name_ << " &_tao_aggregate)";
01129   ps_sin->nl ();
01130 
01131   *ps_sin << "{";
01132   ps_sin->incr_indent (0); ps_sin->nl ();
01133 
01134   *ps_sin << "if (";
01135   ps_sin->incr_indent (0);ps_sin->nl ();
01136 
01137   *ps_sin << "(strm >> _tao_aggregate.name.out ()) &&"; ps_sin->nl ();
01138   *ps_sin << "(strm >> _tao_aggregate.obj_ref.out ())";
01139 
01140   ps_sin->decr_indent (0); ps_sin->nl ();
01141   *ps_sin << ")";
01142 
01143   ps_sin->incr_indent (0); ps_sin->nl ();
01144   *ps_sin << "return 1;";
01145 
01146   ps_sin->decr_indent (0); ps_sin->nl ();
01147   *ps_sin << "else";
01148 
01149   ps_sin->incr_indent (0); ps_sin->nl ();
01150   *ps_sin << "return 0;";
01151 
01152   ps_sin->decr_indent (0);
01153   ps_sin->decr_indent (0);
01154   ps_sin->nl ();
01155 
01156   *ps_sin << "}";
01157 
01158   ps_sin->nl ();
01159 
01160 }

Generated on Thu Nov 9 14:07:05 2006 for TAO_PSS by doxygen 1.3.6