Skip to content

Commit

Permalink
Updated Robot Core Library
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrutsko committed Mar 22, 2016
1 parent 6dd1479 commit 174e907
Show file tree
Hide file tree
Showing 37 changed files with 438 additions and 382 deletions.
56 changes: 28 additions & 28 deletions Native/Robot/Bounds.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down Expand Up @@ -88,7 +88,7 @@ bool Bounds::IsZero (void) const

bool Bounds::IsEmpty (void) const
{
return W == 0 && H == 0;
return W == 0 || H == 0;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -314,28 +314,16 @@ Point Bounds::GetCenter (void) const

////////////////////////////////////////////////////////////////////////////////

Bounds Bounds::operator & (const Bounds& bounds) const
Bounds& Bounds::operator |= (const Bounds& bounds)
{
int32 x = bounds.X;
int32 y = bounds.Y;
int32 w = bounds.W;
int32 h = bounds.H;

if ((W == 0 && H == 0) || (w == 0 && h == 0))
return Bounds();

// Normalize negative rectangles
NORM (l1, r1, t1, b1, X, Y, W, H);
NORM (l2, r2, t2, b2, x, y, w, h);
return *this = *this | bounds;
}

// Check for bounds intersection
if (l1 > r2 || r1 < l2 || t1 > b2 || b1 < t2)
return Bounds();
////////////////////////////////////////////////////////////////////////////////

Bounds result;
result.SetLTRB (max (l1, l2), max (t1, t2),
min (r1, r2), min (b1, b2));
return result;
Bounds& Bounds::operator &= (const Bounds& bounds)
{
return *this = *this & bounds;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -372,16 +360,28 @@ Bounds Bounds::operator | (const Bounds& bounds) const

////////////////////////////////////////////////////////////////////////////////

Bounds& Bounds::operator &= (const Bounds& bounds)
Bounds Bounds::operator & (const Bounds& bounds) const
{
return *this = *this & bounds;
}
int32 x = bounds.X;
int32 y = bounds.Y;
int32 w = bounds.W;
int32 h = bounds.H;

////////////////////////////////////////////////////////////////////////////////
if ((W == 0 && H == 0) || (w == 0 && h == 0))
return Bounds();

Bounds& Bounds::operator |= (const Bounds& bounds)
{
return *this = *this | bounds;
// Normalize negative rectangles
NORM (l1, r1, t1, b1, X, Y, W, H);
NORM (l2, r2, t2, b2, x, y, w, h);

// Check for bounds intersection
if (l1 > r2 || r1 < l2 || t1 > b2 || b1 < t2)
return Bounds();

Bounds result;
result.SetLTRB (max (l1, l2), max (t1, t2),
min (r1, r2), min (b1, b2));
return result;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 5 additions & 5 deletions Native/Robot/Bounds.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down Expand Up @@ -87,11 +87,11 @@ class ROBOT_EXPORT Bounds
Point GetCenter (void) const;

public:
Bounds operator & (const Bounds& bounds) const;
Bounds operator | (const Bounds& bounds) const;

Bounds& operator &= (const Bounds& bounds);
Bounds& operator |= (const Bounds& bounds);
Bounds& operator &= (const Bounds& bounds);

Bounds operator | (const Bounds& bounds) const;
Bounds operator & (const Bounds& bounds) const;

bool operator == (const Bounds& bounds) const;
bool operator != (const Bounds& bounds) const;
Expand Down
2 changes: 1 addition & 1 deletion Native/Robot/Clipboard.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down
2 changes: 1 addition & 1 deletion Native/Robot/Clipboard.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down
2 changes: 1 addition & 1 deletion Native/Robot/Color.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down
2 changes: 1 addition & 1 deletion Native/Robot/Color.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down
32 changes: 17 additions & 15 deletions Native/Robot/Enum.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down Expand Up @@ -97,19 +97,31 @@ template <typename Type> class Enum

////////////////////////////////////////////////////////////////////////////////

static Type Parse (const std::string& key)
static const ValueMap& GetMap (void)
{
// Initialize the static parser
if (mMap.empty()) Enum<Type>();

return mMap;
}

////////////////////////////////////////////////////////////////////////////////

static Type Parse (const std::string& key,
Type defaultValue = (Type) -1)
{
// Initialize the static parser
if (mMap.empty()) Enum<Type>();

// Search for a matching key
return mMap.find (key) != mMap.end()
? mMap.at (key) : (Type) -1;
? mMap.at (key) : defaultValue;
}

////////////////////////////////////////////////////////////////////////////////

static std::string Parse (Type value)
static std::string Parse (Type value,
const char* defaultValue = "")
{
// Initialize the static parser
if (mMap.empty()) Enum<Type>();
Expand All @@ -123,17 +135,7 @@ template <typename Type> class Enum
}

// Nothing was found
return std::string();
}

////////////////////////////////////////////////////////////////////////////////

static const ValueMap& GetMap (void)
{
// Initialize the static parser
if (mMap.empty()) Enum<Type>();

return mMap;
return defaultValue;
}


Expand Down
35 changes: 14 additions & 21 deletions Native/Robot/Global.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand All @@ -20,17 +20,10 @@
//----------------------------------------------------------------------------//

////////////////////////////////////////////////////////////////////////////////
/// Defines the current Robot version as a string and integer value.
/// Defines the current version of Robot as an integer and string value.

#define ROBOT_VERSION 0x020000
#define ROBOT_VERSION_STR "2.0.0"

////////////////////////////////////////////////////////////////////////////////
/// Can be used as an easier method for checking the Robot version.
/// An example: #if (ROBOT_VERSION >= ROBOT_VERSION_CHK (1, 0, 2))

#define ROBOT_VERSION_CHK( major, minor, patch ) \
((major << 16) | (minor << 8) | (patch))
#define ROBOT_VERSION 0x020000
#define ROBOT_VERSION_STR "2.0.0"



Expand Down Expand Up @@ -154,18 +147,18 @@

ROBOT_NS_BEGIN

typedef signed char int8; // Signed 8-bit integer
typedef signed short int16; // Signed 16-bit integer
typedef signed int int32; // Signed 32-bit integer
typedef signed long long int64; // Signed 64-bit integer
typedef signed char int8; // Signed 8-Bit integer
typedef signed short int16; // Signed 16-Bit integer
typedef signed int int32; // Signed 32-Bit integer
typedef signed long long int64; // Signed 64-Bit integer

typedef unsigned char uint8; // Unsigned 8-bit integer
typedef unsigned short uint16; // Unsigned 16-bit integer
typedef unsigned int uint32; // Unsigned 32-bit integer
typedef unsigned long long uint64; // Unsigned 64-bit integer
typedef unsigned char uint8; // Unsigned 8-Bit integer
typedef unsigned short uint16; // Unsigned 16-Bit integer
typedef unsigned int uint32; // Unsigned 32-Bit integer
typedef unsigned long long uint64; // Unsigned 64-Bit integer

typedef float real32; // 32-bit real value
typedef double real64; // 64-bit real value
typedef float real32; // 32-Bit float value
typedef double real64; // 64-Bit float value

#ifdef ROBOT_ARCH_64

Expand Down
2 changes: 1 addition & 1 deletion Native/Robot/Hash.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down
6 changes: 3 additions & 3 deletions Native/Robot/Hash.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand All @@ -28,12 +28,12 @@ class ROBOT_EXPORT Hash
{
public:
explicit Hash (void);
explicit Hash (const char* file);
explicit Hash (const char* file);
explicit Hash (const uint8* data,
uintptr dataLength);

public:
bool Append (const char* file);
bool Append (const char* file);
void Append (const uint8* data,
uintptr dataLength);

Expand Down
15 changes: 9 additions & 6 deletions Native/Robot/Image.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down Expand Up @@ -110,17 +110,18 @@ bool Image::IsValid (void) const

////////////////////////////////////////////////////////////////////////////////

void Image::Create (const Size& size)
bool Image::Create (const Size& size)
{
Create (size.W, size.H);
return Create (size.W, size.H);
}

////////////////////////////////////////////////////////////////////////////////

void Image::Create (uint16 w, uint16 h)
bool Image::Create (uint16 w, uint16 h)
{
// Don't accept empty values
if (w == 0 || h == 0) return;
// Verify dimensions
if (w == 0 || h == 0)
return false;

mWidth = w;
mHeight = h;
Expand All @@ -136,6 +137,8 @@ void Image::Create (uint16 w, uint16 h)
mData = new uint32
[mLimit = mLength];
}

return true;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 4 additions & 4 deletions Native/Robot/Image.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down Expand Up @@ -31,7 +31,7 @@ class ROBOT_EXPORT Image
{
public:
Image (void);
~Image (void);
virtual ~Image (void);

Image (const Image& image);
Image ( Image&& image);
Expand All @@ -42,8 +42,8 @@ class ROBOT_EXPORT Image
public:
bool IsValid (void) const;

void Create (const Size& size);
void Create (uint16 w, uint16 h);
bool Create (const Size& size);
bool Create (uint16 w, uint16 h);
void Destroy (void);

uint16 GetWidth (void) const { return mWidth; }
Expand Down
2 changes: 1 addition & 1 deletion Native/Robot/Keyboard.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2015 Robot Developers //
// (C) 2010-2016 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
Expand Down
Loading

0 comments on commit 174e907

Please sign in to comment.