Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merge 8.6 |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | core-8-branch |
Files: | files | file ages | folders |
SHA3-256: |
37b8b3fdafed766d02dae29df727fefa |
User & Date: | jan.nijtmans 2024-05-23 12:00:59.948 |
Context
2024-05-23
| ||
15:14 | Fix [3fc3287497]: TclGetProcessGlobalValue encodes information twice on Windows check-in: 73dc48ac59 user: jan.nijtmans tags: core-8-branch | |
13:44 | Merge 8.7 check-in: b4a4d46ce0 user: jan.nijtmans tags: trunk, main | |
12:00 | Merge 8.6 check-in: 37b8b3fdaf user: jan.nijtmans tags: core-8-branch | |
11:52 | Fix 2 warnings on Win32 (Thanks, Harald). Some more code cleanup, backported from 8.7) check-in: 73474e33a9 user: jan.nijtmans tags: core-8-6-branch | |
2024-05-22
| ||
22:24 | .travis.yml is not used any more check-in: 918bf2ae16 user: jan.nijtmans tags: core-8-branch | |
Changes
Changes to doc/define.n.
1 2 3 4 5 6 7 8 9 10 11 | '\" '\" Copyright (c) 2007-2018 Donal K. Fellows '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" .TH define n 0.3 TclOO "TclOO Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME | | > > > > > > > < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | '\" '\" Copyright (c) 2007-2018 Donal K. Fellows '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" .TH define n 0.3 TclOO "TclOO Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME oo::define, oo::objdefine, oo::Slot \- define and configure classes and objects .SH SYNOPSIS .nf package require tcl::oo \fBoo::define\fI class defScript\fR \fBoo::define\fI class subcommand arg\fR ?\fIarg ...\fR? \fBoo::objdefine\fI object defScript\fR \fBoo::objdefine\fI object subcommand arg\fR ?\fIarg ...\fR? \fBoo::Slot\fR \fIarg...\fR .fi .SH "CLASS HIERARCHY" .nf \fBoo::object\fR \(-> \fBoo::Slot\fR .fi .BE .SH DESCRIPTION The \fBoo::define\fR command is used to control the configuration of classes, and the \fBoo::objdefine\fR command is used to control the configuration of objects (including classes as instance objects), with the configuration being applied to the entity named in the \fIclass\fR or the \fIobject\fR argument. Configuring a class also updates the configuration of all subclasses of the class and all objects that are |
︙ | ︙ | |||
482 483 484 485 486 487 488 | \fBself call\fR). .VE TIP500 .SH "SLOTTED DEFINITIONS" Some of the configurable definitions of a class or object are \fIslotted definitions\fR. This means that the configuration is implemented by a slot object, that is an instance of the class \fBoo::Slot\fR, which manages a list of values (class names, variable names, etc.) that comprises the contents of | > > | | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | \fBself call\fR). .VE TIP500 .SH "SLOTTED DEFINITIONS" Some of the configurable definitions of a class or object are \fIslotted definitions\fR. This means that the configuration is implemented by a slot object, that is an instance of the class \fBoo::Slot\fR, which manages a list of values (class names, variable names, etc.) that comprises the contents of the slot. .PP The \fBoo::Slot\fR class defines five operations (as methods) that may be done on the slot: .TP \fIslot\fR \fB\-append\fR ?\fImember ...\fR? . This appends the given \fImember\fR elements to the slot definition. .TP \fIslot\fR \fB\-appendifnew\fR ?\fImember ...\fR? .VS TIP558 |
︙ | ︙ | |||
516 517 518 519 520 521 522 523 524 525 526 527 528 529 | \fIslot\fR \fB\-set\fR ?\fImember ...\fR? . This replaces the slot definition with the given \fImember\fR elements. .PP A consequence of this is that any use of a slot's default operation where the first member argument begins with a hyphen will be an error. One of the above operations should be used explicitly in those circumstances. .SS "SLOT IMPLEMENTATION" Internally, slot objects also define a method \fB\-\-default\-operation\fR which is forwarded to the default operation of the slot (thus, for the class .QW \fBvariable\fR slot, this is forwarded to .QW "\fBmy \-append\fR" ), and these methods which provide the implementation interface: | > > > > | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | \fIslot\fR \fB\-set\fR ?\fImember ...\fR? . This replaces the slot definition with the given \fImember\fR elements. .PP A consequence of this is that any use of a slot's default operation where the first member argument begins with a hyphen will be an error. One of the above operations should be used explicitly in those circumstances. .PP You only need to make an instance of \fBoo::Slot\fR if you are definining your own slot that behaves like a standard slot. .PP .SS "SLOT IMPLEMENTATION" Internally, slot objects also define a method \fB\-\-default\-operation\fR which is forwarded to the default operation of the slot (thus, for the class .QW \fBvariable\fR slot, this is forwarded to .QW "\fBmy \-append\fR" ), and these methods which provide the implementation interface: |
︙ | ︙ | |||
556 557 558 559 560 561 562 563 564 565 566 567 568 569 | require that values are resolvable to work). .RS .PP Implementations \fIshould not\fR enforce uniqueness and ordering constraints in this method; that is the responsibility of the \fBSet\fR method. .RE .VE TIP516 .TP \fIslot\fR \fBSet \fIelementList\fR . Sets the contents of the slot to the list \fIelementList\fR and returns the empty string. This method must always be called from a stack frame created by a call to \fBoo::define\fR or \fBoo::objdefine\fR. This method may return an error if it rejects the change to the slot contents (e.g., because of invalid | > > > > > > > > > | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | require that values are resolvable to work). .RS .PP Implementations \fIshould not\fR enforce uniqueness and ordering constraints in this method; that is the responsibility of the \fBSet\fR method. .RE .VE TIP516 .TP \fIslot\fR \fBResolve \fIelement\fR .VS This converts an element of the slotted collection into its resolved form; for a simple value, it could just return the value, but for a slot that contains references to commands or classes it should convert those into their fully-qualified forms (so they can be compared with \fBstring equals\fR): that could be done by forwarding to \fBnamespace which\fR or similar. .VE .TP \fIslot\fR \fBSet \fIelementList\fR . Sets the contents of the slot to the list \fIelementList\fR and returns the empty string. This method must always be called from a stack frame created by a call to \fBoo::define\fR or \fBoo::objdefine\fR. This method may return an error if it rejects the change to the slot contents (e.g., because of invalid |
︙ | ︙ | |||
577 578 579 580 581 582 583 | earliest location in the slot that it can.) .RE .PP The implementation of these methods is slot-dependent (and responsible for accessing the correct part of the class or object definition). Slots also have an unknown method handler to tie all these pieces together, and they hide their \fBdestroy\fR method so that it is not invoked inadvertently. It is | | | > > > > > > | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | earliest location in the slot that it can.) .RE .PP The implementation of these methods is slot-dependent (and responsible for accessing the correct part of the class or object definition). Slots also have an unknown method handler to tie all these pieces together, and they hide their \fBdestroy\fR method so that it is not invoked inadvertently. It is \fIrecommended\fR that any user changes to the slot mechanism itself be restricted to defining new operations whose names start with a hyphen. .PP Note that slot instances are not expected to contain the storage for the slot they manage; that will be in or attached to the class or object that they manage. Those instances should provide their own implementations of the \fBGet\fR and \fBSet\fR methods (and optionally \fBResolve\fR; that defaults to a do-nothing pass-through). .PP .VS TIP516 Most slot operations will initially \fBResolve\fR their argument list, combine it with the results of the \fBGet\fR method, and then \fBSet\fR the result. Some operations omit one or both of the first two steps; omitting the third would result in an idempotent read-only operation (but the standard mechanism for reading from slots is via \fBinfo class\fR and \fBinfo object\fR). |
︙ | ︙ |
Changes to generic/tclIO.c.
︙ | ︙ | |||
492 493 494 495 496 497 498 | #ifndef TCL_NO_DEPRECATED if (offset<LONG_MIN || offset>LONG_MAX) { *errnoPtr = EOVERFLOW; return TCL_INDEX_NONE; } return Tcl_ChannelSeekProc(chanPtr->typePtr)(chanPtr->instanceData, | | | 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | #ifndef TCL_NO_DEPRECATED if (offset<LONG_MIN || offset>LONG_MAX) { *errnoPtr = EOVERFLOW; return TCL_INDEX_NONE; } return Tcl_ChannelSeekProc(chanPtr->typePtr)(chanPtr->instanceData, (long)offset, mode, errnoPtr); #else *errnoPtr = EINVAL; return TCL_INDEX_NONE; #endif } return Tcl_ChannelWideSeekProc(chanPtr->typePtr)(chanPtr->instanceData, |
︙ | ︙ | |||
6355 6356 6357 6358 6359 6360 6361 | * how many characters were produced by the previous pass. */ int factor = *factorPtr; int dstLimit = TCL_UTF_MAX - 1 + toRead * factor / UTF_EXPANSION_FACTOR; if (dstLimit <= 0) dstLimit = INT_MAX; /* avoid overflow */ | | | 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 | * how many characters were produced by the previous pass. */ int factor = *factorPtr; int dstLimit = TCL_UTF_MAX - 1 + toRead * factor / UTF_EXPANSION_FACTOR; if (dstLimit <= 0) dstLimit = INT_MAX; /* avoid overflow */ (void)TclGetStringFromObj(objPtr, &numBytes); TclAppendUtfToUtf(objPtr, NULL, dstLimit); if (toRead == srcLen) { unsigned int size; dst = TclGetStringStorage(objPtr, &size) + numBytes; dstLimit = size - numBytes; } else { |
︙ | ︙ | |||
11407 11408 11409 11410 11411 11412 11413 | */ void Tcl_SetChannelError( Tcl_Channel chan, /* Channel to store the data into. */ Tcl_Obj *msg) /* Error message to store. */ { | | | 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 | */ void Tcl_SetChannelError( Tcl_Channel chan, /* Channel to store the data into. */ Tcl_Obj *msg) /* Error message to store. */ { ChannelState *statePtr = ((Channel *)chan)->state; Tcl_Obj *disposePtr = statePtr->chanMsg; if (msg != NULL) { statePtr->chanMsg = FixLevelCode(msg); Tcl_IncrRefCount(statePtr->chanMsg); } else { statePtr->chanMsg = NULL; |
︙ | ︙ |
Changes to generic/tclStringObj.c.
1 2 3 | /* * tclStringObj.c -- * | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * tclStringObj.c -- * * This file contains functions that implement string operations on Tcl * objects. Some string operations work with UTF-8 encoding forms. * Functions that require knowledge of the width of each character, * such as indexing, operate on fixed width encoding forms such as UTF-32. * * Conceptually, a string is a sequence of Unicode code points. Internally * it may be stored in an encoding form such as a modified version of * UTF-8 or UTF-16 (when TCL_UTF_MAX=3) or UTF-32. * * The String object is optimized for the case where each UTF char * in a string is only one byte. In this case, we store the value of * numChars, but we don't store the fixed form encoding (unless * Tcl_GetUnicode is explicitly called). * * The String object type stores one or both formats. The default * behavior is to store UTF-8. Once UTF-16/UTF32 is calculated, it is * stored in the internal rep for future access (without an additional * O(n) cost). * * To allow many appends to be done to an object without constantly * reallocating space, we allocate double the space and use the * internal representation to keep track of how much space is used vs. * allocated. * * Copyright © 1995-1997 Sun Microsystems, Inc. |
︙ | ︙ | |||
2215 2216 2217 2218 2219 2220 2221 | "\"%n$\" argument index out of range" }; static const char *overflow = "max size for a Tcl value exceeded"; if (Tcl_IsShared(appendObj)) { Tcl_Panic("%s called with shared object", "Tcl_AppendFormatToObj"); } | | | 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 | "\"%n$\" argument index out of range" }; static const char *overflow = "max size for a Tcl value exceeded"; if (Tcl_IsShared(appendObj)) { Tcl_Panic("%s called with shared object", "Tcl_AppendFormatToObj"); } (void)TclGetStringFromObj(appendObj, &originalLength); limit = TCL_SIZE_MAX - originalLength; /* * Format string is NUL-terminated. */ while (*format != '\0') { |
︙ | ︙ | |||
2756 2757 2758 2759 2760 2761 2762 | * Need to be sure zero becomes "0", not "". */ if (numDigits == 0) { numDigits = 1; } TclNewObj(pure); | | | 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 | * Need to be sure zero becomes "0", not "". */ if (numDigits == 0) { numDigits = 1; } TclNewObj(pure); Tcl_SetObjLength(pure, (Tcl_Size)numDigits); bytes = TclGetString(pure); toAppend = length = numDigits; while (numDigits--) { int digitOffset; if (useBig && !mp_iszero(&big)) { if (index < big.used && (size_t) shift < |
︙ | ︙ |