OpenDDS  Snapshot(2023/04/28-20:55)
Functions
be_produce.cpp File Reference
#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>
Include dependency graph for be_produce.cpp:

Go to the source code of this file.

Functions

void BE_cleanup ()
 
void BE_abort ()
 
void BE_produce ()
 

Function Documentation

◆ BE_abort()

void BE_abort ( void  )

◆ BE_cleanup()

void BE_cleanup ( void  )

Definition at line 94 of file be_produce.cpp.

Referenced by BE_abort(), and BE_produce().

95 {
96  if (idl_global) {
97  idl_global->destroy();
98  }
99 }

◆ BE_produce()

void BE_produce ( void  )

Definition at line 299 of file be_produce.cpp.

References ACE_ERROR, ACE_TEXT(), BE_abort(), BE_cleanup(), be_global, ACE_String_Base< char >::c_str(), BE_GlobalData::filename(), ACE_String_Base< char >::length(), LM_ERROR, ACE_OS::strcasecmp(), and strncmp().

300 {
301  const char* idl_fn = idl_global->main_filename()->get_string();
302  be_global->filename(idl_fn);
303 
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;
307 
308  ifstream idl(idl_fn);
309  const size_t buffer_sz = 512;
310  char buffer[buffer_sz];
311  unsigned lineno = 0;
312 
313  while (idl) {
314  idl.getline(buffer, buffer_sz);
315  ++lineno;
316 
317  // search for #includes in the IDL, add them as #includes in the stubs/skels
318  if (0 == strncmp("#include", buffer, 8)) { //FUTURE: account for comments?
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();
324  string base_name;
325 
326  if (len >= 5 &&
327  0 == ACE_OS::strcasecmp(included.c_str() + len - 4, ".idl")) {
328  base_name.assign(included.c_str(), len - 4);
329 
330  } else if (len >= 6 &&
331  0 == ACE_OS::strcasecmp(included.c_str() + len - 5, ".pidl")) {
332  base_name.assign(included.c_str(), len - 5);
333 
334  } else {
335  continue;
336  }
337 
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") {
341  continue; // with Safety Profile C++, skip include of tao/*SeqC.h
342  }
343 
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" ||
348  (stb_inc.size() >= 7
349  && stb_inc.substr(stb_inc.size() - 7) == "/orbC.h") ) {
350  be_global->warning(
351  "Potential inclusion of TAO orbC.h\n"
352  " Include TAO orb.idl with path of tao/orb.idl"
353  " to prevent compilation errors",
354  idl_fn, lineno);
355  }
356  }
357 
358  }
359  }
360 
361  idl.close();
362 
363  be_global->open_streams(idl_fn);
364 
365  AST_Decl* d = idl_global->root();
366  AST_Root* root = dynamic_cast<AST_Root*>(d);
367 
368  if (root == 0) {
369  ACE_ERROR((LM_ERROR,
370  ACE_TEXT("(%N:%l) BE_produce - ")
371  ACE_TEXT("No Root\n")));
372 
373  BE_abort();
374  }
375 
376  be_global->set_inc_paths(idl_global->idl_flags());
377 
378  const bool java_ts_only = be_global->java_arg().length() > 0;
379 
380  dds_visitor visitor(d, java_ts_only);
381 
382  if (root->ast_accept(&visitor) == -1) {
383  ACE_ERROR((LM_ERROR,
384  ACE_TEXT("(%N:%l) BE_produce -")
385  ACE_TEXT(" failed to accept adding visitor\n")));
386  BE_abort();
387  }
388 
389  if (!java_ts_only) {
390  postprocess(be_global->header_name_.c_str(),
391  be_global->header_, BE_GlobalData::STREAM_H);
392  if (!be_global->suppress_idl()) {
393  postprocess(be_global->idl_name_.c_str(),
394  be_global->idl_, BE_GlobalData::STREAM_IDL);
395  }
396  }
397 
398  postprocess(be_global->impl_name_.c_str(),
399  be_global->impl_, BE_GlobalData::STREAM_CPP);
400 
401  if (be_global->itl()) {
402  if (!BE_GlobalData::writeFile(be_global->itl_name_.c_str(), be_global->itl_.str())) {
403  BE_abort(); //error message already printed
404  }
405  }
406 
407  if (be_global->face_ts()) {
408  postprocess(be_global->facets_header_name_.c_str(), be_global->facets_header_,
409  BE_GlobalData::STREAM_FACETS_H);
410  postprocess(be_global->facets_impl_name_.c_str(), be_global->facets_impl_,
411  BE_GlobalData::STREAM_FACETS_CPP);
412  }
413 
414  if (be_global->language_mapping() != BE_GlobalData::LANGMAP_NONE) {
415  postprocess(be_global->lang_header_name_.c_str(), be_global->lang_header_,
416  BE_GlobalData::STREAM_LANG_H);
417  }
418 
419  BE_cleanup();
420 }
const char * filename(void) const
Definition: be_global.cpp:86
#define ACE_ERROR(X)
const char * c_str(void) const
int strncmp(const char *s, const char *t, size_t len)
void BE_abort()
Definition: be_produce.cpp:103
void BE_cleanup()
Definition: be_produce.cpp:94
ACE_TEXT("TCP_Factory")
int strcasecmp(const char *s, const char *t)
BE_GlobalData * be_global
Definition: be_global.cpp:44
size_type length(void) const