Fix deserialization of methods inside function pointers

This commit is contained in:
Ricardo Luís Vaz Silva 2023-10-11 12:55:08 -03:00 committed by Christoph Oelckers
parent e61bd10bbf
commit d9a88d7080

View file

@ -2973,7 +2973,7 @@ bool PFunctionPointer::ReadValue(FSerializer &ar, const char *key, void *addr) c
if(!p)
{
*fn = nullptr;
Printf(TEXTCOLOR_RED "Function Pointer (%s::%s): symbol '%s' in class '%s' is a variable, not a function\n",
Printf(TEXTCOLOR_RED "Function Pointer (%s::%s): '%s' in class '%s' is a variable, not a function\n",
val.ClassName.GetChars(),
val.FunctionName.GetChars(),
val.FunctionName.GetChars(),
@ -2982,7 +2982,10 @@ bool PFunctionPointer::ReadValue(FSerializer &ar, const char *key, void *addr) c
ar.mErrors++;
return false;
}
else if(p->GetImplicitArgs() > 0)
*fn = NativeFunctionPointerCast(p, this);
if(!*fn)
{
if((p->Variants[0].Flags & (VARF_Action | VARF_Virtual)) != 0)
{
*fn = nullptr;
Printf(TEXTCOLOR_RED "Function Pointer (%s::%s): function '%s' in class '%s' is %s, not a static function\n",
@ -2990,13 +2993,10 @@ bool PFunctionPointer::ReadValue(FSerializer &ar, const char *key, void *addr) c
val.FunctionName.GetChars(),
val.FunctionName.GetChars(),
val.ClassName.GetChars(),
(p->GetImplicitArgs() == 1 ? "a method" : "an action function")
(p->GetImplicitArgs() == 1 ? "a virtual function" : "an action function")
);
ar.mErrors++;
return false;
}
*fn = NativeFunctionPointerCast(p, this);
if(!*fn)
else
{
FString fn_name = MakeFunctionPointerDescriptiveName(p->Variants[0].Proto,p->Variants[0].ArgFlags, FScopeBarrier::SideFromFlags(p->Variants[0].Flags));
Printf(TEXTCOLOR_RED "Function Pointer (%s::%s) has incompatible type (Pointer is '%s', Function is '%s')\n",
@ -3005,6 +3005,7 @@ bool PFunctionPointer::ReadValue(FSerializer &ar, const char *key, void *addr) c
fn_name.GetChars(),
mDescriptiveName.GetChars()
);
}
ar.mErrors++;
return false;
}