Differences From Artifact [bb532792bb]:
- File generic/tclNamesp.c — part of check-in [0a6d56f9eb] at 2004-12-29 22:46:32 on branch kennykb-numerics-branch — merge from HEAD (user: kennykb size: 192747)
To Artifact [2ef75fc038]:
- File generic/tclNamesp.c — part of check-in [14457d7982] at 2005-01-20 19:11:49 on branch kennykb-numerics-branch — Development checkpoint, see ChangeLog for details (user: kennykb size: 192786)
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tclNamesp.c -- * * Contains support for namespaces, which provide a separate context of * commands and global variables. The global :: namespace is the * traditional Tcl "global" scope. Other namespaces are created as * children of the global namespace. These other namespaces contain * special-purpose commands and variables for packages. Also includes * the TIP#112 ensemble machinery. * * Copyright (c) 1993-1997 Lucent Technologies. * Copyright (c) 1997 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * tclNamesp.c -- * * Contains support for namespaces, which provide a separate context of * commands and global variables. The global :: namespace is the * traditional Tcl "global" scope. Other namespaces are created as * children of the global namespace. These other namespaces contain * special-purpose commands and variables for packages. Also includes * the TIP#112 ensemble machinery. * * Copyright (c) 1993-1997 Lucent Technologies. * Copyright (c) 1997 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. * Copyright (c) 2002-2005 Donal K. Fellows. * * Originally implemented by * Michael J. McLennan * Bell Labs Innovations for Lucent Technologies * mmclennan@lucent.com * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclNamesp.c,v 1.66.2.3 2005/01/20 19:13:32 kennykb Exp $ */ #include "tclInt.h" /* * Initial size of stack allocated space for tail list - used when resetting * shadowed command references in the functin: TclResetShadowedCmdRefs. |
| ︙ | ︙ | |||
115 116 117 118 119 120 121 |
struct EnsembleConfig *next;/* The next ensemble in the linked list of
* ensembles associated with a namespace. If
* this field points to this ensemble, the
* structure has already been unlinked from
* all lists, and cannot be found by scanning
* the list from the namespace's ensemble
* field. */
| | > | | | | > | | | | | | < < < | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
struct EnsembleConfig *next;/* The next ensemble in the linked list of
* ensembles associated with a namespace. If
* this field points to this ensemble, the
* structure has already been unlinked from
* all lists, and cannot be found by scanning
* the list from the namespace's ensemble
* field. */
int flags; /* ORed combo of ENS_DEAD and
* TCL_ENSEMBLE_PREFIX. */
/* OBJECT FIELDS FOR ENSEMBLE CONFIGURATION */
Tcl_Obj *subcommandDict; /* Dictionary providing mapping from
* subcommands to their implementing command
* prefixes, or NULL if we are to build the
* map automatically from the namespace
* exports. */
Tcl_Obj *subcmdList; /* List of commands that this ensemble
* actually provides, and whose implementation
* will be built using the subcommandDict (if
* present and defined) and by simple mapping
* to the namespace otherwise. If NULL,
* indicates that we are using the (dynamic)
* list of currently exported commands. */
Tcl_Obj *unknownHandler; /* Script prefix used to handle the case when
* no match is found (according to the rule
* defined by flag bit TCL_ENSEMBLE_PREFIX) or
* NULL to use the default error-generating
* behaviour. The script execution gets all
* the arguments to the ensemble command
* (including objv[0]) and will have the
* results passed directly back to the caller
* (including the error code) unless the code
* is TCL_CONTINUE in which case the subcommand
* will be reparsed by the ensemble core,
* presumably because the ensemble itself has
* been updated. */
} EnsembleConfig;
#define ENS_DEAD 0x1 /* Flag value to say that the ensemble is dead
* and on its way out. */
/*
* The data cached in a subcommand's Tcl_Obj rep. This structure is
* not shared between Tcl_Objs referring to the same subcommand, even
* where one is a duplicate of another.
*/
|
| ︙ | ︙ | |||
4510 4511 4512 4513 4514 4515 4516 | * Create the ensemble. Note that this might delete another * ensemble linked to the same namespace, so we must be * careful. However, we should be OK because we only link the * namespace into the list once we've created it (and after * any deletions have occurred.) */ | | | | | | | | | | | | | | | | | | | | | | | | | | 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 |
* Create the ensemble. Note that this might delete another
* ensemble linked to the same namespace, so we must be
* careful. However, we should be OK because we only link the
* namespace into the list once we've created it (and after
* any deletions have occurred.)
*/
token = Tcl_CreateEnsemble(interp, name, NULL,
(permitPrefix ? TCL_ENSEMBLE_PREFIX : 0));
Tcl_SetEnsembleSubcommandList(interp, token, subcmdObj);
Tcl_SetEnsembleMappingDict(interp, token, mapObj);
Tcl_SetEnsembleUnknownHandler(interp, token, unknownObj);
/*
* Tricky! Rely on the object result not being shared!
*/
Tcl_GetCommandFullName(interp, token, Tcl_GetObjResult(interp));
return TCL_OK;
}
case ENS_EXISTS:
if (objc != 4) {
Tcl_WrongNumArgs(interp, 3, objv, "cmdname");
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
Tcl_FindEnsemble(interp, objv[3], 0) != NULL));
return TCL_OK;
case ENS_CONFIG:
if (objc < 4 || (objc != 5 && objc & 1)) {
Tcl_WrongNumArgs(interp, 3, objv, "cmdname ?opt? ?value? ...");
return TCL_ERROR;
}
token = Tcl_FindEnsemble(interp, objv[3], TCL_LEAVE_ERR_MSG);
if (token == NULL) {
return TCL_ERROR;
}
if (objc == 5) {
Tcl_Obj *resultObj;
if (Tcl_GetIndexFromObj(interp, objv[4], configOptions, "option",
0, &index) != TCL_OK) {
return TCL_ERROR;
}
switch ((enum EnsConfigOpts) index) {
case CONF_SUBCMDS:
Tcl_GetEnsembleSubcommandList(NULL, token, &resultObj);
if (resultObj != NULL) {
Tcl_SetObjResult(interp, resultObj);
}
break;
case CONF_MAP:
Tcl_GetEnsembleMappingDict(NULL, token, &resultObj);
if (resultObj != NULL) {
Tcl_SetObjResult(interp, resultObj);
}
break;
case CONF_NAMESPACE: {
Tcl_Namespace *namespacePtr;
Tcl_GetEnsembleNamespace(NULL, token, &namespacePtr);
Tcl_SetResult(interp, ((Namespace *)namespacePtr)->fullName,
TCL_VOLATILE);
break;
}
case CONF_PREFIX: {
int flags;
Tcl_GetEnsembleFlags(NULL, token, &flags);
Tcl_SetObjResult(interp,
Tcl_NewBooleanObj(flags & TCL_ENSEMBLE_PREFIX));
break;
}
case CONF_UNKNOWN:
Tcl_GetEnsembleUnknownHandler(NULL, token, &resultObj);
if (resultObj != NULL) {
Tcl_SetObjResult(interp, resultObj);
}
break;
}
return TCL_OK;
} else if (objc == 4) {
/*
* Produce list of all information.
*/
Tcl_Obj *resultObj, *tmpObj;
Tcl_Namespace *namespacePtr;
int flags;
TclNewObj(resultObj);
/* -map option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_MAP], -1));
Tcl_GetEnsembleMappingDict(NULL, token, &tmpObj);
if (tmpObj != NULL) {
Tcl_ListObjAppendElement(NULL, resultObj, tmpObj);
} else {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewObj());
}
/* -namespace option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_NAMESPACE], -1));
Tcl_GetEnsembleNamespace(NULL, token, &namespacePtr);
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(((Namespace *)namespacePtr)->fullName,
-1));
/* -prefix option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_PREFIX], -1));
Tcl_GetEnsembleFlags(NULL, token, &flags);
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewBooleanObj(flags & TCL_ENSEMBLE_PREFIX));
/* -subcommands option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_SUBCMDS], -1));
Tcl_GetEnsembleSubcommandList(NULL, token, &tmpObj);
if (tmpObj != NULL) {
Tcl_ListObjAppendElement(NULL, resultObj, tmpObj);
} else {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewObj());
}
/* -unknown option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_UNKNOWN], -1));
Tcl_GetEnsembleUnknownHandler(NULL, token, &tmpObj);
if (tmpObj != NULL) {
Tcl_ListObjAppendElement(NULL, resultObj, tmpObj);
} else {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewObj());
}
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
} else {
Tcl_DictSearch search;
Tcl_Obj *listObj;
int done, len, allocatedMapFlag = 0;
/*
* Defaults
*/
Tcl_Obj *subcmdObj, *mapObj, *unknownObj;
int permitPrefix, flags;
Tcl_GetEnsembleSubcommandList(NULL, token, &subcmdObj);
Tcl_GetEnsembleMappingDict(NULL, token, &mapObj);
Tcl_GetEnsembleUnknownHandler(NULL, token, &unknownObj);
Tcl_GetEnsembleFlags(NULL, token, &flags);
permitPrefix = (flags & TCL_ENSEMBLE_PREFIX) != 0;
objv += 4;
objc -= 4;
/*
* Parse the option list, applying type checks as we go.
* Note that we are not incrementing any reference counts
|
| ︙ | ︙ | |||
4788 4789 4790 4791 4792 4793 4794 | } /* * Update the namespace now that we've finished the * parsing stage. */ | | > | | | | | | | 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 |
}
/*
* Update the namespace now that we've finished the
* parsing stage.
*/
flags = (permitPrefix ? flags|TCL_ENSEMBLE_PREFIX
: flags&~TCL_ENSEMBLE_PREFIX);
Tcl_SetEnsembleSubcommandList(NULL, token, subcmdObj);
Tcl_SetEnsembleMappingDict(NULL, token, mapObj);
Tcl_SetEnsembleUnknownHandler(NULL, token, unknownObj);
Tcl_SetEnsembleFlags(NULL, token, flags);
return TCL_OK;
}
default:
Tcl_Panic("unexpected ensemble command");
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_CreateEnsemble --
*
* Create a simple ensemble attached to the given namespace.
*
* Results:
* The token for the command created.
*
* Side effects:
* The ensemble is created and marked for compilation.
*
*----------------------------------------------------------------------
*/
Tcl_Command
Tcl_CreateEnsemble(interp, name, namespacePtr, flags)
Tcl_Interp *interp;
CONST char *name;
Tcl_Namespace *namespacePtr;
int flags;
{
Namespace *nsPtr = (Namespace *) namespacePtr;
EnsembleConfig *ensemblePtr =
|
| ︙ | ︙ | |||
4880 4881 4882 4883 4884 4885 4886 |
}
return ensemblePtr->token;
}
/*
*----------------------------------------------------------------------
*
| | | | 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 |
}
return ensemblePtr->token;
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetEnsembleSubcommandList --
*
* Set the subcommand list for a particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble or the subcommand list - if non-NULL - is not a list).
*
* Side effects:
* The ensemble is updated and marked for recompilation.
*
*----------------------------------------------------------------------
*/
int
Tcl_SetEnsembleSubcommandList(interp, token, subcmdList)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj *subcmdList;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldList;
|
| ︙ | ︙ | |||
4944 4945 4946 4947 4948 4949 4950 |
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 |
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetEnsembleMappingDict --
*
* Set the mapping dictionary for a particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble or the mapping - if non-NULL - is not a dict).
*
* Side effects:
* The ensemble is updated and marked for recompilation.
*
*----------------------------------------------------------------------
*/
int
Tcl_SetEnsembleMappingDict(interp, token, mapDict)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj *mapDict;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldDict;
|
| ︙ | ︙ | |||
5008 5009 5010 5011 5012 5013 5014 |
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 |
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetEnsembleUnknownHandler --
*
* Set the unknown handler for a particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble or the unknown handler - if non-NULL - is not a list).
*
* Side effects:
* The ensemble is updated and marked for recompilation.
*
*----------------------------------------------------------------------
*/
int
Tcl_SetEnsembleUnknownHandler(interp, token, unknownList)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj *unknownList;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
Tcl_Obj *oldList;
|
| ︙ | ︙ | |||
5073 5074 5075 5076 5077 5078 5079 |
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 |
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetEnsembleFlags --
*
* Set the flags for a particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble).
*
* Side effects:
* The ensemble is updated and marked for recompilation.
*
*----------------------------------------------------------------------
*/
int
Tcl_SetEnsembleFlags(interp, token, flags)
Tcl_Interp *interp;
Tcl_Command token;
int flags;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
|
| ︙ | ︙ | |||
5124 5125 5126 5127 5128 5129 5130 |
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 |
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetEnsembleSubcommandList --
*
* Get the list of subcommands associated with a particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble). The list of subcommands is returned by updating the
* variable pointed to by the last parameter (NULL if this is to
* be derived from the mapping dictionary or the associated
* namespace's exported commands).
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
int
Tcl_GetEnsembleSubcommandList(interp, token, subcmdListPtr)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj **subcmdListPtr;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
|
| ︙ | ︙ | |||
5165 5166 5167 5168 5169 5170 5171 |
*subcmdListPtr = ensemblePtr->subcmdList;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 |
*subcmdListPtr = ensemblePtr->subcmdList;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetEnsembleMappingDict --
*
* Get the command mapping dictionary associated with a
* particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble). The mapping dict is returned by updating the
* variable pointed to by the last parameter (NULL if none is
* installed).
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
int
Tcl_GetEnsembleMappingDict(interp, token, mapDictPtr)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj **mapDictPtr;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
|
| ︙ | ︙ | |||
5206 5207 5208 5209 5210 5211 5212 |
*mapDictPtr = ensemblePtr->subcommandDict;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 |
*mapDictPtr = ensemblePtr->subcommandDict;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetEnsembleUnknownHandler --
*
* Get the unknown handler associated with a particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble). The unknown handler is returned by updating the
* variable pointed to by the last parameter (NULL if no handler
* is installed).
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
int
Tcl_GetEnsembleUnknownHandler(interp, token, unknownListPtr)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj **unknownListPtr;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
|
| ︙ | ︙ | |||
5246 5247 5248 5249 5250 5251 5252 |
*unknownListPtr = ensemblePtr->unknownHandler;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 |
*unknownListPtr = ensemblePtr->unknownHandler;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetEnsembleFlags --
*
* Get the flags for a particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble). The flags are returned by updating the variable
* pointed to by the last parameter.
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
int
Tcl_GetEnsembleFlags(interp, token, flagsPtr)
Tcl_Interp *interp;
Tcl_Command token;
int *flagsPtr;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
|
| ︙ | ︙ | |||
5285 5286 5287 5288 5289 5290 5291 |
*flagsPtr = ensemblePtr->flags;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 |
*flagsPtr = ensemblePtr->flags;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetEnsembleNamespace --
*
* Get the namespace associated with a particular ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble). Namespace is returned by updating the variable
* pointed to by the last parameter.
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
int
Tcl_GetEnsembleNamespace(interp, token, namespacePtrPtr)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Namespace **namespacePtrPtr;
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
|
| ︙ | ︙ | |||
5324 5325 5326 5327 5328 5329 5330 |
*namespacePtrPtr = (Tcl_Namespace *) ensemblePtr->nsPtr;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
| | | | 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 |
*namespacePtrPtr = (Tcl_Namespace *) ensemblePtr->nsPtr;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_FindEnsemble --
*
* Given a command name, get the ensemble token for it, allowing
* for [namespace import]s. [Bug 1017022]
*
* Results:
* The token for the ensemble command with the given name, or
* NULL if the command either does not exist or is not an
* ensemble (when an error message will be written into the
* interp if thats non-NULL).
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
Tcl_Command
Tcl_FindEnsemble(interp, cmdNameObj, flags)
Tcl_Interp *interp; /* Where to do the lookup, and where
* to write the errors if
* TCL_LEAVE_ERR_MSG is set in the
* flags. */
Tcl_Obj *cmdNameObj; /* Name of command to look up. */
int flags; /* Either 0 or TCL_LEAVE_ERR_MSG; other
* flags are probably not useful. */
|
| ︙ | ︙ | |||
5379 5380 5381 5382 5383 5384 5385 |
}
return (Tcl_Command) cmdPtr;
}
/*
*----------------------------------------------------------------------
*
| | | | > | 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 |
}
return (Tcl_Command) cmdPtr;
}
/*
*----------------------------------------------------------------------
*
* Tcl_IsEnsemble --
*
* Simple test for ensemble-hood that takes into account imported
* ensemble commands as well.
*
* Results:
* Boolean value
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
int
Tcl_IsEnsemble(token)
Tcl_Command token;
{
Command *cmdPtr = (Command *) token;
if (cmdPtr->objProc == NsEnsembleImplementationCmd) {
return 1;
}
cmdPtr = (Command *) TclGetOriginalCommand((Tcl_Command) cmdPtr);
if (cmdPtr == NULL || cmdPtr->objProc != NsEnsembleImplementationCmd) {
return 0;
}
|
| ︙ | ︙ | |||
5513 5514 5515 5516 5517 5518 5519 | prefixObj = (Tcl_Obj *) Tcl_GetHashValue(hPtr); /* * Cache for later in the subcommand object. */ MakeCachedEnsembleCommand(objv[1], ensemblePtr, fullName, prefixObj); | | | 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 |
prefixObj = (Tcl_Obj *) Tcl_GetHashValue(hPtr);
/*
* Cache for later in the subcommand object.
*/
MakeCachedEnsembleCommand(objv[1], ensemblePtr, fullName, prefixObj);
} else if (!(ensemblePtr->flags & TCL_ENSEMBLE_PREFIX)) {
/*
* Can't find and we are prohibited from using unambiguous prefixes.
*/
goto unknownOrAmbiguousSubcommand;
} else {
/*
* If we've not already confirmed the command with the hash as
|
| ︙ | ︙ | |||
5735 5736 5737 5738 5739 5740 5741 |
if (ensemblePtr->subcommandTable.numEntries == 0) {
Tcl_AppendResult(interp, "unknown subcommand \"", TclGetString(objv[1]),
"\": namespace ", ensemblePtr->nsPtr->fullName,
" does not export any commands", NULL);
return TCL_ERROR;
}
Tcl_AppendResult(interp, "unknown ",
| | | 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 |
if (ensemblePtr->subcommandTable.numEntries == 0) {
Tcl_AppendResult(interp, "unknown subcommand \"", TclGetString(objv[1]),
"\": namespace ", ensemblePtr->nsPtr->fullName,
" does not export any commands", NULL);
return TCL_ERROR;
}
Tcl_AppendResult(interp, "unknown ",
(ensemblePtr->flags & TCL_ENSEMBLE_PREFIX ? "or ambiguous " : ""),
"subcommand \"", TclGetString(objv[1]), "\": must be ", NULL);
if (ensemblePtr->subcommandTable.numEntries == 1) {
Tcl_AppendResult(interp, ensemblePtr->subcommandArrayPtr[0], NULL);
} else {
int i;
for (i=0 ; i<ensemblePtr->subcommandTable.numEntries-1 ; i++) {
Tcl_AppendResult(interp,
|
| ︙ | ︙ |