SDL API renaming: *Is* functions

Feedback from @icculus:
"IsTablet" uses "is" as a form of "to be" ...like, the actual question is of its nature.

The rest is just a superfluous word in the question and it flows as better English with if (RectEmpty) than if (IsRectEmpty)

Fixes https://github.com/libsdl-org/SDL/issues/6932
This commit is contained in:
Sam Lantinga
2022-12-28 19:34:01 -08:00
parent 66351fd4ba
commit ea0c2f55be
34 changed files with 174 additions and 180 deletions

View File

@@ -201,7 +201,7 @@ void loop()
SDLTest_TextWindowAddText(textwin, "%s", event.text.text);
break;
case SDL_FINGERDOWN:
if (SDL_IsTextInputActive()) {
if (SDL_TextInputActive()) {
SDL_Log("Stopping text input\n");
SDL_StopTextInput();
} else {
@@ -214,7 +214,7 @@ void loop()
if (event.button.button == SDL_BUTTON_LEFT) {
done = 1;
} else {
if (SDL_IsTextInputActive()) {
if (SDL_TextInputActive()) {
SDL_Log("Stopping text input\n");
SDL_StopTextInput();
} else {

View File

@@ -191,7 +191,7 @@ void loop()
if (event.button.button == SDL_BUTTON_LEFT) {
done = 1;
} else {
if (SDL_IsTextInputActive()) {
if (SDL_TextInputActive()) {
SDL_Log("Stopping text input\n");
SDL_StopTextInput();
} else {

View File

@@ -360,7 +360,7 @@ void _validateUnionRectResults(
}
/* !
* \brief Private helper to check SDL_IsRectEmpty results
* \brief Private helper to check SDL_RectEmpty results
*/
void _validateRectEmptyResults(
SDL_bool empty, SDL_bool expectedEmpty,
@@ -378,7 +378,7 @@ void _validateRectEmptyResults(
}
/* !
* \brief Private helper to check SDL_AreRectsEqual results
* \brief Private helper to check SDL_RectsEqual results
*/
void _validateRectEqualsResults(
SDL_bool equals, SDL_bool expectedEquals,
@@ -401,7 +401,7 @@ void _validateRectEqualsResults(
}
/* !
* \brief Private helper to check SDL_FRectEquals results
* \brief Private helper to check SDL_RectsEqualF results
*/
void _validateFRectEqualsResults(
SDL_bool equals, SDL_bool expectedEquals,
@@ -648,7 +648,7 @@ int rect_testIntersectRectEmpty(void *arg)
rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
empty = SDL_IsRectEmpty(&result);
empty = SDL_RectEmpty(&result);
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
/* Rect B empty */
@@ -665,7 +665,7 @@ int rect_testIntersectRectEmpty(void *arg)
rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
empty = SDL_IsRectEmpty(&result);
empty = SDL_RectEmpty(&result);
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
/* Rect A and B empty */
@@ -684,7 +684,7 @@ int rect_testIntersectRectEmpty(void *arg)
rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
empty = SDL_IsRectEmpty(&result);
empty = SDL_RectEmpty(&result);
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
return TEST_COMPLETED;
@@ -1510,10 +1510,10 @@ int rect_testUnionRectParam(void *arg)
}
/* !
* \brief Tests SDL_IsRectEmpty() with various inputs
* \brief Tests SDL_RectEmpty() with various inputs
*
* \sa
* http://wiki.libsdl.org/SDL_IsRectEmpty
* http://wiki.libsdl.org/SDL_RectEmpty
*/
int rect_testRectEmpty(void *arg)
{
@@ -1530,7 +1530,7 @@ int rect_testRectEmpty(void *arg)
refRect.h = SDLTest_RandomIntegerInRange(256, 1024);
expectedResult = SDL_FALSE;
rect = refRect;
result = SDL_IsRectEmpty(&rect);
result = SDL_RectEmpty(&rect);
_validateRectEmptyResults(result, expectedResult, &rect, &refRect);
/* Empty case */
@@ -1543,7 +1543,7 @@ int rect_testRectEmpty(void *arg)
refRect.h = h;
expectedResult = SDL_TRUE;
rect = refRect;
result = SDL_IsRectEmpty(&rect);
result = SDL_RectEmpty(&rect);
_validateRectEmptyResults(result, expectedResult, &rect, &refRect);
}
}
@@ -1553,27 +1553,27 @@ int rect_testRectEmpty(void *arg)
}
/* !
* \brief Negative tests against SDL_IsRectEmpty() with invalid parameters
* \brief Negative tests against SDL_RectEmpty() with invalid parameters
*
* \sa
* http://wiki.libsdl.org/SDL_IsRectEmpty
* http://wiki.libsdl.org/SDL_RectEmpty
*/
int rect_testRectEmptyParam(void *arg)
{
SDL_bool result;
/* invalid parameter combinations */
result = SDL_IsRectEmpty(NULL);
result = SDL_RectEmpty(NULL);
SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL");
return TEST_COMPLETED;
}
/* !
* \brief Tests SDL_AreRectsEqual() with various inputs
* \brief Tests SDL_RectsEqual() with various inputs
*
* \sa
* http://wiki.libsdl.org/SDL_AreRectsEqual
* http://wiki.libsdl.org/SDL_RectsEqual
*/
int rect_testRectEquals(void *arg)
{
@@ -1593,17 +1593,17 @@ int rect_testRectEquals(void *arg)
expectedResult = SDL_TRUE;
rectA = refRectA;
rectB = refRectB;
result = SDL_AreRectsEqual(&rectA, &rectB);
result = SDL_RectsEqual(&rectA, &rectB);
_validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED;
}
/* !
* \brief Negative tests against SDL_AreRectsEqual() with invalid parameters
* \brief Negative tests against SDL_RectsEqual() with invalid parameters
*
* \sa
* http://wiki.libsdl.org/SDL_AreRectsEqual
* http://wiki.libsdl.org/SDL_RectsEqual
*/
int rect_testRectEqualsParam(void *arg)
{
@@ -1622,21 +1622,21 @@ int rect_testRectEqualsParam(void *arg)
rectB.h = SDLTest_RandomIntegerInRange(1, 1024);
/* invalid parameter combinations */
result = SDL_AreRectsEqual(NULL, &rectB);
result = SDL_RectsEqual(NULL, &rectB);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
result = SDL_AreRectsEqual(&rectA, NULL);
result = SDL_RectsEqual(&rectA, NULL);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
result = SDL_AreRectsEqual(NULL, NULL);
result = SDL_RectsEqual(NULL, NULL);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
return TEST_COMPLETED;
}
/* !
* \brief Tests SDL_FRectEquals() with various inputs
* \brief Tests SDL_RectsEqualF() with various inputs
*
* \sa
* http://wiki.libsdl.org/SDL_FRectEquals
* http://wiki.libsdl.org/SDL_RectsEqualF
*/
int rect_testFRectEquals(void *arg)
{
@@ -1656,17 +1656,17 @@ int rect_testFRectEquals(void *arg)
expectedResult = SDL_TRUE;
rectA = refRectA;
rectB = refRectB;
result = SDL_FRectEquals(&rectA, &rectB);
result = SDL_RectsEqualF(&rectA, &rectB);
_validateFRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED;
}
/* !
* \brief Negative tests against SDL_FRectEquals() with invalid parameters
* \brief Negative tests against SDL_RectsEqualF() with invalid parameters
*
* \sa
* http://wiki.libsdl.org/SDL_FRectEquals
* http://wiki.libsdl.org/SDL_RectsEqualF
*/
int rect_testFRectEqualsParam(void *arg)
{
@@ -1685,11 +1685,11 @@ int rect_testFRectEqualsParam(void *arg)
rectB.h = SDLTest_RandomFloat();
/* invalid parameter combinations */
result = SDL_FRectEquals(NULL, &rectB);
result = SDL_RectsEqualF(NULL, &rectB);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
result = SDL_FRectEquals(&rectA, NULL);
result = SDL_RectsEqualF(&rectA, NULL);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
result = SDL_FRectEquals(NULL, NULL);
result = SDL_RectsEqualF(NULL, NULL);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
return TEST_COMPLETED;
@@ -1804,33 +1804,33 @@ static const SDLTest_TestCaseReference rectTest25 = {
(SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_GetRectUnion with invalid parameters", TEST_ENABLED
};
/* SDL_IsRectEmpty */
/* SDL_RectEmpty */
static const SDLTest_TestCaseReference rectTest26 = {
(SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_IsRectEmpty with various inputs", TEST_ENABLED
(SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED
};
static const SDLTest_TestCaseReference rectTest27 = {
(SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_IsRectEmpty with invalid parameters", TEST_ENABLED
(SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED
};
/* SDL_AreRectsEqual */
/* SDL_RectsEqual */
static const SDLTest_TestCaseReference rectTest28 = {
(SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_AreRectsEqual with various inputs", TEST_ENABLED
(SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectsEqual with various inputs", TEST_ENABLED
};
static const SDLTest_TestCaseReference rectTest29 = {
(SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_AreRectsEqual with invalid parameters", TEST_ENABLED
(SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectsEqual with invalid parameters", TEST_ENABLED
};
/* SDL_FRectEquals */
/* SDL_RectsEqualF */
static const SDLTest_TestCaseReference rectTest30 = {
(SDLTest_TestCaseFp)rect_testFRectEquals, "rect_testFRectEquals", "Tests SDL_FRectEquals with various inputs", TEST_ENABLED
(SDLTest_TestCaseFp)rect_testFRectEquals, "rect_testFRectEquals", "Tests SDL_RectsEqualF with various inputs", TEST_ENABLED
};
static const SDLTest_TestCaseReference rectTest31 = {
(SDLTest_TestCaseFp)rect_testFRectEqualsParam, "rect_testFRectEqualsParam", "Negative tests against SDL_FRectEquals with invalid parameters", TEST_ENABLED
(SDLTest_TestCaseFp)rect_testFRectEqualsParam, "rect_testFRectEqualsParam", "Negative tests against SDL_RectsEqualF with invalid parameters", TEST_ENABLED
};
/* !

View File

@@ -52,8 +52,8 @@ int video_enableDisableScreensaver(void *arg)
SDL_bool result;
/* Get current state and proceed according to current state */
initialResult = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
initialResult = SDL_ScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
if (initialResult == SDL_TRUE) {
/* Currently enabled: disable first, then enable again */
@@ -61,16 +61,16 @@ int video_enableDisableScreensaver(void *arg)
/* Disable screensaver and check */
SDL_DisableScreenSaver();
SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
result = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
result = SDL_ScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
/* Enable screensaver and check */
SDL_EnableScreenSaver();
SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
result = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
result = SDL_ScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
} else {
@@ -79,16 +79,16 @@ int video_enableDisableScreensaver(void *arg)
/* Enable screensaver and check */
SDL_EnableScreenSaver();
SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
result = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
result = SDL_ScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
/* Disable screensaver and check */
SDL_DisableScreenSaver();
SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
result = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
result = SDL_ScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
}
return TEST_COMPLETED;

View File

@@ -440,7 +440,7 @@ static SDL_GamepadButton FindButtonAtPosition(int x, int y)
rect.y = button_positions[i].y;
rect.w = BUTTON_SIZE;
rect.h = BUTTON_SIZE;
if (SDL_IsPointInRect(&point, &rect)) {
if (SDL_PointInRect(&point, &rect)) {
return (SDL_GamepadButton)i;
}
}
@@ -463,7 +463,7 @@ static SDL_GamepadAxis FindAxisAtPosition(int x, int y)
rect.y = axis_positions[i].y;
rect.w = AXIS_SIZE;
rect.h = AXIS_SIZE;
if (SDL_IsPointInRect(&point, &rect)) {
if (SDL_PointInRect(&point, &rect)) {
return (SDL_GamepadAxis)i;
}
}

View File

@@ -32,7 +32,7 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
int w, h;
for (i = 0; i < numareas; i++) {
if (SDL_IsPointInRect(pt, &areas[i])) {
if (SDL_PointInRect(pt, &areas[i])) {
SDL_Log("HIT-TEST: DRAGGABLE\n");
return SDL_HITTEST_DRAGGABLE;
}

View File

@@ -120,7 +120,7 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_Rect viewport)
cell_rect.w = text_length * FONT_CHARACTER_SIZE;
cell_rect.h = lineHeight;
if (SDL_IsPointInRect(&mouse_pos, &cell_rect)) {
if (SDL_PointInRect(&mouse_pos, &cell_rect)) {
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
/* Update cached mode under the mouse */