mirror of
https://github.com/dlang/phobos.git
synced 2025-05-12 07:08:48 +03:00
Fix Issue 11175 - Format should support IUnknown classes.
This commit is contained in:
parent
18296f048f
commit
c434dfac4b
1 changed files with 36 additions and 1 deletions
35
std/format.d
35
std/format.d
|
@ -2747,10 +2747,25 @@ if (is(T == interface) && (hasToString!(T, Char) || !is(BuiltinTypeOf!T)) && !is
|
||||||
formatRange(w, val, f);
|
formatRange(w, val, f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
version (Windows)
|
||||||
|
{
|
||||||
|
import std.c.windows.com : IUnknown;
|
||||||
|
static if (is(T : IUnknown))
|
||||||
|
{
|
||||||
|
formatValue(w, *cast(void**)&val, f);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
formatValue(w, cast(Object)val, f);
|
formatValue(w, cast(Object)val, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
formatValue(w, cast(Object)val, f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
@ -2770,6 +2785,26 @@ unittest
|
||||||
}
|
}
|
||||||
Whatever val = new C;
|
Whatever val = new C;
|
||||||
formatTest( val, "ab" );
|
formatTest( val, "ab" );
|
||||||
|
|
||||||
|
// Issue 11175
|
||||||
|
version (Windows)
|
||||||
|
{
|
||||||
|
import core.sys.windows.windows : HRESULT;
|
||||||
|
import std.c.windows.com : IUnknown, IID;
|
||||||
|
|
||||||
|
interface IUnknown2 : IUnknown { }
|
||||||
|
|
||||||
|
class D : IUnknown2
|
||||||
|
{
|
||||||
|
extern(Windows) HRESULT QueryInterface(const(IID)* riid, void** pvObject) { return typeof(return).init; }
|
||||||
|
extern(Windows) uint AddRef() { return 0; }
|
||||||
|
extern(Windows) uint Release() { return 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
IUnknown2 d = new D;
|
||||||
|
string expected = format("%X", cast(void*)d);
|
||||||
|
formatTest(d, expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue