Skip to content

Commit

Permalink
Merge pull request #85 from ESTOS/feature/EG-1108
Browse files Browse the repository at this point in the history
EG-1108 Changed the way we decode an optional asn any.
  • Loading branch information
JanFellner authored Nov 14, 2024
2 parents 65f58e6 + af024d8 commit f433aa3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
50 changes: 28 additions & 22 deletions compiler/back-ends/c++-gen/gen-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -2831,23 +2831,23 @@ void PrintSeqDefCodeBerDecodeContent(FILE* src, FILE* hdr, Module* m, CxxRules*
{
fprintf(src, "// [%s]\n", __FUNCTION__);

NamedType* e;
char* classStr;
char* formStr;
const char* codeStr;
NamedType* e = NULL;
char* classStr = NULL;
char* formStr = NULL;
const char* codeStr = NULL;
int i = 0;
Tag* tag;
TagList* tags;
char* varName;
Tag* tag = NULL;
TagList* tags = NULL;
char* varName = NULL;
CxxTRI* cxxtri = NULL;
int elmtLevel = 0;
int varCount, tmpVarCount;
int stoleChoiceTags;
int inTailOptElmts;
bool bHaveLength;
enum BasicTypeChoiceId tmpTypeId;
NamedType* defByNamedType;
NamedType* tmpElmt;
int varCount = 0, tmpVarCount = 0;
int stoleChoiceTags = 0;
int inTailOptElmts = 0;
bool bHaveLength = false;
enum BasicTypeChoiceId tmpTypeId = 0;
NamedType* defByNamedType = NULL;
NamedType* tmpElmt = NULL;
int extensionAdditionFound = FALSE;

fprintf(hdr, "\tvoid B%s(const %s& _b, %s tag, %s elmtLen, %s& bytesDecoded);\n", r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG, lenTypeNameG); //, envTypeNameG);
Expand Down Expand Up @@ -3153,17 +3153,25 @@ void PrintSeqDefCodeBerDecodeContent(FILE* src, FILE* hdr, Module* m, CxxRules*
}
}

/*
* if this seq element is CHOICE &&
* we didn't steal its tags then we must grab
* the key tag out of the contained CHOICE
*/
if (!stoleChoiceTags && (GetBuiltinType(e->type) == BASICTYPE_CHOICE))
/* decode content */
tmpTypeId = GetBuiltinType(e->type);

if (!stoleChoiceTags && GetBuiltinType(e->type) == BASICTYPE_CHOICE)
{
// if this seq element is CHOICE &&
// we didn't steal its tags then we must grab
// the key tag out of the contained CHOICE
fprintf(src, "\t\ttag1 = BDecTag(_b, seqBytesDecoded);\n");
fprintf(src, "\t\telmtLen%d = BDecLen(_b, seqBytesDecoded);\n", ++elmtLevel);
bHaveLength = true;
}
else if (cxxtri->isPtr && tmpTypeId == BASICTYPE_ANY && tag && tag->tclass == CNTX && tag->form == CONS)
{
// If the seq element is an indexed ANY (Constructed) we need to remove the context attributes
// and hand over just the payload to the any object
fprintf(src, "\t\ttag1 = BDecTag(_b, seqBytesDecoded);\n");
fprintf(src, "\t\telmtLen%d = BDecLen(_b, seqBytesDecoded);\n", elmtLevel);
}

/* decode content */
if (cxxtri->isPtr)
Expand All @@ -3176,8 +3184,6 @@ void PrintSeqDefCodeBerDecodeContent(FILE* src, FILE* hdr, Module* m, CxxRules*
fprintf(src, "\t\t%s = new %s();\n", varName, cxxtri->className);
}

/* decode content */
tmpTypeId = GetBuiltinType(e->type);
if (tmpTypeId == BASICTYPE_ANYDEFINEDBY)
{
/*
Expand Down
9 changes: 0 additions & 9 deletions cpp-lib/src/asn-any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,6 @@ void AsnAny::BDec(const AsnBuf& b, AsnLen& bytesDecoded)

void AsnAny::BDecContent(const AsnBuf& b, AsnTag tag, AsnLen elmtLen, AsnLen& bytesDecoded)
{
if (TAG_IS_CNTX(tag) && elmtLen > 2)
{
// Special
// If we have an indexed optional any, we cannot determine the type using the schema (The type is any)
// In this case the details about the structure (is it a sequence a string etc) are burried within
// the object and the reader is now on the position of the any. So we need to read the following tag and len information
tag = BDecTag(b, bytesDecoded);
elmtLen = BDecLen(b, bytesDecoded);
}
const auto tagLen = BytesInTag(tag);
const auto elementLen = BytesInLen(elmtLen);
const auto headerLen = tagLen + elementLen;
Expand Down
6 changes: 3 additions & 3 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef VERSION_H
#define VERSION_H

#define VERSION "6.0.19"
#define VERSION_RC 6, 0, 19
#define RELDATE "20.09.2024"
#define VERSION "6.0.20"
#define VERSION_RC 6, 0, 20
#define RELDATE "14.11.2024"

#endif // VERSION_H

0 comments on commit f433aa3

Please sign in to comment.