#include <itl_generator.h>
Inheritance diagram for itl_generator:
Public Member Functions | |
itl_generator () | |
bool | do_included_files () const |
void | gen_prologue () |
void | gen_epilogue () |
bool | gen_enum (AST_Enum *, UTL_ScopedName *name, const std::vector< AST_EnumVal * > &contents, const char *repoid) |
bool | gen_struct (AST_Structure *, UTL_ScopedName *name, const std::vector< AST_Field * > &fields, AST_Type::SIZE_TYPE size, const char *repoid) |
bool | gen_typedef (AST_Typedef *, UTL_ScopedName *, AST_Type *, const char *) |
bool | gen_union (AST_Union *, UTL_ScopedName *, const std::vector< AST_UnionBranch * > &, AST_Type *, const char *) |
Public Attributes | |
int | level_ |
Private Member Functions | |
void | new_type () |
Private Attributes | |
size_t | count_ |
Classes | |
struct | Close |
struct | Indent |
struct | Open |
Definition at line 14 of file itl_generator.h.
itl_generator::itl_generator | ( | ) | [inline] |
bool itl_generator::do_included_files | ( | ) | const [inline, virtual] |
bool itl_generator::gen_enum | ( | AST_Enum * | , | |
UTL_ScopedName * | name, | |||
const std::vector< AST_EnumVal * > & | contents, | |||
const char * | repoid | |||
) | [virtual] |
Reimplemented from dds_generator.
Definition at line 150 of file itl_generator.cpp.
References be_global, BE_GlobalData::generate_itl(), BE_GlobalData::itl_, and new_type().
00152 { 00153 if (!be_global->generate_itl()) 00154 return true; 00155 00156 new_type(); 00157 00158 be_global->itl_ << Open(this) 00159 << Indent(this) << "{\n" 00160 << Open(this) 00161 << Indent(this) << "\"kind\" : \"alias\",\n" 00162 << Indent(this) << "\"name\" : \"" << repoid << "\",\n" 00163 << Indent(this) << "\"type\" :\n" 00164 << Open(this) 00165 << Indent(this) << "{\n" 00166 << Open(this) 00167 << Indent(this) << "\"kind\" : \"int\",\n" 00168 << Indent(this) << "\"bits\" : 32,\n" 00169 << Indent(this) << "\"unsigned\" : true,\n" 00170 << Indent(this) << "\"constrained\" : true,\n" 00171 << Indent(this) << "\"values\" : {"; 00172 00173 for (size_t i = 0; i < contents.size(); ++i) { 00174 if (i > 0) 00175 be_global->itl_ << ", "; 00176 be_global->itl_ << '"' << contents[i]->local_name()->get_string() << '"' 00177 << " : " 00178 << '"' << i << '"'; 00179 } 00180 00181 be_global->itl_ << "}\n"; 00182 be_global->itl_ << Close(this) 00183 << Indent(this) << "}\n" 00184 << Close(this); 00185 00186 be_global->itl_ << Close(this) 00187 << Indent(this) << "}\n" 00188 << Close(this); 00189 00190 return true; 00191 }
void itl_generator::gen_epilogue | ( | ) | [virtual] |
Reimplemented from dds_generator.
Definition at line 135 of file itl_generator.cpp.
References be_global, and BE_GlobalData::itl_.
00136 { 00137 be_global->itl_ << Indent(this) << "]\n" 00138 << Close(this) 00139 << Close(this) 00140 << Indent(this) << "}\n"; 00141 }
void itl_generator::gen_prologue | ( | ) | [virtual] |
Reimplemented from dds_generator.
Definition at line 126 of file itl_generator.cpp.
References be_global, and BE_GlobalData::itl_.
00127 { 00128 be_global->itl_ << Indent(this) << "{\n" 00129 << Open(this) 00130 << Indent(this) << "\"types\" :\n" 00131 << Open(this) 00132 << Indent(this) << "[\n"; 00133 }
bool itl_generator::gen_struct | ( | AST_Structure * | , | |
UTL_ScopedName * | name, | |||
const std::vector< AST_Field * > & | fields, | |||
AST_Type::SIZE_TYPE | size, | |||
const char * | repoid | |||
) | [virtual] |
Implements dds_generator.
Definition at line 275 of file itl_generator.cpp.
References be_global, BE_GlobalData::generate_itl(), BE_GlobalData::itl_, and new_type().
00278 { 00279 if (!be_global->generate_itl()) 00280 return true; 00281 00282 new_type(); 00283 be_global->itl_ << Open(this) 00284 << Indent(this) << "{\n" 00285 << Open(this) 00286 << Indent(this) << "\"kind\" : \"alias\",\n" 00287 << Indent(this) << "\"name\" : \"" << repoid << "\",\n" 00288 << Indent(this) << "\"type\" :\n" 00289 << Open(this) 00290 << Indent(this) << "{\n" 00291 << Open(this) 00292 << Indent(this) << "\"kind\" : \"record\",\n" 00293 << Indent(this) << "\"fields\" :\n" 00294 << Open(this) 00295 << Indent(this) << "[\n"; 00296 00297 bool comma_flag = false; 00298 for (std::vector<AST_Field*>::const_iterator pos = fields.begin(), limit = fields.end(); 00299 pos != limit; 00300 ++pos) { 00301 AST_Field* field = *pos; 00302 if (comma_flag) { 00303 be_global->itl_ << Indent(this) << ",\n"; 00304 } 00305 be_global->itl_ << Open(this) 00306 << Indent(this) << "{\n" 00307 << Open(this) 00308 << Indent(this) << "\"name\" : \"" << field->local_name()->get_string() << "\",\n" 00309 << Indent(this) << "\"type\" : " << InlineType(field->field_type()) << "\n" 00310 << Close(this) 00311 << Indent(this) << "}\n" 00312 << Close(this); 00313 comma_flag = true; 00314 } 00315 00316 be_global->itl_ << Indent(this) << "]\n" 00317 << Close(this) 00318 << Close(this) 00319 << Indent(this) << "}\n" 00320 << Close(this) 00321 << Close(this) 00322 << Indent(this) << "}\n" 00323 << Close(this); 00324 00325 00326 return true; 00327 }
bool itl_generator::gen_typedef | ( | AST_Typedef * | , | |
UTL_ScopedName * | , | |||
AST_Type * | , | |||
const char * | ||||
) | [virtual] |
Implements dds_generator.
Definition at line 193 of file itl_generator.cpp.
References be_global, BE_GlobalData::generate_itl(), BE_GlobalData::itl_, and new_type().
00196 { 00197 if (!be_global->generate_itl()) 00198 return true; 00199 00200 new_type(); 00201 switch (base->node_type()) { 00202 case AST_Decl::NT_sequence: 00203 { 00204 AST_Sequence *seq = AST_Sequence::narrow_from_decl(base); 00205 be_global->itl_ << Open(this) 00206 << Indent(this) << "{\n" 00207 << Open(this) 00208 << Indent(this) << "\"kind\" : \"alias\",\n" 00209 << Indent(this) << "\"name\" : \"" << repoid << "\",\n" 00210 << Indent(this) << "\"type\" :\n" 00211 << Open(this) 00212 << Indent(this) << "{\n" 00213 << Open(this) 00214 << Indent(this) << "\"kind\" : \"sequence\",\n"; 00215 if (!seq->unbounded()) { 00216 be_global->itl_ << Indent(this) << "\"capacity\" : " << seq->max_size()->ev()->u.ulval << ",\n"; 00217 } 00218 be_global->itl_ << Indent(this) << "\"type\" : " << InlineType(seq->base_type()) << "\n" 00219 << Close(this) 00220 << Indent(this) << "}\n" 00221 << Close(this) 00222 << Close(this) 00223 << Indent(this) << "}\n" 00224 << Close(this); 00225 break; 00226 } 00227 case AST_Decl::NT_array: 00228 { 00229 AST_Array* arr = AST_Array::narrow_from_decl(base); 00230 be_global->itl_ << Open(this) 00231 << Indent(this) << "{\n" 00232 << Open(this) 00233 << Indent(this) << "\"kind\" : \"alias\",\n" 00234 << Indent(this) << "\"name\" : \"" << repoid << "\",\n" 00235 << Indent(this) << "\"type\" :\n" 00236 << Open(this) 00237 << Indent(this) << "{\n" 00238 << Open(this) 00239 << Indent(this) << "\"kind\" : \"sequence\",\n" 00240 << Indent(this) << "\"type\" : " << InlineType(arr->base_type()) << ",\n" 00241 << Indent(this) << "\"size\" : ["; 00242 ACE_CDR::ULong dims = arr->n_dims(); 00243 for (size_t i = 0; i < dims; ++i) { 00244 if (i > 0) 00245 be_global->itl_ << ", "; 00246 be_global->itl_ << arr->dims()[i]->ev()->u.ulval; 00247 } 00248 be_global->itl_ << "]\n" 00249 << Close(this) 00250 << Indent(this) << "}\n" 00251 << Close(this) 00252 << Close(this) 00253 << Indent(this) << "}\n" 00254 << Close(this); 00255 break; 00256 } 00257 default: 00258 { 00259 be_global->itl_ << Open(this) 00260 << Indent(this) << "{\n" 00261 << Open(this) 00262 << Indent(this) << "\"kind\" : \"alias\",\n" 00263 << Indent(this) << "\"name\" : \"" << repoid << "\",\n" 00264 << Indent(this) << "\"type\" : " << InlineType(base) << "\n" 00265 << Close(this) 00266 << Indent(this) << "}\n" 00267 << Close(this); 00268 00269 return true; 00270 } 00271 } 00272 return true; 00273 }
bool itl_generator::gen_union | ( | AST_Union * | , | |
UTL_ScopedName * | , | |||
const std::vector< AST_UnionBranch * > & | , | |||
AST_Type * | , | |||
const char * | ||||
) | [virtual] |
Implements dds_generator.
Definition at line 330 of file itl_generator.cpp.
References be_global, BE_GlobalData::generate_itl(), BE_GlobalData::itl_, and new_type().
00334 { 00335 if (!be_global->generate_itl()) 00336 return true; 00337 00338 new_type(); 00339 be_global->itl_ << Open(this) 00340 << Indent(this) << "{\n" 00341 << Open(this) 00342 << Indent(this) << "\"kind\" : \"alias\",\n" 00343 << Indent(this) << "\"name\" : \"" << repoid << "\",\n" 00344 << Indent(this) << "\"type\" :\n" 00345 << Open(this) 00346 << Indent(this) << "{\n" 00347 << Open(this) 00348 << Indent(this) << "\"kind\" : \"union\",\n" 00349 << Indent(this) << "\"discriminator\" : " << InlineType(_d) << ",\n" 00350 << Indent(this) << "\"fields\" :\n" 00351 << Open(this) 00352 << Indent(this) << "[\n"; 00353 00354 for (std::vector<AST_UnionBranch*>::const_iterator pos = cases.begin(), limit = cases.end(); 00355 pos != limit; 00356 ++pos) { 00357 if (pos != cases.begin()) 00358 be_global->itl_ << Indent(this) << ",\n"; 00359 00360 AST_UnionBranch *branch = *pos; 00361 00362 be_global->itl_ << Open(this) 00363 << Indent(this) << "{\n" 00364 << Open(this) 00365 << Indent(this) << "\"name\" : \"" << branch->local_name()->get_string() << "\",\n" 00366 << Indent(this) << "\"type\" : " << InlineType(branch->field_type()) << ",\n" 00367 00368 << Indent(this) << "\"labels\" : ["; 00369 00370 00371 unsigned long count = branch->label_list_length(); 00372 for (unsigned long i = 0; i < count; i++) 00373 { 00374 if (i > 0) 00375 be_global->itl_ << ", "; 00376 AST_UnionLabel *label = branch->label(i); 00377 if (label->label_kind() == AST_UnionLabel::UL_default) 00378 { 00379 continue; 00380 } 00381 be_global->itl_ << "\"" << label->label_val()->n()->last_component()->get_string() << "\""; 00382 } 00383 00384 be_global->itl_ << "]\n" 00385 << Close(this) 00386 << Indent(this) << "}\n" 00387 << Close(this); 00388 } 00389 00390 be_global->itl_ << Indent(this) << "]\n" 00391 << Close(this) 00392 << Close(this) 00393 << Indent(this) << "}\n" 00394 << Close(this) 00395 << Close(this) 00396 << Indent(this) << "}\n" 00397 << Close(this); 00398 00399 return true; 00400 }
void itl_generator::new_type | ( | ) | [private] |
Definition at line 143 of file itl_generator.cpp.
References be_global, count_, and BE_GlobalData::itl_.
Referenced by gen_enum(), gen_struct(), gen_typedef(), and gen_union().
00144 { 00145 if (count_ > 0) 00146 be_global->itl_ << Indent(this) << ",\n"; 00147 ++count_; 00148 }
size_t itl_generator::count_ [private] |