summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgokhale <asgokhale@users.noreply.github.com>1998-04-23 21:18:52 +0000
committergokhale <asgokhale@users.noreply.github.com>1998-04-23 21:18:52 +0000
commit531f8207adb685c1e6ca972583ecd8c9ec39d62e (patch)
tree705167126a9f07fc34d50ee0ce41dee68800ff8e
parent019120f651ffedb250ad8a17571eb1935b155558 (diff)
downloadATCD-531f8207adb685c1e6ca972583ecd8c9ec39d62e.tar.gz
*** empty log message ***
-rw-r--r--TAO/ChangeLog-98c79
-rw-r--r--TAO/TAO_IDL/be/be_visitor_exception.cpp16
-rw-r--r--TAO/TAO_IDL/be/be_visitor_sequence.cpp16
-rw-r--r--TAO/TAO_IDL/be/be_visitor_structure.cpp16
-rw-r--r--TAO/TAO_IDL/be/be_visitor_union.cpp16
-rw-r--r--TAO/docs/releasenotes/index.html41
-rw-r--r--TAO/tao/Any.cpp18
-rw-r--r--TAO/tao/Any.h13
-rw-r--r--TAO/tao/Any.i7
-rw-r--r--TAO/tao/GIOP.h6
-rw-r--r--TAO/tao/GIOP.i12
-rw-r--r--TAO/tao/IIOP_Object.cpp106
-rw-r--r--TAO/tao/NVList.cpp226
-rw-r--r--TAO/tao/NVList.h9
-rw-r--r--TAO/tao/NVList.i7
-rw-r--r--TAO/tao/ORB.cpp7
-rw-r--r--TAO/tao/Server_Request.cpp4
-rw-r--r--TAO/tao/append.cpp65
-rw-r--r--TAO/tao/decode.cpp64
-rw-r--r--TAO/tao/encode.cpp57
-rw-r--r--TAO/tao/skip.cpp65
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/Makefile7
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/client.cpp36
-rw-r--r--TAO/tests/Param_Test/tests.cpp64
24 files changed, 681 insertions, 276 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index b28101faa37..681b3340010 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,24 +1,87 @@
+Thu Apr 23 15:48:29 1998 Aniruddha Gokhale <gokhale@mambo.cs.wustl.edu>
+
+ * TAO_IDL/be/{be_visitor_structure, be_visitor_exception,
+ be_visitor_union, be_visitor_sequence}.cpp: The code generation of
+ the >>= operators is now improved to take into account the fact
+ that an Any may not own the value. In such cases, the >>= operator
+ should simply do a cast rather than retrieving the value from the
+ CDR member
+
+ * tao/Any.{h,i}: Added a new method (TAO extension) returning a
+ boolean to indicate if the Any owns the data or not. This is used
+ by the >>= operators generated for user-defined types
+
+ * tao/Any.cpp: The constructor and assignment operator of Any that
+ was creating a CDR stream used to point its ACE_Message_Block
+ member to a buffer that was allocated on the function call
+ stack. We now explicitly call "clone" on it to make a deep copy.
+
+ * tao/GIOP.{h,i}: Added two methods that return the underlying
+ input and output CDR streams.
+
+ * tao/IIOP_Object.cpp: (do_dynamic_call): Made major
+ modifications. We are now able to handle the case when the user
+ has not supplied the top level storage for out and return
+ parameters. For these cases, we use exactly the same logic as the
+ Any::decode method. We maintain a pointer to the part of the CDR
+ stream that holds the value and save it in the Any. It is the
+ application's responsibility to use the appropriate >>= methods to
+ retrieve the value.
+
+ * tao/NVList.{h, i, cpp}: We now use ACE_Unbounded_Queue to
+ maintain the list of NamedValues. The original code was mixing up
+ C++ and C memory management by using calloc and realloc. This was
+ cauisng too many problems. At the same time, reallocing would
+ introduce a large number of deep_copies of the Anys that are held.
+ All the add_* and item methods have been affected.
+
+ * tao/ORB.cpp: Modified the create_list method since the NVList
+ now uses ACE_Unbounded_Queue<NamedValue_ptr> to maintain a list of
+ NamedValues.
+
+ * tao/{append, encode, decode, skip}.cpp: For the Union::{append,
+ encode, decode, skip} methods, it was necessary to use the >>=
+ operators to retrieve the label values. We were originally using
+ casts to the void* returned by the Any::value () method. However,
+ since this returns the underlying CDR buffer, we need to use the
+ type-safe >>= operators. For the enum case label, we explicitly
+ invoke the decoder.
+
+ * tao/Server_Request.cpp:(demarshal): We now create an NVList of
+ size 0 and then add individual items according to the
+ CallData_skel table. This is no more wasteful as in the previous
+ scheme because now we use ACE_Unbounded_Queue to mainatin the
+ internal list and hence growing the list does not result in huge
+ amounts of deep_copies.
+
+ * tests/Cubit/TAO/IDL_Cubit/client.cpp: Fixed the usage for DII in
+ struct_dii and union_dii to use the >>= operators.
+
+ * tests/Param_test/tests.cpp: Partially fixed the way DII tests
+ should be coded. Some of them are now working. I need to fix the
+ rest of them.
+
Wed Apr 22 15:56:58 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
- * orbsvcs/tests/EC_Multiple/EC_Multiple.h:
- * orbsvcs/tests/EC_Multiple/EC_Multiple.cpp:
+ * orbsvcs/tests/EC_Multiple/EC_Multiple.h:
+ * orbsvcs/tests/EC_Multiple/EC_Multiple.cpp:
The test also has a collocated scheduling service now.
- * orbsvcs/tests/EC_Multiple/svc.conf:
+ * orbsvcs/tests/EC_Multiple/svc.conf:
Added a missing svc.conf file.
- * orbsvcs/Scheduling_Service/Scheduling_Service.cpp:
+ * orbsvcs/Scheduling_Service/Scheduling_Service.cpp:
The -n option can be used to specify the scheduling service name.
- * orbsvcs/orbsvcs/Scheduler_Factory.h:
- * orbsvcs/orbsvcs/Scheduler_Factory.cpp:
+ * orbsvcs/orbsvcs/Scheduler_Factory.h:
+ * orbsvcs/orbsvcs/Scheduler_Factory.cpp:
We can find scheduling services with different names now.
Removed all method that used resolve_initial_references() to
find the scheduling service; this was needed before the naming
service was working.
- * orbsvcs/tests/EC_Multiple/latency.pl:
- * orbsvcs/tests/EC_Multiple/gen_data:
+ * orbsvcs/tests/EC_Multiple/latency.pl:
+ * orbsvcs/tests/EC_Multiple/gen_data:
Simple scripts to process the data obtained in the experiments.
Mon Apr 20 16:46:07 1998 Aniruddha Gokhale <gokhale@mambo.cs.wustl.edu>
diff --git a/TAO/TAO_IDL/be/be_visitor_exception.cpp b/TAO/TAO_IDL/be/be_visitor_exception.cpp
index 028ab2fd0a9..4e635804a32 100644
--- a/TAO/TAO_IDL/be/be_visitor_exception.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_exception.cpp
@@ -434,6 +434,8 @@ int be_visitor_exception_cs::visit_exception (be_exception *node)
<< "CORBA::Environment _tao_env;" << be_nl
<< "if (!_tao_any.type ()->equal (" << node->tc_name ()
<< ", _tao_env)) return 0; // not equal" << be_nl
+ << "if (_tao_any.any_owns_data ())" << be_nl
+ << "{" << be_idt_nl
<< "ACE_NEW_RETURN (_tao_elem, " << node->name () << ", 0);"
<< be_nl
<< "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any.value ());"
@@ -447,8 +449,18 @@ int be_visitor_exception_cs::visit_exception (be_exception *node)
<< be_nl
<< " return 1;" << be_uidt_nl
<< "}" << be_nl
- << "else" << be_nl
- << " return 0;" << be_uidt_nl
+ << "else" << be_nl // decode failed
+ << "{" << be_idt_nl
+ << "delete _tao_elem;" << be_nl
+ << "return 0;" << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "}" << be_nl
+ << "else" << be_nl // else any does not own the data
+ << "{" << be_idt_nl
+ << "_tao_elem = (" << node->name () << " *)_tao_any.value ();"
+ << be_nl
+ << "return 1;" << be_uidt_nl
+ << "}" << be_uidt_nl
<< "}\n\n";
os->indent ();
diff --git a/TAO/TAO_IDL/be/be_visitor_sequence.cpp b/TAO/TAO_IDL/be/be_visitor_sequence.cpp
index ea8d4c6b015..6c9aa16389f 100644
--- a/TAO/TAO_IDL/be/be_visitor_sequence.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_sequence.cpp
@@ -1164,6 +1164,8 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node)
<< "CORBA::Environment _tao_env;" << be_nl
<< "if (!_tao_any.type ()->equal (" << node->tc_name ()
<< ", _tao_env)) return 0; // not equal" << be_nl
+ << "if (_tao_any.any_owns_data ())" << be_nl
+ << "{" << be_idt_nl
<< "ACE_NEW_RETURN (_tao_elem, " << node->name () << ", 0);"
<< be_nl
<< "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any.value ());"
@@ -1177,8 +1179,18 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node)
<< be_nl
<< " return 1;" << be_uidt_nl
<< "}" << be_nl
- << "else" << be_nl
- << " return 0;" << be_uidt_nl
+ << "else" << be_nl // decode failed
+ << "{" << be_idt_nl
+ << "delete _tao_elem;" << be_nl
+ << "return 0;" << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "}" << be_nl
+ << "else" << be_nl // else any does not own the data
+ << "{" << be_idt_nl
+ << "_tao_elem = (" << node->name () << " *)_tao_any.value ();"
+ << be_nl
+ << "return 1;" << be_uidt_nl
+ << "}" << be_uidt_nl
<< "}\n\n";
// generate the typecode information here
diff --git a/TAO/TAO_IDL/be/be_visitor_structure.cpp b/TAO/TAO_IDL/be/be_visitor_structure.cpp
index 143f1687f33..d59cca1318d 100644
--- a/TAO/TAO_IDL/be/be_visitor_structure.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_structure.cpp
@@ -309,6 +309,8 @@ int be_visitor_structure_cs::visit_structure (be_structure *node)
<< "CORBA::Environment _tao_env;" << be_nl
<< "if (!_tao_any.type ()->equal (" << node->tc_name ()
<< ", _tao_env)) return 0; // not equal" << be_nl
+ << "if (_tao_any.any_owns_data ())" << be_nl
+ << "{" << be_idt_nl
<< "ACE_NEW_RETURN (_tao_elem, " << node->name () << ", 0);"
<< be_nl
<< "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any.value ());"
@@ -322,8 +324,18 @@ int be_visitor_structure_cs::visit_structure (be_structure *node)
<< be_nl
<< " return 1;" << be_uidt_nl
<< "}" << be_nl
- << "else" << be_nl
- << " return 0;" << be_uidt_nl
+ << "else" << be_nl // decode failed
+ << "{" << be_idt_nl
+ << "delete _tao_elem;" << be_nl
+ << "return 0;" << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "}" << be_nl
+ << "else" << be_nl // else any does not own the data
+ << "{" << be_idt_nl
+ << "_tao_elem = (" << node->name () << " *)_tao_any.value ();"
+ << be_nl
+ << "return 1;" << be_uidt_nl
+ << "}" << be_uidt_nl
<< "}\n\n";
os->indent ();
diff --git a/TAO/TAO_IDL/be/be_visitor_union.cpp b/TAO/TAO_IDL/be/be_visitor_union.cpp
index f017abe8ea1..7e2cec05d43 100644
--- a/TAO/TAO_IDL/be/be_visitor_union.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_union.cpp
@@ -570,6 +570,8 @@ int be_visitor_union_cs::visit_union (be_union *node)
<< "CORBA::Environment _tao_env;" << be_nl
<< "if (!_tao_any.type ()->equal (" << node->tc_name ()
<< ", _tao_env)) return 0; // not equal" << be_nl
+ << "if (_tao_any.any_owns_data ())" << be_nl
+ << "{" << be_idt_nl
<< "ACE_NEW_RETURN (_tao_elem, " << node->name () << ", 0);"
<< be_nl
<< "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any.value ());"
@@ -583,8 +585,18 @@ int be_visitor_union_cs::visit_union (be_union *node)
<< be_nl
<< " return 1;" << be_uidt_nl
<< "}" << be_nl
- << "else" << be_nl
- << " return 0;" << be_uidt_nl
+ << "else" << be_nl // decode failed
+ << "{" << be_idt_nl
+ << "delete _tao_elem;" << be_nl
+ << "return 0;" << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "}" << be_nl
+ << "else" << be_nl // else any does not own the data
+ << "{" << be_idt_nl
+ << "_tao_elem = (" << node->name () << " *)_tao_any.value ();"
+ << be_nl
+ << "return 1;" << be_uidt_nl
+ << "}" << be_uidt_nl
<< "}\n\n";
os->indent ();
diff --git a/TAO/docs/releasenotes/index.html b/TAO/docs/releasenotes/index.html
index d8787dfbbbe..569209d5204 100644
--- a/TAO/docs/releasenotes/index.html
+++ b/TAO/docs/releasenotes/index.html
@@ -60,8 +60,14 @@ release</A> of <A HREF="http://www.cs.wustl.edu/~schmidt/TAO.html">TAO</A>:
<A NAME="idl"></A>IDL Compiler</H3>
Point of contact: <A HREF="mailto:gokhale@cs.wustl.edu">Aniruddha Gokhale</A>
-<P>Current status: (As of March 15th, 1998.)
+<P>Current status: (As of April 23rd, 1998.)
<UL>
+
+<LI>
+The &lt;&lt;= and >>= operators for user-defined types are now generated
+yet.
+</LI>
+
<LI>
Completely redesigned the IDL compiler using the Visitor patterns. Many
incomplete issues have been resolved. These include support for "sequence
@@ -165,6 +171,7 @@ added. Two backend options control the name of the export macro, and the
name of an extra include file were the macro is defined; the options are
<TT>-Wp,export_macro=MACRO_NAME</TT> <TT>-Wp,export_include=INCLUDE_NAME</TT>.</LI>
</UL>
+
Known bugs/unimplemented constructs:
<UL>
<LI>
@@ -181,10 +188,6 @@ is still a problem.</LI>
Unions with default cases yet to be handled</LI>
<LI>
-The &lt;&lt;= and >>= operators for user-defined types are not generated
-yet.</LI>
-
-<LI>
Deal with names in the IDL definition that are C++ keywords.</LI>
<LI>
@@ -370,12 +373,12 @@ Point of contact: <A HREF="mailto:sbw1@cs.wustl.edu">Seth Widoff</A>
Development is complete, and testing and debugging have commenced on
the TAO Trading Service. Currently, it
meets the Linked Trader conformance requirements, in that it supports
-the Lookup, Register, Admin, and Link interfaces. The Lookup interface supports
-subtype searching, preference sorting, dynamic property evaluation, federated queries,
+the Lookup, Register, Admin, and Link interfaces. The Lookup interface supports
+subtype searching, preference sorting, dynamic property evaluation, federated queries,
and concurrent queries as a multi-threaded servant.
<p>
-The Trading Service uses the Object Space implementation of the Standard
-Template Library.
+The Trading Service uses the Object Space implementation of the Standard
+Template Library.
<p>
Future Work: <p>
@@ -386,7 +389,7 @@ Future Work: <p>
<P>For general documentation of the Trading Service, please read <A HREF="http://www.omg.org/corba/sectrans.htm#trader">The
-Trading Service Specification.</A>
+Trading Service Specification.</A>
<P>
@@ -531,9 +534,9 @@ Have a DOVE Browser running using Java Beans as vizualization components.
Have the Event Channel as DOVE Agent running with an Event Consumer
in the DOVE Browser.
<LI>
-Having a DOVE Management Information Base (MIB), which dumps all
+Having a DOVE Management Information Base (MIB), which dumps all
events transfered on the Event Channel
-into a file on persistent storage for later reuse.
+into a file on persistent storage for later reuse.
</LI>
</UL>
<P>
@@ -541,9 +544,9 @@ The DOVE Browser uses independent visualization components (Java Beans)
and the Event Channel as DOVE Agent. Connections can be established
between monitored metrics and the visualization components.
<P>
-We have three major components:
+We have three major components:
Observables (monitored metrics), Observers (a Java Bean
-for displaying the metric) and a DataHandler (for demultiplexing the
+for displaying the metric) and a DataHandler (for demultiplexing the
monitored metrics to the appropriate Observables).
Each component inherits from a base class, so that a certain behavior
of the components can be assured for each component. Relationships
@@ -551,15 +554,15 @@ between components are based on these base classes.
<P>
The used Java Beans are required to conform to some standards, as
they have to support a function called "getProperty" which allows
-the DOVE Browser to determine if the vizualization capabilities of
+the DOVE Browser to determine if the vizualization capabilities of
a specific Java Bean are sufficient to display the metric.
A JavaBean is for example a Java Panel which shows a Graph of
-the delivered doubles. So all metrics can be displayed by this visualization
+the delivered doubles. So all metrics can be displayed by this visualization
component which can be expressed by a single double.
<P>
The DataHandler is connected to the Event Push Consumer (PUSH, because
we use the push concept of the Event Service). The Event Push Consumer
-does not know what kind of data is transported. The only component
+does not know what kind of data is transported. The only component
knowing all the details about the dependencies of the metrics is
the DataHandler. This separation allows easy extension and change
of the demo.
@@ -571,8 +574,8 @@ are available about this new concept.
Event Service events are used as communication between DOVE Applications
and the DOVE Browser. The DOVE MIB analyses the event data field of all events
and stores this information into a file. The event data filed is of
-type CORBA::Any and the DOVE MIB has no notion of what is conveyed in
-this field. So the DOVE MIB has to discover the content via the
+type CORBA::Any and the DOVE MIB has no notion of what is conveyed in
+this field. So the DOVE MIB has to discover the content via the
embedded type code information.
Future work includes:
diff --git a/TAO/tao/Any.cpp b/TAO/tao/Any.cpp
index d5115157963..3e411f6f140 100644
--- a/TAO/tao/Any.cpp
+++ b/TAO/tao/Any.cpp
@@ -92,12 +92,14 @@ CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr tc,
CORBA::Environment env;
TAO_OutputCDR stream;
- // encode the value
- stream.encode (this->type_, this->value_, 0, env);
+ if (this->value_)
+ {
+ // encode the value
+ stream.encode (this->type_, this->value_, 0, env);
- // retrieve the start of the message block chain and save it
- this->cdr_ = ACE_Message_Block::duplicate ((ACE_Message_Block *)
- stream.start ());
+ // retrieve the start of the message block chain and save it
+ this->cdr_ = stream.start ()->clone ();
+ }
}
}
@@ -129,8 +131,7 @@ CORBA_Any::CORBA_Any (const CORBA_Any &src)
stream.encode (this->type_, src.value_, 0, env);
// retrieve the start of the message block chain and duplicate it
- this->cdr_ = ACE_Message_Block::duplicate ((ACE_Message_Block *)
- stream.start ());
+ this->cdr_ = stream.start ()->clone ();
}
}
@@ -182,8 +183,7 @@ CORBA_Any::operator= (const CORBA_Any &src)
stream.encode (this->type_, src.value_, 0, env);
// retrieve the start of the message block chain and duplicate it
- this->cdr_ = ACE_Message_Block::duplicate ((ACE_Message_Block *)
- stream.start ());
+ this->cdr_ = stream.start ()->clone ();
}
return *this;
}
diff --git a/TAO/tao/Any.h b/TAO/tao/Any.h
index 937eb444f03..2097f17f8d7 100644
--- a/TAO/tao/Any.h
+++ b/TAO/tao/Any.h
@@ -271,12 +271,19 @@ public:
CORBA::ULong AddRef (void);
CORBA::ULong Release (void);
-
+
// = Debugging method.
-
+
static void dump (const CORBA::Any any_value);
// Prints the type and the value of the any value. Dumping is
// supported only for standard data types.
+
+ // =TAO extension
+ CORBA::Boolean any_owns_data (void) const;
+ // does the Any own the data or not. This is used by the >>= operators
+ // generated by the IDL compiler. The >>= operator checks if the Any owns the
+ // data. If it does, then it will retrieve the data from the CDR stream
+
private:
CORBA::TypeCode_ptr type_;
// Typecode for the <Any>.
@@ -297,7 +304,9 @@ private:
void operator<<= (unsigned char);
CORBA::Boolean operator>>= (unsigned char&) const;
+ friend class IIOP_Object;
friend class TAO_Marshal_Any;
+ friend class CORBA_NVList;
};
class TAO_Export CORBA_Any_var
diff --git a/TAO/tao/Any.i b/TAO/tao/Any.i
index 55c740cf42a..20164c32810 100644
--- a/TAO/tao/Any.i
+++ b/TAO/tao/Any.i
@@ -1,3 +1,4 @@
+// $Id$
// This may look like C, but it's really -*- C++ -*-
ACE_INLINE void *
@@ -304,3 +305,9 @@ CORBA_Any_out::ptr (void)
{
return this->ptr_;
}
+
+ACE_INLINE CORBA::Boolean
+CORBA_Any::any_owns_data (void) const
+{
+ return this->any_owns_data_;
+}
diff --git a/TAO/tao/GIOP.h b/TAO/tao/GIOP.h
index d2039b133c3..8d3313ece98 100644
--- a/TAO/tao/GIOP.h
+++ b/TAO/tao/GIOP.h
@@ -330,6 +330,12 @@ public:
CDR &stream (void);
// Return the underlying stream.
+ TAO_InputCDR &inp_stream (void);
+ // return the underlying input stream
+
+ TAO_OutputCDR &out_stream (void);
+ // return the underlying output stream
+
private:
IIOP_Object *data_;
// The object on which this invocation is going.
diff --git a/TAO/tao/GIOP.i b/TAO/tao/GIOP.i
index f5a9319fa70..71784475b7e 100644
--- a/TAO/tao/GIOP.i
+++ b/TAO/tao/GIOP.i
@@ -30,6 +30,18 @@ TAO_GIOP_Invocation::put_param (CORBA::TypeCode_ptr tc,
(void) this->out_stream_.encode (tc, value, 0, env);
}
+ACE_INLINE TAO_InputCDR &
+TAO_GIOP_Invocation::inp_stream (void)
+{
+ return this->inp_stream_;
+}
+
+ACE_INLINE TAO_OutputCDR &
+TAO_GIOP_Invocation::out_stream (void)
+{
+ return this->out_stream_;
+}
+
#if 0
// @@ TODO
ACE_INLINE CDR &
diff --git a/TAO/tao/IIOP_Object.cpp b/TAO/tao/IIOP_Object.cpp
index d209ca8a1b6..d4b8f8fb4f5 100644
--- a/TAO/tao/IIOP_Object.cpp
+++ b/TAO/tao/IIOP_Object.cpp
@@ -553,6 +553,11 @@ IIOP_Object::do_static_call (CORBA::Environment &env, // exception reporting
call.get_value (pdp->tc, ptr, env);
else
{
+ // @@ (ASG) - I think we must completely get rid of this
+ // case because IDL compiler generated stubs will use
+ // this function and they better allocate all the
+ // memory.
+
// assert (value_size == tc->size());
*(void **)ptr = new CORBA::Octet [pdp->value_size];
call.get_value (pdp->tc, *(void **)ptr, env);
@@ -619,8 +624,19 @@ IIOP_Object::do_dynamic_call (const char *opname, // operation nam
if (value->flags () == CORBA::ARG_IN
|| value->flags () == CORBA::ARG_INOUT)
{
- call.put_param (value->value ()->type (),
- (void *) value->value ()->value (), env);
+ // if the Any owns the data, then we already have a CDR encoded
+ // data
+ if (value->value ()->any_owns_data_)
+ {
+ TAO_OutputCDR &cdr = call.out_stream ();
+ TAO_InputCDR in (value->value ()->cdr_);
+ cdr.append (value->value ()->type (), &in, env);
+ }
+ else
+ {
+ call.put_param (value->value ()->type (),
+ (void *) value->value ()->value_, env);
+ }
if (env.exception ())
{
dexc (env, "do_dynamic_call, put request parameter");
@@ -654,6 +670,10 @@ IIOP_Object::do_dynamic_call (const char *opname, // operation nam
{
if (result != 0)
{
+#if 0
+ // @@ (ASG) I need to look into this OUT_LIST_MEMORY stuff
+ // (4/21/98).
+
// If caller didn't set OUT_LIST_MEMORY flag, allocate
// memory for return value ...
@@ -676,18 +696,56 @@ IIOP_Object::do_dynamic_call (const char *opname, // operation nam
dexc (env, "do_dynamic_call, set result mem");
}
}
+#endif
+ if (!result->value ()->value_)
+ {
+ // storage was not allocated. In this case, we simply grab
+ // the portion of the CDR stream that contained this
+ // parameter, The application should use the appropriate >>=
+ // operator to retrieve the value
+ char *begin, *end;
+ TAO_InputCDR temp (call.inp_stream ());
+ CORBA::TypeCode::traverse_status retval;
+ CORBA::Any *any = result->value ();
+
+ begin = call.inp_stream ().rd_ptr ();
+ // skip the parameter to get the ending position
+ retval = temp.skip (any->type (), env);
+ if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE)
+ {
+ end = temp.rd_ptr ();
+ any->cdr_ = new ACE_Message_Block (end - begin);
+ TAO_OutputCDR out (any->cdr_);
- call.get_value (result->value ()->type (),
- (void *) result->value ()->value (), env);
+ retval = out.append (any->type (),
+ &call.inp_stream (), env);
+ if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE)
+ {
+ any->any_owns_data_ = 1;
+ any->value_ = 0;
+ }
+ }
+ }
+ else
+ {
+ // the application had allocated the top level storage. We
+ // simply retrieve the data
+ call.get_value (result->value ()->type (),
+ (void *) result->value ()->value_, env);
+ }
}
for (i = 0; i < args->count (); i++)
{
CORBA::NamedValue_ptr value = args->item (i, env);
+ CORBA::Any *any = value->value ();
if (value->flags () == CORBA::ARG_OUT
|| value->flags () == CORBA::ARG_INOUT)
{
+#if 0
+ // @@ (ASG) need to deal with this
+
// If caller didn't set OUT_LIST_MEMORY flag, allocate
// memory for this parameter ...
if (!(flags & CORBA::OUT_LIST_MEMORY))
@@ -701,6 +759,8 @@ IIOP_Object::do_dynamic_call (const char *opname, // operation nam
if (size != 0)
{
+
+
void *ptr = new CORBA::Octet [size];
tcp->AddRef ();
@@ -709,9 +769,43 @@ IIOP_Object::do_dynamic_call (const char *opname, // operation nam
dexc (env, "do_dynamic_call, set result mem");
}
}
+#endif
- call.get_value (value->value ()->type (),
- (void *) value->value ()->value (), env);
+ if (!any->value_)
+ {
+ // storage was not allocated. In this case, we simply grab
+ // the portion of the CDR stream that contained this
+ // parameter, The application should use the appropriate >>=
+ // operator to retrieve the value
+ char *begin, *end;
+ TAO_InputCDR temp (call.inp_stream ());
+ CORBA::TypeCode::traverse_status retval;
+
+ begin = call.inp_stream ().rd_ptr ();
+ // skip the parameter to get the ending position
+ retval = temp.skip (any->type (), env);
+ if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE)
+ {
+ end = temp.rd_ptr ();
+ any->cdr_ = new ACE_Message_Block (end - begin);
+ TAO_OutputCDR out (any->cdr_);
+
+ retval = out.append (any->type (),
+ &call.inp_stream (), env);
+ if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE)
+ {
+ any->any_owns_data_ = 1;
+ any->value_ = 0;
+ }
+ }
+ }
+ else
+ {
+ // the application had allocated the top level
+ // storage. We simply retrieve the data
+ call.get_value (any->type (),
+ (void *) any->value_, env);
+ }
if (env.exception ())
{
dexc (env, "do_dynamic_call, get response parameter");
diff --git a/TAO/tao/NVList.cpp b/TAO/tao/NVList.cpp
index a6808686f8a..8d76977bfe7 100644
--- a/TAO/tao/NVList.cpp
+++ b/TAO/tao/NVList.cpp
@@ -11,7 +11,7 @@
CORBA::ULong
CORBA_NamedValue::AddRef (void)
{
- return refcount_++;
+ return this->refcount_++;
}
CORBA::ULong
@@ -24,10 +24,7 @@ CORBA_NamedValue::Release (void)
return this->refcount_;
}
- // delete this;
- // this is causing free mismatched memory error
- this->~CORBA_NamedValue ();
- ACE_OS::free (this);
+ delete this;
return 0;
}
@@ -53,11 +50,9 @@ CORBA_NamedValue::~CORBA_NamedValue (void)
CORBA::string_free (this->name_);
this->name_ = 0;
}
- // the Any will be destroyed on its own as we hold an instance and not a
- // pointer to Any
+ // the any will be destroyed by itself
}
-
// =Methods on class NVList
CORBA::ULong
@@ -97,15 +92,17 @@ CORBA::is_nil (CORBA::NVList_ptr nvl)
CORBA_NVList::~CORBA_NVList (void)
{
- // destroy each NamedValue element
- for (CORBA::ULong i = 0; i < this->max_; i++)
- (&this->values_[i])->~CORBA_NamedValue ();
+ // initialize an iterator and delete each NamedValue
+ ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> iter (this->values_);
- if (this->values_)
- ACE_OS::free ((char *)values_);
+ for (iter.first (); !iter.done (); iter.advance ())
+ {
+ CORBA::NamedValue_ptr *nv;
+ (void) iter.next (nv);
+ delete *nv;
+ }
- this->values_ = 0;
- this->len_ = this->max_ = 0;
+ this->max_ = 0;
}
// add an element and just initialize its flags
@@ -113,15 +110,8 @@ CORBA::NamedValue_ptr
CORBA_NVList::add (CORBA::Flags flags,
CORBA::Environment &env)
{
- CORBA::ULong len = this->len_; // next slot
-
// call the helper to allocate a NamedValue element (if necessary)
- if (!this->add_element (flags, env))
- return 0;
-
- // now initialize the fields
- this->values_[len].flags_ = flags;
- return &this->values_[len];
+ return this->add_element (flags, env);
}
// add an element and just initialize its flags and name
@@ -130,16 +120,17 @@ CORBA_NVList::add_item (const char *name,
CORBA::Flags flags,
CORBA::Environment &env)
{
- CORBA::ULong len = this->len_; // next slot
+ // call the helper to allocate a NamedValue element
+ CORBA::NamedValue_ptr nv = this->add_element (flags, env);
- // call the helper to allocate a NamedValue element (if necessary)
- if (!this->add_element (flags, env))
+ if (nv)
+ {
+ // now initialize the fields
+ nv->name_ = CORBA::string_dup (name);
+ return nv;
+ }
+ else
return 0;
-
- // now initialize the fields
- this->values_[len].flags_ = flags;
- this->values_[len].name_ = CORBA::string_dup (name);
- return &this->values_[len];
}
// add a value. If necessary, increment the list
@@ -149,46 +140,35 @@ CORBA_NVList::add_value (const char *name,
CORBA::Flags flags,
CORBA::Environment &env)
{
- CORBA::ULong len = this->len_; // next slot
-
- // call the helper to allocate a NamedValue element (if necessary)
- if (!this->add_element (flags, env))
- return 0;
+ // call the helper to allocate a NamedValue element
+ CORBA::NamedValue_ptr nv = this->add_element (flags, env);
- // now initialize the fields
- this->values_[len].flags_ = flags;
- this->values_[len].name_ = CORBA::string_dup (name); // make a copy
-
- if (ACE_BIT_ENABLED (flags, CORBA::IN_COPY_VALUE))
- // IN_COPY_VALUE means that the parameter is not "borrowed" by
- // the ORB, but rather that the ORB copies its value.
- //
- // Initialize the newly allocated memory using a copy
- // constructor that places the new "Any" value at just the right
- // place, and makes a "deep copy" of the data.
- (void) new (&this->values_[len].any_) CORBA::Any (value);
+ if (nv)
+ {
+ // now initialize the fields
+ nv->name_ = CORBA::string_dup (name);
+ if (ACE_BIT_ENABLED (flags, CORBA::IN_COPY_VALUE))
+ // IN_COPY_VALUE means that the parameter is not "borrowed" by
+ // the ORB, but rather that the ORB copies its value.
+ //
+ // Initialize the newly allocated memory using a copy
+ // constructor that places the new "Any" value at just the right
+ // place, and makes a "deep copy" of the data.
+ nv->any_ = value;
+ else
+
+ // The normal behaviour for parameters is that the ORB "borrows"
+ // their memory for the duration of calls.
+ //
+
+ nv->any_.replace (value.type (),
+ (void *) value.value_,
+ 0, env);
+
+ return nv;
+ }
else
-
- // The normal behaviour for parameters is that the ORB "borrows"
- // their memory for the duration of calls.
- //
- // Initialize the newly allocated "Any" using a normal
- // constructor that places the new "Any" value at just the right
- // place, yet doesn't copy the memory (except for duplicating
- // the typecode).
- //
- // NOTE: DSI has yet to be updated so that it's OK to use such
- // application-allocated memory. It needs at least a "send the
- // response now" call.
- //
- (void) new (&this->values_[len].any_) CORBA::Any (value.type (),
- (void *)value.value (),
- CORBA::B_FALSE); // does
- // not
- // own
-
- // return pointer to the newly inserted member
- return &this->values_[len];
+ return 0;
}
// add an element and just initialize its flags and name
@@ -197,30 +177,47 @@ CORBA_NVList::add_item_consume (char *name,
CORBA::Flags flags,
CORBA::Environment &env)
{
- CORBA::ULong len = this->len_; // next slot
- // call the helper to allocate a NamedValue element (if necessary)
- if (!this->add_element (flags, env))
- return 0;
+ // call the helper to allocate a NamedValue element
+ CORBA::NamedValue_ptr nv = this->add_element (flags, env);
- // now initialize the fields
- this->values_[len].flags_ = flags;
- this->values_[len].name_ = name; // we consume it
- return &this->values_[len];
+ if (nv)
+ {
+ // now initialize the fields
+
+ // consume the name
+ nv->name_ = name;
+ return nv;
+ }
+ else
+ return 0;
}
// add a value. If necessary, increment the list
CORBA::NamedValue_ptr
-CORBA_NVList::add_value_consume (char * /*name*/,
- CORBA::Any * /*value*/,
- CORBA::Flags /*flags*/,
- CORBA::Environment &/*env*/)
+CORBA_NVList::add_value_consume (char * name,
+ CORBA::Any * value,
+ CORBA::Flags flags,
+ CORBA::Environment & env)
{
- // not implemented because we need to see how we can consume the value
- // One soln is to make the any_ member of NamedValue to be a Any_ptr or
- // Any_var
- // @@ (ASG) - TODO
- return 0;
+ // call the helper to allocate a NamedValue element
+ CORBA::NamedValue_ptr nv = this->add_element (flags, env);
+
+ if (nv)
+ {
+ // now initialize the fields
+
+ // consume name
+ nv->name_ = name;
+
+ // consume the value @@ (ASG) have we? we may need to destroy the in
+ // parameter
+ nv->any_ = *value;
+ return nv;
+ }
+ else
+ return 0;
+
}
//CORBA::Status
@@ -233,7 +230,7 @@ CORBA_NVList::remove (CORBA::ULong /*n*/, CORBA::Environment &/*env*/)
}
// Helper method
-CORBA::Boolean
+CORBA::NamedValue_ptr
CORBA_NVList::add_element (CORBA::Flags flags, CORBA::Environment &env)
{
env.clear ();
@@ -243,44 +240,24 @@ CORBA_NVList::add_element (CORBA::Flags flags, CORBA::Environment &env)
return 0;
}
- // We track "len_" and "max_" like sequences do; mixing the
- // "add_arg" and nvlist[i] style accessors produces undefined
- // behaviour.
- CORBA::ULong len = this->len_++; // len_ points to the next available
- // slot. Access is by zero based indexing
+ CORBA::NamedValue_ptr nv;
- // Extend the array with an _initialized_ element ... relying on
- // zeroed memory to be sufficiently initialized.
- //
+ // allocate a new NamedValue
+ ACE_NEW_RETURN (nv, CORBA::NamedValue, 0);
- if (this->values_ == 0) // list was created as an empty list
- {
- this->values_ = (CORBA::NamedValue_ptr)
- ACE_OS::calloc (this->len_, sizeof (CORBA::NamedValue));
- this->max_ = this->len_;
- }
- else if (len >= max_) // need reallocation
+ // set the flags and enqueue in the queue
+ nv->flags_ = flags;
+ if (this->values_.enqueue_tail (nv) == -1)
{
- // reallocate a larger buffer
- this->values_ = (CORBA::NamedValue_ptr) ACE_OS::realloc
- ((char *)this->values_, sizeof (CORBA::NamedValue) * this->len_);
- // now zero the elements that have been newly allocated
- (void) ACE_OS::memset (&this->values_[this->max_], 0,
- sizeof (values_[this->max_]) * (this->len_ - this->max_));
- this->max_ = this->len_; // set the new maximum size
- }
- if (!this->values_)
- {
- env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
+ delete nv;
return 0;
}
- return 1; // success
+ this->max_++;
+ return nv; // success
}
-// This was inline, but didn't survive the removal of .i #includes
-// from corba.h. env.exception wasn't known. Maybe the circular
-// #includes between corba.h and ORB.h need to be removed.
+// return the item at location n
CORBA::NamedValue_ptr
CORBA_NVList::item (CORBA::ULong n, CORBA::Environment &env)
{
@@ -291,5 +268,18 @@ CORBA_NVList::item (CORBA::ULong n, CORBA::Environment &env)
return 0;
}
else
- return &this->values_ [n];
+ {
+ CORBA::NamedValue_ptr *nv;
+
+ this->values_.get (nv, n);
+ return *nv;
+ }
}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+template class ACE_Unbounded_Queue<CORBA::NamedValue_ptr>;
+template class ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr>;
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+#pragma instantiate ACE_Unbounded_Queue<CORBA::NamedValue_ptr>
+#pragma instantiate ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr>
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/tao/NVList.h b/TAO/tao/NVList.h
index 36ab8139896..52b48eac605 100644
--- a/TAO/tao/NVList.h
+++ b/TAO/tao/NVList.h
@@ -137,19 +137,16 @@ private:
// constructor - cannot be instantiated directly other than through the
// ORB::create_list method
- CORBA::Boolean add_element (CORBA::Flags, CORBA::Environment &);
+ CORBA::NamedValue_ptr add_element (CORBA::Flags, CORBA::Environment &);
// helper to increase the list size. This is used by all the add_ methods of
// the NVList class
- CORBA::NamedValue *values_;
- // list of parameters stored as NamedValues
+ ACE_Unbounded_Queue<CORBA::NamedValue_ptr> values_;
+ // internal list of parameters stored as NamedValues
CORBA::ULong max_;
// maximum length of list
- CORBA::ULong len_;
- // current length of list
-
CORBA::ULong refcount_;
// maintains how many references exist to this object
diff --git a/TAO/tao/NVList.i b/TAO/tao/NVList.i
index ae46118499b..5cd2155bc2e 100644
--- a/TAO/tao/NVList.i
+++ b/TAO/tao/NVList.i
@@ -1,3 +1,4 @@
+// $Id$
// This may look like C, but it's really -*- C++ -*-
// constructor
@@ -20,7 +21,7 @@ CORBA_NamedValue::name (void) const
ACE_INLINE CORBA::Any_ptr
CORBA_NamedValue::value (void) const
{
- return ACE_const_cast(CORBA::Any_ptr,&this->any_);
+ return ACE_const_cast (CORBA::Any_ptr, &this->any_);
}
// return the flags
@@ -36,9 +37,7 @@ CORBA_NamedValue::flags (void) const
// constructor
ACE_INLINE
CORBA_NVList::CORBA_NVList (void)
- : values_ (0),
- max_ (0),
- len_ (0),
+ : max_ (0),
refcount_ (1)
{
}
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index d2382e9c47c..81654fa4797 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -139,14 +139,11 @@ CORBA_ORB::create_list (CORBA::Long count,
// if count is greater than 0, create a list of NamedValues
if (count != 0)
{
- retval->len_ = 0;
retval->max_ = (CORBA::ULong) count;
- retval->values_ = (CORBA::NamedValue_ptr) ACE_OS::calloc ((u_int) count,
- sizeof (CORBA::NamedValue));
for (CORBA::Long i=0; i < count; i++)
{
- // initilaize the NamedValue
- (void) new (&retval->values_[i]) CORBA::NamedValue;
+ CORBA::NamedValue_ptr nv = new CORBA::NamedValue;
+ retval->values_.enqueue_tail (nv);
}
}
}
diff --git a/TAO/tao/Server_Request.cpp b/TAO/tao/Server_Request.cpp
index 97c3ee4f8c6..cc49eaf84a6 100644
--- a/TAO/tao/Server_Request.cpp
+++ b/TAO/tao/Server_Request.cpp
@@ -247,8 +247,8 @@ IIOP_ServerRequest::demarshal (CORBA::Environment &env, // exception reporting
CORBA::NVList_ptr nvlist;
- // Create an NVList of the appropriate size.
- this->orb ()->create_list (list_size, nvlist);
+ // Create an NVList
+ this->orb ()->create_list (0, nvlist);
// Now, put all "in" and "inout" parameters into the NVList.
CORBA::ULong i;
diff --git a/TAO/tao/append.cpp b/TAO/tao/append.cpp
index 43b2194c37f..01eba7c949b 100644
--- a/TAO/tao/append.cpp
+++ b/TAO/tao/append.cpp
@@ -382,32 +382,69 @@ TAO_Marshal_Union::append (CORBA::TypeCode_ptr tc,
switch (member_label->type ()->kind (env))
{
case CORBA::tk_short:
+ {
+ CORBA::Short s;
+ *member_label >>= s;
+ if (s == *(CORBA::Short *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_ushort:
- if (*(CORBA::Short *) member_label->value () ==
- *(CORBA::Short *) &discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::UShort s;
+ *member_label >>= s;
+ if (s == *(CORBA::UShort *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_long:
+ {
+ CORBA::Long l;
+ *member_label >>= l;
+ if (l == *(CORBA::Long *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_ulong:
+ {
+ CORBA::ULong l;
+ *member_label >>= l;
+ if (l == *(CORBA::ULong *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_enum:
- if (*(CORBA::ULong *) member_label->value () ==
- *(CORBA::ULong *) &discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Long l;
+ TAO_InputCDR stream ((ACE_Message_Block *)
+ member_label->value
+ ());
+ (void)stream.decode (discrim_tc, &l, 0, env);
+ if (l == *(CORBA::Long *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_char:
- if (*(CORBA::Char *) member_label->value () ==
- *(CORBA::Char *) &discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Char c;
+ *member_label >>= CORBA::Any::to_char (c);
+ if (c == *(CORBA::Char *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_wchar:
- if (*(CORBA::WChar *) member_label->value () ==
- *(CORBA::WChar *) &discrim_val)
+ // @@ ASG TO-DO
+ if (*(CORBA::WChar *) member_label->value ()
+ == *(CORBA::WChar *) &discrim_val)
discrim_matched = CORBA::B_TRUE;
break;
case CORBA::tk_boolean:
- if (*(CORBA::Boolean *) member_label->value () ==
- *(CORBA::Boolean *) &discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Boolean b;
+ *member_label >>= CORBA::Any::to_boolean (b);
+ if (b == *(CORBA::Boolean *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
default:
env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO));
diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp
index 5ffe49a84a1..391fd4dbfcb 100644
--- a/TAO/tao/decode.cpp
+++ b/TAO/tao/decode.cpp
@@ -859,32 +859,68 @@ TAO_Marshal_Union::decode (CORBA::TypeCode_ptr tc,
switch (member_label->type ()->kind (env))
{
case CORBA::tk_short:
+ {
+ CORBA::Short s;
+ *member_label >>= s;
+ if (s == *(CORBA::Short *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_ushort:
- if (*(CORBA::Short *) member_label->value () ==
- *(CORBA::Short *) discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::UShort s;
+ *member_label >>= s;
+ if (s == *(CORBA::UShort *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_long:
+ {
+ CORBA::Long l;
+ *member_label >>= l;
+ if (l == *(CORBA::Long *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_ulong:
+ {
+ CORBA::ULong l;
+ *member_label >>= l;
+ if (l == *(CORBA::ULong *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_enum:
- if (*(CORBA::ULong *) member_label->value () ==
- *(CORBA::ULong *) discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Long l;
+ TAO_InputCDR stream ((ACE_Message_Block *)
+ member_label->value
+ ());
+ (void)stream.decode (discrim_tc, &l, 0, env);
+ if (l == *(CORBA::Long *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_char:
- if (*(CORBA::Char *) member_label->value () ==
- *(CORBA::Char *) discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Char c;
+ *member_label >>= CORBA::Any::to_char (c);
+ if (c == *(CORBA::Char *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_wchar:
- if (*(CORBA::WChar *) member_label->value () ==
- *(CORBA::WChar *) discrim_val)
+ // @@ ASG TO-DO
+ if (*(CORBA::WChar *) member_label->value () == *(CORBA::WChar *) discrim_val)
discrim_matched = CORBA::B_TRUE;
break;
case CORBA::tk_boolean:
- if (*(CORBA::Boolean *) member_label->value () ==
- *(CORBA::Boolean *) discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Boolean b;
+ *member_label >>= CORBA::Any::to_boolean (b);
+ if (b == *(CORBA::Boolean *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
default:
env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO));
diff --git a/TAO/tao/encode.cpp b/TAO/tao/encode.cpp
index 56a656c8345..6e94ce148d9 100644
--- a/TAO/tao/encode.cpp
+++ b/TAO/tao/encode.cpp
@@ -545,27 +545,68 @@ TAO_Marshal_Union::encode (CORBA::TypeCode_ptr tc,
switch (member_label->type ()->kind (env))
{
case CORBA::tk_short:
+ {
+ CORBA::Short s;
+ *member_label >>= s;
+ if (s == *(CORBA::Short *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_ushort:
- if (*(CORBA::Short *) member_label->value () == *(CORBA::Short *) discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::UShort s;
+ *member_label >>= s;
+ if (s == *(CORBA::UShort *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_long:
+ {
+ CORBA::Long l;
+ *member_label >>= l;
+ if (l == *(CORBA::Long *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_ulong:
+ {
+ CORBA::ULong l;
+ *member_label >>= l;
+ if (l == *(CORBA::ULong *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_enum:
- if (*(CORBA::ULong *) member_label->value () == *(CORBA::ULong *) discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Long l;
+ TAO_InputCDR stream ((ACE_Message_Block *)
+ member_label->value
+ ());
+ (void)stream.decode (discrim_tc, &l, 0, env);
+ if (l == *(CORBA::Long *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_char:
- if (*(CORBA::Char *) member_label->value () == *(CORBA::Char *) discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Char c;
+ *member_label >>= CORBA::Any::to_char (c);
+ if (c == *(CORBA::Char *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_wchar:
+ // @@ ASG TO-DO
if (*(CORBA::WChar *) member_label->value () == *(CORBA::WChar *) discrim_val)
discrim_matched = CORBA::B_TRUE;
break;
case CORBA::tk_boolean:
- if (*(CORBA::Boolean *) member_label->value () == *(CORBA::Boolean *) discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Boolean b;
+ *member_label >>= CORBA::Any::to_boolean (b);
+ if (b == *(CORBA::Boolean *) discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
default:
env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO));
diff --git a/TAO/tao/skip.cpp b/TAO/tao/skip.cpp
index 9e3bc359952..b379393e202 100644
--- a/TAO/tao/skip.cpp
+++ b/TAO/tao/skip.cpp
@@ -431,32 +431,69 @@ TAO_Marshal_Union::skip (CORBA::TypeCode_ptr tc,
switch (member_label->type ()->kind (env))
{
case CORBA::tk_short:
+ {
+ CORBA::Short s;
+ *member_label >>= s;
+ if (s == *(CORBA::Short *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_ushort:
- if (*(CORBA::Short *) member_label->value () ==
- *(CORBA::Short *) &discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::UShort s;
+ *member_label >>= s;
+ if (s == *(CORBA::UShort *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_long:
+ {
+ CORBA::Long l;
+ *member_label >>= l;
+ if (l == *(CORBA::Long *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_ulong:
+ {
+ CORBA::ULong l;
+ *member_label >>= l;
+ if (l == *(CORBA::ULong *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
+ break;
case CORBA::tk_enum:
- if (*(CORBA::ULong *) member_label->value () ==
- *(CORBA::ULong *) &discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Long l;
+ TAO_InputCDR stream ((ACE_Message_Block *)
+ member_label->value
+ ());
+ (void)stream.decode (discrim_tc, &l, 0, env);
+ if (l == *(CORBA::Long *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_char:
- if (*(CORBA::Char *) member_label->value () ==
- *(CORBA::Char *) &discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Char c;
+ *member_label >>= CORBA::Any::to_char (c);
+ if (c == *(CORBA::Char *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
case CORBA::tk_wchar:
- if (*(CORBA::WChar *) member_label->value () ==
- *(CORBA::WChar *) &discrim_val)
+ // @@ ASG TO-DO
+ if (*(CORBA::WChar *) member_label->value ()
+ == *(CORBA::WChar *) &discrim_val)
discrim_matched = CORBA::B_TRUE;
break;
case CORBA::tk_boolean:
- if (*(CORBA::Boolean *) member_label->value () ==
- *(CORBA::Boolean *) &discrim_val)
- discrim_matched = CORBA::B_TRUE;
+ {
+ CORBA::Boolean b;
+ *member_label >>= CORBA::Any::to_boolean (b);
+ if (b == *(CORBA::Boolean *) &discrim_val)
+ discrim_matched = CORBA::B_TRUE;
+ }
break;
default:
env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO));
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/Makefile b/TAO/tests/Cubit/TAO/IDL_Cubit/Makefile
index 7e9fa7cee35..3ec49b0f086 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/Makefile
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/Makefile
@@ -14,14 +14,14 @@ ifndef TAO_ROOT
TAO_ROOT = $(ACE_ROOT)/TAO
endif # ! TAO_ROOT
-LDLIBS = -lorbsvcs -lTAO
+LDLIBS = -lorbsvcs -lTAO
IDL_SRC = cubitC.cpp cubitS.cpp
-PROG_SRCS = $(IDL_SRC) server.cpp client.cpp tmplinst.cpp
+PROG_SRCS = $(IDL_SRC) server.cpp client.cpp tmplinst.cpp
LSRC = $(PROG_SRCS)
-CUBIT_SVR_OBJS = cubitC.o cubitS.o server.o cubit_i.o tmplinst.o
+CUBIT_SVR_OBJS = cubitC.o cubitS.o server.o cubit_i.o tmplinst.o
CUBIT_CLT_OBJS = cubitC.o cubitS.o client.o tmplinst.o
TEST_OBJS = IDL_Cubit_Test.o
@@ -57,6 +57,7 @@ server: $(addprefix $(VDIR),$(CUBIT_SVR_OBJS))
client: $(addprefix $(VDIR),$(CUBIT_CLT_OBJS))
$(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK)
+
IDL_Cubit_Test: $(addprefix $(VDIR),$(TEST_OBJS))
$(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK)
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/client.cpp b/TAO/tests/Cubit/TAO/IDL_Cubit/client.cpp
index 671b66123ee..58ebfecd79e 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/client.cpp
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/client.cpp
@@ -206,7 +206,7 @@ Cubit_Client::cube_union_dii (void)
}
// ... initialise the argument list and result ...
- Cubit::oneof *u, r;
+ Cubit::oneof *u, *r;
u = new Cubit::oneof;
u->_d (Cubit::e_3rd);
@@ -230,12 +230,11 @@ Cubit_Client::cube_union_dii (void)
return;
}
- // @@ Naga, please check with Andy and see if we can update all uses
- // of the Any methods with the new <<= and >>= operators. Please
- // make sure you document what is going on here if you do this.
+ // set the result's typecode to indicate what we expect. Let the ORB allocate
+ // the memory
req->result ()->value ()->replace (Cubit::_tc_oneof,
0,
- CORBA::B_TRUE,
+ 0,
this->env_);
if (this->env_.exception () != 0)
@@ -258,9 +257,17 @@ Cubit_Client::cube_union_dii (void)
return;
}
- r = *(Cubit::oneof *) req->result ()->value ()->value ();
+ // retrieve the value in "r". Note that we don't own the memory that the ORb
+ // has allocated
+ if (!((*req->result ()->value ()) >>= r))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Error retrieving union oneof via the >>= operator\n"));
+ CORBA::release (req);
+ return;
+ }
- if (r.cm ().o != 27 || r.cm ().l != 125 || r.cm ().s != -343)
+ if (r->cm ().o != 27 || r->cm ().l != 125 || r->cm ().s != -343)
{
this->error_count_++;
ACE_ERROR ((LM_ERROR, "cube_union_dii -- bad results\n"));
@@ -483,7 +490,7 @@ Cubit_Client::cube_struct_dii (void)
// ... initialise the argument list and result ...
Cubit::Many arg;
- Cubit::Many result;
+ Cubit::Many *result;
arg.o = 3;
arg.l = 5;
@@ -502,9 +509,10 @@ Cubit_Client::cube_struct_dii (void)
return;
}
+ // set the typecode for the result and expect the ORB to allocate the memory
req->result ()->value ()->replace (Cubit::_tc_Many,
0,
- CORBA::B_TRUE,
+ 0,
this->env_);
if (this->env_.exception () != 0)
@@ -525,9 +533,15 @@ Cubit_Client::cube_struct_dii (void)
return;
}
- result = *(Cubit::Many *) req->result ()->value ()->value ();
+ if (!((*req->result ()->value ()) >>= result))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Error retrieving struct Many via the >>= operator\n"));
+ CORBA::release (req);
+ return;
+ }
- if (result.o != 27 || result.l != 125 || result.s != -343)
+ 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!!");
diff --git a/TAO/tests/Param_Test/tests.cpp b/TAO/tests/Param_Test/tests.cpp
index 845beb5d0e7..7d5f5bbf083 100644
--- a/TAO/tests/Param_Test/tests.cpp
+++ b/TAO/tests/Param_Test/tests.cpp
@@ -78,6 +78,7 @@ Test_Short::add_args (CORBA::NVList_ptr &param_list,
CORBA::NVList_ptr &retval,
CORBA::Environment &env)
{
+ // we provide top level memory to the ORB to retrieve the data
CORBA::Any in_arg (CORBA::_tc_short, &this->in_, 0);
CORBA::Any inout_arg (CORBA::_tc_short, &this->inout_, 0);
CORBA::Any out_arg (CORBA::_tc_short, &this->out_, 0);
@@ -87,9 +88,10 @@ Test_Short::add_args (CORBA::NVList_ptr &param_list,
(void)param_list->add_value ("s2", inout_arg, CORBA::ARG_INOUT, env);
(void)param_list->add_value ("s3", out_arg, CORBA::ARG_OUT, env);
- // add return value
+ // add return value. Let the ORB allocate storage. We simply tell the ORB
+ // what type we are expecting.
(void)retval->item (0, env)->value ()->replace (CORBA::_tc_short,
- &this->ret_,
+ 0, // no value
0, // does not own
env);
return 0;
@@ -110,9 +112,15 @@ CORBA::Boolean
Test_Short::check_validity (CORBA::Request_ptr req)
{
CORBA::Environment env;
- this->inout_ = *(CORBA::Short *) req->arguments ()->item (1, env)->value ()->value ();
- this->out_ = *(CORBA::Short *) req->arguments ()->item (2, env)->value ()->value ();
- this->ret_ = *(CORBA::Short *)req->result ()->value ()->value ();
+#if 0
+ // commented out since we really don't need to this as we have provided the
+ // ORB with the memory
+ *req->arguments ()->item (1, env)->value () >>= this->inout_;
+ *req->arguments ()->item (2, env)->value () >>= this->out_;
+#endif
+ // we must retrieve the return value since we aske dthe ORB to allocate the
+ // memory.
+ *req->result ()->value () >>= this->ret_;
return this->check_validity ();
}
@@ -227,7 +235,7 @@ Test_Unbounded_String::add_args (CORBA::NVList_ptr &param_list,
// add return value
(void)retval->item (0, env)->value ()->replace (CORBA::_tc_string,
- &this->ret_,
+ 0, // ORB will allocate
0, // does not own
env);
return 0;
@@ -252,9 +260,9 @@ CORBA::Boolean
Test_Unbounded_String::check_validity (CORBA::Request_ptr req)
{
CORBA::Environment env;
- this->inout_ = *(char **) req->arguments ()->item (1, env)->value ()->value ();
- this->out_ = *(char **) req->arguments ()->item (2, env)->value ()->value ();
- this->ret_ = *(char **)req->result ()->value ()->value ();
+ // only retrieve the return value. No need to retrieve the out and inout
+ // because we had provided the memory and we own it.
+ *req->result ()->value () >>= this->ret_;
return this->check_validity ();
}
@@ -336,6 +344,7 @@ Test_Fixed_Struct::add_args (CORBA::NVList_ptr &param_list,
CORBA::NVList_ptr &retval,
CORBA::Environment &env)
{
+ // We provide the top level memory
// the Any does not own any of these
CORBA::Any in_arg (Param_Test::_tc_Fixed_Struct, &this->in_, 0);
CORBA::Any inout_arg (Param_Test::_tc_Fixed_Struct, &this->inout_, 0);
@@ -346,9 +355,9 @@ Test_Fixed_Struct::add_args (CORBA::NVList_ptr &param_list,
(void)param_list->add_value ("s2", inout_arg, CORBA::ARG_INOUT, env);
(void)param_list->add_value ("s3", out_arg, CORBA::ARG_OUT, env);
- // add return value
+ // add return value type
(void)retval->item (0, env)->value ()->replace (Param_Test::_tc_Fixed_Struct,
- &this->ret_,
+ 0, // let the ORB allocate
0, // does not own
env);
return 0;
@@ -387,11 +396,12 @@ CORBA::Boolean
Test_Fixed_Struct::check_validity (CORBA::Request_ptr req)
{
CORBA::Environment env;
- this->inout_ = *(Param_Test::Fixed_Struct *) req->arguments ()->item (1, env)
- ->value ()->value ();
- this->out_ = *(Param_Test::Fixed_Struct *) req->arguments ()->item (2, env)
- ->value ()->value ();
- this->ret_ = *(Param_Test::Fixed_Struct *)req->result ()->value ()->value ();
+
+ // we have forced the ORB to allocate memory for the return value so that we
+ // can test the >>= operator
+ Param_Test::Fixed_Struct *ret;
+ *req->result ()->value () >>= ret;
+ this->ret_ = *ret;
return this->check_validity ();
}
@@ -554,16 +564,17 @@ Test_String_Sequence::add_args (CORBA::NVList_ptr &param_list,
{
CORBA::Any in_arg (Param_Test::_tc_StrSeq, (void *) &this->in_.in (), 0);
CORBA::Any inout_arg (Param_Test::_tc_StrSeq, &this->inout_.inout (), 0);
- CORBA::Any out_arg (Param_Test::_tc_StrSeq, this->out_.out (), 0);
+ // ORB will allocate
+ CORBA::Any out_arg (Param_Test::_tc_StrSeq, 0, 0);
// add parameters
(void)param_list->add_value ("s1", in_arg, CORBA::ARG_IN, env);
(void)param_list->add_value ("s2", inout_arg, CORBA::ARG_INOUT, env);
(void)param_list->add_value ("s3", out_arg, CORBA::ARG_OUT, env);
- // add return value
+ // add return value type
(void)retval->item (0, env)->value ()->replace (Param_Test::_tc_StrSeq,
- &this->ret_,
+ 0,
0, // does not own
env);
return 0;
@@ -595,12 +606,15 @@ CORBA::Boolean
Test_String_Sequence::check_validity (CORBA::Request_ptr req)
{
CORBA::Environment env;
- this->inout_ = new Param_Test::StrSeq (*(Param_Test::StrSeq *) req->arguments
- ()->item (1, env)->value ()->value ());
- this->out_ = new Param_Test::StrSeq (*(Param_Test::StrSeq *) req->arguments
- ()->item (2, env)->value ()->value ());
- this->ret_ = new Param_Test::StrSeq (*(Param_Test::StrSeq *)req->result
- ()->value ()->value ());
+
+ Param_Test::StrSeq *out, *ret;
+
+ *req->arguments ()->item (2, env)->value () >>= out;
+ *req->result ()->value () >>= ret;
+
+ this->out_ = out;
+ this->ret_ = ret;
+
return this->check_validity ();
}