Merged default into minor

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2014-06-05 03:02:50 -03:00
68 changed files with 1439 additions and 524 deletions
+24 -26
View File
@@ -25,6 +25,8 @@
#include "font/wrap_GlyphData.h"
#include "font/wrap_Rasterizer.h"
#include "filesystem/wrap_Filesystem.h"
#include "TrueTypeRasterizer.h"
namespace love
@@ -34,31 +36,28 @@ namespace font
namespace freetype
{
static Font *instance = 0;
static Font *instance = nullptr;
int w_newRasterizer(lua_State *L)
{
// Convert to FileData, if necessary.
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T))
luax_convobj(L, 1, "filesystem", "newFileData");
Rasterizer *t = nullptr;
Rasterizer *t = 0;
EXCEPT_GUARD(
if (luax_istype(L, 1, IMAGE_IMAGE_DATA_T))
{
love::image::ImageData *d = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
const char *g = luaL_checkstring(L, 2);
std::string glyphs(g);
t = instance->newRasterizer(d, glyphs);
}
else if (luax_istype(L, 1, DATA_T))
{
Data *d = luax_checkdata(L, 1);
int size = luaL_checkint(L, 2);
t = instance->newRasterizer(d, size);
}
)
if (luax_istype(L, 1, IMAGE_IMAGE_DATA_T))
{
love::image::ImageData *d = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
const char *g = luaL_checkstring(L, 2);
std::string glyphs(g);
luax_catchexcept(L, [&](){ t = instance->newRasterizer(d, glyphs); });
}
else if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
{
love::filesystem::FileData *d = love::filesystem::luax_getfiledata(L, 1);
int size = luaL_checkint(L, 2);
luax_catchexcept(L,
[&]() { t = instance->newRasterizer(d, size); },
[&]() { d->release(); }
);
}
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
return 1;
@@ -67,14 +66,13 @@ int w_newRasterizer(lua_State *L)
int w_newGlyphData(lua_State *L)
{
Rasterizer *r = luax_checkrasterizer(L, 1);
GlyphData *t = 0;
GlyphData *t = nullptr;
// newGlyphData accepts a unicode character or a codepoint number.
if (lua_type(L, 2) == LUA_TSTRING)
{
std::string glyph = luax_checkstring(L, 2);
EXCEPT_GUARD(t = instance->newGlyphData(r, glyph);)
luax_catchexcept(L, [&](){ t = instance->newGlyphData(r, glyph); });
}
else
{
@@ -103,9 +101,9 @@ static const lua_CFunction types[] =
extern "C" int luaopen_love_font(lua_State *L)
{
if (instance == 0)
if (instance == nullptr)
{
EXCEPT_GUARD(instance = new Font();)
luax_catchexcept(L, [](){ instance = new Font(); });
}
else
instance->retain();
+1 -1
View File
@@ -64,7 +64,7 @@ int w_GlyphData_getGlyphString(lua_State *L)
{
GlyphData *t = luax_checkglyphdata(L, 1);
EXCEPT_GUARD(luax_pushstring(L, t->getGlyphString());)
luax_catchexcept(L, [&](){ luax_pushstring(L, t->getGlyphString()); });
return 1;
}
+4 -4
View File
@@ -72,7 +72,7 @@ int w_Rasterizer_getGlyphData(lua_State *L)
Rasterizer *t = luax_checkrasterizer(L, 1);
GlyphData *g = 0;
EXCEPT_GUARD(
luax_catchexcept(L, [&]() {
// getGlyphData accepts a unicode character or a codepoint number.
if (lua_type(L, 2) == LUA_TSTRING)
{
@@ -84,7 +84,7 @@ int w_Rasterizer_getGlyphData(lua_State *L)
uint32 glyph = (uint32) luaL_checknumber(L, 2);
g = t->getGlyphData(glyph);
}
)
});
luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, g);
return 1;
@@ -106,7 +106,7 @@ int w_Rasterizer_hasGlyphs(lua_State *L)
int count = lua_gettop(L) - 1;
count = count < 1 ? 1 : count;
EXCEPT_GUARD(
luax_catchexcept(L, [&]() {
for (int i = 2; i < count + 2; i++)
{
if (lua_type(L, i) == LUA_TSTRING)
@@ -117,7 +117,7 @@ int w_Rasterizer_hasGlyphs(lua_State *L)
if (!hasglyph)
break;
}
)
});
luax_pushboolean(L, hasglyph);
return 1;