Skip to content
Tcl Source Code Update of ”Embedding Support”
Login

Update of ”Embedding Support”

Overview

Artifact ID: 2762f9f61a9f097db40fac39d984dd41b499d158
Page Name:Embedding Support
Date: 2014-09-09 19:30:13
Original User: dgp
Parent: 5d3cddcb470f8d6edd62c05cdf2da2c81e36e686 (diff)
Next 16070b24f55f1403b3812074774b15a6ecf24185
Content

It helps the analysis to break this one into two parts.

Source Files

Public Interface

Private Interface

Directly Depends On Public Interface

Directly Depends On Private Interface of

Discussion

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 Tcl_Panic.

One wrinkle is the routine tclWinDebugPanic which is in multiple places, tclWinError.c and tclWinFile.c. There's also a great deal of #ifdef in tclPanic.c. A restructuring into a generic caller of TclpPanic might be a path to increasing simplicity and conventionality.

The routine TclGetMainLoop is another to note. It appears in no header file. It gets declared with MODULE_SCOPE but there doesn't appear to be any reason it could not be a static function.

The routine TclFullFinalizationRequested probably should move into Event Loops.

The core_zip_vfs Patch

The 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 main.tcl is present).

This patch:

To build a self-contained executable:

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
# The -A argument tells zip to offset itself from the executable
zip -A mynewkit main.tcl
./mynewkit
hello world
(Program exit)

For convenience the tcl Makefile has a "make tclkit", which make a tclkit with an embedded TCL_LIBRARY.

The tk Makefile has a "make tkkit" which provides a similar service for wish-based kits.

If the shells are compiled with --enable-shared=no, the Tcl/Tk libraries will be statically bound with the shells, and thus truly self-contained. Otherwise they will need access to the tcl/tk shared libraries. Either in the same directory as the executable, or tucked somewhere in your operating's systems library search path.