It's now possible to build each module individually (as a DLL).

This commit is contained in:
rude
2009-08-04 19:57:14 +02:00
parent 524ef5e118
commit 8e681b4204
59 changed files with 5315 additions and 400 deletions
+1
View File
@@ -22,6 +22,7 @@
#define LOVE_DATA_H
// LOVE
#include "config.h"
#include "Object.h"
namespace love
+3
View File
@@ -21,6 +21,9 @@
#ifndef LOVE_OBJECT_H
#define LOVE_OBJECT_H
// LOVE
#include "config.h"
namespace love
{
/**
+7 -16
View File
@@ -21,9 +21,6 @@
#ifndef LOVE_CONFIG_H
#define LOVE_CONFIG_H
// STD
#include <string>
// Platform stuff.
#if defined(WIN32) || defined(_WIN32)
# define LOVE_WINDOWS 1
@@ -38,26 +35,20 @@
# define LOVE_MACOS 1
#endif
// Warnings.
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
// Build.
#define LOVE_BUILD_EXE 1
#define LOVE_BUILD_DLL 0
// Version stuff.
const int LOVE_VERSION = 060;
const int LOVE_VERSION_COMPATIBILITY[] = { 0 };
const std::string LOVE_VERSION_STR = "0.6.0";
const std::string LOVE_VERSION_CODENAME = "Jiggly Juice";
const std::string LOVE_VERSION_FULL_STR = std::string("LOVE ") + LOVE_VERSION_STR + std::string(" (") + LOVE_VERSION_CODENAME + std::string(")");
// DLL-stuff.
#ifdef LOVE_WINDOWS
# ifndef DECLSPEC
# define DECLSPEC __declspec(dllexport)
# endif
# define LOVE_EXPORT __declspec(dllexport)
#else
# ifndef DECLSPEC
# define DECLSPEC
# endif
# define LOVE_EXPORT
#endif
#endif // LOVE_CONFIG_H
-279
View File
@@ -1,279 +0,0 @@
/**
* 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 "constants.h"
#include <filesystem/File.h>
#include <event/Event.h>
#include <mouse/Mouse.h>
#include <keyboard/Keyboard.h>
#include <joystick/Joystick.h>
#include <graphics/Graphics.h>
#include <graphics/Image.h>
#include <physics/Shape.h>
#include <physics/Joint.h>
namespace love
{
// Constants.
const lua_constant_entry lua_constants[] =
{
{ "key_unknown", 0 },
{ "key_first", 0 },
{ "key_backspace", 8 },
{ "key_tab", 9 },
{ "key_clear", 12 },
{ "key_return", 13 },
{ "key_pause", 19 },
{ "key_escape", 27 },
{ "key_space", 32 },
{ "key_exclaim", 33 },
{ "key_quotedbl", 34 },
{ "key_hash", 35 },
{ "key_dollar", 36 },
{ "key_ampersand", 38 },
{ "key_quote", 39 },
{ "key_leftparen", 40 },
{ "key_rightparen", 41 },
{ "key_asterisk", 42 },
{ "key_plus", 43 },
{ "key_comma", 44 },
{ "key_minus", 45 },
{ "key_period", 46 },
{ "key_slash", 47 },
{ "key_0", 48 },
{ "key_1", 49 },
{ "key_2", 50 },
{ "key_3", 51 },
{ "key_4", 52 },
{ "key_5", 53 },
{ "key_6", 54 },
{ "key_7", 55 },
{ "key_8", 56 },
{ "key_9", 57 },
{ "key_colon", 58 },
{ "key_semicolon", 59 },
{ "key_less", 60 },
{ "key_equals", 61 },
{ "key_greater", 62 },
{ "key_question", 63 },
{ "key_at", 64 },
{ "key_leftbracket", 91 },
{ "key_backslash", 92 },
{ "key_rightbracket", 93 },
{ "key_caret", 94 },
{ "key_underscore", 95 },
{ "key_backquote", 96 },
{ "key_a", 97 },
{ "key_b", 98 },
{ "key_c", 99 },
{ "key_d", 100 },
{ "key_e", 101 },
{ "key_f", 102 },
{ "key_g", 103 },
{ "key_h", 104 },
{ "key_i", 105 },
{ "key_j", 106 },
{ "key_k", 107 },
{ "key_l", 108 },
{ "key_m", 109 },
{ "key_n", 110 },
{ "key_o", 111 },
{ "key_p", 112 },
{ "key_q", 113 },
{ "key_r", 114 },
{ "key_s", 115 },
{ "key_t", 116 },
{ "key_u", 117 },
{ "key_v", 118 },
{ "key_w", 119 },
{ "key_x", 120 },
{ "key_y", 121 },
{ "key_z", 122 },
{ "key_delete", 127 },
{ "key_kp0", 256 },
{ "key_kp1", 257 },
{ "key_kp2", 258 },
{ "key_kp3", 259 },
{ "key_kp4", 260 },
{ "key_kp5", 261 },
{ "key_kp6", 262 },
{ "key_kp7", 263 },
{ "key_kp8", 264 },
{ "key_kp9", 265 },
{ "key_kp_period", 266 },
{ "key_kp_divide", 267 },
{ "key_kp_multiply", 268 },
{ "key_kp_minus", 269 },
{ "key_kp_plus", 270 },
{ "key_kp_enter", 271 },
{ "key_kp_equals", 272 },
{ "key_up", 273 },
{ "key_down", 274 },
{ "key_right", 275 },
{ "key_left", 276 },
{ "key_insert", 277 },
{ "key_home", 278 },
{ "key_end", 279 },
{ "key_pageup", 280 },
{ "key_pagedown", 281 },
{ "key_f1", 282 },
{ "key_f2", 283 },
{ "key_f3", 284 },
{ "key_f4", 285 },
{ "key_f5", 286 },
{ "key_f6", 287 },
{ "key_f7", 288 },
{ "key_f8", 289 },
{ "key_f9", 290 },
{ "key_f10", 291 },
{ "key_f11", 292 },
{ "key_f12", 293 },
{ "key_f13", 294 },
{ "key_f14", 295 },
{ "key_f15", 296 },
{ "key_numlock", 300 },
{ "key_capslock", 301 },
{ "key_scrollock", 302 },
{ "key_rshift", 303 },
{ "key_lshift", 304 },
{ "key_rctrl", 305 },
{ "key_lctrl", 306 },
{ "key_ralt", 307 },
{ "key_lalt", 308 },
{ "key_rmeta", 309 },
{ "key_lmeta", 310 },
{ "key_lsuper", 311 },
{ "key_rsuper", 312 },
{ "key_mode", 313 },
{ "key_compose", 314 },
{ "key_help", 315 },
{ "key_print", 316 },
{ "key_sysreq", 317 },
{ "key_break", 318 },
{ "key_menu", 319 },
{ "key_power", 320 },
{ "key_euro", 321 },
{ "key_undo", 322 },
{ "key_repeat_delay", keyboard::Keyboard::KEY_REPEAT_DELAY },
{ "key_repeat_interval", keyboard::Keyboard::KEY_REPEAT_INTERVAL },
{ "mouse_left", mouse::Mouse::MOUSE_LEFT },
{ "mouse_middle", mouse::Mouse::MOUSE_MIDDLE },
{ "mouse_right", mouse::Mouse::MOUSE_RIGHT },
{ "mouse_wheelup", mouse::Mouse::MOUSE_WHEELUP },
{ "mouse_wheeldown", mouse::Mouse::MOUSE_WHEELDOWN },
{ "align_left", graphics::Graphics::ALIGN_LEFT },
{ "align_right", graphics::Graphics::ALIGN_RIGHT },
{ "align_center", graphics::Graphics::ALIGN_CENTER },
{ "blend_alpha", graphics::Graphics::BLEND_ALPHA },
{ "blend_additive", graphics::Graphics::BLEND_ADDITIVE },
{ "color_replace", graphics::Graphics::COLOR_REPLACE },
{ "color_modulate", graphics::Graphics::COLOR_MODULATE },
{ "file_closed", filesystem::File::CLOSED },
{ "file_read", filesystem::File::READ },
{ "file_write", filesystem::File::WRITE },
{ "file_append", filesystem::File::APPEND },
{ "draw_line", graphics::Graphics::DRAW_LINE },
{ "draw_fill", graphics::Graphics::DRAW_FILL },
{ "line_smooth", graphics::Graphics::LINE_SMOOTH },
{ "line_rough", graphics::Graphics::LINE_ROUGH },
{ "point_smooth", graphics::Graphics::POINT_SMOOTH },
{ "point_rough", graphics::Graphics::POINT_ROUGH },
{ "shape_circle", physics::Shape::SHAPE_CIRCLE },
{ "shape_polygon", physics::Shape::SHAPE_POLYGON },
{ "joint_distance", physics::Joint::JOINT_DISTANCE },
{ "joint_revolute", physics::Joint::JOINT_REVOLUTE },
{ "joint_prismatic", physics::Joint::JOINT_PRISMATIC },
{ "joint_mouse", physics::Joint::JOINT_MOUSE },
{ "joint_pulley", physics::Joint::JOINT_PULLEY },
{ "joint_gear", physics::Joint::JOINT_GEAR },
{ "joystick_axis_horizontal", joystick::Joystick::JOYSTICK_AXIS_HORIZONTAL },
{ "joystick_axis_vertical", joystick::Joystick::JOYSTICK_AXIS_VERITCAL },
{ "joystick_hat_centered", joystick::Joystick::JOYSTICK_HAT_CENTERED },
{ "joystick_hat_up", joystick::Joystick::JOYSTICK_HAT_UP },
{ "joystick_hat_right", joystick::Joystick::JOYSTICK_HAT_RIGHT },
{ "joystick_hat_down", joystick::Joystick::JOYSTICK_HAT_DOWN },
{ "joystick_hat_left", joystick::Joystick::JOYSTICK_HAT_LEFT },
{ "joystick_hat_rightup", joystick::Joystick::JOYSTICK_HAT_RIGHTUP },
{ "joystick_hat_rightdown", joystick::Joystick::JOYSTICK_HAT_RIGHTDOWN },
{ "joystick_hat_leftup", joystick::Joystick::JOYSTICK_HAT_LEFTUP },
{ "joystick_hat_leftdown", joystick::Joystick::JOYSTICK_HAT_LEFTDOWN },
{ "event_keypressed", event::Event::EVENT_KEYDOWN },
{ "event_keyreleased", event::Event::EVENT_KEYUP },
{ "event_mousepressed", event::Event::EVENT_MOUSEBUTTONDOWN },
{ "event_mousereleased", event::Event::EVENT_MOUSEBUTTONUP },
{ "event_joystickpressed", event::Event::EVENT_JOYBUTTONDOWN },
{ "event_joystickreleased", event::Event::EVENT_JOYBUTTONUP },
{ "event_quit", event::Event::EVENT_QUIT },
{ "filter_linear", graphics::Image::FILTER_LINEAR },
{ "filter_nearest", graphics::Image::FILTER_NEAREST },
{ "wrap_clamp", graphics::Image::WRAP_CLAMP },
{ "wrap_repeat", graphics::Image::WRAP_REPEAT },
/**
// Vertex buffer geometry types.
{ "type_points", TYPE_POINTS },
{ "type_lines", TYPE_LINES },
{ "type_line_strip", TYPE_LINE_STRIP },
{ "type_triangles", TYPE_TRIANGLES },
{ "type_triangle_strip", TYPE_TRIANGLE_STRIP },
{ "type_triangle_fan", TYPE_TRIANGLE_FAN },
{ "type_num", TYPE_NUM },
// Vertex buffer usage hints.
{ "usage_array", USAGE_ARRAY },
{ "usage_dynamic", USAGE_DYNAMIC },
{ "usage_static", USAGE_STATIC },
{ "usage_stream", USAGE_STREAM },
{ "usage_num", USAGE_NUM },
**/
{0, 0}, // Indicates the end
}; // lua constants
} // love
+69 -5
View File
@@ -103,8 +103,7 @@ namespace love
int luax_register_gc(lua_State * L, const char * mname, Module * m)
{
lua_getglobal(L, "love");
lua_getfield(L, -1, "_fin");
luax_getregistry(L, REGISTRY_GC);
userdata * u = (userdata *)lua_newuserdata(L, sizeof(userdata));
u->own = true;
@@ -117,7 +116,7 @@ namespace love
lua_setfield(L, -2, mname);
lua_pop(L, 2); // _fin, love
lua_pop(L, 1); // Registry
return 0;
}
@@ -155,10 +154,20 @@ namespace love
return 0;
}
int luax_register_module(lua_State * L, const luaL_Reg * fn, const lua_CFunction * types, const char * name)
int luax_register_module(lua_State * L, const luaL_Reg * fn, const lua_CFunction * types, const LuaConstant * constants, const char * name)
{
// Gets the love table.
lua_getglobal(L, "love");
luax_insistglobal(L, "love");
// Install constants.
if(constants != 0)
{
for(int i = 0; constants[i].name != 0; i++)
{
lua_pushinteger(L, constants[i].value);
lua_setfield(L, -2, constants[i].name);
}
}
// Create new table for module.
lua_newtable(L);
@@ -281,4 +290,59 @@ namespace love
return luax_convobj(L, idx, "filesystem", "read");
}
int luax_insist(lua_State * L, int idx, const char * k)
{
lua_getfield(L, idx, k);
// Create if necessary.
if(!lua_istable(L, -1))
{
lua_pop(L, 1); // Pop the non-table.
lua_newtable(L);
lua_pushvalue(L, -1); // Duplicate the table to leave on top.
lua_setfield(L, -3, k); // k[idx] = table
}
return 1;
}
int luax_insistglobal(lua_State * L, const char * k)
{
lua_getglobal(L, k);
if(!lua_istable(L, -1))
{
lua_pop(L, 1); // Pop the non-table.
lua_newtable(L);
lua_pushvalue(L, -1);
lua_setglobal(L, k);
}
return 1;
}
int luax_insistlove(lua_State * L, const char * k)
{
luax_insistglobal(L, "love");
luax_insist(L, -1, k);
// The love table should be replaced with the top stack
// item. Only the reqested table should remain on the stack.
lua_replace(L, -2);
return 1;
}
int luax_getregistry(lua_State * L, Registry r)
{
switch(r)
{
case REGISTRY_GC:
return luax_insistlove(L, "_gc");
default:
return luaL_error(L, "Attempted to use invalid registry.");
}
}
} // love
+22 -1
View File
@@ -35,6 +35,18 @@ namespace love
{
class Module;
enum Registry
{
REGISTRY_GC = 1,
};
// Type used for storing constants in an array.
struct LuaConstant
{
const char * name;
int value;
};
void luax_printstack(lua_State * L);
bool luax_toboolean(lua_State * L, int idx);
void luax_pushboolean(lua_State * L, bool b);
@@ -49,7 +61,7 @@ namespace love
const char * provides, const char * desc, const char * author,
lua_CFunction open);
int luax_register_module(lua_State * L, const luaL_Reg * fn, const lua_CFunction * types, const char * name);
int luax_register_module(lua_State * L, const luaL_Reg * fn, const lua_CFunction * types, const LuaConstant * constants, const char * name);
int luax_preload(lua_State * L, lua_CFunction f, const char * name);
int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * fn);
@@ -79,6 +91,15 @@ namespace love
**/
int luax_strtofile(lua_State * L, int idx);
int luax_insist(lua_State * L, int idx, const char * k);
int luax_insistglobal(lua_State * L, const char * k);
int luax_insistlove(lua_State * L, const char * k);
/**
* Gets (creates if needed) the specified Registry.
**/
int luax_getregistry(lua_State * L, Registry r);
template <typename T>
T * luax_checktype(lua_State * L, int idx, const char * tname, love::bits type)
{
+11 -15
View File
@@ -18,21 +18,17 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
#ifndef LOVE_CONSTANTS_H
#define LOVE_CONSTANTS_H
#ifndef LOVE_VERSION_H
#define LOVE_VERSION_H
namespace love
{
// Type used for storing constants
// in an array.
typedef struct lua_constant_entry
{
const char * name;
int value;
} lua_constant_entry;
// STD
#include <string>
extern const lua_constant_entry lua_constants[];
// Version stuff.
const int LOVE_VERSION = 060;
const int LOVE_VERSION_COMPATIBILITY[] = { 0 };
const std::string LOVE_VERSION_STR = "0.6.0";
const std::string LOVE_VERSION_CODENAME = "Jiggly Juice";
const std::string LOVE_VERSION_FULL_STR = std::string("LOVE ") + LOVE_VERSION_STR + std::string(" (") + LOVE_VERSION_CODENAME + std::string(")");
} // love
#endif // LOVE_CONSTANTS_H
#endif // LOVE_VERSION_H