本文整理汇总了C++中RefClassWriter::GetEmitter方法的典型用法代码示例。如果您正苦于以下问题:C++ RefClassWriter::GetEmitter方法的具体用法?C++ RefClassWriter::GetEmitter怎么用?C++ RefClassWriter::GetEmitter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RefClassWriter
的用法示例。
在下文中一共展示了RefClassWriter::GetEmitter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: SetPInvokeData
/*============================SetPInvokeData============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetPInvokeData(QCall::ModuleHandle pModule, LPCWSTR wszDllName, LPCWSTR wszFunctionName, INT32 token, INT32 linkFlags)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
mdModuleRef mrImportDll = mdTokenNil;
IfFailThrow(pRCW->GetEmitter()->DefineModuleRef(wszDllName, &mrImportDll));
IfFailThrow(pRCW->GetEmitter()->DefinePinvokeMap(
token, // the method token
linkFlags, // the mapping flags
wszFunctionName, // function name
mrImportDll));
IfFailThrow(pRCW->GetEmitter()->SetMethodProps(token, (DWORD) -1, 0x0, miIL));
END_QCALL;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: DefineMethodSpec
// This function will create a method within the class
INT32 QCALLTYPE COMDynamicWrite::DefineMethodSpec(QCall::ModuleHandle pModule, INT32 tkParent, LPCBYTE pSignature, INT32 sigLength)
{
QCALL_CONTRACT;
mdMethodDef memberE = mdTokenNil;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// Define the Method
IfFailThrow( pRCW->GetEmitter()->DefineMethodSpec(tkParent, //ParentTypeDef
(PCCOR_SIGNATURE)pSignature, //Blob value of a COM+ signature
sigLength, //Size of the signature blob
&memberE) ); //[OUT]methodToken
END_QCALL;
return (INT32) memberE;
}
示例12: DefineField
/*================================DefineField=================================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
mdFieldDef QCALLTYPE COMDynamicWrite::DefineField(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, LPCBYTE pSignature, INT32 sigLength, INT32 attr)
{
QCALL_CONTRACT;
mdFieldDef retVal = mdTokenNil;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
//Emit the field.
IfFailThrow( pRCW->GetEmitter()->DefineField(tkParent,
wszName, attr,
(PCCOR_SIGNATURE)pSignature, sigLength,
ELEMENT_TYPE_VOID, NULL,
(ULONG) -1, &retVal) );
END_QCALL;
return retVal;
}
示例13: DefineGenericParam
//*************************************************************
//
// Defining a type into metadata of this dynamic module
//
//*************************************************************
INT32 QCALLTYPE COMDynamicWrite::DefineGenericParam(QCall::ModuleHandle pModule,
LPCWSTR wszFullName,
INT32 tkParent,
INT32 attributes,
INT32 position,
INT32 * pConstraintTokens)
{
QCALL_CONTRACT;
mdTypeDef classE = mdTokenNil;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
IfFailThrow(pRCW->GetEmitter()->DefineGenericParam(
tkParent, position, attributes, wszFullName, 0, (mdToken *)pConstraintTokens, &classE));
END_QCALL;
return (INT32)classE;
}
示例14: GetTokenFromSig
/*============================GetTokenFromSig============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
INT32 QCALLTYPE COMDynamicWrite::GetTokenFromSig(QCall::ModuleHandle pModule, LPCBYTE pSignature, INT32 sigLength)
{
QCALL_CONTRACT;
mdSignature retVal = 0;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
_ASSERTE(pSignature);
// Define the signature
IfFailThrow(pRCW->GetEmitter()->GetTokenFromSig(
pSignature, // Signature blob
sigLength, // blob length
&retVal)); // returned token
END_QCALL;
return (INT32)retVal;
}
示例15: GetMemberRef
//******************************************************************************
//
// GetMemberRefToken
// This function will return a MemberRef token given a MethodDef token and the module where the MethodDef/FieldDef is defined.
//
//******************************************************************************
INT32 QCALLTYPE COMModule::GetMemberRef(QCall::ModuleHandle pModule, QCall::ModuleHandle pRefedModule, INT32 tr, INT32 token)
{
QCALL_CONTRACT;
mdMemberRef memberRefE = 0;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE( pRCW );
LPCUTF8 szName;
ULONG cbComSig;
PCCOR_SIGNATURE pvComSig;
if (TypeFromToken(token) == mdtMethodDef)
{
IfFailThrow(pRefedModule->GetMDImport()->GetNameOfMethodDef(token, &szName));
IfFailThrow(pRefedModule->GetMDImport()->GetSigOfMethodDef(token, &cbComSig, &pvComSig));
}
else
{
IfFailThrow(pRefedModule->GetMDImport()->GetNameOfFieldDef(token, &szName));
IfFailThrow(pRefedModule->GetMDImport()->GetSigOfFieldDef(token, &cbComSig, &pvComSig));
}
MAKE_WIDEPTR_FROMUTF8(wzName, szName);
// Translate the method sig into this scope
//
Assembly * pRefedAssembly = pRefedModule->GetAssembly();
Assembly * pRefingAssembly = pModule->GetAssembly();
if (pRefedAssembly->IsCollectible() && pRefedAssembly != pRefingAssembly)
{
if (pRefingAssembly->IsCollectible())
pRefingAssembly->GetLoaderAllocator()->EnsureReference(pRefedAssembly->GetLoaderAllocator());
else
COMPlusThrow(kNotSupportedException, W("NotSupported_CollectibleBoundNonCollectible"));
}
SafeComHolderPreemp<IMetaDataAssemblyEmit> pAssemblyEmit;
IfFailThrow( pRefingAssembly->GetManifestModule()->GetEmitter()->QueryInterface(IID_IMetaDataAssemblyEmit, (void **) &pAssemblyEmit) );
CQuickBytes qbNewSig;
ULONG cbNewSig;
IfFailThrow( pRefedModule->GetMDImport()->TranslateSigWithScope(
pRefedAssembly->GetManifestImport(),
NULL, 0, // hash value
pvComSig,
cbComSig,
pAssemblyEmit, // Emit assembly scope.
pRCW->GetEmitter(),
&qbNewSig,
&cbNewSig) );
mdTypeRef tref;
if (TypeFromToken(tr) == mdtTypeDef)
{
// define a TypeRef using the TypeDef
DefineTypeRefHelper(pRCW->GetEmitter(), tr, &tref);
}
else
tref = tr;
// Define the memberRef
IfFailThrow( pRCW->GetEmitter()->DefineMemberRef(tref, wzName, (PCCOR_SIGNATURE) qbNewSig.Ptr(), cbNewSig, &memberRefE) );
END_QCALL;
// assign output parameter
return (INT32)memberRefE;
}