ifr_adding_visitor Class Reference

#include <ifr_adding_visitor.h>

Inheritance diagram for ifr_adding_visitor:

Inheritance graph
[legend]
Collaboration diagram for ifr_adding_visitor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ifr_adding_visitor (AST_Decl *scope, CORBA::Boolean in_reopened=0, bool allow_duplicate_typedefs=false)
virtual ~ifr_adding_visitor (void)
virtual int visit_scope (UTL_Scope *node)
virtual int visit_predefined_type (AST_PredefinedType *node)
virtual int visit_module (AST_Module *node)
virtual int visit_interface (AST_Interface *node)
virtual int visit_interface_fwd (AST_InterfaceFwd *node)
virtual int visit_valuebox (AST_ValueBox *node)
virtual int visit_valuetype (AST_ValueType *node)
virtual int visit_valuetype_fwd (AST_ValueTypeFwd *node)
virtual int visit_component (AST_Component *node)
virtual int visit_component_fwd (AST_ComponentFwd *node)
virtual int visit_eventtype (AST_EventType *node)
virtual int visit_eventtype_fwd (AST_EventTypeFwd *node)
virtual int visit_home (AST_Home *node)
virtual int visit_factory (AST_Factory *node)
virtual int visit_structure (AST_Structure *node)
virtual int visit_structure_fwd (AST_StructureFwd *node)
virtual int visit_exception (AST_Exception *node)
virtual int visit_enum (AST_Enum *node)
virtual int visit_operation (AST_Operation *node)
virtual int visit_field (AST_Field *node)
virtual int visit_attribute (AST_Attribute *node)
virtual int visit_union (AST_Union *node)
virtual int visit_union_fwd (AST_UnionFwd *node)
virtual int visit_constant (AST_Constant *node)
virtual int visit_array (AST_Array *node)
virtual int visit_sequence (AST_Sequence *node)
virtual int visit_string (AST_String *node)
virtual int visit_typedef (AST_Typedef *node)
virtual int visit_root (AST_Root *node)
virtual int visit_native (AST_Native *node)

Protected Member Functions

CORBA::PrimitiveKind expr_type_to_pkind (AST_Expression::ExprType et)
CORBA::PrimitiveKind predefined_type_to_pkind (AST_PredefinedType *node)
void load_any (AST_Expression::AST_ExprValue *ev, CORBA::Any &any)
void element_type (AST_Type *base_type, bool owned=false)
int create_interface_def (AST_Interface *node)
int create_value_def (AST_ValueType *node)
int create_component_def (AST_Component *node)
int create_home_def (AST_Home *node)
int create_event_def (AST_EventType *node)
int create_value_member (AST_Field *node)
void get_referenced_type (AST_Type *node)
void fill_base_value (CORBA::ValueDef_ptr &result, AST_ValueType *node)
void fill_base_component (CORBA::ComponentIR::ComponentDef_ptr &result, AST_Component *node)
void fill_base_home (CORBA::ComponentIR::HomeDef_ptr &result, AST_Home *node)
void fill_managed_component (CORBA::ComponentIR::ComponentDef_ptr &result, AST_Home *node)
void fill_primary_key (CORBA::ValueDef_ptr &result, AST_Home *node)
void fill_abstract_base_values (CORBA::ValueDefSeq &result, AST_ValueType *node)
void fill_inherited_interfaces (CORBA::InterfaceDefSeq &result, AST_Interface *node)
void fill_supported_interfaces (CORBA::InterfaceDefSeq &result, AST_Interface *node)
void fill_interfaces (CORBA::InterfaceDefSeq &result, AST_Interface **list, CORBA::Long length)
void fill_initializers (CORBA::ExtInitializerSeq &result, AST_ValueType *node)
void fill_get_exceptions (CORBA::ExceptionDefSeq &result, AST_Attribute *node)
void fill_set_exceptions (CORBA::ExceptionDefSeq &result, AST_Attribute *node)
void fill_exceptions (CORBA::ExceptionDefSeq &result, AST_Decl *node)
void fill_exceptions (CORBA::ExceptionDefSeq &result, UTL_ExceptList *list)
void fill_params (CORBA::ParDescriptionSeq &result, AST_Operation *node)
void visit_all_provides (AST_Component *node, CORBA::ComponentIR::ComponentDef_ptr c)
void visit_all_uses (AST_Component *node, CORBA::ComponentIR::ComponentDef_ptr c)
void visit_all_emits (AST_Component *node, CORBA::ComponentIR::ComponentDef_ptr c)
void visit_all_publishes (AST_Component *node, CORBA::ComponentIR::ComponentDef_ptr c)
void visit_all_consumes (AST_Component *node, CORBA::ComponentIR::ComponentDef_ptr c)
void visit_all_factories (AST_Home *node, CORBA::ComponentIR::HomeDef_ptr h)
void visit_all_finders (AST_Home *node, CORBA::ComponentIR::HomeDef_ptr h)
void expand_id (ACE_CString &str, const char *local_name)

Protected Attributes

CORBA::IDLType_var ir_current_
AST_Decl * scope_
bool in_reopened_
bool allow_duplicate_typedefs_

Detailed Description

Definition at line 32 of file ifr_adding_visitor.h.


Constructor & Destructor Documentation

ifr_adding_visitor::ifr_adding_visitor ( AST_Decl *  scope,
CORBA::Boolean  in_reopened = 0,
bool  allow_duplicate_typedefs = false 
)

ifr_adding_visitor::~ifr_adding_visitor ( void   )  [virtual]

Definition at line 62 of file ifr_adding_visitor.cpp.

00063 {
00064 }


Member Function Documentation

int ifr_adding_visitor::create_component_def ( AST_Component *  node  )  [protected]

Definition at line 2914 of file ifr_adding_visitor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), be_global, fill_base_component(), fill_supported_interfaces(), BE_GlobalData::ifr_scopes(), ir_current_, LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), ACE_Unbounded_Stack< T >::top(), visit_all_consumes(), visit_all_emits(), visit_all_provides(), visit_all_publishes(), and visit_all_uses().

Referenced by visit_component().

02915 {
02916   CORBA::Container_ptr current_scope =
02917     CORBA::Container::_nil ();
02918 
02919   if (be_global->ifr_scopes ().top (current_scope) == 0)
02920     {
02921       CORBA::ComponentIR::ComponentDef_var base_component;
02922       this->fill_base_component (base_component.out (),
02923                                  node);
02924 
02925       CORBA::InterfaceDefSeq supported_interfaces;
02926       this->fill_supported_interfaces (supported_interfaces,
02927                                        node);
02928 
02929       CORBA::ComponentIR::Container_var ccm_scope =
02930         CORBA::ComponentIR::Container::_narrow (current_scope);
02931 
02932       CORBA::ComponentIR::ComponentDef_var new_def =
02933         ccm_scope->create_component (node->repoID (),
02934                                      node->local_name ()->get_string (),
02935                                      node->version (),
02936                                      base_component.in (),
02937                                      supported_interfaces);
02938 
02939       node->ifr_added (true);
02940 
02941       if (be_global->ifr_scopes ().push (new_def.in ()) != 0)
02942         {
02943           ACE_ERROR_RETURN ((
02944               LM_ERROR,
02945               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02946               ACE_TEXT ("create_component_def -")
02947               ACE_TEXT (" scope push failed\n")
02948             ),
02949             -1
02950           );
02951         }
02952 
02953       // Visit the members, if any.
02954       if (this->visit_scope (node) == -1)
02955         {
02956           ACE_ERROR_RETURN ((
02957               LM_ERROR,
02958               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02959               ACE_TEXT ("create_component_def -")
02960               ACE_TEXT (" visit_scope failed\n")
02961             ),
02962             -1
02963           );
02964         }
02965 
02966       this->visit_all_provides (node,
02967                                 new_def.in ());
02968 
02969       this->visit_all_uses (node,
02970                             new_def.in ());
02971 
02972       this->visit_all_emits (node,
02973                              new_def.in ());
02974 
02975       this->visit_all_publishes (node,
02976                                  new_def.in ());
02977 
02978       this->visit_all_consumes (node,
02979                                 new_def.in ());
02980 
02981       // This spot in the AST doesn't necessarily have to be the
02982       // interface definition - it could be any reference to it.
02983       // The front end will already have fully defined it, so all
02984       // the info is available anywhere. So it's a good idea to
02985       // update the current IR object holder now. This will
02986       // consume the objref pointer.
02987       this->ir_current_ =
02988         CORBA::IDLType::_duplicate (new_def.in ());
02989 
02990       CORBA::Container_ptr used_scope =
02991         CORBA::Container::_nil ();
02992 
02993       // Pop the new IR object back off the scope stack.
02994       if (be_global->ifr_scopes ().pop (used_scope) != 0)
02995         {
02996           ACE_ERROR_RETURN ((
02997               LM_ERROR,
02998               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02999               ACE_TEXT ("create_component_def -")
03000               ACE_TEXT (" scope pop failed\n")
03001             ),
03002             -1
03003           );
03004         }
03005     }
03006   else
03007     {
03008       ACE_ERROR_RETURN ((
03009           LM_ERROR,
03010           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_component_def -")
03011           ACE_TEXT (" scope stack is empty\n")
03012         ),
03013         -1
03014       );
03015     }
03016 
03017   return 0;
03018 }

int ifr_adding_visitor::create_event_def ( AST_EventType *  node  )  [protected]

Definition at line 3135 of file ifr_adding_visitor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), be_global, fill_abstract_base_values(), fill_base_value(), fill_initializers(), fill_supported_interfaces(), BE_GlobalData::ifr_scopes(), ir_current_, LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), and ACE_Unbounded_Stack< T >::top().

Referenced by visit_eventtype().

03136 {
03137   CORBA::Container_ptr current_scope =
03138     CORBA::Container::_nil ();
03139 
03140   if (be_global->ifr_scopes ().top (current_scope) == 0)
03141     {
03142       CORBA::ValueDef_var base_value;
03143       this->fill_base_value (base_value.out (),
03144                              node);
03145 
03146       CORBA::ValueDefSeq abstract_base_values;
03147       this->fill_abstract_base_values (abstract_base_values,
03148                                        node);
03149 
03150       CORBA::InterfaceDefSeq supported_interfaces;
03151       this->fill_supported_interfaces (supported_interfaces,
03152                                        node);
03153 
03154       CORBA::ExtInitializerSeq initializers;
03155       this->fill_initializers (initializers,
03156                                node);
03157 
03158       CORBA::ComponentIR::Container_var ccm_scope =
03159         CORBA::ComponentIR::Container::_narrow (current_scope);
03160 
03161       CORBA::ExtValueDef_var new_def =
03162         ccm_scope->create_event (
03163                        node->repoID (),
03164                        node->local_name ()->get_string (),
03165                        node->version (),
03166                        static_cast<CORBA::Boolean> (node->custom ()),
03167                        static_cast<CORBA::Boolean> (node->is_abstract ()),
03168                        base_value.in (),
03169                        static_cast<CORBA::Boolean> (node->truncatable ()),
03170                        abstract_base_values,
03171                        supported_interfaces,
03172                        initializers
03173                      );
03174 
03175       node->ifr_added (true);
03176 
03177       // Push the new IR object onto the scope stack.
03178       CORBA::Container_var new_scope =
03179         CORBA::Container::_narrow (new_def.in ());
03180 
03181       if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
03182         {
03183           ACE_ERROR_RETURN ((
03184               LM_ERROR,
03185               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03186               ACE_TEXT ("create_event_def -")
03187               ACE_TEXT (" scope push failed\n")
03188             ),
03189             -1
03190           );
03191         }
03192 
03193       // Visit the members, if any.
03194       if (this->visit_scope (node) == -1)
03195         {
03196           ACE_ERROR_RETURN ((
03197               LM_ERROR,
03198               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03199               ACE_TEXT ("create_event_def -")
03200               ACE_TEXT (" visit_scope failed\n")
03201             ),
03202             -1
03203           );
03204         }
03205 
03206       // This spot in the AST doesn't necessarily have to be the
03207       // interface definition - it could be any reference to it.
03208       // The front end will already have fully defined it, so all
03209       // the info is available anywhere. So it's a good idea to
03210       // update the current IR object holder now. This will
03211       // consume the objref pointer.
03212       this->ir_current_ =
03213         CORBA::IDLType::_duplicate (new_def.in ());
03214 
03215       CORBA::Container_ptr used_scope =
03216         CORBA::Container::_nil ();
03217 
03218       // Pop the new IR object back off the scope stack.
03219       if (be_global->ifr_scopes ().pop (used_scope) != 0)
03220         {
03221           ACE_ERROR_RETURN ((
03222               LM_ERROR,
03223               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03224               ACE_TEXT ("create_event_def -")
03225               ACE_TEXT (" scope pop failed\n")
03226             ),
03227             -1
03228           );
03229         }
03230     }
03231   else
03232     {
03233       ACE_ERROR_RETURN ((
03234           LM_ERROR,
03235           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_event_def -")
03236           ACE_TEXT (" scope stack is empty\n")
03237         ),
03238         -1
03239       );
03240     }
03241 
03242   return 0;
03243 }

int ifr_adding_visitor::create_home_def ( AST_Home *  node  )  [protected]

Definition at line 3021 of file ifr_adding_visitor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), be_global, fill_base_home(), fill_managed_component(), fill_primary_key(), fill_supported_interfaces(), BE_GlobalData::ifr_scopes(), ir_current_, LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), ACE_Unbounded_Stack< T >::top(), visit_all_factories(), and visit_all_finders().

Referenced by visit_home().

03022 {
03023   CORBA::Container_ptr current_scope =
03024     CORBA::Container::_nil ();
03025 
03026   if (be_global->ifr_scopes ().top (current_scope) == 0)
03027     {
03028       CORBA::ComponentIR::HomeDef_var base_home;
03029       this->fill_base_home (base_home.out (),
03030                             node);
03031 
03032       CORBA::ComponentIR::ComponentDef_var managed_component;
03033       this->fill_managed_component (managed_component.out (),
03034                                     node);
03035 
03036       CORBA::InterfaceDefSeq supported_interfaces;
03037       this->fill_supported_interfaces (supported_interfaces,
03038                                        node);
03039 
03040       CORBA::ValueDef_var primary_key;
03041       this->fill_primary_key (primary_key.out (),
03042                               node);
03043 
03044       CORBA::ComponentIR::Container_var ccm_scope =
03045         CORBA::ComponentIR::Container::_narrow (current_scope);
03046 
03047       CORBA::ComponentIR::HomeDef_var new_def =
03048         ccm_scope->create_home (node->repoID (),
03049                                 node->local_name ()->get_string (),
03050                                 node->version (),
03051                                 base_home.in (),
03052                                 managed_component.in (),
03053                                 supported_interfaces,
03054                                 primary_key.in ());
03055 
03056       node->ifr_added (true);
03057 
03058       // Push the new IR object onto the scope stack.
03059       CORBA::Container_var new_scope =
03060         CORBA::Container::_narrow (new_def.in ());
03061 
03062       if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
03063         {
03064           ACE_ERROR_RETURN ((
03065               LM_ERROR,
03066               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03067               ACE_TEXT ("create_home_def -")
03068               ACE_TEXT (" scope push failed\n")
03069             ),
03070             -1
03071           );
03072         }
03073 
03074       // Visit the members, if any.
03075       if (this->visit_scope (node) == -1)
03076         {
03077           ACE_ERROR_RETURN ((
03078               LM_ERROR,
03079               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03080               ACE_TEXT ("create_home_def -")
03081               ACE_TEXT (" visit_scope failed\n")
03082             ),
03083             -1
03084           );
03085         }
03086 
03087       // Get the contents of these lists into the repository.
03088 
03089       this->visit_all_factories (node,
03090                                  new_def.in ());
03091 
03092       this->visit_all_finders (node,
03093                                new_def.in ());
03094 
03095       // This spot in the AST doesn't necessarily have to be the
03096       // interface definition - it could be any reference to it.
03097       // The front end will already have fully defined it, so all
03098       // the info is available anywhere. So it's a good idea to
03099       // update the current IR object holder now. This will
03100       // consume the objref pointer.
03101       this->ir_current_ =
03102         CORBA::IDLType::_duplicate (new_def.in ());
03103 
03104       CORBA::Container_ptr used_scope =
03105         CORBA::Container::_nil ();
03106 
03107       // Pop the new IR object back off the scope stack.
03108       if (be_global->ifr_scopes ().pop (used_scope) != 0)
03109         {
03110           ACE_ERROR_RETURN ((
03111               LM_ERROR,
03112               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03113               ACE_TEXT ("create_home_def -")
03114               ACE_TEXT (" scope pop failed\n")
03115             ),
03116             -1
03117           );
03118         }
03119     }
03120   else
03121     {
03122       ACE_ERROR_RETURN ((
03123           LM_ERROR,
03124           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_home_def -")
03125           ACE_TEXT (" scope stack is empty\n")
03126         ),
03127         -1
03128       );
03129     }
03130 
03131   return 0;
03132 }

int ifr_adding_visitor::create_interface_def ( AST_Interface *  node  )  [protected]

Definition at line 2589 of file ifr_adding_visitor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

Referenced by visit_interface().

