Hex Artifact Content

Login

Artifact fdd4ff2c7f426881dc30f04b113ac8c6d23601516fbb042b268d19c215649b8b:


0000: 09 7c 20 2f 2a 0a 09 7c 20 20 2a 20 74 63 6c 4c  .| /*..|  * tclL
0010: 69 6e 6b 2e 63 20 2d 2d 0a 09 7c 20 20 2a 0a 09  ink.c --..|  *..
0020: 7c 20 20 2a 20 54 68 69 73 20 66 69 6c 65 20 69  |  * This file i
0030: 6d 70 6c 65 6d 65 6e 74 73 20 6c 69 6e 6b 65 64  mplements linked
0040: 20 76 61 72 69 61 62 6c 65 73 20 28 61 20 43 20   variables (a C 
0050: 76 61 72 69 61 62 6c 65 20 74 68 61 74 20 69 73  variable that is
0060: 0a 41 62 73 74 72 61 63 74 7c 20 20 2a 20 74 69  .Abstract|  * ti
0070: 65 64 20 74 6f 20 61 20 54 63 6c 20 76 61 72 69  ed to a Tcl vari
0080: 61 62 6c 65 29 2e 20 54 68 65 20 69 64 65 61 20  able). The idea 
0090: 6f 66 20 6c 69 6e 6b 65 64 20 76 61 72 69 61 62  of linked variab
00a0: 6c 65 73 20 77 61 73 0a 09 7c 20 20 2a 20 66 69  les was..|  * fi
00b0: 72 73 74 20 73 75 67 67 65 73 74 65 64 20 62 79  rst suggested by
00c0: 20 41 6e 64 72 65 61 73 20 53 74 6f 6c 63 6b 65   Andreas Stolcke
00d0: 20 61 6e 64 20 74 68 69 73 20 69 6d 70 6c 65 6d   and this implem
00e0: 65 6e 74 61 74 69 6f 6e 20 69 73 0a 09 7c 20 20  entation is..|  
00f0: 2a 20 62 61 73 65 64 20 68 65 61 76 69 6c 79 20  * based heavily 
0100: 6f 6e 20 61 20 70 72 6f 74 6f 74 79 70 65 20 69  on a prototype i
0110: 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 70 72  mplementation pr
0120: 6f 76 69 64 65 64 20 62 79 0a 09 7c 20 20 2a 20  ovided by..|  * 
0130: 68 69 6d 2e 0a 09 20 20 20 2a 0a 09 7c 20 20 2a  him...   *..|  *
0140: 20 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 31   Copyright (c) 1
0150: 39 39 33 20 54 68 65 20 52 65 67 65 6e 74 73 20  993 The Regents 
0160: 6f 66 20 74 68 65 20 55 6e 69 76 65 72 73 69 74  of the Universit
0170: 79 20 6f 66 20 43 61 6c 69 66 6f 72 6e 69 61 2e  y of California.
0180: 0a 09 7c 20 20 2a 20 41 6c 6c 20 72 69 67 68 74  ..|  * All right
0190: 73 20 72 65 73 65 72 76 65 64 2e 0a 09 7c 20 20  s reserved...|  
01a0: 2a 0a 09 7c 20 20 2a 20 50 65 72 6d 69 73 73 69  *..|  * Permissi
01b0: 6f 6e 20 69 73 20 68 65 72 65 62 79 20 67 72 61  on is hereby gra
01c0: 6e 74 65 64 2c 20 77 69 74 68 6f 75 74 20 77 72  nted, without wr
01d0: 69 74 74 65 6e 20 61 67 72 65 65 6d 65 6e 74 20  itten agreement 
01e0: 61 6e 64 20 77 69 74 68 6f 75 74 0a 43 6f 70 79  and without.Copy
01f0: 72 69 67 68 74 20 20 2a 20 6c 69 63 65 6e 73 65  right  * license
0200: 20 6f 72 20 72 6f 79 61 6c 74 79 20 66 65 65 73   or royalty fees
0210: 2c 20 74 6f 20 75 73 65 2c 20 63 6f 70 79 2c 20  , to use, copy, 
0220: 6d 6f 64 69 66 79 2c 20 61 6e 64 20 64 69 73 74  modify, and dist
0230: 72 69 62 75 74 65 20 74 68 69 73 0a 09 7c 20 20  ribute this..|  
0240: 2a 20 73 6f 66 74 77 61 72 65 20 61 6e 64 20 69  * software and i
0250: 74 73 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e  ts documentation
0260: 20 66 6f 72 20 61 6e 79 20 70 75 72 70 6f 73 65   for any purpose
0270: 2c 20 70 72 6f 76 69 64 65 64 20 74 68 61 74 20  , provided that 
0280: 74 68 65 0a 09 7c 20 20 2a 20 61 62 6f 76 65 20  the..|  * above 
0290: 63 6f 70 79 72 69 67 68 74 20 6e 6f 74 69 63 65  copyright notice
02a0: 20 61 6e 64 20 74 68 65 20 66 6f 6c 6c 6f 77 69   and the followi
02b0: 6e 67 20 74 77 6f 20 70 61 72 61 67 72 61 70 68  ng two paragraph
02c0: 73 20 61 70 70 65 61 72 20 69 6e 0a 09 7c 20 20  s appear in..|  
02d0: 2a 20 61 6c 6c 20 63 6f 70 69 65 73 20 6f 66 20  * all copies of 
02e0: 74 68 69 73 20 73 6f 66 74 77 61 72 65 2e 0a 09  this software...
02f0: 7c 20 20 2a 0a 09 7c 20 20 2a 20 2e 2e 2e 0a 09  |  *..|  * .....
0300: 20 20 20 2a 2f 0a 0a 52 65 76 69 73 69 6f 6e 7c     */..Revision|
0310: 20 73 74 61 74 69 63 20 63 68 61 72 20 72 63 73   static char rcs
0320: 69 64 5b 5d 20 3d 20 22 24 48 65 61 64 65 72 3a  id[] = "$Header:
0330: 20 2f 75 73 65 72 36 2f 6f 75 73 74 65 72 2f 74   /user6/ouster/t
0340: 63 6c 2f 52 43 53 2f 74 63 6c 4c 69 6e 6b 2e 63  cl/RCS/tclLink.c
0350: 2c 76 20 31 2e 35 20 39 34 2f 30 34 2f 32 33 0a  ,v 1.5 94/04/23.
0360: 53 74 72 69 6e 67 09 7c 20 31 36 3a 31 32 3a 33  String.| 16:12:3
0370: 30 20 6f 75 73 74 65 72 20 45 78 70 20 24 20 53  0 ouster Exp $ S
0380: 50 52 49 54 45 20 28 42 65 72 6b 65 6c 65 79 29  PRITE (Berkeley)
0390: 22 3b 0a 0a 49 6e 63 6c 75 64 65 73 7c 20 23 69  ";..Includes| #i
03a0: 6e 63 6c 75 64 65 20 22 74 63 6c 49 6e 74 2e 68  nclude "tclInt.h
03b0: 22 0a 0a 09 7c 20 2f 2a 0a 09 7c 20 20 2a 20 46  "...| /*..|  * F
03c0: 6f 72 20 65 61 63 68 20 6c 69 6e 6b 65 64 20 76  or each linked v
03d0: 61 72 69 61 62 6c 65 20 74 68 65 72 65 20 69 73  ariable there is
03e0: 20 61 20 64 61 74 61 20 73 74 72 75 63 74 75 72   a data structur
03f0: 65 20 6f 66 20 74 68 65 20 66 6f 6c 6c 6f 77 69  e of the followi
0400: 6e 67 0a 09 7c 20 20 2a 20 74 79 70 65 2c 20 77  ng..|  * type, w
0410: 68 69 63 68 20 64 65 73 63 72 69 62 65 73 20 74  hich describes t
0420: 68 65 20 6c 69 6e 6b 20 61 6e 64 20 69 73 20 74  he link and is t
0430: 68 65 20 63 6c 69 65 6e 74 44 61 74 61 20 66 6f  he clientData fo
0440: 72 20 74 68 65 20 74 72 61 63 65 0a 09 7c 20 20  r the trace..|  
0450: 2a 20 73 65 74 20 6f 6e 20 74 68 65 20 54 63 6c  * set on the Tcl
0460: 20 76 61 72 69 61 62 6c 65 2e 0a 09 7c 20 20 2a   variable...|  *
0470: 2f 0a 09 7c 0a 09 7c 20 74 79 70 65 64 65 66 20  /..|..| typedef 
0480: 73 74 72 75 63 74 20 4c 69 6e 6b 20 7b 0a 09 7c  struct Link {..|
0490: 20 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 20       Tcl_Interp 
04a0: 2a 69 6e 74 65 72 70 3b 09 2f 2a 20 49 6e 74 65  *interp;./* Inte
04b0: 72 70 72 65 74 65 72 20 63 6f 6e 74 61 69 6e 69  rpreter containi
04c0: 6e 67 20 54 63 6c 20 76 61 72 69 61 62 6c 65 2e  ng Tcl variable.
04d0: 20 2a 2f 0a 44 65 63 6c 73 2e 09 7c 20 20 20 20   */.Decls..|    
04e0: 20 63 68 61 72 20 2a 61 64 64 72 3b 09 09 2f 2a   char *addr;../*
04f0: 20 4c 6f 63 61 74 69 6f 6e 20 6f 66 20 43 20 76   Location of C v
0500: 61 72 69 61 62 6c 65 2e 20 2a 2f 0a 09 7c 20 20  ariable. */..|  
0510: 20 20 20 69 6e 74 20 74 79 70 65 3b 09 09 09 2f     int type;.../
0520: 2a 20 54 79 70 65 20 6f 66 20 6c 69 6e 6b 20 28  * Type of link (
0530: 54 43 4c 5f 4c 49 4e 4b 5f 49 4e 54 2c 20 65 74  TCL_LINK_INT, et
0540: 63 2e 29 2e 20 2a 2f 0a 09 7c 20 20 20 20 20 69  c.). */..|     i
0550: 6e 74 20 77 72 69 74 61 62 6c 65 3b 09 09 2f 2a  nt writable;../*
0560: 20 5a 65 72 6f 20 6d 65 61 6e 73 20 54 63 6c 20   Zero means Tcl 
0570: 76 61 72 69 61 62 6c 65 20 69 73 20 72 65 61 64  variable is read
0580: 2d 6f 6e 6c 79 2e 20 2a 2f 0a 09 7c 20 20 20 20  -only. */..|    
0590: 20 75 6e 69 6f 6e 20 7b 0a 09 7c 20 20 20 20 20   union {..|     
05a0: 20 20 20 20 69 6e 74 20 69 3b 0a 09 7c 20 20 20      int i;..|   
05b0: 20 20 20 20 20 20 64 6f 75 62 6c 65 20 64 3b 0a        double d;.
05c0: 09 7c 20 20 20 20 20 7d 20 6c 61 73 74 56 61 6c  .|     } lastVal
05d0: 75 65 3b 09 09 2f 2a 20 4c 61 73 74 20 6b 6e 6f  ue;../* Last kno
05e0: 77 6e 20 76 61 6c 75 65 20 6f 66 20 43 20 76 61  wn value of C va
05f0: 72 69 61 62 6c 65 3b 20 75 73 65 64 20 74 6f 0a  riable; used to.
0600: 09 7c 09 09 09 09 20 2a 20 61 76 6f 69 64 20 73  .|.... * avoid s
0610: 74 72 69 6e 67 20 63 6f 6e 76 65 72 73 69 6f 6e  tring conversion
0620: 73 2e 20 2a 2f 0a 09 7c 20 7d 20 4c 69 6e 6b 3b  s. */..| } Link;
0630: 0a 0a 09 7c 20 2f 2a 0a 09 7c 20 20 2a 20 50 72  ...| /*..|  * Pr
0640: 6f 74 6f 74 79 70 65 73 20 66 6f 72 20 70 72 6f  ototypes for pro
0650: 63 65 64 75 72 65 73 20 72 65 66 65 72 65 6e 63  cedures referenc
0660: 65 64 20 6f 6e 6c 79 20 69 6e 20 74 68 69 73 20  ed only in this 
0670: 66 69 6c 65 3a 0a 09 7c 20 20 2a 2f 0a 50 72 6f  file:..|  */.Pro
0680: 74 6f 2d 09 7c 0a 74 79 70 65 73 09 7c 20 73 74  to-.|.types.| st
0690: 61 74 69 63 20 63 68 61 72 20 2a 09 09 09 4c 69  atic char *...Li
06a0: 6e 6b 54 72 61 63 65 50 72 6f 63 20 5f 41 4e 53  nkTraceProc _ANS
06b0: 49 5f 41 52 47 53 5f 28 28 43 6c 69 65 6e 74 44  I_ARGS_((ClientD
06c0: 61 74 61 20 63 6c 69 65 6e 74 44 61 74 61 2c 0a  ata clientData,.
06d0: 09 7c 20 09 09 09 09 20 20 20 20 54 63 6c 5f 49  .| ....    Tcl_I
06e0: 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c 20 63  nterp *interp, c
06f0: 68 61 72 20 2a 6e 61 6d 65 31 2c 20 63 68 61 72  har *name1, char
0700: 20 2a 6e 61 6d 65 32 2c 0a 09 7c 20 09 09 09 09   *name2,..| ....
0710: 20 20 20 20 69 6e 74 20 66 6c 61 67 73 29 29 3b      int flags));
0720: 0a 09 7c 20 73 74 61 74 69 63 20 63 68 61 72 20  ..| static char 
0730: 2a 09 09 09 53 74 72 69 6e 67 56 61 6c 75 65 20  *...StringValue 
0740: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 4c 69 6e  _ANSI_ARGS_((Lin
0750: 6b 20 2a 6c 69 6e 6b 50 74 72 2c 0a 09 7c 20 09  k *linkPtr,..| .
0760: 20 20 09 09 09 20 20 20 20 63 68 61 72 20 2a 62    ...    char *b
0770: 75 66 66 65 72 29 29 3b 0a                       uffer));.