schveiguy / raylib-d

Resurrected copy of onroundit's raylib-d
zlib License
55 stars 14 forks source link

Overloaded functions to allow D strings as arguments #48

Open LiamM32 opened 6 months ago

LiamM32 commented 6 months ago

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 commented 5 months ago

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 commented 3 months ago

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