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
9
10
11#ifndef _MANAGEDMDIMPORT_H_
12#define _MANAGEDMDIMPORT_H_
13
14#include "corhdr.h"
15#include "fcall.h"
16#include "runtimehandles.h"
17
18//
19// Keep the struct definitions in sync with bcl\system\reflection\mdimport.cs
20//
21
22typedef struct
23{
24 INT32 m_count;
25 void* m_array;
26} ConstArray;
27
28typedef struct
29{
30 I4Array * largeResult;
31 int length;
32#ifdef _WIN64
33 int padding;
34#endif
35 int smallResult[16];
36} MetadataEnumResult;
37
38#define MDDecl0(RET, NAME) static FCDECL1(RET, NAME, IMDInternalImport* pScope)
39#define MDDecl1(RET, NAME, arg0) static FCDECL2(RET, NAME, IMDInternalImport* pScope, arg0)
40#define MDDecl2(RET, NAME, arg0, arg1) static FCDECL3(RET, NAME, IMDInternalImport* pScope, arg0, arg1)
41#define MDDecl3(RET, NAME, arg0, arg1, arg2) static FCDECL4(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2)
42#define MDDecl4(RET, NAME, arg0, arg1, arg2, arg3) static FCDECL5(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3)
43#define MDDecl5(RET, NAME, arg0, arg1, arg2, arg3, arg4) static FCDECL6(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4)
44#define MDDecl6(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5) static FCDECL7(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5)
45#define MDDecl7(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5, arg6) static FCDECL8(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5, arg6)
46#define MDDecl8(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) static FCDECL9(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
47#define MDDecl9(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) static FCDECL10(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
48#define MDDecl10(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) static FCDECL11(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
49
50#define MDImpl0(RET, NAME) FCIMPL1(RET, NAME, IMDInternalImport* pScope)
51#define MDImpl1(RET, NAME, arg0) FCIMPL2(RET, NAME, IMDInternalImport* pScope, arg0)
52#define MDImpl2(RET, NAME, arg0, arg1) FCIMPL3(RET, NAME, IMDInternalImport* pScope, arg0, arg1)
53#define MDImpl3(RET, NAME, arg0, arg1, arg2) FCIMPL4(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2)
54#define MDImpl4(RET, NAME, arg0, arg1, arg2, arg3) FCIMPL5(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3)
55#define MDImpl5(RET, NAME, arg0, arg1, arg2, arg3, arg4) FCIMPL6(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4)
56#define MDImpl6(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5) FCIMPL7(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5)
57#define MDImpl7(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5, arg6) FCIMPL8(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5, arg6)
58#define MDImpl8(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) FCIMPL9(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
59#define MDImpl9(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) FCIMPL10(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
60#define MDImpl10(RET, NAME, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) FCIMPL11(RET, NAME, IMDInternalImport* pScope, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
61
62class MetaDataImport
63{
64public:
65 //
66 // GetXXXProps
67 //
68 MDDecl1(void, GetScopeProps, GUID* pmvid);
69 MDDecl4(void, GetTypeDefProps, mdTypeDef td, STRINGREF* pszTypeDef, DWORD* pdwTypeDefFlags, mdToken* ptkExtends);
70 MDDecl2(void, GetMemberRefProps, mdMemberRef mr, ConstArray* ppvSigBlob);
71
72
73 ////
74 //// EnumXXX
75 ////
76 MDDecl3(void, Enum, mdToken type, mdToken tkParent, MetadataEnumResult * pResult);
77 MDDecl3(void, GetCustomAttributeProps, mdCustomAttribute cv, mdToken* ptkType, ConstArray* ppBlob);
78
79 ////
80 //// Misc
81 ////
82
83 MDDecl4(Object *, GetDefaultValue, mdToken tk, INT64* pDefaultValue, INT32* pLength, INT32* pCorElementType);
84 MDDecl2(void, GetName, mdToken tk, LPCSTR* pszName);
85 MDDecl3(void, GetUserString, mdToken tk, LPCSTR* pszName, ULONG* pCount);
86 MDDecl2(void, GetNamespace, mdToken tk, LPCSTR* pszName);
87 MDDecl2(void, GetParentToken, mdToken tk, mdToken* ptk);
88 MDDecl3(void, GetParamDefProps, mdToken tk, INT32* pSequence, INT32* pAttributes);
89 MDDecl4(void, GetPinvokeMap, mdToken tk, DWORD* pMappingFlags, LPCSTR* pszImportName, LPCSTR* pszImportDll);
90
91 MDDecl3(void, GetClassLayout, mdTypeDef td, DWORD* pdwPackSize, ULONG* pulClassSize);
92 MDDecl3(FC_BOOL_RET, GetFieldOffset, mdTypeDef td, mdFieldDef target, DWORD* pdwFieldOffset);
93
94 MDDecl3(void, GetEventProps, mdToken tk, LPCSTR* pszName, INT32 *pdwEventFlags);
95 MDDecl2(void, GetGenericParamProps, mdToken tk, DWORD* pAttributes);
96 MDDecl2(void, GetFieldDefProps, mdToken tk, INT32 *pdwFieldFlags);
97 MDDecl4(void, GetPropertyProps, mdToken tk, LPCSTR* pszName, INT32 *pdwPropertyFlags, ConstArray* ppvSigBlob);
98
99 MDDecl2(void, GetSignatureFromToken, mdToken tk, ConstArray* pSig);
100 MDDecl2(void, GetSigOfFieldDef, mdToken tk, ConstArray* pMarshalInfo);
101 MDDecl2(void, GetSigOfMethodDef, mdToken tk, ConstArray* pMarshalInfo);
102 MDDecl2(void, GetFieldMarshal, mdToken tk, ConstArray* pMarshalInfo);
103 MDDecl2(mdParamDef, GetParamForMethodIndex, mdMethodDef md, ULONG ulParamSeq);
104 MDDecl1(FC_BOOL_RET, IsValidToken, mdToken tk);
105 MDDecl1(mdTypeDef, GetNestedClassProps, mdTypeDef tdNestedClass);
106 MDDecl1(ULONG, GetNativeCallConvFromSig, ConstArray sig);
107
108 static FCDECL11(void, GetMarshalAs,
109 BYTE* pvNativeType,
110 ULONG cbNativeType,
111 INT32* unmanagedType,
112 INT32* safeArraySubType,
113 STRINGREF* safeArrayUserDefinedSubType,
114 INT32* arraySubType,
115 INT32* sizeParamIndex,
116 INT32* sizeConst,
117 STRINGREF* marshalType,
118 STRINGREF* marshalCookie,
119 INT32* iidParamIndex);
120};
121
122#endif
123