Skip to content

Commit

Permalink
EG-1108 Changed the way we decode an optional asn any.
Browse files Browse the repository at this point in the history
The constructed optional attributes need to get removed before passing the content to the any as these belong to the parten structure, not to the any itself
  • Loading branch information
JanFellner committed Nov 14, 2024
1 parent 65f58e6 commit 8919f93
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
53 changes: 31 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,28 @@ 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))
if (strcmp(td->cxxTypeDefInfo->className, "AsnRedisRemoteInvoke") == 0 && strcmp(varName, "argument") == 0)
int iDebug1 = 1;

/* 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 +3187,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

0 comments on commit 8919f93

Please sign in to comment.