[omniORB] omniORB3 string_member mapping for structured types.

Sai-Lai Lo S.Lo@uk.research.att.com
26 Jan 2000 11:19:06 +0000


Thanks for pointing out this change in the 2.3 mapping.

This is a change in CORBA 2.3 mapping. Prior to 2.3, the mapping is to
initialise the string member to NULL, which is what omniORB has been doing
all along. Somehow this change does not have the change bar attached to the
text so it has been overlooked.

I suggest you not to rely on this behaviour. Instead, always initialise the
member yourself. It seems to me this change is inconsistent with the rest
of the string mapping. For instance, the string pointer managed by a
String_var is initialised to a NULL pointer. The mapping of a string is a
char* which obviously is not initialised to anything. To avoid confusion, I
think it is better to initialise a string member of a struct, union or
sequence explicitly.

The ORB already checks if a string member is a NULL pointer when it
marshals a struct. If it is, the ORB marshals an empty string. But again,
don't rely on this behaviour if you want your code to be fully portable.

We'll update the string member to initialise to an empty string (""). I'll
probably initialise it to point to a statically allocated empty string so
as to avoid heap allocating an empty string everytime.

Sai-Lai



>>>>> Terry A Lee writes:

> In Section 1.9 of the OMG C++ mapping specification (June 1999)
> they state that "The mapping for struct, union, and sequence is a
> C++ struct or class with a default constructor, a copy constructor,
> an assignment operator, and a destructor. The default constructor
> initializes object reference members to appropriately-typed nil
> object references, and string members and wide string members to
> the empty string ("" and L"", respectively). All other members
> are initialized via their default constructors."

> However I noticed in stringtypes.h that the omniORB string_member
> constructor called to initialize strings in a structure builds a
> null pointer for pd_data and not a pointer to "".

> inline _CORBA_String_member() : pd_data(0), pd_rel(1), _ptr(pd_data) {}

> Perhaps I have misunderstood something here?

> Environment NT 4.0 SP5, Sparc Solaris 2.6





-- 
Sai-Lai Lo                                   S.Lo@uk.research.att.com
AT&T Laboratories Cambridge           WWW:   http://www.uk.research.att.com 
24a Trumpington Street                Tel:   +44 1223 343000
Cambridge CB2 1QA                     Fax:   +44 1223 313542
ENGLAND