02590 {
02591   CORBA::ULong n_parents = static_cast<CORBA::ULong> (node->n_inherits ());
02592   AST_Interface **parents = node->inherits ();
02593   CORBA::Contained_var result;
02594   CORBA::AbstractInterfaceDefSeq abs_bases;
02595   CORBA::InterfaceDefSeq bases;
02596 
02597   if (node->is_abstract ())
02598     {
02599       abs_bases.length (n_parents);
02600 
02601       // Construct a list of the parents.
02602       for (CORBA::ULong i = 0; i < n_parents; ++i)
02603         {
02604           result =
02605             be_global->repository ()->lookup_id (parents[i]->repoID ());
02606 
02607           // If we got to visit_interface() from a forward declared interface,
02608           // this node may not yet be in the repository.
02609           if (CORBA::is_nil (result.in ()))
02610             {
02611               int status = this->create_interface_def (parents[i]);
02612 
02613               if (status != 0)
02614                 {
02615                   ACE_ERROR_RETURN ((
02616                       LM_ERROR,
02617                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02618                       ACE_TEXT ("create_interface_def -")
02619                       ACE_TEXT (" parent interfacedef creation failed\n")
02620                     ),
02621                     -1
02622                   );
02623                 }
02624 
02625               bases[i] =
02626                 CORBA::AbstractInterfaceDef::_narrow (this->ir_current_.in ());
02627             }
02628           else
02629             {
02630               abs_bases[i] =
02631                 CORBA::AbstractInterfaceDef::_narrow (result.in ());
02632             }
02633 
02634           if (CORBA::is_nil (abs_bases[i]))
02635             {
02636               ACE_ERROR_RETURN ((
02637                   LM_ERROR,
02638                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02639                   ACE_TEXT ("create_interface_def -")
02640                   ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
02641                 ),
02642                 -1
02643               );
02644             }
02645         }
02646     }
02647   else
02648     {
02649       bases.length (n_parents);
02650 
02651       // Construct a list of the parents.
02652       for (CORBA::ULong i = 0; i < n_parents; ++i)
02653         {
02654           result =
02655             be_global->repository ()->lookup_id (parents[i]->repoID ());
02656 
02657           // If we got to visit_interface() from a forward declared interface,
02658           // this node may not yet be in the repository.
02659           if (CORBA::is_nil (result.in ()))
02660             {
02661               int status = this->create_interface_def (parents[i]);
02662 
02663               if (status != 0)
02664                 {
02665                   ACE_ERROR_RETURN ((
02666                       LM_ERROR,
02667                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02668                       ACE_TEXT ("create_interface_def -")
02669                       ACE_TEXT (" parent interfacedef creation failed\n")
02670                     ),
02671                     -1
02672                   );
02673                 }
02674 
02675               bases[i] = CORBA::InterfaceDef::_narrow (this->ir_current_.in ());
02676             }
02677           else
02678             {
02679               bases[i] = CORBA::InterfaceDef::_narrow (result.in ());
02680             }
02681 
02682           if (CORBA::is_nil (bases[i]))
02683             {
02684               ACE_ERROR_RETURN ((
02685                   LM_ERROR,
02686                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02687                   ACE_TEXT ("create_interface_def -")
02688                   ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
02689                 ),
02690                 -1
02691               );
02692             }
02693         }
02694     }
02695 
02696   CORBA::Container_ptr current_scope =
02697     CORBA::Container::_nil ();
02698 
02699   if (be_global->ifr_scopes ().top (current_scope) == 0)
02700     {
02701       CORBA::InterfaceDef_var new_def;
02702 
02703       if (node->is_local ())
02704         {
02705           new_def =
02706             current_scope->create_local_interface (
02707                                node->repoID (),
02708                                node->local_name ()->get_string (),
02709                                node->version (),
02710                                bases
02711                              );
02712         }
02713       else if (node->is_abstract ())
02714         {
02715           new_def =
02716             current_scope->create_abstract_interface (
02717                                node->repoID (),
02718                                node->local_name ()->get_string (),
02719                                node->version (),
02720                                abs_bases
02721                              );
02722         }
02723       else
02724         {
02725           new_def =
02726             current_scope->create_interface (
02727                                node->repoID (),
02728                                node->local_name ()->get_string (),
02729                                node->version (),
02730                                bases
02731                              );
02732         }
02733 
02734 
02735       node->ifr_added (true);
02736 
02737       // Push the new IR object onto the scope stack.
02738       CORBA::Container_var new_scope =
02739         CORBA::Container::_narrow (new_def.in ());
02740 
02741       if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
02742         {
02743           ACE_ERROR_RETURN ((
02744               LM_ERROR,
02745               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02746               ACE_TEXT ("create_interface_def -")
02747               ACE_TEXT (" scope push failed\n")
02748             ),
02749             -1
02750           );
02751         }
02752 
02753       // Visit the members, if any.
02754       if (this->visit_scope (node) == -1)
02755         {
02756           ACE_ERROR_RETURN ((
02757               LM_ERROR,
02758               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02759               ACE_TEXT ("create_interface_def -")
02760               ACE_TEXT (" visit_scope failed\n")
02761             ),
02762             -1
02763           );
02764         }
02765 
02766       // This spot in the AST doesn't necessarily have to be the
02767       // interface definition - it could be any reference to it.
02768       // The front end will already have fully defined it, so all
02769       // the info is available anywhere. So it's a good idea to
02770       // update the current IR object holder now. This will
02771       // consume the objref pointer.
02772       this->ir_current_ =
02773         CORBA::IDLType::_duplicate (new_def.in ());
02774 
02775       CORBA::Container_ptr used_scope =
02776         CORBA::Container::_nil ();
02777 
02778       // Pop the new IR object back off the scope stack.
02779       if (be_global->ifr_scopes ().pop (used_scope) != 0)
02780         {
02781           ACE_ERROR_RETURN ((
02782               LM_ERROR,
02783               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02784               ACE_TEXT ("create_interface_def -")
02785               ACE_TEXT (" scope pop failed\n")
02786             ),
02787             -1
02788           );
02789         }
02790     }
02791   else
02792     {
02793       ACE_ERROR_RETURN ((
02794           LM_ERROR,
02795           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_interface_def -")
02796           ACE_TEXT (" scope stack is empty\n")
02797         ),
02798         -1
02799       );
02800     }
02801 
02802   return 0;
02803 }

int ifr_adding_visitor::create_value_def ( AST_ValueType *  node  )  [protected]

Definition at line 2806 of file ifr_adding_visitor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), be_global, fill_abstract_base_values(), fill_base_value(), fill_initializers(), fill_supported_interfaces(), BE_GlobalData::ifr_scopes(), ir_current_, LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), and ACE_Unbounded_Stack< T >::top().

Referenced by visit_valuetype().

02807 {
02808   CORBA::Container_ptr current_scope =
02809     CORBA::Container::_nil ();
02810 
02811   if (be_global->ifr_scopes ().top (current_scope) == 0)
02812     {
02813       CORBA::ValueDef_var base_value;
02814       this->fill_base_value (base_value.out (),
02815                              node);
02816 
02817       CORBA::ValueDefSeq abstract_base_values;
02818       this->fill_abstract_base_values (abstract_base_values,
02819                                        node);
02820 
02821       CORBA::InterfaceDefSeq supported_interfaces;
02822       this->fill_supported_interfaces (supported_interfaces,
02823                                        node);
02824 
02825       CORBA::ExtInitializerSeq initializers;
02826       this->fill_initializers (initializers,
02827                                node);
02828 
02829       CORBA::ExtValueDef_var new_def =
02830         current_scope->create_ext_value (
02831                            node->repoID (),
02832                            node->local_name ()->get_string (),
02833                            node->version (),
02834                            static_cast<CORBA::Boolean> (node->custom ()),
02835                            static_cast<CORBA::Boolean> (node->is_abstract ()),
02836                            base_value.in (),
02837                            static_cast<CORBA::Boolean> (node->truncatable ()),
02838                            abstract_base_values,
02839                            supported_interfaces,
02840                            initializers
02841                          );
02842 
02843       node->ifr_added (true);
02844 
02845       // Push the new IR object onto the scope stack.
02846       CORBA::Container_var new_scope =
02847         CORBA::Container::_narrow (new_def.in ());
02848 
02849       if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
02850         {
02851           ACE_ERROR_RETURN ((
02852               LM_ERROR,
02853               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02854               ACE_TEXT ("create_value_def -")
02855               ACE_TEXT (" scope push failed\n")
02856             ),
02857             -1
02858           );
02859         }
02860 
02861       // Visit the members, if any.
02862       if (this->visit_scope (node) == -1)
02863         {
02864           ACE_ERROR_RETURN ((
02865               LM_ERROR,
02866               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02867               ACE_TEXT ("create_value_def -")
02868               ACE_TEXT (" visit_scope failed\n")
02869             ),
02870             -1
02871           );
02872         }
02873 
02874       // This spot in the AST doesn't necessarily have to be the
02875       // interface definition - it could be any reference to it.
02876       // The front end will already have fully defined it, so all
02877       // the info is available anywhere. So it's a good idea to
02878       // update the current IR object holder now. This will
02879       // consume the objref pointer.
02880       this->ir_current_ =
02881         CORBA::IDLType::_duplicate (new_def.in ());
02882 
02883       CORBA::Container_ptr used_scope =
02884         CORBA::Container::_nil ();
02885 
02886       // Pop the new IR object back off the scope stack.
02887       if (be_global->ifr_scopes ().pop (used_scope) != 0)
02888         {
02889           ACE_ERROR_RETURN ((
02890               LM_ERROR,
02891               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02892               ACE_TEXT ("create_value_def -")
02893               ACE_TEXT (" scope pop failed\n")
02894             ),
02895             -1
02896           );
02897         }
02898     }
02899   else
02900     {
02901       ACE_ERROR_RETURN ((
02902           LM_ERROR,
02903           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_value_def -")
02904           ACE_TEXT (" scope stack is empty\n")
02905         ),
02906         -1
02907       );
02908     }
02909 
02910   return 0;
02911 }

int ifr_adding_visitor::create_value_member ( AST_Field *  node  )  [protected]

Definition at line 3246 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::ifr_scopes(), ir_current_, LM_ERROR, BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

Referenced by visit_field().

03247 {
03248   try
03249     {
03250       AST_Type *bt = node->field_type ();
03251       AST_Decl::NodeType nt = bt->node_type ();
03252 
03253       // We can't use lookup_id() on these, because
03254       // they don't inherit from Contained.
03255       if (nt == AST_Decl::NT_pre_defined
03256           || nt == AST_Decl::NT_string
03257           || nt == AST_Decl::NT_wstring
03258           || nt == AST_Decl::NT_array
03259           || nt == AST_Decl::NT_sequence)
03260         {
03261           /// This will put the repo entry into ir_current_.
03262           if (bt->ast_accept (this) != 0)
03263             {
03264               ACE_ERROR_RETURN ((
03265                   LM_ERROR,
03266                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03267                   ACE_TEXT ("create_value_member -")
03268                   ACE_TEXT (" visit base type failed\n")
03269                 ),
03270                 -1
03271               );
03272             }
03273         }
03274       else
03275         {
03276           // If the IDL is legal, this will succeed.
03277           CORBA::Contained_var holder =
03278                 be_global->repository ()->lookup_id (bt->repoID ());
03279 
03280           this->ir_current_ =
03281             CORBA::IDLType::_narrow (holder.in ());
03282         }
03283 
03284       CORBA::Visibility vis = CORBA::PUBLIC_MEMBER;
03285 
03286       switch (node->visibility ())
03287         {
03288           case AST_Field::vis_PUBLIC:
03289             break;
03290           case AST_Field::vis_PRIVATE:
03291             vis = CORBA::PRIVATE_MEMBER;
03292             break;
03293           default:
03294             ACE_ERROR_RETURN ((
03295                 LM_ERROR,
03296                 ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_value_member -")
03297                 ACE_TEXT (" bad visibility value in node\n")
03298               ),
03299               -1
03300             );
03301         };
03302 
03303       CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
03304 
03305       if (be_global->ifr_scopes ().top (current_scope) != 0)
03306         {
03307           ACE_ERROR_RETURN ((
03308               LM_ERROR,
03309               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03310               ACE_TEXT ("create_value_member -")
03311               ACE_TEXT (" scope stack empty\n")
03312             ),
03313             -1
03314           );
03315         }
03316 
03317       CORBA::ValueDef_var vt =
03318         CORBA::ValueDef::_narrow (current_scope);
03319 
03320       CORBA::ValueMemberDef_var vm =
03321         vt->create_value_member (node->repoID (),
03322                                  node->local_name ()->get_string (),
03323                                  node->version (),
03324                                  this->ir_current_.in (),
03325                                  vis);
03326     }
03327   catch (const CORBA::Exception& ex)
03328     {
03329       ex._tao_print_exception (ACE_TEXT ("create_value_member"));
03330 
03331       return -1;
03332     }
03333 
03334   return 0;
03335 }

void ifr_adding_visitor::element_type ( AST_Type *  base_type,
bool  owned = false 
) [protected]

Definition at line 2548 of file ifr_adding_visitor.cpp.

References ACE_ERROR, ACE_TEXT(), be_global, ir_current_, CORBA::is_nil(), LM_ERROR, and BE_GlobalData::repository().

Referenced by visit_array(), visit_sequence(), visit_typedef(), and visit_valuebox().

02549 {
02550   AST_Decl::NodeType nt = base_type->node_type ();
02551   bool no_repo_id = nt == AST_Decl::NT_array
02552                     || nt == AST_Decl::NT_sequence
02553                     || base_type->anonymous ();
02554 
02555   if (no_repo_id || owned)
02556     {
02557       if (base_type->ast_accept (this) == -1)
02558         {
02559           ACE_ERROR ((
02560               LM_ERROR,
02561               ACE_TEXT ("(%N:%l) ifr_adding_visitor::element_type -")
02562               ACE_TEXT (" failed to accept visitor\n")
02563             ));
02564 
02565           throw Bailout ();
02566         }
02567     }
02568   else
02569     {
02570       CORBA::Contained_var contained =
02571         be_global->repository ()->lookup_id (base_type->repoID ());
02572 
02573       if (CORBA::is_nil (contained.in ()))
02574         {
02575           ACE_ERROR ((
02576               LM_ERROR,
02577               ACE_TEXT ("(%N:%l) ifr_adding_visitor::element_type -")
02578               ACE_TEXT (" lookup_id failed\n")
02579             ));
02580 
02581           throw Bailout ();
02582         }
02583 
02584       this->ir_current_ = CORBA::IDLType::_narrow (contained.in ());
02585     }
02586 }

void ifr_adding_visitor::expand_id ( ACE_CString str,
const char *  local_name 
) [protected]

Definition at line 4042 of file ifr_adding_visitor.cpp.

References ACE_String_Base< CHAR >::rfind(), and ACE_String_Base< CHAR >::substr().

Referenced by visit_all_consumes(), visit_all_emits(), visit_all_provides(), visit_all_publishes(), and visit_all_uses().

04044 {
04045   ssize_t pos = str.rfind (':');
04046   str = str.substr (0, pos) + '/' + local_name + str.substr (pos);
04047 }

CORBA::PrimitiveKind ifr_adding_visitor::expr_type_to_pkind ( AST_Expression::ExprType  et  )  [protected]

Definition at line 2370 of file ifr_adding_visitor.cpp.

Referenced by visit_constant().

02371 {
02372   switch (et)
02373     {
02374     case AST_Expression::EV_short:
02375       return CORBA::pk_short;
02376     case AST_Expression::EV_ushort:
02377       return CORBA::pk_ushort;
02378     case AST_Expression::EV_long:
02379       return CORBA::pk_long;
02380     case AST_Expression::EV_ulong:
02381       return CORBA::pk_ulong;
02382     case AST_Expression::EV_longlong:
02383       return CORBA::pk_longlong;
02384     case AST_Expression::EV_ulonglong:
02385       return CORBA::pk_ulonglong;
02386     case AST_Expression::EV_float:
02387       return CORBA::pk_float;
02388     case AST_Expression::EV_double:
02389       return CORBA::pk_double;
02390     case AST_Expression::EV_longdouble:
02391       return CORBA::pk_longdouble;
02392     case AST_Expression::EV_char:
02393       return CORBA::pk_char;
02394     case AST_Expression::EV_wchar:
02395       return CORBA::pk_wchar;
02396     case AST_Expression::EV_octet:
02397       return CORBA::pk_octet;
02398     case AST_Expression::EV_bool:
02399       return CORBA::pk_boolean;
02400     case AST_Expression::EV_string:
02401       return CORBA::pk_string;
02402     case AST_Expression::EV_wstring:
02403       return CORBA::pk_wstring;
02404     case AST_Expression::EV_any:
02405       return CORBA::pk_any;
02406     case AST_Expression::EV_void:
02407       return CORBA::pk_void;
02408     case AST_Expression::EV_none:
02409       return CORBA::pk_null;
02410     default:
02411       return CORBA::pk_null;
02412     }
02413 }

void ifr_adding_visitor::fill_abstract_base_values ( CORBA::ValueDefSeq &  result,
AST_ValueType *  node 
) [protected]

Definition at line 3520 of file ifr_adding_visitor.cpp.

Referenced by create_event_def(), create_value_def(), visit_eventtype(), and visit_valuetype().

03522 {
03523   CORBA::Long s_length = node->n_inherits ();
03524   result.length (0);
03525 
03526   // Not sure if this could be negative in some default case or
03527   // not. If it's 0, we should make the call anyway to clear
03528   // existing entries, if any,  from the repository.
03529   if (s_length > 0)
03530     {
03531       AST_Interface **list = node->inherits ();
03532       CORBA::ULong u_length = static_cast<CORBA::ULong> (s_length);
03533       bool first_abs = list[0]->is_abstract ();
03534       result.length (first_abs ? u_length : u_length - 1);
03535 
03536       for (CORBA::ULong i = 0; i < u_length; ++i)
03537         {
03538           if (i == 0 && ! first_abs)
03539             {
03540               continue;
03541             }
03542 
03543           // Get list[i] into ir_current_.
03544           (void) list[i]->ast_accept (this);
03545 
03546           result[first_abs ? i : i - 1] =
03547             CORBA::ValueDef::_narrow (this->ir_current_.in ());
03548         }
03549     }
03550 }

void ifr_adding_visitor::fill_base_component ( CORBA::ComponentIR::ComponentDef_ptr &  result,
AST_Component *  node 
) [protected]

Definition at line 3400 of file ifr_adding_visitor.cpp.

References be_global, CORBA::is_nil(), and BE_GlobalData::repository().

Referenced by create_component_def(), visit_component(), and visit_component_fwd().

03404 {
03405   result = CORBA::ComponentIR::ComponentDef::_nil ();
03406   AST_Component *base_component = node->base_component ();
03407 
03408   if (base_component == 0)
03409     {
03410       return;
03411     }
03412 
03413   CORBA::Contained_var holder =
03414     be_global->repository ()->lookup_id (
03415                                   base_component->repoID ()
03416                                 );
03417 
03418   if (!CORBA::is_nil (holder.in ()))
03419     {
03420       result =
03421         CORBA::ComponentIR::ComponentDef::_narrow (holder.in ());
03422     }
03423 }

void ifr_adding_visitor::fill_base_home ( CORBA::ComponentIR::HomeDef_ptr &  result,
AST_Home *  node 
) [protected]

Definition at line 3426 of file ifr_adding_visitor.cpp.

References be_global, CORBA::is_nil(), and BE_GlobalData::repository().

Referenced by create_home_def().

03428 {
03429   result = CORBA::ComponentIR::HomeDef::_nil ();
03430   AST_Home *base_home = node->base_home ();
03431 
03432   if (base_home == 0)
03433     {
03434       return;
03435     }
03436 
03437   CORBA::Contained_var holder =
03438     be_global->repository ()->lookup_id (
03439                                   base_home->repoID ()
03440                                 );
03441 
03442   if (!CORBA::is_nil (holder.in ()))
03443     {
03444       result =
03445         CORBA::ComponentIR::HomeDef::_narrow (holder.in ());
03446     }
03447   else
03448     {
03449       /// Maybe the base home is in an included IDL file - put it in
03450       /// the repository and go again.
03451       (void) base_home->ast_accept (this);
03452       this->fill_base_home (result,
03453                             node);
03454     }
03455 }

void ifr_adding_visitor::fill_base_value ( CORBA::ValueDef_ptr &  result,
AST_ValueType *  node 
) [protected]

Definition at line 3376 of file ifr_adding_visitor.cpp.

References be_global, CORBA::is_nil(), and BE_GlobalData::repository().

Referenced by create_event_def(), create_value_def(), visit_eventtype(), and visit_valuetype().

03378 {
03379   result = CORBA::ValueDef::_nil ();
03380   AST_ValueType *base_value = node->inherits_concrete ();
03381 
03382   if (base_value == 0)
03383     {
03384       return;
03385     }
03386 
03387   CORBA::Contained_var holder =
03388     be_global->repository ()->lookup_id (
03389                                   base_value->repoID ()
03390                                 );
03391 
03392   if (!CORBA::is_nil (holder.in ()))
03393     {
03394       result =
03395         CORBA::ValueDef::_narrow (holder.in ());
03396     }
03397 }

void ifr_adding_visitor::fill_exceptions ( CORBA::ExceptionDefSeq &  result,
UTL_ExceptList *  list 
) [protected]

Definition at line 3762 of file ifr_adding_visitor.cpp.

References be_global, and BE_GlobalData::repository().

03764 {
03765   if (list == 0)
03766     {
03767       result.length (0);
03768       return;
03769     }
03770 
03771   result.length (static_cast<CORBA::ULong> (list->length ()));
03772   CORBA::ULong index = 0;
03773   AST_Decl *d = 0;
03774   CORBA::Contained_var holder;
03775 
03776   for (UTL_ExceptlistActiveIterator ei (list);
03777        !ei.is_done ();
03778        ei.next (), ++index)
03779     {
03780       d = ei.item ();
03781 
03782       // Just to make sure. The call will return quickly if d has already
03783       // been visited. Can't use ir_current_ because ExceptionDef doesn't
03784       // inherit from IDLType.
03785       (void) d->ast_accept (this);
03786 
03787       holder = be_global->repository ()->lookup_id (d->repoID ());
03788 
03789       result[index] =
03790         CORBA::ExceptionDef::_narrow (holder.in ());
03791     }
03792 }

void ifr_adding_visitor::fill_exceptions ( CORBA::ExceptionDefSeq &  result,
AST_Decl *  node 
) [protected]

Definition at line 3736 of file ifr_adding_visitor.cpp.

Referenced by fill_get_exceptions(), fill_set_exceptions(), visit_all_factories(), and visit_all_finders().

03738 {
03739   switch (node->node_type ())
03740     {
03741       case AST_Decl::NT_op:
03742         {
03743           AST_Operation *op = AST_Operation::narrow_from_decl (node);
03744           this->fill_exceptions (result,
03745                                  op->exceptions ());
03746           return;
03747         }
03748       case AST_Decl::NT_factory:
03749         {
03750           AST_Factory *f = AST_Factory::narrow_from_decl (node);
03751           this->fill_exceptions (result,
03752                                  f->exceptions ());
03753           return;
03754         }
03755       default:
03756         result.length (0);
03757         return;
03758     }
03759 }

void ifr_adding_visitor::fill_get_exceptions ( CORBA::ExceptionDefSeq &  result,
AST_Attribute *  node 
) [protected]

Definition at line 3720 of file ifr_adding_visitor.cpp.

References fill_exceptions().

Referenced by visit_attribute().

03722 {
03723   this->fill_exceptions (result,
03724                          node->get_get_exceptions ());
03725 }

void ifr_adding_visitor::fill_inherited_interfaces ( CORBA::InterfaceDefSeq &  result,
AST_Interface *  node 
) [protected]

Definition at line 3553 of file ifr_adding_visitor.cpp.

References fill_interfaces().

03555 {
03556   result.length (0);
03557   this->fill_interfaces (result,
03558                          node->inherits (),
03559                          node->n_inherits ());
03560 }

void ifr_adding_visitor::fill_initializers ( CORBA::ExtInitializerSeq &  result,
AST_ValueType *  node 
) [protected]

Definition at line 3628 of file ifr_adding_visitor.cpp.

References ACE_ERROR, ACE_TEXT(), LM_ERROR, ACE_Vector< T, DEFAULT_SIZE >::push_back(), ACE_Vector< T, DEFAULT_SIZE >::size(), and CORBA::string_dup().

Referenced by create_event_def(), create_value_def(), visit_eventtype(), and visit_valuetype().

03630 {
03631   result.length (0);
03632   AST_Decl *item = 0;
03633   ACE_Vector<AST_Factory *> factories;
03634 
03635   for (UTL_ScopeActiveIterator v_iter (node,
03636                                        UTL_Scope::IK_decls);
03637        !v_iter.is_done ();
03638        v_iter.next ())
03639     {
03640       item = v_iter.item ();
03641 
03642       if (item->node_type () == AST_Decl::NT_factory)
03643         {
03644           factories.push_back (AST_Factory::narrow_from_decl (item));
03645         }
03646     }
03647 
03648   CORBA::ULong n_factories = factories.size ();
03649 
03650   if (n_factories == 0)
03651     {
03652       return;
03653     }
03654 
03655   result.length (n_factories);
03656   CORBA::ULong n_args = 0;
03657   AST_Argument *arg = 0;
03658   CORBA::ULong index = 0;
03659   AST_Exception *excp = 0;
03660   CORBA::Contained_var holder;
03661 
03662   for (CORBA::ULong i = 0; i < n_factories; ++i)
03663     {
03664       result[i].name =
03665         CORBA::string_dup (factories[i]->local_name ()->get_string ());
03666       n_args = static_cast<CORBA::ULong> (factories[i]->argument_count ());
03667       result[i].members.length (n_args);
03668 
03669       // The factory should have nothing in its scope but args.
03670       for (UTL_ScopeActiveIterator f_iter (factories[i],
03671                                            UTL_Scope::IK_decls);
03672            !f_iter.is_done ();
03673            f_iter.next (), ++index)
03674         {
03675           arg = AST_Argument::narrow_from_decl (f_iter.item ());
03676           result[i].members[index].name =
03677             CORBA::string_dup (arg->local_name ()->get_string ());
03678           result[i].members[index].type =
03679             CORBA::TypeCode::_duplicate (CORBA::_tc_void);
03680 
03681           /// This will put the field type in ir_current_, and also add it
03682           /// to the repository if it's not already there.
03683           if (arg->field_type ()->ast_accept (this) != 0)
03684             {
03685               ACE_ERROR ((
03686                   LM_ERROR,
03687                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03688                   ACE_TEXT ("fill_initializers -")
03689                   ACE_TEXT (" failed to accept arg type visitor\n")
03690                 ));
03691             }
03692 
03693           result[i].members[index].type_def =
03694             CORBA::IDLType::_duplicate (this->ir_current_.in ());
03695         }
03696 
03697       CORBA::ULong n_exceptions =
03698         static_cast<CORBA::ULong> (factories[i]->n_exceptions ());
03699       result[i].exceptions.length (n_exceptions);
03700       index = 0;
03701 
03702       for (UTL_ExceptlistActiveIterator ei (factories[i]->exceptions ());
03703            !ei.is_done ();
03704            ei.next ())
03705         {
03706           excp = AST_Exception::narrow_from_decl (ei.item ());
03707           result[i].exceptions[index].name =
03708             CORBA::string_dup (excp->local_name ()->get_string ());
03709           result[i].exceptions[index].id = excp->repoID ();
03710           result[i].exceptions[index].defined_in =
03711             ScopeAsDecl (excp->defined_in ())->repoID ();
03712           result[i].exceptions[index].version = excp->version ();
03713           result[i].exceptions[index++].type =
03714             CORBA::TypeCode::_duplicate (CORBA::_tc_void);
03715         }
03716     }
03717 }

void ifr_adding_visitor::fill_interfaces ( CORBA::InterfaceDefSeq &  result,
AST_Interface **  list,
CORBA::Long  length 
) [protected]

Definition at line 3604 of file ifr_adding_visitor.cpp.

Referenced by fill_inherited_interfaces(), and fill_supported_interfaces().

03607 {
03608   // Not sure if this could be negative in some default case or
03609   // not. If it's 0, we should make the call anyway to clear
03610   // existing entries, if any,  from the repository.
03611   if (length > 0)
03612     {
03613       CORBA::ULong u_length = static_cast<CORBA::ULong> (length);
03614       result.length (u_length);
03615 
03616       for (CORBA::ULong i = 0; i < u_length; ++i)
03617         {
03618           // Get list[i] into ir_current_.
03619           (void) list[i]->ast_accept (this);
03620 
03621           result[i] =
03622             CORBA::InterfaceDef::_narrow (this->ir_current_.in ());
03623         }
03624     }
03625 }

void ifr_adding_visitor::fill_managed_component ( CORBA::ComponentIR::ComponentDef_ptr &  result,
AST_Home *  node 
) [protected]

Definition at line 3458 of file ifr_adding_visitor.cpp.

References be_global, CORBA::is_nil(), and BE_GlobalData::repository().

Referenced by create_home_def().

03462 {
03463   result = CORBA::ComponentIR::ComponentDef::_nil ();
03464   AST_Component *managed_component = node->managed_component ();
03465 
03466   if (managed_component == 0)
03467     {
03468       return;
03469     }
03470 
03471   CORBA::Contained_var holder =
03472     be_global->repository ()->lookup_id (managed_component->repoID ());
03473 
03474   if (!CORBA::is_nil (holder.in ()))
03475     {
03476       result =
03477         CORBA::ComponentIR::ComponentDef::_narrow (holder.in ());
03478     }
03479   else
03480     {
03481       /// Maybe the managed component is in an included IDL file - put it in
03482       /// the repository and go again.
03483       (void) managed_component->ast_accept (this);
03484       this->fill_managed_component (result,
03485                                     node);
03486     }
03487 }

void ifr_adding_visitor::fill_params ( CORBA::ParDescriptionSeq &  result,
AST_Operation *  node 
) [protected]

Definition at line 3795 of file ifr_adding_visitor.cpp.

References CORBA::string_dup().

Referenced by visit_all_factories(), and visit_all_finders().

03797 {
03798   AST_Argument *arg = 0;
03799   CORBA::ULong n_args = static_cast<CORBA::ULong> (node->argument_count ());
03800   result.length (n_args);
03801   CORBA::ULong index = 0;
03802   CORBA::Contained_var holder;
03803 
03804   for (UTL_ScopeActiveIterator iter (node,
03805                                      UTL_Scope::IK_decls);
03806        ! iter.is_done ();
03807        iter.next (), ++index)
03808     {
03809       arg = AST_Argument::narrow_from_decl (iter.item ());
03810       result[index].name =
03811         CORBA::string_dup (arg->local_name ()->get_string ());
03812       result[index].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void);
03813 
03814       // Get the arg type into ir_current_.
03815       (void) arg->ast_accept (this);
03816 
03817       result[index].type_def =
03818         CORBA::IDLType::_duplicate (this->ir_current_.in ());
03819 
03820       result[index].mode = CORBA::PARAM_IN;
03821     }
03822 }

void ifr_adding_visitor::fill_primary_key ( CORBA::ValueDef_ptr &  result,
AST_Home *  node 
) [protected]

Definition at line 3490 of file ifr_adding_visitor.cpp.

References be_global, CORBA::is_nil(), and BE_GlobalData::repository().

Referenced by create_home_def().

03492 {
03493   result = CORBA::ValueDef::_nil ();
03494   AST_ValueType *primary_key = node->primary_key ();
03495 
03496   if (primary_key == 0)
03497     {
03498       return;
03499     }
03500 
03501   CORBA::Contained_var holder =
03502     be_global->repository ()->lookup_id (primary_key->repoID ());
03503 
03504   if (!CORBA::is_nil (holder.in ()))
03505     {
03506       result =
03507         CORBA::ValueDef::_narrow (holder.in ());
03508     }
03509   else
03510     {
03511       /// Maybe the primary key is in an included IDL file - put it in
03512       /// the repository and go again.
03513       (void) primary_key->ast_accept (this);
03514       this->fill_primary_key (result,
03515                               node);
03516     }
03517 }

void ifr_adding_visitor::fill_set_exceptions ( CORBA::ExceptionDefSeq &  result,
AST_Attribute *  node 
) [protected]

Definition at line 3728 of file ifr_adding_visitor.cpp.

References fill_exceptions().

Referenced by visit_attribute().

03730 {
03731   this->fill_exceptions (result,
03732                          node->get_set_exceptions ());
03733 }

void ifr_adding_visitor::fill_supported_interfaces ( CORBA::InterfaceDefSeq &  result,
AST_Interface *  node 
) [protected]

Definition at line 3563 of file ifr_adding_visitor.cpp.

References fill_interfaces().

Referenced by create_component_def(), create_event_def(), create_home_def(), create_value_def(), visit_component(), visit_eventtype(), and visit_valuetype().

03565 {
03566   result.length (0);
03567   CORBA::Long s_length = 0;
03568   AST_Interface **list = 0;
03569 
03570   switch (node->node_type ())
03571     {
03572       case AST_Decl::NT_valuetype:
03573       case AST_Decl::NT_eventtype:
03574         {
03575           AST_ValueType *v = AST_ValueType::narrow_from_decl (node);
03576           s_length = v->n_supports ();
03577           list = v->supports ();
03578           break;
03579         }
03580       case AST_Decl::NT_component:
03581         {
03582           AST_Component *c = AST_Component::narrow_from_decl (node);
03583           s_length = c->n_supports ();
03584           list = c->supports ();
03585           break;
03586         }
03587       case AST_Decl::NT_home:
03588         {
03589           AST_Home *h = AST_Home::narrow_from_decl (node);
03590           s_length = h->n_supports ();
03591           list = h->supports ();
03592           break;
03593         }
03594       default:
03595         return;
03596     }
03597 
03598   this->fill_interfaces (result,
03599                          list,
03600                          s_length);
03601 }

void ifr_adding_visitor::get_referenced_type ( AST_Type *  node  )  [protected]

Definition at line 3338 of file ifr_adding_visitor.cpp.

References ACE_ERROR, ACE_TEXT(), be_global, ir_current_, LM_ERROR, and BE_GlobalData::repository().

Referenced by ifr_adding_visitor_operation::visit_argument(), visit_attribute(), ifr_adding_visitor_operation::visit_operation(), ifr_adding_visitor_union::visit_scope(), ifr_adding_visitor_structure::visit_scope(), and ifr_adding_visitor_exception::visit_scope().

03339 {
03340   switch (node->node_type ())
03341   {
03342     // For anonymous types, a new IR object is be created each
03343     // time, so we just visit the node, which get the object and
03344     // updates ir_current_.
03345     case AST_Decl::NT_pre_defined:
03346     case AST_Decl::NT_string:
03347     case AST_Decl::NT_wstring:
03348     case AST_Decl::NT_array:
03349     case AST_Decl::NT_sequence:
03350       if (node->ast_accept (this) == -1)
03351         {
03352           ACE_ERROR ((
03353               LM_ERROR,
03354               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03355               ACE_TEXT ("get_scope_member -")
03356               ACE_TEXT (" failed to accept visitor\n")
03357             ));
03358         }
03359 
03360       break;
03361     // For names types, we can just look up the entry and update
03362     // ir_current_.
03363     default:
03364       {
03365         CORBA::Contained_var prev_def =
03366           be_global->repository ()->lookup_id (node->repoID ());
03367 
03368         this->ir_current_ =
03369           CORBA::IDLType::_narrow (prev_def.in ());
03370         break;
03371       }
03372   }
03373 }

void ifr_adding_visitor::load_any ( AST_Expression::AST_ExprValue *  ev,
CORBA::Any &  any 
) [protected]

Definition at line 2471 of file ifr_adding_visitor.cpp.

References ACE_NEW, and ACE_OS::strlen().

Referenced by visit_constant(), and ifr_adding_visitor_union::visit_scope().

