summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--doc/Ensemble.3186
-rw-r--r--generic/tcl.decls49
-rw-r--r--generic/tcl.h9
-rw-r--r--generic/tclBasic.c4
-rw-r--r--generic/tclInt.h37
-rw-r--r--generic/tclNamesp.c145
7 files changed, 332 insertions, 120 deletions
diff --git a/ChangeLog b/ChangeLog
index 1abac3d..f4c8b1e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,16 +1,22 @@
+2005-01-19 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+
+ TIP#235 IMPLEMENTATION
+
+ * doc/Ensemble.3: Documentation for the new public API.
+ * generic/tclNamesp.c (Tcl_CreateEnsemble,...): Rename of
+ * generic/tcl.decls: existing API into TIPped form.
+
2005-01-19 Mo DeJong <mdejong@users.sourceforge.net>
- * win/tclWinChan.c (FileCloseProc): Invoke
- TclpCutFileChannel() to remove a FileInfo from
- the thread local list before deallocating it.
- This should have been done via an earlier
- call to Tcl_CutChannel, but I was running into
- a crash in the next call to Tcl_CutChannel
- during the IO finalization stage.
+ * win/tclWinChan.c (FileCloseProc): Invoke TclpCutFileChannel() to
+ remove a FileInfo from the thread local list before deallocating
+ it. This should have been done via an earlier call to
+ Tcl_CutChannel, but I was running into a crash in the next call to
+ Tcl_CutChannel during the IO finalization stage.
2005-01-18 Kevin Kenny <kennykb@acm.org>
- * library/tzdata/GMT+0:
+ * library/tzdata/GMT+0:
* library/tzdata/GMT-0:
* library/tzdata/GMT0:
* library/tzdata/Greenwich:
diff --git a/doc/Ensemble.3 b/doc/Ensemble.3
new file mode 100644
index 0000000..fad3851
--- /dev/null
+++ b/doc/Ensemble.3
@@ -0,0 +1,186 @@
+'\"
+'\" Copyright (c) 2005 Donal K. Fellows
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+'\" RCS: @(#) $Id: Ensemble.3,v 1.1 2005/01/19 23:15:26 dkf Exp $
+'\"
+'\" This documents the C API introduced in TIP#235
+'\"
+.so man.macros
+.TH Tcl_Ensemble 3 8.5 Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_CreateEnsemble, Tcl_FindEnsemble, Tcl_GetEnsembleFlags, Tcl_GetEnsembleMappingDict, Tcl_GetEnsembleNamespace, Tcl_GetEnsembleUnknownHandler, Tcl_GetEnsmelbeSubcommandList, Tcl_IsEnsemble, Tcl_SetEnsembleFlags, Tcl_SetEnsembleMappingDict, Tcl_SetEnsembleSubcommandList, Tcl_SetEnsembleUnknownHandler \- manipulate ensemble commands
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+Tcl_Command
+\fBTcl_CreateEnsemble\fR(\fIinterp, name, namespacePtr, ensFlags\fR)
+.sp
+Tcl_Command
+\fBTcl_FindEnsemble\fR(\fIinterp, cmdNameObj, flags\fR)
+.sp
+int
+\fBTcl_IsEnsemble\fR(\fItoken\fR)
+.sp
+int
+\fBTcl_GetEnsembleFlags\fR(\fIinterp, token, ensFlagsPtr\fR)
+.sp
+int
+\fBTcl_SetEnsembleFlags\fR(\fIinterp, token, ensFlags\fR)
+.sp
+int
+\fBTcl_GetEnsembleMappingDict\fR(\fIinterp, token, dictObjPtr\fR)
+.sp
+int
+\fBTcl_SetEnsembleMappingDict\fR(\fIinterp, token, dictObj\fR)
+.sp
+int
+\fBTcl_GetEnsembleSubcommandList\fR(\fIinterp, token, listObjPtr\fR)
+.sp
+int
+\fBTcl_SetEnsembleSubcommandList\fR(\fIinterp, token, listObj\fR)
+.sp
+int
+\fBTcl_GetEnsembleUnknownHandler\fR(\fIinterp, token, listObjPtr\fR)
+.sp
+int
+\fBTcl_SetEnsembleUnknownHandler\fR(\fIinterp, token, listObj\fR)
+.sp
+int
+\fBTcl_GetEnsembleNamespace\fR(\fIinterp, token, namespacePtrPtr\fR)
+.SH ARGUMENTS
+.AS Tcl_Namespace **namespacePtrPtr in/out
+.AP Tcl_Interp *interp in/out
+The interpreter in which the ensemble is to be created or found. Also
+where error result messages are written.
+.AP "const char" *name in
+The name of the ensemble command to be created.
+.AP Tcl_Namespace *namespacePtr in
+The namespace to which the ensemble command is to be bound, or NULL
+for the current namespace.
+.AP int ensFlags in
+An ORed set of flag bits describing the basic configuration of the
+ensemble. Currently only one bit has meaning, TCL_ENSEMBLE_PREFIX,
+which is present when the ensemble command should also match
+unambiguous prefixes of subcommands.
+.AP Tcl_Obj *cmdNameObj in
+A value holding the name of the ensemble command to look up.
+.AP int flags in
+An ORed set of flag bits controlling the behavior of
+\fBTcl_FindEnsemble\fR. Currently only TCL_LEAVE_ERR_MSG is supported.
+.AP Tcl_Command token in
+A normal command token that refers to an ensemble command, or which
+you wish to use for testing as an ensemble command in \fBTcl_IsEnsemble\fR.
+.AP int *ensFlagsPtr out
+Pointer to a variable into which to write the current ensemble flag
+bits; currently only the bit TCL_ENSEMBLE_PREFIX is defined.
+.AP Tcl_Obj *dictObj in
+A dictionary value to use for the subcommand to implementation command
+prefix mapping dictionary in the ensemble. May be NULL if the mapping
+dictionary is to be removed.
+.AP Tcl_Obj **dictObjPtr out
+Pointer to a variable into which to write the current ensemble mapping
+dictionary.
+.AP Tcl_Obj *listObj in
+A list value to use for the defined list of subcommands in the
+dictionary or the unknown subcommmand handler command prefix. May be
+NULL if the subcommand list or unknown handler are to be removed.
+.AP Tcl_Obj **listObjPtr out
+Pointer to a variable into which to write the current defiend list of
+subcommands or the current unknown handler prefix.
+.AP Tcl_Namespace **namespacePtrPtr out
+Pointer to a variable into which to write the handle of the namespace
+to which the ensemble is bound.
+.BE
+
+.SH DESCRIPTION
+An ensemble is a command, bound to some namespace, which consists of a
+collection of subcommands implemented by other Tcl commands. The first
+argument to the ensemble command is always interpreted as a selector
+that states what subcommand to execute.
+.PP
+Ensembles are created using \fBTcl_CreateEnsemble\fR, which takes four
+arguments: the interpreter to work within, the name of the ensemble to
+create, the namespace within the interpreter to bind the ensemble to,
+and the default set of ensemble flags. The result of the function is
+the command token for the ensemble, which may be used to further
+configure the ensemble using the API descibed below in \fBENSEMBLE
+PROPERTIES\fR.
+.PP
+Given the name of an ensemble command, the token for that command may
+be retrieved using \fBTcl_FindEnsemble\fR. If the given command name
+(in \fIcmdNameObj\fR) does not refer to an ensemble command, the
+result of the function is NULL and (if the TCL_LEAVE_ERR_MSG bit is
+set in \fIflags\fR) an error message is left in the interpreter
+result.
+.PP
+A command token may be checked to see if it refers to an ensemble
+using \fBTcl_IsEnsemble\fR. This returns 1 if the token refers to an
+ensemble, or 0 otherwise.
+.SS "ENSEMBLE PROPERTIES"
+Every ensemble has four read-write properties and a read-only
+property. The properties are:
+.TP
+\fBflags\fR (read-write)
+The set of flags for the ensemble, expressed as a
+bit-field. Currently, the only public flag is TCL_ENSEMBLE_PREFIX
+which is set when unambiguous prefixes of subcommands are permitted to
+be resolved to implementations as well as exact matches. The flags may
+be read and written using \fBTcl_GetEnsembleFlags\fR and
+\fBTcl_SetEnsembleFlags\fR respectively. The result of both of those
+functions is a Tcl result code (TCL_OK, or TCL_ERROR if the token does
+not refer to an ensemble).
+.TP
+\fBmapping dictionary\fR (read-write)
+A dictionary containing a mapping from subcommand names to lists of
+words to use as a command prefix (replacing the first two words of the
+command which are the ensemble command itself and the subcommand
+name), or NULL if every subcommand is to be mapped to the command with
+the same unqualified name in the ensemble's bound namespace. Defaults
+to NULL. May be read and written using
+\fBTcl_GetEnsembleMappingDict\fR and \fBTcl_SetEnsembleMappingDict\fR
+respectively. The result of both of those functions is a Tcl result
+code (TCL_OK, or TCL_ERROR if the token does not refer to an
+ensemble) and the dictionary obtained from
+\fBTcl_GetEnsembleMappingDict\fR should always be treated as immutable
+even if it is unshared.
+.TP
+\fBsubcommand list\fR (read-write)
+A list of all the subcommand names for the ensemble, or NULL if this
+is to be derived from either the keys of the mapping dictionary (see
+above) or (if that is also NULL) from the set of commands exported by
+the bound namespace. May be read and written using
+\fBTcl_GetEnsembleSubcommandList\fR and
+\fBTcl_SetEnsembleSubcommandList\fR respectively. The result of both
+of those functions is a Tcl result code (TCL_OK, or TCL_ERROR if the
+token does not refer to an ensemble) and the list obtained from
+\fBTcl_GetEnsembleSubcommandList\fR should alays be treated as
+immutable even if it is unshared.
+.TP
+\fBunknown subcommand handler command prefix\fR (read-write)
+A list of words to prepend on the front of any subcommand when the
+subcommand is unknown to the ensemble (according to the current prefix
+handling rule); see the \fBnamespace ensemble\fR command for more
+details. If NULL, the default behavior \- generate a suitable error
+message \- will be used when an unknown subcommand is encountered. May
+be read and written using \fBTcl_GetEnsembleUnknownHandler\fR and
+\fBTcl_SetEnsembleUnknownHandler\fR respectively. The result of both
+functions is a Tcl result code (TCL_OK, or TCL_ERROR if the token does
+not refer to an ensemble) and the list obtained from
+\fBTcl_GetEnsembleUnknownHandler\fR should always be treated as
+immutable even if it is unshared.
+.TP
+\fBbound namespace\fR (read-only)
+The namespace to which the ensemble is bound; when the namespace is
+deleted, so too will the ensemble, and this namespace is also the
+namespace whose list of exported commands is used if both the mapping
+dictionary and the subcommand list properties are NULL. May be read
+using \fBTcl_GetEnsembleNamespace\fR which returns a Tcl result code
+(TCL_OK, or TCL_ERROR if the token does not refer to an ensemble).
+
+.SH "SEE ALSO"
+namespace(n), Tcl_DeleteCommandFromToken(3)
diff --git a/generic/tcl.decls b/generic/tcl.decls
index af227bf..cb0ad5b 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: tcl.decls,v 1.105 2004/11/13 00:19:05 dgp Exp $
+# RCS: @(#) $Id: tcl.decls,v 1.106 2005/01/19 23:15:12 dkf Exp $
library tcl
@@ -1926,6 +1926,53 @@ declare 538 generic {
declare 539 generic {
Tcl_Obj *Tcl_GetReturnOptions(Tcl_Interp *interp, int result)
}
+# TIP#235
+declare 540 generic {
+ int Tcl_IsEnsemble(Tcl_Command token)
+}
+declare 541 generic {
+ Tcl_Command Tcl_CreateEnsemble(Tcl_Interp *interp, CONST char *name,
+ Tcl_Namespace *namespacePtr, int flags)
+}
+declare 542 generic {
+ Tcl_Command Tcl_FindEnsemble(Tcl_Interp *interp, Tcl_Obj *cmdNameObj,
+ int flags)
+}
+declare 543 generic {
+ int Tcl_SetEnsembleSubcommandList(Tcl_Interp *interp, Tcl_Command token,
+ Tcl_Obj *subcmdList)
+}
+declare 544 generic {
+ int Tcl_SetEnsembleMappingDict(Tcl_Interp *interp, Tcl_Command token,
+ Tcl_Obj *mapDict)
+}
+declare 545 generic {
+ int Tcl_SetEnsembleUnknownHandler(Tcl_Interp *interp, Tcl_Command token,
+ Tcl_Obj *unknownList)
+}
+declare 546 generic {
+ int Tcl_SetEnsembleFlags(Tcl_Interp *interp, Tcl_Command token, int flags)
+}
+declare 547 generic {
+ int Tcl_GetEnsembleSubcommandList(Tcl_Interp *interp, Tcl_Command token,
+ Tcl_Obj **subcmdListPtr)
+}
+declare 548 generic {
+ int Tcl_GetEnsembleMappingDict(Tcl_Interp *interp, Tcl_Command token,
+ Tcl_Obj **mapDictPtr)
+}
+declare 549 generic {
+ int Tcl_GetEnsembleUnknownHandler(Tcl_Interp *interp, Tcl_Command token,
+ Tcl_Obj **unknownListPtr)
+}
+declare 550 generic {
+ int Tcl_GetEnsembleFlags(Tcl_Interp *interp, Tcl_Command token,
+ int *flagsPtr)
+}
+declare 551 generic {
+ int Tcl_GetEnsembleNamespace(Tcl_Interp *interp, Tcl_Command token,
+ Tcl_Namespace **namespacePtrPtr)
+}
##############################################################################
diff --git a/generic/tcl.h b/generic/tcl.h
index c183783..2a74307 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tcl.h,v 1.193 2004/12/13 22:17:33 dgp Exp $
+ * RCS: @(#) $Id: tcl.h,v 1.194 2005/01/19 23:15:14 dkf Exp $
*/
#ifndef _TCL
@@ -1053,6 +1053,13 @@ typedef struct Tcl_DString {
#define TCL_TRACE_RESULT_OBJECT 0x10000
/*
+ * Flag values for ensemble commands.
+ */
+#define TCL_ENSEMBLE_PREFIX 0x02/* Flag value to say whether to allow
+ * unambiguous prefixes of commands or to
+ * require exact matches for command names. */
+
+/*
* Flag values passed to command-related procedures.
*/
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 45a3c4b..22ce3c6 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBasic.c,v 1.137 2004/12/15 20:44:34 msofer Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.138 2005/01/19 23:15:14 dkf Exp $
*/
#include "tclInt.h"
@@ -3047,7 +3047,7 @@ TclEvalObjvInternal(interp, objc, objv, command, length, flags)
}
if (!(flags & TCL_EVAL_INVOKE) &&
(iPtr->ensembleRewrite.sourceObjs != NULL) &&
- !TclIsEnsemble(cmdPtr)) {
+ !Tcl_IsEnsemble((Tcl_Command) cmdPtr)) {
iPtr->ensembleRewrite.sourceObjs = NULL;
}
code = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, objc, objv);
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 0f88767..a0d1c4a 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.211 2005/01/14 14:16:52 dkf Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.212 2005/01/19 23:15:16 dkf Exp $
*/
#ifndef _TCLINT
@@ -2024,41 +2024,6 @@ MODULE_SCOPE int TclpDlopen _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_FSUnloadFileProc **unloadProcPtr));
MODULE_SCOPE int TclpUtime _ANSI_ARGS_((Tcl_Obj *pathPtr,
struct utimbuf *tval));
-/*
- * These declarations ought to be exposed in a TIP (i.e. gain a '_' in
- * their names and move to tcl.decls).
- */
-MODULE_SCOPE int TclIsEnsemble _ANSI_ARGS_((Command *cmdPtr));
-MODULE_SCOPE Tcl_Command TclMakeEnsembleCmd _ANSI_ARGS_((
- Tcl_Interp *interp, CONST char *name,
- Tcl_Namespace *namespacePtr, int flags));
-MODULE_SCOPE Tcl_Command TclFindEnsemble _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_Obj *cmdNameObj, int flags));
-MODULE_SCOPE int TclSetEnsembleSubcommandList _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Command token,
- Tcl_Obj *subcmdList));
-MODULE_SCOPE int TclSetEnsembleMappingDict _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Command token,
- Tcl_Obj *mapDict));
-MODULE_SCOPE int TclSetEnsembleUnknownHandler _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Command token,
- Tcl_Obj *unknownList));
-MODULE_SCOPE int TclSetEnsembleFlags _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_Command token, int flags));
-MODULE_SCOPE int TclGetEnsembleSubcommandList _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Command token,
- Tcl_Obj **subcmdList));
-MODULE_SCOPE int TclGetEnsembleMappingDict _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Command token,
- Tcl_Obj **mapDict));
-MODULE_SCOPE int TclGetEnsembleUnknownHandler _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Command token,
- Tcl_Obj **unknownList));
-MODULE_SCOPE int TclGetEnsembleFlags _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_Command token, int *flags));
-MODULE_SCOPE int TclGetEnsembleNamespace _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Command token,
- Tcl_Namespace **namespacePtrPtr));
/*
*----------------------------------------------------------------
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 48a306d..58ab757 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -11,7 +11,7 @@
* Copyright (c) 1993-1997 Lucent Technologies.
* Copyright (c) 1997 Sun Microsystems, Inc.
* Copyright (c) 1998-1999 by Scriptics Corporation.
- * Copyright (c) 2002-2004 Donal K. Fellows.
+ * Copyright (c) 2002-2005 Donal K. Fellows.
*
* Originally implemented by
* Michael J. McLennan
@@ -21,7 +21,7 @@
* 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.70 2004/12/15 20:44:41 msofer Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.71 2005/01/19 23:15:25 dkf Exp $
*/
#include "tclInt.h"
@@ -119,7 +119,8 @@ typedef struct EnsembleConfig {
* all lists, and cannot be found by scanning
* the list from the namespace's ensemble
* field. */
- int flags; /* ORed combo of ENS_DEAD and ENS_PREFIX. */
+ int flags; /* ORed combo of ENS_DEAD and
+ * TCL_ENSEMBLE_PREFIX. */
/* OBJECT FIELDS FOR ENSEMBLE CONFIGURATION */
@@ -137,23 +138,21 @@ typedef struct EnsembleConfig {
* 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 ENS_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. */
+ * 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. */
-#define ENS_PREFIX 0x2 /* Flag value to say whether to allow
- * unambiguous prefixes of commands or to
- * require exact matches for command names. */
/*
* The data cached in a subcommand's Tcl_Obj rep. This structure is
@@ -4514,11 +4513,11 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
* any deletions have occurred.)
*/
- token = TclMakeEnsembleCmd(interp, name, NULL,
- (permitPrefix ? ENS_PREFIX : 0));
- TclSetEnsembleSubcommandList(interp, token, subcmdObj);
- TclSetEnsembleMappingDict(interp, token, mapObj);
- TclSetEnsembleUnknownHandler(interp, token, unknownObj);
+ 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!
@@ -4533,7 +4532,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- TclFindEnsemble(interp, objv[3], 0) != NULL));
+ Tcl_FindEnsemble(interp, objv[3], 0) != NULL));
return TCL_OK;
case ENS_CONFIG:
@@ -4541,7 +4540,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
Tcl_WrongNumArgs(interp, 3, objv, "cmdname ?opt? ?value? ...");
return TCL_ERROR;
}
- token = TclFindEnsemble(interp, objv[3], TCL_LEAVE_ERR_MSG);
+ token = Tcl_FindEnsemble(interp, objv[3], TCL_LEAVE_ERR_MSG);
if (token == NULL) {
return TCL_ERROR;
}
@@ -4555,13 +4554,13 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
}
switch ((enum EnsConfigOpts) index) {
case CONF_SUBCMDS:
- TclGetEnsembleSubcommandList(NULL, token, &resultObj);
+ Tcl_GetEnsembleSubcommandList(NULL, token, &resultObj);
if (resultObj != NULL) {
Tcl_SetObjResult(interp, resultObj);
}
break;
case CONF_MAP:
- TclGetEnsembleMappingDict(NULL, token, &resultObj);
+ Tcl_GetEnsembleMappingDict(NULL, token, &resultObj);
if (resultObj != NULL) {
Tcl_SetObjResult(interp, resultObj);
}
@@ -4569,7 +4568,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
case CONF_NAMESPACE: {
Tcl_Namespace *namespacePtr;
- TclGetEnsembleNamespace(NULL, token, &namespacePtr);
+ Tcl_GetEnsembleNamespace(NULL, token, &namespacePtr);
Tcl_SetResult(interp, ((Namespace *)namespacePtr)->fullName,
TCL_VOLATILE);
break;
@@ -4577,13 +4576,13 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
case CONF_PREFIX: {
int flags;
- TclGetEnsembleFlags(NULL, token, &flags);
+ Tcl_GetEnsembleFlags(NULL, token, &flags);
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(flags & ENS_PREFIX));
+ Tcl_NewBooleanObj(flags & TCL_ENSEMBLE_PREFIX));
break;
}
case CONF_UNKNOWN:
- TclGetEnsembleUnknownHandler(NULL, token, &resultObj);
+ Tcl_GetEnsembleUnknownHandler(NULL, token, &resultObj);
if (resultObj != NULL) {
Tcl_SetObjResult(interp, resultObj);
}
@@ -4604,7 +4603,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
/* -map option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_MAP], -1));
- TclGetEnsembleMappingDict(NULL, token, &tmpObj);
+ Tcl_GetEnsembleMappingDict(NULL, token, &tmpObj);
if (tmpObj != NULL) {
Tcl_ListObjAppendElement(NULL, resultObj, tmpObj);
} else {
@@ -4613,20 +4612,20 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
/* -namespace option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_NAMESPACE], -1));
- TclGetEnsembleNamespace(NULL, token, &namespacePtr);
+ 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));
- TclGetEnsembleFlags(NULL, token, &flags);
+ Tcl_GetEnsembleFlags(NULL, token, &flags);
Tcl_ListObjAppendElement(NULL, resultObj,
- Tcl_NewBooleanObj(flags & ENS_PREFIX));
+ Tcl_NewBooleanObj(flags & TCL_ENSEMBLE_PREFIX));
/* -subcommands option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_SUBCMDS], -1));
- TclGetEnsembleSubcommandList(NULL, token, &tmpObj);
+ Tcl_GetEnsembleSubcommandList(NULL, token, &tmpObj);
if (tmpObj != NULL) {
Tcl_ListObjAppendElement(NULL, resultObj, tmpObj);
} else {
@@ -4635,7 +4634,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
/* -unknown option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_UNKNOWN], -1));
- TclGetEnsembleUnknownHandler(NULL, token, &tmpObj);
+ Tcl_GetEnsembleUnknownHandler(NULL, token, &tmpObj);
if (tmpObj != NULL) {
Tcl_ListObjAppendElement(NULL, resultObj, tmpObj);
} else {
@@ -4654,11 +4653,11 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
Tcl_Obj *subcmdObj, *mapObj, *unknownObj;
int permitPrefix, flags;
- TclGetEnsembleSubcommandList(NULL, token, &subcmdObj);
- TclGetEnsembleMappingDict(NULL, token, &mapObj);
- TclGetEnsembleUnknownHandler(NULL, token, &unknownObj);
- TclGetEnsembleFlags(NULL, token, &flags);
- permitPrefix = (flags & ENS_PREFIX) != 0;
+ 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;
@@ -4792,11 +4791,12 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
* parsing stage.
*/
- flags = (permitPrefix ? flags|ENS_PREFIX : flags&~ENS_PREFIX);
- TclSetEnsembleSubcommandList(NULL, token, subcmdObj);
- TclSetEnsembleMappingDict(NULL, token, mapObj);
- TclSetEnsembleUnknownHandler(NULL, token, unknownObj);
- TclSetEnsembleFlags(NULL, token, flags);
+ 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;
}
@@ -4809,7 +4809,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
/*
*----------------------------------------------------------------------
*
- * TclMakeEnsembleCmd --
+ * Tcl_CreateEnsemble --
*
* Create a simple ensemble attached to the given namespace.
*
@@ -4823,7 +4823,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
*/
Tcl_Command
-TclMakeEnsembleCmd(interp, name, namespacePtr, flags)
+Tcl_CreateEnsemble(interp, name, namespacePtr, flags)
Tcl_Interp *interp;
CONST char *name;
Tcl_Namespace *namespacePtr;
@@ -4884,7 +4884,7 @@ TclMakeEnsembleCmd(interp, name, namespacePtr, flags)
/*
*----------------------------------------------------------------------
*
- * TclSetEnsembleSubcommandList --
+ * Tcl_SetEnsembleSubcommandList --
*
* Set the subcommand list for a particular ensemble.
*
@@ -4899,7 +4899,7 @@ TclMakeEnsembleCmd(interp, name, namespacePtr, flags)
*/
int
-TclSetEnsembleSubcommandList(interp, token, subcmdList)
+Tcl_SetEnsembleSubcommandList(interp, token, subcmdList)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj *subcmdList;
@@ -4948,7 +4948,7 @@ TclSetEnsembleSubcommandList(interp, token, subcmdList)
/*
*----------------------------------------------------------------------
*
- * TclSetEnsembleMappingDict --
+ * Tcl_SetEnsembleMappingDict --
*
* Set the mapping dictionary for a particular ensemble.
*
@@ -4963,7 +4963,7 @@ TclSetEnsembleSubcommandList(interp, token, subcmdList)
*/
int
-TclSetEnsembleMappingDict(interp, token, mapDict)
+Tcl_SetEnsembleMappingDict(interp, token, mapDict)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj *mapDict;
@@ -5012,7 +5012,7 @@ TclSetEnsembleMappingDict(interp, token, mapDict)
/*
*----------------------------------------------------------------------
*
- * TclSetEnsembleUnknownHandler --
+ * Tcl_SetEnsembleUnknownHandler --
*
* Set the unknown handler for a particular ensemble.
*
@@ -5027,7 +5027,7 @@ TclSetEnsembleMappingDict(interp, token, mapDict)
*/
int
-TclSetEnsembleUnknownHandler(interp, token, unknownList)
+Tcl_SetEnsembleUnknownHandler(interp, token, unknownList)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj *unknownList;
@@ -5077,7 +5077,7 @@ TclSetEnsembleUnknownHandler(interp, token, unknownList)
/*
*----------------------------------------------------------------------
*
- * TclSetEnsembleFlags --
+ * Tcl_SetEnsembleFlags --
*
* Set the flags for a particular ensemble.
*
@@ -5092,7 +5092,7 @@ TclSetEnsembleUnknownHandler(interp, token, unknownList)
*/
int
-TclSetEnsembleFlags(interp, token, flags)
+Tcl_SetEnsembleFlags(interp, token, flags)
Tcl_Interp *interp;
Tcl_Command token;
int flags;
@@ -5128,7 +5128,7 @@ TclSetEnsembleFlags(interp, token, flags)
/*
*----------------------------------------------------------------------
*
- * TclGetEnsembleSubcommandList --
+ * Tcl_GetEnsembleSubcommandList --
*
* Get the list of subcommands associated with a particular ensemble.
*
@@ -5146,7 +5146,7 @@ TclSetEnsembleFlags(interp, token, flags)
*/
int
-TclGetEnsembleSubcommandList(interp, token, subcmdListPtr)
+Tcl_GetEnsembleSubcommandList(interp, token, subcmdListPtr)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj **subcmdListPtr;
@@ -5169,7 +5169,7 @@ TclGetEnsembleSubcommandList(interp, token, subcmdListPtr)
/*
*----------------------------------------------------------------------
*
- * TclGetEnsembleMappingDict --
+ * Tcl_GetEnsembleMappingDict --
*
* Get the command mapping dictionary associated with a
* particular ensemble.
@@ -5187,7 +5187,7 @@ TclGetEnsembleSubcommandList(interp, token, subcmdListPtr)
*/
int
-TclGetEnsembleMappingDict(interp, token, mapDictPtr)
+Tcl_GetEnsembleMappingDict(interp, token, mapDictPtr)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj **mapDictPtr;
@@ -5210,7 +5210,7 @@ TclGetEnsembleMappingDict(interp, token, mapDictPtr)
/*
*----------------------------------------------------------------------
*
- * TclGetEnsembleUnknownHandler --
+ * Tcl_GetEnsembleUnknownHandler --
*
* Get the unknown handler associated with a particular ensemble.
*
@@ -5227,7 +5227,7 @@ TclGetEnsembleMappingDict(interp, token, mapDictPtr)
*/
int
-TclGetEnsembleUnknownHandler(interp, token, unknownListPtr)
+Tcl_GetEnsembleUnknownHandler(interp, token, unknownListPtr)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Obj **unknownListPtr;
@@ -5250,7 +5250,7 @@ TclGetEnsembleUnknownHandler(interp, token, unknownListPtr)
/*
*----------------------------------------------------------------------
*
- * TclGetEnsembleFlags --
+ * Tcl_GetEnsembleFlags --
*
* Get the flags for a particular ensemble.
*
@@ -5266,7 +5266,7 @@ TclGetEnsembleUnknownHandler(interp, token, unknownListPtr)
*/
int
-TclGetEnsembleFlags(interp, token, flagsPtr)
+Tcl_GetEnsembleFlags(interp, token, flagsPtr)
Tcl_Interp *interp;
Tcl_Command token;
int *flagsPtr;
@@ -5289,7 +5289,7 @@ TclGetEnsembleFlags(interp, token, flagsPtr)
/*
*----------------------------------------------------------------------
*
- * TclGetEnsembleNamespace --
+ * Tcl_GetEnsembleNamespace --
*
* Get the namespace associated with a particular ensemble.
*
@@ -5305,7 +5305,7 @@ TclGetEnsembleFlags(interp, token, flagsPtr)
*/
int
-TclGetEnsembleNamespace(interp, token, namespacePtrPtr)
+Tcl_GetEnsembleNamespace(interp, token, namespacePtrPtr)
Tcl_Interp *interp;
Tcl_Command token;
Tcl_Namespace **namespacePtrPtr;
@@ -5328,7 +5328,7 @@ TclGetEnsembleNamespace(interp, token, namespacePtrPtr)
/*
*----------------------------------------------------------------------
*
- * TclFindEnsemble --
+ * Tcl_FindEnsemble --
*
* Given a command name, get the ensemble token for it, allowing
* for [namespace import]s. [Bug 1017022]
@@ -5346,7 +5346,7 @@ TclGetEnsembleNamespace(interp, token, namespacePtrPtr)
*/
Tcl_Command
-TclFindEnsemble(interp, cmdNameObj, flags)
+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
@@ -5383,7 +5383,7 @@ TclFindEnsemble(interp, cmdNameObj, flags)
/*
*----------------------------------------------------------------------
*
- * TclIsEnsemble --
+ * Tcl_IsEnsemble --
*
* Simple test for ensemble-hood that takes into account imported
* ensemble commands as well.
@@ -5398,9 +5398,10 @@ TclFindEnsemble(interp, cmdNameObj, flags)
*/
int
-TclIsEnsemble(cmdPtr)
- Command *cmdPtr;
+Tcl_IsEnsemble(token)
+ Tcl_Command token;
{
+ Command *cmdPtr = (Command *) token;
if (cmdPtr->objProc == NsEnsembleImplementationCmd) {
return 1;
}
@@ -5517,7 +5518,7 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
*/
MakeCachedEnsembleCommand(objv[1], ensemblePtr, fullName, prefixObj);
- } else if (!(ensemblePtr->flags & ENS_PREFIX)) {
+ } else if (!(ensemblePtr->flags & TCL_ENSEMBLE_PREFIX)) {
/*
* Can't find and we are prohibited from using unambiguous prefixes.
*/
@@ -5739,7 +5740,7 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
return TCL_ERROR;
}
Tcl_AppendResult(interp, "unknown ",
- (ensemblePtr->flags & ENS_PREFIX ? "or ambiguous " : ""),
+ (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);