AssocData.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
- '"
- '" Copyright (c) 1995-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: AssocData.3,v 1.4 2001/04/24 20:59:17 kennykb Exp $
- .so man.macros
- .TH Tcl_SetAssocData 3 7.5 Tcl "Tcl Library Procedures"
- .BS
- .SH NAME
- Tcl_GetAssocData, Tcl_SetAssocData, Tcl_DeleteAssocData - manage
- associations of string keys and user specified data with Tcl
- interpreters.
- .SH SYNOPSIS
- .nf
- fB#include <tcl.h>fR
- .sp
- ClientData
- fBTcl_GetAssocDatafR(fIinterp, key, delProcPtrfR)
- .sp
- fBTcl_SetAssocDatafR(fIinterp, key, delProc, clientDatafR)
- .sp
- fBTcl_DeleteAssocDatafR(fIinterp, keyfR)
- .SH ARGUMENTS
- .AS Tcl_InterpDeleteProc *delProcPtr
- .AP Tcl_Interp *interp in
- Interpreter in which to execute the specified command.
- .VS 8.4
- .AP "CONST char" *key in
- .VE
- Key for association with which to store data or from which to delete or
- retrieve data. Typically the module prefix for a package.
- .AP Tcl_InterpDeleteProc *delProc in
- Procedure to call when fIinterpfR is deleted.
- .AP Tcl_InterpDeleteProc **delProcPtr in
- Pointer to location in which to store address of current deletion procedure
- for association. Ignored if NULL.
- .AP ClientData clientData in
- Arbitrary one-word value associated with the given key in this
- interpreter. This data is owned by the caller.
- .BE
- .SH DESCRIPTION
- .PP
- These procedures allow extensions to associate their own data with
- a Tcl interpreter.
- An association consists of a string key, typically the name of
- the extension, and a one-word value, which is typically a pointer
- to a data structure holding data specific to the extension.
- Tcl makes no interpretation of either the key or the value for
- an association.
- .PP
- Storage management is facilitated by storing with each association a
- procedure to call when the interpreter is deleted. This
- procedure can dispose of the storage occupied by the client's data in any
- way it sees fit.
- .PP
- fBTcl_SetAssocDatafR creates an association between a string
- key and a user specified datum in the given interpreter.
- If there is already an association with the given fIkeyfR,
- fBTcl_SetAssocDatafR overwrites it with the new information.
- It is up to callers to organize their use of names to avoid conflicts,
- for example, by using package names as the keys.
- If the fIdeleteProcfR argument is non-NULL it specifies the address of a
- procedure to invoke if the interpreter is deleted before the association
- is deleted. fIDeleteProcfR should have arguments and result that match
- the type fBTcl_InterpDeleteProcfR:
- .CS
- typedef void Tcl_InterpDeleteProc(
- ClientData fIclientDatafR,
- Tcl_Interp *fIinterpfR);
- .CE
- When fIdeleteProcfR is invoked the fIclientDatafR and fIinterpfR
- arguments will be the same as the corresponding arguments passed to
- fBTcl_SetAssocDatafR.
- The deletion procedure will fInotfR be invoked if the association
- is deleted before the interpreter is deleted.
- .PP
- fBTcl_GetAssocDatafR returns the datum stored in the association with the
- specified key in the given interpreter, and if the fIdelProcPtrfR field
- is non-fBNULLfR, the address indicated by it gets the address of the
- delete procedure stored with this association. If no association with the
- specified key exists in the given interpreter fBTcl_GetAssocDatafR
- returns fBNULLfR.
- .PP
- fBTcl_DeleteAssocDatafR deletes an association with a specified key in
- the given interpreter. Then it calls the deletion procedure.
- .SH KEYWORDS
- association, data, deletion procedure, interpreter, key