diff --git a/XFX.sln b/XFX.sln index 7ce8601..1907f30 100644 --- a/XFX.sln +++ b/XFX.sln @@ -41,6 +41,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSystem.Xml", "src\libSys {B7A9CAB6-B307-4A2E-A01F-970F9A8B044E} = {B7A9CAB6-B307-4A2E-A01F-970F9A8B044E} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSystem", "src\libSystem\libSystem.vcproj", "{D9A1DA2E-E4C3-430F-998E-51C2B3F92C24}" + ProjectSection(WebsiteProperties) = preProject + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.Debug = "False" + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -67,6 +73,10 @@ Global {4797B7BB-E670-4486-8053-CD969AD3CED5}.Debug|Win32.Build.0 = Debug|Win32 {4797B7BB-E670-4486-8053-CD969AD3CED5}.Release|Win32.ActiveCfg = Release|Win32 {4797B7BB-E670-4486-8053-CD969AD3CED5}.Release|Win32.Build.0 = Release|Win32 + {D9A1DA2E-E4C3-430F-998E-51C2B3F92C24}.Debug|Win32.ActiveCfg = Debug|Win32 + {D9A1DA2E-E4C3-430F-998E-51C2B3F92C24}.Debug|Win32.Build.0 = Debug|Win32 + {D9A1DA2E-E4C3-430F-998E-51C2B3F92C24}.Release|Win32.ActiveCfg = Release|Win32 + {D9A1DA2E-E4C3-430F-998E-51C2B3F92C24}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/include/GameComponentCollection.h b/include/GameComponentCollection.h index 83f0474..98b3e95 100644 --- a/include/GameComponentCollection.h +++ b/include/GameComponentCollection.h @@ -8,6 +8,9 @@ #define _XFX_GAMECOMPONENTCOLLECTION_ #include "Interfaces.h" +#include + +using namespace System::Collections::Generic; namespace XFX { @@ -17,6 +20,9 @@ namespace XFX /// class GameComponentCollection { + private: + List _components; + protected: void ClearItems(); void InsertItem(int index, IGameComponent* item); diff --git a/include/Graphics/TextureCollection.h b/include/Graphics/TextureCollection.h index 84af5f3..795f266 100644 --- a/include/Graphics/TextureCollection.h +++ b/include/Graphics/TextureCollection.h @@ -8,7 +8,7 @@ #define _XFX_GRAPHICS_TEXTURECOLLECTION_ #include -//#include "Texture.h" +#include "Texture.h" using namespace System::Collections::Generic; @@ -16,8 +16,6 @@ namespace XFX { namespace Graphics { - class Texture; - /// /// Represents a collection of Texture objects. /// diff --git a/include/System/Array.h b/include/System/Array.h index 88dce70..00f8b2e 100644 --- a/include/System/Array.h +++ b/include/System/Array.h @@ -27,6 +27,8 @@ namespace System static int IndexOf(T array[], T value, int startIndex, int count); template static int Length(T array[]); + template + static void Reverse(T array[], int index, int length); }; } diff --git a/include/System/Collections/Generic/List.h b/include/System/Collections/Generic/List.h index 1582356..8aea697 100644 --- a/include/System/Collections/Generic/List.h +++ b/include/System/Collections/Generic/List.h @@ -7,6 +7,8 @@ #ifndef _SYSTEM_COLLECTIONS_GENERIC_LIST_ #define _SYSTEM_COLLECTIONS_GENERIC_LIST_ +#include +#include #include #include "Interfaces.h" @@ -25,45 +27,517 @@ namespace System { private: static const int _defaultCapacity = 4; - static T _emptyArray[]; - T _items[]; + static T* _emptyArray; + T* _items; int _size; int _version; - void EnsureCapacity(int min); + void EnsureCapacity(int min) + { + if(Array::Length(_items) < min) + { + int num = (Array::Length(_items) == 0) ? _defaultCapacity : (Array::Length(_items) * 2); + if(num < min) + { + num = min; + } + Capacity(num); + } + } public: - int Count(); - int Capacity(); // get - void Capacity(int newCap); // set + int Count() // Gets the number of elements actually contained in the List<>. + { + return _size; + } - List(); - List(int capacity); - ~List(); + int Capacity() // Gets the total number of elements the internal data structure can hold without resizing. + { + return Array::Length(_items); + } - void Add(T item); //Adds an element to the end of the list - int BinarySearch(T item); - int BinarySearch(T item, IComparer* comparer); - int BinarySearch(int index, int count, T item, IComparer* comparer); - void Clear(); //Removes all elements from the list - bool Contains(T item); - void CopyTo(T array[], int arrayIndex); - int First(); //Goes to the first element in the list - int First(out T item); //Goes to the first element returns the value - int IndexOf(T item); - void Insert(int index, T item); - int Next(); //Goes to next element in the list - int Next(out T item); //Goes to next element and writes the element in parameter - int Change(const T newElem); //changes the current element - bool Remove(T item); //Removes current element - void RemoveAt(int index); //Removes the element at the specified index - void RemoveRange(int index, int count); //Removes all elements in the specified range - void Reverse(); //Reverses the items in the list - void Reverse(int index, int count); //Reverses the items in the specified range - T *ToArray(); - void TrimExcess(); + void Capacity(int value) // Sets the total number of elements the internal data structure can hold without resizing. + { + if (value != Array::Length(_items)) + { + if (value < _size) + { + throw ArgumentOutOfRangeException("value", "New capacity too small."); + } + if (value > 0) + { + T* destinationArray = new T[value]; + if (_size > 0) + { + Array::Copy(_items, 0, destinationArray, 0, _size); + } + delete[] _items; + _items = destinationArray; + } + else + { + delete[] _items; + _items = new T[0]; + } + } + } - T operator[](int index); + List() // Initializes a new instance of the List<> class that is empty and has the default initial capacity. + { + _emptyArray = new T[0]; + _items = _emptyArray; + } + + List(int capacity) // Initializes a new instance of the List<> class that is empty and has the specified initial capacity. + { + if(capacity < 0) + throw ArgumentOutOfRangeException("capacity", "Non-negative number required."); + + _items = new T[capacity]; + } + + ~List() + { + if(_items) + delete[] _items; + } + + void Add(T item) //Adds an element to the end of the list + { + if(_size == Array::Length(_items)) + { + EnsureCapacity(_size + 1); + } + _items[_size++] = item; + _version++; + } + + int BinarySearch(T item) + { + return BinarySearch(0, Count(), item, null); + } + int BinarySearch(T item, IComparer* comparer) + { + return BinarySearch(0, Count(), item, comparer); + } + int BinarySearch(int index, int count, T item, IComparer* comparer) + { + if ((index < 0) || (count < 0)) + { + throw ArgumentOutOfRangeException((index < 0) ? "index" : "count", "Non-negative number required."); + } + if ((_size - index) < count) + { + throw ArgumentException("Invalid Offset."); + } + return Array::BinarySearch(_items, index, count, item, comparer); + } + + void Clear() //Removes all elements from the list + { + if(_size) + { + delete[] _items; + _items = _emptyArray; + _size = 0; + } + _version++; + } + + bool Contains(T item) // Determines whether an element is in the List<>. + { + for (int i = 0; i < _size; i++) + { + if (_items[i] == item) + { + return true; + } + } + return false; + } + + void CopyTo(T array[]) // Copies the entire List<> to a compatible one-dimensional array, starting at the beginning of the target array. + { + Array::Copy(_items, 0, array, 0, _size); + } + + void CopyTo(T array[], int arrayIndex) // Copies the entire List<> to a compatible one-dimensional array, starting at the specified index of the target array. + { + Array::Copy(_items, 0, array, arrayIndex, _size); + } + + int IndexOf(T item) // Searches for the specified object and returns the zero-based index of the first occurrence within the entire List<>. + { + return Array::IndexOf(_items, item, 0, _size); + } + + void Insert(int index, T item) // Inserts an element into the List<> at the specified index. + { + if (index > _size) + { + throw ArgumentOutOfRangeException("index", "Index must be within the bounds of the List."); + } + if (_size == Array::Length(_items)) + { + EnsureCapacity(_size + 1); + } + if (index < _size) + { + Array::Copy(_items, index, _items, index + 1, _size - index); + } + _items[index] = item; + _size++; + _version++; + } + + bool Remove(T item) // Removes the first occurrence of a specific object from the List<>. + { + int index = IndexOf(item); + if (index >= 0) + { + RemoveAt(index); + return true; + } + return false; + } + + void RemoveAt(int index) // Removes the element at the specified index of the List<>. + { + if(index < 0 || index >= _size) + throw ArgumentOutOfRangeException("index", "Index was out of range. Must be non-negative and less than the size of the collection."); + + _size--; + if(index < _size) + { + Array::Copy(_items, index +1, _items, index, _size - index); + } + _items[_size] = new T(); + _version++; + } + + void RemoveRange(int index, int count) // Removes a range of elements from the List<>. + { + if ((index < 0) || (count < 0)) + { + throw ArgumentOutOfRangeException((index < 0) ? "index" : "count", "Non-negative number required."); + } + if ((_size - index) < count) + { + throw ArgumentException("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."); + } + if (count > 0) + { + _size -= count; + if (index < _size) + { + Array::Copy(_items, index + count, _items, index, _size - index); + } + Array::Clear(_items, _size, count); + _version++; + } + } + + void Reverse() + { + Reverse(0, Count()); + } + + void Reverse(int index, int count) + { + if ((index < 0) || (count < 0)) + { + throw ArgumentOutOfRangeException((index < 0) ? "index" : "count", "Non-negative number required."); + } + if ((_size - index) < count) + { + throw ArgumentException("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."); + } + Array::Reverse(_items, index, count); + _version++; + } + + T *ToArray() + { + return _items; + } + + void TrimExcess() + { + int num = (int)(Array::Length(_items) * 0.9); + if(_size < num) + { + Capacity(_size); + } + } + + T operator[](int index) + { + if(index >= _size) + throw ArgumentOutOfRangeException("index"); + + return _items[index]; + } + }; + + /// + /// Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and + /// manipulate lists. + /// + template + class List : public IList + { + private: + static const int _defaultCapacity = 4; + static T** _emptyArray; + T** _items; + int _size; + int _version; + + void EnsureCapacity(int min) + { + if(Array::Length(_items) < min) + { + int num = (Array::Length(_items) == 0) ? _defaultCapacity : (Array::Length(_items) * 2); + if(num < min) + { + num = min; + } + Capacity(num); + } + } + + public: + int Count() // Gets the number of elements actually contained in the List<>. + { + return _size; + } + + int Capacity() // Gets the total number of elements the internal data structure can hold without resizing. + { + return Array::Length(_items); + } + + void Capacity(int value) // Sets the total number of elements the internal data structure can hold without resizing. + { + if (value != Array::Length(_items)) + { + if (value < _size) + { + throw ArgumentOutOfRangeException("value", "New capacity too small."); + } + if (value > 0) + { + T** destinationArray = new T*[value]; + if (_size > 0) + { + Array::Copy(_items, 0, destinationArray, 0, _size); + } + delete[] _items; + _items = destinationArray; + } + else + { + delete[] _items; + _items = new T*[0]; + } + } + } + + List() // Initializes a new instance of the List<> class that is empty and has the default initial capacity. + { + _emptyArray = new T*[0]; + _items = _emptyArray; + } + + List(int capacity) // Initializes a new instance of the List<> class that is empty and has the specified initial capacity. + { + if(capacity < 0) + throw ArgumentOutOfRangeException("capacity", "Non-negative number required."); + + _items = new T*[capacity]; + } + + ~List() + { + if(_items) + delete[] _items; + } + + void Add(T* item) //Adds an element to the end of the list + { + if(_size == Array::Length(_items)) + { + EnsureCapacity(_size + 1); + } + _items[_size++] = item; + _version++; + } + + int BinarySearch(T* item) + { + return BinarySearch(0, Count(), item, null); + } + int BinarySearch(T* item, IComparer* comparer) + { + return BinarySearch(0, Count(), item, comparer); + } + int BinarySearch(int index, int count, T* item, IComparer* comparer) + { + if ((index < 0) || (count < 0)) + { + throw ArgumentOutOfRangeException((index < 0) ? "index" : "count", "Non-negative number required."); + } + if ((_size - index) < count) + { + throw ArgumentException("Invalid Offset."); + } + return Array::BinarySearch(_items, index, count, item, comparer); + } + + void Clear() //Removes all elements from the list + { + if(_size) + { + delete[] _items; + _items = _emptyArray; + _size = 0; + } + _version++; + } + + bool Contains(T* item) // Determines whether an element is in the List<>. + { + for (int i = 0; i < _size; i++) + { + if (_items[i] == item) + { + return true; + } + } + return false; + } + + void CopyTo(T* array[]) // Copies the entire List<> to a compatible one-dimensional array, starting at the beginning of the target array. + { + Array::Copy(_items, 0, array, 0, _size); + } + + void CopyTo(T* array[], int arrayIndex) // Copies the entire List<> to a compatible one-dimensional array, starting at the specified index of the target array. + { + Array::Copy(_items, 0, array, arrayIndex, _size); + } + + int IndexOf(T* item) // Searches for the specified object and returns the zero-based index of the first occurrence within the entire List<>. + { + return Array::IndexOf(_items, item, 0, _size); + } + + void Insert(int index, T* item) // Inserts an element into the List<> at the specified index. + { + if (index > _size) + { + throw ArgumentOutOfRangeException("index", "Index must be within the bounds of the List."); + } + if (_size == Array::Length(_items)) + { + EnsureCapacity(_size + 1); + } + if (index < _size) + { + Array::Copy(_items, index, _items, index + 1, _size - index); + } + _items[index] = item; + _size++; + _version++; + } + + bool Remove(T* item) // Removes the first occurrence of a specific object from the List<>. + { + int index = IndexOf(item); + if (index >= 0) + { + RemoveAt(index); + return true; + } + return false; + } + + void RemoveAt(int index) // Removes the element at the specified index of the List<>. + { + if(index < 0 || index >= _size) + throw ArgumentOutOfRangeException("index", "Index was out of range. Must be non-negative and less than the size of the collection."); + + _size--; + if(index < _size) + { + Array::Copy(_items, index +1, _items, index, _size - index); + } + _items[_size] = new T(); + _version++; + } + + void RemoveRange(int index, int count) // Removes a range of elements from the List<>. + { + if ((index < 0) || (count < 0)) + { + throw ArgumentOutOfRangeException((index < 0) ? "index" : "count", "Non-negative number required."); + } + if ((_size - index) < count) + { + throw ArgumentException("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."); + } + if (count > 0) + { + _size -= count; + if (index < _size) + { + Array::Copy(_items, index + count, _items, index, _size - index); + } + Array::Clear(_items, _size, count); + _version++; + } + } + + void Reverse() + { + Reverse(0, Count()); + } + + void Reverse(int index, int count) + { + if ((index < 0) || (count < 0)) + { + throw ArgumentOutOfRangeException((index < 0) ? "index" : "count", "Non-negative number required."); + } + if ((_size - index) < count) + { + throw ArgumentException("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."); + } + Array::Reverse(_items, index, count); + _version++; + } + + T** ToArray() + { + return _items; + } + + void TrimExcess() + { + int num = (int)(Array::Length(_items) * 0.9); + if(_size < num) + { + Capacity(_size); + } + } + + T* operator[](int index) + { + if(index >= _size) + throw ArgumentOutOfRangeException("index"); + + return _items[index]; + } }; } } diff --git a/include/System/Collections/Interfaces.h b/include/System/Collections/Interfaces.h index 0490fe3..95c2f8a 100644 --- a/include/System/Collections/Interfaces.h +++ b/include/System/Collections/Interfaces.h @@ -1,11 +1,21 @@ #ifndef _SYSTEM_COLLECTIONS_INTERFACES_ #define _SYSTEM_COLLECTIONS_INTERFACES_ +#include +#include + namespace System { namespace Collections { + interface ICollection + { + public: + virtual void CopyTo(Object** array, int index)=0; + virtual int Count()=0; + virtual bool IsSynchronized()=0; + }; } } diff --git a/include/System/Collections/Stack.h b/include/System/Collections/Stack.h new file mode 100644 index 0000000..70aeed4 --- /dev/null +++ b/include/System/Collections/Stack.h @@ -0,0 +1,40 @@ +#ifndef _SYSTEM_COLLECTIONS_STACK_ +#define _SYSTEM_COLLECTIONS_STACK_ + +#include +#include + +namespace System +{ + namespace Collections + { + class Stack : public ICollection, virtual Object + { + private: + Object** _bottom; + Object** _top; + static const int _defaultCapacity; + int _size; + int _version; + + public: + int Count(); + bool IsSynchronized(); + + Stack(); + Stack(ICollection* col); + Stack(int initialCapacity); + virtual ~Stack(); + + virtual void Clear(); + virtual bool Contains(Object* obj); + virtual void CopyTo(Object* array[], int index); + virtual Object* Peek(); + virtual Object* Pop(); + virtual void Push(Object* obj); + virtual Object** ToArray(); + }; + } +} + +#endif //_SYSTEM_COLLECTIONS_STACK_ diff --git a/include/System/Xml/Interfaces.h b/include/System/Xml/Interfaces.h new file mode 100644 index 0000000..f0e2c12 --- /dev/null +++ b/include/System/Xml/Interfaces.h @@ -0,0 +1,50 @@ +#ifndef _SYSTEM_XML_INTERFACES_ +#define _SYSTEM_XML_INTERFACES_ + +#include +#include +#include + +using namespace System::Collections::Generic; + +namespace System +{ + namespace Xml + { + class XmlNode; + + /// + /// Enables a class to return an System::Xml::XmlNode from the current context or position. + /// + interface IHasXmlNode + { + public: + virtual XmlNode GetNode()=0; + }; + + /// + /// Provides an interface to enable a class to return line and position information. + /// + interface IXmlLineInfo + { + public: + virtual bool HasLineInfo()=0; + + virtual int LineNumber(); + virtual int LinePosition(); + }; + + /// + /// Provides read-only access to a set of prefix and namespace mappings. + /// + interface IXmlNamespaceResolver + { + public: + virtual IDictionary* GetNamespacesInScope(XmlNamespaceScope_t scope)=0; + virtual char* LookupNamespace(char* prefix)=0; + virtual char* LookupPrefix(char* namespaceName)=0; + }; + } +} + +#endif //_SYSTEM_XML_INTERFACES_ diff --git a/include/System/Xml/XPath/XPathException.h b/include/System/Xml/XPath/XPathException.h index f86fdca..875c8cc 100644 --- a/include/System/Xml/XPath/XPathException.h +++ b/include/System/Xml/XPath/XPathException.h @@ -1,3 +1,14 @@ +/******************************************************** + * XPathException.h * + * * + * XFX XPathException definition file * + * Copyright © XFX Team. All Rights Reserved * + ********************************************************/ +#ifndef _SYSTEM_XML_XPATH_XPATHEXCEPTION_ +#define _SYSTEM_XML_XPATH_XPATHEXCEPTION_ + +#include + namespace System { namespace Xml @@ -7,13 +18,15 @@ namespace System /// /// Provides the exception thrown when an error occurs while processing an XPath expression. /// - class XPathException : SystemException + class XPathException : public SystemException { public: XPathException(); - XPathException(const char *message); - XPathException(const char *message, Exception &innerException); + XPathException(char *message); + XPathException(char *message, Exception* innerException); }; } } } + +#endif //_SYSTEM_XML_XPATH_XPATHEXCEPTION_ diff --git a/include/System/Xml/Xsl/XsltException.h b/include/System/Xml/Xsl/XsltException.h index ff34cef..cf50d3f 100644 --- a/include/System/Xml/Xsl/XsltException.h +++ b/include/System/Xml/Xsl/XsltException.h @@ -1,7 +1,13 @@ -#ifndef _XSLTEXCEPTION_ -#define _XSLTEXCEPTION_ +/******************************************************** + * XsltException.h * + * * + * XFX XsltException definition file * + * Copyright © XFX Team. All Rights Reserved * + ********************************************************/ +#ifndef _SYSTEM_XML_XSLTEXCEPTION_ +#define _SYSTEM_XML_XSLTEXCEPTION_ -#include "../../SystemException.h" +#include namespace System { @@ -12,19 +18,19 @@ namespace System /// /// The exception that is thrown when an error occurs while processing an XSLT transformation. /// - class XsltException : SystemException + class XsltException : public SystemException { public: - int LineNumber(); - int LinePosition(); - const char* SourceUri(); + int LineNumber(); // Gets the line number indicating where the error occurred in the style sheet. + int LinePosition(); // Gets the line position indicating where the error occurred in the style sheet. + const char* SourceUri(); // Gets the location path of the style sheet. XsltException(); - XsltException(const char *message); - XsltException(const char *message, Exception &innerException); + XsltException(char *message); + XsltException(char *message, Exception* innerException); }; } } } -#endif //_XSLTEXCEPTION_ +#endif //_SYSTEM_XML_XSLTEXCEPTION_ diff --git a/src/libSystem.Xml/XPathException.cpp b/src/libSystem.Xml/XPathException.cpp new file mode 100644 index 0000000..5b4cef1 --- /dev/null +++ b/src/libSystem.Xml/XPathException.cpp @@ -0,0 +1,52 @@ +// Copyright (C) 2010-2012, XFX Team +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the copyright holder nor the names of any +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include + +namespace System +{ + namespace Xml + { + namespace XPath + { + XPathException::XPathException() + : SystemException() + { + } + + XPathException::XPathException(char* message) + : SystemException(message) + { + } + + XPathException::XPathException(char* message, Exception* innerException) + : SystemException(message, innerException) + { + } + } + } +} diff --git a/src/libSystem.Xml/XsltException.cpp b/src/libSystem.Xml/XsltException.cpp new file mode 100644 index 0000000..546463f --- /dev/null +++ b/src/libSystem.Xml/XsltException.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2010-2012, XFX Team +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the copyright holder nor the names of any +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include + +namespace System +{ + namespace Xml + { + namespace Xsl + { + XsltException::XsltException() + : SystemException() + { + } + + XsltException::XsltException(char* message) + : SystemException(message) + { + } + + XsltException::XsltException(char* message, Exception* innerException) + : SystemException(message, innerException) + { + } + + int XsltException::LineNumber() + { + } + + int XsltException::LinePosition() + { + } + + const char* XsltException::SourceUri() + { + } + } + } +} diff --git a/src/libSystem.Xml/libSystem.Xml.vcproj b/src/libSystem.Xml/libSystem.Xml.vcproj index 2ca7811..b5d36a4 100644 --- a/src/libSystem.Xml/libSystem.Xml.vcproj +++ b/src/libSystem.Xml/libSystem.Xml.vcproj @@ -21,6 +21,7 @@ IntermediateDirectory="$(ConfigurationName)" ConfigurationType="0" CharacterSet="1" + BuildLogFile="BuildLog.htm" > + + + + + + diff --git a/src/libSystem.Xml/makefile b/src/libSystem.Xml/makefile index f63c826..102cdf3 100644 --- a/src/libSystem.Xml/makefile +++ b/src/libSystem.Xml/makefile @@ -27,7 +27,7 @@ LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP) LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib LD_LIBS = $(LD_DIRS) -lmscorlib -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lstdc++ -lgcc -OBJS = +OBJS = XPathException.o XsltException.o all: libSystem.Xml.a diff --git a/src/libSystem/libSystem.vcproj b/src/libSystem/libSystem.vcproj index a53fe01..5952c2e 100644 --- a/src/libSystem/libSystem.vcproj +++ b/src/libSystem/libSystem.vcproj @@ -20,6 +20,7 @@ IntermediateDirectory="$(ConfigurationName)" ConfigurationType="0" CharacterSet="2" + BuildLogFile="BuildLog.htm" > - - - - - - - - namespace XFX @@ -8,17 +35,21 @@ namespace XFX void GameComponentCollection::ClearItems() { + _components.Clear(); } void GameComponentCollection::InsertItem(int index, IGameComponent* item) { + _components.Insert(index, item); } void GameComponentCollection::RemoveItem(int index) { + _components.RemoveAt(index); } void GameComponentCollection::SetItem(int index, IGameComponent* item) { + _components[index] = item; } } diff --git a/src/libXFX/DisplayModeCollection.cpp b/src/libXFX/DisplayModeCollection.cpp new file mode 100644 index 0000000..8e278e8 --- /dev/null +++ b/src/libXFX/DisplayModeCollection.cpp @@ -0,0 +1,66 @@ +// Copyright (C) 2010-2012, XFX Team +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the copyright holder nor the names of any +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include + +namespace XFX +{ + namespace Graphics + { + DisplayModeCollection::DisplayModeCollection() + { + } + + bool DisplayModeCollection::operator!=(const DisplayModeCollection other) + { + int num; + if ((adapterOrdinal == other.adapterOrdinal) && (currentFormat == other.currentFormat)) + { + num = 1; + } + else + { + num = 0; + } + return (bool)((byte)(((byte) num) == 0)); + } + + bool DisplayModeCollection::operator==(const DisplayModeCollection other) + { + int num; + if ((adapterOrdinal == other.adapterOrdinal) && (currentFormat == other.currentFormat)) + { + num = 1; + } + else + { + num = 0; + } + return (bool)((byte) num); + } + } +} diff --git a/src/libXFX/libXFX.vcproj b/src/libXFX/libXFX.vcproj index 3929308..01b402f 100644 --- a/src/libXFX/libXFX.vcproj +++ b/src/libXFX/libXFX.vcproj @@ -199,6 +199,10 @@ RelativePath=".\DisplayMode.cpp" > + + diff --git a/src/libXFX/makefile b/src/libXFX/makefile index ab9ae9d..d33cb2d 100644 --- a/src/libXFX/makefile +++ b/src/libXFX/makefile @@ -35,7 +35,7 @@ OBJS = BoundingBox.o BoundingFrustrum.o BoundingSphere.o MathHelper.o Matrix.o P AUDIO_OBJS = CONTENT_OBJS = ContentManager.o ContentReader.o GAMERSERVICES_OBJS = Guide.o -GRAPHICS_OBJS = Color.o DisplayMode.o GraphicsAdapter.o GraphicsDevice.o pbKit.o Sprite.o SpriteBatch.o SpriteFont.o Texture.o Texture2D.o TextureCollection.o TextureCreationParameters.o VertexElement.o VertexPositionColor.o VertexPositionNormalTexture.o VertexPositionTexture.o Viewport.o +GRAPHICS_OBJS = Color.o DisplayMode.o DisplayModeCollection.o GraphicsAdapter.o GraphicsDevice.o pbKit.o Sprite.o SpriteBatch.o SpriteFont.o Texture.o Texture2D.o TextureCollection.o TextureCreationParameters.o VertexElement.o VertexPositionColor.o VertexPositionNormalTexture.o VertexPositionTexture.o Viewport.o INPUT_OBJS = GamePad.o Keyboard.o Mouse.o MEDIA_OBJS = VideoPlayer.o NET_OBJS = diff --git a/src/libmscorlib/Array.cpp b/src/libmscorlib/Array.cpp index 38f6ba5..48a253c 100644 --- a/src/libmscorlib/Array.cpp +++ b/src/libmscorlib/Array.cpp @@ -111,4 +111,27 @@ namespace System { return (sizeof(array)/sizeof(T)); } + + template + void Array::Reverse(T array[], int index, int length) + { + if (array == null) + { + throw ArgumentNullException("array"); + } + if ((Length(array) - index) < length) + { + throw ArgumentException("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."); + } + int num = index; + int num2 = (index + length) - 1; + while (num < num2) + { + T obj2 = array[num]; + array[num] = array[num2]; + array[num2] = obj2; + num++; + num2--; + } + } } diff --git a/src/libmscorlib/Stack.cpp b/src/libmscorlib/Stack.cpp new file mode 100644 index 0000000..caa1e5e --- /dev/null +++ b/src/libmscorlib/Stack.cpp @@ -0,0 +1,90 @@ +#include +#include +#include + +namespace System +{ + namespace Collections + { + const int Stack::_defaultCapacity = 10; + + int Stack::Count() + { + return _size; + } + + bool Stack::IsSynchronized() + { + return false; + } + + Stack::Stack() + { + _bottom = new Object*[_defaultCapacity]; + _size = 0; + _version = 0; + } + + Stack::Stack(ICollection* col) + { + Stack((!col) ? 0x20 : col->Count()); + + if (!col) + throw ArgumentNullException("col"); + + for (int i = 0; i < col->Count(); i++) + { + // TODO: Push all values in the ICollection into this Stack. + } + } + + Stack::Stack(int initialCapacity) + { + if (initialCapacity < 0) + throw ArgumentOutOfRangeException("initialCapacity", "Non-negative number required"); + + if (initialCapacity < _defaultCapacity) + initialCapacity = _defaultCapacity; + + _bottom = new Object*[initialCapacity]; + _size = 0; + _version = 0; + } + + Stack::~Stack() + { + delete[] _bottom; + } + + void Stack::Clear() + { + Array::Clear(_bottom, 0, _size); + _size = 0; + _version++; + } + + Object* Stack::Peek() + { + return *_top; + } + + Object* Stack::Pop() + { + _top--; + _version++; + return *_top; + } + + void Stack::Push(Object* obj) + { + *_top = obj; + _top++; + _version++; + } + + Object** Stack::ToArray() + { + //TODO: Copy the contents of _bottom into a fresh array and return it + } + } +} diff --git a/src/libmscorlib/libmscorlib.vcproj b/src/libmscorlib/libmscorlib.vcproj index 52843c4..37f65c8 100644 --- a/src/libmscorlib/libmscorlib.vcproj +++ b/src/libmscorlib/libmscorlib.vcproj @@ -130,10 +130,6 @@ RelativePath=".\Exception.cpp" > - - @@ -255,6 +251,10 @@ RelativePath=".\HashHelpers.cpp" > + + @@ -274,19 +274,6 @@ RelativePath=".\KeyValuePair.cpp" > - - - - - + + diff --git a/src/libmscorlib/makefile b/src/libmscorlib/makefile index 7eccc04..4e7bba6 100644 --- a/src/libmscorlib/makefile +++ b/src/libmscorlib/makefile @@ -26,7 +26,7 @@ LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP) LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib LD_LIBS = $(LD_DIRS) -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lstdc++ -lgcc -OBJS = Array.o BinaryReader.o BitConverter.o Buffer.o Calendar.o Comparer.o DateTime.o Decoder.o Dictionary.o Directory.o Encoder.o Environment.o Exception.o File.o FileStream.o HashHelpers.o KeyNotFoundException.o KeyValuePair.o List.o Math.o MemoryStream.o Path.o Stream.o StreamAsyncResult.o StreamReader.o StreamWriter.o Thread.o TimeSpan.o Version.o +OBJS = Array.o BinaryReader.o BitConverter.o Buffer.o Calendar.o Comparer.o DateTime.o Decoder.o Dictionary.o Directory.o Encoder.o Environment.o Exception.o File.o FileStream.o HashHelpers.o KeyNotFoundException.o KeyValuePair.o Math.o MemoryStream.o Path.o Stack.o Stream.o StreamAsyncResult.o StreamReader.o StreamWriter.o Thread.o TimeSpan.o Version.o all: libmscorlib.a