diff --git a/include/Audio/SoundEffect.h b/include/Audio/SoundEffect.h index a72d580..870f9b4 100644 --- a/include/Audio/SoundEffect.h +++ b/include/Audio/SoundEffect.h @@ -30,8 +30,11 @@ namespace XFX private: static float distanceScale; static float dopplerScale; + TimeSpan duration; + bool isDisposed; static float masterVolume; static float speedOfSound; + float volume; void Dispose(bool disposing); diff --git a/include/System/Collections/Generic/List.h b/include/System/Collections/Generic/List.h index 72eac18..07cdac5 100644 --- a/include/System/Collections/Generic/List.h +++ b/include/System/Collections/Generic/List.h @@ -86,10 +86,7 @@ namespace System T* destinationArray = new T[value]; if (_size > 0) { - for(int i = 0; i < _size; i++) - { - destinationArray[i] = _items[i]; - } + memcpy(destinationArray, _items, _size * sizeof(T)); } delete[] _items; _items = destinationArray; @@ -129,10 +126,7 @@ namespace System { _items = new T[obj._actualSize]; - for (int i = 0; i < obj._size; i++) - { - _items[i] = obj._items[i]; - } + memcpy(_items, obj._items, obj._size * sizeof(T)); } ~List() @@ -140,7 +134,9 @@ namespace System delete[] _items; } - // Adds an element to the end of the list + /** + * Adds an element to the end of the list + */ void Add(const T& item) { if (_size == _actualSize) @@ -151,7 +147,9 @@ namespace System _version++; } - //Removes all elements from the list + /** + * Removes all elements from the list + */ void Clear() { if (_size > 0) @@ -181,15 +179,13 @@ namespace System { sassert(array != null, String::Format("array; %s", FrameworkResources::ArgumentNull_Generic)); - for (int i = 0, j = arrayIndex; i < _size; i++, j++) - { - array[j] = _items[i]; - } + memcpy(array, &_items[arrayIndex], _size * sizeof(T)) } - int GetType() const + static const Type& GetType() { - //! TODO: implement + static Type ListTypeInfo("List", "System::Collections::Generic::List", TypeCode::Object, true); + return ListTypeInfo; } // Searches for the specified object and returns the zero-based index of the first occurrence within the entire List<>. @@ -206,7 +202,7 @@ namespace System // Inserts an element into the List<> at the specified index. void Insert(const int index, const T& item) { - sassert(index < _size, "Index must be within the bounds of the List."); + sassert(index >= 0 && index < _size, "Index must be within the bounds of the List."); if (_size == _actualSize) { @@ -214,10 +210,7 @@ namespace System } if (index < _size) { - for (int i = index, j = index + 1; i < _size - index; i++, j++) - { - _items[j] = _items[i]; - } + memcpy(&_items[index + 1], &_items[index], (_size - index) * sizeof(T)); } _items[index] = T(item); _size++; @@ -239,10 +232,7 @@ namespace System // Removes the element at the specified index of the List<>. void RemoveAt(const int index) { - for (int i = index + 1, j = index; i < _size - index; i++, j++) - { - _items[j] = _items[i]; - } + memcpy(&_items[index], &_items[index + 1], (size - index) * sizeof(T)): _size--; _version++; @@ -262,15 +252,11 @@ namespace System _size -= count; if (index < _size) { - for (int i = index + count, j = index; i < _size - index; i++, j++) - { - _items[j] = _items[i]; - } - } - for (int i = _size; i < count; i++) - { - _items[i] = T(); + memcpy(&_items[index], &_items[index + count], (_size - index) * sizeof(T)); } + + memset(&_items[_size], 0, count * sizeof(T)); + _version++; } } @@ -341,8 +327,7 @@ namespace System { T* destinationArray = new T[_size]; - for (int i = 0; i < _size; i++) - destinationArray[i] = _items[i]; + memcpy(destinationArray, _items, _size * sizeof(T)); return destinationArray; } @@ -373,10 +358,7 @@ namespace System _size = other._size; _items = new T[other._actualSize]; - for (int i = 0; i < other._size; i++) - { - _items[i] = other._items[i]; - } + memcpy(_items, other._items, other._size * sizeof(T)); _version = other._version; return *this; diff --git a/include/System/Windows/DependencyObject.h b/include/System/Windows/DependencyObject.h index c1ba97a..46f017d 100644 --- a/include/System/Windows/DependencyObject.h +++ b/include/System/Windows/DependencyObject.h @@ -8,6 +8,7 @@ #define _SYSTEM_WINDOWS_DEPENDENCYOBJECT_ #include +#include "DependencyProperty.h" using namespace System::Collections::Generic; @@ -30,9 +31,7 @@ namespace System template void ClearValue(DependencyProperty p) { - Derived_from(); - - if (dependencyProperties.ContainsKey(p.Name) + if (dependencyProperties.ContainsKey(p.Name)) { // Because wrapper classes and other types may be passed in-place, // we explicitly destroy them as to prevent memory leaks. @@ -48,20 +47,16 @@ namespace System template T GetValue(DependencyProperty p) const { - Derived_from(); - return dependencyProperties[p.Name]; } template void SetValue(DependencyProperty p, T value) { - Derived_from(); - if (!dependencyProperties.ContainsKey(p.Name)) dependencyProperties.Add(p.Name, value); else - dependencyProperties[p] = value; + dependencyProperties[p.Name] = value; } }; } diff --git a/include/System/Windows/DependencyProperty.h b/include/System/Windows/DependencyProperty.h index 03275de..2585b50 100644 --- a/include/System/Windows/DependencyProperty.h +++ b/include/System/Windows/DependencyProperty.h @@ -23,7 +23,7 @@ namespace System class DependencyProperty { private: - static Dictionary > _registeredProperties; + static Dictionary > _registeredProperties; DependencyProperty(const String& propertyName, const Type& type, T defaultValue) : DefaultValue(defaultValue), Name(propertyName) @@ -70,17 +70,13 @@ namespace System template DependencyProperty DependencyProperty::Register(const String& propertyName, const Type& type) { - Derived_from(): - - return Register(propertyName, type, new PropertyMetaData(null)); + return Register(propertyName, type, new PropertyMetadata(null)); } template DependencyProperty DependencyProperty::Register(const String& propertyName, const Type& type, PropertyMetadata const * propertyMetaData) { - Derived_from(): - - _registeredProperties.Add(type, Dictionary()); + _registeredProperties.Add(type, Dictionary()); _registeredProperties[type].Add(propertyName, propertyMetaData->DefaultValue); return DependencyProperty(propertyName, type, propertyMetaData->DefaultValue); diff --git a/include/System/Windows/FrameworkElement.h b/include/System/Windows/FrameworkElement.h index 2870bf2..65fe40b 100644 --- a/include/System/Windows/FrameworkElement.h +++ b/include/System/Windows/FrameworkElement.h @@ -31,7 +31,7 @@ namespace System public: int Height; - static const DependencyProperty HeightProperty; + static const DependencyProperty HeightProperty; HorizontalAlignment_t HorizontalAlignment; static const DependencyProperty HorizontalAlignmentProperty; /** @@ -48,7 +48,7 @@ namespace System static const DependencyProperty VerticalAlignmentProperty; int getWidth() const; void setWidth(const int value); - static const DependencyProperty WidthProperty; + static const DependencyProperty WidthProperty; virtual ~FrameworkElement(); diff --git a/include/Vector2.h b/include/Vector2.h index 399388a..5ecfd3f 100644 --- a/include/Vector2.h +++ b/include/Vector2.h @@ -49,7 +49,7 @@ namespace XFX bool Equals(Object const * const obj) const; bool Equals(const Vector2 other) const; int GetHashCode() const; - int GetType() const; + static int GetType(); static Vector2 Hermite(const Vector2 value1, const Vector2 tangent1, const Vector2 value2, const Vector2 tangent2, const float amount); static void Hermite(const Vector2& value1, const Vector2& tangent1, const Vector2& value2, const Vector2& tangent2, const float amount, out Vector2& result); float Length() const; diff --git a/src/libSystem.Windows/FrameworkElement.cpp b/src/libSystem.Windows/FrameworkElement.cpp index cd6bc6a..e8afb46 100644 --- a/src/libSystem.Windows/FrameworkElement.cpp +++ b/src/libSystem.Windows/FrameworkElement.cpp @@ -28,17 +28,21 @@ #include #include +#include + namespace System { namespace Windows { - const DependencyProperty FrameworkElement::HeightProperty = DependencyProperty::Register("Height", FrameworkElement::GetType()); + const DependencyProperty FrameworkElement::HeightProperty = DependencyProperty::Register("Height", FrameworkElement::GetType()); const DependencyProperty FrameworkElement::MarginProperty = DependencyProperty::Register("Margin", FrameworkElement::GetType()); const DependencyProperty FrameworkElement::VerticalAlignmentProperty = DependencyProperty::Register("VerticalAlignment", FrameworkElement::GetType()); - const DependencyProperty FrameworkElement::WidthProperty = DependencyProperty::Register("Width", FrameworkElement::GetType()); + const DependencyProperty FrameworkElement::WidthProperty = DependencyProperty::Register("Width", FrameworkElement::GetType()); + + const Type FrameworkElementTypeInfo("FrameworkElement", "System::Windows::FrameworkElement", TypeCode::Object); Thickness FrameworkElement::getMargin() const { @@ -78,8 +82,9 @@ namespace System { } - int FrameworkElement::GetType() + const Type& FrameworkElement::GetType() { + return FrameworkElementTypeInfo; } Size FrameworkElement::MeasureOverride(const Size finalSize) diff --git a/src/libXFX.Game/Game.cpp b/src/libXFX.Game/Game.cpp index a06fa4b..de9073f 100644 --- a/src/libXFX.Game/Game.cpp +++ b/src/libXFX.Game/Game.cpp @@ -39,6 +39,7 @@ extern "C" #include #include #include +#include #include @@ -47,6 +48,8 @@ namespace XFX const long long Game::DefaultTargetElapsedTicks = 10000000L / 60L; const TimeSpan Game::maximumElapsedTime = TimeSpan::FromMilliseconds(500.0); + const Type GameTypeInfo("Game", "XFX::Game", TypeCode::Object); + bool Game::IsActive() { return isActive; @@ -145,7 +148,9 @@ namespace XFX void Game::EndDraw() { if(graphicsManager) + { graphicsManager->EndDraw(); + } } void Game::EndRun() @@ -158,8 +163,9 @@ namespace XFX XReboot(); } - int Game::GetType() + const Type& Game::GetType() { + return GameTypeInfo; } void Game::Initialize() diff --git a/src/libXFX.Game/GameComponentCollection.cpp b/src/libXFX.Game/GameComponentCollection.cpp index 23a6555..aade814 100644 --- a/src/libXFX.Game/GameComponentCollection.cpp +++ b/src/libXFX.Game/GameComponentCollection.cpp @@ -26,9 +26,13 @@ // POSSIBILITY OF SUCH DAMAGE. #include +#include namespace XFX { + const Type GameComponentCollectionTypeInfo("GameComponentCollection", "XFX::GameComponentCollection", TypeCode::Object); + const Type GameComponentCollectionEventArgsTypeInfo("GameComponentCollectionEventArgs", "XFX::GameComponentCollectionEventArgs", TypeCode::Object); + GameComponentCollection::GameComponentCollection() { } @@ -47,8 +51,9 @@ namespace XFX return _components.Count(); } - int GameComponentCollection::GetType() + const Type& GameComponentCollection::GetType() { + return GameComponentCollectionTypeInfo; } void GameComponentCollection::InsertItem(int index, IGameComponent* item) @@ -82,8 +87,9 @@ namespace XFX return _gameComponent; } - int GameComponentCollectionEventArgs::GetType() + const Type& GameComponentCollectionEventArgs::GetType() { + return GameComponentCollectionEventArgsTypeInfo; } IGameComponent* GameComponentCollection::operator[](const int index) diff --git a/src/libXFX.Game/GameTime.cpp b/src/libXFX.Game/GameTime.cpp index 1ecf424..995a16b 100644 --- a/src/libXFX.Game/GameTime.cpp +++ b/src/libXFX.Game/GameTime.cpp @@ -26,9 +26,12 @@ // POSSIBILITY OF SUCH DAMAGE. #include +#include namespace XFX { + const Type GameTimeTypeInfo("GameTime", "XFX::GameTime", TypeCode::Object); + bool GameTime::IsRunningSlowly() const { return _isRunningSlowly; @@ -58,7 +61,8 @@ namespace XFX { } - int GameTime::GetType() + const Type& GameTime::GetType() { + return GameTimeTypeInfo; } } diff --git a/src/libXFX.Game/GamerServicesComponent.cpp b/src/libXFX.Game/GamerServicesComponent.cpp index 6be60f1..51d30cd 100644 --- a/src/libXFX.Game/GamerServicesComponent.cpp +++ b/src/libXFX.Game/GamerServicesComponent.cpp @@ -26,18 +26,22 @@ // POSSIBILITY OF SUCH DAMAGE. #include +#include namespace XFX { namespace GamerServices { + const Type GamerServicesComponentTypeInfo("GamerServicesComponent", "XFX::GamerServicesComponent", TypeCode::Object); + GamerServicesComponent::GamerServicesComponent(Game * const game) : GameComponent(game) { } - int GamerServicesComponent::GetType() + const Type& GamerServicesComponent::GetType() { + return GamerServicesComponentTypeInfo; } void GamerServicesComponent::Initialize() diff --git a/src/libXFX.Game/GraphicsDeviceManager.cpp b/src/libXFX.Game/GraphicsDeviceManager.cpp index 9adb0d4..36fbd38 100644 --- a/src/libXFX.Game/GraphicsDeviceManager.cpp +++ b/src/libXFX.Game/GraphicsDeviceManager.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -45,6 +46,8 @@ namespace XFX SurfaceFormat_t GraphicsDeviceManager::ValidAdapterFormats[] = { SurfaceFormat::Bgr565 }; // TODO figure out which ones are really supported SurfaceFormat_t GraphicsDeviceManager::ValidBackBufferFormats[] = { SurfaceFormat::Bgr565, SurfaceFormat::Bgra5551, SurfaceFormat::Color }; // idem + const Type GraphicsDeviceManagerTypeInfo("GraphicsDeviceManager", "XFX::GraphicsDeviceManager", TypeCode::Object); + GraphicsDeviceManager::GraphicsDeviceManager(Game * const game) : _game(game), backBufferFormat(SurfaceFormat::Color), backBufferHeight(DefaultBackBufferHeight), backBufferWidth(DefaultBackBufferWidth) { @@ -140,8 +143,9 @@ namespace XFX graphicsDevice->Present(); } - int GraphicsDeviceManager::GetType() + const Type& GraphicsDeviceManager::GetType() { + return GraphicsDeviceManagerTypeInfo; } void GraphicsDeviceManager::OnDeviceCreated(Object* sender, EventArgs* args) diff --git a/src/libXFX/SoundEffect.cpp b/src/libXFX/SoundEffect.cpp index 42f07a0..b72c726 100644 --- a/src/libXFX/SoundEffect.cpp +++ b/src/libXFX/SoundEffect.cpp @@ -28,7 +28,9 @@ #include