| 993 | } |
| 994 | |
| 995 | bool gen_struct(AST_Structure*, UTL_ScopedName* name, |
| 996 | const std::vector<AST_Field*>& fields, |
| 997 | AST_Type::SIZE_TYPE size, |
| 998 | const char*) |
| 999 | { |
| 1000 | const ScopedNamespaceGuard namespaces(name, be_global->lang_header_); |
| 1001 | const char* const nm = name->last_component()->get_string(); |
| 1002 | struct_decls(name, size); |
| 1003 | be_global->lang_header_ << |
| 1004 | "\n" |
| 1005 | "struct " << exporter() << nm << "\n" |
| 1006 | "{\n" |
| 1007 | " typedef " << nm << "_var _var_type;\n" |
| 1008 | " typedef " << nm << "_out _out_type;\n\n"; |
| 1009 | |
| 1010 | for (size_t i = 0; i < fields.size(); ++i) { |
| 1011 | AST_Type* field_type = fields[i]->field_type(); |
| 1012 | const std::string field_name = fields[i]->local_name()->get_string(); |
| 1013 | std::string type_name = map_type(field_type); |
| 1014 | |
| 1015 | const Classification cls = classify(field_type); |
| 1016 | if (cls & CL_STRING) { |
| 1017 | type_name = helpers_[(cls & CL_WIDE) ? HLP_WSTR_MGR : HLP_STR_MGR]; |
| 1018 | } |
| 1019 | be_global->lang_header_ << |
| 1020 | " " << type_name << ' ' << field_name << ";\n"; |
| 1021 | } |
| 1022 | |
| 1023 | be_global->lang_header_ << "\n" |
| 1024 | " bool operator==(const " << nm << "& rhs) const;\n" |
| 1025 | " bool operator!=(const " << nm << "& rhs) const { return !(*this == rhs); }\n" |
| 1026 | " OPENDDS_POOL_ALLOCATION_HOOKS\n" |
| 1027 | "};\n\n"; |
| 1028 | |
| 1029 | be_global->add_include("dds/DCPS/PoolAllocationBase.h", BE_GlobalData::STREAM_LANG_H); |
| 1030 | be_global->add_include("<ace/CDR_Stream.h>", BE_GlobalData::STREAM_LANG_H); |
| 1031 | |
| 1032 | if (size == AST_Type::VARIABLE) { |
| 1033 | be_global->lang_header_ << |
| 1034 | exporter() << "void swap(" << nm << "& lhs, " << nm << "& rhs);\n\n"; |
| 1035 | } |
| 1036 | |
| 1037 | be_global->lang_header_ << |
| 1038 | exporter() << "ACE_CDR::Boolean operator<<(ACE_OutputCDR& os, const " << nm << "& x);\n\n" << |
| 1039 | exporter() << "ACE_CDR::Boolean operator>>(ACE_InputCDR& os, " << nm << "& x);\n\n"; |
| 1040 | |
| 1041 | const ScopedNamespaceGuard guard(name, be_global->impl_); |
| 1042 | be_global->impl_ << |
| 1043 | "bool " << nm << "::operator==(const " << nm << "& rhs) const\n" |
| 1044 | "{\n"; |
| 1045 | for (size_t i = 0; i < fields.size(); ++i) { |
| 1046 | const std::string field_name = fields[i]->local_name()->get_string(); |
| 1047 | AST_Type* field_type = resolveActualType(fields[i]->field_type()); |
| 1048 | const Classification cls = classify(field_type); |
| 1049 | if (cls & CL_ARRAY) { |
| 1050 | std::string indent(" "); |
| 1051 | NestedForLoops nfl("int", "i", |
| 1052 | dynamic_cast<AST_Array*>(field_type), indent, true); |
nothing calls this directly
no test coverage detected