Skip to content

Commit 76a2653

Browse files
author
Steve Ives
committed
Improved <RELATION_TOSTRUCTURE>, <RELATION_TOSTRUCTURE_NOPLURAL> and <RELATION_TOSTRUCTURE_PLURAL> by adding support for structure aliasing.
1 parent 4a90d4a commit 76a2653

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

CodeGenEngine/LoopExpander.dbl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,13 @@ namespace CodeGen.Engine
397397
loop.CurrentRelation = template.Context.CurrentStructure.Relations[ix]
398398
loop.CurrentIndex = ix
399399

400-
;;Load the "from key" information
400+
;;Locate the "from key" information
401401
lambda isFromKey(k) k.Name == loop.CurrentRelation.FromKey
402402
loop.FromKey = template.Context.CurrentStructure.Keys.First(isFromKey)
403403

404-
;;Load the "to structure" information
405-
loop.ToStructure = new RpsStructure(loop.CurrentRelation.ToStructure)
404+
;;Locate the "to structure" information
405+
lambda isToStructure(s) s.Name == loop.CurrentRelation.ToStructure
406+
loop.ToStructure = template.Context.Structures.First(isToStructure)
406407

407408
;Load the "to key" information
408409
lambda isToKey(k) k.Name == loop.CurrentRelation.ToKey

CodeGenEngine/TokenExpanders/TokenExpanderRelationLoop.dbl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace CodeGen.Engine
162162
loops, @IEnumerable<LoopNode>
163163
endparams
164164
proc
165-
lambda doExpand(str, relation, index, fromkey, tostr, tokey) relation.ToStructure
165+
lambda doExpand(str, relation, index, fromkey, tostr, tokey) tostr.Alias
166166
mreturn ExpandRelationLoopToken(tkn, template, loops, doExpand)
167167
endmethod
168168

@@ -172,7 +172,10 @@ namespace CodeGen.Engine
172172
loops, @IEnumerable<LoopNode>
173173
endparams
174174
proc
175-
lambda doExpand(str, relation, index, fromkey, tostr, tokey) relation.ToStructure.EndsWith("S") ? relation.ToStructure : String.Format("{0}S",relation.ToStructure)
175+
lambda doExpand(str, relation, index, fromkey, tostr, tokey)
176+
begin
177+
mreturn tostr.Alias.EndsWith("S") ? tostr.Alias : String.Format("{0}S",tostr.Alias)
178+
end
176179
mreturn ExpandRelationLoopToken(tkn, template, loops, doExpand)
177180
endmethod
178181

@@ -182,7 +185,10 @@ namespace CodeGen.Engine
182185
loops, @IEnumerable<LoopNode>
183186
endparams
184187
proc
185-
lambda doExpand(str, relation, index, fromkey, tostr, tokey) relation.ToStructure.EndsWith("S") ? relation.ToStructure.Substring(0,relation.ToStructure.Length-1) : relation.ToStructure
188+
lambda doExpand(str, relation, index, fromkey, tostr, tokey)
189+
begin
190+
mreturn tostr.Alias.EndsWith("S") ? tostr.Alias.Substring(0,tostr.Alias.Length-1) : tostr.Alias
191+
end
186192
mreturn ExpandRelationLoopToken(tkn, template, loops, doExpand)
187193
endmethod
188194

Documentation/CodeGen.chm

264 Bytes
Binary file not shown.

Documentation/CodeGen.hsm

1.02 KB
Binary file not shown.

RepositoryAPI/RpsField.dbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ namespace CodeGen.RepositoryAPI
20552055
;; Set to the same as Name if no alternate name is defined
20562056
;; Could change to include paths and array dimensions after CheckStructure
20572057
;;
2058-
;;BaseName Starts off as the alternate name of the field per repository
2058+
;;BaseName Starts off as the base name of the field per repository
20592059
;; Could change to include paths and array dimensions after CheckStructure
20602060
;; For arrays, BaseName does NOT include any final array element number
20612061
;;

0 commit comments

Comments
 (0)