Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Exception.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 // $Id: Exception.cpp,v 1.1.1.4.2.3 2003/05/19 16:25:41 chad Exp $
00003 
00004 // THREADING NOTE:  calling thread handles mutual exclusion policy
00005 // on all of these data structures.
00006 
00007 #include "ace/streams.h"
00008 #include "ace/Dynamic_Service.h"
00009 #include "ace/Malloc_Allocator.h"
00010 #include "tao/Exception.h"
00011 #include "tao/Typecode.h"
00012 #include "tao/Environment.h"
00013 #include "tao/Any.h"
00014 #include "tao/CDR.h"
00015 #include "tao/ORB.h"
00016 #include "tao/ORB_Core.h"
00017 #include "tao/Dynamic_Adapter.h"
00018 
00019 #if defined(ACE_MVS)
00020 #include "ace/Codeset_IBM1047.h"
00021 #endif /* ACE_MVS */
00022 
00023 #if !defined (__ACE_INLINE__)
00024 # include "tao/Exception.i"
00025 #endif /* __ACE_INLINE__ */
00026 
00027 ACE_RCSID (TAO,
00028            Exception,
00029            "$Id: Exception.cpp,v 1.1.1.4.2.3 2003/05/19 16:25:41 chad Exp $")
00030 
00031 // Static initializers.
00032 
00033 ACE_Allocator *TAO_Exceptions::global_allocator_;
00034 
00035 // Flag that denotes that the TAO TypeCode constants have been
00036 // initialized.
00037 int TAO_Exceptions::initialized_ = 0;
00038 
00039 // TAO specific typecode.
00040 extern CORBA::TypeCode_ptr TC_completion_status;
00041 
00042 // ****************************************************************
00043 
00044 CORBA_Exception::CORBA_Exception (const char *repository_id,
00045                                   const char *local_name)
00046   : id_ (CORBA::string_dup (repository_id)),
00047     name_ ( CORBA::string_dup (local_name))
00048 {
00049   ACE_ASSERT (this->id_ != 0 && this->name_ != 0);
00050 }
00051 
00052 CORBA_Exception::CORBA_Exception (const CORBA_Exception &src)
00053   : id_ (CORBA::string_dup (src.id_)),
00054     name_ (CORBA::string_dup (src.name_))
00055 {
00056   ACE_ASSERT (this->id_ != 0 && this->name_ != 0);
00057 }
00058 
00059 // NOTE: It's this code, not anything defined in a subclass, which is
00060 // responsible for releasing any storage owned by the exception.  It
00061 // can do this because it's got the local name and the id.
00062 
00063 CORBA_Exception::CORBA_Exception (void)
00064   : id_ (0),
00065     name_ (0)
00066 {
00067 }
00068 
00069 CORBA_Exception::~CORBA_Exception (void)
00070 {
00071   CORBA::string_free (this->id_);
00072   CORBA::string_free (this->name_);
00073 }
00074 
00075 CORBA_Exception &
00076 CORBA_Exception::operator= (const CORBA_Exception &src)
00077 {
00078   if (this->id_)
00079     {
00080       CORBA::string_free (this->id_);
00081     }
00082 
00083   this->id_ = CORBA::string_dup (src.id_);
00084   ACE_ASSERT (this->id_ != 0);
00085 
00086   if (this->name_)
00087     {
00088       CORBA::string_free (this->name_);
00089     }
00090 
00091   this->name_ = CORBA::string_dup (src.name_);
00092   ACE_ASSERT (this->name_ != 0);
00093 
00094   return *this;
00095 }
00096 
00097 const char *
00098 CORBA_Exception::_rep_id (void) const
00099 {
00100   return this->id_;
00101 }
00102 
00103 const char *
00104 CORBA_Exception::_name (void) const
00105 {
00106   return this->name_;
00107 }
00108 
00109 CORBA::TypeCode_ptr
00110 CORBA_Exception::_type (void) const
00111 {
00112   return CORBA::TypeCode::_nil ();
00113 }
00114 
00115 int
00116 CORBA_Exception::_is_a (const char* repository_id) const
00117 {
00118   return ACE_OS_String::strcmp (repository_id,
00119                                 "IDL:omg.org/CORBA/Exception:1.0") == 0;
00120 }
00121 
00122 void
00123 CORBA_Exception::_tao_print_exception (const char *user_provided_info,
00124                                        FILE *) const
00125 {
00126   ACE_DEBUG ((LM_ERROR,
00127               ACE_LIB_TEXT("(%P|%t) EXCEPTION, %s\n")
00128               ACE_LIB_TEXT("%s\n"),
00129               ACE_TEXT_CHAR_TO_TCHAR(user_provided_info),
00130               ACE_TEXT_CHAR_TO_TCHAR(this->_info ().c_str ())));
00131 }
00132 
00133 #if defined (ACE_USES_WCHAR)
00134 void
00135 CORBA_Exception::_tao_print_exception (const ACE_WCHAR_T *info,
00136                                        FILE *f) const
00137 {
00138     // Even though this call causes additional type conversions,
00139     // this is better for the maintenance.  Plus, this will occur
00140     // only on exception anyway.
00141     this->_tao_print_exception(ACE_TEXT_ALWAYS_CHAR(info), f);
00142 }
00143 #endif  // ACE_USES_WCHAR
00144 
00145 void
00146 CORBA_Exception::_tao_any_destructor (void *x)
00147 {
00148   CORBA_Exception *tmp = ACE_static_cast (CORBA_Exception *, x);
00149   delete tmp;
00150 }
00151 
00152 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
00153 
00154 // Convenient ostrean operator.
00155 ostream& operator<< (ostream &os,
00156                      const CORBA_Exception &e)
00157 {
00158   os << e._name () << " (" << e._rep_id () << ')';
00159 
00160   return os;
00161 }
00162 
00163 #endif /* (ACE_LACKS_IOSTREAM_TOTALLY) */
00164 
00165 // Avoid zillions of not-quite-inlined copies of utilities.
00166 
00167 CORBA_UserException::CORBA_UserException (void)
00168 {
00169 }
00170 
00171 CORBA_UserException::CORBA_UserException (const char *repository_id,
00172                                           const char *local_name)
00173   : CORBA_Exception (repository_id,
00174                      local_name)
00175 {
00176 }
00177 
00178 CORBA_UserException::~CORBA_UserException (void)
00179 {
00180 }
00181 
00182 CORBA_UserException &
00183 CORBA_UserException::operator= (const CORBA_UserException &src)
00184 {
00185   this->CORBA_Exception::operator= (src);
00186   return *this;
00187 }
00188 
00189 int
00190 CORBA_UserException::_is_a (const char* interface_id) const
00191 {
00192   return ACE_OS_String::strcmp (interface_id,
00193                                 "IDL:omg.org/CORBA/UserException:1.0") == 0
00194     || CORBA_Exception::_is_a (interface_id);
00195 }
00196 
00197 CORBA_UserException*
00198 CORBA_UserException::_downcast (CORBA_Exception* exception)
00199 {
00200   if (exception->_is_a ("IDL:omg.org/CORBA/UserException:1.0"))
00201     {
00202       return ACE_dynamic_cast (CORBA_UserException *,
00203                                exception);
00204     }
00205 
00206   return 0;
00207 }
00208 
00209 ACE_CString
00210 CORBA_UserException::_info (void) const
00211 {
00212   // @@ we can use the exception's typecode to dump all the data held
00213   // within it ...
00214 
00215   ACE_CString user_exception_info = "user exception, ID '";
00216   user_exception_info += this->_rep_id ();
00217   user_exception_info += "'";
00218   return user_exception_info;
00219 }
00220 
00221 // ****************************************************************
00222 
00223 TAO_NAMESPACE_TYPE (CORBA::TypeCode_ptr)
00224 TAO_NAMESPACE_BEGIN (CORBA)
00225 TAO_NAMESPACE_DEFINE (CORBA::TypeCode_ptr, _tc_UnknownUserException, 0)
00226 TAO_NAMESPACE_END
00227 
00228 // ****************************************************************
00229 
00230 CORBA_SystemException::CORBA_SystemException (void)
00231 {
00232 }
00233 
00234 CORBA_SystemException::CORBA_SystemException (const char *repository_id,
00235                                               const char *local_name,
00236                                               CORBA::ULong code,
00237                                               CORBA::CompletionStatus completed)
00238   : CORBA_Exception (repository_id,
00239                      local_name),
00240     minor_ (code),
00241     completed_ (completed)
00242 {
00243 }
00244 
00245 CORBA_SystemException::CORBA_SystemException (const CORBA_SystemException &src)
00246   : CORBA_Exception (src),
00247     minor_ (src.minor_),
00248     completed_ (src.completed_)
00249 {
00250 }
00251 
00252 CORBA_SystemException::~CORBA_SystemException (void)
00253 {
00254 }
00255 
00256 CORBA_SystemException &
00257 CORBA_SystemException::operator= (const CORBA_SystemException &src)
00258 {
00259   this->CORBA_Exception::operator= (src);
00260 
00261   this->minor_ = src.minor_;
00262   this->completed_ = src.completed_;
00263 
00264   return *this;
00265 }
00266 
00267 int
00268 CORBA_SystemException::_is_a (const char* interface_id) const
00269 {
00270   return ACE_OS_String::strcmp (interface_id,
00271                                 "IDL:omg.org/CORBA/SystemException:1.0") == 0
00272     || CORBA_Exception::_is_a (interface_id);
00273 }
00274 
00275 CORBA_SystemException*
00276 CORBA_SystemException::_downcast (CORBA_Exception* exception)
00277 {
00278   if (exception->_is_a ("IDL:omg.org/CORBA/SystemException:1.0"))
00279     {
00280       return ACE_dynamic_cast (CORBA_SystemException *,
00281                                exception);
00282     }
00283 
00284   return 0;
00285 }
00286 
00287 void
00288 CORBA_SystemException::_tao_encode (TAO_OutputCDR &cdr
00289                                     ACE_ENV_ARG_DECL) const
00290 {
00291   if (cdr.write_string (this->_rep_id ())
00292       && cdr.write_ulong (this->minor ())
00293       && cdr.write_ulong (this->completed ()))
00294     {
00295       return;
00296     }
00297 
00298   ACE_THROW (CORBA::MARSHAL ());
00299 }
00300 
00301 void
00302 CORBA_SystemException::_tao_decode (TAO_InputCDR &cdr
00303                                     ACE_ENV_ARG_DECL)
00304 {
00305   // The string is read by the caller, to determine the exact type of
00306   // the exception.  We just decode the fields...
00307   // cdr.read_string (this->id ());
00308   CORBA::ULong tmp;
00309 
00310   if (cdr.read_ulong (this->minor_)
00311       && cdr.read_ulong (tmp))
00312     {
00313       this->completed_ = CORBA::CompletionStatus (tmp);
00314       return;
00315     }
00316 
00317   ACE_THROW (CORBA::MARSHAL ());
00318 }
00319 
00320 CORBA::ULong
00321 CORBA_SystemException::_tao_errno (int errno_value)
00322 {
00323   switch (errno_value)
00324     {
00325     case 0:
00326       return TAO_UNSPECIFIED_MINOR_CODE;
00327     case ETIMEDOUT:
00328       return TAO_ETIMEDOUT_MINOR_CODE;
00329     case ENFILE:
00330       return TAO_ENFILE_MINOR_CODE;
00331     case EPIPE:
00332       return TAO_EPIPE_MINOR_CODE;
00333     case ECONNREFUSED:
00334       return TAO_ECONNREFUSED_MINOR_CODE;
00335     case ENOENT:
00336       return TAO_ENOENT_MINOR_CODE;
00337 
00338 #if !defined (ACE_HAS_WINCE)
00339     case EMFILE:
00340       return TAO_EMFILE_MINOR_CODE;
00341     case EBADF:
00342       return TAO_EBADF_MINOR_CODE;
00343     case EPERM:
00344       return TAO_EPERM_MINOR_CODE;
00345     case EINVAL:
00346       return TAO_EINVAL_MINOR_CODE;
00347 #endif  // ACE_HAS_WINCE
00348 
00349 #if (ENOSYS != EFAULT)
00350     case ENOSYS:
00351       return TAO_ENOSYS_MINOR_CODE;
00352 #endif /* ENOSYS != EFAULT */
00353     case EAFNOSUPPORT:
00354       return TAO_EAFNOSUPPORT_MINOR_CODE;
00355     case EAGAIN:
00356       return TAO_EAGAIN_MINOR_CODE;
00357     case ENOMEM:
00358       return TAO_ENOMEM_MINOR_CODE;
00359     case EACCES:
00360       return TAO_EACCES_MINOR_CODE;
00361     case EFAULT:
00362       return TAO_EFAULT_MINOR_CODE;
00363     case EBUSY:
00364       return TAO_EBUSY_MINOR_CODE;
00365     case EEXIST:
00366       return TAO_EEXIST_MINOR_CODE;
00367     case ECOMM:
00368       return TAO_ECOMM_MINOR_CODE;
00369     case ECONNRESET:
00370       return TAO_ECONNRESET_MINOR_CODE;
00371 #if (ENOTSUP != ENOSYS)
00372     case ENOTSUP:
00373       return TAO_ENOTSUP_MINOR_CODE;
00374 #endif /* ENOSYS != EFAULT */
00375     default:
00376       // Mask off bottom 7 bits and return them.
00377       return errno_value & 0x7FU;
00378     }
00379 }
00380 
00381 CORBA::ULong
00382 CORBA_SystemException::_tao_minor_code (u_int location,
00383                                         int errno_value)
00384 {
00385   return
00386     TAO_DEFAULT_MINOR_CODE
00387     | location
00388     | _tao_errno (errno_value);
00389 }
00390 
00391 void
00392 CORBA_SystemException::_tao_print_system_exception (FILE *) const
00393 {
00394   ACE_DEBUG ((LM_ERROR,
00395               ACE_LIB_TEXT("(%P|%t) system exception, ID '%s'\n"),
00396               ACE_TEXT_CHAR_TO_TCHAR(this->_info ().c_str ())));
00397 }
00398 
00399 ACE_CString
00400 CORBA_SystemException::_info (void) const
00401 {
00402   // @@ there are a other few "user exceptions" in the CORBA scope,
00403   // they're not all standard/system exceptions ... really need to
00404   // either compare exhaustively against all those IDs (yeech) or
00405   // (preferably) to represent the exception type directly in the
00406   // exception value so it can be queried.
00407 
00408   ACE_CString info = "system exception, ID '";
00409   info += this->_rep_id ();
00410   info += "'\n";
00411 
00412   CORBA::ULong VMCID =
00413     this->minor () & 0xFFFFF000u;
00414 
00415   if (VMCID == TAO_DEFAULT_MINOR_CODE)
00416     {
00417       // @@ Move the following code to a subroutine, it is too long already!
00418       const char *location;
00419       switch (this->minor () & 0x00000F80u)
00420         {
00421         case TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE:
00422           location = "location forward failed";
00423           break;
00424         case TAO_INVOCATION_SEND_REQUEST_MINOR_CODE:
00425           location = "send request failed";
00426           break;
00427         case TAO_POA_DISCARDING:
00428           location = "poa in discarding state";
00429           break;
00430         case TAO_POA_HOLDING:
00431           location = "poa in holding state";
00432           break;
00433         case TAO_POA_INACTIVE:
00434           location = "poa in inactive state";
00435           break;
00436         case TAO_UNHANDLED_SERVER_CXX_EXCEPTION:
00437           location = "unhandled c++ exception in server side";
00438           break;
00439         case TAO_INVOCATION_RECV_REQUEST_MINOR_CODE:
00440           location = "failed to recv request response";
00441           break;
00442         case TAO_CONNECTOR_REGISTRY_NO_USABLE_PROTOCOL:
00443           location = "all protocols failed to parse the IOR";
00444           break;
00445         case TAO_MPROFILE_CREATION_ERROR:
00446           location = "error during MProfile creation";
00447           break;
00448         case TAO_TIMEOUT_CONNECT_MINOR_CODE:
00449           location = "timeout during connect";
00450           break;
00451         case TAO_TIMEOUT_SEND_MINOR_CODE:
00452           location = "timeout during send";
00453           break;
00454         case TAO_TIMEOUT_RECV_MINOR_CODE:
00455           location = "timeout during recv";
00456           break;
00457         case TAO_IMPLREPO_MINOR_CODE:
00458           location = "implrepo server exception";
00459           break;
00460         case TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE:
00461           location = "endpoint initialization failure in Acceptor Registry";
00462           break;
00463         case TAO_ORB_CORE_INIT_LOCATION_CODE:
00464           location = "ORB Core initialization failed";
00465           break;
00466         case TAO_POLICY_NARROW_CODE:
00467           location = "Failure when narrowing a Policy";
00468           break;
00469         case TAO_GUARD_FAILURE:
00470           location = "Failure when trying to acquire a guard/monitor";
00471           break;
00472         case TAO_POA_BEING_DESTROYED:
00473           location = "POA has been destroyed or is currently being destroyed";
00474           break;
00475         case TAO_AMH_REPLY_LOCATION_CODE:
00476           location = "Failure when trying to send AMH reply";
00477           break;
00478         case TAO_RTCORBA_THREAD_CREATION_LOCATION_CODE:
00479           location = "Failure in thread creation for RTCORBA thread pool";
00480           break;
00481         default:
00482           location = "unknown location";
00483         }
00484 
00485       const char *errno_indication;
00486       char unknown_errno [255];
00487       CORBA::ULong minor_code = this->minor () & 0x7FU;
00488       switch (minor_code)
00489         {
00490         case TAO_UNSPECIFIED_MINOR_CODE:
00491           errno_indication = "unspecified errno";
00492           break;
00493         case TAO_ETIMEDOUT_MINOR_CODE:
00494           errno_indication = "ETIMEOUT";
00495           break;
00496         case TAO_ENFILE_MINOR_CODE:
00497           errno_indication = "ENFILE";
00498           break;
00499         case TAO_EMFILE_MINOR_CODE:
00500           errno_indication = "EMFILE";
00501           break;
00502         case TAO_EPIPE_MINOR_CODE:
00503           errno_indication = "EPIPE";
00504           break;
00505         case TAO_ECONNREFUSED_MINOR_CODE:
00506           errno_indication = "ECONNREFUSED";
00507           break;
00508         case TAO_ENOENT_MINOR_CODE:
00509           errno_indication = "ENOENT";
00510           break;
00511         case TAO_EBADF_MINOR_CODE:
00512           errno_indication = "EBADF";
00513           break;
00514         case TAO_ENOSYS_MINOR_CODE:
00515           errno_indication = "ENOSYS";
00516           break;
00517         case TAO_EPERM_MINOR_CODE:
00518           errno_indication = "EPERM";
00519           break;
00520         case TAO_EAFNOSUPPORT_MINOR_CODE:
00521           errno_indication = "EAFNOSUPPORT";
00522           break;
00523         case TAO_EAGAIN_MINOR_CODE:
00524           errno_indication = "EAGAIN";
00525           break;
00526         case TAO_ENOMEM_MINOR_CODE:
00527           errno_indication = "ENOMEM";
00528           break;
00529         case TAO_EACCES_MINOR_CODE:
00530           errno_indication = "EACCES";
00531           break;
00532         case TAO_EFAULT_MINOR_CODE:
00533           errno_indication = "EFAULT";
00534           break;
00535         case TAO_EBUSY_MINOR_CODE:
00536           errno_indication = "EBUSY";
00537           break;
00538         case TAO_EEXIST_MINOR_CODE:
00539           errno_indication = "EEXIST";
00540           break;
00541         case TAO_EINVAL_MINOR_CODE:
00542           errno_indication = "EINVAL";
00543           break;
00544         case TAO_ECOMM_MINOR_CODE:
00545           errno_indication = "ECOMM";
00546           break;
00547         case TAO_ECONNRESET_MINOR_CODE:
00548           errno_indication = "ECONNRESET";
00549           break;
00550         case TAO_ENOTSUP_MINOR_CODE:
00551           errno_indication = "ENOTSUP";
00552           break;
00553         default:
00554           {
00555             // 7 bits of some other errno.
00556             ACE_OS::sprintf (unknown_errno,
00557                              "low 7 bits of errno: %3u %s",
00558                              minor_code, ACE_OS_String::strerror(minor_code));
00559 
00560             errno_indication = unknown_errno;
00561           }
00562         }
00563 
00564       char buffer[BUFSIZ];
00565       ACE_OS::sprintf (buffer,
00566                        "TAO exception, "
00567                        "minor code = %x (%s; %s), "
00568                        "completed = %s\n",
00569                        minor_code,
00570                        location,
00571                        errno_indication,
00572                        (completed () == CORBA::COMPLETED_YES) ? "YES" :
00573                        (completed () == CORBA::COMPLETED_NO) ? "NO" :
00574                        (completed () == CORBA::COMPLETED_MAYBE) ? "MAYBE" :
00575                        "garbage");
00576 
00577       info += buffer;
00578     }
00579   else if (VMCID == CORBA::OMGVMCID)
00580     {
00581       CORBA::ULong minor_code = this->minor () & 0xFFFU;
00582 
00583       const char *minor_description = 0;
00584 
00585       if (minor_code > 0)
00586           minor_description =
00587             CORBA::SystemException::_tao_get_omg_exception_description (
00588               *this,
00589               minor_code);
00590       else
00591         minor_description = "*unknown description*";
00592 
00593       char buffer[BUFSIZ];
00594       ACE_OS::sprintf (buffer,
00595                        "OMG minor code (%d), "
00596                        "described as '%s', "
00597                        "completed = %s\n",
00598                        minor_code,
00599                        minor_description,
00600                        (completed () == CORBA::COMPLETED_YES) ? "YES" :
00601                        (completed () == CORBA::COMPLETED_NO) ? "NO" :
00602                        (completed () == CORBA::COMPLETED_MAYBE) ? "MAYBE" :
00603                        "garbage");
00604 
00605       info += buffer;
00606     }
00607   else
00608     {
00609       char buffer[BUFSIZ];
00610       ACE_OS::sprintf (buffer,
00611                        "Unknown vendor minor code id (%x), "
00612                        "minor code = %x, completed = %s\n",
00613                        VMCID,
00614                        this->minor (),  // Use the raw minor code
00615                        (completed () == CORBA::COMPLETED_YES) ? "YES" :
00616                        (completed () == CORBA::COMPLETED_NO) ? "NO" :
00617                        (completed () == CORBA::COMPLETED_MAYBE) ? "MAYBE" :
00618                        "garbage");
00619 
00620       info += buffer;
00621     }
00622 
00623   return info;
00624 }
00625 
00626 const char *
00627 CORBA_SystemException::_tao_get_omg_exception_description (
00628   const CORBA::SystemException &exc,
00629   CORBA::ULong minor_code)
00630 {
00631 #ifndef ACE_NDEBUG
00632 
00633   static const char *UNKNOWN_TABLE[] =
00634     {
00635       "Unlisted user exception received by client.",    // 1
00636       "Non-standard SystemException not supported.",    // 2
00637       "An unkown user exception received by a portable interceptor." // 3
00638     };
00639 
00640   static const char *BAD_PARAM_TABLE[] =
00641     {
00642       "Failure to register, unregister, or lookup value factory.", // 1
00643       "RID already defined in IFR.",                               // 2
00644       "Name already used in the context in IFR.",                  // 3
00645       "Target is not a valid container.",                          // 4
00646       "Name clash in inherited context.",                          // 5
00647       "Incorrect type for abstract interface.",                    // 6
00648       "string_to_object conversion failed due to a bad scheme name.", // 7
00649       "string_to_object conversion failed due to a bad address.",  // 8
00650       "string_to_object conversion failed due to a bad schema specific part.",// 9
00651       "string_to_object conversion failed due to non specific reason.", // 10
00652       "Attempt to derive abstract interface from non-abstract base interface in the Interface Repository.", // 11
00653       "Attempt to let a ValueDef support more than one non-abstract interface in the Interface Repository.", // 12
00654       "Attempt to use an incomplete TypeCode as a parameter.",     // 13
00655       "Invalid object id passed to POA::create_reference_by_id.",  // 14
00656       "Bad name argument in TypeCode operation.",                  // 15
00657       "Bad RepositoryId argument in TypeCode operation.",          // 16
00658       "Invalid member namein TypeCode operation.",                 // 17
00659       "Duplicate label value in create_union_tc.",                 // 18
00660       "Incompatible TypeCode of label and discriminator in create_union_tc.", // 19
00661       "Supplied discriminator type illegitimate in create_union_tc.", // 20
00662       "Any passed to ServerRequest::set_exception does not contain an exception.", // 21
00663       "Unlisted user exception passed to ServerRequest::set_exception", // 22
00664       "wchar transmission code set not in service context.",       // 23
00665       "Service context is not in OMG-defined range.",              // 24
00666       "Enum value out of range.",                                  // 25
00667       "Invalid service context Id in portable interceptor.",       // 26
00668       "Attempt to call register_initial_reference with a null Object.", // 27
00669       "Invalid component Id in portable interceptor.",             // 28
00670       "Invalid profile Id in portable interceptor.",               // 29
00671       "Two or more Policy objects with the same PolicyType value supplied to Object::set_policy_overrides or PolicyManager::set_policy_overrides." // 30
00672       "Attempt to define a oneway operation with non-void result, out or inout parameters or user exceptions.", // 31
00673       "DII asked to create request for an implicit operation.",     // 32,
00674       "An OTS/XA integration xa_ call returned XAER_INVAL.",        // 33
00675       "Union branch modifier called with bad case label discriminator.", // 34
00676       "Illegal IDL context property name.",   // 35
00677       "Illegal IDL property search string.",  // 36
00678       "Illegal IDL context name.",            // 37
00679       "Non-empty IDL context.",               // 38
00680       "Servant not found [ServantManager].",  // 39
00681       "ORB output stream does not support ValueOutputStream interface.", // 40
00682       "ORB input stream does not support ValueInputStream interface."    // 41
00683     };
00684 
00685   static const char *IMP_LIMIT_TABLE[] =
00686     {
00687       "Unable to use any profile in IOR." // 1
00688     };
00689 
00690   static const char *INITIALIZE_TABLE[] =
00691     {
00692       "Priority range too restricted for ORB." // 1
00693     };
00694 
00695 
00696   static const char *INV_OBJREF_TABLE[] =
00697     {
00698       "wchar Code Set support not specified.", // 1
00699       "Codeset component required for type using wchar or wstring data." // 2
00700     };
00701 
00702   static const char *MARSHAL_TABLE[] =
00703     {
00704       "Unable to locate value factory.",  // 1
00705       "ServerRequest::set_result called before ServerRequest::ctx when the operation IDL contains a context clause.", // 2
00706       "NVList passed to ServerRequest::arguments does not describe all parameters passed by client.", // 3
00707       "Attempt to marshal Local object.", // 4
00708       "wchar or wstring data erroneously sent by client over GIOP 1.0 connection.", // 5
00709       "wchar or wstring data erroneously returned by server over GIOP 1.0 connection." //6
00710       "Unsupported RMI/IDL custom value type stream format." // 7
00711     };
00712 
00713   static const char *BAD_TYPECODE_TABLE[] =
00714     {
00715       "Attempt to marshal incomplete TypeCode.",              // 1
00716       "Member type code illegitimate in TypeCode operation.", // 2
00717       "Illegal parameter type."                               // 3
00718     };
00719 
00720   static const char *NO_IMPLEMENT_TABLE[] =
00721     {
00722       "Missing local value implementation.",        // 1
00723       "Incompatible value implementation version.", // 2
00724       "Unable to use any profile in IOR.",          // 3
00725       "Attempt to use DII on Local object.",        // 4
00726       "Biomolecular Sequence Analysis iterator cannot be reset.",         // 5
00727       "Biomolecular Sequence Analysis metadata is not available as XML.", // 6
00728       "Genomic Maps iterator cannot be rest."       // 7
00729     };
00730 
00731   static const char *NO_RESOURCE_TABLE[] =
00732     {
00733       "Portable Interceptor operation not support in this binding.", // 1
00734       "No connection for request's priority."                        // 2
00735     };
00736 
00737   static const char *BAD_INV_ORDER_TABLE[] =
00738     {
00739       "Dependency exists in IFR preventing destruction of this object", // 1
00740       "Attempt to destroy indestructible objects in IFR.", // 2
00741       "Operation would deadlock.",                         // 3
00742       "ORB has shutdown.",                                 // 4
00743       "Attempt to invoke \"send\" or \"invoke\" operation of the same \"Request\" object more than once.", // 5
00744       "Attempt to set a servant manager after one has already been set.", // 6
00745       "ServerRequest::arguments called more than once or after a call to ServerRequest::set_exception.", // 7
00746       "ServerRequest::ctx called more than once or before ServerRequest::arguments or after ServerRequest::ctx, ServerRequest::set_result or ServerRequest::set_exception.", // 8
00747       "ServerRequest::result called more than once or before ServerRequest::arguments or after ServerRequest::set_result or ServerRequest::set_exception.", // 9
00748       "Attempt to send a DII request after it was sent previously.", // 10
00749       "Attempt to poll a DII request or to retrieve its result before the request was sent.", // 11
00750       "Attempt to poll a DII request or to retrieve its result after the result was retrieved previously.", // 12
00751       "Attempt to poll a synchronous DII request or to retrieve results from a synchronous DII request.", // 13
00752       "Invalid portable interceptor call",                 // 14
00753       "Service context add failed in portable interceptor because a service context with the given id already exists.", // 15
00754       "Registration of PolicyFactory failed because a factory already exists for the given type.", // 16
00755       "POA cannot create POAs while undergoing destruction." // 17
00756     };
00757 
00758   static const char *TRANSIENT_TABLE[] =
00759     {
00760       "Request discarded due to resource exhaustion in POA, or because POA is in discarding state.", // 1
00761       "No usable profile in IOR.",                            // 2
00762       "Request cancelled.",                                   // 3
00763       "POA destroyed."                                        // 4
00764     };
00765 
00766   static const char *OBJ_ADAPTER_TABLE[] =
00767     {
00768       "System exception in POA::unknown_adapter.",              // 1
00769       "Incorrect servant type returned by servant manager",     // 2
00770       "No default servant available [POA policy].",             // 3
00771       "No servant manager available [POA policy].",             // 4
00772       "Violation of POA policy by ServantActivator::incarnate.",// 5
00773       "Exception in PortableInterceptor::IORInterceptor::components_established.", // 6
00774       "Null servant returned by servant manager."               // 7
00775     };
00776 
00777   static const char *DATA_CONVERSION_TABLE[] =
00778     {
00779       "Character does not map to negotiated transmission code set.", // 1
00780       "Failure of PriorityMapping object."                           // 2
00781     };
00782 
00783   static const char *OBJECT_NOT_EXIST_TABLE[] =
00784     {
00785       "Attempt to pass an unactivated (unregistered) value as an object reference.", // 1
00786       "POAManager::incarnate failed to create POA." // 2
00787     };
00788 
00789   static const char *INV_POLICY_TABLE[] =
00790     {
00791       "Unable to reconcile IOR specified policy with the effective policy override." // 1
00792       "Invalid PolicyType.", // 2
00793       "No PolicyFactory has been registered for the given PolicyType." // 3
00794     };
00795 
00796   if (minor_code == 0)
00797     return "*unknown description*";
00798 
00799   minor_code--;  // Adjust to match table offset.
00800 
00801   if (exc._is_a ("IDL:omg.org/CORBA/UNKNOWN:1.0")
00802       && minor_code < sizeof UNKNOWN_TABLE / sizeof (char *))
00803     return UNKNOWN_TABLE[minor_code];
00804 
00805   if (exc._is_a ("IDL:omg.org/CORBA/BAD_PARAM:1.0")
00806       && minor_code < sizeof BAD_PARAM_TABLE / sizeof (char *))
00807     return BAD_PARAM_TABLE[minor_code];
00808 
00809   if (exc._is_a ("IDL:omg.org/CORBA/IMP_LIMIT:1.0")
00810       && minor_code < sizeof IMP_LIMIT_TABLE / sizeof (char *))
00811     return IMP_LIMIT_TABLE[minor_code];
00812 
00813   if (exc._is_a ("IDL:omg.org/CORBA/INITIALIZE:1.0")
00814       && minor_code < sizeof INITIALIZE_TABLE / sizeof (char *))
00815     return INITIALIZE_TABLE[minor_code];
00816 
00817   if (exc._is_a ("IDL:omg.org/CORBA/INV_OBJREF:1.0")
00818       && minor_code < sizeof INV_OBJREF_TABLE / sizeof (char *))
00819     return INV_OBJREF_TABLE[minor_code];
00820 
00821   if (exc._is_a ("IDL:omg.org/CORBA/MARSHAL:1.0")
00822       && minor_code < sizeof MARSHAL_TABLE / sizeof (char *))
00823     return MARSHAL_TABLE[minor_code];
00824 
00825   if (exc._is_a ("IDL:omg.org/CORBA/BAD_TYPECODE:1.0")
00826       && minor_code < sizeof BAD_TYPECODE_TABLE / sizeof (char *))
00827     return BAD_TYPECODE_TABLE[minor_code];
00828 
00829   if (exc._is_a ("IDL:omg.org/CORBA/NO_IMPLEMENT:1.0")
00830       && minor_code < sizeof NO_IMPLEMENT_TABLE / sizeof (char *))
00831     return NO_IMPLEMENT_TABLE[minor_code];
00832 
00833   if (exc._is_a ("IDL:omg.org/CORBA/NO_RESOURCE:1.0")
00834       && minor_code < sizeof NO_RESOURCE_TABLE / sizeof (char *))
00835     return NO_RESOURCE_TABLE[minor_code];
00836 
00837   if (exc._is_a ("IDL:omg.org/CORBA/BAD_INV_ORDER:1.0")
00838       && minor_code < sizeof BAD_INV_ORDER_TABLE / sizeof (char *))
00839     return BAD_INV_ORDER_TABLE[minor_code];
00840 
00841   if (exc._is_a ("IDL:omg.org/CORBA/TRANSIENT:1.0")
00842       && minor_code < sizeof TRANSIENT_TABLE / sizeof (char *))
00843     return TRANSIENT_TABLE[minor_code];
00844 
00845   if (exc._is_a ("IDL:omg.org/CORBA/OBJ_ADAPTER:1.0")
00846       && minor_code < sizeof OBJ_ADAPTER_TABLE / sizeof (char *))
00847     return OBJ_ADAPTER_TABLE[minor_code];
00848 
00849   if (exc._is_a ("IDL:omg.org/CORBA/DATA_CONVERSION:1.0")
00850       && minor_code < sizeof DATA_CONVERSION_TABLE / sizeof (char *))
00851     return DATA_CONVERSION_TABLE[minor_code];
00852 
00853   if (exc._is_a ("IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0")
00854       && minor_code < sizeof OBJECT_NOT_EXIST_TABLE / sizeof (char *))
00855     return OBJECT_NOT_EXIST_TABLE[minor_code];
00856 
00857   if (exc._is_a ("IDL:omg.org/CORBA/INV_POLICY:1.0")
00858       && minor_code < sizeof INV_POLICY_TABLE / sizeof (char *))
00859     return INV_POLICY_TABLE[minor_code];
00860 
00861 #else
00862   ACE_UNUSED_ARG (exc);
00863   ACE_UNUSED_ARG (minor_code);
00864 #endif  /* !ACE_NDEBUG */
00865 
00866   return "*unknown description*";
00867 }
00868 
00869 // Note that "buffer" holds the (unscoped) name originally, and is
00870 // then overwritten.
00871 
00872 void
00873 TAO_Exceptions::make_unknown_user_typecode (CORBA::TypeCode_ptr &tcp
00874                                             ACE_ENV_ARG_DECL)
00875 {
00876   // Create the TypeCode for the CORBA_UnknownUserException.
00877 
00878 #if defined(ACE_MVS)
00879   // @@ We need to use a translator to make sure that all TypeCodes
00880   // are stored in ISO8859 form, the problem is that this hack does
00881   // not scale as more native sets have to be supported
00882 
00883   ACE_IBM1047_ISO8859 translator;
00884   TAO_OutputCDR stream (0,
00885                         ACE_CDR_BYTE_ORDER,
00886                         TAO_Exceptions::global_allocator_,
00887                         TAO_Exceptions::global_allocator_,
00888                         TAO_Exceptions::global_allocator_,
00889                         ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
00890                         &translator);
00891 #else
00892   TAO_OutputCDR stream (0,
00893                         ACE_CDR_BYTE_ORDER,
00894                         TAO_Exceptions::global_allocator_,
00895                         TAO_Exceptions::global_allocator_,
00896                         TAO_Exceptions::global_allocator_,
00897                         ACE_DEFAULT_CDR_MEMCPY_TRADEOFF);
00898 #endif /* ACE_MVS */
00899 
00900   const char *interface_id =
00901     "IDL:omg.org/CORBA/UnknownUserException:1.0";
00902   const char *name = "UnknownUserException";
00903   const char *field_name = "exception";
00904 
00905   CORBA::Boolean result = stream.write_octet (TAO_ENCAP_BYTE_ORDER) == 0
00906     || stream.write_string (interface_id) == 0
00907     || stream.write_string (name) == 0
00908     || stream.write_ulong (1L) == 0
00909     || stream.write_string (field_name) == 0;
00910   if (result)
00911     ACE_THROW (CORBA_INITIALIZE ());
00912 
00913   if (!(stream << CORBA::_tc_any))
00914     ACE_THROW (CORBA_INITIALIZE ());
00915 
00916   ACE_NEW_THROW_EX (tcp,
00917                     CORBA::TypeCode (CORBA::tk_except,
00918                                      stream.length (),
00919                                      stream.buffer (),
00920                                      1,
00921                                      sizeof (CORBA_UserException)),
00922                     CORBA_INITIALIZE ());
00923 }
00924 
00925 void
00926 TAO_Exceptions::make_standard_typecode (CORBA::TypeCode_ptr &tcp,
00927                                         const char *name,
00928                                         char *buffer,
00929                                         size_t buflen
00930                                         ACE_ENV_ARG_DECL)
00931 {
00932   // This function must only be called ONCE, and with a global lock
00933   // held!  The <CORBA::ORB_init> method is responsible for ensuring
00934   // this.
00935   static const char *minor = "minor";
00936   static const char *completed = "completed";
00937 
00938   // Create a CDR stream ... juggle the alignment here a bit, we know
00939   // it's good enough for the typecode.
00940 
00941 #if defined(ACE_MVS)
00942   // @@ We need to use a translator to make sure that all TypeCodes
00943   // are stored in ISO8859 form, the problem is that this hack does
00944   // not scale as more native sets have to be supported
00945 
00946   ACE_IBM1047_ISO8859 translator;
00947   TAO_OutputCDR stream (buffer, buflen,
00948                         ACE_CDR_BYTE_ORDER,
00949                         TAO_Exceptions::global_allocator_,
00950                         TAO_Exceptions::global_allocator_,
00951                         TAO_Exceptions::global_allocator_,
00952                         ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
00953                         &translator);
00954 #else
00955   TAO_OutputCDR stream (buffer, buflen,
00956                         ACE_CDR_BYTE_ORDER,
00957                         TAO_Exceptions::global_allocator_,
00958                         TAO_Exceptions::global_allocator_,
00959                         TAO_Exceptions::global_allocator_,
00960                         ACE_DEFAULT_CDR_MEMCPY_TRADEOFF);
00961 #endif /* ACE_MVS */
00962 
00963   // into CDR stream, stuff (in order):
00964   //    - byte order flag [4 bytes]
00965   //    - exception ID [27 + N bytes]
00966   //    - exception name [4 + N bytes ]
00967   //    - number of members (2) [4 bytes ]
00968   //    - foreach member, { name string, typecode } [~40 bytes]
00969 
00970   const char prefix[] = "IDL:omg.org/CORBA/";
00971   const char suffix[] = ":1.0";
00972   char * full_id =
00973     CORBA::string_alloc (sizeof prefix
00974                          + ACE_static_cast(CORBA::ULong,
00975                                            ACE_OS_String::strlen (name))
00976                          + sizeof suffix);
00977 
00978   ACE_OS_String::strcpy (full_id, prefix);
00979   ACE_OS_String::strcat (full_id, name);
00980   ACE_OS_String::strcat (full_id, suffix);
00981 
00982   CORBA::Boolean result = stream.write_octet (TAO_ENCAP_BYTE_ORDER) == 0
00983     || stream.write_string (full_id) == 0
00984     || stream.write_string (name) == 0
00985     || stream.write_ulong (2L) != 1
00986     || stream.write_string (minor) == 0;
00987 
00988   result = result || !(stream << CORBA::_tc_ulong);
00989 
00990   CORBA::string_free (full_id);  // No longer need the string
00991 
00992   result = result || stream.write_string (completed) == 0;
00993   result = result || !(stream << TC_completion_status);
00994 
00995   if (result)
00996     ACE_THROW (CORBA::INITIALIZE ());
00997 
00998   // @@ It is possible to throw an exception at this point?
00999   //    What if the exception typecode has not been initialized yet?
01000 
01001   // OK, we stuffed the buffer we were given (or grew a bigger one;
01002   // hope to avoid that during initialization).  Now build and return
01003   // a TypeCode, saving it away in the list of ones that the ORB will
01004   // always accept as part of any operation response!
01005 
01006   ACE_NEW_THROW_EX (tcp,
01007                     CORBA::TypeCode (CORBA::tk_except,
01008                                      stream.length (),
01009                                      stream.buffer (),
01010                                      1,
01011                                      sizeof (CORBA_SystemException)),
01012                     CORBA_INITIALIZE ());
01013   ACE_CHECK;
01014 
01015   ACE_ASSERT (tcp->length_ <= buflen);
01016   return;
01017 }
01018 
01019 // List of standard/system exceptions ... used to create static
01020 // storage for their typecodes, then later to initialize that storage
01021 // using the routine above. (It's just too painful to init these
01022 // typecodes statically in all cases!)
01023 
01024 #define STANDARD_EXCEPTION_LIST \
01025     TAO_SYSTEM_EXCEPTION (UNKNOWN) \
01026     TAO_SYSTEM_EXCEPTION (BAD_PARAM) \
01027     TAO_SYSTEM_EXCEPTION (NO_MEMORY) \
01028     TAO_SYSTEM_EXCEPTION (IMP_LIMIT) \
01029     TAO_SYSTEM_EXCEPTION (COMM_FAILURE) \
01030     TAO_SYSTEM_EXCEPTION (INV_OBJREF) \
01031     TAO_SYSTEM_EXCEPTION (OBJECT_NOT_EXIST) \
01032     TAO_SYSTEM_EXCEPTION (NO_PERMISSION) \
01033     TAO_SYSTEM_EXCEPTION (INTERNAL) \
01034     TAO_SYSTEM_EXCEPTION (MARSHAL) \
01035     TAO_SYSTEM_EXCEPTION (INITIALIZE) \
01036     TAO_SYSTEM_EXCEPTION (NO_IMPLEMENT) \
01037     TAO_SYSTEM_EXCEPTION (BAD_TYPECODE) \
01038     TAO_SYSTEM_EXCEPTION (BAD_OPERATION) \
01039     TAO_SYSTEM_EXCEPTION (NO_RESOURCES) \
01040     TAO_SYSTEM_EXCEPTION (NO_RESPONSE) \
01041     TAO_SYSTEM_EXCEPTION (PERSIST_STORE) \
01042     TAO_SYSTEM_EXCEPTION (BAD_INV_ORDER) \
01043     TAO_SYSTEM_EXCEPTION (TRANSIENT) \
01044     TAO_SYSTEM_EXCEPTION (FREE_MEM) \
01045     TAO_SYSTEM_EXCEPTION (INV_IDENT) \
01046     TAO_SYSTEM_EXCEPTION (INV_FLAG) \
01047     TAO_SYSTEM_EXCEPTION (INTF_REPOS) \
01048     TAO_SYSTEM_EXCEPTION (BAD_CONTEXT) \
01049     TAO_SYSTEM_EXCEPTION (OBJ_ADAPTER) \
01050     TAO_SYSTEM_EXCEPTION (DATA_CONVERSION) \
01051     TAO_SYSTEM_EXCEPTION (INV_POLICY) \
01052     TAO_SYSTEM_EXCEPTION (REBIND) \
01053     TAO_SYSTEM_EXCEPTION (TIMEOUT) \
01054     TAO_SYSTEM_EXCEPTION (TRANSACTION_UNAVAILABLE) \
01055     TAO_SYSTEM_EXCEPTION (TRANSACTION_MODE) \
01056     TAO_SYSTEM_EXCEPTION (TRANSACTION_REQUIRED) \
01057     TAO_SYSTEM_EXCEPTION (TRANSACTION_ROLLEDBACK) \
01058     TAO_SYSTEM_EXCEPTION (INVALID_TRANSACTION) \
01059     TAO_SYSTEM_EXCEPTION (CODESET_INCOMPATIBLE) \
01060     TAO_SYSTEM_EXCEPTION (BAD_QOS) \
01061     TAO_SYSTEM_EXCEPTION (INVALID_ACTIVITY) \
01062     TAO_SYSTEM_EXCEPTION (ACTIVITY_COMPLETED) \
01063     TAO_SYSTEM_EXCEPTION (ACTIVITY_REQUIRED)
01064 
01065 // Declare static storage for these ... the buffer is "naturally"
01066 // aligned and overwritten.
01067 //
01068 // @@ this actually doesn't guarantee "natural" alignment, but
01069 // it works that way in most systems.
01070 
01071 #define TAO_TC_BUF_LEN 256
01072 
01073 #define TAO_SYSTEM_EXCEPTION(name) \
01074     static CORBA::Long tc_buf_##name[TAO_TC_BUF_LEN/sizeof(CORBA::Long)]; \
01075     TAO_NAMESPACE_TYPE(CORBA::TypeCode_ptr) \
01076     TAO_NAMESPACE_BEGIN (CORBA) \
01077     TAO_NAMESPACE_DEFINE (CORBA::TypeCode_ptr, _tc_##name, 0) \
01078     TAO_NAMESPACE_END
01079   STANDARD_EXCEPTION_LIST
01080 #undef  TAO_SYSTEM_EXCEPTION
01081 #undef TAO_TC_BUF_LEN
01082 
01083 void
01084 TAO_Exceptions::init (ACE_ENV_SINGLE_ARG_DECL)
01085 {
01086   // This routine should only be called once.
01087 
01088   // Not thread safe.  Caller must provide synchronization.
01089 
01090   if (TAO_Exceptions::initialized_ != 0)
01091     return;
01092 
01093   TAO_Exceptions::initialized_ = 1;
01094 
01095   // Initialize the start up allocator.
01096   ACE_NEW (TAO_Exceptions::global_allocator_,
01097            ACE_New_Allocator);
01098 
01099 #define TAO_SYSTEM_EXCEPTION(name) \
01100   TAO_Exceptions::make_standard_typecode (CORBA::_tc_ ## name, \
01101                                           #name, \
01102                                           (char*)tc_buf_##name, \
01103                                           sizeof(tc_buf_##name) \
01104                                            ACE_ENV_ARG_PARAMETER); \
01105   ACE_CHECK;
01106   STANDARD_EXCEPTION_LIST
01107 #undef  TAO_SYSTEM_EXCEPTION
01108 
01109   TAO_Exceptions::make_unknown_user_typecode (CORBA::_tc_UnknownUserException
01110                                               ACE_ENV_ARG_PARAMETER);
01111 }
01112 
01113 CORBA_SystemException *
01114 TAO_Exceptions::create_system_exception (const char *id
01115                                          ACE_ENV_ARG_DECL_NOT_USED)
01116 {
01117 #define TAO_SYSTEM_EXCEPTION(name) \
01118   { \
01119     const char* xid = "IDL:omg.org/CORBA/" #name ":1.0"; \
01120     if (ACE_OS_String::strcmp (id, xid) == 0) \
01121       return new CORBA:: name; \
01122   }
01123   STANDARD_EXCEPTION_LIST
01124 #undef TAO_SYSTEM_EXCEPTION
01125 
01126   return 0;
01127 }
01128 
01129 void
01130 TAO_Exceptions::fini (void)
01131 {
01132 #define TAO_SYSTEM_EXCEPTION(name) \
01133   CORBA::release (CORBA::_tc_ ## name); \
01134   CORBA::_tc_ ## name = 0;
01135   STANDARD_EXCEPTION_LIST
01136 #undef TAO_SYSTEM_EXCEPTION
01137 
01138   CORBA::release (CORBA::_tc_UnknownUserException);
01139   CORBA::_tc_UnknownUserException = 0;
01140 
01141   delete TAO_Exceptions::global_allocator_;
01142   TAO_Exceptions::global_allocator_ = 0;
01143 }
01144 
01145 #define TAO_SYSTEM_EXCEPTION(name) \
01146 int \
01147 CORBA_##name ::_is_a (const char* interface_id) const \
01148 { \
01149   return ((ACE_OS_String::strcmp ( \
01150                interface_id, \
01151                "IDL:omg.org/CORBA/" #name ":1.0") == 0) \
01152           || CORBA_SystemException::_is_a (interface_id)); \
01153 }
01154 STANDARD_EXCEPTION_LIST
01155 #undef TAO_SYSTEM_EXCEPTION
01156 
01157 #define TAO_SYSTEM_EXCEPTION(name) \
01158 CORBA_##name * \
01159 CORBA_##name ::_downcast (CORBA_Exception* exception) \
01160 { \
01161   if (exception->_is_a ("IDL:omg.org/CORBA/" #name ":1.0")) \
01162     return ACE_dynamic_cast (CORBA_##name *, exception); \
01163   return 0; \
01164 }
01165 STANDARD_EXCEPTION_LIST
01166 #undef TAO_SYSTEM_EXCEPTION
01167 
01168 #define TAO_SYSTEM_EXCEPTION(name) \
01169 void \
01170 CORBA_##name ::_raise (void) \
01171 { \
01172   TAO_RAISE (*this); \
01173 }
01174 STANDARD_EXCEPTION_LIST
01175 #undef TAO_SYSTEM_EXCEPTION
01176 
01177 #define TAO_SYSTEM_EXCEPTION(name) \
01178 CORBA_##name :: CORBA_##name (void) \
01179   :  CORBA_SystemException ("IDL:omg.org/CORBA/" #name ":1.0", \
01180                             #name, \
01181                             TAO_DEFAULT_MINOR_CODE, \
01182                             CORBA::COMPLETED_NO) \
01183 { \
01184 }
01185 STANDARD_EXCEPTION_LIST
01186 #undef TAO_SYSTEM_EXCEPTION
01187 
01188 #define TAO_SYSTEM_EXCEPTION(name) \
01189 CORBA::TypeCode_ptr \
01190 CORBA_##name ::_type (void) const \
01191 { \
01192   return CORBA::_tc_ ## name; \
01193 }
01194 STANDARD_EXCEPTION_LIST
01195 #undef TAO_SYSTEM_EXCEPTION
01196 
01197 #define TAO_SYSTEM_EXCEPTION(name) \
01198 void \
01199 CORBA_##name ::_tao_any_destructor (void *x) \
01200 { \
01201   CORBA_##name *tmp = ACE_static_cast (CORBA_##name *, x); \
01202   delete tmp; \
01203 }
01204 STANDARD_EXCEPTION_LIST
01205 #undef TAO_SYSTEM_EXCEPTION
01206 
01207 #define TAO_SYSTEM_EXCEPTION(name) \
01208 CORBA_Exception * \
01209 CORBA_##name ::_tao_duplicate (void) const \
01210 { \
01211   CORBA_Exception *result; \
01212   ACE_NEW_RETURN (result, CORBA_##name (*this), 0); \
01213   return result; \
01214 }
01215 STANDARD_EXCEPTION_LIST
01216 #undef TAO_SYSTEM_EXCEPTION
01217 
01218 static void
01219 tao_insert_for_insertion_system_exception (CORBA::Any &any,
01220                                            const CORBA::SystemException &ex,
01221                                            const char *msg)
01222 {
01223   ACE_DECLARE_NEW_CORBA_ENV;
01224   ACE_TRY
01225     {
01226       TAO_OutputCDR stream;
01227       ex._tao_encode (stream ACE_ENV_ARG_PARAMETER);
01228       ACE_TRY_CHECK;
01229       any._tao_replace (ex._type (),
01230                         TAO_ENCAP_BYTE_ORDER,
01231                         stream.begin ());
01232     }
01233   ACE_CATCHANY
01234     {
01235       ACE_PRINT_EXCEPTION (
01236           ACE_ANY_EXCEPTION,
01237           msg);
01238     }
01239   ACE_ENDTRY;
01240   ACE_CHECK;
01241 }
01242 
01243 #define TAO_SYSTEM_EXCEPTION(name) \
01244 void operator<<= (CORBA::Any &any, const CORBA_##name &ex) \
01245 { \
01246   tao_insert_for_insertion_system_exception (any, ex, \
01247             "\tCORBA::Any insertion (non-copy) of CORBA_" #name "\n" \
01248                                ); \
01249 }
01250 STANDARD_EXCEPTION_LIST
01251 #undef TAO_SYSTEM_EXCEPTION
01252 
01253 static void
01254 tao_insert_system_exception (CORBA::Any &any,
01255                              CORBA::SystemException *ex,
01256                              CORBA::Any::_tao_destructor destructor,
01257                              const char *msg)
01258 {
01259   ACE_DECLARE_NEW_CORBA_ENV;
01260   ACE_TRY
01261     {
01262       TAO_OutputCDR stream;
01263       ex->_tao_encode (stream ACE_ENV_ARG_PARAMETER);
01264       ACE_TRY_CHECK;
01265       any._tao_replace (ex->_type (),
01266                         TAO_ENCAP_BYTE_ORDER,
01267                         stream.begin (),
01268                         1,
01269                         ex,
01270                         destructor);
01271     }
01272   ACE_CATCHANY
01273     {
01274       ACE_PRINT_EXCEPTION (
01275           ACE_ANY_EXCEPTION,
01276           msg
01277         );
01278     }
01279   ACE_ENDTRY;
01280   ACE_CHECK;
01281 }
01282 
01283 #define TAO_SYSTEM_EXCEPTION(name) \
01284 void operator<<= (CORBA::Any &any, CORBA_##name *ex) \
01285 { \
01286   tao_insert_system_exception (any, ex, \
01287           CORBA_##name ::_tao_any_destructor, \
01288           "\tCORBA::Any insertion (non-copy) of CORBA_" #name "\n" \
01289                                ); \
01290 }
01291 
01292 STANDARD_EXCEPTION_LIST
01293 #undef TAO_SYSTEM_EXCEPTION
01294 
01295 #define TAO_SYSTEM_EXCEPTION(name) \
01296 static CORBA_SystemException* _tao_allocator_##name (void) \
01297 { \
01298   return new CORBA_##name; \
01299 }
01300 STANDARD_EXCEPTION_LIST
01301 #undef TAO_SYSTEM_EXCEPTION
01302 
01303 static CORBA::Boolean
01304 tao_insert_in_extractor_system_exception (
01305         const CORBA::Any &any,
01306         CORBA::SystemException *&tmp,
01307         CORBA::SystemException * (*allocator)(void),
01308         CORBA::TypeCode_ptr tc_name,
01309         CORBA::Any::_tao_destructor destructor,
01310         const char *compare_IR_Id,
01311         const char *msg)
01312 {
01313   ACE_DECLARE_NEW_CORBA_ENV;
01314   ACE_TRY
01315     {
01316       CORBA::TypeCode_var type = any.type ();
01317       CORBA::Boolean equiv =
01318         type->equivalent (tc_name ACE_ENV_ARG_PARAMETER);
01319       ACE_TRY_CHECK;
01320       if (!equiv)
01321         return 0;
01322       if (any.any_owns_data ())
01323         {
01324           tmp = (CORBA_SystemException *)any.value ();
01325           return 1;
01326         }
01327       else
01328         {
01329           TAO_InputCDR stream (
01330               any._tao_get_cdr (),
01331               any._tao_byte_order ()
01332             );
01333           CORBA::String_var interface_repository_id;
01334           if (!(stream >> interface_repository_id.out ()))
01335             return 0;
01336           if (ACE_OS_String::strcmp (interface_repository_id.in (),
01337                                      compare_IR_Id))
01338             return 0;
01339           CORBA::SystemException *tmp = allocator ();
01340           tmp->_tao_decode (stream ACE_ENV_ARG_PARAMETER);
01341           ACE_TRY_CHECK;
01342           ((CORBA::Any *)&any)->_tao_replace (
01343               tc_name,
01344               1,
01345               tmp,
01346               destructor
01347             );
01348           return 1;
01349         }
01350     }
01351   ACE_CATCHANY
01352     {
01353       ACE_PRINT_EXCEPTION (
01354           ACE_ANY_EXCEPTION,
01355           msg
01356         );
01357     }
01358   ACE_ENDTRY;
01359   return 0;
01360 }
01361 
01362 #define TAO_SYSTEM_EXCEPTION(name) \
01363 CORBA::Boolean operator>>= (const CORBA::Any &any, \
01364                             const CORBA_##name *&ex) \
01365 { \
01366   ex = 0; \
01367   CORBA_SystemException *tmp; \
01368   if (tao_insert_in_extractor_system_exception (any, \
01369        tmp, \
01370        _tao_allocator_##name, \
01371        CORBA::_tc_##name, \
01372        CORBA_##name ::_tao_any_destructor, \
01373        "IDL:omg.org/CORBA/" #name ":1.0", \
01374        "\tCORBA::Any extraction of CORBA_" #name "\n") == 0) \
01375          { \
01376              ex = 0; \
01377          return 0; \
01378          } \
01379  ex = (CORBA_##name*)tmp; \
01380  return 1; \
01381 }
01382 
01383 STANDARD_EXCEPTION_LIST
01384 #undef TAO_SYSTEM_EXCEPTION
01385 
01386 #undef STANDARD_EXCEPTION_LIST
01387 
01388 #if defined (TAO_DONT_CATCH_DOT_DOT_DOT)
01389 TAO_DONT_CATCH::TAO_DONT_CATCH (void)
01390 {}
01391 #endif /* TAO_DONT_CATCH_DOT_DOT_DOT */

Generated on Mon Jun 16 13:48:23 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002