[omniORB] OmniORBpy & TypeDefs

Gary D. Duzan gdd0@gte.com
Tue, 22 Aug 2000 09:59:42 -0400


In Message <39A28276.8BE42C8D@i5.informatik.rwth-aachen.de> ,
   Marcus Gruendler <runner@i5.informatik.rwth-aachen.de> wrote:

=>Here is a part of my code. The first declaration of getEntries generates a IDL
=>compiler error, the second one doesn't and produces working code.
=>
=>typedef struct EntryDataStruct
=>{
=>	string name;
=>	long   type;
=>	long   ID;
=>} EntryData;
=>
=>typedef sequence<EntryData> Entries;
=>
=>interface RepoReader
=>{
=>	// Error:
=>	sequence<EntryData> getEntries(in string name);
=>
=>	// Correct:
=>	Entries getEntries(in string name);	
=>}

   The Error example is disallowed to avoid the problem of having
an anonymous sequence type. This isn't a problem in Python since
a sequence maps to an untyped Python sequence (i.e. tuple or list),
but languages such as C++ have to construct a type to represent
it, and for the user code to be able to construct an instance of
that type to return, it needs a name.
   Structures, on the other hand, have a typedef built in, so you
can replace your above declaration with:

===========================================================================
struct EntryData
{
	string name;
	long   type;
	long   ID;
}

typedef sequence<EntryData> Entries;

interface RepoReader
{
	Entries getEntries(in string name);
}
===========================================================================

with no loss (except for the redundant EntryDataStruct name.)

					Gary Duzan
					Verizon Laboratories