be_produce.cpp File Reference

#include "global_extern.h"
#include "TAO_IFR_BE_Export.h"
#include "be_extern.h"
#include "fe_extern.h"
#include "ast_root.h"
#include "ifr_visitor_macro.h"
#include "ifr_removing_visitor.h"
#include "ifr_adding_visitor.h"

Include dependency graph for be_produce.cpp:

Include dependency graph

Go to the source code of this file.

Functions

TAO_IFR_BE_Export void BE_cleanup (void)
TAO_IFR_BE_Export void BE_abort (void)
void BE_create_holding_scope ()
int BE_ifr_repo_init ()
TAO_IFR_BE_Export void BE_produce (void)


Function Documentation

TAO_IFR_BE_Export void BE_abort void   ) 
 

Definition at line 92 of file be_produce.cpp.

References ACE_ERROR, ACE_TEXT(), and LM_ERROR.

Referenced by BE_produce().

00093 {
00094   ACE_ERROR ((LM_ERROR,
00095               ACE_TEXT ("Fatal Error - Aborting\n")));
00096 
00097   // BE_cleanup will be called after the exception is caught.
00098   throw FE_Bailout ();
00099 }

TAO_IFR_BE_Export void BE_cleanup void   ) 
 

Definition at line 85 of file be_produce.cpp.

Referenced by BE_produce().

00086 {
00087   idl_global->destroy ();
00088 }

void BE_create_holding_scope  ) 
 

Definition at line 102 of file be_produce.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, be_global, BE_GlobalData::holding_scope(), BE_GlobalData::holding_scope_name(), CORBA::is_nil(), and BE_GlobalData::repository().

Referenced by BE_produce().

00103 {
00104   CORBA::ModuleDef_ptr scope = CORBA::ModuleDef::_nil ();
00105 
00106   // If we are multi-threaded, it may already be created.
00107   CORBA::Contained_var result =
00108     be_global->repository ()->lookup_id (be_global->holding_scope_name ()
00109                                          ACE_ENV_ARG_PARAMETER);
00110   ACE_CHECK;
00111 
00112   // Will live until the repository goes away for good.
00113   if (CORBA::is_nil (result.in ()))
00114     {
00115       scope =
00116         be_global->repository ()->create_module (
00117                                       be_global->holding_scope_name (),
00118                                       be_global->holding_scope_name (),
00119                                       "1.0"
00120                                       ACE_ENV_ARG_PARAMETER
00121                                     );
00122       ACE_CHECK;
00123     }
00124   else
00125     {
00126       scope = CORBA::ModuleDef::_narrow (result.in ()
00127                                          ACE_ENV_ARG_PARAMETER);
00128       ACE_CHECK;
00129     }
00130 
00131   be_global->holding_scope (scope);
00132 }

int BE_ifr_repo_init  ) 
 

Definition at line 135 of file be_produce.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_ERROR_RETURN, ACE_TEXT(), be_global, CORBA::is_nil(), LM_ERROR, BE_GlobalData::orb(), and BE_GlobalData::repository().

Referenced by BE_produce().

00136 {
00137   CORBA::Object_var object =
00138     be_global->orb ()->resolve_initial_references ("InterfaceRepository"
00139                                                     ACE_ENV_ARG_PARAMETER);
00140   ACE_CHECK_RETURN (-1);
00141 
00142   if (CORBA::is_nil (object.in ()))
00143     {
00144       ACE_ERROR_RETURN ((
00145           LM_ERROR,
00146           ACE_TEXT ("Null objref from resolve_initial_references\n")
00147         ),
00148         -1
00149       );
00150     }
00151 
00152   CORBA::Repository_var repo =
00153     CORBA::Repository::_narrow (object.in ()
00154                                 ACE_ENV_ARG_PARAMETER);
00155   ACE_CHECK_RETURN (-1);
00156 
00157   if (CORBA::is_nil (repo.in ()))
00158     {
00159       ACE_ERROR_RETURN ((
00160           LM_ERROR,
00161           ACE_TEXT ("CORBA::Repository::_narrow failed\n")
00162         ),
00163         -1
00164       );
00165     }
00166 
00167   be_global->repository (repo._retn ());
00168 
00169   return 0;
00170 }

TAO_IFR_BE_Export void BE_produce void   ) 
 

Definition at line 174 of file be_produce.cpp.

References ACE_ANY_EXCEPTION, ACE_CATCHANY, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_ERROR, ACE_PRINT_EXCEPTION, ACE_TEXT(), ACE_TRY, ACE_TRY_CHECK, BE_abort(), BE_cleanup(), BE_create_holding_scope(), be_global, BE_ifr_repo_init(), LM_ERROR, BE_GlobalData::removing(), TAO_IFR_VISITOR_WRITE_GUARD, and ifr_removing_visitor::visit_scope().

00175 {
00176   ACE_DECLARE_NEW_CORBA_ENV;
00177   ACE_TRY
00178     {
00179       int status = BE_ifr_repo_init (ACE_ENV_SINGLE_ARG_PARAMETER);
00180       ACE_TRY_CHECK;
00181 
00182       if (status != 0)
00183         {
00184           return;
00185         }
00186 
00187       BE_create_holding_scope (ACE_ENV_SINGLE_ARG_PARAMETER);
00188       ACE_TRY_CHECK;
00189 
00190       // Get the root node.
00191       AST_Decl *d = idl_global->root ();
00192       AST_Root *root = AST_Root::narrow_from_decl (d);
00193 
00194       if (root == 0)
00195         {
00196           ACE_ERROR ((LM_ERROR,
00197                       ACE_TEXT ("(%N:%l) BE_produce - ")
00198                       ACE_TEXT ("No Root\n")));
00199 
00200           BE_abort ();
00201         }
00202 
00203       if (be_global->removing ())
00204         {
00205           ifr_removing_visitor visitor;
00206 
00207           TAO_IFR_VISITOR_WRITE_GUARD;
00208 
00209           // If the visitor is dispatched this way, we need to override
00210           // only visit_scope() for the removing visitor.
00211           if (visitor.visit_scope (root) == -1)
00212             {
00213               ACE_ERROR ((
00214                   LM_ERROR,
00215                   ACE_TEXT ("(%N:%l) BE_produce -")
00216                   ACE_TEXT (" failed to accept removing visitor\n")
00217                 ));
00218 
00219               BE_abort ();
00220             }
00221         }
00222       else
00223         {
00224           ifr_adding_visitor visitor (d);
00225 
00226           TAO_IFR_VISITOR_WRITE_GUARD;
00227 
00228           if (root->ast_accept (&visitor) == -1)
00229             {
00230               ACE_ERROR ((
00231                   LM_ERROR,
00232                   ACE_TEXT ("(%N:%l) BE_produce -")
00233                   ACE_TEXT (" failed to accept adding visitor\n")
00234                 ));
00235 
00236               BE_abort ();
00237             }
00238         }
00239     }
00240   ACE_CATCHANY
00241     {
00242       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00243                            ACE_TEXT ("BE_produce"));
00244 
00245     }
00246   ACE_ENDTRY;
00247 
00248   // Clean up.
00249   BE_cleanup ();
00250 }


Generated on Thu Nov 9 14:11:57 2006 for TAO_IFR by doxygen 1.3.6