LinkVar.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:5k
- '"
- '" Copyright (c) 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: LinkVar.3,v 1.6.2.1 2003/07/18 16:56:24 dgp Exp $
- '"
- .so man.macros
- .TH Tcl_LinkVar 3 7.5 Tcl "Tcl Library Procedures"
- .BS
- .SH NAME
- Tcl_LinkVar, Tcl_UnlinkVar, Tcl_UpdateLinkedVar - link Tcl variable to C variable
- .SH SYNOPSIS
- .nf
- fB#include <tcl.h>fR
- .sp
- int
- fBTcl_LinkVarfR(fIinterp, varName, addr, typefR)
- .sp
- fBTcl_UnlinkVarfR(fIinterp, varNamefR)
- .sp
- fBTcl_UpdateLinkedVarfR(fIinterp, varNamefR)
- .SH ARGUMENTS
- .AS Tcl_Interp writable
- .AP Tcl_Interp *interp in
- Interpreter that contains fIvarNamefR.
- Also used by fBTcl_LinkVarfR to return error messages.
- .AP "CONST char" *varName in
- Name of global variable.
- .AP char *addr in
- Address of C variable that is to be linked to fIvarNamefR.
- .AP int type in
- Type of C variable. Must be one of TCL_LINK_INT, TCL_LINK_DOUBLE,
- .VS 8.4
- TCL_LINK_WIDE_INT,
- .VE 8.4
- TCL_LINK_BOOLEAN, or TCL_LINK_STRING, optionally OR'ed with
- TCL_LINK_READ_ONLY to make Tcl variable read-only.
- .BE
- .SH DESCRIPTION
- .PP
- fBTcl_LinkVarfR uses variable traces to keep the Tcl variable
- named by fIvarNamefR in sync with the C variable at the address
- given by fIaddrfR.
- Whenever the Tcl variable is read the value of the C variable will
- be returned, and whenever the Tcl variable is written the C
- variable will be updated to have the same value.
- fBTcl_LinkVarfR normally returns TCL_OK; if an error occurs
- while setting up the link (e.g. because fIvarNamefR is the
- name of array) then TCL_ERROR is returned and the interpreter's result
- contains an error message.
- .PP
- The fItypefR argument specifies the type of the C variable,
- and must have one of the following values, optionally OR'ed with
- TCL_LINK_READ_ONLY:
- .TP
- fBTCL_LINK_INTfR
- The C variable is of type fBintfR.
- Any value written into the Tcl variable must have a proper integer
- form acceptable to fBTcl_GetIntFromObjfR; attempts to write
- non-integer values into fIvarNamefR will be rejected with
- Tcl errors.
- .TP
- fBTCL_LINK_DOUBLEfR
- The C variable is of type fBdoublefR.
- Any value written into the Tcl variable must have a proper real
- form acceptable to fBTcl_GetDoubleFromObjfR; attempts to write
- non-real values into fIvarNamefR will be rejected with
- Tcl errors.
- .TP
- fBTCL_LINK_WIDE_INTfR
- .VS 8.4
- The C variable is of type fBTcl_WideIntfR (which is an integer type
- at least 64-bits wide on all platforms that can support it.)
- Any value written into the Tcl variable must have a proper integer
- form acceptable to fBTcl_GetWideIntFromObjfR; attempts to write
- non-integer values into fIvarNamefR will be rejected with
- Tcl errors.
- .VE 8.4
- .TP
- fBTCL_LINK_BOOLEANfR
- The C variable is of type fBintfR.
- If its value is zero then it will read from Tcl as ``0'';
- otherwise it will read from Tcl as ``1''.
- Whenever fIvarNamefR is
- modified, the C variable will be set to a 0 or 1 value.
- Any value written into the Tcl variable must have a proper boolean
- form acceptable to fBTcl_GetBooleanFromObjfR; attempts to write
- non-boolean values into fIvarNamefR will be rejected with
- Tcl errors.
- .TP
- fBTCL_LINK_STRINGfR
- The C variable is of type fBchar *fR.
- .VS
- If its value is not NULL then it must be a pointer to a string
- allocated with fBTcl_AllocfR or fBckallocfR.
- .VE
- Whenever the Tcl variable is modified the current C string will be
- freed and new memory will be allocated to hold a copy of the variable's
- new value.
- If the C variable contains a NULL pointer then the Tcl variable
- will read as ``NULL''.
- .PP
- If the TCL_LINK_READ_ONLY flag is present in fItypefR then the
- variable will be read-only from Tcl, so that its value can only be
- changed by modifying the C variable.
- Attempts to write the variable from Tcl will be rejected with errors.
- .PP
- fBTcl_UnlinkVarfR removes the link previously set up for the
- variable given by fIvarNamefR. If there does not exist a link
- for fIvarNamefR then the procedure has no effect.
- .PP
- fBTcl_UpdateLinkedVarfR may be invoked after the C variable has
- changed to force the Tcl variable to be updated immediately.
- In many cases this procedure is not needed, since any attempt to
- read the Tcl variable will return the latest value of the C variable.
- However, if a trace has been set on the Tcl variable (such as a
- Tk widget that wishes to display the value of the variable), the
- trace will not trigger when the C variable has changed.
- fBTcl_UpdateLinkedVarfR ensures that any traces on the Tcl
- variable are invoked.
- .SH KEYWORDS
- boolean, integer, link, read-only, real, string, traces, variable