⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resolvers.3

📁 这是一个Linux下的集成开发环境
💻 3
字号:
'\"'\" Copyright (c) 1998 Lucent Technologies, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: %W%'\" .so man.macros.TH Tcl_AddInterpResolvers 3 8.0 Tcl "Tcl Library Procedures".BS.SH NAMETcl_AddInterpResolvers, Tcl_GetInterpResolvers, Tcl_RemoveInterpResolvers, Tcl_SetNamespaceResolvers, Tcl_GetNamespaceResolvers \- change the name resolution rules for commands/variables.SH SYNOPSIS.nf\fB#include <tcl.h>\fR.spvoid\fBTcl_AddInterpResolvers\fR(\fIinterp, name, cmdProc, varProc, compiledVarProc\fR).spint\fBTcl_GetInterpResolvers\fR(\fIinterp, name, resInfoPtr\fR).spint\fBTcl_RemoveInterpResolvers\fR(\fIinterp, name\fR).spvoid\fBTcl_SetNamespaceResolvers\fR(\fInamespacePtr, cmdProc, varProc, compiledVarProc\fR).spint\fBTcl_GetNamespaceResolvers\fR(\fInamespacePtr, resInfoPtr\fR).SH ARGUMENTS.AS Tcl_ResolveCompiledVarProc *compiledVarProc.AP Tcl_Interp *interp  inInterpreter whose name resolution rules are being queried or modified..AP char *name inName for a group of name resolution procedures..AP Tcl_ResolveCmdProc *cmdProc inProcedure which will be used to resolve command names..AP Tcl_ResolveVarProc *varProc inProcedure which will be used to resolve variable names at run time..AP Tcl_ResolveCompiledVarProc *compiledVarProc inProcedure which will be used to resolve variable names at compile time..AP Tcl_ResolverInfo *resInfoPtr outReturns the resolution procedures that are currently in effect fora particular namespace or for a particular name resolution schemein the interpreter..AP Tcl_Namespace *namespacePtr inNamespace whose name resolution rules are being queried or modified..BE.SH DESCRIPTION.PPThese procedures make it possible to change the way that Tclresolves command/variable names.  The name resolution rules arechanged by supplying three procedures:  \fIcmdProc\fR, \fIvarProc\fR, and\fIcompiledVarProc\fR.  See the section \fBHOW NAME RESOLUTION PROCEDURESWORK\fR for details about these procedures..PPThe name resolution rules can be changed for a particular namespace,for an entire interpreter, or both.  When a name needs to be resolved,Tcl handles it as follows.  The name resolution scheme for thecurrent namespace is consulted first.  Each of the name resolutionschemes for the interpreter are consulted next.  Finally, Tcl usesthe default rules for name resolution as described for the\fBnamespace\fR command..PP\fBTcl_AddInterpResolver\fR adds a set of name resolution proceduresto an interpreter.  The procedures are identified by a string \fIname\fR,so they can be queried or deleted later on.  All of the name resolutionschemes for the interpreter are kept on a list, and they are consultedin order from most- to least-recently added.  For example, suppose oneextension adds a name resolution scheme called "fred", and anotherextension adds another scheme called "barney".  When a name is resolved,the "barney" scheme will be consulted first, followed by the "fred"scheme, if necessary..PP\fBTcl_GetInterpResolver\fR looks for a particular name resolutionscheme in an interpreter.  If the \fIname\fR is recognized, thisprocedure returns a non-zero value along with pointers to thename resolution procedures in the \fIresInfoPtr\fR structure.  Otherwise,the procedure returns 0..PP\fBTcl_RemoveInterpResolver\fR looks for a particular name resolutionscheme in an interpreter.  If the \fIname\fR is recognized, thisprocedure deletes the scheme and returns a non-zero value.  Otherwise,it returns 0..PP\fBTcl_SetNamespaceResolver\fR sets the name resolution proceduresfor a particular namespace.  Unlike an interpreter, a namespace canhave only one name resolution scheme in effect at any given time..PP\fBTcl_GetNamespaceResolver\fR returns the name resolution proceduresfor a particular namespace.  If the namespace has a special nameresolution scheme, this procedure returns a non-zero value alongwith pointers to the name resolution procedures in the \fIresInfoPtr\fRstructure.  Otherwise, the procedure returns 0..SH "HOW NAME RESOLUTION PROCEDURES WORK"A name resolution scheme is enforced by three name resolution procedures.The \fIcmdProc\fR procedure is used to resolve command names.  It mustconform to the following type:.CStypedef int Tcl_ResolveCmdProc(Tcl_Interp* \fIinterp\fR,        char* \fIname\fR, Tcl_Namespace* \fIcontext\fR, int \fIflags\fR,        Tcl_Command* \fIrPtr\fR);.CEThe \fIinterp\fR argument is the interpreter performing the resolution;\fIname\fR is the command name being resolved; \fIcontext\fR is thenamespace context containing the command reference; and \fIflags\fRmay contain TCL_LEAVE_ERR_MSG..PPIf this procedure recognizes the command \fIname\fR, it shouldstore the Tcl_Command token for that command in the \fIrPtr\fRargument and return TCL_OK.  If this procedure doesn't recognizethe command \fIname\fR, it should return TCL_CONTINUE, and thename resolution will continue with another procedure or with thedefault Tcl resolution scheme.  If this procedure recognizesthe command \fIname\fR, but for some reason the command isinvalid, the procedure should return TCL_ERROR.  If the \fIflags\fRargument contains TCL_LEAVE_ERR_MSG, the procedure should leavean error message in the interpreter, explaining why the commandis invalid..PPThe \fIvarProc\fR procedure is similar to \fIcmdProc\fR, but it isused to resolve variable names encountered at run time.  It mustconform to the following type:.CStypedef int Tcl_ResolveVarProc(Tcl_Interp* \fIinterp\fR,        char* \fIname\fR, Tcl_Namespace* \fIcontext\fR, int \fIflags\fR,        Tcl_Var* \fIrPtr\fR);.CEThe \fIinterp\fR argument is the interpreter performing the resolution;\fIname\fR is the variable name being resolved; \fIcontext\fR is thenamespace context containing the variable reference; and \fIflags\fRmay contain TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, or TCL_LEAVE_ERR_MSG..PPIf this procedure recognizes the variable \fIname\fR, it shouldstore the Tcl_Var token for that variable in the \fIrPtr\fRargument and return TCL_OK.  If this procedure doesn't recognizethe variable \fIname\fR, it should return TCL_CONTINUE, and thename resolution will continue with another procedure or with thedefault Tcl resolution scheme.  If this procedure recognizesthe variable \fIname\fR, but for some reason the variable isnot accessible, the procedure should return TCL_ERROR.  If the\fIflags\fR argument contains TCL_LEAVE_ERR_MSG, the procedureshould leave an error message in the interpreter, explaining whythe variable reference is invalid..PPNote that this procedure should look for the TCL_GLOBAL_ONLY andTCL_NAMESPACE_ONLY flags.  It should handle them appropriately, orreturn TCL_CONTINUE and let Tcl handle the reference.  But it shouldnot ignore the flags..PPTcl also resolves variables when a body of code is compiled; the\fIcompiledVarProc\fR procedure handles that case.  It mustconform to the following type:.CStypedef int Tcl_ResolveCompiledVarProc(Tcl_Interp* \fIinterp\fR,        char* \fIname\fR, int \fIlength\fR, Tcl_Namespace* \fIcontext\fR,        Tcl_ResolvedVarInfo* \fIrPtr\fR);.CEThe \fIinterp\fR argument is the interpreter performing the resolution;\fIname\fR is the variable name being resolved; \fIlength\fR is thenumber of bytes in \fIname\fR, which is not a null-terminatedstring; and \fIcontext\fR is the namespace context containing thevariable reference..PPIf this procedure recognizes the variable \fIname\fR, it shouldreturn some information characterizing the variable in the\fIrPtr\fR structure.  This structure is defined as follows:.CStypedef struct Tcl_ResolvedVarInfo {    ClientData \fIidentity\fR;    Tcl_ResolveRuntimeVarProc *\fIfetchProc\fR;    Tcl_ResolveVarDeleteProc *\fIdeleteProc\fR;} Tcl_ResolvedVarInfo;.CEThe \fIidentity\fR field is an arbitrary value that characterizesthe variable.  Each variable should have a unique identity.  Eachtime the compiled code is executed, Tcl will call the \fIfetchProc\fRprocedure to get the actual variable for a particular \fIidentity\fRvalue.  This callback procedure must conform to the following type:.CStypedef Tcl_Var Tcl_ResolveRuntimeVarProc(Tcl_Interp* \fIinterp\fR,    ClientData \fIidentity\fR);.CEThe \fIfetchProc\fR procedure takes the \fIinterp\fR interpreterand the \fIidentity\fR from compile time and returns a Tcl_Vartoken representing the variable.  If for some reason the variablecan't be found, this procedure should return NULL, and Tcl willcreate a local variable within the call frame of the procedurebeing executed..PPWhen the compiled code is discarded, Tcl calls the \fIdeleteProc\fRprocedure to release the \fIidentity\fR data.  The delete proceduremust conform to the following type:.CStypedef void Tcl_ResolveVarDeleteProc(ClientData \fIidentity\fR);.CE.PPIn general, the \fIvarProc\fR and \fIcompiledVarProc\fR proceduresshould \fIboth\fR be defined.  If the \fIcompiledVarProc\fR is notdefined, then Tcl will create local variables for any variablenames that are not recognized within a procedure.  If the \fIvarProc\fRis not defined, then Tcl will not recognize variables that areencountered at runtime.  For example, consider the following procedure:.CSproc foo {args} {    set anotherRef "1"    set name "another"    set ${name}Ref "2"}.CESuppose that the \fIcompiledVarProc\fR resolves the name\fBanotherRef\fR at compile time.  The name \fB${name}Ref\fRcan't be resolved at compile time, so the resolution of thatname is deferred to run time.  If the \fIvarProc\fR proceduremust intercept the name \fBanotherRef\fR at run time andsupply the appropriate variable..SH KEYWORDSinterpreter, namespace, resolution

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -