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 | |
6 | // |
7 | |
8 | #ifndef _REFCLASSWRITER_H_ |
9 | #define _REFCLASSWRITER_H_ |
10 | |
11 | #include "iceefilegen.h" |
12 | |
13 | // RefClassWriter |
14 | // This will create a Class |
15 | class RefClassWriter { |
16 | protected: |
17 | friend class COMDynamicWrite; |
18 | IMetaDataEmit2* m_emitter; // Emit interface. |
19 | IMetaDataImport* m_importer; // Import interface. |
20 | IMDInternalImport* m_internalimport; // Scopeless internal import interface |
21 | ICeeGen* m_pCeeGen; |
22 | ICeeFileGen* m_pCeeFileGen; |
23 | HCEEFILE m_ceeFile; |
24 | IMetaDataEmitHelper* m_pEmitHelper; |
25 | ULONG m_ulResourceSize; |
26 | mdFile m_tkFile; |
27 | IMetaDataEmit* m_pOnDiskEmitter; |
28 | |
29 | public: |
30 | RefClassWriter() { |
31 | LIMITED_METHOD_CONTRACT; |
32 | m_pOnDiskEmitter = NULL; |
33 | } |
34 | |
35 | HRESULT Init(ICeeGen *pCeeGen, IUnknown *pUnk, LPCWSTR szName); |
36 | |
37 | IMetaDataEmit2* GetEmitter() { |
38 | LIMITED_METHOD_CONTRACT; |
39 | return m_emitter; |
40 | } |
41 | |
42 | IMetaDataEmitHelper* GetEmitHelper() { |
43 | LIMITED_METHOD_CONTRACT; |
44 | return m_pEmitHelper; |
45 | } |
46 | |
47 | IMetaDataImport* GetRWImporter() { |
48 | LIMITED_METHOD_CONTRACT; |
49 | return m_importer; |
50 | } |
51 | |
52 | IMDInternalImport* GetMDImport() { |
53 | LIMITED_METHOD_CONTRACT; |
54 | return m_internalimport; |
55 | } |
56 | |
57 | ICeeGen* GetCeeGen() { |
58 | LIMITED_METHOD_CONTRACT; |
59 | return m_pCeeGen; |
60 | } |
61 | |
62 | ICeeFileGen* GetCeeFileGen() { |
63 | LIMITED_METHOD_CONTRACT; |
64 | return m_pCeeFileGen; |
65 | } |
66 | |
67 | HCEEFILE GetHCEEFILE() { |
68 | LIMITED_METHOD_CONTRACT; |
69 | return m_ceeFile; |
70 | } |
71 | |
72 | IMetaDataEmit* GetOnDiskEmitter() { |
73 | LIMITED_METHOD_CONTRACT; |
74 | return m_pOnDiskEmitter; |
75 | } |
76 | |
77 | void SetOnDiskEmitter(IMetaDataEmit *pOnDiskEmitter) { |
78 | CONTRACTL { |
79 | NOTHROW; |
80 | GC_TRIGGERS; |
81 | // we know that the com implementation is ours so we use mode-any to simplify |
82 | // having to switch mode |
83 | MODE_ANY; |
84 | FORBID_FAULT; |
85 | } |
86 | CONTRACTL_END; |
87 | if (pOnDiskEmitter) |
88 | pOnDiskEmitter->AddRef(); |
89 | if (m_pOnDiskEmitter) |
90 | m_pOnDiskEmitter->Release(); |
91 | m_pOnDiskEmitter = pOnDiskEmitter; |
92 | } |
93 | |
94 | |
95 | ~RefClassWriter(); |
96 | }; |
97 | |
98 | #endif // _REFCLASSWRITER_H_ |
99 |