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

📄 crtmathfnc.3

📁 tcl是工具命令语言
💻 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.'\" '\" RCS: @(#) $Id: CrtMathFnc.3,v 1.5 2001/05/30 08:57:05 dkf Exp $'\" .so man.macros.TH Tcl_CreateMathFunc 3 8.4 Tcl "Tcl Library Procedures".BS.SH NAMETcl_CreateMathFunc, Tcl_GetMathFuncInfo, Tcl_ListMathFuncs \- Define, query and enumerate math functions for expressions.SH SYNOPSIS.nf\fB#include <tcl.h>\fR.spvoid\fBTcl_CreateMathFunc\fR(\fIinterp, name, numArgs, argTypes, proc, clientData\fR).sp.VS 8.4int\fBTcl_GetMathFuncInfo\fR(\fIinterp, name, numArgsPtr, argTypesPtr, procPtr, clientDataPtr\fR).spTcl_Obj *\fBTcl_ListMathFuncs\fR(\fIinterp, pattern\fR).VE.SH ARGUMENTS.AS Tcl_ValueType *clientDataPtr.AP Tcl_Interp *interp inInterpreter in which new function will be defined..VS 8.4.AP "CONST char" *name in.VEName for new function..AP int numArgs inNumber of arguments to new function;  also gives size of \fIargTypes\fR array..AP Tcl_ValueType *argTypes inPoints to an array giving the permissible types for each argument tofunction..AP Tcl_MathProc *proc inProcedure that implements the function..AP ClientData clientData inArbitrary one-word value to pass to \fIproc\fR when it is invoked..AP int *numArgsPtr outPoints to a variable that will be set to contain the number ofarguments to the function..AP Tcl_ValueType *argTypesPtr outPoints to a variable that will be set to contain a pointer to an arraygiving the permissible types for each argument to the function whichwill need to be freed up using \fITcl_Free\fR..AP Tcl_MathProc *procPtr outPoints to a variable that will be set to contain a pointer to theimplementation code for the function (or NULL if the function isimplemented directly in bytecode.).AP ClientData *clientDataPtr outPoints to a variable that will be set to contain the clientDataargument passed to \fITcl_CreateMathFunc\fR when the function wascreated if the function is not implemented directly in bytecode..AP "CONST char" *pattern inPattern to match against function names so as to filter them (bypassing to \fITcl_StringMatch\fR), or NULL to not apply any filter..BE.SH DESCRIPTION.PPTcl allows a number of mathematical functions to be used inexpressions, such as \fBsin\fR, \fBcos\fR, and \fBhypot\fR.\fBTcl_CreateMathFunc\fR allows applications to add additional functionsto those already provided by Tcl or to replace existing functions.\fIName\fR is the name of the function as it will appear in expressions.If \fIname\fR doesn't already exist as a function then a new functionis created.  If it does exist, then the existing function is replaced.\fINumArgs\fR and \fIargTypes\fR describe the arguments to the function.Each entry in the \fIargTypes\fR array must be either TCL_INT, TCL_DOUBLE,or TCL_EITHER to indicate whether the corresponding argument must be aninteger, a double-precision floating value, or either, respectively..PPWhenever the function is invoked in an expression Tcl will invoke\fIproc\fR.  \fIProc\fR should have arguments and result that matchthe type \fBTcl_MathProc\fR:.CStypedef int Tcl_MathProc(	ClientData \fIclientData\fR,	Tcl_Interp *\fIinterp\fR,	Tcl_Value *\fIargs\fR,	Tcl_Value *\fIresultPtr\fR);.CE.PPWhen \fIproc\fR is invoked the \fIclientData\fR and \fIinterp\fRarguments will be the same as those passed to \fBTcl_CreateMathFunc\fR.\fIArgs\fR will point to an array of \fInumArgs\fR Tcl_Value structures,which describe the actual arguments to the function:.CStypedef struct Tcl_Value {	Tcl_ValueType \fItype\fR;	long \fIintValue\fR;	double \fIdoubleValue\fR;} Tcl_Value;.CE.PPThe \fItype\fR field indicates the type of the argument and iseither TCL_INT or TCL_DOUBLE.It will match the \fIargTypes\fR value specified for the function unlessthe \fIargTypes\fR value was TCL_EITHER. Tcl convertsthe argument supplied in the expression to the type requested in\fIargTypes\fR, if that is necessary.Depending on the value of the \fItype\fR field, the \fIintValue\fRor \fIdoubleValue\fR field will contain the actual value of the argument..PP\fIProc\fR should compute its result and store it either as an integerin \fIresultPtr->intValue\fR or as a floating value in\fIresultPtr->doubleValue\fR.It should set also \fIresultPtr->type\fR to either TCL_INT or TCL_DOUBLEto indicate which value was set.Under normal circumstances \fIproc\fR should return TCL_OK.If an error occurs while executing the function, \fIproc\fR shouldreturn TCL_ERROR and leave an error message in the interpreter's result..PP.VS 8.4\fBTcl_GetMathFuncInfo\fR retrieves the values associated withfunction \fIname\fR that were passed to a preceding\fBTcl_CreateMathFunc\fR call.  Normally, the return code is\fBTCL_OK\fR but if the named function does not exist, \fBTCL_ERROR\fRis returned and an error message is placed in the interpreter'sresult..PPIf an error did not occur, the array reference placed in the variablepointed to by \fIargTypesPtr\fR is newly allocated, and should bereleased by passing it to \fBTcl_Free\fR.  Some functions (thestandard set implemented in the core) are implemented directly at thebytecode level; attempting to retrieve values for them causes a NULLto be stored in the variable pointed to by \fIprocPtr\fR and thevariable pointed to by \fIclientDataPtr\fR will not be modified..PP\fBTcl_ListMathFuncs\fR returns a Tcl object containing a list of allthe math functions defined in the interpreter whose name matches\fIpattern\fR.  In the case of an error, NULL is returned and an errormessage is left in the interpreter result, and otherwise the returnedobject will have a reference count of zero..VE.SH KEYWORDSexpression, mathematical function.SH "SEE ALSO"expr(n), info(n), Tcl_Free(3), Tcl_NewListObj(3)

⌨️ 快捷键说明

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