PageRenderTime 42ms CodeModel.GetById 27ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/binding/win32/guiddef.d

http://github.com/wilkie/djehuty
D | 86 lines | 48 code | 16 blank | 22 comment | 4 complexity | 1409ec7b01d62bdb9be6c3df3883ca0b MD5 | raw file
 1/*
 2 * guiddef.d
 3 *
 4 * This module is a port of guiddef.h to D.
 5 * The original copyright notice appears after this information block.
 6 *
 7 * Author: Dave Wilkinson
 8 * Originated: November 24th, 2009
 9 *
10 */
11
12module binding.win32.guiddef;
13
14//+---------------------------------------------------------------------------
15//
16//  Microsoft Windows
17//  Copyright (c) Microsoft Corporation.  All rights reserved.
18//
19//  File:       guiddef.h
20//
21//  Contents:   GUID definition
22//
23//----------------------------------------------------------------------------
24
25import binding.c;
26
27struct GUID {
28    Culong_t Data1;
29    ushort Data2;
30    ushort Data3;
31    ubyte[8]           Data4;
32
33    GUID define(Culong_t d1, ushort d2, ushort d3, byte b1, byte b2, byte b3, byte b4, byte b5, byte b6, byte b7, byte b8) {
34    	GUID ret;
35    	ret.Data1 = d1;
36    	ret.Data2 = d2;
37    	ret.Data3 = d3;
38
39    	ret.Data4[0] = b1;
40    	ret.Data4[1] = b2;
41    	ret.Data4[2] = b3;
42    	ret.Data4[3] = b4;
43    	ret.Data4[4] = b5;
44    	ret.Data4[5] = b6;
45    	ret.Data4[6] = b7;
46    	ret.Data4[7] = b8;
47
48    	return ret;
49    }
50}
51
52typedef GUID* LPGUID;
53typedef GUID* LPCGUID;
54
55typedef GUID IID;
56typedef IID* LPIID;
57const auto GUID_NULL = GUID.init;
58const auto IID_NULL		= GUID_NULL;
59const auto CLSID_NULL	= GUID_NULL;
60const auto FMTID_NULL	= GUID_NULL;
61
62typedef GUID CLSID;
63typedef CLSID *LPCLSID;
64
65typedef GUID FMTID;
66typedef FMTID *LPFMTID;
67
68typedef GUID REFGUID;
69
70// Faster (but makes code fatter) inline version...use sparingly
71int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2) {
72   return (
73      (cast(Culong_t *) &rguid1)[0] == (cast(Culong_t *) &rguid2)[0] &&
74      (cast(Culong_t *) &rguid1)[1] == (cast(Culong_t *) &rguid2)[1] &&
75      (cast(Culong_t *) &rguid1)[2] == (cast(Culong_t *) &rguid2)[2] &&
76      (cast(Culong_t *) &rguid1)[3] == (cast(Culong_t *) &rguid2)[3]);
77}
78
79int IsEqualGUID(REFGUID rguid1, REFGUID rguid2) {
80    return !memcmp(&rguid1, &rguid2, sizeof(GUID));
81}
82
83// Same type, different name
84
85alias IsEqualGUID IsEqualIID;
86alias IsEqualGUID IsEqualCLSID;