Skip to content

Add SDL3_net#50

Open
suve wants to merge 8 commits into
PascalGameDevelopment:mainfrom
suve:add-SDL3_net
Open

Add SDL3_net#50
suve wants to merge 8 commits into
PascalGameDevelopment:mainfrom
suve:add-SDL3_net

Conversation

@suve

@suve suve commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Work in progress. Opening the PR early to avoid duplicating work.

@suve suve marked this pull request as ready for review July 3, 2026 14:59
@suve

suve commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Finished and ready for review.

@Free-Pascal-meets-SDL-Website

Copy link
Copy Markdown
Contributor

Work in progress. Opening the PR early to avoid duplicating work.

Perfect. Indeed I was eying this "project" already. :D

I'm gonna review soon.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi there,

just reviewed your contribution. Basically it is well done, as always.

I'd suggest some minor changes as hinted to by the comments:

  • usually the type def. order is double pointer (first), pointer (second) and type (third); that is how it is throughout our project; while reviewing I wondered, if the other way round would be better in that the comment above the type def. would be bound to the type and not to the double pointer def. as you usually are interested in the original type rather than one of the pointer types (should we change that? What's your opinion?)
  • although not needed, I'd suggest to close even one line statements in functions by semi-colon

Now, this is important (therefore request changes status instead of approve): Please update the README.MD:

  • remove "(not published yet)" from the unit list (Installation part)
  • add "adds SDL3_net unit" in the versions part

Best regards
Matthias

Comment thread units/SDL3_net.pas
*
* \since This enum is available since SDL_net 3.0.0.
*)
TNET_Status = type cint;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For consistency, we usually do it in this order:

doublepointer def
pointer def
type def (below)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, as you noticed in the main comment, I did it like this so the doc-comment is attached to the t-def, not the pp-def.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay, so ignore the def-order comments then. We should update the style guide in this regard and make it flexible (allow both ways) or prefer the "new" order with this reasoning. What would you say?

Comment thread units/SDL3_net.pas
* \sa NET_GetLocalAddresses
* \sa NET_CompareAddresses
*)
PNET_Address = Type Pointer;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor 1: "type" lower case
Minor 2: switch order of defs

Comment thread units/SDL3_net.pas
* \sa NET_WriteToStreamSocket
* \sa NET_ReadFromStreamSocket
*)
PNET_StreamSocket = type Pointer;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Switch order of defs

Comment thread units/SDL3_net.pas
* \sa NET_CreateServer
*)
PNET_Server = type Pointer;
PPNET_Server = ^PNET_Server;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Switch def order

Comment thread units/SDL3_net.pas
* \sa NET_GetStreamSocketPendingWrites
* \sa NET_WaitUntilStreamSocketDrained
*)
procedure NET_DestroyStreamSocket(sock: PNET_StreamSocket); cdecl;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing inline comment: "/* Destroy your sockets when finished with them. Does not block, handles shutdown internally. */"

Not sure why this comment is inlined. Should we add it?

Comment thread units/SDL3_net.pas
* \sa NET_SendDatagram
* \sa NET_ReceiveDatagram
*)
PNET_DatagramSocket = type Pointer;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Switch def order

Comment thread units/SDL3_net.pas
buf: pcuint8; (**< the payload of this datagram. *)
buflen: cint; (**< the number of bytes available at `buf`. *)
end;
PNET_Datagram = ^TNET_Datagram;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Switch def order

Comment thread units/SDL3_net.pas

function SDL_NET_VERSION(): Integer;
begin
Result := SDL_VERSIONNUM(SDL_NET_MAJOR_VERSION, SDL_NET_MINOR_VERSION, SDL_NET_MICRO_VERSION)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Close by semi colon

Comment thread units/SDL3_net.pas
begin
Result := (SDL_NET_MAJOR_VERSION >= major) and
((SDL_NET_MAJOR_VERSION > major) or (SDL_NET_MINOR_VERSION >= minor)) and
((SDL_NET_MAJOR_VERSION > major) or (SDL_NET_MINOR_VERSION > minor) or (SDL_NET_MICRO_VERSION >= micro))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Close by semi colon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants