mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-09 11:26:29 +00:00
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.
In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.
The script I ran for the src directory is added as build-scripts/clang-format-src.sh
This fixes:
#6592
#6593
#6594
(cherry picked from commit 5750bcb174
)
This commit is contained in:
@@ -31,10 +31,11 @@ static const struct
|
||||
{
|
||||
int code;
|
||||
const char *name;
|
||||
} device_classes[] =
|
||||
{
|
||||
#define CLS(x) \
|
||||
{ SDL_UDEV_DEVICE_ ## x, #x }
|
||||
} device_classes[] = {
|
||||
#define CLS(x) \
|
||||
{ \
|
||||
SDL_UDEV_DEVICE_##x, #x \
|
||||
}
|
||||
CLS(MOUSE),
|
||||
CLS(KEYBOARD),
|
||||
CLS(JOYSTICK),
|
||||
@@ -48,18 +49,18 @@ static const struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
uint16_t bus_type;
|
||||
uint16_t vendor_id;
|
||||
uint16_t product_id;
|
||||
uint16_t version;
|
||||
uint8_t ev[(EV_MAX + 1) / 8];
|
||||
uint8_t keys[(KEY_MAX + 1) / 8];
|
||||
uint8_t abs[(ABS_MAX + 1) / 8];
|
||||
uint8_t rel[(REL_MAX + 1) / 8];
|
||||
uint8_t ff[(FF_MAX + 1) / 8];
|
||||
uint8_t props[INPUT_PROP_MAX / 8];
|
||||
int expected;
|
||||
const char *name;
|
||||
uint16_t bus_type;
|
||||
uint16_t vendor_id;
|
||||
uint16_t product_id;
|
||||
uint16_t version;
|
||||
uint8_t ev[(EV_MAX + 1) / 8];
|
||||
uint8_t keys[(KEY_MAX + 1) / 8];
|
||||
uint8_t abs[(ABS_MAX + 1) / 8];
|
||||
uint8_t rel[(REL_MAX + 1) / 8];
|
||||
uint8_t ff[(FF_MAX + 1) / 8];
|
||||
uint8_t props[INPUT_PROP_MAX / 8];
|
||||
int expected;
|
||||
} GuessTest;
|
||||
|
||||
/*
|
||||
@@ -73,10 +74,11 @@ typedef struct
|
||||
*/
|
||||
#define ZEROx4 0, 0, 0, 0
|
||||
#define ZEROx8 ZEROx4, ZEROx4
|
||||
#define FFx4 0xff, 0xff, 0xff, 0xff
|
||||
#define FFx8 FFx4, FFx4
|
||||
#define FFx4 0xff, 0xff, 0xff, 0xff
|
||||
#define FFx8 FFx4, FFx4
|
||||
|
||||
/* Test-cases derived from real devices or from Linux kernel source */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
static const GuessTest guess_tests[] =
|
||||
{
|
||||
{
|
||||
@@ -934,6 +936,7 @@ static const GuessTest guess_tests[] =
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
}
|
||||
};
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
/* The Linux kernel provides capability info in EVIOCGBIT and in /sys
|
||||
* as an array of unsigned long in native byte order, rather than an array
|
||||
@@ -950,7 +953,7 @@ static const GuessTest guess_tests[] =
|
||||
* an appropriate byteswapping function for the architecture's word size. */
|
||||
SDL_COMPILE_TIME_ASSERT(sizeof_long, sizeof(unsigned long) == 4 || sizeof(unsigned long) == 8);
|
||||
#define SwapLongLE(X) \
|
||||
((sizeof(unsigned long) == 4) ? SDL_SwapLE32(X) : SDL_SwapLE64(X))
|
||||
((sizeof(unsigned long) == 4) ? SDL_SwapLE32(X) : SDL_SwapLE64(X))
|
||||
|
||||
static int
|
||||
run_test(void)
|
||||
@@ -962,7 +965,8 @@ run_test(void)
|
||||
const GuessTest *t = &guess_tests[i];
|
||||
size_t j;
|
||||
int actual;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned long ev[NBITS(EV_MAX)];
|
||||
unsigned long abs[NBITS(ABS_MAX)];
|
||||
unsigned long keys[NBITS(KEY_MAX)];
|
||||
@@ -1033,8 +1037,7 @@ run_test(void)
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return run_test() ? 0 : 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user