raylib-d icon indicating copy to clipboard operation
raylib-d copied to clipboard

Overloaded functions to allow D strings as arguments

Open LiamM32 opened this issue 1 year ago • 2 comments

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 avatar Feb 28 '24 23:02 LiamM32

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?

LiamM32 avatar Mar 22 '24 01:03 LiamM32

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

crazymonkyyy avatar May 23 '24 04:05 crazymonkyyy