00001 // -*- C++ -*- 00002 // $Id: PSDL_Enum_Type_Visitor.cpp 45726 2002-07-25 15:25:51Z pgontla $ 00003 00004 #include "PSDL_Enum_Type_Visitor.h" 00005 #include "PSDL_Stream.h" 00006 00007 ACE_RCSID (PSS, PSDL_Enum_Type_Visitor, "$Id: PSDL_Enum_Type_Visitor.cpp 45726 2002-07-25 15:25:51Z pgontla $") 00008 00009 TAO_PSDL_Enum_Type_Visitor::TAO_PSDL_Enum_Type_Visitor (void) 00010 { 00011 } 00012 00013 TAO_PSDL_Enum_Type_Visitor::~TAO_PSDL_Enum_Type_Visitor (void) 00014 { 00015 } 00016 00017 int 00018 TAO_PSDL_Enum_Type_Visitor::visit_identifier (TAO_PSDL_Identifier *identifier) 00019 { 00020 // Save the identifiers for future use. 00021 this->identifiers_.size (this->count_ + 1); 00022 00023 this->identifiers_ [this->count_] = identifier->value (); 00024 00025 ++this->count_; 00026 return 0; 00027 } 00028 00029 int 00030 TAO_PSDL_Enum_Type_Visitor::visit_enumerator (TAO_PSDL_Enumerator *enumerator) 00031 { 00032 // Gets the enum name and saves it in the global array of 00033 // identifiers. 00034 if (enumerator->identifier ()->accept (this) == -1) 00035 return -1; 00036 00037 // Get a pointer to PSDL_Stream of the stub header. 00038 TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh (); 00039 00040 *ps_sh<< " " << this->identifiers_ [this->count_ - 1] 00041 << ";\n"; 00042 00043 // Get the enum members and save them. 00044 if (enumerator->enumerator () != 0) 00045 if (enumerator->enumerator ()->accept (this) == -1) 00046 return -1; 00047 00048 return 0; 00049 } 00050 00051 int 00052 TAO_PSDL_Enum_Type_Visitor::visit_predefined_type (TAO_PSDL_Predefined_Type *predefined_type) 00053 { 00054 if (predefined_type->type_of_variable_one () != 0) 00055 { 00056 if (predefined_type->type_of_variable_one ()->accept (this) == -1) 00057 return -1; 00058 } 00059 00060 ACE_CString enum_type_name = this->identifiers_ [this->count_ - 1]; 00061 00062 // Get a pointer to PSDL_Stream of the stub header. 00063 TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh (); 00064 00065 *ps_sh<< "enum " << enum_type_name.c_str () << "\n"; 00066 *ps_sh<< "{\n"; 00067 00068 if (predefined_type->type_of_variable_two () != 0) 00069 { 00070 if (predefined_type->type_of_variable_two ()->accept (this) == -1) 00071 return -1; 00072 } 00073 00074 *ps_sh<< "};\n"; 00075 00076 // Print the code that should go into the generated header file. 00077 // @@ Update this method to get the code that should go to 00078 // implementation method (as applies). 00079 this->print_class_for_enum_type (enum_type_name); 00080 00081 return 0; 00082 } 00083 00084 void 00085 TAO_PSDL_Enum_Type_Visitor::print_class_for_enum_type (ACE_CString enum_type_name) 00086 { 00087 // Get a pointer to PSDL_Stream of the stub header. 00088 TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh (); 00089 00090 ps_sh->nl (); 00091 00092 *ps_sh << "typedef " << enum_type_name << " &" 00093 << enum_type_name << "_out;\n"; 00094 00095 *ps_sh<< "TAO_NAMESPACE_STORAGE_CLASS ::CORBA::TypeCode_ptr " 00096 << "_tc_" << enum_type_name << ";\n"; 00097 00098 ps_sh->nl (); 00099 00100 }