Finally abstracted constants properly. Changed how the event module works; wasn't really abstract before. Removed libs we're not going to use: native, signal.

This commit is contained in:
rude
2009-10-10 11:11:04 +02:00
parent 0a2ae705dd
commit 87e3c4131c
101 changed files with 3225 additions and 33496 deletions
+54
View File
@@ -0,0 +1,54 @@
/**
* Copyright (c) 2006-2009 LOVE Development Team
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
**/
#include "Joint.h"
namespace love
{
namespace physics
{
Joint::~Joint()
{
}
bool Joint::getConstant(const char * in, Type & out)
{
return types.find(in, out);
}
bool Joint::getConstant(Type in, const char *& out)
{
return types.find(in, out);
}
StringMap<Joint::Type, Joint::JOINT_MAX_ENUM>::Entry Joint::typeEntries[] =
{
{"circle", Joint::JOINT_DISTANCE},
{"revolute", Joint::JOINT_REVOLUTE},
{"prismatic", Joint::JOINT_PRISMATIC},
{"mouse", Joint::JOINT_MOUSE},
{"pulley", Joint::JOINT_PULLEY},
{"gear", Joint::JOINT_GEAR},
};
StringMap<Joint::Type, Joint::JOINT_MAX_ENUM> Joint::types(Joint::typeEntries, sizeof(Joint::typeEntries));
} // physics
} // love
+14 -3
View File
@@ -23,6 +23,7 @@
// LOVE
#include <common/Object.h>
#include <common/StringMap.h>
namespace love
{
@@ -32,18 +33,28 @@ namespace physics
{
public:
enum JointType
enum Type
{
JOINT_INVALID,
JOINT_DISTANCE,
JOINT_REVOLUTE,
JOINT_PRISMATIC,
JOINT_MOUSE,
JOINT_PULLEY,
JOINT_GEAR
JOINT_GEAR,
JOINT_MAX_ENUM
};
virtual ~Joint(){}
virtual ~Joint();
static bool getConstant(const char * in, Type & out);
static bool getConstant(Type in, const char *& out);
private:
static StringMap<Type, JOINT_MAX_ENUM>::Entry typeEntries[];
static StringMap<Type, JOINT_MAX_ENUM> types;
};
} // physics
+50
View File
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2006-2009 LOVE Development Team
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
**/
#include "Shape.h"
namespace love
{
namespace physics
{
Shape::~Shape()
{
}
bool Shape::getConstant(const char * in, Type & out)
{
return types.find(in, out);
}
bool Shape::getConstant(Type in, const char *& out)
{
return types.find(in, out);
}
StringMap<Shape::Type, Shape::SHAPE_MAX_ENUM>::Entry Shape::typeEntries[] =
{
{"circle", Shape::SHAPE_CIRCLE},
{"polygon", Shape::SHAPE_POLYGON},
};
StringMap<Shape::Type, Shape::SHAPE_MAX_ENUM> Shape::types(Shape::typeEntries, sizeof(Shape::typeEntries));
} // physics
} // love
+13 -2
View File
@@ -23,6 +23,7 @@
// LOVE
#include <common/Object.h>
#include <common/StringMap.h>
namespace love
{
@@ -32,13 +33,23 @@ namespace physics
{
public:
enum ShapeType
enum Type
{
SHAPE_INVALID,
SHAPE_CIRCLE,
SHAPE_POLYGON,
SHAPE_MAX_ENUM
};
virtual ~Shape(){}
virtual ~Shape();
static bool getConstant(const char * in, Type & out);
static bool getConstant(Type in, const char *& out);
private:
static StringMap<Type, SHAPE_MAX_ENUM>::Entry typeEntries[];
static StringMap<Type, SHAPE_MAX_ENUM> types;
};
} // physics
+2 -2
View File
@@ -56,7 +56,7 @@ namespace box2d
joint = 0;
}
int Joint::getType() const
Joint::Type Joint::getType() const
{
switch(joint->GetType())
{
@@ -73,7 +73,7 @@ namespace box2d
case e_gearJoint:
return JOINT_GEAR;
default:
return -1;
return JOINT_INVALID;
}
}
+1 -1
View File
@@ -81,7 +81,7 @@ namespace box2d
/**
* Gets the type of joint.
**/
int getType() const;
Type getType() const;
/**
* Gets the anchor positions of the Joint in world
+2 -2
View File
@@ -50,7 +50,7 @@ namespace box2d
data = 0;
}
int Shape::getType() const
Shape::Type Shape::getType() const
{
switch(shape->GetType())
{
@@ -59,7 +59,7 @@ namespace box2d
case e_polygonShape:
return SHAPE_POLYGON;
default:
return -1;
return SHAPE_INVALID;
}
}
+1 -1
View File
@@ -86,7 +86,7 @@ namespace box2d
* Gets the type of Shape. Useful for
* debug drawing.
**/
int getType() const;
Type getType() const;
/**
* Sets the friction of the Shape.
+4 -1
View File
@@ -20,6 +20,7 @@
// LOVE
#include "wrap_Joint.h"
#include <common/StringMap.h>
namespace love
{
@@ -35,7 +36,9 @@ namespace box2d
int w_Joint_getType(lua_State * L)
{
Joint * t = luax_checkjoint(L, 1);
lua_pushinteger(L, t->getType());
const char * type = "";
Joint::getConstant(t->getType(), type);
lua_pushstring(L, type);
return 1;
}
@@ -236,20 +236,6 @@ namespace box2d
0
};
// List of constants.
static const Constant constants[] = {
{ "shape_circle", Shape::SHAPE_CIRCLE },
{ "shape_polygon", Shape::SHAPE_POLYGON },
{ "joint_distance", Joint::JOINT_DISTANCE },
{ "joint_revolute", Joint::JOINT_REVOLUTE },
{ "joint_prismatic", Joint::JOINT_PRISMATIC },
{ "joint_mouse", Joint::JOINT_MOUSE },
{ "joint_pulley", Joint::JOINT_PULLEY },
{ "joint_gear", Joint::JOINT_GEAR },
{ 0, 0 }
};
int luaopen_love_physics(lua_State * L)
{
if(instance == 0)
@@ -270,7 +256,6 @@ namespace box2d
w.flags = MODULE_T;
w.functions = functions;
w.types = types;
w.constants = constants;
return luax_register_module(L, w);
}
+4 -1
View File
@@ -19,6 +19,7 @@
**/
#include "wrap_Shape.h"
#include <common/StringMap.h>
namespace love
{
@@ -34,7 +35,9 @@ namespace box2d
int w_Shape_getType(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
lua_pushinteger(L, t->getType());
const char * type = "";
Shape::getConstant(t->getType(), type);
lua_pushstring(L, type);
return 1;
}