I'm working on developing an implementation for a TIP that I plan to
propose, based on a Tcl extension package I wrote some years ago. Most
of the functionality is already implemented, but I'm not sure how to
translate some of the extension bits into a core command.
The area that is giving me some difficulty is how to refactor the
package initialization code. A lot of the functionality of the module is
dependent on getting a handle for the main Tcl interpreter. See below:
//initalize the package in the tcl interpreter, create tcl commands
int Tclservices_Init (Tcl_Interp *interp) {
//set up an autorelease pool
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
return TCL_ERROR;
}
if (Tk_InitStubs(interp, "8.5", 0) == NULL) {
return TCL_ERROR;
}
Tcl_CreateObjCommand(interp, "::tclservices::registerservicewidget",
RegisterServiceWidget,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
//initialize instance of TclServices to provide service functionality
TclService *service = [[TclService alloc] init];
myInterp = interp;
[NSApp setServicesProvider:service];
if (Tcl_PkgProvide(interp, "tclservices", "1.0") != TCL_OK) {
return TCL_ERROR;
}
[pool release];
return TCL_OK;
}
Where in Tk's codebase can I add some of these initialization bits to
ensure that I have a handle on the correct interpreter, create the key
command, and so on? None of the core files use this initialization
routine, of course, but it must be done somewhere. Advice is appreciated.
Thanks,
Kevin
--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com