02473 {
02474   switch (ev->et)
02475     {
02476     case AST_Expression::EV_short:
02477       any <<= ev->u.sval;
02478       break;
02479     case AST_Expression::EV_ushort:
02480       any <<= ev->u.usval;
02481       break;
02482     case AST_Expression::EV_long:
02483       any <<= static_cast<CORBA::Long> (ev->u.lval);
02484       break;
02485     case AST_Expression::EV_ulong:
02486       any <<= static_cast<CORBA::ULong> (ev->u.ulval);
02487       break;
02488 #if !defined (ACE_LACKS_LONGLONG_T)
02489     case AST_Expression::EV_longlong:
02490       any <<= ev->u.llval;
02491       break;
02492     case AST_Expression::EV_ulonglong:
02493       any <<= ev->u.ullval;
02494       break;
02495 #endif /* !defined (ACE_LACKS_LONGLONG_T) */
02496     case AST_Expression::EV_float:
02497       any <<= ev->u.fval;
02498       break;
02499     case AST_Expression::EV_double:
02500       any <<= ev->u.dval;
02501       break;
02502 #if 0
02503     case AST_Expression::EV_longdouble:
02504     // Not implemented in IDL compiler.
02505 #endif
02506     case AST_Expression::EV_char:
02507       any <<= CORBA::Any::from_char (ev->u.cval);
02508       break;
02509     case AST_Expression::EV_wchar:
02510       any <<= CORBA::Any::from_wchar (ev->u.wcval);
02511       break;
02512     case AST_Expression::EV_octet:
02513       any <<= CORBA::Any::from_octet (ev->u.oval);
02514       break;
02515     case AST_Expression::EV_bool:
02516       any <<= CORBA::Any::from_boolean ((CORBA::Boolean) ev->u.bval);
02517       break;
02518     case AST_Expression::EV_string:
02519       any <<= ev->u.strval->get_string ();
02520       break;
02521     case AST_Expression::EV_wstring:
02522       {
02523         char *str = ev->u.wstrval;
02524         size_t len = ACE_OS::strlen (str);
02525         CORBA::WChar *wstr = 0;
02526         ACE_NEW (wstr,
02527                  CORBA::WChar[len + 1]);
02528 
02529         for (size_t i = 0; i < len; ++i)
02530           {
02531             wstr[i] = static_cast<CORBA::WChar> (str[i]);
02532           }
02533 
02534         wstr[len] = 0;
02535         any <<= wstr;
02536         delete wstr;
02537         break;
02538       }
02539     case AST_Expression::EV_enum:
02540       any <<= static_cast<CORBA::ULong> (ev->u.eval);
02541       break;
02542     default:
02543       break;
02544     }
02545 }

CORBA::PrimitiveKind ifr_adding_visitor::predefined_type_to_pkind ( AST_PredefinedType *  node  )  [protected]

Definition at line 2416 of file ifr_adding_visitor.cpp.

References ACE_OS::strcmp().

02417 {
02418   switch (node->pt ())
02419     {
02420     case AST_PredefinedType::PT_short:
02421       return CORBA::pk_short;
02422     case AST_PredefinedType::PT_ushort:
02423       return CORBA::pk_ushort;
02424     case AST_PredefinedType::PT_long:
02425       return CORBA::pk_long;
02426     case AST_PredefinedType::PT_ulong:
02427       return CORBA::pk_ulong;
02428     case AST_PredefinedType::PT_longlong:
02429       return CORBA::pk_longlong;
02430     case AST_PredefinedType::PT_ulonglong:
02431       return CORBA::pk_ulonglong;
02432     case AST_PredefinedType::PT_float:
02433       return CORBA::pk_float;
02434     case AST_PredefinedType::PT_double:
02435       return CORBA::pk_double;
02436     case AST_PredefinedType::PT_longdouble:
02437       return CORBA::pk_longdouble;
02438     case AST_PredefinedType::PT_char:
02439       return CORBA::pk_char;
02440     case AST_PredefinedType::PT_wchar:
02441       return CORBA::pk_wchar;
02442     case AST_PredefinedType::PT_octet:
02443       return CORBA::pk_octet;
02444     case AST_PredefinedType::PT_boolean:
02445       return CORBA::pk_boolean;
02446     case AST_PredefinedType::PT_any:
02447       return CORBA::pk_any;
02448     case AST_PredefinedType::PT_void:
02449       return CORBA::pk_void;
02450     case AST_PredefinedType::PT_object:
02451       return CORBA::pk_objref;
02452     case AST_PredefinedType::PT_pseudo:
02453       {
02454         const char *local_name = node->local_name ()->get_string ();
02455 
02456         if (!ACE_OS::strcmp (local_name, "Principal"))
02457           {
02458             return CORBA::pk_Principal;
02459           }
02460         else
02461           {
02462             return CORBA::pk_TypeCode;
02463           }
02464       }
02465     default:
02466       return CORBA::pk_null;
02467     }
02468 }

void ifr_adding_visitor::visit_all_consumes ( AST_Component *  node,
CORBA::ComponentIR::ComponentDef_ptr  c 
) [protected]

Definition at line 3952 of file ifr_adding_visitor.cpp.

References ACE_Unbounded_Queue_Iterator< T >::advance(), be_global, ACE_Unbounded_Queue_Iterator< T >::done(), expand_id(), ACE_Unbounded_Queue_Iterator< T >::next(), and BE_GlobalData::repository().

Referenced by create_component_def(), visit_component(), and visit_component_fwd().

03954 {
03955   AST_Component::port_description *tmp = 0;
03956   CORBA::Contained_var contained;
03957   CORBA::ComponentIR::EventDef_var event_type;
03958   CORBA::ComponentIR::ConsumesDef_var new_def;
03959   char *local_name = 0;
03960 
03961   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
03962            node->consumes ()
03963          );
03964        ! i.done ();
03965        i.advance ())
03966     {
03967       i.next (tmp);
03968       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ());
03969 
03970       event_type =
03971         CORBA::ComponentIR::EventDef::_narrow (contained.in ());
03972 
03973       ACE_CString str (node->repoID ());
03974       local_name = tmp->id->get_string ();
03975       this->expand_id (str, local_name);
03976       new_def = c->create_consumes (str.fast_rep (),
03977                                     local_name,
03978                                     tmp->impl->version (),
03979                                     event_type.in ());
03980     }
03981 }

void ifr_adding_visitor::visit_all_emits ( AST_Component *  node,
CORBA::ComponentIR::ComponentDef_ptr  c 
) [protected]

Definition at line 3888 of file ifr_adding_visitor.cpp.

References ACE_Unbounded_Queue_Iterator< T >::advance(), be_global, ACE_Unbounded_Queue_Iterator< T >::done(), expand_id(), ACE_Unbounded_Queue_Iterator< T >::next(), and BE_GlobalData::repository().

Referenced by create_component_def(), visit_component(), and visit_component_fwd().

03890 {
03891   AST_Component::port_description *tmp = 0;
03892   CORBA::Contained_var contained;
03893   CORBA::ComponentIR::EventDef_var event_type;
03894   CORBA::ComponentIR::EmitsDef_var new_def;
03895   char *local_name = 0;
03896 
03897   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
03898            node->emits ()
03899          );
03900        ! i.done ();
03901        i.advance ())
03902     {
03903       i.next (tmp);
03904       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ());
03905 
03906       event_type =
03907         CORBA::ComponentIR::EventDef::_narrow (contained.in ());
03908 
03909       ACE_CString str (node->repoID ());
03910       local_name = tmp->id->get_string ();
03911       this->expand_id (str, local_name);
03912       new_def = c->create_emits (str.fast_rep (),
03913                                  local_name,
03914                                  tmp->impl->version (),
03915                                  event_type.in ());
03916     }
03917 }

void ifr_adding_visitor::visit_all_factories ( AST_Home *  node,
CORBA::ComponentIR::HomeDef_ptr  h 
) [protected]

Definition at line 3984 of file ifr_adding_visitor.cpp.

References ACE_Unbounded_Queue_Iterator< T >::advance(), ACE_Unbounded_Queue_Iterator< T >::done(), fill_exceptions(), fill_params(), and ACE_Unbounded_Queue_Iterator< T >::next().

Referenced by create_home_def().

03986 {
03987   AST_Operation **tmp = 0;
03988   CORBA::Contained_var contained;
03989   CORBA::ComponentIR::FactoryDef_var new_def;
03990 
03991   for (ACE_Unbounded_Queue_Iterator<AST_Operation *> i (node->factories ());
03992        ! i.done ();
03993        i.advance ())
03994     {
03995       i.next (tmp);
03996       CORBA::ParDescriptionSeq params;
03997       this->fill_params (params,
03998                          *tmp);
03999 
04000       CORBA::ExceptionDefSeq exceptions;
04001       this->fill_exceptions (exceptions,
04002                              *tmp);
04003 
04004       new_def = h->create_factory ((*tmp)->repoID (),
04005                                    (*tmp)->local_name ()->get_string (),
04006                                    (*tmp)->version (),
04007                                    params,
04008                                    exceptions);
04009     }
04010 }

void ifr_adding_visitor::visit_all_finders ( AST_Home *  node,
CORBA::ComponentIR::HomeDef_ptr  h 
) [protected]

Definition at line 4013 of file ifr_adding_visitor.cpp.

References ACE_Unbounded_Queue_Iterator< T >::advance(), ACE_Unbounded_Queue_Iterator< T >::done(), fill_exceptions(), fill_params(), and ACE_Unbounded_Queue_Iterator< T >::next().

Referenced by create_home_def().

04015 {
04016   AST_Operation **tmp = 0;
04017   CORBA::Contained_var contained;
04018   CORBA::ComponentIR::FinderDef_var new_def;
04019 
04020   for (ACE_Unbounded_Queue_Iterator<AST_Operation *> i (node->finders ());
04021        ! i.done ();
04022        i.advance ())
04023     {
04024       i.next (tmp);
04025       CORBA::ParDescriptionSeq params;
04026       this->fill_params (params,
04027                          *tmp);
04028 
04029       CORBA::ExceptionDefSeq exceptions;
04030       this->fill_exceptions (exceptions,
04031                              *tmp);
04032 
04033       new_def = h->create_finder ((*tmp)->repoID (),
04034                                   (*tmp)->local_name ()->get_string (),
04035                                   (*tmp)->version (),
04036                                   params,
04037                                   exceptions);
04038     }
04039 }

void ifr_adding_visitor::visit_all_provides ( AST_Component *  node,
CORBA::ComponentIR::ComponentDef_ptr  c 
) [protected]

Definition at line 3825 of file ifr_adding_visitor.cpp.

References ACE_Unbounded_Queue_Iterator< T >::advance(), be_global, ACE_Unbounded_Queue_Iterator< T >::done(), expand_id(), ACE_Unbounded_Queue_Iterator< T >::next(), and BE_GlobalData::repository().

Referenced by create_component_def(), visit_component(), and visit_component_fwd().

03827 {
03828   AST_Component::port_description *tmp = 0;
03829   CORBA::Contained_var contained;
03830   CORBA::InterfaceDef_var interface_type;
03831   CORBA::ComponentIR::ProvidesDef_var new_def;
03832   char *local_name = 0;
03833 
03834   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
03835            node->provides ()
03836          );
03837        ! i.done ();
03838        i.advance ())
03839     {
03840       i.next (tmp);
03841       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ());
03842 
03843       interface_type = CORBA::InterfaceDef::_narrow (contained.in ());
03844 
03845       ACE_CString str (node->repoID ());
03846       local_name = tmp->id->get_string ();
03847       this->expand_id (str, local_name);
03848       new_def = c->create_provides (str.fast_rep (),
03849                                     local_name,
03850                                     tmp->impl->version (),
03851                                     interface_type.in ());
03852     }
03853 }

void ifr_adding_visitor::visit_all_publishes ( AST_Component *  node,
CORBA::ComponentIR::ComponentDef_ptr  c 
) [protected]

Definition at line 3920 of file ifr_adding_visitor.cpp.

References ACE_Unbounded_Queue_Iterator< T >::advance(), be_global, ACE_Unbounded_Queue_Iterator< T >::done(), expand_id(), ACE_Unbounded_Queue_Iterator< T >::next(), and BE_GlobalData::repository().

Referenced by create_component_def(), visit_component(), and visit_component_fwd().

03922 {
03923   AST_Component::port_description *tmp = 0;
03924   CORBA::Contained_var contained;
03925   CORBA::ComponentIR::EventDef_var event_type;
03926   CORBA::ComponentIR::PublishesDef_var new_def;
03927   char *local_name = 0;
03928 
03929   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
03930            node->publishes ()
03931          );
03932        ! i.done ();
03933        i.advance ())
03934     {
03935       i.next (tmp);
03936       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ());
03937 
03938       event_type =
03939         CORBA::ComponentIR::EventDef::_narrow (contained.in ());
03940 
03941       ACE_CString str (node->repoID ());
03942       local_name = tmp->id->get_string ();
03943       this->expand_id (str, local_name);
03944       new_def = c->create_publishes (str.fast_rep (),
03945                                      local_name,
03946                                      tmp->impl->version (),
03947                                      event_type.in ());
03948     }
03949 }

void ifr_adding_visitor::visit_all_uses ( AST_Component *  node,
CORBA::ComponentIR::ComponentDef_ptr  c 
) [protected]

Definition at line 3856 of file ifr_adding_visitor.cpp.

References ACE_Unbounded_Queue_Iterator< T >::advance(), be_global, ACE_Unbounded_Queue_Iterator< T >::done(), expand_id(), ACE_Unbounded_Queue_Iterator< T >::next(), and BE_GlobalData::repository().

Referenced by create_component_def(), visit_component(), and visit_component_fwd().

03858 {
03859   AST_Component::port_description *tmp = 0;
03860   CORBA::Contained_var contained;
03861   CORBA::InterfaceDef_var interface_type;
03862   CORBA::ComponentIR::UsesDef_var new_def;
03863   char *local_name = 0;
03864 
03865   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
03866            node->uses ()
03867          );
03868        ! i.done ();
03869        i.advance ())
03870     {
03871       i.next (tmp);
03872       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ());
03873 
03874       interface_type = CORBA::InterfaceDef::_narrow (contained.in ());
03875 
03876       ACE_CString str (node->repoID ());
03877       local_name = tmp->id->get_string ();
03878       this->expand_id (str, local_name);
03879       new_def = c->create_uses (str.fast_rep (),
03880                                 local_name,
03881                                 tmp->impl->version (),
03882                                 interface_type.in (),
03883                                 static_cast<CORBA::Boolean> (tmp->is_multiple));
03884     }
03885 }

