diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | doc/Clipboard.3 | 4 | ||||
-rw-r--r-- | doc/ConfigWidg.3 | 10 | ||||
-rw-r--r-- | doc/CrtItemType.3 | 26 | ||||
-rw-r--r-- | doc/ParseArgv.3 | 6 | ||||
-rw-r--r-- | generic/tk.h | 26 | ||||
-rw-r--r-- | generic/tkCanvLine.c | 13 | ||||
-rw-r--r-- | generic/tkCanvPoly.c | 13 | ||||
-rw-r--r-- | generic/tkCanvText.c | 20 | ||||
-rw-r--r-- | generic/tkCanvas.c | 18 |
10 files changed, 87 insertions, 61 deletions
@@ -1,3 +1,15 @@ +2009-01-06 Jan Nijtmans <nijtmans@users.sf.net> + + * generic/tk.h: A few const -> CONST86 modifications, improving + * generic/tkCanvas.c: backwards compatibility. Change Tk_ItemIndexProc + * generic/tkCanvLine.c: and Tk_ItemInsertProc signature to have a Tcl_Obj parameter + * generic/tkCanvPoly.c: in stead of a string parameter. This is binary + * generic/tkCanvText.c: and source compatible with previous API, it just prevents + * doc/CrtItemType.3: the need for a type cast in the Tk_ItemType table construction. + * doc/Clipboard.3: Bring doc in line with API + * doc/ConfigWidg.3: + * doc/ParseArgv.3: + 2009-01-06 Donal K. Fellows <dkf@users.sf.net> * generic/tkImgPhoto.c (Tk_PhotoPutBlock): Optimize a common case for diff --git a/doc/Clipboard.3 b/doc/Clipboard.3 index 42fbbb3..927a64e 100644 --- a/doc/Clipboard.3 +++ b/doc/Clipboard.3 @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: Clipboard.3,v 1.5 2008/07/08 22:40:50 patthoyts Exp $ +'\" RCS: @(#) $Id: Clipboard.3,v 1.6 2009/01/06 21:58:15 nijtmans Exp $ '\" .so man.macros .TH Tk_ClipboardClear 3 4.0 Tk "Tk Library Procedures" @@ -33,7 +33,7 @@ Conversion type for this clipboard item; has same meaning as .AP Atom format in Representation to use when data is retrieved; has same meaning as \fIformat\fR argument to \fBTk_CreateSelHandler\fR. -.AP char *buffer in +.AP "const char" *buffer in Null terminated string containing the data to be appended to the clipboard. .BE .SH DESCRIPTION diff --git a/doc/ConfigWidg.3 b/doc/ConfigWidg.3 index 0b76ef4..c9f72f2 100644 --- a/doc/ConfigWidg.3 +++ b/doc/ConfigWidg.3 @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: ConfigWidg.3,v 1.22 2008/10/30 21:39:16 nijtmans Exp $ +'\" RCS: @(#) $Id: ConfigWidg.3,v 1.23 2009/01/06 21:58:15 nijtmans Exp $ '\" .so man.macros .TH Tk_ConfigureWidget 3 4.1 Tk "Tk Library Procedures" @@ -105,10 +105,10 @@ option and has the following structure: .CS typedef struct { int \fItype\fR; - char *\fIargvName\fR; - char *\fIdbName\fR; - char *\fIdbClass\fR; - char *\fIdefValue\fR; + const char *\fIargvName\fR; + const char *\fIdbName\fR; + const char *\fIdbClass\fR; + const char *\fIdefValue\fR; int \fIoffset\fR; int \fIspecFlags\fR; const Tk_CustomOption *\fIcustomPtr\fR; diff --git a/doc/CrtItemType.3 b/doc/CrtItemType.3 index 2549094..a271be2 100644 --- a/doc/CrtItemType.3 +++ b/doc/CrtItemType.3 @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: CrtItemType.3,v 1.14 2008/11/01 17:26:36 dkf Exp $ +'\" RCS: @(#) $Id: CrtItemType.3,v 1.15 2009/01/06 21:58:15 nijtmans Exp $ '\" .so man.macros .TH Tk_CreateItemType 3 4.0 Tk "Tk Library Procedures" @@ -65,7 +65,7 @@ the standard procedures implemented by the type manager: .PP .CS typedef struct Tk_ItemType { - char *\fIname\fR; + const char *\fIname\fR; int \fIitemSize\fR; Tk_ItemCreateProc *\fIcreateProc\fR; Tk_ConfigSpec *\fIconfigSpecs\fR; @@ -280,7 +280,7 @@ typedef int \fBTk_ItemConfigureProc\fR( int \fIflags\fR); .CE .PP -The \fIinterp\fR objument identifies the interpreter in which the +The \fIinterp\fR argument identifies the interpreter in which the widget command was invoked, \fIcanvas\fR is a handle for the canvas widget, and \fIitemPtr\fR is a pointer to the item being configured. \fIobjc\fR and \fIobjv\fR contain the configuration options. @@ -566,18 +566,18 @@ typedef int \fBTk_ItemIndexProc\fR( Tcl_Interp *\fIinterp\fR, Tk_Canvas \fIcanvas\fR, Tk_Item *\fIitemPtr\fR, - char *\fIindexString\fR, + Tcl_Obj *\fIindexObj\fR, int *\fIindexPtr\fR); .CE .PP The \fIinterp\fR, \fIcanvas\fR, and \fIitemPtr\fR arguments all have the usual meaning. -\fIindexString\fR contains a textual description of an index, +\fIindexObj\fR contains a textual description of an index, and \fIindexPtr\fR points to an integer value that should be filled in with a numerical index. -Note that if \fBTK_CONFIG_OBJS\fR is set in the -\fItypePtr\->alwaysRedraw\fR field, the \fIindexString\fR parameter will -actually contain a Tcl_Obj reference. +Note that if \fBTK_CONFIG_OBJS\fR is not set in the +\fItypePtr\->alwaysRedraw\fR field, the \fIindexObj\fR parameter will +actually contain a pointer to a constant string. It is up to the type manager to decide what forms of index are supported (e.g., numbers, \fBinsert\fR, \fBsel.first\fR, \fBend\fR, etc.). @@ -653,17 +653,17 @@ typedef void \fBTk_ItemInsertProc\fR( Tk_Canvas \fIcanvas\fR, Tk_Item *\fIitemPtr\fR, int \fIindex\fR, - char *\fIstring\fR); + Tcl_Obj *\fIobj\fR); .CE .PP \fIcanvas\fR and \fIitemPtr\fR have the usual meanings. \fIindex\fR is an index into the item's text, as returned by a -previous call to \fItypePtr\->insertProc\fR, and \fIstring\fR +previous call to \fItypePtr\->insertProc\fR, and \fIobj\fR contains new text to insert just before the character given by \fIindex\fR. -Note that if \fBTK_CONFIG_OBJS\fR is set in the -\fItypePtr\->alwaysRedraw\fR field, the \fIstring\fR parameter will -actually contain a Tcl_Obj reference to the string to insert. +Note that if \fBTK_CONFIG_OBJS\fR is not set in the +\fItypePtr\->alwaysRedraw\fR field, the \fIobj\fR parameter will +actually contain a pointer to a constant string to be inserted. If the item supports modification of the coordinates list by this .PP The type manager should insert the text and recompute the bounding diff --git a/doc/ParseArgv.3 b/doc/ParseArgv.3 index b5db646..bf065ee 100644 --- a/doc/ParseArgv.3 +++ b/doc/ParseArgv.3 @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: ParseArgv.3,v 1.11 2008/06/30 22:57:01 dkf Exp $ +'\" RCS: @(#) $Id: ParseArgv.3,v 1.12 2009/01/06 21:58:15 nijtmans Exp $ '\" .so man.macros .TH Tk_ParseArgv 3 "" Tk "Tk Library Procedures" @@ -72,11 +72,11 @@ The \fIargTable\fR array specifies the kinds of arguments that are expected; each of its entries has the following structure: .CS typedef struct { - char *\fIkey\fR; + const char *\fIkey\fR; int \fItype\fR; char *\fIsrc\fR; char *\fIdst\fR; - char *\fIhelp\fR; + const char *\fIhelp\fR; } \fBTk_ArgvInfo\fR; .CE The \fIkey\fR field is a string such as diff --git a/generic/tk.h b/generic/tk.h index 1bc32e3..19a2caf 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tk.h,v 1.127 2008/12/19 14:32:25 dgp Exp $ + * RCS: @(#) $Id: tk.h,v 1.128 2009/01/06 21:58:15 nijtmans Exp $ */ #ifndef _TK @@ -342,7 +342,7 @@ typedef struct Tk_ConfigSpec { int type; /* Type of option, such as TK_CONFIG_COLOR; * see definitions below. Last option in table * must have type TK_CONFIG_END. */ - const char *argvName; /* Switch used to specify option in argv. NULL + CONST86 char *argvName; /* Switch used to specify option in argv. NULL * means this spec is part of a group. */ Tk_Uid dbName; /* Name for option in option database. */ Tk_Uid dbClass; /* Class for option in database. */ @@ -402,14 +402,14 @@ typedef enum { */ typedef struct { - const char *key; /* The key string that flags the option in the + CONST86 char *key; /* The key string that flags the option in the * argv array. */ int type; /* Indicates option type; see below. */ char *src; /* Value to be used in setting dst; usage * depends on type. */ char *dst; /* Address of value to be modified; usage * depends on type. */ - const char *help; /* Documentation message describing this + CONST86 char *help; /* Documentation message describing this * option. */ } Tk_ArgvInfo; @@ -897,7 +897,7 @@ typedef enum { } Tk_State; typedef struct Tk_SmoothMethod { - const char *name; + CONST86 char *name; int (*coordProc) (Tk_Canvas canvas, double *pointPtr, int numPoints, int numSteps, XPoint xPoints[], double dblPoints[]); void (*postscriptProc) (Tcl_Interp *interp, Tk_Canvas canvas, @@ -1001,21 +1001,31 @@ typedef void (Tk_ItemScaleProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double scaleY); typedef void (Tk_ItemTranslateProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); +#ifdef USE_OLD_CANVAS typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, char *indexString, int *indexPtr); +#else +typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, + Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr); +#endif typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr, int index); typedef int (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr, int offset, char *buffer, int maxBytes); +#ifdef USE_OLD_CANVAS typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, int beforeThis, char *string); +#else +typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, + int beforeThis, Tcl_Obj *string); +#endif typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr, int first, int last); #ifndef __NO_OLD_CONFIG typedef struct Tk_ItemType { - const char *name; /* The name of this type of item, such as + CONST86 char *name; /* The name of this type of item, such as * "line". */ int itemSize; /* Total amount of space needed for item's * record. */ @@ -1217,7 +1227,7 @@ typedef int (Tk_ImagePostscriptProc) (ClientData clientData, */ struct Tk_ImageType { - const char *name; /* Name of image type. */ + CONST86 char *name; /* Name of image type. */ Tk_ImageCreateProc *createProc; /* Procedure to call to create a new image of * this type. */ @@ -1329,7 +1339,7 @@ typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, Tcl_Obj *format, */ struct Tk_PhotoImageFormat { - const char *name; /* Name of image file format */ + CONST86 char *name; /* Name of image file format */ Tk_ImageFileMatchProc *fileMatchProc; /* Procedure to call to determine whether an * image file matches this format. */ diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index 6abb362..61151c4 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvLine.c,v 1.27 2008/11/27 23:26:05 nijtmans Exp $ + * RCS: @(#) $Id: tkCanvLine.c,v 1.28 2009/01/06 21:58:15 nijtmans Exp $ */ #include <stdio.h> @@ -236,10 +236,10 @@ Tk_ItemType tkLineType = { LineToPostscript, /* postscriptProc */ ScaleLine, /* scaleProc */ TranslateLine, /* translateProc */ - (Tk_ItemIndexProc *) GetLineIndex, /* indexProc */ + GetLineIndex, /* indexProc */ NULL, /* icursorProc */ NULL, /* selectionProc */ - (Tk_ItemInsertProc *) LineInsert, /* insertProc */ + LineInsert, /* insertProc */ LineDeleteCoords, /* dTextProc */ NULL, /* nextPtr */ }; @@ -315,7 +315,7 @@ CreateLine( */ for (i = 1; i < objc; i++) { - char *arg = Tcl_GetString(objv[i]); + const char *arg = Tcl_GetString(objv[i]); if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { break; @@ -1752,7 +1752,7 @@ GetLineIndex( { LineItem *linePtr = (LineItem *) itemPtr; int length; - char *string = Tcl_GetStringFromObj(obj, &length); + const char *string = Tcl_GetStringFromObj(obj, &length); if (string[0] == 'e') { if (strncmp(string, "end", (unsigned) length) == 0) { @@ -1771,7 +1771,8 @@ GetLineIndex( } else if (string[0] == '@') { int i; double x, y, bestDist, dist, *coordPtr; - char *end, *p; + char *end; + const char *p; p = string+1; x = strtod(p, &end); diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index bbdf91a..aaa2d3a 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvPoly.c,v 1.23 2008/11/09 21:53:39 nijtmans Exp $ + * RCS: @(#) $Id: tkCanvPoly.c,v 1.24 2009/01/06 21:58:15 nijtmans Exp $ */ #include <stdio.h> @@ -205,10 +205,10 @@ Tk_ItemType tkPolygonType = { PolygonToPostscript, /* postscriptProc */ ScalePolygon, /* scaleProc */ TranslatePolygon, /* translateProc */ - (Tk_ItemIndexProc *) GetPolygonIndex,/* indexProc */ + GetPolygonIndex, /* indexProc */ NULL, /* icursorProc */ NULL, /* selectionProc */ - (Tk_ItemInsertProc *) PolygonInsert,/* insertProc */ + PolygonInsert, /* insertProc */ PolygonDeleteCoords, /* dTextProc */ NULL, /* nextPtr */ }; @@ -287,7 +287,7 @@ CreatePolygon( */ for (i = 0; i < objc; i++) { - char *arg = Tcl_GetString(objv[i]); + const char *arg = Tcl_GetString(objv[i]); if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { break; @@ -1679,7 +1679,7 @@ GetPolygonIndex( { PolygonItem *polyPtr = (PolygonItem *) itemPtr; int length; - char *string = Tcl_GetStringFromObj(obj, &length); + const char *string = Tcl_GetStringFromObj(obj, &length); if (string[0] == 'e') { if (strncmp(string, "end", (unsigned)length) != 0) { @@ -1689,7 +1689,8 @@ GetPolygonIndex( } else if (string[0] == '@') { int i; double x, y, bestDist, dist, *coordPtr; - char *end, *p; + char *end; + const char *p; p = string+1; x = strtod(p, &end); diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 3f6900b..72da38d 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvText.c,v 1.35 2008/11/23 15:08:58 dkf Exp $ + * RCS: @(#) $Id: tkCanvText.c,v 1.36 2009/01/06 21:58:15 nijtmans Exp $ */ #include <stdio.h> @@ -166,7 +166,7 @@ static int TextCoords(Tcl_Interp *interp, static void TextDeleteChars(Tk_Canvas canvas, Tk_Item *itemPtr, int first, int last); static void TextInsert(Tk_Canvas canvas, - Tk_Item *itemPtr, int beforeThis, char *string); + Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj); static int TextToArea(Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr); static double TextToPoint(Tk_Canvas canvas, @@ -196,7 +196,7 @@ Tk_ItemType tkTextType = { TextToPostscript, /* postscriptProc */ ScaleText, /* scaleProc */ TranslateText, /* translateProc */ - (Tk_ItemIndexProc *) GetTextIndex,/* indexProc */ + GetTextIndex, /* indexProc */ SetTextCursor, /* icursorProc */ GetSelText, /* selectionProc */ TextInsert, /* insertProc */ @@ -285,7 +285,7 @@ CreateText( if (objc == 1) { i = 1; } else { - char *arg = Tcl_GetString(objv[1]); + const char *arg = Tcl_GetString(objv[1]); i = 2; if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { @@ -1002,14 +1002,15 @@ TextInsert( Tk_Item *itemPtr, /* Text item to be modified. */ int index, /* Character index before which string is to * be inserted. */ - char *string) /* New characters to be inserted. */ + Tcl_Obj *obj) /* New characters to be inserted. */ { TextItem *textPtr = (TextItem *) itemPtr; int byteIndex, byteCount, charsAdded; char *newStr, *text; + const char *string; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; - string = Tcl_GetStringFromObj((Tcl_Obj *) string, &byteCount); + string = Tcl_GetStringFromObj(obj, &byteCount); text = textPtr->text; @@ -1345,7 +1346,7 @@ GetTextIndex( int c; TkCanvas *canvasPtr = (TkCanvas *) canvas; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; - char *string = Tcl_GetStringFromObj(obj, &length); + const char *string = Tcl_GetStringFromObj(obj, &length); c = string[0]; @@ -1371,7 +1372,8 @@ GetTextIndex( } else if (c == '@') { int x, y; double tmp, c = textPtr->cosine, s = textPtr->sine; - char *end, *p; + char *end; + const char *p; p = string+1; tmp = strtod(p, &end); @@ -1387,7 +1389,7 @@ GetTextIndex( y = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5); x += canvasPtr->scrollX1 - (int) textPtr->drawOrigin[0]; y += canvasPtr->scrollY1 - (int) textPtr->drawOrigin[1]; - *indexPtr = Tk_PointToChar(textPtr->textLayout, + *indexPtr = Tk_PointToChar(textPtr->textLayout, (int) (x*c - y*s), (int) (y*c + x*s)); } else if (Tcl_GetIntFromObj(NULL, obj, indexPtr) == TCL_OK) { if (*indexPtr < 0) { diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index f1d7421..f21c306 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvas.c,v 1.58 2008/12/09 21:22:56 dgp Exp $ + * RCS: @(#) $Id: tkCanvas.c,v 1.59 2009/01/06 21:58:15 nijtmans Exp $ */ /* #define USE_OLD_TAG_SEARCH 1 */ @@ -77,7 +77,7 @@ typedef struct TagSearch { * return NULL. */ int type; /* Search type (see #defs below) */ int id; /* Item id for searches by id */ - char *string; /* Tag expression string */ + const char *string; /* Tag expression string */ int stringIndex; /* Current position in string scan */ int stringLength; /* Length of tag expression string */ char *rewritebuffer; /* Tag string (after removing escapes) */ @@ -531,10 +531,10 @@ ItemIndex( return TCL_OK; } else if (itemPtr->typePtr->alwaysRedraw & TK_CONFIG_OBJS) { return itemPtr->typePtr->indexProc(interp, (Tk_Canvas) canvasPtr, - itemPtr, (char *) objPtr, indexPtr); + itemPtr, objPtr, indexPtr); } else { return itemPtr->typePtr->indexProc(interp, (Tk_Canvas) canvasPtr, - itemPtr, Tcl_GetString(objPtr), indexPtr); + itemPtr, (Tcl_Obj *) Tcl_GetString(objPtr), indexPtr); } } @@ -547,10 +547,10 @@ ItemInsert( { if (itemPtr->typePtr->alwaysRedraw & TK_CONFIG_OBJS) { itemPtr->typePtr->insertProc((Tk_Canvas) canvasPtr, itemPtr, - beforeThis, (char *) toInsert); + beforeThis, toInsert); } else { itemPtr->typePtr->insertProc((Tk_Canvas) canvasPtr, itemPtr, - beforeThis, Tcl_GetString(toInsert)); + beforeThis, (Tcl_Obj *) Tcl_GetString(toInsert)); } } @@ -975,7 +975,7 @@ CanvasWidgetCmd( if (objc == 5) { int append = 0; unsigned long mask; - char *argv4 = Tcl_GetString(objv[4]); + const char *argv4 = Tcl_GetString(objv[4]); if (argv4[0] == 0) { result = Tk_DeleteBinding(interp, canvasPtr->bindingTable, @@ -1233,7 +1233,7 @@ CanvasWidgetCmd( Tk_Item *itemPtr; int isNew = 0; Tcl_HashEntry *entryPtr; - char *arg; + const char *arg; int length; if (objc < 3) { @@ -3316,7 +3316,7 @@ TagSearchScan( TagSearch **searchPtrPtr) /* Record describing tag search; will be * initialized here. */ { - char *tag = Tcl_GetString(tagObj); + const char *tag = Tcl_GetString(tagObj); int i; TagSearch *searchPtr; |