You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Lefrancois, Carl" <Ca...@axa-canada.com> on 2008/05/30 16:29:58 UTC

discussion: adding support for polymorphism in ADB C code generator

On Thu, May 29, 2008 at 8:02 PM, Lefrancois, Carl
<Ca...@axa-canada.com> wrote:
>>>I'm developing a patch against the ADB C code generator to allow it 
>>>to
> handle polymorphism correctly...
>
>>>Say you have a complexType A, which is abstract. Then there are
> complexTypes A1 and A2, which extend A and are not abstract.
>
>>>The second case, however, is quite problematic... 

>Hi Carl,

>Here 'A' have to aware of the fact A1 and A2 are inheriting from it. In
current codegen implementation it is bit hard to implement. (need to
change the codegen engine implementation). The best thing is let the
mapping to do from external file, (some corresponding file to
'ExtensionMapper.java'). So I will change your suggested code to
something like this..

Hi Dimuthu,

Agreed, your change is a more elegant way to code each ADB object's
serializer.

However, shouldn't there also be an external mapping of the
is_particle() function if we want to keep sub-type details out of A's
definition in this case?

i.e. (changes marked with ***>  )


void adb_A_serialize(void *element, ....)
{

     /* serialize 'A' s element first */
     if(!adb_A_is_particle())
     {
         axutil_stream_write(stream, env, start_input_str,
start_input_str_len);
     }

     serialize_content_func =
axis2_extension_mapper_get_serialize_content_func(element);
***> is_particle_func =
axis2_extension_mapper_get_is_particle_func(element);

     serialize_content_func(element,
                                              env,
                                              current_node,
parent_element,
***>             is_particle_func() || AXIS2_FALSE, namespaces,
next_ns_index);


     if(!adb_A_is_particle())
     {
         axutil_stream_write(stream, env, end_input_str,
end_input_str_len);
     }

}

And in the mapper:
/* for example for is_particle function */

typedef void (*ret_func_ptr)();

ret_func_ptr axis2_extension_mapper_get_is_particle_func() {
   if(strcmp((axis2_char_t*)(element), "A1"))
   {
        return adb_A1_is_particle;
   }
   if(strcmp((axis2_char_t*)(element), "A2"))
   {
        return adb_A2_is_particle;
   }
}


It looks like a working solution is not far :)
Regards, 
Carl
  _____  

"Ce message est confidentiel, a l'usage exclusif du destinataire
ci-dessus et son contenu ne represente en aucun cas un engagement de la
part de AXA, sauf en cas de stipulation expresse et par ecrit de la part
de AXA. Toute publication, utilisation ou diffusion, meme partielle,
doit etre autorisee prealablement. Si vous n'etes pas destinataire de ce
message, merci d'en avertir immediatement l'expediteur."

"This e-mail message is confidential, for the exclusive use of the
addressee and its contents shall not constitute a commitment by AXA,
except as otherwise specifically provided in writing by AXA. Any
unauthorized disclosure, use or dissemination, either whole or partial,
is prohibited. If you are not the intended recipient of the message,
please notify the sender immediately."

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org


Re: discussion: adding support for polymorphism in ADB C code generator

Posted by Dimuthu Gamage <di...@gmail.com>.
Hi Carl,

Here the particle is for either group or for nested/inner type.

for an example

<complexType name="xx"> <!-- this is not a particle class -->
  <sequence>
    <sequence> <!-- this corresponds to a particle class -->
      <element ../>
    </sequence>
    <choice> <!-- this corresponds to a particle class -->
      <element ../>
    </choice>
  </sequence>
</complexType>

So as you can see particle classes can not be inherited. Since they
don't have names. So I think we can assume whether it is a partial or
not by the behavior of the parent itself. So we can continue with what
Sergio is suggsted.

Thanks
Dimuthu


On Fri, May 30, 2008 at 7:59 PM, Lefrancois, Carl
<Ca...@axa-canada.com> wrote:
> On Thu, May 29, 2008 at 8:02 PM, Lefrancois, Carl
> <Ca...@axa-canada.com> wrote:
>>>>I'm developing a patch against the ADB C code generator to allow it
>>>>to
>> handle polymorphism correctly...
>>
>>>>Say you have a complexType A, which is abstract. Then there are
>> complexTypes A1 and A2, which extend A and are not abstract.
>>
>>>>The second case, however, is quite problematic...
>
>>Hi Carl,
>
>>Here 'A' have to aware of the fact A1 and A2 are inheriting from it. In
> current codegen implementation it is bit hard to implement. (need to
> change the codegen engine implementation). The best thing is let the
> mapping to do from external file, (some corresponding file to
> 'ExtensionMapper.java'). So I will change your suggested code to
> something like this..
>
> Hi Dimuthu,
>
> Agreed, your change is a more elegant way to code each ADB object's
> serializer.
>
> However, shouldn't there also be an external mapping of the
> is_particle() function if we want to keep sub-type details out of A's
> definition in this case?
>
> i.e. (changes marked with ***>  )
>
>
> void adb_A_serialize(void *element, ....)
> {
>
>     /* serialize 'A' s element first */
>     if(!adb_A_is_particle())
>     {
>         axutil_stream_write(stream, env, start_input_str,
> start_input_str_len);
>     }
>
>     serialize_content_func =
> axis2_extension_mapper_get_serialize_content_func(element);
> ***> is_particle_func =
> axis2_extension_mapper_get_is_particle_func(element);
>
>     serialize_content_func(element,
>                                              env,
>                                              current_node,
> parent_element,
> ***>             is_particle_func() || AXIS2_FALSE, namespaces,
> next_ns_index);
>
>
>     if(!adb_A_is_particle())
>     {
>         axutil_stream_write(stream, env, end_input_str,
> end_input_str_len);
>     }
>
> }
>
> And in the mapper:
> /* for example for is_particle function */
>
> typedef void (*ret_func_ptr)();
>
> ret_func_ptr axis2_extension_mapper_get_is_particle_func() {
>   if(strcmp((axis2_char_t*)(element), "A1"))
>   {
>        return adb_A1_is_particle;
>   }
>   if(strcmp((axis2_char_t*)(element), "A2"))
>   {
>        return adb_A2_is_particle;
>   }
> }
>
>
> It looks like a working solution is not far :)
> Regards,
> Carl
>  _____
>
> "Ce message est confidentiel, a l'usage exclusif du destinataire
> ci-dessus et son contenu ne represente en aucun cas un engagement de la
> part de AXA, sauf en cas de stipulation expresse et par ecrit de la part
> de AXA. Toute publication, utilisation ou diffusion, meme partielle,
> doit etre autorisee prealablement. Si vous n'etes pas destinataire de ce
> message, merci d'en avertir immediatement l'expediteur."
>
> "This e-mail message is confidential, for the exclusive use of the
> addressee and its contents shall not constitute a commitment by AXA,
> except as otherwise specifically provided in writing by AXA. Any
> unauthorized disclosure, use or dissemination, either whole or partial,
> is prohibited. If you are not the intended recipient of the message,
> please notify the sender immediately."
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-dev-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org