diff options
author | nijtmans <nijtmans> | 2009-01-06 21:58:15 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2009-01-06 21:58:15 (GMT) |
commit | 201429e710c7c59022b3773a0368171bf3475eb6 (patch) | |
tree | 1a968bb5892ca2303852db486e841748082bebb9 /generic | |
parent | 647d64253b5c0c4ad94711d033771789bbc6bc6c (diff) | |
download | tk-201429e710c7c59022b3773a0368171bf3475eb6.zip tk-201429e710c7c59022b3773a0368171bf3475eb6.tar.gz tk-201429e710c7c59022b3773a0368171bf3475eb6.tar.bz2 |
A few const -> CONST86 modifications, improving
backwards compatibility. Change Tk_ItemIndexProc
and Tk_ItemInsertProc signature to have a Tcl_Obj parameter
in stead of a string parameter. This is binary
and source compatible with previous API, it just prevents
the need for a type cast in the Tk_ItemType table construction.
Bring doc in line with API.
Diffstat (limited to 'generic')
-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 |
5 files changed, 52 insertions, 38 deletions
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; |