1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-13 05:44:11 +02:00
Beef/IDEHelper/Tests/LibA/src/LibA0.bf

166 lines
2.1 KiB
Beef
Raw Normal View History

2019-08-23 11:56:54 -07:00
using System;
using System.Collections;
using System.Diagnostics;
2019-08-23 11:56:54 -07:00
namespace LibA
{
2020-07-01 12:06:51 -07:00
struct LibAStruct
{
int mA;
}
2020-05-16 08:21:34 -07:00
interface IVal
{
int Val
{
get; set;
}
}
2019-08-23 11:56:54 -07:00
class LibA0
{
2020-05-16 08:21:34 -07:00
public static int GetVal<T>(T val) where T : IVal
{
return val.Val;
}
public static void Dispose<T>(mut T val) where T : IDisposable
{
val.Dispose();
}
public static void Alloc<T>() where T : new, delete
{
let t = new T();
delete t;
}
public static bool DictEquals(Dictionary<String, int> lhs, Dictionary<String, int> rhs)
{
return lhs == rhs;
}
2020-07-01 12:06:51 -07:00
public static int GetOverload0<T>() where T : var
{
T val = default;
return Overload0(val);
}
}
struct Handler
{
public static int Handle(Object obj)
{
return 0;
}
public static int HandleT<T>(T val) where T : var
{
return Handle(val);
}
2019-08-23 11:56:54 -07:00
}
2020-08-16 08:31:26 -07:00
class LibA1
{
}
class LibA2
{
public static void DoDispose<T>(mut T val) where T : IDisposable
{
val.Dispose();
}
public static bool DoDispose2<T>(mut T val) where T : var
{
return
[IgnoreErrors(true)]
{
val.Dispose();
true
};
}
public static bool CheckEq<T>(T lhs, T rhs)
{
return lhs == rhs;
}
}
2019-08-23 11:56:54 -07:00
}
class LibClassA
{
public int32 mA = GetVal(7, 10, "LibA.LibClassA.mA");
public static int32 sMagic = 1;
public static this()
{
sMagic += 10;
}
2019-08-23 11:56:54 -07:00
public this()
{
//Debug.WriteLine("LibA.LibClassA()\n");
2019-08-23 11:56:54 -07:00
mA += 100;
}
public this(int32 a)
{
mA += a;
}
public ~this()
{
sMagic += 20;
}
public static int32 GetVal(int32 val, int32 magic, String str)
2019-08-23 11:56:54 -07:00
{
//Debug.WriteLine("GetVal: {}", str);
sMagic += magic;
2019-08-23 11:56:54 -07:00
return val;
}
public int GetVal2()
{
return 9;
}
2019-11-30 13:18:07 -08:00
public static int GetVal3(Object obj)
{
return 30;
}
public extern int GetVal4();
public static LibClassA Create()
{
LibClassA ca = new LibClassA();
Test.Assert(ca.GetVal4() == 29);
return ca;
}
2019-08-23 11:56:54 -07:00
}
class LibClassB
{
2019-11-30 13:18:07 -08:00
public static int DoGetVal3<T>(T val)
{
return LibClassA.GetVal3(val);
}
2020-07-01 12:06:51 -07:00
}
static
{
public static int Overload0(Object a)
{
return 0;
}
public static int Overload0(int8 a)
{
return 1;
}
}