1
0
mirror of https://github.com/Halofreak1990/XFXFramework synced 2024-12-26 13:49:34 +01:00

Fixed some compiler errors

Added type info to some more classes
This commit is contained in:
Tom Lint 2013-07-22 01:38:59 +02:00
parent 287bb83aca
commit 535340971d
16 changed files with 94 additions and 73 deletions

View File

@ -30,8 +30,11 @@ namespace XFX
private: private:
static float distanceScale; static float distanceScale;
static float dopplerScale; static float dopplerScale;
TimeSpan duration;
bool isDisposed;
static float masterVolume; static float masterVolume;
static float speedOfSound; static float speedOfSound;
float volume;
void Dispose(bool disposing); void Dispose(bool disposing);

View File

@ -86,10 +86,7 @@ namespace System
T* destinationArray = new T[value]; T* destinationArray = new T[value];
if (_size > 0) if (_size > 0)
{ {
for(int i = 0; i < _size; i++) memcpy(destinationArray, _items, _size * sizeof(T));
{
destinationArray[i] = _items[i];
}
} }
delete[] _items; delete[] _items;
_items = destinationArray; _items = destinationArray;
@ -129,10 +126,7 @@ namespace System
{ {
_items = new T[obj._actualSize]; _items = new T[obj._actualSize];
for (int i = 0; i < obj._size; i++) memcpy(_items, obj._items, obj._size * sizeof(T));
{
_items[i] = obj._items[i];
}
} }
~List() ~List()
@ -140,7 +134,9 @@ namespace System
delete[] _items; 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) void Add(const T& item)
{ {
if (_size == _actualSize) if (_size == _actualSize)
@ -151,7 +147,9 @@ namespace System
_version++; _version++;
} }
//Removes all elements from the list /**
* Removes all elements from the list
*/
void Clear() void Clear()
{ {
if (_size > 0) if (_size > 0)
@ -181,15 +179,13 @@ namespace System
{ {
sassert(array != null, String::Format("array; %s", FrameworkResources::ArgumentNull_Generic)); sassert(array != null, String::Format("array; %s", FrameworkResources::ArgumentNull_Generic));
for (int i = 0, j = arrayIndex; i < _size; i++, j++) memcpy(array, &_items[arrayIndex], _size * sizeof(T))
{
array[j] = _items[i];
}
} }
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<>. // 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. // Inserts an element into the List<> at the specified index.
void Insert(const int index, const T& item) 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) if (_size == _actualSize)
{ {
@ -214,10 +210,7 @@ namespace System
} }
if (index < _size) if (index < _size)
{ {
for (int i = index, j = index + 1; i < _size - index; i++, j++) memcpy(&_items[index + 1], &_items[index], (_size - index) * sizeof(T));
{
_items[j] = _items[i];
}
} }
_items[index] = T(item); _items[index] = T(item);
_size++; _size++;
@ -239,10 +232,7 @@ namespace System
// Removes the element at the specified index of the List<>. // Removes the element at the specified index of the List<>.
void RemoveAt(const int index) void RemoveAt(const int index)
{ {
for (int i = index + 1, j = index; i < _size - index; i++, j++) memcpy(&_items[index], &_items[index + 1], (size - index) * sizeof(T)):
{
_items[j] = _items[i];
}
_size--; _size--;
_version++; _version++;
@ -262,15 +252,11 @@ namespace System
_size -= count; _size -= count;
if (index < _size) if (index < _size)
{ {
for (int i = index + count, j = index; i < _size - index; i++, j++) memcpy(&_items[index], &_items[index + count], (_size - index) * sizeof(T));
{
_items[j] = _items[i];
}
}
for (int i = _size; i < count; i++)
{
_items[i] = T();
} }
memset(&_items[_size], 0, count * sizeof(T));
_version++; _version++;
} }
} }
@ -341,8 +327,7 @@ namespace System
{ {
T* destinationArray = new T[_size]; T* destinationArray = new T[_size];
for (int i = 0; i < _size; i++) memcpy(destinationArray, _items, _size * sizeof(T));
destinationArray[i] = _items[i];
return destinationArray; return destinationArray;
} }
@ -373,10 +358,7 @@ namespace System
_size = other._size; _size = other._size;
_items = new T[other._actualSize]; _items = new T[other._actualSize];
for (int i = 0; i < other._size; i++) memcpy(_items, other._items, other._size * sizeof(T));
{
_items[i] = other._items[i];
}
_version = other._version; _version = other._version;
return *this; return *this;

