diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-08-09 20:22:00 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-08-09 20:22:00 +0000 |
commit | ab5628aad80a2070aa7052f35ea700444cf9ecfc (patch) | |
tree | 6fd48a3cd5a9b5c180097a2314deb285580bc92a /TAO | |
parent | 8aa0985db61c0b5cb337bf9d1b27d1004c59a2e9 (diff) | |
download | ATCD-ab5628aad80a2070aa7052f35ea700444cf9ecfc.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO')
42 files changed, 1025 insertions, 1030 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 8586ffc53c2..e45c9289d7f 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,18 @@ +Sat Aug 9 14:05:08 1997 Douglas C. Schmidt <schmidt@merengue.cs.wustl.edu> + + * tao: Continued to clean up all the code so that it is more + consistent with ACE programming style. + + * tao/orbconf.h: Cleaned up a lot of the unnecessary #defines. + + * tao/default_server.h: Make sure we inherit from + TAO_Server_Strategy_Factory, not TAO_Server_Factory. + + * tao/server_factory.cpp: Moved all the inline methods to be + non-inline since this code will always be dynamically bound. + + * tao/client_factory.cpp: Cleaned things up a bit. + Sat Aug 9 12:37:05 1997 Brian Mendel <brian.r.mendel@boeing.com> * tao/corba.h: Deleted include for xdr.h from corba.h. xdr.h diff --git a/TAO/tao/align.h b/TAO/tao/align.h index a22c4461767..ad689f33e63 100644 --- a/TAO/tao/align.h +++ b/TAO/tao/align.h @@ -40,7 +40,7 @@ typedef u_long long ptr_arith_t; #else # error "Can't find a suitable type for doing pointer arithmetic." -#endif +#endif /* error */ // Efficiently align "value" up to "alignment", knowing that all such // boundaries are binary powers and that we're using two's complement @@ -55,7 +55,7 @@ align_binary (const ptr_arith_t value, return (value + temp) & ~temp; } -#endif +#endif /* 0 */ #define align_binary(ptr, alignment) \ ((ptr + ((ptr_arith_t)((alignment)-1))) & (~((ptr_arith_t)((alignment)-1)))) @@ -73,7 +73,7 @@ ptr_align_binary (const u_char *ptr, { return (u_char *) align_binary ((ptr_arith_t) ptr, alignment); } -#endif +#endif /* 0 */ #define ptr_align_binary(ptr, alignment) \ ((u_char *) align_binary(((ptr_arith_t) (ptr)), (alignment))) diff --git a/TAO/tao/any.cpp b/TAO/tao/any.cpp index 8a58af70082..64dc68815c8 100644 --- a/TAO/tao/any.cpp +++ b/TAO/tao/any.cpp @@ -42,7 +42,7 @@ #if !defined (__ACE_INLINE__) # include "any.i" -#endif +#endif /* __ACE_INLINE__ */ CORBA_TypeCode_ptr CORBA_Any::type (void) const @@ -436,7 +436,7 @@ deep_free (CORBA_TypeCode_ptr tc, break; case tk_any: -#ifdef __BORLANDC__ +#if defined (__BORLANDC__) // XXX BC++ doesn't yet accept explicit calls to destructors // with this syntax. A simple workaround must exist, though; // other explicit destructor calls work. @@ -444,7 +444,7 @@ deep_free (CORBA_TypeCode_ptr tc, dmsg ("Delete Any-in-Any ... memory leak with BC++ 4.5"); #else ((CORBA_Any *) value)->~CORBA_Any (); -#endif +#endif /* __BORLANDC__ */ break; default: diff --git a/TAO/tao/boa.cpp b/TAO/tao/boa.cpp index 882ea7ed274..7c51f62edd7 100644 --- a/TAO/tao/boa.cpp +++ b/TAO/tao/boa.cpp @@ -178,4 +178,4 @@ CORBA_BOA::bind (const CORBA_OctetSeq &key, #if !defined (__ACE_INLINE__) # include "boa.i" -#endif +#endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/boa.h b/TAO/tao/boa.h index 08c389d76e4..c9b3630202a 100644 --- a/TAO/tao/boa.h +++ b/TAO/tao/boa.h @@ -237,7 +237,7 @@ struct TAO_Dispatch_Context # if defined (__ACE_INLINE__) # include "boa.i" -# endif +# endif /* __ACE_INLINE__ */ #endif /* TAO_BOA_H */ diff --git a/TAO/tao/client_factory.cpp b/TAO/tao/client_factory.cpp index cffc8fadf10..cd1f0c48f09 100644 --- a/TAO/tao/client_factory.cpp +++ b/TAO/tao/client_factory.cpp @@ -13,9 +13,9 @@ // $Id$ // ============================================================================ -#if !defined(__ACE_INLINE__) +#if !defined (__ACE_INLINE__) # include "client_factory.i" -#endif +#endif /* __ACE_INLINE__ */ // Template specializations which allow the cached connection manager // to work better. @@ -34,23 +34,29 @@ ACE_Hash_Addr<ACE_INET_Addr, TAO_Client_Connection_Handler>::compare_i (const AC } int -TAO_Client_Connection_Handler::open(void *) +TAO_Client_Connection_Handler::open (void *) { // Here is where we could enable all sorts of things such as // nonblock I/O, sock buf sizes, TCP no-delay, etc. + // @@ Chris, this should be changed to a macro that we put in the + // ACE OS.h file. const int MAX_SOCK_BUF_SIZE = 65536; - if (this->peer ().set_option(SOL_SOCKET, SO_SNDBUF, (void - *)&MAX_SOCK_BUF_SIZE, - sizeof(MAX_SOCK_BUF_SIZE)) == -1) - return -1; - if (this->peer ().set_option(SOL_SOCKET, SO_RCVBUF, (void - *)&MAX_SOCK_BUF_SIZE, - sizeof (MAX_SOCK_BUF_SIZE)) == -1) + + if (this->peer ().set_option (SOL_SOCKET, + SO_SNDBUF, + (void *)&MAX_SOCK_BUF_SIZE, + sizeof (MAX_SOCK_BUF_SIZE)) == -1) return -1; - // For now, we just return success - return 0; + else if (this->peer ().set_option (SOL_SOCKET, + SO_RCVBUF, + (void *) &MAX_SOCK_BUF_SIZE, + sizeof (MAX_SOCK_BUF_SIZE)) == -1) + return -1; + else + // For now, we just return success + return 0; } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) diff --git a/TAO/tao/client_factory.h b/TAO/tao/client_factory.h index dc7171f05eb..24695713293 100644 --- a/TAO/tao/client_factory.h +++ b/TAO/tao/client_factory.h @@ -15,7 +15,7 @@ // $Id$ // ============================================================================ -#if !defined(TAO_CLIENT_FACTORY_H) +#if !defined (TAO_CLIENT_FACTORY_H) # define TAO_CLIENT_FACTORY_H # include "ace/SOCK_Acceptor.h" @@ -28,18 +28,18 @@ # include "tao/params.h" class TAO_Client_Connection_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> -// = TITLE -// <Svc_Handler> used on the client side and returned -// by the <TAO_Client_Factory::CONNECTOR>. -// @@ Should this be in here or in the default_client.*? + // = TITLE + // <Svc_Handler> used on the client side and returned + // by the <TAO_Client_Factory::CONNECTOR>. + // @@ Should this be in here or in the default_client.*? { public: // = Intialization method. - TAO_Client_Connection_Handler (ACE_Thread_Manager* = 0); + TAO_Client_Connection_Handler (ACE_Thread_Manager * = 0); // Do-nothing constructor // = <Connector> hook. - virtual int open (void*); + virtual int open (void *); // Initialization hook void in_use (CORBA_Boolean); @@ -53,16 +53,15 @@ private: // True value indicates that something is using this handler. }; - class TAO_Client_Strategy_Factory : public ACE_Service_Object // = TITLE - // Abstract factory used by the client to turn out various - // strategies used on the client side. + // Abstract factory used by the client to manufacture various + // strategies used on the client-side. { public: // = Intialization and termination methods. TAO_Client_Strategy_Factory (void); - // Constructor + // Constructor. virtual ~TAO_Client_Strategy_Factory (void); // Destructor @@ -76,12 +75,13 @@ public: // = Factory methods for ORB strategies. #if defined (TAO_HAS_CLIENT_CONCURRENCY) + // @@ Chris, shouldn't this always be "potentially" the case, even + // if a client didn't want to use it? virtual CONCURRENCY_STRATEGY *concurrency_strategy (void); -#endif +#endif /* TAO_HAS_CLIENT_CONCURRENCY */ virtual CONNECTOR *connector (void); // Return a pointer to a connector using appropriate strategies. - }; #endif /* TAO_CLIENT_FACTORY_H */ diff --git a/TAO/tao/corba.h b/TAO/tao/corba.h index b479abae812..6ea4fdfaca7 100644 --- a/TAO/tao/corba.h +++ b/TAO/tao/corba.h @@ -25,8 +25,8 @@ // // ============================================================================ -#if !defined(TAO_CORBA_H) -# define TAO_CORBA_H +#if !defined (TAO_CORBA_H) +#define TAO_CORBA_H #include "tao/orbconf.h" @@ -58,4 +58,4 @@ #include "tao/svrrqst.h" #include "tao/typecode.h" -#endif +#endif /* TAO_CORBA_H */ diff --git a/TAO/tao/corbacom.cpp b/TAO/tao/corbacom.cpp index b30bc9e583c..5c7ca11ab82 100644 --- a/TAO/tao/corbacom.cpp +++ b/TAO/tao/corbacom.cpp @@ -6,9 +6,11 @@ #include "tao/orb.h" -#if defined (HAVE_WIDEC_H) +// @@ Chris, do we really need to use HAVE_WIDEC_H anymore? Isn't +// this handled by ACE? +#if defined (HAVE_WIDEC_H) # include <widec.h> -#endif +#endif /* HAVE_WIDEC_H */ // String utility support; this can need to be integrated with the // ORB's own memory allocation subsystem. diff --git a/TAO/tao/corbacom.h b/TAO/tao/corbacom.h index 81b889ff4d1..df3216b9c77 100644 --- a/TAO/tao/corbacom.h +++ b/TAO/tao/corbacom.h @@ -19,14 +19,14 @@ #if !defined (TAO_CORBACOM_H) #define TAO_CORBACOM_H -#if !defined(TAO_CONST) +#if !defined (TAO_CONST) //Something to document the fact that we want to put 'const' in front // of a type, but that it won't turn out the way we want, e.g., we // really want to express that a CORBA_String is const, but since CORBA_String // is a char*, the const modifies the pointer and not the pointed-to, and // some compilers (like SGI's EDG-derived thang) complain. # define TAO_CONST -#endif +#endif /* TAO_CONST */ # if SIZEOF_BOOL != 0 typedef bool CORBA_Boolean; @@ -77,13 +77,13 @@ typedef unsigned __int64 CORBA_ULongLong; // itself. # define NONNATIVE_LONGLONG -# if defined (WORDS_BIGENDIAN) +# if defined (TAO_WORDS_BIGENDIAN) struct CORBA_LongLong { CORBA_Long h, l; }; struct CORBA_ULongLong { CORBA_Long h, l; }; # else struct CORBA_LongLong { CORBA_Long l, h; }; struct CORBA_ULongLong { CORBA_ULong l, h; }; -# endif /* !WORDS_BIGENDIAN */ +# endif /* !TAO_WORDS_BIGENDIAN */ # endif /* no native 64 bit integer type */ typedef float CORBA_Float; @@ -144,10 +144,10 @@ public: CORBA_String_var &operator= (const CORBA_String_var &s); // assignment operator - operator char* () { return ptr_; } + operator char *() { return ptr_; } // access and modify - operator const char* () const {return ptr_; }; + operator const char *() const {return ptr_; }; // only read privileges char &operator[] (CORBA_ULong index); diff --git a/TAO/tao/debug.cpp b/TAO/tao/debug.cpp index c578844f366..943bacc83c8 100644 --- a/TAO/tao/debug.cpp +++ b/TAO/tao/debug.cpp @@ -140,9 +140,9 @@ dmsg_filter (const char *_FAR categories, ACE_OS::fprintf (debug_stream, "\n"); funlockfile (debug_stream); -#if defined (_WIN32) +#if defined (_WIN32) OutputDebugString ("called dmsg_filter\n"); // experimental -#endif +#endif /* _WIN32 */ } void ACE_Svc_Export @@ -165,9 +165,9 @@ dmsg_filter (u_int level, ACE_OS::fprintf (debug_stream, "\n"); funlockfile (debug_stream); -#if defined (_WIN32) +#if defined (_WIN32) OutputDebugString ("called dmsg_filter\n"); // experimental -#endif +#endif /* _WIN32 */ } void ACE_Svc_Export @@ -186,9 +186,9 @@ dmsg_v (const char *_FAR fmt, ACE_OS::fprintf (debug_stream, "\n"); funlockfile (debug_stream); -#if defined (_WIN32) +#if defined (_WIN32) OutputDebugString ("called dmsg_v\n"); // experimental -#endif +#endif /* _WIN32 */ } void ACE_Svc_Export @@ -211,9 +211,9 @@ _dmsg_x (CORBA_Environment _FAR &env, } funlockfile (debug_stream); -#if defined (_WIN32) +#if defined (_WIN32) OutputDebugString ("called _dmsg_x\n"); // experimental -#endif +#endif /* _WIN32 */ } void ACE_Svc_Export @@ -262,9 +262,9 @@ dmsg_opaque (char *_FAR label, ACE_OS::fprintf (debug_stream, "\n"); funlockfile (debug_stream); -#if defined (_WIN32) +#if defined (_WIN32) OutputDebugString ("called dmsg_opaque\n"); // experimental -#endif +#endif /* _WIN32 */ } void ACE_Svc_Export @@ -313,9 +313,9 @@ dmsg_opaque_full (char *_FAR label, ACE_OS::fprintf (debug_stream, "\n"); funlockfile (debug_stream); -#if defined (_WIN32) +#if defined (_WIN32) OutputDebugString ("called dmsg_opaque_full\n"); // experimental -#endif +#endif /* _WIN32 */ } #endif /* DEBUG && HAVE_VPRINTF */ diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp index 1459064da30..6e06f58d3c9 100644 --- a/TAO/tao/decode.cpp +++ b/TAO/tao/decode.cpp @@ -25,7 +25,7 @@ #include "tao/giop.h" #include "tao/debug.h" -#if defined (HAVE_WIDEC_H) +#if defined (HAVE_WIDEC_H) # include <widec.h> #else extern "C" @@ -33,7 +33,7 @@ extern "C" u_int wslen (const CORBA_WChar *); CORBA_WChar *wscpy (CORBA_WChar *, const CORBA_WChar *); } -#endif +#endif /* HAVE_WIDEC_H */ extern CORBA_TypeCode TC_opaque; @@ -409,7 +409,7 @@ TAO_Marshal_TypeCode::decode (CORBA_TypeCode_ptr, #if 0 (*tcp)->_parent = parent; parent->AddRef (); -#endif +#endif /* 0 */ } } break; diff --git a/TAO/tao/deep_copy.cpp b/TAO/tao/deep_copy.cpp index 6a0ef23463f..308b1029ba2 100644 --- a/TAO/tao/deep_copy.cpp +++ b/TAO/tao/deep_copy.cpp @@ -39,7 +39,7 @@ extern "C" u_int wslen (const CORBA_WChar *); CORBA_WChar *wscpy (CORBA_WChar *, const CORBA_WChar *); } -#endif +#endif /* HAVE_WIDEC_H */ extern CORBA_TypeCode TC_opaque; diff --git a/TAO/tao/deep_free.cpp b/TAO/tao/deep_free.cpp index 04a39b99a89..3dbc59bfc6a 100644 --- a/TAO/tao/deep_free.cpp +++ b/TAO/tao/deep_free.cpp @@ -41,7 +41,7 @@ extern "C" u_int wslen (const CORBA_WChar *); CORBA_WChar *wscpy (CORBA_WChar *, const CORBA_WChar *); } -#endif +#endif /* HAVE_WIDEC_H */ extern CORBA_TypeCode TC_opaque; @@ -922,12 +922,12 @@ TAO_Marshal_Except::deep_free (CORBA_TypeCode_ptr tc, #if 0 // temporarily commented out to make compiler happy CORBA_Long i, - member_count; // number of fields in the struct + member_count; // number of fields in the struct CORBA_TypeCode::traverse_status retval = CORBA_TypeCode::TRAVERSE_CONTINUE; CORBA_TypeCode_ptr param; CORBA_Long size, alignment; CDR stream; -#endif +#endif /* 0 */ if (tc) // XXX: Exceptions are currently leaked because of bugs lurking diff --git a/TAO/tao/default_client.cpp b/TAO/tao/default_client.cpp index 158d66db881..5bff5f3a93d 100644 --- a/TAO/tao/default_client.cpp +++ b/TAO/tao/default_client.cpp @@ -13,7 +13,6 @@ // $Id$ // ============================================================================ - #define ACE_BUILD_SVC_DLL #include "default_client.h" @@ -22,6 +21,13 @@ TAO_Default_Client_Strategy_Factory::TAO_Default_Client_Strategy_Factory (void) // When should I do this open ()? It seems like this is way too // early, but doing it in the accessor for connector () seems like // it would be too late as well. + // @@ Chris, a couple of thoughts: + // 1. What is wrong with doing it here, in general? + // 2. We should make sure not to use ACE_Reactor::instance() since + // it makes our ORB too tightly coupled to having just 1 reactor! + // I think it's clear now that we'll have one Reactor "per-ORB" + // and we may have multiple ORBs per process (e.g., consider the + // "real-time rate-based ORB" we discussed the other day). connector_.open (ACE_Reactor::instance (), &null_creation_strategy_, &caching_connect_strategy_, @@ -42,10 +48,10 @@ TAO_Default_Client_Strategy_Factory::init (int argc, char *argv[]) return this->parse_args (argc, argv); } -TAO_Client_Strategy_Factory::CONNECTOR* +TAO_Client_Strategy_Factory::CONNECTOR * TAO_Default_Client_Strategy_Factory::connector (void) { - return &connector_; + return &this->connector_; } int @@ -55,9 +61,9 @@ TAO_Default_Client_Strategy_Factory::parse_args (int argc, char *argv[]) return 0; } -#if ! defined(__ACE_INLINE__) +#if ! defined (__ACE_INLINE__) # include "default_client.i" -#endif +#endif /* __ACE_INLINE__ */ #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Cached_Connect_Strategy<TAO_Client_Connection_Handler, ACE_SOCK_CONNECTOR, ACE_SYNCH_RW_MUTEX>; diff --git a/TAO/tao/default_client.h b/TAO/tao/default_client.h index 00c012ff193..7eca1004b96 100644 --- a/TAO/tao/default_client.h +++ b/TAO/tao/default_client.h @@ -29,25 +29,30 @@ # include "tao/objtable.h" class TAO_Default_Client_Strategy_Factory : public TAO_Client_Strategy_Factory -// = TITLE -// This is the "default" client strategy factor for TAO...basically, it -// includes strategies that are configured through command-line options -// so that everything operates as if there were no dynamically-linkable -// strategies. + // = TITLE + // This is the "default" client strategy factor for + // TAO...basically, it includes strategies that are configured + // through command-line options so that everything operates as if + // there were no dynamically-linkable strategies. { public: + // = Initialization and termination methods. + TAO_Default_Client_Strategy_Factory (void); + // Constructor. + + virtual ~TAO_Default_Client_Strategy_Factory (void); + // Destructor. + + // = Useful typedef. typedef ACE_Cached_Connect_Strategy<TAO_Client_Connection_Handler, ACE_SOCK_CONNECTOR, ACE_SYNCH_RW_MUTEX> CACHED_CONNECT_STRATEGY; - TAO_Default_Client_Strategy_Factory (void); - virtual ~TAO_Default_Client_Strategy_Factory (void); - virtual TAO_Client_Strategy_Factory::CONNECTOR *connector (void); // Return a pointer to a connector using appropriate strategies. - // = SERVICE CONFIGURATOR HOOKS + // = Service Configurator hooks. virtual int init(int argc, char* argv[]); // Dynamic linking hook @@ -55,11 +60,19 @@ public: // Parse svc.conf arguments private: -# if defined (TAO_HAS_CLIENT_CONCURRENCY) + + // @@ Chris, please add comments to these members. + +#if defined (TAO_HAS_CLIENT_CONCURRENCY) + // @@ Chris, shouldn't this always be "potentially" the case, even + // if a client didn't want to use it? CONCURRENCY_STRATEGY *concurrency_strategy_; -# endif +#endif /* TAO_HAS_CLIENT_CONCURRENCY */ + CONNECTOR connector_; + NULL_CREATION_STRATEGY null_creation_strategy_; + CACHED_CONNECT_STRATEGY caching_connect_strategy_; }; diff --git a/TAO/tao/default_server.cpp b/TAO/tao/default_server.cpp index 1d9fc7698ac..6bdf7c7d024 100644 --- a/TAO/tao/default_server.cpp +++ b/TAO/tao/default_server.cpp @@ -13,7 +13,7 @@ #define ACE_BUILD_SVC_DLL #include "default_server.h" -TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory(void) +TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory (void) : thread_flags_ (0), object_table_size_ (SERVER_OBJECT_TABLE_SIZE), concurrency_strategy_ (0), @@ -22,74 +22,81 @@ TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory(void) TAO_Default_Server_Strategy_Factory::~TAO_Default_Server_Strategy_Factory (void) { - // perform appropriate cleanup + // Perform appropriate cleanup. delete this->objtable_; } -TAO_Default_Server_Strategy_Factory::CONCURRENCY_STRATEGY* -TAO_Default_Server_Strategy_Factory::concurrency_strategy(void) +TAO_Default_Server_Strategy_Factory::CONCURRENCY_STRATEGY * +TAO_Default_Server_Strategy_Factory::concurrency_strategy (void) { return this->concurrency_strategy_; } -TAO_Default_Server_Strategy_Factory::TAO_Object_Table* -TAO_Default_Server_Strategy_Factory::object_lookup_strategy(void) +TAO_Default_Server_Strategy_Factory::TAO_Object_Table * +TAO_Default_Server_Strategy_Factory::object_lookup_strategy (void) { return this->objtable_; } // Evil macros b/c I'm lazy! -#define BEGINCHECK if (0) -#define CHECKANDSET(sym) else if (ACE_OS::strcmp (flag, #sym) == 0) ACE_SET_BITS (this->thread_flags_, sym) -#define ENDCHECK +#define TAO_BEGINCHECK if (0) +#define TAO_CHECKANDSET(sym) else if (ACE_OS::strcmp (flag, #sym) == 0) ACE_SET_BITS (this->thread_flags_, sym) +#define TAO_ENDCHECK void TAO_Default_Server_Strategy_Factory::tokenize (char *flag_string) { // @@ Danger! strtok not re-entrant...need to find a re-entrant version! + // @@ Chris, please see ACE_OS::strtok_r (). There are some examples of + // how to use this in JAWS. + for (char *flag = ACE_OS::strtok (flag_string, "|"); flag != 0; - flag = ACE_OS::strtok(0, "|")) + flag = ACE_OS::strtok (0, "|")) { - BEGINCHECK; - CHECKANDSET (THR_DETACHED); - CHECKANDSET (THR_BOUND); - CHECKANDSET (THR_NEW_LWP); - CHECKANDSET (THR_SUSPENDED); - CHECKANDSET (THR_DAEMON); - ENDCHECK; + TAO_BEGINCHECK; + TAO_CHECKANDSET (THR_DETACHED); + TAO_CHECKANDSET (THR_BOUND); + TAO_CHECKANDSET (THR_NEW_LWP); + TAO_CHECKANDSET (THR_SUSPENDED); + TAO_CHECKANDSET (THR_DAEMON); + TAO_ENDCHECK; } } int -TAO_Default_Server_Strategy_Factory::init(int argc, char* argv[]) +TAO_Default_Server_Strategy_Factory::init (int argc, char *argv[]) { - return this->parse_args(argc, argv); + return this->parse_args (argc, argv); } int -TAO_Default_Server_Strategy_Factory::parse_args(int argc, char* argv[]) +TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[]) { - ACE_TRACE("TAO_Default_Server_Strategy_Factory::parse_args"); + ACE_TRACE ("TAO_Default_Server_Strategy_Factory::parse_args"); ACE_Get_Opt get_opt (argc, argv, "t:s:RTL:", 0); TAO_Demux_Strategy strat = TAO_NONE; - for (int c; (c = get_opt()) != -1; ) + // @@ Chris, I think this code should use the same option format + // that is used by CORBA_ORB_init(). Can you please work with Andy + // on this? + + for (int c; (c = get_opt ()) != -1; ) { - switch(c) + switch (c) { case 't': { - char* temp = get_opt.optarg; - this->tokenize(temp); + char *temp = get_opt.optarg; + this->tokenize (temp); } break; case 's': - this->object_table_size_ = ACE_OS::strtoul(get_opt.optarg); + this->object_table_size_ = ACE_OS::strtoul (get_opt.optarg); break; case 'R': @@ -105,24 +112,32 @@ TAO_Default_Server_Strategy_Factory::parse_args(int argc, char* argv[]) case 'L': { char *name = getopt.opt_arg; - if (ACE_OS::strcasecmp(name, "dynamic") == 0) + + // @@ Chris, why do we use "L" for "Demuxing strategy?" + // Also, please make sure that you document all of these + // options! + + if (ACE_OS::strcasecmp (name, "dynamic") == 0) strat = TAO_DYNAMIC_HASH; - else if (ACE_OS::strcasecmp(name, "linear") == 0) + else if (ACE_OS::strcasecmp (name, "linear") == 0) strat = TAO_LINEAR; - else if (ACE_OS::strcasecmp(name, "active") == 0) + else if (ACE_OS::strcasecmp (name, "active") == 0) strat = TAO_ACTIVE_HASH; - else if (ACE_OS::strcasecmp(name, "user") == 0) + else if (ACE_OS::strcasecmp (name, "user") == 0) strat = TAO_USER_DEFINED; } break; } } - // Create the appropriate-sized object table based on passed arguments. + // Create the appropriate-sized object table based on passed + // arguments. switch (strat) { case TAO_LINEAR: - ACE_NEW (this->objtable_, TAO_Linear_ObjTable (this->object_table_size_)); + ACE_NEW_RETURN (this->objtable_, + TAO_Linear_ObjTable (this->object_table_size_), + -1); break; #if 0 // Don't do this one right now until we determine how to deal @@ -132,14 +147,18 @@ TAO_Default_Server_Strategy_Factory::parse_args(int argc, char* argv[]) // user-defined instance of the object table this->objtable_ = p->userdef_lookup_strategy (); break; -#endif +#endif /* 0 */ case TAO_ACTIVE_DEMUX: - ACE_NEW (this->objtable_, TAO_Active_Demux_ObjTable (this->object_table_size_)); + ACE_NEW_RETURN (this->objtable_, + TAO_Active_Demux_ObjTable (this->object_table_size_), + -1); break; case TAO_DYNAMIC_HASH: case TAO_NONE: default: - ACE_NEW (this->objtable_, TAO_Dynamic_Hash_ObjTable (this->object_table_size_)); + ACE_NEW_RETURN (this->objtable_, + TAO_Dynamic_Hash_ObjTable (this->object_table_size_), + -1); break; } } diff --git a/TAO/tao/default_server.h b/TAO/tao/default_server.h index d46c6ed36b9..e0cf68df11e 100644 --- a/TAO/tao/default_server.h +++ b/TAO/tao/default_server.h @@ -32,12 +32,11 @@ # define SERVER_OBJECT_TABLE_SIZE 64 # endif -class TAO_Default_Server_Strategy_Factory : public TAO_Server_Factory -// = TITLE -// This is the default strategy factory for CORBA servers. It -// basically allows one to choose strategies via argument flags and -// so gives substantial freedom for experimentation at the expense -// of memory. +class TAO_Default_Server_Strategy_Factory : public TAO_Server_Strategy_Factory + // = TITLE + // This is the default strategy factory for CORBA servers. It + // allows developers to choose strategies via argument flags. + // This design gives substantial freedom for experimentation. { public: // = Initialization and termination methods. @@ -51,12 +50,12 @@ public: virtual SCHEDULING_STRATEGY *scheduling_strategy (void); virtual TAO_Object_Table *object_lookup_strategy( void); - // = SERVICE CONFIGURATOR HOOKS - virtual int init (int argc, char* argv[]); - int parse_args (int argc, char* argv[]); + // = Service Configurator hooks. + virtual int init (int argc, char *argv[]); + int parse_args (int argc, char *argv[]); private: - void tokenize (char* flag_string); + void tokenize (char *flag_string); u_long thread_flags_; // Default thread flags passed to thr_create(). @@ -66,21 +65,25 @@ private: // = Strategies Used. ACE_Reactive_Strategy<TAO_OA_Connection_Handler> reactive_strategy_; - // A strategy for passively establishing connections which utilizes the Reactor. + // A strategy for passively establishing connections which utilizes + // the Reactor. + ACE_Thread_Strategy<TAO_OA_Connection_Handler> threaded_strategy_; - // The threaded strategy used for passively establishing connections. + // The threaded strategy used for passively establishing + // connections. CONCURRENCY_STRATEGY *concurrency_strategy_; // concrete concurrency strategy. TAO_Object_Table *objtable_; // instance of object table + #if 0 // Someday we'll need these! CREATION_STRATEGY *creation_strategy_; ACCEPT_STRATEGY *accept_strategy_; SCHEDULING_STRATEGY *scheduling_strategy_; -#endif +#endif /* 0 */ }; ACE_SVC_FACTORY_DECLARE (TAO_Default_Server_Strategy_Factory) diff --git a/TAO/tao/encode.cpp b/TAO/tao/encode.cpp index 2056f660d02..e30e2b24be0 100644 --- a/TAO/tao/encode.cpp +++ b/TAO/tao/encode.cpp @@ -32,7 +32,7 @@ extern "C" u_int wslen (const CORBA_WChar *); CORBA_WChar *wscpy (CORBA_WChar *, const CORBA_WChar *); } -#endif +#endif /* HAVE_WIDEC_H */ extern CORBA_TypeCode TC_opaque; diff --git a/TAO/tao/except.cpp b/TAO/tao/except.cpp index 01cd00cf8a5..4fee96130fe 100644 --- a/TAO/tao/except.cpp +++ b/TAO/tao/except.cpp @@ -18,7 +18,7 @@ #if defined (HAVE_WIDEC_H) # include <widec.h> -#endif +#endif /* HAVE_WIDEC_H */ // {77420082-F276-11ce-9598-0000C07CA898} DEFINE_GUID (IID_CORBA_Exception, diff --git a/TAO/tao/giop.cpp b/TAO/tao/giop.cpp index c942b70d855..f77ae6387b4 100644 --- a/TAO/tao/giop.cpp +++ b/TAO/tao/giop.cpp @@ -152,7 +152,7 @@ GIOP::send_message (CDR &stream, writelen = peer.send ((char _FAR *) buf, buflen); -#ifdef DEBUG +#if defined (DEBUG) // dmsg_filter (6, "wrote %d bytes to connection %d", // writelen, connection); dmsg_filter (6, "wrote %d bytes", writelen); @@ -190,14 +190,14 @@ GIOP::send_message (CDR &stream, if ((buflen -= writelen) != 0) buf += writelen; -#ifdef DEBUG +#if defined (DEBUG) // // NOTE: this should never be seen. However, on Linux // it's been seen with UNIX domain sockets. // if (buflen) dmsg_filter (8, "%u more bytes to write...\n", buflen); -#endif +#endif /* DEBUG */ } return CORBA_B_TRUE; } @@ -296,9 +296,9 @@ read_buffer (ACE_SOCK_Stream &peer, retval = peer.recv (buf, len); -#ifdef DEBUG +#if defined (DEBUG) dmsg_filter (6, "read %d bytes from connection: %d", retval, peer.get_handle ()); -#endif +#endif /* DEBUG */ if (retval <= 0) // EOF or error return retval; @@ -306,7 +306,7 @@ read_buffer (ACE_SOCK_Stream &peer, buf += retval; bytes_read += retval; } -#endif +#endif /* 1 */ return bytes_read; } @@ -1168,7 +1168,7 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer, // XXX check whether hdr_status identifies a header // unmarshaling error, and handle appropriately -#ifdef DEBUG +#if defined (DEBUG) if (TAO_debug_level >= 3) { ACE_DEBUG ((LM_DEBUG, " (%P|%t) %sRequest ID %#lx from FD %d\n", diff --git a/TAO/tao/giop.h b/TAO/tao/giop.h index 8a2eaf5bfb5..2ec0a99f25d 100644 --- a/TAO/tao/giop.h +++ b/TAO/tao/giop.h @@ -278,7 +278,7 @@ public: // The handler for the client's connection. #if 0 autorelease <client_endpoint> endpoint; -#endif +#endif /* 0 */ }; // = Close a connection, first sending GIOP::CloseConnection diff --git a/TAO/tao/iiopobj.cpp b/TAO/tao/iiopobj.cpp index 345e21d4a49..867a8e48c8c 100644 --- a/TAO/tao/iiopobj.cpp +++ b/TAO/tao/iiopobj.cpp @@ -18,7 +18,7 @@ #if !defined (__ACE_INLINE__) # include "iiopobj.i" -#endif +#endif /* __ACE_INLINE__ */ IIOP::ProfileBody::ProfileBody (const IIOP::ProfileBody &src) : iiop_version (src.iiop_version), @@ -141,7 +141,7 @@ EXTERN_C ACE_Svc_Export GUID IID_STUB_Object = #else DEFINE_GUID(IID_STUB_Object, 0xa201e4c7, 0xf258, 0x11ce, 0x95, 0x98, 0x0, 0x0, 0xc0, 0x7c, 0xa8, 0x98); -#endif +#endif /* 0 */ // {A201E4C2-F258-11ce-9598-0000C07CA898} DEFINE_GUID (IID_CORBA_Object, @@ -150,7 +150,7 @@ DEFINE_GUID (IID_CORBA_Object, // End - Added by BRM: 2/21/97 IID_STUB_Object and IID_CORBA_Object // were not being defined. Need a central place for all of these // macros. -#endif +#endif /* 0 */ ULONG __stdcall IIOP_Object::AddRef (void) diff --git a/TAO/tao/iiopobj.h b/TAO/tao/iiopobj.h index d20c90f9bc5..d451581b973 100644 --- a/TAO/tao/iiopobj.h +++ b/TAO/tao/iiopobj.h @@ -152,13 +152,12 @@ private: IIOP_Object (const IIOP_Object &); operator = (const IIOP_Object &); -#if defined (__GNUG__) - // - // G++ (even 2.6.3) stupidly thinks instances can't be - // created. This de-warns. - // + +#if defined (__GNUG__) + // G++ (even 2.6.3) stupidly thinks instances can't be created. + // This de-warns. friend class everyone_needs_a_friend; -#endif +#endif /* __GNUG__ */ }; # if defined (__ACE_INLINE__) diff --git a/TAO/tao/iioporb.cpp b/TAO/tao/iioporb.cpp index b451c2d19da..0fc7ecdc105 100644 --- a/TAO/tao/iioporb.cpp +++ b/TAO/tao/iioporb.cpp @@ -21,9 +21,9 @@ static const char ior_prefix [] = "IOR:"; static const char iiop_prefix [] = "iiop:"; static const char xchars [] = "0123456789abcdef"; -#if !defined(__ACE_INLINE__) +#if !defined (__ACE_INLINE__) # include "iioporb.i" -#endif +#endif /* __ACE_INLINE__ */ // // hex conversion utilities diff --git a/TAO/tao/interp.cpp b/TAO/tao/interp.cpp index 8779ab0317a..6dad3f5bd24 100644 --- a/TAO/tao/interp.cpp +++ b/TAO/tao/interp.cpp @@ -205,19 +205,21 @@ static table_element table [TC_KIND_COUNT] = // (one byte). #if defined (unix) || defined (VXWORKS) -#define MAGIC_NUMBER 64 +// @@ Chris, can you please put this magic number macro in a more +// prominent place (e.g., in a header file somewhere? +#define TAO_ALIGNMENT_MAGIC_NUMBER 64 #define setup_entry(x,t) \ { \ struct align_struct_ ## t { \ x one; \ - char dummy [MAGIC_NUMBER + 1 - sizeof(x)]; \ + char dummy [TAO_ALIGNMENT_MAGIC_NUMBER + 1 - sizeof(x)]; \ x two; \ }; \ \ align_struct_ ## t align; \ table [t].size = sizeof (x); \ table [t].alignment = \ - (char*) &align.two - (char*) &align.one - MAGIC_NUMBER; \ + (char *) &align.two - (char *) &align.one - TAO_ALIGNMENT_MAGIC_NUMBER; \ } #else // PC "fixed" alignment @@ -227,7 +229,7 @@ static table_element table [TC_KIND_COUNT] = table [t].alignment = 1; \ } -#endif +#endif /* defined (unix) || defined (VXWORKS) */ // Fills in fixed size and alignment values. diff --git a/TAO/tao/marshal.cpp b/TAO/tao/marshal.cpp index b0e5284b780..f07aba281f6 100644 --- a/TAO/tao/marshal.cpp +++ b/TAO/tao/marshal.cpp @@ -31,7 +31,7 @@ extern "C" u_int wslen (const CORBA_WChar *); CORBA_WChar *wscpy (CORBA_WChar *, const CORBA_WChar *); } -#endif +#endif /* HAVE_WIDEC_H */ TAO_Marshal_Factory* TAO_Marshal::DEFAULT_MARSHAL_FACTORY = 0; @@ -57,7 +57,7 @@ TAO_Marshal_Factory::TAO_Marshal_Factory (void) m_alias_ (TAO_MARSHAL_ALIAS::instance ()), m_except_ (TAO_MARSHAL_EXCEPT::instance ()), m_wstring_ (TAO_MARSHAL_WSTRING::instance ()) -#endif +#endif /* 0 */ { // initialize the mobj table mobj_table_[tk_null].obj_ = TAO_MARSHAL_PRIMITIVE::instance (); @@ -159,8 +159,7 @@ TAO_Marshal_Object* TAO_Marshal_Factory::make_marshal_object (CORBA_TypeCode_ptr return (TAO_Marshal_Object *)0; } } -#endif - +#endif /* 0 */ #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Singleton<TAO_Marshal_Factory, ACE_SYNCH_MUTEX>; diff --git a/TAO/tao/marshal.h b/TAO/tao/marshal.h index 79e41ba8731..045019bc6f8 100644 --- a/TAO/tao/marshal.h +++ b/TAO/tao/marshal.h @@ -39,6 +39,7 @@ DEEP_FREE (CORBA_TypeCode_ptr param, const void *dest, CORBA_Environment &env); +// = Forward declarations. class TAO_Marshal_Object; class TAO_Marshal_Primitive; class TAO_Marshal_Any; @@ -78,7 +79,8 @@ private: }; TAO_Marshal_Object_Entry mobj_table_[TC_KIND_COUNT]; - // A table of specialized marshal objects indexed by the _kind field + // A table of specialized marshal objects indexed by the _kind + // field. #if 0 // define data members that are instances of various Marshal_Object classes @@ -95,7 +97,7 @@ private: TAO_Marshal_Alias *m_alias_; TAO_Marshal_Except *m_except_; TAO_Marshal_WString *m_wstring_; -#endif +#endif /* 0 */ }; // Create a type for the singleton factory @@ -104,7 +106,8 @@ typedef ACE_Singleton<TAO_Marshal_Factory, ACE_SYNCH_MUTEX> class TAO_Marshal // = TITLE -// Namespace in which to put otherwise "global" methods like initialize, etc. +// Namespace in which to put otherwise "global" methods like +// initialize, etc. { public: static void initialize (void); @@ -115,26 +118,28 @@ public: class TAO_Marshal_Object { // = TITLE - // The Marshaling object that provides a common interface to the CDR - // object for marshaling different IDL data types + // The Marshaling object that provides a common interface to the + // CDR object for marshaling different IDL data types // // = DESCRIPTION - // Provides a set of virtual methods for encoding, decoding, - // deep_copying, and deep_freeing. + // Provides a set of virtual methods for encoding, decoding, + // deep_copying, and deep_freeing. public: + // = Encoding and decoding operations. + virtual CORBA_TypeCode::traverse_status encode (CORBA_TypeCode_ptr tc, const void *data, const void *, void *context, CORBA_Environment &env) = 0; - // encoding operation + // Encoding operation. virtual CORBA_TypeCode::traverse_status decode (CORBA_TypeCode_ptr tc, const void *data, const void *parent_typecode, void *context, CORBA_Environment &env) = 0; - // decoding operation + // Decoding operation. TAO_Marshal_Object (void); // constructor @@ -145,6 +150,7 @@ public: class TAO_Marshal_Primitive: public TAO_Marshal_Object { + // @@ Andy, please fill in here and add comments to this class. // = TITLE // = DESCRIPTION public: @@ -582,12 +588,12 @@ typedef ACE_Singleton<TAO_Marshal_WString, ACE_SYNCH_MUTEX> # undef ACE_INLINE # define ACE_INLINE inline # define do_undef_on_ACE_INLINE -# endif +# endif /* __ACE_INLINE__ */ # include "marshal.i" # if defined (do_undef_on_ACE_INLINE) # undef do_undef_on_ACE_INLINE # undef ACE_INLINE # define ACE_INLINE -# endif +# endif /* do_undef_on_ACE_INLINE */ -#endif +#endif /* TAO_MARSHAL_H */ diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index c387a5e982d..f22767e83f5 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -1,131 +1,107 @@ // This may look like C, but it's really -*- C++ -*- // -/* orbconf.hh. Generated automatically by configure. */ -// @(#) $Id$ +// @ (#) $Id$ // Copyright 1995 by Sun Microsystems, Inc // // Build configuration file for the Inter-ORB Engine, and application // level code using it via <corba.hh> // -// !! Modify "orbconf.hh", not the file generated by "configure" !! -// -// Keep the tests in the order they're found in "configure.in". Also, keep -// in mind that all "#undef" preprocessor directives are deemed to be the -// property of "autoconf"; if those are needed in their own right, they must -// be in some other file. -// -// This file builds on work originally contributed by a team at apm.co.uk: -// Owen Rees (rtor), Guangxing Li (gxl) and Mike Beasley (mdrb). -// #if !defined (TAO_ORB_CONFIG_H) #define TAO_ORB_CONFIG_H #include "ace/OS.h" -// -// BC++ seems to have a different convention for detecting Win32 than VC++. -// -#if defined (__WIN32__) +// BC++ seems to have a different convention for detecting Win32 than +// VC++. + +#if defined (__WIN32__) # define _WIN32 #endif /* BC++ convention */ /* Define if you have the <widec.h> header file. */ -#if !defined(linux) && !defined(_WIN32) && !defined(VXWORKS) +#if !defined (linux) && !defined (_WIN32) && !defined (VXWORKS) # define HAVE_WIDEC_H 1 -#endif +#endif /* !defined (linux) && !defined (_WIN32) && !defined (VXWORKS) */ -/* Define to `int' if <sys/types.h> doesn't define. */ +// Define to `int' if <sys/types.h> doesn't define. /* #undef pid_t */ -/* Define if your processor stores words with the most significant - byte first (like Motorola and SPARC, unlike Intel and VAX). */ -#if defined(i386) || defined(_M_IX86) || defined(vax) +// Define if your processor stores words with the most significant +// byte first (like Motorola and SPARC, unlike Intel and VAX). +#if defined (i386) || defined (_M_IX86) || defined (vax) #else -# define WORDS_BIGENDIAN 1 +# define TAO_WORDS_BIGENDIAN 1 #endif -/* The number of bytes in an int. */ -# if defined(_WIN32) || defined(linux) || defined(VXWORKS) +// The number of bytes in an int. +# if defined (_WIN32) || defined (linux) || defined (VXWORKS) # define SIZEOF_INT 4 # else // Win16 # define SIZEOF_INT 2 # endif // Win32/Win16 -/* The number of bytes in a long. */ +// The number of bytes in a long. #define SIZEOF_LONG 4 -/* The number of bytes in a void *. */ +// The number of bytes in a void *. #define SIZEOF_VOID_P 4 -/* The number of bytes in a long long. */ -#if !defined (_WIN32) && !defined (VXWORKS) +// The number of bytes in a long long. +#if !defined (_WIN32) && !defined (VXWORKS) #define SIZEOF_LONG_LONG 8 -#endif +#endif /* !defined (_WIN32) && !defined (VXWORKS) */ -/* The number of bytes in a long double. */ -#if defined(linux) +// The number of bytes in a long double. +#if defined (linux) # define SIZEOF_LONG_DOUBLE 12 -#elif defined(_WIN32) || defined(VXWORKS) || defined (M_UNIX) +#elif defined (_WIN32) || defined (VXWORKS) || defined (M_UNIX) # define SIZEOF_LONG_DOUBLE 8 #else # define SIZEOF_LONG_DOUBLE 16 -#endif +#endif /* linux */ -/* The number of bytes in a bool. */ +// The number of bytes in a bool. #define SIZEOF_BOOL 0 -// The number of bytes in a wchar_t +// The number of bytes in a wchar_t. #if defined (VXWORKS) #define SIZEOF_WCHAR_T 1 #else #define SIZEOF_WCHAR_T 2 -#endif +#endif /* VXWORKS */ -/* Define as the return type of signal handlers (int or void). */ +// Define as the return type of signal handlers (int or void). #define RETSIGTYPE void -/* Define if you don't have vprintf but do have _doprnt. */ +// Define if you don't have vprintf but do have _doprnt. /* #undef HAVE_DOPRNT */ -/* Define if you have the vprintf function. */ +// Define if you have the vprintf function. #define HAVE_VPRINTF 1 -/* Define if you have strerror declared. */ +// Define if you have strerror declared. #define DECLARED_STRERROR 1 // With ACE, we always have this :-) #define HAVE_GETTIMEOFDAY - -// -// Various issues not dealt with via autoconf/configure. -// -#if !defined(ACE_INVALID_HANDLE) -#if !defined (_WINSOCKAPI_) - // Winsock added nonstandard APIs -# define closesocket(s) close(s) -#endif /* _WINSOCKAPI_ */ -#endif - -#ifdef minor +#if defined (minor) // namespace pollution that's common on older UNIXes, // XXX this can't go here, "autoconf" wants to own #undef /* # undef minor */ #endif /* minor */ -// // For Win16, near/far pointers reflect same/other segment addressing. -// -#if defined (unix) || defined (_WIN32) || defined(VXWORKS) + +#if defined (unix) || defined (_WIN32) || defined (VXWORKS) # define _FAR -#endif +#endif /* defined (unix) || defined (_WIN32) || defined (VXWORKS) */ -// // Assume DOS/Windows if "configure" didn't get run. -// -#if !defined(SIZEOF_LONG) || defined(_WIN32) -//# if defined(_WIN32) || defined(linux) + +#if !defined (SIZEOF_LONG) || defined (_WIN32) +//# if defined (_WIN32) || defined (linux) //# define SIZEOF_INT 4 //# else // Win16 //# define SIZEOF_INT 2 @@ -145,32 +121,13 @@ # define HAVE_STRDUP -# if !defined(linux) && !defined(_WIN32) +# if !defined (linux) && !defined (_WIN32) typedef unsigned long pid_t; -# endif +# endif /* !defined (linux) && !defined (_WIN32) */ // "C4355: 'this' : used in base member initializer list" -# pragma warning(disable:4355) /* disable C4355 warning */ +# pragma warning (disable:4355) /* disable C4355 warning */ -#endif - -// -// For both Win16 and Win32, DLLs (shared libraries) need to know what -// classes, functions, and data are exported. DLLs aren't quite dealt -// with here yet, it's tough to do it portably (viz. the different -// answers now used by BC++/VC++). -// -// (Wouldn't it be nice if more C++ compilers and linkers took advantage -// of syntax to help get ensure that only public interfaces get exported -// from shared libraries? Hmmm...) -// -#if defined (unix) || !defined (__BORLANDC__) -# define _EXPFUNC -# define _EXPDATA -#endif - -#if defined (hpux) -# define SELECT_INT_STAR -#endif +#endif /* !defined (SIZEOF_LONG) || defined (_WIN32) */ #endif /* TAO_ORB_CONFIG_H */ diff --git a/TAO/tao/orbobj.cpp b/TAO/tao/orbobj.cpp index f067ed48297..11f821ff585 100644 --- a/TAO/tao/orbobj.cpp +++ b/TAO/tao/orbobj.cpp @@ -28,7 +28,7 @@ extern void __TC_init_standard_exceptions (CORBA_Environment &env); #if defined (SIG_IGN_BROKEN) # undef SIG_IGN # define SIG_IGN ((RETSIGTYPE (*) (int))1) -#endif // NeXT +#endif /* NeXT */ // COM's IUnknown support @@ -41,22 +41,24 @@ DEFINE_GUID (IID_CORBA_ORB, DEFINE_GUID (IID_STUB_Object, 0xa201e4c7, 0xf258, 0x11ce, 0x95, 0x98, 0x0, 0x0, 0xc0, 0x7c, 0xa8, 0x98); -TAO_Client_Strategy_Factory& -CORBA_ORB::client_factory(void) +TAO_Client_Strategy_Factory & +CORBA_ORB::client_factory (void) { if (client_factory_ == 0) { - // Look in the service repository for an instance + // Look in the service repository for an instance. client_factory_ = - ACE_Dynamic_Service<TAO_Client_Strategy_Factory>::instance("Client_Strategy_Factory"); + ACE_Dynamic_Service<TAO_Client_Strategy_Factory>::instance ("Client_Strategy_Factory"); client_factory_from_service_config_ = CORBA_B_TRUE; } if (client_factory_ == 0) { - // Still don't have one - ACE_NEW(client_factory_, TAO_Default_Client_Strategy_Factory); - // this will throw an exception if it fails on exception-throwing platforms + // Still don't have one, so let's allocate the default. This + // will throw an exception if it fails on exception-throwing + // platforms. + ACE_NEW (client_factory_, TAO_Default_Client_Strategy_Factory); + client_factory_from_service_config_ = CORBA_B_FALSE; // @@ At this point we need to register this with the // Service_Repository in order to get it cleaned up properly. @@ -66,22 +68,25 @@ CORBA_ORB::client_factory(void) return *client_factory_; } -TAO_Server_Strategy_Factory& -CORBA_ORB::server_factory(void) +TAO_Server_Strategy_Factory & +CORBA_ORB::server_factory (void) { if (server_factory_ == 0) { - // Look in the service repository for an instance + // Look in the service repository for an instance. server_factory_ = - ACE_Dynamic_Service<TAO_Server_Strategy_Factory>::instance("Server_Strategy_Factory"); + ACE_Dynamic_Service<TAO_Server_Strategy_Factory>::instance ("Server_Strategy_Factory"); + server_factory_from_service_config_ = CORBA_B_TRUE; } if (server_factory_ == 0) { - // Still don't have one - ACE_NEW(server_factory_, TAO_Default_Server_Strategy_Factory); - // this will throw an exception if it fails on exception-throwing platforms + // Still don't have one, so let's allocate the default. This + // will throw an exception if it fails on exception-throwing + // platforms. + ACE_NEW (server_factory_, TAO_Default_Server_Strategy_Factory); + server_factory_from_service_config_ = CORBA_B_FALSE; // @@ At this point we need to register this with the // Service_Repository in order to get it cleaned up properly. @@ -116,9 +121,11 @@ CORBA_ORB::Release (void) // Little convenience function use in parsing arguments inline static void -argvec_shift(int& argc, char *argv[], int numslots) +argvec_shift (int& argc, char *argv[], int numslots) { - ACE_OS::memmove(&argv[0], &argv[numslots], (argc - numslots)*sizeof(argv[0])); + ACE_OS::memmove (&argv[0], + &argv[numslots], + (argc - numslots) * sizeof argv[0]); argc -= numslots; } @@ -189,24 +196,24 @@ CORBA_ORB_init (int &argc, // @@ Should we dup the string before assigning? svc_config_argv[svc_config_argc++] = argv[i + 1]; - argvec_shift(argc, argv[i], 2); + argvec_shift (argc, argv[i], 2); } else if (ACE_OS::strcmp (argv[i], "-OAdaemon") == 0) { // Be a daemon svc_config_argv[svc_config_argc++] = "-b"; - argvec_shift(argc, argv[i], 1); + argvec_shift (argc, argv[i], 1); } else if (ACE_OS::strcmp (argv[i], "-d") == 0) { // Turn on debugging svc_config_argv[svc_config_argc++] = "-d"; - argvec_shift(argc, argv[i], 1); + argvec_shift (argc, argv[i], 1); } } -#ifdef DEBUG +#if defined (DEBUG) // Make it a little easier to debug programs using this code. { char *value = ACE_OS::getenv ("TAO_ORB_DEBUG"); @@ -236,20 +243,21 @@ CORBA_ORB_init (int &argc, // is readable by mortals). CORBA_Boolean use_ior; - if (orb_name != 0 && ACE_OS::strcmp (orb_name, "internet") == 0) + if (orb_name != 0 + && ACE_OS::strcmp (orb_name, "internet") == 0) use_ior = CORBA_B_FALSE; else use_ior = CORBA_B_TRUE; -#ifdef SIGPIPE +#if defined (SIGPIPE) // @@ Is there a better way to deal with this in a portable manner? --cjc // // Impractical to have each call to the ORB protect against the // implementation artifact of potential writes to dead connections, // as it'd be way expensive. Do it here; who cares about SIGPIPE in // these kinds of applications, anyway? - (void) ACE_OS::signal (SIGPIPE, SIG_IGN); -#endif // SIGPIPE + (void) ACE_OS::signal (SIGPIPE, SIG_IGN); +#endif /* SIGPIPE */ ACE_OS::socket_init (ACE_WSOCK_VERSION); @@ -262,7 +270,7 @@ CORBA_ORB_init (int &argc, return 0; // Initialize the Service Configurator - ACE_Service_Config::open(svc_config_argc, svc_config_argv); + ACE_Service_Config::open (svc_config_argc, svc_config_argv); // Inititalize the "ORB" pseudo-object now. IIOP_ORB_ptr the_orb = TAO_ORB::instance (); @@ -275,7 +283,7 @@ void CORBA_ORB::create_list (CORBA_Long count, CORBA_NVList_ptr &retval) { - assert (CORBA_ULong(count) <= UINT_MAX); + assert (CORBA_ULong (count) <= UINT_MAX); retval = new CORBA_NVList; @@ -331,7 +339,7 @@ CORBA_BOA_ptr CORBA_ORB::BOA_init (int &argc, if (i + 1 < argc) id = CORBA_string_dup (argv[i + 1]); - argvec_shift(argc, argv[i], 2); + argvec_shift (argc, argv[i], 2); } else if (ACE_OS::strcmp (argv[i], "-OAhost") == 0) { @@ -340,7 +348,7 @@ CORBA_BOA_ptr CORBA_ORB::BOA_init (int &argc, if (i + 1 < argc) host = CORBA_string_dup (argv[i + 1]); - argvec_shift(argc, argv[i], 2); + argvec_shift (argc, argv[i], 2); } else if (ACE_OS::strcmp (argv[i], "-OAport") == 0) { @@ -349,7 +357,7 @@ CORBA_BOA_ptr CORBA_ORB::BOA_init (int &argc, // @@ We shouldn't limit this to being specified as an int! --cjc port = ACE_OS::atoi (argv[i + 1]); - argvec_shift(argc, argv[i], 2); + argvec_shift (argc, argv[i], 2); } else if (ACE_OS::strcmp (argv[i], "-OAobjdemux") == 0) { @@ -358,7 +366,7 @@ CORBA_BOA_ptr CORBA_ORB::BOA_init (int &argc, if (i + 1 < argc) demux = CORBA_string_dup (argv[i+1]); - argvec_shift(argc, argv[i], 2); + argvec_shift (argc, argv[i], 2); } else if (ACE_OS::strcmp (argv[i], "-OAtablesize") == 0) { @@ -366,7 +374,7 @@ CORBA_BOA_ptr CORBA_ORB::BOA_init (int &argc, if (i + 1 < argc) tablesize = ACE_OS::atoi (argv[i+1]); - argvec_shift(argc, argv[i], 2); + argvec_shift (argc, argv[i], 2); } else if (ACE_OS::strcmp (argv[i], "-OArcvsock") == 0) { @@ -380,7 +388,7 @@ CORBA_BOA_ptr CORBA_ORB::BOA_init (int &argc, { // Specify whether or not threads should be used. use_threads = CORBA_B_TRUE; - argvec_shift(argc, argv[i], 1); + argvec_shift (argc, argv[i], 1); } else i++; @@ -409,7 +417,7 @@ CORBA_BOA_ptr CORBA_ORB::BOA_init (int &argc, #if defined (ROA_NEEDS_REQ_KEY) (void) ACE_Thread::keycreate (&req_key_); -#endif +#endif /* ROA_NEEDS_REQ_KEY */ ACE_NEW_RETURN (rp, ROA (this, env), 0); @@ -418,4 +426,4 @@ CORBA_BOA_ptr CORBA_ORB::BOA_init (int &argc, #if !defined (__ACE_INLINE__) # include "orbobj.i" -#endif +#endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/orbobj.h b/TAO/tao/orbobj.h index 81951bbb019..cd0c4c0515c 100644 --- a/TAO/tao/orbobj.h +++ b/TAO/tao/orbobj.h @@ -50,13 +50,16 @@ CORBA_ORB_init (int &argc, CORBA_Environment &env); class ACE_Svc_Export CORBA_ORB : public IUnknown -// = TITLE -// ORB pseudo-objref + // = TITLE + // ORB pseudo-objref { public: CORBA_BOA_ptr BOA_init (int &argc, - char **argv, + char *argv[], const char *boa_identifier = 0); + // Initialize the BOA. + + // @@ Please add comments. static CORBA_ORB_ptr _duplicate (CORBA_ORB_ptr orb); static CORBA_ORB_ptr _nil (void); @@ -80,7 +83,7 @@ public: ULONG __stdcall AddRef (void); ULONG __stdcall Release (void); - // = TAO-SPECIFIC THINGS + // = TAO-specific methods. TAO_Client_Factory &client_factory (void); TAO_Server_Factory &server_factory (void); TAO_ORB_Parameters ¶ms (void); @@ -94,9 +97,13 @@ private: u_int refcount_; TAO_Client_Strategy_Factory *client_factory_; - CORBA_Boolean client_factory_from_service_config_; + + CORBA_Boolean client_factory_from_service_config_; + TAO_Server_Strategy_Factory *server_factory_; - CORBA_Boolean server_factory_from_service_config_; + + CORBA_Boolean server_factory_from_service_config_; + TAO_ORB_Parameters params_; // = NON-PROVIDED METHODS diff --git a/TAO/tao/params.cpp b/TAO/tao/params.cpp index 53b519c3c3b..63d8726659c 100644 --- a/TAO/tao/params.cpp +++ b/TAO/tao/params.cpp @@ -40,26 +40,16 @@ TAO_OA_Parameters::demux_strategy (const char* strategy) { // Determine the demux strategy based on the given name if (!ACE_OS::strcmp (strategy, "linear")) - { - this->demux_ = TAO_LINEAR; - } + this->demux_ = TAO_LINEAR; else if (!ACE_OS::strcmp (strategy, "dynamic_hash")) - { - this->demux_ = TAO_DYNAMIC_HASH; - } + this->demux_ = TAO_DYNAMIC_HASH; else if (!ACE_OS::strcmp (strategy, "user_def")) - { - this->demux_ = TAO_USER_DEFINED; - } + this->demux_ = TAO_USER_DEFINED; else if (!ACE_OS::strcmp (strategy, "active_demux")) - { - this->demux_ = TAO_ACTIVE_DEMUX; - } + this->demux_ = TAO_ACTIVE_DEMUX; else - { - // Provide fallback! - this->demux_ = TAO_DYNAMIC_HASH; - } + // Provide fallback! + this->demux_ = TAO_DYNAMIC_HASH; } // Pointer to the Singleton instance. @@ -68,7 +58,7 @@ TAO_OA_Parameters *TAO_OA_Parameters::instance_ = 0; // Lock the creation of the singleton. ACE_SYNCH_MUTEX TAO_OA_Parameters::ace_singleton_lock_; -#if !defined(__ACE_INLINE__) +#if !defined (__ACE_INLINE__) # include "params.i" -#endif +#endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/principa.h b/TAO/tao/principa.h index 0036385de94..905dfc4a8e8 100644 --- a/TAO/tao/principa.h +++ b/TAO/tao/principa.h @@ -64,12 +64,12 @@ private: CORBA_Principal &operator = (const CORBA_Principal_ptr &); CORBA_Principal (const CORBA_Principal_ptr &); -#if defined (__GNUG__) +#if defined (__GNUG__) // // G++ (even 2.6.3) stupidly thinks instances can't be // created. This de-warns. // friend class everyone_needs_a_friend; -#endif +#endif /* __GNUG__ */ }; #endif /* TAO_PRINCIPAL_H */ diff --git a/TAO/tao/roa.h b/TAO/tao/roa.h index e8cb3b01a62..639d78ddc07 100644 --- a/TAO/tao/roa.h +++ b/TAO/tao/roa.h @@ -136,7 +136,7 @@ private: #if defined (ROA_NEEDS_REQ_KEY) ACE_thread_key_t req_key_; // Key into TSS for a thread's request header -#endif +#endif /* ROA_NEEDS_REQ_KEY */ // = Copy and assignment: just say no ROA (const ROA &src); diff --git a/TAO/tao/server_factory.cpp b/TAO/tao/server_factory.cpp index 7a7e2f94691..a7e68f1b01a 100644 --- a/TAO/tao/server_factory.cpp +++ b/TAO/tao/server_factory.cpp @@ -13,9 +13,45 @@ // $Id$ // ============================================================================ -#if !defined(__ACE_INLINE__) +#if !defined (__ACE_INLINE__) # include "server_factory.i" -#endif +#endif /* __ACE_INLINE__ */ + +TAO_Server_Strategy_Factory::TAO_Server_Strategy_Factory (void) +{} + +TAO_Server_Strategy_Factory::~TAO_Server_Strategy_Factory(void) +{} + +CREATION_STRATEGY * +TAO_Server_Strategy_Factory::creation_strategy (void) +{ + return 0; +} + +ACCEPT_STRATEGY * +TAO_Server_Strategy_Factory::accept_strategy (void) +{ + return 0; +} + +CONCURRENCY_STRATEGY * +TAO_Server_Strategy_Factory::concurrency_strategy (void) +{ + return 0; +} + +SCHEDULING_STRATEGY * +TAO_Server_Strategy_Factory::scheduling_strategy (void) +{ + return 0; +} + +TAO_Object_Table * +TAO_Server_Strategy_Factory::object_lookup_strategy (void) +{ + return 0; +} #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Creation_Strategy<TAO_OA_Connection_Handler>; diff --git a/TAO/tao/server_factory.h b/TAO/tao/server_factory.h index e75fa94a64b..8db824df408 100644 --- a/TAO/tao/server_factory.h +++ b/TAO/tao/server_factory.h @@ -15,7 +15,7 @@ // $Id$ // ============================================================================ -#if !defined(TAO_SERVER_FACTORY_H) +#if !defined (TAO_SERVER_FACTORY_H) # define TAO_SERVER_FACTORY_H # include "ace/SOCK_Acceptor.h" @@ -28,11 +28,9 @@ # include "tao/connect.h" # include "tao/objtable.h" - class TAO_Server_Strategy_Factory : public ACE_Service_Object // = TITLE - // - // Base class for the server's abstract factory which turns out + // Base class for the server's abstract factory that manufactures // various strategies of special utility to it. This simply // serves as an interface to a subclass that REALLY gets // specified and loaded by the Service Configurator. @@ -40,17 +38,20 @@ class TAO_Server_Strategy_Factory : public ACE_Service_Object public: // = Initialization and termination methods. TAO_Server_Strategy_Factory (void); - // constructor + // Constructor. virtual ~TAO_Server_Strategy_Factory(void); - // destructor - - - // = SERVER-SIDE factory types. - typedef ACE_Creation_Strategy<TAO_OA_Connection_Handler> CREATION_STRATEGY; - typedef ACE_Accept_Strategy<TAO_OA_Connection_Handler, ACE_SOCK_ACCEPTOR> ACCEPT_STRATEGY; - typedef ACE_Concurrency_Strategy<TAO_OA_Connection_Handler> CONCURRENCY_STRATEGY; - typedef ACE_Scheduling_Strategy<TAO_OA_Connection_Handler> SCHEDULING_STRATEGY; + // Destructor. + + // = Server-side factory types. + typedef ACE_Creation_Strategy<TAO_OA_Connection_Handler> + CREATION_STRATEGY; + typedef ACE_Accept_Strategy<TAO_OA_Connection_Handler, ACE_SOCK_ACCEPTOR> + ACCEPT_STRATEGY; + typedef ACE_Concurrency_Strategy<TAO_OA_Connection_Handler> + CONCURRENCY_STRATEGY; + typedef ACE_Scheduling_Strategy<TAO_OA_Connection_Handler> + SCHEDULING_STRATEGY; // = Factory methods for the server-side strategies. @@ -68,13 +69,11 @@ public: virtual TAO_Object_Table *object_lookup_strategy (void); // Return the concrete object lookup strategy. - -private: }; # if defined(__ACE_INLINE__) # include "server_factory.i" -# endif +# endif /* __ACE_INLINE__ */ -#endif +#endif /* TAO_SERVER_FACTORY_H */ diff --git a/TAO/tao/server_factory.i b/TAO/tao/server_factory.i index 0543e2c9b96..e69de29bb2d 100644 --- a/TAO/tao/server_factory.i +++ b/TAO/tao/server_factory.i @@ -1,37 +0,0 @@ -ACE_INLINE -TAO_Server_Strategy_Factory::TAO_Server_Strategy_Factory (void) -{} - -ACE_INLINE -TAO_Server_Strategy_Factory::~TAO_Server_Strategy_Factory(void) -{} - -ACE_INLINE CREATION_STRATEGY * -TAO_Server_Strategy_Factory::creation_strategy (void) -{ - return 0; -} - -ACE_INLINE ACCEPT_STRATEGY * -TAO_Server_Strategy_Factory::accept_strategy (void) -{ - return 0; -} - -ACE_INLINE CONCURRENCY_STRATEGY * -TAO_Server_Strategy_Factory::concurrency_strategy (void) -{ - return 0; -} - -ACE_INLINE SCHEDULING_STRATEGY * -TAO_Server_Strategy_Factory::scheduling_strategy (void) -{ - return 0; -} - -ACE_INLINE TAO_Object_Table * -TAO_Server_Strategy_Factory::object_lookup_strategy (void) -{ - return 0; -} diff --git a/TAO/tao/svc.conf.eg b/TAO/tao/svc.conf.eg index a9a3ded5b91..34f516db002 100644 --- a/TAO/tao/svc.conf.eg +++ b/TAO/tao/svc.conf.eg @@ -1,4 +1,6 @@ +# This file illustrates various ways to configure a TAO server dynamically. + # Reactive, dynamic object table with 64 slots -dynamic Server_Strategy_Factory TAO_Default_Server_Strategy_Factory "-R -L dynamic -o 64" +# dynamic Server_Strategy_Factory TAO_Default_Server_Strategy_Factory "-R -L dynamic -o 64" # Thread-per-Connection, hash object table with 128 slots dynamic Server_Strategy_Factory TAO_Default_Server_Strategy_Factory "-T -L hash -o 128" diff --git a/TAO/tao/svrrqst.cpp b/TAO/tao/svrrqst.cpp index 942ac6689d0..0468d6ccd2a 100644 --- a/TAO/tao/svrrqst.cpp +++ b/TAO/tao/svrrqst.cpp @@ -24,7 +24,7 @@ DEFINE_GUID (IID_CORBA_ServerRequest, #if !defined (__ACE_INLINE__) # include "svrrqst.i" -#endif +#endif /* __ACE_INLINE__ */ IIOP_ServerRequest::~IIOP_ServerRequest (void) { diff --git a/TAO/tao/t-xdr.cpp b/TAO/tao/t-xdr.cpp index 393aed26e88..2b58399c7d5 100644 --- a/TAO/tao/t-xdr.cpp +++ b/TAO/tao/t-xdr.cpp @@ -9,9 +9,9 @@ #include "tao/orb.h" -#if defined(HAVE_WIDEC_H) +#if defined (HAVE_WIDEC_H) # include <widec.h> -#endif +#endif /* HAVE_WIDEC_H */ #include "tao/cdr.h" #include "tao/debug.h" diff --git a/TAO/tao/typecode.cpp b/TAO/tao/typecode.cpp index dd7cbc9db87..a1f6559f394 100644 --- a/TAO/tao/typecode.cpp +++ b/TAO/tao/typecode.cpp @@ -75,7 +75,7 @@ CORBA_TypeCode::CORBA_TypeCode (CORBA_TCKind kind, (void) ACE_OS::memcpy (_buffer, buffer, (size_t) length); _orb_owns = CORBA_B_FALSE; // XXX may leak } -#endif +#endif /* 0 */ // TAO comments: // For free standing typecodes, we choose to always make a copy of the buffer passed diff --git a/TAO/tao/xdr.cpp b/TAO/tao/xdr.cpp index 43f0f505e32..08f1f2d9124 100644 --- a/TAO/tao/xdr.cpp +++ b/TAO/tao/xdr.cpp @@ -32,744 +32,709 @@ #include "tao/principa.h" #include "tao/xdr.h" -#if defined(HAVE_WIDEC_H) +#if defined (HAVE_WIDEC_H) # include <widec.h> -#endif +#endif /* HAVE_WIDEC_H */ - - -// // I/O for 64 bit quantities -- integers, doubles -// + CORBA_Boolean XDR_stream::put_longlong (const CORBA_LongLong &) THROWS_NOTHING { - return CORBA_B_FALSE; + return CORBA_B_FALSE; } CORBA_Boolean XDR_stream::get_longlong (CORBA_LongLong &) THROWS_NOTHING { - return CORBA_B_FALSE; + return CORBA_B_FALSE; } - -// // I/O for 128 bit quantities -- long doubles -// + CORBA_Boolean XDR_stream::put_longdouble (const CORBA_LongDouble &) THROWS_NOTHING { - return CORBA_B_FALSE; + return CORBA_B_FALSE; } CORBA_Boolean XDR_stream::get_longdouble (CORBA_LongDouble &) THROWS_NOTHING { - return CORBA_B_FALSE; + return CORBA_B_FALSE; } - -// -// Encode instances of arbitrary data types based only on typecode. "data" -// points to the data type; if it's not a primitve data type, the TypeCode -// interpreter is used to recursively encode its components. "context" is -// the marshaling stream on which to encode the data value. -// -// This is a fairly typical TypeCode interpreter visit() routine; it works -// on a single data value in conjunction with context information, and must -// handle all IDL data types. +// Encode instances of arbitrary data types based only on typecode. +// "data" points to the data type; if it's not a primitve data type, +// the TypeCode interpreter is used to recursively encode its +// components. "context" is the marshaling stream on which to encode +// the data value. // +// This is a fairly typical TypeCode interpreter visit() routine; it +// works on a single data value in conjunction with context +// information, and must handle all IDL data types. + CORBA_TypeCode::traverse_status -XDR_stream::encoder ( - CORBA_TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA_Environment &env -) -THROWS_NOTHING +XDR_stream::encoder (CORBA_TypeCode_ptr tc, + const void *data, + const void *, + void *context, + CORBA_Environment &env) + THROWS_NOTHING { - CORBA_Boolean continue_encoding = CORBA_B_TRUE; - XDR_stream *stream = (XDR_stream *)context; - - switch (tc->_kind) { - case tk_null: - case tk_void: - // nothing to encode! - break; + CORBA_Boolean continue_encoding = CORBA_B_TRUE; + XDR_stream *stream = (XDR_stream *)context; + + switch (tc->_kind) + { + case tk_null: + case tk_void: + // nothing to encode! + break; - case tk_char: - case tk_octet: - continue_encoding = stream->put_char (*(char *)data); - break; - - case tk_short: - case tk_ushort: - continue_encoding = stream->put_short (*(short *)data); - break; - - case tk_long: - case tk_ulong: - case tk_float: - continue_encoding = stream->put_long (*(CORBA_Long *)data); - break; - - case tk_double: - case tk_longlong: - case tk_ulonglong: - continue_encoding = stream->put_longlong (*(CORBA_LongLong *)data); - break; - - case tk_boolean: - continue_encoding = stream->put_boolean (*(CORBA_Boolean *)data); - break; + case tk_char: + case tk_octet: + continue_encoding = stream->put_char (*(char *)data); + break; + + case tk_short: + case tk_ushort: + continue_encoding = stream->put_short (*(short *)data); + break; + + case tk_long: + case tk_ulong: + case tk_float: + continue_encoding = stream->put_long (*(CORBA_Long *)data); + break; + + case tk_double: + case tk_longlong: + case tk_ulonglong: + continue_encoding = stream->put_longlong (*(CORBA_LongLong *)data); + break; + + case tk_boolean: + continue_encoding = stream->put_boolean (*(CORBA_Boolean *)data); + break; + + case tk_enum: + { + // NOTE assumption that this is in-range. + // + // XXX should check this, it's a hard-to-recover error + // for the other side + u_int value = *(u_int *)data; + continue_encoding = stream->put_ulong (value); + } + break; + + case tk_any: + { + CORBA_Any *any = (CORBA_Any *)data; + + tc = any->type (); + if (encoder (_tc_CORBA_TypeCode, &tc, 0, context, env) + != CORBA_TypeCode::TRAVERSE_CONTINUE) + return CORBA_TypeCode::TRAVERSE_STOP; + + data = any->value (); + return encoder (tc, data, 0, context, env); + } + // NOTREACHED + + case tk_TypeCode: + { + CORBA_TypeCode_ptr tc2; + + tc2 = *(CORBA_TypeCode_ptr *)data; + + continue_encoding = stream->put_ulong ((CORBA_ULong) tc2->_kind); + if (continue_encoding == CORBA_B_FALSE) + break; + + switch (tc2->_kind) + { + // Most TypeCodes have empty parameter lists + default: + break; - case tk_enum: - { - // - // NOTE assumption that this is in-range. // - // XXX should check this, it's a hard-to-recover error - // for the other side + // A few have "simple" parameter lists // - unsigned value = *(unsigned *)data; - continue_encoding = stream->put_ulong (value); - } - break; - - case tk_any: - { - CORBA_Any *any = (CORBA_Any *)data; - - tc = any->type (); - if (encoder (_tc_CORBA_TypeCode, &tc, 0, context, env) - != CORBA_TypeCode::TRAVERSE_CONTINUE) - return CORBA_TypeCode::TRAVERSE_STOP; - - data = any->value (); - return encoder (tc, data, 0, context, env); - } - // NOTREACHED - - case tk_TypeCode: - { - CORBA_TypeCode_ptr tc2; - - tc2 = *(CORBA_TypeCode_ptr *)data; - - continue_encoding = stream->put_ulong ((CORBA_ULong) tc2->_kind); - if (continue_encoding == CORBA_B_FALSE) - break; - - switch (tc2->_kind) { - // - // Most TypeCodes have empty parameter lists - // - default: - break; - - // - // A few have "simple" parameter lists - // - case tk_string: - case tk_wstring: - continue_encoding = stream->put_ulong (tc2->_length); - break; - - // - // Indirected typecodes can't occur at "top level" like - // this, only nested inside others! - // - case ~0: - dmsg ("indirected typecode at top level!"); - continue_encoding = CORBA_B_FALSE; - break; - - // - // The rest have "complex" parameter lists that are already - // encoded as bulk octets ... put length, then octets - // - case tk_objref: - case tk_struct: - case tk_union: - case tk_enum: - case tk_sequence: - case tk_array: - case tk_alias: - case tk_except: - { - unsigned i; - - continue_encoding = stream->put_ulong (tc2->_length); - for (i = 0; i < tc2->_length && continue_encoding; i++) - continue_encoding = - stream->put_octet (tc2->_buffer [i]); - } - } - } - break; - - case tk_Principal: - { - CORBA_Principal_ptr p = *(CORBA_Principal_ptr*) data; - unsigned i; - - if (p != 0) { - continue_encoding = stream->put_long (p->id.length); - for (i = 0; continue_encoding && i < p->id.length; i++) - continue_encoding = stream->put_octet (p->id.buffer [i]); - } else - continue_encoding = stream->put_long (0); - } - break; - - case tk_objref: - // XXX implement me - break; + case tk_string: + case tk_wstring: + continue_encoding = stream->put_ulong (tc2->_length); + break; - case tk_sequence: - { // - // First marshal the sequence length, verifying that - // it's within the sequence bounds ... + // Indirected typecodes can't occur at "top level" like + // this, only nested inside others! // - CORBA_OctetSeq *seq = (CORBA_OctetSeq *) data; - CORBA_ULong len = seq ? seq->length : 0; - - if (len > 0) { - CORBA_ULong bounds; - - bounds = tc->ulong_param (1, env); - if (env.exception () != 0) - return CORBA_TypeCode::TRAVERSE_STOP; - - if (bounds != 0 && len > bounds) { - env.exception (new CORBA_BAD_PARAM (COMPLETED_MAYBE)); - return CORBA_TypeCode::TRAVERSE_STOP; - } - } - continue_encoding = stream->put_ulong (len); + case ~0: + dmsg ("indirected typecode at top level!"); + continue_encoding = CORBA_B_FALSE; + break; // - // Fast exit on error or empty sequence + // The rest have "complex" parameter lists that are already + // encoded as bulk octets ... put length, then octets // - if (!continue_encoding || len == 0) - break; - } - // FALLTHROUGH - - case tk_struct: - case tk_union: - case tk_array: - case tk_alias: - // - // Marshal each member in order. - // - return tc->traverse (data, 0, encoder, context, env); - - case tk_except: - // - // Convert the the "hidden" TypeCode at the beginning of the - // exception into an on-the-wire ID, then marshal the members - // in order (traversal skips that hidden typecode, and more). - // - // NOTE: This is asymmetric with respect to decoding the exception, - // since whoever decodes must pull off the ID and map it to the - // typecode to be used to unmarshal it (search among legal choices). - // - { - CORBA_String id = tc->id (env); + case tk_objref: + case tk_struct: + case tk_union: + case tk_enum: + case tk_sequence: + case tk_array: + case tk_alias: + case tk_except: + { + u_int i; - if (env.exception () == 0) { + continue_encoding = stream->put_ulong (tc2->_length); + for (i = 0; i < tc2->_length && continue_encoding; i++) continue_encoding = - encoder (_tc_CORBA_String, &id, 0, context, env) - == CORBA_TypeCode::TRAVERSE_CONTINUE - && tc->traverse (data, 0, encoder, context, env); - } else - continue_encoding = CORBA_B_FALSE; - } - break; - - case tk_string: - { - CORBA_String str = *(CORBA_String *) data; - CORBA_ULong len, bounds; - - // - // Be nice to programmers: treat nulls as empty strings - // not errors. (OMG-IDL supports languages that don't use - // the C/C++ notion of null v. empty strings; nulls aren't - // part of the OMG-IDL string model.) - // - if (str == 0) { - stream->put_ulong (1); - stream->put_char (0); - break; + stream->put_octet (tc2->_buffer [i]); } - - // - // Verify string satisfies bounds requirements. We're not - // so permissive as to send messages violating the interface - // spec by having excessively long strings! - // - bounds = tc->ulong_param (0, env); + } + } + break; + + case tk_Principal: + { + CORBA_Principal_ptr p = *(CORBA_Principal_ptr*) data; + u_int i; + + if (p != 0) + { + continue_encoding = stream->put_long (p->id.length); + for (i = 0; continue_encoding && i < p->id.length; i++) + continue_encoding = stream->put_octet (p->id.buffer [i]); + } + else + continue_encoding = stream->put_long (0); + } + break; + + case tk_objref: + // XXX implement me + break; + + case tk_sequence: + { + // First marshal the sequence length, verifying that it's + // within the sequence bounds ... + CORBA_OctetSeq *seq = (CORBA_OctetSeq *) data; + CORBA_ULong len = seq ? seq->length : 0; + + if (len > 0) + { + CORBA_ULong bounds; + + bounds = tc->ulong_param (1, env); if (env.exception () != 0) - return CORBA_TypeCode::TRAVERSE_STOP; - len = ACE_OS::strlen ((char *)str); - - if (bounds != 0 && len > bounds) { - continue_encoding = CORBA_B_FALSE; - break; - } + return CORBA_TypeCode::TRAVERSE_STOP; - // - // Encode the string, followed by a NUL character. - // - continue_encoding = stream->put_ulong (len + 1); - while (continue_encoding != CORBA_B_FALSE && *str) - continue_encoding = stream->put_char (*str++); + if (bounds != 0 && len > bounds) + { + env.exception (new CORBA_BAD_PARAM (COMPLETED_MAYBE)); + return CORBA_TypeCode::TRAVERSE_STOP; + } + } + continue_encoding = stream->put_ulong (len); + + // Fast exit on error or empty sequence + if (!continue_encoding || len == 0) + break; + } + // FALLTHROUGH + + case tk_struct: + case tk_union: + case tk_array: + case tk_alias: + // + // Marshal each member in order. + // + return tc->traverse (data, 0, encoder, context, env); + + case tk_except: + // Convert the the "hidden" TypeCode at the beginning of the + // exception into an on-the-wire ID, then marshal the members in + // order (traversal skips that hidden typecode, and more). + // + // NOTE: This is asymmetric with respect to decoding the + // exception, since whoever decodes must pull off the ID and map + // it to the typecode to be used to unmarshal it (search among + // legal choices). + { + CORBA_String id = tc->id (env); + + if (env.exception () == 0) + { + continue_encoding = + encoder (_tc_CORBA_String, &id, 0, context, env) + == CORBA_TypeCode::TRAVERSE_CONTINUE + && tc->traverse (data, 0, encoder, context, env); + } + else + continue_encoding = CORBA_B_FALSE; + } + break; + + case tk_string: + { + CORBA_String str = *(CORBA_String *) data; + CORBA_ULong len, bounds; + + // Be nice to programmers: treat nulls as empty strings not + // errors. (OMG-IDL supports languages that don't use the + // C/C++ notion of null v. empty strings; nulls aren't part of + // the OMG-IDL string model.) + if (str == 0) + { + stream->put_ulong (1); stream->put_char (0); + break; + } + + // Verify string satisfies bounds requirements. We're not so + // permissive as to send messages violating the interface spec + // by having excessively long strings! + bounds = tc->ulong_param (0, env); + if (env.exception () != 0) + return CORBA_TypeCode::TRAVERSE_STOP; + len = ACE_OS::strlen ((char *)str); + + if (bounds != 0 && len > bounds) { + continue_encoding = CORBA_B_FALSE; + break; } - break; - - case tk_wstring: - { - wchar_t *str = *(wchar_t **) data; - CORBA_ULong len, bounds; - - // - // Be nice to programmers: treat nulls as empty strings - // not errors. (OMG-IDL supports languages that don't use - // the C/C++ notion of null v. empty strings; nulls aren't - // part of the OMG-IDL string model.) - // - if (str == 0) { - stream->put_ulong (1); - stream->put_wchar (0); - break; - } - // - // Verify wide string satisfies bounds requirements. We're - // not so permissive as to send messages violating the interface - // spec by having excessively long strings! - // - bounds = tc->ulong_param (0, env); - if (env.exception () != 0) - return CORBA_TypeCode::TRAVERSE_STOP; - len = wslen (str); - if (bounds != 0 && len > bounds) { - continue_encoding = CORBA_B_FALSE; - break; - } - - // - // Encode the wide string, followed by a NUL character. - // - continue_encoding = stream->put_ulong (wslen (str) + 1); - while (continue_encoding != CORBA_B_FALSE && *str) - continue_encoding = stream->put_wchar (*str++); + // Encode the string, followed by a NUL character. + continue_encoding = stream->put_ulong (len + 1); + while (continue_encoding != CORBA_B_FALSE && *str) + continue_encoding = stream->put_char (*str++); + stream->put_char (0); + } + break; + + case tk_wstring: + { + wchar_t *str = *(wchar_t **) data; + CORBA_ULong len, bounds; + + // Be nice to programmers: treat nulls as empty strings not + // errors. (OMG-IDL supports languages that don't use the + // C/C++ notion of null v. empty strings; nulls aren't part of + // the OMG-IDL string model.) + + if (str == 0) + { + stream->put_ulong (1); stream->put_wchar (0); - } - break; - - case tk_longdouble: - continue_encoding = - stream->put_longdouble (*(CORBA_LongDouble *)data); - break; - - case tk_wchar: - continue_encoding = stream->put_wchar (*(wchar_t *)data); - break; + break; + } + + // Verify wide string satisfies bounds requirements. We're + // not so permissive as to send messages violating the + // interface spec by having excessively long strings! + bounds = tc->ulong_param (0, env); + if (env.exception () != 0) + return CORBA_TypeCode::TRAVERSE_STOP; + len = wslen (str); + if (bounds != 0 && len > bounds) + { + continue_encoding = CORBA_B_FALSE; + break; + } + + // Encode the wide string, followed by a NUL character. + continue_encoding = stream->put_ulong (wslen (str) + 1); + while (continue_encoding != CORBA_B_FALSE && *str) + continue_encoding = stream->put_wchar (*str++); + stream->put_wchar (0); + } + break; + + case tk_longdouble: + continue_encoding = + stream->put_longdouble (*(CORBA_LongDouble *)data); + break; + + case tk_wchar: + continue_encoding = stream->put_wchar (*(wchar_t *)data); + break; // case ~0: - default: - dmsg ("encoder default case ?"); - continue_encoding = CORBA_B_FALSE; - break; + default: + dmsg ("encoder default case ?"); + continue_encoding = CORBA_B_FALSE; + break; } - if (continue_encoding == CORBA_B_FALSE) { - env.exception (new CORBA_MARSHAL (COMPLETED_MAYBE)); - dmsg ("marshaling encoder detected error"); - return CORBA_TypeCode::TRAVERSE_STOP; + if (continue_encoding == CORBA_B_FALSE) + { + env.exception (new CORBA_MARSHAL (COMPLETED_MAYBE)); + dmsg ("marshaling encoder detected error"); + return CORBA_TypeCode::TRAVERSE_STOP; } - return CORBA_TypeCode::TRAVERSE_CONTINUE; + return CORBA_TypeCode::TRAVERSE_CONTINUE; } - - -// // Array of typecodes used to unmarshal ... -// -extern CORBA_TypeCode_ptr __tc_consts [TC_KIND_COUNT]; +extern CORBA_TypeCode_ptr __tc_consts [TC_KIND_COUNT]; CORBA_TypeCode::traverse_status -XDR_stream::decoder ( - CORBA_TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA_Environment &env -) -THROWS_NOTHING +XDR_stream::decoder (CORBA_TypeCode_ptr tc, + const void *data, + const void *, + void *context, + CORBA_Environment &env) + THROWS_NOTHING { - CORBA_Boolean continue_decoding = CORBA_B_TRUE; - XDR_stream *stream = (XDR_stream *)context; - - switch (tc->_kind) { - case tk_null: - case tk_void: - // nothing to decode! - break; + CORBA_Boolean continue_decoding = CORBA_B_TRUE; + XDR_stream *stream = (XDR_stream *)context; + + switch (tc->_kind) + { + case tk_null: + case tk_void: + // nothing to decode! + break; - case tk_char: - case tk_octet: - continue_decoding = stream->get_char (*(CORBA_Char *)data); - break; - - case tk_short: - case tk_ushort: - continue_decoding = stream->get_short (*(short *)data); - break; - - case tk_long: - case tk_ulong: - case tk_float: - continue_decoding = stream->get_long (*(CORBA_Long *)data); - break; - - case tk_longlong: - case tk_ulonglong: - case tk_double: - continue_decoding = stream->get_longlong (*(CORBA_LongLong *)data); - break; - - case tk_boolean: - continue_decoding = stream->get_boolean (*(CORBA_Boolean *)data); - break; - - case tk_enum: - { - CORBA_ULong val; - - // - // NOTE assumption that this is in-range. - // - // XXX should check this, it's rather hard to recover - // from such errors since they "do not occur" and are - // essentially never tested for. - // - continue_decoding = stream->get_ulong (val); - *(unsigned *)data = (unsigned) val; - } - break; - - case tk_any: - { - CORBA_Any *any = (CORBA_Any *)data; - CORBA_TypeCode_ptr tc2; - void *value; - - if (decoder (_tc_CORBA_TypeCode, &tc2, 0, context, env) - != CORBA_TypeCode::TRAVERSE_CONTINUE) - return CORBA_TypeCode::TRAVERSE_STOP; - - value = new CORBA_Octet [tc2->size (env)]; - - if (decoder (tc2, value, 0, context, env) - != CORBA_TypeCode::TRAVERSE_CONTINUE) { - delete value; - CORBA_release (tc2); - return CORBA_TypeCode::TRAVERSE_STOP; - } - (void) new (any) CORBA_Any (tc2, value, CORBA_B_TRUE); - } - break; - - case tk_TypeCode: - { - CORBA_ULong kind; - CORBA_TypeCode_ptr *tcp; - - continue_decoding = stream->get_ulong (kind); - if (continue_decoding == CORBA_B_FALSE) - break; - if (kind >= TC_KIND_COUNT) { - continue_decoding = CORBA_B_FALSE; - break; - } + case tk_char: + case tk_octet: + continue_decoding = stream->get_char (*(CORBA_Char *)data); + break; + + case tk_short: + case tk_ushort: + continue_decoding = stream->get_short (*(short *)data); + break; + + case tk_long: + case tk_ulong: + case tk_float: + continue_decoding = stream->get_long (*(CORBA_Long *)data); + break; + + case tk_longlong: + case tk_ulonglong: + case tk_double: + continue_decoding = stream->get_longlong (*(CORBA_LongLong *)data); + break; + + case tk_boolean: + continue_decoding = stream->get_boolean (*(CORBA_Boolean *)data); + break; + + case tk_enum: + { + CORBA_ULong val; + + // NOTE assumption that this is in-range. + // + // XXX should check this, it's rather hard to recover from + // such errors since they "do not occur" and are essentially + // never tested for. + continue_decoding = stream->get_ulong (val); + *(u_int *)data = (u_int) val; + } + break; + + case tk_any: + { + CORBA_Any *any = (CORBA_Any *)data; + CORBA_TypeCode_ptr tc2; + void *value; + + if (decoder (_tc_CORBA_TypeCode, &tc2, 0, context, env) + != CORBA_TypeCode::TRAVERSE_CONTINUE) + return CORBA_TypeCode::TRAVERSE_STOP; + + value = new CORBA_Octet [tc2->size (env)]; + + if (decoder (tc2, value, 0, context, env) + != CORBA_TypeCode::TRAVERSE_CONTINUE) + { + delete value; + CORBA_release (tc2); + return CORBA_TypeCode::TRAVERSE_STOP; + } + (void) new (any) CORBA_Any (tc2, value, CORBA_B_TRUE); + } + break; + + case tk_TypeCode: + { + CORBA_ULong kind; + CORBA_TypeCode_ptr *tcp; + + continue_decoding = stream->get_ulong (kind); + if (continue_decoding == CORBA_B_FALSE) + break; + if (kind >= TC_KIND_COUNT) + { + continue_decoding = CORBA_B_FALSE; + break; + } - tcp = (CORBA_TypeCode_ptr *)data; - - // - // Typecodes with empty parameter lists all have preallocated - // constants. We use those to reduce memory consumption and - // heap access ... also, to speed things up! - // - if (((*tcp) = __tc_consts [(unsigned) kind]) != 0) { - *tcp = __tc_consts [(unsigned) kind]; - break; - } else switch (kind) { - // - // Need special handling for all kinds of typecodes that have - // nonempty parameter lists ... - // - default: // error: missed a case! - env.exception (new CORBA_INTERNAL (COMPLETED_MAYBE)); - return CORBA_TypeCode::TRAVERSE_STOP; - - // - // Some have "simple" parameter lists ... some of these also - // have preallocated constants that could be used. - // - case tk_string: - case tk_wstring: + tcp = (CORBA_TypeCode_ptr *)data; + + // Typecodes with empty parameter lists all have preallocated + // constants. We use those to reduce memory consumption and + // heap access ... also, to speed things up! + if (((*tcp) = __tc_consts [(u_int) kind]) != 0) + { + *tcp = __tc_consts [(u_int) kind]; + break; + } + else switch (kind) + { + // Need special handling for all kinds of typecodes that + // have nonempty parameter lists ... + default: // error: missed a case! + env.exception (new CORBA_INTERNAL (COMPLETED_MAYBE)); + return CORBA_TypeCode::TRAVERSE_STOP; + + // Some have "simple" parameter lists ... some of these also + // have preallocated constants that could be used. + case tk_string: + case tk_wstring: + { + CORBA_ULong bound; + + continue_decoding = stream->get_ulong (bound); + if (continue_decoding) { - CORBA_ULong bound; - - continue_decoding = stream->get_ulong (bound); - if (continue_decoding) { - if (bound == 0) { - if (kind == tk_string) - *tcp = _tc_CORBA_String; - else - *tcp = _tc_CORBA_WString; - } else { - *tcp = new CORBA_TypeCode ((CORBA_TCKind) kind, - bound, 0, CORBA_B_TRUE); - } - } + if (bound == 0) + { + if (kind == tk_string) + *tcp = _tc_CORBA_String; + else + *tcp = _tc_CORBA_WString; + } + else + *tcp = new CORBA_TypeCode ((CORBA_TCKind) kind, + bound, 0, CORBA_B_TRUE); } - break; - - // - // Indirected typecodes, illegal at "top level" but we allow - // unmarshaling of them here because we use the same code to - // read "off the wire" (where they're illegal) and to read - // out of an encapsulation stream. We distinguish the case - // where this is legal as described above. - // - case ~0: - // XXX implement me - break; - - // - // The rest have "complex" parameter lists that are - // encoded as bulk octets ... - // - case tk_objref: - case tk_struct: - case tk_union: - case tk_enum: - case tk_sequence: - case tk_array: - case tk_alias: - case tk_except: - { - unsigned len, i; - CORBA_ULong length; - CORBA_Octet *buffer; - - continue_decoding = stream->get_ulong (length); - if (!continue_decoding) - break; - - // if length > MAXUNSIGNED, error ... - len = (unsigned) length; - - buffer = new CORBA_Octet [len]; - - for (i = 0; i < len && continue_decoding; i++) - continue_decoding = stream->get_octet (buffer [i]); - - if (!continue_decoding) - { - delete [] buffer; - break; - } - *tcp = new CORBA_TypeCode ((CORBA_TCKind)kind, - len, buffer, CORBA_B_TRUE); - } - } - } - break; - - case tk_Principal: - { - CORBA_Principal_ptr *pp = (CORBA_Principal_ptr *)data; - CORBA_ULong len; - - continue_decoding = stream->get_ulong (len); - if (len == 0) - *pp = 0; - else { - *pp = new CORBA_Principal; - (*pp)->id.buffer = new CORBA_Octet [(size_t) len]; - (*pp)->id.maximum = (*pp)->id.length = len; - - for (unsigned i = 0; - continue_decoding != CORBA_B_FALSE && i < len; - i++) - continue_decoding = stream->get_octet ( - (*pp)->id.buffer [i]); } - } - break; + break; - case tk_objref: - // XXX implement me - break; + // Indirected typecodes, illegal at "top level" but we allow + // unmarshaling of them here because we use the same code to + // read "off the wire" (where they're illegal) and to read + // out of an encapsulation stream. We distinguish the case + // where this is legal as described above. - case tk_sequence: - { - // - // First unmarshal the sequence length ... we trust it - // to be right here, on the "be gracious in what you - // accept" principle. We don't generate illegal sequences - // (i.e. length > bounds). - // - CORBA_OctetSeq *seq = (CORBA_OctetSeq *) data; - - continue_decoding = stream->get_ulong (seq->length); - seq->maximum = seq->length; - seq->buffer = 0; + case ~0: + // XXX implement me + break; - // - // Fast exit on empty sequences or errors - // - if (!continue_decoding || seq->length == 0) + // The rest have "complex" parameter lists that are + // encoded as bulk octets ... + case tk_objref: + case tk_struct: + case tk_union: + case tk_enum: + case tk_sequence: + case tk_array: + case tk_alias: + case tk_except: + { + u_int len, i; + CORBA_ULong length; + CORBA_Octet *buffer; + + continue_decoding = stream->get_ulong (length); + if (!continue_decoding) break; - // - // ... then allocate the memory into which we'll unmarshal - // - CORBA_TypeCode_ptr tc2; - size_t size; - - tc2 = tc->typecode_param (0, env); - if (env.exception ()) - return CORBA_TypeCode::TRAVERSE_STOP; - - size = tc2->size (env); - if (env.exception ()) - return CORBA_TypeCode::TRAVERSE_STOP; + // if length > MAXUNSIGNED, error ... + len = (u_int) length; - tc2->Release (); + buffer = new CORBA_Octet [len]; - seq->buffer = new CORBA_Octet [size * (size_t) seq->maximum]; - } - // FALLTHROUGH + for (i = 0; i < len && continue_decoding; i++) + continue_decoding = stream->get_octet (buffer [i]); - case tk_struct: - case tk_union: - case tk_array: - case tk_alias: - // - // Unmarshal all the individual elements using the per-member - // description held in the "parent" TypeCode. - // + if (!continue_decoding) + { + delete [] buffer; + break; + } + *tcp = new CORBA_TypeCode ((CORBA_TCKind)kind, + len, buffer, CORBA_B_TRUE); + } + } + } + break; + + case tk_Principal: + { + CORBA_Principal_ptr *pp = (CORBA_Principal_ptr *)data; + CORBA_ULong len; + + continue_decoding = stream->get_ulong (len); + if (len == 0) + *pp = 0; + else + { + *pp = new CORBA_Principal; + (*pp)->id.buffer = new CORBA_Octet [(size_t) len]; + (*pp)->id.maximum = (*pp)->id.length = len; + + for (u_int i = 0; + continue_decoding != CORBA_B_FALSE && i < len; + i++) + continue_decoding = + stream->get_octet ((*pp)->id.buffer [i]); + } + } + break; + + case tk_objref: + // XXX implement me + break; + + case tk_sequence: + { + // First unmarshal the sequence length ... we trust it to be + // right here, on the "be gracious in what you accept" + // principle. We don't generate illegal sequences + // (i.e. length > bounds). + CORBA_OctetSeq *seq = (CORBA_OctetSeq *) data; + + continue_decoding = stream->get_ulong (seq->length); + seq->maximum = seq->length; + seq->buffer = 0; + + // Fast exit on empty sequences or errors + if (!continue_decoding || seq->length == 0) + break; + + // ... then allocate the memory into which we'll unmarshal + CORBA_TypeCode_ptr tc2; + size_t size; + + tc2 = tc->typecode_param (0, env); + if (env.exception ()) + return CORBA_TypeCode::TRAVERSE_STOP; + + size = tc2->size (env); + if (env.exception ()) + return CORBA_TypeCode::TRAVERSE_STOP; + + tc2->Release (); + + seq->buffer = new CORBA_Octet [size * (size_t) seq->maximum]; + } + // FALLTHROUGH + + case tk_struct: + case tk_union: + case tk_array: + case tk_alias: + // Unmarshal all the individual elements using the per-member + // description held in the "parent" TypeCode. - // FALLTHROUGH - - case tk_except: - // - // For exceptions, the "hidden" type ID near the front of the - // on-wire representation was previously unmarshaled and mapped - // to the "tc" typcode we're using to traverse the memory ... - // at the same time its vtable, refcount, and other state was - // established. + // FALLTHROUGH + + case tk_except: + // For exceptions, the "hidden" type ID near the front of the + // on-wire representation was previously unmarshaled and mapped + // to the "tc" typcode we're using to traverse the memory ... + // at the same time its vtable, refcount, and other state was + // established. + // + // NOTE: This is asymmetric with respect to encoding exceptions. + return tc->traverse (data, 0, decoder, context, env); + + case tk_string: + { + CORBA_String str; + CORBA_ULong len = 0; + + // On decode, omit the check against specified string bounds, + // and cope with illegal "zero length" strings (all lengths on + // the wire must include a NUL). // - // NOTE: This is asymmetric with respect to encoding exceptions. - // - return tc->traverse (data, 0, decoder, context, env); - - case tk_string: - { - CORBA_String str; - CORBA_ULong len = 0; - - // - // On decode, omit the check against specified string bounds, - // and cope with illegal "zero length" strings (all lengths - // on the wire must include a NUL). - // - // This is on the principle of being gracious in what we accept; - // we don't generate messages that fail to comply with protocol - // specs, but we will accept them when it's clear how to do so. - // - continue_decoding = stream->get_ulong (len); - *((CORBA_String*)data) = str = new CORBA_Char [(size_t) (len)]; - if (len != 0) - while (continue_decoding != CORBA_B_FALSE && len-- != 0) { - continue_decoding = stream->get_char (*(CORBA_Char *)str); - str++; - } - break; - } + // This is on the principle of being gracious in what we + // accept; we don't generate messages that fail to comply with + // protocol specs, but we will accept them when it's clear how + // to do so. + + continue_decoding = stream->get_ulong (len); + *((CORBA_String*)data) = str = new CORBA_Char [(size_t) (len)]; + if (len != 0) + while (continue_decoding != CORBA_B_FALSE && len-- != 0) + { + continue_decoding = stream->get_char (*(CORBA_Char *)str); + str++; + } + break; + } - case tk_wstring: - { - wchar_t *str; - CORBA_ULong len = 0; + case tk_wstring: + { + wchar_t *str; + CORBA_ULong len = 0; - // - // On decode, omit the check against specified wstring bounds, - // and cope with illegal "zero length" strings (all lengths - // on the wire must include a NUL). - // - // This is on the principle of being gracious in what we accept; - // we don't generate messages that fail to comply with protocol - // specs, but we will accept them when it's clear how to do so. - // - continue_decoding = stream->get_ulong (len); - *((wchar_t **)data) = str = new wchar_t [(size_t) (len)]; - if (len != 0) { - while (continue_decoding != CORBA_B_FALSE && len--) { - continue_decoding = stream->get_wchar (*str); - str++; - } + // On decode, omit the check against specified wstring bounds, + // and cope with illegal "zero length" strings (all lengths on + // the wire must include a NUL). + // + // This is on the principle of being gracious in what we accept; + // we don't generate messages that fail to comply with protocol + // specs, but we will accept them when it's clear how to do so. + + continue_decoding = stream->get_ulong (len); + *((wchar_t **)data) = str = new wchar_t [(size_t) (len)]; + if (len != 0) + while (continue_decoding != CORBA_B_FALSE && len--) + { + continue_decoding = stream->get_wchar (*str); + str++; } - } - break; + } + break; - case tk_longdouble: - continue_decoding = - stream->get_longdouble (*(CORBA_LongDouble *)data); - break; + case tk_longdouble: + continue_decoding = + stream->get_longdouble (*(CORBA_LongDouble *)data); + break; - case tk_wchar: - continue_decoding = stream->get_wchar (*(wchar_t *)data); - break; + case tk_wchar: + continue_decoding = stream->get_wchar (*(wchar_t *)data); + break; // case ~0: - default: - continue_decoding = CORBA_B_FALSE; - dmsg ("decode, default case?"); - break; + default: + continue_decoding = CORBA_B_FALSE; + dmsg ("decode, default case?"); + break; } - if (continue_decoding == CORBA_B_FALSE) { - env.exception (new CORBA_MARSHAL (COMPLETED_NO)); - dmsg ("marshaling decoder detected error"); - return CORBA_TypeCode::TRAVERSE_STOP; + if (continue_decoding == CORBA_B_FALSE) + { + env.exception (new CORBA_MARSHAL (COMPLETED_NO)); + dmsg ("marshaling decoder detected error"); + return CORBA_TypeCode::TRAVERSE_STOP; } - return CORBA_TypeCode::TRAVERSE_CONTINUE; + return CORBA_TypeCode::TRAVERSE_CONTINUE; } - -// // Write an XDR message fragment out on the stream. -// + CORBA_Boolean XDR_stream::flush_frag (CORBA_Boolean /* is_last */) -THROWS_NOTHING + THROWS_NOTHING { return CORBA_B_FALSE; @@ -795,19 +760,17 @@ THROWS_NOTHING index = 0; return (status == size); -#endif +#endif /* 0 */ } - -// // Read an XDR message fragment in from the stream. -// + CORBA_Boolean -XDR_stream::read_frag () -THROWS_NOTHING +XDR_stream::read_frag (void) + THROWS_NOTHING { - // read cookie, split out size and "is last" flag - // read rest of buffer + // read cookie, split out size and "is last" flag + // read rest of buffer - return CORBA_B_FALSE; + return CORBA_B_FALSE; } |