Check-in [f6d387c96c]
Overview
Comment:Added enough critcl to be handle tcllib
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f6d387c96c04d1f35257a486d5c194423e87a9c3
User & Date: rkeene on 2017-10-13 20:34:02
Other Links: manifest | tags
Context
2017-10-13
20:36
Disabled a test which now does not work check-in: 30810bb6d9 user: rkeene tags: trunk
20:34
Added enough critcl to be handle tcllib check-in: f6d387c96c user: rkeene tags: trunk
19:59
Fixed typo and added test for process_command_line check-in: 6641266e0b user: rkeene tags: trunk
Changes

Modified Makefile.in from [24f224ef33] to [ee6f8c12a0].

56
57
58
59
60
61
62
63
64
65
66
67
68
69

70
71
72
73
74
75
76

tcc4tcl-static.a: tcc4tcl.o tcc/libtcc.a
	cp tcc/libtcc.a tcc4tcl-static.new.a
	$(AR) rcu tcc4tcl-static.new.a tcc4tcl.o
	-$(RANLIB) tcc4tcl-static.new.a
	mv tcc4tcl-static.new.a tcc4tcl-static.a

install: $(TARGET) pkgIndex.tcl $(srcdir)/tcc4tcl.tcl tcc/libtcc1.a $(shell echo $(srcdir)/tcc/include/*) $(shell echo $(srcdir)/tcc/win32/lib/*.c) $(srcdir)/headers.awk $(srcdir)/patch-headers.sh
	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"
	$(INSTALL) -m 0755 $(TARGET) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
	$(INSTALL) -m 0644 pkgIndex.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
	$(INSTALL) -m 0644 $(srcdir)/tcc4tcl.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"

	$(INSTALL) -m 0644 tcc/libtcc1.a "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
	$(INSTALL) -m 0644 $(shell echo $(srcdir)/tcc/win32/lib/*.c) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
	$(INSTALL) -m 0644 $(shell echo $(srcdir)/tcc/include/*) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"
	@if ! echo "_WIN32" | $(CPP) $(CPPFLAGS) - | grep '^_WIN32$$' >/dev/null; then \
		echo cp -r $(srcdir)/tcc/win32/include/* "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/"; \
		cp -r $(srcdir)/tcc/win32/include/* "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/"; \
		echo cp -r $(srcdir)/tcc/win32/lib/*.def "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib/"; \







|






>







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

tcc4tcl-static.a: tcc4tcl.o tcc/libtcc.a
	cp tcc/libtcc.a tcc4tcl-static.new.a
	$(AR) rcu tcc4tcl-static.new.a tcc4tcl.o
	-$(RANLIB) tcc4tcl-static.new.a
	mv tcc4tcl-static.new.a tcc4tcl-static.a

install: $(TARGET) pkgIndex.tcl $(srcdir)/tcc4tcl.tcl $(srcdir)/tcc4critcl.tcl tcc/libtcc1.a $(shell echo $(srcdir)/tcc/include/*) $(shell echo $(srcdir)/tcc/win32/lib/*.c) $(srcdir)/headers.awk $(srcdir)/patch-headers.sh
	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"
	$(INSTALL) -m 0755 $(TARGET) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
	$(INSTALL) -m 0644 pkgIndex.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
	$(INSTALL) -m 0644 $(srcdir)/tcc4tcl.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
	$(INSTALL) -m 0644 $(srcdir)/tcc4critcl.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
	$(INSTALL) -m 0644 tcc/libtcc1.a "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
	$(INSTALL) -m 0644 $(shell echo $(srcdir)/tcc/win32/lib/*.c) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
	$(INSTALL) -m 0644 $(shell echo $(srcdir)/tcc/include/*) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"
	@if ! echo "_WIN32" | $(CPP) $(CPPFLAGS) - | grep '^_WIN32$$' >/dev/null; then \
		echo cp -r $(srcdir)/tcc/win32/include/* "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/"; \
		cp -r $(srcdir)/tcc/win32/include/* "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/"; \
		echo cp -r $(srcdir)/tcc/win32/lib/*.def "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib/"; \
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
		done
	$(srcdir)/patch-headers.sh "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"

test: test.tcl
	rm -rf __TMP__
	$(MAKE) install tcllibdir=$(shell pwd)/__TMP__
	-if [ "$(PACKAGE_VERSION)" = '@@VERS@@' ]; then cd __TMP__/* && ( \
		for file in tcc4tcl.tcl pkgIndex.tcl; do \
			sed 's/@@VERS@@/0.0/g' "$${file}" > "$${file}.new"; \
			cat "$${file}.new" > "$${file}"; \
			rm -f "$${file}.new"; \
		done \
	); fi
	if [ '@build@' = '@host@' ]; then TCC4TCL_TEST_RUN_NATIVE=1; export TCC4TCL_TEST_RUN_NATIVE; fi; $(TCLSH) $(srcdir)/test.tcl __TMP__
	echo Tests Completed OK > TEST-STATUS







|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
		done
	$(srcdir)/patch-headers.sh "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"

test: test.tcl
	rm -rf __TMP__
	$(MAKE) install tcllibdir=$(shell pwd)/__TMP__
	-if [ "$(PACKAGE_VERSION)" = '@@VERS@@' ]; then cd __TMP__/* && ( \
		for file in tcc4tcl.tcl tcc4critcl.tcl pkgIndex.tcl; do \
			sed 's/@@VERS@@/0.0/g' "$${file}" > "$${file}.new"; \
			cat "$${file}.new" > "$${file}"; \
			rm -f "$${file}.new"; \
		done \
	); fi
	if [ '@build@' = '@host@' ]; then TCC4TCL_TEST_RUN_NATIVE=1; export TCC4TCL_TEST_RUN_NATIVE; fi; $(TCLSH) $(srcdir)/test.tcl __TMP__
	echo Tests Completed OK > TEST-STATUS

Modified pkgIndex.tcl.in from [00c586db9f] to [26945f81a8].

1

package ifneeded tcc4tcl @PACKAGE_VERSION@ [list source [file join $dir tcc4tcl.tcl]]


>
1
2
package ifneeded tcc4tcl @PACKAGE_VERSION@ [list source [file join $dir tcc4tcl.tcl]]
package ifneeded critcl 0 [list source [file join $dir tcc4critcl.tcl]]

Added tcc4critcl.tcl version [f455727caf].





































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
#! /usr/bin/env tclsh

package require tcc4tcl

namespace eval ::critcl {}

proc ::critcl::_allocateHandle {} {
	if {![info exists ::critcl::handle]} {
		set ::critcl::handle [::tcc4tcl::new]
	}

	return $::critcl::handle
}

apply {{} {
	foreach {proc args} {
		ccode code
		ccommand {command argList body}
	} {
		set argslist ""
		foreach arg $args {
			append argslist " \$$arg"
		}
		set argslist [string range $argslist 1 end]

		proc ::critcl::${proc} $args [string map [list @@PROC@@ $proc @@ARGSLIST@@ $argslist] {
			set handle [::critcl::_allocateHandle]

			uplevel #0 [list $handle @@PROC@@ @@ARGSLIST@@]
		}]
	}
}}

proc ::critcl::ccode {code} {
	set handle [::critcl::_allocateHandle]

	tailcall $handle ccode $code
}

proc ::critcl::_go {handle} {
	$handle go

	if {$handle != $::critcl::handle} {
		error "out of sync"
	}

	unset -nocomplain ::critcl::handle
}

proc ::critcl::ccommand {command argList body} {
	set handle [::critcl::_allocateHandle]

	set command [::tcc4tcl::lookupNamespace $command]

	$handle ccommand $command $argList $body

	set body {
		set args [uplevel 1 set args]

		::critcl::_go $handle

		tailcall $command {*}$args
	}

	proc $command args [list apply [list {handle command} $body] $handle $command]
}

proc ::critcl::cproc {command argList resultType body} {
	set handle [::critcl::_allocateHandle]

	set command [::tcc4tcl::lookupNamespace $command]

	$handle cproc $command $argList $resultType $body

	set body {
		set args [uplevel 1 set args]

		::critcl::_go $handle


		tailcall $command {*}$args
	}

	proc $command args [list apply [list {handle command} $body] $handle $command]
}

proc ::critcl::cheaders {header} {
	set handle [::critcl::_allocateHandle]

	$handle ccode "#include \"$header\""
}

proc ::critcl::csources {file} {
	set handle [::critcl::_allocateHandle]

	# Locate file relative to current script
	set file [file join $::critcl::dir $file]

	set fd [open $file]
	$handle ccode [read $fd]
	close $fd
}

proc ::critcl::cflags args {
	set handle [::critcl::_allocateHandle]
	$handle process_command_line [join $args " "]
}

proc ::critcl::ldflags args {
	set handle [::critcl::_allocateHandle]
	$handle process_command_line [join $args " "]
}

package provide critcl 0

Modified test.tcl from [3226475418] to [63a2456439].

223
224
225
226
227
228
229











230
	return(TCL_OK);
}
$handle go
if {[testCCommand] ne "OKAY"} {
	error "\[testCCommand\] Invalid result"
}












exit 0







>
>
>
>
>
>
>
>
>
>
>

223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
	return(TCL_OK);
}
$handle go
if {[testCCommand] ne "OKAY"} {
	error "\[testCCommand\] Invalid result"
}

# Critcl test
package require -exact critcl 0
critcl::ccode {
#define test 1234
}

critcl::cproc test14 {int x} int {
	return(x + test);
}
puts "Test14: [test14 3]"

exit 0