Added many comments, and changed function names for wrapper functions.

This commit is contained in:
rude
2009-08-09 21:08:55 +02:00
parent f2adfd53f2
commit ba1a75e547
103 changed files with 2608 additions and 2391 deletions
+274 -122
View File
@@ -172,128 +172,280 @@
</Configurations>
<References>
</References>
<!-- Generated stuff begins -->
<Files>
<File RelativePath="..\..\src\modules\sound\Decoder.h">
</File>
<File RelativePath="..\..\src\modules\sound\Sound.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\Sound.h">
</File>
<File RelativePath="..\..\src\modules\sound\SoundData.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\SoundData.h">
</File>
<File RelativePath="..\..\src\modules\sound\wrap_Decoder.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\wrap_Decoder.h">
</File>
<File RelativePath="..\..\src\modules\sound\wrap_Sound.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\wrap_Sound.h">
</File>
<File RelativePath="..\..\src\modules\sound\wrap_SoundData.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\wrap_SoundData.h">
</File>
<Filter Name="lullaby">
<File RelativePath="..\..\src\modules\sound\lullaby\Decoder.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\Decoder.h">
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\FLACDecoder.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\FLACDecoder.h">
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\ModPlugDecoder.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\ModPlugDecoder.h">
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\Mpg123Decoder.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\Mpg123Decoder.h">
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\Sound.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\Sound.h">
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\VorbisDecoder.cpp">
<FileConfiguration Name="Debug|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
<FileConfiguration Name="Release|Win32">
<Tool Name="VCCLCompilerTool" ObjectFile="$(IntDir)\modules\sound\lullaby\" />
</FileConfiguration>
</File>
<File RelativePath="..\..\src\modules\sound\lullaby\VorbisDecoder.h">
</File>
</Filter>
</Files>
<!-- Generated stuff ends -->
<Files>
<Filter
Name="lullaby"
>
<File
RelativePath="..\..\src\modules\sound\lullaby\Decoder.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\Decoder.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\FLACDecoder.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\FLACDecoder.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\ModPlugDecoder.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\ModPlugDecoder.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\Mpg123Decoder.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\Mpg123Decoder.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\Sound.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\Sound.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\VorbisDecoder.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\lullaby\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\lullaby\VorbisDecoder.h"
>
</File>
</Filter>
<File
RelativePath="..\..\src\modules\sound\Decoder.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\Sound.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\Sound.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\SoundData.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\SoundData.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\wrap_Decoder.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\wrap_Decoder.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\wrap_Sound.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\wrap_Sound.h"
>
</File>
<File
RelativePath="..\..\src\modules\sound\wrap_SoundData.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\modules\sound\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\modules\sound\wrap_SoundData.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+1 -1
View File
@@ -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
View File
@@ -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
+2 -5
View File
@@ -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
View File
@@ -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
-1
View File
@@ -23,7 +23,6 @@
namespace love
{
MemoryData::MemoryData(void * data, int size)
: data(data), size(size)
{
+24 -1
View File
@@ -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
-1
View File
@@ -31,7 +31,6 @@ namespace love
Object::~Object()
{
// PURE VIRUTAL!
}
int Object::getReferenceCount() const
-5
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
+8 -8
View File
@@ -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;
}
+3 -3
View File
@@ -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
+2 -2
View File
@@ -79,7 +79,7 @@ DECLSPEC int luaopen_love(lua_State * L)
love::luax_insistglobal(L, "love");
// Resources.
love::luax_newtype(L, "Data", love::LOVE_DATA_BITS, new love::MemoryData((void*)love::Vera_ttf_data, love::Vera_ttf_size));
love::luax_newtype(L, "Data", love::DATA_T, new love::MemoryData((void*)love::Vera_ttf_data, love::Vera_ttf_size));
lua_setfield(L, -2, "_vera");
lua_pop(L, 1); // love
@@ -141,7 +141,7 @@ int main(int argc, char ** argv)
printf("(press key)\n");
getchar();
#endif
printf("Done. This was: %s (%s)\n", LOVE_VERSION_STR.c_str(), LOVE_VERSION_CODENAME.c_str());
printf("Done. This was: %s (%s)\n", love::VERSION_STR, love::VERSION_CODENAME);
return 0;
}
+62 -69
View File
@@ -30,66 +30,66 @@ namespace audio
{
static Audio * instance = 0;
int _wrap_getNumSources(lua_State * L)
int w_getNumSources(lua_State * L)
{
lua_pushinteger(L, instance->getNumSources());
return 1;
}
int _wrap_newSound(lua_State * L)
int w_newSound(lua_State * L)
{
// Convert to File, if necessary.
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
luax_convobj(L, 1, "filesystem", "newFile");
// Convert to SoundData, if necessary.
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
luax_convobj(L, 1, "sound", "newSoundData");
love::sound::SoundData * data = luax_checktype<love::sound::SoundData>(L, 1, "SoundData", LOVE_SOUND_SOUND_DATA_BITS);
love::sound::SoundData * data = luax_checktype<love::sound::SoundData>(L, 1, "SoundData", SOUND_SOUND_DATA_T);
Sound * t = instance->newSound(data);
luax_newtype(L, "Sound", LOVE_AUDIO_SOUND_BITS, (void*)t);
luax_newtype(L, "Sound", AUDIO_SOUND_T, (void*)t);
return 1;
}
int _wrap_newMusic(lua_State * L)
int w_newMusic(lua_State * L)
{
// Convert to Decoder, if necessary.
if(!luax_istype(L, 1, LOVE_SOUND_DECODER_BITS))
if(!luax_istype(L, 1, SOUND_DECODER_T))
luax_convobj(L, 1, "sound", "newDecoder");
love::sound::Decoder * decoder = luax_checktype<love::sound::Decoder>(L, 1, "Decoder", LOVE_SOUND_DECODER_BITS);
love::sound::Decoder * decoder = luax_checktype<love::sound::Decoder>(L, 1, "Decoder", SOUND_DECODER_T);
Music * t = instance->newMusic(decoder);
luax_newtype(L, "Music", LOVE_AUDIO_MUSIC_BITS, (void*)t);
luax_newtype(L, "Music", AUDIO_MUSIC_T, (void*)t);
return 1;
}
int _wrap_newSource(lua_State * L)
int w_newSource(lua_State * L)
{
Audible * a = luax_checktype<Audible>(L, 1, "Audible", LOVE_AUDIO_AUDIBLE_BITS);
Audible * a = luax_checktype<Audible>(L, 1, "Audible", AUDIO_AUDIBLE_T);
Source * t = instance->newSource(a);
luax_newtype(L, "Source", LOVE_AUDIO_SOURCE_BITS, (void*)t);
luax_newtype(L, "Source", AUDIO_SOURCE_T, (void*)t);
return 1;
}
int _wrap_play(lua_State * L)
int w_play(lua_State * L)
{
int argn = lua_gettop(L);
if(luax_istype(L, 1, LOVE_AUDIO_SOUND_BITS))
if(luax_istype(L, 1, AUDIO_SOUND_T))
{
Sound * s = luax_checksound(L, 1);
instance->play(s);
return 0;
}
else if(luax_istype(L, 1, LOVE_AUDIO_MUSIC_BITS))
else if(luax_istype(L, 1, AUDIO_MUSIC_T))
{
Music * m = luax_checkmusic(L, 1);
instance->play(m);
return 0;
}
else if(luax_istype(L, 1, LOVE_AUDIO_SOURCE_BITS))
else if(luax_istype(L, 1, AUDIO_SOURCE_T))
{
Source * s = luax_checksource(L, 1);
instance->play(s);
@@ -99,48 +99,48 @@ namespace audio
return luaL_error(L, "No matching overload");
}
int _wrap_stop(lua_State * L)
int w_stop(lua_State * L)
{
Source * c = luax_checksource(L, 1);
instance->stop(c);
return 0;
}
int _wrap_pause(lua_State * L)
int w_pause(lua_State * L)
{
Source * c = luax_checksource(L, 1);
instance->pause(c);
return 0;
}
int _wrap_resume(lua_State * L)
int w_resume(lua_State * L)
{
Source * c = luax_checksource(L, 1);
instance->resume(c);
return 0;
}
int _wrap_rewind(lua_State * L)
int w_rewind(lua_State * L)
{
Source * c = luax_checksource(L, 1);
instance->rewind(c);
return 0;
}
int _wrap_setVolume(lua_State * L)
int w_setVolume(lua_State * L)
{
float v = (float)luaL_checknumber(L, 1);
instance->setVolume(v);
return 0;
}
int _wrap_getVolume(lua_State * L)
int w_getVolume(lua_State * L)
{
lua_pushnumber(L, instance->getVolume());
return 1;
}
int _wrap_setPosition(lua_State * L)
int w_setPosition(lua_State * L)
{
float v[3];
v[0] = (float)luaL_checknumber(L, 1);
@@ -150,7 +150,7 @@ namespace audio
return 0;
}
int _wrap_getPosition(lua_State * L)
int w_getPosition(lua_State * L)
{
float v[3];
instance->getPosition(v);
@@ -160,7 +160,7 @@ namespace audio
return 3;
}
int _wrap_setOrientation(lua_State * L)
int w_setOrientation(lua_State * L)
{
float v[6];
v[0] = (float)luaL_checknumber(L, 1);
@@ -173,7 +173,7 @@ namespace audio
return 0;
}
int _wrap_getOrientation(lua_State * L)
int w_getOrientation(lua_State * L)
{
float v[6];
instance->getOrientation(v);
@@ -186,7 +186,7 @@ namespace audio
return 6;
}
int _wrap_setVelocity(lua_State * L)
int w_setVelocity(lua_State * L)
{
float v[3];
v[0] = (float)luaL_checknumber(L, 1);
@@ -196,7 +196,7 @@ namespace audio
return 0;
}
int _wrap_getVelocity(lua_State * L)
int w_getVelocity(lua_State * L)
{
float v[3];
instance->getVelocity(v);
@@ -206,39 +206,37 @@ namespace audio
return 3;
}
// List of functions to wrap.
static const luaL_Reg wrap_Audio_functions[] = {
{ "getNumSources", _wrap_getNumSources },
{ "newSound", _wrap_newSound },
{ "newMusic", _wrap_newMusic },
{ "newSource", _wrap_newSource },
{ "play", _wrap_play },
{ "stop", _wrap_stop },
{ "pause", _wrap_pause },
{ "resume", _wrap_resume },
{ "rewind", _wrap_rewind },
{ "setVolume", _wrap_setVolume },
{ "getVolume", _wrap_getVolume },
{ "setPosition", _wrap_setPosition },
{ "getPosition", _wrap_getPosition },
{ "setOrientation", _wrap_setOrientation },
{ "getOrientation", _wrap_getOrientation },
{ "setVelocity", _wrap_setVelocity },
{ "getVelocity", _wrap_getVelocity },
{ 0, 0 }
};
static const lua_CFunction wrap_Audio_types[] = {
wrap_Source_open,
wrap_Music_open,
wrap_Sound_open,
0
};
int wrap_Audio_open(lua_State * L)
int luaopen_love_audio(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "getNumSources", w_getNumSources },
{ "newSound", w_newSound },
{ "newMusic", w_newMusic },
{ "newSource", w_newSource },
{ "play", w_play },
{ "stop", w_stop },
{ "pause", w_pause },
{ "resume", w_resume },
{ "rewind", w_rewind },
{ "setVolume", w_setVolume },
{ "getVolume", w_getVolume },
{ "setPosition", w_setPosition },
{ "getPosition", w_getPosition },
{ "setOrientation", w_setOrientation },
{ "getOrientation", w_getOrientation },
{ "setVelocity", w_setVelocity },
{ "getVelocity", w_getVelocity },
{ 0, 0 }
};
static const lua_CFunction types[] = {
luaopen_source,
luaopen_music,
luaopen_sound,
0
};
if(instance == 0)
{
// Try OpenAL first.
@@ -268,15 +266,10 @@ namespace audio
if(instance == 0)
return luaL_error(L, "Could not open any audio module.");
luax_register_gc(L, "love.audio", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Audio_functions, wrap_Audio_types, 0, "audio");
return luax_register_module(L, functions, types, 0, "audio");
}
} // audio
} // love
int luaopen_love_audio(lua_State * L)
{
return love::audio::wrap_Audio_open(L);
}
} // love
+18 -20
View File
@@ -31,28 +31,26 @@ namespace love
{
namespace audio
{
int _wrap_getNumSources(lua_State * L);
int _wrap_newSound(lua_State * L);
int _wrap_newMusic(lua_State * L);
int _wrap_newSource(lua_State * L);
int _wrap_play(lua_State * L);
int _wrap_stop(lua_State * L);
int _wrap_pause(lua_State * L);
int _wrap_resume(lua_State * L);
int _wrap_rewind(lua_State * L);
int _wrap_setVolume(lua_State * L);
int _wrap_getVolume(lua_State * L);
int _wrap_setPosition(lua_State * L);
int _wrap_getPosition(lua_State * L);
int _wrap_setOrientation(lua_State * L);
int _wrap_getOrientation(lua_State * L);
int _wrap_setVelocity(lua_State * L);
int _wrap_getVelocity(lua_State * L);
int wrap_Audio_open(lua_State * L);
int w_getNumSources(lua_State * L);
int w_newSound(lua_State * L);
int w_newMusic(lua_State * L);
int w_newSource(lua_State * L);
int w_play(lua_State * L);
int w_stop(lua_State * L);
int w_pause(lua_State * L);
int w_resume(lua_State * L);
int w_rewind(lua_State * L);
int w_setVolume(lua_State * L);
int w_getVolume(lua_State * L);
int w_setPosition(lua_State * L);
int w_getPosition(lua_State * L);
int w_setOrientation(lua_State * L);
int w_getOrientation(lua_State * L);
int w_setVelocity(lua_State * L);
int w_getVelocity(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_audio(lua_State * L);
} // audio
} // love
extern "C" LOVE_EXPORT int luaopen_love_audio(lua_State * L);
#endif // LOVE_AUDIO_WRAP_AUDIO_H
+8 -7
View File
@@ -26,17 +26,18 @@ namespace audio
{
Music * luax_checkmusic(lua_State * L, int idx)
{
return luax_checktype<Music>(L, idx, "Music", LOVE_AUDIO_MUSIC_BITS);
return luax_checktype<Music>(L, idx, "Music", AUDIO_MUSIC_T);
}
static const luaL_Reg wrap_Music_functions[] = {
{ 0, 0 }
};
int wrap_Music_open(lua_State * L)
int luaopen_music(lua_State * L)
{
luax_register_type(L, "Music", wrap_Music_functions);
return 0;
static const luaL_Reg functions[] = {
{ 0, 0 }
};
return luax_register_type(L, "Music", functions);
}
} // audio
+1 -1
View File
@@ -29,7 +29,7 @@ namespace love
namespace audio
{
Music * luax_checkmusic(lua_State * L, int idx);
int wrap_Music_open(lua_State * L);
int luaopen_music(lua_State * L);
} // audio
} // love
+7 -8
View File
@@ -26,17 +26,16 @@ namespace audio
{
Sound * luax_checksound(lua_State * L, int idx)
{
return luax_checktype<Sound>(L, idx, "Sound", LOVE_AUDIO_SOUND_BITS);
return luax_checktype<Sound>(L, idx, "Sound", AUDIO_SOUND_T);
}
static const luaL_Reg wrap_Sound_functions[] = {
{ 0, 0 }
};
int wrap_Sound_open(lua_State * L)
int luaopen_sound(lua_State * L)
{
luax_register_type(L, "Sound", wrap_Sound_functions);
return 0;
static const luaL_Reg functions[] = {
{ 0, 0 }
};
return luax_register_type(L, "Sound", functions);
}
} // audio
+1 -1
View File
@@ -29,7 +29,7 @@ namespace love
namespace audio
{
Sound * luax_checksound(lua_State * L, int idx);
int wrap_Sound_open(lua_State * L);
int luaopen_sound(lua_State * L);
} // audio
} // love
+25 -26
View File
@@ -26,10 +26,10 @@ namespace audio
{
Source * luax_checksource(lua_State * L, int idx)
{
return luax_checktype<Source>(L, idx, "Source", LOVE_AUDIO_SOURCE_BITS);
return luax_checktype<Source>(L, idx, "Source", AUDIO_SOURCE_T);
}
int _wrap_Source_setPitch(lua_State * L)
int w_Source_setPitch(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float p = (float)luaL_checknumber(L, 2);
@@ -37,14 +37,14 @@ namespace audio
return 0;
}
int _wrap_Source_getPitch(lua_State * L)
int w_Source_getPitch(lua_State * L)
{
Source * t = luax_checksource(L, 1);
lua_pushnumber(L, t->getPitch());
return 1;
}
int _wrap_Source_setVolume(lua_State * L)
int w_Source_setVolume(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float p = (float)luaL_checknumber(L, 2);
@@ -52,14 +52,14 @@ namespace audio
return 0;
}
int _wrap_Source_getVolume(lua_State * L)
int w_Source_getVolume(lua_State * L)
{
Source * t = luax_checksource(L, 1);
lua_pushnumber(L, t->getVolume());
return 1;
}
int _wrap_Source_setPosition(lua_State * L)
int w_Source_setPosition(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
@@ -70,7 +70,7 @@ namespace audio
return 0;
}
int _wrap_Source_getPosition(lua_State * L)
int w_Source_getPosition(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
@@ -81,7 +81,7 @@ namespace audio
return 3;
}
int _wrap_Source_setVelocity(lua_State * L)
int w_Source_setVelocity(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
@@ -92,7 +92,7 @@ namespace audio
return 0;
}
int _wrap_Source_getVelocity(lua_State * L)
int w_Source_getVelocity(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
@@ -103,7 +103,7 @@ namespace audio
return 3;
}
int _wrap_Source_setDirection(lua_State * L)
int w_Source_setDirection(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
@@ -114,7 +114,7 @@ namespace audio
return 0;
}
int _wrap_Source_getDirection(lua_State * L)
int w_Source_getDirection(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
@@ -125,34 +125,33 @@ namespace audio
return 3;
}
int _wrap_Source_setLooping(lua_State * L)
int w_Source_setLooping(lua_State * L)
{
Source * t = luax_checksource(L, 1);
t->setLooping(luax_toboolean(L, 2));
return 0;
}
int _wrap_Source_isLooping(lua_State * L)
int w_Source_isLooping(lua_State * L)
{
Source * t = luax_checksource(L, 1);
luax_pushboolean(L, t->isLooping());
return 1;
}
static const luaL_Reg wrap_Source_functions[] = {
{ "setPitch", _wrap_Source_setPitch },
{ "getPitch", _wrap_Source_getPitch },
{ "setVolume", _wrap_Source_setVolume },
{ "getVolume", _wrap_Source_getVolume },
{ "setLooping", _wrap_Source_setLooping },
{ "isLooping", _wrap_Source_isLooping },
{ 0, 0 }
};
int wrap_Source_open(lua_State * L)
int luaopen_source(lua_State * L)
{
luax_register_type(L, "Source", wrap_Source_functions);
return 0;
static const luaL_Reg functions[] = {
{ "setPitch", w_Source_setPitch },
{ "getPitch", w_Source_getPitch },
{ "setVolume", w_Source_setVolume },
{ "getVolume", w_Source_getVolume },
{ "setLooping", w_Source_setLooping },
{ "isLooping", w_Source_isLooping },
{ 0, 0 }
};
return luax_register_type(L, "Source", functions);
}
} // audio
+13 -13
View File
@@ -29,19 +29,19 @@ namespace love
namespace audio
{
Source * luax_checksource(lua_State * L, int idx);
int _wrap_Source_setPitch(lua_State * L);
int _wrap_Source_getPitch(lua_State * L);
int _wrap_Source_setVolume(lua_State * L);
int _wrap_Source_getVolume(lua_State * L);
int _wrap_Source_setPosition(lua_State * L);
int _wrap_Source_getPosition(lua_State * L);
int _wrap_Source_setVelocity(lua_State * L);
int _wrap_Source_getVelocity(lua_State * L);
int _wrap_Source_setDirection(lua_State * L);
int _wrap_Source_getDirection(lua_State * L);
int _wrap_Source_setLooping(lua_State * L);
int _wrap_Source_isLooping(lua_State * L);
int wrap_Source_open(lua_State * L);
int w_Source_setPitch(lua_State * L);
int w_Source_getPitch(lua_State * L);
int w_Source_setVolume(lua_State * L);
int w_Source_getVolume(lua_State * L);
int w_Source_setPosition(lua_State * L);
int w_Source_getPosition(lua_State * L);
int w_Source_setVelocity(lua_State * L);
int w_Source_getVelocity(lua_State * L);
int w_Source_setDirection(lua_State * L);
int w_Source_getDirection(lua_State * L);
int w_Source_setLooping(lua_State * L);
int w_Source_isLooping(lua_State * L);
int luaopen_source(lua_State * L);
} // audio
} // love
+29 -35
View File
@@ -34,57 +34,56 @@ namespace sdl
{
static Event * instance = 0;
int _wrap_pump(lua_State * L)
int w_pump(lua_State * L)
{
instance->pump();
return 0;
}
int _wrap_poll(lua_State * L)
int w_poll(lua_State * L)
{
return instance->poll(L);
}
int _wrap_wait(lua_State * L)
int w_wait(lua_State * L)
{
return instance->wait(L);
}
int _wrap_quit(lua_State * L)
int w_quit(lua_State * L)
{
instance->quit();
return 0;
}
int _wrap_push(lua_State * L)
int w_push(lua_State * L)
{
return instance->push(L);
}
// List of functions to wrap.
static const luaL_Reg wrap_Event_functions[] = {
{ "pump", _wrap_pump },
{ "poll", _wrap_poll },
{ "wait", _wrap_wait },
{ "quit", _wrap_quit },
{ "push", _wrap_push },
{ 0, 0 }
};
// List of constants.
static const LuaConstant wrap_Event_constants[] = {
{ "event_keypressed", Event::EVENT_KEYDOWN },
{ "event_keyreleased", Event::EVENT_KEYUP },
{ "event_mousepressed", Event::EVENT_MOUSEBUTTONDOWN },
{ "event_mousereleased", Event::EVENT_MOUSEBUTTONUP },
{ "event_joystickpressed", Event::EVENT_JOYBUTTONDOWN },
{ "event_joystickreleased", Event::EVENT_JOYBUTTONUP },
{ "event_quit", Event::EVENT_QUIT },
{ 0, 0 }
};
int wrap_Event_open(lua_State * L)
int luaopen_love_event(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "pump", w_pump },
{ "poll", w_poll },
{ "wait", w_wait },
{ "quit", w_quit },
{ "push", w_push },
{ 0, 0 }
};
// List of constants.
static const LuaConstant constants[] = {
{ "event_keypressed", Event::EVENT_KEYDOWN },
{ "event_keyreleased", Event::EVENT_KEYUP },
{ "event_mousepressed", Event::EVENT_MOUSEBUTTONDOWN },
{ "event_mousereleased", Event::EVENT_MOUSEBUTTONUP },
{ "event_joystickpressed", Event::EVENT_JOYBUTTONDOWN },
{ "event_joystickreleased", Event::EVENT_JOYBUTTONUP },
{ "event_quit", Event::EVENT_QUIT },
{ 0, 0 }
};
if(instance == 0)
{
try
@@ -97,16 +96,11 @@ namespace sdl
}
}
luax_register_gc(L, "love.event", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Event_functions, 0, wrap_Event_constants, "event");
return luax_register_module(L, functions, 0, constants, "event");
}
} // sdl
} // event
} // love
int luaopen_love_event(lua_State * L)
{
return love::event::sdl::wrap_Event_open(L);
}
+6 -8
View File
@@ -31,18 +31,16 @@ namespace event
{
namespace sdl
{
int _wrap_pump(lua_State * L);
int _wrap_poll(lua_State * L);
int _wrap_wait(lua_State * L);
int _wrap_quit(lua_State * L);
int _wrap_push(lua_State * L);
int w_pump(lua_State * L);
int w_poll(lua_State * L);
int w_wait(lua_State * L);
int w_quit(lua_State * L);
int w_push(lua_State * L);
int wrap_Event_open(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_event(lua_State * L);
} // sdl
} // event
} // love
extern "C" LOVE_EXPORT int luaopen_love_event(lua_State * L);
#endif // LOVE_EVENT_SDL_WRAP_EVENT_H
+6 -6
View File
@@ -64,10 +64,10 @@ namespace physfs
save_identity = std::string(ident);
// Generate the relative path to the game save folder.
save_path_relative = std::string(LOVE_APPDATA_FOLDER LOVE_PATH_SEPARATOR) + save_identity;
save_path_relative = std::string(APPDATA_FOLDER PATH_SEPARATOR) + save_identity;
// Generate the full path to the game save folder.
save_path_full = std::string(getAppdataDirectory()) + std::string(LOVE_PATH_SEPARATOR);
save_path_full = std::string(getAppdataDirectory()) + std::string(PATH_SEPARATOR);
save_path_full += save_path_relative;
std::cout << save_path_full << std::endl;
@@ -155,7 +155,7 @@ namespace physfs
const char * Filesystem::getWorkingDirectory()
{
#ifdef LOVE_WINDOWS
#ifdef WINDOWS
_getcwd(cwdbuffer, _MAX_PATH);
#else
char * temp = getcwd(cwdbuffer, MAXPATHLEN);
@@ -172,7 +172,7 @@ namespace physfs
const char * Filesystem::getAppdataDirectory()
{
#ifdef LOVE_WINDOWS
#ifdef WINDOWS
return getenv("APPDATA");
#else
return getUserDirectory();
@@ -372,7 +372,7 @@ namespace physfs
return luaL_error(L, "Could not open file %s.\n", lua_tostring(L, 1));
lua_pop(L, 1);
luax_newtype(L, "File", LOVE_FILESYSTEM_FILE_BITS, file, false);
luax_newtype(L, "File", FILESYSTEM_FILE_T, file, false);
lua_pushboolean(L, 1); // 1 = autoclose.
}
else
@@ -392,7 +392,7 @@ namespace physfs
const static int bufsize = 8;
static char buf[bufsize];
File * file = luax_checktype<File>(L, lua_upvalueindex(1), "File", LOVE_FILESYSTEM_FILE_BITS);
File * file = luax_checktype<File>(L, lua_upvalueindex(1), "File", FILESYSTEM_FILE_T);
int close = (int)lua_tointeger(L, lua_upvalueindex(2));
// Find the next newline.
+28 -29
View File
@@ -28,17 +28,17 @@ namespace physfs
{
File * luax_checkfile(lua_State * L, int idx)
{
return luax_checktype<File>(L, idx, "File", LOVE_FILESYSTEM_FILE_BITS);
return luax_checktype<File>(L, idx, "File", FILESYSTEM_FILE_T);
}
int _wrap_File_getSize(lua_State * L)
int w_File_getSize(lua_State * L)
{
File * t = luax_checkfile(L, 1);
lua_pushinteger(L, t->getSize());
return 1;
}
int _wrap_File_open(lua_State * L)
int w_File_open(lua_State * L)
{
File * file = luax_checkfile(L, 1);
int mode = luaL_optint(L, 2, File::READ);
@@ -46,14 +46,14 @@ namespace physfs
return 1;
}
int _wrap_File_close(lua_State * L)
int w_File_close(lua_State * L)
{
File * file = luax_checkfile(L, 1);
lua_pushboolean(L, file->close() ? 1 : 0);
return 1;
}
int _wrap_File_read(lua_State * L)
int w_File_read(lua_State * L)
{
File * file = luax_checkfile(L, 1);
Data * d = file->read(luaL_optint(L, 2, file->getSize()));
@@ -63,7 +63,7 @@ namespace physfs
return 2;
}
int _wrap_File_write(lua_State * L)
int w_File_write(lua_State * L)
{
File * file = luax_checkfile(L, 1);
bool result;
@@ -77,21 +77,21 @@ namespace physfs
return 1;
}
int _wrap_File_eof(lua_State * L)
int w_File_eof(lua_State * L)
{
File * file = luax_checkfile(L, 1);
lua_pushboolean(L, file->eof() ? 1 : 0);
return 1;
}
int _wrap_File_tell(lua_State * L)
int w_File_tell(lua_State * L)
{
File * file = luax_checkfile(L, 1);
lua_pushinteger(L, file->tell());
return 1;
}
int _wrap_File_seek(lua_State * L)
int w_File_seek(lua_State * L)
{
File * file = luax_checkfile(L, 1);
int pos = luaL_checkinteger(L, 2);
@@ -101,13 +101,13 @@ namespace physfs
//yes, the following two are copy-pasted and slightly edited
int _wrap_File_lines(lua_State * L)
int w_File_lines(lua_State * L)
{
File * file;
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
{
file = luax_checktype<File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
file = luax_checktype<File>(L, 1, "File", FILESYSTEM_FILE_T);
lua_pushboolean(L, 0); // 0 = do not close.
}
else
@@ -127,7 +127,7 @@ namespace physfs
const static int bufsize = 1024;
static char buf[bufsize];
File * file = luax_checktype<File>(L, lua_upvalueindex(1), "File", LOVE_FILESYSTEM_FILE_BITS);
File * file = luax_checktype<File>(L, lua_upvalueindex(1), "File", FILESYSTEM_FILE_T);
int close = (int)lua_tointeger(L, lua_upvalueindex(2));
// Find the next newline.
@@ -201,23 +201,22 @@ namespace physfs
return 0;
}
const luaL_Reg wrap_File_functions[] = {
{ "getSize", _wrap_File_getSize },
{ "open", _wrap_File_open },
{ "close", _wrap_File_close },
{ "read", _wrap_File_read },
{ "write", _wrap_File_write },
{ "eof", _wrap_File_eof },
{ "tell", _wrap_File_tell },
{ "seek", _wrap_File_seek },
{ "lines", _wrap_File_lines },
{ 0, 0 }
};
int wrap_File_open(lua_State * L)
int luaopen_file(lua_State * L)
{
luax_register_type(L, "File", wrap_File_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getSize", w_File_getSize },
{ "open", w_File_open },
{ "close", w_File_close },
{ "read", w_File_read },
{ "write", w_File_write },
{ "eof", w_File_eof },
{ "tell", w_File_tell },
{ "seek", w_File_seek },
{ "lines", w_File_lines },
{ 0, 0 }
};
return luax_register_type(L, "File", functions);
}
} // physfs
+10 -10
View File
@@ -32,17 +32,17 @@ namespace filesystem
namespace physfs
{
File * luax_checkfile(lua_State * L, int idx);
int _wrap_File_getSize(lua_State * L);
int _wrap_File_open(lua_State * L);
int _wrap_File_close(lua_State * L);
int _wrap_File_read(lua_State * L);
int _wrap_File_write(lua_State * L);
int _wrap_File_eof(lua_State * L);
int _wrap_File_tell(lua_State * L);
int _wrap_File_seek(lua_State * L);
int _wrap_File_lines(lua_State * L);
int w_File_getSize(lua_State * L);
int w_File_open(lua_State * L);
int w_File_close(lua_State * L);
int w_File_read(lua_State * L);
int w_File_write(lua_State * L);
int w_File_eof(lua_State * L);
int w_File_tell(lua_State * L);
int w_File_seek(lua_State * L);
int w_File_lines(lua_State * L);
int lines_i(lua_State * L);
int wrap_File_open(lua_State * L);
int luaopen_file(lua_State * L);
} // physfs
} // filesystem
} // love
+17 -18
View File
@@ -30,39 +30,38 @@ namespace physfs
{
FileData * luax_checkfiledata(lua_State * L, int idx)
{
return luax_checktype<FileData>(L, idx, "FileData", LOVE_FILESYSTEM_FILE_DATA_BITS);
return luax_checktype<FileData>(L, idx, "FileData", FILESYSTEM_FILE_DATA_T);
}
int _wrap_FileData_getFilename(lua_State * L)
int w_FileData_getFilename(lua_State * L)
{
FileData * t = luax_checkfiledata(L, 1);
lua_pushstring(L, t->getFilename().c_str());
return 1;
}
int _wrap_FileData_getExtension(lua_State * L)
int w_FileData_getExtension(lua_State * L)
{
FileData * t = luax_checkfiledata(L, 1);
lua_pushstring(L, t->getExtension().c_str());
return 1;
}
const luaL_Reg wrap_FileData_functions[] = {
// Data
{ "getPointer", _wrap_Data_getPointer },
{ "getSize", _wrap_Data_getSize },
{ "getFilename", _wrap_FileData_getFilename },
{ "getExtension", _wrap_FileData_getExtension },
{ 0, 0 }
};
int wrap_FileData_open(lua_State * L)
int w_FileData_open(lua_State * L)
{
luax_register_type(L, "FileData", wrap_FileData_functions);
return 0;
static const luaL_Reg w_FileData_functions[] = {
// Data
{ "getPointer", w_Data_getPointer },
{ "getSize", w_Data_getSize },
{ "getFilename", w_FileData_getFilename },
{ "getExtension", w_FileData_getExtension },
{ 0, 0 }
};
return luax_register_type(L, "FileData", w_FileData_functions);
}
} // physfs
@@ -33,9 +33,9 @@ namespace filesystem
namespace physfs
{
FileData * luax_checkfiledata(lua_State * L, int idx);
int _wrap_FileData_getFilename(lua_State * L);
int _wrap_FileData_getExtension(lua_State * L);
int wrap_FileData_open(lua_State * L);
int w_FileData_getFilename(lua_State * L);
int w_FileData_getExtension(lua_State * L);
int w_FileData_open(lua_State * L);
} // physfs
} // filesystem
} // love
@@ -36,7 +36,7 @@ namespace physfs
return false;
}
int _wrap_init(lua_State * L)
int w_init(lua_State * L)
{
const char * arg0 = luaL_checkstring(L, 1);
@@ -52,7 +52,7 @@ namespace physfs
return 0;
}
int _wrap_setIdentity(lua_State * L)
int w_setIdentity(lua_State * L)
{
const char * arg = luaL_checkstring(L, 1);
@@ -62,7 +62,7 @@ namespace physfs
return 0;
}
int _wrap_setSource(lua_State * L)
int w_setSource(lua_State * L)
{
const char * arg = luaL_checkstring(L, 1);
@@ -72,15 +72,15 @@ namespace physfs
return 0;
}
int _wrap_newFile(lua_State * L)
int w_newFile(lua_State * L)
{
const char * filename = luaL_checkstring(L, 1);
File * t = instance->newFile(filename);
luax_newtype(L, "File", LOVE_FILESYSTEM_FILE_BITS, (void*)t);
luax_newtype(L, "File", FILESYSTEM_FILE_T, (void*)t);
return 1;
}
int _wrap_newFileData(lua_State * L)
int w_newFileData(lua_State * L)
{
if(!lua_isstring(L, 1))
return luaL_error(L, "String expected.");
@@ -93,90 +93,90 @@ namespace physfs
FileData * t = instance->newFileData((void*)str, (int)length, filename);
luax_newtype(L, "FileData", LOVE_FILESYSTEM_FILE_DATA_BITS, (void*)t);
luax_newtype(L, "FileData", FILESYSTEM_FILE_DATA_T, (void*)t);
return 1;
}
int _wrap_getWorkingDirectory(lua_State * L)
int w_getWorkingDirectory(lua_State * L)
{
lua_pushstring(L, instance->getWorkingDirectory());
return 1;
}
int _wrap_getUserDirectory(lua_State * L)
int w_getUserDirectory(lua_State * L)
{
lua_pushstring(L, instance->getUserDirectory());
return 1;
}
int _wrap_getAppdataDirectory(lua_State * L)
int w_getAppdataDirectory(lua_State * L)
{
lua_pushstring(L, instance->getAppdataDirectory());
return 1;
}
int _wrap_getSaveDirectory(lua_State * L)
int w_getSaveDirectory(lua_State * L)
{
lua_pushstring(L, instance->getSaveDirectory());
return 1;
}
int _wrap_exists(lua_State * L)
int w_exists(lua_State * L)
{
const char * arg = luaL_checkstring(L, 1);
lua_pushboolean(L, instance->exists(arg) ? 1 : 0);
return 1;
}
int _wrap_isDirectory(lua_State * L)
int w_isDirectory(lua_State * L)
{
const char * arg = luaL_checkstring(L, 1);
lua_pushboolean(L, instance->isDirectory(arg) ? 1 : 0);
return 1;
}
int _wrap_isFile(lua_State * L)
int w_isFile(lua_State * L)
{
const char * arg = luaL_checkstring(L, 1);
lua_pushboolean(L, instance->isFile(arg) ? 1 : 0);
return 1;
}
int _wrap_mkdir(lua_State * L)
int w_mkdir(lua_State * L)
{
const char * arg = luaL_checkstring(L, 1);
lua_pushboolean(L, instance->mkdir(arg) ? 1 : 0);
return 1;
}
int _wrap_remove(lua_State * L)
int w_remove(lua_State * L)
{
const char * arg = luaL_checkstring(L, 1);
lua_pushboolean(L, instance->remove(arg) ? 1 : 0);
return 1;
}
int _wrap_read(lua_State * L)
int w_read(lua_State * L)
{
return instance->read(L);
}
int _wrap_write(lua_State * L)
int w_write(lua_State * L)
{
return instance->write(L);
}
int _wrap_enumerate(lua_State * L)
int w_enumerate(lua_State * L)
{
return instance->enumerate(L);
}
int _wrap_lines(lua_State * L)
int w_lines(lua_State * L)
{
return instance->lines(L);
}
int _wrap_load(lua_State * L)
int w_load(lua_State * L)
{
return instance->load(L);
}
@@ -214,46 +214,46 @@ namespace physfs
return instance->load(L);
}
// List of functions to wrap.
const luaL_Reg wrap_Filesystem_functions[] = {
{ "init", _wrap_init },
{ "setIdentity", _wrap_setIdentity },
{ "setSource", _wrap_setSource },
{ "newFile", _wrap_newFile },
{ "getWorkingDirectory", _wrap_getWorkingDirectory },
{ "getUserDirectory", _wrap_getUserDirectory },
{ "getAppdataDirectory", _wrap_getAppdataDirectory },
{ "getSaveDirectory", _wrap_getSaveDirectory },
{ "exists", _wrap_exists },
{ "isDirectory", _wrap_isDirectory },
{ "isFile", _wrap_isFile },
{ "mkdir", _wrap_mkdir },
{ "remove", _wrap_remove },
{ "read", _wrap_read },
{ "write", _wrap_write },
{ "enumerate", _wrap_enumerate },
{ "lines", _wrap_lines },
{ "load", _wrap_load },
{ 0, 0 }
};
const lua_CFunction wrap_Filesystem_types[] = {
wrap_File_open,
wrap_FileData_open,
0
};
// List of constants.
static const LuaConstant wrap_Filesystem_constants[] = {
{ "file_closed", File::CLOSED },
{ "file_read", File::READ },
{ "file_write", File::WRITE },
{ "file_append", File::APPEND },
{ 0, 0 }
};
int wrap_Filesystem_open(lua_State * L)
int w_Filesystem_open(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "init", w_init },
{ "setIdentity", w_setIdentity },
{ "setSource", w_setSource },
{ "newFile", w_newFile },
{ "getWorkingDirectory", w_getWorkingDirectory },
{ "getUserDirectory", w_getUserDirectory },
{ "getAppdataDirectory", w_getAppdataDirectory },
{ "getSaveDirectory", w_getSaveDirectory },
{ "exists", w_exists },
{ "isDirectory", w_isDirectory },
{ "isFile", w_isFile },
{ "mkdir", w_mkdir },
{ "remove", w_remove },
{ "read", w_read },
{ "write", w_write },
{ "enumerate", w_enumerate },
{ "lines", w_lines },
{ "load", w_load },
{ 0, 0 }
};
static const lua_CFunction types[] = {
luaopen_file,
luaopen_filedata,
0
};
// List of constants.
static const LuaConstant constants[] = {
{ "file_closed", File::CLOSED },
{ "file_read", File::READ },
{ "file_write", File::WRITE },
{ "file_append", File::APPEND },
{ 0, 0 }
};
if(instance == 0)
{
try
@@ -267,16 +267,11 @@ namespace physfs
}
}
luax_register_gc(L, "love.filesystem", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Filesystem_functions, wrap_Filesystem_types, wrap_Filesystem_constants, "filesystem");
return luax_register_module(L, functions, types, constants, "filesystem");
}
} // physfs
} // filesystem
} // love
int luaopen_love_filesystem(lua_State * L)
{
return love::filesystem::physfs::wrap_Filesystem_open(L);
}
} // love
+25 -27
View File
@@ -33,37 +33,35 @@ namespace filesystem
namespace physfs
{
bool hack_setupWriteDirectory();
int _wrap_init(lua_State * L);
int _wrap_setIdentity(lua_State * L);
int _wrap_setSource(lua_State * L);
int _wrap_newFile(lua_State * L);
int _wrap_newFileData(lua_State * L);
int _wrap_getWorkingDirectory(lua_State * L);
int _wrap_getUserDirectory(lua_State * L);
int _wrap_getAppdataDirectory(lua_State * L);
int _wrap_getSaveDirectory(lua_State * L);
int _wrap_exists(lua_State * L);
int _wrap_isDirectory(lua_State * L);
int _wrap_isFile(lua_State * L);
int _wrap_mkdir(lua_State * L);
int _wrap_remove(lua_State * L);
int _wrap_open(lua_State * L);
int _wrap_close(lua_State * L);
int _wrap_read(lua_State * L);
int _wrap_write(lua_State * L);
int _wrap_eof(lua_State * L);
int _wrap_tell(lua_State * L);
int _wrap_seek(lua_State * L);
int _wrap_enumerate(lua_State * L);
int _wrap_lines(lua_State * L);
int _wrap_load(lua_State * L);
int w_init(lua_State * L);
int w_setIdentity(lua_State * L);
int w_setSource(lua_State * L);
int w_newFile(lua_State * L);
int w_newFileData(lua_State * L);
int w_getWorkingDirectory(lua_State * L);
int w_getUserDirectory(lua_State * L);
int w_getAppdataDirectory(lua_State * L);
int w_getSaveDirectory(lua_State * L);
int w_exists(lua_State * L);
int w_isDirectory(lua_State * L);
int w_isFile(lua_State * L);
int w_mkdir(lua_State * L);
int w_remove(lua_State * L);
int w_open(lua_State * L);
int w_close(lua_State * L);
int w_read(lua_State * L);
int w_write(lua_State * L);
int w_eof(lua_State * L);
int w_tell(lua_State * L);
int w_seek(lua_State * L);
int w_enumerate(lua_State * L);
int w_lines(lua_State * L);
int w_load(lua_State * L);
int loader(lua_State * L);
int wrap_Filesystem_open(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_filesystem(lua_State * L);
} // physfs
} // filesystem
} // love
extern "C" LOVE_EXPORT int luaopen_love_filesystem(lua_State * L);
#endif // LOVE_FILESYSTEM_PHYSFS_WRAP_FILESYSTEM_H
+20 -25
View File
@@ -33,41 +33,41 @@ namespace freetype
{
static Font * instance = 0;
int _wrap_newRasterizer(lua_State * L)
int w_newRasterizer(lua_State * L)
{
Data * d = luax_checkdata(L, 1);
int size = luaL_checkint(L, 2);
Rasterizer * t = instance->newRasterizer(d, size);
luax_newtype(L, "Rasterizer", LOVE_FONT_RASTERIZER_BITS, t);
luax_newtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
return 1;
}
int _wrap_newGlyphData(lua_State * L)
int w_newGlyphData(lua_State * L)
{
Rasterizer * r = luax_checkrasterizer(L, 1);
unsigned short g = (unsigned short)luaL_checkint(L, 2);
GlyphData * t = instance->newGlyphData(r, g);
luax_newtype(L, "GlyphData", LOVE_FONT_GLYPH_DATA_BITS, t);
luax_newtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
return 1;
}
// List of functions to wrap.
static const luaL_Reg wrap_Font_functions[] = {
{ "newRasterizer", _wrap_newRasterizer },
{ "newGlyphData", _wrap_newGlyphData },
{ 0, 0 }
};
static const lua_CFunction wrap_Font_types[] = {
wrap_GlyphData_open,
wrap_Rasterizer_open,
0
};
int wrap_Font_open(lua_State * L)
int luaopen_font(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "newRasterizer", w_newRasterizer },
{ "newGlyphData", w_newGlyphData },
{ 0, 0 }
};
static const lua_CFunction types[] = {
luaopen_glyphdata,
luaopen_rasterizer,
0
};
if(instance == 0)
{
try
@@ -80,16 +80,11 @@ namespace freetype
}
}
luax_register_gc(L, "love.font", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Font_functions, wrap_Font_types, 0, "font");
return luax_register_module(L, functions, types, 0, "font");
}
} // freetype
} // font
} // love
int luaopen_love_font(lua_State * L)
{
return love::font::freetype::wrap_Font_open(L);
}
+3 -5
View File
@@ -32,14 +32,12 @@ namespace font
{
namespace freetype
{
int _wrap_newRasterizer(lua_State * L);
int _wrap_newGlyphData(lua_State * L);
int wrap_Font_open(lua_State * L);
int w_newRasterizer(lua_State * L);
int w_newGlyphData(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_font(lua_State * L);
} // freetype
} // font
} // love
#endif // LOVE_FONT_FREETYPE_WRAP_FONT_H
extern "C" LOVE_EXPORT int luaopen_love_font(lua_State * L);
+9 -13
View File
@@ -26,22 +26,18 @@ namespace font
{
GlyphData * luax_checkglyphdata(lua_State * L, int idx)
{
return luax_checktype<GlyphData>(L, idx, "GlyphData", LOVE_FONT_GLYPH_DATA_BITS);
return luax_checktype<GlyphData>(L, idx, "GlyphData", FONT_GLYPH_DATA_T);
}
static const luaL_Reg wrap_GlyphData_functions[] = {
// Data
{ "getPointer", _wrap_Data_getPointer },
{ "getSize", _wrap_Data_getSize },
{ 0, 0 }
};
int wrap_GlyphData_open(lua_State * L)
int luaopen_glyphdata(lua_State * L)
{
luax_register_type(L, "GlyphData", wrap_GlyphData_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getPointer", w_Data_getPointer },
{ "getSize", w_Data_getSize },
{ 0, 0 }
};
return luax_register_type(L, "GlyphData", functions);
}
} // sound
+1 -1
View File
@@ -32,7 +32,7 @@ namespace love
namespace font
{
GlyphData * luax_checkglyphdata(lua_State * L, int idx);
int wrap_GlyphData_open(lua_State * L);
int luaopen_glyphdata(lua_State * L);
} // font
} // love
+10 -13
View File
@@ -28,22 +28,19 @@ namespace font
{
Rasterizer * luax_checkrasterizer(lua_State * L, int idx)
{
return luax_checktype<Rasterizer>(L, idx, "Rasterizer", LOVE_FONT_RASTERIZER_BITS);
return luax_checktype<Rasterizer>(L, idx, "Rasterizer", FONT_RASTERIZER_T);
}
static const luaL_Reg wrap_Rasterizer_functions[] = {
// Data
{ "getPointer", _wrap_Data_getPointer },
{ "getSize", _wrap_Data_getSize },
{ 0, 0 }
};
int wrap_Rasterizer_open(lua_State * L)
int luaopen_rasterizer(lua_State * L)
{
luax_register_type(L, "Rasterizer", wrap_Rasterizer_functions);
return 0;
static const luaL_Reg functions[] = {
// Data
{ "getPointer", w_Data_getPointer },
{ "getSize", w_Data_getSize },
{ 0, 0 }
};
return luax_register_type(L, "Rasterizer", functions);
}
} // font
+1 -1
View File
@@ -30,7 +30,7 @@ namespace love
namespace font
{
Rasterizer * luax_checkrasterizer(lua_State * L, int idx);
int wrap_Rasterizer_open(lua_State * L);
int luaopen_rasterizer(lua_State * L);
} // font
} // love
+15 -17
View File
@@ -27,20 +27,19 @@ namespace graphics
{
namespace opengl
{
// This macro makes checking for the correct type slightly more compact.
Font * luax_checkfont(lua_State * L, int idx)
{
return luax_checktype<Font>(L, idx, "Font", LOVE_GRAPHICS_FONT_BITS);
return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
}
int _wrap_Font_getHeight(lua_State * L)
int w_Font_getHeight(lua_State * L)
{
Font * t = luax_checkfont(L, 1);
lua_pushnumber(L, t->getHeight());
return 1;
}
int _wrap_Font_getWidth(lua_State * L)
int w_Font_getWidth(lua_State * L)
{
Font * t = luax_checkfont(L, 1);
const char * str = luaL_checkstring(L, 2);
@@ -48,7 +47,7 @@ namespace opengl
return 1;
}
int _wrap_Font_setLineHeight(lua_State * L)
int w_Font_setLineHeight(lua_State * L)
{
Font * t = luax_checkfont(L, 1);
float h = (float)luaL_checknumber(L, 2);
@@ -56,25 +55,24 @@ namespace opengl
return 0;
}
int _wrap_Font_getLineHeight(lua_State * L)
int w_Font_getLineHeight(lua_State * L)
{
Font * t = luax_checkfont(L, 1);
lua_pushnumber(L, t->getLineHeight());
return 1;
}
static const luaL_Reg wrap_Font_functions[] = {
{ "getHeight", _wrap_Font_getHeight },
{ "getWidth", _wrap_Font_getWidth },
{ "setLineHeight", _wrap_Font_setLineHeight },
{ "getLineHeight", _wrap_Font_getLineHeight },
{ 0, 0 }
};
int wrap_Font_open(lua_State * L)
int luaopen_font(lua_State * L)
{
luax_register_type(L, "Font", wrap_Font_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getHeight", w_Font_getHeight },
{ "getWidth", w_Font_getWidth },
{ "setLineHeight", w_Font_setLineHeight },
{ "getLineHeight", w_Font_getLineHeight },
{ 0, 0 }
};
return luax_register_type(L, "Font", functions);
}
} // opengl
+5 -5
View File
@@ -32,11 +32,11 @@ namespace graphics
namespace opengl
{
Font * luax_checkfont(lua_State * L, int idx);
int _wrap_Font_getHeight(lua_State * L);
int _wrap_Font_getWidth(lua_State * L);
int _wrap_Font_setLineHeight(lua_State * L);
int _wrap_Font_getLineHeight(lua_State * L);
int wrap_Font_open(lua_State * L);
int w_Font_getHeight(lua_State * L);
int w_Font_getWidth(lua_State * L);
int w_Font_setLineHeight(lua_State * L);
int w_Font_getLineHeight(lua_State * L);
int luaopen_font(lua_State * L);
} // opengl
} // graphics
+7 -7
View File
@@ -29,24 +29,24 @@ namespace opengl
{
Frame * luax_checkframe(lua_State * L, int idx)
{
return luax_checktype<Frame>(L, idx, "Frame", LOVE_GRAPHICS_FRAME_BITS);
return luax_checktype<Frame>(L, idx, "Frame", GRAPHICS_FRAME_T);
}
int _wrap_Frame_flip(lua_State *L)
int w_Frame_flip(lua_State *L)
{
Frame *frame = luax_checktype<Frame>(L, 1, "Frame", LOVE_GRAPHICS_FRAME_BITS);
Frame *frame = luax_checktype<Frame>(L, 1, "Frame", GRAPHICS_FRAME_T);
frame->flip(luax_toboolean(L, 2), luax_toboolean(L, 3));
return 0;
}
static const luaL_Reg wrap_Frame_functions[] = {
{ "flip", _wrap_Frame_flip },
static const luaL_Reg w_Frame_functions[] = {
{ "flip", w_Frame_flip },
{ 0, 0 }
};
int wrap_Frame_open(lua_State * L)
int w_Frame_open(lua_State * L)
{
luax_register_type(L, "Frame", wrap_Frame_functions);
luax_register_type(L, "Frame", w_Frame_functions);
return 0;
}
+2 -2
View File
@@ -32,8 +32,8 @@ namespace graphics
namespace opengl
{
Frame * luax_checkframe(lua_State * L, int idx);
int _wrap_Frame_flip(lua_State *L);
int wrap_Frame_open(lua_State * L);
int w_Frame_flip(lua_State *L);
int luaopen_frame(lua_State * L);
} // opengl
} // graphics
+4 -4
View File
@@ -29,16 +29,16 @@ namespace opengl
{
Glyph * luax_checkglyph(lua_State * L, int idx)
{
return luax_checktype<Glyph>(L, idx, "Glyph", LOVE_GRAPHICS_GLYPH_BITS);
return luax_checktype<Glyph>(L, idx, "Glyph", GRAPHICS_GLYPH_T);
}
static const luaL_Reg wrap_Glyph_functions[] = {
static const luaL_Reg w_Glyph_functions[] = {
{ 0, 0 }
};
int wrap_Glyph_open(lua_State * L)
int w_Glyph_open(lua_State * L)
{
luax_register_type(L, "Glyph", wrap_Glyph_functions);
luax_register_type(L, "Glyph", w_Glyph_functions);
return 0;
}
+1 -1
View File
@@ -32,7 +32,7 @@ namespace graphics
namespace opengl
{
Glyph * luax_checkglyph(lua_State * L, int idx);
int wrap_Glyph_open(lua_State * L);
int luaopen_glyph(lua_State * L);
} // opengl
} // graphics
+239 -244
View File
@@ -28,7 +28,7 @@ namespace opengl
{
static Graphics * instance = 0;
int _wrap_checkMode(lua_State * L)
int w_checkMode(lua_State * L)
{
int w = luaL_checkint(L, 1);
int h = luaL_checkint(L, 2);
@@ -37,7 +37,7 @@ namespace opengl
return 1;
}
int _wrap_setMode(lua_State * L)
int w_setMode(lua_State * L)
{
int w = luaL_checkint(L, 1);
int h = luaL_checkint(L, 2);
@@ -48,66 +48,66 @@ namespace opengl
return 1;
}
int _wrap_toggleFullscreen(lua_State * L)
int w_toggleFullscreen(lua_State * L)
{
luax_pushboolean(L, instance->toggleFullscreen());
return 1;
}
int _wrap_reset(lua_State * L)
int w_reset(lua_State * L)
{
instance->reset();
return 0;
}
int _wrap_clear(lua_State * L)
int w_clear(lua_State * L)
{
instance->clear();
return 0;
}
int _wrap_present(lua_State * L)
int w_present(lua_State * L)
{
instance->present();
return 0;
}
int _wrap_setCaption(lua_State * L)
int w_setCaption(lua_State * L)
{
const char * str = luaL_checkstring(L, 1);
instance->setCaption(str);
return 0;
}
int _wrap_getCaption(lua_State * L)
int w_getCaption(lua_State * L)
{
return instance->getCaption(L);
}
int _wrap_getWidth(lua_State * L)
int w_getWidth(lua_State * L)
{
lua_pushnumber(L, instance->getWidth());
return 1;
}
int _wrap_getHeight(lua_State * L)
int w_getHeight(lua_State * L)
{
lua_pushnumber(L, instance->getHeight());
return 1;
}
int _wrap_isCreated(lua_State * L)
int w_isCreated(lua_State * L)
{
luax_pushboolean(L, instance->isCreated());
return 1;
}
int _wrap_getModes(lua_State * L)
int w_getModes(lua_State * L)
{
return instance->getModes(L);
}
int _wrap_setScissor(lua_State * L)
int w_setScissor(lua_State * L)
{
if(lua_gettop(L) == 0)
{
@@ -124,22 +124,22 @@ namespace opengl
return 0;
}
int _wrap_getScissor(lua_State * L)
int w_getScissor(lua_State * L)
{
return instance->getScissor(L);
}
int _wrap_newImage(lua_State * L)
int w_newImage(lua_State * L)
{
// Convert to File, if necessary.
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
luax_convobj(L, 1, "filesystem", "newFile");
// Convert to ImageData, if necessary.
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
luax_convobj(L, 1, "image", "newImageData");
love::image::ImageData * data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", LOVE_IMAGE_IMAGE_DATA_BITS);
love::image::ImageData * data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
// Create the image.
Image * image = instance->newImage(data);
@@ -149,26 +149,26 @@ namespace opengl
// Push the type.
luax_newtype(L, "Image", LOVE_GRAPHICS_IMAGE_BITS, (void*)image);
luax_newtype(L, "Image", GRAPHICS_IMAGE_T, (void*)image);
return 1;
}
int _wrap_newGlyph(lua_State * L)
int w_newGlyph(lua_State * L)
{
love::font::GlyphData * data = luax_checktype<love::font::GlyphData>(L, 1, "GlyphData", LOVE_FONT_GLYPH_DATA_BITS);
love::font::GlyphData * data = luax_checktype<love::font::GlyphData>(L, 1, "GlyphData", FONT_GLYPH_DATA_T);
// Create the image.
Glyph * t = new Glyph(data);
t->load();
// Push the type.
luax_newtype(L, "Glyph", LOVE_GRAPHICS_GLYPH_BITS, (void*)t);
luax_newtype(L, "Glyph", GRAPHICS_GLYPH_T, (void*)t);
return 1;
}
int _wrap_newFrame(lua_State * L)
int w_newFrame(lua_State * L)
{
int x = luaL_checkint(L, 1);
int y = luaL_checkint(L, 2);
@@ -182,28 +182,28 @@ namespace opengl
if (frame == 0)
return luaL_error(L, "Could not create frame.");
luax_newtype(L, "Frame", LOVE_GRAPHICS_FRAME_BITS, (void*)frame);
luax_newtype(L, "Frame", GRAPHICS_FRAME_T, (void*)frame);
return 1;
}
int _wrap_newFont(lua_State * L)
int w_newFont(lua_State * L)
{
Data * d = 0;
// Convert to File, if necessary.
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
luax_convobj(L, 1, "filesystem", "newFile");
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
{
// Check the value.
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
d = file->read();
}
else if(luax_istype(L, 1, LOVE_DATA_BITS))
else if(luax_istype(L, 1, DATA_T))
{
d = luax_checktype<Data>(L, 1, "Data", LOVE_DATA_BITS);
d = luax_checktype<Data>(L, 1, "Data", DATA_T);
}
// Second optional parameter can be a number:
@@ -214,23 +214,23 @@ namespace opengl
if(font == 0)
return luaL_error(L, "Could not load the font");
luax_newtype(L, "Font", LOVE_GRAPHICS_FONT_BITS, (void*)font);
luax_newtype(L, "Font", GRAPHICS_FONT_T, (void*)font);
return 1;
}
int _wrap_newImageFont(lua_State * L)
int w_newImageFont(lua_State * L)
{
// Convert to File, if necessary.
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
luax_convobj(L, 1, "filesystem", "newFile");
// Convert to Image, if necessary.
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
luax_convobj(L, 1, "graphics", "newImage");
// Check the value.
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
const char * glyphs = luaL_checkstring(L, 2);
@@ -239,22 +239,22 @@ namespace opengl
if(font == 0)
return luaL_error(L, "Could not load the font");
luax_newtype(L, "Font", LOVE_GRAPHICS_FONT_BITS, (void*)font);
luax_newtype(L, "Font", GRAPHICS_FONT_T, (void*)font);
return 1;
}
int _wrap_newSpriteBatch(lua_State * L)
int w_newSpriteBatch(lua_State * L)
{
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
int size = luaL_optint(L, 2, 1000);
int usage = luaL_optint(L, 3, SpriteBatch::USAGE_DYNAMIC);
SpriteBatch * t = instance->newSpriteBatch(image, size, usage);
luax_newtype(L, "SpriteBatch", LOVE_GRAPHICS_SPRITE_BATCH_BITS, (void*)t);
luax_newtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, (void*)t);
return 1;
}
int _wrap_setColor(lua_State * L)
int w_setColor(lua_State * L)
{
Color c;
c.r = (unsigned char)luaL_checkint(L, 1);
@@ -265,7 +265,7 @@ namespace opengl
return 0;
}
int _wrap_getColor(lua_State * L)
int w_getColor(lua_State * L)
{
Color c = instance->getColor();
lua_pushinteger(L, c.r);
@@ -275,7 +275,7 @@ namespace opengl
return 4;
}
int _wrap_setBackgroundColor(lua_State * L)
int w_setBackgroundColor(lua_State * L)
{
Color c;
c.r = (unsigned char)luaL_checkint(L, 1);
@@ -286,7 +286,7 @@ namespace opengl
return 0;
}
int _wrap_getBackgroundColor(lua_State * L)
int w_getBackgroundColor(lua_State * L)
{
Color c = instance->getBackgroundColor();
lua_pushinteger(L, c.r);
@@ -296,35 +296,35 @@ namespace opengl
return 4;
}
int _wrap_setFont(lua_State * L)
int w_setFont(lua_State * L)
{
// The second parameter is an optional int.
int size = luaL_optint(L, 2, 12);
// If the first parameter is a string, convert it to a file.
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
luax_convobj(L, 1, "filesystem", "newFile");
// If the first parameter is a File, use another setFont function.
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
{
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
instance->setFont(file->read(), size);
return 0;
}
else if(luax_istype(L, 1, LOVE_DATA_BITS))
else if(luax_istype(L, 1, DATA_T))
{
Data * data = luax_checktype<Data>(L, 1, "Data", LOVE_DATA_BITS);
Data * data = luax_checktype<Data>(L, 1, "Data", DATA_T);
instance->setFont(data, size);
return 0;
}
Font * font = luax_checktype<Font>(L, 1, "Font", LOVE_GRAPHICS_FONT_BITS);
Font * font = luax_checktype<Font>(L, 1, "Font", GRAPHICS_FONT_T);
instance->setFont(font);
return 0;
}
int _wrap_getFont(lua_State * L)
int w_getFont(lua_State * L)
{
Font * f = instance->getFont();
@@ -332,51 +332,51 @@ namespace opengl
return 0;
f->retain();
luax_newtype(L, "Font", LOVE_GRAPHICS_FONT_BITS, (void*)f);
luax_newtype(L, "Font", GRAPHICS_FONT_T, (void*)f);
return 1;
}
int _wrap_setBlendMode(lua_State * L)
int w_setBlendMode(lua_State * L)
{
int mode = luaL_checkint(L, 1);
instance->setBlendMode(mode);
return 0;
}
int _wrap_setColorMode(lua_State * L)
int w_setColorMode(lua_State * L)
{
int mode = luaL_checkint(L, 1);
instance->setColorMode(mode);
return 0;
}
int _wrap_getBlendMode(lua_State * L)
int w_getBlendMode(lua_State * L)
{
lua_pushinteger(L, instance->getBlendMode());
return 1;
}
int _wrap_getColorMode(lua_State * L)
int w_getColorMode(lua_State * L)
{
lua_pushinteger(L, instance->getColorMode());
return 1;
}
int _wrap_setLineWidth(lua_State * L)
int w_setLineWidth(lua_State * L)
{
float width = (float)luaL_checknumber(L, 1);
instance->setLineWidth(width);
return 0;
}
int _wrap_setLineStyle(lua_State * L)
int w_setLineStyle(lua_State * L)
{
int style = luaL_checkint(L, 1);
instance->setLineStyle(style);
return 0;
}
int _wrap_setLine(lua_State * L)
int w_setLine(lua_State * L)
{
float width = (float)luaL_checknumber(L, 1);
int style = luaL_optint(L, 2, Graphics::LINE_SMOOTH);
@@ -384,7 +384,7 @@ namespace opengl
return 0;
}
int _wrap_setLineStipple(lua_State * L)
int w_setLineStipple(lua_State * L)
{
if(lua_gettop(L) == 0)
{
@@ -398,38 +398,38 @@ namespace opengl
return 0;
}
int _wrap_getLineWidth(lua_State * L)
int w_getLineWidth(lua_State * L)
{
lua_pushnumber(L, instance->getLineWidth());
return 1;
}
int _wrap_getLineStyle(lua_State * L)
int w_getLineStyle(lua_State * L)
{
lua_pushinteger(L, instance->getLineStyle());
return 1;
}
int _wrap_getLineStipple(lua_State * L)
int w_getLineStipple(lua_State * L)
{
return instance->getLineStipple(L);
}
int _wrap_setPointSize(lua_State * L)
int w_setPointSize(lua_State * L)
{
float size = (float)luaL_checknumber(L, 1);
instance->setPointSize(size);
return 0;
}
int _wrap_setPointStyle(lua_State * L)
int w_setPointStyle(lua_State * L)
{
int style = luaL_checkint(L, 1);
instance->setPointStyle(style);
return 0;
}
int _wrap_setPoint(lua_State * L)
int w_setPoint(lua_State * L)
{
float size = (float)luaL_checknumber(L, 1);
int style = luaL_optint(L, 2, Graphics::POINT_SMOOTH);
@@ -437,19 +437,19 @@ namespace opengl
return 0;
}
int _wrap_getPointSize(lua_State * L)
int w_getPointSize(lua_State * L)
{
lua_pushnumber(L, instance->getPointSize());
return 1;
}
int _wrap_getPointStyle(lua_State * L)
int w_getPointStyle(lua_State * L)
{
lua_pushinteger(L, instance->getPointStyle());
return 1;
}
int _wrap_getMaxPointSize(lua_State * L)
int w_getMaxPointSize(lua_State * L)
{
lua_pushnumber(L, instance->getMaxPointSize());
return 1;
@@ -466,9 +466,9 @@ namespace opengl
* @param ox The offset along the x-axis.
* @param oy The offset along the y-axis.
**/
int _wrap_draw(lua_State * L)
int w_draw(lua_State * L)
{
Drawable * drawable = luax_checktype<Drawable>(L, 1, "Drawable", LOVE_GRAPHICS_DRAWABLE_BITS);
Drawable * drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);
float x = (float)luaL_optnumber(L, 2, 0.0f);
float y = (float)luaL_optnumber(L, 3, 0.0f);
float angle = (float)luaL_optnumber(L, 4, 0.0f);
@@ -495,9 +495,9 @@ namespace opengl
* @param rw The width of the source rectangle.
* @param rw The height of the source rectangle.
**/
int _wrap_draws(lua_State * L)
int w_draws(lua_State * L)
{
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
float x = (float)luaL_optnumber(L, 2, 0.0f);
float y = (float)luaL_optnumber(L, 3, 0.0f);
float angle = (float)luaL_optnumber(L, 4, 0.0f);
@@ -526,9 +526,9 @@ namespace opengl
* @param oy The offset along the y-axis.
* @param f The Frame to dra.
**/
int _wrap_drawf(lua_State * L)
int w_drawf(lua_State * L)
{
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
float angle = (float)luaL_checknumber(L, 4);
@@ -541,9 +541,9 @@ namespace opengl
return 0;
}
int _wrap_drawTest(lua_State * L)
int w_drawTest(lua_State * L)
{
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
float x = (float)luaL_optnumber(L, 2, 0.0f);
float y = (float)luaL_optnumber(L, 3, 0.0f);
float angle = (float)luaL_optnumber(L, 4, 0.0f);
@@ -555,7 +555,7 @@ namespace opengl
return 0;
}
int _wrap_print1(lua_State * L)
int w_print1(lua_State * L)
{
const char * str = luaL_checkstring(L, 1);
float x = (float)luaL_checknumber(L, 2);
@@ -584,7 +584,7 @@ namespace opengl
return 0;
}
int _wrap_printf1(lua_State * L)
int w_printf1(lua_State * L)
{
const char * str = luaL_checkstring(L, 1);
float x = (float)luaL_checknumber(L, 2);
@@ -595,7 +595,7 @@ namespace opengl
return 0;
}
int _wrap_point(lua_State * L)
int w_point(lua_State * L)
{
float x = (float)luaL_checknumber(L, 1);
float y = (float)luaL_checknumber(L, 2);
@@ -603,7 +603,7 @@ namespace opengl
return 0;
}
int _wrap_line(lua_State * L)
int w_line(lua_State * L)
{
float x1 = (float)luaL_checknumber(L, 1);
float y1 = (float)luaL_checknumber(L, 2);
@@ -613,7 +613,7 @@ namespace opengl
return 0;
}
int _wrap_triangle(lua_State * L)
int w_triangle(lua_State * L)
{
int type = luaL_checkint(L, 1);
float x1 = (float)luaL_checknumber(L, 2);
@@ -626,7 +626,7 @@ namespace opengl
return 0;
}
int _wrap_rectangle(lua_State * L)
int w_rectangle(lua_State * L)
{
int type = luaL_checkint(L, 1);
float x = (float)luaL_checknumber(L, 2);
@@ -637,7 +637,7 @@ namespace opengl
return 0;
}
int _wrap_quad(lua_State * L)
int w_quad(lua_State * L)
{
int type = luaL_checkint(L, 1);
float x1 = (float)luaL_checknumber(L, 2);
@@ -652,7 +652,7 @@ namespace opengl
return 0;
}
int _wrap_circle(lua_State * L)
int w_circle(lua_State * L)
{
int type = luaL_checkint(L, 1);
float x = (float)luaL_checknumber(L, 2);
@@ -663,31 +663,31 @@ namespace opengl
return 0;
}
int _wrap_polygon(lua_State * L)
int w_polygon(lua_State * L)
{
return instance->polygon(L);
}
int _wrap_push(lua_State * L)
int w_push(lua_State * L)
{
instance->push();
return 0;
}
int _wrap_pop(lua_State * L)
int w_pop(lua_State * L)
{
instance->pop();
return 0;
}
int _wrap_rotate(lua_State * L)
int w_rotate(lua_State * L)
{
float deg = (float)luaL_checknumber(L, 1);
instance->rotate(deg);
return 0;
}
int _wrap_scale(lua_State * L)
int w_scale(lua_State * L)
{
float sx = (float)luaL_optnumber(L, 1, 1.0f);
float sy = (float)luaL_optnumber(L, 2, sx);
@@ -695,7 +695,7 @@ namespace opengl
return 0;
}
int _wrap_translate(lua_State * L)
int w_translate(lua_State * L)
{
float x = (float)luaL_checknumber(L, 1);
float y = (float)luaL_checknumber(L, 2);
@@ -703,152 +703,153 @@ namespace opengl
return 0;
}
// List of functions to wrap.
static const luaL_Reg wrap_Graphics_functions[] = {
{ "checkMode", _wrap_checkMode },
{ "setMode", _wrap_setMode },
{ "toggleFullscreen", _wrap_toggleFullscreen },
{ "reset", _wrap_reset },
{ "clear", _wrap_clear },
{ "present", _wrap_present },
{ "newImage", _wrap_newImage },
{ "newGlyph", _wrap_newGlyph },
{ "newFrame", _wrap_newFrame },
{ "newFont", _wrap_newFont },
{ "newImageFont", _wrap_newImageFont },
{ "newSpriteBatch", _wrap_newSpriteBatch },
{ "setColor", _wrap_setColor },
{ "getColor", _wrap_getColor },
{ "setBackgroundColor", _wrap_setBackgroundColor },
{ "getBackgroundColor", _wrap_getBackgroundColor },
{ "setFont", _wrap_setFont },
{ "getFont", _wrap_getFont },
{ "setBlendMode", _wrap_setBlendMode },
{ "setColorMode", _wrap_setColorMode },
{ "getBlendMode", _wrap_getBlendMode },
{ "getColorMode", _wrap_getColorMode },
{ "setLineWidth", _wrap_setLineWidth },
{ "setLineStyle", _wrap_setLineStyle },
{ "setLine", _wrap_setLine },
{ "setLineStipple", _wrap_setLineStipple },
{ "getLineWidth", _wrap_getLineWidth },
{ "getLineStyle", _wrap_getLineStyle },
{ "getLineStipple", _wrap_getLineStipple },
{ "setPointSize", _wrap_setPointSize },
{ "setPointStyle", _wrap_setPointStyle },
{ "setPoint", _wrap_setPoint },
{ "getPointSize", _wrap_getPointSize },
{ "getPointStyle", _wrap_getPointStyle },
{ "getMaxPointSize", _wrap_getMaxPointSize },
{ "draw", _wrap_draw },
{ "draws", _wrap_draws },
{ "drawf", _wrap_drawf },
{ "drawTest", _wrap_drawTest },
{ "print1", _wrap_print1 },
{ "printf1", _wrap_printf1 },
{ "setCaption", _wrap_setCaption },
{ "getCaption", _wrap_getCaption },
{ "getWidth", _wrap_getWidth },
{ "getHeight", _wrap_getHeight },
{ "isCreated", _wrap_isCreated },
{ "getModes", _wrap_getModes },
{ "setScissor", _wrap_setScissor },
{ "getScissor", _wrap_getScissor },
{ "point", _wrap_point },
{ "line", _wrap_line },
{ "triangle", _wrap_triangle },
{ "rectangle", _wrap_rectangle },
{ "quad", _wrap_quad },
{ "circle", _wrap_circle },
{ "polygon", _wrap_polygon },
{ "push", _wrap_push },
{ "pop", _wrap_pop },
{ "rotate", _wrap_rotate },
{ "scale", _wrap_scale },
{ "translate", _wrap_translate },
{ 0, 0 }
};
// Types for this module.
const lua_CFunction wrap_Graphics_types[] = {
wrap_Font_open,
wrap_Image_open,
wrap_Glyph_open,
wrap_Frame_open,
wrap_SpriteBatch_open,
0
};
// List of constants.
static const LuaConstant wrap_Graphics_constants[] = {
{ "align_left", Graphics::ALIGN_LEFT },
{ "align_right", Graphics::ALIGN_RIGHT },
{ "align_center", Graphics::ALIGN_CENTER },
{ "blend_alpha", Graphics::BLEND_ALPHA },
{ "blend_additive", Graphics::BLEND_ADDITIVE },
{ "color_replace", Graphics::COLOR_REPLACE },
{ "color_modulate", Graphics::COLOR_MODULATE },
{ "draw_line", Graphics::DRAW_LINE },
{ "draw_fill", Graphics::DRAW_FILL },
{ "line_smooth", Graphics::LINE_SMOOTH },
{ "line_rough", Graphics::LINE_ROUGH },
{ "point_smooth", Graphics::POINT_SMOOTH },
{ "point_rough", Graphics::POINT_ROUGH },
{ "filter_linear", Image::FILTER_LINEAR },
{ "filter_nearest", Image::FILTER_NEAREST },
{ "wrap_clamp", Image::WRAP_CLAMP },
{ "wrap_repeat", Image::WRAP_REPEAT },
/**
// Vertex buffer geometry types.
{ "type_points", TYPE_POINTS },
{ "type_lines", TYPE_LINES },
{ "type_line_strip", TYPE_LINE_STRIP },
{ "type_triangles", TYPE_TRIANGLES },
{ "type_triangle_strip", TYPE_TRIANGLE_STRIP },
{ "type_triangle_fan", TYPE_TRIANGLE_FAN },
{ "type_num", TYPE_NUM },
// Vertex buffer usage hints.
{ "usage_array", USAGE_ARRAY },
{ "usage_dynamic", USAGE_DYNAMIC },
{ "usage_static", USAGE_STATIC },
{ "usage_stream", USAGE_STREAM },
{ "usage_num", USAGE_NUM },
**/
{ 0, 0 }
};
int wrap_Graphics_open(lua_State * L)
int luaopen_love_graphics(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "checkMode", w_checkMode },
{ "setMode", w_setMode },
{ "toggleFullscreen", w_toggleFullscreen },
{ "reset", w_reset },
{ "clear", w_clear },
{ "present", w_present },
{ "newImage", w_newImage },
{ "newGlyph", w_newGlyph },
{ "newFrame", w_newFrame },
{ "newFont", w_newFont },
{ "newImageFont", w_newImageFont },
{ "newSpriteBatch", w_newSpriteBatch },
{ "setColor", w_setColor },
{ "getColor", w_getColor },
{ "setBackgroundColor", w_setBackgroundColor },
{ "getBackgroundColor", w_getBackgroundColor },
{ "setFont", w_setFont },
{ "getFont", w_getFont },
{ "setBlendMode", w_setBlendMode },
{ "setColorMode", w_setColorMode },
{ "getBlendMode", w_getBlendMode },
{ "getColorMode", w_getColorMode },
{ "setLineWidth", w_setLineWidth },
{ "setLineStyle", w_setLineStyle },
{ "setLine", w_setLine },
{ "setLineStipple", w_setLineStipple },
{ "getLineWidth", w_getLineWidth },
{ "getLineStyle", w_getLineStyle },
{ "getLineStipple", w_getLineStipple },
{ "setPointSize", w_setPointSize },
{ "setPointStyle", w_setPointStyle },
{ "setPoint", w_setPoint },
{ "getPointSize", w_getPointSize },
{ "getPointStyle", w_getPointStyle },
{ "getMaxPointSize", w_getMaxPointSize },
{ "draw", w_draw },
{ "draws", w_draws },
{ "drawf", w_drawf },
{ "drawTest", w_drawTest },
{ "print1", w_print1 },
{ "printf1", w_printf1 },
{ "setCaption", w_setCaption },
{ "getCaption", w_getCaption },
{ "getWidth", w_getWidth },
{ "getHeight", w_getHeight },
{ "isCreated", w_isCreated },
{ "getModes", w_getModes },
{ "setScissor", w_setScissor },
{ "getScissor", w_getScissor },
{ "point", w_point },
{ "line", w_line },
{ "triangle", w_triangle },
{ "rectangle", w_rectangle },
{ "quad", w_quad },
{ "circle", w_circle },
{ "polygon", w_polygon },
{ "push", w_push },
{ "pop", w_pop },
{ "rotate", w_rotate },
{ "scale", w_scale },
{ "translate", w_translate },
{ 0, 0 }
};
// Types for this module.
static const lua_CFunction types[] = {
luaopen_font,
luaopen_image,
luaopen_glyph,
luaopen_frame,
luaopen_spritebatch,
0
};
// List of constants.
static const LuaConstant constants[] = {
{ "align_left", Graphics::ALIGN_LEFT },
{ "align_right", Graphics::ALIGN_RIGHT },
{ "align_center", Graphics::ALIGN_CENTER },
{ "blend_alpha", Graphics::BLEND_ALPHA },
{ "blend_additive", Graphics::BLEND_ADDITIVE },
{ "color_replace", Graphics::COLOR_REPLACE },
{ "color_modulate", Graphics::COLOR_MODULATE },
{ "draw_line", Graphics::DRAW_LINE },
{ "draw_fill", Graphics::DRAW_FILL },
{ "line_smooth", Graphics::LINE_SMOOTH },
{ "line_rough", Graphics::LINE_ROUGH },
{ "point_smooth", Graphics::POINT_SMOOTH },
{ "point_rough", Graphics::POINT_ROUGH },
{ "filter_linear", Image::FILTER_LINEAR },
{ "filter_nearest", Image::FILTER_NEAREST },
{ "wrap_clamp", Image::WRAP_CLAMP },
{ "wrap_repeat", Image::WRAP_REPEAT },
/**
// Vertex buffer geometry types.
{ "type_points", TYPE_POINTS },
{ "type_lines", TYPE_LINES },
{ "type_line_strip", TYPE_LINE_STRIP },
{ "type_triangles", TYPE_TRIANGLES },
{ "type_triangle_strip", TYPE_TRIANGLE_STRIP },
{ "type_triangle_fan", TYPE_TRIANGLE_FAN },
{ "type_num", TYPE_NUM },
// Vertex buffer usage hints.
{ "usage_array", USAGE_ARRAY },
{ "usage_dynamic", USAGE_DYNAMIC },
{ "usage_static", USAGE_STATIC },
{ "usage_stream", USAGE_STREAM },
{ "usage_num", USAGE_NUM },
**/
{ 0, 0 }
};
if(instance == 0)
{
try
@@ -861,11 +862,10 @@ namespace opengl
}
}
luax_register_gc(L, "love.graphics", instance);
luax_register_module(L, wrap_Graphics_functions, wrap_Graphics_types, wrap_Graphics_constants, "graphics");
luax_register_gc(L, instance);
luax_register_module(L, functions, types, constants, "graphics");
# include <scripts/graphics.lua.h>
//luaL_dofile(L, "../../src/scripts/graphics.lua");
return 0;
}
@@ -873,8 +873,3 @@ namespace opengl
} // opengl
} // graphics
} // love
int luaopen_love_graphics(lua_State * L)
{
return love::graphics::opengl::wrap_Graphics_open(L);
}
+59 -61
View File
@@ -35,70 +35,68 @@ namespace graphics
{
namespace opengl
{
int _wrap_checkMode(lua_State * L);
int _wrap_setMode(lua_State * L);
int _wrap_toggleFullscreen(lua_State * L);
int _wrap_reset(lua_State * L);
int _wrap_clear(lua_State * L);
int _wrap_present(lua_State * L);
int _wrap_setCaption(lua_State * L);
int _wrap_getCaption(lua_State * L);
int _wrap_getWidth(lua_State * L);
int _wrap_getHeight(lua_State * L);
int _wrap_isCreated(lua_State * L);
int _wrap_setScissor(lua_State * L);
int _wrap_getScissor(lua_State * L);
int _wrap_newImage(lua_State * L);
int _wrap_newGlyph(lua_State * L);
int _wrap_newFrame(lua_State * L);
int _wrap_newFont(lua_State * L);
int _wrap_newImageFont(lua_State * L);
int _wrap_newSpriteBatch(lua_State * L);
int _wrap_setColor(lua_State * L);
int _wrap_getColor(lua_State * L);
int _wrap_setBackgroundColor(lua_State * L);
int _wrap_getBackgroundColor(lua_State * L);
int _wrap_setFont(lua_State * L);
int _wrap_getFont(lua_State * L);
int _wrap_setBlendMode(lua_State * L);
int _wrap_setColorMode(lua_State * L);
int _wrap_getBlendMode(lua_State * L);
int _wrap_getColorMode(lua_State * L);
int _wrap_setLineWidth(lua_State * L);
int _wrap_setLineStyle(lua_State * L);
int _wrap_setLine(lua_State * L);
int _wrap_setLineStipple(lua_State * L);
int _wrap_getLineWidth(lua_State * L);
int _wrap_getLineStyle(lua_State * L);
int _wrap_getLineStipple(lua_State * L);
int _wrap_setPointSize(lua_State * L);
int _wrap_setPointStyle(lua_State * L);
int _wrap_setPoint(lua_State * L);
int _wrap_getPointSize(lua_State * L);
int _wrap_getPointStyle(lua_State * L);
int _wrap_getMaxPointSize(lua_State * L);
int _wrap_draw(lua_State * L);
int _wrap_draws(lua_State * L);
int _wrap_drawTest(lua_State * L);
int _wrap_print1(lua_State * L);
int _wrap_printf1(lua_State * L);
int _wrap_point(lua_State * L);
int _wrap_line(lua_State * L);
int _wrap_triangle(lua_State * L);
int _wrap_rectangle(lua_State * L);
int _wrap_quad(lua_State * L);
int _wrap_circle(lua_State * L);
int _wrap_push(lua_State * L);
int _wrap_pop(lua_State * L);
int _wrap_rotate(lua_State * L);
int _wrap_scale(lua_State * L);
int _wrap_translate(lua_State * L);
int wrap_Graphics_open(lua_State * L);
int w_checkMode(lua_State * L);
int w_setMode(lua_State * L);
int w_toggleFullscreen(lua_State * L);
int w_reset(lua_State * L);
int w_clear(lua_State * L);
int w_present(lua_State * L);
int w_setCaption(lua_State * L);
int w_getCaption(lua_State * L);
int w_getWidth(lua_State * L);
int w_getHeight(lua_State * L);
int w_isCreated(lua_State * L);
int w_setScissor(lua_State * L);
int w_getScissor(lua_State * L);
int w_newImage(lua_State * L);
int w_newGlyph(lua_State * L);
int w_newFrame(lua_State * L);
int w_newFont(lua_State * L);
int w_newImageFont(lua_State * L);
int w_newSpriteBatch(lua_State * L);
int w_setColor(lua_State * L);
int w_getColor(lua_State * L);
int w_setBackgroundColor(lua_State * L);
int w_getBackgroundColor(lua_State * L);
int w_setFont(lua_State * L);
int w_getFont(lua_State * L);
int w_setBlendMode(lua_State * L);
int w_setColorMode(lua_State * L);
int w_getBlendMode(lua_State * L);
int w_getColorMode(lua_State * L);
int w_setLineWidth(lua_State * L);
int w_setLineStyle(lua_State * L);
int w_setLine(lua_State * L);
int w_setLineStipple(lua_State * L);
int w_getLineWidth(lua_State * L);
int w_getLineStyle(lua_State * L);
int w_getLineStipple(lua_State * L);
int w_setPointSize(lua_State * L);
int w_setPointStyle(lua_State * L);
int w_setPoint(lua_State * L);
int w_getPointSize(lua_State * L);
int w_getPointStyle(lua_State * L);
int w_getMaxPointSize(lua_State * L);
int w_draw(lua_State * L);
int w_draws(lua_State * L);
int w_drawTest(lua_State * L);
int w_print1(lua_State * L);
int w_printf1(lua_State * L);
int w_point(lua_State * L);
int w_line(lua_State * L);
int w_triangle(lua_State * L);
int w_rectangle(lua_State * L);
int w_quad(lua_State * L);
int w_circle(lua_State * L);
int w_push(lua_State * L);
int w_pop(lua_State * L);
int w_rotate(lua_State * L);
int w_scale(lua_State * L);
int w_translate(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_graphics(lua_State * L);
} // opengl
} // graphics
} // love
#endif // LOVE_GRAPHICS_OPENGL_WRAP_GRAPHICS_H
extern "C" LOVE_EXPORT int luaopen_love_graphics(lua_State * L);
+16 -16
View File
@@ -29,24 +29,24 @@ namespace opengl
{
Image * luax_checkimage(lua_State * L, int idx)
{
return luax_checktype<Image>(L, idx, "Image", LOVE_GRAPHICS_IMAGE_BITS);
return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
}
int _wrap_Image_getWidth(lua_State * L)
int w_Image_getWidth(lua_State * L)
{
Image * t = luax_checkimage(L, 1);
lua_pushnumber(L, t->getWidth());
return 1;
}
int _wrap_Image_getHeight(lua_State * L)
int w_Image_getHeight(lua_State * L)
{
Image * t = luax_checkimage(L, 1);
lua_pushnumber(L, t->getHeight());
return 1;
}
int _wrap_Image_setFilter(lua_State * L)
int w_Image_setFilter(lua_State * L)
{
Image * t = luax_checkimage(L, 1);
Image::Filter f;
@@ -56,7 +56,7 @@ namespace opengl
return 0;
}
int _wrap_Image_getFilter(lua_State * L)
int w_Image_getFilter(lua_State * L)
{
Image * t = luax_checkimage(L, 1);
Image::Filter f = t->getFilter();
@@ -65,7 +65,7 @@ namespace opengl
return 2;
}
int _wrap_Image_setWrap(lua_State * L)
int w_Image_setWrap(lua_State * L)
{
Image * t = luax_checkimage(L, 1);
Image::Wrap w;
@@ -75,7 +75,7 @@ namespace opengl
return 0;
}
int _wrap_Image_getWrap(lua_State * L)
int w_Image_getWrap(lua_State * L)
{
Image * t = luax_checkimage(L, 1);
Image::Wrap w = t->getWrap();
@@ -84,19 +84,19 @@ namespace opengl
return 2;
}
static const luaL_Reg wrap_Image_functions[] = {
{ "getWidth", _wrap_Image_getWidth },
{ "getHeight", _wrap_Image_getHeight },
{ "setFilter", _wrap_Image_setFilter },
{ "getFilter", _wrap_Image_getFilter },
{ "setWrap", _wrap_Image_setWrap },
{ "getWrap", _wrap_Image_getWrap },
static const luaL_Reg w_Image_functions[] = {
{ "getWidth", w_Image_getWidth },
{ "getHeight", w_Image_getHeight },
{ "setFilter", w_Image_setFilter },
{ "getFilter", w_Image_getFilter },
{ "setWrap", w_Image_setWrap },
{ "getWrap", w_Image_getWrap },
{ 0, 0 }
};
int wrap_Image_open(lua_State * L)
int w_Image_open(lua_State * L)
{
luax_register_type(L, "Image", wrap_Image_functions);
luax_register_type(L, "Image", w_Image_functions);
return 0;
}
+4 -4
View File
@@ -32,10 +32,10 @@ namespace graphics
namespace opengl
{
Image * luax_checkimage(lua_State * L, int idx);
int _wrap_Image_getWidth(lua_State * L);
int _wrap_Image_getHeight(lua_State * L);
int _wrap_Image_setFIlter(lua_State * L);
int wrap_Image_open(lua_State * L);
int w_Image_getWidth(lua_State * L);
int w_Image_getHeight(lua_State * L);
int w_Image_setFIlter(lua_State * L);
int luaopen_image(lua_State * L);
} // opengl
} // graphics
@@ -28,10 +28,10 @@ namespace opengl
{
SpriteBatch * luax_checkspritebatch(lua_State * L, int idx)
{
return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", LOVE_GRAPHICS_SPRITE_BATCH_BITS);
return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T);
}
int _wrap_SpriteBatch_add(lua_State * L)
int w_SpriteBatch_add(lua_State * L)
{
SpriteBatch * t = luax_checkspritebatch(L, 1);
float x = (float)luaL_optnumber(L, 2, 0.0f);
@@ -45,39 +45,38 @@ namespace opengl
return 0;
}
int _wrap_SpriteBatch_clear(lua_State * L)
int w_SpriteBatch_clear(lua_State * L)
{
SpriteBatch * t = luax_checkspritebatch(L, 1);
t->clear();
return 0;
}
int _wrap_SpriteBatch_lock(lua_State * L)
int w_SpriteBatch_lock(lua_State * L)
{
SpriteBatch * t = luax_checkspritebatch(L, 1);
lua_pushlightuserdata(L, t->lock());
return 1;
}
int _wrap_SpriteBatch_unlock(lua_State * L)
int w_SpriteBatch_unlock(lua_State * L)
{
SpriteBatch * t = luax_checkspritebatch(L, 1);
t->unlock();
return 0;
}
static const luaL_Reg wrap_SpriteBatch_functions[] = {
{ "add", _wrap_SpriteBatch_add },
{ "clear", _wrap_SpriteBatch_clear },
{ "lock", _wrap_SpriteBatch_lock },
{ "unlock", _wrap_SpriteBatch_unlock },
{ 0, 0 }
};
int wrap_SpriteBatch_open(lua_State * L)
int w_SpriteBatch_open(lua_State * L)
{
luax_register_type(L, "SpriteBatch", wrap_SpriteBatch_functions);
return 0;
static const luaL_Reg functions[] = {
{ "add", w_SpriteBatch_add },
{ "clear", w_SpriteBatch_clear },
{ "lock", w_SpriteBatch_lock },
{ "unlock", w_SpriteBatch_unlock },
{ 0, 0 }
};
return luax_register_type(L, "SpriteBatch", functions);
}
} // opengl
@@ -31,11 +31,11 @@ namespace graphics
namespace opengl
{
SpriteBatch * luax_checkspritebatch(lua_State * L, int idx);
int _wrap_SpriteBatch_add(lua_State * L);
int _wrap_SpriteBatch_clear(lua_State * L);
int _wrap_SpriteBatch_lock(lua_State * L);
int _wrap_SpriteBatch_unlock(lua_State * L);
int wrap_SpriteBatch_open(lua_State * L);
int w_SpriteBatch_add(lua_State * L);
int w_SpriteBatch_clear(lua_State * L);
int w_SpriteBatch_lock(lua_State * L);
int w_SpriteBatch_unlock(lua_State * L);
int luaopen_spritebatch(lua_State * L);
} // opengl
} // graphics
+18 -24
View File
@@ -28,7 +28,7 @@ namespace image
{
static Image * instance = 0;
int _wrap_newImageData(lua_State * L)
int w_newImageData(lua_State * L)
{
// Case 1: Integers.
@@ -37,34 +37,33 @@ namespace image
int w = luaL_checkint(L, 1);
int h = luaL_checkint(L, 2);
ImageData * t = instance->newImageData(w, h);
luax_newtype(L, "ImageData", LOVE_IMAGE_IMAGE_DATA_BITS, (void*)t);
luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void*)t);
return 1;
}
// Convert to File, if necessary.
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
luax_convobj(L, 1, "filesystem", "newFile");
// Case 2: String/File.
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
ImageData * t = instance->newImageData(file);
luax_newtype(L, "ImageData", LOVE_IMAGE_IMAGE_DATA_BITS, (void*)t);
luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void*)t);
return 1;
}
// List of functions to wrap.
const luaL_Reg wrap_Image_functions[] = {
{ "newImageData", _wrap_newImageData },
{ 0, 0 }
};
static const lua_CFunction wrap_Image_types[] = {
wrap_ImageData_open,
0
};
int wrap_Image_open(lua_State * L)
int w_Image_open(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "newImageData", w_newImageData },
{ 0, 0 }
};
static const lua_CFunction types[] = {
luaopen_imagedata,
0
};
if(instance == 0)
{
@@ -78,15 +77,10 @@ namespace image
}
}
luax_register_gc(L, "love.image", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Image_functions, wrap_Image_types, 0, "image");
return luax_register_module(L, functions, types, 0, "image");
}
} // image
} // love
int luaopen_love_image(lua_State * L)
{
return love::image::wrap_Image_open(L);
}
+3 -5
View File
@@ -29,13 +29,11 @@ namespace love
{
namespace image
{
int _wrap_getFormats(lua_State * L);
int _wrap_newImageData(lua_State * L);
int wrap_Image_open(lua_State * L);
int w_getFormats(lua_State * L);
int w_newImageData(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_image(lua_State * L);
} // image
} // love
#endif // LOVE_IMAGE_WRAP_IMAGE_H
extern "C" LOVE_EXPORT int luaopen_love_image(lua_State * L);
+26 -27
View File
@@ -28,24 +28,24 @@ namespace image
{
ImageData * luax_checkimagedata(lua_State * L, int idx)
{
return luax_checktype<ImageData>(L, idx, "ImageData", LOVE_IMAGE_IMAGE_DATA_BITS);
return luax_checktype<ImageData>(L, idx, "ImageData", IMAGE_IMAGE_DATA_T);
}
int _wrap_ImageData_getWidth(lua_State * L)
int w_ImageData_getWidth(lua_State * L)
{
ImageData * t = luax_checkimagedata(L, 1);
lua_pushinteger(L, t->getWidth());
return 1;
}
int _wrap_ImageData_getHeight(lua_State * L)
int w_ImageData_getHeight(lua_State * L)
{
ImageData * t = luax_checkimagedata(L, 1);
lua_pushinteger(L, t->getHeight());
return 1;
}
int _wrap_ImageData_getPixel(lua_State * L)
int w_ImageData_getPixel(lua_State * L)
{
ImageData * t = luax_checkimagedata(L, 1);
int x = luaL_checkint(L, 2);
@@ -58,7 +58,7 @@ namespace image
return 4;
}
int _wrap_ImageData_setPixel(lua_State * L)
int w_ImageData_setPixel(lua_State * L)
{
ImageData * t = luax_checkimagedata(L, 1);
int x = luaL_checkint(L, 2);
@@ -72,7 +72,7 @@ namespace image
return 0;
}
int _wrap_ImageData_mapPixel(lua_State * L)
int w_ImageData_mapPixel(lua_State * L)
{
ImageData * t = luax_checkimagedata(L, 1);
@@ -106,14 +106,14 @@ namespace image
return 0;
}
int _wrap_ImageData_getString(lua_State * L)
int w_ImageData_getString(lua_State * L)
{
ImageData * t = luax_checkimagedata(L, 1);
lua_pushlstring(L, (const char *)t->getData(), t->getSize());
return 1;
}
int _wrap_ImageData_paste(lua_State * L)
int w_ImageData_paste(lua_State * L)
{
ImageData * t = luax_checkimagedata(L, 1);
ImageData * src = luax_checkimagedata(L, 2);
@@ -127,26 +127,25 @@ namespace image
return 0;
}
static const luaL_Reg wrap_ImageData_functions[] = {
// Data
{ "getPointer", _wrap_Data_getPointer },
{ "getSize", _wrap_Data_getSize },
{ "getWidth", _wrap_ImageData_getWidth },
{ "getHeight", _wrap_ImageData_getHeight },
{ "getPixel", _wrap_ImageData_getPixel },
{ "setPixel", _wrap_ImageData_setPixel },
{ "mapPixel", _wrap_ImageData_mapPixel },
{ "getString", _wrap_ImageData_getString },
{ "paste", _wrap_ImageData_paste },
{ 0, 0 }
};
int wrap_ImageData_open(lua_State * L)
int luaopen_imagedata(lua_State * L)
{
luax_register_type(L, "ImageData", wrap_ImageData_functions);
return 0;
static const luaL_Reg functions[] = {
// Data
{ "getPointer", w_Data_getPointer },
{ "getSize", w_Data_getSize },
{ "getWidth", w_ImageData_getWidth },
{ "getHeight", w_ImageData_getHeight },
{ "getPixel", w_ImageData_getPixel },
{ "setPixel", w_ImageData_setPixel },
{ "mapPixel", w_ImageData_mapPixel },
{ "getString", w_ImageData_getString },
{ "paste", w_ImageData_paste },
{ 0, 0 }
};
return luax_register_type(L, "ImageData", functions);
}
} // image
+8 -8
View File
@@ -30,14 +30,14 @@ namespace love
namespace image
{
ImageData * luax_checkimagedata(lua_State * L, int idx);
int _wrap_ImageData_getWidth(lua_State * L);
int _wrap_ImageData_getHeight(lua_State * L);
int _wrap_ImageData_getPixel(lua_State * L);
int _wrap_ImageData_setPixel(lua_State * L);
int _wrap_ImageData_mapPixel(lua_State * L);
int _wrap_ImageData_getString(lua_State * L);
int _wrap_ImageData_paste(lua_State * L);
int wrap_ImageData_open(lua_State * L);
int w_ImageData_getWidth(lua_State * L);
int w_ImageData_getHeight(lua_State * L);
int w_ImageData_getPixel(lua_State * L);
int w_ImageData_setPixel(lua_State * L);
int w_ImageData_mapPixel(lua_State * L);
int w_ImageData_getString(lua_State * L);
int w_ImageData_paste(lua_State * L);
int luaopen_imagedata(lua_State * L);
} // image
} // love
+54 -60
View File
@@ -28,62 +28,62 @@ namespace sdl
{
static Joystick * instance = 0;
int _wrap_getNumJoysticks(lua_State * L)
int w_getNumJoysticks(lua_State * L)
{
lua_pushinteger(L, instance->getNumJoysticks());
return 1;
}
int _wrap_getName(lua_State * L)
int w_getName(lua_State * L)
{
int index = luaL_checkint(L, 1);
lua_pushstring(L, instance->getName(index));
return 1;
}
int _wrap_open(lua_State * L)
int w_open(lua_State * L)
{
int index = luaL_checkint(L, 1);
luax_pushboolean(L, instance->open(index));
return 1;
}
int _wrap_isOpen(lua_State * L)
int w_isOpen(lua_State * L)
{
int index = luaL_checkint(L, 1);
luax_pushboolean(L, instance->isOpen(index));
return 1;
}
int _wrap_getNumAxes(lua_State * L)
int w_getNumAxes(lua_State * L)
{
int index = luaL_checkint(L, 1);
lua_pushinteger(L, instance->getNumAxes(index));
return 1;
}
int _wrap_getNumBalls(lua_State * L)
int w_getNumBalls(lua_State * L)
{
int index = luaL_checkint(L, 1);
lua_pushinteger(L, instance->getNumBalls(index));
return 1;
}
int _wrap_getNumButtons(lua_State * L)
int w_getNumButtons(lua_State * L)
{
int index = luaL_checkint(L, 1);
lua_pushinteger(L, instance->getNumButtons(index));
return 1;
}
int _wrap_getNumHats(lua_State * L)
int w_getNumHats(lua_State * L)
{
int index = luaL_checkint(L, 1);
lua_pushinteger(L, instance->getNumHats(index));
return 1;
}
int _wrap_getAxis(lua_State * L)
int w_getAxis(lua_State * L)
{
int index = luaL_checkint(L, 1);
int axis = luaL_checkint(L, 2);
@@ -91,17 +91,17 @@ namespace sdl
return 1;
}
int _wrap_getAxes(lua_State * L)
int w_getAxes(lua_State * L)
{
return instance->getAxes(L);
}
int _wrap_getBall(lua_State * L)
int w_getBall(lua_State * L)
{
return instance->getBall(L);
}
int _wrap_isDown(lua_State * L)
int w_isDown(lua_State * L)
{
int index = luaL_checkint(L, 1);
int button = luaL_checkint(L, 2);
@@ -109,7 +109,7 @@ namespace sdl
return 1;
}
int _wrap_getHat(lua_State * L)
int w_getHat(lua_State * L)
{
int index = luaL_checkint(L, 1);
int hat = luaL_checkint(L, 2);
@@ -117,53 +117,52 @@ namespace sdl
return 1;
}
int _wrap_close(lua_State * L)
int w_close(lua_State * L)
{
int index = luaL_checkint(L, 1);
instance->close(index);
return 0;
}
// List of functions to wrap.
static const luaL_Reg wrap_Joystick_functions[] = {
{ "getNumJoysticks", _wrap_getNumJoysticks },
{ "getName", _wrap_getName },
{ "open", _wrap_open },
{ "isOpen", _wrap_isOpen },
{ "getNumAxes", _wrap_getNumAxes },
{ "getNumBalls", _wrap_getNumBalls },
{ "getNumButtons", _wrap_getNumButtons },
{ "getNumHats", _wrap_getNumHats },
{ "getAxis", _wrap_getAxis },
{ "getAxes", _wrap_getAxes },
{ "getBall", _wrap_getBall },
{ "isDown", _wrap_isDown },
{ "getHat", _wrap_getHat },
{ "close", _wrap_close },
{ 0, 0 }
};
// List of constants.
static const LuaConstant wrap_Joystick_constants[] = {
{ "joystick_axis_horizontal", Joystick::JOYSTICK_AXIS_HORIZONTAL },
{ "joystick_axis_vertical", Joystick::JOYSTICK_AXIS_VERITCAL },
{ "joystick_hat_centered", Joystick::JOYSTICK_HAT_CENTERED },
{ "joystick_hat_up", Joystick::JOYSTICK_HAT_UP },
{ "joystick_hat_right", Joystick::JOYSTICK_HAT_RIGHT },
{ "joystick_hat_down", Joystick::JOYSTICK_HAT_DOWN },
{ "joystick_hat_left", Joystick::JOYSTICK_HAT_LEFT },
{ "joystick_hat_rightup", Joystick::JOYSTICK_HAT_RIGHTUP },
{ "joystick_hat_rightdown", Joystick::JOYSTICK_HAT_RIGHTDOWN },
{ "joystick_hat_leftup", Joystick::JOYSTICK_HAT_LEFTUP },
{ "joystick_hat_leftdown", Joystick::JOYSTICK_HAT_LEFTDOWN },
{ 0, 0 }
};
int wrap_Joystick_open(lua_State * L)
int luaopen_joystick(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "getNumJoysticks", w_getNumJoysticks },
{ "getName", w_getName },
{ "open", w_open },
{ "isOpen", w_isOpen },
{ "getNumAxes", w_getNumAxes },
{ "getNumBalls", w_getNumBalls },
{ "getNumButtons", w_getNumButtons },
{ "getNumHats", w_getNumHats },
{ "getAxis", w_getAxis },
{ "getAxes", w_getAxes },
{ "getBall", w_getBall },
{ "isDown", w_isDown },
{ "getHat", w_getHat },
{ "close", w_close },
{ 0, 0 }
};
// List of constants.
static const LuaConstant constants[] = {
{ "joystick_axis_horizontal", Joystick::JOYSTICK_AXIS_HORIZONTAL },
{ "joystick_axis_vertical", Joystick::JOYSTICK_AXIS_VERITCAL },
{ "joystick_hat_centered", Joystick::JOYSTICK_HAT_CENTERED },
{ "joystick_hat_up", Joystick::JOYSTICK_HAT_UP },
{ "joystick_hat_right", Joystick::JOYSTICK_HAT_RIGHT },
{ "joystick_hat_down", Joystick::JOYSTICK_HAT_DOWN },
{ "joystick_hat_left", Joystick::JOYSTICK_HAT_LEFT },
{ "joystick_hat_rightup", Joystick::JOYSTICK_HAT_RIGHTUP },
{ "joystick_hat_rightdown", Joystick::JOYSTICK_HAT_RIGHTDOWN },
{ "joystick_hat_leftup", Joystick::JOYSTICK_HAT_LEFTUP },
{ "joystick_hat_leftdown", Joystick::JOYSTICK_HAT_LEFTDOWN },
{ 0, 0 }
};
if(instance == 0)
{
@@ -177,16 +176,11 @@ namespace sdl
}
}
luax_register_gc(L, "love.joystick", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Joystick_functions, 0, wrap_Joystick_constants, "joystick");
return luax_register_module(L, functions, 0, constants, "joystick");
}
} // sdl
} // joystick
} // love
int luaopen_love_joystick(lua_State * L)
{
return love::joystick::sdl::wrap_Joystick_open(L);
}
+15 -17
View File
@@ -31,26 +31,24 @@ namespace joystick
{
namespace sdl
{
int _wrap_getNumJoysticks(lua_State * L);
int _wrap_getName(lua_State * L);
int _wrap_open(lua_State * L);
int _wrap_isOpen(lua_State * L);
int _wrap_getNumAxes(lua_State * L);
int _wrap_getNumBalls(lua_State * L);
int _wrap_getNumButtons(lua_State * L);
int _wrap_getNumHats(lua_State * L);
int _wrap_getAxis(lua_State * L);
int _wrap_getAxes(lua_State * L);
int _wrap_getBall(lua_State * L);
int _wrap_isDown(lua_State * L);
int _wrap_getHat(lua_State * L);
int _wrap_close(lua_State * L);
int wrap_Joystick_open(lua_State * L);
int w_getNumJoysticks(lua_State * L);
int w_getName(lua_State * L);
int w_open(lua_State * L);
int w_isOpen(lua_State * L);
int w_getNumAxes(lua_State * L);
int w_getNumBalls(lua_State * L);
int w_getNumButtons(lua_State * L);
int w_getNumHats(lua_State * L);
int w_getAxis(lua_State * L);
int w_getAxes(lua_State * L);
int w_getBall(lua_State * L);
int w_isDown(lua_State * L);
int w_getHat(lua_State * L);
int w_close(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_joystick(lua_State * L);
} // sdl
} // joystick
} // love
extern "C" LOVE_EXPORT int luaopen_love_joystick(lua_State * L);
#endif // LOVE_JOYSTICK_SDL_WRAP_JOYSTICK_H
+168 -174
View File
@@ -28,14 +28,14 @@ namespace sdl
{
static Keyboard * instance = 0;
int _wrap_isDown(lua_State * L)
int w_isDown(lua_State * L)
{
int b = luaL_checkint(L, 1);
luax_pushboolean(L, instance->isDown(b));
return 1;
}
int _wrap_setKeyRepeat(lua_State * L)
int w_setKeyRepeat(lua_State * L)
{
if(lua_gettop(L) == 0)
{
@@ -49,178 +49,177 @@ namespace sdl
return 0;
}
int _wrap_getKeyRepeat(lua_State * L)
int w_getKeyRepeat(lua_State * L)
{
lua_pushnumber(L, instance->getKeyRepeatDelay());
lua_pushnumber(L, instance->getKeyRepeatInterval());
return 2;
}
// List of functions to wrap.
static const luaL_Reg wrap_Keyboard_functions[] = {
{ "isDown", _wrap_isDown },
{ "setKeyRepeat", _wrap_setKeyRepeat },
{ "getKeyRepeat", _wrap_getKeyRepeat },
{ 0, 0 }
};
// List of constants.
static const LuaConstant wrap_Keyboard_constants[] = {
{ "key_unknown", 0 },
{ "key_first", 0 },
{ "key_backspace", 8 },
{ "key_tab", 9 },
{ "key_clear", 12 },
{ "key_return", 13 },
{ "key_pause", 19 },
{ "key_escape", 27 },
{ "key_space", 32 },
{ "key_exclaim", 33 },
{ "key_quotedbl", 34 },
{ "key_hash", 35 },
{ "key_dollar", 36 },
{ "key_ampersand", 38 },
{ "key_quote", 39 },
{ "key_leftparen", 40 },
{ "key_rightparen", 41 },
{ "key_asterisk", 42 },
{ "key_plus", 43 },
{ "key_comma", 44 },
{ "key_minus", 45 },
{ "key_period", 46 },
{ "key_slash", 47 },
{ "key_0", 48 },
{ "key_1", 49 },
{ "key_2", 50 },
{ "key_3", 51 },
{ "key_4", 52 },
{ "key_5", 53 },
{ "key_6", 54 },
{ "key_7", 55 },
{ "key_8", 56 },
{ "key_9", 57 },
{ "key_colon", 58 },
{ "key_semicolon", 59 },
{ "key_less", 60 },
{ "key_equals", 61 },
{ "key_greater", 62 },
{ "key_question", 63 },
{ "key_at", 64 },
{ "key_leftbracket", 91 },
{ "key_backslash", 92 },
{ "key_rightbracket", 93 },
{ "key_caret", 94 },
{ "key_underscore", 95 },
{ "key_backquote", 96 },
{ "key_a", 97 },
{ "key_b", 98 },
{ "key_c", 99 },
{ "key_d", 100 },
{ "key_e", 101 },
{ "key_f", 102 },
{ "key_g", 103 },
{ "key_h", 104 },
{ "key_i", 105 },
{ "key_j", 106 },
{ "key_k", 107 },
{ "key_l", 108 },
{ "key_m", 109 },
{ "key_n", 110 },
{ "key_o", 111 },
{ "key_p", 112 },
{ "key_q", 113 },
{ "key_r", 114 },
{ "key_s", 115 },
{ "key_t", 116 },
{ "key_u", 117 },
{ "key_v", 118 },
{ "key_w", 119 },
{ "key_x", 120 },
{ "key_y", 121 },
{ "key_z", 122 },
{ "key_delete", 127 },
{ "key_kp0", 256 },
{ "key_kp1", 257 },
{ "key_kp2", 258 },
{ "key_kp3", 259 },
{ "key_kp4", 260 },
{ "key_kp5", 261 },
{ "key_kp6", 262 },
{ "key_kp7", 263 },
{ "key_kp8", 264 },
{ "key_kp9", 265 },
{ "key_kp_period", 266 },
{ "key_kp_divide", 267 },
{ "key_kp_multiply", 268 },
{ "key_kp_minus", 269 },
{ "key_kp_plus", 270 },
{ "key_kp_enter", 271 },
{ "key_kp_equals", 272 },
{ "key_up", 273 },
{ "key_down", 274 },
{ "key_right", 275 },
{ "key_left", 276 },
{ "key_insert", 277 },
{ "key_home", 278 },
{ "key_end", 279 },
{ "key_pageup", 280 },
{ "key_pagedown", 281 },
{ "key_f1", 282 },
{ "key_f2", 283 },
{ "key_f3", 284 },
{ "key_f4", 285 },
{ "key_f5", 286 },
{ "key_f6", 287 },
{ "key_f7", 288 },
{ "key_f8", 289 },
{ "key_f9", 290 },
{ "key_f10", 291 },
{ "key_f11", 292 },
{ "key_f12", 293 },
{ "key_f13", 294 },
{ "key_f14", 295 },
{ "key_f15", 296 },
{ "key_numlock", 300 },
{ "key_capslock", 301 },
{ "key_scrollock", 302 },
{ "key_rshift", 303 },
{ "key_lshift", 304 },
{ "key_rctrl", 305 },
{ "key_lctrl", 306 },
{ "key_ralt", 307 },
{ "key_lalt", 308 },
{ "key_rmeta", 309 },
{ "key_lmeta", 310 },
{ "key_lsuper", 311 },
{ "key_rsuper", 312 },
{ "key_mode", 313 },
{ "key_compose", 314 },
{ "key_help", 315 },
{ "key_print", 316 },
{ "key_sysreq", 317 },
{ "key_break", 318 },
{ "key_menu", 319 },
{ "key_power", 320 },
{ "key_euro", 321 },
{ "key_undo", 322 },
{ "key_repeat_delay", Keyboard::KEY_REPEAT_DELAY },
{ "key_repeat_interval", Keyboard::KEY_REPEAT_INTERVAL },
{ 0, 0 }
};
int wrap_Keyboard_open(lua_State * L)
int luaopen_love_keyboard(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "isDown", w_isDown },
{ "setKeyRepeat", w_setKeyRepeat },
{ "getKeyRepeat", w_getKeyRepeat },
{ 0, 0 }
};
// List of constants.
static const LuaConstant constants[] = {
{ "key_unknown", 0 },
{ "key_first", 0 },
{ "key_backspace", 8 },
{ "key_tab", 9 },
{ "key_clear", 12 },
{ "key_return", 13 },
{ "key_pause", 19 },
{ "key_escape", 27 },
{ "key_space", 32 },
{ "key_exclaim", 33 },
{ "key_quotedbl", 34 },
{ "key_hash", 35 },
{ "key_dollar", 36 },
{ "key_ampersand", 38 },
{ "key_quote", 39 },
{ "key_leftparen", 40 },
{ "key_rightparen", 41 },
{ "key_asterisk", 42 },
{ "key_plus", 43 },
{ "key_comma", 44 },
{ "key_minus", 45 },
{ "key_period", 46 },
{ "key_slash", 47 },
{ "key_0", 48 },
{ "key_1", 49 },
{ "key_2", 50 },
{ "key_3", 51 },
{ "key_4", 52 },
{ "key_5", 53 },
{ "key_6", 54 },
{ "key_7", 55 },
{ "key_8", 56 },
{ "key_9", 57 },
{ "key_colon", 58 },
{ "key_semicolon", 59 },
{ "key_less", 60 },
{ "key_equals", 61 },
{ "key_greater", 62 },
{ "key_question", 63 },
{ "key_at", 64 },
{ "key_leftbracket", 91 },
{ "key_backslash", 92 },
{ "key_rightbracket", 93 },
{ "key_caret", 94 },
{ "key_underscore", 95 },
{ "key_backquote", 96 },
{ "key_a", 97 },
{ "key_b", 98 },
{ "key_c", 99 },
{ "key_d", 100 },
{ "key_e", 101 },
{ "key_f", 102 },
{ "key_g", 103 },
{ "key_h", 104 },
{ "key_i", 105 },
{ "key_j", 106 },
{ "key_k", 107 },
{ "key_l", 108 },
{ "key_m", 109 },
{ "key_n", 110 },
{ "key_o", 111 },
{ "key_p", 112 },
{ "key_q", 113 },
{ "key_r", 114 },
{ "key_s", 115 },
{ "key_t", 116 },
{ "key_u", 117 },
{ "key_v", 118 },
{ "key_w", 119 },
{ "key_x", 120 },
{ "key_y", 121 },
{ "key_z", 122 },
{ "key_delete", 127 },
{ "key_kp0", 256 },
{ "key_kp1", 257 },
{ "key_kp2", 258 },
{ "key_kp3", 259 },
{ "key_kp4", 260 },
{ "key_kp5", 261 },
{ "key_kp6", 262 },
{ "key_kp7", 263 },
{ "key_kp8", 264 },
{ "key_kp9", 265 },
{ "key_kp_period", 266 },
{ "key_kp_divide", 267 },
{ "key_kp_multiply", 268 },
{ "key_kp_minus", 269 },
{ "key_kp_plus", 270 },
{ "key_kp_enter", 271 },
{ "key_kp_equals", 272 },
{ "key_up", 273 },
{ "key_down", 274 },
{ "key_right", 275 },
{ "key_left", 276 },
{ "key_insert", 277 },
{ "key_home", 278 },
{ "key_end", 279 },
{ "key_pageup", 280 },
{ "key_pagedown", 281 },
{ "key_f1", 282 },
{ "key_f2", 283 },
{ "key_f3", 284 },
{ "key_f4", 285 },
{ "key_f5", 286 },
{ "key_f6", 287 },
{ "key_f7", 288 },
{ "key_f8", 289 },
{ "key_f9", 290 },
{ "key_f10", 291 },
{ "key_f11", 292 },
{ "key_f12", 293 },
{ "key_f13", 294 },
{ "key_f14", 295 },
{ "key_f15", 296 },
{ "key_numlock", 300 },
{ "key_capslock", 301 },
{ "key_scrollock", 302 },
{ "key_rshift", 303 },
{ "key_lshift", 304 },
{ "key_rctrl", 305 },
{ "key_lctrl", 306 },
{ "key_ralt", 307 },
{ "key_lalt", 308 },
{ "key_rmeta", 309 },
{ "key_lmeta", 310 },
{ "key_lsuper", 311 },
{ "key_rsuper", 312 },
{ "key_mode", 313 },
{ "key_compose", 314 },
{ "key_help", 315 },
{ "key_print", 316 },
{ "key_sysreq", 317 },
{ "key_break", 318 },
{ "key_menu", 319 },
{ "key_power", 320 },
{ "key_euro", 321 },
{ "key_undo", 322 },
{ "key_repeat_delay", Keyboard::KEY_REPEAT_DELAY },
{ "key_repeat_interval", Keyboard::KEY_REPEAT_INTERVAL },
{ 0, 0 }
};
if(instance == 0)
{
try
@@ -233,16 +232,11 @@ namespace sdl
}
}
luax_register_gc(L, "love.keyboard", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Keyboard_functions, 0, wrap_Keyboard_constants, "keyboard");
return luax_register_module(L, functions, 0, constants, "keyboard");
}
} // sdl
} // keyboard
} // love
int luaopen_love_keyboard(lua_State * L)
{
return love::keyboard::sdl::wrap_Keyboard_open(L);
}
+4 -7
View File
@@ -31,16 +31,13 @@ namespace keyboard
{
namespace sdl
{
int _wrap_isDown(lua_State * L);
int _wrap_setKeyRepeat(lua_State * L);
int _wrap_getKeyRepeat(lua_State * L);
int wrap_Keyboard_open(lua_State * L);
int w_isDown(lua_State * L);
int w_setKeyRepeat(lua_State * L);
int w_getKeyRepeat(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_keyboard(lua_State * L);
} // sdl
} // keyboard
} // love
extern "C" LOVE_EXPORT int luaopen_love_keyboard(lua_State * L);
#endif // LOVE_KEYBOARD_SDL_WRAP_KEYBOARD_H
+37 -37
View File
@@ -28,19 +28,19 @@ namespace sdl
{
static Mouse * instance = 0;
int _wrap_getX(lua_State * L)
int w_getX(lua_State * L)
{
lua_pushnumber(L, instance->getX());
return 1;
}
int _wrap_getY(lua_State * L)
int w_getY(lua_State * L)
{
lua_pushnumber(L, instance->getY());
return 1;
}
int _wrap_getPosition(lua_State * L)
int w_getPosition(lua_State * L)
{
int x, y;
instance->getPosition(&x, &y);
@@ -49,7 +49,7 @@ namespace sdl
return 2;
}
int _wrap_setPosition(lua_State * L)
int w_setPosition(lua_State * L)
{
int x = luaL_checkint(L, 1);
int y = luaL_checkint(L, 2);
@@ -57,66 +57,66 @@ namespace sdl
return 0;
}
int _wrap_isDown(lua_State * L)
int w_isDown(lua_State * L)
{
int b = luaL_checkint(L, 1);
luax_pushboolean(L, instance->isDown(b));
return 1;
}
int _wrap_setVisible(lua_State * L)
int w_setVisible(lua_State * L)
{
bool b = luax_toboolean(L, 1);
instance->setVisible(b);
return 0;
}
int _wrap_isVisible(lua_State * L)
int w_isVisible(lua_State * L)
{
luax_pushboolean(L, instance->isVisible());
return 1;
}
int _wrap_setGrap(lua_State * L)
int w_setGrap(lua_State * L)
{
bool b = luax_toboolean(L, 1);
instance->setGrab(b);
return 0;
}
int _wrap_isGrabbed(lua_State * L)
int w_isGrabbed(lua_State * L)
{
luax_pushboolean(L, instance->isGrabbed());
return 1;
}
// List of functions to wrap.
static const luaL_Reg wrap_Mouse_functions[] = {
{ "getX", _wrap_getX },
{ "getY", _wrap_getY },
{ "setPosition", _wrap_setPosition },
{ "isDown", _wrap_isDown },
{ "setVisible", _wrap_setVisible },
{ "isVisible", _wrap_isVisible },
{ "getPosition", _wrap_getPosition },
{ "setGrab", _wrap_setGrap },
{ "isGrabbed", _wrap_isGrabbed },
{ 0, 0 }
};
// List of constants.
static const LuaConstant wrap_Mouse_constants[] = {
{ "mouse_left", Mouse::MOUSE_LEFT },
{ "mouse_middle", Mouse::MOUSE_MIDDLE },
{ "mouse_right", Mouse::MOUSE_RIGHT },
{ "mouse_wheelup", Mouse::MOUSE_WHEELUP },
{ "mouse_wheeldown", Mouse::MOUSE_WHEELDOWN },
{ 0, 0 }
};
int wrap_Mouse_open(lua_State * L)
int w_Mouse_open(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "getX", w_getX },
{ "getY", w_getY },
{ "setPosition", w_setPosition },
{ "isDown", w_isDown },
{ "setVisible", w_setVisible },
{ "isVisible", w_isVisible },
{ "getPosition", w_getPosition },
{ "setGrab", w_setGrap },
{ "isGrabbed", w_isGrabbed },
{ 0, 0 }
};
// List of constants.
static const LuaConstant constants[] = {
{ "mouse_left", Mouse::MOUSE_LEFT },
{ "mouse_middle", Mouse::MOUSE_MIDDLE },
{ "mouse_right", Mouse::MOUSE_RIGHT },
{ "mouse_wheelup", Mouse::MOUSE_WHEELUP },
{ "mouse_wheeldown", Mouse::MOUSE_WHEELDOWN },
{ 0, 0 }
};
if(instance == 0)
{
try
@@ -129,9 +129,9 @@ namespace sdl
}
}
luax_register_gc(L, "love.mouse", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Mouse_functions, 0, wrap_Mouse_constants, "mouse");
return luax_register_module(L, functions, 0, constants, "mouse");
}
} // sdl
@@ -140,5 +140,5 @@ namespace sdl
int luaopen_love_mouse(lua_State * L)
{
return love::mouse::sdl::wrap_Mouse_open(L);
return love::mouse::sdl::w_Mouse_open(L);
}
+10 -12
View File
@@ -31,22 +31,20 @@ namespace mouse
{
namespace sdl
{
int _wrap_getX(lua_State * L);
int _wrap_getY(lua_State * L);
int _wrap_getPosition(lua_State * L);
int _wrap_setPosition(lua_State * L);
int _wrap_isDown(lua_State * L);
int _wrap_setVisible(lua_State * L);
int _wrap_isVisible(lua_State * L);
int _wrap_setGrap(lua_State * L);
int _wrap_isGrabbed(lua_State * L);
int wrap_Mouse_open(lua_State * L);
int w_getX(lua_State * L);
int w_getY(lua_State * L);
int w_getPosition(lua_State * L);
int w_setPosition(lua_State * L);
int w_isDown(lua_State * L);
int w_setVisible(lua_State * L);
int w_isVisible(lua_State * L);
int w_setGrap(lua_State * L);
int w_isGrabbed(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_mouse(lua_State * L);
} // sdl
} // mouse
} // love
extern "C" LOVE_EXPORT int luaopen_love_mouse(lua_State * L);
#endif // LOVE_MOUSE_SDL_WRAP_MOUSE_H
+14 -19
View File
@@ -33,7 +33,7 @@ namespace tcc
{
static Native * instance = 0;
int _wrap_compile(lua_State * L)
int w_compile(lua_State * L)
{
int argn = lua_gettop(L);
@@ -44,9 +44,9 @@ namespace tcc
{
// Convert to File, if necessary.
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
luax_convobj(L, 1, "filesystem", "newFile");
filesystem::File * file = luax_checktype<filesystem::File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
filesystem::File * file = luax_checktype<filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
int size = file->getSize();
@@ -72,7 +72,7 @@ namespace tcc
return 1;
}
int _wrap_getSymbol(lua_State * L)
int w_getSymbol(lua_State * L)
{
const char * sym = luaL_checkstring(L, 1);
void * ptr = instance->getSymbol(sym);
@@ -113,16 +113,16 @@ namespace tcc
return 1;
}
// List of functions to wrap.
static const luaL_Reg wrap_Native_functions[] = {
{ "compile", _wrap_compile },
{ "getSymbol", _wrap_getSymbol },
{ 0, 0 }
};
int wrap_Native_open(lua_State * L)
int luaopen_native(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "compile", w_compile },
{ "getSymbol", w_getSymbol },
{ 0, 0 }
};
if(instance == 0)
{
try
@@ -137,16 +137,11 @@ namespace tcc
luax_register_searcher(L, searcher);
luax_register_gc(L, "love.native", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Native_functions, 0, 0, "native");
return luax_register_module(L, functions, 0, 0, "native");
}
} // tcc
} // native
} // love
int luaopen_love_native(lua_State * L)
{
return love::native::tcc::wrap_Native_open(L);
}
+3 -5
View File
@@ -31,14 +31,12 @@ namespace native
{
namespace tcc
{
int _wrap_compile(lua_State * L);
int _wrap_getSymbol(lua_State * L);
int wrap_Native_open(lua_State * L);
int w_compile(lua_State * L);
int w_getSymbol(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_native(lua_State * L);
} // tcc
} // native
} // love
extern "C" LOVE_EXPORT int luaopen_love_native(lua_State * L);
#endif // LOVE_NATIVE_TCC_WRAP_NATIVE_H
+1 -1
View File
@@ -142,7 +142,7 @@ namespace box2d
PolygonShape * p = new PolygonShape(b, &def);
luax_newtype(L, "PolygonShape", LOVE_PHYSICS_POLYGON_SHAPE_BITS, (void*)p);
luax_newtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, (void*)p);
return 1;
}
+1 -1
View File
@@ -85,7 +85,7 @@ namespace box2d
lua_pushnil(L);
}
luax_newtype(L, "Contact", (LOVE_PHYSICS_CONTACT_BITS), (void*)add_contacts[i], false);
luax_newtype(L, "Contact", (PHYSICS_CONTACT_T), (void*)add_contacts[i], false);
lua_call(L, 3, 0);
}
+86 -88
View File
@@ -28,90 +28,90 @@ namespace box2d
{
Body * luax_checkbody(lua_State * L, int idx)
{
return luax_checktype<Body>(L, idx, "Body", LOVE_PHYSICS_BODY_BITS);
return luax_checktype<Body>(L, idx, "Body", PHYSICS_BODY_T);
}
int _wrap_Body_getX(lua_State * L)
int w_Body_getX(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushnumber(L, t->getX());
return 1;
}
int _wrap_Body_getY(lua_State * L)
int w_Body_getY(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushnumber(L, t->getY());
return 1;
}
int _wrap_Body_getAngle(lua_State * L)
int w_Body_getAngle(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushnumber(L, t->getAngle());
return 1;
}
int _wrap_Body_getPosition(lua_State * L)
int w_Body_getPosition(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getPosition(L);
}
int _wrap_Body_getLinearVelocity(lua_State * L)
int w_Body_getLinearVelocity(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLinearVelocity(L);
}
int _wrap_Body_getWorldCenter(lua_State * L)
int w_Body_getWorldCenter(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getWorldCenter(L);
}
int _wrap_Body_getLocalCenter(lua_State * L)
int w_Body_getLocalCenter(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLocalCenter(L);
}
int _wrap_Body_getAngularVelocity(lua_State * L)
int w_Body_getAngularVelocity(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushnumber(L, t->getAngularVelocity());
return 1;
}
int _wrap_Body_getMass(lua_State * L)
int w_Body_getMass(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushnumber(L, t->getMass());
return 1;
}
int _wrap_Body_getInertia(lua_State * L)
int w_Body_getInertia(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushnumber(L, t->getInertia());
return 1;
}
int _wrap_Body_getAngularDamping(lua_State * L)
int w_Body_getAngularDamping(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushnumber(L, t->getAngularDamping());
return 1;
}
int _wrap_Body_getLinearDamping(lua_State * L)
int w_Body_getLinearDamping(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushnumber(L, t->getLinearDamping());
return 1;
}
int _wrap_Body_applyImpulse(lua_State * L)
int w_Body_applyImpulse(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float jx = (float)luaL_checknumber(L, 2);
@@ -122,7 +122,7 @@ namespace box2d
return 0;
}
int _wrap_Body_applyTorque(lua_State * L)
int w_Body_applyTorque(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg = (float)luaL_checknumber(L, 2);
@@ -130,7 +130,7 @@ namespace box2d
return 0;
}
int _wrap_Body_applyForce(lua_State * L)
int w_Body_applyForce(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float fx = (float)luaL_checknumber(L, 2);
@@ -141,7 +141,7 @@ namespace box2d
return 0;
}
int _wrap_Body_setX(lua_State * L)
int w_Body_setX(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -149,7 +149,7 @@ namespace box2d
return 0;
}
int _wrap_Body_setY(lua_State * L)
int w_Body_setY(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -157,7 +157,7 @@ namespace box2d
return 0;
}
int _wrap_Body_setLinearVelocity(lua_State * L)
int w_Body_setLinearVelocity(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -166,7 +166,7 @@ namespace box2d
return 0;
}
int _wrap_Body_setAngle(lua_State * L)
int w_Body_setAngle(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -174,7 +174,7 @@ namespace box2d
return 0;
}
int _wrap_Body_setAngularVelocity(lua_State * L)
int w_Body_setAngularVelocity(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -182,7 +182,7 @@ namespace box2d
return 0;
}
int _wrap_Body_setPosition(lua_State * L)
int w_Body_setPosition(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -191,14 +191,14 @@ namespace box2d
return 0;
}
int _wrap_Body_setMassFromShapes(lua_State * L)
int w_Body_setMassFromShapes(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
t->setMassFromShapes();
return 0;
}
int _wrap_Body_setMass(lua_State * L)
int w_Body_setMass(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float x = (float)luaL_checknumber(L, 2);
@@ -209,7 +209,7 @@ namespace box2d
return 0;
}
int _wrap_Body_setAngularDamping(lua_State * L)
int w_Body_setAngularDamping(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -217,7 +217,7 @@ namespace box2d
return 0;
}
int _wrap_Body_setLinearDamping(lua_State * L)
int w_Body_setLinearDamping(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -225,50 +225,50 @@ namespace box2d
return 0;
}
int _wrap_Body_getWorldPoint(lua_State * L)
int w_Body_getWorldPoint(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getWorldPoint(L);
}
int _wrap_Body_getWorldVector(lua_State * L)
int w_Body_getWorldVector(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getWorldVector(L);
}
int _wrap_Body_getLocalPoint(lua_State * L)
int w_Body_getLocalPoint(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLocalPoint(L);
}
int _wrap_Body_getLocalVector(lua_State * L)
int w_Body_getLocalVector(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLocalVector(L);
}
int _wrap_Body_getLinearVelocityFromWorldPoint(lua_State * L)
int w_Body_getLinearVelocityFromWorldPoint(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLinearVelocityFromWorldPoint(L);
}
int _wrap_Body_getLinearVelocityFromLocalPoint(lua_State * L)
int w_Body_getLinearVelocityFromLocalPoint(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLinearVelocityFromLocalPoint(L);
}
int _wrap_Body_isBullet(lua_State * L)
int w_Body_isBullet(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
luax_pushboolean(L, t->isBullet());
return 1;
}
int _wrap_Body_setBullet(lua_State * L)
int w_Body_setBullet(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
bool b = luax_toboolean(L, 2);
@@ -276,35 +276,35 @@ namespace box2d
return 0;
}
int _wrap_Body_isStatic(lua_State * L)
int w_Body_isStatic(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
luax_pushboolean(L, t->isStatic());
return 1;
}
int _wrap_Body_isDynamic(lua_State * L)
int w_Body_isDynamic(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
luax_pushboolean(L, t->isDynamic());
return 1;
}
int _wrap_Body_isFrozen(lua_State * L)
int w_Body_isFrozen(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
luax_pushboolean(L, t->isFrozen());
return 1;
}
int _wrap_Body_isSleeping(lua_State * L)
int w_Body_isSleeping(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
luax_pushboolean(L, t->isSleeping());
return 1;
}
int _wrap_Body_setAllowSleeping(lua_State * L)
int w_Body_setAllowSleeping(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
bool b = luax_toboolean(L, 2);
@@ -312,68 +312,66 @@ namespace box2d
return 0;
}
int _wrap_Body_putToSleep(lua_State * L)
int w_Body_putToSleep(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
t->putToSleep();
return 0;
}
int _wrap_Body_wakeUp(lua_State * L)
int w_Body_wakeUp(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
t->wakeUp();
return 0;
}
static const luaL_Reg wrap_Body_functions[] = {
{ "getX", _wrap_Body_getX },
{ "getY", _wrap_Body_getY },
{ "getAngle", _wrap_Body_getAngle },
{ "getPosition", _wrap_Body_getPosition },
{ "getLinearVelocity", _wrap_Body_getLinearVelocity },
{ "getWorldCenter", _wrap_Body_getWorldCenter },
{ "getLocalCenter", _wrap_Body_getLocalCenter },
{ "getAngularVelocity", _wrap_Body_getAngularVelocity },
{ "getMass", _wrap_Body_getMass },
{ "getInertia", _wrap_Body_getInertia },
{ "getAngularDamping", _wrap_Body_getAngularDamping },
{ "getLinearDamping", _wrap_Body_getLinearDamping },
{ "applyImpulse", _wrap_Body_applyImpulse },
{ "applyTorque", _wrap_Body_applyTorque },
{ "applyForce", _wrap_Body_applyForce },
{ "setX", _wrap_Body_setX },
{ "setY", _wrap_Body_setY },
{ "setLinearVelocity", _wrap_Body_setLinearVelocity },
{ "setAngle", _wrap_Body_setAngle },
{ "setAngularVelocity", _wrap_Body_setAngularVelocity },
{ "setPosition", _wrap_Body_setPosition },
{ "setMassFromShapes", _wrap_Body_setMassFromShapes },
{ "setMass", _wrap_Body_setMass },
{ "setAngularDamping", _wrap_Body_setAngularDamping },
{ "setLinearDamping", _wrap_Body_setLinearDamping },
{ "getWorldPoint", _wrap_Body_getWorldPoint },
{ "getWorldVector", _wrap_Body_getWorldVector },
{ "getLocalPoint", _wrap_Body_getLocalPoint },
{ "getLocalVector", _wrap_Body_getLocalVector },
{ "getLinearVelocityFromWorldPoint", _wrap_Body_getLinearVelocityFromWorldPoint },
{ "getLinearVelocityFromLocalPoint", _wrap_Body_getLinearVelocityFromLocalPoint },
{ "isBullet", _wrap_Body_isBullet },
{ "setBullet", _wrap_Body_setBullet },
{ "isStatic", _wrap_Body_isStatic },
{ "isDynamic", _wrap_Body_isDynamic },
{ "isFrozen", _wrap_Body_isFrozen },
{ "isSleeping", _wrap_Body_isSleeping },
{ "setAllowSleeping", _wrap_Body_setAllowSleeping },
{ "putToSleep", _wrap_Body_putToSleep },
{ "wakeUp", _wrap_Body_wakeUp },
{ 0, 0 }
};
int wrap_Body_open(lua_State * L)
int luaopen_body(lua_State * L)
{
luax_register_type(L, "Body", wrap_Body_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getX", w_Body_getX },
{ "getY", w_Body_getY },
{ "getAngle", w_Body_getAngle },
{ "getPosition", w_Body_getPosition },
{ "getLinearVelocity", w_Body_getLinearVelocity },
{ "getWorldCenter", w_Body_getWorldCenter },
{ "getLocalCenter", w_Body_getLocalCenter },
{ "getAngularVelocity", w_Body_getAngularVelocity },
{ "getMass", w_Body_getMass },
{ "getInertia", w_Body_getInertia },
{ "getAngularDamping", w_Body_getAngularDamping },
{ "getLinearDamping", w_Body_getLinearDamping },
{ "applyImpulse", w_Body_applyImpulse },
{ "applyTorque", w_Body_applyTorque },
{ "applyForce", w_Body_applyForce },
{ "setX", w_Body_setX },
{ "setY", w_Body_setY },
{ "setLinearVelocity", w_Body_setLinearVelocity },
{ "setAngle", w_Body_setAngle },
{ "setAngularVelocity", w_Body_setAngularVelocity },
{ "setPosition", w_Body_setPosition },
{ "setMassFromShapes", w_Body_setMassFromShapes },
{ "setMass", w_Body_setMass },
{ "setAngularDamping", w_Body_setAngularDamping },
{ "setLinearDamping", w_Body_setLinearDamping },
{ "getWorldPoint", w_Body_getWorldPoint },
{ "getWorldVector", w_Body_getWorldVector },
{ "getLocalPoint", w_Body_getLocalPoint },
{ "getLocalVector", w_Body_getLocalVector },
{ "getLinearVelocityFromWorldPoint", w_Body_getLinearVelocityFromWorldPoint },
{ "getLinearVelocityFromLocalPoint", w_Body_getLinearVelocityFromLocalPoint },
{ "isBullet", w_Body_isBullet },
{ "setBullet", w_Body_setBullet },
{ "isStatic", w_Body_isStatic },
{ "isDynamic", w_Body_isDynamic },
{ "isFrozen", w_Body_isFrozen },
{ "isSleeping", w_Body_isSleeping },
{ "setAllowSleeping", w_Body_setAllowSleeping },
{ "putToSleep", w_Body_putToSleep },
{ "wakeUp", w_Body_wakeUp },
{ 0, 0 }
};
return luax_register_type(L, "Body", functions);
}
} // box2d
+41 -41
View File
@@ -33,47 +33,47 @@ namespace box2d
{
Body * luax_checkbody(lua_State * L, int idx);
int _wrap_Body_getX(lua_State * L);
int _wrap_Body_getY(lua_State * L);
int _wrap_Body_getAngle(lua_State * L);
int _wrap_Body_getPosition(lua_State * L);
int _wrap_Body_getLinearVelocity(lua_State * L);
int _wrap_Body_getWorldCenter(lua_State * L);
int _wrap_Body_getLocalCenter(lua_State * L);
int _wrap_Body_getAngularVelocity(lua_State * L);
int _wrap_Body_getMass(lua_State * L);
int _wrap_Body_getInertia(lua_State * L);
int _wrap_Body_getAngularDamping(lua_State * L);
int _wrap_Body_getLinearDamping(lua_State * L);
int _wrap_Body_applyImpulse(lua_State * L);
int _wrap_Body_applyTorque(lua_State * L);
int _wrap_Body_applyForce(lua_State * L);
int _wrap_Body_setX(lua_State * L);
int _wrap_Body_setY(lua_State * L);
int _wrap_Body_setVelocity(lua_State * L);
int _wrap_Body_setAngle(lua_State * L);
int _wrap_Body_setAngularVelocity(lua_State * L);
int _wrap_Body_setPosition(lua_State * L);
int _wrap_Body_setMassFromShapes(lua_State * L);
int _wrap_Body_setMass(lua_State * L);
int _wrap_Body_setAngularDamping(lua_State * L);
int _wrap_Body_setLinearDamping(lua_State * L);
int _wrap_Body_getWorldPoint(lua_State * L);
int _wrap_Body_getWorldVector(lua_State * L);
int _wrap_Body_getLocalPoint(lua_State * L);
int _wrap_Body_getLocalVector(lua_State * L);
int _wrap_Body_getLinearVelocityFromWorldPoint(lua_State * L);
int _wrap_Body_getLinearVelocityFromLocalPoint(lua_State * L);
int _wrap_Body_isBullet(lua_State * L);
int _wrap_Body_setBullet(lua_State * L);
int _wrap_Body_isStatic(lua_State * L);
int _wrap_Body_isDynamic(lua_State * L);
int _wrap_Body_isFrozen(lua_State * L);
int _wrap_Body_isSleeping(lua_State * L);
int _wrap_Body_setAllowSleeping(lua_State * L);
int _wrap_Body_putToSleep(lua_State * L);
int _wrap_Body_wakeUp(lua_State * L);
int wrap_Body_open(lua_State * L);
int w_Body_getX(lua_State * L);
int w_Body_getY(lua_State * L);
int w_Body_getAngle(lua_State * L);
int w_Body_getPosition(lua_State * L);
int w_Body_getLinearVelocity(lua_State * L);
int w_Body_getWorldCenter(lua_State * L);
int w_Body_getLocalCenter(lua_State * L);
int w_Body_getAngularVelocity(lua_State * L);
int w_Body_getMass(lua_State * L);
int w_Body_getInertia(lua_State * L);
int w_Body_getAngularDamping(lua_State * L);
int w_Body_getLinearDamping(lua_State * L);
int w_Body_applyImpulse(lua_State * L);
int w_Body_applyTorque(lua_State * L);
int w_Body_applyForce(lua_State * L);
int w_Body_setX(lua_State * L);
int w_Body_setY(lua_State * L);
int w_Body_setVelocity(lua_State * L);
int w_Body_setAngle(lua_State * L);
int w_Body_setAngularVelocity(lua_State * L);
int w_Body_setPosition(lua_State * L);
int w_Body_setMassFromShapes(lua_State * L);
int w_Body_setMass(lua_State * L);
int w_Body_setAngularDamping(lua_State * L);
int w_Body_setLinearDamping(lua_State * L);
int w_Body_getWorldPoint(lua_State * L);
int w_Body_getWorldVector(lua_State * L);
int w_Body_getLocalPoint(lua_State * L);
int w_Body_getLocalVector(lua_State * L);
int w_Body_getLinearVelocityFromWorldPoint(lua_State * L);
int w_Body_getLinearVelocityFromLocalPoint(lua_State * L);
int w_Body_isBullet(lua_State * L);
int w_Body_setBullet(lua_State * L);
int w_Body_isStatic(lua_State * L);
int w_Body_isDynamic(lua_State * L);
int w_Body_isFrozen(lua_State * L);
int w_Body_isSleeping(lua_State * L);
int w_Body_setAllowSleeping(lua_State * L);
int w_Body_putToSleep(lua_State * L);
int w_Body_wakeUp(lua_State * L);
int luaopen_body(lua_State * L);
} // box2d
} // physics
+26 -27
View File
@@ -28,42 +28,41 @@ namespace box2d
{
CircleShape * luax_checkcircleshape(lua_State * L, int idx)
{
return luax_checktype<CircleShape>(L, idx, "CircleShape", LOVE_PHYSICS_CIRCLE_SHAPE_BITS);
return luax_checktype<CircleShape>(L, idx, "CircleShape", PHYSICS_CIRCLE_SHAPE_T);
}
int _wrap_CircleShape_getRadius(lua_State * L)
int w_CircleShape_getRadius(lua_State * L)
{
CircleShape * c = luax_checkcircleshape(L, 1);
lua_pushnumber(L, c->getRadius());
return 1;
}
static const luaL_Reg wrap_CircleShape_functions[] = {
{ "getRadius", _wrap_CircleShape_getRadius },
// From Shape.
{ "getType", _wrap_Shape_getType },
{ "setFriction", _wrap_Shape_setFriction },
{ "setRestitution", _wrap_Shape_setRestitution },
{ "setDensity", _wrap_Shape_setDensity },
{ "setSensor", _wrap_Shape_setSensor },
{ "getFriction", _wrap_Shape_getFriction },
{ "getRestituion", _wrap_Shape_getRestituion },
{ "getDensity", _wrap_Shape_getDensity },
{ "isSensor", _wrap_Shape_isSensor },
{ "testPoint", _wrap_Shape_testPoint },
{ "testSegment", _wrap_Shape_testSegment },
{ "setFilterData", _wrap_Shape_setFilterData },
{ "getFilterData", _wrap_Shape_getFilterData },
{ "setData", _wrap_Shape_setData },
{ "getData", _wrap_Shape_getData },
{ "getBoundingBox", _wrap_Shape_getBoundingBox },
{ 0, 0 }
};
int wrap_CircleShape_open(lua_State * L)
int luaopen_circleshape(lua_State * L)
{
luax_register_type(L, "CircleShape", wrap_CircleShape_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getRadius", w_CircleShape_getRadius },
// From Shape.
{ "getType", w_Shape_getType },
{ "setFriction", w_Shape_setFriction },
{ "setRestitution", w_Shape_setRestitution },
{ "setDensity", w_Shape_setDensity },
{ "setSensor", w_Shape_setSensor },
{ "getFriction", w_Shape_getFriction },
{ "getRestituion", w_Shape_getRestituion },
{ "getDensity", w_Shape_getDensity },
{ "isSensor", w_Shape_isSensor },
{ "testPoint", w_Shape_testPoint },
{ "testSegment", w_Shape_testSegment },
{ "setFilterData", w_Shape_setFilterData },
{ "getFilterData", w_Shape_getFilterData },
{ "setData", w_Shape_setData },
{ "getData", w_Shape_getData },
{ "getBoundingBox", w_Shape_getBoundingBox },
{ 0, 0 }
};
return luax_register_type(L, "CircleShape", functions);
}
} // box2d
+2 -2
View File
@@ -33,8 +33,8 @@ namespace physics
namespace box2d
{
CircleShape * luax_checkcircleshape(lua_State * L, int idx);
int _wrap_CircleShape_getRadius(lua_State * L);
int wrap_CircleShape_open(lua_State * L);
int w_CircleShape_getRadius(lua_State * L);
int luaopen_circleshape(lua_State * L);
} // box2d
} // physics
+19 -20
View File
@@ -29,62 +29,61 @@ namespace box2d
Contact * luax_checkcontact(lua_State * L, int idx)
{
return luax_checktype<Contact>(L, idx, "Contact", LOVE_PHYSICS_CONTACT_BITS);
return luax_checktype<Contact>(L, idx, "Contact", PHYSICS_CONTACT_T);
}
int _wrap_Contact_getPosition(lua_State * L)
int w_Contact_getPosition(lua_State * L)
{
Contact * t = luax_checkcontact(L, 1);
return t->getPosition(L);
}
int _wrap_Contact_getVelocity(lua_State * L)
int w_Contact_getVelocity(lua_State * L)
{
Contact * t = luax_checkcontact(L, 1);
return t->getVelocity(L);
}
int _wrap_Contact_getNormal(lua_State * L)
int w_Contact_getNormal(lua_State * L)
{
Contact * t = luax_checkcontact(L, 1);
return t->getNormal(L);
}
int _wrap_Contact_getSeparation(lua_State * L)
int w_Contact_getSeparation(lua_State * L)
{
Contact * t = luax_checkcontact(L, 1);
lua_pushnumber(L, t->getSeparation());
return 1;
}
int _wrap_Contact_getFriction(lua_State * L)
int w_Contact_getFriction(lua_State * L)
{
Contact * t = luax_checkcontact(L, 1);
lua_pushnumber(L, t->getFriction());
return 1;
}
int _wrap_Contact_getRestitution(lua_State * L)
int w_Contact_getRestitution(lua_State * L)
{
Contact * t = luax_checkcontact(L, 1);
lua_pushnumber(L, t->getRestitution());
return 1;
}
static const luaL_Reg wrap_Contact_functions[] = {
{ "getPosition", _wrap_Contact_getPosition },
{ "getVelocity", _wrap_Contact_getVelocity },
{ "getNormal", _wrap_Contact_getNormal },
{ "getSeparation", _wrap_Contact_getSeparation },
{ "getFriction", _wrap_Contact_getFriction },
{ "getRestitution", _wrap_Contact_getRestitution },
{ 0, 0 }
};
int wrap_Contact_open(lua_State * L)
int luaopen_contact(lua_State * L)
{
luax_register_type(L, "Contact", wrap_Contact_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getPosition", w_Contact_getPosition },
{ "getVelocity", w_Contact_getVelocity },
{ "getNormal", w_Contact_getNormal },
{ "getSeparation", w_Contact_getSeparation },
{ "getFriction", w_Contact_getFriction },
{ "getRestitution", w_Contact_getRestitution },
{ 0, 0 }
};
return luax_register_type(L, "Contact", functions);
}
} // box2d
+7 -7
View File
@@ -32,13 +32,13 @@ namespace physics
namespace box2d
{
Contact * luax_checkcontact(lua_State * L, int idx);
int _wrap_Contact_getPosition(lua_State * L);
int _wrap_Contact_getVelocity(lua_State * L);
int _wrap_Contact_getNormal(lua_State * L);
int _wrap_Contact_getSeparation(lua_State * L);
int _wrap_Contact_getFriction(lua_State * L);
int _wrap_Contact_getRestitution(lua_State * L);
int wrap_Contact_open(lua_State * L);
int w_Contact_getPosition(lua_State * L);
int w_Contact_getVelocity(lua_State * L);
int w_Contact_getNormal(lua_State * L);
int w_Contact_getSeparation(lua_State * L);
int w_Contact_getFriction(lua_State * L);
int w_Contact_getRestitution(lua_State * L);
int luaopen_contact(lua_State * L);
} // box2d
} // physics
@@ -28,10 +28,10 @@ namespace box2d
{
DistanceJoint * luax_checkdistancejoint(lua_State * L, int idx)
{
return luax_checktype<DistanceJoint>(L, idx, "DistanceJoint", LOVE_PHYSICS_DISTANCE_JOINT_BITS);
return luax_checktype<DistanceJoint>(L, idx, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T);
}
int _wrap_DistanceJoint_setLength(lua_State * L)
int w_DistanceJoint_setLength(lua_State * L)
{
DistanceJoint * t = luax_checkdistancejoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -39,14 +39,14 @@ namespace box2d
return 0;
}
int _wrap_DistanceJoint_getLength(lua_State * L)
int w_DistanceJoint_getLength(lua_State * L)
{
DistanceJoint * t = luax_checkdistancejoint(L, 1);
lua_pushnumber(L, t->getLength());
return 1;
}
int _wrap_DistanceJoint_setFrequency(lua_State * L)
int w_DistanceJoint_setFrequency(lua_State * L)
{
DistanceJoint * t = luax_checkdistancejoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -54,14 +54,14 @@ namespace box2d
return 0;
}
int _wrap_DistanceJoint_getFrequency(lua_State * L)
int w_DistanceJoint_getFrequency(lua_State * L)
{
DistanceJoint * t = luax_checkdistancejoint(L, 1);
lua_pushnumber(L, t->getFrequency());
return 1;
}
int _wrap_DistanceJoint_setDampingRatio(lua_State * L)
int w_DistanceJoint_setDampingRatio(lua_State * L)
{
DistanceJoint * t = luax_checkdistancejoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -69,34 +69,33 @@ namespace box2d
return 0;
}
int _wrap_DistanceJoint_getDampingRatio(lua_State * L)
int w_DistanceJoint_getDampingRatio(lua_State * L)
{
DistanceJoint * t = luax_checkdistancejoint(L, 1);
lua_pushnumber(L, t->getDampingRatio());
return 1;
}
static const luaL_Reg wrap_DistanceJoint_functions[] = {
{ "setLength", _wrap_DistanceJoint_setLength },
{ "getLength", _wrap_DistanceJoint_getLength },
{ "setFrequency", _wrap_DistanceJoint_setFrequency },
{ "getFrequency", _wrap_DistanceJoint_getFrequency },
{ "setDamping", _wrap_DistanceJoint_setDampingRatio },
{ "getDamping", _wrap_DistanceJoint_getDampingRatio },
// From Joint.
{ "getType", _wrap_Joint_getType },
{ "getAnchors", _wrap_Joint_getAnchors },
{ "getReactionForce", _wrap_Joint_getReactionForce },
{ "getReactionTorque", _wrap_Joint_getReactionTorque },
{ "setCollideConnected", _wrap_Joint_setCollideConnected },
{ "getCollideConnected", _wrap_Joint_getCollideConnected },
{ 0, 0 }
};
int wrap_DistanceJoint_open(lua_State * L)
int luaopen_distancejoint(lua_State * L)
{
luax_register_type(L, "DistanceJoint", wrap_DistanceJoint_functions);
return 0;
static const luaL_Reg functions[] = {
{ "setLength", w_DistanceJoint_setLength },
{ "getLength", w_DistanceJoint_getLength },
{ "setFrequency", w_DistanceJoint_setFrequency },
{ "getFrequency", w_DistanceJoint_getFrequency },
{ "setDamping", w_DistanceJoint_setDampingRatio },
{ "getDamping", w_DistanceJoint_getDampingRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
{ "setCollideConnected", w_Joint_setCollideConnected },
{ "getCollideConnected", w_Joint_getCollideConnected },
{ 0, 0 }
};
return luax_register_type(L, "DistanceJoint", functions);
}
} // box2d
@@ -33,13 +33,13 @@ namespace physics
namespace box2d
{
DistanceJoint * luax_checkdistancejoint(lua_State * L, int idx);
int _wrap_DistanceJoint_setLength(lua_State * L);
int _wrap_DistanceJoint_getLength(lua_State * L);
int _wrap_DistanceJoint_setFrequency(lua_State * L);
int _wrap_DistanceJoint_getFrequency(lua_State * L);
int _wrap_DistanceJoint_setDampingRatio(lua_State * L);
int _wrap_DistanceJoint_getDampingRatio(lua_State * L);
int wrap_DistanceJoint_open(lua_State * L);
int w_DistanceJoint_setLength(lua_State * L);
int w_DistanceJoint_getLength(lua_State * L);
int w_DistanceJoint_setFrequency(lua_State * L);
int w_DistanceJoint_getFrequency(lua_State * L);
int w_DistanceJoint_setDampingRatio(lua_State * L);
int w_DistanceJoint_getDampingRatio(lua_State * L);
int luaopen_distancejoint(lua_State * L);
} // box2d
} // physics
+17 -19
View File
@@ -28,10 +28,10 @@ namespace box2d
{
GearJoint * luax_checkgearjoint(lua_State * L, int idx)
{
return luax_checktype<GearJoint>(L, idx, "GearJoint", LOVE_PHYSICS_GEAR_JOINT_BITS);
return luax_checktype<GearJoint>(L, idx, "GearJoint", PHYSICS_GEAR_JOINT_T);
}
int _wrap_GearJoint_setRatio(lua_State * L)
int w_GearJoint_setRatio(lua_State * L)
{
GearJoint * t = luax_checkgearjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -39,30 +39,28 @@ namespace box2d
return 0;
}
int _wrap_GearJoint_getRatio(lua_State * L)
int w_GearJoint_getRatio(lua_State * L)
{
GearJoint * t = luax_checkgearjoint(L, 1);
lua_pushnumber(L, t->getRatio());
return 1;
}
static const luaL_Reg wrap_GearJoint_functions[] = {
{ "setRatio", _wrap_GearJoint_setRatio },
{ "getRatio", _wrap_GearJoint_getRatio },
// From Joint.
{ "getType", _wrap_Joint_getType },
{ "getAnchors", _wrap_Joint_getAnchors },
{ "getReactionForce", _wrap_Joint_getReactionForce },
{ "getReactionTorque", _wrap_Joint_getReactionTorque },
{ "setCollideConnected", _wrap_Joint_setCollideConnected },
{ "getCollideConnected", _wrap_Joint_getCollideConnected },
{ 0, 0 }
};
int wrap_GearJoint_open(lua_State * L)
int luaopen_gearjoint(lua_State * L)
{
luax_register_type(L, "GearJoint", wrap_GearJoint_functions);
return 0;
static const luaL_Reg functions[] = {
{ "setRatio", w_GearJoint_setRatio },
{ "getRatio", w_GearJoint_getRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
{ "setCollideConnected", w_Joint_setCollideConnected },
{ "getCollideConnected", w_Joint_getCollideConnected },
{ 0, 0 }
};
return luax_register_type(L, "GearJoint", functions);
}
} // box2d
+3 -3
View File
@@ -33,9 +33,9 @@ namespace physics
namespace box2d
{
GearJoint * luax_checkgearjoint(lua_State * L, int idx);
int _wrap_GearJoint_setRatio(lua_State * L);
int _wrap_GearJoint_getRatio(lua_State * L);
int wrap_GearJoint_open(lua_State * L);
int w_GearJoint_setRatio(lua_State * L);
int w_GearJoint_getRatio(lua_State * L);
int luaopen_gearjoint(lua_State * L);
} // box2d
} // physics
+19 -20
View File
@@ -29,38 +29,38 @@ namespace box2d
{
Joint * luax_checkjoint(lua_State * L, int idx)
{
return luax_checktype<Joint>(L, idx, "Joint", LOVE_PHYSICS_JOINT_BITS);
return luax_checktype<Joint>(L, idx, "Joint", PHYSICS_JOINT_T);
}
int _wrap_Joint_getType(lua_State * L)
int w_Joint_getType(lua_State * L)
{
Joint * t = luax_checkjoint(L, 1);
lua_pushinteger(L, t->getType());
return 1;
}
int _wrap_Joint_getAnchors(lua_State * L)
int w_Joint_getAnchors(lua_State * L)
{
Joint * t = luax_checkjoint(L, 1);
lua_remove(L, 1);
return t->getAnchors(L);
}
int _wrap_Joint_getReactionForce(lua_State * L)
int w_Joint_getReactionForce(lua_State * L)
{
Joint * t = luax_checkjoint(L, 1);
lua_remove(L, 1);
return t->getReactionForce(L);
}
int _wrap_Joint_getReactionTorque(lua_State * L)
int w_Joint_getReactionTorque(lua_State * L)
{
Joint * t = luax_checkjoint(L, 1);
lua_pushnumber(L, t->getReactionTorque());
return 1;
}
int _wrap_Joint_setCollideConnected(lua_State * L)
int w_Joint_setCollideConnected(lua_State * L)
{
Joint * t = luax_checkjoint(L, 1);
bool arg1 = luax_toboolean(L, 2);
@@ -68,27 +68,26 @@ namespace box2d
return 0;
}
int _wrap_Joint_getCollideConnected(lua_State * L)
int w_Joint_getCollideConnected(lua_State * L)
{
Joint * t = luax_checkjoint(L, 1);
luax_pushboolean(L, t->getCollideConnected());
return 1;
}
static const luaL_Reg wrap_Joint_functions[] = {
{ "getType", _wrap_Joint_getType },
{ "getAnchors", _wrap_Joint_getAnchors },
{ "getReactionForce", _wrap_Joint_getReactionForce },
{ "getReactionTorque", _wrap_Joint_getReactionTorque },
{ "setCollideConnected", _wrap_Joint_setCollideConnected },
{ "getCollideConnected", _wrap_Joint_getCollideConnected },
{ 0, 0 }
};
int wrap_Joint_open(lua_State * L)
int luaopen_joint(lua_State * L)
{
luax_register_type(L, "Joint", wrap_Joint_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getType", w_Joint_getType },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
{ "setCollideConnected", w_Joint_setCollideConnected },
{ "getCollideConnected", w_Joint_getCollideConnected },
{ 0, 0 }
};
return luax_register_type(L, "Joint", functions);
}
} // box2d
+7 -7
View File
@@ -32,13 +32,13 @@ namespace physics
namespace box2d
{
Joint * luax_checkjoint(lua_State * L, int idx);
int _wrap_Joint_getType(lua_State * L);
int _wrap_Joint_getAnchors(lua_State * L);
int _wrap_Joint_getReactionForce(lua_State * L);
int _wrap_Joint_getReactionTorque(lua_State * L);
int _wrap_Joint_setCollideConnected(lua_State * L);
int _wrap_Joint_getCollideConnected(lua_State * L);
int wrap_Joint_open(lua_State * L);
int w_Joint_getType(lua_State * L);
int w_Joint_getAnchors(lua_State * L);
int w_Joint_getReactionForce(lua_State * L);
int w_Joint_getReactionTorque(lua_State * L);
int w_Joint_setCollideConnected(lua_State * L);
int w_Joint_getCollideConnected(lua_State * L);
int luaopen_joint(lua_State * L);
} // box2d
} // physics
+22 -23
View File
@@ -28,10 +28,10 @@ namespace box2d
{
MouseJoint * luax_checkmousejoint(lua_State * L, int idx)
{
return luax_checktype<MouseJoint>(L, idx, "MouseJoint", LOVE_PHYSICS_MOUSE_JOINT_BITS);
return luax_checktype<MouseJoint>(L, idx, "MouseJoint", PHYSICS_MOUSE_JOINT_T);
}
int _wrap_MouseJoint_setTarget(lua_State * L)
int w_MouseJoint_setTarget(lua_State * L)
{
MouseJoint * t = luax_checkmousejoint(L, 1);
float x = (float)luaL_checknumber(L, 2);
@@ -40,14 +40,14 @@ namespace box2d
return 0;
}
int _wrap_MouseJoint_getTarget(lua_State * L)
int w_MouseJoint_getTarget(lua_State * L)
{
MouseJoint * t = luax_checkmousejoint(L, 1);
lua_remove(L, 1);
return t->getTarget(L);
}
int _wrap_MouseJoint_setMaxForce(lua_State * L)
int w_MouseJoint_setMaxForce(lua_State * L)
{
MouseJoint * t = luax_checkmousejoint(L, 1);
float f = (float)luaL_checknumber(L, 2);
@@ -55,32 +55,31 @@ namespace box2d
return 0;
}
int _wrap_MouseJoint_getMaxForce(lua_State * L)
int w_MouseJoint_getMaxForce(lua_State * L)
{
MouseJoint * t = luax_checkmousejoint(L, 1);
lua_pushnumber(L, t->getMaxForce());
return 1;
}
static const luaL_Reg wrap_MouseJoint_functions[] = {
{ "setTarget", _wrap_MouseJoint_setTarget },
{ "getTarget", _wrap_MouseJoint_getTarget },
{ "setMaxForce", _wrap_MouseJoint_setMaxForce },
{ "getMaxForce", _wrap_MouseJoint_getMaxForce },
// From Joint.
{ "getType", _wrap_Joint_getType },
{ "getAnchors", _wrap_Joint_getAnchors },
{ "getReactionForce", _wrap_Joint_getReactionForce },
{ "getReactionTorque", _wrap_Joint_getReactionTorque },
{ "setCollideConnected", _wrap_Joint_setCollideConnected },
{ "getCollideConnected", _wrap_Joint_getCollideConnected },
{ 0, 0 }
};
int wrap_MouseJoint_open(lua_State * L)
int luaopen_mousejoint(lua_State * L)
{
luax_register_type(L, "MouseJoint", wrap_MouseJoint_functions);
return 0;
static const luaL_Reg functions[] = {
{ "setTarget", w_MouseJoint_setTarget },
{ "getTarget", w_MouseJoint_getTarget },
{ "setMaxForce", w_MouseJoint_setMaxForce },
{ "getMaxForce", w_MouseJoint_getMaxForce },
// From Joint.
{ "getType", w_Joint_getType },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
{ "setCollideConnected", w_Joint_setCollideConnected },
{ "getCollideConnected", w_Joint_getCollideConnected },
{ 0, 0 }
};
return luax_register_type(L, "MouseJoint", functions);
}
} // box2d
+5 -5
View File
@@ -33,11 +33,11 @@ namespace physics
namespace box2d
{
MouseJoint * luax_checkmousejoint(lua_State * L, int idx);
int _wrap_MouseJoint_setTarget(lua_State * L);
int _wrap_MouseJoint_getTarget(lua_State * L);
int _wrap_MouseJoint_setMaxForce(lua_State * L);
int _wrap_MouseJoint_getMaxForce(lua_State * L);
int wrap_MouseJoint_open(lua_State * L);
int w_MouseJoint_setTarget(lua_State * L);
int w_MouseJoint_getTarget(lua_State * L);
int w_MouseJoint_setMaxForce(lua_State * L);
int w_MouseJoint_getMaxForce(lua_State * L);
int luaopen_mousejoint(lua_State * L);
} // box2d
} // physics
+87 -94
View File
@@ -29,14 +29,14 @@ namespace box2d
{
static Physics * instance = 0;
int _wrap_newWorld(lua_State * L)
int w_newWorld(lua_State * L)
{
if(lua_gettop(L) == 2)
{
float x = (float)luaL_checknumber(L, 1);
float y = (float)luaL_checknumber(L, 2);
World * w = instance->newWorld(x, y);
luax_newtype(L, "World", LOVE_PHYSICS_WORLD_BITS, (void*)w);
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
return 1;
}
else if(lua_gettop(L) == 6)
@@ -49,35 +49,35 @@ namespace box2d
float gy = (float)luaL_checknumber(L, 6);
bool sleep = luax_toboolean(L, 7);
World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep);
luax_newtype(L, "World", LOVE_PHYSICS_WORLD_BITS, (void*)w);
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
return 1;
}
else
return luaL_error(L, "Incorrect number of parameters");
}
int _wrap_newBody(lua_State * L)
int w_newBody(lua_State * L)
{
World * world = luax_checktype<World>(L, 1, "World", LOVE_PHYSICS_WORLD_BITS);
World * world = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
float x = (float)luaL_optnumber(L, 2, 0.0);
float y = (float)luaL_optnumber(L, 3, 0.0);
float m = (float)luaL_optnumber(L, 4, 1.0);
float i = (float)luaL_optnumber(L, 5, 1.0);
Body * body = instance->newBody(world, x, y, m, i);
luax_newtype(L, "Body", LOVE_PHYSICS_BODY_BITS, (void*)body);
luax_newtype(L, "Body", PHYSICS_BODY_T, (void*)body);
return 1;
}
int _wrap_newCircleShape(lua_State * L)
int w_newCircleShape(lua_State * L)
{
Body * body = luax_checktype<Body>(L, 1, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
int top = lua_gettop(L);
if(top == 2)
{
float radius = (float)luaL_checknumber(L, 2);
CircleShape * shape = instance->newCircleShape(body, radius);
luax_newtype(L, "CircleShape", LOVE_PHYSICS_CIRCLE_SHAPE_BITS, (void*)shape);
luax_newtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, (void*)shape);
return 1;
}
else if(top == 4)
@@ -86,16 +86,16 @@ namespace box2d
float y = (float)luaL_checknumber(L, 3);
float radius = (float)luaL_checknumber(L, 4);
CircleShape * shape = instance->newCircleShape(body, x, y, radius);
luax_newtype(L, "CircleShape", LOVE_PHYSICS_CIRCLE_SHAPE_BITS, (void*)shape);
luax_newtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, (void*)shape);
return 1;
}
else
return luaL_error(L, "Incorrect number of parameters");
}
int _wrap_newRectangleShape(lua_State * L)
int w_newRectangleShape(lua_State * L)
{
Body * body = luax_checktype<Body>(L, 1, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
int top = lua_gettop(L);
if(top == 3)
@@ -103,7 +103,7 @@ namespace box2d
float w = (float)luaL_checknumber(L, 2);
float h = (float)luaL_checknumber(L, 3);
PolygonShape * shape = instance->newRectangleShape(body, w, h);
luax_newtype(L, "PolygonShape", LOVE_PHYSICS_POLYGON_SHAPE_BITS, (void*)shape);
luax_newtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, (void*)shape);
return 1;
}
else if(top == 5 || top == 6)
@@ -114,69 +114,69 @@ namespace box2d
float h = (float)luaL_checknumber(L, 5);
float angle = (float)luaL_optnumber(L, 6, 0);
PolygonShape * shape = instance->newRectangleShape(body, x, y, w, h, angle);
luax_newtype(L, "PolygonShape", LOVE_PHYSICS_POLYGON_SHAPE_BITS, (void*)shape);
luax_newtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, (void*)shape);
return 1;
}
else
return luaL_error(L, "Incorrect number of parameters");
}
int _wrap_newPolygonShape(lua_State * L)
int w_newPolygonShape(lua_State * L)
{
return instance->newPolygonShape(L);
}
int _wrap_newDistanceJoint(lua_State * L)
int w_newDistanceJoint(lua_State * L)
{
Body * body1 = luax_checktype<Body>(L, 1, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body2 = luax_checktype<Body>(L, 2, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body * body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
float x1 = (float)luaL_checknumber(L, 3);
float y1 = (float)luaL_checknumber(L, 4);
float x2 = (float)luaL_checknumber(L, 5);
float y2 = (float)luaL_checknumber(L, 6);
DistanceJoint * j = instance->newDistanceJoint(body1, body2, x1, y1, x2, y2);
luax_newtype(L, "DistanceJoint", LOVE_PHYSICS_DISTANCE_JOINT_BITS, (void*)j);
luax_newtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, (void*)j);
return 1;
}
int _wrap_newMouseJoint(lua_State * L)
int w_newMouseJoint(lua_State * L)
{
Body * body = luax_checktype<Body>(L, 1, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
MouseJoint * j = instance->newMouseJoint(body, x, y);
luax_newtype(L, "MouseJoint", LOVE_PHYSICS_MOUSE_JOINT_BITS, (void*)j);
luax_newtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, (void*)j);
return 1;
}
int _wrap_newRevoluteJoint(lua_State * L)
int w_newRevoluteJoint(lua_State * L)
{
Body * body1 = luax_checktype<Body>(L, 1, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body2 = luax_checktype<Body>(L, 2, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body * body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
float x = (float)luaL_checknumber(L, 3);
float y = (float)luaL_checknumber(L, 4);
RevoluteJoint * j = instance->newRevoluteJoint(body1, body2, x, y);
luax_newtype(L, "RevoluteJoint", LOVE_PHYSICS_REVOLUTE_JOINT_BITS, (void*)j);
luax_newtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, (void*)j);
return 1;
}
int _wrap_newPrismaticJoint(lua_State * L)
int w_newPrismaticJoint(lua_State * L)
{
Body * body1 = luax_checktype<Body>(L, 1, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body2 = luax_checktype<Body>(L, 2, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body * body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
float x = (float)luaL_checknumber(L, 3);
float y = (float)luaL_checknumber(L, 4);
float ax = (float)luaL_checknumber(L, 5);
float ay = (float)luaL_checknumber(L, 6);
PrismaticJoint * j = instance->newPrismaticJoint(body1, body2, x, y, ax, ay);
luax_newtype(L, "PrismaticJoint", LOVE_PHYSICS_PRISMATIC_JOINT_BITS, (void*)j);
luax_newtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, (void*)j);
return 1;
}
int _wrap_newPulleyJoint(lua_State * L)
int w_newPulleyJoint(lua_State * L)
{
Body * body1 = luax_checktype<Body>(L, 1, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body2 = luax_checktype<Body>(L, 2, "Body", LOVE_PHYSICS_BODY_BITS);
Body * body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body * body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
float gx1 = (float)luaL_checknumber(L, 3);
float gy1 = (float)luaL_checknumber(L, 4);
float gx2 = (float)luaL_checknumber(L, 5);
@@ -188,72 +188,70 @@ namespace box2d
float ratio = (float)luaL_optnumber(L, 11, 1.0);
PulleyJoint * j = instance->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio);
luax_newtype(L, "PulleyJoint", LOVE_PHYSICS_PULLEY_JOINT_BITS, (void*)j);
luax_newtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, (void*)j);
return 1;
}
int _wrap_newGearJoint(lua_State * L)
int w_newGearJoint(lua_State * L)
{
Joint * joint1 = luax_checktype<Joint>(L, 1, "Joint", LOVE_PHYSICS_JOINT_BITS);
Joint * joint2 = luax_checktype<Joint>(L, 2, "Joint", LOVE_PHYSICS_JOINT_BITS);
Joint * joint1 = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
Joint * joint2 = luax_checktype<Joint>(L, 2, "Joint", PHYSICS_JOINT_T);
float ratio = (float)luaL_optnumber(L, 3, 1.0);
GearJoint * j = instance->newGearJoint(joint1, joint2, ratio);
luax_newtype(L, "GearJoint", LOVE_PHYSICS_GEAR_JOINT_BITS, (void*)j);
luax_newtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, (void*)j);
return 1;
}
// List of functions to wrap.
static const luaL_Reg wrap_Physics_functions[] = {
{ "newWorld", _wrap_newWorld },
{ "newBody", _wrap_newBody },
{ "newCircleShape", _wrap_newCircleShape },
{ "newRectangleShape", _wrap_newRectangleShape },
{ "newPolygonShape", _wrap_newPolygonShape },
{ "newDistanceJoint", _wrap_newDistanceJoint },
{ "newMouseJoint", _wrap_newMouseJoint },
{ "newRevoluteJoint", _wrap_newRevoluteJoint },
{ "newPrismaticJoint", _wrap_newPrismaticJoint },
{ "newPulleyJoint", _wrap_newPulleyJoint },
{ "newGearJoint", _wrap_newGearJoint },
{ 0, 0 },
};
static const lua_CFunction wrap_Physics_types[] = {
wrap_World_open,
wrap_Contact_open,
wrap_Body_open,
wrap_Shape_open,
wrap_CircleShape_open,
wrap_PolygonShape_open,
wrap_Joint_open,
wrap_MouseJoint_open,
wrap_DistanceJoint_open,
wrap_PrismaticJoint_open,
wrap_RevoluteJoint_open,
wrap_PulleyJoint_open,
wrap_GearJoint_open,
0
};
// List of constants.
static const LuaConstant wrap_Physics_constants[] = {
{ "shape_circle", Shape::SHAPE_CIRCLE },
{ "shape_polygon", Shape::SHAPE_POLYGON },
{ "joint_distance", Joint::JOINT_DISTANCE },
{ "joint_revolute", Joint::JOINT_REVOLUTE },
{ "joint_prismatic", Joint::JOINT_PRISMATIC },
{ "joint_mouse", Joint::JOINT_MOUSE },
{ "joint_pulley", Joint::JOINT_PULLEY },
{ "joint_gear", Joint::JOINT_GEAR },
{ 0, 0 }
};
int wrap_Physics_open(lua_State * L)
int luaopen_love_physics(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "newWorld", w_newWorld },
{ "newBody", w_newBody },
{ "newCircleShape", w_newCircleShape },
{ "newRectangleShape", w_newRectangleShape },
{ "newPolygonShape", w_newPolygonShape },
{ "newDistanceJoint", w_newDistanceJoint },
{ "newMouseJoint", w_newMouseJoint },
{ "newRevoluteJoint", w_newRevoluteJoint },
{ "newPrismaticJoint", w_newPrismaticJoint },
{ "newPulleyJoint", w_newPulleyJoint },
{ "newGearJoint", w_newGearJoint },
{ 0, 0 },
};
static const lua_CFunction types[] = {
luaopen_world,
luaopen_contact,
luaopen_body,
luaopen_shape,
luaopen_circleshape,
luaopen_polygonshape,
luaopen_joint,
luaopen_mousejoint,
luaopen_distancejoint,
luaopen_prismaticjoint,
luaopen_revolutejoint,
luaopen_pulleyjoint,
luaopen_gearjoint,
0
};
// List of constants.
static const LuaConstant constants[] = {
{ "shape_circle", Shape::SHAPE_CIRCLE },
{ "shape_polygon", Shape::SHAPE_POLYGON },
{ "joint_distance", Joint::JOINT_DISTANCE },
{ "joint_revolute", Joint::JOINT_REVOLUTE },
{ "joint_prismatic", Joint::JOINT_PRISMATIC },
{ "joint_mouse", Joint::JOINT_MOUSE },
{ "joint_pulley", Joint::JOINT_PULLEY },
{ "joint_gear", Joint::JOINT_GEAR },
{ 0, 0 }
};
if(instance == 0)
{
try
@@ -266,14 +264,9 @@ namespace box2d
}
}
return luax_register_module(L, wrap_Physics_functions, wrap_Physics_types, wrap_Physics_constants, "physics");
return luax_register_module(L, functions, types, constants, "physics");
}
} // box2d
} // physics
} // love
int luaopen_love_physics(lua_State * L)
{
return love::physics::box2d::wrap_Physics_open(L);
}
+12 -14
View File
@@ -44,23 +44,21 @@ namespace physics
{
namespace box2d
{
int _wrap_newWorld(lua_State * L);
int _wrap_newBody(lua_State * L);
int _wrap_newCircleShape(lua_State * L);
int _wrap_newRectangleShape(lua_State * L);
int _wrap_newPolygonShape(lua_State * L);;
int _wrap_newDistanceJoint(lua_State * L);
int _wrap_newMouseJoint(lua_State * L);
int _wrap_newRevoluteJoint(lua_State * L);
int _wrap_newPrismaticJoint(lua_State * L);
int _wrap_newPulleyJoint(lua_State * L);
int _wrap_newGearJoint(lua_State * L);
int wrap_Physics_open(lua_State * L);
int w_newWorld(lua_State * L);
int w_newBody(lua_State * L);
int w_newCircleShape(lua_State * L);
int w_newRectangleShape(lua_State * L);
int w_newPolygonShape(lua_State * L);;
int w_newDistanceJoint(lua_State * L);
int w_newMouseJoint(lua_State * L);
int w_newRevoluteJoint(lua_State * L);
int w_newPrismaticJoint(lua_State * L);
int w_newPulleyJoint(lua_State * L);
int w_newGearJoint(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_physics(lua_State * L);
} // box2d
} // physics
} // love
extern "C" LOVE_EXPORT int luaopen_love_physics(lua_State * L);
#endif // LOVE_PHYSICS_BOX2D_WRAP_PHYSICS_H
+25 -27
View File
@@ -28,42 +28,40 @@ namespace box2d
{
PolygonShape * luax_checkpolygonshape(lua_State * L, int idx)
{
return luax_checktype<PolygonShape>(L, idx, "PolygonShape", LOVE_PHYSICS_POLYGON_SHAPE_BITS);
return luax_checktype<PolygonShape>(L, idx, "PolygonShape", PHYSICS_POLYGON_SHAPE_T);
}
int _wrap_PolygonShape_getPoints(lua_State * L)
int w_PolygonShape_getPoints(lua_State * L)
{
PolygonShape * t = luax_checkpolygonshape(L, 1);
lua_remove(L, 1);
return t->getPoints(L);
}
static const luaL_Reg wrap_PolygonShape_functions[] = {
{ "getPoints", _wrap_PolygonShape_getPoints },
// From Shape.
{ "getType", _wrap_Shape_getType },
{ "setFriction", _wrap_Shape_setFriction },
{ "setRestitution", _wrap_Shape_setRestitution },
{ "setDensity", _wrap_Shape_setDensity },
{ "setSensor", _wrap_Shape_setSensor },
{ "getFriction", _wrap_Shape_getFriction },
{ "getRestituion", _wrap_Shape_getRestituion },
{ "getDensity", _wrap_Shape_getDensity },
{ "isSensor", _wrap_Shape_isSensor },
{ "testPoint", _wrap_Shape_testPoint },
{ "testSegment", _wrap_Shape_testSegment },
{ "setFilterData", _wrap_Shape_setFilterData },
{ "getFilterData", _wrap_Shape_getFilterData },
{ "setData", _wrap_Shape_setData },
{ "getData", _wrap_Shape_getData },
{ "getBoundingBox", _wrap_Shape_getBoundingBox },
{ 0, 0 }
};
int wrap_PolygonShape_open(lua_State * L)
int luaopen_polygonshape(lua_State * L)
{
luax_register_type(L, "PolygonShape", wrap_PolygonShape_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getPoints", w_PolygonShape_getPoints },
// From Shape.
{ "getType", w_Shape_getType },
{ "setFriction", w_Shape_setFriction },
{ "setRestitution", w_Shape_setRestitution },
{ "setDensity", w_Shape_setDensity },
{ "setSensor", w_Shape_setSensor },
{ "getFriction", w_Shape_getFriction },
{ "getRestituion", w_Shape_getRestituion },
{ "getDensity", w_Shape_getDensity },
{ "isSensor", w_Shape_isSensor },
{ "testPoint", w_Shape_testPoint },
{ "testSegment", w_Shape_testSegment },
{ "setFilterData", w_Shape_setFilterData },
{ "getFilterData", w_Shape_getFilterData },
{ "setData", w_Shape_setData },
{ "getData", w_Shape_getData },
{ "getBoundingBox", w_Shape_getBoundingBox },
{ 0, 0 }
};
return luax_register_type(L, "PolygonShape", functions);
}
} // box2d
@@ -33,8 +33,8 @@ namespace physics
namespace box2d
{
PolygonShape * luax_checkpolygonshape(lua_State * L, int idx);
int _wrap_PolygonShape_getPoints(lua_State * L);
int wrap_PolygonShape_open(lua_State * L);
int w_PolygonShape_getPoints(lua_State * L);
int luaopen_polygonshape(lua_State * L);
} // box2d
} // physics
@@ -28,24 +28,24 @@ namespace box2d
{
PrismaticJoint * luax_checkprismaticjoint(lua_State * L, int idx)
{
return luax_checktype<PrismaticJoint>(L, idx, "PrismaticJoint", LOVE_PHYSICS_PRISMATIC_JOINT_BITS);
return luax_checktype<PrismaticJoint>(L, idx, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T);
}
int _wrap_PrismaticJoint_getJointTranslation(lua_State * L)
int w_PrismaticJoint_getJointTranslation(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
lua_pushnumber(L, t->getJointTranslation());
return 1;
}
int _wrap_PrismaticJoint_getJointSpeed(lua_State * L)
int w_PrismaticJoint_getJointSpeed(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
lua_pushnumber(L, t->getJointSpeed());
return 1;
}
int _wrap_PrismaticJoint_setMotorEnabled(lua_State * L)
int w_PrismaticJoint_setMotorEnabled(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
bool arg1 = luax_toboolean(L, 2);
@@ -53,14 +53,14 @@ namespace box2d
return 0;
}
int _wrap_PrismaticJoint_isMotorEnabled(lua_State * L)
int w_PrismaticJoint_isMotorEnabled(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
luax_pushboolean(L, t->isMotorEnabled());
return 1;
}
int _wrap_PrismaticJoint_setMaxMotorForce(lua_State * L)
int w_PrismaticJoint_setMaxMotorForce(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -68,14 +68,14 @@ namespace box2d
return 0;
}
int _wrap_PrismaticJoint_getMaxMotorForce(lua_State * L)
int w_PrismaticJoint_getMaxMotorForce(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
lua_pushnumber(L, t->getMaxMotorForce());
return 1;
}
int _wrap_PrismaticJoint_setMotorSpeed(lua_State * L)
int w_PrismaticJoint_setMotorSpeed(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -83,21 +83,21 @@ namespace box2d
return 0;
}
int _wrap_PrismaticJoint_getMotorSpeed(lua_State * L)
int w_PrismaticJoint_getMotorSpeed(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
lua_pushnumber(L, t->getMotorSpeed());
return 1;
}
int _wrap_PrismaticJoint_getMotorForce(lua_State * L)
int w_PrismaticJoint_getMotorForce(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
lua_pushnumber(L, t->getMotorForce());
return 1;
}
int _wrap_PrismaticJoint_setLimitsEnabled(lua_State * L)
int w_PrismaticJoint_setLimitsEnabled(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
bool arg1 = luax_toboolean(L, 2);
@@ -105,14 +105,14 @@ namespace box2d
return 0;
}
int _wrap_PrismaticJoint_isLimitsEnabled(lua_State * L)
int w_PrismaticJoint_isLimitsEnabled(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
luax_pushboolean(L, t->isLimitsEnabled());
return 1;
}
int _wrap_PrismaticJoint_setUpperLimit(lua_State * L)
int w_PrismaticJoint_setUpperLimit(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -120,7 +120,7 @@ namespace box2d
return 0;
}
int _wrap_PrismaticJoint_setLowerLimit(lua_State * L)
int w_PrismaticJoint_setLowerLimit(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -128,7 +128,7 @@ namespace box2d
return 0;
}
int _wrap_PrismaticJoint_setLimits(lua_State * L)
int w_PrismaticJoint_setLimits(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -137,59 +137,58 @@ namespace box2d
return 0;
}
int _wrap_PrismaticJoint_getLowerLimit(lua_State * L)
int w_PrismaticJoint_getLowerLimit(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
lua_pushnumber(L, t->getLowerLimit());
return 1;
}
int _wrap_PrismaticJoint_getUpperLimit(lua_State * L)
int w_PrismaticJoint_getUpperLimit(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
lua_pushnumber(L, t->getUpperLimit());
return 1;
}
int _wrap_PrismaticJoint_getLimits(lua_State * L)
int w_PrismaticJoint_getLimits(lua_State * L)
{
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
lua_remove(L, 1);
return t->getLimits(L);
}
static const luaL_Reg wrap_PrismaticJoint_functions[] = {
{ "getJointTranslation", _wrap_PrismaticJoint_getJointTranslation },
{ "getJointSpeed", _wrap_PrismaticJoint_getJointSpeed },
{ "setMotorEnabled", _wrap_PrismaticJoint_setMotorEnabled },
{ "isMotorEnabled", _wrap_PrismaticJoint_isMotorEnabled },
{ "setMaxMotorForce", _wrap_PrismaticJoint_setMaxMotorForce },
{ "getMaxMotorForce", _wrap_PrismaticJoint_getMaxMotorForce },
{ "setMotorSpeed", _wrap_PrismaticJoint_setMotorSpeed },
{ "getMotorSpeed", _wrap_PrismaticJoint_getMotorSpeed },
{ "getMotorForce", _wrap_PrismaticJoint_getMotorForce },
{ "setLimitsEnabled", _wrap_PrismaticJoint_setLimitsEnabled },
{ "isLimitsEnabled", _wrap_PrismaticJoint_isLimitsEnabled },
{ "setUpperLimit", _wrap_PrismaticJoint_setUpperLimit },
{ "setLowerLimit", _wrap_PrismaticJoint_setLowerLimit },
{ "setLimits", _wrap_PrismaticJoint_setLimits },
{ "getLowerLimit", _wrap_PrismaticJoint_getLowerLimit },
{ "getUpperLimit", _wrap_PrismaticJoint_getUpperLimit },
{ "getLimits", _wrap_PrismaticJoint_getLimits },
// From Joint.
{ "getType", _wrap_Joint_getType },
{ "getAnchors", _wrap_Joint_getAnchors },
{ "getReactionForce", _wrap_Joint_getReactionForce },
{ "getReactionTorque", _wrap_Joint_getReactionTorque },
{ "setCollideConnected", _wrap_Joint_setCollideConnected },
{ "getCollideConnected", _wrap_Joint_getCollideConnected },
{ 0, 0 }
};
int wrap_PrismaticJoint_open(lua_State * L)
int w_PrismaticJoint_open(lua_State * L)
{
luax_register_type(L, "PrismaticJoint", wrap_PrismaticJoint_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getJointTranslation", w_PrismaticJoint_getJointTranslation },
{ "getJointSpeed", w_PrismaticJoint_getJointSpeed },
{ "setMotorEnabled", w_PrismaticJoint_setMotorEnabled },
{ "isMotorEnabled", w_PrismaticJoint_isMotorEnabled },
{ "setMaxMotorForce", w_PrismaticJoint_setMaxMotorForce },
{ "getMaxMotorForce", w_PrismaticJoint_getMaxMotorForce },
{ "setMotorSpeed", w_PrismaticJoint_setMotorSpeed },
{ "getMotorSpeed", w_PrismaticJoint_getMotorSpeed },
{ "getMotorForce", w_PrismaticJoint_getMotorForce },
{ "setLimitsEnabled", w_PrismaticJoint_setLimitsEnabled },
{ "isLimitsEnabled", w_PrismaticJoint_isLimitsEnabled },
{ "setUpperLimit", w_PrismaticJoint_setUpperLimit },
{ "setLowerLimit", w_PrismaticJoint_setLowerLimit },
{ "setLimits", w_PrismaticJoint_setLimits },
{ "getLowerLimit", w_PrismaticJoint_getLowerLimit },
{ "getUpperLimit", w_PrismaticJoint_getUpperLimit },
{ "getLimits", w_PrismaticJoint_getLimits },
// From Joint.
{ "getType", w_Joint_getType },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
{ "setCollideConnected", w_Joint_setCollideConnected },
{ "getCollideConnected", w_Joint_getCollideConnected },
{ 0, 0 }
};
return luax_register_type(L, "PrismaticJoint", functions);
}
} // box2d
+18 -18
View File
@@ -33,24 +33,24 @@ namespace physics
namespace box2d
{
PrismaticJoint * luax_checkprismaticjoint(lua_State * L, int idx);
int _wrap_PrismaticJoint_getJointTranslation(lua_State * L);
int _wrap_PrismaticJoint_getJointSpeed(lua_State * L);
int _wrap_PrismaticJoint_setMotorEnabled(lua_State * L);
int _wrap_PrismaticJoint_isMotorEnabled(lua_State * L);
int _wrap_PrismaticJoint_setMaxMotorForce(lua_State * L);
int _wrap_PrismaticJoint_getMaxMotorForce(lua_State * L);
int _wrap_PrismaticJoint_setMotorSpeed(lua_State * L);
int _wrap_PrismaticJoint_getMotorSpeed(lua_State * L);
int _wrap_PrismaticJoint_getMotorForce(lua_State * L);
int _wrap_PrismaticJoint_setLimitsEnabled(lua_State * L);
int _wrap_PrismaticJoint_isLimitsEnabled(lua_State * L);
int _wrap_PrismaticJoint_setUpperLimit(lua_State * L);
int _wrap_PrismaticJoint_setLowerLimit(lua_State * L);
int _wrap_PrismaticJoint_setLimits(lua_State * L);
int _wrap_PrismaticJoint_getLowerLimit(lua_State * L);
int _wrap_PrismaticJoint_getUpperLimit(lua_State * L);
int _wrap_PrismaticJoint_getLimits(lua_State * L);
int wrap_PrismaticJoint_open(lua_State * L);
int w_PrismaticJoint_getJointTranslation(lua_State * L);
int w_PrismaticJoint_getJointSpeed(lua_State * L);
int w_PrismaticJoint_setMotorEnabled(lua_State * L);
int w_PrismaticJoint_isMotorEnabled(lua_State * L);
int w_PrismaticJoint_setMaxMotorForce(lua_State * L);
int w_PrismaticJoint_getMaxMotorForce(lua_State * L);
int w_PrismaticJoint_setMotorSpeed(lua_State * L);
int w_PrismaticJoint_getMotorSpeed(lua_State * L);
int w_PrismaticJoint_getMotorForce(lua_State * L);
int w_PrismaticJoint_setLimitsEnabled(lua_State * L);
int w_PrismaticJoint_isLimitsEnabled(lua_State * L);
int w_PrismaticJoint_setUpperLimit(lua_State * L);
int w_PrismaticJoint_setLowerLimit(lua_State * L);
int w_PrismaticJoint_setLimits(lua_State * L);
int w_PrismaticJoint_getLowerLimit(lua_State * L);
int w_PrismaticJoint_getUpperLimit(lua_State * L);
int w_PrismaticJoint_getLimits(lua_State * L);
int luaopen_prismaticjoint(lua_State * L);
} // box2d
} // physics
+31 -33
View File
@@ -28,17 +28,17 @@ namespace box2d
{
PulleyJoint * luax_checkpulleyjoint(lua_State * L, int idx)
{
return luax_checktype<PulleyJoint>(L, idx, "PulleyJoint", LOVE_PHYSICS_PULLEY_JOINT_BITS);
return luax_checktype<PulleyJoint>(L, idx, "PulleyJoint", PHYSICS_PULLEY_JOINT_T);
}
int _wrap_PulleyJoint_getGroundAnchors(lua_State * L)
int w_PulleyJoint_getGroundAnchors(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
lua_remove(L, 1);
return t->getGroundAnchors(L);
}
int _wrap_PulleyJoint_setMaxLengths(lua_State * L)
int w_PulleyJoint_setMaxLengths(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
float arg1 = (float)luaL_optnumber(L, 2, 0.0);
@@ -47,14 +47,14 @@ namespace box2d
return 0;
}
int _wrap_PulleyJoint_getMaxLengths(lua_State * L)
int w_PulleyJoint_getMaxLengths(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
lua_remove(L, 1);
return t->getMaxLengths(L);
}
int _wrap_PulleyJoint_setConstant(lua_State * L)
int w_PulleyJoint_setConstant(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -62,28 +62,28 @@ namespace box2d
return 0;
}
int _wrap_PulleyJoint_getConstant(lua_State * L)
int w_PulleyJoint_getConstant(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
lua_pushnumber(L, t->getConstant());
return 1;
}
int _wrap_PulleyJoint_getLength1(lua_State * L)
int w_PulleyJoint_getLength1(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
lua_pushnumber(L, t->getLength1());
return 1;
}
int _wrap_PulleyJoint_getLength2(lua_State * L)
int w_PulleyJoint_getLength2(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
lua_pushnumber(L, t->getLength2());
return 1;
}
int _wrap_PulleyJoint_setRatio(lua_State * L)
int w_PulleyJoint_setRatio(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -91,37 +91,35 @@ namespace box2d
return 0;
}
int _wrap_PulleyJoint_getRatio(lua_State * L)
int w_PulleyJoint_getRatio(lua_State * L)
{
PulleyJoint * t = luax_checkpulleyjoint(L, 1);
lua_pushnumber(L, t->getRatio());
return 1;
}
static const luaL_Reg wrap_PulleyJoint_functions[] = {
{ "getGroundAnchors", _wrap_PulleyJoint_getGroundAnchors },
{ "setMaxLengths", _wrap_PulleyJoint_setMaxLengths },
{ "getMaxLengths", _wrap_PulleyJoint_getMaxLengths },
{ "setConstant", _wrap_PulleyJoint_setConstant },
{ "getConstant", _wrap_PulleyJoint_getConstant },
{ "getLength1", _wrap_PulleyJoint_getLength1 },
{ "getLength2", _wrap_PulleyJoint_getLength2 },
{ "setRatio", _wrap_PulleyJoint_setRatio },
{ "getRatio", _wrap_PulleyJoint_getRatio },
// From Joint.
{ "getType", _wrap_Joint_getType },
{ "getAnchors", _wrap_Joint_getAnchors },
{ "getReactionForce", _wrap_Joint_getReactionForce },
{ "getReactionTorque", _wrap_Joint_getReactionTorque },
{ "setCollideConnected", _wrap_Joint_setCollideConnected },
{ "getCollideConnected", _wrap_Joint_getCollideConnected },
{ 0, 0 }
};
int wrap_PulleyJoint_open(lua_State * L)
int luaopen_pulleyjoint(lua_State * L)
{
luax_register_type(L, "PulleyJoint", wrap_PulleyJoint_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getGroundAnchors", w_PulleyJoint_getGroundAnchors },
{ "setMaxLengths", w_PulleyJoint_setMaxLengths },
{ "getMaxLengths", w_PulleyJoint_getMaxLengths },
{ "setConstant", w_PulleyJoint_setConstant },
{ "getConstant", w_PulleyJoint_getConstant },
{ "getLength1", w_PulleyJoint_getLength1 },
{ "getLength2", w_PulleyJoint_getLength2 },
{ "setRatio", w_PulleyJoint_setRatio },
{ "getRatio", w_PulleyJoint_getRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
{ "setCollideConnected", w_Joint_setCollideConnected },
{ "getCollideConnected", w_Joint_getCollideConnected },
{ 0, 0 }
};
return luax_register_type(L, "PulleyJoint", functions);
}
} // box2d
+10 -10
View File
@@ -33,16 +33,16 @@ namespace physics
namespace box2d
{
PulleyJoint * luax_checkpulleyjoint(lua_State * L, int idx);
int _wrap_PulleyJoint_getGroundAnchors(lua_State * L);
int _wrap_PulleyJoint_setMaxLengths(lua_State * L);
int _wrap_PulleyJoint_getMaxLengths(lua_State * L);
int _wrap_PulleyJoint_setConstant(lua_State * L);
int _wrap_PulleyJoint_getConstant(lua_State * L);
int _wrap_PulleyJoint_getLength1(lua_State * L);
int _wrap_PulleyJoint_getLength2(lua_State * L);
int _wrap_PulleyJoint_setRatio(lua_State * L);
int _wrap_PulleyJoint_getRatio(lua_State * L);
int wrap_PulleyJoint_open(lua_State * L);
int w_PulleyJoint_getGroundAnchors(lua_State * L);
int w_PulleyJoint_setMaxLengths(lua_State * L);
int w_PulleyJoint_getMaxLengths(lua_State * L);
int w_PulleyJoint_setConstant(lua_State * L);
int w_PulleyJoint_getConstant(lua_State * L);
int w_PulleyJoint_getLength1(lua_State * L);
int w_PulleyJoint_getLength2(lua_State * L);
int w_PulleyJoint_setRatio(lua_State * L);
int w_PulleyJoint_getRatio(lua_State * L);
int luaopen_pulleyjoint(lua_State * L);
} // box2d
} // physics
@@ -28,24 +28,24 @@ namespace box2d
{
RevoluteJoint * luax_checkrevolutejoint(lua_State * L, int idx)
{
return luax_checktype<RevoluteJoint>(L, idx, "RevoluteJoint", LOVE_PHYSICS_REVOLUTE_JOINT_BITS);
return luax_checktype<RevoluteJoint>(L, idx, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T);
}
int _wrap_RevoluteJoint_getJointAngle(lua_State * L)
int w_RevoluteJoint_getJointAngle(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
lua_pushnumber(L, t->getJointAngle());
return 1;
}
int _wrap_RevoluteJoint_getJointSpeed(lua_State * L)
int w_RevoluteJoint_getJointSpeed(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
lua_pushnumber(L, t->getJointSpeed());
return 1;
}
int _wrap_RevoluteJoint_setMotorEnabled(lua_State * L)
int w_RevoluteJoint_setMotorEnabled(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
bool arg1 = luax_toboolean(L, 2);
@@ -53,14 +53,14 @@ namespace box2d
return 0;
}
int _wrap_RevoluteJoint_isMotorEnabled(lua_State * L)
int w_RevoluteJoint_isMotorEnabled(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
luax_pushboolean(L, t->isMotorEnabled());
return 1;
}
int _wrap_RevoluteJoint_setMaxMotorTorque(lua_State * L)
int w_RevoluteJoint_setMaxMotorTorque(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -68,14 +68,14 @@ namespace box2d
return 0;
}
int _wrap_RevoluteJoint_getMaxMotorTorque(lua_State * L)
int w_RevoluteJoint_getMaxMotorTorque(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
lua_pushnumber(L, t->getMaxMotorTorque());
return 1;
}
int _wrap_RevoluteJoint_setMotorSpeed(lua_State * L)
int w_RevoluteJoint_setMotorSpeed(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -83,21 +83,21 @@ namespace box2d
return 0;
}
int _wrap_RevoluteJoint_getMotorSpeed(lua_State * L)
int w_RevoluteJoint_getMotorSpeed(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
lua_pushnumber(L, t->getMotorSpeed());
return 1;
}
int _wrap_RevoluteJoint_getMotorTorque(lua_State * L)
int w_RevoluteJoint_getMotorTorque(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
lua_pushnumber(L, t->getMotorTorque());
return 1;
}
int _wrap_RevoluteJoint_setLimitsEnabled(lua_State * L)
int w_RevoluteJoint_setLimitsEnabled(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
bool arg1 = luax_toboolean(L, 2);
@@ -105,14 +105,14 @@ namespace box2d
return 0;
}
int _wrap_RevoluteJoint_isLimitsEnabled(lua_State * L)
int w_RevoluteJoint_isLimitsEnabled(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
luax_pushboolean(L, t->isLimitsEnabled());
return 1;
}
int _wrap_RevoluteJoint_setUpperLimit(lua_State * L)
int w_RevoluteJoint_setUpperLimit(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -120,7 +120,7 @@ namespace box2d
return 0;
}
int _wrap_RevoluteJoint_setLowerLimit(lua_State * L)
int w_RevoluteJoint_setLowerLimit(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -128,7 +128,7 @@ namespace box2d
return 0;
}
int _wrap_RevoluteJoint_setLimits(lua_State * L)
int w_RevoluteJoint_setLimits(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -137,59 +137,57 @@ namespace box2d
return 0;
}
int _wrap_RevoluteJoint_getLowerLimit(lua_State * L)
int w_RevoluteJoint_getLowerLimit(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
lua_pushnumber(L, t->getLowerLimit());
return 1;
}
int _wrap_RevoluteJoint_getUpperLimit(lua_State * L)
int w_RevoluteJoint_getUpperLimit(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
lua_pushnumber(L, t->getUpperLimit());
return 1;
}
int _wrap_RevoluteJoint_getLimits(lua_State * L)
int w_RevoluteJoint_getLimits(lua_State * L)
{
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
lua_remove(L, 1);
return t->getLimits(L);
}
static const luaL_Reg wrap_RevoluteJoint_functions[] = {
{ "getJointAngle", _wrap_RevoluteJoint_getJointAngle },
{ "getJointSpeed", _wrap_RevoluteJoint_getJointSpeed },
{ "setMotorEnabled", _wrap_RevoluteJoint_setMotorEnabled },
{ "isMotorEnabled", _wrap_RevoluteJoint_isMotorEnabled },
{ "setMaxMotorTorque", _wrap_RevoluteJoint_setMaxMotorTorque },
{ "getMaxMotorTorque", _wrap_RevoluteJoint_getMaxMotorTorque },
{ "setMotorSpeed", _wrap_RevoluteJoint_setMotorSpeed },
{ "getMotorSpeed", _wrap_RevoluteJoint_getMotorSpeed },
{ "getMotorTorque", _wrap_RevoluteJoint_getMotorTorque },
{ "setLimitsEnabled", _wrap_RevoluteJoint_setLimitsEnabled },
{ "isLimitsEnabled", _wrap_RevoluteJoint_isLimitsEnabled },
{ "setUpperLimit", _wrap_RevoluteJoint_setUpperLimit },
{ "setLowerLimit", _wrap_RevoluteJoint_setLowerLimit },
{ "setLimits", _wrap_RevoluteJoint_setLimits },
{ "getLowerLimit", _wrap_RevoluteJoint_getLowerLimit },
{ "getUpperLimit", _wrap_RevoluteJoint_getUpperLimit },
{ "getLimits", _wrap_RevoluteJoint_getLimits },
// From Joint.
{ "getType", _wrap_Joint_getType },
{ "getAnchors", _wrap_Joint_getAnchors },
{ "getReactionForce", _wrap_Joint_getReactionForce },
{ "getReactionTorque", _wrap_Joint_getReactionTorque },
{ "setCollideConnected", _wrap_Joint_setCollideConnected },
{ "getCollideConnected", _wrap_Joint_getCollideConnected },
{ 0, 0 }
};
int wrap_RevoluteJoint_open(lua_State * L)
int luaopen_revolutejoint(lua_State * L)
{
luax_register_type(L, "RevoluteJoint", wrap_RevoluteJoint_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getJointAngle", w_RevoluteJoint_getJointAngle },
{ "getJointSpeed", w_RevoluteJoint_getJointSpeed },
{ "setMotorEnabled", w_RevoluteJoint_setMotorEnabled },
{ "isMotorEnabled", w_RevoluteJoint_isMotorEnabled },
{ "setMaxMotorTorque", w_RevoluteJoint_setMaxMotorTorque },
{ "getMaxMotorTorque", w_RevoluteJoint_getMaxMotorTorque },
{ "setMotorSpeed", w_RevoluteJoint_setMotorSpeed },
{ "getMotorSpeed", w_RevoluteJoint_getMotorSpeed },
{ "getMotorTorque", w_RevoluteJoint_getMotorTorque },
{ "setLimitsEnabled", w_RevoluteJoint_setLimitsEnabled },
{ "isLimitsEnabled", w_RevoluteJoint_isLimitsEnabled },
{ "setUpperLimit", w_RevoluteJoint_setUpperLimit },
{ "setLowerLimit", w_RevoluteJoint_setLowerLimit },
{ "setLimits", w_RevoluteJoint_setLimits },
{ "getLowerLimit", w_RevoluteJoint_getLowerLimit },
{ "getUpperLimit", w_RevoluteJoint_getUpperLimit },
{ "getLimits", w_RevoluteJoint_getLimits },
// From Joint.
{ "getType", w_Joint_getType },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
{ "setCollideConnected", w_Joint_setCollideConnected },
{ "getCollideConnected", w_Joint_getCollideConnected },
{ 0, 0 }
};
return luax_register_type(L, "RevoluteJoint", functions);
}
} // box2d
+18 -18
View File
@@ -33,24 +33,24 @@ namespace physics
namespace box2d
{
RevoluteJoint * luax_checkrevolutejoint(lua_State * L, int idx);
int _wrap_RevoluteJoint_getJointAngle(lua_State * L);
int _wrap_RevoluteJoint_getJointSpeed(lua_State * L);
int _wrap_RevoluteJoint_setMotorEnabled(lua_State * L);
int _wrap_RevoluteJoint_isMotorEnabled(lua_State * L);
int _wrap_RevoluteJoint_setMaxMotorTorque(lua_State * L);
int _wrap_RevoluteJoint_getMaxMotorTorque(lua_State * L);
int _wrap_RevoluteJoint_setMotorSpeed(lua_State * L);
int _wrap_RevoluteJoint_getMotorSpeed(lua_State * L);
int _wrap_RevoluteJoint_getMotorTorque(lua_State * L);
int _wrap_RevoluteJoint_setLimitsEnabled(lua_State * L);
int _wrap_RevoluteJoint_isLimitsEnabled(lua_State * L);
int _wrap_RevoluteJoint_setUpperLimit(lua_State * L);
int _wrap_RevoluteJoint_setLowerLimit(lua_State * L);
int _wrap_RevoluteJoint_setLimits(lua_State * L);
int _wrap_RevoluteJoint_getLowerLimit(lua_State * L);
int _wrap_RevoluteJoint_getUpperLimit(lua_State * L);
int _wrap_RevoluteJoint_getLimits(lua_State * L);
int wrap_RevoluteJoint_open(lua_State * L);
int w_RevoluteJoint_getJointAngle(lua_State * L);
int w_RevoluteJoint_getJointSpeed(lua_State * L);
int w_RevoluteJoint_setMotorEnabled(lua_State * L);
int w_RevoluteJoint_isMotorEnabled(lua_State * L);
int w_RevoluteJoint_setMaxMotorTorque(lua_State * L);
int w_RevoluteJoint_getMaxMotorTorque(lua_State * L);
int w_RevoluteJoint_setMotorSpeed(lua_State * L);
int w_RevoluteJoint_getMotorSpeed(lua_State * L);
int w_RevoluteJoint_getMotorTorque(lua_State * L);
int w_RevoluteJoint_setLimitsEnabled(lua_State * L);
int w_RevoluteJoint_isLimitsEnabled(lua_State * L);
int w_RevoluteJoint_setUpperLimit(lua_State * L);
int w_RevoluteJoint_setLowerLimit(lua_State * L);
int w_RevoluteJoint_setLimits(lua_State * L);
int w_RevoluteJoint_getLowerLimit(lua_State * L);
int w_RevoluteJoint_getUpperLimit(lua_State * L);
int w_RevoluteJoint_getLimits(lua_State * L);
int luaopen_revolutejoint(lua_State * L);
} // box2d
} // physics
+41 -42
View File
@@ -28,17 +28,17 @@ namespace box2d
{
Shape * luax_checkshape(lua_State * L, int idx)
{
return luax_checktype<Shape>(L, idx, "Shape", LOVE_PHYSICS_SHAPE_BITS);
return luax_checktype<Shape>(L, idx, "Shape", PHYSICS_SHAPE_T);
}
int _wrap_Shape_getType(lua_State * L)
int w_Shape_getType(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
lua_pushinteger(L, t->getType());
return 1;
}
int _wrap_Shape_setFriction(lua_State * L)
int w_Shape_setFriction(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -46,7 +46,7 @@ namespace box2d
return 0;
}
int _wrap_Shape_setRestitution(lua_State * L)
int w_Shape_setRestitution(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -54,7 +54,7 @@ namespace box2d
return 0;
}
int _wrap_Shape_setDensity(lua_State * L)
int w_Shape_setDensity(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -62,7 +62,7 @@ namespace box2d
return 0;
}
int _wrap_Shape_setSensor(lua_State * L)
int w_Shape_setSensor(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
bool arg1 = luax_toboolean(L, 2);
@@ -70,45 +70,45 @@ namespace box2d
return 0;
}
int _wrap_Shape_getFriction(lua_State * L)
int w_Shape_getFriction(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
lua_pushnumber(L, t->getFriction());
return 1;
}
int _wrap_Shape_getRestituion(lua_State * L)
int w_Shape_getRestituion(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
lua_pushnumber(L, t->getRestituion());
return 1;
}
int _wrap_Shape_getDensity(lua_State * L)
int w_Shape_getDensity(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
lua_pushnumber(L, t->getDensity());
return 1;
}
int _wrap_Shape_isSensor(lua_State * L)
int w_Shape_isSensor(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
luax_pushboolean(L, t->isSensor());
return 1;
}
int _wrap_Shape_getBody(lua_State * L)
int w_Shape_getBody(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
Body * body = t->getBody();
if(body == 0)
return 0;
luax_newtype(L, "Body", LOVE_PHYSICS_BODY_BITS, (void*)body);
luax_newtype(L, "Body", PHYSICS_BODY_T, (void*)body);
return 1;
}
int _wrap_Shape_testPoint(lua_State * L)
int w_Shape_testPoint(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
float x = (float)luaL_checknumber(L, 2);
@@ -117,13 +117,13 @@ namespace box2d
return 1;
}
int _wrap_Shape_testSegment(lua_State * L)
int w_Shape_testSegment(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
return t->testSegment(L);
}
int _wrap_Shape_setFilterData(lua_State * L)
int w_Shape_setFilterData(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
int v[3];
@@ -134,7 +134,7 @@ namespace box2d
return 0;
}
int _wrap_Shape_getFilterData(lua_State * L)
int w_Shape_getFilterData(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
int v[3];
@@ -145,51 +145,50 @@ namespace box2d
return 3;
}
int _wrap_Shape_setData(lua_State * L)
int w_Shape_setData(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
lua_remove(L, 1);
return t->setData(L);
}
int _wrap_Shape_getData(lua_State * L)
int w_Shape_getData(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
lua_remove(L, 1);
return t->getData(L);
}
int _wrap_Shape_getBoundingBox(lua_State * L)
int w_Shape_getBoundingBox(lua_State * L)
{
Shape * t = luax_checkshape(L, 1);
lua_remove(L, 1);
return t->getBoundingBox(L);
}
static const luaL_Reg wrap_Shape_functions[] = {
{ "getType", _wrap_Shape_getType },
{ "setFriction", _wrap_Shape_setFriction },
{ "setRestitution", _wrap_Shape_setRestitution },
{ "setDensity", _wrap_Shape_setDensity },
{ "setSensor", _wrap_Shape_setSensor },
{ "getFriction", _wrap_Shape_getFriction },
{ "getRestituion", _wrap_Shape_getRestituion },
{ "getDensity", _wrap_Shape_getDensity },
{ "isSensor", _wrap_Shape_isSensor },
{ "testPoint", _wrap_Shape_testPoint },
{ "testSegment", _wrap_Shape_testSegment },
{ "setFilterData", _wrap_Shape_setFilterData },
{ "getFilterData", _wrap_Shape_getFilterData },
{ "setData", _wrap_Shape_setData },
{ "getData", _wrap_Shape_getData },
{ "getBoundingBox", _wrap_Shape_getBoundingBox },
{ 0, 0 }
};
int wrap_Shape_open(lua_State * L)
int w_Shape_open(lua_State * L)
{
luax_register_type(L, "Shape", wrap_Shape_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getType", w_Shape_getType },
{ "setFriction", w_Shape_setFriction },
{ "setRestitution", w_Shape_setRestitution },
{ "setDensity", w_Shape_setDensity },
{ "setSensor", w_Shape_setSensor },
{ "getFriction", w_Shape_getFriction },
{ "getRestituion", w_Shape_getRestituion },
{ "getDensity", w_Shape_getDensity },
{ "isSensor", w_Shape_isSensor },
{ "testPoint", w_Shape_testPoint },
{ "testSegment", w_Shape_testSegment },
{ "setFilterData", w_Shape_setFilterData },
{ "getFilterData", w_Shape_getFilterData },
{ "setData", w_Shape_setData },
{ "getData", w_Shape_getData },
{ "getBoundingBox", w_Shape_getBoundingBox },
{ 0, 0 }
};
return luax_register_type(L, "Shape", functions);
}
} // box2d
+18 -18
View File
@@ -32,24 +32,24 @@ namespace physics
namespace box2d
{
Shape * luax_checkshape(lua_State * L, int idx);
int _wrap_Shape_getType(lua_State * L);
int _wrap_Shape_setFriction(lua_State * L);
int _wrap_Shape_setRestitution(lua_State * L);
int _wrap_Shape_setDensity(lua_State * L);
int _wrap_Shape_setSensor(lua_State * L);
int _wrap_Shape_getFriction(lua_State * L);
int _wrap_Shape_getRestituion(lua_State * L);
int _wrap_Shape_getDensity(lua_State * L);
int _wrap_Shape_isSensor(lua_State * L);
int _wrap_Shape_getBody(lua_State * L);
int _wrap_Shape_testPoint(lua_State * L);
int _wrap_Shape_testSegment(lua_State * L);
int _wrap_Shape_setFilterData(lua_State * L);
int _wrap_Shape_getFilterData(lua_State * L);
int _wrap_Shape_setData(lua_State * L);
int _wrap_Shape_getData(lua_State * L);
int _wrap_Shape_getBoundingBox(lua_State * L);
int wrap_Shape_open(lua_State * L);
int w_Shape_getType(lua_State * L);
int w_Shape_setFriction(lua_State * L);
int w_Shape_setRestitution(lua_State * L);
int w_Shape_setDensity(lua_State * L);
int w_Shape_setSensor(lua_State * L);
int w_Shape_getFriction(lua_State * L);
int w_Shape_getRestituion(lua_State * L);
int w_Shape_getDensity(lua_State * L);
int w_Shape_isSensor(lua_State * L);
int w_Shape_getBody(lua_State * L);
int w_Shape_testPoint(lua_State * L);
int w_Shape_testSegment(lua_State * L);
int w_Shape_setFilterData(lua_State * L);
int w_Shape_getFilterData(lua_State * L);
int w_Shape_setData(lua_State * L);
int w_Shape_getData(lua_State * L);
int w_Shape_getBoundingBox(lua_State * L);
int luaopen_shape(lua_State * L);
} // box2d
} // physics
+29 -30
View File
@@ -29,10 +29,10 @@ namespace box2d
World * luax_checkworld(lua_State * L, int idx)
{
return luax_checktype<World>(L, idx, "World", LOVE_PHYSICS_WORLD_BITS);
return luax_checktype<World>(L, idx, "World", PHYSICS_WORLD_T);
}
int _wrap_World_update(lua_State * L)
int w_World_update(lua_State * L)
{
World * t = luax_checkworld(L, 1);
float dt = (float)luaL_checknumber(L, 2);
@@ -40,21 +40,21 @@ namespace box2d
return 0;
}
int _wrap_World_setCallback(lua_State * L)
int w_World_setCallback(lua_State * L)
{
World * t = luax_checkworld(L, 1);
lua_remove(L, 1);
return t->setCallback(L);
}
int _wrap_World_getCallback(lua_State * L)
int w_World_getCallback(lua_State * L)
{
World * t = luax_checkworld(L, 1);
lua_remove(L, 1);
return t->getCallback(L);
}
int _wrap_World_setGravity(lua_State * L)
int w_World_setGravity(lua_State * L)
{
World * t = luax_checkworld(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
@@ -63,14 +63,14 @@ namespace box2d
return 0;
}
int _wrap_World_getGravity(lua_State * L)
int w_World_getGravity(lua_State * L)
{
World * t = luax_checkworld(L, 1);
lua_remove(L, 1);
return t->getGravity(L);
}
int _wrap_World_setAllowSleep(lua_State * L)
int w_World_setAllowSleep(lua_State * L)
{
World * t = luax_checkworld(L, 1);
bool b = luax_toboolean(L, 2);
@@ -78,28 +78,28 @@ namespace box2d
return 0;
}
int _wrap_World_isAllowSleep(lua_State * L)
int w_World_isAllowSleep(lua_State * L)
{
World * t = luax_checkworld(L, 1);
luax_pushboolean(L, t->isAllowSleep());
return 1;
}
int _wrap_World_getBodyCount(lua_State * L)
int w_World_getBodyCount(lua_State * L)
{
World * t = luax_checkworld(L, 1);
lua_pushinteger(L, t->getBodyCount());
return 1;
}
int _wrap_World_getJointCount(lua_State * L)
int w_World_getJointCount(lua_State * L)
{
World * t = luax_checkworld(L, 1);
lua_pushinteger(L, t->getJointCount());
return 1;
}
int _wrap_World_setMeter(lua_State * L)
int w_World_setMeter(lua_State * L)
{
World * t = luax_checkworld(L, 1);
int arg1 = luaL_checkint(L, 2);
@@ -107,32 +107,31 @@ namespace box2d
return 0;
}
int _wrap_World_getMeter(lua_State * L)
int w_World_getMeter(lua_State * L)
{
World * t = luax_checkworld(L, 1);
lua_pushinteger(L, t->getMeter());
return 1;
}
static const luaL_Reg wrap_World_functions[] = {
{ "update", _wrap_World_update },
{ "setCallback", _wrap_World_setCallback },
{ "getCallback", _wrap_World_getCallback },
{ "setGravity", _wrap_World_setGravity },
{ "getGravity", _wrap_World_getGravity },
{ "setAllowSleep", _wrap_World_setAllowSleep },
{ "isAllowSleep", _wrap_World_isAllowSleep },
{ "getBodyCount", _wrap_World_getBodyCount },
{ "getJointCount", _wrap_World_getJointCount },
{ "setMeter", _wrap_World_setMeter },
{ "getMeter", _wrap_World_getMeter },
{ 0, 0 }
};
int wrap_World_open(lua_State * L)
int luaopen_world(lua_State * L)
{
luax_register_type(L, "World", wrap_World_functions);
return 0;
static const luaL_Reg functions[] = {
{ "update", w_World_update },
{ "setCallback", w_World_setCallback },
{ "getCallback", w_World_getCallback },
{ "setGravity", w_World_setGravity },
{ "getGravity", w_World_getGravity },
{ "setAllowSleep", w_World_setAllowSleep },
{ "isAllowSleep", w_World_isAllowSleep },
{ "getBodyCount", w_World_getBodyCount },
{ "getJointCount", w_World_getJointCount },
{ "setMeter", w_World_setMeter },
{ "getMeter", w_World_getMeter },
{ 0, 0 }
};
return luax_register_type(L, "World", functions);
}
} // box2d
+12 -12
View File
@@ -32,18 +32,18 @@ namespace physics
namespace box2d
{
World * luax_checkworld(lua_State * L, int idx);
int _wrap_World_update(lua_State * L);
int _wrap_World_setCallback(lua_State * L);
int _wrap_World_getCallback(lua_State * L);
int _wrap_World_setGravity(lua_State * L);
int _wrap_World_getGravity(lua_State * L);
int _wrap_World_setAllowSleep(lua_State * L);
int _wrap_World_isAllowSleep(lua_State * L);
int _wrap_World_getBodyCount(lua_State * L);
int _wrap_World_getJointCount(lua_State * L);
int _wrap_World_setMeter(lua_State * L);
int _wrap_World_getMeter(lua_State * L);
int wrap_World_open(lua_State * L);
int w_World_update(lua_State * L);
int w_World_setCallback(lua_State * L);
int w_World_getCallback(lua_State * L);
int w_World_setGravity(lua_State * L);
int w_World_getGravity(lua_State * L);
int w_World_setAllowSleep(lua_State * L);
int w_World_isAllowSleep(lua_State * L);
int w_World_getBodyCount(lua_State * L);
int w_World_getJointCount(lua_State * L);
int w_World_setMeter(lua_State * L);
int w_World_getMeter(lua_State * L);
int luaopen_world(lua_State * L);
} // box2d
} // physics
+1 -1
View File
@@ -55,7 +55,7 @@ namespace sound
/**
* 16 bit audio is the default.
**/
static const int DEFAULT_BITS = 16;
static const int DEFAULT_T = 16;
/**
* Creates a deep of itself. The sound stream can (and should) be
+13 -14
View File
@@ -26,41 +26,40 @@ namespace sound
{
Decoder * luax_checkdecoder(lua_State * L, int idx)
{
return luax_checktype<Decoder>(L, idx, "Decoder", LOVE_SOUND_DECODER_BITS);
return luax_checktype<Decoder>(L, idx, "Decoder", SOUND_DECODER_T);
}
int _wrap_Decoder_getChannels(lua_State * L)
int w_Decoder_getChannels(lua_State * L)
{
Decoder * t = luax_checkdecoder(L, 1);
lua_pushinteger(L, t->getChannels());
return 1;
}
int _wrap_Decoder_getBits(lua_State * L)
int w_Decoder_getBits(lua_State * L)
{
Decoder * t = luax_checkdecoder(L, 1);
lua_pushinteger(L, t->getBits());
return 1;
}
int _wrap_Decoder_getSampleRate(lua_State * L)
int w_Decoder_getSampleRate(lua_State * L)
{
Decoder * t = luax_checkdecoder(L, 1);
lua_pushinteger(L, t->getSampleRate());
return 1;
}
static const luaL_Reg wrap_Decoder_functions[] = {
{ "getChannels", _wrap_Decoder_getChannels },
{ "getBits", _wrap_Decoder_getBits },
{ "getSampleRate", _wrap_Decoder_getSampleRate },
{ 0, 0 }
};
int wrap_Decoder_open(lua_State * L)
int luaopen_decoder(lua_State * L)
{
luax_register_type(L, "Decoder", wrap_Decoder_functions);
return 0;
static const luaL_Reg functions[] = {
{ "getChannels", w_Decoder_getChannels },
{ "getBits", w_Decoder_getBits },
{ "getSampleRate", w_Decoder_getSampleRate },
{ 0, 0 }
};
return luax_register_type(L, "Decoder", functions);
}
} // sound
+4 -4
View File
@@ -30,10 +30,10 @@ namespace love
namespace sound
{
Decoder * luax_checkdecoder(lua_State * L, int idx);
int _wrap_Decoder_getChannels(lua_State * L);
int _wrap_Decoder_getBits(lua_State * L);
int _wrap_Decoder_getSampleRate(lua_State * L);
int wrap_Decoder_open(lua_State * L);
int w_Decoder_getChannels(lua_State * L);
int w_Decoder_getBits(lua_State * L);
int w_Decoder_getSampleRate(lua_State * L);
int luaopen_decoder(lua_State * L);
} // sound
} // love
+26 -30
View File
@@ -29,7 +29,7 @@ namespace sound
{
static Sound * instance = 0;
int _wrap_newSoundData(lua_State * L)
int w_newSoundData(lua_State * L)
{
SoundData * t = 0;
@@ -37,7 +37,7 @@ namespace sound
{
int samples = luaL_checkint(L, 1);
int sampleRate = luaL_optint(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
int bits = luaL_optint(L, 3, Decoder::DEFAULT_BITS);
int bits = luaL_optint(L, 3, Decoder::DEFAULT_T);
int channels = luaL_optint(L, 4, Decoder::DEFAULT_CHANNELS);
try
@@ -55,9 +55,9 @@ namespace sound
{
// Convert to Decoder, if necessary.
if(!luax_istype(L, 1, LOVE_SOUND_DECODER_BITS))
if(!luax_istype(L, 1, SOUND_DECODER_T))
{
_wrap_newDecoder(L);
w_newDecoder(L);
lua_replace(L, 1);
}
@@ -71,18 +71,18 @@ namespace sound
}
}
luax_newtype(L, "SoundData", LOVE_SOUND_SOUND_DATA_BITS, (void*)t);
luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)t);
return 1;
}
int _wrap_newDecoder(lua_State * L)
int w_newDecoder(lua_State * L)
{
// Convert to File, if necessary.
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
luax_convobj(L, 1, "filesystem", "newFile");
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
int bufferSize = luaL_optint(L, 2, Decoder::DEFAULT_BUFFER_SIZE);
int sampleRate = luaL_optint(L, 3, Decoder::DEFAULT_SAMPLE_RATE);
@@ -91,7 +91,7 @@ namespace sound
Decoder * t = instance->newDecoder(file, bufferSize, sampleRate);
if(t == 0)
return luaL_error(L, "Extension \"%s\" not supported.", file->getExtension().c_str());
luax_newtype(L, "Decoder", LOVE_SOUND_DECODER_BITS, (void*)t);
luax_newtype(L, "Decoder", SOUND_DECODER_T, (void*)t);
}
catch(love::Exception & e)
{
@@ -101,21 +101,22 @@ namespace sound
return 1;
}
// List of functions to wrap.
static const luaL_Reg wrap_Sound_functions[] = {
{ "newSoundData", _wrap_newSoundData },
{ "newDecoder", _wrap_newDecoder },
{ 0, 0 }
};
static const lua_CFunction wrap_Sound_types[] = {
wrap_SoundData_open,
wrap_Decoder_open,
0
};
int wrap_Sound_open(lua_State * L)
int luaopen_love_sound(lua_State * L)
{
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "newSoundData", w_newSoundData },
{ "newDecoder", w_newDecoder },
{ 0, 0 }
};
static const lua_CFunction types[] = {
luaopen_sounddata,
luaopen_decoder,
0
};
if(instance == 0)
{
try
@@ -128,15 +129,10 @@ namespace sound
}
}
luax_register_gc(L, "love.sound", instance);
luax_register_gc(L, instance);
return luax_register_module(L, wrap_Sound_functions, wrap_Sound_types, 0, "sound");
return luax_register_module(L, functions, types, 0, "sound");
}
} // sound
} // love
int luaopen_love_sound(lua_State * L)
{
return love::sound::wrap_Sound_open(L);
}
+3 -5
View File
@@ -31,13 +31,11 @@ namespace love
{
namespace sound
{
int _wrap_newSoundData(lua_State * L);
int _wrap_newDecoder(lua_State * L);
int wrap_Sound_open(lua_State * L);
int w_newSoundData(lua_State * L);
int w_newDecoder(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_sound(lua_State * L);
} // sound
} // love
#endif // LOVE_SOUND_WRAP_SOUND_H
extern "C" LOVE_EXPORT int luaopen_love_sound(lua_State * L);
+22 -21
View File
@@ -28,31 +28,31 @@ namespace sound
{
SoundData * luax_checksounddata(lua_State * L, int idx)
{
return luax_checktype<SoundData>(L, idx, "SoundData", LOVE_SOUND_SOUND_DATA_BITS);
return luax_checktype<SoundData>(L, idx, "SoundData", SOUND_SOUND_DATA_T);
}
int _wrap_SoundData_getChannels(lua_State * L)
int w_SoundData_getChannels(lua_State * L)
{
SoundData * t = luax_checksounddata(L, 1);
lua_pushinteger(L, t->getChannels());
return 1;
}
int _wrap_SoundData_getBits(lua_State * L)
int w_SoundData_getBits(lua_State * L)
{
SoundData * t = luax_checksounddata(L, 1);
lua_pushinteger(L, t->getBits());
return 1;
}
int _wrap_SoundData_getSampleRate(lua_State * L)
int w_SoundData_getSampleRate(lua_State * L)
{
SoundData * t = luax_checksounddata(L, 1);
lua_pushinteger(L, t->getSampleRate());
return 1;
}
int _wrap_SoundData_setSample(lua_State * L)
int w_SoundData_setSample(lua_State * L)
{
SoundData * sd = luax_checksounddata(L, 1);
int i = (int)lua_tointeger(L, 2);
@@ -61,7 +61,7 @@ namespace sound
return 0;
}
int _wrap_SoundData_getSample(lua_State * L)
int w_SoundData_getSample(lua_State * L)
{
SoundData * sd = luax_checksounddata(L, 1);
int i = (int)lua_tointeger(L, 2);
@@ -69,24 +69,25 @@ namespace sound
return 1;
}
static const luaL_Reg wrap_SoundData_functions[] = {
// Data
{ "getPointer", _wrap_Data_getPointer },
{ "getSize", _wrap_Data_getSize },
{ "getChannels", _wrap_SoundData_getChannels },
{ "getBits", _wrap_SoundData_getBits },
{ "getSampleRate", _wrap_SoundData_getSampleRate },
{ "setSample", _wrap_SoundData_setSample },
{ "getSample", _wrap_SoundData_getSample },
{ 0, 0 }
};
int wrap_SoundData_open(lua_State * L)
int luaopen_sounddata(lua_State * L)
{
luax_register_type(L, "SoundData", wrap_SoundData_functions);
return 0;
static const luaL_Reg functions[] = {
// Data
{ "getPointer", w_Data_getPointer },
{ "getSize", w_Data_getSize },
{ "getChannels", w_SoundData_getChannels },
{ "getBits", w_SoundData_getBits },
{ "getSampleRate", w_SoundData_getSampleRate },
{ "setSample", w_SoundData_setSample },
{ "getSample", w_SoundData_getSample },
{ 0, 0 }
};
return luax_register_type(L, "SoundData", functions);
}
} // sound

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