00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 #include "global_extern.h"
00071 #include "TAO_IFR_BE_Export.h"
00072 #include "be_extern.h"
00073 #include "fe_extern.h"
00074 #include "ast_root.h"
00075 #include "ifr_visitor_macro.h"
00076 #include "ifr_removing_visitor.h"
00077 #include "ifr_adding_visitor.h"
00078
00079 ACE_RCSID (be,
00080 be_produce,
00081 "$Id: be_produce.cpp 76589 2007-01-25 18:04:11Z elliott_c $")
00082
00083
00084 TAO_IFR_BE_Export void
00085 BE_cleanup (void)
00086 {
00087 idl_global->destroy ();
00088 }
00089
00090
00091 TAO_IFR_BE_Export void
00092 BE_abort (void)
00093 {
00094 ACE_ERROR ((LM_ERROR,
00095 ACE_TEXT ("Fatal Error - Aborting\n")));
00096
00097
00098 throw FE_Bailout ();
00099 }
00100
00101 void
00102 BE_create_holding_scope (void)
00103 {
00104 CORBA::ModuleDef_ptr scope = CORBA::ModuleDef::_nil ();
00105
00106
00107 CORBA::Contained_var result =
00108 be_global->repository ()->lookup_id (be_global->holding_scope_name ());
00109
00110
00111 if (CORBA::is_nil (result.in ()))
00112 {
00113 scope =
00114 be_global->repository ()->create_module (
00115 be_global->holding_scope_name (),
00116 be_global->holding_scope_name (),
00117 "1.0"
00118 );
00119 }
00120 else
00121 {
00122 scope = CORBA::ModuleDef::_narrow (result.in ());
00123 }
00124
00125 be_global->holding_scope (scope);
00126 }
00127
00128 int
00129 BE_ifr_repo_init (void)
00130 {
00131 CORBA::Object_var object =
00132 be_global->orb ()->resolve_initial_references ("InterfaceRepository");
00133
00134 if (CORBA::is_nil (object.in ()))
00135 {
00136 ACE_ERROR_RETURN ((
00137 LM_ERROR,
00138 ACE_TEXT ("Null objref from resolve_initial_references\n")
00139 ),
00140 -1
00141 );
00142 }
00143
00144 CORBA::Repository_var repo =
00145 CORBA::Repository::_narrow (object.in ());
00146
00147 if (CORBA::is_nil (repo.in ()))
00148 {
00149 ACE_ERROR_RETURN ((
00150 LM_ERROR,
00151 ACE_TEXT ("CORBA::Repository::_narrow failed\n")
00152 ),
00153 -1
00154 );
00155 }
00156
00157 be_global->repository (repo._retn ());
00158
00159 return 0;
00160 }
00161
00162
00163 TAO_IFR_BE_Export void
00164 BE_produce (void)
00165 {
00166 try
00167 {
00168 int status = BE_ifr_repo_init ();
00169
00170 if (status != 0)
00171 {
00172 return;
00173 }
00174
00175 BE_create_holding_scope ();
00176
00177
00178 AST_Decl *d = idl_global->root ();
00179 AST_Root *root = AST_Root::narrow_from_decl (d);
00180
00181 if (root == 0)
00182 {
00183 ACE_ERROR ((LM_ERROR,
00184 ACE_TEXT ("(%N:%l) BE_produce - ")
00185 ACE_TEXT ("No Root\n")));
00186
00187 BE_abort ();
00188 }
00189
00190 if (be_global->removing ())
00191 {
00192 ifr_removing_visitor visitor;
00193
00194 TAO_IFR_VISITOR_WRITE_GUARD;
00195
00196
00197
00198 if (visitor.visit_scope (root) == -1)
00199 {
00200 ACE_ERROR ((
00201 LM_ERROR,
00202 ACE_TEXT ("(%N:%l) BE_produce -")
00203 ACE_TEXT (" failed to accept removing visitor\n")
00204 ));
00205
00206 BE_abort ();
00207 }
00208 }
00209 else
00210 {
00211 ifr_adding_visitor visitor (d);
00212
00213 TAO_IFR_VISITOR_WRITE_GUARD;
00214
00215 if (root->ast_accept (&visitor) == -1)
00216 {
00217 ACE_ERROR ((
00218 LM_ERROR,
00219 ACE_TEXT ("(%N:%l) BE_produce -")
00220 ACE_TEXT (" failed to accept adding visitor\n")
00221 ));
00222
00223 BE_abort ();
00224 }
00225 }
00226 }
00227 catch (const CORBA::Exception& ex)
00228 {
00229 ex._tao_print_exception (ACE_TEXT ("BE_produce"));
00230
00231 }
00232
00233
00234 BE_cleanup ();
00235 }