Skip to content

Commit ba0241e

Browse files
committed
1 parent 30a67bb commit ba0241e

File tree

12 files changed

+140
-17
lines changed

12 files changed

+140
-17
lines changed

BackendAst/DAstXer.fs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ let createSequenceOfFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:C
295295
match definedInRTL with
296296
| false ->
297297
let childTagName = (child.typeDefinitionOrReference).getAsn1Name r.args.TypePrefix
298-
(Some (XerLiteralConstant childTagName))
298+
match child.ActualType.Kind with
299+
| Choice(_) -> None
300+
| _ -> (Some (XerLiteralConstant childTagName))
299301
| true ->
300302
None
301303
let internalItem = chFunc.funcBody ({p with accessPath = lm.lg.getArrayItem p.accessPath i child.isIA5String}) childTag
@@ -436,8 +438,14 @@ let createReferenceFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:Co
436438

437439
match baseTypeXerFunc.funcBody p xmlTag with
438440
| Some baseXerFunc ->
439-
let xmlTag = xmlTag |> orElse (XerLiteralConstant o.tasName.Value)
440-
let funcBodyContent = callBaseTypeFunc (lm.lg.getParamValue t p.accessPath codec) xmlTag.p baseFncName codec
441+
let soXmlTag =
442+
match xmlTag with
443+
| Some x -> Some x.p
444+
| None ->
445+
match o.resolvedType.Kind with
446+
| Asn1AcnAst.Choice(_) -> None
447+
| _ -> Some ((XerLiteralConstant o.tasName.Value).p)
448+
let funcBodyContent = callBaseTypeFunc (lm.lg.getParamValue t p.accessPath codec) soXmlTag baseFncName codec
441449
Some {XERFuncBodyResult.funcBody = funcBodyContent; errCodes= [errCode]; localVariables=[];encodingSizeInBytes=baseXerFunc.encodingSizeInBytes}
442450
| None -> None
443451

CommonTypes/AbstractMacros.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ Generated by the C stg macros with the following command
505505
abstract member CHOICE_child : p:string -> sAcc:string -> sChID:string -> sChildBody:string -> bFirst:bool -> sChildTag:string -> sChildName:string -> sChildTypeDef:string -> sChoiceTypeName:string -> codec:Codec -> string;
506506
abstract member CHOICE_no_tag : p:string -> sAcc:string -> arrsChildren:seq<string> -> sErrCode:string -> codec:Codec -> string;
507507
abstract member CHOICE : p:string -> sAcc:string -> sTag:string -> nLevel:BigInteger -> sMainBody:string -> sErrCode:string -> codec:Codec -> string;
508-
abstract member call_base_type_func : p:string -> sXmlTag:string -> sFuncName:string -> codec:Codec -> string;
508+
abstract member call_base_type_func : p:string -> soXmlTag:string option -> sFuncName:string -> codec:Codec -> string;
509509

510510

511511
[<AbstractClass>]

FrontEndAst/Language.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ type ILangGeneric () =
241241
abstract member isCaseSensitive : bool
242242

243243
abstract member RtlFuncNames : string list
244-
abstract member AlwaysPresentRtlFuncNames : string list
244+
abstract member getAlwaysPresentRtlFuncNames : CommandLineSettings -> string list
245245

246246
abstract member detectFunctionCalls : string -> string -> string list
247247
abstract member removeFunctionFromHeader : string -> string -> string
@@ -363,7 +363,7 @@ type ILangGeneric () =
363363
default this.requiresHandlingOfEmptySequences = false
364364
default this.requiresHandlingOfZeroArrays = false
365365
default this.RtlFuncNames = []
366-
default this.AlwaysPresentRtlFuncNames = []
366+
default this.getAlwaysPresentRtlFuncNames args = []
367367
default this.detectFunctionCalls (sourceCode: string) (functionName: string) = []
368368
default this.removeFunctionFromHeader (sourceCode: string) (functionName: string) : string =
369369
sourceCode

StgAda/xer_a.stg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,5 +455,5 @@ end if;
455455

456456

457457

458-
call_base_type_func_encode(p, sXmlTag, sFuncName) ::= "<sFuncName>_aux(<p>, <sXmlTag>, bs, ret);"
459-
call_base_type_func_decode(p, sXmlTag, sFuncName) ::= "<sFuncName>_aux(<p>, <sXmlTag>, bs, ret);"
458+
call_base_type_func_encode(p, soXmlTag, sFuncName) ::= "<sFuncName>_aux(<p>, <if(soXmlTag)><soXmlTag><else>null<endif>, bs, ret);"
459+
call_base_type_func_decode(p, soXmlTag, sFuncName) ::= "<sFuncName>_aux(<p>, <if(soXmlTag)><soXmlTag><else>null<endif>, bs, ret);"

StgC/LangGeneric_c.fs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,18 @@ type LangGeneric_c() =
363363
CreateCMainFile r di.srcDir
364364
generateVisualStudioProject r di.srcDir (arrsSrcTstFiles, arrsHdrTstFiles)
365365
//AlwaysPresentRtlFuncNames
366-
override this.AlwaysPresentRtlFuncNames : string list =
366+
override this.getAlwaysPresentRtlFuncNames (args:CommandLineSettings) : string list =
367+
let xerFuncs =
368+
match args.encodings |> Seq.exists(fun e -> e = XER) with
369+
| false -> []
370+
| true -> ["ByteStream_AttachBuffer";"ByteStream_Init"]
367371
[
368372
"ByteStream_GetLength"
369373
"BitStream_AttachBuffer2"
370374
"BitStream_AttachBuffer"
371375
"BitStream_Init"
372376
"BitStream_GetLength"
373-
]
377+
]@xerFuncs
374378

