diff --git a/src/java/com/eprosima/microcdr/idl/templates/MicroCdrCommon.stg b/src/java/com/eprosima/microcdr/idl/templates/MicroCdrCommon.stg index afca7f4..571a8d2 100644 --- a/src/java/com/eprosima/microcdr/idl/templates/MicroCdrCommon.stg +++ b/src/java/com/eprosima/microcdr/idl/templates/MicroCdrCommon.stg @@ -43,11 +43,22 @@ $if(params)$$separatorInicial$$endif$$params : {param | /*$param.comment$*/ $par >> object_serialization(ctx, object, preffix) ::= << -scdr << $serializeCasting(typecode=object.typecode)$$preffix$$object.name$; +$if(object.typecode.primitive)$serialize_$object.typecode.cppTypename$(writer, topic->$preffix$$object.name$); +$elseif(object.typecode.isType_d)$ +serialize_uint32_t(writer, strlen(topic->$preffix$$object.name$) + 1); +serialize_array_char(writer, topic->$preffix$$object.name$, strlen(topic->$preffix$$object.name$) + 1); +$endif$ >> object_deserialization(ctx, object, preffix) ::= << -dcdr \>> $deserializeCasting(typecode=object.typecode)$$preffix$$object.name$; +$if(object.typecode.primitive)$ +deserialize_$object.typecode.cppTypename$(reader, &topic->$preffix$$object.name$); +$elseif(object.typecode.isType_d)$ +uint32_t size = 0; +deserialize_uint32_t(reader, &size); +topic->$preffix$$object.name$ = malloc(size); +deserialize_array_char(reader, topic->$preffix$$object.name$, size); +$endif$ >> // TODO Todos los tipos. MEJORAR. size of 1 no deberia generar alignment. diff --git a/src/java/com/eprosima/microcdr/idl/templates/TypesSource.stg b/src/java/com/eprosima/microcdr/idl/templates/TypesSource.stg index b1426b3..5e8fec3 100644 --- a/src/java/com/eprosima/microcdr/idl/templates/TypesSource.stg +++ b/src/java/com/eprosima/microcdr/idl/templates/TypesSource.stg @@ -87,7 +87,7 @@ $if(ctx.anyCdr)$ size_t $exception.scopedname$::getMaxCdrSerializedSize(size_t current_alignment) { size_t initial_alignment = current_alignment; - + $exception.members : { member |$max_serialized_size(ctx=ctx, typecode=member.typecode, var="current_alignment")$}; separator="\n"$ return current_alignment - initial_alignment; @@ -121,11 +121,14 @@ $if(ctx.fastcdr)$ void $exception.scopedname$::serialize(eprosima::fastcdr::FastCdr &scdr) const { $exception.members : { member |$object_serialization(ctx=ctx, object=member, preffix="m_")$}; separator="\n"$ + } void $exception.scopedname$::deserialize(eprosima::fastcdr::FastCdr &dcdr) { $exception.members : { member |$object_deserialization(ctx=ctx, object=member, preffix="m_")$}; separator="\n"$ + + } $endif$ @@ -158,14 +161,14 @@ struct_type(ctx, parent, struct, extensions) ::= << bool serialize_$ctx.filename;format="toUpper"$_topic(MicroBuffer* writer, const AbstractTopic* topic_structure) { $ctx.filename$Topic* topic = ($ctx.filename$Topic*) topic_structure->topic; - + $struct.members : { member |$object_serialization(ctx=ctx, object=member, preffix="m_")$}; separator="\n"$ return true; } bool deserialize_$ctx.filename$_topic(MicroBuffer* reader, AbstractTopic* topic_structure) { - $ctx.filename$Topic* topic = mallo(sizeof($ctx.filename$Topic)); - + $ctx.filename$Topic* topic = malloc(sizeof($ctx.filename$Topic)); + $struct.members : { member |$object_deserialization(ctx=ctx, object=member, preffix="m_")$}; separator="\n"$ return true; } >> @@ -188,7 +191,7 @@ $union.scopedname$::~$union.name$() $union.scopedname$::$union.name$(const $union.name$ &x) { m__d = x.m__d; - + switch(m__d) { $union.members:{$unionmember_copy(it)$}; separator="\n"$ @@ -199,7 +202,7 @@ $union.scopedname$::$union.name$(const $union.name$ &x) $union.scopedname$::$union.name$($union.name$ &&x) { m__d = x.m__d; - + switch(m__d) { $union.members:{$unionmember_move(it)$}; separator="\n"$ @@ -210,40 +213,40 @@ $union.scopedname$::$union.name$($union.name$ &&x) $union.scopedname$& $union.scopedname$::operator=(const $union.name$ &x) { m__d = x.m__d; - + switch(m__d) { $union.members:{$unionmember_copy(it)$}; separator="\n"$ $unionmemberdefault_copy(union.defaultMember)$ } - + return *this; } $union.scopedname$& $union.scopedname$::operator=($union.name$ &&x) { m__d = x.m__d; - + switch(m__d) { $union.members:{$unionmember_move(it)$}; separator="\n"$ $unionmemberdefault_move(union.defaultMember)$ } - + return *this; } void $union.scopedname$::_d($union.discriminator.cppTypename$ __d) { bool b = false; - + switch(m__d) { $union.members:{$unionmember_discriminator_case(member=it, totallabels=union.totallabels)$}; separator="\n"$ } - + if(!b) throw BadParamException("Discriminator doesn't correspond with the selected union member"); - + m__d = __d; } @@ -366,14 +369,14 @@ void $class$::$member.name$($member.typecode.cppTypename$ _$member.name$) $member.typecode.cppTypename$ $class$::$member.name$() const { $unionmember_check_case_list(member=member, totallabels=totallabels)$ - + return m_$member.name$; } $member.typecode.cppTypename$& $class$::$member.name$() { $unionmember_check_case_list(member=member, totallabels=totallabels)$ - + return m_$member.name$; } $else$ @@ -392,14 +395,14 @@ void $class$::$member.name$($member.typecode.cppTypename$ &&_$member.name$) const $member.typecode.cppTypename$& $class$::$member.name$() const { $unionmember_check_case_list(member=member, totallabels=totallabels)$ - + return m_$member.name$; } $member.typecode.cppTypename$& $class$::$member.name$() { $unionmember_check_case_list(member=member, totallabels=totallabels)$ - + return m_$member.name$; } $endif$ @@ -499,7 +502,7 @@ $endif$ unionmember_check_case_list(member, totallabels) ::= << $if(member.default)$ bool b = true; - + switch(m__d) { $totallabels:{case $it$:}; separator="\n"$ @@ -510,7 +513,7 @@ switch(m__d) } $else$ bool b = false; - + switch(m__d) { $member.labels:{case $it$:}; separator="\n"$ @@ -520,7 +523,7 @@ switch(m__d) break; } $endif$ - + if(!b) throw BadParamException("This member is not been selected"); >>