aboutsummaryrefslogtreecommitdiff
path: root/make-c-ext.tcl
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2009-07-29 14:12:41 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 10:11:03 +1000
commit4996f466d3bfb568b4798cbef03f059ae030be7f (patch)
tree05da6b67fd091ef2c081b951168abf78026582fa /make-c-ext.tcl
parent1c0ce5bc7197de87f5820b1afc72304adef537b3 (diff)
downloadjimtcl-4996f466d3bfb568b4798cbef03f059ae030be7f.zip
jimtcl-4996f466d3bfb568b4798cbef03f059ae030be7f.tar.gz
jimtcl-4996f466d3bfb568b4798cbef03f059ae030be7f.tar.bz2
Build fixes, better Jim_EvalFile()
*: make-c-ext is now make-c-ext.tcl *: build doc/Tcl.html with asciidoc *: Jim_SetIntResult -> Jim_SetResultInt *: Jim_EvalFile() now reads the file contents in one go
Diffstat (limited to 'make-c-ext.tcl')
-rw-r--r--make-c-ext.tcl40
1 files changed, 40 insertions, 0 deletions
diff --git a/make-c-ext.tcl b/make-c-ext.tcl
new file mode 100644
index 0000000..96f6355
--- /dev/null
+++ b/make-c-ext.tcl
@@ -0,0 +1,40 @@
+#!/usr/bin/env tclsh
+
+proc tcl_to_string {str} {
+ set result {}
+ foreach buf [split $str \n] {
+ set trimmed [string trim $buf]
+ if {[string match "#*" $trimmed] || $trimmed == ""} {
+ continue
+ }
+ regsub -all {\\} $buf {\\\\} buf
+ regsub -all \" $buf "\\\"" buf
+ append result {"} $buf {\n"} \n
+ }
+ return $result
+}
+
+set outfile [lindex $argv 0]
+set argv [lrange $argv 1 end]
+
+foreach file $argv {
+ if {![string match *.tcl $file]} {
+ error "Not a tcl file: $file"
+ }
+ set tmp [file tail $file]
+ set rootname [file rootname $tmp]
+ if {0} {
+ set outfile jim-$rootname.c
+ }
+ set f [open $file]
+ set str [read $f]
+ close $f
+ set f [open $outfile w]
+ puts $f {#include <jim.h>}
+ puts $f "int Jim_${rootname}Init(Jim_Interp *interp)"
+ puts $f "{"
+ puts $f "\treturn Jim_EvalGlobal(interp, "
+ puts -nonewline $f [tcl_to_string $str]
+ puts $f ");\t}"
+ close $f
+}