1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// File: WinRTTypeNameConverter.cpp
//
//
//
// ============================================================================
#ifndef FEATURE_COMINTEROP
#error This file should only be included when FEATURE_COMINTEROP is defined
#endif
#pragma once
#include "..\md\winmd\inc\adapter.h"
struct WinRTTypeNameInfo;
//
// Converts between a WinRT type name and TypeHandle
//
class WinRTTypeNameConverter
{
public :
//==============================================================================================
// Managed -> WinRT
//==============================================================================================
//
// Append WinRT type name for the specified type handle
//
static bool AppendWinRTTypeNameForManagedType(
TypeHandle thManagedType,
SString &strWinRTTypeName,
bool bForGetRuntimeClassName,
bool *pbIsPrimitive);
//
// Return the redirection index and type kind if the MethodTable* is a redirected type
//
static bool ResolveRedirectedType(MethodTable *pMT, WinMDAdapter::RedirectedTypeIndex * pIndex, WinMDAdapter::WinMDTypeKind * pKind = NULL);
//
// Append the WinRT type name for the method table, if it is a WinRT primitive type
//
static bool AppendWinRTNameForPrimitiveType(MethodTable *pMT, SString &strName);
//
// Is the specified MethodTable a WinRT primitive type
//
static bool IsWinRTPrimitiveType(MethodTable *pMT)
{
WRAPPER_NO_CONTRACT;
return GetWinRTNameForPrimitiveType(pMT, NULL);
}
//
// Is the specified MethodTable a redirected CLR type?
//
static bool IsRedirectedType(MethodTable *pMT)
{
WRAPPER_NO_CONTRACT;
return ResolveRedirectedType(pMT, NULL);
}
static bool IsRedirectedType(MethodTable *pMT, WinMDAdapter::WinMDTypeKind kind);
//
// Determine if the given type redirected only by doing name comparisons. This is used to
// calculate the redirected type index at EEClass creation time.
//
static WinMDAdapter::RedirectedTypeIndex GetRedirectedTypeIndexByName(
Module *pModule,
mdTypeDef token);
public :
//==============================================================================================
// WinRT -> Managed
//==============================================================================================
//
// Is the specified MethodTable a redirected WinRT type?
//
static bool IsRedirectedWinRTSourceType(MethodTable *pMT);
//
// Get TypeHandle from a WinRT type name
// Parse the WinRT type name in the form of WinRTType=TypeName[<WinRTType[, WinRTType, ...]>]
//
static TypeHandle GetManagedTypeFromWinRTTypeName(LPCWSTR wszWinRTTypeName, bool *pbIsPrimitive);
private :
//
// Get predefined WinRT name for a primitive type
//
static bool GetWinRTNameForPrimitiveType(MethodTable *pMT, SString *pName);
//
// Return MethodTable* for the specified WinRT primitive type name
//
static bool GetMethodTableFromWinRTPrimitiveType(LPCWSTR wszTypeName, UINT32 uTypeNameLen, MethodTable **ppMT);
//
// Return TypeHandle for the specified WinRT type name (supports generic type)
// Updates wszWinRTTypeName pointer as it parse the string
//
static TypeHandle GetManagedTypeFromWinRTTypeNameInternal(SString *ssTypeName, bool *pbIsPrimitive);
//
// Return MethodTable* for the specified WinRT primitive type name (non-generic type)
// Updates wszWinRTTypeName pointer as it parse the string
//
static TypeHandle GetManagedTypeFromSimpleWinRTNameInternal(SString *ssTypeName, bool *pbIsPrimitive);
static bool AppendWinRTTypeNameForManagedType(
TypeHandle thManagedType,
SString &strWinRTTypeName,
bool bForGetRuntimeClassName,
bool *pbIsPrimitive,
WinRTTypeNameInfo *pCurrentTypeInfo);
};
|