| 12663 | //========================================================================== |
| 12664 | |
| 12665 | PFunction *NativeFunctionPointerCast(PFunction *from, const PFunctionPointer *to) |
| 12666 | { |
| 12667 | if(to->PointedType == TypeVoid) |
| 12668 | { |
| 12669 | return from; |
| 12670 | } |
| 12671 | else if(from && ((from->Variants[0].Flags & (VARF_Virtual | VARF_Action)) == 0) && FScopeBarrier::CheckSidesForFunctionPointer(FScopeBarrier::SideFromFlags(from->Variants[0].Flags), to->Scope)) |
| 12672 | { |
| 12673 | if(to->ArgFlags.Size() != from->Variants[0].ArgFlags.Size()) return nullptr; |
| 12674 | int n = to->ArgFlags.Size(); |
| 12675 | for(int i = from->GetImplicitArgs(); i < n; i++) // skip checking flags for implicit self |
| 12676 | { |
| 12677 | if(from->Variants[0].ArgFlags[i] != to->ArgFlags[i]) |
| 12678 | { |
| 12679 | return nullptr; |
| 12680 | } |
| 12681 | } |
| 12682 | return AreCompatibleFnPtrTypes(static_cast<PPrototype*>(to->PointedType), from->Variants[0].Proto) ? from : nullptr; |
| 12683 | } |
| 12684 | else |
| 12685 | { // cannot cast virtual/action functions to anything |
| 12686 | return nullptr; |
| 12687 | } |
| 12688 | } |
| 12689 | |
| 12690 | DEFINE_ACTION_FUNCTION_NATIVE(DObject, BuiltinFunctionPtrCast, NativeFunctionPointerCast) |
| 12691 | { |
no test coverage detected