summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-07-02 01:08:53 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-07-02 01:08:53 +0000
commit1b9a2664292e8e6698e49b2e33a891e74de9aad1 (patch)
tree6ca252cf1dc361830d60c54a5480d7a1f4b8779b
parent4de1c28a5a3f1e3467ec095b586813324fd93692 (diff)
downloadATCD-1b9a2664292e8e6698e49b2e33a891e74de9aad1.tar.gz
ChangeLogTag: Thu Jul 1 20:01:16 2004 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/ChangeLog26
-rw-r--r--TAO/TAO_IDL/ast/ast_root.cpp23
-rw-r--r--TAO/TAO_IDL/be/be_produce.cpp5
-rw-r--r--TAO/TAO_IDL/be/be_root.cpp9
-rw-r--r--TAO/TAO_IDL/driver/drv_preproc.cpp60
-rw-r--r--TAO/TAO_IDL/include/ast_root.h3
-rw-r--r--TAO/TAO_IDL/include/idl_global.h3
-rw-r--r--TAO/TAO_IDL/include/utl_scope.h2
-rw-r--r--TAO/TAO_IDL/tao_idl.cpp149
-rw-r--r--TAO/TAO_IDL/util/utl_global.cpp43
-rw-r--r--TAO/orbsvcs/IFR_Service/be_produce.cpp5
11 files changed, 158 insertions, 170 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 3506b777002..7984c5d632e 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,29 @@
+Thu Jul 1 20:01:16 2004 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * TAO_IDL/tao_idl.cpp:
+ * TAO_IDL/ast/ast_root.cpp:
+ * TAO_IDL/be/be_produce.cpp:
+ * TAO_IDL/be/be_root.cpp:
+ * TAO_IDL/driver/drv_preproc.cpp:
+ * TAO_IDL/include/ast_root.h:
+ * TAO_IDL/include/idl_global.h:
+ * TAO_IDL/include/utl_scope.h:
+ * TAO_IDL/util/utl_global.cpp:
+
+ Changed the method of processing multiple file in a single
+ execution from forking off separate processes for each
+ file to simply iterating over the files in a single
+ process. Unique temporary filenames are now created using
+ random numbers instead of process ids as before.
+
+ * orbsvcs/IFR_Service/be_produce.cpp:
+
+ Removed the deletion of pointers to the global data classes,
+ since these pointers are now reused for each file processed.
+ The final deletion of these pointers now occurs in the main()
+ loop of the executable. A similar change was made to
+ TAO_IDL/be/be_produce.cpp as part of the changes above.
+
Thu Jul 1 08:54:12 UTC 2004 Johnny Willemsen <jwillemsen@remedy.nl>
* tao/RTCORBA/Multi_Priority_Mapping.{h,cpp}:
diff --git a/TAO/TAO_IDL/ast/ast_root.cpp b/TAO/TAO_IDL/ast/ast_root.cpp
index 843c6d42e43..16cc9dc66c0 100644
--- a/TAO/TAO_IDL/ast/ast_root.cpp
+++ b/TAO/TAO_IDL/ast/ast_root.cpp
@@ -218,6 +218,29 @@ AST_Root::ast_accept (ast_visitor *visitor)
void
AST_Root::destroy ()
{
+ // Just destroy and delete the non-predefined types in the
+ // scope, in case we are processing multiple IDL files.
+ // Final cleanup will be done in fini().
+ for (long i = this->pd_decls_used; i > 0; --i)
+ {
+ AST_Decl *d = this->pd_decls[i - 1];
+
+ if (d->node_type () == AST_Decl::NT_pre_defined)
+ {
+ break;
+ }
+
+ d->destroy ();
+ delete d;
+ d = 0;
+ --this->pd_decls_used;
+ }
+}
+
+void
+AST_Root::fini (void)
+{
+ this->UTL_Scope::destroy ();
this->AST_Decl::destroy ();
}
diff --git a/TAO/TAO_IDL/be/be_produce.cpp b/TAO/TAO_IDL/be/be_produce.cpp
index 7ab9305498a..d4bdd4d849e 100644
--- a/TAO/TAO_IDL/be/be_produce.cpp
+++ b/TAO/TAO_IDL/be/be_produce.cpp
@@ -82,11 +82,6 @@ TAO_IDL_BE_Export void
BE_cleanup (void)
{
idl_global->destroy ();
- delete idl_global;
- idl_global = 0;
-
- delete be_global;
- be_global = 0;
}
// Abort this run of the BE.
diff --git a/TAO/TAO_IDL/be/be_root.cpp b/TAO/TAO_IDL/be/be_root.cpp
index 27ec7b82782..824ff8565d3 100644
--- a/TAO/TAO_IDL/be/be_root.cpp
+++ b/TAO/TAO_IDL/be/be_root.cpp
@@ -100,8 +100,13 @@ void
be_root::destroy (void)
{
// Call the destroy methods of our base classes.
- be_scope::destroy ();
- be_decl::destroy ();
+
+// The scope of the root is handled specially, since we may
+// be processing multiple IDL files and we want to keep
+// the predefined types around until we are all done.
+// be_scope::destroy ();
+// be_decl::destroy ();
+
AST_Root::destroy ();
}
diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp
index 08603f4a786..599f5ebde36 100644
--- a/TAO/TAO_IDL/driver/drv_preproc.cpp
+++ b/TAO/TAO_IDL/driver/drv_preproc.cpp
@@ -665,8 +665,8 @@ DRV_pre_proc (const char *myfile)
{
const char* tmpdir = idl_global->temp_dir ();
- static const char tao_idlf_template[] = "tao-idlf_XXXXXX";
- static const char tao_idli_template[] = "tao-idli_XXXXXX";
+ static const char tao_idlf_template[] = "tao-idlf_";
+ static const char tao_idli_template[] = "tao-idli_";
static const char temp_file_extension[] = ".cpp";
const size_t tlen = ACE_OS::strlen (tmpdir) + sizeof (temp_file_extension);
@@ -689,51 +689,19 @@ DRV_pre_proc (const char *myfile)
// Append temporary filename template to temporary directory.
ACE_OS::strcat (tmp_file, tao_idlf_template);
ACE_OS::strcat (tmp_ifile, tao_idli_template);
-
- // Fill in temporary filename template.
-#ifdef ACE_LACKS_MKSTEMP
-
- (void) ACE_OS::mktemp (tmp_file);
- (void) ACE_OS::mktemp (tmp_ifile);
-
- // Append C++ source file extension.
- ACE_OS::strcat (tmp_file, temp_file_extension);
- ACE_OS::strcat (tmp_ifile, temp_file_extension);
-
+
+ // Append 6 random digits to the end of the temporary filename
+ // to ensure uniqueness.
+ char digits[7];
+ ACE_OS::sprintf (digits, "%6.6d", rand ());
+ digits[6] = '\0';
+
+ ACE_OS::strcat (tmp_file, digits);
+ ACE_OS::strcat (tmp_ifile, digits);
+
char * t_file = tmp_file;
char * t_ifile = tmp_ifile;
-#else
- int tf_fd = ACE_OS::mkstemp (tmp_file);
- int ti_fd = ACE_OS::mkstemp (tmp_ifile);
-
- if (tf_fd == -1 || ti_fd == -1)
- {
- ACE_ERROR ((LM_ERROR,
- "%s: Unable to create temporary file: %m\n",
- idl_global->prog_name ()));
-
- return;
- }
-
- static char tmp_cpp_file [MAXPATHLEN + 1] = { 0 };
- static char tmp_cpp_ifile[MAXPATHLEN + 1] = { 0 };
-
- // Append C++ source file extension. Temporary files will be renamed
- // to these filenames.
- ACE_OS::strcpy (tmp_cpp_file, tmp_file);
- ACE_OS::strcpy (tmp_cpp_ifile, tmp_ifile);
- ACE_OS::strcat (tmp_cpp_file, temp_file_extension);
- ACE_OS::strcat (tmp_cpp_ifile, temp_file_extension);
-
- char * t_file = tmp_cpp_file;
- char * t_ifile = tmp_cpp_ifile;
-
- // Rename temporary files so that they have extensions accepted
- // by the preprocessor.
-
-#endif /* ACE_LACKS_MKSTEMP */
-
UTL_String *tmp = 0;
FILE *file = ACE_OS::fopen (myfile, "r");
@@ -799,9 +767,9 @@ DRV_pre_proc (const char *myfile)
// symbolic link attack, or another process opened the file before
// us.
fd = ACE_OS::open (t_file,
- O_WRONLY | O_CREAT | O_EXCL,
+ O_WRONLY | O_CREAT,
ACE_DEFAULT_FILE_PERMS);
-
+
if (fd == ACE_INVALID_HANDLE)
{
ACE_ERROR ((LM_ERROR,
diff --git a/TAO/TAO_IDL/include/ast_root.h b/TAO/TAO_IDL/include/ast_root.h
index d4779ba367a..78e44b9e3dc 100644
--- a/TAO/TAO_IDL/include/ast_root.h
+++ b/TAO/TAO_IDL/include/ast_root.h
@@ -95,6 +95,9 @@ public:
// Cleanup.
virtual void destroy ();
+
+ // Final cleanup.
+ void fini (void);
private:
friend class FE_Declarator;
diff --git a/TAO/TAO_IDL/include/idl_global.h b/TAO/TAO_IDL/include/idl_global.h
index abb0aad13f2..05dc5245a1c 100644
--- a/TAO/TAO_IDL/include/idl_global.h
+++ b/TAO/TAO_IDL/include/idl_global.h
@@ -531,6 +531,9 @@ public:
int check_gperf (void);
// Currently called only from IDL backend, but could be useful elsewhere.
+
+ void fini (void);
+ // Do final cleanup just before process exits.
private:
// Data
diff --git a/TAO/TAO_IDL/include/utl_scope.h b/TAO/TAO_IDL/include/utl_scope.h
index 3c27c937b50..7eb8bfae2f3 100644
--- a/TAO/TAO_IDL/include/utl_scope.h
+++ b/TAO/TAO_IDL/include/utl_scope.h
@@ -310,7 +310,7 @@ protected:
idl_bool redef_clash (AST_Decl::NodeType new_nt,
AST_Decl::NodeType scope_elem_nt);
-private:
+protected:
// Data.
// What type is this node? This is a cache of the information
diff --git a/TAO/TAO_IDL/tao_idl.cpp b/TAO/TAO_IDL/tao_idl.cpp
index d36aaaf5612..ed1e1ae18cc 100644
--- a/TAO/TAO_IDL/tao_idl.cpp
+++ b/TAO/TAO_IDL/tao_idl.cpp
@@ -73,7 +73,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
#include "utl_string.h"
#include "utl_identifier.h"
#include "drv_extern.h"
-#include "ace/Process.h"
#include "../tao/Version.h"
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
@@ -139,6 +138,19 @@ DRV_init (int &argc, char *argv[])
return BE_init (argc, argv);
}
+void
+DRV_refresh (void)
+{
+ idl_global->set_err_count (0);
+ idl_global->set_filename (0);
+ idl_global->set_main_filename (0);
+ idl_global->set_real_filename (0);
+ idl_global->set_stripped_filename (0);
+// idl_global->set_import (I_TRUE);
+// idl_global->set_in_main_file (I_FALSE);
+ idl_global->set_lineno (-1);
+}
+
/*
** Drive the compilation
**
@@ -176,29 +188,6 @@ DRV_drive (const char *s)
}
DRV_pre_proc (s);
- AST_Generator *gen = be_global->generator_init ();
-
- if (gen == 0)
- {
- ACE_ERROR ((
- LM_ERROR,
- ACE_TEXT ("IDL: DRV_generator_init() failed to create ")
- ACE_TEXT ("generator, exiting\n")
- ));
-
- ACE_OS::exit (99);
- }
- else
- {
- idl_global->set_gen (gen);
- }
-
- // Initialize AST and load predefined types.
- FE_populate ();
-
- // For the IDL compiler, this has to come after FE_populate().
- // For the IFR loader, it does nothing.
- BE_post_init ();
// Parse.
if (idl_global->compile_flags () & IDL_CF_INFORMATIVE)
@@ -275,60 +264,8 @@ DRV_drive (const char *s)
{
ACE_OS::exit (static_cast<int> (error_count));
}
-
- // Exit cleanly.
- ACE_OS::exit (0);
-}
-
-// Fork off a process, wait for it to die.
-void
-DRV_fork (void)
-{
- // We get this from the BE because it is implemented
- // differently in the IFR backend.
- ACE_CString arg_string = be_global->spawn_options ();
-
- for (DRV_file_index = 0;
- DRV_file_index < DRV_nfiles;
- ++DRV_file_index)
- {
- ACE_Process_Options options (1,
- TAO_IDL_COMMAND_LINE_BUFFER_SIZE);
- options.creation_flags (ACE_Process_Options::NO_EXEC);
- options.command_line ("%s %s %s",
- idl_global->prog_name (),
- arg_string.c_str (),
- DRV_files[DRV_file_index]);
- ACE_Process manager;
- pid_t child_pid = manager.spawn (options);
-
- if (child_pid == 0)
- {
- // OK, do it to this file (in the child).
- DRV_drive (DRV_files[DRV_file_index]);
- ACE_OS::exit (0);
- }
-
- if (child_pid == ACE_INVALID_PID)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("IDL: spawn failed\n")));
-
- ACE_OS::exit (99);
- }
-
- // child_pid is the process id of something at this point.
- if (manager.wait () == -1)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("IDL: wait failed\n")));
-
- ACE_OS::exit (99);
- }
- }
-
- // Now the parent process can exit.
- ACE_OS::exit (0);
+
+ DRV_refresh ();
}
/*
@@ -368,28 +305,56 @@ main (int argc, char *argv[])
ACE_OS::exit (0);
}
- // Fork off a process for each file to process. Fork only if
- // there is more than one file to process.
- if (DRV_nfiles > 1)
+ // If there are no input files, no sense going any further.
+ if (DRV_nfiles == 0)
{
- // DRV_fork never returns.
- DRV_fork ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("IDL: No input files\n")));
+
+ ACE_OS::exit (99);
+ }
+
+ AST_Generator *gen = be_global->generator_init ();
+
+ if (gen == 0)
+ {
+ ACE_ERROR ((
+ LM_ERROR,
+ ACE_TEXT ("IDL: DRV_generator_init() failed to create ")
+ ACE_TEXT ("generator, exiting\n")
+ ));
+
+ ACE_OS::exit (99);
}
else
{
- // Do the one file we have to parse.
- // Check if stdin and handle file name appropriately.
- if (DRV_nfiles == 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("IDL: No input files\n")));
+ idl_global->set_gen (gen);
+ }
- ACE_OS::exit (99);
- }
+ // Initialize AST and load predefined types.
+ FE_populate ();
- DRV_file_index = 0;
+ // For the IDL compiler, this has to come after FE_populate().
+ // For the IFR loader, it does nothing.
+ BE_post_init ();
+
+ // Seed the random number generator used for creating unique
+ // temporary filenames.
+ srand ((unsigned int) time (0));
+
+ for (DRV_file_index = 0;
+ DRV_file_index < DRV_nfiles;
+ ++DRV_file_index)
+ {
DRV_drive (DRV_files[DRV_file_index]);
}
+
+ delete be_global;
+ be_global = 0;
+
+ idl_global->fini ();
+ delete idl_global;
+ idl_global = 0;
ACE_OS::exit (0);
diff --git a/TAO/TAO_IDL/util/utl_global.cpp b/TAO/TAO_IDL/util/utl_global.cpp
index e48e55bc032..5aea4bb812b 100644
--- a/TAO/TAO_IDL/util/utl_global.cpp
+++ b/TAO/TAO_IDL/util/utl_global.cpp
@@ -1037,25 +1037,6 @@ IDL_GlobalData::destroy (void)
}
this->pd_root->destroy ();
- delete this->pd_root;
- this->pd_root = 0;
-
- delete this->pd_err;
- this->pd_err = 0;
- delete this->pd_gen;
- this->pd_gen = 0;
- delete this->pd_indent;
- this->pd_indent = 0;
- delete [] this->pd_local_escapes;
- this->pd_local_escapes = 0;
- delete [] this->tao_root_;
- this->tao_root_ = 0;
- delete [] this->gperf_path_;
- this->gperf_path_ = 0;
- delete [] this->temp_dir_;
- this->temp_dir_ = 0;
- delete [] this->ident_string_;
- this->ident_string_ = 0;
}
void
@@ -1483,3 +1464,27 @@ IDL_GlobalData::check_gperf (void)
}
}
+void
+IDL_GlobalData::fini (void)
+{
+ this->pd_root->fini ();
+ delete this->pd_root;
+ this->pd_root = 0;
+
+ delete this->pd_err;
+ this->pd_err = 0;
+ delete this->pd_gen;
+ this->pd_gen = 0;
+ delete this->pd_indent;
+ this->pd_indent = 0;
+ delete [] this->pd_local_escapes;
+ this->pd_local_escapes = 0;
+ delete [] this->tao_root_;
+ this->tao_root_ = 0;
+ delete [] this->gperf_path_;
+ this->gperf_path_ = 0;
+ delete [] this->temp_dir_;
+ this->temp_dir_ = 0;
+ delete [] this->ident_string_;
+ this->ident_string_ = 0;
+}
diff --git a/TAO/orbsvcs/IFR_Service/be_produce.cpp b/TAO/orbsvcs/IFR_Service/be_produce.cpp
index f07733f4ee9..656ef68579f 100644
--- a/TAO/orbsvcs/IFR_Service/be_produce.cpp
+++ b/TAO/orbsvcs/IFR_Service/be_produce.cpp
@@ -85,8 +85,6 @@ void
BE_cleanup (void)
{
idl_global->destroy ();
- delete idl_global;
- idl_global = 0;
// Remove the holding scope entry from the repository.
ACE_DECLARE_NEW_CORBA_ENV;
@@ -114,9 +112,6 @@ BE_cleanup (void)
ACE_TEXT ("BE_cleanup"));
}
ACE_ENDTRY;
-
- delete be_global;
- be_global = 0;
}
// Abort this run of the BE.