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

📄 interp.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: @(#) Interp.3 1.16 96/06/06 13:48:02'\" .so man.macros.TH Tcl_Interp 3 7.5 Tcl "Tcl Library Procedures".BS.SH NAMETcl_Interp \- client-visible fields of interpreter structures.SH SYNOPSIS.nf\fB#include <tcl.h>\fR.sptypedef struct {	char *\fIresult\fR;	Tcl_FreeProc *\fIfreeProc\fR;	int \fIerrorLine\fR;} Tcl_Interp;typedef void Tcl_FreeProc(char *\fIblockPtr\fR);.BE.SH DESCRIPTION.PPThe \fBTcl_CreateInterp\fR procedure returns a pointer to a Tcl_Interpstructure.  This pointer is then passed into other Tcl proceduresto process commands in the interpreter and perform other operationson the interpreter.  Interpreter structures contain many many fieldsthat are used by Tcl, but only three that may be accessed byclients:  \fIresult\fR, \fIfreeProc\fR, and \fIerrorLine\fR..PPThe \fIresult\fR and \fIfreeProc\fR fields are used to returnresults or error messages from commands.This information is returned by command procedures back to \fBTcl_Eval\fR,and by \fBTcl_Eval\fR back to its callers.The \fIresult\fR field points to the string that represents theresult or error message, and the \fIfreeProc\fR field tells howto dispose of the storage for the string when it isn't needed anymore.The easiest way for command procedures to manipulate thesefields is to call procedures like \fBTcl_SetResult\fRor \fBTcl_AppendResult\fR;  theywill hide all the details of managing the fields.The description below is for those procedures that manipulate thefields directly..PPWhenever a command procedure returns, it must ensurethat the \fIresult\fR field of its interpreter points to the stringbeing returned by the command.The \fIresult\fR field must always point to a valid string.If a command wishes to return no result then \fIinterp->result\fRshould point to an empty string.Normally, results are assumed to be statically allocated,which means that the contents will not change before the next time\fBTcl_Eval\fR is called or some other command procedure is invoked..VSIn this case, the \fIfreeProc\fR field must be zero.Alternatively, a command procedure may dynamicallyallocate its return value (e.g. using \fBTcl_Alloc\fR)and store a pointer to it in \fIinterp->result\fR.In this case, the command procedure must also set \fIinterp->freeProc\fRto the address of a procedure that can free the value, or \fBTCL_DYNAMIC\fRif the storage was allocated directly by Tcl or by a call to\fBTcl_Alloc\fR. .VEIf \fIinterp->freeProc\fR is non-zero, then Tcl will call \fIfreeProc\fRto free the space pointed to by \fIinterp->result\fR before itinvokes the next command.If a client procedure overwrites \fIinterp->result\fR when\fIinterp->freeProc\fR is non-zero, then it is responsible for calling\fIfreeProc\fR to free the old \fIinterp->result\fR (the \fBTcl_FreeResult\fRmacro should be used for this purpose)..PP\fIFreeProc\fR should have arguments and result that match the\fBTcl_FreeProc\fR declaration above:  it receives a singleargument which is a pointer to the result value to free..VSIn most applications \fBTCL_DYNAMIC\fR is the only non-zero value everused for \fIfreeProc\fR..VEHowever, an application may store a different procedure addressin \fIfreeProc\fR in order to use an alternate memory allocatoror in order to do other cleanup when the result memory is freed..PPAs part of processing each command, \fBTcl_Eval\fR initializes\fIinterp->result\fRand \fIinterp->freeProc\fR just before calling the command procedure forthe command.  The \fIfreeProc\fR field will be initialized to zero,and \fIinterp->result\fR will point to an empty string.  Commands thatdo not return any value can simply leave the fields alone.Furthermore, the empty string pointed to by \fIresult\fR is actuallypart of an array of \fBTCL_RESULT_SIZE\fR characters (approximately 200).If a command wishes to return a short string, it can simply copyit to the area pointed to by \fIinterp->result\fR.  Or, it can usethe sprintf procedure to generate a short result string at the locationpointed to by \fIinterp->result\fR..PPIt is a general convention in Tcl-based applications that the resultof an interpreter is normally in the initialized state describedin the previous paragraph.Procedures that manipulate an interpreter's result (e.g. byreturning an error) will generally assume that the resulthas been initialized when the procedure is called.If such a procedure is to be called after the result has beenchanged, then \fBTcl_ResetResult\fR should be called first toreset the result to its initialized state..PPThe \fIerrorLine\fRfield is valid only after \fBTcl_Eval\fR returnsa \fBTCL_ERROR\fR return code.  In this situation the \fIerrorLine\fRfield identifies the line number of the command being executed whenthe error occurred.  The line numbers are relative to the commandbeing executed:  1 means the first line of the command passed to\fBTcl_Eval\fR, 2 means the second line, and so on.The \fIerrorLine\fR field is typically used in conjunction with\fBTcl_AddErrorInfo\fR to report information about where an erroroccurred.\fIErrorLine\fR should not normally be modified except by \fBTcl_Eval\fR..SH KEYWORDSfree, initialized, interpreter, malloc, result

⌨️ 快捷键说明

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