Skip to content

Commit ca493ea

Browse files
committed
Added two new parameter loop expansion tokens <PARAMETER_MAXVALUE> and <PARAMETER_MINVALUE>. Also added a tagloop expansion token <TAGLOOP_TAG_VALUE_QUOTED>.
1 parent fb619b0 commit ca493ea

5 files changed

Lines changed: 138 additions & 2 deletions

File tree

CodeGenEngine/TokenExpanders/TokenExpanderParameterLoop.dbl

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ namespace CodeGen.Engine
7373
parameterLoopTokenExpanders.Add("PARAMETER_SIZE", expandParameterSize)
7474
parameterLoopTokenExpanders.Add("PARAMETER_PRECISION", expandParameterPrecision)
7575
parameterLoopTokenExpanders.Add("PARAMETER_ENUM", expandParameterEnum)
76+
parameterLoopTokenExpanders.Add("PARAMETER_MAXVALUE", expandParameterMaxValue)
77+
parameterLoopTokenExpanders.Add("PARAMETER_MINVALUE", expandParameterMinValue)
7678
parameterLoopTokenExpanders.Add("PARAMETER_STRUCTURE", expandParameterStructure)
7779
parameterLoopTokenExpanders.Add("PARAMETER_STRUCTURE_NOPLURAL", expandParameterStructure)
7880
parameterLoopTokenExpanders.Add("PARAMETER_STRUCTURE_PLURAL", expandParameterStructure)
@@ -631,7 +633,10 @@ namespace CodeGen.Engine
631633
if (template.Context.CurrentTask.Tweaks != ^null && template.Context.CurrentTask.Tweaks.Contains("PARAMDEFSTR"))
632634
begin
633635
strPrefix = "str"
634-
strName = StringTools.PascalCase(param.StructureName.EndsWith("S") ? param.StructureName.Substring(0,param.StructureName.Length-1) : param.StructureName)
636+
if (template.Context.CurrentTask.NoCustomPluralization) then
637+
strName = StringTools.PascalCase(param.StructureName)
638+
else
639+
strName = StringTools.PascalCase(param.StructureName.EndsWith("S") ? param.StructureName.Substring(0,param.StructureName.Length-1) : param.StructureName)
635640
end
636641
mreturn String.Format("{0}{1}{2}",arraySpec,strPrefix,strName)
637642
end
@@ -700,7 +705,10 @@ namespace CodeGen.Engine
700705
if (template.Context.CurrentTask.Tweaks != ^null && template.Context.CurrentTask.Tweaks.Contains("PARAMDEFSTR"))
701706
begin
702707
strPrefix = "str"
703-
strName = StringTools.PascalCase(param.StructureName.EndsWith("S") ? param.StructureName.Substring(0,param.StructureName.Length-1) : param.StructureName)
708+
if (template.Context.CurrentTask.NoCustomPluralization) then
709+
strName = StringTools.PascalCase(param.StructureName)
710+
else
711+
strName = StringTools.PascalCase(param.StructureName.EndsWith("S") ? param.StructureName.Substring(0,param.StructureName.Length-1) : param.StructureName)
704712
end
705713
mreturn String.Format("{0}{1}",strPrefix,strName)
706714
end
@@ -764,6 +772,88 @@ namespace CodeGen.Engine
764772
mreturn ExpandParameterLoopToken(tkn, template, loops, doExpand)
765773
endmethod
766774

775+
private static method expandParameterMaxValue, string
776+
tkn, @Token
777+
template, @FileNode
778+
loops, @IEnumerable<LoopNode>
779+
endparams
780+
proc
781+
lambda doExpand(catalog,iface,meth,param)
782+
begin
783+
data maxValue = String.Empty
784+
data nines, a28, "9999999999999999999999999999"
785+
using param.Type select
786+
(ParameterType.Decimal),
787+
begin
788+
maxValue = nines(1:param.Size)
789+
end
790+
(ParameterType.Integer),
791+
begin
792+
using param.Size select
793+
(1),
794+
maxValue = "127"
795+
(2),
796+
maxValue = "32767"
797+
(4),
798+
maxValue = "2147483647"
799+
(8),
800+
maxValue = "9223372036854775807"
801+
endusing
802+
end
803+
(ParameterType.ImpliedDecimal),
804+
begin
805+
maxValue = String.Format("{0}.{1}",nines(1:param.Size-param.Precision),nines(1:param.Precision))
806+
end
807+
(),
808+
nop
809+
endusing
810+
811+
mreturn maxValue
812+
end
813+
mreturn ExpandParameterLoopToken(tkn, template, loops, doExpand)
814+
endmethod
815+
816+
private static method expandParameterMinValue, string
817+
tkn, @Token
818+
template, @FileNode
819+
loops, @IEnumerable<LoopNode>
820+
endparams
821+
proc
822+
lambda doExpand(catalog,iface,meth,param)
823+
begin
824+
data minValue = String.Empty
825+
data nines, a28, "9999999999999999999999999999"
826+
using param.Type select
827+
(ParameterType.Decimal),
828+
begin
829+
minValue = String.Format("-{0}",nines(1:param.Size))
830+
end
831+
(ParameterType.Integer),
832+
begin
833+
using param.Size select
834+
(1),
835+
minValue = "-128"
836+
(2),
837+
minValue = "-32768"
838+
(4),
839+
minValue = "-2147483648"
840+
(8),
841+
minValue = "-9223372036854775808"
842+
endusing
843+
end
844+
(ParameterType.ImpliedDecimal),
845+
begin
846+
minValue = String.Format("-{0}.{1}",nines(1:param.Size-param.Precision),nines(1:param.Precision))
847+
end
848+
(),
849+
nop
850+
endusing
851+
852+
mreturn minValue
853+
end
854+
mreturn ExpandParameterLoopToken(tkn, template, loops, doExpand)
855+
endmethod
856+
767857
private static method expandParameterStructure, string
768858
tkn, @Token
769859
template, @FileNode

