Make love::Type handle type names

TODO: Fix undefined behaviour in luax_register_type, you can't use a va_list after a reference type

--HG--
branch : dynamiccore2
This commit is contained in:
Bart van Strien
2016-11-14 21:06:53 +01:00
parent 5d43c9601a
commit d967a755e5
110 changed files with 177 additions and 186 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ namespace
namespace love
{
love::Type Module::type(&Object::type);
love::Type Module::type("Module", &Object::type);
Module *Module::instances[] = {};
Module::~Module()
+1 -1
View File
@@ -24,7 +24,7 @@
namespace love
{
love::Type Object::type({});
love::Type Object::type("Object", nullptr);
Object::Object()
: count(1)
+21 -27
View File
@@ -67,9 +67,11 @@ static int w__type(lua_State *L)
static int w__typeOf(lua_State *L)
{
Proxy *p = (Proxy *)lua_touserdata(L, 1);
//Type t = luax_type(L, 2);
love::Type &t = Object::type; // FIXME
luax_pushboolean(L, p->type->isa(t));
Type *t = luax_type(L, 2);
if (!t)
luax_pushboolean(L, false);
else
luax_pushboolean(L, p->type->isa(*t));
return 1;
}
@@ -249,7 +251,7 @@ int luax_require(lua_State *L, const char *name)
int luax_register_module(lua_State *L, const WrappedModule &m)
{
love::addTypeName(m.type->getId(), m.name);
m.type->init();
// Put a reference to the C++ module in Lua.
luax_insistregistry(L, REGISTRY_MODULES);
@@ -305,9 +307,9 @@ int luax_preload(lua_State *L, lua_CFunction f, const char *name)
return 0;
}
int luax_register_type(lua_State *L, love::Type &type, const char *name, ...)
int luax_register_type(lua_State *L, love::Type &type, ...)
{
love::addTypeName(type.getId(), name);
type.init();
// Get the place for storing and re-using instantiated love types.
luax_getregistry(L, REGISTRY_OBJECTS);
@@ -334,7 +336,7 @@ int luax_register_type(lua_State *L, love::Type &type, const char *name, ...)
else
lua_pop(L, 1);
luaL_newmetatable(L, name);
luaL_newmetatable(L, type.getName());
// m.__index = m
lua_pushvalue(L, -1);
@@ -349,12 +351,12 @@ int luax_register_type(lua_State *L, love::Type &type, const char *name, ...)
lua_setfield(L, -2, "__eq");
// Add tostring function.
lua_pushstring(L, name);
lua_pushstring(L, type.getName());
lua_pushcclosure(L, w__tostring, 1);
lua_setfield(L, -2, "__tostring");
// Add type
lua_pushstring(L, name);
lua_pushstring(L, type.getName());
lua_pushcclosure(L, w__type, 1);
lua_setfield(L, -2, "type");
@@ -367,7 +369,7 @@ int luax_register_type(lua_State *L, love::Type &type, const char *name, ...)
lua_setfield(L, -2, "release");
va_list fs;
va_start(fs, name);
va_start(fs, type);
for (const luaL_Reg *f = va_arg(fs, const luaL_Reg *); f; f = va_arg(fs, const luaL_Reg *))
luax_setfuncs(L, f);
va_end(fs);
@@ -378,11 +380,8 @@ int luax_register_type(lua_State *L, love::Type &type, const char *name, ...)
void luax_gettypemetatable(lua_State *L, love::Type &type)
{
const char *name = nullptr;
if (getTypeName(type.getId(), name))
lua_getfield(L, LUA_REGISTRYINDEX, name);
else
lua_pushnil(L);
const char *name = type.getName();
lua_getfield(L, LUA_REGISTRYINDEX, name);
}
int luax_table_insert(lua_State *L, int tindex, int vindex, int pos)
@@ -447,9 +446,7 @@ void luax_rawnewtype(lua_State *L, love::Type &type, love::Object *object)
u->object = object;
u->type = &type;
const char *name = "Invalid";
getTypeName(type.getId(), name);
const char *name = type.getName();
luaL_newmetatable(L, name);
lua_setmetatable(L, -2);
}
@@ -706,7 +703,7 @@ lua_State *luax_getpinnedthread(lua_State *L)
extern "C" int luax_typerror(lua_State *L, int narg, const char *tname)
{
int argtype = lua_type(L, narg);
const char *argtname = 0;
const char *argtname = nullptr;
// We want to use the love type name for userdata, if possible.
if (argtype == LUA_TUSERDATA && luaL_getmetafield(L, narg, "type") != 0)
@@ -718,13 +715,12 @@ extern "C" int luax_typerror(lua_State *L, int narg, const char *tname)
// Non-love userdata might have a type metamethod which doesn't
// describe its type properly, so we only use it for love types.
uint32_t t;
if (!love::getTypeName(argtname, t))
argtname = 0;
if (!Type::byName(argtname))
argtname = nullptr;
}
}
if (argtname == 0)
if (argtname == nullptr)
argtname = lua_typename(L, argtype);
const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, argtname);
@@ -753,11 +749,9 @@ void luax_register(lua_State *L, const char *name, const luaL_Reg *l)
}
}
uint32_t luax_type(lua_State *L, int idx)
Type *luax_type(lua_State *L, int idx)
{
uint32_t t = 0;
getTypeName(luaL_checkstring(L, idx), t);
return t;
return Type::byName(luaL_checkstring(L, idx));
}
} // love
+6 -10
View File
@@ -253,7 +253,7 @@ int luax_preload(lua_State *L, lua_CFunction f, const char *name);
* @param name The type's human-readable name
* @param ... The list of lists of member functions for the type. (of type luaL_Reg*)
**/
int luax_register_type(lua_State *L, love::Type &type, const char *name, ...);
int luax_register_type(lua_State *L, love::Type &type, ...);
/**
* Pushes the metatable of the specified type onto the stack.
@@ -453,8 +453,7 @@ T *luax_checktype(lua_State *L, int idx, love::Type &type)
{
if (lua_type(L, idx) != LUA_TUSERDATA)
{
const char *name = "Invalid";
getTypeName(type.getId(), name);
const char *name = type.getName();
luax_typerror(L, idx, name);
}
@@ -462,8 +461,7 @@ T *luax_checktype(lua_State *L, int idx, love::Type &type)
if (u->type == nullptr || !u->type->isa(type))
{
const char *name = "Invalid";
getTypeName(type.getId(), name);
const char *name = type.getName();
luax_typerror(L, idx, name);
}
@@ -482,8 +480,7 @@ T *luax_checktype(lua_State *L, int idx)
template <typename T>
T *luax_getmodule(lua_State *L, love::Type &type)
{
const char *name = "Invalid";
getTypeName(type.getId(), name);
const char *name = type.getName();
luax_insistregistry(L, REGISTRY_MODULES);
lua_getfield(L, -1, name);
@@ -510,8 +507,7 @@ T *luax_getmodule(lua_State *L)
template <typename T>
T *luax_optmodule(lua_State *L, love::Type &type)
{
const char *name = "Invalid";
getTypeName(type.getId(), name);
const char *name = type.getName();
luax_insistregistry(L, REGISTRY_MODULES);
lua_getfield(L, -1, name);
@@ -563,7 +559,7 @@ T *luax_totype(lua_State *L, int idx)
return luax_totype<T>(L, idx, T::type);
}
uint32 luax_type(lua_State *L, int idx);
Type *luax_type(lua_State *L, int idx);
/**
* Converts any exceptions thrown by the passed lambda function into a Lua error.
+35 -30
View File
@@ -18,41 +18,33 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
// STL
#include <unordered_map>
#include "types.h"
#include "StringMap.h"
namespace love
{
static StringMap<uint32, love::Type::MAX_TYPES> types(nullptr, 0);
void addTypeName(uint32 type, const char *name)
{
const char *n;
if (!types.find(type, n))
types.add(name, type);
}
bool getTypeName(const char *in, uint32 &out)
{
return types.find(in, out);
}
bool getTypeName(uint32 in, const char *&out)
{
return types.find(in, out);
}
static std::unordered_map<std::string, Type*> types;
uint32 love::Type::nextId = 1;
Type::Type(Type *parent)
: inited(false)
Type::Type(const char *name, Type *parent)
: name(name)
, parent(parent)
, inited(false)
{
}
void love::Type::init()
void Type::init()
{
// Make sure we don't init twice, that would be bad
if (inited)
return;
// Note: we add it here, not in the constructor, because some Types can get initialized before the map!
types[name] = this;
id = nextId++;
bits[id] = true;
inited = true;
@@ -64,27 +56,40 @@ void love::Type::init()
bits |= parent->bits;
}
uint32 love::Type::getId()
uint32 Type::getId()
{
if (!inited)
init();
return id;
}
bool love::Type::isa(const uint32 &other)
bool Type::isa(const uint32 &other)
{
if (!inited)
init();
return bits[other];
}
bool love::Type::isa(love::Type &other)
bool Type::isa(love::Type &other)
{
if (!other.inited)
other.init();
return isa(other.id);
}
const char *Type::getName() const
{
return name;
}
Type *Type::byName(const char *name)
{
auto pos = types.find(name);
if (pos == types.end())
return nullptr;
return pos->second;
}
} // love
// FIXME: Move this to the relevant files
@@ -94,8 +99,8 @@ bool love::Type::isa(love::Type &other)
#include "filesystem/Filesystem.h"
#include "image/Image.h"
love::Type love::Data::type(&Object::type);
love::Type love::Stream::type(&Object::type);
love::Type love::graphics::Drawable::type(&Object::type);
love::Type love::filesystem::Filesystem::type(&Module::type);
love::Type love::image::Image::type(&Module::type);
love::Type love::Data::type("Data", &Object::type);
love::Type love::Stream::type("Stream", &Object::type);
love::Type love::graphics::Drawable::type("Drawable", &Object::type);
love::Type love::filesystem::Filesystem::type("filesystem", &Module::type);
love::Type love::image::Image::type("image", &Module::type);
+8 -10
View File
@@ -30,31 +30,29 @@
namespace love
{
void addTypeName(uint32 type, const char *name);
bool getTypeName(const char *in, uint32 &out);
bool getTypeName(uint32 in, const char *&out);
class Type
{
public:
static const uint32 MAX_TYPES = 128;
// TODO: Type-checking templated constructor
Type(Type *parent);
Type(const char *name, Type *parent);
Type(const Type&) = delete;
void init();
uint32 getId();
bool isa(const uint32 &other);
bool isa(Type &other);
const char *getName() const;
static Type *byName(const char *name);
private:
static uint32 nextId;
void init();
bool inited;
Type *parent;
const char * const name;
Type * const parent;
uint32 id;
bool inited;
std::bitset<MAX_TYPES> bits;
};
+1 -1
View File
@@ -59,7 +59,7 @@ const luaL_Reg w_Data_functions[] =
int w_Data_open(lua_State *L)
{
luax_register_type(L, Data::type, "Data", w_Data_functions, nullptr);
luax_register_type(L, Data::type, w_Data_functions, nullptr);
return 0;
}
+1 -1
View File
@@ -25,7 +25,7 @@ namespace love
namespace audio
{
love::Type Source::type(&Object::type);
love::Type Source::type("Source", &Object::type);
Source::Source(Type sourceType)
: sourceType(sourceType)
+1 -1
View File
@@ -450,7 +450,7 @@ static const luaL_Reg w_Source_functions[] =
extern "C" int luaopen_source(lua_State *L)
{
return luax_register_type(L, love::audio::Source::type, "Source", w_Source_functions, nullptr);
return luax_register_type(L, love::audio::Source::type, w_Source_functions, nullptr);
}
} // audio
+1 -1
View File
@@ -37,7 +37,7 @@ namespace love
namespace filesystem
{
love::Type DroppedFile::type(&File::type);
love::Type DroppedFile::type("DroppedFile", &File::type);
DroppedFile::DroppedFile(const std::string &filename)
: filename(filename)
+1 -1
View File
@@ -25,7 +25,7 @@ namespace love
namespace filesystem
{
love::Type File::type(&Object::type);
love::Type File::type("File", &Object::type);
File::~File()
{
+1 -1
View File
@@ -29,7 +29,7 @@ namespace love
namespace filesystem
{
love::Type FileData::type(&Data::type);
love::Type FileData::type("FileData", &Data::type);
FileData::FileData(uint64 size, const std::string &filename)
: data(nullptr)
+1 -1
View File
@@ -33,7 +33,7 @@ DroppedFile *luax_checkdroppedfile(lua_State *L, int idx)
extern "C" int luaopen_droppedfile(lua_State *L)
{
return luax_register_type(L, DroppedFile::type, "DroppedFile", w_File_functions, nullptr);
return luax_register_type(L, DroppedFile::type, w_File_functions, nullptr);
}
} // filesystem
+1 -1
View File
@@ -435,7 +435,7 @@ const luaL_Reg w_File_functions[] =
extern "C" int luaopen_file(lua_State *L)
{
return luax_register_type(L, File::type, "File", w_File_functions, nullptr);
return luax_register_type(L, File::type, w_File_functions, nullptr);
}
} // filesystem
+1 -1
View File
@@ -56,7 +56,7 @@ static const luaL_Reg w_FileData_functions[] =
extern "C" int luaopen_filedata(lua_State *L)
{
return luax_register_type(L, FileData::type, "FileData", w_Data_functions, w_FileData_functions, nullptr);
return luax_register_type(L, FileData::type, w_Data_functions, w_FileData_functions, nullptr);
}
} // filesystem
+1 -1
View File
@@ -33,7 +33,7 @@ namespace love
namespace font
{
love::Type GlyphData::type(&Data::type);
love::Type GlyphData::type("GlyphData", &Data::type);
GlyphData::GlyphData(uint32 glyph, GlyphMetrics glyphMetrics, GlyphData::Format f)
: glyph(glyph)
+1 -1
View File
@@ -29,7 +29,7 @@ namespace love
namespace font
{
love::Type Rasterizer::type(&Object::type);
love::Type Rasterizer::type("Rasterizer", &Object::type);
Rasterizer::~Rasterizer()
{
+1 -1
View File
@@ -131,7 +131,7 @@ const luaL_Reg w_GlyphData_functions[] =
extern "C" int luaopen_glyphdata(lua_State *L)
{
return luax_register_type(L, GlyphData::type, "GlyphData", w_Data_functions, w_GlyphData_functions, nullptr);
return luax_register_type(L, GlyphData::type, w_Data_functions, w_GlyphData_functions, nullptr);
}
} // font
+1 -1
View File
@@ -139,7 +139,7 @@ const luaL_Reg w_Rasterizer_functions[] =
extern "C" int luaopen_rasterizer(lua_State *L)
{
return luax_register_type(L, Rasterizer::type, "Rasterizer", w_Rasterizer_functions, nullptr);
return luax_register_type(L, Rasterizer::type, w_Rasterizer_functions, nullptr);
}
} // font
+1 -1
View File
@@ -58,7 +58,7 @@ void unGammaCorrectColor(Colorf &c)
}
}
love::Type Graphics::type(&Module::type);
love::Type Graphics::type("graphics", &Module::type);
Graphics::~Graphics()
{
+1 -1
View File
@@ -50,7 +50,7 @@ float calculate_variation(float inner, float outer, float var)
} // anonymous namespace
love::Type ParticleSystem::type(&Drawable::type);
love::Type ParticleSystem::type("ParticleSystem", &Drawable::type);
ParticleSystem::ParticleSystem(Texture *texture, uint32 size)
: pMem(nullptr)
+1 -1
View File
@@ -29,7 +29,7 @@ namespace love
namespace graphics
{
love::Type Quad::type(&Object::type);
love::Type Quad::type("Quad", &Object::type);
Quad::Quad(const Quad::Viewport &v, double sw, double sh)
: sw(sw)
+1 -2
View File
@@ -25,8 +25,7 @@ namespace love
namespace graphics
{
love::Type Texture::type(&Drawable::type);
love::Type Texture::type("Texture", &Drawable::type);
Texture::Filter Texture::defaultFilter;
Texture::Texture()
+1 -1
View File
@@ -88,7 +88,7 @@ static GLenum createMSAABuffer(int width, int height, int &samples, GLenum iform
return status;
}
love::Type Canvas::type(&Texture::type);
love::Type Canvas::type("Canvas", &Texture::type);
Canvas *Canvas::current = nullptr;
OpenGL::Viewport Canvas::systemViewport = OpenGL::Viewport();
bool Canvas::screenHasSRGB = false;
+1 -2
View File
@@ -39,13 +39,12 @@ namespace graphics
namespace opengl
{
love::Type Font::type(&Object::type);
static inline uint16 normToUint16(double n)
{
return (uint16) (n * LOVE_UINT16_MAX);
}
love::Type Font::type("Font", &Object::type);
int Font::fontCount = 0;
Font::Font(love::font::Rasterizer *r, const Texture::Filter &filter)
+1 -1
View File
@@ -43,7 +43,7 @@ namespace graphics
namespace opengl
{
love::Type Image::type(&Texture::type);
love::Type Image::type("Image", &Texture::type);
int Image::imageCount = 0;
+1 -1
View File
@@ -58,7 +58,7 @@ static std::vector<Mesh::AttribFormat> getDefaultVertexFormat()
return vertexformat;
}
love::Type Mesh::type(&Drawable::type);
love::Type Mesh::type("Mesh", &Drawable::type);
Mesh::Mesh(const std::vector<AttribFormat> &vertexformat, const void *data, size_t datasize, DrawMode drawmode, Usage usage)
: vertexFormat(vertexformat)
+1 -1
View File
@@ -62,7 +62,7 @@ namespace
} // anonymous namespace
love::Type Shader::type(&Object::type);
love::Type Shader::type("Shader", &Object::type);
Shader *Shader::current = nullptr;
Shader *Shader::defaultShader = nullptr;
Shader *Shader::defaultVideoShader = nullptr;
+1 -1
View File
@@ -41,7 +41,7 @@ namespace graphics
namespace opengl
{
love::Type SpriteBatch::type(&Drawable::type);
love::Type SpriteBatch::type("SpriteBatch", &Drawable::type);
SpriteBatch::SpriteBatch(Texture *texture, int size, Mesh::Usage usage)
: texture(texture)
+1 -1
View File
@@ -30,7 +30,7 @@ namespace graphics
namespace opengl
{
love::Type Text::type(&Drawable::type);
love::Type Text::type("Text", &Drawable::type);
Text::Text(Font *font, const std::vector<Font::ColoredString> &text)
: font(font)
+1 -1
View File
@@ -30,7 +30,7 @@ namespace graphics
namespace opengl
{
love::Type Video::type(&Drawable::type);
love::Type Video::type("Video", &Drawable::type);
Video::Video(love::video::VideoStream *stream)
: stream(stream)
+1 -1
View File
@@ -112,7 +112,7 @@ static const luaL_Reg w_Canvas_functions[] =
extern "C" int luaopen_canvas(lua_State *L)
{
return luax_register_type(L, Canvas::type, "Canvas", w_Texture_functions, w_Canvas_functions, nullptr);
return luax_register_type(L, Canvas::type, w_Texture_functions, w_Canvas_functions, nullptr);
}
} // opengl
+1 -1
View File
@@ -207,7 +207,7 @@ static const luaL_Reg w_Font_functions[] =
extern "C" int luaopen_font(lua_State *L)
{
return luax_register_type(L, Font::type, "Font", w_Font_functions, nullptr);
return luax_register_type(L, Font::type, w_Font_functions, nullptr);
}
} // opengl
@@ -2090,7 +2090,7 @@ static const luaL_Reg functions[] =
static int luaopen_drawable(lua_State *L)
{
return luax_register_type(L, Drawable::type, "Drawable", nullptr);
return luax_register_type(L, Drawable::type, nullptr);
}
// Types for this module.
+1 -1
View File
@@ -150,7 +150,7 @@ static const luaL_Reg w_Image_functions[] =
extern "C" int luaopen_image(lua_State *L)
{
return luax_register_type(L, Image::type, "Image", w_Texture_functions, w_Image_functions, nullptr);
return luax_register_type(L, Image::type, w_Texture_functions, w_Image_functions, nullptr);
}
} // opengl
+1 -1
View File
@@ -528,7 +528,7 @@ static const luaL_Reg w_Mesh_functions[] =
extern "C" int luaopen_mesh(lua_State *L)
{
return luax_register_type(L, Mesh::type, "Mesh", w_Mesh_functions, nullptr);
return luax_register_type(L, Mesh::type, w_Mesh_functions, nullptr);
}
} // opengl
@@ -772,7 +772,7 @@ static const luaL_Reg w_ParticleSystem_functions[] =
extern "C" int luaopen_particlesystem(lua_State *L)
{
return luax_register_type(L, ParticleSystem::type, "ParticleSystem", w_ParticleSystem_functions, nullptr);
return luax_register_type(L, ParticleSystem::type, w_ParticleSystem_functions, nullptr);
}
} // opengl
+1 -1
View File
@@ -317,7 +317,7 @@ static const luaL_Reg w_Shader_functions[] =
extern "C" int luaopen_shader(lua_State *L)
{
return luax_register_type(L, Shader::type, "Shader", w_Shader_functions, nullptr);
return luax_register_type(L, Shader::type, w_Shader_functions, nullptr);
}
} // opengl
@@ -257,7 +257,7 @@ static const luaL_Reg w_SpriteBatch_functions[] =
extern "C" int luaopen_spritebatch(lua_State *L)
{
return luax_register_type(L, SpriteBatch::type, "SpriteBatch", w_SpriteBatch_functions, nullptr);
return luax_register_type(L, SpriteBatch::type, w_SpriteBatch_functions, nullptr);
}
} // opengl
+1 -1
View File
@@ -245,7 +245,7 @@ static const luaL_Reg w_Text_functions[] =
extern "C" int luaopen_text(lua_State *L)
{
return luax_register_type(L, Text::type, "Text", w_Text_functions, nullptr);
return luax_register_type(L, Text::type, w_Text_functions, nullptr);
}
} // opengl
+1 -1
View File
@@ -143,7 +143,7 @@ static const luaL_Reg functions[] =
int luaopen_video(lua_State *L)
{
int ret = luax_register_type(L, Video::type, "Video", functions, nullptr);
int ret = luax_register_type(L, Video::type, functions, nullptr);
luaL_loadbuffer(L, video_lua, sizeof(video_lua), "Video.lua");
luax_gettypemetatable(L, Video::type);
+1 -1
View File
@@ -84,7 +84,7 @@ static const luaL_Reg w_Quad_functions[] =
extern "C" int luaopen_quad(lua_State *L)
{
return luax_register_type(L, Quad::type, "Quad", w_Quad_functions, nullptr);
return luax_register_type(L, Quad::type, w_Quad_functions, nullptr);
}
} // graphics
+1 -1
View File
@@ -139,7 +139,7 @@ const luaL_Reg w_Texture_functions[] =
extern "C" int luaopen_texture(lua_State *L)
{
return luax_register_type(L, Texture::type, "Texture", w_Texture_functions, nullptr);
return luax_register_type(L, Texture::type, w_Texture_functions, nullptr);
}
} // graphics
+1 -1
View File
@@ -25,7 +25,7 @@ namespace love
namespace image
{
love::Type CompressedImageData::type(&Data::type);
love::Type CompressedImageData::type("CompressedImageData", &Data::type);
CompressedImageData::CompressedImageData()
: format(FORMAT_UNKNOWN)
+1 -1
View File
@@ -27,7 +27,7 @@ namespace love
namespace image
{
love::Type ImageData::type(&Data::type);
love::Type ImageData::type("ImageData", &Data::type);
ImageData::ImageData()
: data(nullptr)
@@ -106,7 +106,7 @@ static const luaL_Reg w_CompressedImageData_functions[] =
extern "C" int luaopen_compressedimagedata(lua_State *L)
{
return luax_register_type(L, CompressedImageData::type, "CompressedImageData", w_Data_functions, w_CompressedImageData_functions, nullptr);
return luax_register_type(L, CompressedImageData::type, w_Data_functions, w_CompressedImageData_functions, nullptr);
}
} // image
+1 -1
View File
@@ -366,7 +366,7 @@ static const luaL_Reg w_ImageData_functions[] =
extern "C" int luaopen_imagedata(lua_State *L)
{
int ret = luax_register_type(L, ImageData::type, "ImageData", w_Data_functions, w_ImageData_functions, nullptr);
int ret = luax_register_type(L, ImageData::type, w_Data_functions, w_ImageData_functions, nullptr);
luax_gettypemetatable(L, ImageData::type);
+1 -1
View File
@@ -29,7 +29,7 @@ namespace love
namespace joystick
{
love::Type Joystick::type(&Object::type);
love::Type Joystick::type("Joystick", &Object::type);
float Joystick::clampval(float x)
{
+1 -1
View File
@@ -296,7 +296,7 @@ static const luaL_Reg w_Joystick_functions[] =
extern "C" int luaopen_joystick(lua_State *L)
{
return luax_register_type(L, Joystick::type, "Joystick", w_Joystick_functions, nullptr);
return luax_register_type(L, Joystick::type, w_Joystick_functions, nullptr);
}
} // joystick
+1 -1
View File
@@ -83,7 +83,7 @@ namespace love
namespace math
{
love::Type BezierCurve::type(&Object::type);
love::Type BezierCurve::type("BezierCurve", &Object::type);
BezierCurve::BezierCurve(const vector<Vector> &pts)
: controlPoints(pts)
+1 -1
View File
@@ -26,7 +26,7 @@ namespace love
namespace math
{
love::Type CompressedData::type(&Data::type);
love::Type CompressedData::type("CompressedData", &Data::type);
CompressedData::CompressedData(Compressor::Format format, char *cdata, size_t compressedsize, size_t rawsize, bool own)
: format(format)
+2 -2
View File
@@ -47,6 +47,8 @@ static uint64 wangHash64(uint64 key)
return key;
}
love::Type RandomGenerator::type("RandomGenerator", &Object::type);
// 64 bit Xorshift implementation taken from the end of Sec. 3 (page 4) in
// George Marsaglia, "Xorshift RNGs", Journal of Statistical Software, Vol.8 (Issue 14), 2003
// Use an 'Xorshift*' variant, as shown here: http://xorshift.di.unimi.it
@@ -62,8 +64,6 @@ RandomGenerator::RandomGenerator()
setSeed(newseed);
}
love::Type RandomGenerator::type(&Object::type);
uint64 RandomGenerator::rand()
{
rng_state.b64 ^= (rng_state.b64 >> 12);
+1 -1
View File
@@ -234,7 +234,7 @@ static const luaL_Reg w_BezierCurve_functions[] =
extern "C" int luaopen_beziercurve(lua_State *L)
{
return luax_register_type(L, BezierCurve::type, "BezierCurve", w_BezierCurve_functions, nullptr);
return luax_register_type(L, BezierCurve::type, w_BezierCurve_functions, nullptr);
}
} // math
+1 -1
View File
@@ -53,7 +53,7 @@ static const luaL_Reg w_CompressedData_functions[] =
extern "C" int luaopen_compresseddata(lua_State *L)
{
return luax_register_type(L, CompressedData::type, "CompressedData", w_Data_functions, w_CompressedData_functions, nullptr);
return luax_register_type(L, CompressedData::type, w_Data_functions, w_CompressedData_functions, nullptr);
}
} // math
+1 -1
View File
@@ -147,7 +147,7 @@ static const luaL_Reg w_RandomGenerator_functions[] =
extern "C" int luaopen_randomgenerator(lua_State *L)
{
int n = luax_register_type(L, RandomGenerator::type, "RandomGenerator", w_RandomGenerator_functions, nullptr);
int n = luax_register_type(L, RandomGenerator::type, w_RandomGenerator_functions, nullptr);
luax_gettypemetatable(L, RandomGenerator::type);
+1 -1
View File
@@ -25,7 +25,7 @@ namespace love
namespace mouse
{
love::Type Cursor::type(&Object::type);
love::Type Cursor::type("Cursor", &Object::type);
Cursor::~Cursor()
{
+1 -1
View File
@@ -61,7 +61,7 @@ static const luaL_Reg w_Cursor_functions[] =
extern "C" int luaopen_cursor(lua_State *L)
{
return luax_register_type(L, Cursor::type, "Cursor", w_Cursor_functions, nullptr);
return luax_register_type(L, Cursor::type, w_Cursor_functions, nullptr);
}
} // mouse
+1 -1
View File
@@ -25,7 +25,7 @@ namespace love
namespace physics
{
love::Type Body::type(&Object::type);
love::Type Body::type("Body", &Object::type);
Body::~Body()
{
+1 -1
View File
@@ -25,7 +25,7 @@ namespace love
namespace physics
{
love::Type Joint::type(&Object::type);
love::Type Joint::type("Joint", &Object::type);
Joint::~Joint()
{
+1 -1
View File
@@ -25,7 +25,7 @@ namespace love
namespace physics
{
love::Type Shape::type(&Object::type);
love::Type Shape::type("Shape", &Object::type);
Shape::~Shape()
{
+1 -1
View File
@@ -34,7 +34,7 @@ namespace physics
namespace box2d
{
love::Type ChainShape::type(&Shape::type);
love::Type ChainShape::type("ChainShape", &Shape::type);
ChainShape::ChainShape(b2ChainShape *c, bool loop, bool own)
: Shape(c, own), loop(loop)
+1 -1
View File
@@ -34,7 +34,7 @@ namespace physics
namespace box2d
{
love::Type CircleShape::type(&Shape::type);
love::Type CircleShape::type("CircleShape", &Shape::type);
CircleShape::CircleShape(b2CircleShape *c, bool own)
: Shape(c, own)
+1 -1
View File
@@ -31,7 +31,7 @@ namespace physics
namespace box2d
{
love::Type Contact::type(&Object::type);
love::Type Contact::type("Contact", &Object::type);
Contact::Contact(b2Contact *contact)
: contact(contact)
+1 -1
View File
@@ -34,7 +34,7 @@ namespace physics
namespace box2d
{
love::Type EdgeShape::type(&Shape::type);
love::Type EdgeShape::type("EdgeShape", &Shape::type);
EdgeShape::EdgeShape(b2EdgeShape *e, bool own)
: Shape(e, own)
+1 -1
View File
@@ -37,7 +37,7 @@ namespace physics
namespace box2d
{
love::Type Fixture::type(&Object::type);
love::Type Fixture::type("Fixture", &Object::type);
Fixture::Fixture(Body *body, Shape *shape, float density)
: body(body)
+1 -1
View File
@@ -34,7 +34,7 @@ namespace physics
namespace box2d
{
love::Type FrictionJoint::type(&Joint::type);
love::Type FrictionJoint::type("FrictionJoint", &Joint::type);
FrictionJoint::FrictionJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, bool collideConnected)
: Joint(body1, body2)
+1 -1
View File
@@ -32,7 +32,7 @@ namespace physics
namespace box2d
{
love::Type GearJoint::type(&Joint::type);
love::Type GearJoint::type("GearJoint", &Joint::type);
GearJoint::GearJoint(Joint *joint1, Joint *joint2, float ratio, bool collideConnected)
: Joint(joint1->body2, joint2->body2)
+1 -1
View File
@@ -32,7 +32,7 @@ namespace physics
namespace box2d
{
love::Type MotorJoint::type(&Joint::type);
love::Type MotorJoint::type("MotorJoint", &Joint::type);
MotorJoint::MotorJoint(Body *body1, Body *body2)
: Joint(body1, body2)
+1 -1
View File
@@ -32,7 +32,7 @@ namespace physics
namespace box2d
{
love::Type MouseJoint::type(&Joint::type);
love::Type MouseJoint::type("MouseJoint", &Joint::type);
MouseJoint::MouseJoint(Body *body1, float x, float y)
: Joint(body1)
+1 -1
View File
@@ -34,7 +34,7 @@ namespace physics
namespace box2d
{
love::Type PolygonShape::type(&Shape::type);
love::Type PolygonShape::type("PolygonShape", &Shape::type);
PolygonShape::PolygonShape(b2PolygonShape *p, bool own)
: Shape(p, own)
+1 -1
View File
@@ -32,7 +32,7 @@ namespace physics
namespace box2d
{
love::Type PrismaticJoint::type(&Joint::type);
love::Type PrismaticJoint::type("PrismaticJoint", &Joint::type);
PrismaticJoint::PrismaticJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, float ax, float ay, bool collideConnected)
: Joint(body1, body2)
+1 -1
View File
@@ -32,7 +32,7 @@ namespace physics
namespace box2d
{
love::Type PulleyJoint::type(&Joint::type);
love::Type PulleyJoint::type("PulleyJoint", &Joint::type);
PulleyJoint::PulleyJoint(Body *bodyA, Body *bodyB, b2Vec2 groundAnchorA, b2Vec2 groundAnchorB, b2Vec2 anchorA, b2Vec2 anchorB, float ratio, bool collideConnected)
: Joint(bodyA, bodyB)
+1 -1
View File
@@ -34,7 +34,7 @@ namespace physics
namespace box2d
{
love::Type RevoluteJoint::type(&Joint::type);
love::Type RevoluteJoint::type("RevoluteJoint", &Joint::type);
RevoluteJoint::RevoluteJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, bool collideConnected)
: Joint(body1, body2)
+1 -1
View File
@@ -32,7 +32,7 @@ namespace physics
namespace box2d
{
love::Type RopeJoint::type(&Joint::type);
love::Type RopeJoint::type("RopeJoint", &Joint::type);
RopeJoint::RopeJoint(Body *body1, Body *body2, float x1, float y1, float x2, float y2, float maxLength, bool collideConnected)
: Joint(body1, body2)
+1 -1
View File
@@ -34,7 +34,7 @@ namespace physics
namespace box2d
{
love::Type WeldJoint::type(&Joint::type);
love::Type WeldJoint::type("WeldJoint", &Joint::type);
WeldJoint::WeldJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, bool collideConnected)
: Joint(body1, body2)
+1 -1
View File
@@ -32,7 +32,7 @@ namespace physics
namespace box2d
{
love::Type WheelJoint::type(&Joint::type);
love::Type WheelJoint::type("WheelJoint", &Joint::type);
WheelJoint::WheelJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, float ax, float ay, bool collideConnected)
: Joint(body1, body2)
+1 -1
View File
@@ -34,7 +34,7 @@ namespace physics
namespace box2d
{
love::Type World::type(&Object::type);
love::Type World::type("World", &Object::type);
World::ContactCallback::ContactCallback()
: ref(nullptr)
+1 -1
View File
@@ -650,7 +650,7 @@ static const luaL_Reg w_Body_functions[] =
extern "C" int luaopen_body(lua_State *L)
{
return luax_register_type(L, Body::type, "Body", w_Body_functions, nullptr);
return luax_register_type(L, Body::type, w_Body_functions, nullptr);
}
} // box2d
@@ -149,7 +149,7 @@ static const luaL_Reg w_ChainShape_functions[] =
extern "C" int luaopen_chainshape(lua_State *L)
{
return luax_register_type(L, ChainShape::type, "ChainShape", w_Shape_functions, w_ChainShape_functions, nullptr);
return luax_register_type(L, ChainShape::type, w_Shape_functions, w_ChainShape_functions, nullptr);
}
} // box2d
@@ -75,7 +75,7 @@ static const luaL_Reg w_CircleShape_functions[] =
extern "C" int luaopen_circleshape(lua_State *L)
{
return luax_register_type(L, CircleShape::type, "CircleShape", w_Shape_functions, w_CircleShape_functions, nullptr);
return luax_register_type(L, CircleShape::type, w_Shape_functions, w_CircleShape_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -181,7 +181,7 @@ static const luaL_Reg w_Contact_functions[] =
extern "C" int luaopen_contact(lua_State *L)
{
return luax_register_type(L, Contact::type, "Contact", w_Contact_functions, nullptr);
return luax_register_type(L, Contact::type, w_Contact_functions, nullptr);
}
} // box2d
@@ -93,7 +93,7 @@ static const luaL_Reg w_DistanceJoint_functions[] =
extern "C" int luaopen_distancejoint(lua_State *L)
{
return luax_register_type(L, DistanceJoint::type, "DistanceJoint", w_Joint_functions, w_DistanceJoint_functions, nullptr);
return luax_register_type(L, DistanceJoint::type, w_Joint_functions, w_DistanceJoint_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -105,7 +105,7 @@ static const luaL_Reg w_EdgeShape_functions[] =
extern "C" int luaopen_edgeshape(lua_State *L)
{
return luax_register_type(L, EdgeShape::type, "EdgeShape", w_Shape_functions, w_EdgeShape_functions, nullptr);
return luax_register_type(L, EdgeShape::type, w_Shape_functions, w_EdgeShape_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -302,7 +302,7 @@ static const luaL_Reg w_Fixture_functions[] =
extern "C" int luaopen_fixture(lua_State *L)
{
return luax_register_type(L, Fixture::type, "Fixture", w_Fixture_functions, nullptr);
return luax_register_type(L, Fixture::type, w_Fixture_functions, nullptr);
}
} // box2d
@@ -77,7 +77,7 @@ static const luaL_Reg w_FrictionJoint_functions[] =
extern "C" int luaopen_frictionjoint(lua_State *L)
{
return luax_register_type(L, FrictionJoint::type, "FrictionJoint", w_Joint_functions, w_FrictionJoint_functions, nullptr);
return luax_register_type(L, FrictionJoint::type, w_Joint_functions, w_FrictionJoint_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -77,7 +77,7 @@ static const luaL_Reg w_GearJoint_functions[] =
extern "C" int luaopen_gearjoint(lua_State *L)
{
return luax_register_type(L, GearJoint::type, "GearJoint", w_Joint_functions, w_GearJoint_functions, nullptr);
return luax_register_type(L, GearJoint::type, w_Joint_functions, w_GearJoint_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -182,7 +182,7 @@ const luaL_Reg w_Joint_functions[] =
extern "C" int luaopen_joint(lua_State *L)
{
return luax_register_type(L, Joint::type, "Joint", w_Joint_functions, nullptr);
return luax_register_type(L, Joint::type, w_Joint_functions, nullptr);
}
} // box2d
@@ -127,7 +127,7 @@ static const luaL_Reg w_MotorJoint_functions[] =
extern "C" int luaopen_motorjoint(lua_State *L)
{
return luax_register_type(L, MotorJoint::type, "MotorJoint", w_Joint_functions, w_MotorJoint_functions, nullptr);
return luax_register_type(L, MotorJoint::type, w_Joint_functions, w_MotorJoint_functions, nullptr);
}
@@ -111,7 +111,7 @@ static const luaL_Reg w_MouseJoint_functions[] =
extern "C" int luaopen_mousejoint(lua_State *L)
{
return luax_register_type(L, MouseJoint::type, "MouseJoint", w_Joint_functions, w_MouseJoint_functions, nullptr);
return luax_register_type(L, MouseJoint::type, w_Joint_functions, w_MouseJoint_functions, nullptr);
}
} // box2d
@@ -55,7 +55,7 @@ static const luaL_Reg w_PolygonShape_functions[] =
extern "C" int luaopen_polygonshape(lua_State *L)
{
return luax_register_type(L, PolygonShape::type, "PolygonShape", w_Shape_functions, w_PolygonShape_functions, nullptr);
return luax_register_type(L, PolygonShape::type, w_Shape_functions, w_PolygonShape_functions, nullptr);
}
} // box2d
@@ -204,7 +204,7 @@ static const luaL_Reg w_PrismaticJoint_functions[] =
extern "C" int luaopen_prismaticjoint(lua_State *L)
{
return luax_register_type(L, PrismaticJoint::type, "PrismaticJoint", w_Joint_functions, w_PrismaticJoint_functions, nullptr);
return luax_register_type(L, PrismaticJoint::type, w_Joint_functions, w_PrismaticJoint_functions, nullptr);
}
} // box2d
@@ -74,7 +74,7 @@ static const luaL_Reg w_PulleyJoint_functions[] =
extern "C" int luaopen_pulleyjoint(lua_State *L)
{
return luax_register_type(L, PulleyJoint::type, "PulleyJoint", w_Joint_functions, w_PulleyJoint_functions, nullptr);
return luax_register_type(L, PulleyJoint::type, w_Joint_functions, w_PulleyJoint_functions, nullptr);
}
} // box2d
@@ -196,7 +196,7 @@ static const luaL_Reg w_RevoluteJoint_functions[] =
extern "C" int luaopen_revolutejoint(lua_State *L)
{
return luax_register_type(L, RevoluteJoint::type, "RevoluteJoint", w_Joint_functions, w_RevoluteJoint_functions, nullptr);
return luax_register_type(L, RevoluteJoint::type, w_Joint_functions, w_RevoluteJoint_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -50,7 +50,7 @@ static const luaL_Reg w_RopeJoint_functions[] =
extern "C" int luaopen_ropejoint(lua_State *L)
{
return luax_register_type(L, RopeJoint::type, "RopeJoint", w_Joint_functions, w_RopeJoint_functions, nullptr);
return luax_register_type(L, RopeJoint::type, w_Joint_functions, w_RopeJoint_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -108,7 +108,7 @@ const luaL_Reg w_Shape_functions[] =
extern "C" int luaopen_shape(lua_State *L)
{
return luax_register_type(L, Shape::type, "Shape", w_Shape_functions, nullptr);
return luax_register_type(L, Shape::type, w_Shape_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -84,7 +84,7 @@ static const luaL_Reg w_WeldJoint_functions[] =
extern "C" int luaopen_weldjoint(lua_State *L)
{
return luax_register_type(L, WeldJoint::type, "WeldJoint", w_Joint_functions, w_WeldJoint_functions, nullptr);
return luax_register_type(L, WeldJoint::type, w_Joint_functions, w_WeldJoint_functions, nullptr);
}
} // box2d
@@ -160,7 +160,7 @@ static const luaL_Reg w_WheelJoint_functions[] =
extern "C" int luaopen_wheeljoint(lua_State *L)
{
return luax_register_type(L, WheelJoint::type, "WheelJoint", w_Joint_functions, w_WheelJoint_functions, nullptr);
return luax_register_type(L, WheelJoint::type, w_Joint_functions, w_WheelJoint_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -237,7 +237,7 @@ static const luaL_Reg w_World_functions[] =
extern "C" int luaopen_world(lua_State *L)
{
return luax_register_type(L, World::type, "World", w_World_functions, nullptr);
return luax_register_type(L, World::type, w_World_functions, nullptr);
}
} // box2d
+1 -1
View File
@@ -27,7 +27,7 @@ namespace love
namespace sound
{
love::Type Decoder::type(&Object::type);
love::Type Decoder::type("Decoder", &Object::type);
Decoder::Decoder(Data *data, const std::string &ext, int bufferSize)
: data(data)
+1 -1
View File
@@ -25,7 +25,7 @@ namespace love
namespace sound
{
love::Type Sound::type(&Module::type);
love::Type Sound::type("Sound", &Module::type);
Sound::~Sound()
{

Some files were not shown because too many files have changed in this diff Show More