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
+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