View File

@ -8,6 +8,7 @@
#define _SYSTEM_WINDOWS_DEPENDENCYOBJECT_ #define _SYSTEM_WINDOWS_DEPENDENCYOBJECT_
#include <System/Collections/Generic/Dictionary.h> #include <System/Collections/Generic/Dictionary.h>
#include "DependencyProperty.h"
using namespace System::Collections::Generic; using namespace System::Collections::Generic;
@ -30,9 +31,7 @@ namespace System
template <typename T> template <typename T>
void ClearValue(DependencyProperty<T> p) void ClearValue(DependencyProperty<T> p)
{ {
Derived_from<T, Object *>(); if (dependencyProperties.ContainsKey(p.Name))
if (dependencyProperties.ContainsKey(p.Name)
{ {
// Because wrapper classes and other types may be passed in-place, // Because wrapper classes and other types may be passed in-place,
// we explicitly destroy them as to prevent memory leaks. // we explicitly destroy them as to prevent memory leaks.
@ -48,20 +47,16 @@ namespace System
template <typename T> template <typename T>
T GetValue(DependencyProperty<T> p) const T GetValue(DependencyProperty<T> p) const
{ {
Derived_from<T, Object *>();
return dependencyProperties[p.Name]; return dependencyProperties[p.Name];
} }
template <typename T> template <typename T>
void SetValue(DependencyProperty<T> p, T value) void SetValue(DependencyProperty<T> p, T value)
{ {
Derived_from<T, Object *>();
if (!dependencyProperties.ContainsKey(p.Name)) if (!dependencyProperties.ContainsKey(p.Name))
dependencyProperties.Add(p.Name, value); dependencyProperties.Add(p.Name, value);
else else
dependencyProperties[p] = value; dependencyProperties[p.Name] = value;
} }
}; };
} }

View File

@ -23,7 +23,7 @@ namespace System
class DependencyProperty class DependencyProperty
{ {
private: private:
static Dictionary<int, Dictionary<String&, Object *> > _registeredProperties; static Dictionary<Type, Dictionary<String, Object *> > _registeredProperties;
DependencyProperty(const String& propertyName, const Type& type, T defaultValue) DependencyProperty(const String& propertyName, const Type& type, T defaultValue)
: DefaultValue(defaultValue), Name(propertyName) : DefaultValue(defaultValue), Name(propertyName)
@ -70,17 +70,13 @@ namespace System
template <typename T> template <typename T>
DependencyProperty<T> DependencyProperty<T>::Register(const String& propertyName, const Type& type) DependencyProperty<T> DependencyProperty<T>::Register(const String& propertyName, const Type& type)
{ {
Derived_from<T, Object *>(): return Register(propertyName, type, new PropertyMetadata<T>(null));
return Register(propertyName, type, new PropertyMetaData<T>(null));
} }
template <typename T> template <typename T>
DependencyProperty<T> DependencyProperty<T>::Register(const String& propertyName, const Type& type, PropertyMetadata<T> const * propertyMetaData) DependencyProperty<T> DependencyProperty<T>::Register(const String& propertyName, const Type& type, PropertyMetadata<T> const * propertyMetaData)
{ {
Derived_from<T, Object *>(): _registeredProperties.Add(type, Dictionary<String, T>());
_registeredProperties.Add(type, Dictionary<String&, Object *>());
_registeredProperties[type].Add(propertyName, propertyMetaData->DefaultValue); _registeredProperties[type].Add(propertyName, propertyMetaData->DefaultValue);
return DependencyProperty<T>(propertyName, type, propertyMetaData->DefaultValue); return DependencyProperty<T>(propertyName, type, propertyMetaData->DefaultValue);

View File

@ -31,7 +31,7 @@ namespace System
public: public:
int Height; int Height;
static const DependencyProperty<Int32> HeightProperty; static const DependencyProperty<int> HeightProperty;
HorizontalAlignment_t HorizontalAlignment; HorizontalAlignment_t HorizontalAlignment;
static const DependencyProperty<HorizontalAlignment_t> HorizontalAlignmentProperty; static const DependencyProperty<HorizontalAlignment_t> HorizontalAlignmentProperty;
/** /**
@ -48,7 +48,7 @@ namespace System
static const DependencyProperty<VerticalAlignment_t> VerticalAlignmentProperty; static const DependencyProperty<VerticalAlignment_t> VerticalAlignmentProperty;
int getWidth() const; int getWidth() const;
void setWidth(const int value); void setWidth(const int value);
static const DependencyProperty<Int32> WidthProperty; static const DependencyProperty<int> WidthProperty;
virtual ~FrameworkElement(); virtual ~FrameworkElement();

View File

@ -49,7 +49,7 @@ namespace XFX
bool Equals(Object const * const obj) const; bool Equals(Object const * const obj) const;
bool Equals(const Vector2 other) const; bool Equals(const Vector2 other) const;
int GetHashCode() 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 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); static void Hermite(const Vector2& value1, const Vector2& tangent1, const Vector2& value2, const Vector2& tangent2, const float amount, out Vector2& result);
float Length() const; float Length() const;

View File

@ -28,17 +28,21 @@
#include <System/Windows/FrameworkElement.h> #include <System/Windows/FrameworkElement.h>
#include <System/Windows/Size.h> #include <System/Windows/Size.h>
#include <System/Type.h>
namespace System namespace System
{ {
namespace Windows namespace Windows
{ {
const DependencyProperty<Int32> FrameworkElement::HeightProperty = DependencyProperty<Int32>::Register("Height", FrameworkElement::GetType()); const DependencyProperty<int> FrameworkElement::HeightProperty = DependencyProperty<int>::Register("Height", FrameworkElement::GetType());
const DependencyProperty<Thickness> FrameworkElement::MarginProperty = DependencyProperty<Thickness>::Register("Margin", FrameworkElement::GetType()); const DependencyProperty<Thickness> FrameworkElement::MarginProperty = DependencyProperty<Thickness>::Register("Margin", FrameworkElement::GetType());
const DependencyProperty<VerticalAlignment_t> FrameworkElement::VerticalAlignmentProperty = DependencyProperty<VerticalAlignment_t>::Register("VerticalAlignment", FrameworkElement::GetType()); const DependencyProperty<VerticalAlignment_t> FrameworkElement::VerticalAlignmentProperty = DependencyProperty<VerticalAlignment_t>::Register("VerticalAlignment", FrameworkElement::GetType());
const DependencyProperty<Int32> FrameworkElement::WidthProperty = DependencyProperty<Int32>::Register("Width", FrameworkElement::GetType()); const DependencyProperty<int> FrameworkElement::WidthProperty = DependencyProperty<int>::Register("Width", FrameworkElement::GetType());
const Type FrameworkElementTypeInfo("FrameworkElement", "System::Windows::FrameworkElement", TypeCode::Object);
Thickness FrameworkElement::getMargin() const 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) Size FrameworkElement::MeasureOverride(const Size finalSize)

View File

@ -39,6 +39,7 @@ extern "C"
#include <Game.h> #include <Game.h>
#include <System/Collections/Generic/List.h> #include <System/Collections/Generic/List.h>
#include <Graphics/GraphicsDevice.h> #include <Graphics/GraphicsDevice.h>
#include <System/Type.h>
#include <sassert.h> #include <sassert.h>
@ -47,6 +48,8 @@ namespace XFX
const long long Game::DefaultTargetElapsedTicks = 10000000L / 60L; const long long Game::DefaultTargetElapsedTicks = 10000000L / 60L;
const TimeSpan Game::maximumElapsedTime = TimeSpan::FromMilliseconds(500.0); const TimeSpan Game::maximumElapsedTime = TimeSpan::FromMilliseconds(500.0);
const Type GameTypeInfo("Game", "XFX::Game", TypeCode::Object);
bool Game::IsActive() bool Game::IsActive()
{ {
return isActive; return isActive;
@ -145,7 +148,9 @@ namespace XFX
void Game::EndDraw() void Game::EndDraw()
{ {
if(graphicsManager) if(graphicsManager)
{
graphicsManager->EndDraw(); graphicsManager->EndDraw();
}
} }
void Game::EndRun() void Game::EndRun()
@ -158,8 +163,9 @@ namespace XFX
XReboot(); XReboot();
} }
int Game::GetType() const Type& Game::GetType()
{ {
return GameTypeInfo;
} }
void Game::Initialize() void Game::Initialize()

View File

@ -26,9 +26,13 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
#include <GameComponentCollection.h> #include <GameComponentCollection.h>
#include <System/Type.h>
namespace XFX namespace XFX
{ {
const Type GameComponentCollectionTypeInfo("GameComponentCollection", "XFX::GameComponentCollection", TypeCode::Object);
const Type GameComponentCollectionEventArgsTypeInfo("GameComponentCollectionEventArgs", "XFX::GameComponentCollectionEventArgs", TypeCode::Object);
GameComponentCollection::GameComponentCollection() GameComponentCollection::GameComponentCollection()
{ {
} }
@ -47,8 +51,9 @@ namespace XFX
return _components.Count(); return _components.Count();
} }
int GameComponentCollection::GetType() const Type& GameComponentCollection::GetType()
{ {
return GameComponentCollectionTypeInfo;
} }
void GameComponentCollection::InsertItem(int index, IGameComponent* item) void GameComponentCollection::InsertItem(int index, IGameComponent* item)
@ -82,8 +87,9 @@ namespace XFX
return _gameComponent; return _gameComponent;
} }
int GameComponentCollectionEventArgs::GetType() const Type& GameComponentCollectionEventArgs::GetType()
{ {
return GameComponentCollectionEventArgsTypeInfo;
} }
IGameComponent* GameComponentCollection::operator[](const int index) IGameComponent* GameComponentCollection::operator[](const int index)

View File

@ -26,9 +26,12 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
#include <GameTime.h> #include <GameTime.h>
#include <System/Type.h>
namespace XFX namespace XFX
{ {
const Type GameTimeTypeInfo("GameTime", "XFX::GameTime", TypeCode::Object);
bool GameTime::IsRunningSlowly() const bool GameTime::IsRunningSlowly() const
{ {
return _isRunningSlowly; return _isRunningSlowly;
@ -58,7 +61,8 @@ namespace XFX
{ {
} }
int GameTime::GetType() const Type& GameTime::GetType()
{ {
return GameTimeTypeInfo;
} }
} }

View File

@ -26,18 +26,22 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
#include <GamerServices/GamerServicesComponent.h> #include <GamerServices/GamerServicesComponent.h>
#include <System/Type.h>
namespace XFX namespace XFX
{ {
namespace GamerServices namespace GamerServices
{ {
const Type GamerServicesComponentTypeInfo("GamerServicesComponent", "XFX::GamerServicesComponent", TypeCode::Object);
GamerServicesComponent::GamerServicesComponent(Game * const game) GamerServicesComponent::GamerServicesComponent(Game * const game)
: GameComponent(game) : GameComponent(game)
{ {
} }
int GamerServicesComponent::GetType() const Type& GamerServicesComponent::GetType()
{ {
return GamerServicesComponentTypeInfo;
} }
void GamerServicesComponent::Initialize() void GamerServicesComponent::Initialize()

View File

@ -28,6 +28,7 @@
#include <GraphicsDeviceManager.h> #include <GraphicsDeviceManager.h>
#include <Game.h> #include <Game.h>
#include <System/Event.h> #include <System/Event.h>
#include <System/Type.h>
#include <sassert.h> #include <sassert.h>
@ -45,6 +46,8 @@ namespace XFX
SurfaceFormat_t GraphicsDeviceManager::ValidAdapterFormats[] = { SurfaceFormat::Bgr565 }; // TODO figure out which ones are really supported 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 SurfaceFormat_t GraphicsDeviceManager::ValidBackBufferFormats[] = { SurfaceFormat::Bgr565, SurfaceFormat::Bgra5551, SurfaceFormat::Color }; // idem
const Type GraphicsDeviceManagerTypeInfo("GraphicsDeviceManager", "XFX::GraphicsDeviceManager", TypeCode::Object);
GraphicsDeviceManager::GraphicsDeviceManager(Game * const game) GraphicsDeviceManager::GraphicsDeviceManager(Game * const game)
: _game(game), backBufferFormat(SurfaceFormat::Color), backBufferHeight(DefaultBackBufferHeight), backBufferWidth(DefaultBackBufferWidth) : _game(game), backBufferFormat(SurfaceFormat::Color), backBufferHeight(DefaultBackBufferHeight), backBufferWidth(DefaultBackBufferWidth)
{ {
@ -140,8 +143,9 @@ namespace XFX
graphicsDevice->Present(); graphicsDevice->Present();
} }
int GraphicsDeviceManager::GetType() const Type& GraphicsDeviceManager::GetType()
{ {
return GraphicsDeviceManagerTypeInfo;
} }
void GraphicsDeviceManager::OnDeviceCreated(Object* sender, EventArgs* args) void GraphicsDeviceManager::OnDeviceCreated(Object* sender, EventArgs* args)

View File

@ -28,7 +28,9 @@
#include <Audio/SoundEffect.h> #include <Audio/SoundEffect.h>
#include <Audio/SoundEffectInstance.h> #include <Audio/SoundEffectInstance.h>
#include <System/FrameworkResources.h>
#include <System/Single.h> #include <System/Single.h>
#include <System/Type.h>
#include <sassert.h> #include <sassert.h>
@ -38,6 +40,8 @@ namespace XFX
{ {
float SoundEffect::masterVolume = 1.0f; float SoundEffect::masterVolume = 1.0f;
const Type SoundEffectTypeInfo("SoundEffect", "XFX::Audio::SoundEffect", TypeCode::Object);
float SoundEffect::getDistanceScale() float SoundEffect::getDistanceScale()
{ {
return distanceScale; return distanceScale;
@ -59,7 +63,7 @@ namespace XFX
void SoundEffect::setDopplerScale(float value) void SoundEffect::setDopplerScale(float value)
{ {
sassert(value >= 0, ""); sassert(value >= 0, String::Format("value; %s", FrameworkResources::ArgumentOutOfRange_NeedNonNegNum));
dopplerScale = value; dopplerScale = value;
@ -113,6 +117,12 @@ namespace XFX
void SoundEffect::Dispose(bool disposing) void SoundEffect::Dispose(bool disposing)
{ {
if (!isDisposed)
{
if (disposing)
{
}
}
} }
SoundEffect* SoundEffect::FromStream(Stream * const stream) SoundEffect* SoundEffect::FromStream(Stream * const stream)
@ -120,8 +130,9 @@ namespace XFX
} }
int SoundEffect::GetType() const const Type& SoundEffect::GetType()
{ {
return SoundEffectTypeInfo;
} }
bool SoundEffect::Play() bool SoundEffect::Play()

View File

@ -27,6 +27,7 @@
#include <System/Byte.h> #include <System/Byte.h>
#include <System/String.h> #include <System/String.h>
#include <System/Type.h>
#include <stdlib.h> #include <stdlib.h>
namespace System namespace System
@ -34,6 +35,8 @@ namespace System
const byte Byte::MaxValue = 255; const byte Byte::MaxValue = 255;
const byte Byte::MinValue = 0; const byte Byte::MinValue = 0;
const Type ByteTypeInfo("Byte", "System::Byte", TypeCode::Byte);
Byte::Byte() Byte::Byte()
: value(0) : value(0)
{ {
@ -63,9 +66,9 @@ namespace System
return (value == other.value); return (value == other.value);
} }
int Byte::GetType() const Type& Byte::GetType()
{ {
return 6; return ByteTypeInfo;
} }
const String Byte::ToString() const const String Byte::ToString() const
@ -73,7 +76,7 @@ namespace System
return String::Format("%i", value); return String::Format("%i", value);
} }
const String& Byte::ToString(byte value) const String Byte::ToString(byte value)
{ {
return String::Format("%i", value); return String::Format("%i", value);
} }

View File

@ -33,6 +33,8 @@
#include <System/TimeZone.h> #include <System/TimeZone.h>
#include <System/Type.h> #include <System/Type.h>
#include <xboxkrnl/xboxkrnl.h>
#include <sassert.h> #include <sassert.h>
namespace System namespace System
@ -295,7 +297,7 @@ namespace System
return (int)encoded; return (int)encoded;
} }
Type DateTime::GetType() const Type& DateTime::GetType()
{ {
return DateTimeTypeInfo; return DateTimeTypeInfo;
} }

View File

@ -79,7 +79,7 @@ namespace System
return (int)value; return (int)value;
} }
Type Double::GetType() const Type& Double::GetType()
{ {
return DoubleTypeInfo; return DoubleTypeInfo;
} }