mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Added many comments, and changed function names for wrapper functions.
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@
|
||||
namespace love
|
||||
{
|
||||
/**
|
||||
* This class is a simple abstraction over
|
||||
* This class is a simple abstraction over all objects which contain data.
|
||||
**/
|
||||
class Data : public Object
|
||||
{
|
||||
|
||||
+35
-11
@@ -22,23 +22,47 @@
|
||||
#define LOVE_EXCEPTION_H
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdarg> // vararg
|
||||
#include <cstdio> // vsnprintf
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
/**
|
||||
* A convenient vararg-enabled exception class.
|
||||
**/
|
||||
class Exception : public std::exception
|
||||
{
|
||||
private:
|
||||
static const int BUFFER_SIZE = 256;
|
||||
char buffer[BUFFER_SIZE];
|
||||
public:
|
||||
Exception(const char * fmt, ...);
|
||||
virtual const char * what() const throw();
|
||||
};
|
||||
|
||||
}
|
||||
/**
|
||||
* The vsnprintf operates on a buffer this large.
|
||||
**/
|
||||
static const int BUFFER_SIZE = 256;
|
||||
|
||||
/**
|
||||
* The buffer for vsnprintf.
|
||||
**/
|
||||
char buffer[BUFFER_SIZE];
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new Exception according to printf-rules.
|
||||
*
|
||||
* See: http://www.cplusplus.com/reference/clibrary/cstdio/printf/
|
||||
*
|
||||
* @param fmt The format string (see printf).
|
||||
**/
|
||||
Exception(const char * fmt, ...);
|
||||
|
||||
/**
|
||||
* Returns a string containing reason for the exception.
|
||||
* @return A description of the exception.
|
||||
**/
|
||||
virtual const char * what() const throw();
|
||||
|
||||
}; // class
|
||||
|
||||
} // love
|
||||
|
||||
#endif // LOVE_EXCEPTION_H
|
||||
|
||||
@@ -21,12 +21,9 @@
|
||||
#include "Matrix.h"
|
||||
|
||||
// STD
|
||||
#include <cstring>
|
||||
#include <cstring> // memcpy
|
||||
#include <cmath>
|
||||
|
||||
// LOVE
|
||||
#include "Vector.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
@@ -80,7 +77,7 @@ namespace love
|
||||
return t;
|
||||
}
|
||||
|
||||
void Matrix::operator *= (const Matrix & m) const
|
||||
void Matrix::operator *= (const Matrix & m)
|
||||
{
|
||||
Matrix t = (*this) * m;
|
||||
memcpy((void*)this->e, (void*)t.e, sizeof(float)*16);
|
||||
|
||||
+75
-21
@@ -21,30 +21,30 @@
|
||||
#ifndef LOVE_MATRIX_H
|
||||
#define LOVE_MATRIX_H
|
||||
|
||||
// STD
|
||||
#include <cmath>
|
||||
|
||||
// LOVE
|
||||
#include "math.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
// Forward declarations.
|
||||
class Vector;
|
||||
|
||||
/**
|
||||
* This class is the basis for all transformations in LOVE. Althought not
|
||||
* really needed for 2D, it contains 4x4 elements to be compatible with
|
||||
* OpenGL without conversions.
|
||||
**/
|
||||
class Matrix
|
||||
{
|
||||
friend class Vector;
|
||||
private:
|
||||
|
||||
/**
|
||||
* | e0 e4 e8 e12 |
|
||||
* | e1 e5 e9 e13 |
|
||||
* | e2 e6 e10 e14 |
|
||||
* | e3 e7 e11 e15 |
|
||||
**/
|
||||
float e[16];
|
||||
|
||||
public:
|
||||
|
||||
// | e0 e4 e8 e12 |
|
||||
// | e1 e5 e9 e13 |
|
||||
// | e2 e6 e10 e14 |
|
||||
// | e3 e7 e11 e15 |
|
||||
float e[16];
|
||||
|
||||
/**
|
||||
* Creates a new identity matrix.
|
||||
**/
|
||||
@@ -55,19 +55,53 @@ namespace love
|
||||
**/
|
||||
~Matrix();
|
||||
|
||||
/**
|
||||
* Multiplies this Matrix with another Matrix, changing neither.
|
||||
* @param m The Matrix to multiply with this Matrix.
|
||||
* @return The combined matrix.
|
||||
**/
|
||||
Matrix operator * (const Matrix & m) const;
|
||||
void operator *= (const Matrix & m) const;
|
||||
|
||||
/**
|
||||
* Multiplies a Matrix into this Matrix.
|
||||
* @param m The Matrix to combine into this Matrix.
|
||||
**/
|
||||
void operator *= (const Matrix & m);
|
||||
|
||||
/**
|
||||
* Gets a pointer to the 16 array elements.
|
||||
* @return The array elements.
|
||||
**/
|
||||
const float * getElements() const;
|
||||
|
||||
/**
|
||||
* Resets this Matrix to the identity matrix.
|
||||
**/
|
||||
void setIdentity();
|
||||
|
||||
/**
|
||||
* Resets this Matrix to a translation.
|
||||
* @param x Translation along x-axis.
|
||||
* @param y Translation along y-axis.
|
||||
**/
|
||||
void setTranslation(float x, float y);
|
||||
void setRotation(float rad);
|
||||
|
||||
/**
|
||||
* Resets this Matrix to a rotaion.
|
||||
* @param r The angle in radians.
|
||||
**/
|
||||
void setRotation(float r);
|
||||
|
||||
/**
|
||||
* Resets this Matrix to a scale transformation.
|
||||
* @param sx Scale factor along the x-axis.
|
||||
* @param sy Scale factor along the y-axis.
|
||||
**/
|
||||
void setScale(float sx, float sy);
|
||||
|
||||
/**
|
||||
* Creates a transformation with a certain position, orientation, scale
|
||||
* and offset.
|
||||
* and offset. Perfect for Drawables -- what a coincidence!
|
||||
*
|
||||
* @param x The translation along the x-axis.
|
||||
* @param y The translation along the y-axis.
|
||||
@@ -79,17 +113,37 @@ namespace love
|
||||
**/
|
||||
void setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy);
|
||||
|
||||
/**
|
||||
* Multiplies this Matrix with a translation.
|
||||
* @param x Translation along x-axis.
|
||||
* @param y Translation along y-axis.
|
||||
**/
|
||||
void translate(float x, float y);
|
||||
void rotate(float rad);
|
||||
|
||||
/**
|
||||
* Multiplies this Matrix with a rotation.
|
||||
* @param r Angle in radians.
|
||||
**/
|
||||
void rotate(float r);
|
||||
|
||||
/**
|
||||
* Multiplies this Matrix with a scale transformation.
|
||||
* @param sx Scale factor along the x-axis.
|
||||
* @param sy Scale factor along the y-axis.
|
||||
**/
|
||||
void scale(float sx, float sy);
|
||||
|
||||
/**
|
||||
* Transforms an array of vertices.
|
||||
* @stride Stride in bytes.
|
||||
* Transforms an array of vertices by this Matrix. The sources and
|
||||
* destination arrays may be the same.
|
||||
*
|
||||
* @param dst Storage for the transformed vertices.
|
||||
* @param src The source vertices.
|
||||
* @param size The number of vertices.
|
||||
**/
|
||||
void transform(vertex * dst, const vertex * src, int size);
|
||||
|
||||
};
|
||||
}; // Matrix
|
||||
|
||||
} //love
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
MemoryData::MemoryData(void * data, int size)
|
||||
: data(data), size(size)
|
||||
{
|
||||
|
||||
+24
-1
@@ -26,14 +26,37 @@
|
||||
|
||||
namespace love
|
||||
{
|
||||
/**
|
||||
* Allows files to be embedded into LOVE and used in Lua. This
|
||||
* class assumes the referenced memory area is static, which means
|
||||
* it will not attempt to delete the memory.
|
||||
**/
|
||||
class MemoryData : public Data
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Pointer to the memory area.
|
||||
**/
|
||||
void * data;
|
||||
|
||||
/**
|
||||
* Size of the memory pointed to.
|
||||
**/
|
||||
int size;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new MemoryData.
|
||||
* @param data Pointer to the static memory.
|
||||
* @param size Size of the memory data.
|
||||
**/
|
||||
MemoryData(void * data, int size);
|
||||
|
||||
/**
|
||||
* Destructor. Does NOTHING.
|
||||
**/
|
||||
virtual ~MemoryData();
|
||||
|
||||
// Implements Data.
|
||||
@@ -43,4 +66,4 @@ namespace love
|
||||
}; // MemoryData
|
||||
} // love
|
||||
|
||||
#endif // LOVE_MEMORY_DATA_H
|
||||
#endif // LOVE_MEMORY_DATA_H
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace love
|
||||
|
||||
Object::~Object()
|
||||
{
|
||||
// PURE VIRUTAL!
|
||||
}
|
||||
|
||||
int Object::getReferenceCount() const
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
#ifndef LOVE_OBJECT_H
|
||||
#define LOVE_OBJECT_H
|
||||
|
||||
// LOVE
|
||||
#include "config.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
/**
|
||||
@@ -33,8 +30,6 @@ namespace love
|
||||
* This class is an alternative to using smart pointers; it contains retain/release
|
||||
* methods, and will delete itself with the reference count hits zero. The wrapper
|
||||
* code assumes that all userdata inherits from this class.
|
||||
*
|
||||
* @author Anders Ruud
|
||||
**/
|
||||
class Object
|
||||
{
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@
|
||||
#define LOVE_M_2_SQRTPI 1.12837916709551257390
|
||||
#define LOVE_M_SQRT2 1.41421356237309504880
|
||||
#define LOVE_M_SQRT1_2 0.707106781186547524401
|
||||
#define LOVE_M_TORAD (float)(LOVE_M_PI/180.0)
|
||||
#define LOVE_M_TORAD (float)(LOVE_M_PI/180.0)
|
||||
#define LOVE_M_TODEG (float)(180.0/LOVE_M_PI)
|
||||
#define LOVE_TORAD(x) (float)(x*LOVE_M_TORAD)
|
||||
#define LOVE_TODEG(x) (float)(x*LOVE_M_TODEG)
|
||||
|
||||
+22
-57
@@ -34,9 +34,9 @@ namespace love
|
||||
* Called when an object is collected. The object is released
|
||||
* once in this function, possibly deleting it.
|
||||
**/
|
||||
static int _wrap__gc(lua_State * L)
|
||||
static int w__gc(lua_State * L)
|
||||
{
|
||||
userdata * u = (userdata *)lua_touserdata(L, 1);
|
||||
UserData * u = (UserData *)lua_touserdata(L, 1);
|
||||
Object * t = (Object *)u->data;
|
||||
t->release();
|
||||
return 0;
|
||||
@@ -45,9 +45,9 @@ namespace love
|
||||
/**
|
||||
* Special garbage collector for Modules.
|
||||
**/
|
||||
static int _wrap__Module_gc(lua_State * L)
|
||||
static int w__Module_gc(lua_State * L)
|
||||
{
|
||||
userdata * u = (userdata *)lua_touserdata(L, 1);
|
||||
UserData * u = (UserData *)lua_touserdata(L, 1);
|
||||
Module * t = (Module *)u->data;
|
||||
delete t;
|
||||
return 0;
|
||||
@@ -78,19 +78,19 @@ namespace love
|
||||
return b;
|
||||
}
|
||||
|
||||
int luax_assert_argc(lua_State * L, int lower)
|
||||
int luax_assert_argc(lua_State * L, int min)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
if( argc < lower )
|
||||
return luaL_error(L, "Incorrect number of arguments. Got [%d], expected at least [%d]", argc, lower);
|
||||
if( argc < min )
|
||||
return luaL_error(L, "Incorrect number of arguments. Got [%d], expected at least [%d]", argc, min);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luax_assert_argc(lua_State * L, int lower, int upper)
|
||||
int luax_assert_argc(lua_State * L, int min, int max)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
if( argc < lower || argc > upper)
|
||||
return luaL_error(L, "Incorrect number of arguments. Got [%d], expected [%d-%d]", argc, lower, upper);
|
||||
if( argc < min || argc > max)
|
||||
return luaL_error(L, "Incorrect number of arguments. Got [%d], expected [%d-%d]", argc, min, max);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -101,59 +101,26 @@ namespace love
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luax_register_gc(lua_State * L, const char * mname, Module * m)
|
||||
int luax_register_gc(lua_State * L, Module * m)
|
||||
{
|
||||
luax_getregistry(L, REGISTRY_GC);
|
||||
|
||||
userdata * u = (userdata *)lua_newuserdata(L, sizeof(userdata));
|
||||
UserData * u = (UserData *)lua_touserdata(L, sizeof(UserData));
|
||||
u->own = true;
|
||||
u->data = m;
|
||||
|
||||
luaL_newmetatable(L, mname);
|
||||
lua_pushcfunction(L, _wrap__Module_gc);
|
||||
luaL_newmetatable(L, m->getName());
|
||||
lua_pushcfunction(L, w__Module_gc);
|
||||
lua_setfield(L, -2, "__gc");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
lua_setfield(L, -2, mname);
|
||||
lua_setfield(L, -2, m->getName());
|
||||
|
||||
lua_pop(L, 1); // Registry
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luax_register_info(lua_State * L, const char * name,
|
||||
const char * provides, const char * desc, const char * author,
|
||||
lua_CFunction open)
|
||||
{
|
||||
lua_getglobal(L, "love");
|
||||
lua_getfield(L, -1, "__mod");
|
||||
lua_getfield(L, -1, provides);
|
||||
|
||||
// Make sure it exists.
|
||||
if(lua_isnil(L, -1))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
lua_newtable(L);
|
||||
lua_setfield(L, -2, provides);
|
||||
lua_getfield(L, -1, provides);
|
||||
}
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
lua_pushstring(L, desc);
|
||||
lua_setfield(L, -2, "description");
|
||||
lua_pushstring(L, author);
|
||||
lua_setfield(L, -2, "author");
|
||||
lua_pushcfunction(L, open);
|
||||
lua_setfield(L, -2, "open");
|
||||
|
||||
lua_setfield(L, -2, name);
|
||||
|
||||
// Pop "provides", __mod, love
|
||||
lua_pop(L, 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luax_register_module(lua_State * L, const luaL_Reg * fn, const lua_CFunction * types, const LuaConstant * constants, const char * name)
|
||||
{
|
||||
// Gets the love table.
|
||||
@@ -196,7 +163,7 @@ namespace love
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * fn)
|
||||
int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * f)
|
||||
{
|
||||
luaL_newmetatable(L, tname);
|
||||
|
||||
@@ -205,10 +172,10 @@ namespace love
|
||||
lua_setfield(L, -2, "__index");
|
||||
|
||||
// setup gc
|
||||
lua_pushcfunction(L, _wrap__gc);
|
||||
lua_pushcfunction(L, w__gc);
|
||||
lua_setfield(L, -2, "__gc");
|
||||
|
||||
luaL_register(L, 0, fn);
|
||||
luaL_register(L, 0, f);
|
||||
lua_pop(L, 1); // Pops metatable.
|
||||
return 0;
|
||||
}
|
||||
@@ -234,15 +201,15 @@ namespace love
|
||||
return 0;
|
||||
}
|
||||
|
||||
void luax_newtype(lua_State * L, const char * tname, bits flags, void * data, bool own)
|
||||
void luax_newtype(lua_State * L, const char * name, bits flags, void * data, bool own)
|
||||
{
|
||||
userdata * u = (userdata *)lua_newuserdata(L, sizeof(userdata));
|
||||
UserData * u = (UserData *)lua_touserdata(L, sizeof(UserData));
|
||||
|
||||
u->data = data;
|
||||
u->flags = flags;
|
||||
u->own = own;
|
||||
|
||||
luaL_newmetatable(L, tname);
|
||||
luaL_newmetatable(L, name);
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
|
||||
@@ -251,9 +218,7 @@ namespace love
|
||||
if(lua_isuserdata(L, idx) == 0)
|
||||
return false;
|
||||
|
||||
userdata * u = (userdata *)lua_touserdata(L, idx);
|
||||
|
||||
return ((u->flags & type) == type);
|
||||
return ((((UserData *)lua_touserdata(L, idx))->flags & type) == type);
|
||||
}
|
||||
|
||||
int luax_getfunction(lua_State * L, const char * mod, const char * fn)
|
||||
|
||||
+190
-30
@@ -21,8 +21,8 @@
|
||||
#ifndef LOVE_RUNTIME_H
|
||||
#define LOVE_RUNTIME_H
|
||||
|
||||
// LOVE
|
||||
#include "types.h"
|
||||
#include "Module.h"
|
||||
|
||||
// Lua
|
||||
extern "C" {
|
||||
@@ -33,83 +33,243 @@ extern "C" {
|
||||
|
||||
namespace love
|
||||
{
|
||||
// Forward declarations.
|
||||
class Module;
|
||||
|
||||
/**
|
||||
* Registries represent special tables which can be accessed with
|
||||
* luax_getregistry.
|
||||
**/
|
||||
enum Registry
|
||||
{
|
||||
REGISTRY_GC = 1,
|
||||
};
|
||||
|
||||
// Type used for storing constants in an array.
|
||||
/**
|
||||
* This structure wraps all Lua-exposed objects. It exists in the
|
||||
* Lua state as a full UserData (so we can catch __gc "events"),
|
||||
* though the Object it refers to is light UserData in the sense
|
||||
* that it is not allocated by the Lua VM.
|
||||
**/
|
||||
struct UserData
|
||||
{
|
||||
bits flags; // Holds type information (see types.h).
|
||||
void * data;
|
||||
bool own; // True if Lua should delete on GC.
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Used to store constants in arrays.
|
||||
**/
|
||||
struct LuaConstant
|
||||
{
|
||||
const char * name;
|
||||
int value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Prints the current contents of the stack. Only useful for debugging.
|
||||
* @param L The Lua state.
|
||||
**/
|
||||
void luax_printstack(lua_State * L);
|
||||
|
||||
/**
|
||||
* Converts the value at idx to a bool. It follow the same rules
|
||||
* as lua_toboolean, but returns a bool instead of an int.
|
||||
* @param L The Lua state.
|
||||
* @param idx The index on the Lua state.
|
||||
* @return True if the value evaluates to true, false otherwise.
|
||||
**/
|
||||
bool luax_toboolean(lua_State * L, int idx);
|
||||
|
||||
/**
|
||||
* Pushes a bool onto the stack. It's the same as lua_pushboolean,
|
||||
* but with bool instead of int.
|
||||
* @param L The Lua state.
|
||||
* @paarm b The bool to push.
|
||||
**/
|
||||
void luax_pushboolean(lua_State * L, bool b);
|
||||
|
||||
/**
|
||||
* Converts the value at idx to a bool, or if not present, b is returned.
|
||||
* @param L The Lua state.
|
||||
* @param idx The index of the Lua state.
|
||||
* @param b The value to return if no value exist at the specified index.
|
||||
* @return True if the value evaluates to true, false otherwise.
|
||||
**/
|
||||
bool luax_optboolean(lua_State * L, int idx, bool b);
|
||||
int luax_assert_argc(lua_State * L, int lower);
|
||||
int luax_assert_argc(lua_State * L, int lower, int upper);
|
||||
int luax_assert_function(lua_State * L, int n);
|
||||
|
||||
int luax_register_gc(lua_State * L, const char * mname, Module * module);
|
||||
/**
|
||||
* Require at least 'min' number of items on the stack.
|
||||
* @param L The Lua state.
|
||||
* @param min The minimum number of items on the stack.
|
||||
* @return Zero if conditions are met, otherwise a Lua error (longjmp).
|
||||
**/
|
||||
int luax_assert_argc(lua_State * L, int min);
|
||||
|
||||
int luax_register_info(lua_State * L, const char * name,
|
||||
const char * provides, const char * desc, const char * author,
|
||||
lua_CFunction open);
|
||||
/**
|
||||
* Require at least 'min', but more than 'max' items on the stack.
|
||||
* @param L The Lua state.
|
||||
* @param min The minimum number of items on the stack.
|
||||
* @param max The maximum number of items on the stack.
|
||||
* @return Zero if conditions are met, otherwise a Lua error (longjmp).
|
||||
**/
|
||||
int luax_assert_argc(lua_State * L, int min, int max);
|
||||
|
||||
int luax_register_module(lua_State * L, const luaL_Reg * fn, const lua_CFunction * types, const LuaConstant * constants, const char * name);
|
||||
int luax_preload(lua_State * L, lua_CFunction f, const char * name);
|
||||
int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * fn);
|
||||
/**
|
||||
* Require that the value at idx is a function.
|
||||
* @param L The Lua state.
|
||||
*@param idx The index on the stack.
|
||||
**/
|
||||
int luax_assert_function(lua_State * L, int idx);
|
||||
|
||||
int luax_register_searcher(lua_State * L, lua_CFunction f);
|
||||
/**
|
||||
* Register a dummy UserData (full) for a module. This enables us to catch the
|
||||
* call to __gc, and properly call the destructor on the Module in question.
|
||||
* @param L The Lua state.
|
||||
* @param module The Module to register the dummy UserData for.
|
||||
**/
|
||||
int luax_register_gc(lua_State * L, Module * module);
|
||||
|
||||
/**
|
||||
* Register a module in the love table. The love table will created if it does not exist.
|
||||
* @param L The Lua state.
|
||||
* @param f The functions of the module (last element {0,0}).
|
||||
* @param t A list of functions which expose the types of the modules (last element 0).
|
||||
* @param c A list of constants (last element 0).
|
||||
* @param name The name for the table to put the functions in, without the 'love'-prefix.
|
||||
**/
|
||||
int luax_register_module(lua_State * L, const luaL_Reg * f, const lua_CFunction * t, const LuaConstant * c, const char * name);
|
||||
|
||||
/**
|
||||
* Inserts a module with 'name' into the package.preloaded table.
|
||||
* @param f The function to be called when the module is opened.
|
||||
* @param name The name of the module, with 'love'-prefix, for instance 'love.graphics'.
|
||||
**/
|
||||
int luax_preload(lua_State * L, lua_CFunction f, const char * name);
|
||||
|
||||
void luax_newtype(lua_State * L, const char * tname, bits flags, void * data, bool own = true);
|
||||
/**
|
||||
* Register a new type.
|
||||
* @param tname The name of the type. This must not conflict with other type names,
|
||||
* even from other modules.
|
||||
* @param f The list of member functions for the type.
|
||||
**/
|
||||
int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * f);
|
||||
|
||||
/**
|
||||
* Register a new searcher function for package.loaders. This can for instance enable
|
||||
* loading of files through love.filesystem using standard require.
|
||||
* @param L The Lua state.
|
||||
* @param f The searcher function.
|
||||
**/
|
||||
int luax_register_searcher(lua_State * L, lua_CFunction f);
|
||||
|
||||
/**
|
||||
* Creates a new Lua-accessible object of the given type, and put it on the stack.
|
||||
* @param L The Lua state.
|
||||
* @param name The name of the type. This must match the used earlier with luax_register_type.
|
||||
* @param flags The type information.
|
||||
* @param data The pointer to the actual object.
|
||||
* @own Set this to true (default) if the object should be released upon garbage collection.
|
||||
**/
|
||||
void luax_newtype(lua_State * L, const char * name, bits flags, void * data, bool own = true);
|
||||
|
||||
/**
|
||||
* Checks whether the value at idx is a certain type.
|
||||
* @param L The Lua state.
|
||||
* @param idx The index on the stack.
|
||||
* @param type The type to check for.
|
||||
* @return True if the value is UserData of the specified type, false otherwise.
|
||||
**/
|
||||
bool luax_istype(lua_State * L, int idx, love::bits type);
|
||||
|
||||
// Gets a function love.mod.fn.
|
||||
int luax_getfunction(lua_State * L, const char * mod, const char * fn);
|
||||
/**
|
||||
* Gets the function love.module.function and puts it on top of the stack (alone). If the
|
||||
* love table, the module, or the function does not exist, an error is returned.
|
||||
* @return An error if nonexistent, or 1 if successful.
|
||||
**/
|
||||
int luax_getfunction(lua_State * L, const char * module, const char * function);
|
||||
|
||||
/**
|
||||
* Converts an object into another object
|
||||
* by the specified function mod.fn. The function must accept
|
||||
* a single file as a parameter, and return one value.
|
||||
* Converts an object into another object by the specified function love.module.function.
|
||||
* The conversion function must accept a single object of the relevant type as a parameter,
|
||||
* and returnone value. If the function does not exist (see luax_getfunction), an error is returned.
|
||||
*
|
||||
* Note that the initial object is converted, i.e. replaced.
|
||||
* Note that the initial object at idx is replaced by the new object.
|
||||
*
|
||||
* @param L The Lua state.
|
||||
* @param idx The index on the stack.
|
||||
* @param module The module in the love table.
|
||||
* @param function The function in the module.
|
||||
**/
|
||||
int luax_convobj(lua_State * L, int idx, const char * mod, const char * fn);
|
||||
int luax_convobj(lua_State * L, int idx, const char * module, const char * function);
|
||||
|
||||
/**
|
||||
* Converts a string into a File object. Note that the
|
||||
* string is replaced by the new File object at the
|
||||
* specified index, and NOT pushed onto the stack.
|
||||
* 'Insist' that a table 'k' exists in the table at idx. Insistence involves that the
|
||||
* table (k) is created if it does not exist in the table at idx. The table at idx must
|
||||
* pre-exist, however. Also note that if the a non-table value exists at the specified
|
||||
* location, it will be overwritten with a new table. The insisted table, and only the
|
||||
* insisted table, will be placed on top of the stack.
|
||||
*
|
||||
* @param idx The index on the stack containing a table.
|
||||
* @param k The name of the table we are insisting exist.
|
||||
**/
|
||||
int luax_strtofile(lua_State * L, int idx);
|
||||
|
||||
int luax_insist(lua_State * L, int idx, const char * k);
|
||||
|
||||
/**
|
||||
* Insist that a global table 'k' exists. See luax_insist.
|
||||
* @param k The name of the table we are insisting exist.
|
||||
**/
|
||||
int luax_insistglobal(lua_State * L, const char * k);
|
||||
|
||||
/**
|
||||
* Insists that a table 'k' exists inside the 'love' table. See luax_insist.
|
||||
* @param k The name of the table we are insisting exist.
|
||||
**/
|
||||
int luax_insistlove(lua_State * L, const char * k);
|
||||
|
||||
/**
|
||||
* Gets (creates if needed) the specified Registry.
|
||||
* Gets (creates if needed) the specified Registry, and puts it on top
|
||||
* of the stack.
|
||||
* @param L The Lua state.
|
||||
* @param r The Registry to get.
|
||||
**/
|
||||
int luax_getregistry(lua_State * L, Registry r);
|
||||
|
||||
/**
|
||||
* Converts the value at idx to the specified type without checking that
|
||||
* this conversion is valid. If the type has been previously verified with
|
||||
* 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.
|
||||
**/
|
||||
template <typename T>
|
||||
T * luax_checktype(lua_State * L, int idx, const char * tname, love::bits type)
|
||||
T * luax_totype(lua_State * L, int idx, const char * name, love::bits type)
|
||||
{
|
||||
return (T*)(((UserData *)lua_touserdata(L, idx))->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like luax_totype, but causes an error if the value at idx is not UserData,
|
||||
* or is not the specified type.
|
||||
* @param L The Lua state.
|
||||
* @param idx The index on the stack.
|
||||
* @param name The name of the type.
|
||||
* @param type The type bit.
|
||||
**/
|
||||
template <typename T>
|
||||
T * luax_checktype(lua_State * L, int idx, const char * name, love::bits type)
|
||||
{
|
||||
if(lua_isuserdata(L, idx) == 0)
|
||||
luaL_error(L, "Incorrect parameter type: expected userdata.");
|
||||
|
||||
userdata * u = (userdata *)lua_touserdata(L, idx);
|
||||
UserData * u = (UserData *)lua_touserdata(L, idx);
|
||||
|
||||
if((u->flags & type) != type)
|
||||
luaL_error(L, "Incorrect parameter type: expected %s", tname);
|
||||
luaL_error(L, "Incorrect parameter type: expected %s", name);
|
||||
|
||||
return (T *)u->data;
|
||||
}
|
||||
|
||||
+75
-101
@@ -29,138 +29,112 @@ namespace love
|
||||
enum
|
||||
{
|
||||
// Cross-module types.
|
||||
LOVE_OBJECT_ID = 0,
|
||||
LOVE_DATA_ID,
|
||||
OBJECT_ID = 0,
|
||||
DATA_ID,
|
||||
|
||||
// Filesystem.
|
||||
LOVE_FILESYSTEM_FILE_ID,
|
||||
LOVE_FILESYSTEM_FILE_DATA_ID,
|
||||
FILESYSTEM_FILE_ID,
|
||||
FILESYSTEM_FILE_DATA_ID,
|
||||
|
||||
// Font
|
||||
LOVE_FONT_GLYPH_DATA_ID,
|
||||
LOVE_FONT_RASTERIZER_ID,
|
||||
FONT_GLYPH_DATA_ID,
|
||||
FONT_RASTERIZER_ID,
|
||||
|
||||
// Graphics
|
||||
LOVE_GRAPHICS_DRAWABLE_ID,
|
||||
LOVE_GRAPHICS_IMAGE_ID,
|
||||
LOVE_GRAPHICS_FRAME_ID,
|
||||
LOVE_GRAPHICS_GLYPH_ID,
|
||||
LOVE_GRAPHICS_ANIMATION_ID,
|
||||
LOVE_GRAPHICS_COLOR_ID,
|
||||
LOVE_GRAPHICS_FONT_ID,
|
||||
LOVE_GRAPHICS_PARTICLE_SYSTEM_ID,
|
||||
LOVE_GRAPHICS_SPRITE_BATCH_ID,
|
||||
LOVE_GRAPHICS_VERTEX_BUFFER_ID,
|
||||
GRAPHICS_DRAWABLE_ID,
|
||||
GRAPHICS_IMAGE_ID,
|
||||
GRAPHICS_FRAME_ID,
|
||||
GRAPHICS_GLYPH_ID,
|
||||
GRAPHICS_ANIMATION_ID,
|
||||
GRAPHICS_COLOR_ID,
|
||||
GRAPHICS_FONT_ID,
|
||||
GRAPHICS_PARTICLE_SYSTEM_ID,
|
||||
GRAPHICS_SPRITE_BATCH_ID,
|
||||
GRAPHICS_VERTEX_BUFFER_ID,
|
||||
|
||||
// Image
|
||||
LOVE_IMAGE_IMAGE_DATA_ID,
|
||||
IMAGE_IMAGE_DATA_ID,
|
||||
|
||||
// Audio
|
||||
LOVE_AUDIO_AUDIBLE_ID,
|
||||
LOVE_AUDIO_SOUND_ID,
|
||||
LOVE_AUDIO_MUSIC_ID,
|
||||
LOVE_AUDIO_SOURCE_ID,
|
||||
AUDIO_AUDIBLE_ID,
|
||||
AUDIO_SOUND_ID,
|
||||
AUDIO_MUSIC_ID,
|
||||
AUDIO_SOURCE_ID,
|
||||
|
||||
// Sound
|
||||
LOVE_SOUND_SOUND_DATA_ID,
|
||||
LOVE_SOUND_DECODER_ID,
|
||||
SOUND_SOUND_DATA_ID,
|
||||
SOUND_DECODER_ID,
|
||||
|
||||
// Physics
|
||||
LOVE_PHYSICS_WORLD_ID,
|
||||
LOVE_PHYSICS_CONTACT_ID,
|
||||
LOVE_PHYSICS_BODY_ID,
|
||||
LOVE_PHYSICS_SHAPE_ID,
|
||||
LOVE_PHYSICS_CIRCLE_SHAPE_ID,
|
||||
LOVE_PHYSICS_POLYGON_SHAPE_ID,
|
||||
LOVE_PHYSICS_JOINT_ID,
|
||||
LOVE_PHYSICS_MOUSE_JOINT_ID,
|
||||
LOVE_PHYSICS_DISTANCE_JOINT_ID,
|
||||
LOVE_PHYSICS_PRISMATIC_JOINT_ID,
|
||||
LOVE_PHYSICS_REVOLUTE_JOINT_ID,
|
||||
LOVE_PHYSICS_PULLEY_JOINT_ID,
|
||||
LOVE_PHYSICS_GEAR_JOINT_ID,
|
||||
|
||||
// Modules.
|
||||
LOVE_PHYSFS_ID,
|
||||
LOVE_OPENGL_ID,
|
||||
LOVE_DIRECT3D_ID,
|
||||
LOVE_BOX2D_ID,
|
||||
LOVE_DEVIL_ID,
|
||||
LOVE_SDLSOUND_ID,
|
||||
LOVE_OPENAL_ID,
|
||||
PHYSICS_WORLD_ID,
|
||||
PHYSICS_CONTACT_ID,
|
||||
PHYSICS_BODY_ID,
|
||||
PHYSICS_SHAPE_ID,
|
||||
PHYSICS_CIRCLE_SHAPE_ID,
|
||||
PHYSICS_POLYGON_SHAPE_ID,
|
||||
PHYSICS_JOINT_ID,
|
||||
PHYSICS_MOUSE_JOINT_ID,
|
||||
PHYSICS_DISTANCE_JOINT_ID,
|
||||
PHYSICS_PRISMATIC_JOINT_ID,
|
||||
PHYSICS_REVOLUTE_JOINT_ID,
|
||||
PHYSICS_PULLEY_JOINT_ID,
|
||||
PHYSICS_GEAR_JOINT_ID,
|
||||
|
||||
// Count the number of bits needed.
|
||||
LOVE_BIT_SIZE
|
||||
BIT_SIZE
|
||||
};
|
||||
|
||||
typedef std::bitset<LOVE_BIT_SIZE> bits;
|
||||
typedef std::bitset<BIT_SIZE> bits;
|
||||
|
||||
const bits LOVE_OBJECT_BITS = bits(1) << LOVE_OBJECT_ID;
|
||||
const bits LOVE_DATA_BITS = (bits(1) << LOVE_DATA_ID) | LOVE_OBJECT_BITS;
|
||||
const bits OBJECT_T = bits(1) << OBJECT_ID;
|
||||
const bits DATA_T = (bits(1) << DATA_ID) | OBJECT_T;
|
||||
|
||||
// Filesystem.
|
||||
const bits LOVE_FILESYSTEM_FILE_BITS = (bits(1) << LOVE_FILESYSTEM_FILE_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_FILESYSTEM_FILE_DATA_BITS = (bits(1) << LOVE_FILESYSTEM_FILE_DATA_ID) | LOVE_DATA_BITS;
|
||||
// Filesystem.
|
||||
const bits FILESYSTEM_FILE_T = (bits(1) << FILESYSTEM_FILE_ID) | OBJECT_T;
|
||||
const bits FILESYSTEM_FILE_DATA_T = (bits(1) << FILESYSTEM_FILE_DATA_ID) | DATA_T;
|
||||
|
||||
const bits LOVE_FONT_GLYPH_DATA_BITS = (bits(1) << LOVE_FONT_GLYPH_DATA_ID) | LOVE_DATA_BITS;
|
||||
const bits LOVE_FONT_RASTERIZER_BITS = (bits(1) << LOVE_FONT_RASTERIZER_ID) | LOVE_OBJECT_BITS;
|
||||
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 LOVE_GRAPHICS_DRAWABLE_BITS = (bits(1) << LOVE_GRAPHICS_DRAWABLE_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_GRAPHICS_IMAGE_BITS = (bits(1) << LOVE_GRAPHICS_IMAGE_ID) | LOVE_GRAPHICS_DRAWABLE_BITS;
|
||||
const bits LOVE_GRAPHICS_FRAME_BITS = (bits(1) << LOVE_GRAPHICS_FRAME_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_GRAPHICS_GLYPH_BITS = (bits(1) << LOVE_GRAPHICS_GLYPH_ID) | LOVE_GRAPHICS_DRAWABLE_BITS;
|
||||
const bits LOVE_GRAPHICS_ANIMATION_BITS = (bits(1) << LOVE_GRAPHICS_ANIMATION_ID) | LOVE_GRAPHICS_DRAWABLE_BITS;
|
||||
const bits LOVE_GRAPHICS_COLOR_BITS = (bits(1) << LOVE_GRAPHICS_COLOR_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_GRAPHICS_FONT_BITS = (bits(1) << LOVE_GRAPHICS_FONT_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_GRAPHICS_PARTICLE_SYSTEM_BITS = (bits(1) << LOVE_GRAPHICS_PARTICLE_SYSTEM_ID) | LOVE_GRAPHICS_DRAWABLE_BITS;
|
||||
const bits LOVE_GRAPHICS_SPRITE_BATCH_BITS = (bits(1) << LOVE_GRAPHICS_SPRITE_BATCH_ID) | LOVE_GRAPHICS_DRAWABLE_BITS;
|
||||
const bits LOVE_GRAPHICS_VERTEX_BUFFER_BITS = (bits(1) << LOVE_GRAPHICS_VERTEX_BUFFER_ID) | LOVE_GRAPHICS_DRAWABLE_BITS;
|
||||
const bits GRAPHICS_DRAWABLE_T = (bits(1) << GRAPHICS_DRAWABLE_ID) | OBJECT_T;
|
||||
const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_DRAWABLE_T;
|
||||
const bits GRAPHICS_FRAME_T = (bits(1) << GRAPHICS_FRAME_ID) | OBJECT_T;
|
||||
const bits GRAPHICS_GLYPH_T = (bits(1) << GRAPHICS_GLYPH_ID) | GRAPHICS_DRAWABLE_T;
|
||||
const bits GRAPHICS_ANIMATION_T = (bits(1) << GRAPHICS_ANIMATION_ID) | GRAPHICS_DRAWABLE_T;
|
||||
const bits GRAPHICS_COLOR_T = (bits(1) << GRAPHICS_COLOR_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_VERTEX_BUFFER_T = (bits(1) << GRAPHICS_VERTEX_BUFFER_ID) | GRAPHICS_DRAWABLE_T;
|
||||
|
||||
// Image.
|
||||
const bits LOVE_IMAGE_IMAGE_DATA_BITS = (bits(1) << LOVE_IMAGE_IMAGE_DATA_ID) | LOVE_DATA_BITS;
|
||||
const bits IMAGE_IMAGE_DATA_T = (bits(1) << IMAGE_IMAGE_DATA_ID) | DATA_T;
|
||||
|
||||
// Audio.
|
||||
const bits LOVE_AUDIO_AUDIBLE_BITS = (bits(1) << LOVE_AUDIO_AUDIBLE_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_AUDIO_SOUND_BITS = (bits(1) << LOVE_AUDIO_SOUND_ID) | LOVE_AUDIO_AUDIBLE_BITS;
|
||||
const bits LOVE_AUDIO_MUSIC_BITS = (bits(1) << LOVE_AUDIO_MUSIC_ID) | LOVE_AUDIO_AUDIBLE_BITS;
|
||||
const bits LOVE_AUDIO_SOURCE_BITS = (bits(1) << LOVE_AUDIO_SOURCE_ID) | LOVE_OBJECT_BITS;
|
||||
const bits AUDIO_AUDIBLE_T = (bits(1) << AUDIO_AUDIBLE_ID) | OBJECT_T;
|
||||
const bits AUDIO_SOUND_T = (bits(1) << AUDIO_SOUND_ID) | AUDIO_AUDIBLE_T;
|
||||
const bits AUDIO_MUSIC_T = (bits(1) << AUDIO_MUSIC_ID) | AUDIO_AUDIBLE_T;
|
||||
const bits AUDIO_SOURCE_T = (bits(1) << AUDIO_SOURCE_ID) | OBJECT_T;
|
||||
|
||||
// Sound.
|
||||
const bits LOVE_SOUND_SOUND_DATA_BITS = (bits(1) << LOVE_SOUND_SOUND_DATA_ID) | LOVE_DATA_BITS;
|
||||
const bits LOVE_SOUND_DECODER_BITS = bits(1) << LOVE_SOUND_DECODER_ID;
|
||||
const bits SOUND_SOUND_DATA_T = (bits(1) << SOUND_SOUND_DATA_ID) | DATA_T;
|
||||
const bits SOUND_DECODER_T = bits(1) << SOUND_DECODER_ID;
|
||||
|
||||
// Physics.
|
||||
const bits LOVE_PHYSICS_WORLD_BITS = (bits(1) << LOVE_PHYSICS_WORLD_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_PHYSICS_CONTACT_BITS = (bits(1) << LOVE_PHYSICS_CONTACT_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_PHYSICS_BODY_BITS = (bits(1) << LOVE_PHYSICS_BODY_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_PHYSICS_SHAPE_BITS = (bits(1) << LOVE_PHYSICS_SHAPE_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_PHYSICS_CIRCLE_SHAPE_BITS = (bits(1) << LOVE_PHYSICS_CIRCLE_SHAPE_ID) | LOVE_PHYSICS_SHAPE_BITS;
|
||||
const bits LOVE_PHYSICS_POLYGON_SHAPE_BITS = (bits(1) << LOVE_PHYSICS_POLYGON_SHAPE_ID) | LOVE_PHYSICS_SHAPE_BITS;
|
||||
const bits LOVE_PHYSICS_JOINT_BITS = (bits(1) << LOVE_PHYSICS_JOINT_ID) | LOVE_OBJECT_BITS;
|
||||
const bits LOVE_PHYSICS_MOUSE_JOINT_BITS = (bits(1) << LOVE_PHYSICS_MOUSE_JOINT_ID) | LOVE_PHYSICS_JOINT_BITS;
|
||||
const bits LOVE_PHYSICS_DISTANCE_JOINT_BITS = (bits(1) << LOVE_PHYSICS_DISTANCE_JOINT_ID) | LOVE_PHYSICS_JOINT_BITS;
|
||||
const bits LOVE_PHYSICS_PRISMATIC_JOINT_BITS = (bits(1) << LOVE_PHYSICS_PRISMATIC_JOINT_ID) | LOVE_PHYSICS_JOINT_BITS;
|
||||
const bits LOVE_PHYSICS_REVOLUTE_JOINT_BITS = (bits(1) << LOVE_PHYSICS_REVOLUTE_JOINT_ID) | LOVE_PHYSICS_JOINT_BITS;
|
||||
const bits LOVE_PHYSICS_PULLEY_JOINT_BITS = (bits(1) << LOVE_PHYSICS_PULLEY_JOINT_ID) | LOVE_PHYSICS_JOINT_BITS;
|
||||
const bits LOVE_PHYSICS_GEAR_JOINT_BITS = (bits(1) << LOVE_PHYSICS_GEAR_JOINT_ID) | LOVE_PHYSICS_JOINT_BITS;
|
||||
|
||||
// Modules.
|
||||
const bits LOVE_PHYSFS_BITS = bits(1) << LOVE_PHYSFS_ID;
|
||||
const bits LOVE_OPENGL_BITS = bits(1) << LOVE_OPENGL_ID;
|
||||
const bits LOVE_DIRECT3D_BITS = bits(1) << LOVE_DIRECT3D_ID;
|
||||
const bits LOVE_BOX2D_BITS = bits(1) << LOVE_BOX2D_ID;
|
||||
const bits LOVE_DEVIL_BITS = bits(1) << LOVE_DEVIL_ID;
|
||||
const bits LOVE_SDLSOUND_BITS = bits(1) << LOVE_SDLSOUND_ID;
|
||||
const bits LOVE_OPENAL_BITS = bits(1) << LOVE_OPENAL_ID;
|
||||
|
||||
// Wraps all userdata pointers.
|
||||
struct userdata
|
||||
{
|
||||
bits flags; // Holds type information.
|
||||
void * data;
|
||||
bool own; // True if Lua should delete on GC.
|
||||
};
|
||||
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_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_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;
|
||||
|
||||
} // love
|
||||
|
||||
|
||||
+10
-8
@@ -21,14 +21,16 @@
|
||||
#ifndef LOVE_VERSION_H
|
||||
#define LOVE_VERSION_H
|
||||
|
||||
// STD
|
||||
#include <string>
|
||||
namespace love
|
||||
{
|
||||
// Version stuff.
|
||||
const char VERSION_MAJOR = 0;
|
||||
const char VERSION_MINOR = 6;
|
||||
const char VERSION_REV = 0;
|
||||
const int VERSION_COMPATIBILITY[] = { 0 };
|
||||
const char * VERSION_STR = "0.6.0";
|
||||
const char * VERSION_CODENAME = "Jiggly Juice";
|
||||
|
||||
// Version stuff.
|
||||
const int LOVE_VERSION = 060;
|
||||
const int LOVE_VERSION_COMPATIBILITY[] = { 0 };
|
||||
const std::string LOVE_VERSION_STR = "0.6.0";
|
||||
const std::string LOVE_VERSION_CODENAME = "Jiggly Juice";
|
||||
const std::string LOVE_VERSION_FULL_STR = std::string("LOVE ") + LOVE_VERSION_STR + std::string(" (") + LOVE_VERSION_CODENAME + std::string(")");
|
||||
} // love
|
||||
|
||||
#endif // LOVE_VERSION_H
|
||||
|
||||
@@ -24,32 +24,32 @@ namespace love
|
||||
{
|
||||
Data * luax_checkdata(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Data>(L, idx, "Data", LOVE_DATA_BITS);
|
||||
return luax_checktype<Data>(L, idx, "Data", DATA_T);
|
||||
}
|
||||
|
||||
int _wrap_Data_getPointer(lua_State * L)
|
||||
int w_Data_getPointer(lua_State * L)
|
||||
{
|
||||
Data * t = luax_checkdata(L, 1);
|
||||
lua_pushlightuserdata(L, t->getData());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Data_getSize(lua_State * L)
|
||||
int w_Data_getSize(lua_State * L)
|
||||
{
|
||||
Data * t = luax_checkdata(L, 1);
|
||||
lua_pushinteger(L, t->getSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg wrap_Data_functions[] = {
|
||||
{ "getPointer", _wrap_Data_getPointer },
|
||||
{ "getSize", _wrap_Data_getSize },
|
||||
const luaL_Reg w_Data_functions[] = {
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_Data_open(lua_State * L)
|
||||
int w_Data_open(lua_State * L)
|
||||
{
|
||||
luax_register_type(L, "Data", wrap_Data_functions);
|
||||
luax_register_type(L, "Data", w_Data_functions);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
namespace love
|
||||
{
|
||||
Data * luax_checkdata(lua_State * L, int idx);
|
||||
int _wrap_Data_getPointer(lua_State * L);
|
||||
int _wrap_Data_getSize(lua_State * L);
|
||||
int wrap_Data_open(lua_State * L);
|
||||
int w_Data_getPointer(lua_State * L);
|
||||
int w_Data_getSize(lua_State * L);
|
||||
int w_Data_open(lua_State * L);
|
||||
|
||||
} // love
|
||||
|
||||
|
||||
Reference in New Issue
Block a user