|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttcl.lang.Namespace
public class Namespace
This structure contains a cached pointer to a namespace that is the result of resolving the namespace's name in some other namespace. It is the internal representation for a nsName object. It contains the pointer along with some information that is used to check the cached pointer's validity. (ported Tcl_Namespace to Namespace)
Nested Class Summary | |
---|---|
static interface |
Namespace.DeleteProc
This interface is used to provide a callback when a namespace is deleted |
static class |
Namespace.GetNamespaceForQualNameResult
|
static class |
Namespace.ResolvedNsName
|
Field Summary | |
---|---|
int |
activationCount
Number of "activations" or active call frames for this namespace that are on the Tcl call stack. |
HashMap<String,Namespace> |
childTable
Contains any child namespaces. |
HashMap<String,WrappedCommand> |
cmdTable
Contains all the commands currently registered in the namespace. |
static int |
CREATE_NS_IF_UNKNOWN
Flag passed to getNamespaceForQualName to have it create all namespace components of a namespace-qualified name that cannot be found. |
Namespace.DeleteProc |
deleteProc
method to invoke when namespace is deleted |
String[] |
exportArray
Reference to an array of string patterns specifying which commands are exported. |
static int |
FIND_ONLY_NS
|
int |
flags
OR-ed combination of the namespace status flags NS_DYING and NS_DEAD (listed below) |
String |
fullName
The namespace's fully qualified name. |
Interp |
interp
The interpreter containing this namespace. |
int |
maxExportPatterns
Mumber of export patterns for which space is currently allocated. |
String |
name
/The namespace's simple (unqualified) name. |
static int |
NS_DEAD
NS_DEAD - 1 means deleteNamespace has been called to delete the namespace and no call frames still refer to it. |
long |
nsId
unique id for the namespace |
int |
numExportPatterns
Number of export patterns currently registered using "namespace export". |
Namespace |
parent
reference to the namespace that contains this one. |
int |
refCount
Count of references by nsName objects. |
Resolver |
resolver
If non-null, this object overrides the usual command and variable resolution mechanism in Tcl. |
HashMap<String,Var> |
varTable
Contains all the (global) variables currently in this namespace. |
Constructor Summary | |
---|---|
Namespace()
|
Method Summary | |
---|---|
static void |
appendExportList(Interp interp,
Namespace namespace,
TclObject obj)
Appends onto the argument object the list of export patterns for the specified namespace. |
static Namespace |
createNamespace(Interp interp,
String name,
Namespace.DeleteProc deleteProc)
Creates a new namespace with the given name. |
static void |
deleteNamespace(Namespace namespace)
Deletes a namespace and all of the commands, variables, and other namespaces within it. |
static void |
exportList(Interp interp,
Namespace namespace,
String pattern,
boolean resetListFirst)
Makes all the commands matching a pattern available to later be imported from the namespace specified by namespace (or the current namespace if namespace is null). |
static WrappedCommand |
findCommand(Interp interp,
String name,
Namespace contextNs,
int flags)
Tcl_FindCommand -> findCommand Searches for a command. |
static Namespace |
findNamespace(Interp interp,
String name,
Namespace contextNs,
int flags)
Searches for a namespace. |
static Var |
findNamespaceVar(Interp interp,
String name,
Namespace contextNs,
int flags)
|
static Object |
FirstHashEntry(HashMap table)
Return the first Object value contained in the given table. |
static void |
forgetImport(Interp interp,
Namespace namespace,
String pattern)
Deletes previously imported commands. |
static void |
free(Namespace ns)
|
static Namespace |
getCurrentNamespace(Interp interp)
Returns a reference to an interpreter's currently active namespace. |
static Namespace |
getGlobalNamespace(Interp interp)
Returns a reference to an interpreter's global :: namespace. |
static void |
getNamespaceForQualName(Interp interp,
String qualName,
Namespace cxtNs,
int flags,
Namespace.GetNamespaceForQualNameResult gnfqnr)
|
static WrappedCommand |
getOriginalCommand(WrappedCommand command)
An imported command is created in a namespace when a "real" command is imported from another namespace. |
static void |
importList(Interp interp,
Namespace namespace,
String pattern,
boolean allowOverwrite)
Imports all of the commands matching a pattern into the namespace specified by namespace (or the current namespace if namespace is null). |
static void |
popCallFrame(Interp interp)
|
static void |
pushCallFrame(Interp interp,
CallFrame frame,
Namespace namespace,
boolean isProcCallFrame)
|
static void |
setNamespaceResolver(Namespace namespace,
Resolver resolver)
---------------------------------------------------------------------- Tcl_SetNamespaceResolvers -> setNamespaceResolver Sets the command/variable resolution object for a namespace, thereby changing the way that command/variable names are interpreted. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public String name
public String fullName
public Namespace.DeleteProc deleteProc
public Namespace parent
public HashMap<String,Namespace> childTable
public long nsId
public Interp interp
public int flags
public int activationCount
public int refCount
public HashMap<String,WrappedCommand> cmdTable
public HashMap<String,Var> varTable
public String[] exportArray
public int numExportPatterns
public int maxExportPatterns
public Resolver resolver
public static final int FIND_ONLY_NS
public static final int NS_DEAD
public static final int CREATE_NS_IF_UNKNOWN
Constructor Detail |
---|
public Namespace()
Method Detail |
---|
public String toString()
toString
in class Object
Object.toString()
public static Namespace getCurrentNamespace(Interp interp)
interp
- the current interpreter
public static Namespace getGlobalNamespace(Interp interp)
interp
- the current interpreter
public static void pushCallFrame(Interp interp, CallFrame frame, Namespace namespace, boolean isProcCallFrame)
public static void popCallFrame(Interp interp)
public static Namespace createNamespace(Interp interp, String name, Namespace.DeleteProc deleteProc)
interp
- interpreter in which to create new namespacename
- name for the new namespace; may be a qualified name with the
ancestors separated with ::'sdeleteProc
- procedure called when namespace is deleted, or null if none
should be called
public static void deleteNamespace(Namespace namespace)
namespace
- namespace to deletepublic static void free(Namespace ns)
public static void exportList(Interp interp, Namespace namespace, String pattern, boolean resetListFirst) throws TclException
interp
- current interpreternamespace
- export commands from this namespace, or null for the current
namespacepattern
- String pattern indicating which commands to export. This
pattern may not include any namespace qualifiers; only
commands // in the specified namespace may be exported.resetListFirst
- If true, resets the namespace's export list before
appending. If false, return an error if an imported cmd
conflicts
TclException
public static void appendExportList(Interp interp, Namespace namespace, TclObject obj) throws TclException
interp
- the interpreter used for error reportingnamespace
- points to the namespace whose export pattern list is appended
onto obj; null for current namespaceobj
- Tcl object onto which current export pattern list is appended
TclException
public static void importList(Interp interp, Namespace namespace, String pattern, boolean allowOverwrite) throws TclException
interp
- current interpreternamespace
- reference to the namespace into which the commands are to be
imported. null for the current namespace.pattern
- String pattern indicating which commands to import. This
pattern should be qualified by the name of the namespace from
which to import the command(s).allowOverwrite
- If true, allow existing commands to be overwritten by
imported commands. If 0, return an error if an imported
cmd conflicts with an existing one.
TclException
public static void forgetImport(Interp interp, Namespace namespace, String pattern) throws TclException
interp
- current interpreternamespace
- Points to the namespace from which previously imported
commands should be removed. null for current namespace.pattern
- String pattern indicating which importedcommands to
remove. This pattern may be qualified by the name of the
namespace from which the command(s) were imported.
TclException
public static WrappedCommand getOriginalCommand(WrappedCommand command)
command
- the imported command for which the original command should be
returned
public static void getNamespaceForQualName(Interp interp, String qualName, Namespace cxtNs, int flags, Namespace.GetNamespaceForQualNameResult gnfqnr)
public static Namespace findNamespace(Interp interp, String name, Namespace contextNs, int flags)
interp
- the interpreter in which to find the namespacename
- Namespace name. If it starts with "::", will be looked up in
global namespace. Else, looked up first in contextNs (current
namespace if contextNs is null), then in global namespace.contextNs
- Ignored if TCL.GLOBAL_ONLY flag is set or if the name starts
with "::". Otherwise, points to namespace in which to resolve
name; if null, look up name in the current namespace.flags
- Flags controlling namespace lookup: an OR'd combination of
TCL.GLOBAL_ONLY and TCL.LEAVE_ERR_MSG flags.
public static WrappedCommand findCommand(Interp interp, String name, Namespace contextNs, int flags) throws TclException
interp
- the interpreter in which to find the commandname
- the commands name; if it starts with "::" it will be looked up
in the global namespace, otherwise in contextNs, or the
current namespace if contextNs is null, and then the global
namespacecontextNs
- Ignored if TCL.GLOBAL_ONLY flag set. Otherwise, points to
namespace in which to resolve name. If null, look up name in
the current namespace.flags
- An OR'd combination of flags: TCL.GLOBAL_ONLY (look up name
only in global namespace), TCL.NAMESPACE_ONLY (look up only in
contextNs, or the current namespace if contextNs is null), and
TCL.LEAVE_ERR_MSG. If both TCL.GLOBAL_ONLY and
TCL.NAMESPACE_ONLY are given, TCL.GLOBAL_ONLY is ignored.
TclException
public static Var findNamespaceVar(Interp interp, String name, Namespace contextNs, int flags) throws TclException
TclException
public static void setNamespaceResolver(Namespace namespace, Resolver resolver)
public static Object FirstHashEntry(HashMap table)
table
- a hash table
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |