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     56   
    57     57   tcc4tcl-static.a: tcc4tcl.o tcc/libtcc.a
    58     58   	cp tcc/libtcc.a tcc4tcl-static.new.a
    59     59   	$(AR) rcu tcc4tcl-static.new.a tcc4tcl.o
    60     60   	-$(RANLIB) tcc4tcl-static.new.a
    61     61   	mv tcc4tcl-static.new.a tcc4tcl-static.a
    62     62   
    63         -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
           63  +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
    64     64   	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
    65     65   	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
    66     66   	$(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"
    67     67   	$(INSTALL) -m 0755 $(TARGET) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
    68     68   	$(INSTALL) -m 0644 pkgIndex.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
    69     69   	$(INSTALL) -m 0644 $(srcdir)/tcc4tcl.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
           70  +	$(INSTALL) -m 0644 $(srcdir)/tcc4critcl.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)"
    70     71   	$(INSTALL) -m 0644 tcc/libtcc1.a "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
    71     72   	$(INSTALL) -m 0644 $(shell echo $(srcdir)/tcc/win32/lib/*.c) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib"
    72     73   	$(INSTALL) -m 0644 $(shell echo $(srcdir)/tcc/include/*) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"
    73     74   	@if ! echo "_WIN32" | $(CPP) $(CPPFLAGS) - | grep '^_WIN32$$' >/dev/null; then \
    74     75   		echo cp -r $(srcdir)/tcc/win32/include/* "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/"; \
    75     76   		cp -r $(srcdir)/tcc/win32/include/* "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/"; \
    76     77   		echo cp -r $(srcdir)/tcc/win32/lib/*.def "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib/"; \
................................................................................
    87     88   		done
    88     89   	$(srcdir)/patch-headers.sh "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include"
    89     90   
    90     91   test: test.tcl
    91     92   	rm -rf __TMP__
    92     93   	$(MAKE) install tcllibdir=$(shell pwd)/__TMP__
    93     94   	-if [ "$(PACKAGE_VERSION)" = '@@VERS@@' ]; then cd __TMP__/* && ( \
    94         -		for file in tcc4tcl.tcl pkgIndex.tcl; do \
           95  +		for file in tcc4tcl.tcl tcc4critcl.tcl pkgIndex.tcl; do \
    95     96   			sed 's/@@VERS@@/0.0/g' "$${file}" > "$${file}.new"; \
    96     97   			cat "$${file}.new" > "$${file}"; \
    97     98   			rm -f "$${file}.new"; \
    98     99   		done \
    99    100   	); fi
   100    101   	if [ '@build@' = '@host@' ]; then TCC4TCL_TEST_RUN_NATIVE=1; export TCC4TCL_TEST_RUN_NATIVE; fi; $(TCLSH) $(srcdir)/test.tcl __TMP__
   101    102   	echo Tests Completed OK > TEST-STATUS

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

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

Added tcc4critcl.tcl version [f455727caf].

            1  +#! /usr/bin/env tclsh
            2  +
            3  +package require tcc4tcl
            4  +
            5  +namespace eval ::critcl {}
            6  +
            7  +proc ::critcl::_allocateHandle {} {
            8  +	if {![info exists ::critcl::handle]} {
            9  +		set ::critcl::handle [::tcc4tcl::new]
           10  +	}
           11  +
           12  +	return $::critcl::handle
           13  +}
           14  +
           15  +apply {{} {
           16  +	foreach {proc args} {
           17  +		ccode code
           18  +		ccommand {command argList body}
           19  +	} {
           20  +		set argslist ""
           21  +		foreach arg $args {
           22  +			append argslist " \$$arg"
           23  +		}
           24  +		set argslist [string range $argslist 1 end]
           25  +
           26  +		proc ::critcl::${proc} $args [string map [list @@PROC@@ $proc @@ARGSLIST@@ $argslist] {
           27  +			set handle [::critcl::_allocateHandle]
           28  +
           29  +			uplevel #0 [list $handle @@PROC@@ @@ARGSLIST@@]
           30  +		}]
           31  +	}
           32  +}}
           33  +
           34  +proc ::critcl::ccode {code} {
           35  +	set handle [::critcl::_allocateHandle]
           36  +
           37  +	tailcall $handle ccode $code
           38  +}
           39  +
           40  +proc ::critcl::_go {handle} {
           41  +	$handle go
           42  +
           43  +	if {$handle != $::critcl::handle} {
           44  +		error "out of sync"
           45  +	}
           46  +
           47  +	unset -nocomplain ::critcl::handle
           48  +}
           49  +
           50  +proc ::critcl::ccommand {command argList body} {
           51  +	set handle [::critcl::_allocateHandle]
           52  +
           53  +	set command [::tcc4tcl::lookupNamespace $command]
           54  +
           55  +	$handle ccommand $command $argList $body
           56  +
           57  +	set body {
           58  +		set args [uplevel 1 set args]
           59  +
           60  +		::critcl::_go $handle
           61  +
           62  +		tailcall $command {*}$args
           63  +	}
           64  +
           65  +	proc $command args [list apply [list {handle command} $body] $handle $command]
           66  +}
           67  +
           68  +proc ::critcl::cproc {command argList resultType body} {
           69  +	set handle [::critcl::_allocateHandle]
           70  +
           71  +	set command [::tcc4tcl::lookupNamespace $command]
           72  +
           73  +	$handle cproc $command $argList $resultType $body
           74  +
           75  +	set body {
           76  +		set args [uplevel 1 set args]
           77  +
           78  +		::critcl::_go $handle
           79  +
           80  +
           81  +		tailcall $command {*}$args
           82  +	}
           83  +
           84  +	proc $command args [list apply [list {handle command} $body] $handle $command]
           85  +}
           86  +
           87  +proc ::critcl::cheaders {header} {
           88  +	set handle [::critcl::_allocateHandle]
           89  +
           90  +	$handle ccode "#include \"$header\""
           91  +}
           92  +
           93  +proc ::critcl::csources {file} {
           94  +	set handle [::critcl::_allocateHandle]
           95  +
           96  +	# Locate file relative to current script
           97  +	set file [file join $::critcl::dir $file]
           98  +
           99  +	set fd [open $file]
          100  +	$handle ccode [read $fd]
          101  +	close $fd
          102  +}
          103  +
          104  +proc ::critcl::cflags args {
          105  +	set handle [::critcl::_allocateHandle]
          106  +	$handle process_command_line [join $args " "]
          107  +}
          108  +
          109  +proc ::critcl::ldflags args {
          110  +	set handle [::critcl::_allocateHandle]
          111  +	$handle process_command_line [join $args " "]
          112  +}
          113  +
          114  +package provide critcl 0

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

   223    223   	return(TCL_OK);
   224    224   }
   225    225   $handle go
   226    226   if {[testCCommand] ne "OKAY"} {
   227    227   	error "\[testCCommand\] Invalid result"
   228    228   }
   229    229   
          230  +# Critcl test
          231  +package require -exact critcl 0
          232  +critcl::ccode {
          233  +#define test 1234
          234  +}
          235  +
          236  +critcl::cproc test14 {int x} int {
          237  +	return(x + test);
          238  +}
          239  +puts "Test14: [test14 3]"
          240  +
   230    241   exit 0