Skip to content

Commit f81bab4

Browse files
committed
Add encoding/decoding for NullType in XER format Introduce `Xer_EncodeNull` and `Xer_DecodeNull` functions to handle `NullType` values in the XER (XML Encoding Rules) format.
1 parent ed6966e commit f81bab4

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

BackendAst/DAstXer.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ let createTimeTypeFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:Com
211211
let createNullTypeFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.NullType) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (us:State) =
212212
let nullFunc = lm.xer.Null
213213
let funcBody (errCode:ErrorCode) (p:CallerScope) (xmlTag:XerTag option) =
214-
let pp = match codec with CommonTypes.Encode -> lm.lg.getPointer p.arg | CommonTypes.Decode -> lm.lg.getPointer p.arg
214+
let pp = match codec with CommonTypes.Encode -> lm.lg.getValue p.arg | CommonTypes.Decode -> lm.lg.getPointer p.arg
215215
let xmlTag = xmlTag |> orElse (XerLiteralConstant "NULL")
216216
let nLevel = BigInteger (t.id.AcnAbsPath.Length - 2)
217217
let totalSize = getMaxSizeInBytesForXER xmlTag 0I

asn1crt/asn1crt_encoding_xer.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ flag Xer_DecodeComplexElementEnd(ByteStream* pByteStrm, const char* elementTag,
506506

507507

508508

509+
flag Xer_EncodeNull(ByteStream* pByteStrm, const char* elementTag, NullType value, int *pErrCode, int level)
510+
{
511+
return Xer_EncodePrimitiveElement(pByteStrm, elementTag, NULL, pErrCode, level);
512+
}
513+
509514
flag Xer_EncodeInteger(ByteStream* pByteStrm, const char* elementTag, asn1SccSint value, int *pErrCode, int level)
510515
{
511516
return Xer_EncodePrimitiveElement(pByteStrm, elementTag, Int2String(value), pErrCode, level);
@@ -677,6 +682,15 @@ flag Xer_EncodeObjectIdentifier(ByteStream* pByteStrm, const char* elementTag, c
677682

678683

679684

685+
flag Xer_DecodeNull(ByteStream* pByteStrm, const char* elementTag, NullType* value, int *pErrCode)
686+
{
687+
char tmp[256];
688+
memset(tmp, 0x0, sizeof(tmp));
689+
if (!Xer_DecodePrimitiveElement(pByteStrm, elementTag, tmp, pErrCode))
690+
return FALSE;
691+
*value = 0;
692+
return TRUE;
693+
}
680694

681695

682696

asn1crt/asn1crt_encoding_xer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ extern "C" {
1010
void Xer_EncodeXmlHeader(ByteStream* pByteStrm, const char* xmlHeader);
1111
flag Xer_EncodeComment(ByteStream* pByteStrm, const char* comment, int *pErrCode);
1212

13+
flag Xer_EncodeNull(ByteStream* pByteStrm, const char* elementTag, NullType value, int *pErrCode, int level);
1314
flag Xer_EncodeInteger(ByteStream* pByteStrm, const char* elementTag, asn1SccSint value, int *pErrCode, int level);
1415
flag Xer_EncodePosInteger(ByteStream* pByteStrm, const char* elementTag, asn1SccUint value, int *pErrCode, int level);
1516
flag Xer_EncodeBoolean(ByteStream* pByteStrm, const char* elementTag, flag value, int *pErrCode, int level);
@@ -20,7 +21,7 @@ flag Xer_EncodeOctetString(ByteStream* pByteStrm, const char* elementTag, const
2021
flag Xer_EncodeBitString(ByteStream* pByteStrm, const char* elementTag, const byte value[], int nCount, int *pErrCode, int level);
2122
flag Xer_EncodeObjectIdentifier(ByteStream* pByteStrm, const char* elementTag, const Asn1ObjectIdentifier *pVal, int *pErrCode, int level);
2223

23-
24+
flag Xer_DecodeNull(ByteStream* pByteStrm, const char* elementTag, NullType* value, int *pErrCode);
2425
flag Xer_DecodeInteger(ByteStream* pByteStrm, const char* elementTag, asn1SccSint* value, int *pErrCode);
2526
flag Xer_DecodePosInteger(ByteStream* pByteStrm, const char* elementTag, asn1SccUint* value, int *pErrCode);
2627
flag Xer_DecodeBoolean(ByteStream* pByteStrm, const char* elementTag, flag* value, int *pErrCode);

asn1scc/Program.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ let printVersion () =
123123
//let fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
124124
//let version = fvi.FileVersion;
125125

126-
let version = "4.5.2.8"
126+
let version = "4.5.2.9"
127127
printfn "asn1scc version %s\n" version
128128
()
129129

0 commit comments

Comments
 (0)