OpenDDS  Snapshot(2023/04/28-20:55)
typeobject_generator.cpp
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #include "typeobject_generator.h"
7 
8 #include "topic_keys.h"
9 #include "dds_visitor.h"
10 #include "be_extern.h"
11 #include "be_util.h"
12 
13 #include <dds/DCPS/Hash.h>
15 #include <dds/DCPS/Definitions.h>
16 
17 #include <utl_identifier.h>
18 
19 using std::string;
20 using namespace AstTypeClassification;
21 
22 namespace {
23 
25 extensibility_to_type_flag(ExtensibilityKind exten)
26 {
27  switch (exten) {
34  }
35 
36  return 0;
37 }
38 
40 try_construct_to_member_flag(TryConstructFailAction trycon)
41 {
42  switch (trycon) {
49  }
50 
51  return 0;
52 }
53 
55 to_long(const AST_Expression::AST_ExprValue& ev)
56 {
57  switch (ev.et) {
58  case AST_Expression::EV_octet:
59  return ev.u.oval;
60 #if OPENDDS_HAS_EXPLICIT_INTS
61  case AST_Expression::EV_uint8:
62  return ev.u.uint8val;
63  case AST_Expression::EV_int8:
64  return ev.u.int8val;
65 #endif
66  case AST_Expression::EV_short:
67  return ev.u.sval;
68  case AST_Expression::EV_ushort:
69  return ev.u.usval;
70  case AST_Expression::EV_long:
71  return ev.u.lval;
72  case AST_Expression::EV_ulong:
73  return ev.u.ulval;
74  case AST_Expression::EV_wchar:
75  return ev.u.wcval;
76  case AST_Expression::EV_char:
77  return ev.u.cval;
78  case AST_Expression::EV_bool:
79  return ev.u.bval;
80  case AST_Expression::EV_enum:
81  return ev.u.eval;
82  default:
83  // Spec issue DDSXTY14-36 (64-bit integers as case labels in TypeObject)
84  be_util::misc_error_and_abort("Illegal conversion to long");
85  return 0;
86  }
87 }
88 
89 struct Printer {
90  virtual ~Printer() {}
91  virtual std::ostream& print_on(std::ostream& out) const = 0;
92 };
93 
94 std::ostream&
95 operator<<(std::ostream& out, const Printer& printer)
96 {
97  return printer.print_on(out);
98 }
99 
100 template <typename T>
101 struct ValuePrinter : Printer {
102  explicit ValuePrinter(const T& a_value) : value(a_value) {}
103 
104  const T value;
105 };
106 
107 template <typename T>
108 struct UintPrinter : ValuePrinter<T> {
109  explicit UintPrinter(const T& a_value) : ValuePrinter<T>(a_value) {}
110 
111  std::ostream& print_on(std::ostream& out) const
112  {
113  return out << static_cast<unsigned int>(this->value);
114  }
115 };
116 
117 struct SBoundPrinter : UintPrinter<OpenDDS::XTypes::SBound> {
118  explicit SBoundPrinter(const OpenDDS::XTypes::SBound a_value)
119  : UintPrinter<OpenDDS::XTypes::SBound>(a_value) {}
120 };
121 
122 struct LBoundPrinter : UintPrinter<OpenDDS::XTypes::LBound> {
123  explicit LBoundPrinter(const OpenDDS::XTypes::LBound a_value)
124  : UintPrinter<OpenDDS::XTypes::LBound>(a_value) {}
125 };
126 
127 struct EquivalenceKindPrinter : ValuePrinter<OpenDDS::XTypes::EquivalenceKind> {
128  explicit EquivalenceKindPrinter(const OpenDDS::XTypes::EquivalenceKind a_value)
129  : ValuePrinter<OpenDDS::XTypes::EquivalenceKind>(a_value) {}
130 
131  std::ostream& print_on(std::ostream& out) const
132  {
133  switch (this->value) {
135  return out << "XTypes::EK_MINIMAL";
137  return out << "XTypes::EK_COMPLETE";
139  return out << "XTypes::EK_BOTH";
140  }
141  return out;
142  }
143 };
144 
145 struct BitmaskPrintHelper {
146  explicit BitmaskPrintHelper(std::ostream& os) : os_(os), first_(true) {}
147 
148  std::ostream& os_;
149  bool first_;
150 
151  BitmaskPrintHelper& operator<<(const char* str)
152  {
153  if (first_) {
154  first_ = false;
155  } else {
156  os_ << " | ";
157  }
158  os_ << str;
159  return *this;
160  }
161 
162  ~BitmaskPrintHelper()
163  {
164  if (first_) {
165  os_ << '0';
166  }
167  }
168 };
169 
170 struct MemberFlagPrinter : ValuePrinter<OpenDDS::XTypes::MemberFlag> {
171  explicit MemberFlagPrinter(const OpenDDS::XTypes::MemberFlag a_value)
172  : ValuePrinter<OpenDDS::XTypes::MemberFlag>(a_value) {}
173 
174  std::ostream& print_on(std::ostream& out) const
175  {
176  BitmaskPrintHelper bph(out);
178  bph << "XTypes::TRY_CONSTRUCT1";
179  }
181  bph << "XTypes::TRY_CONSTRUCT2";
182  }
183  if (this->value & OpenDDS::XTypes::IS_EXTERNAL) {
184  bph << "XTypes::IS_EXTERNAL";
185  }
186  if (this->value & OpenDDS::XTypes::IS_OPTIONAL) {
187  bph << "XTypes::IS_OPTIONAL";
188  }
190  bph << "XTypes::IS_MUST_UNDERSTAND";
191  }
192  if (this->value & OpenDDS::XTypes::IS_KEY) {
193  bph << "XTypes::IS_KEY";
194  }
195  if (this->value & OpenDDS::XTypes::IS_DEFAULT) {
196  bph << "XTypes::IS_DEFAULT";
197  }
198  return out;
199  }
200 };
201 
202 struct CollectionElementFlagPrinter : MemberFlagPrinter {
203  explicit CollectionElementFlagPrinter(const OpenDDS::XTypes::CollectionElementFlag a_value) : MemberFlagPrinter(a_value) {}
204 };
205 
206 struct StructMemberFlagPrinter : MemberFlagPrinter {
207  explicit StructMemberFlagPrinter(const OpenDDS::XTypes::StructMemberFlag a_value) : MemberFlagPrinter(a_value) {}
208 };
209 
210 struct UnionMemberFlagPrinter : MemberFlagPrinter {
211  explicit UnionMemberFlagPrinter(const OpenDDS::XTypes::UnionMemberFlag a_value) : MemberFlagPrinter(a_value) {}
212 };
213 
214 struct UnionDiscriminatorFlagPrinter : MemberFlagPrinter {
215  explicit UnionDiscriminatorFlagPrinter(const OpenDDS::XTypes::UnionDiscriminatorFlag a_value) : MemberFlagPrinter(a_value) {}
216 };
217 
218 struct EnumeratedLiteralFlagPrinter : MemberFlagPrinter {
219  explicit EnumeratedLiteralFlagPrinter(const OpenDDS::XTypes::EnumeratedLiteralFlag a_value) : MemberFlagPrinter(a_value) {}
220 };
221 
222 struct AliasMemberFlagPrinter : MemberFlagPrinter {
223  explicit AliasMemberFlagPrinter(const OpenDDS::XTypes::AliasMemberFlag a_value) : MemberFlagPrinter(a_value) {}
224 };
225 
226 struct TypeFlagPrinter : ValuePrinter<OpenDDS::XTypes::TypeFlag> {
227  explicit TypeFlagPrinter(const OpenDDS::XTypes::TypeFlag a_value)
228  : ValuePrinter<OpenDDS::XTypes::TypeFlag>(a_value) {}
229 
230  std::ostream& print_on(std::ostream& out) const
231  {
232  BitmaskPrintHelper bph(out);
233  if (this->value & OpenDDS::XTypes::IS_FINAL) {
234  bph << "XTypes::IS_FINAL";
235  }
237  bph << "XTypes::IS_APPENDABLE";
238  }
239  if (this->value & OpenDDS::XTypes::IS_MUTABLE) {
240  bph << "XTypes::IS_MUTABLE";
241  }
242  if (this->value & OpenDDS::XTypes::IS_NESTED) {
243  bph << "XTypes::IS_NESTED";
244  }
246  bph << "XTypes::IS_AUTOID_HASH";
247  }
248  return out;
249  }
250 };
251 
252 struct StructTypeFlagPrinter : TypeFlagPrinter {
253  explicit StructTypeFlagPrinter(const OpenDDS::XTypes::StructTypeFlag a_value) : TypeFlagPrinter(a_value) {}
254 };
255 
256 struct UnionTypeFlagPrinter : TypeFlagPrinter {
257  explicit UnionTypeFlagPrinter(const OpenDDS::XTypes::UnionTypeFlag a_value) : TypeFlagPrinter(a_value) {}
258 };
259 
260 struct CollectionTypeFlagPrinter : TypeFlagPrinter {
261  explicit CollectionTypeFlagPrinter(const OpenDDS::XTypes::CollectionTypeFlag a_value) : TypeFlagPrinter(a_value) {}
262 };
263 
264 struct AliasTypeFlagPrinter : TypeFlagPrinter {
265  explicit AliasTypeFlagPrinter(const OpenDDS::XTypes::AliasTypeFlag a_value) : TypeFlagPrinter(a_value) {}
266 };
267 
268 struct EnumTypeFlagPrinter : TypeFlagPrinter {
269  explicit EnumTypeFlagPrinter(const OpenDDS::XTypes::EnumTypeFlag a_value) : TypeFlagPrinter(a_value) {}
270 };
271 
272 struct MemberIdPrinter : UintPrinter<OpenDDS::XTypes::MemberId> {
273  explicit MemberIdPrinter(const OpenDDS::XTypes::MemberId a_value)
274  : UintPrinter<OpenDDS::XTypes::MemberId>(a_value) {}
275 };
276 
277 struct BitBoundPrinter : UintPrinter<OpenDDS::XTypes::BitBound> {
278  explicit BitBoundPrinter(const OpenDDS::XTypes::BitBound a_value)
279  : UintPrinter<OpenDDS::XTypes::BitBound>(a_value) {}
280 };
281 
282 std::ostream&
283 operator<<(std::ostream& out, const OpenDDS::XTypes::TypeIdentifier& ti);
284 
285 std::ostream&
286 operator<<(std::ostream& out, const OpenDDS::XTypes::SBoundSeq& seq)
287 {
288  out << "XTypes::SBoundSeq()";
289  for (OpenDDS::XTypes::SBoundSeq::const_iterator pos = seq.begin(), limit = seq.end(); pos != limit; ++pos) {
290  out << ".append(" << SBoundPrinter(*pos) << ")";
291  }
292  return out;
293 }
294 
295 std::ostream&
296 operator<<(std::ostream& out, const OpenDDS::XTypes::LBoundSeq& seq)
297 {
298  out << "XTypes::LBoundSeq()";
299  for (OpenDDS::XTypes::LBoundSeq::const_iterator pos = seq.begin(), limit = seq.end(); pos != limit; ++pos) {
300  out << ".append(" << LBoundPrinter(*pos) << ")";
301  }
302  return out;
303 }
304 
305 std::ostream&
306 operator<<(std::ostream& out, const OpenDDS::XTypes::StringSTypeDefn& string_sdefn)
307 {
308  return out << "XTypes::StringSTypeDefn(" << SBoundPrinter(string_sdefn.bound) << ")";
309 }
310 
311 std::ostream&
312 operator<<(std::ostream& out, const OpenDDS::XTypes::StringLTypeDefn& string_ldefn)
313 {
314  return out << "XTypes::StringLTypeDefn(" << LBoundPrinter(string_ldefn.bound) << ")";
315 }
316 
317 
318 std::ostream&
320 {
321  return out
322  << "XTypes::PlainCollectionHeader("
323  << EquivalenceKindPrinter(header.equiv_kind) << ", "
324  << CollectionElementFlagPrinter(header.element_flags)
325  << ")";
326 }
327 
328 std::ostream&
329 operator<<(std::ostream& out, const OpenDDS::XTypes::PlainSequenceSElemDefn& seq_sdefn)
330 {
331  return out
332  << "XTypes::PlainSequenceSElemDefn("
333  << seq_sdefn.header << ", "
334  << SBoundPrinter(seq_sdefn.bound) << ", "
335  << *seq_sdefn.element_identifier
336  << ")";
337 }
338 
339 std::ostream&
340 operator<<(std::ostream& out, const OpenDDS::XTypes::PlainSequenceLElemDefn& seq_ldefn)
341 {
342  return out
343  << "XTypes::PlainSequenceLElemDefn("
344  << seq_ldefn.header << ", "
345  << LBoundPrinter(seq_ldefn.bound) << ", "
346  << *seq_ldefn.element_identifier
347  << ")";
348 }
349 
350 std::ostream&
351 operator<<(std::ostream& out, const OpenDDS::XTypes::PlainArraySElemDefn& array_sdefn)
352 {
353  return out
354  << "XTypes::PlainArraySElemDefn("
355  << array_sdefn.header << ", "
356  << array_sdefn.array_bound_seq << ", "
357  << *array_sdefn.element_identifier
358  << ")";
359 }
360 
361 std::ostream&
362 operator<<(std::ostream& out, const OpenDDS::XTypes::PlainArrayLElemDefn& array_ldefn)
363 {
364  return out
365  << "XTypes::PlainArrayLElemDefn("
366  << array_ldefn.header << ", "
367  << array_ldefn.array_bound_seq << ", "
368  << *array_ldefn.element_identifier
369  << ")";
370 }
371 
372 std::ostream&
373 operator<<(std::ostream& out, const OpenDDS::XTypes::PlainMapSTypeDefn& map_sdefn)
374 {
375  return out
376  << "XTypes::PlainMapSTypeDefn("
377  << map_sdefn.header << ", "
378  << SBoundPrinter(map_sdefn.bound) << ", "
379  << *map_sdefn.element_identifier << ", "
380  << CollectionElementFlagPrinter(map_sdefn.key_flags) << ", "
381  << *map_sdefn.key_identifier
382  << ")";
383 }
384 
385 std::ostream&
386 operator<<(std::ostream& out, const OpenDDS::XTypes::PlainMapLTypeDefn& map_ldefn)
387 {
388  return out
389  << "XTypes::PlainMapLTypeDefn("
390  << map_ldefn.header << ", "
391  << LBoundPrinter(map_ldefn.bound) << ", "
392  << *map_ldefn.element_identifier << ", "
393  << CollectionElementFlagPrinter(map_ldefn.key_flags) << ", "
394  << *map_ldefn.key_identifier
395  << ")";
396 }
397 
398 std::ostream&
399 operator<<(std::ostream& out, const OpenDDS::XTypes::EquivalenceHash& equivalence_hash)
400 {
401  return out
402  << "XTypes::EquivalenceHashWrapper("
404  << ")";
405 }
406 
407 std::ostream&
408 operator<<(std::ostream& out, const OpenDDS::XTypes::TypeObjectHashId& id)
409 {
410  return out
411  << "XTypes::TypeObjectHashId("
412  << EquivalenceKindPrinter(id.kind) << ", "
413  << id.hash
414  << ")";
415 }
416 
417 std::ostream&
418 operator<<(std::ostream& out, const OpenDDS::XTypes::StronglyConnectedComponentId& scc)
419 {
420  return out
421  << "XTypes::StronglyConnectedComponentId("
422  << scc.sc_component_id << ", "
423  << scc.scc_length << ", "
424  << scc.scc_index
425  << ")";
426 }
427 
428 std::ostream&
429 operator<<(std::ostream& out, const OpenDDS::XTypes::TypeIdentifier& ti)
430 {
431  out << "XTypes::TypeIdentifier(";
432  switch (ti.kind()) {
434  out << "XTypes::TK_NONE";
435  break;
437  out << "XTypes::TK_BOOLEAN";
438  break;
440  out << "XTypes::TK_BYTE";
441  break;
443  out << "XTypes::TK_INT8";
444  break;
446  out << "XTypes::TK_INT16";
447  break;
449  out << "XTypes::TK_INT32";
450  break;
452  out << "XTypes::TK_INT64";
453  break;
455  out << "XTypes::TK_UINT8";
456  break;
458  out << "XTypes::TK_UINT16";
459  break;
461  out << "XTypes::TK_UINT32";
462  break;
464  out << "XTypes::TK_UINT64";
465  break;
467  out << "XTypes::TK_FLOAT32";
468  break;
470  out << "XTypes::TK_FLOAT64";
471  break;
473  out << "XTypes::TK_FLOAT128";
474  break;
476  out << "XTypes::TK_CHAR8";
477  break;
479  out << "XTypes::TK_CHAR16";
480  break;
482  out << "XTypes::TI_STRING8_SMALL, " << ti.string_sdefn();
483  break;
485  out << "XTypes::TI_STRING16_SMALL, " << ti.string_sdefn();
486  break;
488  out << "XTypes::TI_STRING8_LARGE, " << ti.string_ldefn();
489  break;
491  out << "XTypes::TI_STRING16_LARGE, " << ti.string_ldefn();
492  break;
494  out << "XTypes::TI_PLAIN_SEQUENCE_SMALL, " << ti.seq_sdefn();
495  break;
497  out << "XTypes::TI_PLAIN_SEQUENCE_LARGE, " << ti.seq_ldefn();
498  break;
500  out << "XTypes::TI_PLAIN_ARRAY_SMALL, " << ti.array_sdefn();
501  break;
503  out << "XTypes::TI_PLAIN_ARRAY_LARGE, " << ti.array_ldefn();
504  break;
506  out << "XTypes::TI_PLAIN_MAP_SMALL, " << ti.map_sdefn();
507  break;
509  out << "XTypes::TI_PLAIN_MAP_LARGE, " << ti.map_ldefn();
510  break;
512  out << "XTypes::TI_STRONGLY_CONNECTED_COMPONENT, " << ti.sc_component_id();
513  break;
515  out << "XTypes::EK_COMPLETE, " << ti.equivalence_hash();
516  break;
518  out << "XTypes::EK_MINIMAL, " << ti.equivalence_hash();
519  break;
520  default:
521  be_util::misc_error_and_abort("Extended type definitions output is not supported");
522  break;
523  }
524 
525  out << ')';
526  return out;
527 }
528 
529 void dump_bytes(const OpenDDS::XTypes::TypeObject& to)
530 {
533  if (!(ser << to)) {
534  be_util::misc_error_and_abort("Failed to serialize type object");
535  }
536 
537  for (const char* ptr = buffer.rd_ptr(); ptr != buffer.wr_ptr(); ++ptr) {
538  if (ptr != buffer.rd_ptr()) {
539  be_global->impl_ << ", ";
540  }
541  be_global->impl_ << int(*reinterpret_cast<const unsigned char*>(ptr));
542  }
543 }
544 
545 }
546 
547 void
549 {
550  if (!produce_output_ || get_type_map_declared_) {
551  return;
552  }
553  get_type_map_declared_ = true;
554 
555  be_global->add_include("dds/DCPS/XTypes/TypeObject.h", BE_GlobalData::STREAM_H);
556 
557  be_global->impl_ << "static const XTypes::TypeMap& get_minimal_type_map();\n";
558 
559  if (produce_xtypes_complete_) {
560  be_global->impl_ << "static const XTypes::TypeMap& get_complete_type_map();\n";
561  }
562 }
563 
564 void
566 {
568  enc.skip_sequence_dheader(true);
569  typeid_encoding_ = &enc;
570 }
571 
572 void
574 {
575  be_global->add_include("dds/DCPS/Service_Participant.h");
576 
577  if (!produce_output_ || !get_type_map_declared_) {
578  return;
579  }
580 
581  NamespaceGuard ng;
582 
583  be_global->impl_ <<
584  "namespace {\n";
585 
586  size_t idx = 0;
587  for (OpenDDS::XTypes::TypeMap::const_iterator pos = minimal_type_map_.begin();
588  pos != minimal_type_map_.end(); ++pos, ++idx) {
589  be_global->impl_ <<
590  "XTypes::TypeObject minimal_to" << idx << "()\n"
591  "{\n"
592  " const unsigned char to_bytes[] = { ";
593  dump_bytes(pos->second);
594  be_global->add_include("<stdexcept>", BE_GlobalData::STREAM_CPP);
595  be_global->impl_ <<
596  " };\n"
597  " XTypes::TypeObject to;\n"
598  " if (!to_type_object(to_bytes, sizeof(to_bytes), to)) {\n"
599  " throw std::runtime_error(\"Could not deserialize minimal Type Object " << idx << "\");\n"
600  " }\n"
601  " return to;\n"
602  "}\n\n";
603  }
604 
605  be_global->impl_ <<
606  "XTypes::TypeMap get_minimal_type_map_private()\n"
607  "{\n"
608  " XTypes::TypeMap tm;\n";
609 
610  idx = 0;
611  for (OpenDDS::XTypes::TypeMap::const_iterator pos = minimal_type_map_.begin();
612  pos != minimal_type_map_.end(); ++pos, ++idx) {
613  be_global->impl_ << " tm[" << pos->first << "] = minimal_to" << idx << "();\n";
614  }
615 
616  be_global->impl_ <<
617  " return tm;\n"
618  "}\n\n";
619 
620  if (produce_xtypes_complete_) {
621  idx = 0;
622  for (OpenDDS::XTypes::TypeMap::const_iterator pos = complete_type_map_.begin();
623  pos != complete_type_map_.end(); ++pos, ++idx) {
624  be_global->impl_ <<
625  "XTypes::TypeObject complete_to" << idx << "()\n"
626  "{\n"
627  " const unsigned char to_bytes[] = {\n";
628  dump_bytes(pos->second);
629  be_global->add_include("<stdexcept>", BE_GlobalData::STREAM_CPP);
630  be_global->impl_ <<
631  " };\n"
632  " XTypes::TypeObject to;\n"
633  " if (!to_type_object(to_bytes, sizeof(to_bytes), to)) {\n"
634  " throw std::runtime_error(\"Could not deserialize complete Type Object " << idx << "\");\n"
635  " }\n"
636  " return to;\n"
637  "}\n\n";
638  }
639 
640  be_global->impl_ <<
641  "XTypes::TypeMap get_complete_type_map_private()\n"
642  "{\n"
643  " XTypes::TypeMap tm;\n";
644 
645  idx = 0;
646  for (OpenDDS::XTypes::TypeMap::const_iterator pos = complete_type_map_.begin();
647  pos != complete_type_map_.end(); ++pos, ++idx) {
648  be_global->impl_ << " tm[" << pos->first << "] = complete_to" << idx << "();\n";
649  }
650 
651  be_global->impl_ <<
652  " return tm;\n"
653  "}\n";
654  }
655  be_global->impl_ << "}\n\n";
656 
657  const std::string common = "{\n"
658  " static XTypes::TypeMap tm;\n"
659  " ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, TheServiceParticipant->get_static_xtypes_lock(), tm);\n"
660  " if (tm.empty()) {\n";
661 
662  be_global->impl_ <<
663  "const XTypes::TypeMap& get_minimal_type_map()\n" << common <<
664  " tm = get_minimal_type_map_private();\n"
665  " }\n"
666  " return tm;\n"
667  "}\n\n";
668 
669  if (produce_xtypes_complete_) {
670  be_global->impl_ <<
671  "const XTypes::TypeMap& get_complete_type_map()\n" << common <<
672  " tm = get_complete_type_map_private();\n"
673  " }\n"
674  " return tm;\n"
675  "}\n";
676  }
677 }
678 
679 string
681 {
682  return dds_generator::get_xtag_name(name);
683 }
684 
685 bool
686 typeobject_generator::gen_enum(AST_Enum* node, UTL_ScopedName* name,
687  const std::vector<AST_EnumVal*>&, const char*)
688 {
689  return generate(node, name);
690 }
691 
692 bool
693 typeobject_generator::gen_struct(AST_Structure* node, UTL_ScopedName* name,
694  const std::vector<AST_Field*>&, AST_Type::SIZE_TYPE, const char*)
695 {
696  return generate(node, name);
697 }
698 
699 bool
700 typeobject_generator::gen_typedef(AST_Typedef* node, UTL_ScopedName* name,
701  AST_Type*, const char*)
702 {
703  return generate(node, name);
704 }
705 
706 bool
707 typeobject_generator::gen_union(AST_Union* node, UTL_ScopedName* name,
708  const std::vector<AST_UnionBranch*>&, AST_Type*,
709  const char*)
710 {
711  return generate(node, name);
712 }
713 
714 void
715 typeobject_generator::consider(Element& v, AST_Type* type, const std::string& anonymous_name)
716 {
717  switch (type->node_type()) {
718  case AST_ConcreteType::NT_union_fwd:
719  {
720  AST_UnionFwd* const n = dynamic_cast<AST_UnionFwd*>(type);
721  type = n->full_definition();
722  break;
723  }
724  case AST_ConcreteType::NT_struct_fwd:
725  {
726  AST_StructureFwd* const n = dynamic_cast<AST_StructureFwd*>(type);
727  type = n->full_definition();
728  break;
729  }
730  default:
731  break;
732  }
733 
734  if (element_.find(type) == element_.end()) {
735  strong_connect(type, anonymous_name);
736  v.lowlink = std::min(v.lowlink, element_[type].lowlink);
737  } else if (element_[type].on_stack) {
738  v.lowlink = std::min(v.lowlink, element_[type].index);
739  }
740 }
741 
742 void
743 typeobject_generator::strong_connect(AST_Type* type, const std::string& anonymous_name)
744 {
745  switch (type->node_type()) {
746  case AST_ConcreteType::NT_union_fwd:
747  {
748  AST_UnionFwd* const n = dynamic_cast<AST_UnionFwd*>(type);
749  type = n->full_definition();
750  break;
751  }
752  case AST_ConcreteType::NT_struct_fwd:
753  {
754  AST_StructureFwd* const n = dynamic_cast<AST_StructureFwd*>(type);
755  type = n->full_definition();
756  break;
757  }
758  default:
759  break;
760  }
761 
762  Element& v = element_[type];
763  v.type = type;
764  v.index = index_;
765  v.lowlink = index_;
766  ++index_;
767  stack_.push_back(type);
768  v.on_stack = true;
769 
771  AST_Structure* const stru = dynamic_cast<AST_Structure*>(type);
772  switch (type->node_type()) {
773 
774  case AST_ConcreteType::NT_union:
775  {
776  AST_Union* const n = dynamic_cast<AST_Union*>(type);
777  v.name = canonical_name(n->name());
778 
779  AST_Type* discriminator = n->disc_type();
780  const Fields fields(n);
781 
782  consider(v, discriminator, v.name + ".d");
783 
784  const AutoidKind auto_id = be_global->autoid(n);
785  MemberId member_id = 0;
786 
787  for (Fields::Iterator i = fields.begin(); i != fields.end(); ++i) {
788  AST_UnionBranch* ub = dynamic_cast<AST_UnionBranch*>(*i);
789  const MemberId id = be_global->compute_id(stru, ub, auto_id, member_id);
790  consider(v, ub->field_type(), v.name + "." + OpenDDS::DCPS::to_dds_string(id));
791  }
792 
793  break;
794  }
795 
796  case AST_ConcreteType::NT_struct:
797  {
798  AST_Structure* const n = dynamic_cast<AST_Structure*>(type);
799  v.name = canonical_name(n->name());
800 
801  // TODO: Struct inheritance.
802 
803  const Fields fields(n);
804  const AutoidKind auto_id = be_global->autoid(n);
805  MemberId member_id = 0;
806 
807  for (Fields::Iterator i = fields.begin(); i != fields.end(); ++i) {
808  AST_Field* field = *i;
809  const MemberId id = be_global->compute_id(stru, field, auto_id, member_id);
810  consider(v, field->field_type(), v.name + "." + OpenDDS::DCPS::to_dds_string(id));
811  }
812 
813  break;
814  }
815 
816  case AST_ConcreteType::NT_array:
817  {
818  AST_Array* const n = dynamic_cast<AST_Array*>(type);
819  v.name = anonymous_name + ".a";
820  consider(v, n->base_type(), v.name);
821  break;
822  }
823 
824  case AST_ConcreteType::NT_sequence:
825  {
826  AST_Sequence* const n = dynamic_cast<AST_Sequence*>(type);
827  v.name = anonymous_name + ".s";
828  consider(v, n->base_type(), v.name);
829  break;
830  }
831 
832  case AST_ConcreteType::NT_typedef:
833  {
834  AST_Typedef* const n = dynamic_cast<AST_Typedef*>(type);
835  v.name = canonical_name(n->name());
836  // TODO: What is the member name for an anonymous type in a typedef?
837  // 7.3.4.9.2
838  consider(v, n->base_type(), v.name + ".0");
839  break;
840  }
841 
842  case AST_ConcreteType::NT_enum:
843  {
844  AST_Enum* const n = dynamic_cast<AST_Enum*>(type);
845  v.name = canonical_name(n->name());
846  break;
847  }
848 
849  case AST_ConcreteType::NT_string:
850  case AST_ConcreteType::NT_wstring:
851  case AST_ConcreteType::NT_pre_defined:
852  case AST_ConcreteType::NT_fixed:
853  case AST_ConcreteType::NT_interface:
854  case AST_ConcreteType::NT_interface_fwd:
855  break;
856 
857  case AST_ConcreteType::NT_struct_fwd:
858  case AST_ConcreteType::NT_union_fwd:
859  case AST_ConcreteType::NT_native:
860  case AST_ConcreteType::NT_factory:
861  case AST_ConcreteType::NT_finder:
862  case AST_ConcreteType::NT_component:
863  case AST_ConcreteType::NT_component_fwd:
864  case AST_ConcreteType::NT_home:
865  case AST_ConcreteType::NT_eventtype:
866  case AST_ConcreteType::NT_eventtype_fwd:
867  case AST_ConcreteType::NT_valuebox:
868  case AST_ConcreteType::NT_type:
869  case AST_ConcreteType::NT_porttype:
870  case AST_ConcreteType::NT_provides:
871  case AST_ConcreteType::NT_uses:
872  case AST_ConcreteType::NT_publishes:
873  case AST_ConcreteType::NT_emits:
874  case AST_ConcreteType::NT_consumes:
875  case AST_ConcreteType::NT_ext_port:
876  case AST_ConcreteType::NT_mirror_port:
877  case AST_ConcreteType::NT_connector:
878  case AST_ConcreteType::NT_param_holder:
879  case AST_ConcreteType::NT_annotation_decl:
880  case AST_ConcreteType::NT_annotation_appl:
881  case AST_ConcreteType::NT_annotation_member:
882  case AST_ConcreteType::NT_module:
883  case AST_ConcreteType::NT_root:
884  case AST_ConcreteType::NT_valuetype:
885  case AST_ConcreteType::NT_valuetype_fwd:
886  case AST_ConcreteType::NT_const:
887  case AST_ConcreteType::NT_except:
888  case AST_ConcreteType::NT_attr:
889  case AST_ConcreteType::NT_op:
890  case AST_ConcreteType::NT_argument:
891  case AST_ConcreteType::NT_union_branch:
892  case AST_ConcreteType::NT_field:
893  case AST_ConcreteType::NT_enum_val:
894  be_util::misc_error_and_abort("Unexpected AST type", type);
895  break;
896  }
897 
898  if (v.lowlink == v.index) {
899  typedef std::vector<Element> List;
900  List scc;
901  AST_Type* wt;
902  do {
903  wt = stack_.back();
904  stack_.pop_back();
905  Element& w = element_[wt];
906  w.on_stack = false;
907  scc.push_back(w);
908  } while (wt != v.type);
909 
910  // Sort types in SCC using lexicographic order of their fully qualified names.
911  std::sort(scc.begin(), scc.end());
912 
913  if (scc.size() == 1) {
914  generate_type_identifier(scc[0].type, false);
915  } else {
916  // Compute temporary type identifiers for the types in SCC with hash value of zero.
918  minimal_ti.sc_component_id().sc_component_id.kind = OpenDDS::XTypes::EK_MINIMAL;
919  std::memset(&minimal_ti.sc_component_id().sc_component_id.hash, 0, sizeof(OpenDDS::XTypes::EquivalenceHash));
920  minimal_ti.sc_component_id().scc_length = static_cast<int>(scc.size());
921 
922  OpenDDS::XTypes::TypeIdentifier complete_ti = minimal_ti;
923  complete_ti.sc_component_id().sc_component_id.kind = OpenDDS::XTypes::EK_COMPLETE;
924 
925  {
926  size_t idx = 0;
927  for (List::const_iterator pos = scc.begin(); pos != scc.end(); ++pos) {
928  minimal_ti.sc_component_id().scc_index = static_cast<int>(++idx); // Starts at 1.
929  complete_ti.sc_component_id().scc_index = minimal_ti.sc_component_id().scc_index;
930  const TypeIdentifierPair ti_pair = {minimal_ti, complete_ti};
931  hash_type_identifier_map_[pos->type] = ti_pair;
932  }
933  }
934 
935  // Construct temporary type objects from the temporary type identifiers.
936  OpenDDS::XTypes::TypeObjectSeq minimal_seq, complete_seq;
937  for (List::const_iterator pos = scc.begin(); pos != scc.end(); ++pos) {
938  generate_type_identifier(pos->type, true);
939  OPENDDS_ASSERT(type_object_map_.count(pos->type) != 0);
940  minimal_seq.append(type_object_map_[pos->type].minimal);
941  complete_seq.append(type_object_map_[pos->type].complete);
942  }
943 
944  // Compute the final type identifiers with the correct hash value.
946  size_t minimal_size = serialized_size(encoding, minimal_seq);
947  ACE_Message_Block minimal_buff(minimal_size);
948  OpenDDS::DCPS::Serializer minimal_ser(&minimal_buff, encoding);
949  if (!(minimal_ser << minimal_seq)) {
950  be_util::misc_error_and_abort("Failed to serialize minimal type object sequence in strongly-connected component", type);
951  }
952 
953  unsigned char result[sizeof(OpenDDS::DCPS::MD5Result)];
954  OpenDDS::DCPS::MD5Hash(result, minimal_buff.rd_ptr(), minimal_buff.length());
955 
956  // First 14 bytes of MD5 of the serialized TypeObject using XCDR
957  // version 2 with Little Endian encoding
958  std::memcpy(minimal_ti.sc_component_id().sc_component_id.hash, result, sizeof(OpenDDS::XTypes::EquivalenceHash));
959 
960  size_t complete_size = serialized_size(encoding, complete_seq);
961  ACE_Message_Block complete_buff(complete_size);
962  OpenDDS::DCPS::Serializer complete_ser(&complete_buff, encoding);
963  if (!(complete_ser << complete_seq)) {
964  be_util::misc_error_and_abort("Failed to serialize complete type object sequence in strongly-connected component", type);
965  }
966 
967  OpenDDS::DCPS::MD5Hash(result, complete_buff.rd_ptr(), complete_buff.length());
968  std::memcpy(complete_ti.sc_component_id().sc_component_id.hash, result, sizeof(OpenDDS::XTypes::EquivalenceHash));
969 
970  {
971  size_t idx = 0;
972  for (List::const_iterator pos = scc.begin(); pos != scc.end(); ++pos) {
973  minimal_ti.sc_component_id().scc_index = static_cast<int>(++idx);
974  complete_ti.sc_component_id().scc_index = minimal_ti.sc_component_id().scc_index;
975  const TypeIdentifierPair ti_pair = {minimal_ti, complete_ti};
976  hash_type_identifier_map_[pos->type] = ti_pair;
977  }
978  }
979 
980  // Compute the final type objects with the final type identifiers.
981  for (List::const_iterator pos = scc.begin(); pos != scc.end(); ++pos) {
982  generate_type_identifier(pos->type, true);
983  const OpenDDS::XTypes::TypeIdentifier& minimal_ti = hash_type_identifier_map_[pos->type].minimal;
984  const OpenDDS::XTypes::TypeIdentifier& complete_ti = hash_type_identifier_map_[pos->type].complete;
985  minimal_type_map_[minimal_ti] = type_object_map_[pos->type].minimal;
986  complete_type_map_[complete_ti] = type_object_map_[pos->type].complete;
987  }
988  }
989  }
990 }
991 
992 void
994  const OpenDDS::XTypes::TypeObject& minimal_to,
995  const OpenDDS::XTypes::TypeObject& complete_to)
996 {
997  const TypeObjectPair to_pair = {minimal_to, complete_to};
998  type_object_map_[type] = to_pair;
999 
1000  // In case of SCC, type identifiers of the types in SCC are computed first and
1001  // type objects are constructed using them. In that case, we don't want to update
1002  // each individual type's type identifier by hashing the corresponding type object.
1003  // On the other hand, type identifier is computed if the type is not part of a SCC.
1004  if (hash_type_identifier_map_.count(type) == 0) {
1005  const OpenDDS::XTypes::TypeIdentifier minimal_ti = makeTypeIdentifier(minimal_to, typeid_encoding_);
1006  const OpenDDS::XTypes::TypeIdentifier complete_ti = makeTypeIdentifier(complete_to, typeid_encoding_);
1007  const TypeIdentifierPair ti_pair = {minimal_ti, complete_ti};
1008  hash_type_identifier_map_[type] = ti_pair;
1009 
1010  minimal_type_map_[minimal_ti] = minimal_to;
1011  complete_type_map_[complete_ti] = complete_to;
1012  }
1013 }
1014 
1017 {
1018  // Support only @hashid annotation for member at this time.
1019  const HashidAnnotation* hashid_ann = dynamic_cast<const HashidAnnotation*>(be_global->builtin_annotations_["::@hashid"]);
1020  std::string hash_name;
1021  if (hashid_ann->node_value_exists(member, hash_name)) {
1022  OpenDDS::XTypes::Optional<std::string> hash_id(hash_name);
1023  if (!annotations) {
1026  }
1027  annotations.value().hash_id = hash_id;
1028  }
1029 }
1030 
1031 void
1033 {
1034  AST_Structure* const n = dynamic_cast<AST_Structure*>(type);
1035  const Fields fields(n);
1036 
1037  const ExtensibilityKind exten = be_global->extensibility(n);
1038  const AutoidKind auto_id = be_global->autoid(n);
1039 
1040  OpenDDS::XTypes::TypeObject minimal_to, complete_to;
1041  minimal_to.kind = OpenDDS::XTypes::EK_MINIMAL;
1043 
1044  minimal_to.minimal.struct_type.struct_flags = extensibility_to_type_flag(exten);
1045 
1046  if (be_global->is_nested(n)) {
1048  }
1049 
1050  if (auto_id == autoidkind_hash) {
1052  }
1053 
1054  // TODO: Support inheritance.
1056 
1057  complete_to.kind = OpenDDS::XTypes::EK_COMPLETE;
1059 
1062  complete_to.complete.struct_type.header.detail.type_name = canonical_name(type->name());
1063  // @verbatim and custom annotations are not supported.
1064 
1065  for (Fields::Iterator i = fields.begin(); i != fields.end(); ++i) {
1066  AST_Field* field = *i;
1067  const TryConstructFailAction trycon = be_global->try_construct(field);
1068 
1069  OpenDDS::XTypes::MinimalStructMember minimal_member;
1070  minimal_member.common.member_id = be_global->get_id(field);
1071  minimal_member.common.member_flags = try_construct_to_member_flag(trycon);
1072 
1073  if (be_global->is_optional(field)) {
1075  }
1076 
1077  if (be_global->is_must_understand(field)) {
1079  }
1080 
1081  if (be_global->is_key(field)) {
1082  minimal_member.common.member_flags |= OpenDDS::XTypes::IS_KEY;
1083  }
1084 
1085  if (be_global->is_external(field)) {
1087  }
1088 
1089  minimal_member.common.member_type_id = get_minimal_type_identifier(field->field_type());
1090  const std::string name = canonical_name(field->local_name());
1091  OpenDDS::XTypes::hash_member_name(minimal_member.detail.name_hash, name);
1092  minimal_to.minimal.struct_type.member_seq.append(minimal_member);
1093 
1094  OpenDDS::XTypes::CompleteStructMember complete_member;
1095  complete_member.common.member_id = minimal_member.common.member_id;
1096  complete_member.common.member_flags = minimal_member.common.member_flags;
1097  complete_member.common.member_type_id = get_complete_type_identifier(field->field_type());
1098 
1099  complete_member.detail.name = name;
1100  set_builtin_member_annotations(field, complete_member.detail.ann_builtin);
1101 
1102  complete_to.complete.struct_type.member_seq.append(complete_member);
1103  }
1104 
1105  if (be_global->old_typeobject_member_order()) {
1106  minimal_to.minimal.struct_type.member_seq.sort();
1107  complete_to.complete.struct_type.member_seq.sort();
1108  }
1109 
1110  update_maps(type, minimal_to, complete_to);
1111 }
1112 
1113 void
1115 {
1116  AST_Union* const n = dynamic_cast<AST_Union*>(type);
1117  AST_Type* discriminator = n->disc_type();
1118  const Fields fields(n);
1119 
1120  const ExtensibilityKind exten = be_global->extensibility(n);
1121  const AutoidKind auto_id = be_global->autoid(n);
1122 
1123  OpenDDS::XTypes::TypeObject minimal_to, complete_to;
1124  minimal_to.kind = OpenDDS::XTypes::EK_MINIMAL;
1125  minimal_to.minimal.kind = OpenDDS::XTypes::TK_UNION;
1126  minimal_to.minimal.union_type.union_flags = extensibility_to_type_flag(exten);
1127 
1128  if (be_global->is_nested(n)) {
1130  }
1131 
1132  if (auto_id == autoidkind_hash) {
1134  }
1135 
1136  const TryConstructFailAction trycon = be_global->union_discriminator_try_construct(n);
1137  minimal_to.minimal.union_type.discriminator.common.member_flags = try_construct_to_member_flag(trycon);
1138  if (be_global->union_discriminator_is_key(n)) {
1140  }
1141  minimal_to.minimal.union_type.discriminator.common.type_id = get_minimal_type_identifier(discriminator);
1142 
1143  complete_to.kind = OpenDDS::XTypes::EK_COMPLETE;
1144  complete_to.complete.kind = OpenDDS::XTypes::TK_UNION;
1145  complete_to.complete.union_type.union_flags = minimal_to.minimal.union_type.union_flags;
1146 
1147  complete_to.complete.union_type.header.detail.type_name = canonical_name(type->name());
1148 
1151  complete_to.complete.union_type.discriminator.common.type_id = get_complete_type_identifier(discriminator);
1152 
1153  for (Fields::Iterator i = fields.begin(); i != fields.end(); ++i) {
1154  AST_UnionBranch* branch = dynamic_cast<AST_UnionBranch*>(*i);
1155  const TryConstructFailAction trycon = be_global->try_construct(branch);
1156 
1157  bool is_default = false;
1158  for (unsigned long j = 0; j < branch->label_list_length(); ++j) {
1159  AST_UnionLabel* label = branch->label(j);
1160  if (label->label_kind() == AST_UnionLabel::UL_default) {
1161  is_default = true;
1162  break;
1163  }
1164  }
1165 
1166  OpenDDS::XTypes::MinimalUnionMember minimal_member;
1167  minimal_member.common.member_id = be_global->get_id(branch);
1168  minimal_member.common.member_flags = try_construct_to_member_flag(trycon);
1169 
1170  if (is_default) {
1172  }
1173 
1174  if (be_global->is_external(branch)) {
1176  }
1177 
1178  minimal_member.common.type_id = get_minimal_type_identifier(branch->field_type());
1179 
1180  for (unsigned long j = 0; j < branch->label_list_length(); ++j) {
1181  AST_UnionLabel* label = branch->label(j);
1182  if (label->label_kind() != AST_UnionLabel::UL_default) {
1183  minimal_member.common.label_seq.append(to_long(*label->label_val()->ev()));
1184  }
1185  }
1186  minimal_member.common.label_seq.sort();
1187 
1188  const std::string name = canonical_name(branch->local_name());
1189  OpenDDS::XTypes::hash_member_name(minimal_member.detail.name_hash, name);
1190  minimal_to.minimal.union_type.member_seq.append(minimal_member);
1191 
1192  OpenDDS::XTypes::CompleteUnionMember complete_member;
1193  complete_member.common.member_id = minimal_member.common.member_id;
1194  complete_member.common.member_flags = minimal_member.common.member_flags;
1195  complete_member.common.type_id = get_complete_type_identifier(branch->field_type());
1196  complete_member.common.label_seq = minimal_member.common.label_seq;
1197 
1198  complete_member.detail.name = name;
1199  set_builtin_member_annotations(branch, complete_member.detail.ann_builtin);
1200 
1201  complete_to.complete.union_type.member_seq.append(complete_member);
1202  }
1203 
1204  if (be_global->old_typeobject_member_order()) {
1205  minimal_to.minimal.union_type.member_seq.sort();
1206  complete_to.complete.union_type.member_seq.sort();
1207  }
1208 
1209  update_maps(type, minimal_to, complete_to);
1210 }
1211 
1212 void
1214 {
1215  AST_Enum* const n = dynamic_cast<AST_Enum*>(type);
1216  std::vector<AST_EnumVal*> contents;
1217  scope2vector(contents, n, AST_Decl::NT_enum_val);
1218  bool has_extensibility_annotation = false;
1219  const ExtensibilityKind ek = be_global->extensibility(type, extensibilitykind_appendable, has_extensibility_annotation);
1220 
1221  if (ek == extensibilitykind_mutable) {
1222  be_util::misc_error_and_abort("MUTABLE extensibility for enum is not allowed", type);
1223  }
1224 
1225  size_t default_literal_idx = 0;
1226  for (size_t i = 0; i != contents.size(); ++i) {
1227  if (contents[i]->annotations().find("@default_literal")) {
1228  default_literal_idx = i;
1229  break;
1230  }
1231  }
1232 
1233  OpenDDS::XTypes::TypeObject minimal_to, complete_to;
1234  minimal_to.kind = OpenDDS::XTypes::EK_MINIMAL;
1235  minimal_to.minimal.kind = OpenDDS::XTypes::TK_ENUM;
1236  if (has_extensibility_annotation || !be_global->default_enum_extensibility_zero()) {
1237  minimal_to.minimal.enumerated_type.enum_flags = extensibility_to_type_flag(ek);
1238  }
1239  // TODO: Add support for @bit_bound.
1240  minimal_to.minimal.enumerated_type.header.common.bit_bound = 32;
1241 
1242  complete_to.kind = OpenDDS::XTypes::EK_COMPLETE;
1243  complete_to.complete.kind = OpenDDS::XTypes::TK_ENUM;
1244  if (has_extensibility_annotation || !be_global->default_enum_extensibility_zero()) {
1245  complete_to.complete.enumerated_type.enum_flags = extensibility_to_type_flag(ek);
1246  }
1247  complete_to.complete.enumerated_type.header.common.bit_bound = 32;
1248  complete_to.complete.enumerated_type.header.detail.type_name = canonical_name(type->name());
1249 
1250  for (size_t i = 0; i != contents.size(); ++i) {
1252  minimal_lit.common.value = contents[i]->constant_value()->ev()->u.eval;
1253  minimal_lit.common.flags = (i == default_literal_idx ? OpenDDS::XTypes::IS_DEFAULT : 0);
1254  const std::string name = canonical_name(contents[i]->local_name());
1256  minimal_to.minimal.enumerated_type.literal_seq.append(minimal_lit);
1257 
1259  complete_lit.common = minimal_lit.common;
1260  complete_lit.detail.name = name;
1261 
1262  complete_to.complete.enumerated_type.literal_seq.append(complete_lit);
1263  }
1264  minimal_to.minimal.enumerated_type.literal_seq.sort();
1265  complete_to.complete.enumerated_type.literal_seq.sort();
1266 
1267  update_maps(type, minimal_to, complete_to);
1268 }
1269 
1270 void
1271 typeobject_generator::generate_array_type_identifier(AST_Type* type, bool force_type_object)
1272 {
1273  AST_Array* const n = dynamic_cast<AST_Array*>(type);
1274 
1275  const TryConstructFailAction trycon = be_global->try_construct(n->base_type());
1276  OpenDDS::XTypes::CollectionElementFlag cef = try_construct_to_member_flag(trycon);
1277  if (be_global->is_external(n->base_type())) {
1279  }
1280  const OpenDDS::XTypes::TypeIdentifier minimal_elem_ti = get_minimal_type_identifier(n->base_type());
1281  const OpenDDS::XTypes::TypeIdentifier complete_elem_ti = get_complete_type_identifier(n->base_type());
1282 
1283  if (be_global->is_plain(type) && !force_type_object) {
1284  const OpenDDS::XTypes::EquivalenceKind minimal_ek =
1286  const OpenDDS::XTypes::EquivalenceKind complete_ek =
1287  minimal_ek == OpenDDS::XTypes::EK_BOTH ? minimal_ek : OpenDDS::XTypes::EK_COMPLETE;
1288 
1289  ACE_CDR::ULong max_bound = 0;
1290  for (ACE_CDR::ULong dim = 0; dim != n->n_dims(); ++dim) {
1291  max_bound = std::max(max_bound, n->dims()[dim]->ev()->u.ulval);
1292  }
1293 
1294  if (max_bound < 256) {
1296  minimal_ti.array_sdefn().header.equiv_kind = minimal_ek;
1297  minimal_ti.array_sdefn().header.element_flags = cef;
1298  for (ACE_CDR::ULong dim = 0; dim != n->n_dims(); ++dim) {
1299  minimal_ti.array_sdefn().array_bound_seq.append(n->dims()[dim]->ev()->u.ulval);
1300  }
1301  minimal_ti.array_sdefn().element_identifier = minimal_elem_ti;
1302 
1303  if (minimal_ek == OpenDDS::XTypes::EK_BOTH) {
1304  fully_desc_type_identifier_map_[type] = minimal_ti;
1305  } else {
1307  complete_ti.array_sdefn().header.equiv_kind = complete_ek;
1308  complete_ti.array_sdefn().header.element_flags = cef;
1309  complete_ti.array_sdefn().array_bound_seq = minimal_ti.array_sdefn().array_bound_seq;
1310  complete_ti.array_sdefn().element_identifier = complete_elem_ti;
1311 
1312  const TypeIdentifierPair ti_pair = {minimal_ti, complete_ti};
1313  hash_type_identifier_map_[type] = ti_pair;
1314  }
1315  } else {
1317  minimal_ti.array_ldefn().header.equiv_kind = minimal_ek;
1318  minimal_ti.array_ldefn().header.element_flags = cef;
1319  for (ACE_CDR::ULong dim = 0; dim != n->n_dims(); ++dim) {
1320  minimal_ti.array_ldefn().array_bound_seq.append(n->dims()[dim]->ev()->u.ulval);
1321  }
1322  minimal_ti.array_ldefn().element_identifier = minimal_elem_ti;
1323 
1324  if (minimal_ek == OpenDDS::XTypes::EK_BOTH) {
1325  fully_desc_type_identifier_map_[type] = minimal_ti;
1326  } else {
1328  complete_ti.array_ldefn().header.equiv_kind = complete_ek;
1329  complete_ti.array_ldefn().header.element_flags = cef;
1330  complete_ti.array_ldefn().array_bound_seq = minimal_ti.array_ldefn().array_bound_seq;
1331  complete_ti.array_ldefn().element_identifier = complete_elem_ti;
1332 
1333  const TypeIdentifierPair ti_pair = {minimal_ti, complete_ti};
1334  hash_type_identifier_map_[type] = ti_pair;
1335  }
1336  }
1337  } else {
1338  OpenDDS::XTypes::TypeObject minimal_to, complete_to;
1339  minimal_to.kind = OpenDDS::XTypes::EK_MINIMAL;
1340  minimal_to.minimal.kind = OpenDDS::XTypes::TK_ARRAY;
1341  for (ACE_CDR::ULong dim = 0; dim != n->n_dims(); ++dim) {
1342  minimal_to.minimal.array_type.header.common.bound_seq.append(n->dims()[dim]->ev()->u.ulval);
1343  }
1344  minimal_to.minimal.array_type.element.common.element_flags = cef;
1345  minimal_to.minimal.array_type.element.common.type = minimal_elem_ti;
1346 
1347  complete_to.kind = OpenDDS::XTypes::EK_COMPLETE;
1348  complete_to.complete.kind = OpenDDS::XTypes::TK_ARRAY;
1350  complete_to.complete.array_type.header.detail.type_name = canonical_name(type->name());
1351 
1352  complete_to.complete.array_type.element.common.element_flags = cef;
1353  complete_to.complete.array_type.element.common.type = complete_elem_ti;
1354 
1355  update_maps(type, minimal_to, complete_to);
1356  }
1357 }
1358 
1359 void
1360 typeobject_generator::generate_sequence_type_identifier(AST_Type* type, bool force_type_object)
1361 {
1362  AST_Sequence* const n = dynamic_cast<AST_Sequence*>(type);
1363 
1364  ACE_CDR::ULong bound = 0;
1365  if (!n->unbounded()) {
1366  bound = n->max_size()->ev()->u.ulval;
1367  }
1368 
1369  const TryConstructFailAction trycon = be_global->try_construct(n->base_type());
1370  OpenDDS::XTypes::CollectionElementFlag cef = try_construct_to_member_flag(trycon);
1371  if (be_global->is_external(n->base_type())) {
1373  }
1374  const OpenDDS::XTypes::TypeIdentifier minimal_elem_ti = get_minimal_type_identifier(n->base_type());
1375  const OpenDDS::XTypes::TypeIdentifier complete_elem_ti = get_complete_type_identifier(n->base_type());
1376 
1377  if (be_global->is_plain(type) && !force_type_object) {
1378  const OpenDDS::XTypes::EquivalenceKind minimal_ek =
1380  const OpenDDS::XTypes::EquivalenceKind complete_ek =
1381  minimal_ek == OpenDDS::XTypes::EK_BOTH ? minimal_ek : OpenDDS::XTypes::EK_COMPLETE;
1382  if (bound < 256) {
1384  minimal_ti.seq_sdefn().header.equiv_kind = minimal_ek;
1385  minimal_ti.seq_sdefn().header.element_flags = cef;
1386  minimal_ti.seq_sdefn().bound = bound;
1387  minimal_ti.seq_sdefn().element_identifier = minimal_elem_ti;
1388 
1389  if (minimal_ek == OpenDDS::XTypes::EK_BOTH) {
1390  fully_desc_type_identifier_map_[type] = minimal_ti;
1391  } else {
1393  complete_ti.seq_sdefn().header.equiv_kind = complete_ek;
1394  complete_ti.seq_sdefn().header.element_flags = cef;
1395  complete_ti.seq_sdefn().bound = bound;
1396  complete_ti.seq_sdefn().element_identifier = complete_elem_ti;
1397 
1398  const TypeIdentifierPair ti_pair = {minimal_ti, complete_ti};
1399  hash_type_identifier_map_[type] = ti_pair;
1400  }
1401  } else {
1403  minimal_ti.seq_ldefn().header.equiv_kind = minimal_ek;
1404  minimal_ti.seq_ldefn().header.element_flags = cef;
1405  minimal_ti.seq_ldefn().bound = bound;
1406  minimal_ti.seq_ldefn().element_identifier = minimal_elem_ti;
1407 
1408  if (minimal_ek == OpenDDS::XTypes::EK_BOTH) {
1409  fully_desc_type_identifier_map_[type] = minimal_ti;
1410  } else {
1412  complete_ti.seq_ldefn().header.equiv_kind = complete_ek;
1413  complete_ti.seq_ldefn().header.element_flags = cef;
1414  complete_ti.seq_ldefn().bound = bound;
1415  complete_ti.seq_ldefn().element_identifier = complete_elem_ti;
1416 
1417  const TypeIdentifierPair ti_pair = {minimal_ti, complete_ti};
1418  hash_type_identifier_map_[type] = ti_pair;
1419  }
1420  }
1421  } else {
1422  OpenDDS::XTypes::TypeObject minimal_to, complete_to;
1423  minimal_to.kind = OpenDDS::XTypes::EK_MINIMAL;
1425  minimal_to.minimal.sequence_type.header.common.bound = bound;
1427  minimal_to.minimal.sequence_type.element.common.type = minimal_elem_ti;
1428 
1429  complete_to.kind = OpenDDS::XTypes::EK_COMPLETE;
1431  complete_to.complete.sequence_type.header.common.bound = bound;
1433  complete_to.complete.sequence_type.element.common.type = complete_elem_ti;
1434 
1435  update_maps(type, minimal_to, complete_to);
1436  }
1437 }
1438 
1439 void
1441 {
1442  AST_Typedef* const n = dynamic_cast<AST_Typedef*>(type);
1443 
1444  OpenDDS::XTypes::TypeObject minimal_to, complete_to;
1445  minimal_to.kind = OpenDDS::XTypes::EK_MINIMAL;
1446  minimal_to.minimal.kind = OpenDDS::XTypes::TK_ALIAS;
1447  minimal_to.minimal.alias_type.body.common.related_type = get_minimal_type_identifier(n->base_type());
1448 
1449  complete_to.kind = OpenDDS::XTypes::EK_COMPLETE;
1450  complete_to.complete.kind = OpenDDS::XTypes::TK_ALIAS;
1451  complete_to.complete.alias_type.header.detail.type_name = canonical_name(type->name());
1452  complete_to.complete.alias_type.body.common.related_type = get_complete_type_identifier(n->base_type());
1453 
1454  update_maps(type, minimal_to, complete_to);
1455 }
1456 
1457 void
1459 {
1460  AST_PredefinedType* const n = dynamic_cast<AST_PredefinedType*>(type);
1461  switch (n->pt()) {
1462  case AST_PredefinedType::PT_long:
1463  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_INT32);
1464  break;
1465  case AST_PredefinedType::PT_ulong:
1466  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_UINT32);
1467  break;
1468  case AST_PredefinedType::PT_longlong:
1469  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_INT64);
1470  break;
1471  case AST_PredefinedType::PT_ulonglong:
1472  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_UINT64);
1473  break;
1474  case AST_PredefinedType::PT_short:
1475  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_INT16);
1476  break;
1477  case AST_PredefinedType::PT_ushort:
1478  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_UINT16);
1479  break;
1480 #if OPENDDS_HAS_EXPLICIT_INTS
1481  case AST_PredefinedType::PT_int8:
1482  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_INT8);
1483  break;
1484  case AST_PredefinedType::PT_uint8:
1485  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_UINT8);
1486  break;
1487 #endif
1488  case AST_PredefinedType::PT_float:
1489  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_FLOAT32);
1490  break;
1491  case AST_PredefinedType::PT_double:
1492  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_FLOAT64);
1493  break;
1494  case AST_PredefinedType::PT_longdouble:
1495  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_FLOAT128);
1496  break;
1497  case AST_PredefinedType::PT_char:
1498  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_CHAR8);
1499  break;
1500  case AST_PredefinedType::PT_wchar:
1501  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_CHAR16);
1502  break;
1503  case AST_PredefinedType::PT_boolean:
1504  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_BOOLEAN);
1505  break;
1506  case AST_PredefinedType::PT_octet:
1507  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_BYTE);
1508  break;
1509  case AST_PredefinedType::PT_any:
1510  case AST_PredefinedType::PT_object:
1511  case AST_PredefinedType::PT_value:
1512  case AST_PredefinedType::PT_abstract:
1513  case AST_PredefinedType::PT_void:
1514  case AST_PredefinedType::PT_pseudo:
1515  be_util::misc_error_and_abort("Unexpected primitive type");
1516  }
1517 }
1518 
1519 void
1520 typeobject_generator::generate_type_identifier(AST_Type* type, bool force_type_object)
1521 {
1522  // Generate both minimal and complete identifiers (and type objects) and cache.
1523  switch (type->node_type()) {
1524 
1525  case AST_ConcreteType::NT_union:
1526  {
1527  generate_union_type_identifier(type);
1528  break;
1529  }
1530 
1531  case AST_ConcreteType::NT_struct:
1532  {
1533  generate_struct_type_identifier(type);
1534  break;
1535  }
1536 
1537  case AST_ConcreteType::NT_enum:
1538  {
1539  generate_enum_type_identifier(type);
1540  break;
1541  }
1542 
1543  case AST_ConcreteType::NT_string:
1544  {
1545  AST_String* const n = dynamic_cast<AST_String*>(type);
1546  ACE_CDR::ULong bound = n->max_size()->ev()->u.ulval;
1547  if (bound < 256) {
1549  ti.string_sdefn().bound = bound;
1550  fully_desc_type_identifier_map_[type] = ti;
1551  } else {
1553  ti.string_ldefn().bound = bound;
1554  fully_desc_type_identifier_map_[type] = ti;
1555  }
1556  break;
1557  }
1558 
1559  case AST_ConcreteType::NT_wstring:
1560  {
1561  AST_String* const n = dynamic_cast<AST_String*>(type);
1562  ACE_CDR::ULong bound = n->max_size()->ev()->u.ulval;
1563  if (bound < 256) {
1565  ti.string_sdefn().bound = bound;
1566  fully_desc_type_identifier_map_[type] = ti;
1567  } else {
1569  ti.string_ldefn().bound = bound;
1570  fully_desc_type_identifier_map_[type] = ti;
1571  }
1572  break;
1573  }
1574 
1575  case AST_ConcreteType::NT_array:
1576  {
1577  generate_array_type_identifier(type, force_type_object);
1578  break;
1579  }
1580 
1581  case AST_ConcreteType::NT_sequence:
1582  {
1583  generate_sequence_type_identifier(type, force_type_object);
1584  break;
1585  }
1586 
1587  case AST_ConcreteType::NT_typedef:
1588  {
1589  generate_alias_type_identifier(type);
1590  break;
1591  }
1592 
1593  case AST_ConcreteType::NT_pre_defined:
1594  {
1595  generate_primitive_type_identifier(type);
1596  break;
1597  }
1598 
1599  case AST_ConcreteType::NT_fixed:
1600  case AST_ConcreteType::NT_interface:
1601  case AST_ConcreteType::NT_interface_fwd:
1602  {
1603  fully_desc_type_identifier_map_[type] = OpenDDS::XTypes::TypeIdentifier(OpenDDS::XTypes::TK_NONE);
1604  break;
1605  }
1606 
1607  case AST_ConcreteType::NT_struct_fwd:
1608  case AST_ConcreteType::NT_union_fwd:
1609  case AST_ConcreteType::NT_native:
1610  case AST_ConcreteType::NT_factory:
1611  case AST_ConcreteType::NT_finder:
1612  case AST_ConcreteType::NT_component:
1613  case AST_ConcreteType::NT_component_fwd:
1614  case AST_ConcreteType::NT_home:
1615  case AST_ConcreteType::NT_eventtype:
1616  case AST_ConcreteType::NT_eventtype_fwd:
1617  case AST_ConcreteType::NT_valuebox:
1618  case AST_ConcreteType::NT_type:
1619  case AST_ConcreteType::NT_porttype:
1620  case AST_ConcreteType::NT_provides:
1621  case AST_ConcreteType::NT_uses:
1622  case AST_ConcreteType::NT_publishes:
1623  case AST_ConcreteType::NT_emits:
1624  case AST_ConcreteType::NT_consumes:
1625  case AST_ConcreteType::NT_ext_port:
1626  case AST_ConcreteType::NT_mirror_port:
1627  case AST_ConcreteType::NT_connector:
1628  case AST_ConcreteType::NT_param_holder:
1629  case AST_ConcreteType::NT_annotation_decl:
1630  case AST_ConcreteType::NT_annotation_appl:
1631  case AST_ConcreteType::NT_annotation_member:
1632  case AST_ConcreteType::NT_module:
1633  case AST_ConcreteType::NT_root:
1634  case AST_ConcreteType::NT_valuetype:
1635  case AST_ConcreteType::NT_valuetype_fwd:
1636  case AST_ConcreteType::NT_const:
1637  case AST_ConcreteType::NT_except:
1638  case AST_ConcreteType::NT_attr:
1639  case AST_ConcreteType::NT_op:
1640  case AST_ConcreteType::NT_argument:
1641  case AST_ConcreteType::NT_union_branch:
1642  case AST_ConcreteType::NT_field:
1643  case AST_ConcreteType::NT_enum_val:
1644  be_util::misc_error_and_abort("Unexpected AST type", type);
1645  }
1646 }
1647 
1648 // Get minimal or fully descriptive type identifier
1651 {
1652  switch(type->node_type()) {
1653  case AST_Decl::NT_union_fwd:
1654  {
1655  AST_UnionFwd* const td = dynamic_cast<AST_UnionFwd*>(type);
1656  return get_minimal_type_identifier(td->full_definition());
1657  }
1658  case AST_Decl::NT_struct_fwd:
1659  {
1660  AST_StructureFwd* const td = dynamic_cast<AST_StructureFwd*>(type);
1661  return get_minimal_type_identifier(td->full_definition());
1662  }
1663  default:
1664  break;
1665  }
1666 
1667  if (fully_desc_type_identifier_map_.count(type) != 0) {
1668  return fully_desc_type_identifier_map_[type];
1669  }
1670 
1671  HashTypeIdentifierMap::const_iterator pos = hash_type_identifier_map_.find(type);
1672  OPENDDS_ASSERT(pos != hash_type_identifier_map_.end());
1673  return pos->second.minimal;
1674 }
1675 
1676 // Get complete or fully descriptive type identifier
1679 {
1680  switch(type->node_type()) {
1681  case AST_Decl::NT_union_fwd:
1682  {
1683  AST_UnionFwd* const td = dynamic_cast<AST_UnionFwd*>(type);
1684  return get_complete_type_identifier(td->full_definition());
1685  }
1686  case AST_Decl::NT_struct_fwd:
1687  {
1688  AST_StructureFwd* const td = dynamic_cast<AST_StructureFwd*>(type);
1689  return get_complete_type_identifier(td->full_definition());
1690  }
1691  default:
1692  break;
1693  }
1694 
1695  if (fully_desc_type_identifier_map_.count(type) != 0) {
1696  return fully_desc_type_identifier_map_[type];
1697  }
1698 
1699  HashTypeIdentifierMap::const_iterator pos = hash_type_identifier_map_.find(type);
1700  OPENDDS_ASSERT(pos != hash_type_identifier_map_.end());
1701  return pos->second.complete;
1702 }
1703 
1704 bool
1705 typeobject_generator::generate(AST_Type* node, UTL_ScopedName* name)
1706 {
1707  strong_connect(node, "");
1708 
1709  if (!produce_output_) {
1710  return true;
1711  }
1712 
1713  NamespaceGuard ng;
1714  const string clazz = tag_type(name);
1715 
1716  be_global->header_ << "struct " << clazz << " {};\n";
1717 
1718  const std::string common = " static XTypes::TypeIdentifier ti;\n"
1719  " ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, TheServiceParticipant->get_static_xtypes_lock(), ti);\n"
1720  " if (ti.kind() == XTypes::TK_NONE) {\n";
1721 
1722  {
1723  const string decl = "getMinimalTypeIdentifier<" + clazz + ">";
1724  Function gti(decl.c_str(), "const XTypes::TypeIdentifier&", "");
1725  gti.endArgs();
1726  const OpenDDS::XTypes::TypeIdentifier ti = get_minimal_type_identifier(node);
1727  be_global->impl_ << common <<
1728  " ti = " << ti << ";\n"
1729  " }\n"
1730  " return ti;\n";
1731  }
1732 
1733  declare_get_type_map();
1734  {
1735  const string decl = "getMinimalTypeMap<" + clazz + ">";
1736  Function gti(decl.c_str(), "const XTypes::TypeMap&", "");
1737  gti.endArgs();
1738  be_global->impl_ <<
1739  " return get_minimal_type_map();\n";
1740  }
1741 
1742  if (produce_xtypes_complete_) {
1743  {
1744  const string decl = "getCompleteTypeIdentifier<" + clazz + ">";
1745  Function gti(decl.c_str(), "const XTypes::TypeIdentifier&", "");
1746  gti.endArgs();
1747 
1748  if (produce_xtypes_complete_) {
1749  const OpenDDS::XTypes::TypeIdentifier ti = get_complete_type_identifier(node);
1750  be_global->impl_ << common <<
1751  " ti = " << ti << ";\n"
1752  " }\n"
1753  " return ti;\n";
1754  } else {
1755  be_global->impl_ <<
1756  " static XTypes::TypeIdentifier ti;\n"
1757  " return ti;\n";
1758  }
1759  }
1760 
1761  {
1762  const string decl = "getCompleteTypeMap<" + clazz + ">";
1763  Function gti(decl.c_str(), "const XTypes::TypeMap&", "");
1764  gti.endArgs();
1765  be_global->impl_ <<
1766  " return get_complete_type_map();\n";
1767  }
1768  }
1769 
1770  return true;
1771 }
MemberFlag StructMemberFlag
Definition: TypeObject.h:379
void scope2vector(std::vector< T *> &v, UTL_Scope *s, AST_Decl::NodeType nt)
Definition: dds_visitor.h:141
const TypeKind TK_SEQUENCE
Definition: TypeObject.h:248
CompleteCollectionElement element
Definition: TypeObject.h:2254
MinimalEnumeratedType enumerated_type
Definition: TypeObject.h:3135
External< TypeIdentifier > element_identifier
Definition: TypeObject.h:562
ACE_CDR::ULong MemberId
Definition: TypeObject.h:910
const LogLevel::Value value
Definition: debug.cpp:61
const TypeKind TK_INT32
Definition: TypeObject.h:217
MemberFlag UnionMemberFlag
Definition: TypeObject.h:380
MinimalCollectionHeader header
Definition: TypeObject.h:2283
const TypeKind TK_FLOAT128
Definition: TypeObject.h:224
const Encoding & get_typeobject_encoding()
Definition: TypeObject.cpp:27
CORBA::Boolean operator<<(TAO_OutputCDR &, const CORBA::Object *)
Definition: Object.cpp:321
External< TypeIdentifier > element_identifier
Definition: TypeObject.h:486
const EquivalenceKind EK_BOTH
Definition: TypeObject.h:207
const TypeIdentifierKind TI_STRING8_LARGE
Definition: TypeObject.h:256
size_t length(void) const
bool generate(AST_Type *node, UTL_ScopedName *name)
Iterator begin() const
const TypeKind TK_BYTE
Definition: TypeObject.h:215
const TypeFlag IS_MUTABLE
Definition: TypeObject.h:402
const TypeKind TK_UNION
Definition: TypeObject.h:244
void MD5Hash(MD5Result &result, const void *input, size_t size)
Definition: Hash.cpp:323
CompleteUnionMemberSeq member_seq
Definition: TypeObject.h:1747
const TypeKind TK_INT16
Definition: TypeObject.h:216
void strong_connect(AST_Type *type, const std::string &anonymous_name)
String to_dds_string(unsigned short to_convert)
static std::string get_xtag_name(UTL_ScopedName *name)
const TypeIdentifierKind TI_PLAIN_SEQUENCE_LARGE
Definition: TypeObject.h:261
MinimalCollectionElement element
Definition: TypeObject.h:2407
const MemberFlag IS_MUST_UNDERSTAND
Definition: TypeObject.h:374
TypeFlag UnionTypeFlag
Definition: TypeObject.h:408
const TypeKind TK_UINT16
Definition: TypeObject.h:219
ACE_CDR::UShort BitBound
Definition: TypeObject.h:2478
ACE_CDR::Octet kind() const
Definition: TypeObject.h:748
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
MinimalEnumeratedLiteralSeq literal_seq
Definition: TypeObject.h:2667
PlainCollectionHeader header
Definition: TypeObject.h:524
TryConstructFailAction
Definition: annotations.h:316
CollectionElementFlag element_flags
Definition: TypeObject.h:460
ExtensibilityKind
Definition: annotations.h:278
const TypeIdentifierKind TI_STRING16_LARGE
Definition: TypeObject.h:258
bool is_fully_descriptive(const TypeIdentifier &ti)
Definition: TypeObject.cpp:408
void generate_enum_type_identifier(AST_Type *type)
const_iterator end() const
Definition: TypeObject.h:196
void serialized_size(const Encoding &encoding, size_t &size, const SequenceNumber &)
const MemberFlag TRY_CONSTRUCT2
Definition: TypeObject.h:370
static std::string tag_type(UTL_ScopedName *name)
bool gen_enum(AST_Enum *node, UTL_ScopedName *name, const std::vector< AST_EnumVal *> &contents, const char *repoid)
Members::const_iterator const_iterator
Definition: TypeObject.h:194
char * rd_ptr(void) const
External< TypeIdentifier > element_identifier
Definition: TypeObject.h:544
void generate_primitive_type_identifier(AST_Type *type)
const TypeKind TK_INT8
Definition: TypeObject.h:225
const TypeIdentifierKind TI_STRING8_SMALL
Definition: TypeObject.h:255
CompleteEnumeratedLiteralSeq literal_seq
Definition: TypeObject.h:2638
PlainCollectionHeader header
Definition: TypeObject.h:560
bool gen_struct(AST_Structure *node, UTL_ScopedName *name, const std::vector< AST_Field *> &fields, AST_Type::SIZE_TYPE size, const char *repoid)
CompleteSequenceType sequence_type
Definition: TypeObject.h:2982
const EquivalenceKind EK_COMPLETE
Definition: TypeObject.h:206
TypeFlag EnumTypeFlag
Definition: TypeObject.h:412
const TypeIdentifierKind TI_PLAIN_MAP_LARGE
Definition: TypeObject.h:267
void generate_union_type_identifier(AST_Type *type)
ACE_CDR::UShort MemberFlag
Definition: TypeObject.h:368
const TypeFlag IS_AUTOID_HASH
Definition: TypeObject.h:405
const TypeFlag IS_NESTED
Definition: TypeObject.h:404
const MemberFlag IS_KEY
Definition: TypeObject.h:375
MemberFlag UnionDiscriminatorFlag
Definition: TypeObject.h:381
const MemberFlag TryConstructTrimValue
Definition: TypeObject.h:390
Class to serialize and deserialize data for DDS.
Definition: Serializer.h:369
PlainCollectionHeader header
Definition: TypeObject.h:587
std::string canonical_name(UTL_ScopedName *sn)
const TypeKind TK_BOOLEAN
Definition: TypeObject.h:214
void update_maps(AST_Type *type, const OpenDDS::XTypes::TypeObject &minimal_to, const OpenDDS::XTypes::TypeObject &complete_to)
const TypeIdentifierKind TI_PLAIN_MAP_SMALL
Definition: TypeObject.h:266
MemberFlag CollectionElementFlag
Definition: TypeObject.h:378
unsigned char MD5Result[16]
Definition: Hash.h:21
const TypeIdentifierKind TI_PLAIN_ARRAY_LARGE
Definition: TypeObject.h:264
Christopher Diggins *renamed files *fixing compilation errors *adding Visual C project file *removed make Max Lybbert *removed references to missing and unused header
Definition: CHANGELOG.txt:8
const TypeIdentifierKind TI_PLAIN_ARRAY_SMALL
Definition: TypeObject.h:263
Iterator end() const
bool gen_union(AST_Union *node, UTL_ScopedName *name, const std::vector< AST_UnionBranch *> &branches, AST_Type *type, const char *repoid)
External< TypeIdentifier > element_identifier
Definition: TypeObject.h:526
const TypeFlag IS_FINAL
Definition: TypeObject.h:400
MinimalDiscriminatorMember discriminator
Definition: TypeObject.h:1777
const MemberFlag TryConstructUseDefaultValue
Definition: TypeObject.h:389
DCPS::String equivalence_hash_to_string(const EquivalenceHash &equivalence_hash)
Definition: TypeObject.cpp:33
CompleteStructMemberSeq member_seq
Definition: TypeObject.h:1477
void set_builtin_member_annotations(AST_Decl *member, OpenDDS::XTypes::Optional< OpenDDS::XTypes::AppliedBuiltinMemberAnnotations > &annotations)
ACE_CDR::Octet SBound
Definition: TypeObject.h:317
Optional< AppliedBuiltinMemberAnnotations > ann_builtin
Definition: TypeObject.h:1251
void generate_array_type_identifier(AST_Type *type, bool force_type_object)
CompleteCollectionHeader header
Definition: TypeObject.h:2253
MinimalUnionMemberSeq member_seq
Definition: TypeObject.h:1778
TypeFlag CollectionTypeFlag
Definition: TypeObject.h:409
External< TypeIdentifier > element_identifier
Definition: TypeObject.h:589
void endArgs()
virtual bool node_value_exists(AST_Decl *node, T &value) const
Definition: annotations.h:117
bool skip_sequence_dheader() const
Definition: Serializer.inl:100
const TypeKind TK_CHAR8
Definition: TypeObject.h:227
ACE_UINT32 ULong
void consider(Element &v, AST_Type *type, const std::string &anonymous_name)
const TypeKind TK_STRUCTURE
Definition: TypeObject.h:243
void generate_sequence_type_identifier(AST_Type *type, bool force_type_object)
void hash_member_name(NameHash &name_hash, const OPENDDS_STRING &name)
Definition: TypeObject.cpp:400
const char *const name
Definition: debug.cpp:60
Sequence & append(const T &member)
Definition: TypeObject.h:155
bool gen_typedef(AST_Typedef *node, UTL_ScopedName *name, AST_Type *type, const char *repoid)
const TypeKind TK_FLOAT32
Definition: TypeObject.h:222
MinimalSequenceType sequence_type
Definition: TypeObject.h:3132
OpenDDS::XTypes::TypeIdentifier get_minimal_type_identifier(AST_Type *type)
OpenDDS::XTypes::TypeIdentifier get_complete_type_identifier(AST_Type *type)
ACE_CDR::Octet EquivalenceHash[14]
Definition: TypeObject.h:287
External< TypeIdentifier > key_identifier
Definition: TypeObject.h:591
ACE_INT32 Long
ACE_CDR::Octet EquivalenceKind
Definition: TypeObject.h:204
External< TypeIdentifier > element_identifier
Definition: TypeObject.h:506
ACE_CDR::UShort TypeFlag
Definition: TypeObject.h:399
void generate_alias_type_identifier(AST_Type *type)
CompleteEnumeratedType enumerated_type
Definition: TypeObject.h:2985
const TypeKind TK_UINT64
Definition: TypeObject.h:221
const MemberFlag TRY_CONSTRUCT1
Definition: TypeObject.h:369
const MemberFlag TryConstructDiscardValue
Definition: TypeObject.h:388
MinimalStructMemberSeq member_seq
Definition: TypeObject.h:1505
const TypeKind TK_INT64
Definition: TypeObject.h:218
MinimalCollectionElement element
Definition: TypeObject.h:2284
void generate_type_identifier(AST_Type *type, bool force_type_object)
const MemberFlag IS_OPTIONAL
Definition: TypeObject.h:373
const TypeKind TK_UINT32
Definition: TypeObject.h:220
BE_GlobalData * be_global
Definition: be_global.cpp:44
const TypeKind TK_ALIAS
Definition: TypeObject.h:235
MemberFlag AliasMemberFlag
Definition: TypeObject.h:384
External< TypeIdentifier > key_identifier
Definition: TypeObject.h:564
TypeFlag AliasTypeFlag
Definition: TypeObject.h:411
const TypeIdentifierKind TI_PLAIN_SEQUENCE_SMALL
Definition: TypeObject.h:260
const TypeKind TK_ENUM
Definition: TypeObject.h:238
CollectionElementFlag key_flags
Definition: TypeObject.h:563
MemberFlag EnumeratedLiteralFlag
Definition: TypeObject.h:382
std::ostream & os_
const TypeFlag IS_APPENDABLE
Definition: TypeObject.h:401
const EquivalenceKind EK_MINIMAL
Definition: TypeObject.h:205
const TypeIdentifierKind TI_STRING16_SMALL
Definition: TypeObject.h:257
const MemberFlag IS_DEFAULT
Definition: TypeObject.h:376
const TypeIdentifierKind TI_STRONGLY_CONNECTED_COMPONENT
Definition: TypeObject.h:269
const TypeKind TK_ARRAY
Definition: TypeObject.h:249
const TypeKind TK_UINT8
Definition: TypeObject.h:226
void misc_error_and_abort(const std::string &message, AST_Decl *node=0)
Report a miscellaneous error and abort.
ACE_CDR::ULong LBound
Definition: TypeObject.h:312
TypeFlag StructTypeFlag
Definition: TypeObject.h:407
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)
const TypeKind TK_NONE
Definition: TypeObject.h:213
CompleteCollectionElement element
Definition: TypeObject.h:2377
PlainCollectionHeader header
Definition: TypeObject.h:542
TypeIdentifier makeTypeIdentifier(const TypeObject &type_object, const DCPS::Encoding *encoding_option)
Definition: TypeObject.cpp:254
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
CompleteTypeObject complete
Definition: TypeObject.h:3243
void generate_struct_type_identifier(AST_Type *type)
CompleteDiscriminatorMember discriminator
Definition: TypeObject.h:1746
CollectionElementFlag key_flags
Definition: TypeObject.h:590
AutoidKind
Definition: annotations.h:217
const MemberFlag IS_EXTERNAL
Definition: TypeObject.h:371
CompleteEnumeratedHeader header
Definition: TypeObject.h:2637
const TypeKind TK_CHAR16
Definition: TypeObject.h:228
MinimalTypeObject minimal
Definition: TypeObject.h:3244
const TypeKind TK_FLOAT64
Definition: TypeObject.h:223
MinimalEnumeratedHeader header
Definition: TypeObject.h:2666
void generate(AST_Structure *node)
called directly by dds_visitor::visit_structure() if -Wb,java
const_iterator begin() const
Definition: TypeObject.h:195