From 2001be1fc75dae5d9ae1a39acee4ba0df6c6f190 Mon Sep 17 00:00:00 2001 From: Redall Date: Sat, 12 Dec 2015 16:12:05 +0100 Subject: [PATCH 01/16] Updating the readme.md file > Correction of some like-'robot' texts --- readme.md | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/readme.md b/readme.md index ce739aaea..f494747e7 100644 --- a/readme.md +++ b/readme.md @@ -1,42 +1,40 @@ -### C# Open Source Managed Operating System +### Cosmos (C# Open Source Managed Operating System) [![Join the chat at https://gitter.im/CosmosOS/Cosmos](https://img.shields.io/badge/GITTER-Join%20Chat-brightgreen.svg)](https://gitter.im/CosmosOS/Cosmos?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![GitHub release](https://img.shields.io/github/release/CosmosOS/Cosmos.svg)](https://github.com/CosmosOS/Cosmos/releases) -[We are currently migrating from codeplex](http://cosmos.codeplex.com/) - Cosmos is an operating system "construction kit", built from the ground up around the IL2CPU compiler in C# and our home-brewed language called X#. It's current stage is only usable for academic work. Some day Cosmos will be ready for production work, but to reach that stage we need more developers. Specifically, we need a few more low level developers to help the few core developers who are currently overwhelmed with work. -Download +Downloads anvailables : --------- -Cosmos is available in two forms: -* **User Kit** - User Kit allows you to develop your own custom operating system in Visual Studio. - If you are new to Cosmos, [start here](https://github.com/CosmosOS/Cosmos/wiki). [Latest Release](https://github.com/CosmosOS/Cosmos/releases/latest) -* **Dev Kit** - Dev Kit is the full Cosmos source with build tools. - If you need to modify core Cosmos functions or modify built in drivers, boot, compiler, etc then you will need to use Dev Kit. - [How to build the Dev Kit](https://github.com/CosmosOS/Cosmos/wiki/Devkit) - Building from source is easy with our automated builder. +Cosmos is available in two types of "constructions kits": +* **User Kit** - The User Kit is used to develop your operating system in Visual Basic. + If you are new to Cosmos, you can learn [here](https://github.com/CosmosOS/Cosmos/wiki). [Latest Release anvailable](https://github.com/CosmosOS/Cosmos/releases/latest) +* **Devloppement Kit** - The Devloppement Kit is the full Cosmos source comming with build tools. + If you need to modify the Cosmos core functions or modify built-in drivers, boot, compiler, etc.. you will need to use Devloppement Kit. + [Tutorial for building the Devloppement Kit](https://github.com/CosmosOS/Cosmos/wiki/Devkit) - Building from the source is easy with our automated builder. Getting Started --------- -* [Cosmos Documentation](https://github.com/CosmosOS/Cosmos/wiki) -* Video: [Using VS Express Editions](https://www.youtube.com/watch?v=NNl8S2xOtdo) -* [FAQ](https://github.com/CosmosOS/Cosmos/wiki/FAQ) +* [Documentation for Cosmos](https://github.com/CosmosOS/Cosmos/wiki) +* Video Tutorial for [using Visual Studio Express Editions](https://www.youtube.com/watch?v=NNl8S2xOtdo) +* [FAQ (Frequently Asked Questions)](https://github.com/CosmosOS/Cosmos/wiki/FAQ) * [Low Hanging Fruit](https://github.com/CosmosOS/Cosmos/issues?q=is%3Aopen+is%3Aissue+label%3Acomplexity_low+sort%3Acreated-asc) - Looking for something easy to do and prove your worth in Cosmos? Here are a few easy tasks we have on our to do list that are also of importance to us. -Joining Cosmos +Joining and helping Cosmos --------- -* [Gitter.im](https://gitter.im/CosmosOS/Cosmos) - Live chat. Click the green `Join Chat` badge at the top of this file. As with the IRC and CodePlex chatroom, please be patient if we don't respond immediately (no pinging). -* [Yahoo Group](https://tech.groups.yahoo.com/group/Cosmos-Dev) - Email Discussion List. To prevent spambots from spamming our list we ask you introduce yourself to join. Please mention something specific to Cosmos. "Hey I want to join" won't get you in.... +* [Gitter.im](https://gitter.im/CosmosOS/Cosmos) - The Live Chat: Click the green `Join Chat` badge at the top of this file. As with the IRC and CodePlex chatroom, please be patient if we don't respond immediately (no pinging). +* [Yahoo Group](https://tech.groups.yahoo.com/group/Cosmos-Dev) - Email Discussion List: To prevent spambots from spamming, we ask you introduce yourself to join. Please mention something specific to Cosmos. For example: "Hey, I want to join" and will won't get you in.... * [Facebook](http://www.facebook.com/pages/Cosmos-Operating-System/10235842745) - Like us to see frequent updates of what is going on with Cosmos. -* [YouTube Channel](https://www.youtube.com/channel/UCsSKtqjfpSR0B3Ov4cBIarQ/) - Follow use to see useful videos. +* [YouTube Channel](https://www.youtube.com/channel/UCsSKtqjfpSR0B3Ov4cBIarQ/) - Follow to see useful videos and help you programming your operating system. * [Resources](https://github.com/CosmosOS/Cosmos/wiki/Resources) - More Cosmos related links. @@ -48,8 +46,8 @@ Articles and Resources * [Intro to Plugs](https://github.com/CosmosOS/Cosmos/wiki/Intro-to-Plugs) * [X86 Assembly Debugger Preview](https://github.com/CosmosOS/Cosmos/wiki/Visual-Studio-X86-Assembly-Debugger) * [Making a Remote PC Slave for Debugging or Fun](http://www.codeproject.com/Articles/413942/Making-a-Remote-PC-Slave-for-Debugging-or-Fun) (old article, code deprecated) -* [Cosmos Tutorials](https://int0x10.com/forums/forum-22.html) -* [Cosmos Projects](https://github.com/CosmosOS/Cosmos/wiki/Cosmos-Projects) +* [Tutorials for Cosmos](https://int0x10.com/forums/forum-22.html) +* [Projects for Cosmos](https://github.com/CosmosOS/Cosmos/wiki/Cosmos-Projects) Publicity From 7e1290ec5f4008a716e882173972e2a6157057e4 Mon Sep 17 00:00:00 2001 From: Redall Date: Sat, 12 Dec 2015 16:30:16 +0100 Subject: [PATCH 02/16] Updated the directories.md file > Replaced 'folder' to 'directory' > Replaced some words to correct words --- Docs/Directories.md | 66 +++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/Docs/Directories.md b/Docs/Directories.md index f1d39ec31..44aa3a78a 100644 --- a/Docs/Directories.md +++ b/Docs/Directories.md @@ -6,122 +6,118 @@ At a first look, the directory structure of Cosmos is quite confusing. There are ### \Artwork -Just some Cosmos artwork. It contains Cosmos logo and YouTube channel logo. +This directory cointains it contains Cosmos logos and a YouTube channel logo. ### \Build -The build directory contains file used to build ISO images and Virtual Machines files and images. There is a folder with support files for BOCHS, for Virtual PC, for VMware, QEMU, for support for boot from ISO CD, USB, Ethernet (PXE). +This directory contains file used to build ISO images and Virtual Machines files and images, there is a folder with supporting files for BOCHS, for Virtual PC, for VMware, QEMU and for boot from ISO CD, USB, Ethernet (PXE). ### \Demos -This folder contains some Cosmos demo projects to help you. +This directory contains the Cosmos demos projects to help you in programming your operating system. #### \Demos\Guess -This is the basic Cosmos demo project. It's a simple guess-the-number game. +This directory contains the basic Cosmos demo project, it's a simple guess-the-number game. ### \Docs -This folder contains the Cosmos documentation that you're currently reading. +This direcotry contains the Cosmos documentation that you're currently reading. ### \QA -This folder contains the old Cosmos build scripts. -It isn't used at the moment. +This directory contains the old Cosmos build scripts, it's no more used at the moment. ### \Resources -This folder contains the 3rd party libraries that Cosmos uses. +This directory contains the third party libraries that Cosmos uses. ### \Setup -Contains scripts and languages to build the Cosmos User Kit Installer. The creation (and execution) of the installer is started from \install-VS2015.bat. +This directory contains all the scripts and languages to build the Cosmos User Kit Installer. The creation (and execution) of the installer is started from '.\install-VS2015.bat'. ### \Source -Contains all the code of the Cosmos project. You will spend most of your time here.including the Compiler, Installer, Debugger and the main features of Cosmos. It also contains unused code. - -It also contains the solution file of Cosmos and some support libraries. +This directory contains all the code of the Cosmos project. You will spend most of your time here, including the Compiler, Installer, Debugger and the main features of Cosmos. It's contains unused code, the solution file of Cosmos and some support libraries. #### \Source\Cosmos.Assembler -This folder contains the Cosmos assembler, the thing that writes generated assembly code in the kernel file. +This directory contains the Cosmos assembler, the thing that writes generated assembly code in the kernel file. #### \Source\Cosmos.Build -Any code related to the building process of Cosmos with the exception of -IL2CPU which is however executed from here. Contains code for executing ld, +This directory contains any code related to the building process of Cosmos with the exception of +IL2CPU which is however executed from here, it's contains code for executing ld, nasm, makeiso, MSBuild, and others. #### \Source\Cosmos.Common -Contains various helpers and files for Cosmos. +This directory contains various helpers and files for Cosmos. #### \Source\Cosmos.Core -This is the core assembly of cosmos. It contains code for managing CPU, IO groups, interrupts, etc. +This directory contains the core assembly of cosmos. It contains code for managing CPU, IO groups, interrupts, etc.. ##### \Source\Cosmos.Core.Plugs -This folder contains the low-level plugs for Cosmos.Core. +This directory contains the low-level plugs for Cosmos.Core. #### \Source\Cosmos.Debug -Contains the Debug Engine and Connector code. Also gives the possibility to -work with GDB. For more informations about debugging see -[Debugger](debugger.htm) +This directory contains the Debug Engine and Connector code and also, it's gives the possibility to +work with GDB. For more informations about debugging see the [Debugger](debugger.htm) page #### \Source\Cosmos.Deploy -Contains the deployment code. +This directory contains the deployment code. #### \Source\Cosmos.HAL -Contains code for Csosmos HAL (Hardware Abstraction Layer), means the hardware drivers for graphics, networking, HDD, etc. +This directory contains the Cosmos HAL (Hardware Abstraction Layer), means the hardware drivers for graphics, networking, HDD, etc. #### \Source\Cosmos.IL2CPU -Code for the IL2CPU program. It's the Cosmos AOT Compiler. For more -informations about AOT compilers and IL2CPU see [IL2CPU](https://github.com/CosmosOS/Cosmos/blob/master/Docs/Compiler/il2cpu.md) +This directory contains the code for the IL2CPU program, the Cosmos AOT Compiler. For more +informations about the AOT compilers and IL2CPU, see [IL2CPU](https://github.com/CosmosOS/Cosmos/blob/master/Docs/Compiler/il2cpu.md) documentation. #### \Source\Cosmos.System -Contains the system-level code for Cosmos. It contains wrappers for Console, networking and filesystem. It also contains the base class for Kernel. +This directory contains the system-level code for Cosmos. It contains wrappers for Console, networking, filesystem and also contains the base class for Kernel. #### \Source\Cosmos.VS -Contains the code for the integration with Visual Studio. Adds support for the Cosmos Kernel project type, and custom build steps. +This directory contains the code for the integration with Visual Studio. Adds support for the Cosmos Kernel project type, and custom build steps. ##### \Source\Cosmos.VS.Debug -Contains the code for the Visual Studio debugger integration. +This directory contains the code for the Visual Studio debugger integration. ##### \Source\Cosmos.VS.Package -Contains the code for the Visual Studio package of Cosmos. +This directory contains the code for the Visual Studio package of Cosmos. ##### \Source\Cosmos.VS.Windows -Contains the Cosmos windows in VS, like the Registers window. +This directory contains the Cosmos windows in Visual Studio, like the Registers Window. ##### \Source\Cosmos.VS.Windows.Test -Contains the tests for Cosmos.VS.Windows. +This directory contains the tests for Cosmos.VS.Windows. ##### \Source\Cosmos.VS.Wizards -Contains the project wizards of Cosmos. +This directory contains the wizards projects of Cosmos. #### \Source\Unused -This folder contains work-in-progress or deprecated features, like FAT, VGA and Networking. +This directory contains work-in-progress or deprecated features, like FAT, VGA, Networking and more. #### \Source\XSharp -This piece of code gives us the possibility to write Assembly in C#. In this way we can keep all in an OO-like style. +This directory contains code for the possibility to write Assembly in C#. In this way we can keep all in an OO-like style. #### \Users -Custom code playground. You can put your examples, random code, and toughts +This directory contains the custom code playground. You can put your examples, random code, and toughts here From c26a2bcd95cb146d3712da342515de59782e5df5 Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 16 Dec 2015 16:42:15 -0500 Subject: [PATCH 03/16] Fixed Broken String Functions fixed StartsWith, Contains, and EndsWith --- .../Cosmos.System.Plugs.csproj | 13 ++- .../Cosmos.System.Plugs/System/StringImpl.cs | 96 +++++++++++++++++++ 2 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 source/Cosmos.System.Plugs/System/StringImpl.cs diff --git a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj index 28b7edbad..4b1ce68e7 100644 --- a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj +++ b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj @@ -12,10 +12,14 @@ Cosmos.System.Plugs v4.5 512 - SAK - SAK - SAK - SAK + + + + + + + + true Cosmos.snk @@ -82,6 +86,7 @@ + diff --git a/source/Cosmos.System.Plugs/System/StringImpl.cs b/source/Cosmos.System.Plugs/System/StringImpl.cs new file mode 100644 index 000000000..cd4f94655 --- /dev/null +++ b/source/Cosmos.System.Plugs/System/StringImpl.cs @@ -0,0 +1,96 @@ +using Cosmos.IL2CPU.Plugs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plug = Cosmos.IL2CPU.Plugs.PlugAttribute; + +namespace Cosmos.System.Plugs.System +{ + [@Plug(Target = typeof(string))] + public static class StringImpl + { + public static bool StartsWith(this string str, string value) + { + Char[] di = str.ToCharArray(); + Char[] ci = value.ToCharArray(); + if (value.Length > str.Length) + { + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) + { + return false; + + } + } + return true; + } + + public static bool Contains(this string str, string comp) + { + Char[] di = str.ToCharArray(); + Char[] ci = comp.ToCharArray(); + if (comp.Length == str.Length) + { + if (comp == str) + { + return true; + } + else + { + return false; + } + } + else if (!(comp.Length > str.Length) && (comp.Length != str.Length)) + { + for (int i = 0; i < str.Length; i++) + { + if (di[i] == ci[0]) + { + for (int j = 1; j < comp.Length; j++) + { + if (di[i + j] != ci[j]) + { + return false; + } + } + return true; + } + } + } + return false; + } + public static bool EndsWith(this string str, string comp) + { + Char[] di = str.ToCharArray(); + Char[] ci = comp.ToCharArray(); + if(str.Length == comp.Length) + { + if(str == comp) + { + return true; + } + return false; + } + else if(comp.Length > str.Length) + { + return false; + } + else + { + for (int i = str.Length - comp.Length; i < str.Length; i++) + { + if (di[str.Length - comp.Length + i] != ci[i]) + { + return false; + } + } + return true; + } + } + } +} From 1b4bdaec6dce248682c7e36e58280c075a02ce0c Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 16 Dec 2015 16:44:37 -0500 Subject: [PATCH 04/16] Revert "Fixed Broken String Functions" This reverts commit c26a2bcd95cb146d3712da342515de59782e5df5. --- .../Cosmos.System.Plugs.csproj | 13 +-- .../Cosmos.System.Plugs/System/StringImpl.cs | 96 ------------------- 2 files changed, 4 insertions(+), 105 deletions(-) delete mode 100644 source/Cosmos.System.Plugs/System/StringImpl.cs diff --git a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj index 4b1ce68e7..28b7edbad 100644 --- a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj +++ b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj @@ -12,14 +12,10 @@ Cosmos.System.Plugs v4.5 512 - - - - - - - - + SAK + SAK + SAK + SAK true Cosmos.snk @@ -86,7 +82,6 @@ - diff --git a/source/Cosmos.System.Plugs/System/StringImpl.cs b/source/Cosmos.System.Plugs/System/StringImpl.cs deleted file mode 100644 index cd4f94655..000000000 --- a/source/Cosmos.System.Plugs/System/StringImpl.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Cosmos.IL2CPU.Plugs; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Plug = Cosmos.IL2CPU.Plugs.PlugAttribute; - -namespace Cosmos.System.Plugs.System -{ - [@Plug(Target = typeof(string))] - public static class StringImpl - { - public static bool StartsWith(this string str, string value) - { - Char[] di = str.ToCharArray(); - Char[] ci = value.ToCharArray(); - if (value.Length > str.Length) - { - return false; - } - for (int i = 0; i < ci.Length; i++) - { - if (di[i] != ci[i]) - { - return false; - - } - } - return true; - } - - public static bool Contains(this string str, string comp) - { - Char[] di = str.ToCharArray(); - Char[] ci = comp.ToCharArray(); - if (comp.Length == str.Length) - { - if (comp == str) - { - return true; - } - else - { - return false; - } - } - else if (!(comp.Length > str.Length) && (comp.Length != str.Length)) - { - for (int i = 0; i < str.Length; i++) - { - if (di[i] == ci[0]) - { - for (int j = 1; j < comp.Length; j++) - { - if (di[i + j] != ci[j]) - { - return false; - } - } - return true; - } - } - } - return false; - } - public static bool EndsWith(this string str, string comp) - { - Char[] di = str.ToCharArray(); - Char[] ci = comp.ToCharArray(); - if(str.Length == comp.Length) - { - if(str == comp) - { - return true; - } - return false; - } - else if(comp.Length > str.Length) - { - return false; - } - else - { - for (int i = str.Length - comp.Length; i < str.Length; i++) - { - if (di[str.Length - comp.Length + i] != ci[i]) - { - return false; - } - } - return true; - } - } - } -} From 0a5a46aac914e2f02521a46af63d060a05464fa7 Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 16 Dec 2015 16:44:52 -0500 Subject: [PATCH 05/16] Revert "Revert "Fixed Broken String Functions"" This reverts commit 1b4bdaec6dce248682c7e36e58280c075a02ce0c. --- .../Cosmos.System.Plugs.csproj | 13 ++- .../Cosmos.System.Plugs/System/StringImpl.cs | 96 +++++++++++++++++++ 2 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 source/Cosmos.System.Plugs/System/StringImpl.cs diff --git a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj index 28b7edbad..4b1ce68e7 100644 --- a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj +++ b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj @@ -12,10 +12,14 @@ Cosmos.System.Plugs v4.5 512 - SAK - SAK - SAK - SAK + + + + + + + + true Cosmos.snk @@ -82,6 +86,7 @@ + diff --git a/source/Cosmos.System.Plugs/System/StringImpl.cs b/source/Cosmos.System.Plugs/System/StringImpl.cs new file mode 100644 index 000000000..cd4f94655 --- /dev/null +++ b/source/Cosmos.System.Plugs/System/StringImpl.cs @@ -0,0 +1,96 @@ +using Cosmos.IL2CPU.Plugs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plug = Cosmos.IL2CPU.Plugs.PlugAttribute; + +namespace Cosmos.System.Plugs.System +{ + [@Plug(Target = typeof(string))] + public static class StringImpl + { + public static bool StartsWith(this string str, string value) + { + Char[] di = str.ToCharArray(); + Char[] ci = value.ToCharArray(); + if (value.Length > str.Length) + { + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) + { + return false; + + } + } + return true; + } + + public static bool Contains(this string str, string comp) + { + Char[] di = str.ToCharArray(); + Char[] ci = comp.ToCharArray(); + if (comp.Length == str.Length) + { + if (comp == str) + { + return true; + } + else + { + return false; + } + } + else if (!(comp.Length > str.Length) && (comp.Length != str.Length)) + { + for (int i = 0; i < str.Length; i++) + { + if (di[i] == ci[0]) + { + for (int j = 1; j < comp.Length; j++) + { + if (di[i + j] != ci[j]) + { + return false; + } + } + return true; + } + } + } + return false; + } + public static bool EndsWith(this string str, string comp) + { + Char[] di = str.ToCharArray(); + Char[] ci = comp.ToCharArray(); + if(str.Length == comp.Length) + { + if(str == comp) + { + return true; + } + return false; + } + else if(comp.Length > str.Length) + { + return false; + } + else + { + for (int i = str.Length - comp.Length; i < str.Length; i++) + { + if (di[str.Length - comp.Length + i] != ci[i]) + { + return false; + } + } + return true; + } + } + } +} From 224ef150009066308f904085ee92ae4b7f2b7e55 Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 16 Dec 2015 16:45:11 -0500 Subject: [PATCH 06/16] Revert "Revert "Revert "Fixed Broken String Functions""" This reverts commit 0a5a46aac914e2f02521a46af63d060a05464fa7. --- .../Cosmos.System.Plugs.csproj | 13 +-- .../Cosmos.System.Plugs/System/StringImpl.cs | 96 ------------------- 2 files changed, 4 insertions(+), 105 deletions(-) delete mode 100644 source/Cosmos.System.Plugs/System/StringImpl.cs diff --git a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj index 4b1ce68e7..28b7edbad 100644 --- a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj +++ b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj @@ -12,14 +12,10 @@ Cosmos.System.Plugs v4.5 512 - - - - - - - - + SAK + SAK + SAK + SAK true Cosmos.snk @@ -86,7 +82,6 @@ - diff --git a/source/Cosmos.System.Plugs/System/StringImpl.cs b/source/Cosmos.System.Plugs/System/StringImpl.cs deleted file mode 100644 index cd4f94655..000000000 --- a/source/Cosmos.System.Plugs/System/StringImpl.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Cosmos.IL2CPU.Plugs; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Plug = Cosmos.IL2CPU.Plugs.PlugAttribute; - -namespace Cosmos.System.Plugs.System -{ - [@Plug(Target = typeof(string))] - public static class StringImpl - { - public static bool StartsWith(this string str, string value) - { - Char[] di = str.ToCharArray(); - Char[] ci = value.ToCharArray(); - if (value.Length > str.Length) - { - return false; - } - for (int i = 0; i < ci.Length; i++) - { - if (di[i] != ci[i]) - { - return false; - - } - } - return true; - } - - public static bool Contains(this string str, string comp) - { - Char[] di = str.ToCharArray(); - Char[] ci = comp.ToCharArray(); - if (comp.Length == str.Length) - { - if (comp == str) - { - return true; - } - else - { - return false; - } - } - else if (!(comp.Length > str.Length) && (comp.Length != str.Length)) - { - for (int i = 0; i < str.Length; i++) - { - if (di[i] == ci[0]) - { - for (int j = 1; j < comp.Length; j++) - { - if (di[i + j] != ci[j]) - { - return false; - } - } - return true; - } - } - } - return false; - } - public static bool EndsWith(this string str, string comp) - { - Char[] di = str.ToCharArray(); - Char[] ci = comp.ToCharArray(); - if(str.Length == comp.Length) - { - if(str == comp) - { - return true; - } - return false; - } - else if(comp.Length > str.Length) - { - return false; - } - else - { - for (int i = str.Length - comp.Length; i < str.Length; i++) - { - if (di[str.Length - comp.Length + i] != ci[i]) - { - return false; - } - } - return true; - } - } - } -} From 64440ba3c12b70c3b4e77c5cf75245ac8199f43e Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 16 Dec 2015 16:47:07 -0500 Subject: [PATCH 07/16] Fixed Broken String Comparison Functions StartsWith() Contains() EndsWith() --- .../Cosmos.System.Plugs.csproj | 13 ++- .../Cosmos.System.Plugs/System/StringImpl.cs | 96 +++++++++++++++++++ 2 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 source/Cosmos.System.Plugs/System/StringImpl.cs diff --git a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj index 28b7edbad..4b1ce68e7 100644 --- a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj +++ b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj @@ -12,10 +12,14 @@ Cosmos.System.Plugs v4.5 512 - SAK - SAK - SAK - SAK + + + + + + + + true Cosmos.snk @@ -82,6 +86,7 @@ + diff --git a/source/Cosmos.System.Plugs/System/StringImpl.cs b/source/Cosmos.System.Plugs/System/StringImpl.cs new file mode 100644 index 000000000..cd4f94655 --- /dev/null +++ b/source/Cosmos.System.Plugs/System/StringImpl.cs @@ -0,0 +1,96 @@ +using Cosmos.IL2CPU.Plugs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plug = Cosmos.IL2CPU.Plugs.PlugAttribute; + +namespace Cosmos.System.Plugs.System +{ + [@Plug(Target = typeof(string))] + public static class StringImpl + { + public static bool StartsWith(this string str, string value) + { + Char[] di = str.ToCharArray(); + Char[] ci = value.ToCharArray(); + if (value.Length > str.Length) + { + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) + { + return false; + + } + } + return true; + } + + public static bool Contains(this string str, string comp) + { + Char[] di = str.ToCharArray(); + Char[] ci = comp.ToCharArray(); + if (comp.Length == str.Length) + { + if (comp == str) + { + return true; + } + else + { + return false; + } + } + else if (!(comp.Length > str.Length) && (comp.Length != str.Length)) + { + for (int i = 0; i < str.Length; i++) + { + if (di[i] == ci[0]) + { + for (int j = 1; j < comp.Length; j++) + { + if (di[i + j] != ci[j]) + { + return false; + } + } + return true; + } + } + } + return false; + } + public static bool EndsWith(this string str, string comp) + { + Char[] di = str.ToCharArray(); + Char[] ci = comp.ToCharArray(); + if(str.Length == comp.Length) + { + if(str == comp) + { + return true; + } + return false; + } + else if(comp.Length > str.Length) + { + return false; + } + else + { + for (int i = str.Length - comp.Length; i < str.Length; i++) + { + if (di[str.Length - comp.Length + i] != ci[i]) + { + return false; + } + } + return true; + } + } + } +} From f8fabfd49e31b88837827d5d2b665bef4ebe89f5 Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 16 Dec 2015 21:11:29 -0500 Subject: [PATCH 08/16] Revert "Fixed Broken String Comparison Functions" This reverts commit 64440ba3c12b70c3b4e77c5cf75245ac8199f43e. --- .../Cosmos.System.Plugs.csproj | 13 +-- .../Cosmos.System.Plugs/System/StringImpl.cs | 96 ------------------- 2 files changed, 4 insertions(+), 105 deletions(-) delete mode 100644 source/Cosmos.System.Plugs/System/StringImpl.cs diff --git a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj index 4b1ce68e7..28b7edbad 100644 --- a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj +++ b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj @@ -12,14 +12,10 @@ Cosmos.System.Plugs v4.5 512 - - - - - - - - + SAK + SAK + SAK + SAK true Cosmos.snk @@ -86,7 +82,6 @@ - diff --git a/source/Cosmos.System.Plugs/System/StringImpl.cs b/source/Cosmos.System.Plugs/System/StringImpl.cs deleted file mode 100644 index cd4f94655..000000000 --- a/source/Cosmos.System.Plugs/System/StringImpl.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Cosmos.IL2CPU.Plugs; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Plug = Cosmos.IL2CPU.Plugs.PlugAttribute; - -namespace Cosmos.System.Plugs.System -{ - [@Plug(Target = typeof(string))] - public static class StringImpl - { - public static bool StartsWith(this string str, string value) - { - Char[] di = str.ToCharArray(); - Char[] ci = value.ToCharArray(); - if (value.Length > str.Length) - { - return false; - } - for (int i = 0; i < ci.Length; i++) - { - if (di[i] != ci[i]) - { - return false; - - } - } - return true; - } - - public static bool Contains(this string str, string comp) - { - Char[] di = str.ToCharArray(); - Char[] ci = comp.ToCharArray(); - if (comp.Length == str.Length) - { - if (comp == str) - { - return true; - } - else - { - return false; - } - } - else if (!(comp.Length > str.Length) && (comp.Length != str.Length)) - { - for (int i = 0; i < str.Length; i++) - { - if (di[i] == ci[0]) - { - for (int j = 1; j < comp.Length; j++) - { - if (di[i + j] != ci[j]) - { - return false; - } - } - return true; - } - } - } - return false; - } - public static bool EndsWith(this string str, string comp) - { - Char[] di = str.ToCharArray(); - Char[] ci = comp.ToCharArray(); - if(str.Length == comp.Length) - { - if(str == comp) - { - return true; - } - return false; - } - else if(comp.Length > str.Length) - { - return false; - } - else - { - for (int i = str.Length - comp.Length; i < str.Length; i++) - { - if (di[str.Length - comp.Length + i] != ci[i]) - { - return false; - } - } - return true; - } - } - } -} From 2b46c857e7fbe119de669737099b86a1cf748707 Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 16 Dec 2015 21:14:17 -0500 Subject: [PATCH 09/16] Fixed String Comparisons Fixed String Comparisons --- source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj | 12 +- .../CustomImplementation/System/StringImpl.cs | 147 ++++++++++++++---- 2 files changed, 128 insertions(+), 31 deletions(-) diff --git a/source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj b/source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj index e3d02687a..7b3f456ed 100644 --- a/source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj +++ b/source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj @@ -12,10 +12,14 @@ Cosmos.IL2CPU v4.5 512 - SAK - SAK - SAK - SAK + + + + + + + + true Cosmos.snk diff --git a/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs b/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs index 36aecce0a..e4dc2007f 100644 --- a/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs +++ b/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs @@ -177,8 +177,21 @@ public static bool StartsWith(string aThis, string aSubstring, StringComparison aComparison) { - Console.WriteLine("String.StartsWith not working!"); - throw new NotImplementedException(); + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubstring.ToCharArray(); + if (aSubstring.Length > aThis.Length) + { + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) + { + return false; + + } + } + return true; } //String concatenation plugs @@ -559,11 +572,36 @@ public static bool Contains(string aThis, string value) { - if (aThis.IndexOf(value) != -1) + Char[] di = aThis.ToCharArray(); + Char[] ci = value.ToCharArray(); + if (value.Length == aThis.Length) { - return true; + if (value == aThis) + { + return true; + } + else + { + return false; + } + } + else if (!(value.Length > aThis.Length) && (value.Length != aThis.Length)) + { + for (int i = 0; i < aThis.Length; i++) + { + if (di[i] == ci[0]) + { + for (int j = 1; j < value.Length; j++) + { + if (di[i + j] != ci[j]) + { + return false; + } + } + return true; + } + } } - return false; } @@ -574,30 +612,31 @@ public static bool EndsWith(string aThis, string aSubStr, StringComparison aComparison) { - if (aSubStr == null) + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubStr.ToCharArray(); + if (aThis.Length == aSubStr.Length) { - throw new ArgumentNullException("aSubStr"); - } - - if (aThis == aSubStr) - { - return true; - } - - if (aSubStr.Length == 0) - { - return true; - } - - int xLastIdx = aThis.Length - aSubStr.Length; - for (int i = 0; i < aSubStr.Length; i++) - { - if (aThis[xLastIdx + i] != aSubStr[i]) + if (aThis == aSubStr) { - return false; + return true; } + return false; + } + else if (aThis.Length > aSubStr.Length) + { + return false; + } + else + { + for (int i = aThis.Length - aSubStr.Length; i < aThis.Length; i++) + { + if (di[aThis.Length - aSubStr.Length + i] != ci[i]) + { + return false; + } + } + return true; } - return true; } // System.Int32 System.String.IndexOf(System.String, System.Int32, System.Int32, System.StringComparison) @@ -689,11 +728,18 @@ public static bool StartsWith(string aThis, string aSubStr, bool aIgnoreCase, CultureInfo aCulture) { - for (int i = 0; i < aSubStr.Length; i++) + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubStr.ToCharArray(); + if (aSubStr.Length > aThis.Length) { - if (aThis[i] != aSubStr[i]) + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) { return false; + } } return true; @@ -760,6 +806,53 @@ return new string(new char[length]); } + public static string dTrimStart(string aThis, string aSubStr) + { + char[] ci = aThis.ToCharArray(); + char[] di = aSubStr.ToCharArray(); + + if(aThis.StartsWith(aSubStr)) + { + if(!(aThis == aSubStr)) + { + char[] oi = new char[ci.Length - di.Length]; + for(int i=0; i < ci.Length - di.Length; i++) + { + oi[i] = ci[i + di.Length]; + } + return oi.ToString(); + } + else + { + return ""; + } + } + else + { + throw new ArgumentNullException(); + } + + } + + + + + + + + + + + + + + + + + + + + /*public int IndexOf(char c) { // TODO: We can't get 'this' From e9b163a75b6ae293344cdd6ff244869ae140b930 Mon Sep 17 00:00:00 2001 From: Cyber Date: Thu, 17 Dec 2015 15:01:54 -0500 Subject: [PATCH 10/16] Revert "Fixed String Comparisons" This reverts commit 2b46c857e7fbe119de669737099b86a1cf748707. --- source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj | 12 +- .../CustomImplementation/System/StringImpl.cs | 145 ++++-------------- 2 files changed, 30 insertions(+), 127 deletions(-) diff --git a/source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj b/source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj index 7b3f456ed..e3d02687a 100644 --- a/source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj +++ b/source/Cosmos.IL2CPU/Cosmos.IL2CPU.csproj @@ -12,14 +12,10 @@ Cosmos.IL2CPU v4.5 512 - - - - - - - - + SAK + SAK + SAK + SAK true Cosmos.snk diff --git a/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs b/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs index e4dc2007f..36aecce0a 100644 --- a/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs +++ b/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs @@ -177,21 +177,8 @@ public static bool StartsWith(string aThis, string aSubstring, StringComparison aComparison) { - Char[] di = aThis.ToCharArray(); - Char[] ci = aSubstring.ToCharArray(); - if (aSubstring.Length > aThis.Length) - { - return false; - } - for (int i = 0; i < ci.Length; i++) - { - if (di[i] != ci[i]) - { - return false; - - } - } - return true; + Console.WriteLine("String.StartsWith not working!"); + throw new NotImplementedException(); } //String concatenation plugs @@ -572,36 +559,11 @@ public static bool Contains(string aThis, string value) { - Char[] di = aThis.ToCharArray(); - Char[] ci = value.ToCharArray(); - if (value.Length == aThis.Length) + if (aThis.IndexOf(value) != -1) { - if (value == aThis) - { - return true; - } - else - { - return false; - } - } - else if (!(value.Length > aThis.Length) && (value.Length != aThis.Length)) - { - for (int i = 0; i < aThis.Length; i++) - { - if (di[i] == ci[0]) - { - for (int j = 1; j < value.Length; j++) - { - if (di[i + j] != ci[j]) - { - return false; - } - } - return true; - } - } + return true; } + return false; } @@ -612,31 +574,30 @@ public static bool EndsWith(string aThis, string aSubStr, StringComparison aComparison) { - Char[] di = aThis.ToCharArray(); - Char[] ci = aSubStr.ToCharArray(); - if (aThis.Length == aSubStr.Length) + if (aSubStr == null) { - if (aThis == aSubStr) - { - return true; - } - return false; + throw new ArgumentNullException("aSubStr"); } - else if (aThis.Length > aSubStr.Length) + + if (aThis == aSubStr) { - return false; - } - else - { - for (int i = aThis.Length - aSubStr.Length; i < aThis.Length; i++) - { - if (di[aThis.Length - aSubStr.Length + i] != ci[i]) - { - return false; - } - } return true; } + + if (aSubStr.Length == 0) + { + return true; + } + + int xLastIdx = aThis.Length - aSubStr.Length; + 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) @@ -728,18 +689,11 @@ public static bool StartsWith(string aThis, string aSubStr, bool aIgnoreCase, CultureInfo aCulture) { - Char[] di = aThis.ToCharArray(); - Char[] ci = aSubStr.ToCharArray(); - if (aSubStr.Length > aThis.Length) + for (int i = 0; i < aSubStr.Length; i++) { - return false; - } - for (int i = 0; i < ci.Length; i++) - { - if (di[i] != ci[i]) + if (aThis[i] != aSubStr[i]) { return false; - } } return true; @@ -806,53 +760,6 @@ return new string(new char[length]); } - public static string dTrimStart(string aThis, string aSubStr) - { - char[] ci = aThis.ToCharArray(); - char[] di = aSubStr.ToCharArray(); - - if(aThis.StartsWith(aSubStr)) - { - if(!(aThis == aSubStr)) - { - char[] oi = new char[ci.Length - di.Length]; - for(int i=0; i < ci.Length - di.Length; i++) - { - oi[i] = ci[i + di.Length]; - } - return oi.ToString(); - } - else - { - return ""; - } - } - else - { - throw new ArgumentNullException(); - } - - } - - - - - - - - - - - - - - - - - - - - /*public int IndexOf(char c) { // TODO: We can't get 'this' From 05148af8cfbb1d00bfe6624437cc3f5c397e6323 Mon Sep 17 00:00:00 2001 From: Cyber Date: Thu, 17 Dec 2015 15:52:22 -0500 Subject: [PATCH 11/16] FINALLY fixed string stuff --- .../CustomImplementation/System/StringImpl.cs | 152 ++- .../Cosmos.System.Plugs/System/StringImpl.cs | 871 ++++++++++++++++++ 2 files changed, 994 insertions(+), 29 deletions(-) create mode 100644 source/Cosmos.System.Plugs/System/StringImpl.cs diff --git a/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs b/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs index 36aecce0a..7e0aab250 100644 --- a/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs +++ b/source/Cosmos.IL2CPU/CustomImplementation/System/StringImpl.cs @@ -7,10 +7,10 @@ using global::System; using global::System.Globalization; - [Plug(Target = typeof(string), IsMicrosoftdotNETOnly = true)] + //[Plug(Target = typeof(string), IsMicrosoftdotNETOnly = true)] public static class StringImpl { - public static unsafe void Ctor( + /*public static unsafe void Ctor( string aThis, char[] aChars, [FieldAccess(Name = "System.Int32 System.String.m_stringLength")] ref int aStringLength, @@ -177,8 +177,21 @@ public static bool StartsWith(string aThis, string aSubstring, StringComparison aComparison) { - Console.WriteLine("String.StartsWith not working!"); - throw new NotImplementedException(); + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubstring.ToCharArray(); + if (aSubstring.Length > aThis.Length) + { + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) + { + return false; + + } + } + return true; } //String concatenation plugs @@ -559,11 +572,36 @@ public static bool Contains(string aThis, string value) { - if (aThis.IndexOf(value) != -1) + Char[] di = aThis.ToCharArray(); + Char[] ci = value.ToCharArray(); + if (value.Length == aThis.Length) { - return true; + if (value == aThis) + { + return true; + } + else + { + return false; + } + } + else if (!(value.Length > aThis.Length) && (value.Length != aThis.Length)) + { + for (int i = 0; i < aThis.Length; i++) + { + if (di[i] == ci[0]) + { + for (int j = 1; j < value.Length; j++) + { + if (di[i + j] != ci[j]) + { + return false; + } + } + return true; + } + } } - return false; } @@ -574,30 +612,31 @@ public static bool EndsWith(string aThis, string aSubStr, StringComparison aComparison) { - if (aSubStr == null) + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubStr.ToCharArray(); + if (aThis.Length == aSubStr.Length) { - throw new ArgumentNullException("aSubStr"); - } - - if (aThis == aSubStr) - { - return true; - } - - if (aSubStr.Length == 0) - { - return true; - } - - int xLastIdx = aThis.Length - aSubStr.Length; - for (int i = 0; i < aSubStr.Length; i++) - { - if (aThis[xLastIdx + i] != aSubStr[i]) + if (aThis == aSubStr) { - return false; + return true; } + return false; + } + else if (aThis.Length > aSubStr.Length) + { + return false; + } + else + { + for (int i = aThis.Length - aSubStr.Length; i < aThis.Length; i++) + { + if (di[aThis.Length - aSubStr.Length + i] != ci[i]) + { + return false; + } + } + return true; } - return true; } // System.Int32 System.String.IndexOf(System.String, System.Int32, System.Int32, System.StringComparison) @@ -689,11 +728,18 @@ public static bool StartsWith(string aThis, string aSubStr, bool aIgnoreCase, CultureInfo aCulture) { - for (int i = 0; i < aSubStr.Length; i++) + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubStr.ToCharArray(); + if (aSubStr.Length > aThis.Length) { - if (aThis[i] != aSubStr[i]) + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) { return false; + } } return true; @@ -760,6 +806,53 @@ return new string(new char[length]); } + public static string dTrimStart(string aThis, string aSubStr) + { + char[] ci = aThis.ToCharArray(); + char[] di = aSubStr.ToCharArray(); + + if(aThis.StartsWith(aSubStr)) + { + if(!(aThis == aSubStr)) + { + char[] oi = new char[ci.Length - di.Length]; + for(int i=0; i < ci.Length - di.Length; i++) + { + oi[i] = ci[i + di.Length]; + } + return oi.ToString(); + } + else + { + return ""; + } + } + else + { + throw new ArgumentNullException(); + } + + } + + + + + + + + + + + + + + + + + + + + /*public int IndexOf(char c) { // TODO: We can't get 'this' @@ -771,5 +864,6 @@ //} return -1; }*/ + } } \ No newline at end of file diff --git a/source/Cosmos.System.Plugs/System/StringImpl.cs b/source/Cosmos.System.Plugs/System/StringImpl.cs new file mode 100644 index 000000000..e8a2b2704 --- /dev/null +++ b/source/Cosmos.System.Plugs/System/StringImpl.cs @@ -0,0 +1,871 @@ +using Cosmos.Common; +using Cosmos.Debug.Kernel; +using Cosmos.IL2CPU.Plugs; +using Sys = Cosmos.System; +using global::System; +using global::System.Globalization; + + +namespace Cosmos.System.Plugs.System +{ + [Plug(Target = typeof(string), IsMicrosoftdotNETOnly = true)] + public static class StringImpl + { + public static unsafe void Ctor( + string aThis, + char[] aChars, + [FieldAccess(Name = "System.Int32 System.String.m_stringLength")] ref int aStringLength, + [FieldAccess(Name = "System.Char System.String.m_firstChar")] char* aFirstChar) + { + aStringLength = aChars.Length; + for (int i = 0; i < aChars.Length; i++) + { + aFirstChar[i] = aChars[i]; + } + } + + public static unsafe void Ctor( + string aThis, + char[] aChars, + int start, + int length, + [FieldAccess(Name = "System.Int32 System.String.m_stringLength")] ref int aStringLength, + [FieldAccess(Name = "System.Char System.String.m_firstChar")] char* aFirstChar) + { + aStringLength = length; + for (int i = 0; i < length; i++) + { + aFirstChar[i] = aChars[start + i]; + } + } + + public static unsafe void Ctor( + string aThis, + char aChar, + int aLength, + [FieldAccess(Name = "System.Int32 System.String.m_stringLength")] ref int aStringLength, + [FieldAccess(Name = "System.Char System.String.m_firstChar")] char* aFirstChar) + { + aStringLength = aLength; + for (int i = 0; i < aLength; i++) + { + aFirstChar[i] = aChar; + } + } + + public static unsafe int get_Length( + int* aThis, + [FieldAccess(Name = "System.Int32 System.String.m_stringLength")] ref int aLength) + { + return aLength; + } + + public static unsafe char get_Chars(uint* aThis, int aIndex) + { + // todo: change to use a FieldAccessAttribute, to get the pointer to the first character and go from there + + // we first need to dereference the handle to a pointer. + uint xActualThis = aThis[0]; + var xCharIdx = (char*)(xActualThis + 16); + return xCharIdx[aIndex]; + } + + public static string Format(string aFormat, object aArg1) + { + if (aArg1 == null) + { + throw new ArgumentNullException(aFormat == null ? "aFormat" : "aArgs"); + } + var xO = new object[1]; + xO[0] = aArg1; + return FormatHelper(null, aFormat, xO); + } + + public static string Format(string aFormat, object aArg1, object aArg2) + { + if ((aArg1 == null) || (aArg2 == null)) + { + throw new ArgumentNullException(aFormat == null ? "aFormat" : "aArgs"); + } + var xO = new object[2]; + xO[0] = aArg1; + xO[1] = aArg2; + return FormatHelper(null, aFormat, xO); + } + + public static string Format(string aFormat, object aArg1, object aArg2, object aArg3) + { + if ((aArg1 == null) || (aArg2 == null) || (aArg3 == null)) + { + throw new ArgumentNullException(aFormat == null ? "aFormat" : "aArgs"); + } + var xO = new object[3]; + xO[0] = aArg1; + xO[1] = aArg2; + xO[2] = aArg3; + return FormatHelper(null, aFormat, xO); + } + + public static string Format(string aFormat, params object[] aArgs) + { + if (aArgs == null) + { + throw new ArgumentNullException(aFormat == null ? "aFormat" : "aArgs"); + } + return FormatHelper(null, aFormat, aArgs); + } + + public static string Format(IFormatProvider aFormatProvider, string aFormat, params object[] aArgs) + { + if (aArgs == null) + { + throw new ArgumentNullException(aFormat == null ? "aFormat" : "aArgs"); + } + return FormatHelper(aFormatProvider, aFormat, aArgs); + } + + public static string FormatHelper(IFormatProvider aFormatProvider, string aFormat, object[] aArgs) + { + char[] xCharArray = aFormat.ToCharArray(); + string xFormattedString = string.Empty; + bool xFoundPlaceholder = false; + string xParamNumber = string.Empty; + bool xParamNumberDone = true; + for (int i = 0; i < xCharArray.Length; i++) + { + if (xFoundPlaceholder) + { + if (xCharArray[i] == '{') + { + throw new FormatException("The format string provided is invalid."); + } + if (xCharArray[i] == '}') + { + int xParamIndex = StringHelper.GetStringToNumber(xParamNumber); + if ((xParamIndex < aArgs.Length - 1) && (aArgs[xParamIndex] != null)) + { + string xParamValue = aArgs[xParamIndex].ToString(); + xFormattedString = string.Concat(xFormattedString, xParamValue); + } + xFoundPlaceholder = false; + xParamNumberDone = true; + xParamNumber = string.Empty; + } + else if (xCharArray[i] == ':') + { + xParamNumberDone = true; + // TODO: Need to handle different formats. (X, N, etc) + } + else if ((char.IsDigit(xCharArray[i])) && (!xParamNumberDone)) + { + xParamNumber = string.Concat(xParamNumber, xCharArray[i]); + } + } + else if (xCharArray[i] == '{') + { + xFoundPlaceholder = true; + xParamNumberDone = false; + xParamNumber = string.Empty; + } + else + { + xFormattedString = string.Concat(xFormattedString, xCharArray[i]); + } + } + + return xFormattedString; + } + + public static bool StartsWith(this string aThis, string aSubstring, StringComparison aComparison) + { + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubstring.ToCharArray(); + if (aSubstring.Length > aThis.Length) + { + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) + { + return false; + + } + } + return true; + } + + //String concatenation plugs + public static string Concat(string str0) + { + return str0; + } + + public static string Concat(string str0, string str1) + { + return Concat(new[] { str0, str1 }); + } + + public static string Concat(string str0, string str1, string str2) + { + return Concat(new[] { str0, str1, str2 }); + } + + public static string Concat(string str0, string str1, string str2, string str3) + { + return Concat(new[] { str0, str1, str2, str3 }); + } + + //Object concatenation plugs + public static string Concat(object obj0) + { + return obj0?.ToString(); + } + + public static string Concat(object obj0, object obj1) + { + return Concat(obj0?.ToString(), obj1?.ToString()); + } + + public static string Concat(object obj0, object obj1, object obj2) + { + return Concat(obj0?.ToString(), obj1?.ToString(), obj2?.ToString()); + } + + public static string Concat(object obj0, object obj1, object obj2, object obj3) + { + return Concat(new[] { obj0?.ToString(), obj1?.ToString(), obj2?.ToString(), obj3?.ToString() }); + } + + //Array concatenation plugs + public static string Concat(params string[] values) + { + if (values != null) + { + int len = 0; + for (int i = 0; i < values.Length; i++) + { + string xValue = values[i]; + if (xValue != null) + { + len += values[i].Length; + } + } + return ConcatArray(values, len); + } + return string.Empty; + } + + public static string Concat(params object[] args) + { + if (args != null) + { + var values = new string[args.Length]; + for (int i = 0; i < args.Length; i++) + { + var xArg = args[i]; + if (xArg != null) + { + string xStrArg = xArg as string; + if (xStrArg != null) + { + values[i] = xStrArg; + } + else + { + values[i] = xArg.ToString(); + } + } + } + return Concat(values); + } + return string.Empty; + } + + public static string ConcatArray(string[] values, int totalLength) + { + if (values != null) + { + var xResultChars = new char[totalLength]; + int xCurPos = 0; + for (int i = 0; i < values.Length; i++) + { + string xStr = values[i]; + if (xStr != null) + { + for (int j = 0; j < xStr.Length; j++) + { + xResultChars[xCurPos] = xStr[j]; + xCurPos++; + } + } + } + string xResult = new string(xResultChars); + return xResult; + } + return string.Empty; + } + + public static string PadHelper(this string aThis, int totalWidth, char paddingChar, bool isRightPadded) + { + //Console.Write("PadHelper, totalWidth = "); + //WriteNumber((uint)totalWidth, 32); + //Console.WriteLine(""); + var cs = new char[totalWidth]; + + int pos = aThis.Length; + + if (isRightPadded) + { + for (int i = 0; i < aThis.Length; i++) + { + cs[i] = aThis[i]; + } + + for (int i = aThis.Length; i < totalWidth; i++) + { + cs[i] = paddingChar; + } + } + else + { + int offset = totalWidth - aThis.Length; + for (int i = 0; i < aThis.Length; i++) + { + cs[i + offset] = aThis[i]; + } + + for (int i = 0; i < offset; i++) + { + cs[i] = paddingChar; + } + } + + return new string(cs); + } + + public static string Substring(this string aThis, int startpos) + { + var cs = new char[aThis.Length - startpos]; + int j = 0; + for (int i = startpos; i < aThis.Length; i++) + { + cs[j++] = aThis[i]; + } + + return new string(cs); + } + + public static string Substring(this string aThis, int startpos, int length) + { + if (startpos + length > aThis.Length) + { + length = aThis.Length - startpos; + } + + var cs = new char[length]; + + int j = 0; + for (int i = startpos; i < startpos + length; i++) + { + cs[j++] = aThis[i]; + } + + return new string(cs); + } + + public static string Replace(this string aThis, char oldValue, char newValue) + { + var cs = new char[aThis.Length]; + + for (int i = 0; i < aThis.Length; i++) + { + if (aThis[i] != oldValue) + { + cs[i] = aThis[i]; + } + else + { + cs[i] = newValue; + } + } + + return new string(cs); + } + + // HACK: We need to redo this once char support is complete (only returns 0, -1). + public static int CompareTo(this string aThis, string other) + { + if (aThis.Length != other.Length) + { + return -1; + } + for (int i = 0; i < aThis.Length; i++) + { + if (aThis[i] != other[i]) + { + return -1; + } + } + return 0; + } + + public static int IndexOf(this string aThis, char value, int startIndex, int count) + { + int xEndIndex = aThis.Length; + if (startIndex + count < xEndIndex) + { + xEndIndex = startIndex + count; + } + for (int i = startIndex; i < xEndIndex; i++) + { + if (aThis[i] == value) + { + return i; + } + } + + return -1; + } + + // HACK: TODO - improve efficiency of this. + //How do we access the raw memory to copy it into a char array? + public static char[] ToCharArray(this string aThis) + { + var result = new char[aThis.Length]; + + for (int i = 0; i < aThis.Length; i++) + { + result[i] = aThis[i]; + } + + return result; + } + + [PlugMethod(Enabled = false)] + public static uint GetStorage(string aString) + { + return 0; + } + + //[PlugMethod(Enabled = false)] + //public static char[] GetStorageArray(string aString) { + // return null; + //} + + private static int[] BuildBadCharTable(char[] needle) + { + var badShift = new int[256]; + for (int i = 0; i < 256; i++) + { + badShift[i] = needle.Length; + } + int last = needle.Length - 1; + for (int i = 0; i < last; i++) + { + badShift[needle[i]] = last - i; + } + return badShift; + } + + private static int boyerMooreHorsepool(string pattern, string text) + { + var needle = pattern.ToCharArray(); + var haystack = text.ToCharArray(); + + if (needle.Length > haystack.Length) + { + return -1; + } + var badShift = BuildBadCharTable(needle); + int offset = 0; + int scan = 0; + int last = needle.Length - 1; + int maxoffset = haystack.Length - needle.Length; + while (offset <= maxoffset) + { + for (scan = last; needle[scan] == haystack[scan + offset]; scan--) + { + if (scan == 0) + { + //Match found + return offset; + } + } + offset += badShift[haystack[offset + last]]; + } + return -1; + } + + public static int IndexOf(this string aThis, string aSubstring, int aIdx, int aLength, StringComparison aComparison) + { + + return boyerMooreHorsepool(aSubstring, aThis.Substring(aIdx, aLength)); + } + + //private static void WriteNumber(uint aValue, + // byte aBitCount) + //{ + // uint xValue = aValue; + // byte xCurrentBits = aBitCount; + // Console.Write("0x"); + // while (xCurrentBits >= 4) + // { + // xCurrentBits -= 4; + // byte xCurrentDigit = (byte)((xValue >> xCurrentBits) & 0xF); + // string xDigitString = null; + // switch (xCurrentDigit) + // { + // case 0: + // xDigitString = "0"; + // goto default; + // case 1: + // xDigitString = "1"; + // goto default; + // case 2: + // xDigitString = "2"; + // goto default; + // case 3: + // xDigitString = "3"; + // goto default; + // case 4: + // xDigitString = "4"; + // goto default; + // case 5: + // xDigitString = "5"; + // goto default; + // case 6: + // xDigitString = "6"; + // goto default; + // case 7: + // xDigitString = "7"; + // goto default; + // case 8: + // xDigitString = "8"; + // goto default; + // case 9: + // xDigitString = "9"; + // goto default; + // case 10: + // xDigitString = "A"; + // goto default; + // case 11: + // xDigitString = "B"; + // goto default; + // case 12: + // xDigitString = "C"; + // goto default; + // case 13: + // xDigitString = "D"; + // goto default; + // case 14: + // xDigitString = "E"; + // goto default; + // case 15: + // xDigitString = "F"; + // goto default; + // default: + // Console.Write(xDigitString); + // break; + // } + // } + //} + + public static bool Contains(this string aThis, string value) + { + Char[] di = aThis.ToCharArray(); + Char[] ci = value.ToCharArray(); + if (value.Length == aThis.Length) + { + if (value == aThis) + { + return true; + } + else + { + return false; + } + } + else if (!(value.Length > aThis.Length) && (value.Length != aThis.Length)) + { + for (int i = 0; i < aThis.Length; i++) + { + if (di[i] == ci[0]) + { + for (int j = 1; j < value.Length; j++) + { + if (di[i + j] != ci[j]) + { + return false; + } + } + return true; + } + } + } + return false; + } + + public static bool EndsWith(this string aThis, string aSubStr, bool aIgnoreCase, CultureInfo aCulture) + { + return EndsWith(aThis, aSubStr, StringComparison.CurrentCulture); + } + + public static bool EndsWith(this string aThis, string aSubStr, StringComparison aComparison) + { + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubStr.ToCharArray(); + if (aThis.Length == aSubStr.Length) + { + if (aThis == aSubStr) + { + return true; + } + return false; + } + else if (aThis.Length > aSubStr.Length) + { + return false; + } + else + { + for (int i = aThis.Length - aSubStr.Length; i < aThis.Length; i++) + { + if (di[aThis.Length - aSubStr.Length + i] != ci[i]) + { + return false; + } + } + return true; + } + } + + // System.Int32 System.String.IndexOf(System.String, System.Int32, System.Int32, System.StringComparison) + + public static bool Equals(this string aThis, string aThat, StringComparison aComparison) + { +#warning TODO: implement + if (aComparison == StringComparison.OrdinalIgnoreCase) + { + string xLowerThis = aThis.ToLower(); + string xLowerThat = aThat.ToLower(); + return EqualsHelper(xLowerThis, xLowerThat); + } + return EqualsHelper(aThis, aThat); + } + + public static bool EqualsHelper(string aStrA, string aStrB) + { + return aStrA.CompareTo(aStrB) == 0; + } + + private static bool CharArrayContainsChar(char[] aArray, char aChar) + { + for (int i = 0; i < aArray.Length; i++) + { + if (aArray[i] == aChar) + { + return true; + } + } + return false; + } + + public static int IndexOf(this string aThis, string aValue) + { + return aThis.IndexOf(aValue, 0, aThis.Length, StringComparison.CurrentCulture); + } + + public static int IndexOfAny(this string aThis, char[] aSeparators, int aStartIndex, int aLength) + { + if (aSeparators == null) + { + throw new ArgumentNullException("aSeparators"); + } + + int xResult = -1; + for (int i = 0; i < aSeparators.Length; i++) + { + int xValue = IndexOf(aThis, aSeparators[i], aStartIndex, aLength); + if (xValue < xResult || xResult == -1) + { + xResult = xValue; + } + } + return xResult; + } + + public static string Insert(this string aThis, int aStartPos, string aValue) + { + return aThis.Substring(0, aStartPos) + aValue + aThis.Substring(aStartPos); + } + + public static int LastIndexOf(this string aThis, char aChar, int aStartIndex, int aCount) + { + return LastIndexOfAny(aThis, new[] { aChar }, aStartIndex, aCount); + } + + public static int LastIndexOfAny(this string aThis, char[] aChars, int aStartIndex, int aCount) + { + for (int i = 0; i < aCount; i++) + { + if (CharArrayContainsChar(aChars, aThis[aStartIndex - i])) + { + return aStartIndex - i; + } + } + return -1; + } + + public static int nativeCompareOrdinalEx(string aStrA, int aIndexA, string aStrB, int aIndexB, int aCount) + { + //Just a basic implementation + if (aStrA == aStrB) + { + return 0; + } + return -1; + } + + public static bool StartsWith(this string aThis, string aSubStr, bool aIgnoreCase, CultureInfo aCulture) + { + Char[] di = aThis.ToCharArray(); + Char[] ci = aSubStr.ToCharArray(); + if (aSubStr.Length > aThis.Length) + { + return false; + } + for (int i = 0; i < ci.Length; i++) + { + if (di[i] != ci[i]) + { + return false; + + } + } + return true; + } + + + + public static string Remove(this string aThis, int aStart, int aCount) + { + return aThis.Substring(0, aStart) + aThis.Substring(aStart + aCount, aThis.Length - (aStart + aCount)); + } + + public static string Replace(this string aThis, string oldValue, string newValue) + { + while (aThis.IndexOf(oldValue) != -1) + { + int xIndex = aThis.IndexOf(oldValue); + aThis = aThis.Remove(xIndex, oldValue.Length); + aThis = aThis.Insert(xIndex, newValue); + } + return aThis; + } + + public static string ToLower(this string aThis, CultureInfo aCulture) + { + return ChangeCasing(aThis, 65, 90, 32); + } + + public static string ToUpper(this string aThis, CultureInfo aCulture) + { + return ChangeCasing(aThis, 97, 122, -32); + } + + public static string ToUpper(this string aThis) + { + return ChangeCasing(aThis, 97, 122, -32); + } + + private static string ChangeCasing(string aValue, int lowerAscii, int upperAscii, int offset) + { + var xChars = new char[aValue.Length]; + + for (int i = 0; i < aValue.Length; i++) + { + int xAsciiCode = aValue[i]; + if ((xAsciiCode <= upperAscii) && (xAsciiCode >= lowerAscii)) + { + xChars[i] = (char)(xAsciiCode + offset); + } + else + { + xChars[i] = aValue[i]; + } + } + + return new string(xChars); + } + + public static string ToString(this string aThis) + { + return aThis; + } + + public static string FastAllocateString(int length) + { + return new string(new char[length]); + } + + public static string TrimStart(this char[] aThis, string aSubStr) + { + char[] ci = aThis; + char[] di = aSubStr.ToCharArray(); + + if (aThis[0] == (aSubStr.ToCharArray()[0])) + { + if (!(aThis.ToString() == aSubStr)) + { + char[] oi = new char[ci.Length - di.Length]; + for (int i = 0; i < ci.Length - di.Length; i++) + { + oi[i] = ci[i + di.Length]; + } + return oi.ToString(); + } + else + { + return ""; + } + } + else + { + throw new ArgumentNullException(); + } + + } + + + + + + + + + + + + + + + + + + + + + /*public int IndexOf(char c) + { + // TODO: We can't get 'this' + //string me = ToString(); + //for (int i = 0; i < me.Length; i++) + //{ + // if (me[i] == c) + // return i; + //} + return -1; + }*/ + } +} From 34720e6c7fb7ee09ec652c3d564d9f7a570e8eb4 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Thu, 14 Jan 2016 12:22:47 -0600 Subject: [PATCH 12/16] Removed some debug code in string plugs. Added a helper to grab debug sysmbols for debugging in bochs. --- Users/Sentinel/SentinelKernel/Kernel.cs | 59 +++---------------- .../SentinelKernel/SentinelKernelBoot.Cosmos | 8 +-- source/Cosmos.Core.Plugs/System/StringImpl.cs | 1 - source/Cosmos.Debug.Common/BochsSupport.cs | 49 +++++++++++++-- 4 files changed, 57 insertions(+), 60 deletions(-) diff --git a/Users/Sentinel/SentinelKernel/Kernel.cs b/Users/Sentinel/SentinelKernel/Kernel.cs index 1509473d7..b85cd9a42 100644 --- a/Users/Sentinel/SentinelKernel/Kernel.cs +++ b/Users/Sentinel/SentinelKernel/Kernel.cs @@ -1,69 +1,28 @@ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; -using System.IO; -using Cosmos.Common.Extensions; -using Cosmos.System.FileSystem.VFS; -using Cosmos.TestRunner; +using System.Linq; + using Sys = Cosmos.System; namespace SentinelKernel { - using Cosmos.System.FileSystem; - public class Kernel : Sys.Kernel { - private VFSBase myVFS; - protected override void BeforeRun() { - Console.WriteLine("Cosmos booted successfully."); - myVFS = new CosmosVFS(); - VFSManager.RegisterVFS(myVFS); } protected override void Run() { - Console.WriteLine("Run"); - try - { - var xRoot = Path.GetPathRoot(@"0:\test"); - bool xTest = Directory.Exists("0:\\test"); - Console.WriteLine("After test"); - Assert.IsTrue(xTest, "Folder does not exist!"); + var xList = new List { "A", "B" }; - Console.WriteLine("Folder exists!"); - xTest = Directory.Exists("0:\\test\\DirInTest"); - Assert.IsTrue(xTest, "Subfolder doesn't exist!"); - - xTest = File.Exists(@"0:\KudzU.txt"); - Assert.IsTrue(xTest, @"\Kudzu.txt not found!"); + string[] xArray = new[] { "A", "B" }; + // var xItem = xList.First(); // mkrefany - Console.WriteLine("Kudzu.txt found!"); - Console.Write("File contents of Kudzu.txt: "); - Console.WriteLine(File.ReadAllText(@"0:\Kudzu.txt")); -// File.WriteAllText(@"0:\Kudzu.txt", "Test FAT write."); -// Console.WriteLine(File.ReadAllText(@"0:\Kudzu.txt")); - - //xTest = File.Exists(@"0:\Test\DirInTest\Readme.txt"); - //if (!xTest) - //{ - // Console.WriteLine(@"\Test\DirInTest\Readme.txt not found!"); - // return; - //} - - //Console.WriteLine(@"Test\DirInTest\Readme.txt found!"); - - //Console.WriteLine(@"File contents of Test\DirInTest\Readme.txt: "); - //Console.WriteLine(File.ReadAllText(@"0:\Test\DirInTest\Readme.txt")); - Stop(); - } - catch (Exception e) - { - Console.WriteLine("Exception occurred:"); - Console.WriteLine(e.Message); - - } + string xItem = string.Join("|", xArray); + Console.WriteLine(xItem); } } } + diff --git a/Users/Sentinel/SentinelKernel/SentinelKernelBoot.Cosmos b/Users/Sentinel/SentinelKernel/SentinelKernelBoot.Cosmos index 0b286a3fc..85f3062d1 100644 --- a/Users/Sentinel/SentinelKernel/SentinelKernelBoot.Cosmos +++ b/Users/Sentinel/SentinelKernel/SentinelKernelBoot.Cosmos @@ -43,7 +43,7 @@ bin\Debug\ False False - True + False SentinelKernelBoot Use Bochs emulator to deploy and debug. ISO @@ -56,9 +56,9 @@ bin\Debug\ False false - True + False True - All + User All SentinelKernelBoot Connect to Intel Edison device to deploy and debug. @@ -102,7 +102,7 @@ True True True - All + User diff --git a/source/Cosmos.Core.Plugs/System/StringImpl.cs b/source/Cosmos.Core.Plugs/System/StringImpl.cs index 281e56dbd..e09081023 100644 --- a/source/Cosmos.Core.Plugs/System/StringImpl.cs +++ b/source/Cosmos.Core.Plugs/System/StringImpl.cs @@ -178,7 +178,6 @@ namespace Cosmos.Core.Plugs.System bool xParamNumberDone = true; for (int i = 0; i < xCharArray.Length; i++) { - mDebugger.Send(aFormat[i].ToString()); if (xFoundPlaceholder) { if (xCharArray[i] == '{') diff --git a/source/Cosmos.Debug.Common/BochsSupport.cs b/source/Cosmos.Debug.Common/BochsSupport.cs index e7a0b1e46..3b190027a 100644 --- a/source/Cosmos.Debug.Common/BochsSupport.cs +++ b/source/Cosmos.Debug.Common/BochsSupport.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using Microsoft.Win32; @@ -19,11 +20,11 @@ namespace Cosmos.Debug.Common /// Get a flag that tell whether Bochs is enabled on this system. public static bool BochsEnabled { - get - { - return (null != BochsExe); - //return false; - } + get + { + return (null != BochsExe); + //return false; + } } /// Get a descriptor for the Bochs emulator with debugger support program. The return value @@ -42,6 +43,44 @@ namespace Cosmos.Debug.Common private set; } + public static void ExtractBochsDebugSymbols(string xInputFile, string xOutputFile) + { + try + { + int i = 0; + using (var reader = new StreamReader(xInputFile)) + { + using (var writer = new StreamWriter(xOutputFile)) + { + Console.WriteLine($"Exporting symbols for Bochs: {xInputFile} -> {xOutputFile}"); + bool startSymbolTable = false; + while (!reader.EndOfStream) + { + string line = reader.ReadLine(); + if (startSymbolTable) + { + string[] items = line.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); + if (items.Length > 1) + { + writer.WriteLine($"{items.First()} {items.Last()}"); + i++; + } + } + else if (line.Trim().ToUpper().Contains("SYMBOL TABLE")) + { + startSymbolTable = true; + } + } + Console.WriteLine($"Exported {i} symbols."); + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + /// Retrieve installation path for Bochs and initialize the property. /// Search is performed using the registry and rely on the shell command defined for the /// BochsConfigFile. From 5c923da9920f1ec6eeb0d6c3bba259a803a03201 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Thu, 14 Jan 2016 12:27:20 -0600 Subject: [PATCH 13/16] Compiler error. --- Tests/Cosmos.Compiler.Tests.Exceptions/Kernel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Cosmos.Compiler.Tests.Exceptions/Kernel.cs b/Tests/Cosmos.Compiler.Tests.Exceptions/Kernel.cs index 80d2423da..9545575c5 100644 --- a/Tests/Cosmos.Compiler.Tests.Exceptions/Kernel.cs +++ b/Tests/Cosmos.Compiler.Tests.Exceptions/Kernel.cs @@ -104,7 +104,7 @@ namespace Cosmos.Compiler.Tests.Exceptions { TestReturnSimpleException(); } - catch (Exception ex) where (xShouldCatch == true) + catch (Exception ex) when (xShouldCatch == true) { Console.WriteLine("Caught filtered exception."); mDebugger.Send("EXCEPTION: " + ex.Message); @@ -136,7 +136,7 @@ namespace Cosmos.Compiler.Tests.Exceptions { TestReturnSimpleException(); } - catch (Exception ex) where (xShouldCatch == true) + catch (Exception ex) when (xShouldCatch == true) { Console.WriteLine("Caught filtered exception."); mDebugger.Send("EXCEPTION: " + ex.Message); From c469f1392086c9b6ed71f95c6dfa71b51e932d06 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Thu, 14 Jan 2016 13:45:31 -0600 Subject: [PATCH 14/16] Fix error from merge --- source/Cosmos.System.Plugs/System/IO/FileImpl.cs | 15 +++++++++------ source/Cosmos.System/FileSystem/FAT/FatStream.cs | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/Cosmos.System.Plugs/System/IO/FileImpl.cs b/source/Cosmos.System.Plugs/System/IO/FileImpl.cs index 54a48b673..b29b2a418 100644 --- a/source/Cosmos.System.Plugs/System/IO/FileImpl.cs +++ b/source/Cosmos.System.Plugs/System/IO/FileImpl.cs @@ -55,25 +55,26 @@ namespace Cosmos.System.Plugs.System.IO using (var xFS = new FileStream(aFile, FileMode.Append)) { Global.mFileSystemDebugger.SendInternal("Converting " + aText + " to UFT8"); - var xBuff = aText.GetUtf8Bytes(0, (uint)aText.Length); + var xBuff = aText.GetUtf8Bytes(0, (uint) aText.Length); Global.mFileSystemDebugger.SendInternal("Writing bytes"); xFS.Write(xBuff, 0, xBuff.Length); Global.mFileSystemDebugger.SendInternal("Bytes written"); + } } public static string[] ReadAllLines(string aFile) { String text = ReadAllText(aFile); - Global.mFileSystemDebugger.SendInternal(("Read content"); - Global.mFileSystemDebugger.SendInternal(("\n", text); + Global.mFileSystemDebugger.SendInternal("Read contents"); + Global.mFileSystemDebugger.SendInternal(text); String []result = text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - Global.mFileSystemDebugger.SendInternal(("content as array of lines:"); + Global.mFileSystemDebugger.SendInternal("content as array of lines:"); #if COSMOSDEBUG for (int i = 0; i < result.Length; i++) - Global.mFileSystemDebugger.SendInternal((result[i]); + Global.mFileSystemDebugger.SendInternal(result[i]); #endif return result; @@ -88,7 +89,9 @@ namespace Cosmos.System.Plugs.System.IO text = String.Concat(text, contents[i], Environment.NewLine); } - Global.mFileSystemDebugger.SendInternal("Writing contents\n" + text); + Global.mFileSystemDebugger.SendInternal("Writing contents"); + Global.mFileSystemDebugger.SendInternal(text); + WriteAllText(aFile, text); } diff --git a/source/Cosmos.System/FileSystem/FAT/FatStream.cs b/source/Cosmos.System/FileSystem/FAT/FatStream.cs index d3b61b7df..6b51c7659 100644 --- a/source/Cosmos.System/FileSystem/FAT/FatStream.cs +++ b/source/Cosmos.System/FileSystem/FAT/FatStream.cs @@ -30,13 +30,13 @@ namespace Cosmos.System.FileSystem.FAT public FatStream(FatDirectoryEntry aEntry) { - Global.mFileSystemDebugger.SendInternal("FatStream with entry " + aEntry); + Global.mFileSystemDebugger.SendInternal($"FatStream with entry {aEntry}"); mDirectoryEntry = aEntry; mFS = mDirectoryEntry.GetFileSystem(); mSize = mDirectoryEntry.mSize; - Global.mFileSystemDebugger.SendInternal("FatStream with mSize", mSize); + Global.mFileSystemDebugger.SendInternal("FatStream with mSize {mSize}"); Global.mFileSystemDebugger.SendInternal("Getting FatTable"); // We get always the FatTable if the file is empty too @@ -199,7 +199,7 @@ namespace Cosmos.System.FileSystem.FAT protected void Write(byte[] aBuffer, long aOffset, long aCount) { - Global.mFileSystemDebugger.SendInternal("Write() called aCount ", aCount, ", aOffset", aOffset); + Global.mFileSystemDebugger.SendInternal($"Write() called aCount = {aCount}, aOffset = {aOffset}"); if (aCount < 0) { throw new ArgumentOutOfRangeException("aCount"); From acaa60067dcf19e6056987aea6431e49e8712cb6 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Thu, 14 Jan 2016 14:35:20 -0600 Subject: [PATCH 15/16] Changes to a previous merge. --- source/Cosmos.Core.Plugs/System/StringImpl.cs | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/source/Cosmos.Core.Plugs/System/StringImpl.cs b/source/Cosmos.Core.Plugs/System/StringImpl.cs index 2f9aba3a1..24b8c5ef0 100644 --- a/source/Cosmos.Core.Plugs/System/StringImpl.cs +++ b/source/Cosmos.Core.Plugs/System/StringImpl.cs @@ -244,67 +244,6 @@ namespace Cosmos.Core.Plugs.System return true; } - //String concatenation plugs - public static string Concat(string str0) - { - return str0; - } - - public static string Concat(string str0, string str1) - { - return Concat(new[] { str0, str1 }); - } - - public static string Concat(string str0, string str1, string str2) - { - return Concat(new[] { str0, str1, str2 }); - } - - public static string Concat(string str0, string str1, string str2, string str3) - { - return Concat(new[] { str0, str1, str2, str3 }); - } - - //Object concatenation plugs - public static string Concat(object obj0) - { - return obj0?.ToString(); - } - - public static string Concat(object obj0, object obj1) - { - return Concat(obj0?.ToString(), obj1?.ToString()); - } - - public static string Concat(object obj0, object obj1, object obj2) - { - return Concat(obj0?.ToString(), obj1?.ToString(), obj2?.ToString()); - } - - public static string Concat(object obj0, object obj1, object obj2, object obj3) - { - return Concat(new[] { obj0?.ToString(), obj1?.ToString(), obj2?.ToString(), obj3?.ToString() }); - } - - //Array concatenation plugs - public static string Concat(params string[] values) - { - if (values != null) - { - int len = 0; - for (int i = 0; i < values.Length; i++) - { - string xValue = values[i]; - if (xValue != null) - { - len += values[i].Length; - } - } - return ConcatArray(values, len); - } - return string.Empty; - } - public static string PadHelper(string aThis, int totalWidth, char paddingChar, bool isRightPadded) { var cs = new char[totalWidth]; From 76591d2434e1b9d5f63293c74ba26101aa274d83 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Thu, 14 Jan 2016 14:43:02 -0600 Subject: [PATCH 16/16] Update readme.md --- readme.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index f494747e7..c705a6d45 100644 --- a/readme.md +++ b/readme.md @@ -5,18 +5,18 @@ Cosmos is an operating system "construction kit", built from the ground up around the IL2CPU compiler in C# and our home-brewed language called X#. -It's current stage is only usable for academic work. Some day Cosmos will be ready for production work, but to reach that stage we need more developers. Specifically, we need a few more low level developers to help the few core developers who are currently overwhelmed with work. +It's current stage is only usable for academic work. Some day Cosmos will be ready for production work, but to reach that stage we need more developers. Specifically, we need a few more low-level developers to help the few core developers who are currently overwhelmed with work. -Downloads anvailables : +Downloads: --------- -Cosmos is available in two types of "constructions kits": -* **User Kit** - The User Kit is used to develop your operating system in Visual Basic. +Cosmos is available in two flavors: +* **User Kit** - The User Kit is used to develop your operating system in Visual Studio. If you are new to Cosmos, you can learn [here](https://github.com/CosmosOS/Cosmos/wiki). [Latest Release anvailable](https://github.com/CosmosOS/Cosmos/releases/latest) -* **Devloppement Kit** - The Devloppement Kit is the full Cosmos source comming with build tools. - If you need to modify the Cosmos core functions or modify built-in drivers, boot, compiler, etc.. you will need to use Devloppement Kit. - [Tutorial for building the Devloppement Kit](https://github.com/CosmosOS/Cosmos/wiki/Devkit) - Building from the source is easy with our automated builder. +* **Development Kit** - The Development Kit is the full Cosmos source and build tools. + If you need to modify the Cosmos core functions or modify built-in drivers, boot, compiler, etc.. you will need to use Development Kit. + [Tutorial for building the Development Kit](https://github.com/CosmosOS/Cosmos/wiki/Devkit) - Building from the source is easy with our automated builder. Getting Started @@ -31,8 +31,8 @@ Getting Started Joining and helping Cosmos --------- -* [Gitter.im](https://gitter.im/CosmosOS/Cosmos) - The Live Chat: Click the green `Join Chat` badge at the top of this file. As with the IRC and CodePlex chatroom, please be patient if we don't respond immediately (no pinging). -* [Yahoo Group](https://tech.groups.yahoo.com/group/Cosmos-Dev) - Email Discussion List: To prevent spambots from spamming, we ask you introduce yourself to join. Please mention something specific to Cosmos. For example: "Hey, I want to join" and will won't get you in.... +* [Gitter.im](https://gitter.im/CosmosOS/Cosmos) - The Live Chat: Click the green `Join Chat` badge at the top of this file. As with the IRC and CodePlex chat, please be patient if we don't respond immediately (no pinging). +* [Yahoo Group](https://tech.groups.yahoo.com/group/Cosmos-Dev) - Email Discussion List: To prevent spam-bots from spamming, we ask you introduce yourself to join. Please mention something specific to Cosmos. For example: "Hey, I want to join" and will won't get you in.... * [Facebook](http://www.facebook.com/pages/Cosmos-Operating-System/10235842745) - Like us to see frequent updates of what is going on with Cosmos. * [YouTube Channel](https://www.youtube.com/channel/UCsSKtqjfpSR0B3Ov4cBIarQ/) - Follow to see useful videos and help you programming your operating system. * [Resources](https://github.com/CosmosOS/Cosmos/wiki/Resources) - More Cosmos related links. @@ -53,7 +53,7 @@ Articles and Resources Publicity --------- -* [Mary Jo Foley - Cosmos: An open-source .Net-based microkernel OS is born](http://www.zdnet.com/blog/microsoft/cosmos-an-open-source-net-based-microkernel-os-is-born/1162) +* [Mary Jo Foley - Cosmos: An open-source .Net-based micro-kernel OS is born](http://www.zdnet.com/blog/microsoft/cosmos-an-open-source-net-based-microkernel-os-is-born/1162) * [Scott Hanselman - Tiny Managed Operating System Edition](http://www.hanselman.com/blog/TheWeeklySourceCode15TinyManagedOperatingSystemEdition.aspx)