Skip to content

Commit

Permalink
Use Tcl_NewBooleanObj() where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed May 1, 2024
2 parents 1c045c9 + 280afa1 commit d52dd6d
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions generic/tk3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,9 +1389,9 @@ TkDebugBorder(
Tcl_Obj *objPtr = Tcl_NewObj();

Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj((Tcl_WideInt)borderPtr->resourceRefCount));
Tcl_NewWideIntObj(borderPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj((Tcl_WideInt)borderPtr->objRefCount));
Tcl_NewWideIntObj(borderPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
Expand Down
4 changes: 2 additions & 2 deletions generic/tkCursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,9 +868,9 @@ TkDebugCursor(
for ( ; (cursorPtr != NULL); cursorPtr = cursorPtr->nextPtr) {
objPtr = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj((Tcl_WideInt)cursorPtr->resourceRefCount));
Tcl_NewWideIntObj(cursorPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj((Tcl_WideInt)cursorPtr->objRefCount));
Tcl_NewWideIntObj(cursorPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
Expand Down
2 changes: 1 addition & 1 deletion generic/tkEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ EntryWidgetObjCmd(
goto error;
}
Tcl_SetObjResult(interp,
Tcl_NewWideIntObj(entryPtr->selectFirst != TCL_INDEX_NONE));
Tcl_NewBooleanObj(entryPtr->selectFirst != TCL_INDEX_NONE));
goto done;

case SELECTION_RANGE:
Expand Down
6 changes: 3 additions & 3 deletions generic/tkWindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,15 +888,15 @@ TkCreateMainWindow(
#if TCL_MAJOR_VERSION > 8
mainPtr->tclUpdateObjProc2 = NULL;
#endif
if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif,
if (Tcl_LinkVar(interp, "tk_strictMotif", (char *)&mainPtr->strictMotif,
TCL_LINK_BOOLEAN) != TCL_OK) {
Tcl_ResetResult(interp);
}
if (Tcl_CreateNamespace(interp, "::tk", NULL, NULL) == NULL) {
Tcl_ResetResult(interp);
}
if (Tcl_LinkVar(interp, "::tk::AlwaysShowSelection",
(char *) &mainPtr->alwaysShowSelection,
(char *)&mainPtr->alwaysShowSelection,
TCL_LINK_BOOLEAN) != TCL_OK) {
Tcl_ResetResult(interp);
}
Expand Down Expand Up @@ -3293,7 +3293,7 @@ Initialize(
Tcl_SetVar2Ex(interp, "argv", NULL,
Tcl_NewListObj(objc-1, rest+1), TCL_GLOBAL_ONLY);
Tcl_SetVar2Ex(interp, "argc", NULL,
Tcl_NewWideIntObj((Tcl_WideInt)objc-1), TCL_GLOBAL_ONLY);
Tcl_NewWideIntObj(objc-1), TCL_GLOBAL_ONLY);
ckfree(rest);
}
Tcl_DecrRefCount(parseList);
Expand Down
2 changes: 1 addition & 1 deletion generic/ttk/ttkEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ static int EntrySelectionPresentCommand(
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
Tcl_NewWideIntObj(entryPtr->entry.selectFirst >= 0));
Tcl_NewBooleanObj(entryPtr->entry.selectFirst >= 0));
return TCL_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions generic/ttk/ttkTreeview.c
Original file line number Diff line number Diff line change
Expand Up @@ -2716,7 +2716,7 @@ static int TreeviewExistsCommand(
}

entryPtr = Tcl_FindHashEntry(&tv->tree.items, Tcl_GetString(objv[2]));
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(entryPtr != 0));
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(entryPtr != 0));
return TCL_OK;
}

