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

📄 crtinterp.3

📁 linux系统下的音频通信
💻 3
字号:
'\"'\" Copyright (c) 1989-1993 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: @(#) CrtInterp.3 1.17 97/10/31 13:05:51'\" .so man.macros.TH Tcl_CreateInterp 3 7.5 Tcl "Tcl Library Procedures".BS.SH NAMETcl_CreateInterp, Tcl_DeleteInterp, Tcl_InterpDeleted \- create and delete Tcl command interpreters.SH SYNOPSIS.nf\fB#include <tcl.h>\fR.spTcl_Interp *\fBTcl_CreateInterp\fR().sp\fBTcl_DeleteInterp\fR(\fIinterp\fR).spint\fBTcl_InterpDeleted\fR(\fIinterp\fR).SH ARGUMENTS.AS Tcl_Interp *interp.AP Tcl_Interp *interp inToken for interpreter to be destroyed..BE.SH DESCRIPTION.PP\fBTcl_CreateInterp\fR creates a new interpreter structure and returnsa token for it.  The token is required in calls to most other Tclprocedures, such as \fBTcl_CreateCommand\fR, \fBTcl_Eval\fR, and\fBTcl_DeleteInterp\fR.Clients are only allowed to access a few of the fields ofTcl_Interp structures;  see the Tcl_Interpand \fBTcl_CreateCommand\fR man pages for details.The new interpreter is initialized with no defined variables and onlythe built-in Tcl commands.  To bind in additional commands, call\fBTcl_CreateCommand\fR..PP\fBTcl_DeleteInterp\fR marks an interpreter as deleted; the interpreterwill eventually be deleted when all calls to \fBTcl_Preserve\fR for it havebeen matched by calls to \fBTcl_Release\fR. At that time, all of theresources associated with it, including variables, procedures, andapplication-specific command bindings, will be deleted.  After\fBTcl_DeleteInterp\fR returns any attempt to use \fBTcl_Eval\fR on theinterpreter will fail and return \fBTCL_ERROR\fR. After the call to\fBTcl_DeleteInterp\fR it is safe to examine \fIinterp->result\fR, query orset the values of variables, define, undefine or retrieve procedures, andexamine the runtime evaluation stack. See below, in the section\fBINTERPRETERS AND MEMORY MANAGEMENT\fR for details..PP\fBTcl_InterpDeleted\fR returns nonzero if \fBTcl_DeleteInterp\fR wascalled with \fIinterp\fR as its argument; this indicates that theinterpreter will eventually be deleted, when the last call to\fBTcl_Preserve\fR for it is matched by a call to \fBTcl_Release\fR. Ifnonzero is returned, further calls to \fBTcl_Eval\fR in this interpreterwill return \fBTCL_ERROR\fR..PP\fBTcl_InterpDeleted\fR is useful in deletion callbacks to distinguishbetween when only the memory the callback is responsible for is beingdeleted and when the whole interpreter is being deleted. In the former casethe callback may recreate the data being deleted, but this would lead to aninfinite loop if the interpreter were being deleted..SH "INTERPRETERS AND MEMORY MANAGEMENT".PP\fBTcl_DeleteInterp\fR can be called at any time on an interpreter that maybe used by nested evaluations and C code in various extensions. Tclimplements a simple mechanism that allows callers to use interpreterswithout worrying about the interpreter being deleted in a nested call, andwithout requiring special code to protect the interpreter, in most cases.This mechanism ensures that nested uses of an interpreter can safelycontinue using it even after \fBTcl_DeleteInterp\fR is called..PPThe mechanism relies on matching up calls to \fBTcl_Preserve\fR with callsto \fBTcl_Release\fR. If \fBTcl_DeleteInterp\fR has been called, only whenthe last call to \fBTcl_Preserve\fR is matched by a call to\fBTcl_Release\fR, will the interpreter be freed. See the manual entry for\fBTcl_Preserve\fR for a description of these functions..PPThe rules for when the user of an interpreter must call \fBTcl_Preserve\fRand \fBTcl_Release\fR are simple:.TPInterpreters Passed As ArgumentsFunctions that are passed an interpreter as an argument can safely use theinterpreter without any special protection. Thus, when you write anextension consisting of new Tcl commands, no special code is needed toprotect interpreters received as arguments. This covers the majority of alluses..TPInterpreter Creation And DeletionWhen a new interpreter is created and used in a call to \fBTcl_Eval\fR,\fBTcl_VarEval\fR, \fBTcl_GlobalEval\fR, \fBTcl_SetVar\fR, or\fBTcl_GetVar\fR, a pair of calls to \fBTcl_Preserve\fR and\fBTcl_Release\fR should be wrapped around all uses of the interpreter.Remember that it is unsafe to use the interpreter once \fBTcl_Release\fRhas been called. To ensure that the interpreter is properly deleted whenit is no longer needed, call \fBTcl_InterpDeleted\fR to test if some othercode already called \fBTcl_DeleteInterp\fR; if not, call\fBTcl_DeleteInterp\fR before calling \fBTcl_Release\fR in your own code.Do not call \fBTcl_DeleteInterp\fR on an interpreter for which\fBTcl_InterpDeleted\fR returns nonzero..TPRetrieving An Interpreter From A Data StructureWhen an interpreter is retrieved from a data structure (e.g. the clientdata of a callback) for use in \fBTcl_Eval\fR, \fBTcl_VarEval\fR,\fBTcl_GlobalEval\fR, \fBTcl_SetVar\fR, or \fBTcl_GetVar\fR, a pair ofcalls to \fBTcl_Preserve\fR and \fBTcl_Release\fR should be wrapped aroundall uses of the interpreter; it is unsafe to reuse the interpreter once\fBTcl_Release\fR has been called.  If an interpreter is stored inside acallback data structure, an appropriate deletion cleanup mechanism shouldbe set up by the code that creates the data structure so that theinterpreter is removed from the data structure (e.g. by setting the fieldto NULL) when the interpreter is deleted. Otherwise, you may be using aninterpreter that has been freed and whose memory may already have beenreused..PPAll uses of interpreters in Tcl and Tk have already been protected.Extension writers should ensure that their code also properly protects anyadditional interpreters used, as described above..SH KEYWORDScommand, create, delete, interpreter.SH "SEE ALSO"Tcl_Preserve(3), Tcl_Release(3)

⌨️ 快捷键说明

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