Check-in [2bc3e54e9e]
Overview
Comment:Added a test using "curl" as a baseline for linking in external functions and libraries
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2bc3e54e9e9b17bac2f8af52889267d0e90d6169
User & Date: rkeene on 2014-06-22 23:40:15
Other Links: manifest | tags
Context
2014-06-23
00:54
Added Tcl_WideInt support check-in: 60d4d528a0 user: rkeene tags: trunk
2014-06-22
23:40
Added a test using "curl" as a baseline for linking in external functions and libraries check-in: 2bc3e54e9e user: rkeene tags: trunk
23:23
Fixed issues with several subcommands check-in: 05cac27666 user: rkeene tags: trunk
Changes

Modified tcc4tcl.tcl from [f5126bcd41] to [64ae92f63e].

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335

		lappend state(add_lib) {*}$args
	}

	proc _cproc {handle name adefs rtype {body "#"}} {
		upvar #0 $handle state

		set wrap [::tcc4tcl::wrap $name $adefs $rtype $body]

		set wrapped [lindex $wrap 0]
		set wrapper [lindex $wrap 1]
		set tclname [lindex $wrap 2]

		append state(code) $wrapped "\n"
		append state(code) $wrapper "\n"
................................................................................

	# Create wrapped function
	if {$body ne "#"} {
		append code "static $rtype2 ${cname}([join $cargs {, }]) \{\n"
		append code $body
		append code "\}\n"
	} else {
		append code "#define $cname $name" "\n"
	}

	# Create wrapper function
	## Supported input types
	##   Tcl_Interp*
	##   int
	##   long







|







 







|







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335

		lappend state(add_lib) {*}$args
	}

	proc _cproc {handle name adefs rtype {body "#"}} {
		upvar #0 $handle state

		set wrap [uplevel 1 [list ::tcc4tcl::wrap $name $adefs $rtype $body]]

		set wrapped [lindex $wrap 0]
		set wrapper [lindex $wrap 1]
		set tclname [lindex $wrap 2]

		append state(code) $wrapped "\n"
		append state(code) $wrapper "\n"
................................................................................

	# Create wrapped function
	if {$body ne "#"} {
		append code "static $rtype2 ${cname}([join $cargs {, }]) \{\n"
		append code $body
		append code "\}\n"
	} else {
		append code "#define $cname [namespace tail $name]" "\n"
	}

	# Create wrapper function
	## Supported input types
	##   Tcl_Interp*
	##   int
	##   long

Modified test.tcl from [271d570bc1] to [cd217a385a].

65
66
67
68
69
70
71
72
73
74
75












# New API
set handle [tcc4tcl::new]
$handle cproc test5 {int i} int { return(i + 42); }
if {[$handle code] == ""} {
	error "[list $handle code] did not give code output"
}
$handle cproc test6 {int i} int { return(i + 42); }
$handle add_library_path .
$handle go
puts [test5 1]
puts [test6 1]



















<



>
>
>
>
>
>
>
>
>
>
>
>
65
66
67
68
69
70
71

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# New API
set handle [tcc4tcl::new]
$handle cproc test5 {int i} int { return(i + 42); }
if {[$handle code] == ""} {
	error "[list $handle code] did not give code output"
}
$handle cproc test6 {int i} int { return(i + 42); }

$handle go
puts [test5 1]
puts [test6 1]

set handle [tcc4tcl::new]
$handle ccode {const char *curl_version(void);}
$handle cproc curl_version {} char*
$handle add_library_path /usr/lib64
$handle add_library_path /usr/lib
$handle add_library curl
$handle go
puts [curl_version]

set handle [tcc4tcl::new]
$handle delete