1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Disabled custom attributes when boxed

This commit is contained in:
Brian Fiete 2020-04-02 08:57:00 -07:00
parent 67dadf34e5
commit bb59aa3162

View file

@ -2096,42 +2096,45 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
typeInstance->mInstSize = std::max(0, typeInstance->mInstSize);
typeInstance->mInstAlign = std::max(0, typeInstance->mInstAlign);
if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->mTypeDeclaration->mAttributes != NULL))
if (!typeInstance->IsBoxed())
{
BfAttributeTargets attrTarget;
if ((typeDef->mIsDelegate) || (typeDef->mIsFunction))
attrTarget = BfAttributeTargets_Delegate;
else if (typeInstance->IsEnum())
attrTarget = BfAttributeTargets_Enum;
else if (typeInstance->IsInterface())
attrTarget = BfAttributeTargets_Interface;
else if (typeInstance->IsStruct())
attrTarget = BfAttributeTargets_Struct;
else
attrTarget = BfAttributeTargets_Class;
if (!typeInstance->mTypeFailed)
if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->mTypeDeclaration->mAttributes != NULL))
{
// This allows us to avoid reentrancy when checking for inner types
SetAndRestoreValue<bool> prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true);
if (typeDef->mIsCombinedPartial)
{
for (auto partialTypeDef : typeDef->mPartials)
{
if (partialTypeDef->mTypeDeclaration->mAttributes == NULL)
continue;
BfTypeState typeState;
typeState.mPrevState = mContext->mCurTypeState;
typeState.mCurTypeDef = partialTypeDef;
typeState.mTypeInstance = typeInstance;
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
if (typeInstance->mCustomAttributes == NULL)
typeInstance->mCustomAttributes = new BfCustomAttributes();
GetCustomAttributes(typeInstance->mCustomAttributes, partialTypeDef->mTypeDeclaration->mAttributes, attrTarget);
}
}
BfAttributeTargets attrTarget;
if ((typeDef->mIsDelegate) || (typeDef->mIsFunction))
attrTarget = BfAttributeTargets_Delegate;
else if (typeInstance->IsEnum())
attrTarget = BfAttributeTargets_Enum;
else if (typeInstance->IsInterface())
attrTarget = BfAttributeTargets_Interface;
else if (typeInstance->IsStruct())
attrTarget = BfAttributeTargets_Struct;
else
typeInstance->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, attrTarget);
attrTarget = BfAttributeTargets_Class;
if (!typeInstance->mTypeFailed)
{
// This allows us to avoid reentrancy when checking for inner types
SetAndRestoreValue<bool> prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true);
if (typeDef->mIsCombinedPartial)
{
for (auto partialTypeDef : typeDef->mPartials)
{
if (partialTypeDef->mTypeDeclaration->mAttributes == NULL)
continue;
BfTypeState typeState;
typeState.mPrevState = mContext->mCurTypeState;
typeState.mCurTypeDef = partialTypeDef;
typeState.mTypeInstance = typeInstance;
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
if (typeInstance->mCustomAttributes == NULL)
typeInstance->mCustomAttributes = new BfCustomAttributes();
GetCustomAttributes(typeInstance->mCustomAttributes, partialTypeDef->mTypeDeclaration->mAttributes, attrTarget);
}
}
else
typeInstance->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, attrTarget);
}
}
}