本文整理汇总了C++中MethodDesc::EnsureActive方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodDesc::EnsureActive方法的具体用法?C++ MethodDesc::EnsureActive怎么用?C++ MethodDesc::EnsureActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodDesc
的用法示例。
在下文中一共展示了MethodDesc::EnsureActive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCustomMarshaler
CustomMarshalerInfo::CustomMarshalerInfo(BaseDomain *pDomain, TypeHandle hndCustomMarshalerType, TypeHandle hndManagedType, LPCUTF8 strCookie, DWORD cCookieStrBytes)
: m_NativeSize(0)
, m_hndManagedType(hndManagedType)
, m_hndCustomMarshaler(NULL)
, m_pMarshalNativeToManagedMD(NULL)
, m_pMarshalManagedToNativeMD(NULL)
, m_pCleanUpNativeDataMD(NULL)
, m_pCleanUpManagedDataMD(NULL)
, m_bDataIsByValue(FALSE)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
PRECONDITION(CheckPointer(pDomain));
}
CONTRACTL_END;
// Make sure the custom marshaller implements ICustomMarshaler.
if (!hndCustomMarshalerType.GetMethodTable()->CanCastToNonVariantInterface(MscorlibBinder::GetClass(CLASS__ICUSTOM_MARSHALER)))
{
DefineFullyQualifiedNameForClassW()
COMPlusThrow(kApplicationException,
IDS_EE_ICUSTOMMARSHALERNOTIMPL,
GetFullyQualifiedNameForClassW(hndCustomMarshalerType.GetMethodTable()));
}
// Determine if this type is a value class.
m_bDataIsByValue = m_hndManagedType.GetMethodTable()->IsValueType();
// Custom marshalling of value classes is not currently supported.
if (m_bDataIsByValue)
COMPlusThrow(kNotSupportedException, W("NotSupported_ValueClassCM"));
#ifndef CROSSGEN_COMPILE
// Run the <clinit> on the marshaler since it might not have run yet.
hndCustomMarshalerType.GetMethodTable()->EnsureInstanceActive();
hndCustomMarshalerType.GetMethodTable()->CheckRunClassInitThrowing();
// Create a COM+ string that will contain the string cookie.
STRINGREF CookieStringObj = StringObject::NewString(strCookie, cCookieStrBytes);
GCPROTECT_BEGIN(CookieStringObj);
#endif
// Load the method desc's for all the methods in the ICustomMarshaler interface.
m_pMarshalNativeToManagedMD = GetCustomMarshalerMD(CustomMarshalerMethods_MarshalNativeToManaged, hndCustomMarshalerType);
m_pMarshalManagedToNativeMD = GetCustomMarshalerMD(CustomMarshalerMethods_MarshalManagedToNative, hndCustomMarshalerType);
m_pCleanUpNativeDataMD = GetCustomMarshalerMD(CustomMarshalerMethods_CleanUpNativeData, hndCustomMarshalerType);
m_pCleanUpManagedDataMD = GetCustomMarshalerMD(CustomMarshalerMethods_CleanUpManagedData, hndCustomMarshalerType);
// Load the method desc for the static method to retrieve the instance.
MethodDesc *pGetCustomMarshalerMD = GetCustomMarshalerMD(CustomMarshalerMethods_GetInstance, hndCustomMarshalerType);
// If the GetInstance method is generic, get an instantiating stub for it -
// the CallDescr infrastructure doesn't know how to pass secret generic arguments.
if (pGetCustomMarshalerMD->RequiresInstMethodTableArg())
{
pGetCustomMarshalerMD = MethodDesc::FindOrCreateAssociatedMethodDesc(
pGetCustomMarshalerMD,
hndCustomMarshalerType.GetMethodTable(),
FALSE, // forceBoxedEntryPoint
Instantiation(), // methodInst
FALSE, // allowInstParam
FALSE); // forceRemotableMethod
_ASSERTE(!pGetCustomMarshalerMD->RequiresInstMethodTableArg());
}
#ifndef CROSSGEN_COMPILE
MethodDescCallSite getCustomMarshaler(pGetCustomMarshalerMD, (OBJECTREF*)&CookieStringObj);
pGetCustomMarshalerMD->EnsureActive();
// Prepare the arguments that will be passed to GetCustomMarshaler.
ARG_SLOT GetCustomMarshalerArgs[] = {
ObjToArgSlot(CookieStringObj)
};
// Call the GetCustomMarshaler method to retrieve the custom marshaler to use.
OBJECTREF CustomMarshalerObj = getCustomMarshaler.Call_RetOBJECTREF(GetCustomMarshalerArgs);
if (!CustomMarshalerObj)
{
DefineFullyQualifiedNameForClassW()
COMPlusThrow(kApplicationException,
IDS_EE_NOCUSTOMMARSHALER,
GetFullyQualifiedNameForClassW(hndCustomMarshalerType.GetMethodTable()));
}
m_hndCustomMarshaler = pDomain->CreateHandle(CustomMarshalerObj);
// Retrieve the size of the native data.
if (m_bDataIsByValue)
{
// <TODO>@TODO(DM): Call GetNativeDataSize() to retrieve the size of the native data.</TODO>
_ASSERTE(!"Value classes are not yet supported by the custom marshaler!");
}
else
{
m_NativeSize = sizeof(void *);
//.........这里部分代码省略.........