diff options
Diffstat (limited to 'doc/ListObj.3')
-rw-r--r-- | doc/ListObj.3 | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/doc/ListObj.3 b/doc/ListObj.3 index 2adea4e..443eafe 100644 --- a/doc/ListObj.3 +++ b/doc/ListObj.3 @@ -36,7 +36,7 @@ int int \fBTcl_ListObjReplace\fR(\fIinterp, listPtr, first, count, objc, objv\fR) .SH ARGUMENTS -.AS Tcl_Interp "*CONST objv[]" out +.AS "Tcl_Obj *const" *elemListPtr in/out .AP Tcl_Interp *interp in If an error occurs while converting an object to be a list object, an error message is left in the interpreter's result object @@ -71,13 +71,11 @@ will insert into a new list object, and \fBTcl_ListObjReplace\fR will insert into \fIlistPtr\fR. For \fBTcl_SetListObj\fR, the number of Tcl objects to insert into \fIobjPtr\fR. -.VS -.AP Tcl_Obj "*CONST\ objv[]" in +.AP "Tcl_Obj *const" objv[] in An array of pointers to objects. \fBTcl_NewListObj\fR will insert these objects into a new list object and \fBTcl_ListObjReplace\fR will insert them into an existing \fIlistPtr\fR. Each object will become a separate list element. -.VE .AP int *intPtr out Points to location where \fBTcl_ListObjLength\fR stores the length of the list. @@ -151,8 +149,9 @@ has reference count zero. the elements in a list object. It returns the count by storing it in the address \fIobjcPtr\fR. Similarly, it returns the array pointer by storing it in the address \fIobjvPtr\fR. -The memory pointed to is managed by Tcl and should not be freed by the -caller. +The memory pointed to is managed by Tcl and should not be freed or written +to by the caller. If the list is empty, 0 is stored at \fIobjcPtr\fR +and NULL at \fIobjvPtr\fR. If \fIlistPtr\fR is not already a list object, \fBTcl_ListObjGetElements\fR will attempt to convert it to one; if the conversion fails, it returns \fBTCL_ERROR\fR and leaves an error message in the interpreter's result @@ -219,27 +218,33 @@ it can be used to implement a number of list operations. For example, the following code inserts the \fIobjc\fR objects referenced by the array of object pointers \fIobjv\fR just before the element \fIindex\fR of the list referenced by \fIlistPtr\fR: +.PP .CS -result = Tcl_ListObjReplace(interp, listPtr, index, 0, objc, objv); +result = Tcl_ListObjReplace(interp, listPtr, index, 0, + objc, objv); .CE +.PP Similarly, the following code appends the \fIobjc\fR objects referenced by the array \fIobjv\fR to the end of the list \fIlistPtr\fR: +.PP .CS result = Tcl_ListObjLength(interp, listPtr, &length); if (result == TCL_OK) { - result = Tcl_ListObjReplace(interp, listPtr, length, 0, objc, objv); + result = Tcl_ListObjReplace(interp, listPtr, length, 0, + objc, objv); } .CE +.PP The \fIcount\fR list elements starting at \fIfirst\fR can be deleted by simply calling \fBTcl_ListObjReplace\fR with a NULL \fIobjvPtr\fR: +.PP .CS -result = Tcl_ListObjReplace(interp, listPtr, first, count, 0, NULL); +result = Tcl_ListObjReplace(interp, listPtr, first, count, + 0, NULL); .CE - .SH "SEE ALSO" Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_GetObjResult - .SH KEYWORDS append, index, insert, internal representation, length, list, list object, list type, object, object type, replace, string representation |