mirror of
https://github.com/Halofreak1990/XFXFramework
synced 2024-12-26 13:49:34 +01:00
Almost fixed the List template (moved all code into the header as per the template implementation requirements)
Added Exceptions to the System.Xml library Added missing DisplayModeCollection class Added Stack class (will be tested soon, and removed again if it doesn't work) * This revision's libXFX doesn't build. This is due to the List template not handling pointers to abstract classes the way I'd like it to do. Need to look into.
This commit is contained in:
parent
da68d727e4
commit
c4a46bae5d
10
XFX.sln
10
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
|
||||
|
@ -8,6 +8,9 @@
|
||||
#define _XFX_GAMECOMPONENTCOLLECTION_
|
||||
|
||||
#include "Interfaces.h"
|
||||
#include <System/Collections/Generic/List.h>
|
||||
|
||||
using namespace System::Collections::Generic;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
@ -17,6 +20,9 @@ namespace XFX
|
||||
/// </summary>
|
||||
class GameComponentCollection
|
||||
{
|
||||
private:
|
||||
List<IGameComponent*> _components;
|
||||
|
||||
protected:
|
||||
void ClearItems();
|
||||
void InsertItem(int index, IGameComponent* item);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define _XFX_GRAPHICS_TEXTURECOLLECTION_
|
||||
|
||||
#include <System/Collections/Generic/List.h>
|
||||
//#include "Texture.h"
|
||||
#include "Texture.h"
|
||||
|
||||
using namespace System::Collections::Generic;
|
||||
|
||||
@ -16,8 +16,6 @@ namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
class Texture;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of Texture objects.
|
||||
/// </summary>
|
||||
|
@ -27,6 +27,8 @@ namespace System
|
||||
static int IndexOf(T array[], T value, int startIndex, int count);
|
||||
template <class T>
|
||||
static int Length(T array[]);
|
||||
template <class T>
|
||||
static void Reverse(T array[], int index, int length);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#ifndef _SYSTEM_COLLECTIONS_GENERIC_LIST_
|
||||
#define _SYSTEM_COLLECTIONS_GENERIC_LIST_
|
||||
|
||||
#include <System/Array.h>
|
||||
#include <System/Exception.h>
|
||||
#include <System/Types.h>
|
||||
#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<T>* comparer);
|
||||
int BinarySearch(int index, int count, T item, IComparer<T>* 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<T>* comparer)
|
||||
{
|
||||
return BinarySearch(0, Count(), item, comparer);
|
||||
}
|
||||
int BinarySearch(int index, int count, T item, IComparer<T>* 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<T>(_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];
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and
|
||||
/// manipulate lists.
|
||||
/// </summary>
|
||||
template <class T>
|
||||
class List<T *> : public IList<T *>
|
||||
{
|
||||
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<T>* comparer)
|
||||
{
|
||||
return BinarySearch(0, Count(), item, comparer);
|
||||
}
|
||||
int BinarySearch(int index, int count, T* item, IComparer<T>* 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<T>(_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];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,21 @@
|
||||
#ifndef _SYSTEM_COLLECTIONS_INTERFACES_
|
||||
#define _SYSTEM_COLLECTIONS_INTERFACES_
|
||||
|
||||
#include <System/Object.h>
|
||||
#include <System/Types.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Collections
|
||||
{
|
||||
interface ICollection
|
||||
{
|
||||
public:
|
||||
virtual void CopyTo(Object** array, int index)=0;
|
||||
|
||||
virtual int Count()=0;
|
||||
virtual bool IsSynchronized()=0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
40
include/System/Collections/Stack.h
Normal file
40
include/System/Collections/Stack.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef _SYSTEM_COLLECTIONS_STACK_
|
||||
#define _SYSTEM_COLLECTIONS_STACK_
|
||||
|
||||
#include <System/Object.h>
|
||||
#include <System/Collections/Interfaces.h>
|
||||
|
||||
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_
|
50
include/System/Xml/Interfaces.h
Normal file
50
include/System/Xml/Interfaces.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef _SYSTEM_XML_INTERFACES_
|
||||
#define _SYSTEM_XML_INTERFACES_
|
||||
|
||||
#include <System/Collections/Generic/Interfaces.h>
|
||||
#include <System/Types.h>
|
||||
#include <System/Xml/Enums.h>
|
||||
|
||||
using namespace System::Collections::Generic;
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Xml
|
||||
{
|
||||
class XmlNode;
|
||||
|
||||
/// <summary>
|
||||
/// Enables a class to return an System::Xml::XmlNode from the current context or position.
|
||||
/// </summary>
|
||||
interface IHasXmlNode
|
||||
{
|
||||
public:
|
||||
virtual XmlNode GetNode()=0;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Provides an interface to enable a class to return line and position information.
|
||||
/// </summary>
|
||||
interface IXmlLineInfo
|
||||
{
|
||||
public:
|
||||
virtual bool HasLineInfo()=0;
|
||||
|
||||
virtual int LineNumber();
|
||||
virtual int LinePosition();
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Provides read-only access to a set of prefix and namespace mappings.
|
||||
/// </summary>
|
||||
interface IXmlNamespaceResolver
|
||||
{
|
||||
public:
|
||||
virtual IDictionary<char*, char*>* GetNamespacesInScope(XmlNamespaceScope_t scope)=0;
|
||||
virtual char* LookupNamespace(char* prefix)=0;
|
||||
virtual char* LookupPrefix(char* namespaceName)=0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_SYSTEM_XML_INTERFACES_
|
@ -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 <System/Exception.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Xml
|
||||
@ -7,13 +18,15 @@ namespace System
|
||||
/// <summary>
|
||||
/// Provides the exception thrown when an error occurs while processing an XPath expression.
|
||||
/// </summary>
|
||||
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_
|
||||
|
@ -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 <System/Exception.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
@ -12,19 +18,19 @@ namespace System
|
||||
/// <summary>
|
||||
/// The exception that is thrown when an error occurs while processing an XSLT transformation.
|
||||
/// </summary>
|
||||
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_
|
||||
|
52
src/libSystem.Xml/XPathException.cpp
Normal file
52
src/libSystem.Xml/XPathException.cpp
Normal file
@ -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 <System/Xml/XPath/XPathException.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Xml
|
||||
{
|
||||
namespace XPath
|
||||
{
|
||||
XPathException::XPathException()
|
||||
: SystemException()
|
||||
{
|
||||
}
|
||||
|
||||
XPathException::XPathException(char* message)
|
||||
: SystemException(message)
|
||||
{
|
||||
}
|
||||
|
||||
XPathException::XPathException(char* message, Exception* innerException)
|
||||
: SystemException(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
64
src/libSystem.Xml/XsltException.cpp
Normal file
64
src/libSystem.Xml/XsltException.cpp
Normal file
@ -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 <System/Xml/Xsl/XsltException.h>
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="0"
|
||||
CharacterSet="1"
|
||||
BuildLogFile="BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCNMakeTool"
|
||||
@ -116,10 +117,18 @@
|
||||
<Filter
|
||||
Name="XPath"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\XPathException.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Xsl"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\XsltException.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
@ -131,6 +140,10 @@
|
||||
RelativePath="..\..\include\System\Xml\Enums.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\System\Xml\Interfaces.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Schema"
|
||||
>
|
||||
|
@ -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
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="0"
|
||||
CharacterSet="2"
|
||||
BuildLogFile="BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCNMakeTool"
|
||||
@ -115,28 +116,12 @@
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<Filter
|
||||
Name="IO"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Threading"
|
||||
>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<Filter
|
||||
Name="Threading"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Text"
|
||||
>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
|
@ -1,3 +1,30 @@
|
||||
// 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 <GameComponentCollection.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
66
src/libXFX/DisplayModeCollection.cpp
Normal file
66
src/libXFX/DisplayModeCollection.cpp
Normal file
@ -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 <Graphics/DisplayModeCollection.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -199,6 +199,10 @@
|
||||
RelativePath=".\DisplayMode.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DisplayModeCollection.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GraphicsAdapter.cpp"
|
||||
>
|
||||
|
@ -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 =
|
||||
|
@ -111,4 +111,27 @@ namespace System
|
||||
{
|
||||
return (sizeof(array)/sizeof(T));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
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--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
90
src/libmscorlib/Stack.cpp
Normal file
90
src/libmscorlib/Stack.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#include <System/Array.h>
|
||||
#include <System/Collections/Stack.h>
|
||||
#include <System/Exception.h>
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -130,10 +130,6 @@
|
||||
RelativePath=".\Exception.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\libSystem\List.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Math.cpp"
|
||||
>
|
||||
@ -255,6 +251,10 @@
|
||||
RelativePath=".\HashHelpers.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Stack.cpp"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Generic"
|
||||
>
|
||||
@ -274,19 +274,6 @@
|
||||
RelativePath=".\KeyValuePair.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\List.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\$(InputName)1.obj"
|
||||
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
@ -478,6 +465,10 @@
|
||||
RelativePath="..\..\include\System\Collections\Interfaces.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\System\Collections\Stack.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Generic"
|
||||
>
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user