Skip to content

Commit a2b4906

Browse files
committed
FindPath revisited
1 parent c19e406 commit a2b4906

File tree

7 files changed

+13
-47
lines changed

7 files changed

+13
-47
lines changed

APLSource/APLTreeUtils.apln

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
:Namespace APLTreeUtils
2-
⍝ *** Version 4.3.0 ⋄ 2019-11-28 ***
2+
3+
⍝ *** Version 5.0.0 ⋄ 2020-03-03 ***
34
⍝ ## Overview
45
⍝ Note that `APLTreeUtils` does not work with the Classic edition - it requires Unicode.\\
56
⍝ ## Version History
7+
⍝ * 5.0.0
8+
⍝ * `FindPath` redefined, see there.
69
⍝ * 4.3.0
710
⍝ * Method `ToNum` introduced
811
⍝ Kai Jaeger - APL Team Ltd.\\
@@ -337,18 +340,18 @@
337340
⍝ 2. The namespace where the class (if instanciated) comes from.
338341
⍝ 3. In `#`.
339342
⍝ 4. Where it was called from (**not** the same as either 1 or 2!).
340-
⍝ If it fails to find `⍵` an empty string is returned.
343+
⍝ If it fails it signals an error.
341344
⎕IO←1 ⋄ ⎕ML←1
342345
base←⎕THIS.## ⍝ were are we coming from?
343346
base{11::0 ⋄ 9=⍺.⎕NC ⍵}⍵:base ⍝ Is it in that namespace?
344347
base←{11::⍬ ⋄ (1⊃∊⎕CLASS ⍵).##}⍵ ⍝ Where stems the class from?
345348
base{11::0 ⋄ 9=⍺.⎕NC{Last ⍵}⍕1⊃⊃⎕CLASS ⍵}⍵:base ⍝ Is it in that namespace?
349+
base←{11::⍬ ⋄ (⊃⊃⎕CLASS ⎕THIS)}⍬ ⍝ Where stems the class from?
350+
base{11::0 ⋄ 9=⍺.##.⎕NC⍕⍵}⍵:base.## ⍝ Is it in the parent of that namespace?
346351
9={11::0 ⋄ #.⎕NC ⍵}⍵:# ⍝ Is it in root?
347352
path←1⊃⎕RSI~⎕THIS ⍝ From where got we called?
348353
0<path.⎕NC ⍵:path ⍝ May be it's there?
349-
0=#.⎕NC'_dependencies':''
350-
9=#._dependencies.⎕NC ⍵:#._dependencies
351-
'' ⍝ Give up
354+
6 ⎕SIGNAL⍨'Could not find ',⍵
352355
}
353356

354357
∇ r←GetOperatingSystem dummy;⎕ML;⎕IO
@@ -420,4 +423,4 @@
420423
:EndIf
421424
422425

423-
:EndNamespace ⍝ APLTreeUtils
426+
:EndNamespace
File renamed without changes.
File renamed without changes.

APLSource/TestCases/Test_012.aplf

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,11 @@
5252
:EndIf
5353
⎕CS ## ⍝ Back to "Testspace'
5454

55-
⍝ Test C)
56-
⍝ We now instanciate MyTest somewhere else, but Obstacle
57-
⍝ should be found where the instance stems from (local):
58-
instance←⎕NEW local.Obstacle
59-
its←⍕⎕THIS.MyTest.Get instance
60-
⎕CS #.APLTreeUtils.TestCases
61-
flag←its≢(⍕⎕THIS),'.Testspace.local'
62-
:If flag
63-
:If 0<⎕NC'stopFlag'
64-
:AndIf stopFlag
65-
. ⍝ Something went wrong
66-
:EndIf
67-
:Leave
68-
:EndIf
69-
70-
⍝ Test D)
55+
⍝ Test E)
7156
⍝ We now delete "Obstacle" from local but fix it in TestCase.
7257
⍝ Then we call Testspace.local.MyTest from TestCases, so
7358
⍝ it should be found in TestCase
59+
⎕CS ##
7460
Testspace.local.⎕EX'Obstacle'
7561
⎕FIX ⎕SRC #.Obstacle
7662
#.⎕EX'Obstacle'
@@ -101,30 +87,7 @@
10187
'Create!'##.FilesAndDirs.CheckPath home,'Logs'
10288
:EndIf
10389

104-
⎕EX'#.SSO'
105-
#.⎕SHADOW'SSO'
106-
ref←⍎'#.SSO'⎕NS''
107-
ref.⎕FIX ⎕SRC ##.APLTreeUtils
108-
ref2←ref.⎕NS''
109-
ref2.⎕FIX ⎕SRC ##.APLTreeUtils
110-
ref2.⎕FIX ⎕SRC ##.FilesAndDirs
111-
ref2←⍎'qq'ref.⎕NS''
112-
ref2.⎕FIX ⎕SRC ##.APLTreeUtils
113-
ref2.⎕FIX ⎕SRC ##.Logger
114-
'Source'ref.⎕NS''
115-
ref.Source.⎕FX'r←Foo home' 'myLogger←⎕NEW ##.qq.Logger (,⊂home)' ' r←myLogger.(path ,filename)'
116-
fn←ref.Source.Foo home
117-
118-
:Trap 0
119-
myLogger←⎕NEW ref2.Logger(,⊂home,'Logs') ⍝ #.Logger will use FindPathTo in order to find FilesAndDirs!
120-
R←T._OK
121-
:Else
122-
→T.GoToTidyUp 1
123-
:EndTrap
124-
⎕DL 1
125-
:Trap 0
126-
myLogger.Close
127-
:EndTrap
90+
R←T._OK
12891

12992
∆TidyUp:
13093
{}##.FilesAndDirs.RmDir home,'Logs'

Make/Make.DWS

-256 Bytes
Binary file not shown.

project.dws

31.7 KB
Binary file not shown.

publish.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<tool name="APLTreeUtils"> <version>4.3.0</version> <date>2019-11-28</date> <container>#.APLTreeUtils</container> <needs> <script>APLTreeUtils</script> <script>FilesAndDirs</script> <script>OS</script> <script>Logger</script> <script>Execute</script> <script development="true">Tester2</script> </needs> <autoload>1</autoload> <scriptOnly>1</scriptOnly> <buildid>1</buildid></tool>
1+
<tool name="APLTreeUtils"> <version>5.0.0</version> <date>2020-03-03</date> <container>#.APLTreeUtils</container> <needs> <script>APLTreeUtils</script> <script>FilesAndDirs</script> <script>OS</script> <script>Logger</script> <script>Execute</script> <script development="true">Tester2</script> </needs> <autoload>1</autoload> <scriptOnly>1</scriptOnly> <buildid>1</buildid> <package>1</package></tool>

0 commit comments

Comments
 (0)