From b4837bc07d5a684d825bb9ecdf6763a32feedd5b Mon Sep 17 00:00:00 2001 From: mterwoord_cp <7cd3fd84a0151ea055c2f79e4d2eef9576fe9afesxUZAwxD> Date: Sat, 16 Aug 2008 14:06:00 +0000 Subject: [PATCH] Several fixes --- .../Playgrounds/Kudzu/KudzuTest/Program.cs | 4 +-- source/Cosmos/Cosmos.Hardware/PCIBus.cs | 4 +-- source/Cosmos/Cosmos.Kernel.Plugs/String.cs | 35 +++++++++++++++++++ .../Cosmos.Sys.Plugs/VFS/DirectoryInfoImpl.cs | 18 +++++----- .../Cosmos.Sys.Plugs/VFS/FileInfoImpl.cs | 4 +++ source/FrodeTest/Program.cs | 4 +-- source/FrodeTest/Test/DirectoryInfoTest.cs | 10 +++--- .../System/ExceptionImpl.cs | 2 +- source/MatthijsTest/Program.cs | 8 ++++- 9 files changed, 67 insertions(+), 22 deletions(-) diff --git a/source/Boot/Playgrounds/Kudzu/KudzuTest/Program.cs b/source/Boot/Playgrounds/Kudzu/KudzuTest/Program.cs index 312d60955..10ba386a3 100644 --- a/source/Boot/Playgrounds/Kudzu/KudzuTest/Program.cs +++ b/source/Boot/Playgrounds/Kudzu/KudzuTest/Program.cs @@ -18,9 +18,9 @@ namespace Cosmos.Playground.Kudzu { //System.Diagnostics.Debugger.Break(); Console.WriteLine("Boot complete"); - //PCITest.Test(); + PCITest.Test(); //Tests.DoAll(); - RTL8139.Test(); + //RTL8139.Test(); //TODO: Make this automatically called after Init if no other shut downs are called Cosmos.Sys.Deboot.Halt(); diff --git a/source/Cosmos/Cosmos.Hardware/PCIBus.cs b/source/Cosmos/Cosmos.Hardware/PCIBus.cs index eca71d38b..1d1c9310e 100644 --- a/source/Cosmos/Cosmos.Hardware/PCIBus.cs +++ b/source/Cosmos/Cosmos.Hardware/PCIBus.cs @@ -6775,7 +6775,7 @@ namespace Cosmos.Hardware { } else if ((address & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) { - UInt32 size = ~(PCI_BASE_ADDRESS_MEM_MASK & flags)+1; + UInt32 size = (~(PCI_BASE_ADDRESS_MEM_MASK & flags))+1; IOMaps[i] = new Kernel.MemoryAddressSpace(address, size); //Console.WriteLine("register " + i + " - " + size + "b mem"); @@ -6834,7 +6834,7 @@ namespace Cosmos.Hardware { /// /// Is this a multifunction device? /// - public bool IsMultiFunction { get { return (Read8(0x0e) & 0x80) != 0; } } + public bool IsMultiFunction { get { return (Read8(0x0e) & 0xF0) != 0; } } /// /// The Vendor ID diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/String.cs b/source/Cosmos/Cosmos.Kernel.Plugs/String.cs index ab13dca2c..8e16596c2 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/String.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/String.cs @@ -91,6 +91,41 @@ namespace Cosmos.Kernel.Plugs { return new global::System.String(xChars); } + public static int IndexOf(string aThis, string aSubStr, int aStart, int aLength, StringComparison aComparison) { + int xEndIdx = aStart + aLength; + for (int i = aStart; i < xEndIdx; i++) { + bool xFound = true; + for (int j = 0; j < aSubStr.Length; j++) { + if (aThis[i + j] != aSubStr[j]) { + xFound = false; + break; + } + } + if (xFound) { + return i; + } + } + return -1; + } + + public static bool EndsWith(string aThis, string aSubStr, StringComparison aComparison) { + int xLastIdx = aThis.Length - aSubStr.Length - 1; + for(int i = 0; i < aSubStr.Length; i++) { + if(aThis[xLastIdx+i] != aSubStr[i]) { + return false; + } + } + return true; + } + +// System.Int32 System.String.IndexOf(System.String, System.Int32, System.Int32, System.StringComparison) + + public static bool Equals(string aThis, string aThat, StringComparison aComparison) { +#warning TODO: implement + return EqualsHelper(aThis, + aThat); + } + public static bool EqualsHelper(string aStrA, string aStrB) { return aStrA.CompareTo(aStrB) == 0; diff --git a/source/Cosmos/Cosmos.Sys.Plugs/VFS/DirectoryInfoImpl.cs b/source/Cosmos/Cosmos.Sys.Plugs/VFS/DirectoryInfoImpl.cs index e0cef0215..a9191bf6e 100644 --- a/source/Cosmos/Cosmos.Sys.Plugs/VFS/DirectoryInfoImpl.cs +++ b/source/Cosmos/Cosmos.Sys.Plugs/VFS/DirectoryInfoImpl.cs @@ -31,19 +31,19 @@ namespace Cosmos.Sys.Plugs aStorage = VFSManager.GetDirectoryEntry(aPath); } - public static bool get_Exists([FieldAccess(Name = "$$Storage$$")] ref FilesystemEntry aStorage) + public static bool get_Exists(DirectoryInfo aThis, [FieldAccess(Name = "$$Storage$$")] ref FilesystemEntry aStorage) { //TODO: actually test if it exists return (aStorage != null); } - public static string get_FullName([FieldAccess(Name="$$Storage$$")] ref FilesystemEntry aStorage) + public static string get_FullName(DirectoryInfo aThis, [FieldAccess(Name = "$$Storage$$")] ref FilesystemEntry aStorage) { //TODO: return FULL name return aStorage.Name; } - public static string get_Name([FieldAccess(Name = "$$Storage$$")] ref FilesystemEntry aStorage) + public static string get_Name(DirectoryInfo aThis, [FieldAccess(Name = "$$Storage$$")] ref FilesystemEntry aStorage) { return aStorage.Name; } @@ -61,11 +61,11 @@ namespace Cosmos.Sys.Plugs // return xFiles.ToArray(); //} - - - //public static string ToString([FieldAccess(Name = "$$Path$$")] ref String aPath) - //{ - // return "ToString()"; - //} + + + public static string ToString([FieldAccess(Name = "$$Path$$")] ref String aPath) + { + return "DirectoryInfo.ToString() not yet implemented"; + } } } diff --git a/source/Cosmos/Cosmos.Sys.Plugs/VFS/FileInfoImpl.cs b/source/Cosmos/Cosmos.Sys.Plugs/VFS/FileInfoImpl.cs index 60220bd9e..051300bfd 100644 --- a/source/Cosmos/Cosmos.Sys.Plugs/VFS/FileInfoImpl.cs +++ b/source/Cosmos/Cosmos.Sys.Plugs/VFS/FileInfoImpl.cs @@ -34,5 +34,9 @@ namespace Cosmos.Sys.Plugs { return VFSManager.FileExists(aStorage.Name); } + + public static string ToString(FileInfo aThis) { + return "FileInfo.ToString() not yet implemented!"; + } } } diff --git a/source/FrodeTest/Program.cs b/source/FrodeTest/Program.cs index a00eb94fa..4a587e885 100644 --- a/source/FrodeTest/Program.cs +++ b/source/FrodeTest/Program.cs @@ -65,8 +65,8 @@ namespace FrodeTest //Test.LinqTest.RunTest(); //Test.ExceptionTest.RunTest(); //Test.FilesystemEntryTest.RunTest(); - Test.VirtualFileSystemTest.RunTest(); - //Test.DirectoryInfoTest.RunTest(); + //Test.VirtualFileSystemTest.RunTest(); + Test.DirectoryInfoTest.RunTest(); //Test.FileInfoTest.RunTest(); //Tests ready for Matthijs to fix ;) diff --git a/source/FrodeTest/Test/DirectoryInfoTest.cs b/source/FrodeTest/Test/DirectoryInfoTest.cs index 5739f5f7b..c6a7c286b 100644 --- a/source/FrodeTest/Test/DirectoryInfoTest.cs +++ b/source/FrodeTest/Test/DirectoryInfoTest.cs @@ -15,14 +15,14 @@ namespace FrodeTest.Test //Console.WriteLine("CurrentDirectory: " + Environment.CurrentDirectory); DirectoryInfo dir = new DirectoryInfo("/0/lost+found/"); - Console.WriteLine("FullName: " + dir.FullName); + //Console.WriteLine("FullName: " + dir.FullName); Console.WriteLine("Name: " + dir.Name); - Console.WriteLine("ToString: " + dir.ToString()); + //Console.WriteLine("ToString: " + dir.ToString()); - Console.WriteLine("Files in the directory:"); - foreach (FileInfo file in dir.GetFiles()) - Console.WriteLine(file.Name); + //Console.WriteLine("Files in the directory:"); + //foreach (FileInfo file in dir.GetFiles()) + // Console.WriteLine(file.Name); if (dir.Exists) diff --git a/source/Indy.IL2CPU.IL.X86/CustomImplementations/System/ExceptionImpl.cs b/source/Indy.IL2CPU.IL.X86/CustomImplementations/System/ExceptionImpl.cs index c5502fe09..031b3f97f 100644 --- a/source/Indy.IL2CPU.IL.X86/CustomImplementations/System/ExceptionImpl.cs +++ b/source/Indy.IL2CPU.IL.X86/CustomImplementations/System/ExceptionImpl.cs @@ -17,7 +17,7 @@ namespace Indy.IL2CPU.IL.X86.CustomImplementations.System { return VTablesImpl.GetTypeName(xObjectType); } - public static string get_Message(Exception aThis, [FieldAccess(Name = "System.String System.Exception._message")]string mMessage) + public static string get_Message(Exception aThis, [FieldAccess(Name = "System.String System.Exception._message")]ref string mMessage) { return mMessage; } diff --git a/source/MatthijsTest/Program.cs b/source/MatthijsTest/Program.cs index 82fb6444a..36c2f3244 100644 --- a/source/MatthijsTest/Program.cs +++ b/source/MatthijsTest/Program.cs @@ -146,7 +146,13 @@ namespace MatthijsTest { var xBoot = new Cosmos.Sys.Boot(); xBoot.Execute(); } - + try { + throw new Exception("Test error"); + } + catch (Exception E) { + Console.Write("Error: "); + Console.WriteLine(E.Message); + } Console.WriteLine("Done"); do {