375379
override this.RtlFuncNames : string list =
376380
[

StgC/test_cases_c.stg

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ ret = <sFuncName>(<sVal>, <sAmber>decodedPDU);
101101
>>
102102

103103
Codec_write_CharstreamToFile() ::= <<
104-
<Codec_write_bitstreamToFile()>
104+
char buf[1024];
105+
strcpy(buf, filename);
106+
FILE* fp = fopen(strcat(buf,".xml"), "w");
107+
fwrite(bitStrm.buf, 1, bitStrm.currentByte, fp);
108+
fclose(fp);
105109
>>
106110

107111
Codec_write_bitstreamToFile() ::= <<

StgC/xer_c.stg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@ if (ret) {
436436

437437

438438

439-
call_base_type_func_encode(p, sXmlTag, sFuncName) ::= "ret = <sFuncName>_aux(<p>, <sXmlTag>, pByteStrm, pErrCode, FALSE);"
440-
call_base_type_func_decode(p, sXmlTag, sFuncName) ::= "ret = <sFuncName>_aux(<p>, <sXmlTag>, pByteStrm, pErrCode);"
439+
call_base_type_func_encode(p, soXmlTag, sFuncName) ::= "ret = <sFuncName>_aux(<p>, <if(soXmlTag)><soXmlTag><else>NULL<endif>, pByteStrm, pErrCode, FALSE);"
440+
call_base_type_func_decode(p, soXmlTag, sFuncName) ::= "ret = <sFuncName>_aux(<p>, <if(soXmlTag)><soXmlTag><else>NULL<endif>, pByteStrm, pErrCode);"
441441

442442

443443

StgScala/xer_scala.stg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ if (ret) {
430430

431431

432432

433-
call_base_type_func_encode(p, sXmlTag, sFuncName) ::= "ret = <sFuncName>_aux(<p>, <sXmlTag>, pByteStrm, pErrCode, FALSE);"
434-
call_base_type_func_decode(p, sXmlTag, sFuncName) ::= "ret = <sFuncName>_aux(<p>, <sXmlTag>, pByteStrm, pErrCode);"
433+
call_base_type_func_encode(p, soXmlTag, sFuncName) ::= "ret = <sFuncName>_aux(<p>, <soXmlTag>, pByteStrm, pErrCode, FALSE);"
434+
call_base_type_func_decode(p, soXmlTag, sFuncName) ::= "ret = <sFuncName>_aux(<p>, <soXmlTag>, pByteStrm, pErrCode);"
435435

436436

437437

asn1crt/asn1crt_encoding_xer.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ flag Xer_DecodeComplexElementStart(ByteStream* pByteStrm, const char* elementTag
417417
{
418418
Token t;
419419

420+
if (elementTag == NULL || strlen(elementTag) == 0)
421+
return TRUE;
422+
420423
if (NT(pByteStrm).TokenID != '<') {
421424
*pErrCode = ERR_INVALID_XML_FILE; /* +++ */
422425
return FALSE;
@@ -479,6 +482,10 @@ flag Xer_EncodeComplexElementEnd(ByteStream* pByteStrm, const char* elementTag,
479482
flag Xer_DecodeComplexElementEnd(ByteStream* pByteStrm, const char* elementTag, int *pErrCode)
480483
{
481484
Token t;
485+
486+
if (elementTag == NULL || strlen(elementTag) == 0)
487+
return TRUE;
488+
482489
if (NT(pByteStrm).TokenID != '<') {
483490
*pErrCode = ERR_INVALID_XML_FILE; /* +++ */
484491
return FALSE;
@@ -508,6 +515,7 @@ flag Xer_DecodeComplexElementEnd(ByteStream* pByteStrm, const char* elementTag,
508515

509516
flag Xer_EncodeNull(ByteStream* pByteStrm, const char* elementTag, NullType value, int *pErrCode, int level)
510517
{
518+
(void)value;
511519
return Xer_EncodePrimitiveElement(pByteStrm, elementTag, NULL, pErrCode, level);
512520
}
513521

asn1scc/GenerateRTL.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let findUnusedRtlFunctions (args:CommandLineSettings) (lm:LanguageMacros) (rtlCo
4848
lm.lg.RtlFuncNames |> List.filter (fun fn -> generatedContent.Contains(fn))
4949

5050

51-
let allUsedFunctions = findAllUsedRtlFunctions lm rtlContent (lm.lg.AlwaysPresentRtlFuncNames@directlyUsedFunctions@args.userRtlFunctionsToGenerate) |> Set.ofList
51+
let allUsedFunctions = findAllUsedRtlFunctions lm rtlContent ((lm.lg.getAlwaysPresentRtlFuncNames args)@directlyUsedFunctions@args.userRtlFunctionsToGenerate) |> Set.ofList
5252
lm.lg.RtlFuncNames |> List.filter (fun fn -> not (allUsedFunctions.Contains(fn)))
5353

5454

0 commit comments

Comments
 (0)