Check-in [3c45d1d050]
Overview
Comment:Updated to support output to exe
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3c45d1d05084629c47f91f432bf20de7f5a052ec
User & Date: rkeene on 2014-06-18 17:03:25
Other Links: manifest | tags
Context
2014-06-18
17:26
Updated to produce working shared objects and executables (might need more stuff for Windows) check-in: ff53d13ed7 user: rkeene tags: trunk
17:03
Updated to support output to exe check-in: 3c45d1d050 user: rkeene tags: trunk
05:05
Updated to allow output to file (DLL/SO) to work -- but segfaults check-in: c208e3c07f user: rkeene tags: trunk
Changes

Modified tcc4tcl.tcl from [0ac3e6cbbe] to [54d1a42bf7].

    20     20   
    21     21   		set handle ::tcc4tcl::tcc_[incr count]
    22     22   		set tcc_handle ::tcc4tcl::tcc_[incr count]
    23     23   
    24     24   		if {$output == ""} {
    25     25   			set type "memory"
    26     26   		} else {
    27         -			set type "dll"
           27  +			if {$pkgName == ""} {
           28  +				set type "exe"
           29  +			} else {
           30  +				set type "dll"
           31  +			}
    28     32   		}
    29     33   
    30     34   		array set $handle [list tcc $tcc_handle code "" type $type filename $output package $pkgName]
    31     35   
    32     36   		proc $handle {cmd args} [string map [list @@HANDLE@@ $handle] {
    33     37   			set handle {@@HANDLE@@}
    34     38   			uplevel 1 [list ::tcc4tcl::_$cmd $handle {*}$args]
................................................................................
    80     84   			"memory" {
    81     85   				tcc compile $state(code)
    82     86   
    83     87   				foreach {procname cname} $state(procs) {
    84     88   					tcc command $procname $cname
    85     89   				}
    86     90   			}
           91  +			"exe" {
           92  +				if {[info exists state(procs)] && [llength $state(procs)] > 0} {
           93  +					append state(code) "int _initProcs(Tcl_Interp *interp) \{\n"
           94  +					
           95  +					foreach {procname cname} $state(procs) {
           96  +						append state(code) "  Tcl_CreateObjCommand(interp, \"$procname\", $cname, NULL, NULL);"
           97  +					}
           98  +
           99  +					append state(code) "\}"
          100  +				}
          101  +
          102  +				tcc compile $state(code)
          103  +
          104  +				tcc output_file $state(filename)
          105  +			}
    87    106   			"dll" {
    88    107   				append state(code) "int [string totitle $state(package)]_Init(Tcl_Interp *interp) \{\n"
    89    108   				append state(code) "#ifdef USE_TCL_STUBS\n"
    90    109   				append state(code) "  if (Tcl_InitStubs(interp, \"8.4\" , 0) == 0L) \{\n"
    91    110   				append state(code) "    return TCL_ERROR;\n"
    92    111   				append state(code) "  \}\n"
    93    112   				append state(code) "#endif\n"