00001
00002
00003
00004
00005
00006
00007
00008 #include "dds_generator.h"
00009
00010 #include "utl_identifier.h"
00011
00012 using namespace std;
00013
00014 dds_generator::~dds_generator() {}
00015
00016 string dds_generator::scoped_helper(UTL_ScopedName* sn, const char* sep)
00017 {
00018 string sname;
00019
00020 for (; sn; sn = static_cast<UTL_ScopedName*>(sn->tail())) {
00021 if (sn->head()->escaped())
00022 sname += "_";
00023
00024 sname += sn->head()->get_string();
00025
00026 if (sname != "" && sn->tail())
00027 sname += sep;
00028 }
00029
00030 return sname;
00031 }
00032
00033 string dds_generator::module_scope_helper(UTL_ScopedName* sn, const char* sep)
00034 {
00035 string sname;
00036
00037 for (; sn; sn = static_cast<UTL_ScopedName*>(sn->tail())) {
00038 if (sn->tail() != 0) {
00039 if (sn->head()->escaped())
00040 sname += "_";
00041
00042 sname += sn->head()->get_string();
00043
00044 if (sname != "" && sn->tail())
00045 sname += sep;
00046 }
00047 }
00048
00049 return sname;
00050 }
00051
00052 void composite_generator::gen_prologue()
00053 {
00054 for (vector<dds_generator*>::iterator it(components_.begin());
00055 it != components_.end(); ++it) {
00056 (*it)->gen_prologue();
00057 }
00058 }
00059
00060 void composite_generator::gen_epilogue()
00061 {
00062 for (vector<dds_generator*>::iterator it(components_.begin());
00063 it != components_.end(); ++it) {
00064 (*it)->gen_epilogue();
00065 }
00066 }
00067
00068 bool composite_generator::gen_const(UTL_ScopedName* name, bool nestedInInteface,
00069 AST_Constant* constant)
00070 {
00071 for (vector<dds_generator*>::iterator it(components_.begin());
00072 it != components_.end(); ++it) {
00073 if (!constant->imported() || (*it)->do_included_files())
00074 if (!(*it)->gen_const(name, nestedInInteface, constant))
00075 return false;
00076 }
00077
00078 return true;
00079 }
00080
00081 bool composite_generator::gen_enum(AST_Enum* node, UTL_ScopedName* name,
00082 const std::vector<AST_EnumVal*>& contents, const char* repoid)
00083 {
00084 for (vector<dds_generator*>::iterator it(components_.begin());
00085 it != components_.end(); ++it) {
00086 if (!node->imported() || (*it)->do_included_files())
00087 if (!(*it)->gen_enum(node, name, contents, repoid))
00088 return false;
00089 }
00090
00091 return true;
00092 }
00093
00094 bool composite_generator::gen_struct(AST_Structure* node, UTL_ScopedName* name,
00095 const vector<AST_Field*>& fields, AST_Type::SIZE_TYPE size,
00096 const char* repoid)
00097 {
00098 for (vector<dds_generator*>::iterator it(components_.begin());
00099 it != components_.end(); ++it) {
00100 if (!node->imported() || (*it)->do_included_files())
00101 if (!(*it)->gen_struct(node, name, fields, size, repoid))
00102 return false;
00103 }
00104
00105 return true;
00106 }
00107
00108 bool composite_generator::gen_struct_fwd(UTL_ScopedName* name,
00109 AST_Type::SIZE_TYPE size)
00110 {
00111 for (vector<dds_generator*>::iterator it(components_.begin());
00112 it != components_.end(); ++it) {
00113 if (!(*it)->gen_struct_fwd(name, size))
00114 return false;
00115 }
00116
00117 return true;
00118 }
00119
00120 bool composite_generator::gen_typedef(AST_Typedef* node, UTL_ScopedName* name, AST_Type* base,
00121 const char* repoid)
00122 {
00123 for (vector<dds_generator*>::iterator it(components_.begin());
00124 it != components_.end(); ++it) {
00125 if (!node->imported() || (*it)->do_included_files())
00126 if (!(*it)->gen_typedef(node, name, base, repoid))
00127 return false;
00128 }
00129
00130 return true;
00131 }
00132
00133 bool composite_generator::gen_interf(AST_Interface* node, UTL_ScopedName* name, bool local,
00134 const std::vector<AST_Interface*>& inherits,
00135 const std::vector<AST_Interface*>& inh_flat,
00136 const std::vector<AST_Attribute*>& attrs,
00137 const std::vector<AST_Operation*>& ops, const char* repoid)
00138 {
00139 for (vector<dds_generator*>::iterator it(components_.begin());
00140 it != components_.end(); ++it) {
00141 if (!node->imported() || (*it)->do_included_files())
00142 if (!(*it)->gen_interf(node, name, local, inherits, inh_flat,
00143 attrs, ops, repoid))
00144 return false;
00145 }
00146
00147 return true;
00148 }
00149
00150 bool composite_generator::gen_interf_fwd(UTL_ScopedName* name)
00151 {
00152 for (vector<dds_generator*>::iterator it(components_.begin());
00153 it != components_.end(); ++it) {
00154 if (!(*it)->gen_interf_fwd(name))
00155 return false;
00156 }
00157
00158 return true;
00159 }
00160
00161 bool composite_generator::gen_native(AST_Native* node, UTL_ScopedName* name, const char* repoid)
00162 {
00163 for (vector<dds_generator*>::iterator it(components_.begin());
00164 it != components_.end(); ++it) {
00165 if (!node->imported() || (*it)->do_included_files())
00166 if (!(*it)->gen_native(node, name, repoid))
00167 return false;
00168 }
00169
00170 return true;
00171 }
00172
00173 bool composite_generator::gen_union(AST_Union* node,
00174 UTL_ScopedName* name,
00175 const std::vector<AST_UnionBranch*>& branches,
00176 AST_Type* discriminator,
00177 const char* repoid)
00178 {
00179 for (vector<dds_generator*>::iterator it(components_.begin());
00180 it != components_.end(); ++it) {
00181 if (!node->imported() || (*it)->do_included_files())
00182 if (!(*it)->gen_union(node, name, branches, discriminator, repoid))
00183 return false;
00184 }
00185
00186 return true;
00187 }
00188
00189 bool composite_generator::gen_union_fwd(AST_UnionFwd* uf, UTL_ScopedName* name,
00190 AST_Type::SIZE_TYPE size)
00191 {
00192 for (vector<dds_generator*>::iterator it(components_.begin());
00193 it != components_.end(); ++it) {
00194 if (!(*it)->gen_union_fwd(uf, name, size))
00195 return false;
00196 }
00197
00198 return true;
00199 }