Expand Down Expand Up @@ -4036,7 +4036,7 @@ static int TreeviewTagHasCommand(
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
Tcl_NewWideIntObj(Ttk_TagSetContains(item->tagset, tag)));
Tcl_NewBooleanObj(Ttk_TagSetContains(item->tagset, tag)));
return TCL_OK;
} else {
Tcl_WrongNumArgs(interp, 3, objv, "tagName ?item?");
Expand Down
2 changes: 1 addition & 1 deletion generic/ttk/ttkWidget.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ int TtkWidgetInstateCommand(

if (objc == 3) {
Tcl_SetObjResult(interp,
Tcl_NewWideIntObj(Ttk_StateMatches(state,&spec)));
Tcl_NewBooleanObj(Ttk_StateMatches(state,&spec)));
} else if (objc == 4) {
if (Ttk_StateMatches(state,&spec)) {
status = Tcl_EvalObjEx(interp, objv[3], 0);
Expand Down
8 changes: 4 additions & 4 deletions unix/tkUnixWm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,11 +1349,11 @@ WmGetAttribute(
case WMATT_ALPHA:
return Tcl_NewDoubleObj(wmPtr->attributes.alpha);
case WMATT_TOPMOST:
return Tcl_NewWideIntObj(wmPtr->attributes.topmost != 0);
return Tcl_NewBooleanObj(wmPtr->attributes.topmost);
case WMATT_ZOOMED:
return Tcl_NewWideIntObj(wmPtr->attributes.zoomed != 0);
return Tcl_NewBooleanObj(wmPtr->attributes.zoomed);
case WMATT_FULLSCREEN:
return Tcl_NewWideIntObj(wmPtr->attributes.fullscreen != 0);
return Tcl_NewBooleanObj(wmPtr->attributes.fullscreen);
case WMATT_TYPE:
return GetNetWmType(winPtr);
case _WMATT_LAST_ATTRIBUTE:
Expand Down Expand Up @@ -2938,7 +2938,7 @@ WmOverrideredirectCmd(
}
curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
if (objc == 3) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(curValue != 0));
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(curValue));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[3], &boolValue) != TCL_OK) {
Expand Down
2 changes: 1 addition & 1 deletion win/tkWinDialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -3203,7 +3203,7 @@ FontchooserCget(
}
break;
case FontchooserVisible:
resObj = Tcl_NewWideIntObj((hdPtr->hwnd != NULL) && IsWindow(hdPtr->hwnd));
resObj = Tcl_NewBooleanObj((hdPtr->hwnd != NULL) && IsWindow(hdPtr->hwnd));
break;
default:
resObj = Tcl_NewStringObj("", 0);
Expand Down
22 changes: 11 additions & 11 deletions win/tkWinWm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2706,8 +2706,8 @@ Tk_WmObjCmd(
return TCL_ERROR;
}
if (objc == 2) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(dispPtr->flags & TK_DISPLAY_WM_TRACING) != 0));
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
dispPtr->flags & TK_DISPLAY_WM_TRACING));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) {
Expand Down Expand Up @@ -2914,7 +2914,7 @@ WmAttributesCmd(
WmInfo *wmPtr = winPtr->wmInfoPtr;
LONG style, exStyle, styleBit, *stylePtr = NULL;
const char *string;
Bool boolValue;
int boolValue;
Tcl_Size i, length;
int config_fullscreen = 0, updatewrapper = 0;
int fullscreen_attr_changed = 0, fullscreen_attr = 0;
Expand Down Expand Up @@ -2945,19 +2945,19 @@ WmAttributesCmd(
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj("-disabled", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj((style & WS_DISABLED) != 0));
Tcl_NewBooleanObj(style & WS_DISABLED));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj("-fullscreen", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj((wmPtr->flags & WM_FULLSCREEN) != 0));
Tcl_NewBooleanObj(wmPtr->flags & WM_FULLSCREEN));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj("-toolwindow", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj((exStyle & WS_EX_TOOLWINDOW) != 0));
Tcl_NewBooleanObj(exStyle & WS_EX_TOOLWINDOW));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj("-topmost", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj((exStyle & WS_EX_TOPMOST) != 0));
Tcl_NewBooleanObj(exStyle & WS_EX_TOPMOST));
Tcl_SetObjResult(interp, objPtr);
return TCL_OK;
}
Expand Down Expand Up @@ -3105,7 +3105,7 @@ WmAttributesCmd(
config_fullscreen = 0;
} else if (objc == 4) {
Tcl_SetObjResult(interp,
Tcl_NewWideIntObj((*stylePtr & styleBit) != 0));
Tcl_NewBooleanObj(*stylePtr & styleBit));
} else if (boolValue) {
*stylePtr |= styleBit;
} else {
Expand Down Expand Up @@ -4752,7 +4752,7 @@ WmOverrideredirectCmd(
curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
}
if (objc == 3) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(curValue != 0));
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(curValue));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[3], &boolValue) != TCL_OK) {
Expand Down Expand Up @@ -4978,8 +4978,8 @@ WmResizableCmd(
if (objc == 3) {
Tcl_Obj *results[2];

results[0] = Tcl_NewWideIntObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE));
results[1] = Tcl_NewWideIntObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE));
results[0] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE));
results[1] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE));
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
Expand Down

0 comments on commit d52dd6d

Please sign in to comment.