Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions APLSource/Core/CompileObject.aplf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
r←depth CompileObject(toolsdir obj name);propnames;properties;mask;f;nstdclassmask;classnames;toolspath;componentspath
r←depth CompileObject(toolsdir obj name);arrayobjmask;propnames;properties;mask;f;nstdclassmask;classnames;toolspath;componentspath
r←⍬
r,←⊂':Class ',name
toolspath←(∊depth/⊂'##.'),toolsdir
Expand All @@ -18,6 +18,8 @@
propnames←obj.properties.⎕NL ¯9
properties←obj.properties⍎¨propnames
nstdclassmask←{⍵.(0≠⎕NC'type'):⊃⍵.(0≠⎕NC'properties')∧⍵.type≡'object' ⋄ 0}¨properties
arrayobjmask←{6::0 ⋄ (⍵.type≡'array')∧(⍵.items.type≡'object')∧0<≢⍵.items.properties}¨properties
nstdclassmask∨←arrayobjmask
classnames←nstdclassmask{⍺:⍵,'Class' ⋄ ''}¨propnames
r,←⊂' ∇ make0'
r,←⊂' :Access Public Instance'
Expand All @@ -40,24 +42,30 @@
r,←⊂' (ind⊃isSet)←1'
r,←⊂' ∇'
r,←⊂' :EndProperty'
properties←obj.properties⍎¨propnames
mask←properties.(∧/0≠⎕NC'type' 'items')
:If ∨/mask
mask←mask\(mask/properties).type∊⊂'array'
:AndIf ∨/mask
r,←⊂''
r,←⊂' :Property Simple ',1↓∊',',¨(mask/propnames),¨⊂'Add'
r,←⊂' :Access Public Instance'
r,←⊂' ∇ r←get args;ind'
r,←⊂' ∇ r←get args;ind;class'
r,←⊂' ind←∆propertyNames⍳⊂¯3↓args.Name'
r,←⊂' r←(⊃⎕RSI).⎕NEW getComponent(ind⊃∆properties).items'
r,←⊂' :If 0<≢class←ind⊃nestedObjnames'
r,←⊂' r←⎕NEW⍎class'
r,←⊂' :Else'
r,←⊂' r←(⊃⎕RSI).⎕NEW getComponent(ind⊃∆properties).items'
r,←⊂' :EndIf'
r,←⊂' (ind⊃fieldValues),←r'
r,←⊂' (ind⊃isSet)←1'
r,←⊂' ∇'
r,←⊂' :EndProperty'
:EndIf
r,←⊂''
:If ∨/nstdclassmask
:If ∨/arrayobjmask
(arrayobjmask/properties)←(arrayobjmask/properties).items
:EndIf
depth+←1
f←depth CompileObject¨↓(⊂toolsdir),nstdclassmask⌿properties,⍪classnames
r,←¨{(⊂' '),¨(⊂''),⍵}¨f
Expand Down
5 changes: 5 additions & 0 deletions APLSource/Tests/UnitTests/arrayProps_test.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
arrayProps_test;c;rqb
rqb←TestClasses.TestODA.AddThing.NewRequestBody
c←rqb.colour
(0 Try⍎)'c.TotalCostAdd'
Assert 1=≢c.TotalCost
17 changes: 17 additions & 0 deletions Testdata/test-ODA.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,23 @@
},
"hex": {
"type": "string"
},
"TotalCost": {
"type": "array",
"items": {
"type": "object",
"properties": {
"cost": {
"type": "string"
},
"primary": {
"type": "string"
},
"currency": {
"type": "string"
}
}
}
}
}
},
Expand Down