Cosmos/source/Cosmos.Core_Plugs/System/DelegateImpl.cs
fanoI 4a990ac2af Added the concept of Encoding to the Console for now ASCII (default) and CP437 are supported (for others as CP858 I think it is needed to change font too)
- moved EncodingTest on Text subdir
- added ConsoleTest (not enabled by default)
- removed ASCIIEncodingImpl (it was not needed)
- Made plugs of Console better and added plugs for formatted versions
- Removed code to test Hashtable, Hashtable it will be a separate PR
2018-01-27 20:00:11 +01:00

42 lines
1.4 KiB
C#

using System;
using Cosmos.Core;
using IL2CPU.API;
using IL2CPU.API.Attribs;
namespace Cosmos.Core_Plugs.System
{
[Plug(Target = typeof(Delegate), Inheritable = true)]
[PlugField(FieldType = typeof(int), FieldId = "$$ArgSize$$")]
[PlugField(FieldType = typeof(int), FieldId = "$$ReturnsValue$$")]
public static class DelegateImpl
{
public static bool Equals(Delegate aThis, object aThat)
{
// todo: implement proper Delegate.Equals(object)
return false;
}
public static unsafe bool InternalEqualTypes([ObjectPointerAccess] uint** a, [ObjectPointerAccess] uint** b)
{
var xTypeA = a[0][0];
var xTypeB = b[0][0];
return xTypeA == xTypeB;
}
[PlugMethod(Signature = "System_MulticastDelegate__System_Delegate_InternalAllocLike_System_Delegate_")]
public static unsafe uint InternalAllocLike(uint* aDelegate)
{
uint xNeededSize = 1024; // 24 is needed fields for Multicast Delegate
xNeededSize += 12;
uint xResultAddr = GCImplementation.AllocNewObject(xNeededSize);
byte* xResult = (byte*)xResultAddr;
byte* xDelegateAsByte = (byte*)aDelegate;
for (int i = 0; i < 1024; i++)
{
xResult[i] = xDelegateAsByte[i];
}
return xResultAddr;
}
}
}