Attachment "Duoas-patch.2008-11-01.2014.diff" to
ticket [2215022fff]
added by
duoas
2008-11-02 07:21:36.
0000: 64 69 66 66 20 2d 72 20 74 63 6c 2f 64 6f 63 2f diff -r tcl/doc/
0010: 42 79 74 65 41 72 72 4f 62 6a 2e 33 20 74 63 6c ByteArrObj.3 tcl
0020: 2d 6d 6f 64 69 66 69 65 64 2f 64 6f 63 2f 42 79 -modified/doc/By
0030: 74 65 41 72 72 4f 62 6a 2e 33 0a 33 32 63 33 32 teArrObj.3.32c32
0040: 2c 33 33 0a 3c 20 54 68 65 20 61 72 72 61 79 20 ,33.< The array
0050: 6f 66 20 62 79 74 65 73 20 75 73 65 64 20 74 6f of bytes used to
0060: 20 69 6e 69 74 69 61 6c 69 7a 65 20 6f 72 20 73 initialize or s
0070: 65 74 20 61 20 62 79 74 65 2d 61 72 72 61 79 20 et a byte-array
0080: 6f 62 6a 65 63 74 2e 0a 2d 2d 2d 0a 3e 20 54 68 object..---.> Th
0090: 65 20 61 72 72 61 79 20 6f 66 20 62 79 74 65 73 e array of bytes
00a0: 20 75 73 65 64 20 74 6f 20 69 6e 69 74 69 61 6c used to initial
00b0: 69 7a 65 20 6f 72 20 73 65 74 20 61 20 62 79 74 ize or set a byt
00c0: 65 2d 61 72 72 61 79 20 6f 62 6a 65 63 74 2e 20 e-array object.
00d0: 4d 61 79 20 62 65 20 4e 55 4c 4c 0a 3e 20 65 76 May be NULL.> ev
00e0: 65 6e 20 69 66 20 5c 66 49 6c 65 6e 67 74 68 5c en if \fIlength\
00f0: 66 52 20 69 73 20 6e 6f 6e 2d 7a 65 72 6f 2e 0a fR is non-zero..
0100: 35 38 63 35 39 0a 3c 20 55 54 46 2d 38 20 63 68 58c59.< UTF-8 ch
0110: 61 72 61 63 74 65 72 73 20 69 6e 20 74 68 65 20 aracters in the
0120: 73 74 72 69 6e 67 20 72 65 70 72 65 73 65 6e 74 string represent
0130: 61 74 69 6f 6e 2e 20 20 0a 2d 2d 2d 0a 3e 20 55 ation. .---.> U
0140: 54 46 2d 38 20 63 68 61 72 61 63 74 65 72 73 20 TF-8 characters
0150: 69 6e 20 74 68 65 20 73 74 72 69 6e 67 20 72 65 in the string re
0160: 70 72 65 73 65 6e 74 61 74 69 6f 6e 2e 0a 36 38 presentation..68
0170: 63 36 39 2c 37 30 0a 3c 20 72 65 70 72 65 73 65 c69,70.< represe
0180: 6e 74 61 74 69 6f 6e 2e 0a 2d 2d 2d 0a 3e 20 72 ntation..---.> r
0190: 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 2e 20 49 epresentation. I
01a0: 66 20 5c 66 49 62 79 74 65 73 5c 66 52 20 69 73 f \fIbytes\fR is
01b0: 20 4e 55 4c 4c 20 74 68 65 6e 20 74 68 65 20 6e NULL then the n
01c0: 65 77 20 62 79 74 65 20 61 72 72 61 79 20 63 6f ew byte array co
01d0: 6e 74 61 69 6e 73 0a 3e 20 61 72 62 69 74 72 61 ntains.> arbitra
01e0: 72 79 20 76 61 6c 75 65 73 2e 0a 37 36 63 37 38 ry values..76c78
01f0: 0a 3c 20 69 6e 76 61 6c 69 64 61 74 65 73 20 74 .< invalidates t
0200: 68 65 20 73 74 72 69 6e 67 20 72 65 70 72 65 73 he string repres
0210: 65 6e 74 61 74 69 6f 6e 2e 20 20 0a 2d 2d 2d 0a entation. .---.
0220: 3e 20 69 6e 76 61 6c 69 64 61 74 65 73 20 74 68 > invalidates th
0230: 65 20 73 74 72 69 6e 67 20 72 65 70 72 65 73 65 e string represe
0240: 6e 74 61 74 69 6f 6e 2e 0a 64 69 66 66 20 2d 72 ntation..diff -r
0250: 20 74 63 6c 2f 67 65 6e 65 72 69 63 2f 74 63 6c tcl/generic/tcl
0260: 42 69 6e 61 72 79 2e 63 20 74 63 6c 2d 6d 6f 64 Binary.c tcl-mod
0270: 69 66 69 65 64 2f 67 65 6e 65 72 69 63 2f 74 63 ified/generic/tc
0280: 6c 42 69 6e 61 72 79 2e 63 0a 37 37 63 37 37 0a lBinary.c.77c77.
0290: 3c 20 09 09 09 20 20 20 20 69 6e 74 20 6f 62 6a < ... int obj
02a0: 63 2c 20 54 63 6c 5f 4f 62 6a 20 2a 63 6f 6e 73 c, Tcl_Obj *cons
02b0: 74 20 6f 62 6a 76 5b 5d 29 3b 0a 2d 2d 2d 0a 3e t objv[]);.---.>
02c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
02d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 int
02e0: 20 6f 62 6a 63 2c 20 54 63 6c 5f 4f 62 6a 20 2a objc, Tcl_Obj *
02f0: 63 6f 6e 73 74 20 6f 62 6a 76 5b 5d 29 3b 0a 33 const objv[]);.3
0300: 31 35 2c 33 31 37 63 33 31 35 2c 33 31 37 0a 3c 15,317c315,317.<
0310: 20 09 09 09 09 20 2a 20 76 61 6c 75 65 2e 20 2a .... * value. *
0320: 2f 0a 3c 20 20 20 20 20 69 6e 74 20 6c 65 6e 67 /.< int leng
0330: 74 68 29 09 09 09 2f 2a 20 4c 65 6e 67 74 68 20 th).../* Length
0340: 6f 66 20 74 68 65 20 61 72 72 61 79 20 6f 66 20 of the array of
0350: 62 79 74 65 73 2c 20 77 68 69 63 68 20 6d 75 73 bytes, which mus
0360: 74 20 62 65 0a 3c 20 09 09 09 09 20 2a 20 3e 3d t be.< .... * >=
0370: 20 30 2e 20 2a 2f 0a 2d 2d 2d 0a 3e 20 09 09 09 0. */.---.> ...
0380: 09 20 20 20 76 61 6c 75 65 2e 20 4d 61 79 20 62 . value. May b
0390: 65 20 4e 55 4c 4c 20 65 76 65 6e 20 69 66 20 6c e NULL even if l
03a0: 65 6e 67 74 68 20 3e 20 30 2e 20 2a 2f 0a 3e 20 ength > 0. */.>
03b0: 20 20 20 20 69 6e 74 20 6c 65 6e 67 74 68 29 09 int length).
03c0: 09 09 2f 2a 20 4c 65 6e 67 74 68 20 6f 66 20 74 ../* Length of t
03d0: 68 65 20 61 72 72 61 79 20 6f 66 20 62 79 74 65 he array of byte
03e0: 73 2c 20 77 68 69 63 68 20 6d 75 73 74 0a 3e 20 s, which must.>
03f0: 09 09 09 09 20 20 20 62 65 20 3e 3d 20 30 2e 20 .... be >= 0.
0400: 2a 2f 0a 33 32 36 61 33 32 37 0a 3e 20 20 20 20 */.326a327.>
0410: 20 6c 65 6e 67 74 68 20 3d 20 28 6c 65 6e 67 74 length = (lengt
0420: 68 20 3c 20 30 29 20 3f 20 30 20 3a 20 6c 65 6e h < 0) ? 0 : len
0430: 67 74 68 3b 0a 33 33 30 63 33 33 31 2c 33 33 33 gth;.330c331,333
0440: 0a 3c 20 20 20 20 20 6d 65 6d 63 70 79 28 62 79 .< memcpy(by
0450: 74 65 41 72 72 61 79 50 74 72 2d 3e 62 79 74 65 teArrayPtr->byte
0460: 73 2c 20 62 79 74 65 73 2c 20 28 73 69 7a 65 5f s, bytes, (size_
0470: 74 29 20 6c 65 6e 67 74 68 29 3b 0a 2d 2d 2d 0a t) length);.---.
0480: 3e 20 20 20 20 20 69 66 20 28 62 79 74 65 73 20 > if (bytes
0490: 26 26 20 6c 65 6e 67 74 68 29 20 7b 0a 3e 20 20 && length) {.>
04a0: 20 20 20 20 20 20 20 6d 65 6d 63 70 79 28 62 79 memcpy(by
04b0: 74 65 41 72 72 61 79 50 74 72 2d 3e 62 79 74 65 teArrayPtr->byte
04c0: 73 2c 20 62 79 74 65 73 2c 20 28 73 69 7a 65 5f s, bytes, (size_
04d0: 74 29 20 6c 65 6e 67 74 68 29 3b 0a 3e 20 20 20 t) length);.>
04e0: 20 20 7d 0a 35 39 36 2c 35 39 37 63 35 39 39 2c }.596,597c599,
04f0: 36 30 30 0a 3c 20 20 2a 09 54 68 69 73 20 66 75 600.< *.This fu
0500: 6e 63 74 69 6f 6e 20 69 73 20 63 61 6c 6c 65 64 nction is called
0510: 20 74 6f 20 63 72 65 61 74 65 20 74 68 65 20 22 to create the "
0520: 62 69 6e 61 72 79 22 20 54 63 6c 20 63 6f 6d 6d binary" Tcl comm
0530: 61 6e 64 2e 20 53 65 65 20 74 68 65 20 75 73 65 and. See the use
0540: 72 0a 3c 20 20 2a 09 64 6f 63 75 6d 65 6e 74 61 r.< *.documenta
0550: 74 69 6f 6e 20 66 6f 72 20 64 65 74 61 69 6c 73 tion for details
0560: 20 6f 6e 20 77 68 61 74 20 69 74 20 64 6f 65 73 on what it does
0570: 2e 0a 2d 2d 2d 0a 3e 20 20 2a 09 54 68 69 73 20 ..---.> *.This
0580: 66 75 6e 63 74 69 6f 6e 20 69 73 20 63 61 6c 6c function is call
0590: 65 64 20 74 6f 20 63 72 65 61 74 65 20 74 68 65 ed to create the
05a0: 20 22 62 69 6e 61 72 79 22 20 54 63 6c 20 63 6f "binary" Tcl co
05b0: 6d 6d 61 6e 64 2e 20 53 65 65 20 74 68 65 0a 3e mmand. See the.>
05c0: 20 20 2a 20 20 20 20 20 20 75 73 65 72 20 64 6f * user do
05d0: 63 75 6d 65 6e 74 61 74 69 6f 6e 20 66 6f 72 20 cumentation for
05e0: 64 65 74 61 69 6c 73 20 6f 6e 20 77 68 61 74 20 details on what
05f0: 69 74 20 64 6f 65 73 2e 0a 36 31 31 2c 36 31 33 it does..611,613
0600: 63 36 31 34 2c 36 33 38 0a 3c 20 20 20 20 20 54 c614,638.< T
0610: 63 6c 5f 4e 61 6d 65 73 70 61 63 65 20 2a 6e 73 cl_Namespace *ns
0620: 54 63 6c 50 74 72 2c 20 2a 6e 73 42 69 6e 50 74 TclPtr, *nsBinPt
0630: 72 2c 20 2a 6e 73 45 6e 63 50 74 72 2c 20 2a 6e r, *nsEncPtr, *n
0640: 73 44 65 63 50 74 72 3b 0a 3c 20 20 20 20 20 54 sDecPtr;.< T
0650: 63 6c 5f 43 6f 6d 6d 61 6e 64 20 62 69 6e 45 6e cl_Command binEn
0660: 73 65 6d 62 6c 65 2c 20 65 6e 63 45 6e 73 65 6d semble, encEnsem
0670: 62 6c 65 2c 20 64 65 63 45 6e 73 65 6d 62 6c 65 ble, decEnsemble
0680: 3b 0a 3c 20 20 20 20 20 54 63 6c 5f 4f 62 6a 20 ;.< Tcl_Obj
0690: 2a 62 69 6e 44 69 63 74 2c 20 2a 65 6e 63 44 69 *binDict, *encDi
06a0: 63 74 2c 20 2a 64 65 63 44 69 63 74 3b 0a 2d 2d ct, *decDict;.--
06b0: 2d 0a 3e 20 20 20 20 20 63 6f 6e 73 74 20 45 6e -.> const En
06c0: 73 65 6d 62 6c 65 49 6d 70 6c 4d 61 70 20 62 69 sembleImplMap bi
06d0: 6e 61 72 79 4d 61 70 5b 5d 20 3d 20 7b 0a 3e 20 naryMap[] = {.>
06e0: 20 20 20 20 20 20 20 20 7b 20 22 66 6f 72 6d 61 { "forma
06f0: 74 22 2c 20 42 69 6e 61 72 79 46 6f 72 6d 61 74 t", BinaryFormat
0700: 43 6d 64 20 7d 2c 0a 3e 20 20 20 20 20 20 20 20 Cmd },.>
0710: 20 7b 20 22 73 63 61 6e 22 2c 20 20 20 42 69 6e { "scan", Bin
0720: 61 72 79 53 63 61 6e 43 6d 64 20 20 20 7d 2c 0a aryScanCmd },.
0730: 3e 20 20 20 20 20 20 20 20 20 7b 20 22 65 6e 63 > { "enc
0740: 6f 64 65 22 2c 20 4e 55 4c 4c 20 20 20 20 20 20 ode", NULL
0750: 20 20 20 20 20 20 7d 2c 0a 3e 20 20 20 20 20 20 },.>
0760: 20 20 20 7b 20 22 64 65 63 6f 64 65 22 2c 20 4e { "decode", N
0770: 55 4c 4c 20 20 20 20 20 20 20 20 20 20 20 20 7d ULL }
0780: 2c 0a 3e 20 20 20 20 20 20 20 20 20 7b 20 4e 55 ,.> { NU
0790: 4c 4c 20 7d 0a 3e 20 20 20 20 20 7d 3b 0a 3e 20 LL }.> };.>
07a0: 20 20 20 20 63 6f 6e 73 74 20 45 6e 73 65 6d 62 const Ensemb
07b0: 6c 65 49 6d 70 6c 4d 61 70 20 65 6e 63 6f 64 65 leImplMap encode
07c0: 4d 61 70 5b 5d 20 3d 20 7b 0a 3e 20 20 20 20 20 Map[] = {.>
07d0: 20 20 20 20 7b 20 22 68 65 78 22 2c 20 20 20 20 { "hex",
07e0: 20 20 42 69 6e 61 72 79 45 6e 63 6f 64 65 48 65 BinaryEncodeHe
07f0: 78 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 28 x, NULL, NULL, (
0800: 43 6c 69 65 6e 74 44 61 74 61 29 48 65 78 44 69 ClientData)HexDi
0810: 67 69 74 73 20 7d 2c 0a 3e 20 20 20 20 20 20 20 gits },.>
0820: 20 20 7b 20 22 75 75 65 6e 63 6f 64 65 22 2c 20 { "uuencode",
0830: 42 69 6e 61 72 79 45 6e 63 6f 64 65 36 34 2c 20 BinaryEncode64,
0840: 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 28 43 6c NULL, NULL, (Cl
0850: 69 65 6e 74 44 61 74 61 29 55 75 65 44 69 67 69 ientData)UueDigi
0860: 74 73 20 7d 2c 0a 3e 20 20 20 20 20 20 20 20 20 ts },.>
0870: 7b 20 22 62 61 73 65 36 34 22 2c 20 20 20 42 69 { "base64", Bi
0880: 6e 61 72 79 45 6e 63 6f 64 65 36 34 2c 20 20 4e naryEncode64, N
0890: 55 4c 4c 2c 20 4e 55 4c 4c 2c 20 28 43 6c 69 65 ULL, NULL, (Clie
08a0: 6e 74 44 61 74 61 29 42 36 34 44 69 67 69 74 73 ntData)B64Digits
08b0: 20 7d 2c 0a 3e 20 20 20 20 20 20 20 20 20 7b 20 },.> {
08c0: 4e 55 4c 4c 20 7d 0a 3e 20 20 20 20 20 7d 3b 0a NULL }.> };.
08d0: 3e 20 20 20 20 20 63 6f 6e 73 74 20 45 6e 73 65 > const Ense
08e0: 6d 62 6c 65 49 6d 70 6c 4d 61 70 20 64 65 63 6f mbleImplMap deco
08f0: 64 65 4d 61 70 5b 5d 20 3d 20 7b 0a 3e 20 20 20 deMap[] = {.>
0900: 20 20 20 20 20 20 7b 20 22 68 65 78 22 2c 20 20 { "hex",
0910: 20 20 20 20 42 69 6e 61 72 79 44 65 63 6f 64 65 BinaryDecode
0920: 48 65 78 20 7d 2c 0a 3e 20 20 20 20 20 20 20 20 Hex },.>
0930: 20 7b 20 22 75 75 65 6e 63 6f 64 65 22 2c 20 42 { "uuencode", B
0940: 69 6e 61 72 79 44 65 63 6f 64 65 55 75 20 20 7d inaryDecodeUu }
0950: 2c 0a 3e 20 20 20 20 20 20 20 20 20 7b 20 22 62 ,.> { "b
0960: 61 73 65 36 34 22 2c 20 20 20 42 69 6e 61 72 79 ase64", Binary
0970: 44 65 63 6f 64 65 36 34 20 20 7d 2c 0a 3e 20 20 Decode64 },.>
0980: 20 20 20 20 20 20 20 7b 20 4e 55 4c 4c 20 7d 0a { NULL }.
0990: 3e 20 20 20 20 20 7d 3b 0a 3e 20 0a 3e 20 20 20 > };.> .>
09a0: 20 20 54 63 6c 5f 43 6f 6d 6d 61 6e 64 20 62 69 Tcl_Command bi
09b0: 6e 61 72 79 45 6e 73 65 6d 62 6c 65 3b 0a 3e 20 naryEnsemble;.>
09c0: 0a 3e 20 20 20 20 20 62 69 6e 61 72 79 45 6e 73 .> binaryEns
09d0: 65 6d 62 6c 65 20 3d 20 54 63 6c 4d 61 6b 65 45 emble = TclMakeE
09e0: 6e 73 65 6d 62 6c 65 28 20 69 6e 74 65 72 70 2c nsemble( interp,
09f0: 20 22 62 69 6e 61 72 79 22 2c 20 20 20 20 20 20 "binary",
0a00: 20 20 62 69 6e 61 72 79 4d 61 70 20 29 3b 0a 3e binaryMap );.>
0a10: 20 20 20 20 20 2f 2a 65 6e 63 6f 64 65 45 6e 73 /*encodeEns
0a20: 65 6d 62 2a 2f 20 54 63 6c 4d 61 6b 65 45 6e 73 emb*/ TclMakeEns
0a30: 65 6d 62 6c 65 28 20 69 6e 74 65 72 70 2c 20 22 emble( interp, "
0a40: 62 69 6e 61 72 79 20 65 6e 63 6f 64 65 22 2c 20 binary encode",
0a50: 65 6e 63 6f 64 65 4d 61 70 20 29 3b 0a 3e 20 20 encodeMap );.>
0a60: 20 20 20 2f 2a 64 65 63 6f 64 65 45 6e 73 65 6d /*decodeEnsem
0a70: 62 2a 2f 20 54 63 6c 4d 61 6b 65 45 6e 73 65 6d b*/ TclMakeEnsem
0a80: 62 6c 65 28 20 69 6e 74 65 72 70 2c 20 22 62 69 ble( interp, "bi
0a90: 6e 61 72 79 20 64 65 63 6f 64 65 22 2c 20 64 65 nary decode", de
0aa0: 63 6f 64 65 4d 61 70 20 29 3b 0a 36 31 35 2c 36 codeMap );.615,6
0ab0: 39 33 63 36 34 30 0a 3c 20 20 20 20 20 2f 2a 0a 93c640.< /*.
0ac0: 3c 20 20 20 20 20 20 2a 20 46 49 58 20 4d 45 3a < * FIX ME:
0ad0: 20 49 20 73 6f 20 75 67 6c 79 20 2d 20 70 6c 65 I so ugly - ple
0ae0: 61 73 65 20 6d 61 6b 65 20 6d 65 20 70 72 65 74 ase make me pret
0af0: 74 79 20 2e 2e 2e 0a 3c 20 20 20 20 20 20 2a 2f ty ....< */
0b00: 0a 3c 20 0a 3c 20 20 20 20 20 6e 73 54 63 6c 50 .< .< nsTclP
0b10: 74 72 20 3d 20 54 63 6c 5f 46 69 6e 64 4e 61 6d tr = Tcl_FindNam
0b20: 65 73 70 61 63 65 28 69 6e 74 65 72 70 2c 20 22 espace(interp, "
0b30: 3a 3a 74 63 6c 22 2c 0a 3c 20 09 4e 55 4c 4c 2c ::tcl",.< .NULL,
0b40: 20 54 43 4c 5f 43 52 45 41 54 45 5f 4e 53 5f 49 TCL_CREATE_NS_I
0b50: 46 5f 55 4e 4b 4e 4f 57 4e 29 3b 0a 3c 20 20 20 F_UNKNOWN);.<
0b60: 20 20 69 66 20 28 6e 73 54 63 6c 50 74 72 20 3d if (nsTclPtr =
0b70: 3d 20 4e 55 4c 4c 29 20 7b 0a 3c 20 09 54 63 6c = NULL) {.< .Tcl
0b80: 5f 50 61 6e 69 63 28 22 75 6e 61 62 6c 65 20 74 _Panic("unable t
0b90: 6f 20 66 69 6e 64 20 6f 72 20 63 72 65 61 74 65 o find or create
0ba0: 20 3a 3a 74 63 6c 20 6e 61 6d 65 73 70 61 63 65 ::tcl namespace
0bb0: 21 22 29 3b 0a 3c 20 20 20 20 20 7d 0a 3c 20 20 !");.< }.<
0bc0: 20 20 20 6e 73 42 69 6e 50 74 72 20 3d 20 54 63 nsBinPtr = Tc
0bd0: 6c 5f 46 69 6e 64 4e 61 6d 65 73 70 61 63 65 28 l_FindNamespace(
0be0: 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a interp, "::tcl::
0bf0: 62 69 6e 61 72 79 22 2c 0a 3c 20 09 4e 55 4c 4c binary",.< .NULL
0c00: 2c 20 54 43 4c 5f 43 52 45 41 54 45 5f 4e 53 5f , TCL_CREATE_NS_
0c10: 49 46 5f 55 4e 4b 4e 4f 57 4e 29 3b 0a 3c 20 20 IF_UNKNOWN);.<
0c20: 20 20 20 69 66 20 28 6e 73 42 69 6e 50 74 72 20 if (nsBinPtr
0c30: 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 3c 20 09 54 63 == NULL) {.< .Tc
0c40: 6c 5f 50 61 6e 69 63 28 22 75 6e 61 62 6c 65 20 l_Panic("unable
0c50: 74 6f 20 66 69 6e 64 20 6f 72 20 63 72 65 61 74 to find or creat
0c60: 65 20 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 20 e ::tcl::binary
0c70: 6e 61 6d 65 73 70 61 63 65 21 22 29 3b 0a 3c 20 namespace!");.<
0c80: 20 20 20 20 7d 0a 3c 20 20 20 20 20 62 69 6e 45 }.< binE
0c90: 6e 73 65 6d 62 6c 65 20 3d 20 54 63 6c 5f 43 72 nsemble = Tcl_Cr
0ca0: 65 61 74 65 45 6e 73 65 6d 62 6c 65 28 69 6e 74 eateEnsemble(int
0cb0: 65 72 70 2c 20 22 3a 3a 62 69 6e 61 72 79 22 2c erp, "::binary",
0cc0: 0a 3c 20 09 6e 73 42 69 6e 50 74 72 2c 20 54 43 .< .nsBinPtr, TC
0cd0: 4c 5f 45 4e 53 45 4d 42 4c 45 5f 50 52 45 46 49 L_ENSEMBLE_PREFI
0ce0: 58 29 3b 0a 3c 20 0a 3c 20 20 20 20 20 6e 73 45 X);.< .< nsE
0cf0: 6e 63 50 74 72 20 3d 20 54 63 6c 5f 46 69 6e 64 ncPtr = Tcl_Find
0d00: 4e 61 6d 65 73 70 61 63 65 28 69 6e 74 65 72 70 Namespace(interp
0d10: 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 , "::tcl::binary
0d20: 3a 3a 65 6e 63 6f 64 65 22 2c 0a 3c 20 09 4e 55 ::encode",.< .NU
0d30: 4c 4c 2c 20 54 43 4c 5f 43 52 45 41 54 45 5f 4e LL, TCL_CREATE_N
0d40: 53 5f 49 46 5f 55 4e 4b 4e 4f 57 4e 29 3b 0a 3c S_IF_UNKNOWN);.<
0d50: 20 20 20 20 20 69 66 20 28 6e 73 45 6e 63 50 74 if (nsEncPt
0d60: 72 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 3c 20 09 r == NULL) {.< .
0d70: 54 63 6c 5f 50 61 6e 69 63 28 22 75 6e 61 62 6c Tcl_Panic("unabl
0d80: 65 20 74 6f 20 66 69 6e 64 20 6f 72 20 63 72 65 e to find or cre
0d90: 61 74 65 20 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 ate ::tcl::binar
0da0: 79 3a 3a 65 6e 63 6f 64 65 20 6e 61 6d 65 73 70 y::encode namesp
0db0: 61 63 65 21 22 29 3b 0a 3c 20 20 20 20 20 7d 0a ace!");.< }.
0dc0: 3c 20 20 20 20 20 65 6e 63 45 6e 73 65 6d 62 6c < encEnsembl
0dd0: 65 20 3d 20 54 63 6c 5f 43 72 65 61 74 65 45 6e e = Tcl_CreateEn
0de0: 73 65 6d 62 6c 65 28 69 6e 74 65 72 70 2c 20 22 semble(interp, "
0df0: 65 6e 63 6f 64 65 22 2c 0a 3c 20 09 6e 73 42 69 encode",.< .nsBi
0e00: 6e 50 74 72 2c 20 30 29 3b 0a 3c 20 0a 3c 20 20 nPtr, 0);.< .<
0e10: 20 20 20 6e 73 44 65 63 50 74 72 20 3d 20 54 63 nsDecPtr = Tc
0e20: 6c 5f 46 69 6e 64 4e 61 6d 65 73 70 61 63 65 28 l_FindNamespace(
0e30: 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a interp, "::tcl::
0e40: 62 69 6e 61 72 79 3a 3a 64 65 63 6f 64 65 22 2c binary::decode",
0e50: 0a 3c 20 09 4e 55 4c 4c 2c 20 54 43 4c 5f 43 52 .< .NULL, TCL_CR
0e60: 45 41 54 45 5f 4e 53 5f 49 46 5f 55 4e 4b 4e 4f EATE_NS_IF_UNKNO
0e70: 57 4e 29 3b 0a 3c 20 20 20 20 20 69 66 20 28 6e WN);.< if (n
0e80: 73 44 65 63 50 74 72 20 3d 3d 20 4e 55 4c 4c 29 sDecPtr == NULL)
0e90: 20 7b 0a 3c 20 09 54 63 6c 5f 50 61 6e 69 63 28 {.< .Tcl_Panic(
0ea0: 22 75 6e 61 62 6c 65 20 74 6f 20 66 69 6e 64 20 "unable to find
0eb0: 6f 72 20 63 72 65 61 74 65 20 3a 3a 74 63 6c 3a or create ::tcl:
0ec0: 3a 62 69 6e 61 72 79 3a 3a 64 65 63 6f 64 65 20 :binary::decode
0ed0: 6e 61 6d 65 73 70 61 63 65 21 22 29 3b 0a 3c 20 namespace!");.<
0ee0: 20 20 20 20 7d 0a 3c 20 20 20 20 20 64 65 63 45 }.< decE
0ef0: 6e 73 65 6d 62 6c 65 20 3d 20 54 63 6c 5f 43 72 nsemble = Tcl_Cr
0f00: 65 61 74 65 45 6e 73 65 6d 62 6c 65 28 69 6e 74 eateEnsemble(int
0f10: 65 72 70 2c 20 22 64 65 63 6f 64 65 22 2c 0a 3c erp, "decode",.<
0f20: 20 09 6e 73 42 69 6e 50 74 72 2c 20 30 29 3b 0a .nsBinPtr, 0);.
0f30: 3c 20 0a 3c 20 20 20 20 20 54 63 6c 4e 65 77 4f < .< TclNewO
0f40: 62 6a 28 62 69 6e 44 69 63 74 29 3b 0a 3c 20 20 bj(binDict);.<
0f50: 20 20 20 54 63 6c 5f 44 69 63 74 4f 62 6a 50 75 Tcl_DictObjPu
0f60: 74 28 4e 55 4c 4c 2c 20 62 69 6e 44 69 63 74 2c t(NULL, binDict,
0f70: 20 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 Tcl_NewStringOb
0f80: 6a 28 22 66 6f 72 6d 61 74 22 2c 2d 31 29 2c 0a j("format",-1),.
0f90: 3c 20 09 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 < .Tcl_NewString
0fa0: 4f 62 6a 28 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 Obj("::tcl::bina
0fb0: 72 79 3a 3a 66 6f 72 6d 61 74 22 2c 2d 31 29 29 ry::format",-1))
0fc0: 3b 0a 3c 20 20 20 20 20 54 63 6c 5f 44 69 63 74 ;.< Tcl_Dict
0fd0: 4f 62 6a 50 75 74 28 4e 55 4c 4c 2c 20 62 69 6e ObjPut(NULL, bin
0fe0: 44 69 63 74 2c 20 54 63 6c 5f 4e 65 77 53 74 72 Dict, Tcl_NewStr
0ff0: 69 6e 67 4f 62 6a 28 22 73 63 61 6e 22 2c 2d 31 ingObj("scan",-1
1000: 29 2c 0a 3c 20 09 54 63 6c 5f 4e 65 77 53 74 72 ),.< .Tcl_NewStr
1010: 69 6e 67 4f 62 6a 28 22 3a 3a 74 63 6c 3a 3a 62 ingObj("::tcl::b
1020: 69 6e 61 72 79 3a 3a 73 63 61 6e 22 2c 2d 31 29 inary::scan",-1)
1030: 29 3b 0a 3c 20 20 20 20 20 54 63 6c 5f 44 69 63 );.< Tcl_Dic
1040: 74 4f 62 6a 50 75 74 28 4e 55 4c 4c 2c 20 62 69 tObjPut(NULL, bi
1050: 6e 44 69 63 74 2c 20 54 63 6c 5f 4e 65 77 53 74 nDict, Tcl_NewSt
1060: 72 69 6e 67 4f 62 6a 28 22 65 6e 63 6f 64 65 22 ringObj("encode"
1070: 2c 2d 31 29 2c 0a 3c 20 09 54 63 6c 5f 4e 65 77 ,-1),.< .Tcl_New
1080: 53 74 72 69 6e 67 4f 62 6a 28 22 3a 3a 74 63 6c StringObj("::tcl
1090: 3a 3a 62 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 ::binary::encode
10a0: 22 2c 2d 31 29 29 3b 0a 3c 20 20 20 20 20 54 63 ",-1));.< Tc
10b0: 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 4c l_DictObjPut(NUL
10c0: 4c 2c 20 62 69 6e 44 69 63 74 2c 20 54 63 6c 5f L, binDict, Tcl_
10d0: 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 64 65 NewStringObj("de
10e0: 63 6f 64 65 22 2c 2d 31 29 2c 0a 3c 20 09 54 63 code",-1),.< .Tc
10f0: 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 l_NewStringObj("
1100: 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a 64 ::tcl::binary::d
1110: 65 63 6f 64 65 22 2c 2d 31 29 29 3b 0a 3c 20 20 ecode",-1));.<
1120: 20 20 20 54 63 6c 5f 43 72 65 61 74 65 4f 62 6a Tcl_CreateObj
1130: 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 72 70 2c 20 Command(interp,
1140: 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a "::tcl::binary::
1150: 66 6f 72 6d 61 74 22 2c 0a 3c 20 09 42 69 6e 61 format",.< .Bina
1160: 72 79 46 6f 72 6d 61 74 43 6d 64 2c 20 4e 55 4c ryFormatCmd, NUL
1170: 4c 2c 20 4e 55 4c 4c 29 3b 0a 3c 20 20 20 20 20 L, NULL);.<
1180: 54 63 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d Tcl_CreateObjCom
1190: 6d 61 6e 64 28 69 6e 74 65 72 70 2c 20 22 3a 3a mand(interp, "::
11a0: 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a 73 63 61 tcl::binary::sca
11b0: 6e 22 2c 0a 3c 20 09 42 69 6e 61 72 79 53 63 61 n",.< .BinarySca
11c0: 6e 43 6d 64 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c nCmd, NULL, NULL
11d0: 29 3b 0a 3c 20 20 20 20 20 54 63 6c 5f 53 65 74 );.< Tcl_Set
11e0: 45 6e 73 65 6d 62 6c 65 4d 61 70 70 69 6e 67 44 EnsembleMappingD
11f0: 69 63 74 28 69 6e 74 65 72 70 2c 20 62 69 6e 45 ict(interp, binE
1200: 6e 73 65 6d 62 6c 65 2c 20 62 69 6e 44 69 63 74 nsemble, binDict
1210: 29 3b 0a 3c 20 0a 3c 20 20 20 20 20 54 63 6c 4e );.< .< TclN
1220: 65 77 4f 62 6a 28 65 6e 63 44 69 63 74 29 3b 0a ewObj(encDict);.
1230: 3c 20 20 20 20 20 54 63 6c 5f 44 69 63 74 4f 62 < Tcl_DictOb
1240: 6a 50 75 74 28 4e 55 4c 4c 2c 20 65 6e 63 44 69 jPut(NULL, encDi
1250: 63 74 2c 20 54 63 6c 5f 4e 65 77 53 74 72 69 6e ct, Tcl_NewStrin
1260: 67 4f 62 6a 28 22 68 65 78 22 2c 2d 31 29 2c 0a gObj("hex",-1),.
1270: 3c 20 09 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 < .Tcl_NewString
1280: 4f 62 6a 28 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 Obj("::tcl::bina
1290: 72 79 3a 3a 65 6e 63 6f 64 65 3a 3a 68 65 78 22 ry::encode::hex"
12a0: 2c 2d 31 29 29 3b 0a 3c 20 20 20 20 20 54 63 6c ,-1));.< Tcl
12b0: 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 4c 4c _DictObjPut(NULL
12c0: 2c 20 65 6e 63 44 69 63 74 2c 20 54 63 6c 5f 4e , encDict, Tcl_N
12d0: 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 75 75 65 ewStringObj("uue
12e0: 6e 63 6f 64 65 22 2c 2d 31 29 2c 0a 3c 20 09 54 ncode",-1),.< .T
12f0: 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 cl_NewStringObj(
1300: 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a "::tcl::binary::
1310: 65 6e 63 6f 64 65 3a 3a 75 75 65 6e 63 6f 64 65 encode::uuencode
1320: 22 2c 2d 31 29 29 3b 0a 3c 20 20 20 20 20 54 63 ",-1));.< Tc
1330: 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 4c l_DictObjPut(NUL
1340: 4c 2c 20 65 6e 63 44 69 63 74 2c 20 54 63 6c 5f L, encDict, Tcl_
1350: 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 62 61 NewStringObj("ba
1360: 73 65 36 34 22 2c 2d 31 29 2c 0a 3c 20 09 54 63 se64",-1),.< .Tc
1370: 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 l_NewStringObj("
1380: 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a 65 ::tcl::binary::e
1390: 6e 63 6f 64 65 3a 3a 62 61 73 65 36 34 22 2c 2d ncode::base64",-
13a0: 31 29 29 3b 0a 3c 20 20 20 20 20 54 63 6c 5f 43 1));.< Tcl_C
13b0: 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 reateObjCommand(
13c0: 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a interp, "::tcl::
13d0: 62 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 3a 3a binary::encode::
13e0: 68 65 78 22 2c 0a 3c 20 09 42 69 6e 61 72 79 45 hex",.< .BinaryE
13f0: 6e 63 6f 64 65 48 65 78 2c 20 28 43 6c 69 65 6e ncodeHex, (Clien
1400: 74 44 61 74 61 29 48 65 78 44 69 67 69 74 73 2c tData)HexDigits,
1410: 20 4e 55 4c 4c 29 3b 0a 3c 20 20 20 20 20 54 63 NULL);.< Tc
1420: 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 l_CreateObjComma
1430: 6e 64 28 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 nd(interp, "::tc
1440: 6c 3a 3a 62 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 l::binary::encod
1450: 65 3a 3a 75 75 65 6e 63 6f 64 65 22 2c 0a 3c 20 e::uuencode",.<
1460: 09 42 69 6e 61 72 79 45 6e 63 6f 64 65 36 34 2c .BinaryEncode64,
1470: 20 28 43 6c 69 65 6e 74 44 61 74 61 29 55 75 65 (ClientData)Uue
1480: 44 69 67 69 74 73 2c 20 4e 55 4c 4c 29 3b 0a 3c Digits, NULL);.<
1490: 20 20 20 20 20 54 63 6c 5f 43 72 65 61 74 65 4f Tcl_CreateO
14a0: 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 72 70 bjCommand(interp
14b0: 2c 20 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 , "::tcl::binary
14c0: 3a 3a 65 6e 63 6f 64 65 3a 3a 62 61 73 65 36 34 ::encode::base64
14d0: 22 2c 0a 3c 20 09 42 69 6e 61 72 79 45 6e 63 6f ",.< .BinaryEnco
14e0: 64 65 36 34 2c 20 28 43 6c 69 65 6e 74 44 61 74 de64, (ClientDat
14f0: 61 29 42 36 34 44 69 67 69 74 73 2c 20 4e 55 4c a)B64Digits, NUL
1500: 4c 29 3b 0a 3c 20 20 20 20 20 54 63 6c 5f 53 65 L);.< Tcl_Se
1510: 74 45 6e 73 65 6d 62 6c 65 4d 61 70 70 69 6e 67 tEnsembleMapping
1520: 44 69 63 74 28 69 6e 74 65 72 70 2c 20 65 6e 63 Dict(interp, enc
1530: 45 6e 73 65 6d 62 6c 65 2c 20 65 6e 63 44 69 63 Ensemble, encDic
1540: 74 29 3b 0a 3c 20 0a 3c 20 20 20 20 20 54 63 6c t);.< .< Tcl
1550: 4e 65 77 4f 62 6a 28 64 65 63 44 69 63 74 29 3b NewObj(decDict);
1560: 0a 3c 20 20 20 20 20 54 63 6c 5f 44 69 63 74 4f .< Tcl_DictO
1570: 62 6a 50 75 74 28 4e 55 4c 4c 2c 20 64 65 63 44 bjPut(NULL, decD
1580: 69 63 74 2c 20 54 63 6c 5f 4e 65 77 53 74 72 69 ict, Tcl_NewStri
1590: 6e 67 4f 62 6a 28 22 68 65 78 22 2c 2d 31 29 2c ngObj("hex",-1),
15a0: 0a 3c 20 09 54 63 6c 5f 4e 65 77 53 74 72 69 6e .< .Tcl_NewStrin
15b0: 67 4f 62 6a 28 22 3a 3a 74 63 6c 3a 3a 62 69 6e gObj("::tcl::bin
15c0: 61 72 79 3a 3a 64 65 63 6f 64 65 3a 3a 68 65 78 ary::decode::hex
15d0: 22 2c 2d 31 29 29 3b 0a 3c 20 20 20 20 20 54 63 ",-1));.< Tc
15e0: 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 4c l_DictObjPut(NUL
15f0: 4c 2c 20 64 65 63 44 69 63 74 2c 20 54 63 6c 5f L, decDict, Tcl_
1600: 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 75 75 NewStringObj("uu
1610: 65 6e 63 6f 64 65 22 2c 2d 31 29 2c 0a 3c 20 09 encode",-1),.< .
1620: 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a Tcl_NewStringObj
1630: 28 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a ("::tcl::binary:
1640: 3a 64 65 63 6f 64 65 3a 3a 75 75 65 6e 63 6f 64 :decode::uuencod
1650: 65 22 2c 2d 31 29 29 3b 0a 3c 20 20 20 20 20 54 e",-1));.< T
1660: 63 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 4e 55 cl_DictObjPut(NU
1670: 4c 4c 2c 20 64 65 63 44 69 63 74 2c 20 54 63 6c LL, decDict, Tcl
1680: 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 22 62 _NewStringObj("b
1690: 61 73 65 36 34 22 2c 2d 31 29 2c 0a 3c 20 09 54 ase64",-1),.< .T
16a0: 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 cl_NewStringObj(
16b0: 22 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a "::tcl::binary::
16c0: 64 65 63 6f 64 65 3a 3a 62 61 73 65 36 34 22 2c decode::base64",
16d0: 2d 31 29 29 3b 0a 3c 20 20 20 20 20 54 63 6c 5f -1));.< Tcl_
16e0: 43 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 CreateObjCommand
16f0: 28 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a (interp, "::tcl:
1700: 3a 62 69 6e 61 72 79 3a 3a 64 65 63 6f 64 65 3a :binary::decode:
1710: 3a 68 65 78 22 2c 0a 3c 20 09 42 69 6e 61 72 79 :hex",.< .Binary
1720: 44 65 63 6f 64 65 48 65 78 2c 20 28 43 6c 69 65 DecodeHex, (Clie
1730: 6e 74 44 61 74 61 29 4e 55 4c 4c 2c 20 4e 55 4c ntData)NULL, NUL
1740: 4c 29 3b 0a 3c 20 20 20 20 20 54 63 6c 5f 43 72 L);.< Tcl_Cr
1750: 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 eateObjCommand(i
1760: 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a 3a 62 nterp, "::tcl::b
1770: 69 6e 61 72 79 3a 3a 64 65 63 6f 64 65 3a 3a 75 inary::decode::u
1780: 75 65 6e 63 6f 64 65 22 2c 0a 3c 20 09 42 69 6e uencode",.< .Bin
1790: 61 72 79 44 65 63 6f 64 65 55 75 2c 20 28 43 6c aryDecodeUu, (Cl
17a0: 69 65 6e 74 44 61 74 61 29 4e 55 4c 4c 2c 20 4e ientData)NULL, N
17b0: 55 4c 4c 29 3b 0a 3c 20 20 20 20 20 54 63 6c 5f ULL);.< Tcl_
17c0: 43 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e 64 CreateObjCommand
17d0: 28 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c 3a (interp, "::tcl:
17e0: 3a 62 69 6e 61 72 79 3a 3a 64 65 63 6f 64 65 3a :binary::decode:
17f0: 3a 62 61 73 65 36 34 22 2c 0a 3c 20 09 42 69 6e :base64",.< .Bin
1800: 61 72 79 44 65 63 6f 64 65 36 34 2c 20 28 43 6c aryDecode64, (Cl
1810: 69 65 6e 74 44 61 74 61 29 4e 55 4c 4c 2c 20 4e ientData)NULL, N
1820: 55 4c 4c 29 3b 0a 3c 20 20 20 20 20 54 63 6c 5f ULL);.< Tcl_
1830: 53 65 74 45 6e 73 65 6d 62 6c 65 4d 61 70 70 69 SetEnsembleMappi
1840: 6e 67 44 69 63 74 28 69 6e 74 65 72 70 2c 20 64 ngDict(interp, d
1850: 65 63 45 6e 73 65 6d 62 6c 65 2c 20 64 65 63 44 ecEnsemble, decD
1860: 69 63 74 29 3b 0a 3c 20 0a 3c 20 20 20 20 20 72 ict);.< .< r
1870: 65 74 75 72 6e 20 62 69 6e 45 6e 73 65 6d 62 6c eturn binEnsembl
1880: 65 3b 0a 2d 2d 2d 0a 3e 20 20 20 20 20 72 65 74 e;.---.> ret
1890: 75 72 6e 20 62 69 6e 61 72 79 45 6e 73 65 6d 62 urn binaryEnsemb
18a0: 6c 65 3b 0a 32 37 31 32 61 32 36 36 30 0a 3e 20 le;.2712a2660.>
18b0: 0a 64 69 66 66 20 2d 72 20 74 63 6c 2f 67 65 6e .diff -r tcl/gen
18c0: 65 72 69 63 2f 74 63 6c 49 6e 74 2e 68 20 74 63 eric/tclInt.h tc
18d0: 6c 2d 6d 6f 64 69 66 69 65 64 2f 67 65 6e 65 72 l-modified/gener
18e0: 69 63 2f 74 63 6c 49 6e 74 2e 68 0a 31 34 35 38 ic/tclInt.h.1458
18f0: 2c 31 34 36 31 63 31 34 35 38 2c 31 34 36 35 0a ,1461c1458,1465.
1900: 3c 20 20 20 20 20 63 6f 6e 73 74 20 63 68 61 72 < const char
1910: 20 2a 6e 61 6d 65 3b 09 09 2f 2a 20 54 68 65 20 *name;../* The
1920: 6e 61 6d 65 20 6f 66 20 74 68 65 20 73 75 62 63 name of the subc
1930: 6f 6d 6d 61 6e 64 2e 20 2a 2f 0a 3c 20 20 20 20 ommand. */.<
1940: 20 54 63 6c 5f 4f 62 6a 43 6d 64 50 72 6f 63 20 Tcl_ObjCmdProc
1950: 2a 70 72 6f 63 3b 09 2f 2a 20 54 68 65 20 69 6d *proc;./* The im
1960: 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 plementation of
1970: 74 68 65 20 73 75 62 63 6f 6d 6d 61 6e 64 2e 20 the subcommand.
1980: 2a 2f 0a 3c 20 20 20 20 20 43 6f 6d 70 69 6c 65 */.< Compile
1990: 50 72 6f 63 20 2a 63 6f 6d 70 69 6c 65 50 72 6f Proc *compilePro
19a0: 63 3b 09 2f 2a 20 54 68 65 20 63 6f 6d 70 69 6c c;./* The compil
19b0: 65 72 20 66 6f 72 20 74 68 65 20 73 75 62 63 6f er for the subco
19c0: 6d 6d 61 6e 64 2e 20 2a 2f 0a 3c 20 20 20 20 20 mmand. */.<
19d0: 54 63 6c 5f 4f 62 6a 43 6d 64 50 72 6f 63 20 2a Tcl_ObjCmdProc *
19e0: 6e 72 65 50 72 6f 63 3b 09 2f 2a 20 4e 52 45 20 nreProc;./* NRE
19f0: 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 6f implementation o
1a00: 66 20 74 68 69 73 20 63 6f 6d 6d 61 6e 64 20 2a f this command *
1a10: 2f 0a 2d 2d 2d 0a 3e 20 20 20 20 20 63 6f 6e 73 /.---.> cons
1a20: 74 20 63 68 61 72 20 20 20 20 20 20 20 20 2a 6e t char *n
1a30: 61 6d 65 3b 20 20 20 20 20 20 20 20 2f 2a 20 54 ame; /* T
1a40: 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 73 he name of the s
1a50: 75 62 63 6f 6d 6d 61 6e 64 20 20 20 20 20 20 20 ubcommand
1a60: 20 20 20 20 2a 2f 0a 3e 20 20 20 20 20 54 63 6c */.> Tcl
1a70: 5f 4f 62 6a 43 6d 64 50 72 6f 63 20 20 20 20 2a _ObjCmdProc *
1a80: 70 72 6f 63 3b 20 20 20 20 20 20 20 20 2f 2a 20 proc; /*
1a90: 54 68 65 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 The implementati
1aa0: 6f 6e 20 6f 66 20 74 68 65 20 73 75 62 63 6f 6d on of the subcom
1ab0: 6d 61 6e 64 20 2a 2f 0a 3e 20 20 20 20 20 43 6f mand */.> Co
1ac0: 6d 70 69 6c 65 50 72 6f 63 20 20 20 20 20 20 20 mpileProc
1ad0: 2a 63 6f 6d 70 69 6c 65 50 72 6f 63 3b 20 2f 2a *compileProc; /*
1ae0: 20 54 68 65 20 63 6f 6d 70 69 6c 65 72 20 66 6f The compiler fo
1af0: 72 20 74 68 65 20 73 75 62 63 6f 6d 6d 61 6e 64 r the subcommand
1b00: 20 20 20 20 20 20 2a 2f 0a 3e 20 20 20 20 20 54 */.> T
1b10: 63 6c 5f 4f 62 6a 43 6d 64 50 72 6f 63 20 20 20 cl_ObjCmdProc
1b20: 20 2a 6e 72 65 50 72 6f 63 3b 20 20 20 20 20 2f *nreProc; /
1b30: 2a 20 4e 52 45 20 69 6d 70 6c 65 6d 65 6e 74 61 * NRE implementa
1b40: 74 69 6f 6e 20 6f 66 20 74 68 69 73 20 63 6f 6d tion of this com
1b50: 6d 61 6e 64 20 20 20 2a 2f 0a 3e 20 20 20 20 20 mand */.>
1b60: 43 6c 69 65 6e 74 44 61 74 61 20 20 20 20 20 20 ClientData
1b70: 20 20 20 63 6c 69 65 6e 74 44 61 74 61 3b 20 20 clientData;
1b80: 2f 2a 20 41 6e 79 20 63 6c 69 65 6e 74 44 61 74 /* Any clientDat
1b90: 61 20 74 6f 20 67 69 76 65 20 74 68 65 20 63 6f a to give the co
1ba0: 6d 6d 61 6e 64 20 20 20 2a 2f 0a 3e 20 20 20 20 mmand */.>
1bb0: 20 23 69 66 20 30 0a 3e 20 20 20 20 20 54 63 6c #if 0.> Tcl
1bc0: 5f 43 6d 64 44 65 6c 65 74 65 50 72 6f 63 20 2a _CmdDeleteProc *
1bd0: 64 65 6c 65 74 65 50 72 6f 63 3b 20 20 2f 2a 20 deleteProc; /*
1be0: 54 68 65 20 63 6f 6d 6d 61 6e 64 27 73 20 64 65 The command's de
1bf0: 6c 65 74 65 20 70 72 6f 63 20 20 20 20 20 20 20 lete proc
1c00: 20 20 20 20 20 2a 2f 0a 3e 20 20 20 20 20 23 65 */.> #e
1c10: 6e 64 69 66 0a 34 31 38 35 61 34 31 39 30 0a 3e ndif.4185a4190.>
1c20: 20 0a 64 69 66 66 20 2d 72 20 74 63 6c 2f 67 65 .diff -r tcl/ge
1c30: 6e 65 72 69 63 2f 74 63 6c 4e 61 6d 65 73 70 2e neric/tclNamesp.
1c40: 63 20 74 63 6c 2d 6d 6f 64 69 66 69 65 64 2f 67 c tcl-modified/g
1c50: 65 6e 65 72 69 63 2f 74 63 6c 4e 61 6d 65 73 70 eneric/tclNamesp
1c60: 2e 63 0a 36 31 32 39 61 36 31 33 30 2c 36 31 36 .c.6129a6130,616
1c70: 32 0a 3e 20 20 2a 20 20 20 20 20 20 54 68 65 20 2.> * The
1c80: 65 6e 73 65 6d 62 6c 65 20 6e 61 6d 65 20 6d 61 ensemble name ma
1c90: 79 20 62 65 20 61 20 74 6f 70 2d 6c 65 76 65 6c y be a top-level
1ca0: 20 63 6f 6d 6d 61 6e 64 2c 20 6c 69 6b 65 20 22 command, like "
1cb0: 62 69 6e 61 72 79 22 2e 0a 3e 20 20 2a 0a 3e 20 binary"..> *.>
1cc0: 20 2a 20 20 20 20 20 20 20 20 54 6f 70 2d 6c 65 * Top-le
1cd0: 76 65 6c 20 63 6f 6d 6d 61 6e 64 73 20 61 72 65 vel commands are
1ce0: 20 70 6c 61 63 65 64 20 69 6e 20 74 68 65 20 67 placed in the g
1cf0: 6c 6f 62 61 6c 20 6e 61 6d 65 73 70 61 63 65 20 lobal namespace
1d00: 61 6e 64 20 74 68 65 0a 3e 20 20 2a 20 20 20 20 and the.> *
1d10: 20 20 20 20 65 6e 73 65 6d 62 6c 65 20 73 75 62 ensemble sub
1d20: 2d 63 6f 6d 6d 61 6e 64 20 70 72 6f 63 65 64 75 -command procedu
1d30: 72 65 73 20 61 72 65 20 70 6c 61 63 65 64 20 69 res are placed i
1d40: 6e 20 74 68 65 20 3a 3a 74 63 6c 3a 3a 24 6e 61 n the ::tcl::$na
1d50: 6d 65 0a 3e 20 20 2a 20 20 20 20 20 20 20 20 6e me.> * n
1d60: 61 6d 65 73 70 61 63 65 2e 20 46 6f 72 20 74 68 amespace. For th
1d70: 65 20 27 62 69 6e 61 72 79 27 20 63 6f 6d 6d 61 e 'binary' comma
1d80: 6e 64 20 61 6e 64 20 69 74 73 20 27 66 6f 72 6d nd and its 'form
1d90: 61 74 27 2c 20 27 73 63 61 6e 27 2c 20 65 74 63 at', 'scan', etc
1da0: 0a 3e 20 20 2a 20 20 20 20 20 20 20 20 73 75 62 .> * sub
1db0: 2d 63 6f 6d 6d 61 6e 64 73 2c 20 74 68 65 20 66 -commands, the f
1dc0: 6f 6c 6c 6f 77 69 6e 67 20 63 6f 6d 6d 61 6e 64 ollowing command
1dd0: 73 20 61 72 65 20 63 72 65 61 74 65 64 3a 0a 3e s are created:.>
1de0: 20 20 2a 20 20 20 20 20 20 20 20 20 20 3a 3a 62 * ::b
1df0: 69 6e 61 72 79 0a 3e 20 20 2a 20 20 20 20 20 20 inary.> *
1e00: 20 20 20 20 3a 3a 74 63 6c 3a 3a 62 69 6e 61 72 ::tcl::binar
1e10: 79 3a 3a 66 6f 72 6d 61 74 0a 3e 20 20 2a 20 20 y::format.> *
1e20: 20 20 20 20 20 20 20 20 3a 3a 74 63 6c 3a 3a 62 ::tcl::b
1e30: 69 6e 61 72 79 3a 3a 73 63 61 6e 0a 3e 20 20 2a inary::scan.> *
1e40: 20 20 20 20 20 20 20 20 20 20 3a 3a 74 63 6c 3a ::tcl:
1e50: 3a 62 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 0a :binary::encode.
1e60: 3e 20 20 2a 20 20 20 20 20 20 20 20 20 20 3a 3a > * ::
1e70: 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a 64 65 63 tcl::binary::dec
1e80: 6f 64 65 0a 3e 20 20 2a 0a 3e 20 20 2a 20 20 20 ode.> *.> *
1e90: 20 20 20 54 68 65 20 65 6e 73 65 6d 62 6c 65 20 The ensemble
1ea0: 6e 61 6d 65 20 6d 61 79 20 62 65 20 61 20 6e 65 name may be a ne
1eb0: 73 74 65 64 20 65 6e 73 65 6d 62 6c 65 20 63 6f sted ensemble co
1ec0: 6d 6d 61 6e 64 2c 20 6c 69 6b 65 0a 3e 20 20 2a mmand, like.> *
1ed0: 20 20 20 20 20 20 22 62 69 6e 61 72 79 20 65 6e "binary en
1ee0: 63 6f 64 65 22 2e 0a 3e 20 20 2a 0a 3e 20 20 2a code"..> *.> *
1ef0: 20 20 20 20 20 20 20 20 4e 65 73 74 65 64 20 63 Nested c
1f00: 6f 6d 6d 61 6e 64 73 20 61 72 65 20 70 6c 61 63 ommands are plac
1f10: 65 64 20 69 6e 20 74 68 65 69 72 20 70 72 6f 70 ed in their prop
1f20: 65 72 20 6e 65 73 74 65 64 2d 6e 61 6d 65 73 70 er nested-namesp
1f30: 61 63 65 0a 3e 20 20 2a 20 20 20 20 20 20 20 20 ace.> *
1f40: 70 6c 61 63 65 73 20 28 77 68 65 72 65 20 74 68 places (where th
1f50: 65 79 20 62 65 6c 6f 6e 67 29 2e 20 46 6f 72 20 ey belong). For
1f60: 65 78 61 6d 70 6c 65 2c 20 74 68 65 20 27 62 69 example, the 'bi
1f70: 6e 61 72 79 20 65 6e 63 6f 64 65 27 0a 3e 20 20 nary encode'.>
1f80: 2a 20 20 20 20 20 20 20 20 6e 65 73 74 65 64 20 * nested
1f90: 65 6e 73 65 6d 62 6c 65 20 63 6f 6d 6d 61 6e 64 ensemble command
1fa0: 20 61 6e 64 20 69 74 73 20 27 68 65 78 27 2c 20 and its 'hex',
1fb0: 27 75 75 65 6e 63 6f 64 65 27 2c 20 61 6e 64 20 'uuencode', and
1fc0: 27 62 61 73 65 36 34 27 0a 3e 20 20 2a 20 20 20 'base64'.> *
1fd0: 20 20 20 20 20 73 75 62 2d 63 6f 6d 6d 61 6e 64 sub-command
1fe0: 73 20 6e 61 6d 65 73 20 61 72 65 3a 0a 3e 20 20 s names are:.>
1ff0: 2a 20 20 20 20 20 20 20 20 20 20 3a 3a 74 63 6c * ::tcl
2000: 3a 3a 62 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 ::binary::encode
2010: 0a 3e 20 20 2a 20 20 20 20 20 20 20 20 20 20 3a .> * :
2020: 3a 74 63 6c 3a 3a 62 69 6e 61 72 79 3a 3a 65 6e :tcl::binary::en
2030: 63 6f 64 65 3a 3a 68 65 78 0a 3e 20 20 2a 20 20 code::hex.> *
2040: 20 20 20 20 20 20 20 20 3a 3a 74 63 6c 3a 3a 62 ::tcl::b
2050: 69 6e 61 72 79 3a 3a 65 6e 63 6f 64 65 3a 3a 75 inary::encode::u
2060: 75 65 6e 63 6f 64 65 0a 3e 20 20 2a 20 20 20 20 uencode.> *
2070: 20 20 20 20 20 20 3a 3a 74 63 6c 3a 3a 62 69 6e ::tcl::bin
2080: 61 72 79 3a 3a 65 6e 63 6f 64 65 3a 3a 62 61 73 ary::encode::bas
2090: 65 36 34 0a 3e 20 20 2a 0a 3e 20 20 2a 20 41 64 e64.> *.> * Ad
20a0: 64 69 74 69 6f 6e 61 6c 20 6e 6f 74 65 73 3a 0a ditional notes:.
20b0: 3e 20 20 2a 20 20 20 20 20 20 43 75 72 72 65 6e > * Curren
20c0: 74 6c 79 2c 20 74 68 65 20 54 43 4c 5f 45 4e 53 tly, the TCL_ENS
20d0: 45 4d 42 4c 45 5f 50 52 45 46 49 58 20 65 6e 73 EMBLE_PREFIX ens
20e0: 65 6d 62 6c 65 20 66 6c 61 67 20 69 73 20 6f 6e emble flag is on
20f0: 6c 79 20 75 73 65 64 20 6f 6e 0a 3e 20 20 2a 20 ly used on.> *
2100: 20 20 20 20 20 74 6f 70 2d 6c 65 76 65 6c 20 65 top-level e
2110: 6e 73 65 6d 62 6c 65 20 63 6f 6d 6d 61 6e 64 73 nsemble commands
2120: 2e 20 54 68 61 74 20 69 73 20 74 68 65 20 77 61 . That is the wa
2130: 79 20 74 68 65 20 27 62 69 6e 61 72 79 27 20 63 y the 'binary' c
2140: 6f 6d 6d 61 6e 64 0a 3e 20 20 2a 20 20 20 20 20 ommand.> *
2150: 20 77 61 73 20 6f 72 69 67 69 6e 61 6c 6c 79 20 was originally
2160: 65 6e 63 6f 64 65 64 2e 2e 2e 0a 3e 20 20 2a 0a encoded....> *.
2170: 3e 20 20 2a 20 20 20 20 20 20 54 68 65 20 45 6e > * The En
2180: 73 65 6d 62 6c 65 49 6d 70 6c 4d 61 70 20 63 75 sembleImplMap cu
2190: 72 72 65 6e 74 6c 79 20 68 61 73 20 74 68 65 20 rrently has the
21a0: 54 63 6c 5f 43 6d 64 44 65 6c 65 74 65 50 72 6f Tcl_CmdDeletePro
21b0: 63 20 69 74 65 6d 0a 3e 20 20 2a 20 20 20 20 20 c item.> *
21c0: 20 63 6f 6d 6d 65 6e 74 65 64 2d 6f 75 74 20 2d commented-out -
21d0: 2d 49 20 64 6f 6e 27 74 20 74 68 69 6e 6b 20 69 -I don't think i
21e0: 74 20 69 73 20 65 76 65 72 20 75 73 65 64 20 69 t is ever used i
21f0: 6e 20 63 6f 72 65 20 63 6f 6d 6d 61 6e 64 73 2e n core commands.
2200: 20 48 65 6e 63 65 2c 0a 3e 20 20 2a 20 20 20 20 Hence,.> *
2210: 20 20 69 74 20 69 73 20 63 6f 6d 6d 65 6e 74 65 it is commente
2220: 64 20 6f 75 74 20 62 65 6c 6f 77 20 61 73 20 77 d out below as w
2230: 65 6c 6c 2e 2e 2e 20 0a 3e 20 20 2a 0a 36 31 33 ell... .> *.613
2240: 31 63 36 31 36 34 0a 3c 20 20 2a 09 48 61 6e 64 1c6164.< *.Hand
2250: 6c 65 20 66 6f 72 20 74 68 65 20 65 6e 73 65 6d le for the ensem
2260: 62 6c 65 2c 20 6f 72 20 4e 55 4c 4c 20 69 66 20 ble, or NULL if
2270: 63 72 65 61 74 69 6f 6e 20 6f 66 20 69 74 20 66 creation of it f
2280: 61 69 6c 73 2e 0a 2d 2d 2d 0a 3e 20 20 2a 09 48 ails..---.> *.H
2290: 61 6e 64 6c 65 20 66 6f 72 20 74 68 65 20 6e 65 andle for the ne
22a0: 77 20 65 6e 73 65 6d 62 6c 65 2c 20 6f 72 20 4e w ensemble, or N
22b0: 55 4c 4c 20 6f 6e 20 66 61 69 6c 75 72 65 2e 0a ULL on failure..
22c0: 36 31 33 34 63 36 31 36 37 0a 3c 20 20 2a 09 4d 6134c6167.< *.M
22d0: 61 79 20 61 64 76 61 6e 63 65 20 62 79 74 65 63 ay advance bytec
22e0: 6f 64 65 20 63 6f 6d 70 69 6c 61 74 69 6f 6e 20 ode compilation
22f0: 65 70 6f 63 68 2e 0a 2d 2d 2d 0a 3e 20 20 2a 09 epoch..---.> *.
2300: 4d 61 79 20 61 64 76 61 6e 63 65 20 74 68 65 20 May advance the
2310: 62 79 74 65 63 6f 64 65 20 63 6f 6d 70 69 6c 61 bytecode compila
2320: 74 69 6f 6e 20 65 70 6f 63 68 2e 0a 36 31 34 31 tion epoch..6141
2330: 2c 36 31 34 33 63 36 31 37 34 2c 36 31 37 36 0a ,6143c6174,6176.
2340: 3c 20 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 < Tcl_Interp
2350: 20 2a 69 6e 74 65 72 70 2c 0a 3c 20 20 20 20 20 *interp,.<
2360: 63 6f 6e 73 74 20 63 68 61 72 20 2a 6e 61 6d 65 const char *name
2370: 2c 0a 3c 20 20 20 20 20 63 6f 6e 73 74 20 45 6e ,.< const En
2380: 73 65 6d 62 6c 65 49 6d 70 6c 4d 61 70 20 6d 61 sembleImplMap ma
2390: 70 5b 5d 29 0a 2d 2d 2d 0a 3e 20 20 20 20 20 54 p[]).---.> T
23a0: 63 6c 5f 49 6e 74 65 72 70 20 20 20 20 20 20 20 cl_Interp
23b0: 20 20 20 20 2a 69 6e 74 65 72 70 2c 0a 3e 20 20 *interp,.>
23c0: 20 20 20 63 6f 6e 73 74 20 63 68 61 72 20 20 20 const char
23d0: 20 20 20 20 20 20 20 20 2a 6e 61 6d 65 2c 20 20 *name,
23e0: 20 2f 2a 20 54 68 65 20 65 6e 73 65 6d 62 6c 65 /* The ensemble
23f0: 20 6e 61 6d 65 20 28 61 73 20 65 78 70 6c 61 69 name (as explai
2400: 6e 65 64 20 61 62 6f 76 65 29 20 2a 2f 0a 3e 20 ned above) */.>
2410: 20 20 20 20 63 6f 6e 73 74 20 45 6e 73 65 6d 62 const Ensemb
2420: 6c 65 49 6d 70 6c 4d 61 70 20 6d 61 70 5b 5d 29 leImplMap map[])
2430: 20 20 2f 2a 20 54 68 65 20 73 75 62 63 6f 6d 6d /* The subcomm
2440: 61 6e 64 73 20 74 6f 20 63 72 65 61 74 65 20 2a ands to create *
2450: 2f 0a 36 31 34 35 2c 36 31 35 32 63 36 31 37 38 /.6145,6152c6178
2460: 2c 36 32 31 33 0a 3c 20 20 20 20 20 54 63 6c 5f ,6213.< Tcl_
2470: 43 6f 6d 6d 61 6e 64 20 65 6e 73 65 6d 62 6c 65 Command ensemble
2480: 3b 09 2f 2a 20 54 68 65 20 6f 76 65 72 61 6c 6c ;./* The overall
2490: 20 65 6e 73 65 6d 62 6c 65 2e 20 2a 2f 0a 3c 20 ensemble. */.<
24a0: 20 20 20 20 54 63 6c 5f 4e 61 6d 65 73 70 61 63 Tcl_Namespac
24b0: 65 20 2a 74 63 6c 4e 73 50 74 72 3b 09 2f 2a 20 e *tclNsPtr;./*
24c0: 52 65 66 65 72 65 6e 63 65 20 74 6f 20 74 68 65 Reference to the
24d0: 20 22 3a 3a 74 63 6c 22 20 6e 61 6d 65 73 70 61 "::tcl" namespa
24e0: 63 65 2e 20 2a 2f 0a 3c 20 20 20 20 20 54 63 6c ce. */.< Tcl
24f0: 5f 44 53 74 72 69 6e 67 20 62 75 66 3b 0a 3c 20 _DString buf;.<
2500: 0a 3c 20 20 20 20 20 74 63 6c 4e 73 50 74 72 20 .< tclNsPtr
2510: 3d 20 54 63 6c 5f 46 69 6e 64 4e 61 6d 65 73 70 = Tcl_FindNamesp
2520: 61 63 65 28 69 6e 74 65 72 70 2c 20 22 3a 3a 74 ace(interp, "::t
2530: 63 6c 22 2c 20 4e 55 4c 4c 2c 0a 3c 20 09 20 20 cl", NULL,.< .
2540: 20 20 54 43 4c 5f 43 52 45 41 54 45 5f 4e 53 5f TCL_CREATE_NS_
2550: 49 46 5f 55 4e 4b 4e 4f 57 4e 29 3b 0a 3c 20 20 IF_UNKNOWN);.<
2560: 20 20 20 69 66 20 28 74 63 6c 4e 73 50 74 72 20 if (tclNsPtr
2570: 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 3c 20 09 54 63 == NULL) {.< .Tc
2580: 6c 5f 50 61 6e 69 63 28 22 75 6e 61 62 6c 65 20 l_Panic("unable
2590: 74 6f 20 66 69 6e 64 20 6f 72 20 63 72 65 61 74 to find or creat
25a0: 65 20 3a 3a 74 63 6c 20 6e 61 6d 65 73 70 61 63 e ::tcl namespac
25b0: 65 21 22 29 3b 0a 2d 2d 2d 0a 3e 20 20 20 20 20 e!");.---.>
25c0: 54 63 6c 5f 43 6f 6d 6d 61 6e 64 20 20 20 20 65 Tcl_Command e
25d0: 6e 73 65 6d 62 6c 65 3b 20 20 20 20 20 20 2f 2a nsemble; /*
25e0: 20 54 68 65 20 66 75 6e 63 74 69 6f 6e 20 72 65 The function re
25f0: 73 75 6c 74 20 2a 2f 0a 3e 20 20 20 20 20 54 63 sult */.> Tc
2600: 6c 5f 4e 61 6d 65 73 70 61 63 65 20 2a 6e 73 3b l_Namespace *ns;
2610: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e /* N
2620: 65 77 2f 73 75 62 2d 63 6f 6d 6d 61 6e 64 20 70 ew/sub-command p
2630: 61 72 65 6e 74 20 6e 61 6d 65 73 70 61 63 65 20 arent namespace
2640: 2a 2f 0a 3e 20 20 20 20 20 54 63 6c 5f 4f 62 6a */.> Tcl_Obj
2650: 20 20 20 20 20 20 20 2a 6e 73 4e 61 6d 65 4f 62 *nsNameOb
2660: 6a 3b 20 20 20 20 20 2f 2a 20 45 6e 73 65 6d 62 j; /* Ensemb
2670: 6c 65 20 6e 61 6d 65 73 70 61 63 65 20 61 6e 64 le namespace and
2680: 20 63 6d 64 20 6e 61 6d 65 20 70 72 65 66 69 78 cmd name prefix
2690: 20 2a 2f 0a 3e 20 20 20 20 20 63 6f 6e 73 74 20 */.> const
26a0: 63 68 61 72 20 20 20 20 2a 6e 73 4e 61 6d 65 3b char *nsName;
26b0: 20 20 20 20 20 20 20 20 2f 2a 20 3d 3d 20 54 63 /* == Tc
26c0: 6c 5f 47 65 74 53 74 72 69 6e 67 28 20 6e 73 4e l_GetString( nsN
26d0: 61 6d 65 4f 62 6a 20 29 20 2a 2f 0a 3e 20 20 20 ameObj ) */.>
26e0: 20 20 63 6f 6e 73 74 20 63 68 61 72 20 20 20 20 const char
26f0: 2a 63 75 72 72 4e 61 6d 65 3b 20 20 20 20 20 20 *currName;
2700: 2f 2a 20 75 73 65 64 20 74 6f 20 6d 61 6e 69 70 /* used to manip
2710: 75 6c 61 74 65 20 74 68 65 20 66 75 6c 6c 20 6e ulate the full n
2720: 73 20 6e 61 6d 65 20 2a 2f 0a 3e 20 20 20 20 20 s name */.>
2730: 63 6f 6e 73 74 20 63 68 61 72 20 20 20 20 2a 6e const char *n
2740: 65 78 74 4e 61 6d 65 3b 20 20 20 20 20 20 2f 2a extName; /*
2750: 20 64 69 74 74 6f 20 2a 2f 0a 3e 20 20 20 20 20 ditto */.>
2760: 69 6e 74 20 20 20 20 20 20 20 20 20 20 20 20 6c int l
2770: 65 6e 67 74 68 3b 20 20 20 20 20 20 20 20 2f 2a ength; /*
2780: 20 64 69 74 74 6f 20 2a 2f 0a 3e 20 20 20 20 20 ditto */.>
2790: 69 6e 74 20 20 20 20 20 20 20 20 20 20 20 20 6e int n
27a0: 61 6d 65 43 6f 75 6e 74 3b 20 20 20 20 20 2f 2a ameCount; /*
27b0: 20 6e 20 3d 3d 20 31 3a 20 74 6f 70 2d 6c 65 76 n == 1: top-lev
27c0: 65 6c 3b 20 6e 20 3e 20 31 3a 20 6e 65 73 74 65 el; n > 1: neste
27d0: 64 20 63 6d 64 20 2a 2f 0a 3e 20 20 20 20 20 69 d cmd */.> i
27e0: 6e 74 20 20 20 20 20 20 20 20 20 20 20 20 65 6e nt en
27f0: 73 65 6d 62 6c 65 46 6c 61 67 73 20 3d 20 30 3b sembleFlags = 0;
2800: 20 20 2f 2a 20 53 65 65 20 6e 6f 74 65 73 20 61 /* See notes a
2810: 62 6f 76 65 3b 20 63 6f 6d 70 69 6c 65 20 66 6c bove; compile fl
2820: 61 67 20 2a 2f 0a 3e 20 0a 3e 20 20 20 20 20 2f ag */.> .> /
2830: 2a 20 53 6f 6d 65 20 76 61 6c 69 64 61 74 69 6f * Some validatio
2840: 6e 20 61 67 61 69 6e 73 74 20 65 6d 70 74 79 20 n against empty
2850: 6e 61 6d 65 73 20 2a 2f 0a 3e 20 20 20 20 20 69 names */.> i
2860: 66 20 28 21 6e 61 6d 65 20 7c 7c 20 21 6e 61 6d f (!name || !nam
2870: 65 5b 30 5d 20 7c 7c 20 73 74 72 73 70 6e 28 20 e[0] || strspn(
2880: 6e 61 6d 65 2c 20 22 20 5c 74 22 20 29 20 3d 3d name, " \t" ) ==
2890: 20 73 74 72 6c 65 6e 28 20 6e 61 6d 65 20 29 29 strlen( name ))
28a0: 20 7b 0a 3e 20 20 20 20 20 20 20 20 20 54 63 6c {.> Tcl
28b0: 5f 50 61 6e 69 63 28 20 22 54 63 6c 4d 61 6b 65 _Panic( "TclMake
28c0: 45 6e 73 65 6d 62 6c 65 3a 20 27 6e 61 6d 65 27 Ensemble: 'name'
28d0: 20 61 72 67 75 6d 65 6e 74 20 6e 6f 74 20 73 70 argument not sp
28e0: 65 63 69 66 69 65 64 21 22 20 29 3b 0a 3e 20 20 ecified!" );.>
28f0: 20 20 20 7d 0a 3e 20 0a 3e 20 20 20 20 20 2f 2a }.> .> /*
2900: 20 43 6f 6c 6c 65 63 74 20 74 68 65 20 61 72 67 Collect the arg
2910: 75 6d 65 6e 74 20 65 6e 73 65 6d 62 6c 65 20 63 ument ensemble c
2920: 6f 6d 6d 61 6e 64 20 69 6e 74 6f 20 61 20 63 6f ommand into a co
2930: 6d 70 6c 65 74 65 20 6e 61 6d 65 73 70 61 63 65 mplete namespace
2940: 20 6e 61 6d 65 2e 20 2a 2f 0a 3e 20 20 20 20 20 name. */.>
2950: 6e 73 4e 61 6d 65 4f 62 6a 20 3d 20 54 63 6c 5f nsNameObj = Tcl_
2960: 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 20 22 3a NewStringObj( ":
2970: 3a 74 63 6c 22 2c 20 35 20 29 3b 0a 3e 20 20 20 :tcl", 5 );.>
2980: 20 20 54 63 6c 5f 49 6e 63 72 52 65 66 43 6f 75 Tcl_IncrRefCou
2990: 6e 74 28 20 6e 73 4e 61 6d 65 4f 62 6a 20 29 3b nt( nsNameObj );
29a0: 0a 3e 20 20 20 20 20 6e 65 78 74 4e 61 6d 65 20 .> nextName
29b0: 3d 20 6e 61 6d 65 3b 0a 3e 20 20 20 20 20 6e 61 = name;.> na
29c0: 6d 65 43 6f 75 6e 74 20 3d 20 30 3b 0a 3e 20 20 meCount = 0;.>
29d0: 20 20 20 64 6f 20 7b 0a 3e 20 20 20 20 20 20 20 do {.>
29e0: 20 20 6e 61 6d 65 43 6f 75 6e 74 2b 2b 3b 0a 3e nameCount++;.>
29f0: 20 20 20 20 20 20 20 20 20 63 75 72 72 4e 61 6d currNam
2a00: 65 20 3d 20 6e 65 78 74 4e 61 6d 65 20 2b 73 74 e = nextName +st
2a10: 72 73 70 6e 28 20 6e 65 78 74 4e 61 6d 65 2c 20 rspn( nextName,
2a20: 22 20 5c 74 22 20 29 3b 0a 3e 20 20 20 20 20 20 " \t" );.>
2a30: 20 20 20 6e 65 78 74 4e 61 6d 65 20 3d 20 73 74 nextName = st
2a40: 72 70 62 72 6b 28 20 20 20 20 20 20 20 20 20 20 rpbrk(
2a50: 63 75 72 72 4e 61 6d 65 2c 20 22 20 5c 74 22 20 currName, " \t"
2a60: 29 3b 0a 3e 20 20 20 20 20 20 20 20 20 6c 65 6e );.> len
2a70: 67 74 68 20 20 20 3d 20 28 6e 65 78 74 4e 61 6d gth = (nextNam
2a80: 65 20 3d 3d 20 4e 55 4c 4c 29 20 3f 20 2d 31 20 e == NULL) ? -1
2a90: 3a 20 28 6e 65 78 74 4e 61 6d 65 20 2d 20 63 75 : (nextName - cu
2aa0: 72 72 4e 61 6d 65 29 3b 0a 3e 20 0a 3e 20 20 20 rrName);.> .>
2ab0: 20 20 20 20 20 20 54 63 6c 5f 41 70 70 65 6e 64 Tcl_Append
2ac0: 54 6f 4f 62 6a 28 20 6e 73 4e 61 6d 65 4f 62 6a ToObj( nsNameObj
2ad0: 2c 20 22 3a 3a 22 2c 20 32 20 29 3b 0a 3e 20 20 , "::", 2 );.>
2ae0: 20 20 20 20 20 20 20 54 63 6c 5f 41 70 70 65 6e Tcl_Appen
2af0: 64 54 6f 4f 62 6a 28 20 6e 73 4e 61 6d 65 4f 62 dToObj( nsNameOb
2b00: 6a 2c 20 63 75 72 72 4e 61 6d 65 2c 20 6c 65 6e j, currName, len
2b10: 67 74 68 20 29 3b 0a 3e 20 0a 3e 20 20 20 20 20 gth );.> .>
2b20: 7d 20 77 68 69 6c 65 20 28 6e 65 78 74 4e 61 6d } while (nextNam
2b30: 65 29 3b 0a 3e 20 20 20 20 20 6e 73 4e 61 6d 65 e);.> nsName
2b40: 20 3d 20 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 = Tcl_GetString
2b50: 28 20 6e 73 4e 61 6d 65 4f 62 6a 20 29 3b 0a 3e ( nsNameObj );.>
2b60: 20 0a 3e 20 20 20 20 20 2f 2a 20 43 72 65 61 74 .> /* Creat
2b70: 65 20 74 68 65 20 65 6e 73 65 6d 62 6c 65 27 73 e the ensemble's
2b80: 20 6e 61 6d 65 73 70 61 63 65 20 2a 2f 0a 3e 20 namespace */.>
2b90: 20 20 20 20 6e 73 20 3d 20 54 63 6c 5f 46 69 6e ns = Tcl_Fin
2ba0: 64 4e 61 6d 65 73 70 61 63 65 28 20 69 6e 74 65 dNamespace( inte
2bb0: 72 70 2c 20 6e 73 4e 61 6d 65 2c 20 4e 55 4c 4c rp, nsName, NULL
2bc0: 2c 20 54 43 4c 5f 43 52 45 41 54 45 5f 4e 53 5f , TCL_CREATE_NS_
2bd0: 49 46 5f 55 4e 4b 4e 4f 57 4e 20 29 3b 0a 3e 20 IF_UNKNOWN );.>
2be0: 20 20 20 20 69 66 20 28 21 6e 73 29 20 7b 0a 3e if (!ns) {.>
2bf0: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 50 61 6e Tcl_Pan
2c00: 69 63 28 20 22 75 6e 61 62 6c 65 20 74 6f 20 66 ic( "unable to f
2c10: 69 6e 64 20 6f 72 20 63 72 65 61 74 65 20 25 73 ind or create %s
2c20: 20 6e 61 6d 65 73 70 61 63 65 21 22 2c 20 6e 73 namespace!", ns
2c30: 4e 61 6d 65 20 29 3b 0a 36 31 35 34 2c 36 31 36 Name );.6154,616
2c40: 31 63 36 32 31 35 2c 36 32 32 32 0a 3c 20 20 20 1c6215,6222.<
2c50: 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 49 6e 69 Tcl_DStringIni
2c60: 74 28 26 62 75 66 29 3b 0a 3c 20 20 20 20 20 54 t(&buf);.< T
2c70: 63 6c 5f 44 53 74 72 69 6e 67 41 70 70 65 6e 64 cl_DStringAppend
2c80: 28 26 62 75 66 2c 20 22 3a 3a 74 63 6c 3a 3a 22 (&buf, "::tcl::"
2c90: 2c 20 2d 31 29 3b 0a 3c 20 20 20 20 20 54 63 6c , -1);.< Tcl
2ca0: 5f 44 53 74 72 69 6e 67 41 70 70 65 6e 64 28 26 _DStringAppend(&
2cb0: 62 75 66 2c 20 6e 61 6d 65 2c 20 2d 31 29 3b 0a buf, name, -1);.
2cc0: 3c 20 20 20 20 20 74 63 6c 4e 73 50 74 72 20 3d < tclNsPtr =
2cd0: 20 54 63 6c 5f 46 69 6e 64 4e 61 6d 65 73 70 61 Tcl_FindNamespa
2ce0: 63 65 28 69 6e 74 65 72 70 2c 20 54 63 6c 5f 44 ce(interp, Tcl_D
2cf0: 53 74 72 69 6e 67 56 61 6c 75 65 28 26 62 75 66 StringValue(&buf
2d00: 29 2c 20 4e 55 4c 4c 2c 0a 3c 20 09 20 20 20 20 ), NULL,.< .
2d10: 54 43 4c 5f 43 52 45 41 54 45 5f 4e 53 5f 49 46 TCL_CREATE_NS_IF
2d20: 5f 55 4e 4b 4e 4f 57 4e 29 3b 0a 3c 20 20 20 20 _UNKNOWN);.<
2d30: 20 69 66 20 28 74 63 6c 4e 73 50 74 72 20 3d 3d if (tclNsPtr ==
2d40: 20 4e 55 4c 4c 29 20 7b 0a 3c 20 09 54 63 6c 5f NULL) {.< .Tcl_
2d50: 50 61 6e 69 63 28 22 75 6e 61 62 6c 65 20 74 6f Panic("unable to
2d60: 20 66 69 6e 64 20 6f 72 20 63 72 65 61 74 65 20 find or create
2d70: 25 73 20 6e 61 6d 65 73 70 61 63 65 21 22 2c 0a %s namespace!",.
2d80: 3c 20 09 09 54 63 6c 5f 44 53 74 72 69 6e 67 56 < ..Tcl_DStringV
2d90: 61 6c 75 65 28 26 62 75 66 29 29 3b 0a 2d 2d 2d alue(&buf));.---
2da0: 0a 3e 20 0a 3e 20 20 20 20 20 2f 2a 20 43 72 65 .> .> /* Cre
2db0: 61 74 65 20 74 68 65 20 65 6e 73 65 6d 62 6c 65 ate the ensemble
2dc0: 20 69 74 73 65 6c 66 20 69 6e 20 74 68 65 20 63 itself in the c
2dd0: 6f 72 72 65 63 74 20 6e 61 6d 65 73 70 61 63 65 orrect namespace
2de0: 20 2a 2f 0a 3e 20 20 20 20 20 63 75 72 72 4e 61 */.> currNa
2df0: 6d 65 20 3d 20 6e 73 4e 61 6d 65 20 2b 20 73 74 me = nsName + st
2e00: 72 6c 65 6e 28 20 6e 73 4e 61 6d 65 20 29 20 2d rlen( nsName ) -
2e10: 20 73 74 72 6c 65 6e 28 20 63 75 72 72 4e 61 6d strlen( currNam
2e20: 65 20 29 3b 0a 3e 20 20 20 20 20 69 66 20 28 6e e );.> if (n
2e30: 61 6d 65 43 6f 75 6e 74 20 3d 3d 20 31 29 20 7b ameCount == 1) {
2e40: 0a 3e 20 20 20 20 20 20 20 20 20 65 6e 73 65 6d .> ensem
2e50: 62 6c 65 46 6c 61 67 73 20 3d 20 54 43 4c 5f 45 bleFlags = TCL_E
2e60: 4e 53 45 4d 42 4c 45 5f 50 52 45 46 49 58 3b 0a NSEMBLE_PREFIX;.
2e70: 3e 20 20 20 20 20 20 20 20 20 63 75 72 72 4e 61 > currNa
2e80: 6d 65 20 2d 3d 20 32 3b 0a 3e 20 20 20 20 20 7d me -= 2;.> }
2e90: 20 65 6c 73 65 20 7b 0a 3e 20 20 20 20 20 20 20 else {.>
2ea0: 20 20 6e 73 20 3d 20 6e 73 2d 3e 70 61 72 65 6e ns = ns->paren
2eb0: 74 50 74 72 3b 0a 36 31 36 33 2c 36 31 39 30 63 tPtr;.6163,6190c
2ec0: 36 32 32 34 2c 36 32 36 36 0a 3c 20 20 20 20 20 6224,6266.<
2ed0: 65 6e 73 65 6d 62 6c 65 20 3d 20 54 63 6c 5f 43 ensemble = Tcl_C
2ee0: 72 65 61 74 65 45 6e 73 65 6d 62 6c 65 28 69 6e reateEnsemble(in
2ef0: 74 65 72 70 2c 20 54 63 6c 5f 44 53 74 72 69 6e terp, Tcl_DStrin
2f00: 67 56 61 6c 75 65 28 26 62 75 66 29 2b 35 2c 20 gValue(&buf)+5,
2f10: 74 63 6c 4e 73 50 74 72 2c 0a 3c 20 09 20 20 20 tclNsPtr,.< .
2f20: 20 54 43 4c 5f 45 4e 53 45 4d 42 4c 45 5f 50 52 TCL_ENSEMBLE_PR
2f30: 45 46 49 58 29 3b 0a 3c 20 20 20 20 20 54 63 6c EFIX);.< Tcl
2f40: 5f 44 53 74 72 69 6e 67 41 70 70 65 6e 64 28 26 _DStringAppend(&
2f50: 62 75 66 2c 20 22 3a 3a 22 2c 20 2d 31 29 3b 0a buf, "::", -1);.
2f60: 3c 20 20 20 20 20 69 66 20 28 65 6e 73 65 6d 62 < if (ensemb
2f70: 6c 65 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 3c 20 le != NULL) {.<
2f80: 09 54 63 6c 5f 4f 62 6a 20 2a 6d 61 70 44 69 63 .Tcl_Obj *mapDic
2f90: 74 3b 0a 3c 20 09 69 6e 74 20 69 2c 20 63 6f 6d t;.< .int i, com
2fa0: 70 69 6c 65 20 3d 20 30 3b 0a 3c 20 0a 3c 20 09 pile = 0;.< .< .
2fb0: 54 63 6c 4e 65 77 4f 62 6a 28 6d 61 70 44 69 63 TclNewObj(mapDic
2fc0: 74 29 3b 0a 3c 20 09 66 6f 72 20 28 69 3d 30 20 t);.< .for (i=0
2fd0: 3b 20 6d 61 70 5b 69 5d 2e 6e 61 6d 65 20 21 3d ; map[i].name !=
2fe0: 20 4e 55 4c 4c 20 3b 20 69 2b 2b 29 20 7b 0a 3c NULL ; i++) {.<
2ff0: 20 09 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 66 . Tcl_Obj *f
3000: 72 6f 6d 4f 62 6a 2c 20 2a 74 6f 4f 62 6a 3b 0a romObj, *toObj;.
3010: 3c 20 09 20 20 20 20 72 65 67 69 73 74 65 72 20 < . register
3020: 43 6f 6d 6d 61 6e 64 20 2a 63 6d 64 50 74 72 3b Command *cmdPtr;
3030: 0a 3c 20 0a 3c 20 09 20 20 20 20 66 72 6f 6d 4f .< .< . fromO
3040: 62 6a 20 3d 20 54 63 6c 5f 4e 65 77 53 74 72 69 bj = Tcl_NewStri
3050: 6e 67 4f 62 6a 28 6d 61 70 5b 69 5d 2e 6e 61 6d ngObj(map[i].nam
3060: 65 2c 20 2d 31 29 3b 0a 3c 20 09 20 20 20 20 54 e, -1);.< . T
3070: 63 6c 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 74 clNewStringObj(t
3080: 6f 4f 62 6a 2c 20 54 63 6c 5f 44 53 74 72 69 6e oObj, Tcl_DStrin
3090: 67 56 61 6c 75 65 28 26 62 75 66 29 2c 0a 3c 20 gValue(&buf),.<
30a0: 09 09 20 20 20 20 54 63 6c 5f 44 53 74 72 69 6e .. Tcl_DStrin
30b0: 67 4c 65 6e 67 74 68 28 26 62 75 66 29 29 3b 0a gLength(&buf));.
30c0: 3c 20 09 20 20 20 20 54 63 6c 5f 41 70 70 65 6e < . Tcl_Appen
30d0: 64 54 6f 4f 62 6a 28 74 6f 4f 62 6a 2c 20 6d 61 dToObj(toObj, ma
30e0: 70 5b 69 5d 2e 6e 61 6d 65 2c 20 2d 31 29 3b 0a p[i].name, -1);.
30f0: 3c 20 09 20 20 20 20 54 63 6c 5f 44 69 63 74 4f < . Tcl_DictO
3100: 62 6a 50 75 74 28 4e 55 4c 4c 2c 20 6d 61 70 44 bjPut(NULL, mapD
3110: 69 63 74 2c 20 66 72 6f 6d 4f 62 6a 2c 20 74 6f ict, fromObj, to
3120: 4f 62 6a 29 3b 0a 3c 20 09 20 20 20 20 63 6d 64 Obj);.< . cmd
3130: 50 74 72 20 3d 20 28 43 6f 6d 6d 61 6e 64 20 2a Ptr = (Command *
3140: 29 20 54 63 6c 5f 43 72 65 61 74 65 4f 62 6a 43 ) Tcl_CreateObjC
3150: 6f 6d 6d 61 6e 64 28 69 6e 74 65 72 70 2c 0a 3c ommand(interp,.<
3160: 20 09 09 20 20 20 20 54 63 6c 47 65 74 53 74 72 .. TclGetStr
3170: 69 6e 67 28 74 6f 4f 62 6a 29 2c 20 6d 61 70 5b ing(toObj), map[
3180: 69 5d 2e 70 72 6f 63 2c 20 4e 55 4c 4c 2c 20 4e i].proc, NULL, N
3190: 55 4c 4c 29 3b 0a 3c 20 09 20 20 20 20 63 6d 64 ULL);.< . cmd
31a0: 50 74 72 2d 3e 63 6f 6d 70 69 6c 65 50 72 6f 63 Ptr->compileProc
31b0: 20 3d 20 6d 61 70 5b 69 5d 2e 63 6f 6d 70 69 6c = map[i].compil
31c0: 65 50 72 6f 63 3b 0a 3c 20 09 20 20 20 20 63 6d eProc;.< . cm
31d0: 64 50 74 72 2d 3e 6e 72 65 50 72 6f 63 20 3d 20 dPtr->nreProc =
31e0: 6d 61 70 5b 69 5d 2e 6e 72 65 50 72 6f 63 3b 0a map[i].nreProc;.
31f0: 3c 20 09 20 20 20 20 63 6f 6d 70 69 6c 65 20 7c < . compile |
3200: 3d 20 28 6d 61 70 5b 69 5d 2e 63 6f 6d 70 69 6c = (map[i].compil
3210: 65 50 72 6f 63 20 21 3d 20 4e 55 4c 4c 29 3b 0a eProc != NULL);.
3220: 3c 20 09 7d 0a 3c 20 09 54 63 6c 5f 53 65 74 45 < .}.< .Tcl_SetE
3230: 6e 73 65 6d 62 6c 65 4d 61 70 70 69 6e 67 44 69 nsembleMappingDi
3240: 63 74 28 69 6e 74 65 72 70 2c 20 65 6e 73 65 6d ct(interp, ensem
3250: 62 6c 65 2c 20 6d 61 70 44 69 63 74 29 3b 0a 3c ble, mapDict);.<
3260: 20 09 69 66 20 28 63 6f 6d 70 69 6c 65 29 20 7b .if (compile) {
3270: 0a 3c 20 09 20 20 20 20 54 63 6c 5f 53 65 74 45 .< . Tcl_SetE
3280: 6e 73 65 6d 62 6c 65 46 6c 61 67 73 28 69 6e 74 nsembleFlags(int
3290: 65 72 70 2c 20 65 6e 73 65 6d 62 6c 65 2c 0a 3c erp, ensemble,.<
32a0: 20 09 09 20 20 20 20 54 43 4c 5f 45 4e 53 45 4d .. TCL_ENSEM
32b0: 42 4c 45 5f 50 52 45 46 49 58 20 7c 20 45 4e 53 BLE_PREFIX | ENS
32c0: 45 4d 42 4c 45 5f 43 4f 4d 50 49 4c 45 29 3b 0a EMBLE_COMPILE);.
32d0: 3c 20 09 7d 0a 2d 2d 2d 0a 3e 20 20 20 20 20 65 < .}.---.> e
32e0: 6e 73 65 6d 62 6c 65 20 3d 20 54 63 6c 5f 43 72 nsemble = Tcl_Cr
32f0: 65 61 74 65 45 6e 73 65 6d 62 6c 65 28 20 69 6e eateEnsemble( in
3300: 74 65 72 70 2c 20 63 75 72 72 4e 61 6d 65 2c 20 terp, currName,
3310: 6e 73 2c 20 65 6e 73 65 6d 62 6c 65 46 6c 61 67 ns, ensembleFlag
3320: 73 20 29 3b 0a 3e 20 0a 3e 20 20 20 20 20 2f 2a s );.> .> /*
3330: 0a 3e 20 20 20 20 20 20 2a 20 43 72 65 61 74 65 .> * Create
3340: 20 74 68 65 20 65 6e 73 65 6d 62 6c 65 20 6d 61 the ensemble ma
3350: 70 70 69 6e 67 20 64 69 63 74 69 6f 6e 61 72 79 pping dictionary
3360: 0a 3e 20 20 20 20 20 20 2a 20 43 72 65 61 74 65 .> * Create
3370: 20 74 68 65 20 65 6e 73 65 6d 62 6c 65 20 63 6f the ensemble co
3380: 6d 6d 61 6e 64 20 70 72 6f 63 73 0a 3e 20 20 20 mmand procs.>
3390: 20 20 20 2a 2f 0a 3e 20 20 20 20 20 69 66 20 28 */.> if (
33a0: 65 6e 73 65 6d 62 6c 65 29 20 7b 0a 3e 20 20 20 ensemble) {.>
33b0: 20 20 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 64 Tcl_Obj *d
33c0: 69 63 74 3b 0a 3e 20 20 20 20 20 20 20 20 20 69 ict;.> i
33d0: 6e 74 20 20 20 20 20 20 6e 3b 0a 3e 20 0a 3e 20 nt n;.> .>
33e0: 20 20 20 20 20 20 20 20 2f 2a 20 6e 73 4e 61 6d /* nsNam
33f0: 65 20 3a 3d 20 50 72 65 66 69 78 20 66 6f 72 20 e := Prefix for
3400: 61 6c 6c 20 63 6f 6d 6d 61 6e 64 20 6e 61 6d 65 all command name
3410: 73 20 2a 2f 0a 3e 20 20 20 20 20 20 20 20 20 54 s */.> T
3420: 63 6c 5f 41 70 70 65 6e 64 54 6f 4f 62 6a 28 20 cl_AppendToObj(
3430: 6e 73 4e 61 6d 65 4f 62 6a 2c 20 22 3a 3a 22 2c nsNameObj, "::",
3440: 20 32 20 29 3b 0a 3e 20 20 20 20 20 20 20 20 20 2 );.>
3450: 6e 73 4e 61 6d 65 20 3d 20 54 63 6c 5f 47 65 74 nsName = Tcl_Get
3460: 53 74 72 69 6e 67 28 20 6e 73 4e 61 6d 65 4f 62 String( nsNameOb
3470: 6a 20 29 3b 0a 3e 20 0a 3e 20 20 20 20 20 20 20 j );.> .>
3480: 20 20 64 69 63 74 20 3d 20 54 63 6c 5f 4e 65 77 dict = Tcl_New
3490: 44 69 63 74 4f 62 6a 28 29 3b 0a 3e 20 20 20 20 DictObj();.>
34a0: 20 20 20 20 20 66 6f 72 20 28 6e 20 3d 20 30 3b for (n = 0;
34b0: 20 6d 61 70 5b 6e 5d 2e 6e 61 6d 65 3b 20 6e 2b map[n].name; n+
34c0: 2b 29 20 7b 0a 3e 20 0a 3e 20 20 20 20 20 20 20 +) {.> .>
34d0: 20 20 20 20 20 20 72 65 67 69 73 74 65 72 20 43 register C
34e0: 6f 6d 6d 61 6e 64 20 2a 63 6f 6d 6d 61 6e 64 3b ommand *command;
34f0: 0a 3e 20 0a 3e 20 20 20 20 20 20 20 20 20 20 20 .> .>
3500: 20 20 2f 2a 20 54 68 65 20 63 6f 6d 6d 61 6e 64 /* The command
3510: 20 6e 61 6d 65 20 6d 61 70 70 69 6e 67 20 2a 2f name mapping */
3520: 0a 3e 20 20 20 20 20 20 20 20 20 20 20 20 20 72 .> r
3530: 65 67 69 73 74 65 72 20 54 63 6c 5f 4f 62 6a 20 egister Tcl_Obj
3540: 2a 6e 61 6d 65 4b 65 79 20 20 20 3d 20 54 63 6c *nameKey = Tcl
3550: 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 20 6d _NewStringObj( m
3560: 61 70 5b 6e 5d 2e 6e 61 6d 65 2c 20 2d 31 20 29 ap[n].name, -1 )
3570: 3b 0a 3e 20 20 20 20 20 20 20 20 20 20 20 20 20 ;.>
3580: 72 65 67 69 73 74 65 72 20 54 63 6c 5f 4f 62 6a register Tcl_Obj
3590: 20 2a 6e 61 6d 65 56 61 6c 75 65 20 3d 20 54 63 *nameValue = Tc
35a0: 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 20 l_NewStringObj(
35b0: 6e 73 4e 61 6d 65 2c 20 20 20 20 20 20 2d 31 20 nsName, -1
35c0: 29 3b 0a 3e 20 20 20 20 20 20 20 20 20 20 20 20 );.>
35d0: 20 54 63 6c 5f 41 70 70 65 6e 64 54 6f 4f 62 6a Tcl_AppendToObj
35e0: 28 20 6e 61 6d 65 56 61 6c 75 65 2c 20 6d 61 70 ( nameValue, map
35f0: 5b 6e 5d 2e 6e 61 6d 65 2c 20 2d 31 20 29 3b 0a [n].name, -1 );.
3600: 3e 20 0a 3e 20 20 20 20 20 20 20 20 20 20 20 20 > .>
3610: 20 54 63 6c 5f 44 69 63 74 4f 62 6a 50 75 74 28 Tcl_DictObjPut(
3620: 20 4e 55 4c 4c 2c 20 64 69 63 74 2c 20 6e 61 6d NULL, dict, nam
3630: 65 4b 65 79 2c 20 6e 61 6d 65 56 61 6c 75 65 20 eKey, nameValue
3640: 29 3b 0a 3e 20 0a 3e 20 20 20 20 20 20 20 20 20 );.> .>
3650: 20 20 20 20 2f 2a 20 41 64 64 20 74 68 65 20 61 /* Add the a
3660: 63 74 75 61 6c 20 54 63 6c 20 63 6f 6d 6d 61 6e ctual Tcl comman
3670: 64 20 69 74 73 65 6c 66 20 74 6f 20 74 68 65 20 d itself to the
3680: 69 6e 74 65 72 70 72 65 74 65 72 20 2a 2f 0a 3e interpreter */.>
3690: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
36a0: 28 6d 61 70 5b 6e 5d 2e 70 72 6f 63 29 20 7b 0a (map[n].proc) {.
36b0: 3e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 >
36c0: 20 20 63 6f 6d 6d 61 6e 64 20 3d 20 28 43 6f 6d command = (Com
36d0: 6d 61 6e 64 20 2a 29 54 63 6c 5f 43 72 65 61 74 mand *)Tcl_Creat
36e0: 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 20 69 6e 74 eObjCommand( int
36f0: 65 72 70 2c 0a 3e 20 20 20 20 20 20 20 20 20 20 erp,.>
3700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 T
3710: 63 6c 5f 47 65 74 53 74 72 69 6e 67 28 20 6e 61 cl_GetString( na
3720: 6d 65 56 61 6c 75 65 20 29 2c 0a 3e 20 20 20 20 meValue ),.>
3730: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3740: 20 20 20 20 20 6d 61 70 5b 6e 5d 2e 70 72 6f 63 map[n].proc
3750: 2c 20 6d 61 70 5b 6e 5d 2e 63 6c 69 65 6e 74 44 , map[n].clientD
3760: 61 74 61 2c 20 2f 2a 20 6d 61 70 5b 6e 5d 2e 64 ata, /* map[n].d
3770: 65 6c 65 74 65 50 72 6f 63 0a 3e 20 20 20 20 20 eleteProc.>
3780: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3790: 20 20 20 20 2a 2f 20 4e 55 4c 4c 20 29 3b 0a 3e */ NULL );.>
37a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
37b0: 20 63 6f 6d 6d 61 6e 64 2d 3e 63 6f 6d 70 69 6c command->compil
37c0: 65 50 72 6f 63 20 3d 20 6d 61 70 5b 6e 5d 2e 63 eProc = map[n].c
37d0: 6f 6d 70 69 6c 65 50 72 6f 63 3b 0a 3e 20 20 20 ompileProc;.>
37e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f co
37f0: 6d 6d 61 6e 64 2d 3e 6e 72 65 50 72 6f 63 20 20 mmand->nreProc
3800: 20 20 20 3d 20 6d 61 70 5b 6e 5d 2e 6e 72 65 50 = map[n].nreP
3810: 72 6f 63 3b 0a 3e 20 20 20 20 20 20 20 20 20 20 roc;.>
3820: 20 20 20 20 20 20 20 65 6e 73 65 6d 62 6c 65 46 ensembleF
3830: 6c 61 67 73 20 7c 3d 0a 3e 20 20 20 20 20 20 20 lags |=.>
3840: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3850: 20 20 28 63 6f 6d 6d 61 6e 64 2d 3e 63 6f 6d 70 (command->comp
3860: 69 6c 65 50 72 6f 63 20 21 3d 20 4e 55 4c 4c 29 ileProc != NULL)
3870: 20 3f 20 45 4e 53 45 4d 42 4c 45 5f 43 4f 4d 50 ? ENSEMBLE_COMP
3880: 49 4c 45 20 3a 20 30 3b 0a 3e 20 20 20 20 20 20 ILE : 0;.>
3890: 20 20 20 20 20 20 20 7d 0a 3e 20 20 20 20 20 20 }.>
38a0: 20 20 20 7d 0a 3e 20 20 20 20 20 20 20 20 20 54 }.> T
38b0: 63 6c 5f 53 65 74 45 6e 73 65 6d 62 6c 65 4d 61 cl_SetEnsembleMa
38c0: 70 70 69 6e 67 44 69 63 74 28 20 69 6e 74 65 72 ppingDict( inter
38d0: 70 2c 20 65 6e 73 65 6d 62 6c 65 2c 20 64 69 63 p, ensemble, dic
38e0: 74 20 29 3b 0a 3e 20 0a 3e 20 20 20 20 20 20 20 t );.> .>
38f0: 20 20 69 66 20 28 65 6e 73 65 6d 62 6c 65 46 6c if (ensembleFl
3900: 61 67 73 20 26 20 45 4e 53 45 4d 42 4c 45 5f 43 ags & ENSEMBLE_C
3910: 4f 4d 50 49 4c 45 29 20 7b 0a 3e 20 20 20 20 20 OMPILE) {.>
3920: 20 20 20 20 20 20 20 20 54 63 6c 5f 53 65 74 45 Tcl_SetE
3930: 6e 73 65 6d 62 6c 65 46 6c 61 67 73 28 20 69 6e nsembleFlags( in
3940: 74 65 72 70 2c 20 65 6e 73 65 6d 62 6c 65 2c 20 terp, ensemble,
3950: 65 6e 73 65 6d 62 6c 65 46 6c 61 67 73 20 29 3b ensembleFlags );
3960: 0a 3e 20 20 20 20 20 20 20 20 20 7d 0a 36 31 39 .> }.619
3970: 32 63 36 32 36 38 2c 36 32 36 39 0a 3c 20 20 20 2c6268,6269.<
3980: 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 46 72 65 Tcl_DStringFre
3990: 65 28 26 62 75 66 29 3b 0a 2d 2d 2d 0a 3e 20 0a e(&buf);.---.> .
39a0: 3e 20 20 20 20 20 54 63 6c 5f 44 65 63 72 52 65 > Tcl_DecrRe
39b0: 66 43 6f 75 6e 74 28 20 6e 73 4e 61 6d 65 4f 62 fCount( nsNameOb
39c0: 6a 20 29 3b 0a j );.