endianness.h icon indicating copy to clipboard operation
endianness.h copied to clipboard

Big refactoring

Open elgeniusz opened this issue 5 years ago • 3 comments

Split code to API and implementation headers

It was really hard to find, at the first glance, the true API of
the project.

Restructuring the code to the interface and the implementation
headers shall help future users get on track faster.

Extend tests with conversion functions

Network to host and host to network functions are tested now. 

Refactor endianness.h

* All API functions have been moved to endianness.h.
* Postfix "_impl" has been added to the non public functions.
* Added missing POSIX htons, htonl, ntohl, ntohs functions.
* Macros have been reorder for readability.
* Replaced tabs with spaces.
* Enforced 80 characters line lenght limit.

elgeniusz avatar Jan 29 '20 20:01 elgeniusz

thanks for your interest in this project.

Restructuring the code to the interface and the implementation headers shall help future users get on track faster.

you seem to have solved this by having two distinct headers, but this defeats the purpose of having a single-file header... if the API is insufficiently documented, i'd rather see the documentation improved.

Added missing POSIX htons, htonl, ntohl, ntohs functions.

i guess nothing speaks against that, given that you make proper use of the end_ prefix.

Replaced tabs with spaces.

personal style preference - i don't think we want to argue about this topic.

Enforced 80 characters line lenght limit.

this might add a little benefit at least, if it doesn't gratuitously make the code uglier.

Extend tests

thanks, this is a valuable contribution.

rofl0r avatar Jan 29 '20 20:01 rofl0r

Restructuring the code to the interface and the implementation headers shall help future users get on track faster.

you seem to have solved this by having two distinct headers, but this defeats the purpose of having a single-file header... if the API is insufficiently documented, i'd rather see the documentation improved.

DONE - I've moved API macros to the top of the header and removed the implementation header. Now the user clearly sees the API after opening the file for the first time.

Added missing POSIX htons, htonl, ntohl, ntohs functions.

i guess nothing speaks against that, given that you make proper use of the end_ prefix.

DONE - Fixed the commit message. Macros in the code already had a proper prefix.

Replaced tabs with spaces.

personal style preference - i don't think we want to argue about this topic.

DONE - Consistent tabs in all of the code base.

Enforced 80 characters line lenght limit.

this might add a little benefit at least, if it doesn't gratuitously make the code uglier.

DONE - There is only one place where this really changed anything, and I don't think it changes anything from the readability perspective (see endianness.h:169).

elgeniusz avatar Jan 30 '20 16:01 elgeniusz

DONE - I've moved API macros to the top of the header and removed the implementation header. Now the user clearly sees the API after opening the file for the first time.

so the additional _impl redirection layer is no longer actually needed, right ?

DONE - Consistent tabs in all of the code base.

i'd pretty much prefer no whitespace changes at all

rofl0r avatar Jan 31 '20 18:01 rofl0r