int ifr_adding_visitor::visit_array ( AST_Array *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 2101 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_TEXT(), be_global, element_type(), and BE_GlobalData::repository().

02102 {
02103   try
02104     {
02105       bool owned = false;
02106       AST_Type *bt = node->base_type ();
02107       UTL_Scope *bts = bt->defined_in ();
02108       UTL_Scope *ns = node->defined_in ();
02109  
02110       if (bts == ns && !bt->ifr_added ())
02111         {
02112           // What we most likely have if we get here is an
02113           // anonymous array member whose base type is
02114           // defined as part of the array declaration.
02115           // Setting the boolean to TRUE and passing it
02116           // to element_type() will force the base type
02117           // to be added to the IFR before anything else
02118           // happens.
02119           owned = true;
02120         }
02121  
02122       this->element_type (bt, owned);
02123 
02124       AST_Expression **dims = node->dims ();
02125 
02126       for (unsigned long i = node->n_dims (); i > 0; --i)
02127         {
02128           this->ir_current_ =
02129             be_global->repository ()->create_array (
02130                 dims[i - 1]->ev ()->u.ulval,
02131                 this->ir_current_.in ()
02132               );
02133         }
02134     }
02135   catch (const CORBA::Exception& ex)
02136     {
02137       ex._tao_print_exception (ACE_TEXT ("visit_array"));
02138 
02139       return -1;
02140     }
02141 
02142   return 0;
02143 }

int ifr_adding_visitor::visit_attribute ( AST_Attribute *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1797 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, fill_get_exceptions(), fill_set_exceptions(), get_referenced_type(), BE_GlobalData::ifr_scopes(), ir_current_, LM_ERROR, and ACE_Unbounded_Stack< T >::top().

01798 {
01799   try
01800     {
01801       AST_Type *type = node->field_type ();
01802 
01803       // Updates ir_current_.
01804       this->get_referenced_type (type);
01805 
01806       CORBA::AttributeMode mode =
01807         node->readonly () ? CORBA::ATTR_READONLY : CORBA::ATTR_NORMAL;
01808 
01809       CORBA::ExceptionDefSeq get_exceptions;
01810       this->fill_get_exceptions (get_exceptions,
01811                                  node);
01812 
01813       CORBA::ExceptionDefSeq set_exceptions;
01814       this->fill_set_exceptions (set_exceptions,
01815                                  node);
01816 
01817       CORBA::Container_ptr current_scope =
01818         CORBA::Container::_nil ();
01819 
01820       if (be_global->ifr_scopes ().top (current_scope) == 0)
01821         {
01822           CORBA::DefinitionKind kind =
01823             current_scope->def_kind ();
01824 
01825           if (kind == CORBA::dk_Value || kind == CORBA::dk_Event)
01826             {
01827               CORBA::ExtValueDef_var value =
01828                 CORBA::ExtValueDef::_narrow (current_scope);
01829 
01830               CORBA::ExtAttributeDef_var new_def =
01831                 value->create_ext_attribute (
01832                     node->repoID (),
01833                     node->local_name ()->get_string (),
01834                     node->version (),
01835                     this->ir_current_.in (),
01836                     mode,
01837                     get_exceptions,
01838                     set_exceptions
01839                   );
01840             }
01841           else
01842             {
01843               // We are an interface, a local interface, an abstract
01844               // interface or a component. This narrow covers them all.
01845               CORBA::InterfaceAttrExtension_var iface =
01846                 CORBA::InterfaceAttrExtension::_narrow (current_scope);
01847 
01848               CORBA::ExtAttributeDef_var new_def =
01849                 iface->create_ext_attribute (
01850                     node->repoID (),
01851                     node->local_name ()->get_string (),
01852                     node->version (),
01853                     this->ir_current_.in (),
01854                     mode,
01855                     get_exceptions,
01856                     set_exceptions
01857                   );
01858             }
01859         }
01860       else
01861         {
01862           ACE_ERROR_RETURN ((
01863               LM_ERROR,
01864               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_attribute -")
01865               ACE_TEXT (" scope stack is empty\n")
01866             ),
01867             -1
01868           );
01869         }
01870     }
01871   catch (const CORBA::Exception& ex)
01872     {
01873       ex._tao_print_exception (ACE_TEXT ("visit_attribute"));
01874 
01875       return -1;
01876     }
01877 
01878   return 0;
01879 }

int ifr_adding_visitor::visit_component ( AST_Component *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 845 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, create_component_def(), BE_GlobalData::do_included_files(), fill_base_component(), fill_supported_interfaces(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), BE_GlobalData::repository(), visit_all_consumes(), visit_all_emits(), visit_all_provides(), visit_all_publishes(), and visit_all_uses().

00846 {
00847   if (node->imported () && !be_global->do_included_files ())
00848     {
00849       return 0;
00850     }
00851 
00852   try
00853     {
00854       // Is this interface already in the respository?
00855       CORBA::Contained_var prev_def =
00856         be_global->repository ()->lookup_id (node->repoID ());
00857 
00858       // If not, create a new entry.
00859       if (CORBA::is_nil (prev_def.in ()))
00860         {
00861           int status = this->create_component_def (node);
00862 
00863           return status;
00864         }
00865       else
00866         {
00867           // There is already an entry in the repository. If the interface is
00868           // defined and has not already been populated, we do so
00869           // now. If it is not yet defined or the full definition has already
00870           // been added to the repository, we just update the current IR object
00871           // holder.
00872           if (node->is_defined () && !node->ifr_added ())
00873             {
00874               // If we are here and the line below is true, then either
00875               // 1. We are defining an undefined forward declaration
00876               //    from a previously processed IDL file, or
00877               // 2. We are clobbering a previous definition, either of the
00878               //    node type or of some other type.
00879               // If prev_def would narrow successfully to the node type, we
00880               // have NO WAY of knowing if we are defining or clobbering. So
00881               // we destroy the contents of the previous entry (we don't want
00882               // to destroy the entry itself, since it may have already been
00883               // made a member of some other entry, and destroying it would
00884               // make the containing entry's section key invalid) and repopulate.
00885               // On the other hand, if prev_def is NOT the node type, we go
00886               // ahead an attempt to create an interface, which will get an
00887               // exception from the IFR, as the spec requires.
00888               if (!node->ifr_fwd_added ())
00889                 {
00890                   CORBA::DefinitionKind kind =
00891                     prev_def->def_kind ();
00892 
00893                   if (kind == CORBA::dk_Component)
00894                     {
00895                       CORBA::ComponentIR::ComponentDef_var value =
00896                         CORBA::ComponentIR::ComponentDef::_narrow (
00897                             prev_def.in ()
00898                           );
00899 
00900                       CORBA::ContainedSeq_var contents =
00901                         value->contents (CORBA::dk_all,
00902                                          1);
00903 
00904                       CORBA::ULong length = contents->length ();
00905 
00906                       for (CORBA::ULong i = 0; i < length; ++i)
00907                         {
00908                           contents[i]->destroy ();
00909                         }
00910                     }
00911                   else
00912                     {
00913                       prev_def->destroy ();
00914 
00915                       int status =
00916                         this->create_component_def (node);
00917 
00918                       return status;
00919                     }
00920                 }
00921 
00922               // Re-populate the repository entry.
00923 
00924               CORBA::ComponentIR::ComponentDef_var extant_def =
00925                 CORBA::ComponentIR::ComponentDef::_narrow (
00926                                                       prev_def.in ()
00927                                                     );
00928 
00929               CORBA::InterfaceDefSeq supported_interfaces;
00930               this->fill_supported_interfaces (supported_interfaces,
00931                                                node);
00932 
00933               extant_def->supported_interfaces (supported_interfaces);
00934 
00935               CORBA::ComponentIR::ComponentDef_var base_component;
00936               this->fill_base_component (base_component.out (),
00937                                          node);
00938 
00939               extant_def->base_component (base_component.in ());
00940 
00941               this->visit_all_provides (node,
00942                                         extant_def.in ());
00943 
00944               this->visit_all_uses (node,
00945                                     extant_def.in ());
00946 
00947               this->visit_all_emits (node,
00948                                      extant_def.in ());
00949 
00950               this->visit_all_publishes (node,
00951                                          extant_def.in ());
00952 
00953               this->visit_all_consumes (node,
00954                                         extant_def.in ());
00955 
00956               node->ifr_added (true);
00957 
00958               // Push the new IR object onto the scope stack before visiting
00959               // the new object's scope.
00960               if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
00961                 {
00962                   ACE_ERROR_RETURN ((
00963                       LM_ERROR,
00964                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00965                       ACE_TEXT ("visit_component -")
00966                       ACE_TEXT (" scope push failed\n")
00967                     ),
00968                     -1
00969                   );
00970                 }
00971 
00972               // Visit the members, if any.
00973               if (this->visit_scope (node) == -1)
00974                 {
00975                   ACE_ERROR_RETURN ((
00976                       LM_ERROR,
00977                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00978                       ACE_TEXT ("visit_component -")
00979                       ACE_TEXT (" visit_scope failed\n")
00980                     ),
00981                     -1
00982                   );
00983                 }
00984 
00985               // This spot in the AST doesn't necessarily have to be the
00986               // interface definition - it could be any reference to it.
00987               // The front end will already have fully defined it, so all
00988               // the info is available anywhere. So it's a good idea to
00989               // update the current IR object holder now.
00990               this->ir_current_ =
00991                 CORBA::IDLType::_duplicate (extant_def.in ());
00992 
00993               CORBA::Container_ptr used_scope =
00994                 CORBA::Container::_nil ();
00995 
00996               // Pop the new IR object back off the scope stack.
00997               if (be_global->ifr_scopes ().pop (used_scope) != 0)
00998                 {
00999                   ACE_ERROR_RETURN ((
01000                       LM_ERROR,
01001                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01002                       ACE_TEXT ("visit_interface -")
01003                       ACE_TEXT (" scope pop failed\n")
01004                     ),
01005                     -1
01006                   );
01007                 }
01008              }
01009           else
01010             {
01011               // @@ (JP) I think we're ok here without a check:
01012               // not defined/not added - visit_interface_fwd will have
01013               //                         detected a clobber.
01014               // not defined/added - not possible.
01015               // defined/not added - takes the other branch.
01016               // defined/added - we're ok.
01017               this->ir_current_ =
01018                 CORBA::IDLType::_narrow (prev_def.in ());
01019             }
01020         }
01021    }
01022   catch (const CORBA::Exception& ex)
01023     {
01024       ex._tao_print_exception (ACE_TEXT ("visit_component"));
01025 
01026       return -1;
01027     }
01028 
01029   return 0;
01030 }

int ifr_adding_visitor::visit_component_fwd ( AST_ComponentFwd *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1033 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), fill_base_component(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, BE_GlobalData::repository(), ACE_Unbounded_Stack< T >::top(), visit_all_consumes(), visit_all_emits(), visit_all_provides(), visit_all_publishes(), and visit_all_uses().

01034 {
01035   if (node->imported () && !be_global->do_included_files ())
01036     {
01037       return 0;
01038     }
01039 
01040   AST_Component *c =
01041     AST_Component::narrow_from_decl (node->full_definition ());
01042 
01043   try
01044     {
01045       // Is this interface already in the respository?
01046       CORBA::Contained_var prev_def =
01047         be_global->repository ()->lookup_id (c->repoID ());
01048 
01049       if (CORBA::is_nil (prev_def.in ()))
01050         {
01051           CORBA::Container_ptr current_scope =
01052             CORBA::Container::_nil ();
01053 
01054           if (be_global->ifr_scopes ().top (current_scope) == 0)
01055             {
01056               CORBA::ComponentIR::Container_var ccm_scope =
01057                 CORBA::ComponentIR::Container::_narrow (
01058                                                    current_scope
01059                                                  );
01060 
01061               // If our full definition is found in this IDL file, we go
01062               // ahead and create the full entry now.
01063               // The forward declared component is not defined anywhere
01064               // in this IDL file, so we just create an empty entry to
01065               // be replaced by a full definition later.
01066               CORBA::InterfaceDefSeq supported_interfaces;
01067               supported_interfaces.length (0);
01068               CORBA::ComponentIR::ComponentDef_var base_component;
01069 
01070 
01071               if (node->is_defined ())
01072                 {
01073                   this->fill_supported_interfaces (supported_interfaces,
01074                                                    c);
01075 
01076                   this->fill_base_component (base_component.out (),
01077                                              c);
01078                 }
01079 
01080               this->ir_current_ =
01081                 ccm_scope->create_component (
01082                                c->repoID (),
01083                                c->local_name ()->get_string (),
01084                                c->version (),
01085                                base_component.in (),
01086                                supported_interfaces
01087                              );
01088 
01089               // Might as well go ahead and complete the repository
01090               // entry now, if we can - we're halfway there already.
01091               if (node->is_defined ())
01092                 {
01093                   CORBA::ComponentIR::ComponentDef_var new_def =
01094                     CORBA::ComponentIR::ComponentDef::_narrow (
01095                         this->ir_current_.in ()
01096                       );
01097 
01098                   this->visit_all_provides (c,
01099                                             new_def.in ());
01100 
01101                   this->visit_all_uses (c,
01102                                         new_def.in ());
01103 
01104                   this->visit_all_emits (c,
01105                                          new_def.in ());
01106 
01107                   this->visit_all_publishes (c,
01108                                              new_def.in ());
01109 
01110                   this->visit_all_consumes (c,
01111                                             new_def.in ());
01112                 }
01113             }
01114           else
01115             {
01116               ACE_ERROR_RETURN ((
01117                   LM_ERROR,
01118                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01119                   ACE_TEXT ("visit_component_fwd -")
01120                   ACE_TEXT (" scope stack is empty\n")
01121                 ),
01122                 -1
01123               );
01124             }
01125 
01126           node->ifr_added (true);
01127           c->ifr_fwd_added (true);
01128         }
01129    }
01130   catch (const CORBA::Exception& ex)
01131     {
01132       ex._tao_print_exception (ACE_TEXT ("visit_component_fwd"));
01133 
01134       return -1;
01135     }
01136 
01137   return 0;
01138 }

int ifr_adding_visitor::visit_constant ( AST_Constant *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1991 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), expr_type_to_pkind(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, load_any(), BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

01992 {
01993   if (node->imported () && !be_global->do_included_files ())
01994     {
01995       return 0;
01996     }
01997 
01998   const char *id = node->repoID ();
01999 
02000   try
02001     {
02002       CORBA::Contained_var prev_def =
02003         be_global->repository ()->lookup_id (id);
02004 
02005       // Nothing prevents this constant's repo id from already being
02006       // in the repository as another type, if it came from another
02007       // IDL file whose generated code is not linked to the generated
02008       // code from this IDL file. So we check here before we make a
02009       // call on ir_current_.
02010       if (!CORBA::is_nil (prev_def.in ()))
02011         {
02012           // If the line below is true, we are clobbering a previous
02013           // entry (from another IDL file) of another type. In that
02014           // case we do what other ORB vendors do, and destroy the
02015           // original entry, create the new one, and let the user beware.
02016           if (!node->ifr_added ())
02017             {
02018               prev_def->destroy ();
02019             }
02020           else
02021             {
02022               // The node is referenced in an array size, string bound
02023               // or sequence bound - no action needed in the IFR.
02024               return 0;
02025             }
02026         }
02027 
02028       AST_Expression::ExprType et = node->et ();
02029       AST_Expression *cv = node->constant_value ();
02030 
02031       /// @@@ (JP 2007-12-12) I've removed code to check
02032       /// for constants of typedefs. The CORBA document
02033       /// formal/2004-03-12 (CORBA 3.0.3) says in section
02034       /// 10.5.8.1 that the type of a constant in the IFR must be
02035       /// 'one of the primitive types allowed in constant
02036       /// declarations'. So for constants of typedefs we store
02037       /// the underlying type in the IFR.
02038 
02039       if (et == AST_Expression::EV_enum)
02040         {
02041           // This constant's type is an enum - look up the enum member
02042           // representing the value, then get the enclosing enum to pass
02043           // to create_constant().
02044           AST_Decl *enum_val =
02045             node->defined_in ()->lookup_by_name (cv->n (), true);
02046           AST_Decl *d = ScopeAsDecl (enum_val->defined_in ());
02047  
02048           CORBA::Contained_var contained =
02049             be_global->repository ()->lookup_id (d->repoID ());
02050  
02051           this->ir_current_ = CORBA::IDLType::_narrow (contained.in ());
02052         }
02053       else
02054         {
02055           // This constant's type is a primitive type - fetch it from the
02056           // repo and pass it to create_constant().
02057           CORBA::PrimitiveKind pkind = this->expr_type_to_pkind (et);
02058  
02059           this->ir_current_ =
02060             be_global->repository ()->get_primitive (pkind);
02061         }
02062 
02063       CORBA::Any any;
02064       this->load_any (cv->ev (), any);
02065 
02066       CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
02067 
02068       if (be_global->ifr_scopes ().top (current_scope) == 0)
02069         {
02070           CORBA::ConstantDef_var new_def =
02071             current_scope->create_constant (
02072                 id,
02073                 node->local_name ()->get_string (),
02074                 node->version (),
02075                 this->ir_current_.in (),
02076                 any
02077               );
02078         }
02079       else
02080         {
02081           ACE_ERROR_RETURN ((
02082               LM_ERROR,
02083               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_constant -")
02084               ACE_TEXT (" scope stack is empty\n")
02085             ),
02086             -1
02087           );
02088         }
02089     }
02090   catch (const CORBA::Exception& ex)
02091     {
02092       ex._tao_print_exception (ACE_TEXT ("visit_constant"));
02093 
02094       return -1;
02095     }
02096 
02097   return 0;
02098 }

int ifr_adding_visitor::visit_enum ( AST_Enum *  node  )  [virtual]

Reimplemented from ifr_visitor.

Reimplemented in ifr_adding_visitor_exception, ifr_adding_visitor_structure, and ifr_adding_visitor_union.

Definition at line 1658 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, BE_GlobalData::repository(), CORBA::string_dup(), and ACE_Unbounded_Stack< T >::top().

01659 {
01660   if (node->imported () && !be_global->do_included_files ())
01661     {
01662       return 0;
01663     }
01664 
01665   try
01666     {
01667       // Is this enum already in the respository?
01668       CORBA::Contained_var prev_def =
01669         be_global->repository ()->lookup_id (node->repoID ());
01670 
01671       // If not, create a new entry.
01672       if (CORBA::is_nil (prev_def.in ()))
01673         {
01674           CORBA::ULong member_count =
01675             static_cast<CORBA::ULong> (node->member_count ());
01676 
01677           CORBA::EnumMemberSeq members (member_count);
01678           members.length (member_count);
01679 
01680           UTL_ScopedName *member_name = 0;
01681 
01682           // Get a list of the member names.
01683           for (CORBA::ULong i = 0; i < member_count; ++i)
01684             {
01685               member_name = node->value_to_name (i);
01686 
01687               members[i] =
01688                 CORBA::string_dup (
01689                     member_name->last_component ()->get_string ()
01690                   );
01691             }
01692 
01693           CORBA::Container_ptr current_scope =
01694             CORBA::Container::_nil ();
01695 
01696           if (be_global->ifr_scopes ().top (current_scope) == 0)
01697             {
01698               this->ir_current_ =
01699                 current_scope->create_enum (
01700                     node->repoID (),
01701                     node->local_name ()->get_string (),
01702                     node->version (),
01703                     members
01704                   );
01705             }
01706           else
01707             {
01708               ACE_ERROR_RETURN ((
01709                   LM_ERROR,
01710                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_enum -")
01711                   ACE_TEXT (" scope stack is empty\n")
01712                 ),
01713                 -1
01714               );
01715             }
01716 
01717           node->ifr_added (true);
01718         }
01719       else
01720         {
01721           // If the line below is true, we are clobbering a previous
01722           // entry (from another IDL file) of another type. In that
01723           // case we do what other ORB vendors do, and destroy the
01724           // original entry, create the new one, and let the user beware.
01725           if (!node->ifr_added ())
01726             {
01727               prev_def->destroy ();
01728 
01729               return this->visit_enum (node);
01730             }
01731 
01732           // There is already an entry in the repository, so just update
01733           // the current IR object holder.
01734           this->ir_current_ =
01735             CORBA::EnumDef::_narrow (prev_def.in ());
01736         }
01737     }
01738   catch (const CORBA::Exception& ex)
01739     {
01740       ex._tao_print_exception (ACE_TEXT ("ifr_adding_visitor::visit_enum"));
01741 
01742       return -1;
01743     }
01744 
01745   return 0;
01746 }

int ifr_adding_visitor::visit_eventtype ( AST_EventType *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1141 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, create_event_def(), BE_GlobalData::do_included_files(), fill_abstract_base_values(), fill_base_value(), fill_initializers(), fill_supported_interfaces(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), and BE_GlobalData::repository().

01142 {
01143   if (node->imported () && !be_global->do_included_files ())
01144     {
01145       return 0;
01146     }
01147 
01148   try
01149     {
01150       // Is this interface already in the respository?
01151       CORBA::Contained_var prev_def =
01152         be_global->repository ()->lookup_id (node->repoID ());
01153 
01154       // If not, create a new entry.
01155       if (CORBA::is_nil (prev_def.in ()))
01156         {
01157           int status = this->create_event_def (node);
01158 
01159           return status;
01160         }
01161       else
01162         {
01163           // There is already an entry in the repository. If the interface is
01164           // defined and has not already been populated, we do so
01165           // now. If it is not yet defined or the full definition has already
01166           // been added to the repository, we just update the current IR object
01167           // holder.
01168           if (node->is_defined () && !node->ifr_added ())
01169             {
01170               // If we are here and the line below is true, then either
01171               // 1. We are defining an undefined forward declaration
01172               //    from a previously processed IDL file, or
01173               // 2. We are clobbering a previous definition, either of the
01174               //    node type or of some other type.
01175               // If prev_def would narrow successfully to the node type, we
01176               // have NO WAY of knowing if we are defining or clobbering. So
01177               // we destroy the contents of the previous entry (we don't want
01178               // to destroy the entry itself, since it may have already been
01179               // made a member of some other entry, and destroying it would
01180               // make the containing entry's section key invalid) and repopulate.
01181               // On the other hand, if prev_def is NOT the node type, we go
01182               // ahead an attempt to create an interface, which will get an
01183               // exception from the IFR, as the spec requires.
01184               if (!node->ifr_fwd_added ())
01185                 {
01186                   CORBA::DefinitionKind kind =
01187                     prev_def->def_kind ();
01188 
01189                   if (kind == CORBA::dk_Value)
01190                     {
01191                       CORBA::ComponentIR::EventDef_var event =
01192                         CORBA::ComponentIR::EventDef::_narrow (
01193                             prev_def.in ()
01194                           );
01195 
01196                       CORBA::ContainedSeq_var contents =
01197                         event->contents (CORBA::dk_all,
01198                                          1);
01199 
01200                       CORBA::ULong length = contents->length ();
01201 
01202                       for (CORBA::ULong i = 0; i < length; ++i)
01203                         {
01204                           contents[i]->destroy ();
01205                         }
01206                     }
01207                   else
01208                     {
01209                       prev_def->destroy ();
01210 
01211                       int status =
01212                         this->create_event_def (node);
01213 
01214                       return status;
01215                     }
01216                 }
01217 
01218               // Our previous definition is a valuetype, so narrow it here,
01219               // then populate it.
01220               CORBA::ComponentIR::EventDef_var extant_def =
01221                 CORBA::ComponentIR::EventDef::_narrow (prev_def. in ());
01222 
01223               // Concrete base value.
01224 
01225               CORBA::ValueDef_var base_vt;
01226               this->fill_base_value (base_vt.out (),
01227                                      node);
01228 
01229               extant_def->base_value (base_vt.in ());
01230 
01231               // Abstract base values.
01232 
01233               CORBA::ValueDefSeq abstract_base_values;
01234               this->fill_abstract_base_values (abstract_base_values,
01235                                                node);
01236 
01237               extant_def->abstract_base_values (abstract_base_values);
01238 
01239               // Supported interfaces.
01240 
01241               CORBA::InterfaceDefSeq supported;
01242               this->fill_supported_interfaces (supported,
01243                                                node);
01244 
01245               extant_def->supported_interfaces (supported);
01246 
01247               // Intializers.
01248 
01249               CORBA::ExtInitializerSeq initializers;
01250               this->fill_initializers (initializers,
01251                                        node);
01252 
01253               extant_def->ext_initializers (initializers);
01254 
01255               // Truncatable, abstract, custom.
01256 
01257               extant_def->is_abstract (static_cast<CORBA::Boolean> (node->is_abstract ()));
01258 
01259               extant_def->is_truncatable (static_cast<CORBA::Boolean> (node->truncatable ()));
01260 
01261               extant_def->is_custom (static_cast<CORBA::Boolean> (node->custom ()));
01262 
01263               node->ifr_added (true);
01264 
01265               // Push the new IR object onto the scope stack before visiting
01266               // the new object's scope.
01267               if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
01268                 {
01269                   ACE_ERROR_RETURN ((
01270                       LM_ERROR,
01271                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01272                       ACE_TEXT ("visit_eventtype -")
01273                       ACE_TEXT (" scope push failed\n")
01274                     ),
01275                     -1
01276                   );
01277                 }
01278 
01279               // Visit the members, if any.
01280               if (this->visit_scope (node) == -1)
01281                 {
01282                   ACE_ERROR_RETURN ((
01283                       LM_ERROR,
01284                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01285                       ACE_TEXT ("visit_eventtype -")
01286                       ACE_TEXT (" visit_scope failed\n")
01287                     ),
01288                     -1
01289                   );
01290                 }
01291 
01292               // This spot in the AST doesn't necessarily have to be the
01293               // interface definition - it could be any reference to it.
01294               // The front end will already have fully defined it, so all
01295               // the info is available anywhere. So it's a good idea to
01296               // update the current IR object holder now.
01297               this->ir_current_ =
01298                 CORBA::IDLType::_duplicate (extant_def.in ());
01299 
01300               CORBA::Container_ptr used_scope =
01301                 CORBA::Container::_nil ();
01302 
01303               // Pop the new IR object back off the scope stack.
01304               if (be_global->ifr_scopes ().pop (used_scope) != 0)
01305                 {
01306                   ACE_ERROR_RETURN ((
01307                       LM_ERROR,
01308                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01309                       ACE_TEXT ("visit_eventtype -")
01310                       ACE_TEXT (" scope pop failed\n")
01311                     ),
01312                     -1
01313                   );
01314                 }
01315             }
01316           else
01317             {
01318               // @@ (JP) I think we're ok here without a check:
01319               // not defined/not added - visit_valuetype_fwd will have
01320               //                         detected a clobber.
01321               // not defined/added - not possible.
01322               // defined/not added - takes the other branch.
01323               // defined/added - we're ok.
01324               this->ir_current_ =
01325                 CORBA::IDLType::_narrow (prev_def.in ());
01326             }
01327         }
01328     }
01329   catch (const CORBA::Exception& ex)
01330     {
01331       ex._tao_print_exception (ACE_TEXT ("visit_eventtype"));
01332 
01333       return -1;
01334     }
01335 
01336   return 0;
01337 }

int ifr_adding_visitor::visit_eventtype_fwd ( AST_EventTypeFwd *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1340 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

01341 {
01342   if (node->imported () && !be_global->do_included_files ())
01343     {
01344       return 0;
01345     }
01346 
01347   AST_Interface *v = node->full_definition ();
01348 
01349   try
01350     {
01351       // Is this interface already in the respository?
01352       CORBA::Contained_var prev_def =
01353         be_global->repository ()->lookup_id (v->repoID ());
01354 
01355       if (CORBA::is_nil (prev_def.in ()))
01356         {
01357           // If our full definition is found in this IDL file, we go
01358           // ahead and create the full entry now.
01359           // The forward declared valuetype is not defined anywhere
01360           // in this IDL file, so we just create an empty entry to
01361           // be replaced by a full definition in some other IDL file.
01362           CORBA::ValueDefSeq abstract_bases (0);
01363           abstract_bases.length (0);
01364           CORBA::InterfaceDefSeq supported (0);
01365           supported.length (0);
01366           CORBA::ExtInitializerSeq initializers (0);
01367           initializers.length (0);
01368 
01369           CORBA::Container_ptr current_scope =
01370             CORBA::Container::_nil ();
01371 
01372           if (be_global->ifr_scopes ().top (current_scope) == 0)
01373             {
01374               CORBA::ComponentIR::Container_var ccm_scope =
01375                 CORBA::ComponentIR::Container::_narrow (
01376                                                    current_scope
01377                                                  );
01378 
01379               CORBA::Boolean abstract =
01380                 static_cast<CORBA::Boolean> (v->is_abstract ());
01381 
01382               this->ir_current_ =
01383                 ccm_scope->create_event (
01384                                v->repoID (),
01385                                v->local_name ()->get_string (),
01386                                v->version (),
01387                                0, // 'custom' not handled yet
01388                                abstract,
01389                                CORBA::ValueDef::_nil (),
01390                                0, // 'truncatable' not handled yet
01391                                abstract_bases,
01392                                supported,
01393                                initializers
01394                              );
01395             }
01396           else
01397             {
01398               ACE_ERROR_RETURN ((
01399                   LM_ERROR,
01400                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01401                   ACE_TEXT ("visit_eventtype_fwd -")
01402                   ACE_TEXT (" scope stack is empty\n")
01403                 ),
01404                 -1
01405               );
01406             }
01407 
01408           node->ifr_added (true);
01409           v->ifr_fwd_added (true);
01410         }
01411    }
01412   catch (const CORBA::Exception& ex)
01413     {
01414       ex._tao_print_exception (ACE_TEXT ("visit_eventtype_fwd"));
01415 
01416       return -1;
01417     }
01418 
01419   return 0;
01420 }

int ifr_adding_visitor::visit_exception ( AST_Exception *  node  )  [virtual]

Reimplemented from ifr_visitor.

Reimplemented in ifr_adding_visitor_exception.

Definition at line 1641 of file ifr_adding_visitor.cpp.

References be_global, BE_GlobalData::do_included_files(), and ifr_adding_visitor_exception::visit_exception().

01642 {
01643   if (node->imported () && !be_global->do_included_files ())
01644     {
01645       return 0;
01646     }
01647 
01648   ifr_adding_visitor_exception visitor (node,
01649                                         this->in_reopened_);
01650 
01651   // No point in updating ir_current_ here because
01652   // ExceptionDef is not an IDLType.
01653 
01654   return visitor.visit_exception (node);
01655 }

int ifr_adding_visitor::visit_factory ( AST_Factory *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1527 of file ifr_adding_visitor.cpp.

01528 {
01529   return 0;
01530 }

int ifr_adding_visitor::visit_field ( AST_Field *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1757 of file ifr_adding_visitor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), create_value_member(), and LM_ERROR.

01758 {
01759   AST_Decl *scope = ScopeAsDecl (node->defined_in ());
01760   AST_Decl::NodeType nt = scope->node_type ();
01761 
01762   if (nt == AST_Decl::NT_valuetype || nt == AST_Decl::NT_eventtype)
01763     {
01764       return this->create_value_member (node);
01765     }
01766 
01767   AST_Type *ft = AST_Type::narrow_from_decl (node->field_type ());
01768 
01769   if (ft == 0)
01770     {
01771       ACE_ERROR_RETURN ((
01772           LM_ERROR,
01773           ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01774           ACE_TEXT ("visit_field - ")
01775           ACE_TEXT ("Bad field type\n")
01776         ),
01777         -1
01778       );
01779     }
01780 
01781   if (ft->ast_accept (this) == -1)
01782     {
01783       ACE_ERROR_RETURN ((
01784           LM_ERROR,
01785           ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01786           ACE_TEXT ("visit_field - ")
01787           ACE_TEXT ("failed to accept visitor\n")
01788         ),
01789         -1
01790       );
01791     }
01792 
01793   return 0;
01794 }

int ifr_adding_visitor::visit_home ( AST_Home *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1423 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_TEXT(), be_global, create_home_def(), BE_GlobalData::do_included_files(), ir_current_, CORBA::is_nil(), and BE_GlobalData::repository().

01424 {
01425   if (node->imported () && !be_global->do_included_files ())
01426     {
01427       return 0;
01428     }
01429 
01430   try
01431     {
01432       // Is this interface already in the respository?
01433       CORBA::Contained_var prev_def =
01434         be_global->repository ()->lookup_id (node->repoID ());
01435 
01436       // If not, create a new entry.
01437       if (CORBA::is_nil (prev_def.in ()))
01438         {
01439           int status = this->create_home_def (node);
01440 
01441           return status;
01442         }
01443       else
01444         {
01445           // There is already an entry in the repository. If the interface is
01446           // defined and has not already been populated, we do so
01447           // now. If it is not yet defined or the full definition has already
01448           // been added to the repository, we just update the current IR object
01449           // holder.
01450           if (node->is_defined () && !node->ifr_added ())
01451             {
01452               // If we are here and the line below is true, then either
01453               // 1. We are defining an undefined forward declaration
01454               //    from a previously processed IDL file, or
01455               // 2. We are clobbering a previous definition, either of the
01456               //    node type or of some other type.
01457               // If prev_def would narrow successfully to the node type, we
01458               // have NO WAY of knowing if we are defining or clobbering. So
01459               // we destroy the contents of the previous entry (we don't want
01460               // to destroy the entry itself, since it may have already been
01461               // made a member of some other entry, and destroying it would
01462               // make the containing entry's section key invalid) and repopulate.
01463               // On the other hand, if prev_def is NOT the node type, we go
01464               // ahead an attempt to create an interface, which will get an
01465               // exception from the IFR, as the spec requires.
01466               if (!node->ifr_fwd_added ())
01467                 {
01468                   CORBA::DefinitionKind kind =
01469                     prev_def->def_kind ();
01470 
01471                   if (kind == CORBA::dk_Component)
01472                     {
01473                       CORBA::ComponentIR::HomeDef_var value =
01474                         CORBA::ComponentIR::HomeDef::_narrow (
01475                             prev_def.in ()
01476                           );
01477 
01478                       CORBA::ContainedSeq_var contents =
01479                         value->contents (CORBA::dk_all,
01480                                          1);
01481 
01482                       CORBA::ULong length = contents->length ();
01483 
01484                       for (CORBA::ULong i = 0; i < length; ++i)
01485                         {
01486                           contents[i]->destroy ();
01487                         }
01488                     }
01489                   else
01490                     {
01491                       prev_def->destroy ();
01492 
01493                       int status =
01494                         this->create_home_def (node);
01495 
01496                       return status;
01497                     }
01498                 }
01499 
01500               // Re-populate the repository entry.
01501 
01502             }
01503           else
01504             {
01505               // @@ (JP) I think we're ok here without a check:
01506               // not defined/not added - visit_interface_fwd will have
01507               //                         detected a clobber.
01508               // not defined/added - not possible.
01509               // defined/not added - takes the other branch.
01510               // defined/added - we're ok.
01511               this->ir_current_ =
01512                 CORBA::IDLType::_narrow (prev_def.in ());
01513             }
01514         }
01515    }
01516   catch (const CORBA::Exception& ex)
01517     {
01518       ex._tao_print_exception (ACE_TEXT ("visit_home"));
01519 
01520       return -1;
01521     }
01522 
01523   return 0;
01524 }

int ifr_adding_visitor::visit_interface ( AST_Interface *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 250 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, create_interface_def(), BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), and BE_GlobalData::repository().

00251 {
00252   if (node->imported () && !be_global->do_included_files ())
00253     {
00254       return 0;
00255     }
00256 
00257   try
00258     {
00259       // Is this interface already in the respository?
00260       CORBA::Contained_var prev_def =
00261         be_global->repository ()->lookup_id (node->repoID ());
00262 
00263       // If not, create a new entry.
00264       if (CORBA::is_nil (prev_def.in ()))
00265         {
00266           int status = this->create_interface_def (node);
00267 
00268           return status;
00269         }
00270       else
00271         {
00272           // There is already an entry in the repository. If the interface is
00273           // defined and has not already been populated, we do so
00274           // now. If it is not yet defined or the full definition has already
00275           // been added to the repository, we just update the current IR object
00276           // holder.
00277           if (node->is_defined () && !node->ifr_added ())
00278             {
00279               // If we are here and the line below is true, then either
00280               // 1. We are defining an undefined forward declaration
00281               //    from a previously processed IDL file, or
00282               // 2. We are clobbering a previous definition, either of the
00283               //    node type or of some other type.
00284               // If prev_def would narrow successfully to the node type, we
00285               // have NO WAY of knowing if we are defining or clobbering. So
00286               // we destroy the contents of the previous entry (we don't want
00287               // to destroy the entry itself, since it may have already been
00288               // made a member of some other entry, and destroying it would
00289               // make the containing entry's section key invalid) and repopulate.
00290               // On the other hand, if prev_def is NOT the node type, we go
00291               // ahead an attempt to create an interface, which will get an
00292               // exception from the IFR, as the spec requires.
00293               if (!node->ifr_fwd_added () && !node->imported ())
00294                 {
00295                   CORBA::DefinitionKind kind = prev_def->def_kind ();
00296 
00297                   if (kind == CORBA::dk_Interface)
00298                     {
00299                       CORBA::InterfaceDef_var iface =
00300                         CORBA::InterfaceDef::_narrow (prev_def.in ());
00301 
00302                       CORBA::ContainedSeq_var contents =
00303                         iface->contents (CORBA::dk_all, true);
00304 
00305                       for (CORBA::ULong i = 0; i < contents->length (); ++i)
00306                         {
00307                           contents[i]->destroy ();
00308                         }
00309                     }
00310                   else
00311                     {
00312                       // This will cause the IFR to throw an exception,
00313                       // as it should.
00314                       return this->create_interface_def (node);
00315                     }
00316                 }
00317 
00318               CORBA::ULong n_parents = static_cast<CORBA::ULong> (node->n_inherits ());
00319 
00320               CORBA::InterfaceDefSeq bases (n_parents);
00321               bases.length (n_parents);
00322               CORBA::Contained_var result;
00323 
00324               AST_Interface **parents = node->inherits ();
00325 
00326               // Construct a list of the parents.
00327               for (CORBA::ULong i = 0; i < n_parents; ++i)
00328                 {
00329                   result =
00330                     be_global->repository ()->lookup_id (parents[i]->repoID ());
00331 
00332                   // If one of our interface's parents is not in the repository,
00333                   // that means that it has not yet been seen (even as a
00334                   // forward declaration) in the IDL file, and we will have to
00335                   // postpone the populating of our interface until they are all
00336                   // added.
00337                   if (CORBA::is_nil (result.in ()))
00338                     {
00339                       this->ir_current_ =
00340                         CORBA::IDLType::_narrow (prev_def.in ());
00341 
00342                       return 0;
00343                     }
00344 
00345                   bases[i] =
00346                     CORBA::InterfaceDef::_narrow (result.in ());
00347 
00348                   if (CORBA::is_nil (bases[i]))
00349                     {
00350                       ACE_ERROR_RETURN ((
00351                           LM_ERROR,
00352                           ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00353                           ACE_TEXT ("visit_interface -")
00354                           ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
00355                         ),
00356                         -1
00357                       );
00358                     }
00359                 }
00360 
00361               CORBA::InterfaceDef_var extant_def =
00362                 CORBA::InterfaceDef::_narrow (prev_def. in ());
00363 
00364               extant_def->base_interfaces (bases);
00365 
00366               node->ifr_added (true);
00367 
00368               // Push the new IR object onto the scope stack.
00369               if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
00370                 {
00371                   ACE_ERROR_RETURN ((
00372                       LM_ERROR,
00373                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00374                       ACE_TEXT ("visit_interface -")
00375                       ACE_TEXT (" scope push failed\n")
00376                     ),
00377                     -1
00378                   );
00379                 }
00380 
00381               // Visit the members, if any.
00382               if (this->visit_scope (node) == -1)
00383                 {
00384                   ACE_ERROR_RETURN ((
00385                       LM_ERROR,
00386                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00387                       ACE_TEXT ("visit_interface -")
00388                       ACE_TEXT (" visit_scope failed\n")
00389                     ),
00390                     -1
00391                   );
00392                 }
00393 
00394               // This spot in the AST doesn't necessarily have to be the
00395               // interface definition - it could be any reference to it.
00396               // The front end will already have fully defined it, so all
00397               // the info is available anywhere. So it's a good idea to
00398               // update the current IR object holder now.
00399               this->ir_current_ =
00400                 CORBA::IDLType::_duplicate (extant_def.in ());
00401 
00402               CORBA::Container_ptr used_scope =
00403                 CORBA::Container::_nil ();
00404 
00405               // Pop the new IR object back off the scope stack.
00406               if (be_global->ifr_scopes ().pop (used_scope) != 0)
00407                 {
00408                   ACE_ERROR_RETURN ((
00409                       LM_ERROR,
00410                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00411                       ACE_TEXT ("visit_interface -")
00412                       ACE_TEXT (" scope pop failed\n")
00413                     ),
00414                     -1
00415                   );
00416                 }
00417             }
00418           else
00419             {
00420               // @@ (JP) I think we're ok here without a check:
00421               // not defined/not added - visit_interface_fwd will have
00422               //                         detected a clobber.
00423               // not defined/added - not possible.
00424               // defined/not added - takes the other branch.
00425               // defined/added - we're ok.
00426               this->ir_current_ =
00427                 CORBA::IDLType::_narrow (prev_def.in ());
00428             }
00429         }
00430     }
00431   catch (const CORBA::Exception& ex)
00432     {
00433       ex._tao_print_exception (ACE_TEXT ("visit_interface"));
00434 
00435       return -1;
00436     }
00437 
00438   return 0;
00439 }

int ifr_adding_visitor::visit_interface_fwd ( AST_InterfaceFwd *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 442 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

00443 {
00444   if (node->imported () && !be_global->do_included_files ())
00445     {
00446       return 0;
00447     }
00448 
00449   AST_Interface *i = node->full_definition ();
00450 
00451   try
00452     {
00453       // Is this interface already in the respository?
00454       CORBA::Contained_var prev_def =
00455         be_global->repository ()->lookup_id (i->repoID ());
00456 
00457       if (CORBA::is_nil (prev_def.in ()))
00458         {
00459           // If our full definition is found in this IDL file, we go
00460           // ahead and create the full entry now.
00461           // The forward declared interface is not defined anywhere
00462           // in this IDL file, so we just create an empty entry to
00463           // be replaced by a full definition in some other IDL file.
00464           CORBA::InterfaceDefSeq bases (0);
00465           bases.length (0);
00466 
00467           CORBA::Container_ptr current_scope =
00468             CORBA::Container::_nil ();
00469 
00470           if (be_global->ifr_scopes ().top (current_scope) == 0)
00471             {
00472               if (i->is_local ())
00473                 {
00474                   this->ir_current_ =
00475                     current_scope->create_local_interface (
00476                                        i->repoID (),
00477                                        i->local_name ()->get_string (),
00478                                        i->version (),
00479                                        bases
00480                                      );
00481                 }
00482               else
00483                 {
00484                   this->ir_current_ =
00485                     current_scope->create_interface (
00486                                        i->repoID (),
00487                                        i->local_name ()->get_string (),
00488                                        i->version (),
00489                                        bases
00490                                      );
00491                 }
00492 
00493             }
00494           else
00495             {
00496               ACE_ERROR_RETURN ((
00497                   LM_ERROR,
00498                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00499                   ACE_TEXT ("visit_interface_fwd -")
00500                   ACE_TEXT (" scope stack is empty\n")
00501                 ),
00502                 -1
00503               );
00504             }
00505 
00506           node->ifr_added (true);
00507           i->ifr_fwd_added (true);
00508         }
00509 
00510    }
00511   catch (const CORBA::Exception& ex)
00512     {
00513       ex._tao_print_exception (ACE_TEXT ("visit_interface_fwd"));
00514 
00515       return -1;
00516     }
00517 
00518   return 0;
00519 }

int ifr_adding_visitor::visit_module ( AST_Module *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 141 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), in_reopened_, CORBA::is_nil(), LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

00142 {
00143   if (node->imported () && !be_global->do_included_files ())
00144     {
00145       return 0;
00146     }
00147 
00148   CORBA::Container_var new_def;
00149 
00150   try
00151     {
00152       // If this module been opened before, it will already be in
00153       // the repository.
00154       CORBA::Contained_var prev_def =
00155         be_global->repository ()->lookup_id (node->repoID ());
00156 
00157       if (CORBA::is_nil (prev_def.in ()))
00158         {
00159           // New module.
00160           CORBA::Container_ptr container =
00161             CORBA::Container::_nil ();
00162 
00163           if (be_global->ifr_scopes ().top (container) == 0)
00164             {
00165               new_def = container->create_module (
00166                                        node->repoID (),
00167                                        node->local_name ()->get_string (),
00168                                        node->version ()
00169                                      );
00170             }
00171           else
00172             {
00173               ACE_ERROR_RETURN ((
00174                   LM_ERROR,
00175                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00176                   ACE_TEXT (" scope stack is empty\n")
00177                 ),
00178                 -1
00179               );
00180             }
00181         }
00182       else
00183         {
00184           CORBA::DefinitionKind kind =
00185             prev_def->def_kind ();
00186 
00187           if (kind == CORBA::dk_Module)
00188             {
00189               // We are either in a reopened module, are processing an IDL
00190               // IDL file for the second time, or are in a module whose
00191               // name already exists by coincidence - there is no way to
00192               // tell the difference. So any members whose repository ID
00193               // already exists in this case will throw BAD_PARAM
00194               // when we attempt to add them to the repository.
00195               this->in_reopened_ = true;
00196 
00197               new_def =
00198                 CORBA::ComponentIR::Container::_narrow (prev_def.in ());
00199             }
00200         }
00201 
00202       if (be_global->ifr_scopes ().push (new_def.in ()) != 0)
00203         {
00204           ACE_ERROR_RETURN ((
00205               LM_ERROR,
00206               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00207               ACE_TEXT (" scope push failed\n")
00208             ),
00209             -1
00210           );
00211         }
00212 
00213       if (this->visit_scope (node) == -1)
00214         {
00215           ACE_ERROR_RETURN ((
00216               LM_ERROR,
00217               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00218               ACE_TEXT (" visit_scope failed\n")
00219             ),
00220             -1
00221           );
00222         }
00223 
00224       this->in_reopened_ = false;
00225       CORBA::Container_ptr tmp =
00226         CORBA::Container::_nil ();
00227 
00228       if (be_global->ifr_scopes ().pop (tmp) != 0)
00229         {
00230           ACE_ERROR_RETURN ((
00231               LM_ERROR,
00232               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00233               ACE_TEXT (" scope pop failed\n")
00234             ),
00235             -1
00236           );
00237         }
00238     }
00239   catch (const CORBA::Exception& ex)
00240     {
00241       ex._tao_print_exception (ACE_TEXT ("visit_module"));
00242 
00243       return -1;
00244     }
00245 
00246   return 0;
00247 }

int ifr_adding_visitor::visit_native ( AST_Native *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 2302 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

02303 {
02304   if (node->imported () && !be_global->do_included_files ())
02305     {
02306       return 0;
02307     }
02308 
02309   try
02310     {
02311       CORBA::Contained_var prev_def =
02312         be_global->repository ()->lookup_id (node->repoID ());
02313 
02314       if (CORBA::is_nil (prev_def.in ()))
02315         {
02316           CORBA::Container_ptr current_scope =
02317             CORBA::Container::_nil ();
02318 
02319           if (be_global->ifr_scopes ().top (current_scope) == 0)
02320             {
02321               this->ir_current_ =
02322                 current_scope->create_native (
02323                     node->repoID (),
02324                     node->local_name ()->get_string (),
02325                     node->version ()
02326                   );
02327             }
02328           else
02329             {
02330               ACE_ERROR_RETURN ((
02331                   LM_ERROR,
02332                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_native -")
02333                   ACE_TEXT (" scope stack is empty\n")
02334                 ),
02335                 -1
02336               );
02337             }
02338 
02339           node->ifr_added (true);
02340         }
02341       else
02342         {
02343           // If the line below is true, we are clobbering a previous
02344           // entry (from another IDL file) of another type. In that
02345           // case we do what other ORB vendors do, and destroy the
02346           // original entry, create the new one, and let the user beware.
02347           if (!node->ifr_added ())
02348             {
02349               prev_def->destroy ();
02350 
02351               // This call will take the other branch.
02352               return this->visit_native (node);
02353             }
02354 
02355           this->ir_current_ =
02356             CORBA::NativeDef::_narrow (prev_def.in ());
02357         }
02358     }
02359   catch (const CORBA::Exception& ex)
02360     {
02361       ex._tao_print_exception (ACE_TEXT ("visit_native"));
02362 
02363       return -1;
02364     }
02365 
02366   return 0;
02367 }

int ifr_adding_visitor::visit_operation ( AST_Operation *  node  )  [virtual]

Reimplemented from ifr_visitor.

Reimplemented in ifr_adding_visitor_operation.

Definition at line 1749 of file ifr_adding_visitor.cpp.

References ifr_adding_visitor_operation::visit_operation().

01750 {
01751   ifr_adding_visitor_operation visitor (node);
01752 
01753   return visitor.visit_operation (node);
01754 }

int ifr_adding_visitor::visit_predefined_type ( AST_PredefinedType *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 121 of file ifr_adding_visitor.cpp.

References ACE_TEXT(), be_global, ir_current_, and BE_GlobalData::repository().

00122 {
00123   try
00124     {
00125       this->ir_current_ =
00126       be_global->repository ()->get_primitive (
00127                                     this->predefined_type_to_pkind (node)
00128                                   );
00129     }
00130   catch (const CORBA::Exception& ex)
00131     {
00132       ex._tao_print_exception (ACE_TEXT ("visit_predefined_type"));
00133 
00134       return -1;
00135     }
00136 
00137   return 0;
00138 }

int ifr_adding_visitor::visit_root ( AST_Root *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 2260 of file ifr_adding_visitor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::ifr_scopes(), LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), and BE_GlobalData::repository().

02261 {
02262   if (be_global->ifr_scopes ().push (be_global->repository ()) != 0)
02263     {
02264       ACE_ERROR_RETURN ((
02265           LM_ERROR,
02266           ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02267           ACE_TEXT (" scope push failed\n")
02268         ),
02269         -1
02270       );
02271     }
02272 
02273   if (this->visit_scope (node) == -1)
02274     {
02275       ACE_ERROR_RETURN ((
02276           LM_ERROR,
02277           ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02278           ACE_TEXT (" visit_scope failed\n")
02279         ),
02280         -1
02281       );
02282     }
02283 
02284   CORBA::Container_ptr tmp =
02285     CORBA::Container::_nil ();
02286 
02287   if (be_global->ifr_scopes ().pop (tmp) != 0)
02288     {
02289       ACE_ERROR_RETURN ((
02290           LM_ERROR,
02291           ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02292           ACE_TEXT (" scope pop failed\n")
02293         ),
02294         -1
02295       );
02296     }
02297 
02298   return 0;
02299 }

int ifr_adding_visitor::visit_scope ( UTL_Scope *  node  )  [virtual]

Reimplemented from ifr_visitor.

Reimplemented in ifr_adding_visitor_exception, ifr_adding_visitor_structure, and ifr_adding_visitor_union.

Definition at line 67 of file ifr_adding_visitor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), and LM_ERROR.

Referenced by ifr_adding_visitor_union::visit_scope(), ifr_adding_visitor_structure::visit_scope(), and ifr_adding_visitor_exception::visit_scope().

00068 {
00069   // Proceed if the number of members in our scope is greater than 0.
00070   if (node->nmembers () > 0)
00071     {
00072       // Initialize an iterator to iterate over our scope.
00073       UTL_ScopeActiveIterator si (node,
00074                                   UTL_Scope::IK_decls);
00075 
00076       AST_Decl *d = 0;
00077 
00078       // Continue until each element is visited.
00079       while (!si.is_done ())
00080         {
00081           d = si.item ();
00082 
00083           if (d == 0)
00084             {
00085               ACE_ERROR_RETURN ((
00086                   LM_ERROR,
00087                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_scope -")
00088                   ACE_TEXT (" bad node in this scope\n")
00089                 ),
00090                 -1
00091               );
00092             }
00093 
00094           // These are created at startup in the repository, and
00095           // need not be dealt with here.
00096           if (d->node_type () == AST_Decl::NT_pre_defined)
00097             {
00098               si.next ();
00099               continue;
00100             }
00101 
00102           if (d->ast_accept (this) == -1)
00103             {
00104               ACE_ERROR_RETURN ((
00105                   LM_ERROR,
00106                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_scope -")
00107                   ACE_TEXT (" failed to accept visitor\n")
00108                 ),
00109                 -1
00110               );
00111             }
00112 
00113           si.next ();
00114         }
00115     }
00116 
00117   return 0;
00118 }

int ifr_adding_visitor::visit_sequence ( AST_Sequence *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 2146 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_TEXT(), be_global, element_type(), ir_current_, and BE_GlobalData::repository().

02147 {
02148   try
02149     {
02150       this->element_type (node->base_type ());
02151 
02152       this->ir_current_ =
02153         be_global->repository ()->create_sequence (
02154                                       node->max_size ()->ev ()->u.ulval,
02155                                       this->ir_current_.in ()
02156                                     );
02157     }
02158   catch (const CORBA::Exception& ex)
02159     {
02160       ex._tao_print_exception (ACE_TEXT ("visit_sequence"));
02161 
02162       return -1;
02163     }
02164 
02165   return 0;
02166 }

int ifr_adding_visitor::visit_string ( AST_String *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 2169 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_TEXT(), be_global, ir_current_, and BE_GlobalData::repository().

02170 {
02171   AST_Expression *ex = node->max_size ();
02172 
02173   AST_Expression::AST_ExprValue *ev = ex->ev ();
02174 
02175   CORBA::ULong bound = static_cast<CORBA::ULong> (ev->u.ulval);
02176 
02177   try
02178     {
02179       if (node->node_type () == AST_Decl::NT_string)
02180         {
02181           this->ir_current_ =
02182             be_global->repository ()->create_string (bound);
02183         }
02184       else
02185         {
02186           this->ir_current_ =
02187             be_global->repository ()->create_wstring (bound);
02188         }
02189 
02190     }
02191   catch (const CORBA::Exception& ex)
02192     {
02193       ex._tao_print_exception (ACE_TEXT ("visit_string"));
02194 
02195       return -1;
02196     }
02197 
02198   return 0;
02199 }

int ifr_adding_visitor::visit_structure ( AST_Structure *  node  )  [virtual]

Reimplemented from ifr_visitor.

Reimplemented in ifr_adding_visitor_exception, ifr_adding_visitor_structure, and ifr_adding_visitor_union.

Definition at line 1533 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), ifr_adding_visitor_structure::ir_current(), ir_current_, CORBA::is_nil(), BE_GlobalData::repository(), and ifr_adding_visitor_structure::visit_structure().

01534 {
01535   if (node->imported () && !be_global->do_included_files ())
01536     {
01537       return 0;
01538     }
01539 
01540   try
01541     {
01542       CORBA::Contained_var prev_def =
01543         be_global->repository ()->lookup_id (node->repoID ());
01544 
01545       if (CORBA::is_nil (prev_def.in ()))
01546         {
01547           ifr_adding_visitor_structure visitor (node, false);
01548           int retval = visitor.visit_structure (node);
01549 
01550           if (retval == 0)
01551             {
01552               this->ir_current_ =
01553                 CORBA::IDLType::_duplicate (visitor.ir_current ());
01554             }
01555 
01556           return retval;
01557         }
01558       else
01559         {
01560           // If the line below is true, we are clobbering a previous
01561           // entry (from another IDL file) of another type. In that
01562           // case we do what other ORB vendors do, and destroy the
01563           // original entry, create the new one, and let the user beware.
01564           if (!node->ifr_added ())
01565             {
01566               prev_def->destroy ();
01567 
01568               return this->visit_structure (node);
01569             }
01570 
01571           this->ir_current_ =
01572             CORBA::IDLType::_narrow (prev_def.in ());
01573         }
01574     }
01575   catch (const CORBA::Exception& ex)
01576     {
01577       ex._tao_print_exception (
01578         ACE_TEXT (
01579           "ifr_adding_visitor::visit_structure"));
01580 
01581       return -1;
01582     }
01583 
01584   return 0;
01585 }

int ifr_adding_visitor::visit_structure_fwd ( AST_StructureFwd *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1588 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), CORBA::is_nil(), LM_ERROR, BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

01589 {
01590   if (node->imported () && !be_global->do_included_files ())
01591     {
01592       return 0;
01593     }
01594 
01595   try
01596     {
01597       CORBA::Contained_var prev_def =
01598         be_global->repository ()->lookup_id (node->repoID ());
01599 
01600       if (CORBA::is_nil (prev_def.in ()))
01601         {
01602           CORBA::StructMemberSeq dummyMembers;
01603           dummyMembers.length (0);
01604           CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
01605  
01606           if (be_global->ifr_scopes ().top (current_scope) != 0)
01607             {
01608               ACE_ERROR_RETURN ((
01609                   LM_ERROR,
01610                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01611                   ACE_TEXT ("visit_structure_fwd -")
01612                   ACE_TEXT (" scope stack is empty\n")
01613                 ),
01614                 -1
01615               );
01616             }
01617  
01618           CORBA::StructDef_var struct_def =
01619             current_scope->create_struct (
01620                 node->repoID (),
01621                 node->local_name ()->get_string (),
01622                 node->version (),
01623                 dummyMembers
01624               );
01625  
01626           node->full_definition ()->ifr_fwd_added (true);
01627         }
01628     }
01629   catch (const CORBA::Exception& ex)
01630     {
01631       ex._tao_print_exception (ACE_TEXT ("ifr_adding_visitor::")
01632                                ACE_TEXT ("visit_structure_fwd"));
01633 
01634       return -1;
01635     }
01636 
01637   return 0;
01638 }

int ifr_adding_visitor::visit_typedef ( AST_Typedef *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 2202 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_DEBUG, ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), element_type(), BE_GlobalData::ifr_scopes(), ir_current_, LM_DEBUG, LM_ERROR, and ACE_Unbounded_Stack< T >::top().

02203 {
02204   if (node->imported () && !be_global->do_included_files ())
02205     {
02206       return 0;
02207     }
02208 
02209   try
02210     {
02211       this->element_type (node->base_type (), node->owns_base_type ());
02212 
02213       CORBA::Container_ptr current_scope =
02214         CORBA::Container::_nil ();
02215 
02216       if (be_global->ifr_scopes ().top (current_scope) == 0)
02217         {
02218           this->ir_current_ =
02219             current_scope->create_alias (
02220                 node->repoID (),
02221                 node->local_name ()->get_string (),
02222                 node->version (),
02223                 this->ir_current_.in ()
02224               );
02225         }
02226       else
02227         {
02228           ACE_ERROR_RETURN ((
02229               LM_ERROR,
02230               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_typedef -")
02231               ACE_TEXT (" scope stack is empty\n")
02232             ),
02233             -1
02234           );
02235         }
02236 
02237       node->ifr_added (true);
02238     }
02239   catch (const CORBA::Exception& ex)
02240     {
02241       if (!this->allow_duplicate_typedefs_)
02242         {
02243           ex._tao_print_exception (ACE_TEXT ("visit_typedef"));
02244 
02245           return -1;
02246         }
02247       else
02248         {
02249           ACE_DEBUG ((LM_DEBUG,
02250               "%s %s\n",
02251               ACE_TEXT ("ifr_adding_visitor::visit_typedef - ignoring duplicate typedef"),
02252               node->local_name ()->get_string ()));
02253         }
02254     }
02255 
02256   return 0;
02257 }

int ifr_adding_visitor::visit_union ( AST_Union *  node  )  [virtual]

Reimplemented from ifr_visitor.

Reimplemented in ifr_adding_visitor_exception, ifr_adding_visitor_structure, and ifr_adding_visitor_union.

Definition at line 1882 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), ifr_adding_visitor_union::ir_current(), ir_current_, CORBA::is_nil(), BE_GlobalData::repository(), and ifr_adding_visitor_union::visit_union().

01883 {
01884   if (node->imported () && !be_global->do_included_files ())
01885     {
01886       return 0;
01887     }
01888 
01889   try
01890     {
01891       CORBA::Contained_var prev_def =
01892         be_global->repository ()->lookup_id (node->repoID ());
01893 
01894       if (CORBA::is_nil (prev_def.in ()))
01895         {
01896           ifr_adding_visitor_union visitor (node,
01897                                             0);
01898 
01899           int retval = visitor.visit_union (node);
01900 
01901           if (retval == 0)
01902             {
01903               this->ir_current_ =
01904                 CORBA::IDLType::_duplicate (visitor.ir_current ());
01905             }
01906 
01907           return retval;
01908         }
01909       else
01910         {
01911           // If the line below is true, we are clobbering a previous
01912           // entry (from another IDL file) of another type. In that
01913           // case we do what other ORB vendors do, and destroy the
01914           // original entry, create the new one, and let the user beware.
01915           if (!node->ifr_added ())
01916             {
01917               prev_def->destroy ();
01918 
01919               return this->visit_union (node);
01920             }
01921 
01922           this->ir_current_ =
01923             CORBA::UnionDef::_narrow (prev_def.in ());
01924         }
01925     }
01926   catch (const CORBA::Exception& ex)
01927     {
01928       ex._tao_print_exception (ACE_TEXT ("ifr_adding_visitor::visit_union"));
01929 
01930       return -1;
01931     }
01932 
01933   return 0;
01934 }

int ifr_adding_visitor::visit_union_fwd ( AST_UnionFwd *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 1937 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), CORBA::is_nil(), LM_ERROR, BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

01938 {
01939   if (node->imported () && !be_global->do_included_files ())
01940     {
01941       return 0;
01942     }
01943 
01944   try
01945     {
01946       CORBA::Contained_var prev_def =
01947         be_global->repository ()->lookup_id (node->repoID ());
01948 
01949       if (CORBA::is_nil (prev_def.in ()))
01950         {
01951           CORBA::UnionMemberSeq dummyMembers;
01952           dummyMembers.length (0);
01953           CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
01954  
01955           if (be_global->ifr_scopes ().top (current_scope) != 0)
01956             {
01957               ACE_ERROR_RETURN ((
01958                   LM_ERROR,
01959                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01960                   ACE_TEXT ("visit_union_fwd -")
01961                   ACE_TEXT (" scope stack is empty\n")
01962                 ),
01963                 -1
01964               );
01965             }
01966  
01967           CORBA::UnionDef_var union_def =
01968             current_scope->create_union (
01969                 node->repoID (),
01970                 node->local_name ()->get_string (),
01971                 node->version (),
01972                 CORBA::IDLType::_nil (),
01973                 dummyMembers
01974               );
01975  
01976           node->full_definition ()->ifr_fwd_added (true);
01977         }
01978     }
01979   catch (const CORBA::Exception& ex)
01980     {
01981       ex._tao_print_exception (ACE_TEXT ("ifr_adding_visitor::")
01982                                ACE_TEXT ("visit_union_fwd"));
01983 
01984       return -1;
01985     }
01986 
01987   return 0;
01988 }

int ifr_adding_visitor::visit_valuebox ( AST_ValueBox *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 522 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), element_type(), BE_GlobalData::ifr_scopes(), ir_current_, LM_ERROR, and ACE_Unbounded_Stack< T >::top().

00523 {
00524   if (node->imported () && !be_global->do_included_files ())
00525     {
00526       return 0;
00527     }
00528 
00529   try
00530     {
00531       this->element_type (node->boxed_type ());
00532 
00533       CORBA::Container_ptr current_scope =
00534         CORBA::Container::_nil ();
00535 
00536       if (be_global->ifr_scopes ().top (current_scope) == 0)
00537         {
00538           this->ir_current_ =
00539             current_scope->create_value_box (
00540                 node->repoID (),
00541                 node->local_name ()->get_string (),
00542                 node->version (),
00543                 this->ir_current_.in ()
00544               );
00545         }
00546       else
00547         {
00548           ACE_ERROR_RETURN ((
00549               LM_ERROR,
00550               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_valuebox -")
00551               ACE_TEXT (" scope stack is empty\n")
00552             ),
00553             -1
00554           );
00555         }
00556 
00557       node->ifr_added (true);
00558     }
00559   catch (const CORBA::Exception& ex)
00560     {
00561       ex._tao_print_exception (ACE_TEXT ("visit_valuebox"));
00562 
00563       return -1;
00564     }
00565 
00566   return 0;
00567 }

int ifr_adding_visitor::visit_valuetype ( AST_ValueType *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 570 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, create_value_def(), BE_GlobalData::do_included_files(), fill_abstract_base_values(), fill_base_value(), fill_initializers(), fill_supported_interfaces(), BE_GlobalData::ifr_scopes(), ir_current_, CORBA::is_nil(), LM_ERROR, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), and BE_GlobalData::repository().

00571 {
00572   if (node->imported () && !be_global->do_included_files ())
00573     {
00574       return 0;
00575     }
00576 
00577   try
00578     {
00579       // Is this interface already in the respository?
00580       CORBA::Contained_var prev_def =
00581         be_global->repository ()->lookup_id (node->repoID ());
00582 
00583       // If not, create a new entry.
00584       if (CORBA::is_nil (prev_def.in ()))
00585         {
00586           int status = this->create_value_def (node);
00587 
00588           return status;
00589         }
00590       else
00591         {
00592           // There is already an entry in the repository. If the interface is
00593           // defined and has not already been populated, we do so
00594           // now. If it is not yet defined or the full definition has already
00595           // been added to the repository, we just update the current IR object
00596           // holder.
00597           if (node->is_defined () && !node->ifr_added ())
00598             {
00599               // If we are here and the line below is true, then either
00600               // 1. We are defining an undefined forward declaration
00601               //    from a previously processed IDL file, or
00602               // 2. We are clobbering a previous definition, either of the
00603               //    node type or of some other type.
00604               // If prev_def would narrow successfully to the node type, we
00605               // have NO WAY of knowing if we are defining or clobbering. So
00606               // we destroy the contents of the previous entry (we don't want
00607               // to destroy the entry itself, since it may have already been
00608               // made a member of some other entry, and destroying it would
00609               // make the containing entry's section key invalid) and repopulate.
00610               // On the other hand, if prev_def is NOT the node type, we go
00611               // ahead an attempt to create an interface, which will get an
00612               // exception from the IFR, as the spec requires.
00613               if (!node->ifr_fwd_added ())
00614                 {
00615                   CORBA::DefinitionKind kind =
00616                     prev_def->def_kind ();
00617 
00618                   if (kind == CORBA::dk_Value)
00619                     {
00620                       CORBA::ValueDef_var value =
00621                         CORBA::ValueDef::_narrow (prev_def.in ());
00622 
00623                       CORBA::ContainedSeq_var contents =
00624                         value->contents (CORBA::dk_all,
00625                                          1);
00626 
00627                       CORBA::ULong length = contents->length ();
00628 
00629                       for (CORBA::ULong i = 0; i < length; ++i)
00630                         {
00631                           contents[i]->destroy ();
00632                         }
00633                     }
00634                   else
00635                     {
00636                       prev_def->destroy ();
00637 
00638                       int status =
00639                         this->create_value_def (node);
00640 
00641                       return status;
00642                     }
00643                 }
00644 
00645               // Our previous definition is a valuetype, so narrow it here,
00646               // then populate it.
00647               CORBA::ExtValueDef_var extant_def =
00648                 CORBA::ExtValueDef::_narrow (prev_def. in ());
00649 
00650               // Concrete base value.
00651 
00652               CORBA::ValueDef_var base_vt;
00653               this->fill_base_value (base_vt.out (),
00654                                      node);
00655 
00656               extant_def->base_value (base_vt.in ());
00657 
00658               // Abstract base values.
00659 
00660               CORBA::ValueDefSeq abstract_base_values;
00661               this->fill_abstract_base_values (abstract_base_values,
00662                                                node);
00663 
00664               extant_def->abstract_base_values (abstract_base_values);
00665 
00666               // Supported interfaces.
00667 
00668               CORBA::InterfaceDefSeq supported;
00669               this->fill_supported_interfaces (supported,
00670                                                node);
00671 
00672               extant_def->supported_interfaces (supported);
00673 
00674               // Intializers.
00675 
00676               CORBA::ExtInitializerSeq initializers;
00677               this->fill_initializers (initializers,
00678                                        node);
00679 
00680               extant_def->ext_initializers (initializers);
00681 
00682               // Truncatable, abstract, custom.
00683 
00684               extant_def->is_abstract (static_cast<CORBA::Boolean> (node->is_abstract ()));
00685 
00686               extant_def->is_truncatable (static_cast<CORBA::Boolean> (node->truncatable ()));
00687 
00688               extant_def->is_custom (static_cast<CORBA::Boolean> (node->custom ()));
00689 
00690               node->ifr_added (true);
00691 
00692               // Push the new IR object onto the scope stack before visiting
00693               // the new object's scope.
00694               if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
00695                 {
00696                   ACE_ERROR_RETURN ((
00697                       LM_ERROR,
00698                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00699                       ACE_TEXT ("visit_valuetype -")
00700                       ACE_TEXT (" scope push failed\n")
00701                     ),
00702                     -1
00703                   );
00704                 }
00705 
00706               // Visit the members, if any.
00707               if (this->visit_scope (node) == -1)
00708                 {
00709                   ACE_ERROR_RETURN ((
00710                       LM_ERROR,
00711                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00712                       ACE_TEXT ("visit_valuetype -")
00713                       ACE_TEXT (" visit_scope failed\n")
00714                     ),
00715                     -1
00716                   );
00717                 }
00718 
00719               // This spot in the AST doesn't necessarily have to be the
00720               // interface definition - it could be any reference to it.
00721               // The front end will already have fully defined it, so all
00722               // the info is available anywhere. So it's a good idea to
00723               // update the current IR object holder now.
00724               this->ir_current_ =
00725                 CORBA::IDLType::_duplicate (extant_def.in ());
00726 
00727               CORBA::Container_ptr used_scope =
00728                 CORBA::Container::_nil ();
00729 
00730               // Pop the new IR object back off the scope stack.
00731               if (be_global->ifr_scopes ().pop (used_scope) != 0)
00732                 {
00733                   ACE_ERROR_RETURN ((
00734                       LM_ERROR,
00735                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00736                       ACE_TEXT ("visit_valuetype -")
00737                       ACE_TEXT (" scope pop failed\n")
00738                     ),
00739                     -1
00740                   );
00741                 }
00742             }
00743           else
00744             {
00745               // @@ (JP) I think we're ok here without a check:
00746               // not defined/not added - visit_valuetype_fwd will have
00747               //                         detected a clobber.
00748               // not defined/added - not possible.
00749               // defined/not added - takes the other branch.
00750               // defined/added - we're ok.
00751               this->ir_current_ =
00752                 CORBA::IDLType::_narrow (prev_def.in ());
00753             }
00754         }
00755     }
00756   catch (const CORBA::Exception& ex)
00757     {
00758       ex._tao_print_exception (ACE_TEXT ("visit_valuetype"));
00759 
00760       return -1;
00761     }
00762 
00763   return 0;
00764 }

int ifr_adding_visitor::visit_valuetype_fwd ( AST_ValueTypeFwd *  node  )  [virtual]

Reimplemented from ifr_visitor.

Definition at line 767 of file ifr_adding_visitor.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, BE_GlobalData::do_included_files(), BE_GlobalData::ifr_scopes(), CORBA::is_nil(), LM_ERROR, BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().

00768 {
00769   if (node->imported () && !be_global->do_included_files ())
00770     {
00771       return 0;
00772     }
00773 
00774   AST_Interface *v = node->full_definition ();
00775 
00776   try
00777     {
00778       // Is this interface already in the respository?
00779       CORBA::Contained_var prev_def =
00780         be_global->repository ()->lookup_id (v->repoID ());
00781 
00782       if (CORBA::is_nil (prev_def.in ()))
00783         {
00784           // If our full definition is found in this IDL file, we go
00785           // ahead and create the full entry now.
00786           // The forward declared valuetype is not defined anywhere
00787           // in this IDL file, so we just create an empty entry to
00788           // be replaced by a full definition in some other IDL file.
00789           CORBA::ValueDefSeq abstract_bases (0);
00790           abstract_bases.length (0);
00791           CORBA::InterfaceDefSeq supported (0);
00792           supported.length (0);
00793           CORBA::InitializerSeq initializers (0);
00794           initializers.length (0);
00795 
00796           CORBA::Container_ptr current_scope =
00797             CORBA::Container::_nil ();
00798 
00799           CORBA::Boolean abstract =
00800             static_cast<CORBA::Boolean> (v->is_abstract ());
00801 
00802           if (be_global->ifr_scopes ().top (current_scope) == 0)
00803             {
00804               this->ir_current_ =
00805                 current_scope->create_value (
00806                                    v->repoID (),
00807                                    v->local_name ()->get_string (),
00808                                    v->version (),
00809                                    0, // 'custom' not handled yet
00810                                    abstract,
00811                                    CORBA::ValueDef::_nil (),
00812                                    0, // 'truncatable' not handled yet
00813                                    abstract_bases,
00814                                    supported,
00815                                    initializers
00816                                  );
00817             }
00818           else
00819             {
00820               ACE_ERROR_RETURN ((
00821                   LM_ERROR,
00822                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00823                   ACE_TEXT ("visit_valuetype_fwd -")
00824                   ACE_TEXT (" scope stack is empty\n")
00825                 ),
00826                 -1
00827               );
00828             }
00829 
00830           node->ifr_added (true);
00831           v->ifr_fwd_added (true);
00832         }
00833    }
00834   catch (const CORBA::Exception& ex)
00835     {
00836       ex._tao_print_exception (ACE_TEXT ("visit_valuetype_fwd"));
00837 
00838       return -1;
00839     }
00840 
00841   return 0;
00842 }


Member Data Documentation

bool ifr_adding_visitor::allow_duplicate_typedefs_ [protected]

Definition at line 198 of file ifr_adding_visitor.h.

bool ifr_adding_visitor::in_reopened_ [protected]

Definition at line 195 of file ifr_adding_visitor.h.

Referenced by visit_module().

CORBA::IDLType_var ifr_adding_visitor::ir_current_ [protected]

Definition at line 186 of file ifr_adding_visitor.h.

Referenced by ifr_adding_visitor_union::add_members(), ifr_adding_visitor_structure::add_members(), create_component_def(), create_event_def(), create_home_def(), create_interface_def(), create_value_def(), create_value_member(), element_type(), get_referenced_type(), ifr_adding_visitor_union::ir_current(), ifr_adding_visitor_structure::ir_current(), ifr_adding_visitor_exception::ir_current(), visit_attribute(), visit_component(), visit_component_fwd(), visit_constant(), ifr_adding_visitor_union::visit_enum(), ifr_adding_visitor_structure::visit_enum(), ifr_adding_visitor_exception::visit_enum(), visit_enum(), visit_eventtype(), visit_eventtype_fwd(), visit_home(), visit_interface(), visit_interface_fwd(), visit_native(), ifr_adding_visitor_operation::visit_operation(), visit_predefined_type(), ifr_adding_visitor_union::visit_scope(), ifr_adding_visitor_structure::visit_scope(), visit_sequence(), visit_string(), ifr_adding_visitor_union::visit_structure(), ifr_adding_visitor_structure::visit_structure(), ifr_adding_visitor_exception::visit_structure(), visit_structure(), visit_typedef(), ifr_adding_visitor_union::visit_union(), ifr_adding_visitor_structure::visit_union(), ifr_adding_visitor_exception::visit_union(), visit_union(), visit_valuebox(), and visit_valuetype().

AST_Decl* ifr_adding_visitor::scope_ [protected]

Definition at line 192 of file ifr_adding_visitor.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:50:52 2010 for TAO_IFR by  doxygen 1.4.7