OSDN Git Service

Updated to tcl 8.4.1
[pf3gnuchains/sourceware.git] / tcl / doc / AssocData.3
1 '\"
2 '\" Copyright (c) 1995-1996 Sun Microsystems, Inc.
3 '\"
4 '\" See the file "license.terms" for information on usage and redistribution
5 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\" 
7 '\" 
8 '\" RCS: @(#) $Id$
9 .so man.macros
10 .TH Tcl_SetAssocData 3 7.5 Tcl "Tcl Library Procedures"
11 .BS
12 .SH NAME
13 Tcl_GetAssocData, Tcl_SetAssocData, Tcl_DeleteAssocData \- manage
14 associations of string keys and user specified data with Tcl
15 interpreters.
16 .SH SYNOPSIS
17 .nf
18 \fB#include <tcl.h>\fR
19 .sp
20 ClientData
21 \fBTcl_GetAssocData\fR(\fIinterp, key, delProcPtr\fR)
22 .sp
23 \fBTcl_SetAssocData\fR(\fIinterp, key, delProc, clientData\fR)
24 .sp
25 \fBTcl_DeleteAssocData\fR(\fIinterp, key\fR)
26 .SH ARGUMENTS
27 .AS Tcl_InterpDeleteProc *delProcPtr
28 .AP Tcl_Interp *interp in
29 Interpreter in which to execute the specified command.
30 .VS 8.4
31 .AP "CONST char" *key in
32 .VE
33 Key for association with which to store data or from which to delete or
34 retrieve data.  Typically the module prefix for a package.
35 .AP Tcl_InterpDeleteProc *delProc in
36 Procedure to call when \fIinterp\fR is deleted.
37 .AP Tcl_InterpDeleteProc **delProcPtr in
38 Pointer to location in which to store address of current deletion procedure
39 for association.  Ignored if NULL.
40 .AP ClientData clientData in
41 Arbitrary one-word value associated with the given key in this
42 interpreter.  This data is owned by the caller.
43 .BE
44
45 .SH DESCRIPTION
46 .PP
47 These procedures allow extensions to associate their own data with
48 a Tcl interpreter.
49 An association consists of a string key, typically the name of
50 the extension, and a one-word value, which is typically a pointer
51 to a data structure holding data specific to the extension.
52 Tcl makes no interpretation of either the key or the value for
53 an association.
54 .PP
55 Storage management is facilitated by storing with each association a
56 procedure to call when the interpreter is deleted. This
57 procedure can dispose of the storage occupied by the client's data in any
58 way it sees fit.
59 .PP
60 \fBTcl_SetAssocData\fR creates an association between a string
61 key and a user specified datum in the given interpreter.
62 If there is already an association with the given \fIkey\fR,
63 \fBTcl_SetAssocData\fR overwrites it with the new information.
64 It is up to callers to organize their use of names to avoid conflicts,
65 for example, by using package names as the keys.
66 If the \fIdeleteProc\fR argument is non-NULL it specifies the address of a
67 procedure to invoke if the interpreter is deleted before the association
68 is deleted.  \fIDeleteProc\fR should have arguments and result that match
69 the type \fBTcl_InterpDeleteProc\fR:
70 .CS
71 typedef void Tcl_InterpDeleteProc(
72         ClientData \fIclientData\fR,
73         Tcl_Interp *\fIinterp\fR);
74 .CE
75 When \fIdeleteProc\fR is invoked the \fIclientData\fR and \fIinterp\fR
76 arguments will be the same as the corresponding arguments passed to
77 \fBTcl_SetAssocData\fR.
78 The deletion procedure will \fInot\fR be invoked if the association
79 is deleted before the interpreter is deleted.
80 .PP
81 \fBTcl_GetAssocData\fR returns the datum stored in the association with the
82 specified key in the given interpreter, and if the \fIdelProcPtr\fR field
83 is non-\fBNULL\fR, the address indicated by it gets the address of the
84 delete procedure stored with this association. If no association with the
85 specified key exists in the given interpreter \fBTcl_GetAssocData\fR
86 returns \fBNULL\fR.
87 .PP
88 \fBTcl_DeleteAssocData\fR deletes an association with a specified key in
89 the given interpreter.  Then it calls the deletion procedure.
90 .SH KEYWORDS
91 association, data, deletion procedure, interpreter, key