summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-05-24 21:31:09 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-05-24 21:31:09 +0000
commit4e9c7687279ab2081833e984231b83c82c22a0cf (patch)
tree0e224e155c88edbe6aed459436ba85539b1e0869
parent1ae025a20bae0a7886122681392c1cf39a34f465 (diff)
downloadATCD-4e9c7687279ab2081833e984231b83c82c22a0cf.tar.gz
ChangeLogTag: Thu May 24 16:25:36 2001 Jeff Parsons <parsons@cs.wustl.edu>
-rw-r--r--TAO/orbsvcs/IFR_Service/README10
-rw-r--r--TAO/orbsvcs/IFR_Service/be_extern.h4
-rw-r--r--TAO/orbsvcs/IFR_Service/be_produce.cpp104
-rw-r--r--TAO/orbsvcs/IFR_Service/drv_args_ifr.cpp16
-rw-r--r--TAO/orbsvcs/IFR_Service/drv_extern_ifr.h9
-rw-r--r--TAO/orbsvcs/IFR_Service/ifr_visitor.cpp32
-rw-r--r--TAO/orbsvcs/IFR_Service/ifr_visitor_macro.h2
-rw-r--r--TAO/orbsvcs/IFR_Service/tao_ifr.cpp28
8 files changed, 122 insertions, 83 deletions
diff --git a/TAO/orbsvcs/IFR_Service/README b/TAO/orbsvcs/IFR_Service/README
index 24ff24afa1d..28b6bf882ae 100644
--- a/TAO/orbsvcs/IFR_Service/README
+++ b/TAO/orbsvcs/IFR_Service/README
@@ -54,6 +54,16 @@ the IFR service, plus the IFR_Service executable itself.
Test code for tao_ifr can be found in
ACE_ROOT/TAO/orbsvcs/tests/InterfaceRepo/Application_Test.
+tao_ifr can also handle the -ORBxxx parameters. The one most
+frequently used would probably be
+
+'-ORBInitRef InterfaceRepository=file://<filename>'
+
+which will enable the IFR service to be resolved by getting
+its IOR from <filename>. By default, the IFR service stores
+its IOR in the file 'if_repo.ior', but that can be modified
+by starting the IFR service using the -o option (see above).
+
More information about the Interface Repository and tao_ifr can
be found in ACE_ROOT/TAO/docs/releasenotes/index.html.
diff --git a/TAO/orbsvcs/IFR_Service/be_extern.h b/TAO/orbsvcs/IFR_Service/be_extern.h
index ab8bb851d99..efa3158f897 100644
--- a/TAO/orbsvcs/IFR_Service/be_extern.h
+++ b/TAO/orbsvcs/IFR_Service/be_extern.h
@@ -79,6 +79,10 @@ extern TAO_IFR_BE_Export BE_GlobalData *be_global;
// Functions:
extern TAO_IFR_BE_Export void BE_produce (void);
+
extern TAO_IFR_BE_Export void BE_abort (void);
+extern TAO_IFR_BE_Export int BE_ifr_init (int &,
+ char *[]);
+
#endif /* TAO_IFR_BE_EXTERN_H */
diff --git a/TAO/orbsvcs/IFR_Service/be_produce.cpp b/TAO/orbsvcs/IFR_Service/be_produce.cpp
index 78c17e6c08c..08acc78b326 100644
--- a/TAO/orbsvcs/IFR_Service/be_produce.cpp
+++ b/TAO/orbsvcs/IFR_Service/be_produce.cpp
@@ -78,7 +78,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
ACE_RCSID(be, be_produce, "$Id$")
// Clean up before exit, whether successful or not.
-TAO_IFR_BE_Export void
+// Need not be exported since it is called only from this file.
+void
BE_cleanup (void)
{
AST_Decl *root = idl_global->root ();
@@ -103,6 +104,66 @@ BE_abort (void)
ACE_OS::exit (1);
}
+
+// ac must be passed in by reference, because it is also
+// passed by reference to ORB_init, which may modify it.
+// After BE_ifr_init returns to main() the modified argc
+// must be passed to DRV_parse_args().
+TAO_IFR_BE_Export int
+BE_ifr_init (int &ac,
+ char *av[])
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ be_global->orb (CORBA::ORB_init (ac,
+ av,
+ 0,
+ ACE_TRY_ENV));
+ ACE_TRY_CHECK;
+
+ CORBA::Object_var object =
+ be_global->orb ()->resolve_initial_references ("InterfaceRepository",
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (object.in ()))
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("Null objref from resolve_initial_references\n")
+ ),
+ -1
+ );
+ }
+
+ CORBA_Repository_var repo = CORBA_Repository::_narrow (object.in (),
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (repo.in ()))
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("CORBA::Repository::_narrow failed\n")
+ ),
+ -1
+ );
+ }
+
+ be_global->repository (repo._retn ());
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ ACE_TEXT ("BE_ifr_init"));
+
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
// Do the work of this BE. This is the starting point for code generation.
TAO_IFR_BE_Export void
@@ -121,42 +182,33 @@ BE_produce (void)
BE_abort ();
}
+ ifr_visitor *visitor = 0;
+
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
if (be_global->removing ())
{
- ifr_removing_visitor visitor;
-
- TAO_IFR_VISITOR_WRITE_GUARD;
-
- if (visitor.visit_scope (root) == -1)
- {
- ACE_ERROR ((
- LM_ERROR,
- ACE_TEXT ("(%N:%l) BE_produce -")
- ACE_TEXT (" visiting root scope failed\n")
- ));
-
- BE_abort ();
- }
+ ifr_removing_visitor removing_visitor;
+ visitor = &removing_visitor;
}
else
{
- ifr_adding_visitor visitor;
+ ifr_adding_visitor adding_visitor;
+ visitor = &adding_visitor;
+ }
- TAO_IFR_VISITOR_WRITE_GUARD;
+ TAO_IFR_VISITOR_WRITE_GUARD;
- if (root->ast_accept (&visitor) == -1)
- {
- ACE_ERROR ((
- LM_ERROR,
- ACE_TEXT ("(%N:%l) BE_produce -")
- ACE_TEXT (" failed to accept visitor\n")
- ));
+ if (root->ast_accept (visitor) == -1)
+ {
+ ACE_ERROR ((
+ LM_ERROR,
+ ACE_TEXT ("(%N:%l) BE_produce -")
+ ACE_TEXT (" failed to accept visitor\n")
+ ));
- BE_abort ();
- }
+ BE_abort ();
}
}
ACE_CATCHANY
diff --git a/TAO/orbsvcs/IFR_Service/drv_args_ifr.cpp b/TAO/orbsvcs/IFR_Service/drv_args_ifr.cpp
index cfaf2a0d522..76ea980a21f 100644
--- a/TAO/orbsvcs/IFR_Service/drv_args_ifr.cpp
+++ b/TAO/orbsvcs/IFR_Service/drv_args_ifr.cpp
@@ -92,16 +92,15 @@ DRV_usage (void)
// Parse arguments on command line
void
-DRV_parse_args (long ac, char **av)
+DRV_parse_args (int ac, char *av[])
{
- char *buffer;
- char *s = 0;
- long i;
+ char *buffer = 0;
+ char *s = 0;
DRV_cpp_init ();
idl_global->set_prog_name (av[0]);
- for (i = 1; i < ac; i++)
+ for (int i = 1; i < ac; i++)
{
if (av[i][0] == '-')
{
@@ -287,10 +286,3 @@ DRV_parse_args (long ac, char **av)
}
}
-// No-op definition so we can use drv_extern.h (where this is declared
-// 'extern') unmodified. The IFR BE doesn't use gperf.
-int
-DRV_check_gperf (void)
-{
- return 0;
-}
diff --git a/TAO/orbsvcs/IFR_Service/drv_extern_ifr.h b/TAO/orbsvcs/IFR_Service/drv_extern_ifr.h
index 7645ea5310b..9cda4fd29b4 100644
--- a/TAO/orbsvcs/IFR_Service/drv_extern_ifr.h
+++ b/TAO/orbsvcs/IFR_Service/drv_extern_ifr.h
@@ -73,8 +73,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
extern void DRV_init (void);
-extern void DRV_parse_args (long,
- char **);
+extern void DRV_parse_args (int,
+ char *[]);
extern void DRV_usage (void);
@@ -86,9 +86,8 @@ extern void DRV_cpp_putarg (const char *str);
extern void DRV_cpp_new_location (const char *new_loc);
-extern void DRV_fork (void);
-
-extern int DRV_check_gperf (void);
+extern void DRV_fork (int,
+ char *[]);
extern void DRV_check_for_include (const char* buf);
diff --git a/TAO/orbsvcs/IFR_Service/ifr_visitor.cpp b/TAO/orbsvcs/IFR_Service/ifr_visitor.cpp
index 0a1b26aefcc..bcf1c371b70 100644
--- a/TAO/orbsvcs/IFR_Service/ifr_visitor.cpp
+++ b/TAO/orbsvcs/IFR_Service/ifr_visitor.cpp
@@ -8,41 +8,9 @@ ACE_RCSID(IFR_Service, ifr_visitor, "$Id$")
ifr_visitor::ifr_visitor (void)
: lock_ (0)
{
- int argc = 0;
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- be_global->orb (CORBA::ORB_init (argc,
- 0,
- 0,
- ACE_TRY_ENV));
- ACE_TRY_CHECK;
-
- CORBA::Object_var object =
- be_global->orb ()->resolve_initial_references ("InterfaceRepository",
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- if (CORBA::is_nil (object.in ()))
- {
- ACE_ERROR ((
- LM_ERROR,
- ACE_TEXT ("Null objref from resolve_initial_references\n")
- ));
- }
-
- CORBA_Repository_var repo = CORBA_Repository::_narrow (object.in (),
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- if (CORBA::is_nil (repo.in ()))
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("CORBA::Repository::_narrow failed\n")));
- }
-
- be_global->repository (repo._retn ());
-
// Create the appropriate lock.
if (be_global->enable_locking ())
{
diff --git a/TAO/orbsvcs/IFR_Service/ifr_visitor_macro.h b/TAO/orbsvcs/IFR_Service/ifr_visitor_macro.h
index 6897bd9e38e..911a8e41399 100644
--- a/TAO/orbsvcs/IFR_Service/ifr_visitor_macro.h
+++ b/TAO/orbsvcs/IFR_Service/ifr_visitor_macro.h
@@ -8,7 +8,7 @@
#define TAO_IFR_VISITOR_WRITE_GUARD \
ACE_WRITE_GUARD_THROW_EX (ACE_Lock, \
monitor, \
- visitor.lock (), \
+ visitor->lock (), \
CORBA::INTERNAL ( \
CORBA_SystemException::_tao_minor_code ( \
TAO_GUARD_FAILURE, \
diff --git a/TAO/orbsvcs/IFR_Service/tao_ifr.cpp b/TAO/orbsvcs/IFR_Service/tao_ifr.cpp
index ba0a20b0501..5e54a20e44b 100644
--- a/TAO/orbsvcs/IFR_Service/tao_ifr.cpp
+++ b/TAO/orbsvcs/IFR_Service/tao_ifr.cpp
@@ -194,10 +194,11 @@ DRV_drive (const char *s)
// main LOGIC:
-// 1. Initialize compiler driver
-// 2. Parse command line args
-// 3. If more than one file to parse, fork
-// 4. Otherwise, for the single file, invoke DRV_drive
+// 1. Initialize compiler driver.
+// 2. Initialize ORB and resolve Interface Repository.
+// 3. Parse command line args.
+// 4. If more than one file to parse, fork.
+// 5. Otherwise, for the single file, invoke DRV_drive.
int
main (int argc, char *argv[])
@@ -205,8 +206,21 @@ main (int argc, char *argv[])
// Initialize driver and global variables.
DRV_init ();
+ // Initialize our ORB and resolve the Interface Repository.
+ // Since CORBA::ORB_init strips any -ORBxxx xxx arguments
+ // it finds, we must do this first. DRV_parse_args cannot
+ // deal with them.
+ int init_status = BE_ifr_init (argc,
+ argv);
+
+ if (init_status != 0)
+ {
+ ACE_OS::exit (init_status);
+ }
+
// Parse arguments.
- DRV_parse_args (argc, argv);
+ DRV_parse_args (argc,
+ argv);
// If a usage message is requested, give it and exit.
if (idl_global->compile_flags () & IDL_CF_ONLY_USAGE)
@@ -215,8 +229,8 @@ 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.
+ // Fork off a process for each file to process, only if
+ // there is more than one.
if (DRV_nfiles > 1)
{
// DRV_fork never returns.