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
21
22
23
24
25
26



27

28
29
30
31
32
33
34
..
80
81
82
83
84
85
86















87
88
89
90
91
92
93

		set handle ::tcc4tcl::tcc_[incr count]
		set tcc_handle ::tcc4tcl::tcc_[incr count]

		if {$output == ""} {
			set type "memory"
		} else {



			set type "dll"

		}

		array set $handle [list tcc $tcc_handle code "" type $type filename $output package $pkgName]

		proc $handle {cmd args} [string map [list @@HANDLE@@ $handle] {
			set handle {@@HANDLE@@}
			uplevel 1 [list ::tcc4tcl::_$cmd $handle {*}$args]
................................................................................
			"memory" {
				tcc compile $state(code)

				foreach {procname cname} $state(procs) {
					tcc command $procname $cname
				}
			}















			"dll" {
				append state(code) "int [string totitle $state(package)]_Init(Tcl_Interp *interp) \{\n"
				append state(code) "#ifdef USE_TCL_STUBS\n"
				append state(code) "  if (Tcl_InitStubs(interp, \"8.4\" , 0) == 0L) \{\n"
				append state(code) "    return TCL_ERROR;\n"
				append state(code) "  \}\n"
				append state(code) "#endif\n"







>
>
>
|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
..
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

		set handle ::tcc4tcl::tcc_[incr count]
		set tcc_handle ::tcc4tcl::tcc_[incr count]

		if {$output == ""} {
			set type "memory"
		} else {
			if {$pkgName == ""} {
				set type "exe"
			} else {
				set type "dll"
			}
		}

		array set $handle [list tcc $tcc_handle code "" type $type filename $output package $pkgName]

		proc $handle {cmd args} [string map [list @@HANDLE@@ $handle] {
			set handle {@@HANDLE@@}
			uplevel 1 [list ::tcc4tcl::_$cmd $handle {*}$args]
................................................................................
			"memory" {
				tcc compile $state(code)

				foreach {procname cname} $state(procs) {
					tcc command $procname $cname
				}
			}
			"exe" {
				if {[info exists state(procs)] && [llength $state(procs)] > 0} {
					append state(code) "int _initProcs(Tcl_Interp *interp) \{\n"
					
					foreach {procname cname} $state(procs) {
						append state(code) "  Tcl_CreateObjCommand(interp, \"$procname\", $cname, NULL, NULL);"
					}

					append state(code) "\}"
				}

				tcc compile $state(code)

				tcc output_file $state(filename)
			}
			"dll" {
				append state(code) "int [string totitle $state(package)]_Init(Tcl_Interp *interp) \{\n"
				append state(code) "#ifdef USE_TCL_STUBS\n"
				append state(code) "  if (Tcl_InitStubs(interp, \"8.4\" , 0) == 0L) \{\n"
				append state(code) "    return TCL_ERROR;\n"
				append state(code) "  \}\n"
				append state(code) "#endif\n"