mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +02:00
Minor code cleanup
This commit is contained in:
+1
-1
@@ -47,7 +47,7 @@ public:
|
||||
* Gets a pointer to the data. This pointer will obviously not
|
||||
* be valid if the Data object is destroyed.
|
||||
**/
|
||||
virtual void *getData() const = 0 ;
|
||||
virtual void *getData() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the size of the Data in bytes.
|
||||
|
||||
+10
-10
@@ -26,7 +26,7 @@
|
||||
namespace love
|
||||
{
|
||||
|
||||
template<typename T, typename U, unsigned PEAK>
|
||||
template<typename T, typename U, unsigned int PEAK>
|
||||
class EnumMap
|
||||
{
|
||||
public:
|
||||
@@ -37,14 +37,14 @@ public:
|
||||
U u;
|
||||
};
|
||||
|
||||
EnumMap(Entry *entries, unsigned size)
|
||||
EnumMap(const Entry *entries, unsigned int size)
|
||||
{
|
||||
unsigned n = size/sizeof(Entry);
|
||||
unsigned int n = size / sizeof(Entry);
|
||||
|
||||
for (unsigned i = 0; i<n; ++i)
|
||||
for (unsigned int i = 0; i < n; ++i)
|
||||
{
|
||||
unsigned e_t = (unsigned)entries[i].t;
|
||||
unsigned e_u = (unsigned)entries[i].u;
|
||||
unsigned int e_t = (unsigned int) entries[i].t;
|
||||
unsigned int e_u = (unsigned int) entries[i].u;
|
||||
|
||||
if (e_t < PEAK)
|
||||
{
|
||||
@@ -61,9 +61,9 @@ public:
|
||||
|
||||
bool find(T t, U &u)
|
||||
{
|
||||
if ((unsigned)t < PEAK && values_u[(unsigned)t].set)
|
||||
if ((unsigned int) t < PEAK && values_u[(unsigned int) t].set)
|
||||
{
|
||||
u = (U)values_u[(unsigned)t].v;
|
||||
u = (U) values_u[(unsigned int) t].v;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ public:
|
||||
|
||||
bool find(U u, T &t)
|
||||
{
|
||||
if ((unsigned)u < PEAK && values_t[(unsigned)u].set)
|
||||
if ((unsigned int) u < PEAK && values_t[(unsigned int) u].set)
|
||||
{
|
||||
t = (T)values_t[(unsigned)u].v;
|
||||
t = (T) values_t[(unsigned int) u].v;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+20
-21
@@ -26,7 +26,7 @@
|
||||
namespace love
|
||||
{
|
||||
|
||||
template<typename T, unsigned SIZE>
|
||||
template<typename T, unsigned int SIZE>
|
||||
class StringMap
|
||||
{
|
||||
public:
|
||||
@@ -37,18 +37,16 @@ public:
|
||||
T value;
|
||||
};
|
||||
|
||||
StringMap(Entry *entries, unsigned num)
|
||||
StringMap(const Entry *entries, unsigned int num)
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < SIZE; ++i)
|
||||
reverse[i] = 0;
|
||||
for (unsigned int i = 0; i < SIZE; ++i)
|
||||
reverse[i] = nullptr;
|
||||
|
||||
unsigned n = num/sizeof(Entry);
|
||||
unsigned int n = num / sizeof(Entry);
|
||||
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < n; ++i)
|
||||
add(entries[i].key, entries[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
bool streq(const char *a, const char *b)
|
||||
@@ -57,6 +55,7 @@ public:
|
||||
{
|
||||
if (*a != *b)
|
||||
return false;
|
||||
|
||||
++a;
|
||||
++b;
|
||||
}
|
||||
@@ -66,11 +65,11 @@ public:
|
||||
|
||||
bool find(const char *key, T &t)
|
||||
{
|
||||
unsigned str_hash = djb2(key);
|
||||
unsigned int str_hash = djb2(key);
|
||||
|
||||
for (unsigned i = 0; i < MAX; ++i)
|
||||
for (unsigned int i = 0; i < MAX; ++i)
|
||||
{
|
||||
unsigned str_i = (str_hash + i) % MAX;
|
||||
unsigned int str_i = (str_hash + i) % MAX;
|
||||
|
||||
if (!records[str_i].set)
|
||||
return false;
|
||||
@@ -85,14 +84,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool find(T key, const char *&str)
|
||||
bool find(T key, const char *&str)
|
||||
{
|
||||
unsigned index = (unsigned)key;
|
||||
unsigned int index = (unsigned int) key;
|
||||
|
||||
if (index >= SIZE)
|
||||
return false;
|
||||
|
||||
if (reverse[index] != 0)
|
||||
if (reverse[index] != nullptr)
|
||||
{
|
||||
str = reverse[index];
|
||||
return true;
|
||||
@@ -105,12 +104,12 @@ public:
|
||||
|
||||
bool add(const char *key, T value)
|
||||
{
|
||||
unsigned str_hash = djb2(key);
|
||||
unsigned int str_hash = djb2(key);
|
||||
bool inserted = false;
|
||||
|
||||
for (unsigned i = 0; i < MAX; ++i)
|
||||
for (unsigned int i = 0; i < MAX; ++i)
|
||||
{
|
||||
unsigned str_i = (str_hash + i) % MAX;
|
||||
unsigned int str_i = (str_hash + i) % MAX;
|
||||
|
||||
if (!records[str_i].set)
|
||||
{
|
||||
@@ -122,7 +121,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
unsigned index = (unsigned)value;
|
||||
unsigned int index = (unsigned int) value;
|
||||
|
||||
if (index >= SIZE)
|
||||
{
|
||||
@@ -135,9 +134,9 @@ public:
|
||||
return inserted;
|
||||
}
|
||||
|
||||
unsigned djb2(const char *key)
|
||||
unsigned int djb2(const char *key)
|
||||
{
|
||||
unsigned hash = 5381;
|
||||
unsigned int hash = 5381;
|
||||
int c;
|
||||
|
||||
while ((c = *key++))
|
||||
@@ -156,7 +155,7 @@ private:
|
||||
Record() : set(false) {}
|
||||
};
|
||||
|
||||
const static unsigned MAX = SIZE*2;
|
||||
static const unsigned int MAX = SIZE * 2;
|
||||
|
||||
Record records[MAX];
|
||||
const char *reverse[SIZE];
|
||||
|
||||
+11
-24
@@ -21,11 +21,10 @@
|
||||
#ifndef LOVE_INT_H
|
||||
#define LOVE_INT_H
|
||||
|
||||
#include "common/config.h"
|
||||
|
||||
#ifndef LOVE_WINDOWS
|
||||
// C standard sized integer types.
|
||||
// This header was added to Visual studio in VS 2012, which is LOVE's current
|
||||
// minimum supported VS version (as of this comment's commit date.)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#define LOVE_INT8_MAX 0x7F
|
||||
#define LOVE_UINT8_MAX 0xFF
|
||||
@@ -39,26 +38,14 @@
|
||||
namespace love
|
||||
{
|
||||
|
||||
// Blame Microsoft
|
||||
#ifdef LOVE_WINDOWS
|
||||
typedef __int8 int8;
|
||||
typedef unsigned __int8 uint8;
|
||||
typedef __int16 int16;
|
||||
typedef unsigned __int16 uint16;
|
||||
typedef __int32 int32;
|
||||
typedef unsigned __int32 uint32;
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#else // LOVE_WINDOWS
|
||||
typedef int8_t int8;
|
||||
typedef uint8_t uint8;
|
||||
typedef int16_t int16;
|
||||
typedef uint16_t uint16;
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
#endif // LOVE_WINDOWS
|
||||
typedef int8_t int8;
|
||||
typedef uint8_t uint8;
|
||||
typedef int16_t int16;
|
||||
typedef uint16_t uint16;
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
} // love
|
||||
|
||||
|
||||
@@ -283,10 +283,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
|
||||
arg1 = new Variant(JOYSTICK_JOYSTICK_ID, (void *) &proxy);
|
||||
arg2 = new Variant((double)(e.jaxis.axis+1));
|
||||
float value = e.jaxis.value / 32768.0f;
|
||||
if (fabsf(value) < 0.001f) value = 0.0f;
|
||||
if (value < -0.99f) value = -1.0f;
|
||||
if (value > 0.99f) value = 1.0f;
|
||||
float value = joystick::Joystick::clampval(e.jaxis.value / 32768.0f);
|
||||
arg3 = new Variant((double) value);
|
||||
msg = new Message("joystickaxis", arg1, arg2, arg3);
|
||||
arg1->release();
|
||||
@@ -345,10 +342,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
arg1 = new Variant(JOYSTICK_JOYSTICK_ID, (void *) &proxy);
|
||||
|
||||
arg2 = new Variant(txt, strlen(txt));
|
||||
float value = e.jaxis.value / 32768.0f;
|
||||
if (fabsf(value) < 0.001f) value = 0.0f;
|
||||
if (value < -0.99f) value = -1.0f;
|
||||
if (value > 0.99f) value = 1.0f;
|
||||
float value = joystick::Joystick::clampval(e.caxis.value / 32768.0f);
|
||||
arg3 = new Variant((double) value);
|
||||
msg = new Message("gamepadaxis", arg1, arg2, arg3);
|
||||
arg1->release();
|
||||
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
static EnumMap<love::mouse::Mouse::Button, Uint8, love::mouse::Mouse::BUTTON_MAX_ENUM>::Entry buttonEntries[];
|
||||
static EnumMap<love::mouse::Mouse::Button, Uint8, love::mouse::Mouse::BUTTON_MAX_ENUM> buttons;
|
||||
|
||||
}; // System
|
||||
}; // Event
|
||||
|
||||
} // sdl
|
||||
} // event
|
||||
|
||||
@@ -276,8 +276,8 @@ void ParticleSystem::initParticle(Particle *p, float t)
|
||||
min = speedMin;
|
||||
max = speedMax;
|
||||
float speed = (float) rng.random(min, max);
|
||||
p->speed = love::Vector(cosf(p->direction), sinf(p->direction));
|
||||
p->speed *= speed;
|
||||
p->velocity = love::Vector(cosf(p->direction), sinf(p->direction));
|
||||
p->velocity *= speed;
|
||||
|
||||
p->linearAcceleration.x = (float) rng.random(linearAccelerationMin.x, linearAccelerationMax.x);
|
||||
p->linearAcceleration.y = (float) rng.random(linearAccelerationMin.y, linearAccelerationMax.y);
|
||||
@@ -302,7 +302,7 @@ void ParticleSystem::initParticle(Particle *p, float t)
|
||||
|
||||
p->angle = p->rotation;
|
||||
if (relativeRotation)
|
||||
p->angle += atan2f(p->speed.y, p->speed.x);
|
||||
p->angle += atan2f(p->velocity.y, p->velocity.x);
|
||||
|
||||
p->color = colors[0];
|
||||
}
|
||||
@@ -907,11 +907,11 @@ void ParticleSystem::update(float dt)
|
||||
// Resize tangential.
|
||||
tangential *= p->tangentialAcceleration;
|
||||
|
||||
// Update position.
|
||||
p->speed += (radial+tangential+p->linearAcceleration)*dt;
|
||||
// Update velocity.
|
||||
p->velocity += (radial + tangential + p->linearAcceleration) * dt;
|
||||
|
||||
// Modify position.
|
||||
ppos += p->speed * dt;
|
||||
ppos += p->velocity * dt;
|
||||
|
||||
p->position[0] = ppos.getX();
|
||||
p->position[1] = ppos.getY();
|
||||
@@ -924,7 +924,7 @@ void ParticleSystem::update(float dt)
|
||||
p->angle = p->rotation;
|
||||
|
||||
if (relativeRotation)
|
||||
p->angle += atan2f(p->speed.y, p->speed.x);
|
||||
p->angle += atan2f(p->velocity.y, p->velocity.x);
|
||||
|
||||
// Change size according to given intervals:
|
||||
// i = 0 1 2 3 n-1
|
||||
|
||||
@@ -516,7 +516,7 @@ protected:
|
||||
// Particles gravitate towards this point.
|
||||
love::Vector origin;
|
||||
|
||||
love::Vector speed;
|
||||
love::Vector velocity;
|
||||
love::Vector linearAcceleration;
|
||||
float radialAcceleration;
|
||||
float tangentialAcceleration;
|
||||
|
||||
@@ -111,7 +111,7 @@ int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, fl
|
||||
memcpy(sprite, texture->getVertices(), sizeof(Vertex) * 4);
|
||||
|
||||
// Transform.
|
||||
static Matrix t;
|
||||
Matrix t;
|
||||
t.setTransformation(x, y, a, sx, sy, ox, oy, kx, ky);
|
||||
t.transform(sprite, sprite, 4);
|
||||
|
||||
@@ -138,7 +138,7 @@ int SpriteBatch::addq(Quad *quad, float x, float y, float a, float sx, float sy,
|
||||
// Needed for colors.
|
||||
memcpy(sprite, quad->getVertices(), sizeof(Vertex) * 4);
|
||||
|
||||
static Matrix t;
|
||||
Matrix t;
|
||||
t.setTransformation(x, y, a, sx, sy, ox, oy, kx, ky);
|
||||
t.transform(sprite, sprite, 4);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace love
|
||||
namespace joystick
|
||||
{
|
||||
|
||||
float Joystick::clampval(float x) const
|
||||
float Joystick::clampval(float x)
|
||||
{
|
||||
if (fabsf(x) < 0.01)
|
||||
return 0.0f;
|
||||
|
||||
@@ -173,9 +173,7 @@ public:
|
||||
static bool getConstant(const char *in, InputType &out);
|
||||
static bool getConstant(InputType in, const char *&out);
|
||||
|
||||
protected:
|
||||
|
||||
float clampval(float x) const;
|
||||
static float clampval(float x);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -51,12 +51,11 @@ bool Keyboard::hasKeyRepeat() const
|
||||
|
||||
bool Keyboard::isDown(Key *keylist) const
|
||||
{
|
||||
const Uint8 *keystate = SDL_GetKeyboardState(0);
|
||||
std::map<Key, SDL_Keycode>::const_iterator it;
|
||||
const Uint8 *keystate = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
for (Key key = *keylist; key != KEY_MAX_ENUM; key = *(++keylist))
|
||||
{
|
||||
it = keys.find(key);
|
||||
auto it = keys.find(key);
|
||||
if (it != keys.end() && keystate[SDL_GetScancodeFromKey(it->second)])
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// Whether holding down a key triggers repeated key press events.
|
||||
// The real implementation is in love::event::sdl::Event::Convert.
|
||||
bool key_repeat;
|
||||
|
||||
static std::map<Key, SDL_Keycode> createKeyMap();
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace love
|
||||
namespace keyboard
|
||||
{
|
||||
|
||||
static Keyboard *instance = 0;
|
||||
static Keyboard *instance = nullptr;
|
||||
|
||||
int w_setKeyRepeat(lua_State *L)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_love_keyboard(lua_State *L)
|
||||
{
|
||||
if (instance == 0)
|
||||
if (instance == nullptr)
|
||||
{
|
||||
EXCEPT_GUARD(instance = new love::keyboard::sdl::Keyboard();)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace sdl
|
||||
{
|
||||
|
||||
Cursor::Cursor(image::ImageData *data, int hotx, int hoty)
|
||||
: cursor(0)
|
||||
: cursor(nullptr)
|
||||
, type(CURSORTYPE_IMAGE)
|
||||
, systemType(CURSOR_MAX_ENUM)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ Cursor::Cursor(image::ImageData *data, int hotx, int hoty)
|
||||
}
|
||||
|
||||
Cursor::Cursor(mouse::Cursor::SystemCursor cursortype)
|
||||
: cursor(0)
|
||||
: cursor(nullptr)
|
||||
, type(CURSORTYPE_SYSTEM)
|
||||
, systemType(cursortype)
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ const char *Mouse::getName() const
|
||||
}
|
||||
|
||||
Mouse::Mouse()
|
||||
: curCursor(0)
|
||||
: curCursor(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ void Mouse::setVisible(bool visible)
|
||||
|
||||
bool Mouse::isDown(Button *buttonlist) const
|
||||
{
|
||||
Uint32 buttonstate = SDL_GetMouseState(0, 0);
|
||||
Uint32 buttonstate = SDL_GetMouseState(nullptr, nullptr);
|
||||
|
||||
for (Button button = *buttonlist; button != BUTTON_MAX_ENUM; button = *(++buttonlist))
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ int w_Cursor_getType(lua_State *L)
|
||||
Cursor *cursor = luax_checkcursor(L, 1);
|
||||
|
||||
Cursor::CursorType ctype = cursor->getType();
|
||||
const char *typestr = 0;
|
||||
const char *typestr = nullptr;
|
||||
|
||||
if (ctype == Cursor::CURSORTYPE_IMAGE)
|
||||
mouse::Cursor::getConstant(ctype, typestr);
|
||||
|
||||
@@ -30,11 +30,11 @@ namespace love
|
||||
namespace mouse
|
||||
{
|
||||
|
||||
static Mouse *instance = 0;
|
||||
static Mouse *instance = nullptr;
|
||||
|
||||
int w_newCursor(lua_State *L)
|
||||
{
|
||||
Cursor *cursor = 0;
|
||||
Cursor *cursor = nullptr;
|
||||
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
|
||||
luax_convobj(L, 1, "image", "newImageData");
|
||||
@@ -212,7 +212,7 @@ static const lua_CFunction types[] =
|
||||
|
||||
extern "C" int luaopen_love_mouse(lua_State *L)
|
||||
{
|
||||
if (instance == 0)
|
||||
if (instance == nullptr)
|
||||
{
|
||||
EXCEPT_GUARD(instance = new love::mouse::sdl::Mouse();)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace love
|
||||
namespace system
|
||||
{
|
||||
|
||||
static System *instance = 0;
|
||||
static System *instance = nullptr;
|
||||
|
||||
int w_getOS(lua_State *L)
|
||||
{
|
||||
@@ -99,7 +99,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_love_system(lua_State *L)
|
||||
{
|
||||
if (instance == 0)
|
||||
if (instance == nullptr)
|
||||
{
|
||||
instance = new love::system::sdl::System();
|
||||
}
|
||||
@@ -111,7 +111,7 @@ extern "C" int luaopen_love_system(lua_State *L)
|
||||
w.name = "system";
|
||||
w.flags = MODULE_T;
|
||||
w.functions = functions;
|
||||
w.types = 0;
|
||||
w.types = nullptr;
|
||||
|
||||
return luax_register_module(L, w);
|
||||
}
|
||||
|
||||
@@ -26,13 +26,14 @@
|
||||
#include <string>
|
||||
|
||||
// LOVE
|
||||
#include <common/Variant.h>
|
||||
#include <thread/threads.h>
|
||||
#include "common/Variant.h"
|
||||
#include "threads.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace thread
|
||||
{
|
||||
|
||||
class Channel : public love::Object
|
||||
{
|
||||
// FOR WRAPPER USE ONLY
|
||||
@@ -40,8 +41,10 @@ friend void retainVariant(Channel *, Variant *);
|
||||
friend void releaseVariant(Channel *, Variant *);
|
||||
|
||||
public:
|
||||
|
||||
Channel();
|
||||
~Channel();
|
||||
|
||||
static Channel *getChannel(const std::string &name);
|
||||
|
||||
unsigned long push(Variant *var);
|
||||
@@ -56,6 +59,7 @@ public:
|
||||
void release();
|
||||
|
||||
private:
|
||||
|
||||
Channel(const std::string &name);
|
||||
void lockMutex();
|
||||
void unlockMutex();
|
||||
@@ -68,7 +72,9 @@ private:
|
||||
|
||||
unsigned long sent;
|
||||
unsigned long received;
|
||||
|
||||
}; // Channel
|
||||
|
||||
} // thread
|
||||
} // love
|
||||
|
||||
|
||||
@@ -25,15 +25,16 @@
|
||||
#include <string>
|
||||
|
||||
// LOVE
|
||||
#include <common/Data.h>
|
||||
#include <common/Object.h>
|
||||
#include <common/Variant.h>
|
||||
#include <thread/threads.h>
|
||||
#include "common/Data.h"
|
||||
#include "common/Object.h"
|
||||
#include "common/Variant.h"
|
||||
#include "threads.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace thread
|
||||
{
|
||||
|
||||
class LuaThread : public love::Object, public Threadable
|
||||
{
|
||||
public:
|
||||
@@ -55,7 +56,9 @@ private:
|
||||
|
||||
Variant **args;
|
||||
int nargs;
|
||||
};
|
||||
|
||||
}; // LuaThread
|
||||
|
||||
} // thread
|
||||
} // love
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#define LOVE_THREAD_THREAD_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include <common/Object.h>
|
||||
#include "common/runtime.h"
|
||||
#include "common/Object.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define LOVE_THREAD_SDL_THREAD_H
|
||||
|
||||
// LOVE
|
||||
#include <thread/Thread.h>
|
||||
#include "thread/Thread.h"
|
||||
#include "threads.h"
|
||||
|
||||
// SDL
|
||||
@@ -34,6 +34,7 @@ namespace thread
|
||||
{
|
||||
namespace sdl
|
||||
{
|
||||
|
||||
class Thread : public thread::Thread
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace thread
|
||||
{
|
||||
namespace sdl
|
||||
{
|
||||
|
||||
Mutex::Mutex()
|
||||
{
|
||||
mutex = SDL_CreateMutex();
|
||||
@@ -81,6 +82,11 @@ bool Conditional::wait(thread::Mutex *_mutex, int timeout)
|
||||
|
||||
} // sdl
|
||||
|
||||
|
||||
/**
|
||||
* Implementations of the functions declared in src/modules/threads.h.
|
||||
**/
|
||||
|
||||
thread::Mutex *newMutex()
|
||||
{
|
||||
return new sdl::Mutex();
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#ifndef LOVE_THREAD_SDL_THREADS_H
|
||||
#define LOVE_THREAD_SDL_THREADS_H
|
||||
|
||||
#include <common/config.h>
|
||||
#include <thread/threads.h>
|
||||
#include "common/config.h"
|
||||
#include "thread/threads.h"
|
||||
|
||||
#include <SDL_thread.h>
|
||||
|
||||
@@ -32,11 +32,13 @@ namespace thread
|
||||
{
|
||||
namespace sdl
|
||||
{
|
||||
|
||||
class Conditional;
|
||||
|
||||
class Mutex : public thread::Mutex
|
||||
{
|
||||
public:
|
||||
|
||||
Mutex();
|
||||
~Mutex();
|
||||
|
||||
@@ -44,15 +46,18 @@ public:
|
||||
void unlock();
|
||||
|
||||
private:
|
||||
|
||||
SDL_mutex *mutex;
|
||||
Mutex(const Mutex&/* mutex*/) {}
|
||||
|
||||
friend class Conditional;
|
||||
};
|
||||
|
||||
}; // Mutex
|
||||
|
||||
class Conditional : public thread::Conditional
|
||||
{
|
||||
public:
|
||||
|
||||
Conditional();
|
||||
~Conditional();
|
||||
|
||||
@@ -61,8 +66,10 @@ public:
|
||||
bool wait(thread::Mutex *mutex, int timeout=-1);
|
||||
|
||||
private:
|
||||
|
||||
SDL_cond *cond;
|
||||
};
|
||||
|
||||
}; // Conditional
|
||||
|
||||
} // sdl
|
||||
} // thread
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef LOVE_THREAD_THREADS_H
|
||||
#define LOVE_THREAD_THREADS_H
|
||||
|
||||
#include <common/config.h>
|
||||
#include "common/config.h"
|
||||
#include "Thread.h"
|
||||
|
||||
namespace love
|
||||
|
||||
Reference in New Issue
Block a user