MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / generate_ts

Method generate_ts

dds/idl/ts_generator.cpp:96–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96bool ts_generator::generate_ts(AST_Type* node, UTL_ScopedName* name)
97{
98 if (idl_template_.empty()) {
99 // error reported in read_template
100 return false;
101 }
102 if (!node || !name) {
103 return false;
104 }
105
106 AST_Structure* struct_node = 0;
107 AST_Union* union_node = 0;
108 AST_Type::SIZE_TYPE size_type;
109 if (node->node_type() == AST_Decl::NT_struct) {
110 struct_node = dynamic_cast<AST_Structure*>(node);
111 size_type = struct_node->size_type();
112 } else if (node->node_type() == AST_Decl::NT_union) {
113 union_node = dynamic_cast<AST_Union*>(node);
114 size_type = union_node->size_type();
115 } else {
116 idl_global->err()->misc_error(
117 "Could not cast AST Nodes to valid types", node);
118 return false;
119 }
120
121 size_t key_count = 0;
122 IDL_GlobalData::DCPS_Data_Type_Info* info = 0;
123 TopicKeys keys;
124 if (struct_node) {
125 info = idl_global->is_dcps_type(name);
126 if (be_global->is_topic_type(struct_node)) {
127 keys = TopicKeys(struct_node);
128 key_count = keys.count();
129 } else if (info) {
130 key_count = info->key_list_.size();
131 } else {
132 return true;
133 }
134 } else if (be_global->is_topic_type(union_node)) {
135 key_count = be_global->union_discriminator_is_key(union_node) ? 1 : 0;
136 } else {
137 return true;
138 }
139
140 const std::string full_cxx_name = scoped(name);
141 const std::string short_cxx_name = name->last_component()->get_string();
142 const std::string ts_base = "OpenDDS::DCPS::TypeSupportImpl_T<" + short_cxx_name + ">";
143 const std::string full_name_from_tsch = scoped(name, EscapeContext_FromGenIdl);
144 const std::string short_name_from_tsch = to_string(
145 name->last_component(), EscapeContext_FromGenIdl);
146 const std::string full_ts_name = full_name_from_tsch + "TypeSupport";
147 const std::string short_ts_name = short_name_from_tsch + "TypeSupport";
148 const std::string full_tsi_name = full_ts_name + "Impl";
149 const std::string short_tsi_name = short_ts_name + "Impl";
150 const std::string unescaped_name =
151 dds_generator::scoped_helper(name, "::", EscapeContext_StripEscapes);
152 const std::string name_underscores = dds_generator::scoped_helper(name, "_");
153 static const std::string ns("OpenDDS::DCPS::");

Callers

nothing calls this directly

Calls 15

TopicKeysClass · 0.85
scopedFunction · 0.85
add_includesFunction · 0.85
replaceAllFunction · 0.85
gen_isDcpsKeyFunction · 0.85
generateFunction · 0.85
is_topic_typeMethod · 0.80
versioning_nameMethod · 0.80
export_macroMethod · 0.80
sequence_suffixMethod · 0.80
java_argMethod · 0.80

Tested by

no test coverage detected