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

Added ability to dynamically cast delegates with compatible signatures

This commit is contained in:
Brian Fiete 2025-03-22 15:34:59 -04:00
parent f10365c1ad
commit 37f72cd3b6
8 changed files with 217 additions and 76 deletions

View file

@ -1398,6 +1398,27 @@ void BfDefBuilder::AddDynamicCastMethods(BfTypeDef* typeDef)
methodDef->mReturnTypeRef = typeDef->mSystem->mDirectObjectTypeRef;
methodDef->mIsNoReflect = true;
}
if ((typeDef->mIsDelegate) && (!typeDef->mIsClosure))
{
auto methodDef = new BfMethodDef();
methodDef->mIdx = (int)typeDef->mMethods.size();
typeDef->mMethods.push_back(methodDef);
methodDef->mDeclaringType = typeDef;
methodDef->mName = BF_METHODNAME_DYNAMICCAST_SIGNATURE;
methodDef->mProtection = BfProtection_Protected;
methodDef->mIsStatic = false;
methodDef->mMethodType = BfMethodType_Normal;
methodDef->mIsVirtual = true;
methodDef->mIsOverride = true;
auto paramDef = new BfParameterDef();
paramDef->mName = "sig";
paramDef->mTypeRef = typeDef->mSystem->mDirectInt32TypeRef;
methodDef->mParams.push_back(paramDef);
methodDef->mReturnTypeRef = typeDef->mSystem->mDirectObjectTypeRef;
methodDef->mIsNoReflect = true;
}
}
void BfDefBuilder::AddParam(BfMethodDef* methodDef, BfTypeReference* typeRef, const StringImpl& paramName)