mirror of
https://github.com/Halofreak1990/XFXFramework
synced 2024-12-26 13:49:34 +01:00
Added missing TypeInfos in the System namespace
Fixed spacing Added Stopwatch class
This commit is contained in:
parent
cc43a97149
commit
ca63aaa9a5
@ -232,7 +232,7 @@ namespace System
|
||||
// Removes the element at the specified index of the List<>.
|
||||
void RemoveAt(const int index)
|
||||
{
|
||||
memcpy(&_items[index], &_items[index + 1], (size - index) * sizeof(T)):
|
||||
memcpy(&_items[index], &_items[index + 1], (_size - index) * sizeof(T));
|
||||
|
||||
_size--;
|
||||
_version++;
|
||||
|
@ -7,12 +7,6 @@
|
||||
#ifndef _SYSTEM_DIAGNOSTICS_DEBUG_
|
||||
#define _SYSTEM_DIAGNOSTICS_DEBUG_
|
||||
|
||||
#if _MSC_VER
|
||||
#define FORMAT
|
||||
#else
|
||||
#define FORMAT __attribute__(format(printf, 1, 2));
|
||||
#endif
|
||||
|
||||
namespace System
|
||||
{
|
||||
class String;
|
||||
@ -54,7 +48,7 @@ namespace System
|
||||
* @param args
|
||||
* An object array containing zero or more objects to format.
|
||||
*/
|
||||
static void WriteLine(const String& format, ...) FORMAT;
|
||||
static void WriteLine(const String& format, ...);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
42
include/System/Diagnostics/Stopwatch.h
Normal file
42
include/System/Diagnostics/Stopwatch.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef _SYSTEM_DIAGNOSTICS_STOPWATCH_
|
||||
#define _SYSTEM_DIAGNOSTICS_STOPWATCH_
|
||||
|
||||
#include <System/TimeSpan.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Diagnostics
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Stopwatch
|
||||
{
|
||||
private:
|
||||
bool isRunning;
|
||||
long long elapsedTicks;
|
||||
|
||||
public:
|
||||
static const long long Frequency;
|
||||
|
||||
TimeSpan getElapsed() const;
|
||||
/**
|
||||
* Gets the total elapsed time measured by the current instance, in milliseconds.
|
||||
*/
|
||||
long long getElapsedMilliseconds() const;
|
||||
long long getElapsedTicks() const;
|
||||
bool IsRunning() const;
|
||||
|
||||
Stopwatch();
|
||||
|
||||
static long long GetTimestamp();
|
||||
void Reset();
|
||||
void Restart();
|
||||
void Start();
|
||||
static const Stopwatch& StartNew();
|
||||
void Stop();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_SYSTEM_DIAGNOSTICS_STOPWATCH_
|
@ -1,8 +1,8 @@
|
||||
/*****************************************************************************
|
||||
* DirectoryInfo.h *
|
||||
* DirectoryInfo.h *
|
||||
* *
|
||||
* XFX System::IO::DirectoryInfo class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
* XFX System::IO::DirectoryInfo class definition file. *
|
||||
* Copyright (c) XFX Team. All Rights Reserved. *
|
||||
*****************************************************************************/
|
||||
#ifndef _SYSTEM_IO_DIRECTORYINFO_
|
||||
#define _SYSTEM_IO_DIRECTORYINFO_
|
||||
@ -30,20 +30,28 @@ namespace System
|
||||
public:
|
||||
bool Exists() const;
|
||||
String getName() const;
|
||||
DirectoryInfo Parent();
|
||||
DirectoryInfo Root();
|
||||
DirectoryInfo* getParent() const;
|
||||
DirectoryInfo* getRoot() const;
|
||||
|
||||
DirectoryInfo();
|
||||
DirectoryInfo(const String& path); // Initializes a new instance of the System::IO::DirectoryInfo class on the specified path.
|
||||
|
||||
// Creates a directory.
|
||||
/**
|
||||
* Creates a directory.
|
||||
*/
|
||||
void Create();
|
||||
// Creates a subdirectory or subdirectories on the specified path.
|
||||
// The specified path can be relative to this instance of the System::IO::DirectoryInfo class.
|
||||
/**
|
||||
* Creates a subdirectory or subdirectories on the specified path.
|
||||
* The specified path can be relative to this instance of the System::IO::DirectoryInfo class.
|
||||
*/
|
||||
DirectoryInfo CreateSubDirectory(const String& path);
|
||||
// Deletes this System::IO::DirectoryInfo if it is empty.
|
||||
/**
|
||||
* Deletes this System::IO::DirectoryInfo if it is empty.
|
||||
*/
|
||||
void Delete();
|
||||
// Deletes this instance of a System::IO::DirectoryInfo, specifying whether to delete subdirectories and files.
|
||||
/**
|
||||
* Deletes this instance of a System::IO::DirectoryInfo, specifying whether to delete subdirectories and files.
|
||||
*/
|
||||
void Delete(const bool recursive);
|
||||
DirectoryInfo* GetDirectories(); //
|
||||
DirectoryInfo* GetDirectories(const String& searchPattern);
|
||||
|
@ -13,7 +13,7 @@
|
||||
* Differences from C++ auto_ptr: exception-less and supports array notation.
|
||||
*/
|
||||
template <typename T>
|
||||
class auto_ptr
|
||||
struct auto_ptr
|
||||
{
|
||||
private:
|
||||
T* ptr;
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include <System/Diagnostics/Debug.h>
|
||||
#include <System/String.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if ENABLE_XBOX
|
||||
#include <xboxkrnl/xboxkrnl.h>
|
||||
#else
|
||||
@ -76,7 +80,20 @@ namespace System
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: implement
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
int count = vsnprintf(NULL, 0, format, args);
|
||||
|
||||
char* res = (char*)malloc(count + 1);
|
||||
|
||||
vsnprintf(res, count + 1, format, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
DbgPrint(res);
|
||||
|
||||
free(res);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
68
src/libSystem/Stopwatch.cpp
Normal file
68
src/libSystem/Stopwatch.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include <System/Diagnostics/Stopwatch.h>
|
||||
|
||||
#if ENABLE_XBOX
|
||||
#include <xboxkrnl/xboxkrnl.h>
|
||||
#else
|
||||
#endif
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Diagnostics
|
||||
{
|
||||
const long long Stopwatch::Frequency = KeQueryPerformanceFrequency();
|
||||
|
||||
TimeSpan Stopwatch::getElapsed() const
|
||||
{
|
||||
return TimeSpan::FromTicks(elapsedTicks);
|
||||
}
|
||||
|
||||
long long Stopwatch::getElapsedMilliseconds() const
|
||||
{
|
||||
return getElapsed().Milliseconds();
|
||||
}
|
||||
|
||||
long long Stopwatch::getElapsedTicks() const
|
||||
{
|
||||
return elapsedTicks;
|
||||
}
|
||||
|
||||
bool Stopwatch::IsRunning() const
|
||||
{
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
Stopwatch::Stopwatch()
|
||||
{
|
||||
}
|
||||
|
||||
long long Stopwatch::GetTimestamp()
|
||||
{
|
||||
return KeQueryPerformanceCounter();
|
||||
}
|
||||
|
||||
void Stopwatch::Restart()
|
||||
{
|
||||
Reset();
|
||||
Start();
|
||||
}
|
||||
|
||||
void Stopwatch::Start()
|
||||
{
|
||||
|
||||
isRunning = true;
|
||||
}
|
||||
|
||||
const Stopwatch& Stopwatch::StartNew()
|
||||
{
|
||||
Stopwatch sw = Stopwatch();
|
||||
sw.Start();
|
||||
return sw;
|
||||
}
|
||||
|
||||
void Stopwatch::Stop()
|
||||
{
|
||||
|
||||
isRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -77,6 +77,7 @@
|
||||
<ClCompile Include="Socket.cpp" />
|
||||
<ClCompile Include="SocketAsyncEventArgs.cpp" />
|
||||
<ClCompile Include="CancelEventArgs.cpp" />
|
||||
<ClCompile Include="Stopwatch.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\System\ComponentModel\CancelEventArgs.h" />
|
||||
|
@ -54,6 +54,9 @@
|
||||
<ClCompile Include="Debug.cpp">
|
||||
<Filter>Source Files\Diagnostics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Stopwatch.cpp">
|
||||
<Filter>Source Files\Diagnostics</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\System\ComponentModel\CancelEventArgs.h">
|
||||
|
@ -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) -lmscorlib -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lgcc -lstdc++
|
||||
|
||||
OBJS = CancelEventArgs.o Debug.o Socket.o SocketAddress.o SocketAsyncEventArgs.o
|
||||
OBJS = CancelEventArgs.o Debug.o Socket.o SocketAddress.o SocketAsyncEventArgs.o Stopwatch.o
|
||||
|
||||
all: libSystem.a
|
||||
|
||||
|
@ -27,11 +27,14 @@
|
||||
|
||||
#include <System/DateTime.h>
|
||||
#include <System/Globalization/Calendar.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Globalization
|
||||
{
|
||||
const Type CalendarTypeInfo("Calendar", "System::Globalization::Calendar", TypeCode::Object);
|
||||
|
||||
DateTime Calendar::AddDays(DateTime time, int days)
|
||||
{
|
||||
DateTime result(time);
|
||||
@ -67,9 +70,9 @@ namespace System
|
||||
return result;
|
||||
}
|
||||
|
||||
int Calendar::GetType()
|
||||
const Type& Calendar::GetType()
|
||||
{
|
||||
//! TODO: implement
|
||||
return CalendarTypeInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,13 @@ namespace System
|
||||
void Console::Write(const bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
debugPrint("true");
|
||||
}
|
||||
else
|
||||
{
|
||||
debugPrint("false");
|
||||
}
|
||||
}
|
||||
|
||||
void Console::Write(const char value)
|
||||
@ -41,7 +45,9 @@ namespace System
|
||||
//sassert(index + count < Array::Length(value), "index + count are out of range of the array.");
|
||||
|
||||
for (int i = index; i < (index + count); i++)
|
||||
{
|
||||
debugPrint("%c", value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Console::Write(const double value)
|
||||
|
@ -92,15 +92,15 @@ namespace System
|
||||
DateTime DateTime::Add(double value, int scale)
|
||||
{
|
||||
long long num = (long long)((value * scale) + ((value >= 0.0) ? 0.5 : -0.5));
|
||||
if ((num <= -315537897600000LL) || (num >= 0x11efae44cb400LL))
|
||||
if ((num <= -315537897600000LL) || (num >= 0x11efae44cb400LL))
|
||||
{
|
||||
#if DEBUG
|
||||
//throw ArgumentOutOfRangeException("value", "ArgumentOutOfRange_AddValue");
|
||||
//throw ArgumentOutOfRangeException("value", "ArgumentOutOfRange_AddValue");
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
return AddTicks(num * 0x2710L);
|
||||
return AddTicks(num * 0x2710L);
|
||||
}
|
||||
|
||||
DateTime::DateTime(int year, int month, int day)
|
||||
|
@ -41,6 +41,21 @@ namespace System
|
||||
{
|
||||
namespace IO
|
||||
{
|
||||
DirectoryInfo* DirectoryInfo::getParent() const
|
||||
{
|
||||
return new DirectoryInfo(parent);
|
||||
}
|
||||
|
||||
DirectoryInfo* DirectoryInfo::getRoot() const
|
||||
{
|
||||
// TODO; implement
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DirectoryInfo::DirectoryInfo()
|
||||
{
|
||||
}
|
||||
|
||||
DirectoryInfo::DirectoryInfo(const String& path)
|
||||
{
|
||||
sassert(path != null, FrameworkResources::ArgumentNull_Path);
|
||||
@ -57,11 +72,12 @@ namespace System
|
||||
|
||||
void DirectoryInfo::Create()
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
DirectoryInfo DirectoryInfo::CreateSubDirectory(const String& path)
|
||||
{
|
||||
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
void DirectoryInfo::Delete()
|
||||
@ -92,14 +108,12 @@ namespace System
|
||||
|
||||
bool DirectoryInfo::operator !=(const DirectoryInfo& right) const
|
||||
{
|
||||
return ((strncmp(current, right.current, strlen(current)) != 0) ||
|
||||
(strncmp(parent, right.parent, strlen(parent)) != 0));
|
||||
return (current != right.current) || (parent != right.parent);
|
||||
}
|
||||
|
||||
bool DirectoryInfo::operator ==(const DirectoryInfo& right) const
|
||||
{
|
||||
return ((strncmp(current, right.current, strlen(current)) == 0) &&
|
||||
(strncmp(parent, right.parent, strlen(parent)) == 0));
|
||||
return (current == right.current) && (parent == right.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
extern "C" int strcasecmp(const char * s1, const char * s2);
|
||||
|
||||
namespace System
|
||||
{
|
||||
static unsigned long long rawNaND = 0x7ff8000000000000ULL;
|
||||
@ -63,9 +65,15 @@ namespace System
|
||||
int Double::CompareTo(const Double other) const
|
||||
{
|
||||
if (value > other.value)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (value < other.value)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -92,22 +100,32 @@ namespace System
|
||||
|
||||
*result = 0;
|
||||
char sign = 0;
|
||||
char *sp = const_cast<char*>((const char *)str.ToString());
|
||||
char* sp = const_cast<char *>((const char *)str.ToString());
|
||||
|
||||
if (*sp == '+' || *sp == '-')
|
||||
{
|
||||
sign = *sp++;
|
||||
}
|
||||
|
||||
if (strcasecmp(sp, "inf") == 0)
|
||||
{
|
||||
if (!sign || sign == '+')
|
||||
{
|
||||
*result = PositiveInfinity;
|
||||
}
|
||||
else
|
||||
{
|
||||
*result = NegativeInfinity;
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(sp, "nan") == 0)
|
||||
{
|
||||
*result = NaN;
|
||||
}
|
||||
else /* valid number */
|
||||
{
|
||||
*result = atof(sp);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -110,17 +110,17 @@ namespace System
|
||||
}
|
||||
|
||||
FileStream::FileStream()
|
||||
: handle(NULL), _file(NULL)
|
||||
: _file(NULL), handle(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
FileStream::FileStream(FILE * const file)
|
||||
: handle(NULL), _file(file)
|
||||
: _file(file), handle(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
FileStream::FileStream(const String& path, const FileMode_t mode)
|
||||
: handle(NULL), _file(NULL)
|
||||
: _file(NULL), handle(NULL)
|
||||
{
|
||||
sassert(!String::IsNullOrEmpty(path), FrameworkResources::ArgumentNull_Path);
|
||||
|
||||
|
@ -98,12 +98,16 @@ namespace System
|
||||
char* end = NULL;
|
||||
|
||||
if (String::IsNullOrEmpty(str))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long long retval = strtoll(str, &end, 10);
|
||||
|
||||
if (end)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*result = retval;
|
||||
return true;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <System/FrameworkResources.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
@ -39,6 +40,8 @@ namespace System
|
||||
{
|
||||
const String String::Empty = "";
|
||||
|
||||
const Type StringTypeInfo("String", "System::String", TypeCode::String);
|
||||
|
||||
String::String()
|
||||
: Length(0)
|
||||
{
|
||||
@ -92,7 +95,9 @@ namespace System
|
||||
String::~String()
|
||||
{
|
||||
if (internalString)
|
||||
{
|
||||
free(internalString);
|
||||
}
|
||||
}
|
||||
|
||||
String String::Clone() const
|
||||
@ -107,7 +112,7 @@ namespace System
|
||||
|
||||
int String::CompareTo(const String other) const
|
||||
{
|
||||
return (Compare(*this, other));
|
||||
return strcmp(this->internalString, other.internalString);
|
||||
}
|
||||
|
||||
String String::Concat(const String values[], const int stringCount)
|
||||
@ -165,6 +170,8 @@ namespace System
|
||||
|
||||
vsnprintf(res, count + 1, format, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -180,9 +187,9 @@ namespace System
|
||||
return h;
|
||||
}
|
||||
|
||||
int String::GetType()
|
||||
const Type& String::GetType()
|
||||
{
|
||||
return 18;
|
||||
return StringTypeInfo;
|
||||
}
|
||||
|
||||
int String::IndexOf(char value) const
|
||||
@ -190,8 +197,11 @@ namespace System
|
||||
for(int i = 0; i <= Length; i++)
|
||||
{
|
||||
if (internalString[i] == value)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -210,8 +220,11 @@ namespace System
|
||||
for(int i = startIndex; i < startIndex + count; i++)
|
||||
{
|
||||
if(internalString[i] == value)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -233,7 +246,9 @@ namespace System
|
||||
{
|
||||
indexOf = IndexOf(anyOf[i], startIndex, count);
|
||||
if (indexOf != -1)
|
||||
{
|
||||
return indexOf;
|
||||
}
|
||||
}
|
||||
|
||||
return indexOf;
|
||||
@ -279,7 +294,9 @@ namespace System
|
||||
String String::PadRight(int totalWidth, char paddingChar)
|
||||
{
|
||||
if(totalWidth <= Length)
|
||||
return String(*this);
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
char* newString = (char*)malloc(totalWidth + 1);
|
||||
|
||||
@ -369,7 +386,9 @@ namespace System
|
||||
String newString = String(*this);
|
||||
|
||||
for (int i = 0; i < Length; i++)
|
||||
{
|
||||
newString.internalString[i] = tolower(internalString[i]);
|
||||
}
|
||||
|
||||
return newString;
|
||||
}
|
||||
@ -379,13 +398,15 @@ namespace System
|
||||
size_t strLen = strlen(str);
|
||||
char* tmp = (char*)malloc(strLen + 1);
|
||||
for (size_t i = 0; i < strLen; i++)
|
||||
{
|
||||
tmp[i] = tolower(str[i]);
|
||||
}
|
||||
|
||||
tmp[strLen] = '\0';
|
||||
return tmp;
|
||||
}
|
||||
|
||||
const String& String::ToString() const
|
||||
const String String::ToString() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
@ -395,7 +416,9 @@ namespace System
|
||||
String newString = String(*this);
|
||||
|
||||
for (int i = 0; i < Length; i++)
|
||||
{
|
||||
newString.internalString[i] = toupper(internalString[i]);
|
||||
}
|
||||
|
||||
return newString;
|
||||
}
|
||||
@ -404,8 +427,11 @@ namespace System
|
||||
{
|
||||
size_t strLen = strlen(str);
|
||||
char* tmp = (char*)malloc(strLen + 1);
|
||||
|
||||
for (size_t i = 0; i < strLen; i++)
|
||||
{
|
||||
tmp[i] = toupper(str[i]);
|
||||
}
|
||||
|
||||
tmp[strLen] = '\0';
|
||||
return tmp;
|
||||
@ -422,6 +448,7 @@ namespace System
|
||||
{
|
||||
return !Equals(right);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -431,6 +458,7 @@ namespace System
|
||||
{
|
||||
return (strncmp(internalString, right, Length) != 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -449,6 +477,7 @@ namespace System
|
||||
{
|
||||
return (strncmp(internalString, right, Length) == 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -456,15 +485,11 @@ namespace System
|
||||
{
|
||||
// check for self-assignment
|
||||
if (*this == right)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
*(const_cast<int*>(&Length)) = right.Length;
|
||||
free(internalString);
|
||||
internalString = (char*)malloc(Length + 1);
|
||||
strncpy(internalString, right.internalString, Length);
|
||||
internalString[Length] = '\0';
|
||||
|
||||
return *this;
|
||||
return String(right);
|
||||
}
|
||||
|
||||
String String::operator +(const char *right) const
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <System/String.h>
|
||||
#include <System/TimeSpan.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
@ -41,6 +42,8 @@ namespace System
|
||||
const long long TimeSpan::TicksPerHour = 36000000000LL;
|
||||
const long long TimeSpan::TicksPerDay = 864000000000LL;
|
||||
|
||||
const Type TimeSpanTypeInfo("TimeSpan", "System::TimeSpan", TypeCode::Object);
|
||||
|
||||
TimeSpan::TimeSpan()
|
||||
{
|
||||
_ticks = 0;
|
||||
@ -141,9 +144,15 @@ namespace System
|
||||
int TimeSpan::Compare(const TimeSpan t1, const TimeSpan t2)
|
||||
{
|
||||
if (t1._ticks < t2._ticks)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (t1._ticks > t2._ticks)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -202,9 +211,9 @@ namespace System
|
||||
return (((int)_ticks) ^ ((int)(_ticks >> 0x20)));
|
||||
}
|
||||
|
||||
int TimeSpan::GetType()
|
||||
const Type& TimeSpan::GetType()
|
||||
{
|
||||
//! TODO: implement
|
||||
return TimeSpanTypeInfo;
|
||||
}
|
||||
|
||||
TimeSpan TimeSpan::Negate()
|
||||
@ -223,7 +232,7 @@ namespace System
|
||||
return TimeSpan(ticks);
|
||||
}
|
||||
|
||||
const String& TimeSpan::ToString() const
|
||||
const String TimeSpan::ToString() const
|
||||
{
|
||||
return String::Format("Ticks: %ll", _ticks);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <System/UInt16.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -34,6 +35,7 @@ namespace System
|
||||
{
|
||||
const ushort UInt16::MaxValue = 0xFFFF;
|
||||
const ushort UInt16::MinValue = 0;
|
||||
const Type UInt16TypeInfo("UInt16", "System::UInt16", TypeCode::UInt16);
|
||||
|
||||
UInt16::UInt16()
|
||||
: value(0)
|
||||
@ -53,9 +55,15 @@ namespace System
|
||||
int UInt16::CompareTo(const UInt16 other) const
|
||||
{
|
||||
if (value < other.value)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (value > other.value)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -74,17 +82,17 @@ namespace System
|
||||
return value;
|
||||
}
|
||||
|
||||
int UInt16::GetType()
|
||||
const Type& UInt16::GetType()
|
||||
{
|
||||
return 8;
|
||||
return UInt16TypeInfo;
|
||||
}
|
||||
|
||||
const String& UInt16::ToString() const
|
||||
const String UInt16::ToString() const
|
||||
{
|
||||
return String::Format("%i", value);
|
||||
}
|
||||
|
||||
const String& UInt16::ToString(const ushort value)
|
||||
const String UInt16::ToString(const ushort value)
|
||||
{
|
||||
return String::Format("%i", value);
|
||||
}
|
||||
@ -95,12 +103,16 @@ namespace System
|
||||
char* end = NULL;
|
||||
|
||||
if (String::IsNullOrEmpty(str))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ushort retval = (ushort)strtoul(str, &end, 10);
|
||||
|
||||
if (end)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*result = retval;
|
||||
return true;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <System/UInt32.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -34,6 +35,7 @@ namespace System
|
||||
{
|
||||
const uint UInt32::MaxValue = 0xFFFFFFFF;
|
||||
const uint UInt32::MinValue = 0;
|
||||
const Type UInt32TypeInfo("UInt32", "System::UInt32", TypeCode::UInt32);
|
||||
|
||||
UInt32::UInt32(const UInt32 &obj)
|
||||
: value(obj.value)
|
||||
@ -69,17 +71,17 @@ namespace System
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
int UInt32::GetType()
|
||||
const Type& UInt32::GetType()
|
||||
{
|
||||
return 10;
|
||||
return UInt32TypeInfo;
|
||||
}
|
||||
|
||||
const String& UInt32::ToString() const
|
||||
const String UInt32::ToString() const
|
||||
{
|
||||
return String::Format("%i", value);
|
||||
}
|
||||
|
||||
const String& UInt32::ToString(const uint value)
|
||||
const String UInt32::ToString(const uint value)
|
||||
{
|
||||
return String::Format("%i", value);
|
||||
}
|
||||
@ -90,12 +92,16 @@ namespace System
|
||||
char* end = NULL;
|
||||
|
||||
if (String::IsNullOrEmpty(str))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint retval = strtoul(str, &end, 10);
|
||||
|
||||
if (*end)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*result = retval;
|
||||
return true;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <System/UInt64.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -34,6 +35,7 @@ namespace System
|
||||
{
|
||||
const ulong UInt64::MaxValue = 0xFFFFFFFFFFFFFFFFULL;
|
||||
const ulong UInt64::MinValue = 0;
|
||||
const Type UInt64TypeInfo("UInt64", "System::UInt64", TypeCode::UInt64);
|
||||
|
||||
UInt64::UInt64(const UInt64 &obj)
|
||||
: value(obj.value)
|
||||
@ -48,9 +50,15 @@ namespace System
|
||||
int UInt64::CompareTo(const UInt64 other) const
|
||||
{
|
||||
if (value > other.value)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (value < other.value)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -69,9 +77,9 @@ namespace System
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
int UInt64::GetType()
|
||||
const Type& UInt64::GetType()
|
||||
{
|
||||
return 12;
|
||||
return UInt64TypeInfo;
|
||||
}
|
||||
|
||||
const String UInt64::ToString() const
|
||||
@ -90,12 +98,16 @@ namespace System
|
||||
char* end = NULL;
|
||||
|
||||
if (String::IsNullOrEmpty(str))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ulong retval = strtoull(str, &end, 10);
|
||||
|
||||
if (end)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*result = retval;
|
||||
return true;
|
||||
|
@ -26,12 +26,15 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
#include <System/Version.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
const Type VersionTypeInfo("Version", "System::Version", TypeCode::Object);
|
||||
|
||||
Version::Version(int major, int minor)
|
||||
: Build(0), Major(major), Minor(minor), Revision(0)
|
||||
{
|
||||
@ -60,9 +63,15 @@ namespace System
|
||||
int Version::CompareTo(const Version value) const
|
||||
{
|
||||
if (*this < value)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (*this > value)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -82,22 +91,22 @@ namespace System
|
||||
return (Build ^ Major ^ Minor ^ Revision);
|
||||
}
|
||||
|
||||
int Version::GetType()
|
||||
const Type& Version::GetType()
|
||||
{
|
||||
// TODO: implement
|
||||
return VersionTypeInfo;
|
||||
}
|
||||
|
||||
const String& Version::ToString() const
|
||||
const String Version::ToString() const
|
||||
{
|
||||
return String::Format("%i.%i.%i.%i", Major, Minor, Build, Revision);
|
||||
}
|
||||
|
||||
const String& Version::ToString(int fieldCount) const
|
||||
const String Version::ToString(int fieldCount) const
|
||||
{
|
||||
switch(fieldCount)
|
||||
{
|
||||
case 0:
|
||||
return "";
|
||||
return String::Empty;
|
||||
break;
|
||||
case 1:
|
||||
return String::Format("%i", Major);
|
||||
|
@ -4,15 +4,15 @@
|
||||
#########################################################################
|
||||
PREFIX = /openxdk
|
||||
|
||||
CC = xbox-gcc
|
||||
CCAS = xbox-gcc
|
||||
CPP = xbox-g++
|
||||
AR = xbox-ar rcu
|
||||
RANLIB = xbox-ranlib
|
||||
CC = gcc
|
||||
CCAS = gcc
|
||||
CPP = g++
|
||||
AR = ar rcu
|
||||
RANLIB = ranlib
|
||||
CXBE = $(PREFIX)/bin/cxbe
|
||||
|
||||
SDLFLAGS = -DENABLE_XBOX -DDEBUG
|
||||
CC_FLAGS = -c -g -O2 -std=gnu99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS)
|
||||
CC_FLAGS = -c -g -O2 -std=C99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS)
|
||||
CCAS_FLAGS = --32 -march=pentiumiii, mmx, sse -mtune=pentiumiii -msse-check=error
|
||||
CPP_FLAGS = -c -O2 -std=c++03 -Wall -nostdlib -fno-builtin -fno-exceptions -fno-rtti -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS)
|
||||
INCLUDE = -I$(PREFIX)/i386-pc-xbox/include -I$(PREFIX)/include -I$(PREFIX)/include/SDL -I../../include
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <System/misc.h>
|
||||
#include <xboxkrnl/xboxkrnl.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -135,3 +136,19 @@ void *memset(void *s, char c, size_t count)
|
||||
:"memory");
|
||||
return s;
|
||||
}
|
||||
|
||||
int strcasecmp(const char * s1, const char * s2)
|
||||
{
|
||||
const unsigned char *us1 = (const unsigned char *)s1,
|
||||
*us2 = (const unsigned char *)s2;
|
||||
|
||||
while (tolower(*us1) == tolower(*us2++))
|
||||
{
|
||||
if (*us1++ == '\0')
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
return (tolower(*us1) - tolower(*--us2));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user