[omniORB] Returning complex types from server

Clarke Brunt clarke.brunt at trafficmaster.co.uk
Tue Apr 26 16:09:41 BST 2005


> -----Original Message-----
> From: omniorb-list-bounces at omniorb-support.com 
> [mailto:omniorb-list-bounces at omniorb-support.com] On Behalf 
> Of Frederico Faria
>
>  I have a general doubt about CORBA. I want return a
> struct composed from another struct from my corba
> server. But it looks that my returned struct is empty
> when the client trys print its fields.
> How can I do the right memory allocation in the server
> to return correctly the struct ?
> 
> Example: ( it doesnt work )
> 
>   struct MyTime {
> short   day;
> short   month;
> short   year;
> short   second;
> short   minute;
> short   hour;
> };
> 
>   struct MyEvent {
>    short eventType;   
>    MyTime eventTime;
> }
> interface  I1 
> {
>   MyEvent   getEvent()
> }
> ---------------------------------------------
> // generated serevr implementation code
> 
>  MyEvent getEvent()
> {
>   MyEvent  event;
>  // some code
>   
>  return  event;
> }

I can't see anything wrong. You have a fixed length struct (one of its
members happens to be another fixed length struct). Fixed length struct is
returned from a method by value, so the signature of your getEvent method is
correct, and it shouldn't matter that 'event' is a local variable in
getEvent(), since a copy of it is being returned.

Unless I'm missing something (or indeed there's a bug - possibly I never
used a fixed length struct myself), then I can only suggest you trying more
experiments. Try something just returning an integer. Then try a struct that
_doesn't_ have another struct as a member. etc...

-- 
Clarke Brunt, Principal Software Engineer, Trafficmaster




More information about the omniORB-list mailing list