Brian Fiete пре 5 година
родитељ
комит
c97b074fee

+ 9 - 0
BeefLibs/Beefy2D/src/widgets/ListView.bf

@@ -424,6 +424,15 @@ namespace Beefy.widgets
             return mSubItems[columnIdx];
         }
 
+		public ListViewItem GetOrCreateSubItem(int columnIdx)
+		{
+			if (mColumnIdx == columnIdx)
+				return this;
+			if ((mSubItems != null) && (columnIdx < mSubItems.Count))
+		    	return mSubItems[columnIdx];
+			return CreateSubItem(columnIdx);
+		}
+
         public virtual void MakeParent()
         {
             if (mChildItems == null)

+ 1 - 1
BeefLibs/corlib/src/Environment.bf

@@ -44,7 +44,7 @@ namespace System
 		{
 			Platform.GetStrHelper(outPath, scope (outPtr, outSize, outResult) =>
                 {
-					Platform.BfpDynLib_GetFilePath(null, outPtr, outSize, (Platform.BfpLibResult*)outResult);
+					Platform.BfpSystem_GetExecutablePath(outPtr, outSize, (Platform.BfpSystemResult*)outResult);
                 });
 		}
 

+ 4 - 2
BeefLibs/corlib/src/Platform.bf

@@ -55,8 +55,6 @@ namespace System
 		[StdCall, CLink]
 		public static extern BfpTimeStamp BfpSystem_GetTimeStamp();
 		[StdCall, CLink]
-		public static extern void BfpSystem_GetEnvironmentStrings(char8* outStr, int32* inOutStrSize, BfpSystemResult* outResult);
-		[StdCall, CLink]
 		public static extern uint8 BfpSystem_InterlockedExchange8(uint8* ptr, uint8 val); /// Returns the initial value in 'ptr'
 		[StdCall, CLink]
 		public static extern uint16 BfpSystem_InterlockedExchange16(uint16* ptr, uint16 val); /// Returns the initial value in 'ptr'
@@ -81,6 +79,10 @@ namespace System
 		[StdCall, CLink]
 		public static extern uint64 BfpSystem_InterlockedCompareExchange64(uint64* ptr, uint64 oldVal, uint64 newVal);
 		[StdCall, CLink]
+		public static extern void BfpSystem_GetExecutablePath(char8* outStr, int32* inOutStrSize, BfpSystemResult* outResult);
+		[StdCall, CLink]
+		public static extern void BfpSystem_GetEnvironmentStrings(char8* outStr, int32* inOutStrSize, BfpSystemResult* outResult);
+		[StdCall, CLink]
 		public static extern int32 BfpSystem_GetNumLogicalCPUs(BfpSystemResult* outResult);
 		[StdCall, CLink]
 		public static extern int64 BfpSystem_GetCPUTick();

+ 1 - 1
BeefySysLib/platform/win/Platform.cpp

@@ -416,7 +416,7 @@ void Beefy::BFFatalError(const StringImpl& message, const StringImpl& file, int
 #endif
 
 #ifdef _DEBUG
-   	OutputDebugStrF("FATAL ERROR: %s\n", message.c_str());
+  	OutputDebugStrF("FATAL ERROR: %s\n", message.c_str());
    	_wassert(UTF8Decode(message).c_str(), UTF8Decode(file).c_str(), line);
 #else
 	String error = StrFormat("%s in %s:%d", message.c_str(), file.c_str(), line);

+ 11 - 0
BeefySysLib/third_party/zlib/compress.c

@@ -64,3 +64,14 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
 {
     return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
 }
+
+/* ===========================================================================
+	 If the default memLevel or windowBits for deflateInit() is changed, then
+   this function needs to be updated.
+ */
+uLong ZEXPORT compressBound(sourceLen)
+uLong sourceLen;
+{
+	return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+		(sourceLen >> 25) + 13;
+}

+ 4 - 0
BeefySysLib/util/AllocDebug.cpp

@@ -2,6 +2,10 @@
 #include "CritSect.h"
 #include "util/Dictionary.h"
 
+#ifdef DEF_BF_ALLOCDEBUG
+#define USE_BF_ALLOCDEBUG
+#endif
+
 #pragma warning(disable:4996)
 #include <cstdio>
 #include "AllocDebug.h"

+ 1 - 1
BeefySysLib/util/MultiHashSet.h

@@ -111,7 +111,7 @@ public:
 
 public:
 	Entry** mHashHeads;
-	const int cDefaultHashSize = 17;
+	static const int cDefaultHashSize = 17;
 	int mHashSize;
 	int mCount;
 	

+ 1 - 1
IDE/mintest/BeefProj.toml

@@ -70,4 +70,4 @@ Path = "../../../temp/test.txt"
 [[ProjectFolder.Items]]
 Type = "Folder"
 Path = "../../../temp/borf"
-Source = ["a.txt"]
+AutoInclude = true

+ 20 - 3
IDE/mintest/minlib/src/System/Object.bf

@@ -153,14 +153,31 @@ namespace System
 
 	}
 
-	struct Pointer
+	[AlwaysInclude]
+	struct Pointer : IHashable
 	{
+		void* mVal;
 
+		public int GetHashCode()
+		{
+			return (int)mVal;
+		}
+
+		[AlwaysInclude]
+		Object GetBoxed()
+		{
+			return new box this;
+		}
 	}
 
-    struct Pointer<T> : Pointer
-    {
+	struct Pointer<T> : IHashable
+	{
 		T* mVal;
+
+		public int GetHashCode()
+		{
+			return (int)mVal;
+		}
 	}
 
 	struct MethodReference<T>

+ 10 - 0
IDE/mintest/minlib/src/System/Type.bf

@@ -333,6 +333,16 @@ namespace System
 			}
 		}
 
