summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2003-07-24 21:11:33 +0000
committerbala <balanatarajan@users.noreply.github.com>2003-07-24 21:11:33 +0000
commit30b7fe55133c70633fad2849c3a32976bf96f997 (patch)
tree4ea196e0e4fb1393cd1328800e3e7379be923896
parent1942355ebe4305cb46431b440c9881d4d3f92fef (diff)
downloadATCD-30b7fe55133c70633fad2849c3a32976bf96f997.tar.gz
ChangeLogTag:Thu Jul 24 16:06:21 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
-rw-r--r--TAO/ChangeLog17
-rw-r--r--TAO/tao/Exception.cpp135
-rw-r--r--TAO/tao/Exception.h14
3 files changed, 107 insertions, 59 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index f2d4bc5cce4..fca8d527043 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,12 @@
+Thu Jul 24 16:06:21 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
+
+ * tao/Exception.h:
+ * tao/Exception.cpp: Some cosmetic fixes that reduce the in disk
+ footprint of this file. The problem is that we use macros to
+ create and initalize a tonne of system exceptions. The footprint
+ blow up is due to code duplication. This checkin primarily tries
+ to reduce code duplication which helps the footprint.
+
Thu Jul 24 15:29:37 2003 George Edwards <g.edwards@vanderbilt.edu>
* CIAO/examples/handcrafted/BasicSP_EC/*.*:
@@ -7,10 +16,10 @@ Thu Jul 24 15:29:37 2003 George Edwards <g.edwards@vanderbilt.edu>
* CIAO/examples/handcrafted/BasicSP_EC/descriptors/*.*:
* CIAO/examples/handcrafted/BasicSP_EC/EC/*.*:
- Handcrafted BasicSP example to use TAO's RT event channel for event
- propagation. This involved modifications to each component's servant
- header and source files, which are normally generated by the CIDL
- compiler.
+ Handcrafted BasicSP example to use TAO's RT event channel for
+ event propagation. This involved modifications to each
+ component's servant header and source files, which are normally
+ generated by the CIDL compiler.
Thu Jul 24 14:26:12 2003 Yamuna Krishnamurthy <yamuna@oomworks.com>
diff --git a/TAO/tao/Exception.cpp b/TAO/tao/Exception.cpp
index 6e3d37fafaa..7577221b8c3 100644
--- a/TAO/tao/Exception.cpp
+++ b/TAO/tao/Exception.cpp
@@ -114,6 +114,8 @@ CORBA::Exception::_is_a (const char* repository_id) const
"IDL:omg.org/CORBA/Exception:1.0") == 0;
}
+
+
void
CORBA::Exception::_tao_print_exception (const char *user_provided_info,
FILE *) const
@@ -259,12 +261,14 @@ CORBA::SystemException::operator= (const CORBA::SystemException &src)
return *this;
}
+
int
CORBA::SystemException::_is_a (const char* interface_id) const
{
- return ACE_OS_String::strcmp (interface_id,
- "IDL:omg.org/CORBA/SystemException:1.0") == 0
- || this->Exception::_is_a (interface_id);
+ return ((ACE_OS_String::strcmp (interface_id, this->_rep_id ()) == 0) ||
+ (ACE_OS_String::strcmp (interface_id,
+ "IDL:omg.org/CORBA/SystemException:1.0") == 0)
+ || this->Exception::_is_a (interface_id));
}
CORBA::SystemException*
@@ -1052,14 +1056,32 @@ TAO_Exceptions::make_standard_typecode (CORBA::TypeCode_ptr &tcp,
// it works that way in most systems.
#define TAO_TC_BUF_LEN 256
+// static CORBA::Long tc_buf_CORBA_ ## name[TAO_TC_BUF_LEN / sizeof (CORBA::Long)];
#define TAO_SYSTEM_EXCEPTION(name) \
- static CORBA::Long tc_buf_CORBA_ ## name[TAO_TC_BUF_LEN / sizeof (CORBA::Long)]; \
CORBA::TypeCode_ptr CORBA::_tc_ ## name = 0;
STANDARD_EXCEPTION_LIST
#undef TAO_SYSTEM_EXCEPTION
-#undef TAO_TC_BUF_LEN
+
+ CORBA::TypeCode_ptr type_code_array [] = {
+#define TAO_SYSTEM_EXCEPTION(name) \
+ CORBA::_tc_ ## name,
+ STANDARD_EXCEPTION_LIST
+#undef TAO_SYSTEM_EXCEPTION
+ CORBA::_tc_null};
+
+// Since we add an extra element subtract 1
+static CORBA::ULong array_sz =
+ (sizeof (type_code_array) / sizeof (CORBA::TypeCode_ptr)) - 1;
+
+static char *repo_id_array [] = {
+#define TAO_SYSTEM_EXCEPTION(name) \
+ "IDL:omg.org/CORBA/" #name ":1.0",
+ STANDARD_EXCEPTION_LIST
+#undef TAO_SYSTEM_EXCEPTION
+ 0
+ };
void
TAO_Exceptions::init (ACE_ENV_SINGLE_ARG_DECL)
@@ -1075,15 +1097,27 @@ TAO_Exceptions::init (ACE_ENV_SINGLE_ARG_DECL)
ACE_NEW (TAO_Exceptions::global_allocator_,
ACE_New_Allocator);
+ char *name_array [] = {
#define TAO_SYSTEM_EXCEPTION(name) \
- TAO_Exceptions::make_standard_typecode (CORBA::_tc_ ## name, \
- #name, \
- (char*) tc_buf_CORBA_ ## name, \
- sizeof (tc_buf_CORBA_ ## name) \
- ACE_ENV_ARG_PARAMETER); \
- ACE_CHECK;
- STANDARD_EXCEPTION_LIST
+ # name,
+ STANDARD_EXCEPTION_LIST
#undef TAO_SYSTEM_EXCEPTION
+ 0
+ };
+
+ for (CORBA::ULong i = 0;
+ i < array_sz;
+ ++i)
+ {
+ CORBA::Long tc_buf_CORBA_tc [TAO_TC_BUF_LEN/sizeof(CORBA::Long)];
+
+ TAO_Exceptions::make_standard_typecode (type_code_array[i],
+ name_array[i],
+ (char*) tc_buf_CORBA_tc,
+ sizeof tc_buf_CORBA_tc
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ }
TAO_Exceptions::make_unknown_user_typecode (CORBA::_tc_UnknownUserException
ACE_ENV_ARG_PARAMETER);
@@ -1091,18 +1125,30 @@ TAO_Exceptions::init (ACE_ENV_SINGLE_ARG_DECL)
TAO_Exceptions::initialized_ = 1;
}
+#undef TAO_TC_BUF_LEN
+
+
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) \
- { \
- const char* xid = "IDL:omg.org/CORBA/" #name ":1.0"; \
- if (ACE_OS_String::strcmp (id, xid) == 0) \
- return new CORBA::name; \
- }
- STANDARD_EXCEPTION_LIST
-#undef TAO_SYSTEM_EXCEPTION
+ &CORBA::name::_tao_create,
+ STANDARD_EXCEPTION_LIST
+#undef TAO_SYSTEM_EXCEPTION
+ 0
+ };
+
+ for (CORBA::ULong i = 0;
+ i < array_sz;
+ ++i)
+ {
+ if (ACE_OS_String::strcmp (id, repo_id_array[i]) == 0)
+ return (*(excp_array[i])) ();
+ }
return 0;
}
@@ -1110,11 +1156,13 @@ TAO_Exceptions::create_system_exception (const char *id
void
TAO_Exceptions::fini (void)
{
-#define TAO_SYSTEM_EXCEPTION(name) \
- CORBA::release (CORBA::_tc_ ## name); \
- CORBA::_tc_ ## name = 0;
- STANDARD_EXCEPTION_LIST
-#undef TAO_SYSTEM_EXCEPTION
+ for (CORBA::ULong i = 0;
+ i < array_sz;
+ ++i)
+ {
+ CORBA::release (type_code_array[i]);
+ type_code_array[i] = 0;
+ }
CORBA::release (CORBA::_tc_UnknownUserException);
CORBA::_tc_UnknownUserException = 0;
@@ -1124,19 +1172,6 @@ TAO_Exceptions::fini (void)
}
#define TAO_SYSTEM_EXCEPTION(name) \
-int \
-CORBA::name ::_is_a (const char* interface_id) const \
-{ \
- return ((ACE_OS_String::strcmp ( \
- interface_id, \
- "IDL:omg.org/CORBA/" #name ":1.0") == 0) \
- || this->SystemException::_is_a (interface_id)); \
-}
-
-STANDARD_EXCEPTION_LIST
-#undef TAO_SYSTEM_EXCEPTION
-
-#define TAO_SYSTEM_EXCEPTION(name) \
CORBA::name * \
CORBA::name ::_downcast (CORBA::Exception* exception) \
{ \
@@ -1213,6 +1248,18 @@ STANDARD_EXCEPTION_LIST
#undef TAO_SYSTEM_EXCEPTION
#define TAO_SYSTEM_EXCEPTION(name) \
+CORBA::SystemException * \
+CORBA::name ::_tao_create (void) \
+{ \
+ CORBA::SystemException *result; \
+ ACE_NEW_RETURN (result, CORBA::name (), 0); \
+ return result; \
+}
+
+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) \
@@ -1304,24 +1351,14 @@ STANDARD_EXCEPTION_LIST
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-#define TAO_SYSTEM_EXCEPTION(name) \
-template class TAO::Any_Dual_Impl_T<CORBA::name >;
-
-STANDARD_EXCEPTION_LIST
-#undef TAO_SYSTEM_EXCEPTION
+template class TAO::Any_Dual_Impl_T<CORBA::SystemException>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#define TAO_SYSTEM_EXCEPTION(name) \
-#pragma instantiate TAO::Any_Dual_Impl_T<CORBA::name >
-
-STANDARD_EXCEPTION_LIST
-#undef TAO_SYSTEM_EXCEPTION
+#pragma instantiate TAO::Any_Dual_Impl_T<CORBA::SystemException>;
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
-#undef STANDARD_EXCEPTION_LIST
-
#if defined (TAO_DONT_CATCH_DOT_DOT_DOT)
TAO_DONT_CATCH::TAO_DONT_CATCH (void)
{}
diff --git a/TAO/tao/Exception.h b/TAO/tao/Exception.h
index 22e7df6bda9..fb4f1b0fe8f 100644
--- a/TAO/tao/Exception.h
+++ b/TAO/tao/Exception.h
@@ -15,8 +15,8 @@
#ifndef TAO_EXCEPTION_H
#define TAO_EXCEPTION_H
+#include /**/"ace/pre.h"
-#include /**/ "ace/pre.h"
#include "tao/corbafwd.h"
@@ -171,7 +171,7 @@ namespace CORBA
/// Constructor from a repository id.
UserException (const char *repository_id,
- const char *local_name);
+ const char *local_name);
virtual int _is_a (const char *interface_id) const;
@@ -225,6 +225,7 @@ namespace CORBA
/// Narrow to a SystemException.
static SystemException *_downcast (CORBA::Exception *exception);
+
// = TAO-specific extension.
/// Helper for the _downcast operation.
@@ -234,6 +235,9 @@ namespace CORBA
/// This function is not CORBA compliant.
void _tao_print_system_exception (FILE *f = stdout) const;
+ /// Create an exception from the available exception
+ virtual CORBA::Exception *_tao_duplicate (void) const;
+
/// Returns a string containing information about the exception. This
/// function is not CORBA compliant.
virtual ACE_CString _info (void) const;
@@ -287,11 +291,11 @@ namespace CORBA
name (CORBA::ULong code, \
CORBA::CompletionStatus completed); \
static name * _downcast (CORBA::Exception* exception); \
- virtual int _is_a (const char* type_id) const; \
virtual void _raise (void); \
virtual CORBA::TypeCode_ptr _type (void) const; \
static void _tao_any_destructor (void*); \
virtual CORBA::Exception *_tao_duplicate (void) const; \
+ static CORBA::SystemException *_tao_create (void); \
}; \
TAO_Export void operator<<= (CORBA::Any &, const CORBA::name &); \
TAO_Export void operator<<= (CORBA::Any &, CORBA::name *); \
@@ -389,7 +393,6 @@ public:
ACE_ENV_ARG_DECL
);
-
/**
* This global allocator is used to initialize system exception
* typecodes. Since at the time, the ORB is mostly still not
@@ -422,6 +425,5 @@ public:
# include "tao/Exception.i"
#endif /* __ACE_INLINE__ */
-#include /**/ "ace/post.h"
-
+#include /**/"ace/post.h"
#endif /* TAO_EXCEPTION_H */