GeneratorBase::GenerateGettersAndSetters Struct Reference

List of all members.

Public Member Functions

 GenerateGettersAndSetters (AST_Union *u, AST_Type *d)
void operator() (AST_UnionBranch *branch)

Public Attributes

AST_Union * the_union
AST_Type * discriminator

Detailed Description

Definition at line 208 of file langmap_generator.cpp.


Constructor & Destructor Documentation

GeneratorBase::GenerateGettersAndSetters::GenerateGettersAndSetters ( AST_Union *  u,
AST_Type *  d 
) [inline]

Definition at line 213 of file langmap_generator.cpp.

00214       : the_union(u)
00215       , discriminator(d)
00216     { }


Member Function Documentation

void GeneratorBase::GenerateGettersAndSetters::operator() ( AST_UnionBranch *  branch  )  [inline]

Definition at line 218 of file langmap_generator.cpp.

References be_global, AstTypeClassification::CL_ARRAY, AstTypeClassification::CL_ENUM, AstTypeClassification::CL_FIXED, AstTypeClassification::CL_SEQUENCE, AstTypeClassification::CL_STRUCTURE, AstTypeClassification::CL_UNION, AstTypeClassification::CL_WIDE, AstTypeClassification::classify(), discriminator, GeneratorBase::generateDefaultValue(), getEnumLabel(), AstTypeClassification::resolveActualType(), and the_union.

00219     {
00220       const char* field_name = branch->local_name()->get_string();
00221       std::stringstream first_label;
00222       {
00223         AST_UnionLabel* label = branch->label(0);
00224         if (label->label_kind() == AST_UnionLabel::UL_default) {
00225           first_label << generateDefaultValue(the_union, discriminator);
00226         } else if (discriminator->node_type() == AST_Decl::NT_enum) {
00227           first_label << getEnumLabel(label->label_val(), discriminator);
00228         } else {
00229           first_label << *label->label_val()->ev();
00230         }
00231       }
00232 
00233       AST_Type* field_type = branch->field_type();
00234       const std::string field_type_string = map_type(field_type);
00235       AST_Type* actual_field_type = resolveActualType(field_type);
00236       const Classification cls = classify(actual_field_type);
00237       if (cls & (CL_PRIMITIVE | CL_ENUM)) {
00238         be_global->lang_header_ <<
00239           "  void " << field_name << " (" << field_type_string << " x) {\n"
00240           "    _reset();\n"
00241           "    this->_u." << field_name << " = x;\n"
00242           "    _discriminator = " << first_label.str() << ";\n"
00243           "  }\n"
00244           "  " << field_type_string << ' ' << field_name << " () const {\n"
00245           "    return this->_u." << field_name << ";\n"
00246           "  }\n";
00247       } else if (cls & CL_STRING) {
00248         const std::string& primtype = (cls & CL_WIDE) ? primtype_[AST_PredefinedType::PT_wchar] : primtype_[AST_PredefinedType::PT_char];
00249         const std::string& helper = (cls & CL_WIDE) ? helpers_[HLP_WSTR_VAR] : helpers_[HLP_STR_VAR];
00250         be_global->lang_header_ <<
00251           "  void " << field_name << " (" << primtype << "* x) {\n"
00252           "    _reset();\n" <<
00253           "    this->_u." << field_name << " = x;\n"
00254           "    _discriminator = " << first_label.str() << ";\n"
00255           "  }\n"
00256           "  void " << field_name << " (const " << primtype << "* x) {\n"
00257           "    _reset();\n"
00258           "    this->_u." << field_name << " = ::CORBA::string_dup(x);\n"
00259           "    _discriminator = " << first_label.str() << ";\n"
00260           "  }\n"
00261           "  void " << field_name << " (const " << helper << "& x) {\n"
00262           "    _reset();\n" <<
00263           "    this->_u." << field_name << " = ::CORBA::string_dup(x.in());\n"
00264           "    _discriminator = " << first_label.str() << ";\n"
00265           "  }\n"
00266           "  const " << primtype << "* " << field_name << " () const {\n"
00267           "    return this->_u." << field_name << ";\n"
00268           "  }\n";
00269       } else if (cls & CL_ARRAY) {
00270         be_global->lang_header_ <<
00271           "  void " << field_name << " (" << field_type_string << " x) {\n"
00272           "    _reset();\n" <<
00273           "    this->_u." << field_name << " = " << field_type_string << "_dup(x);\n"
00274           "    _discriminator = " << first_label.str() << ";\n"
00275           "  }\n"
00276           "  " << field_type_string << "_slice* " << field_name << " () const {\n"
00277           "    return this->_u." << field_name << ";\n"
00278           "  }\n";
00279       } else if (cls & (CL_STRUCTURE | CL_UNION | CL_SEQUENCE | CL_FIXED)) {
00280         be_global->lang_header_ <<
00281           "  void " << field_name << " (const " << field_type_string << "& x) {\n"
00282           "    _reset();\n"
00283           "    this->_u." << field_name << " = new " << field_type_string << "(x);\n"
00284           "    _discriminator = " << first_label.str() << ";\n"
00285           "  }\n"
00286           "  const " << field_type_string << "& " << field_name << " () const {\n"
00287           "    return *this->_u." << field_name << ";\n"
00288           "  }\n"
00289           "  " << field_type_string << "& " << field_name << " () {\n"
00290           "    return *this->_u." << field_name << ";\n"
00291           "  }\n";
00292       } else {
00293         std::cerr << "Unsupported type for union element\n";
00294       }
00295     }

Here is the call graph for this function:


Member Data Documentation

Definition at line 211 of file langmap_generator.cpp.

Referenced by operator()().

Definition at line 210 of file langmap_generator.cpp.

Referenced by operator()().


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1