Skip to content

Commit

Permalink
(backport) Add TkLengthOne() function, just as TclLengthOne() in Tcl,…
Browse files Browse the repository at this point in the history
… for optimization within Tk internal objTypes. Only functional when compiling with Tcl 9.0 headers
  • Loading branch information
jan.nijtmans committed Jul 10, 2024
1 parent 50b13ee commit 1d0390a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion generic/tkColor.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const TkObjType tkColorObjType = {
DupColorObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL, /* setFromAnyProc */
TCL_OBJTYPE_V0},
TCL_OBJTYPE_V1(TkLengthOne)},
0
};

Expand Down
2 changes: 1 addition & 1 deletion generic/tkCursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const TkObjType tkCursorObjType = {
DupCursorObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL, /* setFromAnyProc */
TCL_OBJTYPE_V0},
TCL_OBJTYPE_V1(TkLengthOne)},
0
};

Expand Down
4 changes: 4 additions & 0 deletions generic/tkInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,9 @@ typedef struct {
#ifndef TCL_OBJTYPE_V0
# define TCL_OBJTYPE_V0 /* just empty */
#endif
#ifndef TCL_OBJTYPE_V1
# define TCL_OBJTYPE_V1(lengthProc) /* just empty */
#endif

MODULE_SCOPE const TkObjType tkBorderObjType;
MODULE_SCOPE const TkObjType tkBitmapObjType;
Expand Down Expand Up @@ -1330,6 +1333,7 @@ MODULE_SCOPE void TkpDrawFrameEx(Tk_Window tkwin, Drawable drawable,
int borderWidth, int relief);
MODULE_SCOPE void TkpShowBusyWindow(TkBusy busy);
MODULE_SCOPE void TkpHideBusyWindow(TkBusy busy);
MODULE_SCOPE Tcl_Size TkLengthOne(Tcl_Obj *);
MODULE_SCOPE void TkpMakeTransparentWindowExist(Tk_Window tkwin,
Window parent);
MODULE_SCOPE void TkpCreateBusy(Tk_FakeWin *winPtr, Tk_Window tkRef,
Expand Down
11 changes: 9 additions & 2 deletions generic/tkObj.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,17 @@ static const TkObjType pixelObjType = {
DupPixelInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL, /* setFromAnyProc */
TCL_OBJTYPE_V0},
TCL_OBJTYPE_V1(TkLengthOne)},
0
};

Tcl_Size
TkLengthOne(
TCL_UNUSED(Tcl_Obj *))
{
return 1;
}

/*
* The following structure defines the implementation of the "pixel" Tcl
* object, used for measuring distances. The pixel object remembers its
Expand All @@ -153,7 +160,7 @@ static const TkObjType mmObjType = {
DupMMInternalRep, /* dupIntRepProc */
UpdateStringOfMM, /* updateStringProc */
NULL, /* setFromAnyProc */
TCL_OBJTYPE_V0},
TCL_OBJTYPE_V1(TkLengthOne)},
0
};

Expand Down

0 comments on commit 1d0390a

Please sign in to comment.