forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic-call.lcb
More file actions
47 lines (33 loc) · 1.09 KB
/
Copy pathdynamic-call.lcb
File metadata and controls
47 lines (33 loc) · 1.09 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module __VMTEST.dynamic_call
use com.livecode.foreign
---------- LCB THUNKS
handler type Thunk()
handler Yes()
return true
end handler
handler InvokeArgument(in pFunc as Thunk)
return pFunc()
end handler
public handler TestDynamicInvokeVariable()
variable pFunc as Thunk
put Yes into pFunc
test "dynamic invoke (variable)" when pFunc()
end handler
public handler TestDynamicInvokeArgument()
test "dynamic invoke (argument)" when InvokeArgument(Yes)
end handler
--------- FOREIGN THUNKS
foreign handler type ForeignThunk(in pValue as any) returns CBool
foreign handler MCStringIsEmpty(in pValue as String) returns CBool binds to "<builtin>"
handler InvokeForeignArgument(in pFunc as ForeignThunk, in pParam as any)
return pFunc(pParam)
end handler
public handler TestDynamicForeignInvokeVariable()
variable tFunc as ForeignThunk
put MCStringIsEmpty into tFunc
test "dynamic foreign invoke (variable)" when tFunc("")
end handler
public handler TestDynamicForeignInvokeArgument()
test "dynamic foreign invoke (argument)" when InvokeForeignArgument(MCStringIsEmpty, "")
end handler
end module