OpenDDS  Snapshot(2023/04/28-20:55)
Classes | Functions
itl_generator.cpp File Reference
#include "itl_generator.h"
#include "be_extern.h"
#include "global_extern.h"
#include <dds/DCPS/Definitions.h>
#include <utl_identifier.h>
#include <utl_labellist.h>
#include <ast_fixed.h>
Include dependency graph for itl_generator.cpp:

Go to the source code of this file.

Classes

struct  InlineType
 

Functions

std::ostreamoperator<< (std::ostream &out, const itl_generator::Indent &i)
 
std::ostreamoperator<< (std::ostream &out, const itl_generator::Open &i)
 
std::ostreamoperator<< (std::ostream &out, const itl_generator::Close &i)
 
std::ostreamoperator<< (std::ostream &out, const InlineType &it)
 

Function Documentation

◆ operator<<() [1/4]

std::ostream& operator<< ( std::ostream out,
const itl_generator::Indent i 
)

Definition at line 20 of file itl_generator.cpp.

References itl_generator::Indent::generator, and itl_generator::level_.

22 {
23  out << std::string(static_cast<size_t> (i.generator->level_ * 2), ' ');
24  return out;
25 }
itl_generator * generator
Definition: itl_generator.h:55

◆ operator<<() [2/4]

std::ostream& operator<< ( std::ostream out,
const itl_generator::Open i 
)

Definition at line 28 of file itl_generator.cpp.

References itl_generator::Open::generator, and itl_generator::level_.

30 {
31  i.generator->level_ += 1;
32  return out;
33 }
itl_generator * generator
Definition: itl_generator.h:39

◆ operator<<() [3/4]

std::ostream& operator<< ( std::ostream out,
const itl_generator::Close i 
)

Definition at line 36 of file itl_generator.cpp.

References itl_generator::Close::generator, and itl_generator::level_.

38 {
39  i.generator->level_ -= 1;
40  return out;
41 }
itl_generator * generator
Definition: itl_generator.h:47

◆ operator<<() [4/4]

std::ostream& operator<< ( std::ostream out,
const InlineType it 
)

Definition at line 52 of file itl_generator.cpp.

References be_global, AstTypeClassification::CL_PRIMITIVE, AstTypeClassification::CL_STRING, AstTypeClassification::CL_WIDE, AstTypeClassification::classify(), and InlineType::type.

54 {
55  AST_Typedef* td = dynamic_cast<AST_Typedef*>(it.type);
56  if (td) {
57  be_global->itl_ << '"' << it.type->repoID() << '"';
58  return out;
59  }
60 
62  if (c & CL_STRING) {
63  // TODO: Support bounded strings.
64  if (c & CL_WIDE) {
65  be_global->itl_ << "{ \"kind\" : \"string\", \"note\" : { \"idl\" : { \"type\" : \"wstring\" } } }";
66  }
67  else {
68  be_global->itl_ << "{ \"kind\" : \"string\" }";
69  }
70  }
71  else if (c & CL_PRIMITIVE) {
72  switch (dynamic_cast<AST_PredefinedType*>(it.type)->pt()) {
73  case AST_PredefinedType::PT_long:
74  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 32 }";
75  break;
76  case AST_PredefinedType::PT_ulong:
77  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 32, \"unsigned\" : true}";
78  break;
79  case AST_PredefinedType::PT_longlong:
80  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 64 }";
81  break;
82  case AST_PredefinedType::PT_ulonglong:
83  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 64, \"unsigned\" : true}";
84  break;
85  case AST_PredefinedType::PT_short:
86  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 16 }";
87  break;
88  case AST_PredefinedType::PT_ushort:
89  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 16, \"unsigned\" : true}";
90  break;
91  case AST_PredefinedType::PT_float:
92  be_global->itl_ << "{ \"kind\" : \"float\", \"model\" : \"binary32\" }";
93  break;
94  case AST_PredefinedType::PT_double:
95  be_global->itl_ << "{ \"kind\" : \"float\", \"model\" : \"binary64\" }";
96  break;
97  case AST_PredefinedType::PT_longdouble:
98  be_global->itl_ << "{ \"kind\" : \"float\", \"model\" : \"binary128\" }";
99  break;
100  case AST_PredefinedType::PT_char:
101  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 8, \"note\" : { \"presentation\" : { \"type\" : \"char\" } } }";
102  break;
103  case AST_PredefinedType::PT_wchar:
104  be_global->itl_ << "{ \"kind\" : \"int\", \"note\" : { \"presentation\" : { \"type\" : \"char\" }, \"idl\" : { \"type\" : \"wchar\" } } }";
105  break;
106  case AST_PredefinedType::PT_boolean:
107  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 1, \"note\" : { \"presentation\" : { \"type\" : \"bool\" } } }";
108  break;
109  case AST_PredefinedType::PT_octet:
110  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 8, \"unsigned\" : true, "
111  "\"note\" : { \"presentation\" : { \"type\" : \"byte\" } } }";
112  break;
113 #if OPENDDS_HAS_EXPLICIT_INTS
114  case AST_PredefinedType::PT_uint8:
115  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 8, \"unsigned\" : true }";
116  break;
117  case AST_PredefinedType::PT_int8:
118  be_global->itl_ << "{ \"kind\" : \"int\", \"bits\" : 8 }";
119  break;
120 #endif
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:
127  // TODO
128  break;
129  }
130  }
131  else {
132  be_global->itl_ << '"' << it.type->repoID() << '"';
133  }
134 
135  return out;
136 }
Classification classify(AST_Type *type)
const Classification CL_STRING
const Classification CL_WIDE
const Classification CL_PRIMITIVE
AST_Type * type
BE_GlobalData * be_global
Definition: be_global.cpp:44