-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.apls
More file actions
executable file
·31 lines (26 loc) · 1.15 KB
/
Copy pathtest.apls
File metadata and controls
executable file
·31 lines (26 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/local/bin/dyalogscript
⎕SE.(⍎⊃2⎕FIX'/StartupSession.aplf',⍨2⎕NQ # 'GetEnvironment' 'DYALOG')
⎕SE.Link.Create 'ffiw' './ffiw'
⎕IO ← 0
struct_a ← ffiw.Build_Struct [
'a' ffiw.types.u32
'b' ffiw.types.u16
'c' ffiw.types.u32
'd' ffiw.types.u16
]
inner ← ffiw.Build_Struct ['a' ffiw.types.u32 ⋄ 'b' ffiw.types.u32]
outer ← ffiw.Build_Struct ['a' inner ⋄ 'b' inner]
⎕FX ffiw.Build_Function 'fn_a' ['a' ffiw.types.u32⋄] ffiw.types.u32
⎕FX ffiw.Build_Function 'fn_b' ['s' struct_a⋄] struct_a
⎕FX ffiw.Build_Function 'fn_add' ['a' ffiw.types.u32 ⋄ 'b' ffiw.types.u32] ffiw.types.u32
⎕FX ffiw.Build_Function 'fn_struct' ['s' inner⋄] ffiw.types.u32
⎕FX ffiw.Build_Function 'fn_c' ['s' outer⋄] ffiw.types.u32
⎕ ← 'fn_a:', fn_a (a: 10)
⎕ ← 'fn_add:', fn_add(a:5 ⋄ b: 10)
⎕ ← 'fn_struct', fn_struct(s: (a: 1 ⋄ b: 2))
⎕ ← 'fn_struct', fn_struct(s: (a: 10))
⎕ ← 'fn_struct', fn_struct(s: ⎕NS⍬)
⎕ ← 'fn_c', fn_c ⎕NS⍬
⎕ ← 'fn_c', fn_c (s: (a: (a: 1) ⋄ b: (b: 2)))
res ← fn_b (s: (a: 1 ⋄ b: 2 ⋄ c: 3 ⋄ d: 4))
⎕ ← 'fn_b struct return: ', ⍕res.a res.b res.c res.d