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:
parent
287bb83aca
commit
535340971d
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define _SYSTEM_WINDOWS_DEPENDENCYOBJECT_
|
||||
|
||||
#include <System/Collections/Generic/Dictionary.h>
|
||||
#include "DependencyProperty.h"
|
||||
|
||||
using namespace System::Collections::Generic;
|
||||
|
||||
@ -30,9 +31,7 @@ namespace System
|
||||
template <typename T>
|
||||
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,
|
||||
// we explicitly destroy them as to prevent memory leaks.
|
||||
@ -48,20 +47,16 @@ namespace System
|
||||
template <typename T>
|
||||
T GetValue(DependencyProperty<T> p) const
|
||||
{
|
||||
Derived_from<T, Object *>();
|
||||
|
||||
return dependencyProperties[p.Name];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SetValue(DependencyProperty<T> p, T value)
|
||||
{
|
||||
Derived_from<T, Object *>();
|
||||
|
||||
if (!dependencyProperties.ContainsKey(p.Name))
|
||||
dependencyProperties.Add(p.Name, value);
|
||||
else
|
||||
dependencyProperties[p] = value;
|
||||
dependencyProperties[p.Name] = value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace System
|
||||
class DependencyProperty
|
||||
{
|
||||
private:
|
||||
static Dictionary<int, Dictionary<String&, Object *> > _registeredProperties;
|
||||
static Dictionary<Type, Dictionary<String, Object *> > _registeredProperties;
|
||||
|
||||
DependencyProperty(const String& propertyName, const Type& type, T defaultValue)
|
||||
: DefaultValue(defaultValue), Name(propertyName)
|
||||
@ -70,17 +70,13 @@ namespace System
|
||||
template <typename T>
|
||||
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>
|
||||
DependencyProperty<T> DependencyProperty<T>::Register(const String& propertyName, const Type& type, PropertyMetadata<T> const * propertyMetaData)
|
||||
{
|
||||
Derived_from<T, Object *>():
|
||||
|
||||
_registeredProperties.Add(type, Dictionary<String&, Object *>());
|
||||
_registeredProperties.Add(type, Dictionary<String, T>());
|
||||
_registeredProperties[type].Add(propertyName, propertyMetaData->DefaultValue);
|
||||
|
||||
return DependencyProperty<T>(propertyName, type, propertyMetaData->DefaultValue);
|
||||
|
@ -31,7 +31,7 @@ namespace System
|
||||
|
||||
public:
|
||||
int Height;
|
||||
static const DependencyProperty<Int32> HeightProperty;
|
||||
static const DependencyProperty<int> HeightProperty;
|
||||
HorizontalAlignment_t HorizontalAlignment;
|
||||
static const DependencyProperty<HorizontalAlignment_t> HorizontalAlignmentProperty;
|
||||
/**
|
||||
@ -48,7 +48,7 @@ namespace System
|
||||
static const DependencyProperty<VerticalAlignment_t> VerticalAlignmentProperty;
|
||||
int getWidth() const;
|
||||
void setWidth(const int value);
|
||||
static const DependencyProperty<Int32> WidthProperty;
|
||||
static const DependencyProperty<int> WidthProperty;
|
||||
|
||||
virtual ~FrameworkElement();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -28,17 +28,21 @@
|
||||
#include <System/Windows/FrameworkElement.h>
|
||||
#include <System/Windows/Size.h>
|
||||
|
||||
#include <System/Type.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
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<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
|
||||
{
|
||||
@ -78,8 +82,9 @@ namespace System
|
||||
{
|
||||
}
|
||||
|
||||
int FrameworkElement::GetType()
|
||||
const Type& FrameworkElement::GetType()
|
||||
{
|
||||
return FrameworkElementTypeInfo;
|
||||
}
|
||||
|
||||
Size FrameworkElement::MeasureOverride(const Size finalSize)
|
||||
|
@ -39,6 +39,7 @@ extern "C"
|
||||
#include <Game.h>
|
||||
#include <System/Collections/Generic/List.h>
|
||||
#include <Graphics/GraphicsDevice.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
@ -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()
|
||||
|
@ -26,9 +26,13 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <GameComponentCollection.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
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)
|
||||
|
@ -26,9 +26,12 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <GameTime.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -26,18 +26,22 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <GamerServices/GamerServicesComponent.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
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()
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <GraphicsDeviceManager.h>
|
||||
#include <Game.h>
|
||||
#include <System/Event.h>
|
||||
#include <System/Type.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::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)
|
||||
|
@ -28,7 +28,9 @@
|
||||
#include <Audio/SoundEffect.h>
|
||||
#include <Audio/SoundEffectInstance.h>
|
||||
|
||||
#include <System/FrameworkResources.h>
|
||||
#include <System/Single.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
@ -38,6 +40,8 @@ namespace XFX
|
||||
{
|
||||
float SoundEffect::masterVolume = 1.0f;
|
||||
|
||||
const Type SoundEffectTypeInfo("SoundEffect", "XFX::Audio::SoundEffect", TypeCode::Object);
|
||||
|
||||
float SoundEffect::getDistanceScale()
|
||||
{
|
||||
return distanceScale;
|
||||
@ -59,7 +63,7 @@ namespace XFX
|
||||
|
||||
void SoundEffect::setDopplerScale(float value)
|
||||
{
|
||||
sassert(value >= 0, "");
|
||||
sassert(value >= 0, String::Format("value; %s", FrameworkResources::ArgumentOutOfRange_NeedNonNegNum));
|
||||
|
||||
dopplerScale = value;
|
||||
|
||||
@ -113,6 +117,12 @@ namespace XFX
|
||||
|
||||
void SoundEffect::Dispose(bool disposing)
|
||||
{
|
||||
if (!isDisposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <System/Byte.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace System
|
||||
@ -34,6 +35,8 @@ namespace System
|
||||
const byte Byte::MaxValue = 255;
|
||||
const byte Byte::MinValue = 0;
|
||||
|
||||
const Type ByteTypeInfo("Byte", "System::Byte", TypeCode::Byte);
|
||||
|
||||
Byte::Byte()
|
||||
: value(0)
|
||||
{
|
||||
@ -63,9 +66,9 @@ namespace System
|
||||
return (value == other.value);
|
||||
}
|
||||
|
||||
int Byte::GetType()
|
||||
const Type& Byte::GetType()
|
||||
{
|
||||
return 6;
|
||||
return ByteTypeInfo;
|
||||
}
|
||||
|
||||
const String Byte::ToString() const
|
||||
@ -73,7 +76,7 @@ namespace System
|
||||
return String::Format("%i", value);
|
||||
}
|
||||
|
||||
const String& Byte::ToString(byte value)
|
||||
const String Byte::ToString(byte value)
|
||||
{
|
||||
return String::Format("%i", value);
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <System/TimeZone.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <xboxkrnl/xboxkrnl.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
namespace System
|
||||
@ -295,7 +297,7 @@ namespace System
|
||||
return (int)encoded;
|
||||
}
|
||||
|
||||
Type DateTime::GetType()
|
||||
const Type& DateTime::GetType()
|
||||
{
|
||||
return DateTimeTypeInfo;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace System
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
Type Double::GetType()
|
||||
const Type& Double::GetType()
|
||||
{
|
||||
return DoubleTypeInfo;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user