Wiki page
[Embedding Support] by
hypnotoad
2014-09-03 10:37:43.
D 2014-09-03T10:37:43.250
L Embedding\sSupport
P e5194c66dafe6aee54aa95fde8c1586305970126
U hypnotoad
W 2923
<h1>Source Files</h1>
* [/finfo?name=generic/tclMain.c|tclMain.c]
* [/finfo?name=generic/tclPanic.c|tclPanic.c]
* [/finfo?name=unix/tclAppInit.c|tclAppInit.c]
* [/finfo?name=win/tclAppInit.c|tclAppInit.c]
<h1>Public Interface</h1>
* Tcl_SetStartupScript
* Tcl_GetStartupScript
* Tcl_SourceRCFile
* Tcl_Main
* Tcl_MainEx
* Tcl_SetMainLoop
* Tcl_SetPanicProc
* Tcl_PanicVA
* Tcl_Panic
<h1>Private Interface</h1>
* TclFullFinalizationRequested
* TclGetMainLoop
<h1>Directly Depends On Public Interface</h1>
* [Threads]
* [Object System and Fundamental Object Types]
* [Variable Commands and Interfaces]
* [Pathname Management]
* [Filesystem Access]
* [Channel System]
* [list Object Type]
* [Preservation]
* [Parsing and Evaluation]
* [interp]
* [Event Loops]
* [dict Object Type]
* [Linked C Variables]
* [history]
* <i>unistd.h</i>
<h1>Directly Depends On Private Interface of</h1>
* [Initialization, Library, Autoloader]
* [Pathname Management]
* [Object System and Fundamental Object Types]
* [Parsing and Evaluation]
* [Allocation]
* [Environment Variables]
<h1>The core_zip_vfs Patch</h1>
The [/timeline?r=core_zip_vfs|core_zip_vfs] branch adds the ability to mount a zip archive concatenated to the current executable as a virtual file system, capable of hosting both env(TCL_LIBRARY) and kick off
a bootloader (if a file called <i>main.tcl</i> is present).
This patch:
* Adds [/finfo?name=generic/tclZipVfs.c|tclZipVfs.c]
* Modifies [/finfo?name=unix/tclAppInit.c|tclAppInit.c]
* Modifies [/finfo?name=win/tclAppInit.c|tclAppInit.c]
To build a self-contained executable:
<verbatim>
cp tclsh mynewkit
# Build an empty zipfile and concat it to the executable
touch .empty
zip null.zip .empty
cat null.zip >> mynewkit
#
echo "puts {hello world}" > main.tcl
zip -A mynewkit main.tcl
./mynewkit
hello world
(Program exit)
</verbatim>
<h1>Discussion</h1>
This has been considered a single module, but tclPanic.c is essentially a self contained
bit without dependencies, while tclMain.c depends on nearly everything. Most other parts
of Tcl that claim a dependence on this module are really just callers of <b>Tcl_Panic</b>.
One wrinkle is the routine <b>tclWinDebugPanic</b> which is in multiple places,
tclWinError.c and tclWinFile.c. There's also a great deal of <b>#ifdef</b> in tclPanic.c.
A restructuring into a generic caller of <b>TclpPanic</b> might be a path to increasing
simplicity and conventionality.
The routine <b>TclGetMainLoop</b> is another to note. It appears in no header file.
It gets declared with <b>MODULE_SCOPE</b> but there doesn't appear to be any reason
it could not be a static function.
The routine <b>TclFullFinalizationRequested</b> probably should move into [Event Loops].
Z 3e19bdacf0a0ce8623b1cfc67221eb17