mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.
--HG-- branch : minor
This commit is contained in:
@@ -101,7 +101,6 @@ Variant::Variant(love::Type udatatype, void *userdata)
|
||||
if (udatatype != INVALID_ID)
|
||||
{
|
||||
Proxy *p = (Proxy *) userdata;
|
||||
flags = p->flags;
|
||||
data.userdata = p->object;
|
||||
p->object->retain();
|
||||
}
|
||||
@@ -223,11 +222,7 @@ void Variant::toLua(lua_State *L)
|
||||
break;
|
||||
case FUSERDATA:
|
||||
if (udatatype != INVALID_ID)
|
||||
{
|
||||
const char *name = NULL;
|
||||
love::types.find(udatatype, name);
|
||||
luax_pushtype(L, name, flags, (love::Object *) data.userdata);
|
||||
}
|
||||
luax_pushtype(L, udatatype, (love::Object *) data.userdata);
|
||||
else
|
||||
lua_pushlightuserdata(L, data.userdata);
|
||||
// I know this is not the same
|
||||
|
||||
@@ -76,7 +76,6 @@ public:
|
||||
|
||||
private:
|
||||
love::Type udatatype;
|
||||
bits flags;
|
||||
|
||||
}; // Variant
|
||||
} // love
|
||||
|
||||
+20
-113
@@ -56,7 +56,7 @@ static int w__typeOf(lua_State *L)
|
||||
{
|
||||
Proxy *p = (Proxy *)lua_touserdata(L, 1);
|
||||
Type t = luax_type(L, 2);
|
||||
luax_pushboolean(L, p->flags[t]);
|
||||
luax_pushboolean(L, typeFlags[p->type][t]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ int luax_register_module(lua_State *L, const WrappedModule &m)
|
||||
|
||||
Proxy *p = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
|
||||
p->object = m.module;
|
||||
p->flags = m.flags;
|
||||
p->type = m.type;
|
||||
|
||||
luaL_newmetatable(L, m.module->getName());
|
||||
lua_pushvalue(L, -1);
|
||||
@@ -254,12 +254,12 @@ int luax_preload(lua_State *L, lua_CFunction f, const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luax_register_type(lua_State *L, const char *tname, const luaL_Reg *f)
|
||||
int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f)
|
||||
{
|
||||
// Verify that this type name has a matching Type ID and type name mapping.
|
||||
love::Type ltype;
|
||||
if (!love::getType(tname, ltype))
|
||||
printf("Missing type entry for type name: %s\n", tname);
|
||||
const char *tname = "Invalid";
|
||||
if (!love::getType(type, tname))
|
||||
printf("Missing type name entry for type ID %d\n", type);
|
||||
|
||||
// Get the place for storing and re-using instantiated love types.
|
||||
luax_getregistry(L, REGISTRY_TYPES);
|
||||
@@ -374,20 +374,23 @@ int luax_register_searcher(lua_State *L, lua_CFunction f, int pos)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void luax_rawnewtype(lua_State *L, const char *name, bits flags, love::Object *object)
|
||||
void luax_rawnewtype(lua_State *L, love::Type type, love::Object *object)
|
||||
{
|
||||
Proxy *u = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
|
||||
|
||||
object->retain();
|
||||
|
||||
u->object = object;
|
||||
u->flags = flags;
|
||||
u->type = type;
|
||||
|
||||
const char *name = "Invalid";
|
||||
getType(type, name);
|
||||
|
||||
luaL_newmetatable(L, name);
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
|
||||
void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *object)
|
||||
void luax_pushtype(lua_State *L, love::Type type, love::Object *object)
|
||||
{
|
||||
if (object == nullptr)
|
||||
{
|
||||
@@ -402,11 +405,11 @@ void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *obj
|
||||
if (!lua_istable(L, -1))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
return luax_rawnewtype(L, name, flags, object);
|
||||
return luax_rawnewtype(L, type, object);
|
||||
}
|
||||
|
||||
// Get the value of lovetypes[object] on the stack.
|
||||
lua_pushlightuserdata(L, (void *) object);
|
||||
lua_pushlightuserdata(L, object);
|
||||
lua_gettable(L, -2);
|
||||
|
||||
// If the Proxy userdata isn't in the instantiated types table yet, add it.
|
||||
@@ -414,9 +417,9 @@ void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *obj
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
|
||||
luax_rawnewtype(L, name, flags, object);
|
||||
luax_rawnewtype(L, type, object);
|
||||
|
||||
lua_pushlightuserdata(L, (void *) object);
|
||||
lua_pushlightuserdata(L, object);
|
||||
lua_pushvalue(L, -2);
|
||||
|
||||
// lovetypes[object] = Proxy.
|
||||
@@ -429,12 +432,13 @@ void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *obj
|
||||
// Keep the Proxy userdata on the stack.
|
||||
}
|
||||
|
||||
bool luax_istype(lua_State *L, int idx, love::bits type)
|
||||
bool luax_istype(lua_State *L, int idx, love::Type type)
|
||||
{
|
||||
if (lua_type(L, idx) != LUA_TUSERDATA)
|
||||
return false;
|
||||
|
||||
return ((((Proxy *)lua_touserdata(L, idx))->flags & type) == type);
|
||||
Proxy *p = (Proxy *) lua_touserdata(L, idx);
|
||||
return typeFlags[p->type][type];
|
||||
}
|
||||
|
||||
int luax_getfunction(lua_State *L, const char *mod, const char *fn)
|
||||
@@ -624,107 +628,10 @@ extern "C" int luax_typerror(lua_State *L, int narg, const char *tname)
|
||||
return luaL_argerror(L, narg, msg);
|
||||
}
|
||||
|
||||
StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
|
||||
{
|
||||
{"Invalid", INVALID_ID},
|
||||
|
||||
{"Object", OBJECT_ID},
|
||||
{"Data", DATA_ID},
|
||||
{"Module", MODULE_ID},
|
||||
|
||||
// Filesystem
|
||||
{"File", FILESYSTEM_FILE_ID},
|
||||
{"DroppedFile", FILESYSTEM_DROPPED_FILE_ID},
|
||||
{"FileData", FILESYSTEM_FILE_DATA_ID},
|
||||
|
||||
// Font
|
||||
{"GlyphData", FONT_GLYPH_DATA_ID},
|
||||
{"Rasterizer", FONT_RASTERIZER_ID},
|
||||
|
||||
// Graphics
|
||||
{"Drawable", GRAPHICS_DRAWABLE_ID},
|
||||
{"Texture", GRAPHICS_TEXTURE_ID},
|
||||
{"Image", GRAPHICS_IMAGE_ID},
|
||||
{"Quad", GRAPHICS_QUAD_ID},
|
||||
{"Font", GRAPHICS_FONT_ID},
|
||||
{"ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_ID},
|
||||
{"SpriteBatch", GRAPHICS_SPRITE_BATCH_ID},
|
||||
{"Canvas", GRAPHICS_CANVAS_ID},
|
||||
{"Shader", GRAPHICS_SHADER_ID},
|
||||
{"Mesh", GRAPHICS_MESH_ID},
|
||||
{"Text", GRAPHICS_TEXT_ID},
|
||||
|
||||
// Image
|
||||
{"ImageData", IMAGE_IMAGE_DATA_ID},
|
||||
{"CompressedData", IMAGE_COMPRESSED_DATA_ID},
|
||||
|
||||
// Joystick
|
||||
{"Joystick", JOYSTICK_JOYSTICK_ID},
|
||||
|
||||
// Math
|
||||
{"RandomGenerator", MATH_RANDOM_GENERATOR_ID},
|
||||
{"BezierCurve", MATH_BEZIER_CURVE_ID},
|
||||
|
||||
// Audio
|
||||
{"Source", AUDIO_SOURCE_ID},
|
||||
|
||||
// Sound
|
||||
{"SoundData", SOUND_SOUND_DATA_ID},
|
||||
{"Decoder", SOUND_DECODER_ID},
|
||||
|
||||
// Mouse
|
||||
{"Cursor", MOUSE_CURSOR_ID},
|
||||
|
||||
// Physics
|
||||
{"World", PHYSICS_WORLD_ID},
|
||||
{"Contact", PHYSICS_CONTACT_ID},
|
||||
{"Body", PHYSICS_BODY_ID},
|
||||
{"Fixture", PHYSICS_FIXTURE_ID},
|
||||
{"Shape", PHYSICS_SHAPE_ID},
|
||||
{"CircleShape", PHYSICS_CIRCLE_SHAPE_ID},
|
||||
{"PolygonShape", PHYSICS_POLYGON_SHAPE_ID},
|
||||
{"EdgeShape", PHYSICS_EDGE_SHAPE_ID},
|
||||
{"ChainShape", PHYSICS_CHAIN_SHAPE_ID},
|
||||
{"Joint", PHYSICS_JOINT_ID},
|
||||
{"MouseJoint", PHYSICS_MOUSE_JOINT_ID},
|
||||
{"DistanceJoint", PHYSICS_DISTANCE_JOINT_ID},
|
||||
{"PrismaticJoint", PHYSICS_PRISMATIC_JOINT_ID},
|
||||
{"RevoluteJoint", PHYSICS_REVOLUTE_JOINT_ID},
|
||||
{"PulleyJoint", PHYSICS_PULLEY_JOINT_ID},
|
||||
{"GearJoint", PHYSICS_GEAR_JOINT_ID},
|
||||
{"FrictionJoint", PHYSICS_FRICTION_JOINT_ID},
|
||||
{"WeldJoint", PHYSICS_WELD_JOINT_ID},
|
||||
{"RopeJoint", PHYSICS_ROPE_JOINT_ID},
|
||||
{"WheelJoint", PHYSICS_WHEEL_JOINT_ID},
|
||||
{"MotorJoint", PHYSICS_MOTOR_JOINT_ID},
|
||||
|
||||
// Thread
|
||||
{"Thread", THREAD_THREAD_ID},
|
||||
{"Channel", THREAD_CHANNEL_ID},
|
||||
|
||||
// The modules themselves. Only add abstracted modules here.
|
||||
{"filesystem", MODULE_FILESYSTEM_ID},
|
||||
{"graphics", MODULE_GRAPHICS_ID},
|
||||
{"image", MODULE_IMAGE_ID},
|
||||
{"sound", MODULE_SOUND_ID},
|
||||
};
|
||||
|
||||
StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
|
||||
|
||||
bool getType(const char *in, love::Type &out)
|
||||
{
|
||||
return types.find(in, out);
|
||||
}
|
||||
|
||||
bool getType(love::Type in, const char *&out)
|
||||
{
|
||||
return types.find(in, out);
|
||||
}
|
||||
|
||||
Type luax_type(lua_State *L, int idx)
|
||||
{
|
||||
Type t = INVALID_ID;
|
||||
types.find(luaL_checkstring(L, idx), t);
|
||||
getType(luaL_checkstring(L, idx), t);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
+37
-26
@@ -63,7 +63,7 @@ enum Registry
|
||||
struct Proxy
|
||||
{
|
||||
// Holds type information (see types.h).
|
||||
bits flags;
|
||||
Type type;
|
||||
|
||||
// Pointer to the actual object.
|
||||
Object *object;
|
||||
@@ -80,15 +80,14 @@ struct WrappedModule
|
||||
// The name for the table to put the functions in, without the 'love'-prefix.
|
||||
const char *name;
|
||||
|
||||
// The type flags of this module.
|
||||
love::bits flags;
|
||||
// The type of this module.
|
||||
love::Type type;
|
||||
|
||||
// The functions of the module (last element {0,0}).
|
||||
const luaL_Reg *functions;
|
||||
|
||||
// A list of functions which expose the types of the modules (last element 0).
|
||||
const lua_CFunction *types;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -241,11 +240,10 @@ int luax_preload(lua_State *L, lua_CFunction f, const char *name);
|
||||
|
||||
/**
|
||||
* Register a new type.
|
||||
* @param tname The name of the type. This must not conflict with other type names,
|
||||
* even from other modules.
|
||||
* @param type The type.
|
||||
* @param f The list of member functions for the type.
|
||||
**/
|
||||
int luax_register_type(lua_State *L, const char *tname, const luaL_Reg *f = 0);
|
||||
int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f = 0);
|
||||
|
||||
/**
|
||||
* Do a table.insert from C
|
||||
@@ -271,10 +269,10 @@ int luax_register_searcher(lua_State *L, lua_CFunction f, int pos = -1);
|
||||
* NOTE: The object will be retained by Lua and released upon garbage collection.
|
||||
* @param L The Lua state.
|
||||
* @param name The name of the type. This must match the name used with luax_register_type.
|
||||
* @param flags The type information of the object.
|
||||
* @param type The type information of the object.
|
||||
* @param object The pointer to the actual object.
|
||||
**/
|
||||
void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *object);
|
||||
void luax_pushtype(lua_State *L, const love::Type type, love::Object *object);
|
||||
|
||||
/**
|
||||
* Creates a new Lua representation of the given object *without* checking if it
|
||||
@@ -285,10 +283,10 @@ void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *obj
|
||||
* NOTE: The object will be retained by Lua and released upon garbage collection.
|
||||
* @param L The Lua state.
|
||||
* @param name The name of the type. This must match the name used with luax_register_type.
|
||||
* @param flags The type information of the object.
|
||||
* @param type The type information of the object.
|
||||
* @param object The pointer to the actual object.
|
||||
**/
|
||||
void luax_rawnewtype(lua_State *L, const char *name, bits flags, love::Object *object);
|
||||
void luax_rawnewtype(lua_State *L, love::Type type, love::Object *object);
|
||||
|
||||
/**
|
||||
* Checks whether the value at idx is a certain type.
|
||||
@@ -297,7 +295,7 @@ void luax_rawnewtype(lua_State *L, const char *name, bits flags, love::Object *o
|
||||
* @param type The type to check for.
|
||||
* @return True if the value is Proxy of the specified type, false otherwise.
|
||||
**/
|
||||
bool luax_istype(lua_State *L, int idx, love::bits type);
|
||||
bool luax_istype(lua_State *L, int idx, love::Type type);
|
||||
|
||||
/**
|
||||
* Gets the function love.module.function and puts it on top of the stack (alone). If the
|
||||
@@ -399,32 +397,43 @@ extern "C" { // Also called from luasocket
|
||||
* @param type The type bit.
|
||||
**/
|
||||
template <typename T>
|
||||
T *luax_checktype(lua_State *L, int idx, const char *name, love::bits type)
|
||||
T *luax_checktype(lua_State *L, int idx, love::Type type)
|
||||
{
|
||||
if (lua_type(L, idx) != LUA_TUSERDATA)
|
||||
{
|
||||
const char *name = "Invalid";
|
||||
getType(type, name);
|
||||
luax_typerror(L, idx, name);
|
||||
}
|
||||
|
||||
Proxy *u = (Proxy *)lua_touserdata(L, idx);
|
||||
|
||||
if ((u->flags & type) != type)
|
||||
if (!typeFlags[u->type][type])
|
||||
{
|
||||
const char *name = "Invalid";
|
||||
getType(type, name);
|
||||
luax_typerror(L, idx, name);
|
||||
}
|
||||
|
||||
return (T *)u->object;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *luax_getmodule(lua_State *L, const char *k, love::bits type)
|
||||
T *luax_getmodule(lua_State *L, love::Type type)
|
||||
{
|
||||
const char *name = "Invalid";
|
||||
getType(type, name);
|
||||
|
||||
luax_insistregistry(L, REGISTRY_MODULES);
|
||||
lua_getfield(L, -1, k);
|
||||
lua_getfield(L, -1, name);
|
||||
|
||||
if (!lua_isuserdata(L, -1))
|
||||
luaL_error(L, "Tried to get nonexistant module %s.", k);
|
||||
luaL_error(L, "Tried to get nonexistant module %s.", name);
|
||||
|
||||
Proxy *u = (Proxy *)lua_touserdata(L, -1);
|
||||
|
||||
if ((u->flags & type) != type)
|
||||
luaL_error(L, "Incorrect module %s", k);
|
||||
if (!typeFlags[u->type][type])
|
||||
luaL_error(L, "Incorrect module %s", name);
|
||||
|
||||
lua_pop(L, 2);
|
||||
|
||||
@@ -432,10 +441,13 @@ T *luax_getmodule(lua_State *L, const char *k, love::bits type)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *luax_optmodule(lua_State *L, const char *k, love::bits type)
|
||||
T *luax_optmodule(lua_State *L, love::Type type)
|
||||
{
|
||||
const char *name = "Invalid";
|
||||
getType(type, name);
|
||||
|
||||
luax_insistregistry(L, REGISTRY_MODULES);
|
||||
lua_getfield(L, -1, k);
|
||||
lua_getfield(L, -1, name);
|
||||
|
||||
if (!lua_isuserdata(L, -1))
|
||||
{
|
||||
@@ -445,8 +457,8 @@ T *luax_optmodule(lua_State *L, const char *k, love::bits type)
|
||||
|
||||
Proxy *u = (Proxy *)lua_touserdata(L, -1);
|
||||
|
||||
if ((u->flags & type) != type)
|
||||
luaL_error(L, "Incorrect module %s", k);
|
||||
if (!typeFlags[u->type][type])
|
||||
luaL_error(L, "Incorrect module %s", name);
|
||||
|
||||
lua_pop(L, 2);
|
||||
|
||||
@@ -459,11 +471,10 @@ T *luax_optmodule(lua_State *L, const char *k, love::bits type)
|
||||
* luax_istype, then this can be safely used. Otherwise, use luax_checktype.
|
||||
* @param L The Lua state.
|
||||
* @param idx The index on the stack.
|
||||
* @param name The name of the type.
|
||||
* @param type The type bit.
|
||||
* @param type The type of the object.
|
||||
**/
|
||||
template <typename T>
|
||||
T *luax_totype(lua_State *L, int idx, const char * /* name */, love::bits /* type */)
|
||||
T *luax_totype(lua_State *L, int idx, love::Type /*type*/)
|
||||
{
|
||||
return (T *)(((Proxy *)lua_touserdata(L, idx))->object);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2015 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 "types.h"
|
||||
#include "StringMap.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
static const TypeBits *createTypeFlags()
|
||||
{
|
||||
static TypeBits b[TYPE_MAX_ENUM];
|
||||
TypeBits one = TypeBits(1);
|
||||
|
||||
b[INVALID_ID] = one << INVALID_ID;
|
||||
|
||||
b[OBJECT_ID] = one << OBJECT_ID;
|
||||
b[DATA_ID] = (one << DATA_ID) | b[OBJECT_ID];
|
||||
b[MODULE_ID] = (one << MODULE_ID) | b[OBJECT_ID];
|
||||
|
||||
// Filesystem.
|
||||
b[FILESYSTEM_FILE_ID] = (one << FILESYSTEM_FILE_ID) | b[OBJECT_ID];
|
||||
b[FILESYSTEM_DROPPED_FILE_ID] = (one << FILESYSTEM_DROPPED_FILE_ID) | b[FILESYSTEM_FILE_ID];
|
||||
b[FILESYSTEM_FILE_DATA_ID] = (one << FILESYSTEM_FILE_DATA_ID) | b[DATA_ID];
|
||||
|
||||
b[FONT_GLYPH_DATA_ID] = (one << FONT_GLYPH_DATA_ID) | b[DATA_ID];
|
||||
b[FONT_RASTERIZER_ID] = (one << FONT_RASTERIZER_ID) | b[OBJECT_ID];
|
||||
|
||||
// Graphics.
|
||||
b[GRAPHICS_DRAWABLE_ID] = (one << GRAPHICS_DRAWABLE_ID) | b[OBJECT_ID];
|
||||
b[GRAPHICS_TEXTURE_ID] = (one << GRAPHICS_TEXTURE_ID) | b[GRAPHICS_DRAWABLE_ID];
|
||||
b[GRAPHICS_IMAGE_ID] = (one << GRAPHICS_IMAGE_ID) | b[GRAPHICS_TEXTURE_ID];
|
||||
b[GRAPHICS_QUAD_ID] = (one << GRAPHICS_QUAD_ID) | b[OBJECT_ID];
|
||||
b[GRAPHICS_FONT_ID] = (one << GRAPHICS_FONT_ID) | b[OBJECT_ID];
|
||||
b[GRAPHICS_PARTICLE_SYSTEM_ID] = (one << GRAPHICS_PARTICLE_SYSTEM_ID) | b[GRAPHICS_DRAWABLE_ID];
|
||||
b[GRAPHICS_SPRITE_BATCH_ID] = (one << GRAPHICS_SPRITE_BATCH_ID) | b[GRAPHICS_DRAWABLE_ID];
|
||||
b[GRAPHICS_CANVAS_ID] = (one << GRAPHICS_CANVAS_ID) | b[GRAPHICS_TEXTURE_ID];
|
||||
b[GRAPHICS_SHADER_ID] = (one << GRAPHICS_SHADER_ID) | b[OBJECT_ID];
|
||||
b[GRAPHICS_MESH_ID] = (one << GRAPHICS_MESH_ID) | b[GRAPHICS_DRAWABLE_ID];
|
||||
b[GRAPHICS_TEXT_ID] = (one << GRAPHICS_TEXT_ID) | b[GRAPHICS_DRAWABLE_ID];
|
||||
|
||||
// Image.
|
||||
b[IMAGE_IMAGE_DATA_ID] = (one << IMAGE_IMAGE_DATA_ID) | b[DATA_ID];
|
||||
b[IMAGE_COMPRESSED_DATA_ID] = (one << IMAGE_COMPRESSED_DATA_ID) | b[DATA_ID];
|
||||
|
||||
// Joystick.
|
||||
b[JOYSTICK_JOYSTICK_ID] = (one << JOYSTICK_JOYSTICK_ID) | b[OBJECT_ID];
|
||||
|
||||
// Math.
|
||||
b[MATH_RANDOM_GENERATOR_ID] = (one << MATH_RANDOM_GENERATOR_ID) | b[OBJECT_ID];
|
||||
b[MATH_BEZIER_CURVE_ID] = (one << MATH_BEZIER_CURVE_ID) | b[OBJECT_ID];
|
||||
|
||||
// Audio.
|
||||
b[AUDIO_SOURCE_ID] = (one << AUDIO_SOURCE_ID) | b[OBJECT_ID];
|
||||
|
||||
// Sound.
|
||||
b[SOUND_SOUND_DATA_ID] = (one << SOUND_SOUND_DATA_ID) | b[DATA_ID];
|
||||
b[SOUND_DECODER_ID] = one << SOUND_DECODER_ID;
|
||||
|
||||
// Mouse.
|
||||
b[MOUSE_CURSOR_ID] = (one << MOUSE_CURSOR_ID) | b[OBJECT_ID];
|
||||
|
||||
// Physics.
|
||||
b[PHYSICS_WORLD_ID] = (one << PHYSICS_WORLD_ID) | b[OBJECT_ID];
|
||||
b[PHYSICS_CONTACT_ID] = (one << PHYSICS_CONTACT_ID) | b[OBJECT_ID];
|
||||
b[PHYSICS_BODY_ID] = (one << PHYSICS_BODY_ID) | b[OBJECT_ID];
|
||||
b[PHYSICS_FIXTURE_ID] = (one << PHYSICS_FIXTURE_ID) | b[OBJECT_ID];
|
||||
b[PHYSICS_SHAPE_ID] = (one << PHYSICS_SHAPE_ID) | b[OBJECT_ID];
|
||||
b[PHYSICS_CIRCLE_SHAPE_ID] = (one << PHYSICS_CIRCLE_SHAPE_ID) | b[PHYSICS_SHAPE_ID];
|
||||
b[PHYSICS_POLYGON_SHAPE_ID] = (one << PHYSICS_POLYGON_SHAPE_ID) | b[PHYSICS_SHAPE_ID];
|
||||
b[PHYSICS_EDGE_SHAPE_ID] = (one << PHYSICS_EDGE_SHAPE_ID) | b[PHYSICS_SHAPE_ID];
|
||||
b[PHYSICS_CHAIN_SHAPE_ID] = (one << PHYSICS_CHAIN_SHAPE_ID) | b[PHYSICS_SHAPE_ID];
|
||||
b[PHYSICS_JOINT_ID] = (one << PHYSICS_JOINT_ID) | b[OBJECT_ID];
|
||||
b[PHYSICS_MOUSE_JOINT_ID] = (one << PHYSICS_MOUSE_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_DISTANCE_JOINT_ID] = (one << PHYSICS_DISTANCE_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_PRISMATIC_JOINT_ID] = (one << PHYSICS_PRISMATIC_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_REVOLUTE_JOINT_ID] = (one << PHYSICS_REVOLUTE_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_PULLEY_JOINT_ID] = (one << PHYSICS_PULLEY_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_GEAR_JOINT_ID] = (one << PHYSICS_GEAR_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_FRICTION_JOINT_ID] = (one << PHYSICS_FRICTION_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_WELD_JOINT_ID] = (one << PHYSICS_WELD_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_ROPE_JOINT_ID] = (one << PHYSICS_ROPE_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_WHEEL_JOINT_ID] = (one << PHYSICS_WHEEL_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
b[PHYSICS_MOTOR_JOINT_ID] = (one << PHYSICS_MOTOR_JOINT_ID) | b[PHYSICS_JOINT_ID];
|
||||
|
||||
// Thread.
|
||||
b[THREAD_THREAD_ID] = (one << THREAD_THREAD_ID) | b[OBJECT_ID];
|
||||
b[THREAD_CHANNEL_ID] = (one << THREAD_CHANNEL_ID) | b[OBJECT_ID];
|
||||
|
||||
// Modules.
|
||||
b[MODULE_FILESYSTEM_ID] = (one << MODULE_FILESYSTEM_ID) | b[MODULE_ID];
|
||||
b[MODULE_GRAPHICS_ID] = (one << MODULE_GRAPHICS_ID) | b[MODULE_ID];
|
||||
b[MODULE_IMAGE_ID] = (one << MODULE_IMAGE_ID) | b[MODULE_ID];
|
||||
b[MODULE_SOUND_ID] = (one << MODULE_SOUND_ID) | b[MODULE_ID];
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
const TypeBits *typeFlags = createTypeFlags();
|
||||
|
||||
StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
|
||||
{
|
||||
{"Invalid", INVALID_ID},
|
||||
|
||||
{"Object", OBJECT_ID},
|
||||
{"Data", DATA_ID},
|
||||
{"Module", MODULE_ID},
|
||||
|
||||
// Filesystem
|
||||
{"File", FILESYSTEM_FILE_ID},
|
||||
{"DroppedFile", FILESYSTEM_DROPPED_FILE_ID},
|
||||
{"FileData", FILESYSTEM_FILE_DATA_ID},
|
||||
|
||||
// Font
|
||||
{"GlyphData", FONT_GLYPH_DATA_ID},
|
||||
{"Rasterizer", FONT_RASTERIZER_ID},
|
||||
|
||||
// Graphics
|
||||
{"Drawable", GRAPHICS_DRAWABLE_ID},
|
||||
{"Texture", GRAPHICS_TEXTURE_ID},
|
||||
{"Image", GRAPHICS_IMAGE_ID},
|
||||
{"Quad", GRAPHICS_QUAD_ID},
|
||||
{"Font", GRAPHICS_FONT_ID},
|
||||
{"ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_ID},
|
||||
{"SpriteBatch", GRAPHICS_SPRITE_BATCH_ID},
|
||||
{"Canvas", GRAPHICS_CANVAS_ID},
|
||||
{"Shader", GRAPHICS_SHADER_ID},
|
||||
{"Mesh", GRAPHICS_MESH_ID},
|
||||
{"Text", GRAPHICS_TEXT_ID},
|
||||
|
||||
// Image
|
||||
{"ImageData", IMAGE_IMAGE_DATA_ID},
|
||||
{"CompressedData", IMAGE_COMPRESSED_DATA_ID},
|
||||
|
||||
// Joystick
|
||||
{"Joystick", JOYSTICK_JOYSTICK_ID},
|
||||
|
||||
// Math
|
||||
{"RandomGenerator", MATH_RANDOM_GENERATOR_ID},
|
||||
{"BezierCurve", MATH_BEZIER_CURVE_ID},
|
||||
|
||||
// Audio
|
||||
{"Source", AUDIO_SOURCE_ID},
|
||||
|
||||
// Sound
|
||||
{"SoundData", SOUND_SOUND_DATA_ID},
|
||||
{"Decoder", SOUND_DECODER_ID},
|
||||
|
||||
// Mouse
|
||||
{"Cursor", MOUSE_CURSOR_ID},
|
||||
|
||||
// Physics
|
||||
{"World", PHYSICS_WORLD_ID},
|
||||
{"Contact", PHYSICS_CONTACT_ID},
|
||||
{"Body", PHYSICS_BODY_ID},
|
||||
{"Fixture", PHYSICS_FIXTURE_ID},
|
||||
{"Shape", PHYSICS_SHAPE_ID},
|
||||
{"CircleShape", PHYSICS_CIRCLE_SHAPE_ID},
|
||||
{"PolygonShape", PHYSICS_POLYGON_SHAPE_ID},
|
||||
{"EdgeShape", PHYSICS_EDGE_SHAPE_ID},
|
||||
{"ChainShape", PHYSICS_CHAIN_SHAPE_ID},
|
||||
{"Joint", PHYSICS_JOINT_ID},
|
||||
{"MouseJoint", PHYSICS_MOUSE_JOINT_ID},
|
||||
{"DistanceJoint", PHYSICS_DISTANCE_JOINT_ID},
|
||||
{"PrismaticJoint", PHYSICS_PRISMATIC_JOINT_ID},
|
||||
{"RevoluteJoint", PHYSICS_REVOLUTE_JOINT_ID},
|
||||
{"PulleyJoint", PHYSICS_PULLEY_JOINT_ID},
|
||||
{"GearJoint", PHYSICS_GEAR_JOINT_ID},
|
||||
{"FrictionJoint", PHYSICS_FRICTION_JOINT_ID},
|
||||
{"WeldJoint", PHYSICS_WELD_JOINT_ID},
|
||||
{"RopeJoint", PHYSICS_ROPE_JOINT_ID},
|
||||
{"WheelJoint", PHYSICS_WHEEL_JOINT_ID},
|
||||
{"MotorJoint", PHYSICS_MOTOR_JOINT_ID},
|
||||
|
||||
// Thread
|
||||
{"Thread", THREAD_THREAD_ID},
|
||||
{"Channel", THREAD_CHANNEL_ID},
|
||||
|
||||
// The modules themselves. Only add abstracted modules here.
|
||||
{"filesystem", MODULE_FILESYSTEM_ID},
|
||||
{"graphics", MODULE_GRAPHICS_ID},
|
||||
{"image", MODULE_IMAGE_ID},
|
||||
{"sound", MODULE_SOUND_ID},
|
||||
};
|
||||
|
||||
StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
|
||||
|
||||
bool getType(const char *in, love::Type &out)
|
||||
{
|
||||
return types.find(in, out);
|
||||
}
|
||||
|
||||
bool getType(love::Type in, const char *&out)
|
||||
{
|
||||
return types.find(in, out);
|
||||
}
|
||||
|
||||
} // love
|
||||
+6
-82
@@ -115,91 +115,15 @@ enum Type
|
||||
TYPE_MAX_ENUM
|
||||
};
|
||||
|
||||
typedef std::bitset<TYPE_MAX_ENUM> bits;
|
||||
typedef std::bitset<TYPE_MAX_ENUM> TypeBits;
|
||||
|
||||
const bits INVALID_T = bits(1) << INVALID_ID;
|
||||
|
||||
const bits OBJECT_T = bits(1) << OBJECT_ID;
|
||||
const bits DATA_T = (bits(1) << DATA_ID) | OBJECT_T;
|
||||
const bits MODULE_T = (bits(1) << MODULE_ID) | OBJECT_T;
|
||||
|
||||
// Filesystem.
|
||||
const bits FILESYSTEM_FILE_T = (bits(1) << FILESYSTEM_FILE_ID) | OBJECT_T;
|
||||
const bits FILESYSTEM_DROPPED_FILE_T = (bits(1) << FILESYSTEM_DROPPED_FILE_ID) | FILESYSTEM_FILE_T;
|
||||
const bits FILESYSTEM_FILE_DATA_T = (bits(1) << FILESYSTEM_FILE_DATA_ID) | DATA_T;
|
||||
|
||||
const bits FONT_GLYPH_DATA_T = (bits(1) << FONT_GLYPH_DATA_ID) | DATA_T;
|
||||
const bits FONT_RASTERIZER_T = (bits(1) << FONT_RASTERIZER_ID) | OBJECT_T;
|
||||
|
||||
// Graphics.
|
||||
const bits GRAPHICS_DRAWABLE_T = (bits(1) << GRAPHICS_DRAWABLE_ID) | OBJECT_T;
|
||||
const bits GRAPHICS_TEXTURE_T = (bits(1) << GRAPHICS_TEXTURE_ID) | GRAPHICS_DRAWABLE_T;
|
||||
const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_TEXTURE_T;
|
||||
const bits GRAPHICS_QUAD_T = (bits(1) << GRAPHICS_QUAD_ID) | OBJECT_T;
|
||||
const bits GRAPHICS_FONT_T = (bits(1) << GRAPHICS_FONT_ID) | OBJECT_T;
|
||||
const bits GRAPHICS_PARTICLE_SYSTEM_T = (bits(1) << GRAPHICS_PARTICLE_SYSTEM_ID) | GRAPHICS_DRAWABLE_T;
|
||||
const bits GRAPHICS_SPRITE_BATCH_T = (bits(1) << GRAPHICS_SPRITE_BATCH_ID) | GRAPHICS_DRAWABLE_T;
|
||||
const bits GRAPHICS_CANVAS_T = (bits(1) << GRAPHICS_CANVAS_ID) | GRAPHICS_TEXTURE_T;
|
||||
const bits GRAPHICS_SHADER_T = (bits(1) << GRAPHICS_SHADER_ID) | OBJECT_T;
|
||||
const bits GRAPHICS_MESH_T = (bits(1) << GRAPHICS_MESH_ID) | GRAPHICS_DRAWABLE_T;
|
||||
const bits GRAPHICS_TEXT_T = (bits(1) << GRAPHICS_TEXT_ID) | GRAPHICS_DRAWABLE_T;
|
||||
|
||||
// Image.
|
||||
const bits IMAGE_IMAGE_DATA_T = (bits(1) << IMAGE_IMAGE_DATA_ID) | DATA_T;
|
||||
const bits IMAGE_COMPRESSED_DATA_T = (bits(1) << IMAGE_COMPRESSED_DATA_ID) | DATA_T;
|
||||
|
||||
// Joystick.
|
||||
const bits JOYSTICK_JOYSTICK_T = (bits(1) << JOYSTICK_JOYSTICK_ID) | OBJECT_T;
|
||||
|
||||
// Math.
|
||||
const bits MATH_RANDOM_GENERATOR_T = (bits(1) << MATH_RANDOM_GENERATOR_ID) | OBJECT_T;
|
||||
const bits MATH_BEZIER_CURVE_T = (bits(1) << MATH_BEZIER_CURVE_ID) | OBJECT_T;
|
||||
|
||||
// Audio.
|
||||
const bits AUDIO_SOURCE_T = (bits(1) << AUDIO_SOURCE_ID) | OBJECT_T;
|
||||
|
||||
// Sound.
|
||||
const bits SOUND_SOUND_DATA_T = (bits(1) << SOUND_SOUND_DATA_ID) | DATA_T;
|
||||
const bits SOUND_DECODER_T = bits(1) << SOUND_DECODER_ID;
|
||||
|
||||
// Mouse.
|
||||
const bits MOUSE_CURSOR_T = (bits(1) << MOUSE_CURSOR_ID) | OBJECT_T;
|
||||
|
||||
// Physics.
|
||||
const bits PHYSICS_WORLD_T = (bits(1) << PHYSICS_WORLD_ID) | OBJECT_T;
|
||||
const bits PHYSICS_CONTACT_T = (bits(1) << PHYSICS_CONTACT_ID) | OBJECT_T;
|
||||
const bits PHYSICS_BODY_T = (bits(1) << PHYSICS_BODY_ID) | OBJECT_T;
|
||||
const bits PHYSICS_FIXTURE_T = (bits(1) << PHYSICS_FIXTURE_ID) | OBJECT_T;
|
||||
const bits PHYSICS_SHAPE_T = (bits(1) << PHYSICS_SHAPE_ID) | OBJECT_T;
|
||||
const bits PHYSICS_CIRCLE_SHAPE_T = (bits(1) << PHYSICS_CIRCLE_SHAPE_ID) | PHYSICS_SHAPE_T;
|
||||
const bits PHYSICS_POLYGON_SHAPE_T = (bits(1) << PHYSICS_POLYGON_SHAPE_ID) | PHYSICS_SHAPE_T;
|
||||
const bits PHYSICS_EDGE_SHAPE_T = (bits(1) << PHYSICS_EDGE_SHAPE_ID) | PHYSICS_SHAPE_T;
|
||||
const bits PHYSICS_CHAIN_SHAPE_T = (bits(1) << PHYSICS_CHAIN_SHAPE_ID) | PHYSICS_SHAPE_T;
|
||||
const bits PHYSICS_JOINT_T = (bits(1) << PHYSICS_JOINT_ID) | OBJECT_T;
|
||||
const bits PHYSICS_MOUSE_JOINT_T = (bits(1) << PHYSICS_MOUSE_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_DISTANCE_JOINT_T = (bits(1) << PHYSICS_DISTANCE_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_PRISMATIC_JOINT_T = (bits(1) << PHYSICS_PRISMATIC_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_REVOLUTE_JOINT_T = (bits(1) << PHYSICS_REVOLUTE_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_PULLEY_JOINT_T = (bits(1) << PHYSICS_PULLEY_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_GEAR_JOINT_T = (bits(1) << PHYSICS_GEAR_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_FRICTION_JOINT_T = (bits(1) << PHYSICS_FRICTION_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_WELD_JOINT_T = (bits(1) << PHYSICS_WELD_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_ROPE_JOINT_T = (bits(1) << PHYSICS_ROPE_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_WHEEL_JOINT_T = (bits(1) << PHYSICS_WHEEL_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
const bits PHYSICS_MOTOR_JOINT_T = (bits(1) << PHYSICS_MOTOR_JOINT_ID) | PHYSICS_JOINT_T;
|
||||
|
||||
// Thread.
|
||||
const bits THREAD_THREAD_T = (bits(1) << THREAD_THREAD_ID) | OBJECT_T;
|
||||
const bits THREAD_CHANNEL_T = (bits(1) << THREAD_CHANNEL_ID) | OBJECT_T;
|
||||
|
||||
// Modules.
|
||||
const bits MODULE_FILESYSTEM_T = (bits(1) << MODULE_FILESYSTEM_ID) | MODULE_T;
|
||||
const bits MODULE_GRAPHICS_T = (bits(1) << MODULE_GRAPHICS_ID) | MODULE_T;
|
||||
const bits MODULE_IMAGE_T = (bits(1) << MODULE_IMAGE_ID) | MODULE_T;
|
||||
const bits MODULE_SOUND_T = (bits(1) << MODULE_SOUND_ID) | MODULE_T;
|
||||
/**
|
||||
* Array of length TYPE_MAX_ENUM containing the flags for each love Type.
|
||||
**/
|
||||
extern const TypeBits *typeFlags;
|
||||
|
||||
bool getType(const char *in, Type &out);
|
||||
bool getType(Type in, const char *&out);
|
||||
bool getType(Type in, const char *&out);
|
||||
|
||||
} // love
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace love
|
||||
|
||||
Data *luax_checkdata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Data>(L, idx, "Data", DATA_T);
|
||||
return luax_checktype<Data>(L, idx, DATA_ID);
|
||||
}
|
||||
|
||||
int w_Data_getString(lua_State *L)
|
||||
@@ -59,7 +59,7 @@ const luaL_Reg w_Data_functions[] =
|
||||
|
||||
int w_Data_open(lua_State *L)
|
||||
{
|
||||
luax_register_type(L, "Data", w_Data_functions);
|
||||
luax_register_type(L, DATA_ID, w_Data_functions);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ int w_getSourceCount(lua_State *L)
|
||||
|
||||
int w_newSource(lua_State *L)
|
||||
{
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
|
||||
luax_convobj(L, 1, "sound", "newDecoder");
|
||||
|
||||
Source::Type stype = Source::TYPE_STREAM;
|
||||
@@ -53,21 +53,21 @@ int w_newSource(lua_State *L)
|
||||
if (stypestr && !Source::getConstant(stypestr, stype))
|
||||
return luaL_error(L, "Invalid source type: %s", stypestr);
|
||||
|
||||
if (stype == Source::TYPE_STATIC && luax_istype(L, 1, SOUND_DECODER_T))
|
||||
if (stype == Source::TYPE_STATIC && luax_istype(L, 1, SOUND_DECODER_ID))
|
||||
luax_convobj(L, 1, "sound", "newSoundData");
|
||||
|
||||
Source *t = 0;
|
||||
|
||||
luax_catchexcept(L, [&]() {
|
||||
if (luax_istype(L, 1, SOUND_SOUND_DATA_T))
|
||||
t = instance()->newSource(luax_totype<love::sound::SoundData>(L, 1, "SoundData", SOUND_SOUND_DATA_T));
|
||||
else if (luax_istype(L, 1, SOUND_DECODER_T))
|
||||
t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, "Decoder", SOUND_DECODER_T));
|
||||
if (luax_istype(L, 1, SOUND_SOUND_DATA_ID))
|
||||
t = instance()->newSource(luax_totype<love::sound::SoundData>(L, 1, SOUND_SOUND_DATA_ID));
|
||||
else if (luax_istype(L, 1, SOUND_DECODER_ID))
|
||||
t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, SOUND_DECODER_ID));
|
||||
});
|
||||
|
||||
if (t)
|
||||
{
|
||||
luax_pushtype(L, "Source", AUDIO_SOURCE_T, t);
|
||||
luax_pushtype(L, AUDIO_SOURCE_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ int w_getRecordedData(lua_State *L)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
{
|
||||
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
|
||||
luax_pushtype(L, SOUND_SOUND_DATA_ID, sd);
|
||||
sd->release();
|
||||
}
|
||||
return 1;
|
||||
@@ -258,7 +258,7 @@ int w_stopRecording(lua_State *L)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
{
|
||||
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
|
||||
luax_pushtype(L, SOUND_SOUND_DATA_ID, sd);
|
||||
sd->release();
|
||||
}
|
||||
return 1;
|
||||
@@ -369,7 +369,7 @@ extern "C" int luaopen_love_audio(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "audio";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace audio
|
||||
|
||||
Source *luax_checksource(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Source>(L, idx, "Source", AUDIO_SOURCE_T);
|
||||
return luax_checktype<Source>(L, idx, AUDIO_SOURCE_ID);
|
||||
}
|
||||
|
||||
int w_Source_clone(lua_State *L)
|
||||
@@ -37,7 +37,7 @@ int w_Source_clone(lua_State *L)
|
||||
Source *t = luax_checksource(L, 1);
|
||||
Source *clone = nullptr;
|
||||
luax_catchexcept(L, [&](){ clone = t->clone(); });
|
||||
luax_pushtype(L, "Source", AUDIO_SOURCE_T, clone);
|
||||
luax_pushtype(L, AUDIO_SOURCE_ID, clone);
|
||||
clone->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_source(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Source", functions);
|
||||
return luax_register_type(L, AUDIO_SOURCE_ID, functions);
|
||||
}
|
||||
|
||||
} // audio
|
||||
|
||||
@@ -350,7 +350,7 @@ Message *Event::convert(const SDL_Event &e) const
|
||||
{
|
||||
Proxy proxy;
|
||||
proxy.object = new love::filesystem::DroppedFile(e.drop.file);
|
||||
proxy.flags = FILESYSTEM_DROPPED_FILE_T;
|
||||
proxy.type = FILESYSTEM_DROPPED_FILE_ID;
|
||||
vargs.push_back(new Variant(FILESYSTEM_DROPPED_FILE_ID, &proxy));
|
||||
msg = new Message("filedropped", vargs);
|
||||
proxy.object->release();
|
||||
@@ -400,7 +400,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
{
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP:
|
||||
proxy.flags = JOYSTICK_JOYSTICK_T;
|
||||
proxy.type = JOYSTICK_JOYSTICK_ID;
|
||||
proxy.object = joymodule->getJoystickFromID(e.jbutton.which);
|
||||
if (!proxy.object)
|
||||
break;
|
||||
@@ -413,7 +413,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
break;
|
||||
case SDL_JOYAXISMOTION:
|
||||
{
|
||||
proxy.flags = JOYSTICK_JOYSTICK_T;
|
||||
proxy.type = JOYSTICK_JOYSTICK_ID;
|
||||
proxy.object = joymodule->getJoystickFromID(e.jaxis.which);
|
||||
if (!proxy.object)
|
||||
break;
|
||||
@@ -429,7 +429,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
if (!joystick::sdl::Joystick::getConstant(e.jhat.value, hat) || !joystick::Joystick::getConstant(hat, txt))
|
||||
break;
|
||||
|
||||
proxy.flags = JOYSTICK_JOYSTICK_T;
|
||||
proxy.type = JOYSTICK_JOYSTICK_ID;
|
||||
proxy.object = joymodule->getJoystickFromID(e.jhat.which);
|
||||
if (!proxy.object)
|
||||
break;
|
||||
@@ -447,7 +447,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
if (!joystick::Joystick::getConstant(padbutton, txt))
|
||||
break;
|
||||
|
||||
proxy.flags = JOYSTICK_JOYSTICK_T;
|
||||
proxy.type = JOYSTICK_JOYSTICK_ID;
|
||||
proxy.object = joymodule->getJoystickFromID(e.cbutton.which);
|
||||
if (!proxy.object)
|
||||
break;
|
||||
@@ -463,7 +463,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
if (!joystick::Joystick::getConstant(padaxis, txt))
|
||||
break;
|
||||
|
||||
proxy.flags = JOYSTICK_JOYSTICK_T;
|
||||
proxy.type = JOYSTICK_JOYSTICK_ID;
|
||||
proxy.object = joymodule->getJoystickFromID(e.caxis.which);
|
||||
if (!proxy.object)
|
||||
break;
|
||||
@@ -479,7 +479,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
case SDL_JOYDEVICEADDED:
|
||||
// jdevice.which is the joystick device index.
|
||||
proxy.object = joymodule->addJoystick(e.jdevice.which);
|
||||
proxy.flags = JOYSTICK_JOYSTICK_T;
|
||||
proxy.type = JOYSTICK_JOYSTICK_ID;
|
||||
if (proxy.object)
|
||||
{
|
||||
vargs.push_back(new Variant(JOYSTICK_JOYSTICK_ID, (void *) &proxy));
|
||||
@@ -489,7 +489,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
// jdevice.which is the joystick instance ID now.
|
||||
proxy.object = joymodule->getJoystickFromID(e.jdevice.which);
|
||||
proxy.flags = JOYSTICK_JOYSTICK_T;
|
||||
proxy.type = JOYSTICK_JOYSTICK_ID;
|
||||
if (proxy.object)
|
||||
{
|
||||
joymodule->removeJoystick((joystick::Joystick *) proxy.object);
|
||||
|
||||
@@ -129,7 +129,7 @@ extern "C" int luaopen_love_event(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "event";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = 0;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace filesystem
|
||||
|
||||
DroppedFile *luax_checkdroppedfile(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<DroppedFile>(L, idx, "DroppedFile", FILESYSTEM_DROPPED_FILE_T);
|
||||
return luax_checktype<DroppedFile>(L, idx, FILESYSTEM_DROPPED_FILE_ID);
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] =
|
||||
@@ -55,7 +55,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_droppedfile(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "DroppedFile", functions);
|
||||
return luax_register_type(L, FILESYSTEM_DROPPED_FILE_ID, functions);
|
||||
}
|
||||
|
||||
} // filesystem
|
||||
|
||||
@@ -43,7 +43,7 @@ int luax_ioError(lua_State *L, const char *fmt, ...)
|
||||
|
||||
File *luax_checkfile(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<File>(L, idx, "File", FILESYSTEM_FILE_T);
|
||||
return luax_checktype<File>(L, idx, FILESYSTEM_FILE_ID);
|
||||
}
|
||||
|
||||
int w_File_getSize(lua_State *L)
|
||||
@@ -149,11 +149,11 @@ int w_File_write(lua_State *L)
|
||||
return luax_ioError(L, "%s", e.what());
|
||||
}
|
||||
}
|
||||
else if (luax_istype(L, 2, DATA_T))
|
||||
else if (luax_istype(L, 2, DATA_ID))
|
||||
{
|
||||
try
|
||||
{
|
||||
love::Data *data = luax_totype<love::Data>(L, 2, "Data", DATA_T);
|
||||
love::Data *data = luax_totype<love::Data>(L, 2, DATA_ID);
|
||||
result = file->write(data, luaL_optinteger(L, 3, data->getSize()));
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
@@ -228,7 +228,7 @@ int w_File_lines_i(lua_State *L)
|
||||
int linesize = 0;
|
||||
bool newline = false;
|
||||
|
||||
File *file = luax_checktype<File>(L, lua_upvalueindex(1), "File", FILESYSTEM_FILE_T);
|
||||
File *file = luax_checktype<File>(L, lua_upvalueindex(1), FILESYSTEM_FILE_ID);
|
||||
|
||||
// Only accept read mode at this point.
|
||||
if (file->getMode() != File::MODE_READ)
|
||||
@@ -436,7 +436,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_file(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "File", functions);
|
||||
return luax_register_type(L, FILESYSTEM_FILE_ID, functions);
|
||||
}
|
||||
|
||||
} // filesystem
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace filesystem
|
||||
|
||||
FileData *luax_checkfiledata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<FileData>(L, idx, "FileData", FILESYSTEM_FILE_DATA_T);
|
||||
return luax_checktype<FileData>(L, idx, FILESYSTEM_FILE_DATA_ID);
|
||||
}
|
||||
|
||||
int w_FileData_getFilename(lua_State *L)
|
||||
@@ -61,7 +61,7 @@ static const luaL_Reg w_FileData_functions[] =
|
||||
|
||||
extern "C" int luaopen_filedata(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "FileData", w_FileData_functions);
|
||||
return luax_register_type(L, FILESYSTEM_FILE_DATA_ID, w_FileData_functions);
|
||||
}
|
||||
|
||||
} // filesystem
|
||||
|
||||
@@ -150,7 +150,7 @@ int w_newFile(lua_State *L)
|
||||
}
|
||||
}
|
||||
|
||||
luax_pushtype(L, "File", FILESYSTEM_FILE_T, t);
|
||||
luax_pushtype(L, FILESYSTEM_FILE_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -165,12 +165,12 @@ FileData *luax_getfiledata(lua_State *L, int idx)
|
||||
const char *filename = luaL_checkstring(L, idx);
|
||||
file = instance()->newFile(filename);
|
||||
}
|
||||
else if (luax_istype(L, idx, FILESYSTEM_FILE_T))
|
||||
else if (luax_istype(L, idx, FILESYSTEM_FILE_ID))
|
||||
{
|
||||
file = luax_checkfile(L, idx);
|
||||
file->retain();
|
||||
}
|
||||
else if (luax_istype(L, idx, FILESYSTEM_FILE_DATA_T))
|
||||
else if (luax_istype(L, idx, FILESYSTEM_FILE_DATA_ID))
|
||||
{
|
||||
data = luax_checkfiledata(L, idx);
|
||||
data->retain();
|
||||
@@ -203,7 +203,7 @@ int w_newFileData(lua_State *L)
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
// Get FileData from the File.
|
||||
if (luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
if (luax_istype(L, 1, FILESYSTEM_FILE_ID))
|
||||
{
|
||||
File *file = luax_checkfile(L, 1);
|
||||
|
||||
@@ -216,7 +216,7 @@ int w_newFileData(lua_State *L)
|
||||
{
|
||||
return luax_ioError(L, "%s", e.what());
|
||||
}
|
||||
luax_pushtype(L, "FileData", FILESYSTEM_FILE_DATA_T, data);
|
||||
luax_pushtype(L, FILESYSTEM_FILE_DATA_ID, data);
|
||||
data->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ int w_newFileData(lua_State *L)
|
||||
return luaL_error(L, "Invalid FileData decoder: %s", decstr);
|
||||
}
|
||||
|
||||
luax_pushtype(L, "FileData", FILESYSTEM_FILE_DATA_T, t);
|
||||
luax_pushtype(L, FILESYSTEM_FILE_DATA_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -366,9 +366,9 @@ static int w_write_or_append(lua_State *L, File::Mode mode)
|
||||
const char *input = 0;
|
||||
size_t len = 0;
|
||||
|
||||
if (luax_istype(L, 2, DATA_T))
|
||||
if (luax_istype(L, 2, DATA_ID))
|
||||
{
|
||||
love::Data *data = luax_totype<love::Data>(L, 2, "Data", DATA_T);
|
||||
love::Data *data = luax_totype<love::Data>(L, 2, DATA_ID);
|
||||
input = (const char *) data->getData();
|
||||
len = data->getSize();
|
||||
}
|
||||
@@ -428,7 +428,7 @@ int w_lines(lua_State *L)
|
||||
return luaL_error(L, "Could not open file.");
|
||||
}
|
||||
|
||||
luax_pushtype(L, "File", FILESYSTEM_FILE_T, file);
|
||||
luax_pushtype(L, FILESYSTEM_FILE_ID, file);
|
||||
file->release();
|
||||
}
|
||||
else
|
||||
@@ -731,7 +731,7 @@ extern "C" int luaopen_love_filesystem(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "filesystem";
|
||||
w.flags = MODULE_FILESYSTEM_T;
|
||||
w.type = MODULE_FILESYSTEM_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ int w_newRasterizer(lua_State *L)
|
||||
[&]() { d->release(); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
luax_pushtype(L, FONT_RASTERIZER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ int w_newTrueTypeRasterizer(lua_State *L)
|
||||
{
|
||||
love::Data *d = nullptr;
|
||||
|
||||
if (luax_istype(L, 1, DATA_T))
|
||||
if (luax_istype(L, 1, DATA_ID))
|
||||
d = luax_checkdata(L, 1);
|
||||
else
|
||||
d = filesystem::luax_getfiledata(L, 1);
|
||||
@@ -95,14 +95,14 @@ int w_newTrueTypeRasterizer(lua_State *L)
|
||||
);
|
||||
}
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
luax_pushtype(L, FONT_RASTERIZER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void convimagedata(lua_State *L, int idx)
|
||||
{
|
||||
if (lua_isstring(L, idx) || luax_istype(L, idx, FILESYSTEM_FILE_T) || luax_istype(L, idx, FILESYSTEM_FILE_DATA_T))
|
||||
if (lua_isstring(L, idx) || luax_istype(L, idx, FILESYSTEM_FILE_ID) || luax_istype(L, idx, FILESYSTEM_FILE_DATA_ID))
|
||||
luax_convobj(L, idx, "image", "newImageData");
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ int w_newBMFontRasterizer(lua_State *L)
|
||||
lua_rawgeti(L, 2, i);
|
||||
|
||||
convimagedata(L, -1);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, -1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, -1, IMAGE_IMAGE_DATA_ID);
|
||||
images.push_back(id);
|
||||
id->retain();
|
||||
|
||||
@@ -132,7 +132,7 @@ int w_newBMFontRasterizer(lua_State *L)
|
||||
for (int i = 2; i <= lua_gettop(L); i++)
|
||||
{
|
||||
convimagedata(L, i);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, i, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, i, IMAGE_IMAGE_DATA_ID);
|
||||
images.push_back(id);
|
||||
id->retain();
|
||||
}
|
||||
@@ -143,7 +143,7 @@ int w_newBMFontRasterizer(lua_State *L)
|
||||
[&]() { d->release(); for (auto id : images) id->release(); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
luax_pushtype(L, FONT_RASTERIZER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -154,12 +154,12 @@ int w_newImageRasterizer(lua_State *L)
|
||||
|
||||
convimagedata(L, 1);
|
||||
|
||||
image::ImageData *d = luax_checktype<image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
image::ImageData *d = luax_checktype<image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
|
||||
std::string glyphs = luax_checkstring(L, 2);
|
||||
|
||||
luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs); });
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
luax_pushtype(L, FONT_RASTERIZER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ int w_newGlyphData(lua_State *L)
|
||||
t = instance()->newGlyphData(r, g);
|
||||
}
|
||||
|
||||
luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
|
||||
luax_pushtype(L, FONT_GLYPH_DATA_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ extern "C" int luaopen_love_font(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "font";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace font
|
||||
|
||||
GlyphData *luax_checkglyphdata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<GlyphData>(L, idx, "GlyphData", FONT_GLYPH_DATA_T);
|
||||
return luax_checktype<GlyphData>(L, idx, FONT_GLYPH_DATA_ID);
|
||||
}
|
||||
|
||||
int w_GlyphData_getWidth(lua_State *L)
|
||||
@@ -136,7 +136,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_glyphdata(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "GlyphData", functions);
|
||||
return luax_register_type(L, FONT_GLYPH_DATA_ID, functions);
|
||||
}
|
||||
|
||||
} // font
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace font
|
||||
|
||||
Rasterizer *luax_checkrasterizer(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Rasterizer>(L, idx, "Rasterizer", FONT_RASTERIZER_T);
|
||||
return luax_checktype<Rasterizer>(L, idx, FONT_RASTERIZER_ID);
|
||||
}
|
||||
|
||||
int w_Rasterizer_getHeight(lua_State *L)
|
||||
@@ -86,7 +86,7 @@ int w_Rasterizer_getGlyphData(lua_State *L)
|
||||
}
|
||||
});
|
||||
|
||||
luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, g);
|
||||
luax_pushtype(L, FONT_GLYPH_DATA_ID, g);
|
||||
g->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_rasterizer(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Rasterizer", functions);
|
||||
return luax_register_type(L, FONT_RASTERIZER_ID, functions);
|
||||
}
|
||||
|
||||
} // font
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Canvas *luax_checkcanvas(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Canvas>(L, idx, "Canvas", GRAPHICS_CANVAS_T);
|
||||
return luax_checktype<Canvas>(L, idx, GRAPHICS_CANVAS_ID);
|
||||
}
|
||||
|
||||
int w_Canvas_renderTo(lua_State *L)
|
||||
@@ -65,7 +65,7 @@ int w_Canvas_renderTo(lua_State *L)
|
||||
int w_Canvas_newImageData(lua_State *L)
|
||||
{
|
||||
Canvas *canvas = luax_checkcanvas(L, 1);
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, MODULE_IMAGE_ID);
|
||||
int x = luaL_optint(L, 2, 0);
|
||||
int y = luaL_optint(L, 3, 0);
|
||||
int w = luaL_optint(L, 4, canvas->getWidth());
|
||||
@@ -74,7 +74,7 @@ int w_Canvas_newImageData(lua_State *L)
|
||||
love::image::ImageData *img = nullptr;
|
||||
luax_catchexcept(L, [&](){ img = canvas->newImageData(image, x, y, w, h); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, img);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, img);
|
||||
img->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_canvas(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Canvas", functions);
|
||||
return luax_register_type(L, GRAPHICS_CANVAS_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Font *luax_checkfont(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
|
||||
return luax_checktype<Font>(L, idx, GRAPHICS_FONT_ID);
|
||||
}
|
||||
|
||||
int w_Font_getHeight(lua_State *L)
|
||||
@@ -186,7 +186,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_font(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Font", functions);
|
||||
return luax_register_type(L, GRAPHICS_FONT_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -203,7 +203,7 @@ int w_newImage(lua_State *L)
|
||||
bool releasedata = false;
|
||||
|
||||
// Convert to ImageData / CompressedData, if necessary.
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
|
||||
{
|
||||
love::image::Image *image = Module::getInstance<love::image::Image>(Module::M_IMAGE);
|
||||
if (image == nullptr)
|
||||
@@ -229,10 +229,10 @@ int w_newImage(lua_State *L)
|
||||
// Lua's GC won't release the image data, so we should do it ourselves.
|
||||
releasedata = true;
|
||||
}
|
||||
else if (luax_istype(L, 1, IMAGE_COMPRESSED_DATA_T))
|
||||
cdata = luax_checktype<love::image::CompressedData>(L, 1, "CompressedData", IMAGE_COMPRESSED_DATA_T);
|
||||
else if (luax_istype(L, 1, IMAGE_COMPRESSED_DATA_ID))
|
||||
cdata = luax_checktype<love::image::CompressedData>(L, 1, IMAGE_COMPRESSED_DATA_ID);
|
||||
else
|
||||
data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
data = luax_checktype<love::image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
|
||||
|
||||
if (!data && !cdata)
|
||||
return luaL_error(L, "Error creating image (could not load data.)");
|
||||
@@ -258,7 +258,7 @@ int w_newImage(lua_State *L)
|
||||
return luaL_error(L, "Could not load image.");
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, image);
|
||||
luax_pushtype(L, GRAPHICS_IMAGE_ID, image);
|
||||
image->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ int w_newQuad(lua_State *L)
|
||||
float sh = (float) luaL_checknumber(L, 6);
|
||||
|
||||
Quad *quad = instance()->newQuad(v, sw, sh);
|
||||
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quad);
|
||||
luax_pushtype(L, GRAPHICS_QUAD_ID, quad);
|
||||
quad->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ int w_newFont(lua_State *L)
|
||||
Font *font = nullptr;
|
||||
|
||||
// Convert to Rasterizer, if necessary.
|
||||
if (!luax_istype(L, 1, FONT_RASTERIZER_T))
|
||||
if (!luax_istype(L, 1, FONT_RASTERIZER_ID))
|
||||
{
|
||||
std::vector<int> idxs;
|
||||
for (int i = 0; i < lua_gettop(L); i++)
|
||||
@@ -294,14 +294,14 @@ int w_newFont(lua_State *L)
|
||||
luax_convobj(L, &idxs[0], (int) idxs.size(), "font", "newRasterizer");
|
||||
}
|
||||
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, FONT_RASTERIZER_ID);
|
||||
|
||||
luax_catchexcept(L, [&]() {
|
||||
font = instance()->newFont(rasterizer, instance()->getDefaultFilter()); }
|
||||
);
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
|
||||
luax_pushtype(L, GRAPHICS_FONT_ID, font);
|
||||
font->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -312,32 +312,32 @@ int w_newImageFont(lua_State *L)
|
||||
Texture::Filter filter = instance()->getDefaultFilter();
|
||||
|
||||
// Convert to ImageData if necessary.
|
||||
if (luax_istype(L, 1, GRAPHICS_IMAGE_T))
|
||||
if (luax_istype(L, 1, GRAPHICS_IMAGE_ID))
|
||||
{
|
||||
Image *i = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
|
||||
Image *i = luax_checktype<Image>(L, 1, GRAPHICS_IMAGE_ID);
|
||||
filter = i->getFilter();
|
||||
love::image::ImageData *id = i->getImageData();
|
||||
if (!id)
|
||||
return luaL_argerror(L, 1, "Image must not be compressed.");
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, id);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, id);
|
||||
lua_replace(L, 1);
|
||||
}
|
||||
|
||||
// Convert to Rasterizer if necessary.
|
||||
if (!luax_istype(L, 1, FONT_RASTERIZER_T))
|
||||
if (!luax_istype(L, 1, FONT_RASTERIZER_ID))
|
||||
{
|
||||
luaL_checkstring(L, 2);
|
||||
int idxs[] = {1, 2};
|
||||
luax_convobj(L, idxs, 2, "font", "newImageRasterizer");
|
||||
}
|
||||
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, FONT_RASTERIZER_ID);
|
||||
|
||||
// Create the font.
|
||||
Font *font = instance()->newFont(rasterizer, filter);
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
|
||||
luax_pushtype(L, GRAPHICS_FONT_ID, font);
|
||||
font->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ int w_newSpriteBatch(lua_State *L)
|
||||
[&](){ t = instance()->newSpriteBatch(texture, size, usage); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, t);
|
||||
luax_pushtype(L, GRAPHICS_SPRITE_BATCH_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -376,7 +376,7 @@ int w_newParticleSystem(lua_State *L)
|
||||
[&](){ t = instance()->newParticleSystem(texture, int(size)); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, t);
|
||||
luax_pushtype(L, GRAPHICS_PARTICLE_SYSTEM_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -401,7 +401,7 @@ int w_newCanvas(lua_State *L)
|
||||
if (canvas == nullptr)
|
||||
return luaL_error(L, "Canvas not created, but no error thrown. I don't even...");
|
||||
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, canvas);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, canvas);
|
||||
canvas->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -492,7 +492,7 @@ int w_newShader(lua_State *L)
|
||||
try
|
||||
{
|
||||
Shader *shader = instance()->newShader(source);
|
||||
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
|
||||
luax_pushtype(L, GRAPHICS_SHADER_ID, shader);
|
||||
shader->release();
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
@@ -585,7 +585,7 @@ int w_newMesh(lua_State *L)
|
||||
if (tex)
|
||||
t->setTexture(tex);
|
||||
|
||||
luax_pushtype(L, "Mesh", GRAPHICS_MESH_T, t);
|
||||
luax_pushtype(L, GRAPHICS_MESH_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -603,7 +603,7 @@ int w_newText(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ t = instance()->newText(font, text); });
|
||||
}
|
||||
|
||||
luax_pushtype(L, "Text", GRAPHICS_TEXT_T, t);
|
||||
luax_pushtype(L, GRAPHICS_TEXT_ID, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -682,14 +682,14 @@ int w_getBackgroundColor(lua_State *L)
|
||||
int w_setNewFont(lua_State *L)
|
||||
{
|
||||
int ret = w_newFont(L);
|
||||
Font *font = luax_checktype<Font>(L, -1, "Font", GRAPHICS_FONT_T);
|
||||
Font *font = luax_checktype<Font>(L, -1, GRAPHICS_FONT_ID);
|
||||
instance()->setFont(font);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int w_setFont(lua_State *L)
|
||||
{
|
||||
Font *font = luax_checktype<Font>(L, 1, "Font", GRAPHICS_FONT_T);
|
||||
Font *font = luax_checktype<Font>(L, 1, GRAPHICS_FONT_ID);
|
||||
instance()->setFont(font);
|
||||
return 0;
|
||||
}
|
||||
@@ -699,7 +699,7 @@ int w_getFont(lua_State *L)
|
||||
Font *f = nullptr;
|
||||
luax_catchexcept(L, [&](){ f = instance()->getFont(); });
|
||||
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
|
||||
luax_pushtype(L, GRAPHICS_FONT_ID, f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -913,13 +913,13 @@ int w_isWireframe(lua_State *L)
|
||||
|
||||
int w_newScreenshot(lua_State *L)
|
||||
{
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, MODULE_IMAGE_ID);
|
||||
bool copyAlpha = luax_optboolean(L, 1, false);
|
||||
love::image::ImageData *i = 0;
|
||||
|
||||
luax_catchexcept(L, [&](){ i = instance()->newScreenshot(image, copyAlpha); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, i);
|
||||
i->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -971,7 +971,7 @@ int w_getCanvas(lua_State *L)
|
||||
|
||||
for (Canvas *c : canvases)
|
||||
{
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, c);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, c);
|
||||
n++;
|
||||
}
|
||||
|
||||
@@ -1001,7 +1001,7 @@ int w_getShader(lua_State *L)
|
||||
{
|
||||
Shader *shader = instance()->getShader();
|
||||
if (shader)
|
||||
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
|
||||
luax_pushtype(L, GRAPHICS_SHADER_ID, shader);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
@@ -1172,10 +1172,10 @@ int w_draw(lua_State *L)
|
||||
Quad *quad = nullptr;
|
||||
int startidx = 2;
|
||||
|
||||
if (luax_istype(L, 2, GRAPHICS_QUAD_T))
|
||||
if (luax_istype(L, 2, GRAPHICS_QUAD_ID))
|
||||
{
|
||||
texture = luax_checktexture(L, 1);
|
||||
quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
|
||||
quad = luax_totype<Quad>(L, 2, GRAPHICS_QUAD_ID);
|
||||
startidx = 3;
|
||||
}
|
||||
else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
|
||||
@@ -1184,7 +1184,7 @@ int w_draw(lua_State *L)
|
||||
}
|
||||
else
|
||||
{
|
||||
drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);
|
||||
drawable = luax_checktype<Drawable>(L, 1, GRAPHICS_DRAWABLE_ID);
|
||||
startidx = 2;
|
||||
}
|
||||
|
||||
@@ -1595,7 +1595,7 @@ extern "C" int luaopen_love_graphics(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "graphics";
|
||||
w.flags = MODULE_GRAPHICS_T;
|
||||
w.type = MODULE_GRAPHICS_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Image *luax_checkimage(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
|
||||
return luax_checktype<Image>(L, idx, GRAPHICS_IMAGE_ID);
|
||||
}
|
||||
|
||||
int w_Image_setMipmapFilter(lua_State *L)
|
||||
@@ -96,18 +96,12 @@ int w_Image_getData(lua_State *L)
|
||||
if (i->isCompressed())
|
||||
{
|
||||
love::image::CompressedData *t = i->getCompressedData();
|
||||
if (t)
|
||||
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
luax_pushtype(L, IMAGE_COMPRESSED_DATA_ID, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
love::image::ImageData *t = i->getImageData();
|
||||
if (t)
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -134,7 +128,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_image(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Image", functions);
|
||||
return luax_register_type(L, GRAPHICS_IMAGE_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace opengl
|
||||
|
||||
Mesh *luax_checkmesh(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Mesh>(L, idx, "Mesh", GRAPHICS_MESH_T);
|
||||
return luax_checktype<Mesh>(L, idx, GRAPHICS_MESH_ID);
|
||||
}
|
||||
|
||||
int w_Mesh_setVertex(lua_State *L)
|
||||
@@ -265,9 +265,9 @@ int w_Mesh_getTexture(lua_State *L)
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
|
||||
else
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
|
||||
@@ -368,7 +368,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_mesh(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Mesh", functions);
|
||||
return luax_register_type(L, GRAPHICS_MESH_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace opengl
|
||||
|
||||
ParticleSystem *luax_checkparticlesystem(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<ParticleSystem>(L, idx, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T);
|
||||
return luax_checktype<ParticleSystem>(L, idx, GRAPHICS_PARTICLE_SYSTEM_ID);
|
||||
}
|
||||
|
||||
int w_ParticleSystem_clone(lua_State *L)
|
||||
@@ -51,7 +51,7 @@ int w_ParticleSystem_clone(lua_State *L)
|
||||
ParticleSystem *clone = nullptr;
|
||||
luax_catchexcept(L, [&](){ clone = t->clone(); });
|
||||
|
||||
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, clone);
|
||||
luax_pushtype(L, GRAPHICS_PARTICLE_SYSTEM_ID, clone);
|
||||
clone->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -71,9 +71,9 @@ int w_ParticleSystem_getTexture(lua_State *L)
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
|
||||
else
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
|
||||
@@ -596,7 +596,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
|
||||
{
|
||||
lua_rawgeti(L, 2, i);
|
||||
|
||||
Quad *q = luax_checktype<Quad>(L, -1, "Quad", GRAPHICS_QUAD_T);
|
||||
Quad *q = luax_checktype<Quad>(L, -1, GRAPHICS_QUAD_ID);
|
||||
quads.push_back(q);
|
||||
|
||||
lua_pop(L, 1);
|
||||
@@ -606,7 +606,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
|
||||
{
|
||||
for (int i = 2; i <= lua_gettop(L); i++)
|
||||
{
|
||||
Quad *q = luax_checktype<Quad>(L, i, "Quad", GRAPHICS_QUAD_T);
|
||||
Quad *q = luax_checktype<Quad>(L, i, GRAPHICS_QUAD_ID);
|
||||
quads.push_back(q);
|
||||
}
|
||||
}
|
||||
@@ -624,7 +624,7 @@ int w_ParticleSystem_getQuads(lua_State *L)
|
||||
|
||||
for (int i = 0; i < (int) quads.size(); i++)
|
||||
{
|
||||
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quads[i]);
|
||||
luax_pushtype(L, GRAPHICS_QUAD_ID, quads[i]);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
}
|
||||
|
||||
@@ -784,7 +784,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_particlesystem(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "ParticleSystem", functions);
|
||||
return luax_register_type(L, GRAPHICS_PARTICLE_SYSTEM_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace opengl
|
||||
|
||||
Shader *luax_checkshader(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Shader>(L, idx, "Shader", GRAPHICS_SHADER_T);
|
||||
return luax_checktype<Shader>(L, idx, GRAPHICS_SHADER_ID);
|
||||
}
|
||||
|
||||
int w_Shader_getWarnings(lua_State *L)
|
||||
@@ -308,7 +308,7 @@ int w_Shader_send(lua_State *L)
|
||||
// Texture (Image or Canvas).
|
||||
p = (Proxy *) lua_touserdata(L, 3);
|
||||
|
||||
if (p->flags[GRAPHICS_TEXTURE_ID])
|
||||
if (typeFlags[p->type][GRAPHICS_TEXT_ID])
|
||||
return w_Shader_sendTexture(L);
|
||||
|
||||
break;
|
||||
@@ -381,7 +381,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_shader(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Shader", functions);
|
||||
return luax_register_type(L, GRAPHICS_SHADER_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace opengl
|
||||
|
||||
SpriteBatch *luax_checkspritebatch(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T);
|
||||
return luax_checktype<SpriteBatch>(L, idx, GRAPHICS_SPRITE_BATCH_ID);
|
||||
}
|
||||
|
||||
int w_SpriteBatch_add(lua_State *L)
|
||||
@@ -45,9 +45,9 @@ int w_SpriteBatch_add(lua_State *L)
|
||||
Quad *quad = nullptr;
|
||||
int startidx = 2;
|
||||
|
||||
if (luax_istype(L, 2, GRAPHICS_QUAD_T))
|
||||
if (luax_istype(L, 2, GRAPHICS_QUAD_ID))
|
||||
{
|
||||
quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
|
||||
quad = luax_totype<Quad>(L, 2, GRAPHICS_QUAD_ID);
|
||||
startidx = 3;
|
||||
}
|
||||
else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
|
||||
@@ -83,9 +83,9 @@ int w_SpriteBatch_set(lua_State *L)
|
||||
Quad *quad = nullptr;
|
||||
int startidx = 3;
|
||||
|
||||
if (luax_istype(L, 3, GRAPHICS_QUAD_T))
|
||||
if (luax_istype(L, 3, GRAPHICS_QUAD_ID))
|
||||
{
|
||||
quad = luax_totype<Quad>(L, 3, "Quad", GRAPHICS_QUAD_T);
|
||||
quad = luax_totype<Quad>(L, 3, GRAPHICS_QUAD_ID);
|
||||
startidx = 4;
|
||||
}
|
||||
else if (lua_isnil(L, 3) && !lua_isnoneornil(L, 4))
|
||||
@@ -140,9 +140,9 @@ int w_SpriteBatch_getTexture(lua_State *L)
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
|
||||
else
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
|
||||
@@ -241,7 +241,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_spritebatch(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "SpriteBatch", functions);
|
||||
return luax_register_type(L, GRAPHICS_SPRITE_BATCH_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -33,9 +33,7 @@ namespace opengl
|
||||
|
||||
SpriteBatch *luax_checkspritebatch(lua_State *L, int idx);
|
||||
int w_SpriteBatch_add(lua_State *L);
|
||||
int w_SpriteBatch_addg(lua_State *L);
|
||||
int w_SpriteBatch_set(lua_State *L);
|
||||
int w_SpriteBatch_setg(lua_State *L);
|
||||
int w_SpriteBatch_clear(lua_State *L);
|
||||
int w_SpriteBatch_flush(lua_State *L);
|
||||
int w_SpriteBatch_setTexture(lua_State *L);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace opengl
|
||||
|
||||
Text *luax_checktext(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Text>(L, idx, "Text", GRAPHICS_TEXT_T);
|
||||
return luax_checktype<Text>(L, idx, GRAPHICS_TEXT_ID);
|
||||
}
|
||||
|
||||
int w_Text_set(lua_State *L)
|
||||
@@ -139,7 +139,7 @@ int w_Text_getFont(lua_State *L)
|
||||
{
|
||||
Text *t = luax_checktext(L, 1);
|
||||
Font *f = t->getFont();
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
|
||||
luax_pushtype(L, GRAPHICS_FONT_ID, f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_text(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Text", functions);
|
||||
return luax_register_type(L, GRAPHICS_TEXT_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace graphics
|
||||
|
||||
Quad *luax_checkquad(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T);
|
||||
return luax_checktype<Quad>(L, idx, GRAPHICS_QUAD_ID);
|
||||
}
|
||||
|
||||
int w_Quad_setViewport(lua_State *L)
|
||||
@@ -73,7 +73,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_quad(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Quad", functions);
|
||||
return luax_register_type(L, GRAPHICS_QUAD_ID, functions);
|
||||
}
|
||||
|
||||
} // graphics
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace graphics
|
||||
|
||||
Texture *luax_checktexture(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Texture>(L, idx, "Texture", GRAPHICS_TEXTURE_T);
|
||||
return luax_checktype<Texture>(L, idx, GRAPHICS_TEXTURE_ID);
|
||||
}
|
||||
|
||||
int w_Texture_getWidth(lua_State *L)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace image
|
||||
|
||||
CompressedData *luax_checkcompresseddata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<CompressedData>(L, idx, "CompressedData", IMAGE_COMPRESSED_DATA_T);
|
||||
return luax_checktype<CompressedData>(L, idx, IMAGE_COMPRESSED_DATA_ID);
|
||||
}
|
||||
|
||||
int w_CompressedData_getWidth(lua_State *L)
|
||||
@@ -111,7 +111,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_compresseddata(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "CompressedData", functions);
|
||||
return luax_register_type(L, IMAGE_COMPRESSED_DATA_ID, functions);
|
||||
}
|
||||
|
||||
} // image
|
||||
|
||||
@@ -47,7 +47,7 @@ int w_newImageData(lua_State *L)
|
||||
ImageData *t = nullptr;
|
||||
luax_catchexcept(L, [&](){ t = instance()->newImageData(w, h); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ int w_newImageData(lua_State *L)
|
||||
[&]() { data->release(); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ int w_newCompressedData(lua_State *L)
|
||||
[&]() { data->release(); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
|
||||
luax_pushtype(L, IMAGE_COMPRESSED_DATA_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ extern "C" int luaopen_love_image(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "image";
|
||||
w.flags = MODULE_IMAGE_T;
|
||||
w.type = MODULE_IMAGE_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace image
|
||||
|
||||
ImageData *luax_checkimagedata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<ImageData>(L, idx, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
return luax_checktype<ImageData>(L, idx, IMAGE_IMAGE_DATA_ID);
|
||||
}
|
||||
|
||||
int w_ImageData_getWidth(lua_State *L)
|
||||
@@ -245,7 +245,7 @@ int w_ImageData_encode(lua_State *L)
|
||||
|
||||
if (lua_isstring(L, 2))
|
||||
luax_convobj(L, 2, "filesystem", "newFile");
|
||||
love::filesystem::File *file = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T);
|
||||
love::filesystem::File *file = luax_checktype<love::filesystem::File>(L, 2, FILESYSTEM_FILE_ID);
|
||||
|
||||
if (lua_isnoneornil(L, 3))
|
||||
{
|
||||
@@ -285,7 +285,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_imagedata(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "ImageData", functions);
|
||||
return luax_register_type(L, IMAGE_IMAGE_DATA_ID, functions);
|
||||
}
|
||||
|
||||
} // image
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace joystick
|
||||
|
||||
Joystick *luax_checkjoystick(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Joystick>(L, idx, "Joystick", JOYSTICK_JOYSTICK_T);
|
||||
return luax_checktype<Joystick>(L, idx, JOYSTICK_JOYSTICK_ID);
|
||||
}
|
||||
|
||||
int w_Joystick_isConnected(lua_State *L)
|
||||
@@ -255,7 +255,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_joystick(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Joystick", functions);
|
||||
return luax_register_type(L, JOYSTICK_JOYSTICK_ID, functions);
|
||||
}
|
||||
|
||||
} // joystick
|
||||
|
||||
@@ -40,7 +40,7 @@ int w_getJoysticks(lua_State *L)
|
||||
for (int i = 0; i < stickcount; i++)
|
||||
{
|
||||
Joystick *stick = instance()->getJoystick(i);
|
||||
luax_pushtype(L, "Joystick", JOYSTICK_JOYSTICK_T, stick);
|
||||
luax_pushtype(L, JOYSTICK_JOYSTICK_ID, stick);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ extern "C" int luaopen_love_joystick(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "joystick";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ extern "C" int luaopen_love_keyboard(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "keyboard";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = 0;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace math
|
||||
|
||||
BezierCurve *luax_checkbeziercurve(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<BezierCurve>(L, idx, "BezierCurve", MATH_BEZIER_CURVE_T);
|
||||
return luax_checktype<BezierCurve>(L, idx, MATH_BEZIER_CURVE_ID);
|
||||
}
|
||||
|
||||
int w_BezierCurve_getDegree(lua_State *L)
|
||||
@@ -44,7 +44,7 @@ int w_BezierCurve_getDerivative(lua_State *L)
|
||||
{
|
||||
BezierCurve *curve = luax_checkbeziercurve(L, 1);
|
||||
BezierCurve *deriv = new BezierCurve(curve->getDerivative());
|
||||
luax_pushtype(L, "BezierCurve", MATH_BEZIER_CURVE_T, deriv);
|
||||
luax_pushtype(L, MATH_BEZIER_CURVE_ID, deriv);
|
||||
deriv->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_beziercurve(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "BezierCurve", functions);
|
||||
return luax_register_type(L, MATH_BEZIER_CURVE_ID, functions);
|
||||
}
|
||||
|
||||
} // math
|
||||
|
||||
@@ -100,7 +100,7 @@ int w_newRandomGenerator(lua_State *L)
|
||||
return luaL_error(L, "%s", lua_tostring(L, -1));
|
||||
}
|
||||
|
||||
luax_pushtype(L, "RandomGenerator", MATH_RANDOM_GENERATOR_T, t);
|
||||
luax_pushtype(L, MATH_RANDOM_GENERATOR_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ int w_newBezierCurve(lua_State *L)
|
||||
}
|
||||
|
||||
BezierCurve *curve = Math::instance.newBezierCurve(points);
|
||||
luax_pushtype(L, "BezierCurve", MATH_BEZIER_CURVE_T, curve);
|
||||
luax_pushtype(L, MATH_BEZIER_CURVE_ID, curve);
|
||||
curve->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -384,7 +384,7 @@ extern "C" int luaopen_love_math(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = &Math::instance;
|
||||
w.name = "math";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ int luax_getrandom(lua_State *L, int startidx, double r)
|
||||
|
||||
RandomGenerator *luax_checkrandomgenerator(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<RandomGenerator>(L, idx, "RandomGenerator", MATH_RANDOM_GENERATOR_T);
|
||||
return luax_checktype<RandomGenerator>(L, idx, MATH_RANDOM_GENERATOR_ID);
|
||||
}
|
||||
|
||||
int w_RandomGenerator_random(lua_State *L)
|
||||
@@ -148,7 +148,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_randomgenerator(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "RandomGenerator", functions);
|
||||
return luax_register_type(L, MATH_RANDOM_GENERATOR_ID, functions);
|
||||
}
|
||||
|
||||
} // math
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace mouse
|
||||
|
||||
Cursor *luax_checkcursor(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Cursor>(L, idx, "Cursor", MOUSE_CURSOR_T);
|
||||
return luax_checktype<Cursor>(L, idx, MOUSE_CURSOR_ID);
|
||||
}
|
||||
|
||||
int w_Cursor_getType(lua_State *L)
|
||||
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_cursor(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Cursor", functions);
|
||||
return luax_register_type(L, MOUSE_CURSOR_ID, functions);
|
||||
}
|
||||
|
||||
} // mouse
|
||||
|
||||
@@ -36,16 +36,16 @@ int w_newCursor(lua_State *L)
|
||||
{
|
||||
Cursor *cursor = nullptr;
|
||||
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
|
||||
luax_convobj(L, 1, "image", "newImageData");
|
||||
|
||||
love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
|
||||
int hotx = luaL_optint(L, 2, 0);
|
||||
int hoty = luaL_optint(L, 3, 0);
|
||||
|
||||
luax_catchexcept(L, [&](){ cursor = instance()->newCursor(data, hotx, hoty); });
|
||||
|
||||
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
|
||||
luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
|
||||
cursor->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ int w_getSystemCursor(lua_State *L)
|
||||
Cursor *cursor = 0;
|
||||
luax_catchexcept(L, [&](){ cursor = instance()->getSystemCursor(systemCursor); });
|
||||
|
||||
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
|
||||
luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ int w_getCursor(lua_State *L)
|
||||
Cursor *cursor = instance()->getCursor();
|
||||
|
||||
if (cursor)
|
||||
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
|
||||
luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
@@ -242,7 +242,7 @@ extern "C" int luaopen_love_mouse(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "mouse";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ int Body::getFixtureList(lua_State *L) const
|
||||
Fixture *fixture = (Fixture *)Memoizer::find(f);
|
||||
if (!fixture)
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, fixture);
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
}
|
||||
@@ -483,7 +483,7 @@ int Body::getContactList(lua_State *L) const
|
||||
else
|
||||
contact->retain();
|
||||
|
||||
luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
|
||||
luax_pushtype(L, PHYSICS_CONTACT_ID, contact);
|
||||
contact->release();
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
|
||||
@@ -146,7 +146,7 @@ int Physics::newPolygonShape(lua_State *L)
|
||||
}
|
||||
|
||||
PolygonShape *p = new PolygonShape(s);
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, p);
|
||||
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, p);
|
||||
p->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ int Physics::newChainShape(lua_State *L)
|
||||
delete[] vecs;
|
||||
|
||||
ChainShape *c = new ChainShape(s);
|
||||
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, c);
|
||||
luax_pushtype(L, PHYSICS_CHAIN_SHAPE_ID, c);
|
||||
c->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -281,8 +281,8 @@ Fixture *Physics::newFixture(Body *body, Shape *shape, float density)
|
||||
|
||||
int Physics::getDistance(lua_State *L)
|
||||
{
|
||||
Fixture *fixtureA = luax_checktype<Fixture>(L, 1, "Fixture", PHYSICS_FIXTURE_T);
|
||||
Fixture *fixtureB = luax_checktype<Fixture>(L, 2, "Fixture", PHYSICS_FIXTURE_T);
|
||||
Fixture *fixtureA = luax_checktype<Fixture>(L, 1, PHYSICS_FIXTURE_ID);
|
||||
Fixture *fixtureB = luax_checktype<Fixture>(L, 2, PHYSICS_FIXTURE_ID);
|
||||
b2DistanceProxy pA, pB;
|
||||
b2DistanceInput i;
|
||||
b2DistanceOutput o;
|
||||
|
||||
@@ -57,7 +57,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
|
||||
{
|
||||
Fixture *a = (Fixture *)Memoizer::find(contact->GetFixtureA());
|
||||
if (a != 0)
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
|
||||
else
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
|
||||
{
|
||||
Fixture *b = (Fixture *)Memoizer::find(contact->GetFixtureB());
|
||||
if (b != 0)
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
|
||||
else
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
}
|
||||
@@ -77,7 +77,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
|
||||
else
|
||||
cobj->retain();
|
||||
|
||||
luax_pushtype(L, "Contact", (PHYSICS_CONTACT_T), cobj);
|
||||
luax_pushtype(L, PHYSICS_CONTACT_ID, cobj);
|
||||
cobj->release();
|
||||
|
||||
int args = 3;
|
||||
@@ -128,8 +128,8 @@ bool World::ContactFilter::process(Fixture *a, Fixture *b)
|
||||
{
|
||||
lua_State *L = ref->getL();
|
||||
ref->push();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
|
||||
lua_call(L, 2, 1);
|
||||
return luax_toboolean(L, -1);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ bool World::QueryCallback::ReportFixture(b2Fixture *fixture)
|
||||
Fixture *f = (Fixture *)Memoizer::find(fixture);
|
||||
if (!f)
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, f);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, f);
|
||||
lua_call(L, 1, 1);
|
||||
return luax_toboolean(L, -1);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ float32 World::RayCastCallback::ReportFixture(b2Fixture *fixture, const b2Vec2 &
|
||||
Fixture *f = (Fixture *)Memoizer::find(fixture);
|
||||
if (!f)
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, f);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, f);
|
||||
b2Vec2 scaledPoint = Physics::scaleUp(point);
|
||||
lua_pushnumber(L, scaledPoint.x);
|
||||
lua_pushnumber(L, scaledPoint.y);
|
||||
@@ -431,7 +431,7 @@ int World::getBodyList(lua_State *L) const
|
||||
Body *body = (Body *)Memoizer::find(b);
|
||||
if (!body)
|
||||
throw love::Exception("A body has escaped Memoizer!");
|
||||
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
|
||||
luax_pushtype(L, PHYSICS_BODY_ID, body);
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
}
|
||||
@@ -449,7 +449,7 @@ int World::getJointList(lua_State *L) const
|
||||
if (!j) break;
|
||||
Joint *joint = (Joint *)Memoizer::find(j);
|
||||
if (!joint) throw love::Exception("A joint has escaped Memoizer!");
|
||||
luax_pushtype(L, "Joint", PHYSICS_JOINT_T, joint);
|
||||
luax_pushtype(L, PHYSICS_JOINT_ID, joint);
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
}
|
||||
@@ -470,7 +470,7 @@ int World::getContactList(lua_State *L) const
|
||||
contact = new Contact(c);
|
||||
else
|
||||
contact->retain();
|
||||
luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
|
||||
luax_pushtype(L, PHYSICS_CONTACT_ID, contact);
|
||||
contact->release();
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
Body *luax_checkbody(lua_State *L, int idx)
|
||||
{
|
||||
Body *b = luax_checktype<Body>(L, idx, "Body", PHYSICS_BODY_T);
|
||||
Body *b = luax_checktype<Body>(L, idx, PHYSICS_BODY_ID);
|
||||
if (b->body == 0)
|
||||
luaL_error(L, "Attempt to use destroyed body.");
|
||||
return b;
|
||||
@@ -526,7 +526,7 @@ int w_Body_getWorld(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
World *world = t->getWorld();
|
||||
luax_pushtype(L, "World", PHYSICS_WORLD_T, world);
|
||||
luax_pushtype(L, PHYSICS_WORLD_ID, world);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ int w_Body_destroy(lua_State *L)
|
||||
|
||||
int w_Body_isDestroyed(lua_State *L)
|
||||
{
|
||||
Body *b = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *b = luax_checktype<Body>(L, 1, PHYSICS_BODY_ID);
|
||||
luax_pushboolean(L, b->body == nullptr);
|
||||
return 1;
|
||||
}
|
||||
@@ -650,7 +650,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_body(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Body", functions);
|
||||
return luax_register_type(L, PHYSICS_BODY_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace box2d
|
||||
|
||||
ChainShape *luax_checkchainshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<ChainShape>(L, idx, "ChainShape", PHYSICS_CHAIN_SHAPE_T);
|
||||
return luax_checktype<ChainShape>(L, idx, PHYSICS_CHAIN_SHAPE_ID);
|
||||
}
|
||||
|
||||
int w_ChainShape_setNextVertex(lua_State *L)
|
||||
@@ -65,7 +65,7 @@ int w_ChainShape_getChildEdge(lua_State *L)
|
||||
int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
|
||||
EdgeShape *e = 0;
|
||||
luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
|
||||
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, e);
|
||||
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, e);
|
||||
e->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_chainshape(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "ChainShape", functions);
|
||||
return luax_register_type(L, PHYSICS_CHAIN_SHAPE_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
CircleShape *luax_checkcircleshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<CircleShape>(L, idx, "CircleShape", PHYSICS_CIRCLE_SHAPE_T);
|
||||
return luax_checktype<CircleShape>(L, idx, PHYSICS_CIRCLE_SHAPE_ID);
|
||||
}
|
||||
|
||||
int w_CircleShape_getRadius(lua_State *L)
|
||||
@@ -83,7 +83,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_circleshape(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "CircleShape", functions);
|
||||
return luax_register_type(L, PHYSICS_CIRCLE_SHAPE_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
Contact *luax_checkcontact(lua_State *L, int idx)
|
||||
{
|
||||
Contact *c = luax_checktype<Contact>(L, idx, "Contact", PHYSICS_CONTACT_T);
|
||||
Contact *c = luax_checktype<Contact>(L, idx, PHYSICS_CONTACT_ID);
|
||||
if (!c->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed contact.");
|
||||
return c;
|
||||
@@ -146,14 +146,14 @@ int w_Contact_getFixtures(lua_State *L)
|
||||
Fixture *b = nullptr;
|
||||
luax_catchexcept(L, [&](){ t->getFixtures(a, b); });
|
||||
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_Contact_isDestroyed(lua_State *L)
|
||||
{
|
||||
Contact *c = luax_checktype<Contact>(L, 1, "Contact", PHYSICS_CONTACT_T);
|
||||
Contact *c = luax_checktype<Contact>(L, 1, PHYSICS_CONTACT_ID);
|
||||
luax_pushboolean(L, !c->isValid());
|
||||
return 1;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ extern "C" int luaopen_contact(lua_State *L)
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
return luax_register_type(L, "Contact", functions);
|
||||
return luax_register_type(L, PHYSICS_CONTACT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
DistanceJoint *luax_checkdistancejoint(lua_State *L, int idx)
|
||||
{
|
||||
DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T);
|
||||
DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, PHYSICS_DISTANCE_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -104,7 +104,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_distancejoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "DistanceJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_DISTANCE_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
EdgeShape *luax_checkedgeshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<EdgeShape>(L, idx, "EdgeShape", PHYSICS_EDGE_SHAPE_T);
|
||||
return luax_checktype<EdgeShape>(L, idx, PHYSICS_EDGE_SHAPE_ID);
|
||||
}
|
||||
|
||||
int w_EdgeShape_getPoints(lua_State *L)
|
||||
@@ -55,7 +55,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_edgeshape(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "EdgeShape", functions);
|
||||
return luax_register_type(L, PHYSICS_EDGE_SHAPE_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
Fixture *luax_checkfixture(lua_State *L, int idx)
|
||||
{
|
||||
Fixture *f = luax_checktype<Fixture>(L, idx, "Fixture", PHYSICS_FIXTURE_T);
|
||||
Fixture *f = luax_checktype<Fixture>(L, idx, PHYSICS_FIXTURE_ID);
|
||||
if (!f->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed fixture.");
|
||||
return f;
|
||||
@@ -111,7 +111,7 @@ int w_Fixture_getBody(lua_State *L)
|
||||
Body *body = t->getBody();
|
||||
if (body == 0)
|
||||
return 0;
|
||||
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
|
||||
luax_pushtype(L, PHYSICS_BODY_ID, body);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -124,19 +124,19 @@ int w_Fixture_getShape(lua_State *L)
|
||||
switch (shape->getType())
|
||||
{
|
||||
case Shape::SHAPE_EDGE:
|
||||
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, shape);
|
||||
break;
|
||||
case Shape::SHAPE_CHAIN:
|
||||
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_CHAIN_SHAPE_ID, shape);
|
||||
break;
|
||||
case Shape::SHAPE_CIRCLE:
|
||||
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
|
||||
break;
|
||||
case Shape::SHAPE_POLYGON:
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
|
||||
break;
|
||||
default:
|
||||
luax_pushtype(L, "Shape", PHYSICS_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_SHAPE_ID, shape);
|
||||
break;
|
||||
}
|
||||
shape->release();
|
||||
@@ -264,7 +264,7 @@ int w_Fixture_destroy(lua_State *L)
|
||||
|
||||
int w_Fixture_isDestroyed(lua_State *L)
|
||||
{
|
||||
Fixture *f = luax_checktype<Fixture>(L, 1, "Fixture", PHYSICS_FIXTURE_T);
|
||||
Fixture *f = luax_checktype<Fixture>(L, 1, PHYSICS_FIXTURE_ID);
|
||||
luax_pushboolean(L, !f->isValid());
|
||||
return 1;
|
||||
}
|
||||
@@ -303,7 +303,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_fixture(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Fixture", functions);
|
||||
return luax_register_type(L, PHYSICS_FIXTURE_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
FrictionJoint *luax_checkfrictionjoint(lua_State *L, int idx)
|
||||
{
|
||||
FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, "FrictionJoint", PHYSICS_FRICTION_JOINT_T);
|
||||
FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, PHYSICS_FRICTION_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -88,7 +88,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_frictionjoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "FrictionJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_FRICTION_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
GearJoint *luax_checkgearjoint(lua_State *L, int idx)
|
||||
{
|
||||
GearJoint *j = luax_checktype<GearJoint>(L, idx, "GearJoint", PHYSICS_GEAR_JOINT_T);
|
||||
GearJoint *j = luax_checktype<GearJoint>(L, idx, PHYSICS_GEAR_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -88,7 +88,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_gearjoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "GearJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_GEAR_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -38,27 +38,27 @@ void luax_pushjoint(lua_State *L, Joint *j)
|
||||
switch (j->getType())
|
||||
{
|
||||
case Joint::JOINT_DISTANCE:
|
||||
return luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_DISTANCE_JOINT_ID, j);
|
||||
case Joint::JOINT_REVOLUTE:
|
||||
return luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
|
||||
case Joint::JOINT_PRISMATIC:
|
||||
return luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
|
||||
case Joint::JOINT_MOUSE:
|
||||
return luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_MOUSE_JOINT_ID, j);
|
||||
case Joint::JOINT_PULLEY:
|
||||
return luax_pushtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_PULLEY_JOINT_ID, j);
|
||||
case Joint::JOINT_GEAR:
|
||||
return luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_GEAR_JOINT_ID, j);
|
||||
case Joint::JOINT_FRICTION:
|
||||
return luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_FRICTION_JOINT_ID, j);
|
||||
case Joint::JOINT_WELD:
|
||||
return luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
|
||||
case Joint::JOINT_WHEEL:
|
||||
return luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_WHEEL_JOINT_ID, j);
|
||||
case Joint::JOINT_ROPE:
|
||||
return luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_ROPE_JOINT_ID, j);
|
||||
case Joint::JOINT_MOTOR:
|
||||
return luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
|
||||
return luax_pushtype(L, PHYSICS_MOTOR_JOINT_ID, j);
|
||||
default:
|
||||
return lua_pushnil(L);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void luax_pushjoint(lua_State *L, Joint *j)
|
||||
|
||||
Joint *luax_checkjoint(lua_State *L, int idx)
|
||||
{
|
||||
Joint *t = luax_checktype<Joint>(L, idx, "Joint", PHYSICS_JOINT_T);
|
||||
Joint *t = luax_checktype<Joint>(L, idx, PHYSICS_JOINT_ID);
|
||||
if (!t->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return t;
|
||||
@@ -92,8 +92,8 @@ int w_Joint_getBodies(lua_State *L)
|
||||
b2 = t->getBodyB();
|
||||
});
|
||||
|
||||
luax_pushtype(L, "Body", PHYSICS_BODY_T, b1);
|
||||
luax_pushtype(L, "Body", PHYSICS_BODY_T, b2);
|
||||
luax_pushtype(L, PHYSICS_BODY_ID, b1);
|
||||
luax_pushtype(L, PHYSICS_BODY_ID, b2);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ int w_Joint_destroy(lua_State *L)
|
||||
|
||||
int w_Joint_isDestroyed(lua_State *L)
|
||||
{
|
||||
Joint *t = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
|
||||
Joint *t = luax_checktype<Joint>(L, 1, PHYSICS_JOINT_ID);
|
||||
luax_pushboolean(L, !t->isValid());
|
||||
return 1;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_joint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Joint", functions);
|
||||
return luax_register_type(L, PHYSICS_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
MotorJoint *luax_checkmotorjoint(lua_State *L, int idx)
|
||||
{
|
||||
MotorJoint *j = luax_checktype<MotorJoint>(L, idx, "MotorJoint", PHYSICS_MOTOR_JOINT_T);
|
||||
MotorJoint *j = luax_checktype<MotorJoint>(L, idx, PHYSICS_MOTOR_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -138,7 +138,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_motorjoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "MotorJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_MOTOR_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
MouseJoint *luax_checkmousejoint(lua_State *L, int idx)
|
||||
{
|
||||
MouseJoint *j = luax_checktype<MouseJoint>(L, idx, "MouseJoint", PHYSICS_MOUSE_JOINT_T);
|
||||
MouseJoint *j = luax_checktype<MouseJoint>(L, idx, PHYSICS_MOUSE_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -122,7 +122,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_mousejoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "MouseJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_MOUSE_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -59,7 +59,7 @@ int w_newWorld(lua_State *L)
|
||||
|
||||
World *w;
|
||||
luax_catchexcept(L, [&](){ w = instance()->newWorld(gx, gy, sleep); });
|
||||
luax_pushtype(L, "World", PHYSICS_WORLD_T, w);
|
||||
luax_pushtype(L, PHYSICS_WORLD_ID, w);
|
||||
w->release();
|
||||
|
||||
return 1;
|
||||
@@ -67,7 +67,7 @@ int w_newWorld(lua_State *L)
|
||||
|
||||
int w_newBody(lua_State *L)
|
||||
{
|
||||
World *world = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
|
||||
World *world = luax_checkworld(L, 1);
|
||||
float x = (float)luaL_optnumber(L, 2, 0.0);
|
||||
float y = (float)luaL_optnumber(L, 3, 0.0);
|
||||
|
||||
@@ -78,7 +78,7 @@ int w_newBody(lua_State *L)
|
||||
|
||||
Body *body;
|
||||
luax_catchexcept(L, [&](){ body = instance()->newBody(world, x, y, btype); });
|
||||
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
|
||||
luax_pushtype(L, PHYSICS_BODY_ID, body);
|
||||
body->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ int w_newFixture(lua_State *L)
|
||||
float density = (float)luaL_optnumber(L, 3, 1.0f);
|
||||
Fixture *fixture;
|
||||
luax_catchexcept(L, [&](){ fixture = instance()->newFixture(body, shape, density); });
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
|
||||
luax_pushtype(L, PHYSICS_FIXTURE_ID, fixture);
|
||||
fixture->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ int w_newCircleShape(lua_State *L)
|
||||
float radius = (float)luaL_checknumber(L, 1);
|
||||
CircleShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(radius); });
|
||||
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ int w_newCircleShape(lua_State *L)
|
||||
float radius = (float)luaL_checknumber(L, 3);
|
||||
CircleShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(x, y, radius); });
|
||||
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ int w_newRectangleShape(lua_State *L)
|
||||
float h = (float)luaL_checknumber(L, 2);
|
||||
PolygonShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(w, h); });
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ int w_newRectangleShape(lua_State *L)
|
||||
float angle = (float)luaL_optnumber(L, 5, 0);
|
||||
PolygonShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(x, y, w, h, angle); });
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ int w_newEdgeShape(lua_State *L)
|
||||
float y2 = (float)luaL_checknumber(L, 4);
|
||||
EdgeShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newEdgeShape(x1, y1, x2, y2); });
|
||||
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, shape);
|
||||
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -183,8 +183,8 @@ int w_newChainShape(lua_State *L)
|
||||
|
||||
int w_newDistanceJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
float x1 = (float)luaL_checknumber(L, 3);
|
||||
float y1 = (float)luaL_checknumber(L, 4);
|
||||
float x2 = (float)luaL_checknumber(L, 5);
|
||||
@@ -194,27 +194,27 @@ int w_newDistanceJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_DISTANCE_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newMouseJoint(lua_State *L)
|
||||
{
|
||||
Body *body = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body = luax_checkbody(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
MouseJoint *j;
|
||||
luax_catchexcept(L, [&](){ j = instance()->newMouseJoint(body, x, y); });
|
||||
luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_MOUSE_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newRevoluteJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
float x = (float)luaL_checknumber(L, 3);
|
||||
float y = (float)luaL_checknumber(L, 4);
|
||||
bool collideConnected = luax_optboolean(L, 5, false);
|
||||
@@ -222,15 +222,15 @@ int w_newRevoluteJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newRevoluteJoint(body1, body2, x, y, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newPrismaticJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
float xA = (float)luaL_checknumber(L, 3);
|
||||
float yA = (float)luaL_checknumber(L, 4);
|
||||
float xB, yB, ax, ay;
|
||||
@@ -255,15 +255,15 @@ int w_newPrismaticJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newPulleyJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
float gx1 = (float)luaL_checknumber(L, 3);
|
||||
float gy1 = (float)luaL_checknumber(L, 4);
|
||||
float gx2 = (float)luaL_checknumber(L, 5);
|
||||
@@ -279,15 +279,15 @@ int w_newPulleyJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_PULLEY_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newGearJoint(lua_State *L)
|
||||
{
|
||||
Joint *joint1 = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
|
||||
Joint *joint2 = luax_checktype<Joint>(L, 2, "Joint", PHYSICS_JOINT_T);
|
||||
Joint *joint1 = luax_checkjoint(L, 1);
|
||||
Joint *joint2 = luax_checkjoint(L, 2);
|
||||
float ratio = (float)luaL_optnumber(L, 3, 1.0);
|
||||
bool collideConnected = luax_optboolean(L, 4, false);
|
||||
|
||||
@@ -295,15 +295,15 @@ int w_newGearJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newGearJoint(joint1, joint2, ratio, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_GEAR_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newFrictionJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
float xA = (float)luaL_checknumber(L, 3);
|
||||
float yA = (float)luaL_checknumber(L, 4);
|
||||
float xB, yB;
|
||||
@@ -324,15 +324,15 @@ int w_newFrictionJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_FRICTION_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newWeldJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
float xA = (float)luaL_checknumber(L, 3);
|
||||
float yA = (float)luaL_checknumber(L, 4);
|
||||
float xB, yB;
|
||||
@@ -353,15 +353,15 @@ int w_newWeldJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newWheelJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
float xA = (float)luaL_checknumber(L, 3);
|
||||
float yA = (float)luaL_checknumber(L, 4);
|
||||
float xB, yB, ax, ay;
|
||||
@@ -387,15 +387,15 @@ int w_newWheelJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_WHEEL_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newRopeJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
float x1 = (float)luaL_checknumber(L, 3);
|
||||
float y1 = (float)luaL_checknumber(L, 4);
|
||||
float x2 = (float)luaL_checknumber(L, 5);
|
||||
@@ -406,15 +406,15 @@ int w_newRopeJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_ROPE_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newMotorJoint(lua_State *L)
|
||||
{
|
||||
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
|
||||
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
|
||||
Body *body1 = luax_checkbody(L, 1);
|
||||
Body *body2 = luax_checkbody(L, 2);
|
||||
MotorJoint *j = 0;
|
||||
if (!lua_isnoneornil(L, 3))
|
||||
{
|
||||
@@ -427,7 +427,7 @@ int w_newMotorJoint(lua_State *L)
|
||||
{
|
||||
luax_catchexcept(L, [&](){ j = instance()->newMotorJoint(body1, body2); });
|
||||
}
|
||||
luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
|
||||
luax_pushtype(L, PHYSICS_MOTOR_JOINT_ID, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -517,7 +517,7 @@ extern "C" int luaopen_love_physics(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "physics";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
PolygonShape *luax_checkpolygonshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<PolygonShape>(L, idx, "PolygonShape", PHYSICS_POLYGON_SHAPE_T);
|
||||
return luax_checktype<PolygonShape>(L, idx, PHYSICS_POLYGON_SHAPE_ID);
|
||||
}
|
||||
|
||||
int w_PolygonShape_getPoints(lua_State *L)
|
||||
@@ -63,7 +63,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_polygonshape(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "PolygonShape", functions);
|
||||
return luax_register_type(L, PHYSICS_POLYGON_SHAPE_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
PrismaticJoint *luax_checkprismaticjoint(lua_State *L, int idx)
|
||||
{
|
||||
PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T);
|
||||
PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, PHYSICS_PRISMATIC_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -199,7 +199,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_prismaticjoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "PrismaticJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_PRISMATIC_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
PulleyJoint *luax_checkpulleyjoint(lua_State *L, int idx)
|
||||
{
|
||||
PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, "PulleyJoint", PHYSICS_PULLEY_JOINT_T);
|
||||
PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, PHYSICS_PULLEY_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -85,7 +85,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_pulleyjoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "PulleyJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_PULLEY_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
RevoluteJoint *luax_checkrevolutejoint(lua_State *L, int idx)
|
||||
{
|
||||
RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T);
|
||||
RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, PHYSICS_REVOLUTE_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -199,7 +199,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_revolutejoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "RevoluteJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_REVOLUTE_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
RopeJoint *luax_checkropejoint(lua_State *L, int idx)
|
||||
{
|
||||
RopeJoint *j = luax_checktype<RopeJoint>(L, idx, "RopeJoint", PHYSICS_ROPE_JOINT_T);
|
||||
RopeJoint *j = luax_checktype<RopeJoint>(L, idx, PHYSICS_ROPE_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_ropejoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "RopeJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_ROPE_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
Shape *luax_checkshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Shape>(L, idx, "Shape", PHYSICS_SHAPE_T);
|
||||
return luax_checktype<Shape>(L, idx, PHYSICS_SHAPE_ID);
|
||||
}
|
||||
|
||||
int w_Shape_getType(lua_State *L)
|
||||
@@ -108,7 +108,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_shape(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Shape", functions);
|
||||
return luax_register_type(L, PHYSICS_SHAPE_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
WeldJoint *luax_checkweldjoint(lua_State *L, int idx)
|
||||
{
|
||||
WeldJoint *j = luax_checktype<WeldJoint>(L, idx, "WeldJoint", PHYSICS_WELD_JOINT_T);
|
||||
WeldJoint *j = luax_checktype<WeldJoint>(L, idx, PHYSICS_WELD_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -87,7 +87,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_weldjoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "WeldJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_WELD_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
WheelJoint *luax_checkwheeljoint(lua_State *L, int idx)
|
||||
{
|
||||
WheelJoint *j = luax_checktype<WheelJoint>(L, idx, "WheelJoint", PHYSICS_WHEEL_JOINT_T);
|
||||
WheelJoint *j = luax_checktype<WheelJoint>(L, idx, PHYSICS_WHEEL_JOINT_ID);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
@@ -163,7 +163,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_wheeljoint(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "WheelJoint", functions);
|
||||
return luax_register_type(L, PHYSICS_WHEEL_JOINT_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
World *luax_checkworld(lua_State *L, int idx)
|
||||
{
|
||||
World *w = luax_checktype<World>(L, idx, "World", PHYSICS_WORLD_T);
|
||||
World *w = luax_checktype<World>(L, idx, PHYSICS_WORLD_ID);
|
||||
if (!w->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed world.");
|
||||
return w;
|
||||
@@ -191,7 +191,7 @@ int w_World_destroy(lua_State *L)
|
||||
|
||||
int w_World_isDestroyed(lua_State *L)
|
||||
{
|
||||
World *w = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
|
||||
World *w = luax_checktype<World>(L, 1, PHYSICS_WORLD_ID);
|
||||
luax_pushboolean(L, !w->isValid());
|
||||
return 1;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_world(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "World", functions);
|
||||
return luax_register_type(L, PHYSICS_WORLD_ID, functions);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace sound
|
||||
|
||||
Decoder *luax_checkdecoder(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Decoder>(L, idx, "Decoder", SOUND_DECODER_T);
|
||||
return luax_checktype<Decoder>(L, idx, SOUND_DECODER_ID);
|
||||
}
|
||||
|
||||
int w_Decoder_getChannels(lua_State *L)
|
||||
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_decoder(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Decoder", functions);
|
||||
return luax_register_type(L, SOUND_DECODER_ID, functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
|
||||
@@ -49,7 +49,7 @@ int w_newSoundData(lua_State *L)
|
||||
else
|
||||
{
|
||||
// Convert to Decoder, if necessary.
|
||||
if (!luax_istype(L, 1, SOUND_DECODER_T))
|
||||
if (!luax_istype(L, 1, SOUND_DECODER_ID))
|
||||
{
|
||||
w_newDecoder(L);
|
||||
lua_replace(L, 1);
|
||||
@@ -58,7 +58,7 @@ int w_newSoundData(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ t = instance()->newSoundData(luax_checkdecoder(L, 1)); });
|
||||
}
|
||||
|
||||
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, t);
|
||||
luax_pushtype(L, SOUND_SOUND_DATA_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ int w_newDecoder(lua_State *L)
|
||||
if (t == nullptr)
|
||||
return luaL_error(L, "Extension \"%s\" not supported.", data->getExtension().c_str());
|
||||
|
||||
luax_pushtype(L, "Decoder", SOUND_DECODER_T, t);
|
||||
luax_pushtype(L, SOUND_DECODER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ extern "C" int luaopen_love_sound(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "sound";
|
||||
w.flags = MODULE_SOUND_T;
|
||||
w.type = MODULE_SOUND_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace sound
|
||||
|
||||
SoundData *luax_checksounddata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<SoundData>(L, idx, "SoundData", SOUND_SOUND_DATA_T);
|
||||
return luax_checktype<SoundData>(L, idx, SOUND_SOUND_DATA_ID);
|
||||
}
|
||||
|
||||
int w_SoundData_getChannels(lua_State *L)
|
||||
@@ -105,7 +105,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_sounddata(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "SoundData", functions);
|
||||
return luax_register_type(L, SOUND_SOUND_DATA_ID, functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
|
||||
@@ -110,7 +110,7 @@ extern "C" int luaopen_love_system(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "system";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = nullptr;
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ void LuaThread::onError()
|
||||
return;
|
||||
|
||||
Proxy p;
|
||||
p.flags = THREAD_THREAD_T;
|
||||
p.type = THREAD_THREAD_ID;
|
||||
p.object = this;
|
||||
|
||||
std::vector<StrongRef<Variant>> vargs = {
|
||||
|
||||
@@ -40,7 +40,7 @@ void releaseVariant(Channel *c, Variant *v)
|
||||
|
||||
Channel *luax_checkchannel(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Channel>(L, idx, "Channel", THREAD_CHANNEL_T);
|
||||
return luax_checktype<Channel>(L, idx, THREAD_CHANNEL_ID);
|
||||
}
|
||||
|
||||
int w_Channel_push(lua_State *L)
|
||||
@@ -129,7 +129,7 @@ static const luaL_Reg type_functions[] = {
|
||||
|
||||
extern "C" int luaopen_channel(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Channel", type_functions);
|
||||
return luax_register_type(L, THREAD_CHANNEL_ID, type_functions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace thread
|
||||
|
||||
LuaThread *luax_checkthread(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<LuaThread>(L, idx, "Thread", THREAD_THREAD_T);
|
||||
return luax_checktype<LuaThread>(L, idx, THREAD_THREAD_ID);
|
||||
}
|
||||
|
||||
int w_Thread_start(lua_State *L)
|
||||
@@ -91,7 +91,7 @@ static const luaL_Reg type_functions[] = {
|
||||
|
||||
extern "C" int luaopen_thread(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Thread", type_functions);
|
||||
return luax_register_type(L, THREAD_THREAD_ID, type_functions);
|
||||
}
|
||||
|
||||
} // thread
|
||||
|
||||
@@ -61,22 +61,22 @@ int w_newThread(lua_State *L)
|
||||
else
|
||||
luax_convobj(L, 1, "filesystem", "newFileData");
|
||||
}
|
||||
else if (luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
else if (luax_istype(L, 1, FILESYSTEM_FILE_ID))
|
||||
luax_convobj(L, 1, "filesystem", "newFileData");
|
||||
|
||||
if (luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
|
||||
if (luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
|
||||
{
|
||||
love::filesystem::FileData *fdata = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
|
||||
love::filesystem::FileData *fdata = luax_checktype<love::filesystem::FileData>(L, 1, FILESYSTEM_FILE_DATA_ID);
|
||||
name = std::string("@") + fdata->getFilename();
|
||||
data = fdata;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = luax_checktype<love::Data>(L, 1, "Data", DATA_T);
|
||||
data = luax_checktype<love::Data>(L, 1, DATA_ID);
|
||||
}
|
||||
|
||||
LuaThread *t = instance()->newThread(name, data);
|
||||
luax_pushtype(L, "Thread", THREAD_THREAD_T, t);
|
||||
luax_pushtype(L, THREAD_THREAD_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ int w_newThread(lua_State *L)
|
||||
int w_newChannel(lua_State *L)
|
||||
{
|
||||
Channel *c = instance()->newChannel();
|
||||
luax_pushtype(L, "Channel", THREAD_CHANNEL_T, c);
|
||||
luax_pushtype(L, THREAD_CHANNEL_ID, c);
|
||||
c->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ int w_getChannel(lua_State *L)
|
||||
{
|
||||
std::string name = luax_checkstring(L, 1);
|
||||
Channel *c = instance()->getChannel(name);
|
||||
luax_pushtype(L, "Channel", THREAD_CHANNEL_T, c);
|
||||
luax_pushtype(L, THREAD_CHANNEL_ID, c);
|
||||
c->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ extern "C" int luaopen_love_thread(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "thread";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = module_functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ extern "C" int luaopen_love_timer(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "timer";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = 0;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ extern "C" int luaopen_love_touch(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "touch";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = nullptr;
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ int w_getPosition(lua_State *L)
|
||||
|
||||
int w_setIcon(lua_State *L)
|
||||
{
|
||||
image::ImageData *i = luax_checktype<image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
image::ImageData *i = luax_checktype<image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
|
||||
luax_pushboolean(L, instance()->setIcon(i));
|
||||
return 1;
|
||||
}
|
||||
@@ -300,10 +300,7 @@ int w_setIcon(lua_State *L)
|
||||
int w_getIcon(lua_State *L)
|
||||
{
|
||||
image::ImageData *i = instance()->getIcon();
|
||||
if (i)
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, i);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -500,7 +497,7 @@ extern "C" int luaopen_love_window(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "window";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user