SFML community forums

Bindings - other languages => D => Topic started by: aldarion on April 16, 2016, 05:35:37 pm

Title: DSFML with DUB - object.Object.toString () is not callable using argument types
Post by: aldarion on April 16, 2016, 05:35:37 pm
Hello,

I´m trying to use DFML with dub in a D Project. I have no DSFML related Code in my app.d, I have just added DSFML 2.1.0 to the dependencies in dub.json. If i use "dub build" I get the following Errors:
Performing "debug" build using dmd for x86.
dsfml:system 2.1.0: target for configuration "library" is up to date.
dsfml:audio 2.1.0: building configuration "library"...
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundbuffer.d(63,21): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundbuffer.d(148,22): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundbuffer.d(172,22): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundbuffer.d(196,22): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundbuffer.d(222,22): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundbuffer.d(247,22): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundrecorder.d(61,21): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundrecorder.d(92,21): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundstream.d(82,21): Error: function object.Object.toString () is not callable using argument types (const(char)*)
C:\Users\me\AppData\Roaming\dub\packages\dsfml-2.1.0\src\dsfml\audio\soundstream.d(278,21): Error: function object.Object.toString () is not callable using argument types (const(char)*)
dmd failed with exit code 1.
 

Those Errors seem to be caused by this code:
class SoundBuffer
{
        package sfSoundBuffer* sfPtr;

        this()
        {
                import dsfml.system.string;
                sfPtr = sfSoundBuffer_construct();
                err.write(toString(sfErr_getOutput())); //This is the excact error position.
        }
 
And similar snippets in other modules.
Which is imho related to this code in the module system.string.d:
immutable(T)[] toString(T)(in const(T)* str) pure
        if (is(T == dchar)||is(T == wchar)||is(T == char))
{
        return str[0..strlen(str)].idup;
}
 

I haven´t worked with templates in D yet, but to me it seems allright.
If I skip DSFML.Audio in the dub process, I get similar Errors in Graphics, Window and Network module.
I have tried to comment out the code to skip the "err.write", but some parts in the Network  and the Graphics Module are different, so I cant comment them out.


I´m using DUB 0.9.24 (newest) and DMD 2.071.0 (newest).
Thanks in advance.

Title: Re: DSFML with DUB - object.Object.toString () is not callable using argument types
Post by: Jebbs on April 19, 2016, 05:11:23 pm
This is because of the newest D compiler. They fixed a few long standing bugs, but it ended up breaking the way the import system was doing some things. What was actually happening is that it was using Object.toString() instead of dsfml.system.string.toString() because the compiler will search locally for symbols before checking any imported packages, even packages imported in the same scope. You just need to make sure you're a little more explicit with your calls where there is an ambiguity of function names. 

I put the fixes in the code just a couple of minutes ago, so once dub updates its DSFML package you should be good to go.