Skip to content
New issue

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

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

Already on GitHub? # to your account

Overloaded functions to allow D strings as arguments #48

Open
LiamM32 opened this issue Feb 28, 2024 · 2 comments
Open

Overloaded functions to allow D strings as arguments #48

LiamM32 opened this issue Feb 28, 2024 · 2 comments

Comments

@LiamM32
Copy link
Contributor

LiamM32 commented Feb 28, 2024

Some functions here have const(char)* as an argument type, which is used to pass strings to C functions. Calling these functions using D strings instead sometimes, but not always works.

I propose that new versions of these functions are added that have D strings as arguments. They will all convert the D strings to C-style strings using getStringz from std.string, and then call the original version of the function. Those that have cost(char)* as their return type will instead have string as their return type when using a D string as an argument.

@LiamM32
Copy link
Contributor Author

LiamM32 commented Mar 22, 2024

I have my own forked repository now. If I get around to it, I may make this and commit it.

Should the overloaded versions of the functions be placed right underneath the declarations for the current ones (which use const(char)*), or should they all be placed in their own block of lines later in the file?

@crazymonkyyy
Copy link

I have my own forked repository now. If I get around to it, I may make this and commit it.

Should the overloaded versions of the functions be placed right underneath the declarations for the current ones (which use const(char)*), or should they all be placed in their own block of lines later in the file?

Id write a script that scans for function headers with char* functions, pulls out the lines and then add that as an string[] enum
then make a mixin tempate makestringoverload(alias stringtype,alias tostringz)

theres probably to much debate to use Phobos toStringz directly and it wouldnt be that much harder to make it genertic

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants