Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Changes to make use of TIP 638 routine Tcl_GetNumberFromObj |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tip-638 |
Files: | files | file ages | folders |
SHA3-256: |
42ad10c0b55dec60f1d617b45579bd57 |
User & Date: | dgp 2022-09-30 12:27:23.593 |
Context
2022-10-07
| ||
09:33 | Add some backwards compatibility, so it still works without TIP #638 (with Tcl 8.6). Can be simplified as soon as TIP #638 arrives in Tcl 9.0. check-in: 73479389 user: jan.nijtmans tags: tip-638 | |
2022-09-30
| ||
12:27 | Changes to make use of TIP 638 routine Tcl_GetNumberFromObj check-in: 42ad10c0 user: dgp tags: tip-638 | |
2022-09-27
| ||
17:47 | Fix [f326f30e82]: DestroyMenuInstance(): clear stale pointer. Patch from Christopher Chavez. check-in: 5c8e8017 user: fvogel tags: trunk, main | |
Changes
Changes to generic/tkObj.c.
︙ | ︙ | |||
35 36 37 38 39 40 41 | #define SET_COMPLEXPIXEL(objPtr, repPtr) \ (objPtr)->internalRep.twoPtrValue.ptr1 = NULL; \ (objPtr)->internalRep.twoPtrValue.ptr2 = repPtr #define GET_COMPLEXPIXEL(objPtr) \ ((PixelRep *) (objPtr)->internalRep.twoPtrValue.ptr2) | < < < < < < < < < < < < < < | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #define SET_COMPLEXPIXEL(objPtr, repPtr) \ (objPtr)->internalRep.twoPtrValue.ptr1 = NULL; \ (objPtr)->internalRep.twoPtrValue.ptr2 = repPtr #define GET_COMPLEXPIXEL(objPtr) \ ((PixelRep *) (objPtr)->internalRep.twoPtrValue.ptr2) /* * The following structure is the internal representation for mm objects. */ typedef struct MMRep { double value; int units; |
︙ | ︙ | |||
87 88 89 90 91 92 93 | static void DupMMInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void DupPixelInternalRep(Tcl_Obj *srcPtr, Tcl_Obj*copyPtr); static void DupWindowInternalRep(Tcl_Obj *srcPtr,Tcl_Obj*copyPtr); static void FreeMMInternalRep(Tcl_Obj *objPtr); static void FreePixelInternalRep(Tcl_Obj *objPtr); static void FreeWindowInternalRep(Tcl_Obj *objPtr); | < | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | static void DupMMInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void DupPixelInternalRep(Tcl_Obj *srcPtr, Tcl_Obj*copyPtr); static void DupWindowInternalRep(Tcl_Obj *srcPtr,Tcl_Obj*copyPtr); static void FreeMMInternalRep(Tcl_Obj *objPtr); static void FreePixelInternalRep(Tcl_Obj *objPtr); static void FreeWindowInternalRep(Tcl_Obj *objPtr); static void UpdateStringOfMM(Tcl_Obj *objPtr); static int SetMMFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static int SetPixelFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static int SetWindowFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); #if TCL_MAJOR_VERSION < 9 #ifdef __cplusplus |
︙ | ︙ | |||
162 163 164 165 166 167 168 | static const Tcl_ObjType windowObjType = { "window", /* name */ FreeWindowInternalRep, /* freeIntRepProc */ DupWindowInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ NULL /* setFromAnyProc */ }; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | static const Tcl_ObjType windowObjType = { "window", /* name */ FreeWindowInternalRep, /* freeIntRepProc */ DupWindowInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ NULL /* setFromAnyProc */ }; /* *---------------------------------------------------------------------- * * TkGetIntForIndex -- * * Almost the same as Tcl_GetIntForIndex, but it return an int. Accepts |
︙ | ︙ | |||
278 279 280 281 282 283 284 285 286 287 288 289 | Tk_Window tkwin, Tcl_Obj *objPtr, /* The object from which to get pixels. */ int *intPtr, double *dblPtr) /* Places to store resulting pixels. */ { int result, fresh; double d; PixelRep *pixelPtr; static const double bias[] = { 1.0, 10.0, 25.4, 0.35278 /*25.4 / 72.0*/ }; | > < < < < < < < | > < | > > > | | | | | | > > > | | | | | > > > > > | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | Tk_Window tkwin, Tcl_Obj *objPtr, /* The object from which to get pixels. */ int *intPtr, double *dblPtr) /* Places to store resulting pixels. */ { int result, fresh; double d; Tcl_WideInt w; PixelRep *pixelPtr; static const double bias[] = { 1.0, 10.0, 25.4, 0.35278 /*25.4 / 72.0*/ }; if (objPtr->typePtr != &pixelObjType) { int type; void *ptr; if (TCL_OK == Tcl_GetNumberFromObj(interp, objPtr, &ptr, &type)) { switch (type) { case TCL_NUMBER_DOUBLE: d = *(const double *)ptr; if (dblPtr) { *dblPtr = d; } *intPtr = (int) (d<0 ? d-0.5 : d+0.5); return TCL_OK; case TCL_NUMBER_INT: w = *(const Tcl_WideInt *)ptr; if (w <= INT_MAX && w >= INT_MIN) { *intPtr = (int) w; if (dblPtr) { *dblPtr = (double) (*intPtr); } return TCL_OK; } /* Unhandled cases fall through */ } } } retry: fresh = (objPtr->typePtr != &pixelObjType); if (fresh) { result = SetPixelFromAny(interp, objPtr); |
︙ | ︙ | |||
784 785 786 787 788 789 790 | */ static int SetMMFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ Tcl_Obj *objPtr) /* The object to convert. */ { | < > > > | > | > > > > | > | > > > > | | | | | | | > > | | > > > | > | 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | */ static int SetMMFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ Tcl_Obj *objPtr) /* The object to convert. */ { const Tcl_ObjType *typePtr; const char *string; char *rest; double d; int units; MMRep *mmPtr; int type, needParse = 1; void *ptr; Tcl_WideInt w; if (TCL_OK == Tcl_GetNumberFromObj(NULL, objPtr, &ptr, &type)) { switch (type) { case TCL_NUMBER_DOUBLE: needParse = 0; d = *(const double *)ptr; units = -1; break; case TCL_NUMBER_INT: w = *(const Tcl_WideInt *)ptr; if (w <= INT_MAX && w >= INT_MIN) { needParse = 0; units = (int) w; d = (double) units; units = -1; /* * In the case of ints, we need to ensure that a valid * string exists in order for int-but-not-string objects * to be converted back to ints again from mm obj types. * * TODO: Is this really necessary? */ (void) Tcl_GetString(objPtr); } } } if (needParse) { /* * It wasn't a known int or double, so parse it. */ string = Tcl_GetString(objPtr); d = strtod(string, &rest); |
︙ | ︙ |