Return-Path: Delivered-To: apmail-ws-axis-c-dev-archive@www.apache.org Received: (qmail 87248 invoked from network); 8 Sep 2004 04:33:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Sep 2004 04:33:01 -0000 Received: (qmail 60000 invoked by uid 500); 8 Sep 2004 04:32:52 -0000 Delivered-To: apmail-ws-axis-c-dev-archive@ws.apache.org Received: (qmail 59963 invoked by uid 500); 8 Sep 2004 04:32:51 -0000 Mailing-List: contact axis-c-dev-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: List-Id: "Apache AXIS C Developers List" Reply-To: "Apache AXIS C Developers List" Delivered-To: mailing list axis-c-dev@ws.apache.org Received: (qmail 59880 invoked by uid 99); 8 Sep 2004 04:32:50 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [209.68.1.20] (HELO relay.pair.com) (209.68.1.20) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 07 Sep 2004 21:32:49 -0700 Received: (qmail 41424 invoked from network); 8 Sep 2004 04:32:37 -0000 Received: from unknown (HELO SusanthaNB) (202.69.192.7) by relay.pair.com with SMTP; 8 Sep 2004 04:32:37 -0000 X-pair-Authenticated: 202.69.192.7 From: "Susantha Kumara" To: "'Apache AXIS C Developers List'" Subject: RE: Few questions on values returned to Stubs Date: Wed, 8 Sep 2004 10:31:57 +0600 Message-ID: <000101c4955c$e0e60f80$b8c2a8c0@SusanthaNB> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-Reply-To: <20040907035413.32025.qmail@web40606.mail.yahoo.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N > -----Original Message----- > From: Samisa Abeysinghe [mailto:samisa_abeysinghe@yahoo.com] > 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 code > always return a pointer in > case of returning class objects. In other words, is it possible to return > 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 allocate > 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 generated > 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? Yes. > In other > words, is it possible that > the generated code return a pointer to an array struct? Also why are we > 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 the > 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 Axis_Array > struct. And we cast the > result to SOAPStruct_Array. (Note that they are structs and not classes. > 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 here? 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! > http://promotions.yahoo.com/new_mail