1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-18 08:06:04 +02:00
Beef/BeefLibs/corlib/src/Pointer.bf

42 lines
614 B
Beef
Raw Normal View History

2019-08-23 11:56:54 -07:00
namespace System
{
2019-10-09 16:16:01 -07:00
[AlwaysInclude]
struct Pointer : IHashable
2019-08-23 11:56:54 -07:00
{
2019-10-09 16:16:01 -07:00
void* mVal;
2019-08-23 11:56:54 -07:00
2019-10-09 16:16:01 -07:00
public int GetHashCode()
{
return (int)mVal;
}
[AlwaysInclude]
Object GetBoxed()
{
return new box this;
}
2020-06-03 12:05:49 -07:00
public override void ToString(String strBuffer)
{
2020-06-05 07:23:46 -07:00
strBuffer.AppendF("0x{0:A}", (uint)(void*)mVal);
2020-06-03 12:05:49 -07:00
}
2019-08-23 11:56:54 -07:00
}
2019-10-09 16:16:01 -07:00
struct Pointer<T> : IHashable
2019-08-23 11:56:54 -07:00
{
T* mVal;
2019-10-09 16:16:01 -07:00
public int GetHashCode()
{
return (int)(void*)mVal;
2019-10-09 16:16:01 -07:00
}
2020-06-03 12:05:49 -07:00
public override void ToString(String strBuffer)
{
strBuffer.Append("(");
typeof(T).GetFullName(strBuffer);
2020-06-05 07:23:46 -07:00
strBuffer.AppendF("*)0x{0:A}", (uint)(void*)mVal);
2020-06-03 12:05:49 -07:00
}
2019-08-23 11:56:54 -07:00
}
}