1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | // |
5 | // class.hpp |
6 | // |
7 | |
8 | #ifndef _CLASS_HPP |
9 | #define _CLASS_HPP |
10 | |
11 | class PermissionDecl; |
12 | class PermissionSetDecl; |
13 | |
14 | extern unsigned int g_uCodePage; |
15 | extern WCHAR wzUniBuf[]; |
16 | |
17 | class Class |
18 | { |
19 | public: |
20 | Class * m_pEncloser; |
21 | LPCUTF8 m_szFQN; |
22 | DWORD m_dwFQN; |
23 | unsigned m_Hash; |
24 | mdTypeDef m_cl; |
25 | mdTypeRef m_crExtends; |
26 | mdTypeRef *m_crImplements; |
27 | TyParDescr* m_TyPars; |
28 | DWORD m_NumTyPars; |
29 | DWORD m_Attr; |
30 | DWORD m_dwNumInterfaces; |
31 | DWORD m_dwNumFieldsWithOffset; |
32 | PermissionDecl* m_pPermissions; |
33 | PermissionSetDecl* m_pPermissionSets; |
34 | ULONG m_ulSize; |
35 | ULONG m_ulPack; |
36 | BOOL m_bIsMaster; |
37 | BOOL m_fNew; |
38 | BOOL m_fNewMembers; |
39 | |
40 | MethodList m_MethodList; |
41 | //MethodSortedList m_MethodSList; |
42 | FieldDList m_FieldDList; |
43 | EventDList m_EventDList; |
44 | PropDList m_PropDList; |
45 | CustomDescrList m_CustDList; |
46 | |
47 | Class(LPCUTF8 pszFQN) |
48 | { |
49 | m_pEncloser = NULL; |
50 | m_cl = mdTypeDefNil; |
51 | m_crExtends = mdTypeRefNil; |
52 | m_NumTyPars = 0; |
53 | m_TyPars = NULL; |
54 | m_dwNumInterfaces = 0; |
55 | m_dwNumFieldsWithOffset = 0; |
56 | m_crImplements = NULL; |
57 | m_szFQN = pszFQN; |
58 | m_dwFQN = pszFQN ? (DWORD)strlen(pszFQN) : 0; |
59 | m_Hash = pszFQN ? hash((const BYTE*)pszFQN, m_dwFQN, 10) : 0; |
60 | |
61 | m_Attr = tdPublic; |
62 | |
63 | m_bIsMaster = TRUE; |
64 | m_fNew = TRUE; |
65 | |
66 | m_pPermissions = NULL; |
67 | m_pPermissionSets = NULL; |
68 | |
69 | m_ulPack = 0; |
70 | m_ulSize = 0xFFFFFFFF; |
71 | } |
72 | |
73 | ~Class() |
74 | { |
75 | delete [] m_szFQN; |
76 | delete [] m_crImplements; |
77 | delete [] m_TyPars; |
78 | } |
79 | |
80 | int FindTyPar(LPCWSTR wz) |
81 | { |
82 | int i,retval=-1; |
83 | for(i=0; i < (int)m_NumTyPars; i++) |
84 | { |
85 | if(!wcscmp(wz,m_TyPars[i].Name())) |
86 | { |
87 | retval = i; |
88 | break; |
89 | } |
90 | } |
91 | return retval; |
92 | }; |
93 | int FindTyPar(LPCUTF8 sz) |
94 | { |
95 | if(sz) |
96 | { |
97 | wzUniBuf[0] = 0; |
98 | WszMultiByteToWideChar(g_uCodePage,0,sz,-1,wzUniBuf,dwUniBuf); |
99 | return FindTyPar(wzUniBuf); |
100 | } |
101 | else return -1; |
102 | }; |
103 | int ComparedTo(Class* T) |
104 | { |
105 | if (m_Hash == T->m_Hash) |
106 | { |
107 | // Properly handle hash conflict |
108 | return (m_szFQN == T->m_szFQN) ? 0 : strcmp(m_szFQN, T->m_szFQN); |
109 | } else |
110 | { |
111 | return (m_Hash > T->m_Hash) ? 1 : -1; |
112 | } |
113 | } |
114 | }; |
115 | |
116 | |
117 | #endif /* _CLASS_HPP */ |
118 | |
119 | |