Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting updates using newest version of clang-format #2744

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion buildconfig/stubs/pygame/camera.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import List, Optional, Tuple, Union
from typing import List, Optional, Tuple, Union, Literal

from ._common import IntCoordinate

Expand All @@ -9,6 +9,9 @@ def get_backends() -> List[str]: ...
def init(backend: Optional[str] = None) -> None: ...
def quit() -> None: ...
def list_cameras() -> List[str]: ...
def colorspace(
surface: Surface, color: Literal["YUV", "HSV"], dest_surface: Surface = ..., /
) -> Surface: ...

class AbstractCamera(ABC):
@abstractmethod
Expand Down
10 changes: 5 additions & 5 deletions docs/reST/ref/camera.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ The Bayer to ``RGB`` function is based on:
The other big difference is "camera enumeration." Some backends don't have
a way to list out camera names, or even the number of cameras on the
system. In these cases, :func:`list_cameras()` will return
something like ``[0]``. If you know you have multiple cameras on the
system, these backend ports will pass through a "camera index number"
something like ``[0]``. If you know you have multiple cameras on the
system, these backend ports will pass through a "camera index number"
through if you use that as the ``device`` parameter.

.. versionaddedold:: 2.0.3
Expand All @@ -100,7 +100,7 @@ The Bayer to ``RGB`` function is based on:
.. function:: colorspace

| :sl:`Surface colorspace conversion`
| :sg:`colorspace(Surface, format, DestSurface = None, /) -> Surface`
| :sg:`colorspace(surface, format, dest_surface = None, /) -> Surface`
Allows for conversion from "RGB" to a destination colorspace of "HSV" or
"YUV". The source and destination surfaces must be the same size and pixel
Expand Down Expand Up @@ -132,7 +132,7 @@ The Bayer to ``RGB`` function is based on:
Loads a camera. On Linux, the device is typically something like
"/dev/video0". Default width and height are 640 by 480.
Format is the desired colorspace of the output.
Format is the desired colorspace of the output.
This is useful for computer vision purposes. The default is
``RGB``. The following are supported:

Expand Down Expand Up @@ -214,7 +214,7 @@ The Bayer to ``RGB`` function is based on:
frame when called with a blocking function like :func:`get_image()`.
On Windows (MSMF), and the OpenCV backends, :func:`query_image()`
should be reliable, though. This is useful to separate the framerate of
the game from that of the camera without having to use threading.
the game from that of the camera without having to use threading.

.. ## Camera.query_image ##
Expand Down
3 changes: 2 additions & 1 deletion src_c/SDL_gfx/SDL_gfxPrimitives.c
Original file line number Diff line number Diff line change
Expand Up @@ -4226,7 +4226,8 @@ lrint(double flt)
#include <armintr.h>
#pragma warning(push)
#pragma warning(disable : 4716)
__declspec(naked) long int lrint(double flt)
__declspec(naked) long int
lrint(double flt)
{
__emit(0xEC410B10); // fmdrr d0, r0, r1
__emit(0xEEBD0B40); // ftosid s0, d0
Expand Down
2 changes: 1 addition & 1 deletion src_c/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && \
!defined(round)
#define pg_round(d) (((d < 0) ? (ceil((d)-0.5)) : (floor((d) + 0.5))))
#define pg_round(d) (((d < 0) ? (ceil((d) - 0.5)) : (floor((d) + 0.5))))
#else
#define pg_round(d) round(d)
#endif
Expand Down
2 changes: 1 addition & 1 deletion src_c/doc/camera_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define DOC_CAMERA "pygame module for camera use"
#define DOC_CAMERA_INIT "init(backend = None) -> None\nModule init"
#define DOC_CAMERA_GETBACKENDS "get_backends() -> [str]\nGet the backends supported on this system"
#define DOC_CAMERA_COLORSPACE "colorspace(Surface, format, DestSurface = None, /) -> Surface\nSurface colorspace conversion"
#define DOC_CAMERA_COLORSPACE "colorspace(surface, format, dest_surface = None, /) -> Surface\nSurface colorspace conversion"
#define DOC_CAMERA_LISTCAMERAS "list_cameras() -> [cameras]\nreturns a list of available cameras"
#define DOC_CAMERA_CAMERA "Camera(device, (width, height), format) -> Camera\nload a camera"
#define DOC_CAMERA_CAMERA_START "start() -> None\nopens, initializes, and starts capturing"
Expand Down
2 changes: 1 addition & 1 deletion src_c/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ dict_from_event(SDL_Event *event)
}
break;
#endif /* (defined(unix) || ... */
} /* switch (event->type) */
} /* switch (event->type) */
/* Events that dont have any attributes are not handled in switch
* statement */
SDL_Window *window;
Expand Down
51 changes: 25 additions & 26 deletions src_c/freetype/ft_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ ft_wrap_quit(pgFontObject *);
*
*********************************************************/
void
_PGFT_SetError(FreeTypeInstance *ft, const char *error_msg, FT_Error error_id)
{
_PGFT_SetError(FreeTypeInstance *ft, const char *error_msg, FT_Error error_id){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file are weird... but we will just go with whatever clang-format is doing here

#undef __FTERRORS_H__
#define FT_ERRORDEF(e, v, s) {e, s},
#define FT_ERROR_START_LIST {
Expand All @@ -49,37 +48,37 @@ _PGFT_SetError(FreeTypeInstance *ft, const char *error_msg, FT_Error error_id)
} \
} \
;
static const struct {
int err_code;
const char *err_msg;
} ft_errors[] =
static const struct {int err_code;
const char *err_msg;
}
ft_errors[] =
#include FT_ERRORS_H

const int maxlen = (int)(sizeof(ft->_error_msg)) - 1;
int i;
const char *ft_msg;
const int maxlen = (int)(sizeof(ft->_error_msg)) - 1;
int i;
const char *ft_msg;

ft_msg = 0;
for (i = 0; ft_errors[i].err_msg; ++i) {
if (error_id == ft_errors[i].err_code) {
ft_msg = ft_errors[i].err_msg;
break;
}
ft_msg = 0;
for (i = 0; ft_errors[i].err_msg; ++i) {
if (error_id == ft_errors[i].err_code) {
ft_msg = ft_errors[i].err_msg;
break;
}
}

if (error_id && ft_msg) {
int ret = PyOS_snprintf(ft->_error_msg, sizeof(ft->_error_msg),
"%.*s: %s", maxlen - 3, error_msg, ft_msg);
if (ret >= 0) {
/* return after successfully copying full or truncated error.
* If ret < 0, PyOS_snprintf failed so try to strncpy error
* message */
return;
}
if (error_id && ft_msg) {
int ret = PyOS_snprintf(ft->_error_msg, sizeof(ft->_error_msg), "%.*s: %s",
maxlen - 3, error_msg, ft_msg);
if (ret >= 0) {
/* return after successfully copying full or truncated error.
* If ret < 0, PyOS_snprintf failed so try to strncpy error
* message */
return;
}
}

strncpy(ft->_error_msg, error_msg, maxlen);
ft->_error_msg[maxlen] = '\0'; /* in case of message truncation */
strncpy(ft->_error_msg, error_msg, maxlen);
ft->_error_msg[maxlen] = '\0'; /* in case of message truncation */
}

const char *
Expand Down
Loading