OSDN Git Service

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