CodeGenEngine/TokenExpanders/TokenExpanderTagLoop.dbl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ namespace CodeGen.Engine
7676
tagLoopTokenExpanders.Add("TAGLOOP_SEQUENCE", expandTagSequence)
7777
tagLoopTokenExpanders.Add("TAGLOOP_TAG_NAME", expandTagName)
7878
tagLoopTokenExpanders.Add("TAGLOOP_TAG_VALUE", expandTagValue)
79+
tagLoopTokenExpanders.Add("TAGLOOP_TAG_VALUE_QUOTED", expandTagValueQuoted)
7980

8081
endmethod
8182

@@ -432,6 +433,48 @@ namespace CodeGen.Engine
432433
mreturn ExpandTagLoopToken(tkn, template, loops, doExpand)
433434
endmethod
434435

436+
private static method expandTagValueQuoted, string
437+
tkn, @Token
438+
template, @FileNode
439+
loops, @IEnumerable<LoopNode>
440+
endparams
441+
proc
442+
lambda doExpand(str, tag, index)
443+
begin
444+
data value, string, ""
445+
data field, @RpsField
446+
foreach field in str.Fields
447+
begin
448+
if (field.OriginalName == tag.Field)
449+
begin
450+
using (field.DataType) select
451+
(RpsFieldDataType.Alpha, RpsFieldDataType.User),
452+
begin
453+
data tmplen, int, field.Size
454+
if (tmplen > 15)
455+
tmplen = 15
456+
if (tag.ComparisonValue.Length > 0) then
457+
begin
458+
data tmpval, a15, tag.ComparisonValue
459+
value = String.Format("""{0}""", tmpval(1:tmplen))
460+
end
461+
else
462+
begin
463+
data spaces, a15, " " ;15 is the max length of a tag comparison in RPS
464+
value = String.Format("""{0}""", spaces(1:tmplen))
465+
end
466+
end
467+
(),
468+
value = String.Format("""{0}""",tag.ComparisonValue)
469+
endusing
470+
exitloop
471+
end
472+
end
473+
mreturn value
474+
end
475+
mreturn ExpandTagLoopToken(tkn, template, loops, doExpand)
476+
endmethod
477+
435478
endclass
436479

437480
endnamespace

CodeGenEngine/Tokenizer.dbl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ namespace CodeGen.Engine
554554
& { new TokenMeta() {Name = "TAGLOOP_SEQUENCE", TypeOfToken = TokenType.TagLoop, IsPaired = false, Validity = TokenValidity.TagLoop, RequiresRepository = true} },
555555
& { new TokenMeta() {Name = "TAGLOOP_TAG_NAME", TypeOfToken = TokenType.TagLoop, IsPaired = false, Validity = TokenValidity.TagLoop, RequiresRepository = true} },
556556
& { new TokenMeta() {Name = "TAGLOOP_TAG_VALUE", TypeOfToken = TokenType.TagLoop, IsPaired = false, Validity = TokenValidity.TagLoop, RequiresRepository = true} },
557+
& { new TokenMeta() {Name = "TAGLOOP_TAG_VALUE_QUOTED", TypeOfToken = TokenType.TagLoop, IsPaired = false, Validity = TokenValidity.TagLoop, RequiresRepository = true} },
557558
&
558559
& { new TokenMeta() {Name = "WINDOW_HEIGHT", TypeOfToken = TokenType.Window, IsPaired = false, Validity = TokenValidity.Anywhere} },
559560
& { new TokenMeta() {Name = "WINDOW_HEIGHTPX", TypeOfToken = TokenType.Window, IsPaired = false, Validity = TokenValidity.Anywhere} },
@@ -618,6 +619,8 @@ namespace CodeGen.Engine
618619
& { makeTokenMeta_UpperLower("PARAMETER_DIRECTION", TokenType.ParameterLoop, TokenValidity.ParameterLoop, false) },
619620
& { makeTokenMeta_UpperLower("PARAMETER_DIRECTION_PAD", TokenType.ParameterLoop, TokenValidity.ParameterLoop, false) },
620621
& { new TokenMeta() {Name = "PARAMETER_ENUM", TypeOfToken = TokenType.ParameterLoop, IsPaired = false, Validity = TokenValidity.ParameterLoop, RequiresRepository = false} },
622+
& { new TokenMeta() {Name = "PARAMETER_MAXVALUE", TypeOfToken = TokenType.ParameterLoop, IsPaired = false, Validity = TokenValidity.ParameterLoop, RequiresRepository = false} },
623+
& { new TokenMeta() {Name = "PARAMETER_MINVALUE", TypeOfToken = TokenType.ParameterLoop, IsPaired = false, Validity = TokenValidity.ParameterLoop, RequiresRepository = false} },
621624
& { makeTokenMeta_AllVariants("PARAMETER_NAME", TokenType.ParameterLoop, TokenValidity.ParameterLoop, false) },
622625
& { new TokenMeta() {Name = "PARAMETER_NUMBER", TypeOfToken = TokenType.ParameterLoop, IsPaired = false, Validity = TokenValidity.ParameterLoop, RequiresRepository = false} },
623626
& { new TokenMeta() {Name = "PARAMETER_PASS_BY", TypeOfToken = TokenType.ParameterLoop, IsPaired = false, Validity = TokenValidity.ParameterLoop, RequiresRepository = false} },

Documentation/CodeGen.chm

-3.21 KB
Binary file not shown.

Documentation/CodeGen.hsmx

1.26 KB
Binary file not shown.

0 commit comments

Comments
 (0)