diff --git a/BeefLibs/Beefy2D/src/widgets/ListView.bf b/BeefLibs/Beefy2D/src/widgets/ListView.bf index f6c694ec..1aa4e570 100644 --- a/BeefLibs/Beefy2D/src/widgets/ListView.bf +++ b/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) diff --git a/BeefLibs/corlib/src/Environment.bf b/BeefLibs/corlib/src/Environment.bf index bf806e1b..acdef564 100644 --- a/BeefLibs/corlib/src/Environment.bf +++ b/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); }); } diff --git a/BeefLibs/corlib/src/Platform.bf b/BeefLibs/corlib/src/Platform.bf index 54ebdd16..794c1de1 100644 --- a/BeefLibs/corlib/src/Platform.bf +++ b/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(); diff --git a/BeefySysLib/platform/win/Platform.cpp b/BeefySysLib/platform/win/Platform.cpp index 995afa9e..8ea5afa1 100644 --- a/BeefySysLib/platform/win/Platform.cpp +++ b/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); diff --git a/BeefySysLib/third_party/zlib/compress.c b/BeefySysLib/third_party/zlib/compress.c index 07e29410..d26f52ff 100644 --- a/BeefySysLib/third_party/zlib/compress.c +++ b/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; +} diff --git a/BeefySysLib/util/AllocDebug.cpp b/BeefySysLib/util/AllocDebug.cpp index 79f7d369..195553d2 100644 --- a/BeefySysLib/util/AllocDebug.cpp +++ b/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 #include "AllocDebug.h" diff --git a/BeefySysLib/util/MultiHashSet.h b/BeefySysLib/util/MultiHashSet.h index 6c87f753..6e9548a9 100644 --- a/BeefySysLib/util/MultiHashSet.h +++ b/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; diff --git a/IDE/mintest/BeefProj.toml b/IDE/mintest/BeefProj.toml index 8190bc6f..55773dab 100644 --- a/IDE/mintest/BeefProj.toml +++ b/IDE/mintest/BeefProj.toml @@ -70,4 +70,4 @@ Path = "../../../temp/test.txt" [[ProjectFolder.Items]] Type = "Folder" Path = "../../../temp/borf" -Source = ["a.txt"] +AutoInclude = true diff --git a/IDE/mintest/minlib/src/System/Object.bf b/IDE/mintest/minlib/src/System/Object.bf index 0819e0fc..2e240d31 100644 --- a/IDE/mintest/minlib/src/System/Object.bf +++ b/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 : Pointer - { + struct Pointer : IHashable + { T* mVal; + + public int GetHashCode() + { + return (int)mVal; + } } struct MethodReference diff --git a/IDE/mintest/minlib/src/System/Type.bf b/IDE/mintest/minlib/src/System/Type.bf index 7a33868a..ad1daa7e 100644 --- a/IDE/mintest/minlib/src/System/Type.bf +++ b/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; diff --git a/IDE/mintest/src/main.bf b/IDE/mintest/src/main.bf index d3c2675b..7d1c256e 100644 --- a/IDE/mintest/src/main.bf +++ b/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 GetHash(T val) where T : IHashable + { + return val.GetHashCode(); + } + public static int Main(String[] args) { + /*IHashable ih = (int32)TypeCode.Boolean; + let hashCode = ih.GetHashCode();*/ + + Object obj = new Object(); + + int* iPtr = scope .(); + int hash = GetHash(iPtr); + + //Test2(1, 2, 3, 4); - //int a = Fartso; + -#if ZLOG - PrintF("HEY!"); -#endif - List iList = scope .(); - for (int i < 1000) - { - iList.Add("Zpops"); - } - - bool b = false; - - //File file; - int len = args.Count; - - int zog = 123; - - int a = 0x1122334455667788; - - void* prev = SetUnhandledExceptionFilter(=> SEHHandler); - PrintF("Prev: %p\n", prev); - - //TestA(); Blurg.Hey(); - for (int i < 100) - { - PrintF("Hello 2!\n"); - Thread.Sleep(10); - } return 1; } diff --git a/IDE/mintest/src/main3.bf b/IDE/mintest/src/main3.bf index 7cbe4b84..3c458b4f 100644 --- a/IDE/mintest/src/main3.bf +++ b/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; } - } + }*/ } -struct Blurg +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 +{ + [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 GetMe() + { + return 123; + } + public static int32 Hey() { - Result res = .Ok(123); + let t = typeof(Self); + let field = t.GetField("mVal").Value; + var foofAttrib = field.GetCustomAttribute(); - 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 { - } }