summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-05-23 12:00:59 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-05-23 12:00:59 (GMT)
commit40f392b7dd51270e178e4ed1404b80b7878daf26 (patch)
tree23ec4c8be538373c27c4f9e1cf458b985d983e65
parente857121ed3570fe6d998e4ffb78cfea9de200107 (diff)
parentd707e1395bbbeba874f52e6aa30c013b12e88eaa (diff)
downloadtcl-40f392b7dd51270e178e4ed1404b80b7878daf26.zip
tcl-40f392b7dd51270e178e4ed1404b80b7878daf26.tar.gz
tcl-40f392b7dd51270e178e4ed1404b80b7878daf26.tar.bz2
Merge 8.6
-rw-r--r--doc/define.n39
-rw-r--r--generic/tclIO.c6
-rw-r--r--generic/tclStringObj.c18
3 files changed, 45 insertions, 18 deletions
diff --git a/doc/define.n b/doc/define.n
index c1c3049..ef2735e 100644
--- a/doc/define.n
+++ b/doc/define.n
@@ -9,7 +9,7 @@
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
-oo::define, oo::objdefine \- define and configure classes and objects
+oo::define, oo::objdefine, oo::Slot \- define and configure classes and objects
.SH SYNOPSIS
.nf
package require tcl::oo
@@ -18,9 +18,15 @@ package require tcl::oo
\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
@@ -486,8 +492,10 @@ 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. The class defines five operations (as methods) that may be done on
-the slot:
+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?
.
@@ -520,6 +528,10 @@ This replaces the slot definition with the given \fImember\fR elements.
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
@@ -561,6 +573,15 @@ 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
@@ -581,8 +602,14 @@ 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 be restricted to
-defining new operations whose names start with a hyphen.
+\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
diff --git a/generic/tclIO.c b/generic/tclIO.c
index fe5472e..5089b19 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -496,7 +496,7 @@ ChanSeek(
}
return Tcl_ChannelSeekProc(chanPtr->typePtr)(chanPtr->instanceData,
- offset, mode, errnoPtr);
+ (long)offset, mode, errnoPtr);
#else
*errnoPtr = EINVAL;
return TCL_INDEX_NONE;
@@ -6359,7 +6359,7 @@ ReadChars(
int dstLimit = TCL_UTF_MAX - 1 + toRead * factor / UTF_EXPANSION_FACTOR;
if (dstLimit <= 0) dstLimit = INT_MAX; /* avoid overflow */
- (void) TclGetStringFromObj(objPtr, &numBytes);
+ (void)TclGetStringFromObj(objPtr, &numBytes);
TclAppendUtfToUtf(objPtr, NULL, dstLimit);
if (toRead == srcLen) {
unsigned int size;
@@ -11411,7 +11411,7 @@ Tcl_SetChannelError(
Tcl_Channel chan, /* Channel to store the data into. */
Tcl_Obj *msg) /* Error message to store. */
{
- ChannelState *statePtr = ((Channel *) chan)->state;
+ ChannelState *statePtr = ((Channel *)chan)->state;
Tcl_Obj *disposePtr = statePtr->chanMsg;
if (msg != NULL) {
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 967fdd0..980bf22 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -1,9 +1,9 @@
/*
* 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,
+ * 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
@@ -15,10 +15,10 @@
* 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).
+ * 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
@@ -2219,7 +2219,7 @@ Tcl_AppendFormatToObj(
if (Tcl_IsShared(appendObj)) {
Tcl_Panic("%s called with shared object", "Tcl_AppendFormatToObj");
}
- TclGetStringFromObj(appendObj, &originalLength);
+ (void)TclGetStringFromObj(appendObj, &originalLength);
limit = TCL_SIZE_MAX - originalLength;
/*
@@ -2760,7 +2760,7 @@ Tcl_AppendFormatToObj(
numDigits = 1;
}
TclNewObj(pure);
- Tcl_SetObjLength(pure, numDigits);
+ Tcl_SetObjLength(pure, (Tcl_Size)numDigits);
bytes = TclGetString(pure);
toAppend = length = numDigits;
while (numDigits--) {