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// COMDynamic.h
6// This module defines the native methods that are used for Dynamic IL generation
7
8////////////////////////////////////////////////////////////////////////////////
9
10#ifndef _COMDYNAMIC_H_
11#define _COMDYNAMIC_H_
12
13#include "iceefilegen.h"
14#include "dbginterface.h"
15
16typedef enum PEFileKinds {
17 Dll = 0x1,
18 ConsoleApplication = 0x2,
19 WindowApplication = 0x3,
20} PEFileKinds;
21
22struct ExceptionInstance;
23
24// COMDynamicWrite
25// This class defines all the methods that implement the dynamic IL creation process
26// inside reflection.
27class COMDynamicWrite
28{
29public:
30 // This function will create the class's metadata definition
31 static
32 INT32 QCALLTYPE DefineType(QCall::ModuleHandle pModule,
33 LPCWSTR wszFullName,
34 INT32 tkParent,
35 INT32 attributes,
36 INT32 tkEnclosingType,
37 INT32 * pInterfaceTokens);
38
39 static
40 INT32 QCALLTYPE DefineGenericParam(QCall::ModuleHandle pModule,
41 LPCWSTR wszFullName,
42 INT32 tkParent,
43 INT32 attributes,
44 INT32 position,
45 INT32 * pConstraintTokens);
46
47 // This function will reset the parent class in metadata
48 static
49 void QCALLTYPE SetParentType(QCall::ModuleHandle pModule, INT32 tdType, INT32 tkParent);
50
51 // This function will add another interface impl
52 static
53 void QCALLTYPE AddInterfaceImpl(QCall::ModuleHandle pModule, INT32 tdType, INT32 tkInterface);
54
55 // This function will create a method within the class
56 static
57 INT32 QCALLTYPE DefineMethod(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, LPCBYTE pSignature, INT32 sigLength, INT32 attributes);
58
59 static
60 INT32 QCALLTYPE DefineMethodSpec(QCall::ModuleHandle pModule, INT32 tkParent, LPCBYTE pSignature, INT32 sigLength);
61
62 // This function will create a method within the class
63 static
64 void QCALLTYPE SetMethodIL(QCall::ModuleHandle pModule,
65 INT32 tk,
66 BOOL fIsInitLocal,
67 LPCBYTE pBody,
68 INT32 cbBody,
69 LPCBYTE pLocalSig,
70 INT32 sigLength,
71 UINT16 maxStackSize,
72 ExceptionInstance * pExceptions,
73 INT32 numExceptions,
74 INT32 * pTokenFixups,
75 INT32 numTokenFixups);
76
77 static
78 void QCALLTYPE TermCreateClass(QCall::ModuleHandle pModule, INT32 tk, QCall::ObjectHandleOnStack retType);
79
80 static
81 mdFieldDef QCALLTYPE DefineField(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, LPCBYTE pSignature, INT32 sigLength, INT32 attr);
82
83 static
84 void QCALLTYPE SetPInvokeData(QCall::ModuleHandle pModule, LPCWSTR wszDllName, LPCWSTR wszFunctionName, INT32 token, INT32 linkFlags);
85
86 static
87 INT32 QCALLTYPE DefineProperty(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, INT32 attr, LPCBYTE pSignature, INT32 sigLength);
88
89 static
90 INT32 QCALLTYPE DefineEvent(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, INT32 attr, INT32 tkEventType);
91
92 // functions to set Setter, Getter, Reset, TestDefault, and other methods
93 static
94 void QCALLTYPE DefineMethodSemantics(QCall::ModuleHandle pModule, INT32 tkAssociation, INT32 attr, INT32 tkMethod);
95
96 // functions to set method's implementation flag
97 static
98 void QCALLTYPE SetMethodImpl(QCall::ModuleHandle pModule, INT32 tkMethod, INT32 attr);
99
100 // functions to create MethodImpl record
101 static
102 void QCALLTYPE DefineMethodImpl(QCall::ModuleHandle pModule, UINT32 tkType, UINT32 tkBody, UINT32 tkDecl);
103
104 // GetTokenFromSig's argument
105 static
106 INT32 QCALLTYPE GetTokenFromSig(QCall::ModuleHandle pModule, LPCBYTE pSignature, INT32 sigLength);
107
108 // Set Field offset
109 static
110 void QCALLTYPE SetFieldLayoutOffset(QCall::ModuleHandle pModule, INT32 tkField, INT32 iOffset);
111
112 // Set classlayout info
113 static
114 void QCALLTYPE SetClassLayout(QCall::ModuleHandle pModule, INT32 tk, INT32 iPackSize, UINT32 iTotalSize);
115
116 // Set a custom attribute
117 static
118 void QCALLTYPE DefineCustomAttribute(QCall::ModuleHandle pModule, INT32 token, INT32 conTok, LPCBYTE pBlob, INT32 cbBlob, BOOL toDisk, BOOL updateCompilerFlags);
119
120 // functions to set ParamInfo
121 static
122 INT32 QCALLTYPE SetParamInfo(QCall::ModuleHandle pModule, UINT32 tkMethod, UINT32 iSequence, UINT32 iAttributes, LPCWSTR wszParamName);
123
124 // functions to set default value
125 static
126 void QCALLTYPE SetConstantValue(QCall::ModuleHandle pModule, UINT32 tk, DWORD valueType, LPVOID pValue);
127};
128
129#endif // _COMDYNAMIC_H_
130