
perlPort.pod - Notes on Porting tkTable from tcl to perltk


This contains a TCL script that is run when table is loaded. This will probably have to be completly converted to perl. Excluded.
Used by gnu autoconfigure in the TCL scripts. Excluded.
Used for mac port. Don't worry about for now.
Command structure lookup definitions. Called out by tkTable.h
TCL application Init. A similar file is excluded in ../tclUnix, ../tclWin, etc. Excluded.
Main tkTable code/header file.
Functions for the tkTable Cells
Implements general commands of the table widget
Implements editing functions for the table widget.
Implements postscript output for table widgets.
Implements tags for table widgets.
Implements embedded windows for table widgets

As an example,
Scale.xs references Tk_ScaleCmd,
which is defined in tkScale.c.
Should the top leved Table.xs do a similar thing?

These notes are taken from looking at the difference between the tkScale.h and tkScale.c files in the stock tk8.0.5 distribution and the Tk800.022/pTk/mTk distribution.
Also add:
#include "tkPort.h" #include "tkInt.h" #include "tkVMacro.h"
Or change to Tk_State type?
Before "tkScale.h" or equivalent.
Tk_CONFIG_STRINGS for commands to TK_CONFIG_CALLBACK.
Removed/Change UID type variables
Change TK_CONFIG_STRING to TK_CONFIG_SCALAR_VAR for -variable type entries.
From char * name to Var name where appropriate.
Also for disabled (TK_STATE_DISABLED)
Anything like value = strtod(stringValue, &end) should be converted to a Arg stringValue; type and a (Tcl_GetDouble(interp, stringValue, &value) call.
Similar to the way this was changed in the tkCanvas.c file in the main tk distribution.
Replace Tcl_SetStringObj with Tcl_ArgResult similar to what is in tkCanvas.c
Any calls to Tcl_VarEval are converted to LangDoCallback
Any calls to Tcl_SplitList are changed to Tcl_ListObjGetElements.
Any calls to Tcl_Merge are changed to Tcl_NewListObj.
Any calls to Tcl_GetStringResult are changed to Tcl_GetResult. Tcl_GetStringResult wasn't provided as part of the tkGlue.c parkage and Tcl_GetResult appeared to do the same thing.
The original tktable widget accepts TCL scripts (text) to be used as callbacks (Like for -browsecommand, and the -command options). The tcl/tk code takes the TCL script and performs Expand Percents on it, and then evals it, using Tcl_GlobalEval. To work with perltk, this sequence was changed to a LangDoCallBack.
Files in the lib directory (tkTable.tcl) are equivalent to the .pm files for the widget, so the tkTable.tcl file has to be converted to perl. See the various .pm files in the Tk distribution for examples.
Note the tcl2perl script in the Tk distribution can provided a starting point for the translation. Much hand-editing is still required however.