-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstage20.sh
executable file
·39 lines (27 loc) · 912 Bytes
/
stage20.sh
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
#!/usr/bin/env bash
set -eu
source ctypes.sh
export LD_LIBRARY_PATH=/home/jaseg/ffi:/usr/local/lib:/usr/lib/x86_64-linux-gnu:/usr/lib:/home/jaseg/ffi:/home/jaseg/ffi/haskell-libs:/usr/lib/ghc
foo="$1"
>&2 echo "Stage 20: $foo"
dlopen libtcl8.6.so
dlcall Tcl_FindExecutable "string:$0"
dlcall -n interp -r pointer Tcl_CreateInterp
dlcall Tcl_Init $interp
dlcall Tcl_EvalFile $interp "/home/jaseg/ffi/stage21.tcl"
dlcall -n argbuf -r pointer malloc 16
blep="blep"
dlcall -n blepp -r pointer get_string_value blep
dlcall -n foop -r pointer get_string_value foo
args=($blepp $foop)
pack $argbuf args
dlcall -n args -r pointer Tcl_Merge 2 $argbuf
dlcall free $argbuf
dlcall Tcl_Eval $interp $args
dlcall Tcl_Free $args
dlcall -n resp -r pointer Tcl_GetStringResult $interp
bar="$(dlcall -r int puts $resp)"
dlcall Tcl_ResetResult $interp
>&2 echo "Return value [20]: $bar"
echo "$bar"
dlcall Tcl_Finalize