+		public virtual int32 MaxValue
+		{
+			[Error("This property can only be accessed directly from a typeof() expression")]
+			get
+			{
+				return 0;
+			}
+		}
+
+
         public int32 GetTypeId()
         {
             return (int32)mTypeId;

+ 13 - 26
IDE/mintest/src/main.bf

@@ -189,40 +189,27 @@ namespace Hey.Dude.Bro
 		[CRepr, CLink]
 		public static extern void* SetUnhandledExceptionFilter(function int32(void* p) func);
 
-		public static int Main(String[] args)
+		public static int GetHash<T>(T val) where T : IHashable
 		{
-			//Test2(1, 2, 3, 4);
-			//int a = Fartso;
-
-#if ZLOG
-			PrintF("HEY!");
-#endif
-			List<String> iList = scope .();
-			for (int i < 1000)
-			{
-				iList.Add("Zpops");
-			}
-
-			bool b = false;
+			return val.GetHashCode();
+		}	
 
-			//File file;
-			int len = args.Count;
+		public static int Main(String[] args)
+		{
+			/*IHashable ih = (int32)TypeCode.Boolean;
+			let hashCode = ih.GetHashCode();*/
 
-			int zog = 123;
+			Object obj = new Object();
 
-			int a = 0x1122334455667788;
+			int* iPtr = scope .();
+			int hash = GetHash(iPtr);
+			
 
-			void* prev = SetUnhandledExceptionFilter(=> SEHHandler);
-			PrintF("Prev: %p\n", prev);
+			//Test2(1, 2, 3, 4);
+		
 
-			//TestA();
 			Blurg.Hey();
 
-			for (int i < 100)
-			{
-				PrintF("Hello 2!\n");
-				Thread.Sleep(10);
-			}
 			
 			return 1;
 		}

+ 53 - 30
IDE/mintest/src/main3.bf

@@ -13,18 +13,15 @@ class ClassA
 {
 	public virtual void ClassA0()
 	{
-
 	}
 
 	public virtual void ClassA1()
 	{
-
 	}
 }
 
 class ClassB
 {
-	
 }
 
 #if B
@@ -71,13 +68,11 @@ class ClassE : ClassD
 {
 	public void Zog2()
 	{
-
 	}
 }
 
 class ClassF : ClassE
 {
-
 }
 
 [NoDiscard("Use this value!")]
@@ -95,11 +90,10 @@ class Bloozer
 enum Zorf : IDisposable
 {
 	case A;
-	case B;
+		case B;
 
 	public void Dispose()
 	{
-
 	}
 }
 
@@ -107,7 +101,6 @@ class IFaceA
 {
 	public static void Fart()
 	{
-
 	}
 }
 
@@ -115,7 +108,6 @@ class Zlips : IFaceA, IDisposable
 {
 	static void Fart()
 	{
-
 	}
 
 	public void Dispose()
@@ -129,9 +121,7 @@ class Testo
 	public this()
 	{
 		PrintF("Testo this %p\n", this);
-	}
-
-	public ~this()
+	} public ~this()
 	{
 		PrintF("Testo ~this %p\n", this);
 	}
@@ -143,7 +133,7 @@ class Norg
 	public int32 mA;
 	public int32 mB;
 
-	public int32 GetIt(int32 a, int32 b, int32 c) mut
+	public int32 GetIt(int32 a, int32 b, int32 c)
 	{
 		return a + b + c + mA;
 	}
@@ -157,10 +147,13 @@ class Norg
 	{
 		set
 		{
-			
+			mA = (.)value;
 		}
 
-		
+		get
+		{
+			return mA;
+		}
 	}
 
 	public virtual int GetVal()
@@ -171,18 +164,47 @@ class Norg
 
 class Norg2 : Norg
 {
-	public override void Zorf
+	public int mVal2;
+
+	public int Zof => 123;
+
+	public int GetIt() => 234;
+
+	/*public override int Zorf
 	{
 		set
 		{
 			base.Zorf = 123;
 		}
-	}
+	}*/
+
+}
+
+enum TestEnumA
+{
+	A,
+	B,
+	C
+}
 
+[AttributeUsage(.Field, .ReflectAttribute, ReflectUser=.All)]
+struct FoofAttribute : Attribute
+{
+	int32 mA;
+	int32 mB;
+	int32 mC;
+
+	public this(int32 a, int32 b, int32 c)
+	{
+		mA = a;
+		mB = b;
+		mC = c;
+	}
 }
 
-struct Blurg 
+struct Blurg
 {
+	[Foof(1, 2, 3)]
 	public String mVal;
 	public int32 mA;
 	public int32 mB;
@@ -196,7 +218,6 @@ struct Blurg
 
 	void TestIt(String a, String b)
 	{
-
 	}
 
 	TestStruct GetTS()
@@ -209,26 +230,29 @@ struct Blurg
 		PrintF("a0");
 	}
 
+	[Error("This property can only be accessed directly from a typeof() expression")]
 	static void Test(int a, int b, int c)
 	{
+	}
 
+	public static Result<int> GetMe()
+	{
+		return 123;
 	}
 
-	
 	public static int32 Hey()
 	{
-		Result<int, float> res = .Ok(123);
+		let t = typeof(Self);
+		let field = t.GetField("mVal").Value;
+		var foofAttrib = field.GetCustomAttribute<FoofAttribute>();
 
-		Florg fl = .();
+		//for (TypeCode tc < .Boolean)
 
-		let f2 = fl;
-		//defer f2.Dispose();
+		//Test(1, 2, 3);
+
+		/*TestEnumA ta = .A;
+		IHashable ih = ta;*/
 
-		using (var f = fl)
-		{
-			
-		}
-		
 		return 123;
 	}
 
@@ -240,7 +264,6 @@ struct Florg
 
 	public void Dispose() mut
 	{
-
 	}
 }