9 #include "global_extern.h" 13 #include <utl_identifier.h> 14 #include <utl_labellist.h> 15 #include <ast_fixed.h> 55 AST_Typedef* td =
dynamic_cast<AST_Typedef*
>(it.
type);
65 be_global->itl_ <<
"{ \"kind\" : \"string\", \"note\" : { \"idl\" : { \"type\" : \"wstring\" } } }";
68 be_global->itl_ <<
"{ \"kind\" : \"string\" }";
72 switch (dynamic_cast<AST_PredefinedType*>(it.
type)->pt()) {
73 case AST_PredefinedType::PT_long:
74 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 32 }";
76 case AST_PredefinedType::PT_ulong:
77 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 32, \"unsigned\" : true}";
79 case AST_PredefinedType::PT_longlong:
80 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 64 }";
82 case AST_PredefinedType::PT_ulonglong:
83 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 64, \"unsigned\" : true}";
85 case AST_PredefinedType::PT_short:
86 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 16 }";
88 case AST_PredefinedType::PT_ushort:
89 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 16, \"unsigned\" : true}";
91 case AST_PredefinedType::PT_float:
92 be_global->itl_ <<
"{ \"kind\" : \"float\", \"model\" : \"binary32\" }";
94 case AST_PredefinedType::PT_double:
95 be_global->itl_ <<
"{ \"kind\" : \"float\", \"model\" : \"binary64\" }";
97 case AST_PredefinedType::PT_longdouble:
98 be_global->itl_ <<
"{ \"kind\" : \"float\", \"model\" : \"binary128\" }";
100 case AST_PredefinedType::PT_char:
101 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 8, \"note\" : { \"presentation\" : { \"type\" : \"char\" } } }";
103 case AST_PredefinedType::PT_wchar:
104 be_global->itl_ <<
"{ \"kind\" : \"int\", \"note\" : { \"presentation\" : { \"type\" : \"char\" }, \"idl\" : { \"type\" : \"wchar\" } } }";
106 case AST_PredefinedType::PT_boolean:
107 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 1, \"note\" : { \"presentation\" : { \"type\" : \"bool\" } } }";
109 case AST_PredefinedType::PT_octet:
110 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 8, \"unsigned\" : true, " 111 "\"note\" : { \"presentation\" : { \"type\" : \"byte\" } } }";
113 #if OPENDDS_HAS_EXPLICIT_INTS 114 case AST_PredefinedType::PT_uint8:
115 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 8, \"unsigned\" : true }";
117 case AST_PredefinedType::PT_int8:
118 be_global->itl_ <<
"{ \"kind\" : \"int\", \"bits\" : 8 }";
121 case AST_PredefinedType::PT_any:
122 case AST_PredefinedType::PT_object:
123 case AST_PredefinedType::PT_value:
124 case AST_PredefinedType::PT_abstract:
125 case AST_PredefinedType::PT_void:
126 case AST_PredefinedType::PT_pseudo:
142 <<
Indent(
this) <<
"\"types\" :\n" 163 const std::vector<AST_EnumVal*>& contents,
const char* repoid)
170 <<
Indent(
this) <<
"\"kind\" : \"alias\",\n" 171 <<
Indent(
this) <<
"\"name\" : \"" << repoid <<
"\",\n" 172 <<
Indent(
this) <<
"\"type\" :\n" 176 <<
Indent(
this) <<
"\"kind\" : \"int\",\n" 177 <<
Indent(
this) <<
"\"bits\" : 32,\n" 178 <<
Indent(
this) <<
"\"unsigned\" : true,\n" 179 <<
Indent(
this) <<
"\"constrained\" : true,\n" 180 <<
Indent(
this) <<
"\"values\" : {";
182 for (
size_t i = 0; i < contents.size(); ++i) {
185 be_global->itl_ <<
'"' << contents[i]->local_name()->get_string() <<
'"' 208 switch (base->node_type()) {
209 case AST_Decl::NT_sequence:
211 AST_Sequence *seq =
dynamic_cast<AST_Sequence*
>(base);
215 <<
Indent(
this) <<
"\"kind\" : \"alias\",\n" 216 <<
Indent(
this) <<
"\"name\" : \"" << repoid <<
"\",\n" 217 <<
Indent(
this) <<
"\"type\" :\n" 221 <<
Indent(
this) <<
"\"kind\" : \"sequence\",\n";
222 if (!seq->unbounded()) {
223 be_global->itl_ <<
Indent(
this) <<
"\"capacity\" : " << seq->max_size()->ev()->u.ulval <<
",\n";
234 case AST_Decl::NT_array:
236 AST_Array* arr =
dynamic_cast<AST_Array*
>(base);
240 <<
Indent(
this) <<
"\"kind\" : \"alias\",\n" 241 <<
Indent(
this) <<
"\"name\" : \"" << repoid <<
"\",\n" 242 <<
Indent(
this) <<
"\"type\" :\n" 246 <<
Indent(
this) <<
"\"kind\" : \"sequence\",\n" 248 <<
Indent(
this) <<
"\"size\" : [";
250 for (
size_t i = 0; i < dims; ++i) {
253 be_global->itl_ << arr->dims()[i]->ev()->u.ulval;
264 case AST_Decl::NT_fixed:
266 AST_Fixed* fixed =
dynamic_cast<AST_Fixed*
>(base);
267 unsigned digits = fixed->digits()->ev()->u.ulval;
268 unsigned scale = fixed->scale()->ev()->u.ulval;
271 <<
Indent(
this) <<
"\"kind\" : \"alias\",\n" 272 <<
Indent(
this) <<
"\"name\" : \"" << repoid <<
"\",\n" 273 <<
Indent(
this) <<
"\"type\" : { " 274 <<
"\"kind\" : \"fixed\", " 275 <<
"\"digits\" : " << digits <<
", " 276 <<
"\"scale\" : " << scale <<
", " 277 <<
"\"base\" : 10 }\n" 286 <<
Indent(
this) <<
"\"kind\" : \"alias\",\n" 287 <<
Indent(
this) <<
"\"name\" : \"" << repoid <<
"\",\n" 300 const std::vector<AST_Field*>& fields,
301 AST_Type::SIZE_TYPE,
const char* repoid)
306 const bool is_topic_type =
307 idl_global->is_dcps_type(node->name()) ||
be_global->is_topic_type(node);
314 <<
Indent(
this) <<
"\"kind\" : \"alias\",\n" 315 <<
Indent(
this) <<
"\"name\" : \"" << repoid <<
"\",\n" 318 <<
Indent(
this) <<
"\"note\" : { \"is_dcps_data_type\" : " 319 << (is_topic_type ?
"true" :
"false")
322 <<
Indent(
this) <<
"\"type\" :\n" 326 <<
Indent(
this) <<
"\"kind\" : \"record\",\n" 327 <<
Indent(
this) <<
"\"fields\" :\n" 331 bool comma_flag =
false;
332 for (std::vector<AST_Field*>::const_iterator pos = fields.begin(), limit = fields.end();
335 AST_Field* field = *pos;
342 <<
Indent(
this) <<
"\"name\" : \"" << field->local_name()->get_string() <<
"\",\n" 365 const std::vector<AST_UnionBranch*>& cases,
374 <<
Indent(
this) <<
"\"kind\" : \"alias\",\n" 375 <<
Indent(
this) <<
"\"name\" : \"" << repoid <<
"\",\n" 376 <<
Indent(
this) <<
"\"type\" :\n" 380 <<
Indent(
this) <<
"\"kind\" : \"union\",\n" 382 <<
Indent(
this) <<
"\"note\" : { \"is_dcps_data_type\" : " 383 << (
be_global->is_topic_type(node) ?
"true" :
"false")
385 <<
Indent(
this) <<
"\"fields\" :\n" 389 for (std::vector<AST_UnionBranch*>::const_iterator pos = cases.begin(), limit = cases.end();
392 if (pos != cases.begin())
395 AST_UnionBranch *branch = *pos;
400 <<
Indent(
this) <<
"\"name\" : \"" << branch->local_name()->get_string() <<
"\",\n" 401 <<
Indent(
this) <<
"\"type\" : " <<
InlineType(branch->field_type()) <<
",\n" 403 <<
Indent(
this) <<
"\"labels\" : [";
406 unsigned long count = branch->label_list_length();
407 for (
unsigned long i = 0; i < count; i++)
411 AST_UnionLabel *label = branch->label(i);
412 if (label->label_kind() == AST_UnionLabel::UL_default)
416 be_global->itl_ <<
"\"" << label->label_val()->n()->last_component()->get_string() <<
"\"";
itl_generator * generator
Classification classify(AST_Type *type)
const Classification CL_STRING
bool gen_typedef(AST_Typedef *, UTL_ScopedName *, AST_Type *, const char *)
const Classification CL_WIDE
const Classification CL_PRIMITIVE
bool gen_struct(AST_Structure *node, UTL_ScopedName *name, const std::vector< AST_Field *> &fields, AST_Type::SIZE_TYPE size, const char *repoid)
bool gen_enum(AST_Enum *, UTL_ScopedName *name, const std::vector< AST_EnumVal *> &contents, const char *repoid)
std::ostream & operator<<(std::ostream &out, const itl_generator::Indent &i)
itl_generator * generator
BE_GlobalData * be_global
itl_generator * generator
bool gen_union(AST_Union *, UTL_ScopedName *, const std::vector< AST_UnionBranch *> &, AST_Type *, const char *)