summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2003-07-28 17:38:25 +0000
committerbala <balanatarajan@users.noreply.github.com>2003-07-28 17:38:25 +0000
commit92fa9e6af2bbd36745b528752c1d92b0cb76f6bd (patch)
treec545df09172ec295d622e71b0d8ed35abcaf70af
parentc12ed3fd8a6bfd5794ab50267cb8a44ddb701a68 (diff)
downloadATCD-92fa9e6af2bbd36745b528752c1d92b0cb76f6bd.tar.gz
ChangeLogTag:Mon Jul 28 12:34:16 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
-rw-r--r--TAO/ChangeLog15
-rw-r--r--TAO/tao/Any_SystemException.cpp209
-rw-r--r--TAO/tao/Any_SystemException.h79
-rw-r--r--TAO/tao/Exception.cpp93
-rw-r--r--TAO/tao/Makefile.bor1
-rw-r--r--TAO/tao/Makefile.tao1
-rw-r--r--TAO/tao/tao.mpc1
7 files changed, 330 insertions, 69 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 92dd78ae083..6e6cfa2241b 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,18 @@
+Mon Jul 28 12:34:16 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
+
+ * tao/Any_SystemException.h:
+ * tao/Any_SystemException.cpp: New Any_Impl classes to be used by
+ different concrete CORBA::SystemException types. The way it was
+ done before added a lot of footprint.
+
+ * tao/Exception.cpp: Use TAO::Any_SystemException class for Any
+ extraction and insertion operators.
+
+ * tao/Makefile.tao:
+ * tao/tao.mpc:
+ * tao/makefile.bor: Added the new file to the following Makefiles
+ and project files.
+
Mon Jul 28 13:25:00 2003 Stephen Torri <storri@cse.wustl.edu>
* orbsvcs/orbsvcs/Metrics.idl:
diff --git a/TAO/tao/Any_SystemException.cpp b/TAO/tao/Any_SystemException.cpp
new file mode 100644
index 00000000000..b6c8a5e283a
--- /dev/null
+++ b/TAO/tao/Any_SystemException.cpp
@@ -0,0 +1,209 @@
+// $Id$
+
+#ifndef TAO_ANY_SYSTEMEXCEPTION_C
+#define TAO_ANY_SYSTEMEXCEPTION_C
+
+#include "Any_SystemException.h"
+#include "Exception.h"
+#include "Marshal.h"
+#include "debug.h"
+#include "CORBA_String.h"
+
+#include "ace/CORBA_macros.h"
+
+
+ACE_RCSID (tao,
+ Any_SystemException,
+ "$Id$")
+
+TAO::Any_SystemException::Any_SystemException (_tao_destructor destructor,
+ CORBA::TypeCode_ptr tc,
+ CORBA::SystemException * const val)
+ : Any_Impl (destructor,
+ tc),
+ value_ (val)
+{
+}
+
+TAO::Any_SystemException::Any_SystemException (_tao_destructor destructor,
+ CORBA::TypeCode_ptr tc,
+ const CORBA::SystemException & val)
+ : Any_Impl (destructor,
+ tc)
+{
+ this->value_ =
+ dynamic_cast <CORBA::SystemException *> (val._tao_duplicate ());
+}
+
+TAO::Any_SystemException::Any_SystemException (CORBA::TypeCode_ptr tc)
+ : Any_Impl (0,
+ tc)
+{
+}
+
+TAO::Any_SystemException::~Any_SystemException (void)
+{
+}
+
+void
+TAO::Any_SystemException::insert (CORBA::Any & any,
+ _tao_destructor destructor,
+ CORBA::TypeCode_ptr tc,
+ CORBA::SystemException * const value)
+{
+ Any_SystemException *new_impl = 0;
+ ACE_NEW (new_impl,
+ Any_SystemException (destructor,
+ tc,
+ value));
+ any.replace (new_impl);
+}
+
+void
+TAO::Any_SystemException::insert_copy (CORBA::Any & any,
+ _tao_destructor destructor,
+ CORBA::TypeCode_ptr tc,
+ const CORBA::SystemException & value)
+{
+ Any_SystemException *new_impl = 0;
+ ACE_NEW (new_impl,
+ Any_SystemException (destructor,
+ tc,
+ value));
+ any.replace (new_impl);
+}
+
+CORBA::Boolean
+TAO::Any_SystemException::extract (const CORBA::Any & any,
+ _tao_destructor destructor,
+ CORBA::TypeCode_ptr tc,
+ const CORBA::SystemException *& _tao_elem,
+ TAO::excp_factory f)
+{
+ _tao_elem = 0;
+
+ ACE_TRY_NEW_ENV
+ {
+ CORBA::TypeCode_ptr any_tc = any._tao_get_typecode ();
+ CORBA::Boolean _tao_equiv = any_tc->equivalent (tc
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (_tao_equiv == 0)
+ {
+ return 0;
+ }
+
+ TAO::Any_Impl *impl = any.impl ();
+
+ ACE_Message_Block *mb = impl->_tao_get_cdr ();
+
+ if (mb == 0)
+ {
+ TAO::Any_SystemException *narrow_impl =
+ dynamic_cast <TAO::Any_SystemException *> (impl);
+
+ if (narrow_impl == 0)
+ {
+ return 0;
+ }
+
+ _tao_elem = narrow_impl->value_;
+ return 1;
+ }
+
+ CORBA::SystemException *empty_value = (*f) ();
+
+ TAO::Any_SystemException *replacement = 0;
+ ACE_NEW_RETURN (replacement,
+ TAO::Any_SystemException (destructor,
+ any_tc,
+ empty_value),
+ 0);
+
+ auto_ptr<TAO::Any_SystemException > replacement_safety (replacement);
+
+ TAO_InputCDR cdr (mb->data_block (),
+ ACE_Message_Block::DONT_DELETE,
+ mb->rd_ptr () - mb->base (),
+ mb->wr_ptr () - mb->base (),
+ impl->_tao_byte_order (),
+ TAO_DEF_GIOP_MAJOR,
+ TAO_DEF_GIOP_MINOR);
+
+ CORBA::TCKind kind = any_tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ impl->assign_translator (kind,
+ &cdr);
+ CORBA::Boolean result = replacement->demarshal_value (cdr);
+
+ if (result == 1)
+ {
+ _tao_elem = replacement->value_;
+ ACE_const_cast (CORBA::Any &, any).replace (replacement);
+ replacement_safety.release ();
+ return result;
+ }
+ }
+ ACE_CATCHANY
+ {
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
+
+void
+TAO::Any_SystemException::free_value (void)
+{
+ if (this->value_destructor_ != 0)
+ {
+ (*this->value_destructor_) (this->value_);
+ this->value_destructor_ = 0;
+ }
+
+ this->value_ = 0;
+}
+
+const void *
+TAO::Any_SystemException::value (void) const
+{
+ return this->value_;
+}
+
+CORBA::Boolean
+TAO::Any_SystemException::marshal_value (TAO_OutputCDR &cdr) \
+{
+ ACE_TRY_NEW_ENV
+ {
+ this->value_->_tao_encode (cdr
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ return 1;
+ }
+ ACE_CATCHANY
+ {
+ }
+ ACE_ENDTRY;
+ return 0;
+}
+
+CORBA::Boolean
+TAO::Any_SystemException::demarshal_value (TAO_InputCDR &cdr)
+{
+ ACE_TRY_NEW_ENV
+ {
+ this->value_->_tao_decode (cdr
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ return 1;
+ }
+ ACE_CATCHANY
+ {
+ }
+ ACE_ENDTRY;
+ return 0;
+}
+
+#endif /* TAO_ANY_EXCEPTION_C */
diff --git a/TAO/tao/Any_SystemException.h b/TAO/tao/Any_SystemException.h
new file mode 100644
index 00000000000..7cd6cfb6744
--- /dev/null
+++ b/TAO/tao/Any_SystemException.h
@@ -0,0 +1,79 @@
+// This may look like C, but it's really -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Any_SystemException.h
+ *
+ * $Id$
+ *
+ * @authors Carlos O'Ryan and Jeff Parsons
+ */
+//=============================================================================
+#ifndef TAO_ANY_SYSTEMEXCEPTION_H
+#define TAO_ANY_SYSTEMEXCEPTION_H
+
+#include /**/ "ace/pre.h"
+
+#include "tao/Any.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+namespace TAO
+{
+ typedef CORBA::SystemException* (*excp_factory)(void);
+
+ /**
+ * @class Any_Exception
+ *
+ * @brief Template Any class for IDL types with 2 modes of insertion
+ *
+ * Used for the IDL types that have copying and non-copying insertion,
+ * but which are not (de)marshaled as pointers - struct, union, sequence,
+ * and exception.
+ */
+ class Any_SystemException : public Any_Impl
+ {
+ public:
+ Any_SystemException (_tao_destructor destructor,
+ CORBA::TypeCode_ptr,
+ CORBA::SystemException* const);
+
+ Any_SystemException (_tao_destructor destructor,
+ CORBA::TypeCode_ptr,
+ const CORBA::SystemException &);
+
+ Any_SystemException (CORBA::TypeCode_ptr);
+
+ virtual ~Any_SystemException (void);
+
+ static void insert (CORBA::Any &,
+ _tao_destructor,
+ CORBA::TypeCode_ptr,
+ CORBA::SystemException * const);
+
+ static void insert_copy (CORBA::Any &,
+ _tao_destructor destructor,
+ CORBA::TypeCode_ptr,
+ const CORBA::SystemException &);
+
+ static CORBA::Boolean extract (const CORBA::Any &,
+ _tao_destructor,
+ CORBA::TypeCode_ptr,
+ const CORBA::SystemException *&,
+ excp_factory f);
+
+ virtual CORBA::Boolean marshal_value (TAO_OutputCDR &);
+ CORBA::Boolean demarshal_value (TAO_InputCDR &);
+
+ virtual const void *value (void) const;
+ virtual void free_value (void);
+
+ protected:
+ CORBA::SystemException *value_;
+ };
+};
+
+#include /**/ "ace/post.h"
+#endif /*TAO_ANY_SYSTEMEXCEPTION_H*/
diff --git a/TAO/tao/Exception.cpp b/TAO/tao/Exception.cpp
index 8d222762093..9c3e397fbe3 100644
--- a/TAO/tao/Exception.cpp
+++ b/TAO/tao/Exception.cpp
@@ -3,17 +3,17 @@
// THREADING NOTE: calling thread handles mutual exclusion policy
// on all of these data structures.
+#include "Exception.h"
+#include "Typecode.h"
+#include "Environment.h"
+#include "Any.h"
+#include "CDR.h"
+#include "ORB.h"
+#include "ORB_Core.h"
+#include "Any_SystemException.h"
+
#include "ace/streams.h"
-#include "ace/Dynamic_Service.h"
-#include "ace/Malloc_Allocator.h"
-#include "tao/Exception.h"
-#include "tao/Typecode.h"
-#include "tao/Environment.h"
-#include "tao/Any.h"
-#include "tao/CDR.h"
-#include "tao/ORB.h"
-#include "tao/ORB_Core.h"
-#include "tao/Dynamic_Adapter.h"
+
#if !defined (__ACE_INLINE__)
# include "tao/Exception.i"
@@ -1083,6 +1083,15 @@ static char *repo_id_array [] = {
0
};
+
+TAO::excp_factory excp_array [] = {
+#define TAO_SYSTEM_EXCEPTION(name) \
+ &CORBA::name::_tao_create,
+ STANDARD_EXCEPTION_LIST
+#undef TAO_SYSTEM_EXCEPTION
+ 0
+ };
+
void
TAO_Exceptions::init (ACE_ENV_SINGLE_ARG_DECL)
{
@@ -1132,16 +1141,6 @@ CORBA::SystemException *
TAO_Exceptions::create_system_exception (const char *id
ACE_ENV_ARG_DECL_NOT_USED)
{
- typedef CORBA::SystemException* (*funcp)(void);
-
- funcp excp_array [] = {
-#define TAO_SYSTEM_EXCEPTION(name) \
- &CORBA::name::_tao_create,
- STANDARD_EXCEPTION_LIST
-#undef TAO_SYSTEM_EXCEPTION
- 0
- };
-
for (CORBA::ULong i = 0;
i < array_sz;
++i)
@@ -1260,54 +1259,10 @@ STANDARD_EXCEPTION_LIST
#undef TAO_SYSTEM_EXCEPTION
#define TAO_SYSTEM_EXCEPTION(name) \
-template<> \
-CORBA::Boolean \
-TAO::Any_Dual_Impl_T<CORBA::name >::marshal_value (TAO_OutputCDR &cdr) \
-{ \
- ACE_TRY_NEW_ENV \
- { \
- this->value_->_tao_encode (cdr \
- ACE_ENV_ARG_PARAMETER); \
- ACE_TRY_CHECK; \
- return 1; \
- } \
- ACE_CATCHANY \
- { \
- } \
- ACE_ENDTRY; \
- return 0; \
-}
-
-STANDARD_EXCEPTION_LIST
-#undef TAO_SYSTEM_EXCEPTION
-
-#define TAO_SYSTEM_EXCEPTION(name) \
-template<> \
-CORBA::Boolean \
-TAO::Any_Dual_Impl_T<CORBA::name >::demarshal_value (TAO_InputCDR &cdr) \
-{ \
- ACE_TRY_NEW_ENV \
- { \
- this->value_->_tao_decode (cdr \
- ACE_ENV_ARG_PARAMETER); \
- ACE_TRY_CHECK; \
- return 1; \
- } \
- ACE_CATCHANY \
- { \
- } \
- ACE_ENDTRY; \
- return 0; \
-}
-
-STANDARD_EXCEPTION_LIST
-#undef TAO_SYSTEM_EXCEPTION
-
-#define TAO_SYSTEM_EXCEPTION(name) \
void \
CORBA::operator<<= (CORBA::Any &any, const CORBA::name &ex) \
{ \
- TAO::Any_Dual_Impl_T<CORBA::name >::insert_copy ( \
+ TAO::Any_SystemException::insert_copy ( \
any, \
CORBA::name ::_tao_any_destructor, \
CORBA::_tc_ ## name, \
@@ -1322,7 +1277,7 @@ STANDARD_EXCEPTION_LIST
void \
CORBA::operator<<= (CORBA::Any &any, CORBA::name *ex) \
{ \
- TAO::Any_Dual_Impl_T<CORBA::name >::insert ( \
+ TAO::Any_SystemException::insert ( \
any, \
CORBA::name ::_tao_any_destructor, \
CORBA::_tc_ ## name, \
@@ -1338,12 +1293,12 @@ CORBA::Boolean operator>>= (const CORBA::Any &any, \
const CORBA::name *&ex) \
{ \
return \
- TAO::Any_Dual_Impl_T<CORBA::name >::extract ( \
+ TAO::Any_SystemException::extract ( \
any, \
CORBA::name ::_tao_any_destructor, \
CORBA::_tc_ ## name, \
- ex \
- ); \
+ (const CORBA::SystemException *&) ex, \
+ &CORBA::name ::_tao_create); \
}
STANDARD_EXCEPTION_LIST
diff --git a/TAO/tao/Makefile.bor b/TAO/tao/Makefile.bor
index e6f0405c6e9..cd853bc4692 100644
--- a/TAO/tao/Makefile.bor
+++ b/TAO/tao/Makefile.bor
@@ -30,6 +30,7 @@ OBJFILES = \
$(OBJDIR)\Acceptor_Registry.obj \
$(OBJDIR)\Adapter.obj \
$(OBJDIR)\Any.obj \
+ $(OBJDIR)\Any_SystemException.obj \
$(OBJDIR)\Asynch_Invocation.obj \
$(OBJDIR)\Asynch_Queued_Message.obj \
$(OBJDIR)\Asynch_Reply_Dispatcher_Base.obj \
diff --git a/TAO/tao/Makefile.tao b/TAO/tao/Makefile.tao
index d772bef33ef..856c7a3f31d 100644
--- a/TAO/tao/Makefile.tao
+++ b/TAO/tao/Makefile.tao
@@ -146,6 +146,7 @@ IDL_COMPILER_FILES = \
ORB_CORE_FILES = \
Any \
+ Any_Exception \
CORBA_String \
CurrentC \
Exception \
diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc
index b7c73c0e416..b52885f45fa 100644
--- a/TAO/tao/tao.mpc
+++ b/TAO/tao/tao.mpc
@@ -70,6 +70,7 @@ project(TAO) : acelib, taoversion, core, tao_output {
}
ORB_Core {
Any.cpp
+ Any_SystemException.cpp
CORBA_String.cpp
CurrentC.cpp
Exception.cpp