Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Minor corrections. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
dcb134ea099d4958d25f3b6742e66a9b |
User & Date: | dkf 2011-11-01 23:22:00 |
Context
2011-11-02
| ||
09:31 | A better way of managing the type cache across the tkObj.c file. check-in: 8c2f350d user: dkf tags: trunk | |
2011-11-01
| ||
23:22 | Minor corrections. check-in: dcb134ea user: dkf tags: trunk | |
22:57 | Minor: Capitalization/formatting in changelog. check-in: 3e78af60 user: dkf tags: trunk | |
Changes
Changes to generic/tkObj.c.
︙ | ︙ | |||
44 45 46 47 48 49 50 | * data. In this case, it is used to contain references to selected * Tcl_ObjTypes that we can use as screen distances without conversion. The * "dataKey" below is used to locate the ThreadSpecificData for the current * thread. */ typedef struct ThreadSpecificData { | | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | * data. In this case, it is used to contain references to selected * Tcl_ObjTypes that we can use as screen distances without conversion. The * "dataKey" below is used to locate the ThreadSpecificData for the current * thread. */ typedef struct ThreadSpecificData { const Tcl_ObjType *doubleTypePtr; const Tcl_ObjType *intTypePtr; } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; /* * The following structure is the internal representation for mm objects. */ |
︙ | ︙ | |||
78 79 80 81 82 83 84 | } WindowRep; /* * Prototypes for functions defined later in this file: */ static void DupMMInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); | | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | } WindowRep; /* * Prototypes for functions defined later in this file: */ 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); |
︙ | ︙ | |||
159 160 161 162 163 164 165 | GetPixelsFromObjEx( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ Tk_Window tkwin, Tcl_Obj *objPtr, /* The object from which to get pixels. */ int *intPtr, double *dblPtr) /* Places to store resulting pixels. */ { | | | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | GetPixelsFromObjEx( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ 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*/ }; /* * Special hacks where the type of the object is known to be something * that is just numeric and cannot require distance conversion. This pokes * holes in Tcl's abstractions, but they are just for optimization, not * semantics. */ if (objPtr->typePtr != &pixelObjType) { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->doubleTypePtr == NULL) { tsdPtr->doubleTypePtr = Tcl_GetObjType("double"); tsdPtr->intTypePtr = Tcl_GetObjType("int"); } |
︙ | ︙ | |||
199 200 201 202 203 204 205 | *dblPtr = (double) (*intPtr); } return TCL_OK; } } retry: | | > < < < | | < > | | | | | | | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | *dblPtr = (double) (*intPtr); } return TCL_OK; } } retry: fresh = (objPtr->typePtr != &pixelObjType); if (fresh) { result = SetPixelFromAny(interp, objPtr); if (result != TCL_OK) { return result; } } if (SIMPLE_PIXELREP(objPtr)) { *intPtr = GET_SIMPLEPIXEL(objPtr); if (dblPtr) { *dblPtr = (double) (*intPtr); } } else { pixelPtr = GET_COMPLEXPIXEL(objPtr); if ((!fresh) && (pixelPtr->tkwin != tkwin)) { /* * In the case of exo-screen conversions of non-pixels, we force a * recomputation from the string. */ FreePixelInternalRep(objPtr); goto retry; } if ((pixelPtr->tkwin != tkwin) || dblPtr) { d = pixelPtr->value; if (pixelPtr->units >= 0) { d *= bias[pixelPtr->units] * WidthOfScreen(Tk_Screen(tkwin)); d /= WidthMMOfScreen(Tk_Screen(tkwin)); } if (d < 0) { pixelPtr->returnValue = (int) (d - 0.5); } else { pixelPtr->returnValue = (int) (d + 0.5); } pixelPtr->tkwin = tkwin; if (dblPtr) { *dblPtr = d; } } *intPtr = pixelPtr->returnValue; } return TCL_OK; } |
︙ | ︙ | |||
274 275 276 277 278 279 280 | int Tk_GetPixelsFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ Tk_Window tkwin, Tcl_Obj *objPtr, /* The object from which to get pixels. */ int *intPtr) /* Place to store resulting pixels. */ { | | | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | int Tk_GetPixelsFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ Tk_Window tkwin, Tcl_Obj *objPtr, /* The object from which to get pixels. */ int *intPtr) /* Place to store resulting pixels. */ { return GetPixelsFromObjEx(interp, tkwin, objPtr, intPtr, NULL); } /* *---------------------------------------------------------------------- * * Tk_GetDoublePixelsFromObj -- * |
︙ | ︙ | |||
306 307 308 309 310 311 312 | Tk_GetDoublePixelsFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ Tk_Window tkwin, Tcl_Obj *objPtr, /* The object from which to get pixels. */ double *doublePtr) /* Place to store resulting pixels. */ { double d; | | | | | > | > > | | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | Tk_GetDoublePixelsFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ Tk_Window tkwin, Tcl_Obj *objPtr, /* The object from which to get pixels. */ double *doublePtr) /* Place to store resulting pixels. */ { double d; int result, val; result = GetPixelsFromObjEx(interp, tkwin, objPtr, &val, &d); if (result != TCL_OK) { return result; } if (objPtr->typePtr == &pixelObjType && !SIMPLE_PIXELREP(objPtr)) { PixelRep *pixelPtr = GET_COMPLEXPIXEL(objPtr); if (pixelPtr->units >= 0) { /* * Internally "shimmer" to pixel units. */ pixelPtr->units = -1; pixelPtr->value = d; } } *doublePtr = d; return TCL_OK; } /* |
︙ | ︙ | |||
1018 1019 1020 1021 1022 1023 1024 | int *allPtr) /* Write the total padding here */ { int firstInt, secondInt; /* The two components of the padding */ int objc; /* The length of the list (should be 1 or 2) */ Tcl_Obj **objv; /* The objects in the list */ /* | | | | | 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | int *allPtr) /* Write the total padding here */ { int firstInt, secondInt; /* The two components of the padding */ int objc; /* The length of the list (should be 1 or 2) */ Tcl_Obj **objv; /* The objects in the list */ /* * Check for a common case where a single object would otherwise be * shimmered between a list and a pixel spec. */ if (specObj->typePtr == &pixelObjType) { if (Tk_GetPixelsFromObj(interp, tkwin, specObj, &firstInt) != TCL_OK){ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "bad pad value \"", Tcl_GetString(specObj), "\": must be positive screen distance", NULL); return TCL_ERROR; } secondInt = firstInt; |
︙ | ︙ |