74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
-
-
+
+
+
-
+
|
puts [test5 1]
puts [test6 1]
## Delete without performing
set handle [tcc4tcl::new]
$handle delete
# External functions (requires .a files)
if {[info exists ::env(TCC4TCL_TEST_RUN_NATIVE)]} {
# External functions (requires .so or .a (ELF) files which do not exist on Darwin)
if {[info exists ::env(TCC4TCL_TEST_RUN_NATIVE)] && $::tcl_platform(os) != "Darwin"} {
set handle [tcc4tcl::new]
$handle ccode {const char *curl_version(void);}
$handle cproc curl_version {} vstring
$handle add_library_path /usr/lib64
$handle add_library_path /usr/lib
$handle add_library curl
$handle go
puts [curl_version]
}
# wide values
set handle [tcc4tcl::new]
$handle cproc wideTest {Tcl_WideInt x} Tcl_WideInt {
return(x);
}
$handle go
puts [wideTest 30]
# Produce a loadable object
## Currently doesn't work on Darwin
if {[info exists ::env(TCC4TCL_TEST_RUN_NATIVE)]} {
if {[info exists ::env(TCC4TCL_TEST_RUN_NATIVE)] && $::tcl_platform(os) != "Darwin"} {
set tmpfile "/tmp/DELETEME_tcc4tcl_test_exec[expr rand()].so"
file delete $tmpfile
set handle [tcc4tcl::new $tmpfile "myPkg 0.1"]
$handle cproc ext_add {int a int b} long { return(a+b); }
$handle add_library_path /usr/lib64
$handle add_library_path /usr/lib
$handle add_library tclstub8.5
$handle go
load $tmpfile myPkg
puts [ext_add 1 42]
file delete $tmpfile
}
|