#include "global_extern.h"
#include "be_extern.h"
#include "dds_visitor.h"
#include "ast_root.h"
#include "utl_string.h"
#include "ace/OS_NS_strings.h"
#include "ace/OS_NS_sys_time.h"
#include "ace/OS_NS_unistd.h"
#include "../Version.h"
#include "ace/Version.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <limits>
#include <cassert>
Go to the source code of this file.
Functions | |
void | BE_cleanup () |
void | BE_abort () |
void | BE_produce () |
void BE_abort | ( | void | ) |
Definition at line 101 of file be_produce.cpp.
References ACE_TEXT(), BE_cleanup(), ACE_OS::exit(), and LM_ERROR.
Referenced by BE_produce().
00102 { 00103 ACE_ERROR((LM_ERROR, ACE_TEXT("Fatal Error - Aborting\n"))); 00104 BE_cleanup(); 00105 ACE_OS::exit(1); 00106 }
void BE_cleanup | ( | void | ) |
Definition at line 94 of file be_produce.cpp.
Referenced by BE_abort(), and BE_produce().
void BE_produce | ( | void | ) |
Definition at line 284 of file be_produce.cpp.
References ACE_TEXT(), BE_abort(), BE_cleanup(), be_global, ACE_String_Base< ACE_CHAR_T >::c_str(), ACE_String_Base< ACE_CHAR_T >::length(), LM_ERROR, LM_WARNING, ACE_OS::strcasecmp(), and strncmp().
00285 { 00286 //search for #includes in the IDL, add them as #includes in the stubs/skels 00287 const char* idl_fn = idl_global->main_filename()->get_string(); 00288 00289 const BE_GlobalData::stream_enum_t out_stream = 00290 be_global->language_mapping() == BE_GlobalData::LANGMAP_NONE 00291 ? BE_GlobalData::STREAM_H : BE_GlobalData::STREAM_LANG_H; 00292 00293 ifstream idl(idl_fn); 00294 const size_t buffer_sz = 512; 00295 char buffer[buffer_sz]; 00296 00297 while (idl) { 00298 idl.getline(buffer, buffer_sz); 00299 00300 if (0 == strncmp("#include", buffer, 8)) { //FUTURE: account for comments? 00301 string inc(buffer + 8); 00302 size_t delim1 = inc.find_first_of("<\""); 00303 size_t delim2 = inc.find_first_of(">\"", delim1 + 1); 00304 string included(inc, delim1 + 1, delim2 - delim1 - 1); 00305 size_t len = included.size(); 00306 string base_name; 00307 00308 if (len >= 5 && 00309 0 == ACE_OS::strcasecmp(included.c_str() + len - 4, ".idl")) { 00310 base_name.assign(included.c_str(), len - 4); 00311 00312 } else if (len >= 6 && 00313 0 == ACE_OS::strcasecmp(included.c_str() + len - 5, ".pidl")) { 00314 base_name.assign(included.c_str(), len - 5); 00315 00316 } else { 00317 ACE_ERROR((LM_ERROR, ACE_TEXT("(%N:%l) BE_produce - included ") 00318 ACE_TEXT("file must end in .idl or .pidl\n"))); 00319 BE_abort(); 00320 } 00321 00322 string stb_inc = base_name + "C.h"; 00323 if (stb_inc != "tao/orbC.h") { 00324 be_global->add_include(stb_inc.c_str(), out_stream); 00325 if (stb_inc == "orbC.h" || 00326 (stb_inc.size() >= 7 00327 && stb_inc.substr(stb_inc.size() - 7) == "/orbC.h") ) { 00328 ACE_DEBUG((LM_WARNING, 00329 ACE_TEXT("Warning: (%s) Potential inclusion of TAO orbC.H ") 00330 ACE_TEXT(" Include TAO orb.idl with path of tao/orb.idl") 00331 ACE_TEXT(" to prevent compilation errors\n"), idl_fn)); 00332 } 00333 } 00334 00335 } 00336 } 00337 00338 idl.close(); 00339 00340 be_global->open_streams(idl_fn); 00341 00342 AST_Decl* d = idl_global->root(); 00343 AST_Root* root = AST_Root::narrow_from_decl(d); 00344 00345 if (root == 0) { 00346 ACE_ERROR((LM_ERROR, 00347 ACE_TEXT("(%N:%l) BE_produce - ") 00348 ACE_TEXT("No Root\n"))); 00349 00350 BE_abort(); 00351 } 00352 00353 be_global->set_inc_paths(idl_global->idl_flags()); 00354 00355 const bool java_ts_only = be_global->java_arg().length() > 0; 00356 00357 dds_visitor visitor(d, java_ts_only); 00358 00359 if (root->ast_accept(&visitor) == -1) { 00360 ACE_ERROR((LM_ERROR, 00361 ACE_TEXT("(%N:%l) BE_produce -") 00362 ACE_TEXT(" failed to accept adding visitor\n"))); 00363 BE_abort(); 00364 } 00365 00366 if (!java_ts_only) { 00367 postprocess(be_global->header_name_.c_str(), 00368 be_global->header_, BE_GlobalData::STREAM_H); 00369 if (!be_global->suppress_idl()) { 00370 postprocess(be_global->idl_name_.c_str(), 00371 be_global->idl_, BE_GlobalData::STREAM_IDL); 00372 } 00373 } 00374 00375 postprocess(be_global->impl_name_.c_str(), 00376 be_global->impl_, BE_GlobalData::STREAM_CPP); 00377 00378 if (be_global->generate_wireshark()) { 00379 postprocess(be_global->ws_config_name_.c_str(), 00380 be_global->ws_config_, BE_GlobalData::STREAM_WS); 00381 } 00382 00383 if (be_global->generate_itl()) { 00384 if (!BE_GlobalData::writeFile(be_global->itl_name_.c_str(), be_global->itl_.str())) { 00385 BE_abort(); //error message already printed 00386 } 00387 } 00388 00389 if (be_global->face_ts()) { 00390 postprocess(be_global->facets_header_name_.c_str(), be_global->facets_header_, 00391 BE_GlobalData::STREAM_FACETS_H); 00392 postprocess(be_global->facets_impl_name_.c_str(), be_global->facets_impl_, 00393 BE_GlobalData::STREAM_FACETS_CPP); 00394 } 00395 00396 if (be_global->language_mapping() == BE_GlobalData::LANGMAP_FACE_CXX || 00397 be_global->language_mapping() == BE_GlobalData::LANGMAP_SP_CXX) { 00398 postprocess(be_global->lang_header_name_.c_str(), be_global->lang_header_, 00399 BE_GlobalData::STREAM_LANG_H); 00400 } 00401 00402 BE_cleanup(); 00403 }