Skip to content

Commit ac48f55

Browse files
committed
run clang-format
1 parent 32200b3 commit ac48f55

File tree

4 files changed

+192
-118
lines changed

4 files changed

+192
-118
lines changed

setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from setuptools import setup, Extension
2+
import subprocess
3+
import shlex
4+
import glob
25
import sys
36

47
extensions = [
@@ -17,5 +20,13 @@ def build() -> None:
1720

1821

1922
if __name__ == "__main__":
23+
if "format" in sys.argv:
24+
c_files = glob.glob("src_c/*.c")
25+
h_files = glob.glob("src_c/include/*.h")
26+
27+
cmd = ["clang-format", "-i"] + c_files + h_files
28+
print(shlex.join(cmd))
29+
sys.exit(subprocess.call(cmd))
30+
2031
build()
2132

src_c/collisions.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#include "include/collisions.h"
22

3-
43
static int
5-
pgCollision_LineLine(pgLineBase* A, pgLineBase* B) {
4+
pgCollision_LineLine(pgLineBase *A, pgLineBase *B)
5+
{
66
double x1_m_x2 = A->x1 - A->x2;
77
double y3_m_y4 = B->y1 - B->y2;
88
double y1_m_y2 = A->y1 - A->y2;
99
double x3_m_x4 = B->x1 - B->x2;
10-
10+
1111
double den = x1_m_x2 * y3_m_y4 - y1_m_y2 * x3_m_x4;
1212

13-
if (!den) return 0;
13+
if (!den)
14+
return 0;
1415

1516
double x1_m_x3 = A->x1 - B->x1;
1617
double y1_m_y3 = A->y1 - B->y1;
@@ -25,7 +26,8 @@ pgCollision_LineLine(pgLineBase* A, pgLineBase* B) {
2526
}
2627

2728
static int
28-
pgIntersection_LineLine(pgLineBase* A, pgLineBase* B, double* X, double* Y) {
29+
pgIntersection_LineLine(pgLineBase *A, pgLineBase *B, double *X, double *Y)
30+
{
2931
double x1 = A->x1;
3032
double y1 = A->y1;
3133
double x2 = A->x2;
@@ -39,10 +41,11 @@ pgIntersection_LineLine(pgLineBase* A, pgLineBase* B, double* X, double* Y) {
3941
double y3_m_y4 = y3 - y4;
4042
double y1_m_y2 = y1 - y2;
4143
double x3_m_x4 = x3 - x4;
42-
44+
4345
double den = x1_m_x2 * y3_m_y4 - y1_m_y2 * x3_m_x4;
4446

45-
if (!den) return 0;
47+
if (!den)
48+
return 0;
4649

4750
double x1_m_x3 = x1 - x3;
4851
double y1_m_y3 = y1 - y3;
@@ -54,29 +57,35 @@ pgIntersection_LineLine(pgLineBase* A, pgLineBase* B, double* X, double* Y) {
5457
double u = -(u1 / den);
5558

5659
if (t >= 0 && t <= 1 && u >= 0 && u <= 1) {
57-
if (X) *X = x1 + t * (x2 - x1);
58-
if (Y) *Y = y1 + t * (y2 - y1);
60+
if (X)
61+
*X = x1 + t * (x2 - x1);
62+
if (Y)
63+
*Y = y1 + t * (y2 - y1);
5964
return 1;
6065
}
6166
return 0;
6267
}
6368

6469
static int
65-
pgCollision_LineCircle(pgLineBase* line, pgCircleBase* circle) {
70+
pgCollision_LineCircle(pgLineBase *line, pgCircleBase *circle)
71+
{
6672
return 0;
6773
}
6874

6975
static int
70-
pgCollision_CircleCircle(pgCircleBase* A, pgCircleBase* B) {
76+
pgCollision_CircleCircle(pgCircleBase *A, pgCircleBase *B)
77+
{
7178
return 0;
7279
}
7380

7481
static int
75-
pgCollision_RectLine(SDL_FRect* rect, pgLineBase* line) {
82+
pgCollision_RectLine(SDL_FRect *rect, pgLineBase *line)
83+
{
7684
return 0;
7785
}
7886

7987
static int
80-
pgCollision_RectCircle(SDL_FRect* rect, pgCircleBase* circle) {
88+
pgCollision_RectCircle(SDL_FRect *rect, pgCircleBase *circle)
89+
{
8190
return 0;
8291
}

src_c/geometry.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ MODINIT_DEFINE(geometry)
8686
c_api[15] = pgCircle_New3;
8787
c_api[16] = pgCircle_FromObject;
8888

89-
9089
apiobj = encapsulate_api(c_api, "geometry");
9190
if (PyModule_AddObject(module, PYGAMEAPI_LOCAL_ENTRY, apiobj)) {
9291
Py_XDECREF(apiobj);

0 commit comments

Comments
 (0)