axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Susantha Kumara" <>
Subject RE: Few questions on values returned to Stubs
Date Wed, 08 Sep 2004 04:31:57 GMT

> -----Original Message-----
> From: Samisa Abeysinghe []
> Sent: Tuesday, September 07, 2004 9:54 AM
> To: Apache AXIS C Developers List
> Subject: Few questions on values returned to Stubs
> Hi All,
>    I have few doubts to clarify regarding the values reurned by the
> generated code.
>    I will use the 'base' sample to explain my questions.
> 1. The generated code has a method with signature:
>     SOAPStruct* echoStruct(SOAPStruct* Value0);
> SOAPStruct here is a class. My question is that will the generated
> always return a pointer in
> case of returning class objects. In other words, is it possible to
> an object by value from
> a method call?

This is the convention used in the generated code by WSDL2Ws tool. All
complex types are passed/returned by reference(pointers) and basic types
and Arrays are passed/returned by value. 

These conventions are documented in CAXRPC (C API for XML RPC) draft
which is incomplete yet.

> 2. The SOAPStruct class has a member with the signature:
>     xsd__string varString;
> Here xsd__string is basically char* and destructor uses malloc to
> memory for this member.
> However destructor of SOAPStruct class does not release the varString
> member.
> Hence in the user written code, I have to release the varString member
> explicitly.
> e.g.
>     SOAPStruct* stctResult = ws.echoStruct (&stct);
>     // Do stuff
>     // clean memory
>     free(stctResult->varString);
> Can we update the code generation tool to clean up char* members from
> class destructor? Is there
> any specific reason not to do this?

No you can safely add Clean up code generation. Please remove the line "
/*delete any pointer and array members here*/ " when you have done the
clean up code generation.

> 3. As I mentioned in an earlier email, in case of arrays, the
> code use stucts
> e.g.
> typedef struct SOAPStruct_ArrayTag
> {
>         SOAPStruct* m_Array;
>         int m_Size;
> } SOAPStruct_Array;
> Arrays are returned by value.
> e.g.
>     SOAPStruct_Array echoStructArray(SOAPStruct_Array Value0);
>   3.1 In case of array structs, do we always retun by value? 


> In other
> words, is it possible that
> the generated code return a pointer to an array struct? Also why are
> not returning a pointer in
> case of array struct?

This is convention (design decision) because
	- If we return a pointer we have to manage the memory
allocation/deallocation for the Array struct too. By adhering to this
convention we can avoid that.

>   3.2 In this case I have to use the assignment operator to hold the
> return value
> e.g.
>     SOAPStruct_Array arrstctResult = ws.echoStructArray (arrstct);
>       Is this syntax correct?

Yes. Usually when you assign a struct to another instance all its
members are copied. But I am not sure whether there are compilers that
do not do this.
>   3.3 When I look in the generated code for echo array of struct I see
> following:
>       RetArray = (SOAPStruct_Array&)m_pCall->getCmplxArray((void*)
> Axis_DeSerialize_SOAPStruct, (v
> oid*) Axis_Create_SOAPStruct, (void*) Axis_Delete_SOAPStruct, (void*)
> Axis_GetSize_SOAPStruct,
> "return", Axis_URI_SOAPStruct
> );
>       Here the getCmplxArray method of Call class returns an
> struct. And we cast the
> result to SOAPStruct_Array. (Note that they are structs and not
> Hence there is no
> inheritance here) How correct is this cast (casting one struct type to
> another)? It may work but
> it looks like therer is something wrong. Or am I missing something

What we do here is just copying the struct returned by getComplexArray
to RetArray. This is like using memcpy because we know for sure that
memory layout of Axis_Array and SOAPStruct_Array is the same. So this
casting is just to say the compiler to treat the returned Axis_Array as
a SOAPStruct_Array.
> Your help on this is highly appreciated.
> Thanks,
> Samisa...
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail is new and improved - Check it out!

View raw message