67 #include "global_extern.h" 73 #include "utl_string.h" 79 #include "../Version.h" 97 idl_global->destroy();
113 string to_macro(
const char* fn)
115 string ret =
"OPENDDS_IDL_GENERATED_";
117 for (
size_t i = 0; i <
strlen(fn); ++i) {
118 if (isalnum(fn[i])) {
119 ret +=
static_cast<char>(toupper(fn[i]));
120 }
else if (ret[ret.size() - 1] !=
'_') {
129 const size_t NUM_CHARS = 6;
137 unsigned int seed =
static_cast<unsigned int>(msec);
139 if (ret[ret.size() - 1] !=
'_') ret +=
'_';
140 static const char alphanum[] =
142 "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
144 for (
unsigned int n = 0; n < NUM_CHARS; ++n) {
152 string to_header(
const char* cpp_name)
154 size_t len =
strlen(cpp_name);
156 string base_name(cpp_name, len - 4);
157 return base_name +
".h";
160 void postprocess(
const char* fn, ostringstream& content,
161 BE_GlobalData::stream_enum_t which)
165 if (which == BE_GlobalData::STREAM_H ||
166 which == BE_GlobalData::STREAM_LANG_H) {
167 out <<
"/* -*- C++ -*- */\n";
170 out <<
"/* Generated by " << idl_global->prog_name()
172 <<
") running on input file " 173 << idl_global->main_filename()->get_string()
180 case BE_GlobalData::STREAM_H:
181 case BE_GlobalData::STREAM_FACETS_H:
182 case BE_GlobalData::STREAM_LANG_H: {
183 macrofied = to_macro(fn);
184 out <<
"#ifndef " << macrofied <<
"\n#define " << macrofied <<
'\n';
185 if (which == BE_GlobalData::STREAM_H) {
188 "#include <dds/Version.h>\n" 192 "# error \"This file should be regenerated with opendds_idl\"\n" 194 "#include <dds/DCPS/Definitions.h>\n" 196 "#include <dds/DdsDcpsC.h>\n" 199 if (which == BE_GlobalData::STREAM_LANG_H) {
200 if (
be_global->language_mapping() == BE_GlobalData::LANGMAP_FACE_CXX ||
201 be_global->language_mapping() == BE_GlobalData::LANGMAP_SP_CXX) {
203 "#include <tao/orbconf.h>\n" 204 "#include <tao/Basic_Types_IDLv4.h>\n" 205 "TAO_BEGIN_VERSIONED_NAMESPACE_DECL\n" 206 "namespace CORBA {\n" 207 " using namespace IDLv4;\n" 209 "TAO_END_VERSIONED_NAMESPACE_DECL\n";
213 taoheader.replace(taoheader.find(
"TypeSupportImpl.h"), 17,
"C.h");
215 && (taoheader ==
"Int8SeqC.h" || taoheader ==
"UInt8SeqC.h");
218 out <<
"#if OPENDDS_HAS_EXPLICIT_INTS\n";
221 out <<
"#" << indent <<
"include \"" <<
be_global->tao_inc_pre_ << taoheader <<
"\"\n";
228 case BE_GlobalData::STREAM_CPP: {
231 out <<
"#include \"" << pch <<
"\"\n";
234 string header = to_header(fn);
235 out <<
"#include \"" << header <<
"\"\n\n";
237 out <<
"#include \"" <<
be_global->header_name_.
c_str() <<
"\"\n\n";
241 case BE_GlobalData::STREAM_FACETS_CPP: {
244 out <<
"#include \"" << pch <<
"\"\n";
246 out <<
"#include \"" <<
be_global->facets_header_name_.
c_str() <<
"\"\n" 248 "#include \"dds/FACE/FaceTSS.h\"\n\n" 249 "namespace FACE { namespace TS {\n\n";
252 case BE_GlobalData::STREAM_IDL: {
253 macrofied = to_macro(fn);
254 out <<
"#ifndef " << macrofied <<
"\n#define " << macrofied <<
'\n';
256 #ifdef ACE_HAS_CDR_FIXED 257 out <<
"#define __OPENDDS_IDL_HAS_FIXED\n";
261 const size_t idx = filebase.find_last_of(
"/\\");
262 if (idx != string::npos) {
263 filebase = filebase.substr(idx + 1);
265 out <<
"#include \"" << filebase <<
"\"\n\n";
272 out <<
be_global->get_include_block(which);
274 out << content.str();
277 case BE_GlobalData::STREAM_H:
278 case BE_GlobalData::STREAM_IDL:
279 case BE_GlobalData::STREAM_FACETS_H:
280 case BE_GlobalData::STREAM_LANG_H:
281 out <<
"#endif /* " << macrofied <<
" */\n";
283 case BE_GlobalData::STREAM_FACETS_CPP:
290 if (!BE_GlobalData::writeFile(fn, out.str())) {
301 const char* idl_fn = idl_global->main_filename()->get_string();
304 const BE_GlobalData::stream_enum_t out_stream =
305 be_global->language_mapping() == BE_GlobalData::LANGMAP_NONE
306 ? BE_GlobalData::STREAM_H : BE_GlobalData::STREAM_LANG_H;
308 ifstream idl(idl_fn);
309 const size_t buffer_sz = 512;
310 char buffer[buffer_sz];
314 idl.getline(buffer, buffer_sz);
318 if (0 ==
strncmp(
"#include", buffer, 8)) {
319 string inc(buffer + 8);
320 size_t delim1 = inc.find_first_of(
"<\"");
321 size_t delim2 = inc.find_first_of(
">\"", delim1 + 1);
322 string included(inc, delim1 + 1, delim2 - delim1 - 1);
323 size_t len = included.size();
328 base_name.assign(included.c_str(), len - 4);
330 }
else if (len >= 6 &&
332 base_name.assign(included.c_str(), len - 5);
338 if (
be_global->language_mapping() == BE_GlobalData::LANGMAP_SP_CXX &&
339 base_name.substr(0, 4) ==
"tao/" &&
340 base_name.substr(base_name.size() - 3) ==
"Seq") {
344 string stb_inc = base_name +
"C.h";
345 if (stb_inc !=
"tao/orbC.h") {
346 be_global->add_include(stb_inc.c_str(), out_stream);
347 if (stb_inc ==
"orbC.h" ||
349 && stb_inc.substr(stb_inc.size() - 7) ==
"/orbC.h") ) {
351 "Potential inclusion of TAO orbC.h\n" 352 " Include TAO orb.idl with path of tao/orb.idl" 353 " to prevent compilation errors",
365 AST_Decl* d = idl_global->root();
366 AST_Root* root =
dynamic_cast<AST_Root*
>(d);
376 be_global->set_inc_paths(idl_global->idl_flags());
382 if (root->ast_accept(&visitor) == -1) {
385 ACE_TEXT(
" failed to accept adding visitor\n")));
391 be_global->header_, BE_GlobalData::STREAM_H);
394 be_global->idl_, BE_GlobalData::STREAM_IDL);
399 be_global->impl_, BE_GlobalData::STREAM_CPP);
409 BE_GlobalData::STREAM_FACETS_H);
411 BE_GlobalData::STREAM_FACETS_CPP);
414 if (
be_global->language_mapping() != BE_GlobalData::LANGMAP_NONE) {
416 BE_GlobalData::STREAM_LANG_H);
const char * filename(void) const
#define OPENDDS_MICRO_VERSION
const char * c_str(void) const
int strncmp(const char *s, const char *t, size_t len)
void exit(int status=0) ACE_GCC_NO_RETURN
ACE_thread_t thr_self(void)
size_t strlen(const char *s)
Christopher Diggins *renamed files *fixing compilation errors *adding Visual C project file *removed make Max Lybbert *removed references to missing and unused header
#define OPENDDS_MINOR_VERSION
#define OPENDDS_MAJOR_VERSION
unsigned long long ACE_UINT64
unsigned long msec(void) const
int strcasecmp(const char *s, const char *t)
BE_GlobalData * be_global
ACE_Time_Value gettimeofday(void)
size_type length(void) const
int rand_r(unsigned int *seed)