1 module aurora.directx.com;
2 
3 version(Windows):
4 
5 public import core.sys.windows.windows;
6 public import core.sys.windows.com;
7 
8 import core.atomic;
9 
10 public:
11 
12 mixin(uuid!(IUnknown, "00000000-0000-0000-C000-000000000046"));
13 mixin(uuid!(IClassFactory,"00000001-0000-0000-C000-000000000046"));
14 
15 public struct LUID {
16 	uint LowPart;
17 	int HighPart;
18 }
19 
20 struct GUID {
21   ulong  Data1;
22   ushort Data2;
23   ushort Data3;
24   ubyte[8] Data4;
25 }
26 alias GUID UUID;
27 
28 public struct SIZE {
29 	long X;
30 	long Y;
31 }
32 
33 struct FILETIME {
34   uint dwLowDateTime;
35   uint dwHighDateTime;
36 }
37 
38 struct FONTSIGNATURE
39 {
40     int[4] fsUsb;
41     int[2] fsCsb;
42 }
43 
44 public template uuid(T, const char[] g) {
45 	const char [] uuid =
46 		"const IID IID_" ~ T.stringof ~ "={ 0x" ~ g[0..8] ~ ",0x" ~ g[9..13] ~ ",0x" ~ g[14..18] ~ ",[0x" ~ g[19..21] ~ ",0x" ~ g[21..23] ~ ",0x" ~ g[24..26] ~ ",0x" ~ g[26..28] ~ ",0x" ~ g[28..30] ~ ",0x" ~ g[30..32] ~ ",0x" ~ g[32..34] ~ ",0x" ~ g[34..36] ~ "]};" ~
47 		"template uuidof(T:" ~ T.stringof ~ "){" ~
48 		"    const IID uuidof ={ 0x" ~ g[0..8] ~ ",0x" ~ g[9..13] ~ ",0x" ~ g[14..18] ~ ",[0x" ~ g[19..21] ~ ",0x" ~ g[21..23] ~ ",0x" ~ g[24..26] ~ ",0x" ~ g[26..28] ~ ",0x" ~ g[28..30] ~ ",0x" ~ g[30..32] ~ ",0x" ~ g[32..34] ~ ",0x" ~ g[34..36] ~ "]};"~
49 		"}";
50 }
51 
52 public struct STATSTG {
53 	LPOLESTR       pwcsName;
54 	DWORD          type;
55 	ULARGE_INTEGER cbSize;
56 	FILETIME       mtime;
57 	FILETIME       ctime;
58 	FILETIME       atime;
59 	DWORD          grfMode;
60 	DWORD          grfLocksSupported;
61 	CLSID          clsid;
62 	DWORD          grfStateBits;
63 	DWORD          reserved;
64 }
65 
66 public class DXPtr(T : IUnknown)
67 {
68 	private T _value = null;
69 
70 	public @property T value() { return _value; }
71 	alias value this;
72 
73 	public this(T value) {
74 		_value = value;
75 	}
76 
77 	public void opAssign(T value) {
78 		if(_value !is null) {
79 			_value.Release();
80 			_value = value;
81 		} else {
82 			_value = value;
83 		}
84 	}
85 
86 	public ~this() {
87 		if(_value !is null) {
88 			_value.Release();
89 			_value = null;
90 		}
91 	}
92 }
93 
94 mixin(uuid!(ISequentialStream, "0C733A30-2A1C-11CE-ADE5-00AA0044773D"));
95 public interface ISequentialStream : IUnknown
96 {
97 extern(Windows):
98 	HRESULT Read(void *pv, ULONG cb, ULONG *pcbRead);
99 	HRESULT Write(const void *pv, ULONG cb, ULONG *pcbWritten);
100 }
101 
102 mixin(uuid!(IStream, "0C733A30-2A1C-11CE-ADE5-00AA0044773D"));
103 public interface IStream : ISequentialStream
104 {
105 extern(Windows):
106 	HRESULT Clone(IStream *ppstm);
107 	HRESULT Commit(uint grfCommitFlags);
108 	HRESULT CopyTo(IStream pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
109 	HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, uint dwLockType);
110 	HRESULT Revert();
111 	HRESULT Seek(LARGE_INTEGER dlibMove, uint dwOrigin, ULARGE_INTEGER *plibNewPosition);
112 	HRESULT SetSize(ULARGE_INTEGER libNewSize);
113 	HRESULT Stat(STATSTG *pstatstg, uint grfStatFlag);
114 	HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, uint dwLockType);
115 }
116 
117 mixin(uuid!(IPrintDocumentPackageTarget, "1b8efec4-3019-4c27-964e-367202156906"));
118 public interface IPrintDocumentPackageTarget : IUnknown
119 {
120 extern(Windows):
121 	HRESULT Cancel();
122 	HRESULT GetPackageTarget(GUID* guidTargetType, IID* riid, void **ppvTarget);
123 	HRESULT GetPackageTargetTypes(uint *targetCount, GUID **targetTypes);
124 }
125 
126 mixin(uuid!(IEnumUnknown, "00000100-0000-0000-C000-000000000046"));
127 public interface IEnumUnknown : IUnknown
128 {
129 extern(Windows):
130 	HRESULT Clone(IEnumUnknown **ppenum);
131 	HRESULT Next(ulong celt, IUnknown **rgelt, ulong *pceltFetched);
132 	HRESULT Reset();
133 	HRESULT Skip(ulong celt);
134 }
135 
136 mixin(uuid!(IEnumString, "00000101-0000-0000-C000-000000000046"));
137 public interface IEnumString : IUnknown
138 {
139 extern(Windows):
140 	HRESULT Clone(IEnumString **ppenum);
141 	HRESULT Next(ulong celt, LPOLESTR *rgelt, ulong *pceltFetched);
142 	HRESULT Reset();
143 	HRESULT Skip(ulong celt);
144 }