diff options
author | surles <surles> | 1998-07-24 13:49:13 (GMT) |
---|---|---|
committer | surles <surles> | 1998-07-24 13:49:13 (GMT) |
commit | aaf71b185279c46208cedda0caf510bc43baa437 (patch) | |
tree | adfbcc6f4259a132707c66b34c76a64cab2654f4 /generic/tclNamesp.c | |
parent | 88d6f2dc3a97fd42cfca3ea9bb1cb3a721e10c76 (diff) | |
download | tcl-aaf71b185279c46208cedda0caf510bc43baa437.zip tcl-aaf71b185279c46208cedda0caf510bc43baa437.tar.gz tcl-aaf71b185279c46208cedda0caf510bc43baa437.tar.bz2 |
Updated core w/ Micheals latest changes.
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r-- | generic/tclNamesp.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index d399426..45367c7 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -1085,6 +1085,10 @@ Tcl_AppendExportList(interp, namespacePtr, objPtr) * is NULL). This is done by creating a new command (the "imported * command") that points to the real command in its original namespace. * + * If matching commands are on the autoload path but haven't been + * loaded yet, this command forces them to be loaded, then creates + * the links to them. + * * Results: * Returns TCL_OK if successful, or TCL_ERROR (along with an error * message in the interpreter's result) if something goes wrong. @@ -1120,7 +1124,7 @@ Tcl_Import(interp, namespacePtr, pattern, allowOverwrite) Tcl_HashSearch search; Command *cmdPtr; ImportRef *refPtr; - Tcl_Command importedCmd; + Tcl_Command autoCmd, importedCmd; ImportedCmdData *dataPtr; int wasExported, i, result; @@ -1133,6 +1137,38 @@ Tcl_Import(interp, namespacePtr, pattern, allowOverwrite) } else { nsPtr = (Namespace *) namespacePtr; } + + /* + * First, invoke the "auto_import" command with the pattern + * being imported. This command is part of the Tcl library. + * It looks for imported commands in autoloaded libraries and + * loads them in. That way, they will be found when we try + * to create links below. + */ + + autoCmd = Tcl_FindCommand(interp, "auto_import", + (Tcl_Namespace *) NULL, /*flags*/ TCL_GLOBAL_ONLY); + + if (autoCmd != NULL) { + Tcl_Obj *objv[2]; + + objv[0] = Tcl_NewStringObj("auto_import", -1); + Tcl_IncrRefCount(objv[0]); + objv[1] = Tcl_NewStringObj(pattern, -1); + Tcl_IncrRefCount(objv[1]); + + cmdPtr = (Command *) autoCmd; + result = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, + 2, objv); + + Tcl_DecrRefCount(objv[0]); + Tcl_DecrRefCount(objv[1]); + + if (result != TCL_OK) { + return TCL_ERROR; + } + Tcl_ResetResult(interp); + } /* * From the pattern, find the namespace from which we are importing |