summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs
diff options
context:
space:
mode:
authorsma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-12-14 14:22:18 +0000
committersma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-12-14 14:22:18 +0000
commit3384192434562bb8d66974587207060bebefd3f2 (patch)
tree4a2f671095c4ad9b76d49ac21a9aa9a870d2a5aa /TAO/orbsvcs
parent97bc3e42cec8d42c367973d1cc18d9346e47e416 (diff)
downloadATCD-3384192434562bb8d66974587207060bebefd3f2.tar.gz
ChangeLogTag: Tue Dec 14 14:10:00 UTC 2004 Simon Massey <sma@prismtech.com>
Diffstat (limited to 'TAO/orbsvcs')
-rw-r--r--TAO/orbsvcs/IFR_Service/ifr_adding_visitor_structure.cpp71
-rw-r--r--TAO/orbsvcs/orbsvcs/IFRService/RecursDef_i.cpp42
-rw-r--r--TAO/orbsvcs/orbsvcs/IFRService/RecursDef_i.h63
-rw-r--r--TAO/orbsvcs/orbsvcs/IFRService/StructDef_i.cpp20
-rw-r--r--TAO/orbsvcs/orbsvcs/IFRService/UnionDef_i.cpp20
-rw-r--r--TAO/orbsvcs/orbsvcs/Makefile.am2
6 files changed, 182 insertions, 36 deletions
diff --git a/TAO/orbsvcs/IFR_Service/ifr_adding_visitor_structure.cpp b/TAO/orbsvcs/IFR_Service/ifr_adding_visitor_structure.cpp
index 379d645e0e0..013ee97e839 100644
--- a/TAO/orbsvcs/IFR_Service/ifr_adding_visitor_structure.cpp
+++ b/TAO/orbsvcs/IFR_Service/ifr_adding_visitor_structure.cpp
@@ -160,55 +160,54 @@ ifr_adding_visitor_structure::visit_structure (AST_Structure *node)
if (CORBA::is_nil (prev_def.in ()))
{
- if (this->visit_scope (node) == -1)
+ CORBA::StructDef_var struct_def;
+ CORBA::StructMemberSeq dummyMembers( 0 );
+ dummyMembers.length( 0 );
+
+ CORBA::Container_ptr current_scope= CORBA::Container::_nil ();
+ if (this->is_nested_)
+ {
+ current_scope= be_global->holding_scope ();
+ }
+ else if (be_global->ifr_scopes ().top (current_scope) != 0)
{
ACE_ERROR_RETURN ((
LM_ERROR,
ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::")
ACE_TEXT ("visit_structure -")
- ACE_TEXT (" visit_scope failed\n")
+ ACE_TEXT (" scope stack is empty\n")
),
-1
);
}
- if (this->is_nested_)
+ // First create the named structure without any members
+ struct_def=
+ current_scope->create_struct (
+ node->repoID (),
+ node->local_name ()->get_string (),
+ node->version (),
+ dummyMembers
+ ACE_ENV_ARG_PARAMETER
+ );
+ ACE_TRY_CHECK;
+
+ // Then recurse into the real structure members (which corrupts ir_current_)
+ if (this->visit_scope (node) == -1)
{
- this->ir_current_ =
- be_global->holding_scope ()->create_struct (
- node->repoID (),
- node->local_name ()->get_string (),
- node->version (),
- this->members_
- ACE_ENV_ARG_PARAMETER
- );
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::")
+ ACE_TEXT ("visit_structure -")
+ ACE_TEXT (" visit_scope failed\n")
+ ),
+ -1
+ );
}
- else
- {
- CORBA::Container_ptr current_scope =
- CORBA::Container::_nil ();
- if (be_global->ifr_scopes ().top (current_scope) != 0)
- {
- ACE_ERROR_RETURN ((
- LM_ERROR,
- ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::")
- ACE_TEXT ("visit_structure -")
- ACE_TEXT (" scope stack is empty\n")
- ),
- -1
- );
- }
-
- this->ir_current_ =
- current_scope->create_struct (
- node->repoID (),
- node->local_name ()->get_string (),
- node->version (),
- this->members_
- ACE_ENV_ARG_PARAMETER
- );
- }
+ // Correct ir_current_ and move the real structure members into the struct
+ this->ir_current_= CORBA::StructDef::_duplicate( struct_def );
+ struct_def->members( this->members_ );
ACE_TRY_CHECK;
diff --git a/TAO/orbsvcs/orbsvcs/IFRService/RecursDef_i.cpp b/TAO/orbsvcs/orbsvcs/IFRService/RecursDef_i.cpp
new file mode 100644
index 00000000000..1e360a8d813
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/IFRService/RecursDef_i.cpp
@@ -0,0 +1,42 @@
+/* -*- C++ -*- */
+// $Id$
+
+#include "RecursDef_i.h"
+
+ACE_RCSID (IFRService,
+ RecursDef_i,
+ "RecursDef_i.cpp,v 1.1 2004/10/18 09:00:00 SMA Exp")
+
+//-----------------------------------------------------------------------------
+// Class TAO_RecursiveDef_OuterScopes is a support class for StructDef_i.h and
+// UnionDef_i.h files. It creates a stack of outer structure definitions, used
+// by TAO_StructDef_i::type_i(), and TAO_UnionDef_i::type_i() during nested
+// structure processing.
+//-----------------------------------------------------------------------------
+
+TAO_RecursiveDef_OuterScopes::TAO_RecursiveDef_OuterScopes( const ACE_TString &id )
+ : id_( id ), pNextOuterID_( pIDsSeenAlready )
+{
+ pIDsSeenAlready= this; // "Push" this scope
+}
+
+TAO_RecursiveDef_OuterScopes::~TAO_RecursiveDef_OuterScopes()
+{
+ pIDsSeenAlready= pNextOuterID_; // "Pop" this scope
+}
+
+bool TAO_RecursiveDef_OuterScopes::SeenBefore( const ACE_TString &id )
+{
+ for ( const TAO_RecursiveDef_OuterScopes *pOuterScope= pIDsSeenAlready;
+ pOuterScope;
+ pOuterScope= pOuterScope->pNextOuterID_ )
+ {
+ if (pOuterScope->id_ == id)
+ return true;
+ }
+
+ return false;
+}
+
+const TAO_RecursiveDef_OuterScopes
+ *TAO_RecursiveDef_OuterScopes::pIDsSeenAlready= 0;
diff --git a/TAO/orbsvcs/orbsvcs/IFRService/RecursDef_i.h b/TAO/orbsvcs/orbsvcs/IFRService/RecursDef_i.h
new file mode 100644
index 00000000000..33065794fca
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/IFRService/RecursDef_i.h
@@ -0,0 +1,63 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/orbsvcs/orbsvcs/IFRService
+//
+// = FILENAME
+// RecursDef_i.h
+//
+// = DESCRIPTION
+// StructDef & UnionDef support class.
+//
+// = AUTHOR
+// Simon Massey <sma@prismtech.com>
+//
+// ============================================================================
+
+#ifndef TAO_RECURSDEF_I_H
+#define TAO_RECURSDEF_I_H
+
+#include "TypedefDef_i.h"
+#include "ace/OS_NS_stdlib.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+//-----------------------------------------------------------------------------
+// Class TAO_RecursiveDef_OuterScopes is a support class for StructDef_i.h and
+// UnionDef_i.h files. It creates a stack of outer structure definitions, used
+// by TAO_StructDef_i::type_i(), and TAO_UnionDef_i::type_i() during nested
+// structure processing.
+//-----------------------------------------------------------------------------
+
+class TAO_RecursiveDef_OuterScopes
+{
+public:
+ TAO_RecursiveDef_OuterScopes( const ACE_TString &id ); // "Push" scope's ID
+ ~TAO_RecursiveDef_OuterScopes(); // "Pop" this scope
+
+ static bool SeenBefore( const ACE_TString &id ); // Check for outer ID
+
+private: // Data
+ const ACE_TString id_;
+ const TAO_RecursiveDef_OuterScopes *const pNextOuterID_;
+
+ static const TAO_RecursiveDef_OuterScopes *pIDsSeenAlready;
+};
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* TAO_RECURSDEF_I_H */
diff --git a/TAO/orbsvcs/orbsvcs/IFRService/StructDef_i.cpp b/TAO/orbsvcs/orbsvcs/IFRService/StructDef_i.cpp
index 89e62d0d879..147ca3cc548 100644
--- a/TAO/orbsvcs/orbsvcs/IFRService/StructDef_i.cpp
+++ b/TAO/orbsvcs/orbsvcs/IFRService/StructDef_i.cpp
@@ -2,6 +2,7 @@
// $Id$
#include "StructDef_i.h"
+#include "RecursDef_i.h"
#include "Repository_i.h"
#include "IFR_Service_Utils.h"
#include "ace/Auto_Ptr.h"
@@ -76,6 +77,25 @@ TAO_StructDef_i::type_i (ACE_ENV_SINGLE_ARG_DECL)
"id",
id);
+ //---------------------------------------------------------------------------
+ // Have we already seen this structure definition at an outer scope?
+ // If yes, return a recursive type code to signal the nesting.
+ // If not, record this new structure id in our stack (it will automatically
+ // be removed when NowSeenThis goes out of scope).
+ //---------------------------------------------------------------------------
+
+ if (TAO_RecursiveDef_OuterScopes::SeenBefore( id ))
+ return this->repo_->tc_factory ()->
+ create_recursive_tc ( id.c_str () ACE_ENV_ARG_PARAMETER);
+
+ TAO_RecursiveDef_OuterScopes NowSeenThis( id );
+
+ //---------------------------------------------------------------------------
+ // Create a new type code for this structure; the create_struct_tc() call
+ // that follows may recursivly call this method again if one of its children
+ // refers to a structure (which is the point of the above NowSeenThis stack).
+ //---------------------------------------------------------------------------
+
ACE_TString name;
this->repo_->config ()->get_string_value (this->section_key_,
"name",
diff --git a/TAO/orbsvcs/orbsvcs/IFRService/UnionDef_i.cpp b/TAO/orbsvcs/orbsvcs/IFRService/UnionDef_i.cpp
index 2664eb0a1e9..5886ea613f0 100644
--- a/TAO/orbsvcs/orbsvcs/IFRService/UnionDef_i.cpp
+++ b/TAO/orbsvcs/orbsvcs/IFRService/UnionDef_i.cpp
@@ -2,6 +2,7 @@
// $Id$
#include "UnionDef_i.h"
+#include "RecursDef_i.h"
#include "Repository_i.h"
#include "IFR_Service_Utils.h"
@@ -80,6 +81,25 @@ TAO_UnionDef_i::type_i (ACE_ENV_SINGLE_ARG_DECL)
"id",
id);
+ //---------------------------------------------------------------------------
+ // Have we already seen this union definition at an outer scope?
+ // If yes, return a recursive type code to signal the nesting.
+ // If not, record this new union id in our stack (it will automatically be
+ // removed when NowSeenThis goes out of scope).
+ //---------------------------------------------------------------------------
+
+ if (TAO_RecursiveDef_OuterScopes::SeenBefore( id ))
+ return this->repo_->tc_factory ()->
+ create_recursive_tc ( id.c_str () ACE_ENV_ARG_PARAMETER);
+
+ TAO_RecursiveDef_OuterScopes NowSeenThis( id );
+
+ //---------------------------------------------------------------------------
+ // Create a new type code for this structure; the create_union_tc() call
+ // that follows may recursivly call this method again if one of its children
+ // refers to a union (which is the point of the above NowSeenThis stack).
+ //---------------------------------------------------------------------------
+
ACE_TString name;
this->repo_->config ()->get_string_value (this->section_key_,
"name",
diff --git a/TAO/orbsvcs/orbsvcs/Makefile.am b/TAO/orbsvcs/orbsvcs/Makefile.am
index 357b81d9142..2d143fd533c 100644
--- a/TAO/orbsvcs/orbsvcs/Makefile.am
+++ b/TAO/orbsvcs/orbsvcs/Makefile.am
@@ -4222,6 +4222,7 @@ IFRService = \
IFRService/PrimitiveDef_i.cpp \
IFRService/ProvidesDef_i.cpp \
IFRService/PublishesDef_i.cpp \
+ IFRService/RecursDef_i.cpp \
IFRService/Repository_i.cpp \
IFRService/SequenceDef_i.cpp \
IFRService/StringDef_i.cpp \
@@ -4311,6 +4312,7 @@ nobase_include_HEADERS += \
IFRService/PrimitiveDef_i.h \
IFRService/ProvidesDef_i.h \
IFRService/PublishesDef_i.h \
+ IFRService/RecursDef_i.h \
IFRService/Repository_i.h \
IFRService/SequenceDef_i.h \
IFRService/StringDef_i.h \