diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-08-02 18:56:51 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-08-02 18:56:51 +0000 |
commit | 4a48d1a4c56776a8649e1ee698ca714a56fc4847 (patch) | |
tree | d61c7fc556faccf7463c5d48a7463056f80e9c8c /TAO | |
parent | 7d2578e80a7f623b02042c0512835741296268cb (diff) | |
download | ATCD-4a48d1a4c56776a8649e1ee698ca714a56fc4847.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/tests/Cubit/TAO/clnt.cpp | 649 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/cubitC.cpp | 438 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/cubitS.cpp | 216 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/cubit_i.cpp | 21 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/cubit_i.h | 38 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/method_db.i | 10 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/svr.cpp | 249 |
7 files changed, 787 insertions, 834 deletions
diff --git a/TAO/tests/Cubit/TAO/clnt.cpp b/TAO/tests/Cubit/TAO/clnt.cpp index 1d5146d6c34..894effeef5b 100644 --- a/TAO/tests/Cubit/TAO/clnt.cpp +++ b/TAO/tests/Cubit/TAO/clnt.cpp @@ -1,126 +1,245 @@ -// @(#)clnt.cpp 1.2 05/14/97 -// Copyright 1994-1995 by Sun Microsystems Inc. -// All Rights Reserved +// @ (#)clnt.cpp 1.2 05/14/97 Copyright 1994-1995 by Sun Microsystems +// Inc. All Rights Reserved // // TEST: Simple "cube" client, calling hand-crafted stubs. // // Modified version of Cubit Example written by Sun Microsystems Inc. // Modified by: Brian Mendel -#include <ace/Get_Opt.h> -//#include <crtdbg.h> - -#if unix -# include <unistd.h> -# include <sys/time.h> - -#elif defined (VXWORKS) -# include <unistd.h> -# include <time.h> - -#else // windows - -#endif // unix - -#include "cubitC.h" - +#include "ace/Get_Opt.h" #include "tao/corba.h" - -#if !defined (_WIN32) -extern char *optarg; // missing on some platforms -#endif +#include "cubitC.h" inline int func (unsigned i) { return i - 117; } extern void print_exception (const CORBA_Exception *, const char *, FILE *f=stdout); - -// -// forward declarations -// -static void cube_union_stub(unsigned, unsigned&, unsigned&, - CORBA_Object_ptr, CORBA_Environment &); - -static void cube_union_dii(unsigned &, unsigned &, - CORBA_Object_ptr, CORBA_Environment &); - // Global variables -const char* TAO_arg_ior = 0; -unsigned loop_count = 1; -int exit_later = 0; +static const char *TAO_arg_ior = 0; +static u_int loop_count = 1; +static int exit_later = 0; -// = TITLE -// Parses the command line arguments and returns an error status -// -// = DESCRIPTION -// This method parses the command line arguments -int parse_args(int argc, char *argv[]) +// Parses the command line arguments and returns an error status + +static int +parse_args (int argc, char *argv[]) { - ACE_Get_Opt opts (argc, argv, "dn:O:x"); - int c; + ACE_Get_Opt opts (argc, argv, "dn:O:x"); + int c; - while ((c = opts ()) != -1) - switch (c) { - + while ((c = opts ()) != -1) + switch (c) + { case 'd': // debug flag - TAO_debug_level++; - continue; + TAO_debug_level++; + continue; case 'n': // loop count - loop_count = (unsigned) ACE_OS::atoi (opts.optarg); - continue; + loop_count = (u_int) ACE_OS::atoi (opts.optarg); + continue; case 'O': // stringified objref - { - TAO_arg_ior = ACE_OS::strdup(opts.optarg); - } - continue; + { + TAO_arg_ior = ACE_OS::strdup (opts.optarg); + } + continue; case 'x': - exit_later++; - continue; + exit_later++; + continue; case '?': default: - ACE_OS::fprintf (stderr, "usage: %s" - " [-d]" - " [-n loopcount]" - " [-O objref]" - " [-x]" - "\n", argv [0] - ); - return 1; + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-n loopcount]" + " [-O objref]" + " [-x]" + "\n", argv [0] + ), 1); } - return 0; // Indicates successful parsing of command line + return 0; // Indicates successful parsing of command line +} + +static void +cube_union_stub (u_int i, + u_int &call_count, + u_int &error_count, + CORBA_Object_ptr objref, + CORBA_Environment &env) +{ + Cubit_ptr cubit = Cubit::_narrow (objref); + + Cubit_oneof u, *r; + + call_count++; + + u._disc = e_2nd; + u.l = 3; + + // Cube a "union" ... + r = cubit->Cubit_cube_union (u, env); + + if (env.exception () != 0) + { + print_exception (env.exception (), "from cube_union"); + error_count++; + } + else + { + dmsg ("cube union ..."); + u.l = u.l * u.l * u.l ; + + if (u.l != r->l) + { + ACE_DEBUG ((LM_DEBUG, "** cube_union ERROR\n")); + error_count++; + } + + delete r; + } + + call_count++; + + u._disc = e_5th; + u.cm.l = func (i); + u.cm.s = func (i); + u.cm.o = func (i); + + u.cm.l = 7; + u.cm.s = 5; + u.cm.o = 3; + + // Cube another "union" which uses the default arm ... + r = cubit->Cubit_cube_union (u, env); + + if (env.exception () != 0) + { + print_exception (env.exception (), "from cube_union"); + error_count++; + } + else + { + dmsg ("cube union ..."); + u.cm.l = u.cm.l * u.cm.l * u.cm.l; + u.cm.s = u.cm.s * u.cm.s * u.cm.s; + u.cm.o = u.cm.o * u.cm.o * u.cm.o; + + if (u.cm.l != r->cm.l + || u.cm.s != r->cm.s + || u.cm.o != r->cm.o) + { + ACE_DEBUG ((LM_DEBUG, "** cube_union ERROR\n")); + error_count++; + } + + delete r; + } +} + +static void +cube_union_dii (u_int &call_count, + u_int &error_count, + CORBA_Object_ptr objref, + CORBA_Environment &env) +{ + // Create the request ... + CORBA_Request_ptr req; + + call_count++; + + req = objref->_request ((const CORBA_String) "cube_union", env); + + if (env.exception () != 0) + { + error_count++; + + print_exception (env.exception (), "cube_union_dii request create"); + return; + } + + // ... initialise the argument list and result ... + Cubit_oneof u, *r; + + u._disc = e_3rd; + u.cm.l = 5; + u.cm.s = -7; + u.cm.o = 3; + + CORBA_Any tmp_arg (TC_Cubit_oneof, &u, CORBA_B_FALSE); + + req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env); + + if (env.exception () != 0) + { + error_count++; + print_exception (env.exception (), "cube_union_dii request arg add"); + CORBA_release (req); + return; + } + + req->result ()->value ()->replace (TC_Cubit_oneof, 0, CORBA_B_TRUE, env); + + if (env.exception () != 0) + { + error_count++; + print_exception (env.exception (), "cube_union_dii result type"); + CORBA_release (req); + return; + } + + // Make the invocation, verify the result + + req->invoke (); + if (req->env ()->exception () != 0) + { + error_count++; + print_exception (req->env ()->exception (),"cube_union_dii invoke"); + CORBA_release (req); + return; + } + + r = (Cubit_oneof *) req->result ()->value ()->value (); + + if (r->cm.o != 27 || r->cm.l != 125 || r->cm.s != -343) + { + error_count++; + ACE_ERROR ((LM_ERROR, "cube_union_dii -- bad results\n")); + } + else + dmsg ("cube_union_dii ... success!!"); + + CORBA_release (req); } int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { - CORBA_ORB_ptr orb_ptr; - CORBA_Object_ptr objref = CORBA_Object::_nil(); + CORBA_Object_ptr objref = CORBA_Object::_nil (); CORBA_Environment env; - orb_ptr = CORBA_ORB_init(argc, argv, "internet", env); - if (env.exception() != 0) + CORBA_ORB_ptr orb_ptr = CORBA_ORB_init (argc, argv, "internet", env); + if (env.exception () != 0) { - print_exception(env.exception(), "ORB initialization"); + print_exception (env.exception (), "ORB initialization"); return 1; } - // // Parse command line and verify parameters. - // - parse_args(argc, argv); + parse_args (argc, argv); if (TAO_arg_ior == 0) - ACE_ERROR_RETURN((LM_ERROR, "%s: must specify an object reference using -O <ior>\n", argv[0]), 1); + ACE_ERROR_RETURN ((LM_ERROR, + "%s: must specify an object reference using -O <ior>\n", + argv[0]), + 1); - objref = orb_ptr->string_to_object ((CORBA_String)TAO_arg_ior, env); + objref = orb_ptr->string_to_object ((CORBA_String) TAO_arg_ior, env); - ACE_OS::free((void*)TAO_arg_ior); + ACE_OS::free ((void *) TAO_arg_ior); TAO_arg_ior = 0; if (env.exception () != 0) @@ -130,36 +249,43 @@ main (int argc, char *argv[]) } if (CORBA_is_nil (objref) == CORBA_B_TRUE) - ACE_ERROR_RETURN((LM_ERROR, "%s: must identify non-null target objref\n", argv [0]), 1); + ACE_ERROR_RETURN ((LM_ERROR, + "%s: must identify non-null target objref\n", + argv [0]), + 1); // Narrow the CORBA_Object reference to the stub object, checking // the type along the way using _is_a - Cubit_ptr aCubit = Cubit::_narrow(objref); - if (aCubit == 0) - ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to narrow object reference to a Cubit_ptr.\n"), 1); + Cubit_ptr cubit = Cubit::_narrow (objref); + + if (cubit == 0) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to narrow object reference to a Cubit_ptr.\n"), + 1); - // // Make the calls in a loop. - // - unsigned i; - unsigned call_count, error_count; + + u_int i; + u_int call_count, error_count; call_count = 0; error_count = 0; - ACE_Time_Value before, after; + ACE_Time_Value before; + ACE_Time_Value after; - before = ACE_OS::gettimeofday(); + before = ACE_OS::gettimeofday (); for (i = 0; i < loop_count; i++) { - // - // Cube an octet. - // - CORBA_Octet arg_octet, ret_octet; + CORBA_Octet arg_octet; + CORBA_Octet ret_octet; call_count++; - ret_octet = aCubit->Cubit_cube_octet (arg_octet = func (i), env); + + // Cube an octet. + ret_octet = cubit->Cubit_cube_octet (arg_octet = func (i), env); + if (env.exception () != 0) { print_exception (env.exception (), "from cube_octet"); @@ -170,43 +296,50 @@ main (int argc, char *argv[]) dmsg2 ("cube octet: %d --> %d\n", arg_octet, ret_octet); arg_octet = arg_octet * arg_octet * arg_octet; if (arg_octet != ret_octet) { - ACE_OS::printf ("** cube_octet(%d) ERROR (--> %d)\n", - (CORBA_Octet) func (i), ret_octet); + ACE_DEBUG ((LM_DEBUG, + "** cube_octet (%d) ERROR (--> %d)\n", + (CORBA_Octet) func (i), + ret_octet)); error_count++; } } - // - // Cube a short. - // - CORBA_Short arg_short, ret_short; + CORBA_Short arg_short, ret_short; call_count++; - ret_short = aCubit->Cubit_cube_short (arg_short = func (i), env); + + // Cube a short. + ret_short = cubit->Cubit_cube_short (arg_short = func (i), env); + if (env.exception () != 0) { - print_exception (env.exception (), "from cube_short"); + print_exception (env.exception (), + "from cube_short"); error_count++; } else { - dmsg2 ("cube short: %d --> %d\n", arg_short, ret_short); + dmsg2 ("cube short: %d --> %d\n", + arg_short, + ret_short); arg_short = arg_short * arg_short * arg_short; + if (arg_short != ret_short) { - ACE_OS::printf ("** cube_short(%d) ERROR (--> %d)\n", - (CORBA_Short) func (i), ret_short); + ACE_ERROR ((LM_ERROR, "** cube_short (%d) ERROR (--> %d)\n", + (CORBA_Short) func (i), + ret_short)); error_count++; } } - // - // Cube a long. - // - CORBA_Long arg_long, ret_long; + CORBA_Long arg_long, ret_long; call_count++; - ret_long = aCubit->Cubit_cube_long (arg_long = func (i), env); + + // Cube a long. + ret_long = cubit->Cubit_cube_long (arg_long = func (i), env); + if (env.exception () != 0) { print_exception (env.exception (), "from cube_long"); @@ -217,16 +350,15 @@ main (int argc, char *argv[]) dmsg2 ("cube long: %d --> %d\n", arg_long, ret_long); arg_long = arg_long * arg_long * arg_long; if (arg_long != ret_long) { - ACE_OS::printf ("** cube_long(%ld) ERROR (--> %ld)\n", - (CORBA_Long) func (i), ret_long); + ACE_ERROR ((LM_ERROR, + "** cube_long (%ld) ERROR (--> %ld)\n", + (CORBA_Long) func (i), + ret_long)); error_count++; } } - // - // Cube a "struct" ... - // - Cubit_Many arg_struct, *ret_struct; + Cubit_Many arg_struct, *ret_struct; call_count++; @@ -234,7 +366,9 @@ main (int argc, char *argv[]) arg_struct.s = func (i); arg_struct.o = func (i); - ret_struct = aCubit->Cubit_cube_struct (arg_struct, env); + // Cube a "struct" ... + ret_struct = cubit->Cubit_cube_struct (arg_struct, env); + if (env.exception () != 0) { print_exception (env.exception (), "from cube_struct"); @@ -251,257 +385,120 @@ main (int argc, char *argv[]) || arg_struct.s != ret_struct->s || arg_struct.o != ret_struct->o) { - ACE_OS::printf ("** cube_struct ERROR\n"); + ACE_ERROR ((LM_ERROR, "** cube_struct ERROR\n")); error_count++; } + delete ret_struct; } } - after = ACE_OS::gettimeofday(); + after = ACE_OS::gettimeofday (); if (call_count > 0) { if (error_count == 0) { ACE_Time_Value diff = after - before; - unsigned long us = diff.sec() * 1000 * 1000 + diff.usec(); + u_int long us = diff.sec () * 1000 * 1000 + diff.usec (); us /= call_count; if (us > 0) - ACE_OS::printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t" - "%ld calls/second\n", - us / 1000, us % 1000, - 1000000L / us); + ACE_DEBUG ((LM_DEBUG, + "cube average call ACE_OS::time\t= %ld.%.03ldms, \t" + "%ld calls/second\n", + us / 1000, us % 1000, + 1000000L / us)); } - ACE_OS::printf ("%d calls, %d errors\n", call_count, error_count); + ACE_DEBUG ((LM_DEBUG, "%d calls, %d errors\n", call_count, error_count)); } - // - // Simple test for DII: call "cube_struct". (It's not timed - // since the copious mallocation of DII would bias numbers against - // typical stub-based calls.) - // - do { - // - // Create the request ... - // - CORBA_Request_ptr req; - - req = objref->_request ((const CORBA_String) "cube_struct", env); - if (env.exception () != 0) { - print_exception (env.exception (), "DII request create"); - break; - } + // Simple test for DII: call "cube_struct". (It's not timed since + // the copious mallocation of DII would bias numbers against typical + // stub-based calls.) + do + { + // Create the request ... + + CORBA_Request_ptr req = + objref->_request ((const CORBA_String) "cube_struct", env); - // - // ... initialise the argument list and result ... - // - Cubit_Many arg, *result; + if (env.exception () != 0) + { + print_exception (env.exception (), "DII request create"); + break; + } + + // ... initialise the argument list and result ... + Cubit_Many arg, *result; - arg.o = 3; arg.l = 5; arg.s = -7; + arg.o = 3; arg.l = 5; arg.s = -7; - CORBA_Any tmp_arg (TC_Cubit_Many, &arg, CORBA_B_FALSE); + CORBA_Any tmp_arg (TC_Cubit_Many, &arg, CORBA_B_FALSE); - req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env); - if (env.exception () != 0) { - print_exception (env.exception (), "DII request arg add"); - CORBA_release (req); - break; - } + req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env); + + if (env.exception () != 0) + { + print_exception (env.exception (), "DII request arg add"); + CORBA_release (req); + break; + } - req->result ()->value () - ->replace (TC_Cubit_Many, 0, CORBA_B_TRUE, env); - if (env.exception () != 0) { - print_exception (env.exception (), "DII request result type"); - CORBA_release (req); - break; - } + req->result ()->value ()->replace (TC_Cubit_Many, 0, CORBA_B_TRUE, env); - // - // Make the invocation, verify the result - // - req->invoke (); - if (req->env ()->exception () != 0) { - print_exception (req->env ()->exception (), "DII invoke"); - CORBA_release (req); - break; - } + if (env.exception () != 0) + { + print_exception (env.exception (), "DII request result type"); + CORBA_release (req); + break; + } + + // Make the invocation, verify the result + + req->invoke (); + + if (req->env ()->exception () != 0) + { + print_exception (req->env ()->exception (), "DII invoke"); + CORBA_release (req); + break; + } - result = (Cubit_Many *) req->result ()->value ()->value (); + result = (Cubit_Many *) req->result ()->value ()->value (); - if (result->o != 27 || result->l != 125 || result->s != -343) - ACE_OS::fprintf (stderr, "DII cube_struct -- bad results\n"); - else - dmsg ("DII cube_struct ... success!!"); + if (result->o != 27 || result->l != 125 || result->s != -343) + ACE_ERROR ((LM_ERROR, "DII cube_struct -- bad results\n")); + else + dmsg ("DII cube_struct ... success!!"); - CORBA_release (req); + CORBA_release (req); - } while (0); + } while (0); - // // Two more tests, using the "cube_union" function - // - cube_union_dii(call_count, error_count, objref, env); + + cube_union_dii (call_count, error_count, objref, env); + if (env.exception () != 0) error_count++; - cube_union_stub(i, call_count, error_count, objref, env); + cube_union_stub (i, call_count, error_count, objref, env); + if (env.exception () != 0) error_count++; - if (exit_later) { - aCubit->Cubit_please_exit (env); - dexc (env, "server, please ACE_OS::exit"); - } + if (exit_later) + { + cubit->Cubit_please_exit (env); + dexc (env, "server, please ACE_OS::exit"); + } CORBA_release (objref); return (error_count == 0) ? 0 : 1; } - -static void -cube_union_stub(unsigned i, - unsigned &call_count, - unsigned &error_count, - CORBA_Object_ptr objref, - CORBA_Environment &env) -{ - Cubit_ptr aCubit = Cubit::_narrow(objref); - // - // Cube a "union" ... - // - Cubit_oneof u, *r; - - call_count++; - - u._disc = e_2nd; - u.l = 3; - - r = aCubit->Cubit_cube_union (u, env); - if (env.exception () != 0) { - print_exception (env.exception (), "from cube_union"); - error_count++; - } else { - dmsg ("cube union ..."); - u.l = u.l * u.l * u.l ; - - if (u.l != r->l) { - ACE_OS::printf ("** cube_union ERROR\n"); - error_count++; - } - - delete r; - } - - // - // Cube another "union" which uses the default arm ... - // - call_count++; - - u._disc = e_5th; - u.cm.l = func (i); - u.cm.s = func (i); - u.cm.o = func (i); - - u.cm.l = 7; - u.cm.s = 5; - u.cm.o = 3; - - r = aCubit->Cubit_cube_union (u, env); - if (env.exception () != 0) { - print_exception (env.exception (), "from cube_union"); - error_count++; - } else { - dmsg ("cube union ..."); - u.cm.l = u.cm.l * u.cm.l * u.cm.l; - u.cm.s = u.cm.s * u.cm.s * u.cm.s; - u.cm.o = u.cm.o * u.cm.o * u.cm.o; - - if (u.cm.l != r->cm.l - || u.cm.s != r->cm.s - || u.cm.o != r->cm.o) { - ACE_OS::printf ("** cube_union ERROR\n"); - error_count++; - } - - delete r; - } -} - - -static void -cube_union_dii (unsigned &call_count, - unsigned &error_count, - CORBA_Object_ptr objref, - CORBA_Environment &env) -{ - // - // Create the request ... - // - CORBA_Request_ptr req; - - call_count++; - - req = objref->_request ((const CORBA_String) "cube_union", env); - if (env.exception () != 0) { - error_count++; - - print_exception (env.exception (), "cube_union_dii request create"); - return; - } - - // - // ... initialise the argument list and result ... - // - Cubit_oneof u, *r; - - u._disc = e_3rd; - u.cm.l = 5; - u.cm.s = -7; - u.cm.o = 3; - - CORBA_Any tmp_arg (TC_Cubit_oneof, &u, CORBA_B_FALSE); - - req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env); - if (env.exception () != 0) { - error_count++; - print_exception (env.exception (), "cube_union_dii request arg add"); - CORBA_release (req); - return; - } - - req->result ()->value ()->replace (TC_Cubit_oneof, 0, CORBA_B_TRUE, env); - if (env.exception () != 0) { - error_count++; - print_exception (env.exception (), "cube_union_dii result type"); - CORBA_release (req); - return; - } - - // - // Make the invocation, verify the result - // - req->invoke (); - if (req->env ()->exception () != 0) { - error_count++; - print_exception (req->env ()->exception (),"cube_union_dii invoke"); - CORBA_release (req); - return; - } - - r = (Cubit_oneof *) req->result ()->value ()->value (); - - if (r->cm.o != 27 || r->cm.l != 125 || r->cm.s != -343) { - error_count++; - ACE_OS::fprintf (stderr, "cube_union_dii -- bad results\n"); - } - else - dmsg ("cube_union_dii ... success!!"); - - CORBA_release (req); -} diff --git a/TAO/tests/Cubit/TAO/cubitC.cpp b/TAO/tests/Cubit/TAO/cubitC.cpp index bc71b30b094..16c26a2bc0a 100644 --- a/TAO/tests/Cubit/TAO/cubitC.cpp +++ b/TAO/tests/Cubit/TAO/cubitC.cpp @@ -1,4 +1,4 @@ -// @(#)cubitC.cpp 05/14/97 +// @ (#)cubitC.cpp 05/14/97 // Copyright 1994-1995 by Sun Microsystems Inc. // All Rights Reserved // @@ -7,388 +7,378 @@ #include "cubitC.h" // for stubs ... -Cubit_ptr Cubit::_duplicate(Cubit_ptr obj) +Cubit_ptr Cubit::_duplicate (Cubit_ptr obj) { - if (obj) - obj->AddRef(); + if (obj) + obj->AddRef (); - return obj; + return obj; } -Cubit_ptr Cubit::_narrow(CORBA_Object_ptr obj) +Cubit_ptr Cubit::_narrow (CORBA_Object_ptr obj) { CORBA_Environment env; - if (obj->_is_a("IDL:Cubit:1.0", env)) + if (obj->_is_a ("IDL:Cubit:1.0", env)) { - obj->Release(); // Release the reference grabbed by _is_a() + obj->Release (); // Release the reference grabbed by _is_a () STUB_Object *istub; - if (obj->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR) - { - return Cubit::_nil(); - } - obj->Release(); - Cubit_ptr new_obj = new Cubit(istub); - return Cubit::_duplicate(new_obj); + + if (obj->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR) + return Cubit::_nil (); + + obj->Release (); + Cubit_ptr new_obj = new Cubit (istub); + return Cubit::_duplicate (new_obj); } else - { - // Do we need to do an obj->Release() here if _is_a() failed? - } - return Cubit::_nil(); + ;// Do we need to do an obj->Release () here if _is_a () failed? + + return Cubit::_nil (); } -Cubit_ptr Cubit::_nil() +Cubit_ptr Cubit::_nil (void) { - return (Cubit_ptr)NULL; + return (Cubit_ptr)NULL; } -// // CUBE OCTET -// static const TAO_Param_Data Cubit_cube_octet_params [] = { - { _tc_CORBA_Octet, PARAM_RETURN, 0 }, - { _tc_CORBA_Octet, PARAM_IN, 0 } + { _tc_CORBA_Octet, PARAM_RETURN, 0 }, + { _tc_CORBA_Octet, PARAM_IN, 0 } }; - static const TAO_Call_Data Cubit_cube_octet_calldata = { - "cube_octet", CORBA_B_TRUE, - 2, &Cubit_cube_octet_params [0], - 0, 0 + "cube_octet", CORBA_B_TRUE, + 2, &Cubit_cube_octet_params [0], + 0, 0 }; - CORBA_Octet -Cubit::Cubit_cube_octet (CORBA_Octet o, - CORBA_Environment &env) +Cubit::Cubit_cube_octet (CORBA_Octet o, + CORBA_Environment &env) { - CORBA_Octet retval; + CORBA_Octet retval; - STUB_Object *istub; - if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR) - { - env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO)); + STUB_Object *istub; + + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR) + { + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); return 0; - } - this->Release(); + } + + this->Release (); - istub->do_call (env, &Cubit_cube_octet_calldata, - &retval, &o); - istub->Release (); + istub->do_call (env, &Cubit_cube_octet_calldata, + &retval, &o); + istub->Release (); - return retval; + return retval; } - -// // CUBE SHORT -// static const TAO_Param_Data Cubit_cube_short_params [] = { - { _tc_CORBA_Short, PARAM_RETURN, 0 }, - { _tc_CORBA_Short, PARAM_IN, 0 } + { _tc_CORBA_Short, PARAM_RETURN, 0 }, + { _tc_CORBA_Short, PARAM_IN, 0 } }; static const TAO_Call_Data Cubit_cube_short_calldata = { - "cube_short", CORBA_B_TRUE, - 2, &Cubit_cube_short_params [0], - 0, 0 + "cube_short", CORBA_B_TRUE, + 2, &Cubit_cube_short_params [0], + 0, 0 }; CORBA_Short -Cubit::Cubit_cube_short (CORBA_Short s, - CORBA_Environment &env) +Cubit::Cubit_cube_short (CORBA_Short s, + CORBA_Environment &env) { - CORBA_Short retval; + CORBA_Short retval; - STUB_Object *istub; - if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR) - { - env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO)); + STUB_Object *istub; + + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR) + { + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); return 0; - } - this->Release(); + } + + this->Release (); - istub->do_call(env, &Cubit_cube_short_calldata, + istub->do_call (env, &Cubit_cube_short_calldata, &retval, &s); - istub->Release (); + istub->Release (); - return retval; + return retval; } -// // CUBE LONG -// static const TAO_Param_Data Cubit_cube_long_params [] = { - { _tc_CORBA_Long, PARAM_RETURN, 0 }, - { _tc_CORBA_Long, PARAM_IN, 0 } + { _tc_CORBA_Long, PARAM_RETURN, 0 }, + { _tc_CORBA_Long, PARAM_IN, 0 } }; static const TAO_Call_Data Cubit_cube_long_calldata = { - "cube_long", CORBA_B_TRUE, - 2, &Cubit_cube_long_params [0], - 0, 0 + "cube_long", CORBA_B_TRUE, + 2, &Cubit_cube_long_params [0], + 0, 0 }; - CORBA_Long -Cubit::Cubit_cube_long (CORBA_Long l, - CORBA_Environment &env) +Cubit::Cubit_cube_long (CORBA_Long l, + CORBA_Environment &env) { - CORBA_Long retval; + CORBA_Long retval; - STUB_Object *istub; - if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR) - { - env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO)); + STUB_Object *istub; + + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR) + { + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); return 0; - } - this->Release(); + } + + this->Release (); - istub->do_call (env, &Cubit_cube_long_calldata, + istub->do_call (env, &Cubit_cube_long_calldata, &retval, &l); - istub->Release (); + istub->Release (); - return retval; + return retval; } - -// -// Encapsulated parameters for struct "Cubit_Many" typecode. -// None of these parameters is complicated, so this is just -// a linear sequence of element encodings +// Encapsulated parameters for struct "Cubit_Many" typecode. None of +// these parameters is complicated, so this is just a linear sequence +// of element encodings // // NOTE: it's important that this be longword aligned!! -// + static const CORBA_Long _oc_Cubit_Many [] = { - 1, // byte order flag (TRICKY!) + 1, // byte order flag (TRICKY!) - 1, 0, // empty string: repository/type ID - 1, 0, // empty string: struct name + 1, 0, // empty string: repository/type ID + 1, 0, // empty string: struct name - 3, // three struct elements + 3, // three struct elements - // First structure element: name, typecode for Octet - 1, 0, // empty string: name "o" - tk_octet, + // First structure element: name, typecode for Octet + 1, 0, // empty string: name "o" + tk_octet, - // Second structure element: name, typecode for Long - 1, 0, // empty string: name "l" - tk_long, + // Second structure element: name, typecode for Long + 1, 0, // empty string: name "l" + tk_long, - // Third structure element: name, typecode for Short - 1, 0, // empty string: name "s" - tk_short, + // Third structure element: name, typecode for Short + 1, 0, // empty string: name "s" + tk_short, }; static CORBA_TypeCode _tc_Cubit_Many (tk_struct, - sizeof _oc_Cubit_Many, (unsigned char *) &_oc_Cubit_Many, + sizeof _oc_Cubit_Many, + (u_char *) &_oc_Cubit_Many, CORBA_B_FALSE); CORBA_TypeCode_ptr TC_Cubit_Many = &_tc_Cubit_Many; - -// // CUBE STRUCT -// static const TAO_Param_Data Cubit_cube_struct_params [] = { - { &_tc_Cubit_Many, PARAM_RETURN, sizeof (Cubit_Many) }, - { &_tc_Cubit_Many, PARAM_IN, 0 } + { &_tc_Cubit_Many, PARAM_RETURN, sizeof (Cubit_Many) }, + { &_tc_Cubit_Many, PARAM_IN, 0 } }; static const TAO_Call_Data Cubit_cube_struct_calldata = { - "cube_struct", CORBA_B_TRUE, - 2, &Cubit_cube_struct_params [0], - 0, 0 + "cube_struct", CORBA_B_TRUE, + 2, &Cubit_cube_struct_params [0], + 0, 0 }; Cubit_Many* Cubit::Cubit_cube_struct (Cubit_Many &values, CORBA_Environment &env) { - Cubit_Many *retval; + Cubit_Many *retval; + + STUB_Object *istub; - STUB_Object *istub; - if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR) - { - env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO)); + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR) + { + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); return 0; - } - this->Release(); + } + + this->Release (); - istub->do_call (env, &Cubit_cube_struct_calldata, - &retval, &values); - istub->Release (); + istub->do_call (env, &Cubit_cube_struct_calldata, + &retval, &values); + istub->Release (); - return retval; + return retval; } - -// // CUBE UNION -// +// NOTE: not all union typecodes can be encoded as an array of "long +// "values, but this one can. Ones with discriminants that are one or +// two bytes long can't easily be coded portably. // -// NOTE: not all union typecodes can be encoded as an array -// of "long "values, but this one can. Ones with discriminants -// that are one or two bytes long can't easily be coded portably. -// -// The benefit of doing it as an array of "long" values is -// twofold: (a) easier to read; (b) on most systems it's then -// adequately aligned for the typecode interpreter to use, so -// no additional runtime copy needs to be made. -// +// The benefit of doing it as an array of "long" values is twofold: +// (a) easier to read; (b) on most systems it's then adequately +// aligned for the typecode interpreter to use, so no additional +// runtime copy needs to be made. + static const CORBA_Long _oc_Cubit_oneof [] = { - 1, // byte order flag (TRICKY) - 1, 0, // omitted repository/type ID - 1, 0, // omitted struct name, "oneof" + 1, // byte order flag (TRICKY) + 1, 0, // omitted repository/type ID + 1, 0, // omitted struct name, "oneof" - // - // discriminant typecode: - // - tk_enum, // tk_enum - 72, // encapsulation length + // + // discriminant typecode: + // + tk_enum, // tk_enum + 72, // encapsulation length - 1, // byte order flag (TRICKY) - 1, 0, // omitted repository/type ID - 1, 0, // omitted enum name, "discrim" - 6, // 5 elements in the enum + 1, // byte order flag (TRICKY) + 1, 0, // omitted repository/type ID + 1, 0, // omitted enum name, "discrim" + 6, // 5 elements in the enum - 1, 0, // omitted member name, "e_0th" - 1, 0, // omitted member name, "e_1st" - 1, 0, // omitted member name, "e_2nd" - 1, 0, // omitted member name, "e_3rd" - 1, 0, // omitted member name, "e_4th" - 1, 0, // omitted member name, "e_5th" + 1, 0, // omitted member name, "e_0th" + 1, 0, // omitted member name, "e_1st" + 1, 0, // omitted member name, "e_2nd" + 1, 0, // omitted member name, "e_3rd" + 1, 0, // omitted member name, "e_4th" + 1, 0, // omitted member name, "e_5th" - 4, // default member index (zero based) - 5, // number of union members + 4, // default member index (zero based) + 5, // number of union members - // the 1st union branch arm - e_0th, // member label value - 1, 0, // omitted member name, "o" - tk_octet, // member typecode + // the 1st union branch arm + e_0th, // member label value + 1, 0, // omitted member name, "o" + tk_octet, // member typecode - // the 2nd union branch arm - e_1st, // member label value - 1, 0, // omitted member name, "s" - tk_short, // member typecode + // the 2nd union branch arm + e_1st, // member label value + 1, 0, // omitted member name, "s" + tk_short, // member typecode - // the 3rd union branch arm - e_2nd, // member label value - 1, 0, // omitted member name, "l" - tk_long, // member typecode + // the 3rd union branch arm + e_2nd, // member label value + 1, 0, // omitted member name, "l" + tk_long, // member typecode - // the 4th union branch arm - e_3rd, // member label value - 1, 0, // omitted member name, "cm" + // the 4th union branch arm + e_3rd, // member label value + 1, 0, // omitted member name, "cm" - // the 4th union member typecode - tk_struct, // tk_struct - 60, // encap length + // the 4th union member typecode + tk_struct, // tk_struct + 60, // encap length - 1, // byte order flag (TRICKY) - 1, 0, // omitted repository/type ID - 1, 0, // omitted struct name, "Many" - 3, // three struct members + 1, // byte order flag (TRICKY) + 1, 0, // omitted repository/type ID + 1, 0, // omitted struct name, "Many" + 3, // three struct members - // First structure element - 1, 0, // omitted member name, "o" - tk_octet, // member type, tk_octet + // First structure element + 1, 0, // omitted member name, "o" + tk_octet, // member type, tk_octet - // Second structure element - 1, 0, // omitted member name, "l" - tk_long, // member type, tk_long + // Second structure element + 1, 0, // omitted member name, "l" + tk_long, // member type, tk_long - // Third structure element - 1, 0, // omitted member name, "s" - tk_short, // member type, tk_short + // Third structure element + 1, 0, // omitted member name, "s" + tk_short, // member type, tk_short - // the 5th union branch arm - 4, // the 5th member label value - 1, 0, // omitted member name, "cm" - ~0, // indirected typecode (~0) - -88 // offset to struct "Many" typecode + // the 5th union branch arm + 4, // the 5th member label value + 1, 0, // omitted member name, "cm" + ~0, // indirected typecode (~0) + -88 // offset to struct "Many" typecode }; static CORBA_TypeCode _tc_Cubit_oneof (tk_union, - (sizeof _oc_Cubit_oneof), (unsigned char *) &_oc_Cubit_oneof, + (sizeof _oc_Cubit_oneof), + (u_char *) &_oc_Cubit_oneof, CORBA_B_FALSE); CORBA_TypeCode_ptr TC_Cubit_oneof = &_tc_Cubit_oneof; static const TAO_Param_Data Cubit_cube_union_params [] = { - { &_tc_Cubit_oneof, PARAM_RETURN, sizeof (Cubit_oneof) }, - { &_tc_Cubit_oneof, PARAM_IN, 0 } + { &_tc_Cubit_oneof, PARAM_RETURN, sizeof (Cubit_oneof) }, + { &_tc_Cubit_oneof, PARAM_IN, 0 } }; static const TAO_Call_Data Cubit_cube_union_calldata = { - "cube_union", CORBA_B_TRUE, - 2, &Cubit_cube_union_params [0], - 0, 0 + "cube_union", CORBA_B_TRUE, + 2, &Cubit_cube_union_params [0], + 0, 0 }; Cubit_oneof* -Cubit::Cubit_cube_union (Cubit_oneof &values, - CORBA_Environment &env) +Cubit::Cubit_cube_union (Cubit_oneof &values, + CORBA_Environment &env) { - Cubit_oneof *retval; + Cubit_oneof *retval; - STUB_Object *istub; - if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR) - { - env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO)); + STUB_Object *istub; + + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR) + { + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); return 0; - } - this->Release(); + } + + this->Release (); - istub->do_call (env, &Cubit_cube_union_calldata, + istub->do_call (env, &Cubit_cube_union_calldata, &retval, &values); - istub->Release (); + istub->Release (); - return retval; + return retval; } - - -// // PLEASE EXIT -// static const TAO_Call_Data Cubit_please_exit_calldata = { - "please_exit", CORBA_B_FALSE, - 0, 0, - 0, 0 + "please_exit", CORBA_B_FALSE, + 0, 0, + 0, 0 }; void -Cubit::Cubit_please_exit (CORBA_Environment &env) +Cubit::Cubit_please_exit (CORBA_Environment &env) { - STUB_Object *istub; - if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR) - { - env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO)); + STUB_Object *istub; + + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR) + { + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); return; - } - this->Release(); + } + + this->Release (); - istub->do_call (env, &Cubit_please_exit_calldata); - istub->Release (); + istub->do_call (env, &Cubit_please_exit_calldata); + istub->Release (); } diff --git a/TAO/tests/Cubit/TAO/cubitS.cpp b/TAO/tests/Cubit/TAO/cubitS.cpp index 9726c6ac34d..c7141ff8c30 100644 --- a/TAO/tests/Cubit/TAO/cubitS.cpp +++ b/TAO/tests/Cubit/TAO/cubitS.cpp @@ -12,59 +12,63 @@ #include "method_db.i" -TAO_Dynamic_Hash_OpTable tao_cubit_optable(cubit_operations, 7, 14); // Dynamic Operation Table +TAO_Dynamic_Hash_OpTable tao_cubit_optable (cubit_operations, 7, 14); // Dynamic Operation Table -_skel_Cubit::_skel_Cubit(const char* obj_name) +_skel_Cubit::_skel_Cubit (const char *obj_name) { - const char* mn = "_skel_Cubit::_skel_Cubit()"; + const char* mn = "_skel_Cubit::_skel_Cubit ()"; - char *type_id = "IDL:Cubit:1.0"; - IIOP_Object *data; - - CORBA_BOA_ptr oa = TAO_OA_Parameters::instance()->oa(); - if (oa == 0) - { - // We just have to assume that oa will be good, or we have to - // throw an exception. For now we "assume", but we'll - ACE_ERROR((LM_ERROR, "(%P|%t) %s Unable to locate a valid object adapter\n", mn)); - return; - } - - this->optable_ = &tao_cubit_optable; - data = new IIOP_Object(type_id); - - data->profile.iiop_version.major = IIOP::MY_MAJOR; - data->profile.iiop_version.minor = IIOP::MY_MINOR; - data->profile.host = ACE_OS::strdup(oa->get_addr().get_host_name()); - data->profile.port = oa->get_addr().get_port_number(); - data->profile.object_key.length = ACE_OS::strlen(obj_name); - data->profile.object_key.maximum = data->profile.object_key.length; - data->profile.object_key.buffer = new CORBA_Octet [(size_t)data->profile.object_key.length+1]; - - ACE_OS::memcpy (data->profile.object_key.buffer, - obj_name, - data->profile.object_key.length+1); - - this->set_parent(data); - this->sub_ = this; - - if (oa->bind(data->profile.object_key, this) == -1) - { - ACE_ERROR((LM_ERROR, "(%P|%t) %s Unable to bind object to key '%s': %p\n", mn, data->profile.object_key.buffer)); - return; - } + char *type_id = "IDL:Cubit:1.0"; + IIOP_Object *data; + + CORBA_BOA_ptr oa = TAO_OA_Parameters::instance ()->oa (); + if (oa == 0) + { + // We just have to assume that oa will be good, or we have to + // throw an exception. For now we "assume", but we'll + ACE_ERROR ((LM_ERROR, " (%P|%t) %s Unable to locate a valid object adapter\n", mn)); + return; + } + + this->optable_ = &tao_cubit_optable; + data = new IIOP_Object (type_id); + + data->profile.iiop_version.major = IIOP::MY_MAJOR; + data->profile.iiop_version.minor = IIOP::MY_MINOR; + data->profile.host = ACE_OS::strdup (oa->get_addr ().get_host_name ()); + data->profile.port = oa->get_addr ().get_port_number (); + data->profile.object_key.length = ACE_OS::strlen (obj_name); + data->profile.object_key.maximum = data->profile.object_key.length; + data->profile.object_key.buffer = + new CORBA_Octet[(size_t)data->profile.object_key.length + 1]; + + ACE_OS::memcpy (data->profile.object_key.buffer, + obj_name, + data->profile.object_key.length+1); + + this->set_parent (data); + this->sub_ = this; + + if (oa->bind (data->profile.object_key, this) == -1) + { + ACE_ERROR ((LM_ERROR, + " (%P|%t) %s Unable to bind object to key '%s': %p\n", + mn, + data->profile.object_key.buffer)); + return; + } } void -_skel_Cubit::_cube_octet_skel(CORBA_ServerRequest &req, - CORBA_Object_ptr obj, - CORBA_Environment &env) +_skel_Cubit::_cube_octet_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) { - CORBA_NVList_ptr nvlist; + CORBA_NVList_ptr nvlist; CORBA_NamedValue_ptr nv; - CORBA_Any temp_value (_tc_CORBA_Octet); + CORBA_Any temp_value (_tc_CORBA_Octet); - req.orb()->create_list (0, nvlist); + req.orb ()->create_list (0, nvlist); nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); dexc (env, "cube_octet, add value"); @@ -72,10 +76,10 @@ _skel_Cubit::_cube_octet_skel(CORBA_ServerRequest &req, dexc (env, "cube_octet, get params"); // Call Implementation - CORBA_Octet *value = new CORBA_Octet; - Cubit *the_cubit = (Cubit*)obj->get_subclass(); + CORBA_Octet *value = new CORBA_Octet; + Cubit *the_cubit = (Cubit *) obj->get_subclass (); - *value = the_cubit->Cubit_cube_octet(*(CORBA_Octet *)nv->value()->value(), env); + *value = the_cubit->Cubit_cube_octet (*(CORBA_Octet *) nv->value ()->value (), env); CORBA_Any *any = new CORBA_Any (_tc_CORBA_Octet, value, CORBA_B_TRUE); @@ -92,7 +96,7 @@ _skel_Cubit::_cube_short_skel (CORBA_ServerRequest &req, CORBA_NamedValue_ptr nv; CORBA_Any temp_value (_tc_CORBA_Short); - req.orb()->create_list (0, nvlist); + req.orb ()->create_list (0, nvlist); nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); dexc (env, "cube_short, add_value"); @@ -101,8 +105,8 @@ _skel_Cubit::_cube_short_skel (CORBA_ServerRequest &req, // Call Implementation CORBA_Short *value = new CORBA_Short; - Cubit *the_cubit = (Cubit*)obj->get_subclass(); - *value = the_cubit->Cubit_cube_short(*(CORBA_Short *)nv->value ()->value (), env); + Cubit *the_cubit = (Cubit *) obj->get_subclass (); + *value = the_cubit->Cubit_cube_short (*(CORBA_Short *) nv->value ()->value (), env); CORBA_Any *any = new CORBA_Any (_tc_CORBA_Short, value, CORBA_B_TRUE); @@ -119,7 +123,7 @@ _skel_Cubit::_cube_long_skel (CORBA_ServerRequest &req, CORBA_NamedValue_ptr nv; CORBA_Any temp_value (_tc_CORBA_Long); - req.orb()->create_list (0, nvlist); + req.orb ()->create_list (0, nvlist); nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); dexc (env, "cube_long, add_value"); @@ -128,8 +132,8 @@ _skel_Cubit::_cube_long_skel (CORBA_ServerRequest &req, // Call Implementation CORBA_Long *value = new CORBA_Long; - Cubit *the_cubit = (Cubit*)obj->get_subclass(); - *value = the_cubit->Cubit_cube_long(*(CORBA_Long *)nv->value ()->value (), env); + Cubit *the_cubit = (Cubit *) obj->get_subclass (); + *value = the_cubit->Cubit_cube_long (*(CORBA_Long *) nv->value ()->value (), env); CORBA_Any *any = new CORBA_Any (_tc_CORBA_Long, value, CORBA_B_TRUE); @@ -143,35 +147,35 @@ _skel_Cubit::_cube_struct_skel (CORBA_ServerRequest &req, CORBA_Object_ptr obj, CORBA_Environment &env) { - CORBA_NVList_ptr nvlist; - CORBA_NamedValue_ptr nv; - CORBA_Any temp_value (TC_Cubit_Many); + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv; + CORBA_Any temp_value (TC_Cubit_Many); - req.orb()->create_list (0, nvlist); - nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); - dexc (env, "cube_struct, add_value"); + req.orb ()->create_list (0, nvlist); + nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); + dexc (env, "cube_struct, add_value"); - req.params (nvlist, env); - dexc (env, "cube_struct, get params"); + req.params (nvlist, env); + dexc (env, "cube_struct, get params"); - // Call Implementation - Cubit_Many *value; - Cubit *the_cubit = (Cubit*)obj->get_subclass(); - value = the_cubit->Cubit_cube_struct(*(Cubit_Many*)nv->value()->value(), env); + // Call Implementation + Cubit_Many *value; + Cubit *the_cubit = (Cubit *) obj->get_subclass (); + value = the_cubit->Cubit_cube_struct (*(Cubit_Many *) nv->value ()->value (), env); - Cubit_Many *retval = new Cubit_Many; - retval->o = (CORBA_Octet)value->o; - retval->s = (CORBA_Short)value->s; - retval->l = value->l; + Cubit_Many *retval = new Cubit_Many; + retval->o = (CORBA_Octet)value->o; + retval->s = (CORBA_Short)value->s; + retval->l = value->l; - // dmsg2 ("cube struct.o, %d -> %d", value->o, retval->o); - // dmsg2 ("cube struct.s, %d -> %d", value->s, retval->s); - // dmsg2 ("cube struct.l, %d -> %d", value->l, retval->l); + // dmsg2 ("cube struct.o, %d -> %d", value->o, retval->o); + // dmsg2 ("cube struct.s, %d -> %d", value->s, retval->s); + // dmsg2 ("cube struct.l, %d -> %d", value->l, retval->l); - CORBA_Any *any = new CORBA_Any (TC_Cubit_Many, retval, CORBA_B_TRUE); + CORBA_Any *any = new CORBA_Any (TC_Cubit_Many, retval, CORBA_B_TRUE); - req.result (any, env); - dexc (env, "cube_struct, result"); + req.result (any, env); + dexc (env, "cube_struct, result"); } void @@ -179,35 +183,35 @@ _skel_Cubit::_cube_union_skel (CORBA_ServerRequest &req, CORBA_Object_ptr obj, CORBA_Environment &env) { - CORBA_NVList_ptr nvlist; - CORBA_NamedValue_ptr nv; - CORBA_Any temp_value (TC_Cubit_oneof); - - req.orb()->create_list (0, nvlist); - nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); - dexc (env, "cube_union_3rd, add_value"); - - req.params (nvlist, env); - dexc (env, "cube_union_3rd, get params"); - - // Call Implementation - Cubit_oneof *v; - Cubit *the_cubit = (Cubit*)obj->get_subclass(); - v = the_cubit->Cubit_cube_union(*(Cubit_oneof *)nv->value ()->value (), env); - - Cubit_oneof *r = new Cubit_oneof; - r->_disc = v->_disc; - r->o = (CORBA_Octet) (v->o); - r->s = (CORBA_Short) (v->s); - r->l = v->l; - r->cm.o = (CORBA_Octet) (v->cm.o); - r->cm.s = (CORBA_Short) (v->cm.s); - r->cm.l = v->cm.l; - - CORBA_Any *any = new CORBA_Any (TC_Cubit_oneof, r, CORBA_B_TRUE); - - req.result (any, env); - dexc (env, "cube_struct, result"); + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv; + CORBA_Any temp_value (TC_Cubit_oneof); + + req.orb ()->create_list (0, nvlist); + nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); + dexc (env, "cube_union_3rd, add_value"); + + req.params (nvlist, env); + dexc (env, "cube_union_3rd, get params"); + + // Call Implementation + Cubit_oneof *v; + Cubit *the_cubit = (Cubit *)obj->get_subclass (); + v = the_cubit->Cubit_cube_union (*(Cubit_oneof *) nv->value ()->value (), env); + + Cubit_oneof *r = new Cubit_oneof; + r->_disc = v->_disc; + r->o = (CORBA_Octet) (v->o); + r->s = (CORBA_Short) (v->s); + r->l = v->l; + r->cm.o = (CORBA_Octet) (v->cm.o); + r->cm.s = (CORBA_Short) (v->cm.s); + r->cm.l = v->cm.l; + + CORBA_Any *any = new CORBA_Any (TC_Cubit_oneof, r, CORBA_B_TRUE); + + req.result (any, env); + dexc (env, "cube_struct, result"); } void @@ -217,6 +221,6 @@ _skel_Cubit::_please_exit_skel (CORBA_ServerRequest &req, { ACE_UNUSED_ARG (req); - Cubit *the_cubit = (Cubit*)obj->get_subclass(); - the_cubit->Cubit_please_exit(env); + Cubit *the_cubit = (Cubit *) obj->get_subclass (); + the_cubit->Cubit_please_exit (env); } diff --git a/TAO/tests/Cubit/TAO/cubit_i.cpp b/TAO/tests/Cubit/TAO/cubit_i.cpp index 395fe0602d6..d229c3bbbe3 100644 --- a/TAO/tests/Cubit/TAO/cubit_i.cpp +++ b/TAO/tests/Cubit/TAO/cubit_i.cpp @@ -8,16 +8,14 @@ // Modified by: Brian Mendel #include "tao/corba.h" // ... and skeletons - #include "cubit_i.h" - -Cubit_i::Cubit_i(const char* obj_name) -: _skel_Cubit(obj_name) +Cubit_i::Cubit_i (const char* obj_name) + : _skel_Cubit (obj_name) { } -Cubit_i::~Cubit_i() +Cubit_i::~Cubit_i (void) { } @@ -37,7 +35,6 @@ Cubit_i::Cubit_cube_short (CORBA_Short s, return (CORBA_Short) (s * s * s); } - CORBA_Long Cubit_i::Cubit_cube_long (CORBA_Long l, CORBA_Environment &env) @@ -46,7 +43,7 @@ Cubit_i::Cubit_cube_long (CORBA_Long l, return (CORBA_Long) (l * l * l); } -Cubit_Many* +Cubit_Many * Cubit_i::Cubit_cube_struct (Cubit_Many &values, CORBA_Environment &env) { @@ -58,7 +55,7 @@ Cubit_i::Cubit_cube_struct (Cubit_Many &values, return &values; } -Cubit_oneof* +Cubit_oneof * Cubit_i::Cubit_cube_union (Cubit_oneof &values, CORBA_Environment &env) { @@ -85,9 +82,9 @@ Cubit_i::Cubit_cube_union (Cubit_oneof &values, void Cubit_i::Cubit_please_exit (CORBA_Environment &env) { - TAO_OA_Parameters* params = TAO_OA_Parameters::instance(); + TAO_OA_Parameters* params = TAO_OA_Parameters::instance (); - dmsg ("I've been asked to shut down..."); - params->oa()->please_shutdown(env); - dexc (env, "please_exit, please_shutdown"); + dmsg ("I've been asked to shut down..."); + params->oa ()->please_shutdown (env); + dexc (env, "please_exit, please_shutdown"); } diff --git a/TAO/tests/Cubit/TAO/cubit_i.h b/TAO/tests/Cubit/TAO/cubit_i.h index 6f4bee0d486..e95b39e60ed 100644 --- a/TAO/tests/Cubit/TAO/cubit_i.h +++ b/TAO/tests/Cubit/TAO/cubit_i.h @@ -24,31 +24,31 @@ typedef Cubit_i_ptr Cubit_i_ref; class Cubit_i : public _skel_Cubit { public: - Cubit_i(const char* obj_name = 0); - ~Cubit_i(); + Cubit_i(const char* obj_name = 0); + ~Cubit_i(); - virtual - CORBA_Octet Cubit_cube_octet (CORBA_Octet o, - CORBA_Environment &env); + virtual + CORBA_Octet Cubit_cube_octet (CORBA_Octet o, + CORBA_Environment &env); - virtual - CORBA_Short Cubit_cube_short (CORBA_Short s, - CORBA_Environment &env); + virtual + CORBA_Short Cubit_cube_short (CORBA_Short s, + CORBA_Environment &env); - virtual - CORBA_Long Cubit_cube_long (CORBA_Long l, - CORBA_Environment &env); + virtual + CORBA_Long Cubit_cube_long (CORBA_Long l, + CORBA_Environment &env); - virtual - Cubit_Many* Cubit_cube_struct (Cubit_Many &values, - CORBA_Environment &env); + virtual + Cubit_Many* Cubit_cube_struct (Cubit_Many &values, + CORBA_Environment &env); - virtual - Cubit_oneof* Cubit_cube_union (Cubit_oneof &values, - CORBA_Environment &env); + virtual + Cubit_oneof* Cubit_cube_union (Cubit_oneof &values, + CORBA_Environment &env); - virtual - void Cubit_please_exit (CORBA_Environment &env); + virtual + void Cubit_please_exit (CORBA_Environment &env); }; #endif // _CUBIT_I_HH diff --git a/TAO/tests/Cubit/TAO/method_db.i b/TAO/tests/Cubit/TAO/method_db.i index dcf7ffa0897..39fe4565f5f 100644 --- a/TAO/tests/Cubit/TAO/method_db.i +++ b/TAO/tests/Cubit/TAO/method_db.i @@ -1,4 +1,4 @@ -// @(#)method_db.i 05/14/97 +// @ (#)method_db.i 05/14/97 // This file provides a way of initializing the method database // Written by: Brian Mendel @@ -16,7 +16,7 @@ is_a_skel (CORBA_ServerRequest &req, CORBA_NamedValue_ptr nv; CORBA_Any temp_value (_tc_CORBA_String); - req.orb()->create_list (0, nvlist); + req.orb ()->create_list (0, nvlist); nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); req.params (nvlist, env); @@ -27,10 +27,10 @@ is_a_skel (CORBA_ServerRequest &req, } CORBA_Boolean *retval; - CORBA_String value = *(CORBA_String *) nv->value()->value(); + CORBA_String value = * (CORBA_String *) nv->value ()->value (); - if (ACE_OS::strcmp ((char*)value, "IDL:Cubit:1.0") == 0 - || ACE_OS::strcmp ((char *)value, _tc_CORBA_Object->id (env)) == 0) + if (ACE_OS::strcmp ( (char*)value, "IDL:Cubit:1.0") == 0 + || ACE_OS::strcmp ( (char *)value, _tc_CORBA_Object->id (env)) == 0) retval = new CORBA_Boolean (CORBA_B_TRUE); else retval = new CORBA_Boolean (CORBA_B_FALSE); diff --git a/TAO/tests/Cubit/TAO/svr.cpp b/TAO/tests/Cubit/TAO/svr.cpp index f424a5dded7..a339fb9a979 100644 --- a/TAO/tests/Cubit/TAO/svr.cpp +++ b/TAO/tests/Cubit/TAO/svr.cpp @@ -4,7 +4,7 @@ // // TEST: simple IIOP server for "cubit.idl" interface. // -// Starts up, builds an objref, prints its string in debug mode, +// Starts up, builds an objref, prints its string in debug mode, // listens for messages, responds to them. // // Modified version of Cubit Example written by Sun Microsystems Inc. @@ -17,180 +17,146 @@ #include "cubit_i.h" +// @@ Shouldn't this be defined in a headerfile somewhere? extern void print_exception (const CORBA_Exception *, const char *, FILE *f=stdout); // Global Variables -CORBA_String key = (CORBA_String)"key0"; -int num_of_objs = 1; +static CORBA_String key = (CORBA_String) "key0"; -// = TITLE -// Parses the command line arguments and returns an error status -// -// = DESCRIPTION -// This method parses the command line arguments -int parse_args(int argc, char *argv[]) +static int num_of_objs = 1; + +// Parses the command line arguments and returns an error status + +static int +parse_args (int argc, char *argv[]) { ACE_Get_Opt opts (argc, argv, "dk:n:"); int c; while ((c = opts ()) != -1) - switch (c) { - - case 'd': // debug flag - TAO_debug_level++; - continue; + switch (c) + { + case 'd': // debug flag + TAO_debug_level++; + continue; - case 'k': // key (str) - key = (CORBA_String) opts.optarg; - continue; + case 'k': // key (str) + key = (CORBA_String) opts.optarg; + continue; - case 'n': // idle seconds b4 exit - num_of_objs = ACE_OS::atoi(opts.optarg); - continue; - - case '?': - default: - ACE_OS::fprintf (stderr, "usage: %s" - " [-d]" - " [-k {object_key}]" - "\n", argv [0] - ); - return 1; - } + case 'n': // idle seconds b4 exit + num_of_objs = ACE_OS::atoi (opts.optarg); + continue; + + case '?': + default: + ACE_OS::fprintf (stderr, "usage: %s" + " [-d]" + " [-k {object_key}]" + "\n", argv [0] + ); + return 1; + } return 0; // Indicates successful parsing of command line } - -// // Standard command line parsing utilities used. -// + int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { - CORBA_Environment env; - CORBA_Object_ptr obj = 0; - CORBA_ORB_ptr orb_ptr; - CORBA_BOA_ptr oa_ptr; - char *orb_name = "internet"; - - orb_ptr = CORBA_ORB_init (argc, argv, orb_name, env); - if (env.exception () != 0) { - print_exception (env.exception (), "ORB init"); - return 1; - } + CORBA_Environment env; + char *orb_name = "internet"; + + CORBA_ORB_ptr orb_ptr = CORBA_ORB_init (argc, argv, orb_name, env); + + if (env.exception () != 0) + { + print_exception (env.exception (), "ORB init"); + return 1; + } // Initialize the Basic Object Adapter - oa_ptr = orb_ptr->BOA_init(argc, argv, "ROA"); + CORBA_BOA_ptr oa_ptr = orb_ptr->BOA_init (argc, argv, "ROA"); + if (oa_ptr == 0) - ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to initialize the BOA.\n"), 1); - + ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the BOA.\n"), 1); - // // Parse remaining command line and verify parameters. - // - parse_args(argc, argv); + + parse_args (argc, argv); - // Create implementation object with user specified key - Cubit_i_ptr *my_cubit = new Cubit_i_ptr[num_of_objs]; - for (int ndx = 0; ndx < num_of_objs; ndx++) - { - CORBA_String obj_str = CORBA_string_alloc(ACE_OS::strlen ((char *)key)+2); - sprintf(obj_str, "%s%d", (char*)key, ndx); - my_cubit[ndx] = new Cubit_i(obj_str); - if (my_cubit[ndx] == 0) - ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to create implementation object&d\n", ndx), 2); - - if (TAO_debug_level >= 1) - { - // Why are we getting the BOA_ptr from here when we've already - // got it above? - CORBA_OctetSeq obj_key; - obj_key.buffer = (CORBA_Octet *) obj_str; - obj_key.length = obj_key.maximum = ACE_OS::strlen (obj_str); - - if (oa_ptr->find(obj_key, obj) == -1) - ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to locate object with key '%s', %p\n", key), 3); - - // - // Stringify the objref we'll be implementing, and - // print it to stdout. Someone will take that string - // and give it to some client. Then release the object. - // - CORBA_String str; - - str = orb_ptr->object_to_string (obj, env); - if (env.exception () != 0) { - print_exception (env.exception (), "object2string"); - return 1; - } - ACE_OS::puts ((char *)str); - ACE_OS::fflush (stdout); - dmsg1 ("Object Created at: '%ul'", obj); - dmsg1 ("listening as object '%s'", str); - - } - CORBA_string_free(obj_str); - } -// Cubit_i_ptr my_cubit = new Cubit_i(key); -// if (my_cubit1 == 0) -// ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to create implementation object\n"), 2); + // Create implementation object with user specified key. + Cubit_i_ptr *my_cubit = new Cubit_i_ptr[num_of_objs]; -/* if (TAO_debug_level >= 1) + for (int i = 0; i < num_of_objs; i++) { - // Why are we getting the BOA_ptr from here when we've already - // got it above? - CORBA_OctetSeq obj_key; - obj_key.buffer = (CORBA_Octet *) key; - obj_key.length = obj_key.maximum = ACE_OS::strlen ((char *)key); - - if (oa_ptr->find(obj_key, obj) == -1) - ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to locate object with key '%s', %p\n", key), 3); + CORBA_String obj_str = CORBA_string_alloc (ACE_OS::strlen ((char *) key)+2); + + ::sprintf (obj_str, "%s%d", (char *) key, i); + + my_cubit[i] = new Cubit_i (obj_str); + + if (my_cubit[i] == 0) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to create implementation object&d\n", + i), + 2); + + if (TAO_debug_level >= 1) + { + // Why are we getting the BOA_ptr from here when we've + // already got it above? + CORBA_OctetSeq obj_key; + obj_key.buffer = (CORBA_Octet *) obj_str; + obj_key.length = obj_key.maximum = ACE_OS::strlen (obj_str); - // - // Stringify the objref we'll be implementing, and - // print it to stdout. Someone will take that string - // and give it to some client. Then release the object. - // - CORBA_String str; + CORBA_Object_ptr obj = 0; + + if (oa_ptr->find (obj_key, obj) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to locate object with key '%s', %p\n", key), 3); - str = orb_ptr->object_to_string (obj, env); - if (env.exception () != 0) { - print_exception (env.exception (), "object2string"); - return 1; - } - ACE_OS::puts ((char *)str); - ACE_OS::fflush (stdout); - dmsg1 ("listening as object '%s'", str); - - obj_key.buffer = (CORBA_Octet *)"key1"; - obj_key.length = obj_key.maximum = 4; - if (oa_ptr->find(obj_key, obj) == -1) - ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to locate object with key '%s', %p\n", key), 3); - - str = orb_ptr->object_to_string (obj, env); - if (env.exception () != 0) { - print_exception (env.exception (), "object2string"); - return 1; - } - ACE_OS::puts ((char *)str); - ACE_OS::fflush (stdout); - dmsg1 ("listening as object '%s'", str); + // Stringify the objref we'll be implementing, and print it + // to stdout. Someone will take that string and give it to + // some client. Then release the object. + + CORBA_String str; + + str = orb_ptr->object_to_string (obj, env); + + if (env.exception () != 0) + { + print_exception (env.exception (), "object2string"); + return 1; + } + + ACE_OS::puts ((char *) str); + ACE_OS::fflush (stdout); + dmsg1 ("Object Created at: '%ul'", obj); + dmsg1 ("listening as object '%s'", str); + } + + CORBA_string_free (obj_str); } -*/ - // Handle requests for this object until we're killed, or one of - // the methods asks us to exit. - // -#if !defined(USE_HOMEBREW_EVENT_LOOP) - ACE_Reactor::run_event_loop(); +// Cubit_i_ptr my_cubit = new Cubit_i (key); +// if (my_cubit1 == 0) +// ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to create implementation object\n"), 2); + + // Handle requests for this object until we're killed, or one of the + // methods asks us to exit. + +#if !defined (USE_HOMEBREW_EVENT_LOOP) + ACE_Reactor::run_event_loop (); #else int terminationStatus = 0; while (1) { - int result = params->reactor()->handle_events (); + int result = params->reactor ()->handle_events (); if (result == -1) { @@ -198,12 +164,11 @@ main (int argc, char *argv[]) break; } } -#endif +#endif /* USE_HOMEBREW_EVENT_LOOP */ - // // Shut down the OA -- recycles all underlying resources (e.g. file // descriptors, etc). - // + oa_ptr->clean_shutdown (env); return 0; } |