Manual Pages for UNIX Darwin command on man CrtMathFnc
MyWebUniversity

Manual Pages for UNIX Darwin command on man CrtMathFnc

TclCreateMathFunc(3) Tcl Library Procedures TclCreateMathFunc(3)

NAME

TclCreateMathFunc, TclGetMathFuncInfo, TclListMathFuncs - Define,

query and enumerate math functions for expressions

SYNOPSIS

##iinncclluuddee <>

void TTccllCCrreeaatteeMMaatthhFFuunncc(interp, name, numArgs, argTypes, proc, clientData) int | TTccllGGeettMMaatthhFFuunnccIInnffoo(interp, name, numArgsPtr, argTypesPtr, procPtr, clientDataPtr)| TclObj * | TTccllLLiissttMMaatthhFFuunnccss(interp, pattern) | AARRGGUUMMEENNTTSS TclInterp *interp (in) Interpreter in which new function will be defined. | CONST | char *name (in) | | Name for new function. int numArgs (in) Number of arguments to new function; also gives size of argTypes array. TclValueType *argTypes (in) Points to an array giving the permissible types for each argument to function. TclMathProc *proc (in) Procedure that implements the function.

ClientData clientData (in) Arbitrary one-word value to

pass to proc when it is invoked. int *numArgsPtr (out) Points to a variable that will be set to contain the number of arguments to the function. TclValueType **argTypesPtr (out) Points to a variable that will be set to contain a pointer to an array giving the permissible types for

each argument to the func-

tion which will need to be freed up using TclFree. TclMathProc **procPtr (out) Points to a variable that will be set to contain a

pointer to the implementa-

tion code for the function (or NULL if the function is implemented directly in bytecode.) ClientData *clientDataPtr (out) Points to a variable that will be set to contain the clientData argument passed to TclCreateMathFunc when the function was created if

the function is not imple-

mented directly in bytecode. CONST char *pattern (in) Pattern to match against

function names so as to fil-

ter them (by passing to TclStringMatch), or NULL to not apply any filter.

DESCRIPTION

Tcl allows a number of mathematical functions to be used in expres-

sions, such as ssiinn, ccooss, and hhyyppoott. TTccllCCrreeaatteeMMaatthhFFuunncc allows applica-

tions to add additional functions to those already provided by Tcl or to replace existing functions. Name is the name of the function as it

will appear in expressions. If name doesn't already exist as a func-

tion then a new function is created. If it does exist, then the exist-

ing function is replaced. NumArgs and argTypes describe the arguments to the function. Each entry in the argTypes array must be one of | TCLINT, TCLDOUBLE, TCLWIDEINT, or TCLEITHER to indicate whether |

the corresponding argument must be an integer, a double-precision |

floating value, a wide (64-bit) integer, or any, respectively.

Whenever the function is invoked in an expression Tcl will invoke proc. Proc should have arguments and result that match the type TTccllMMaatthhPPrroocc: typedef int TclMathProc( ClientData clientData, TclInterp *interp, TclValue *args, TclValue *resultPtr); When proc is invoked the clientData and interp arguments will be the same as those passed to TTccllCCrreeaatteeMMaatthhFFuunncc. Args will point to an

array of numArgs TclValue structures, which describe the actual argu-

ments to the function: | typedef struct TclValue { | TclValueType type; | long intValue; | double doubleValue; | TclWideInt wideValue; | } TclValue; | The type field indicates the type of the argument and is one of | TCLINT, TCLDOUBLE or TCLWIDEINT. It will match the argTypes value specified for the function unless the argTypes value was TCLEITHER. Tcl converts the argument supplied in the expression to the type requested in argTypes, if that is necessary. Depending on the value of

the type field, the intValue, doubleValue or wideValue field will con- |

tain the actual value of the argument. Proc should compute its result and store it either as an integer in

resultPtr->intValue or as a floating value in resultPtr->doubleValue.

It should set also resultPtr->type to one of TCLINT, TCLDOUBLE or |

TCLWIDEINT to indicate which value was set. Under normal circum-

stances proc should return TCLOK. If an error occurs while executing

the function, proc should return TCLERROR and leave an error message

in the interpreter's result. TTccllGGeettMMaatthhFFuunnccIInnffoo retrieves the values associated with function name | that were passed to a preceding TTccllCCrreeaatteeMMaatthhFFuunncc call. Normally, the | return code is TTCCLLOOKK but if the named function does not exist, |

TTCCLLEERRRROORR is returned and an error message is placed in the inter- |

preter's result. | If an error did not occur, the array reference placed in the variable | pointed to by argTypesPtr is newly allocated, and should be released by | passing it to TTccllFFrreeee. Some functions (the standard set implemented | in the core) are implemented directly at the bytecode level; attempting | to retrieve values for them causes a NULL to be stored in the variable | pointed to by procPtr and the variable pointed to by clientDataPtr will | not be modified. | TTccllLLiissttMMaatthhFFuunnccss returns a Tcl object containing a list of all the | math functions defined in the interpreter whose name matches pattern. | In the case of an error, NULL is returned and an error message is left | in the interpreter result, and otherwise the returned object will have | a reference count of zero. KKEEYYWWOORRDDSS expression, mathematical function

SEE ALSO

expr(n), info(n), TclFree(3), TclNewListObj(3) Tcl 8.4 TclCreateMathFunc(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™