本文整理汇总了C++中qcall::ModuleHandle类的典型用法代码示例。如果您正苦于以下问题:C++ ModuleHandle类的具体用法?C++ ModuleHandle怎么用?C++ ModuleHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModuleHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TermCreateClass
void QCALLTYPE COMDynamicWrite::TermCreateClass(QCall::ModuleHandle pModule, INT32 tk, QCall::ObjectHandleOnStack retType)
{
QCALL_CONTRACT;
TypeHandle typeHnd;
BEGIN_QCALL;
_ASSERTE(pModule->GetReflectionModule()->GetClassWriter());
// Use the same service, regardless of whether we are generating a normal
// class, or the special class for the module that holds global functions
// & methods.
pModule->GetReflectionModule()->AddClass(tk);
// manually load the class if it is not the global type
if (!IsNilToken(tk))
{
TypeKey typeKey(pModule, tk);
typeHnd = pModule->GetClassLoader()->LoadTypeHandleForTypeKey(&typeKey, TypeHandle());
}
if (!typeHnd.IsNull())
{
GCX_COOP();
retType.Set(typeHnd.GetManagedClassObject());
}
END_QCALL;
return;
}
示例2: DefineType
INT32 QCALLTYPE COMDynamicWrite::DefineType(QCall::ModuleHandle pModule,
LPCWSTR wszFullName,
INT32 tkParent,
INT32 attributes,
INT32 tkEnclosingType,
INT32 * pInterfaceTokens)
{
QCALL_CONTRACT;
mdTypeDef classE = mdTokenNil;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
HRESULT hr;
if (RidFromToken(tkEnclosingType))
{
// defining nested type
hr = pRCW->GetEmitter()->DefineNestedType(wszFullName,
attributes,
tkParent == 0 ? mdTypeRefNil : tkParent,
(mdToken *)pInterfaceTokens,
tkEnclosingType,
&classE);
}
else
{
// top level type
hr = pRCW->GetEmitter()->DefineTypeDef(wszFullName,
attributes,
tkParent == 0 ? mdTypeRefNil : tkParent,
(mdToken *)pInterfaceTokens,
&classE);
}
if (hr == META_S_DUPLICATE)
{
COMPlusThrow(kArgumentException, W("Argument_DuplicateTypeName"));
}
if (FAILED(hr)) {
_ASSERTE(hr == E_OUTOFMEMORY || !"DefineTypeDef Failed");
COMPlusThrowHR(hr);
}
AllocMemTracker amTracker;
pModule->GetClassLoader()->AddAvailableClassDontHaveLock(pModule,
classE,
&amTracker);
amTracker.SuppressRelease();
END_QCALL;
return (INT32)classE;
}
示例3: LoadInMemoryTypeByName
FCIMPLEND
//**************************************************
// LoadInMemoryTypeByName
// Explicitly loading an in memory type
// <TODO>@todo: this function is not dealing with nested type correctly yet.
// We will need to parse the full name by finding "+" for enclosing type, etc.</TODO>
//**************************************************
void QCALLTYPE COMModule::LoadInMemoryTypeByName(QCall::ModuleHandle pModule, LPCWSTR wszFullName)
{
QCALL_CONTRACT;
TypeHandle typeHnd;
BEGIN_QCALL;
if (!pModule->IsReflection())
COMPlusThrow(kNotSupportedException, W("NotSupported_NonReflectedType"));
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// it is ok to use public import API because this is a dynamic module anyway. We are also receiving Unicode full name as
// parameter.
IMetaDataImport * pImport = pRCW->GetRWImporter();
if (wszFullName == NULL)
IfFailThrow( E_FAIL );
// look up the handle
mdTypeDef td;
HRESULT hr = pImport->FindTypeDefByName(wszFullName, mdTokenNil, &td);
if (FAILED(hr))
{
if (hr != CLDB_E_RECORD_NOTFOUND)
COMPlusThrowHR(hr);
// Get the UTF8 version of strFullName
MAKE_UTF8PTR_FROMWIDE(szFullName, wszFullName);
pModule->GetAssembly()->ThrowTypeLoadException(szFullName, IDS_CLASSLOAD_GENERAL);
}
TypeKey typeKey(pModule, td);
typeHnd = pModule->GetClassLoader()->LoadTypeHandleForTypeKey(&typeKey, TypeHandle());
END_QCALL;
return;
}
示例4: DefineProperty
/*============================DefineProperty============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
INT32 QCALLTYPE COMDynamicWrite::DefineProperty(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, INT32 attr, LPCBYTE pSignature, INT32 sigLength)
{
QCALL_CONTRACT;
mdProperty pr = mdTokenNil;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Define the Property
IfFailThrow(pRCW->GetEmitter()->DefineProperty(
tkParent, // ParentTypeDef
wszName, // Name of Member
attr, // property Attributes (prDefaultProperty, etc);
(PCCOR_SIGNATURE)pSignature, // Blob value of a COM+ signature
sigLength, // Size of the signature blob
ELEMENT_TYPE_VOID, // don't specify the default value
0, // no default value
(ULONG) -1, // optional length
mdMethodDefNil, // no setter
mdMethodDefNil, // no getter
NULL, // no other methods
&pr));
END_QCALL;
return (INT32)pr;
}
示例5: SetParamInfo
/*============================SetParamInfo============================
**Action: Helper to set parameter information
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
INT32 QCALLTYPE COMDynamicWrite::SetParamInfo(QCall::ModuleHandle pModule, UINT32 tkMethod, UINT32 iSequence, UINT32 iAttributes, LPCWSTR wszParamName)
{
QCALL_CONTRACT;
mdParamDef retVal = 0;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Set the methodimpl flags
IfFailThrow(pRCW->GetEmitter()->DefineParam(
tkMethod,
iSequence, // sequence of the parameter
wszParamName,
iAttributes, // change the impl flags
ELEMENT_TYPE_VOID,
0,
(ULONG) -1,
&retVal));
END_QCALL;
return (INT32)retVal;
}
示例6: DefineMethod
INT32 QCALLTYPE COMDynamicWrite::DefineMethod(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, LPCBYTE pSignature, INT32 sigLength, INT32 attributes)
{
QCALL_CONTRACT;
mdMethodDef memberE = mdTokenNil;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Define the Method
IfFailThrow( pRCW->GetEmitter()->DefineMethod(tkParent, //ParentTypeDef
wszName, //Name of Member
attributes, //Member Attributes (public, etc);
(PCCOR_SIGNATURE)pSignature, //Blob value of a COM+ signature
sigLength, //Size of the signature blob
0, //Code RVA
miIL | miManaged, //Implementation Flags is default to managed IL
&memberE) ); //[OUT]methodToken
END_QCALL;
return (INT32) memberE;
}
示例7: GetArrayMethodToken
/*=============================GetArrayMethodToken==============================
**Action:
**Returns:
**Arguments: REFLECTMODULEBASEREF refThis
** U1ARRAYREF sig
** STRINGREF methodName
** int tkTypeSpec
**Exceptions:
==============================================================================*/
INT32 QCALLTYPE COMModule::GetArrayMethodToken(QCall::ModuleHandle pModule,
INT32 tkTypeSpec,
LPCWSTR wszMethodName,
LPCBYTE pSignature,
INT32 sigLength)
{
QCALL_CONTRACT;
mdMemberRef memberRefE = mdTokenNil;
BEGIN_QCALL;
if (!wszMethodName)
COMPlusThrow(kArgumentNullException, W("ArgumentNull_String"));
if (!tkTypeSpec)
COMPlusThrow(kArgumentNullException, W("ArgumentNull_Type"));
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
HRESULT hr = pRCW->GetEmitter()->DefineMemberRef(tkTypeSpec, wszMethodName, (PCCOR_SIGNATURE)pSignature, sigLength, &memberRefE);
if (FAILED(hr))
{
_ASSERTE(!"Failed on DefineMemberRef");
COMPlusThrowHR(hr);
}
END_QCALL;
return (INT32)memberRefE;
}
示例8: AddInterfaceImpl
// This function will add another interface impl
void QCALLTYPE COMDynamicWrite::AddInterfaceImpl(QCall::ModuleHandle pModule, INT32 tdType, INT32 tkInterface)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
IfFailThrow( pRCW->GetEmitHelper()->AddInterfaceImpl(tdType, tkInterface) );
END_QCALL;
}
示例9: SetParentType
// This function will reset the parent class in metadata
void QCALLTYPE COMDynamicWrite::SetParentType(QCall::ModuleHandle pModule, INT32 tdType, INT32 tkParent)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
IfFailThrow( pRCW->GetEmitHelper()->SetTypeParent(tdType, tkParent) );
END_QCALL;
}
示例10: SetConstantValue
/*============================SetConstantValue============================
**Action: Helper to set constant value to field or parameter
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetConstantValue(QCall::ModuleHandle pModule, UINT32 tk, DWORD valueCorType, LPVOID pValue)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
HRESULT hr;
if (TypeFromToken(tk) == mdtFieldDef)
{
hr = pRCW->GetEmitter()->SetFieldProps(
tk, // [IN] The FieldDef.
ULONG_MAX, // [IN] Field attributes.
valueCorType, // [IN] Flag for the value type, selected ELEMENT_TYPE_*
pValue, // [IN] Constant value.
(ULONG) -1); // [IN] Optional length.
}
else if (TypeFromToken(tk) == mdtProperty)
{
hr = pRCW->GetEmitter()->SetPropertyProps(
tk, // [IN] The PropertyDef.
ULONG_MAX, // [IN] Property attributes.
valueCorType, // [IN] Flag for the value type, selected ELEMENT_TYPE_*
pValue, // [IN] Constant value.
(ULONG) -1, // [IN] Optional length.
mdMethodDefNil, // [IN] Getter method.
mdMethodDefNil, // [IN] Setter method.
NULL); // [IN] Other methods.
}
else
{
hr = pRCW->GetEmitter()->SetParamProps(
tk, // [IN] The ParamDef.
NULL,
ULONG_MAX, // [IN] Parameter attributes.
valueCorType, // [IN] Flag for the value type, selected ELEMENT_TYPE_*
pValue, // [IN] Constant value.
(ULONG) -1); // [IN] Optional length.
}
if (FAILED(hr)) {
_ASSERTE(!"Set default value is failing");
COMPlusThrow(kArgumentException, W("Argument_BadConstantValue"));
}
END_QCALL;
}
示例11: SetMethodImpl
/*============================SetMethodImpl============================
** To set a Method's Implementation flags
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetMethodImpl(QCall::ModuleHandle pModule, INT32 tkMethod, INT32 attr)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Set the methodimpl flags
IfFailThrow(pRCW->GetEmitter()->SetMethodImplFlags(
tkMethod,
attr)); // change the impl flags
END_QCALL;
}
示例12: SetFieldLayoutOffset
/*============================SetFieldLayoutOffset============================
**Action: set fieldlayout of a field
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetFieldLayoutOffset(QCall::ModuleHandle pModule, INT32 tkField, INT32 iOffset)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Set the field layout
IfFailThrow(pRCW->GetEmitHelper()->SetFieldLayoutHelper(
tkField, // field
iOffset)); // layout offset
END_QCALL;
}
示例13: DefineMethodImpl
/*============================DefineMethodImpl============================
** Define a MethodImpl record
==============================================================================*/
void QCALLTYPE COMDynamicWrite::DefineMethodImpl(QCall::ModuleHandle pModule, UINT32 tkType, UINT32 tkBody, UINT32 tkDecl)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Set the methodimpl flags
IfFailThrow(pRCW->GetEmitter()->DefineMethodImpl(
tkType,
tkBody,
tkDecl)); // change the impl flags
END_QCALL;
}
示例14: DefineMethodSemantics
/*============================DefineMethodSemantics============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::DefineMethodSemantics(QCall::ModuleHandle pModule, INT32 tkAssociation, INT32 attr, INT32 tkMethod)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Define the MethodSemantics
IfFailThrow(pRCW->GetEmitHelper()->DefineMethodSemanticsHelper(
tkAssociation,
attr,
tkMethod));
END_QCALL;
}
示例15: SetClassLayout
/*============================SetClassLayout============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetClassLayout(QCall::ModuleHandle pModule, INT32 tk, INT32 iPackSize, UINT32 iTotalSize)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter* pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Define the packing size and total size of a class
IfFailThrow(pRCW->GetEmitter()->SetClassLayout(
tk, // Typedef
iPackSize, // packing size
NULL, // no field layout
iTotalSize)); // total size for the type
END_QCALL;
}