Browse Source

Re-added Data:getPointer (can be used with LuaJIT's FFI)

Alex Szpakowski 12 years ago
parent
commit
c15fc4453b

+ 8 - 0
src/common/wrap_Data.cpp

@@ -35,6 +35,13 @@ int w_Data_getString(lua_State *L)
 	return 1;
 }
 
+int w_Data_getPointer(lua_State *L)
+{
+	Data *t = luax_checkdata(L, 1);
+	lua_pushlightuserdata(L, t->getData());
+	return 1;
+}
+
 int w_Data_getSize(lua_State *L)
 {
 	Data *t = luax_checkdata(L, 1);
@@ -45,6 +52,7 @@ int w_Data_getSize(lua_State *L)
 const luaL_Reg w_Data_functions[] =
 {
 	{ "getString", w_Data_getString },
+	{ "getPointer", w_Data_getPointer },
 	{ "getSize", w_Data_getSize },
 	{ 0, 0 }
 };

+ 1 - 0
src/common/wrap_Data.h

@@ -30,6 +30,7 @@ namespace love
 
 Data *luax_checkdata(lua_State *L, int idx);
 int w_Data_getString(lua_State *L);
+int w_Data_getPointer(lua_State *L);
 int w_Data_getSize(lua_State *L);
 int w_Data_open(lua_State *L);
 

+ 1 - 0
src/modules/filesystem/physfs/wrap_FileData.cpp

@@ -52,6 +52,7 @@ static const luaL_Reg w_FileData_functions[] =
 {
 	// Data
 	{ "getString", w_Data_getString },
+	{ "getPointer", w_Data_getPointer },
 	{ "getSize", w_Data_getSize },
 
 	{ "getFilename", w_FileData_getFilename },

+ 1 - 0
src/modules/font/wrap_GlyphData.cpp

@@ -125,6 +125,7 @@ static const luaL_Reg functions[] =
 {
 	// Data
 	{ "getString", w_Data_getString },
+	{ "getPointer", w_Data_getPointer },
 	{ "getSize", w_Data_getSize },
 
 	{ "getWidth", w_GlyphData_getWidth },

+ 1 - 0
src/modules/image/wrap_CompressedData.cpp

@@ -110,6 +110,7 @@ static const luaL_Reg functions[] =
 {
 	// Data
 	{ "getString", w_Data_getString },
+	{ "getPointer", w_Data_getPointer },
 	{ "getSize", w_Data_getSize },
 
 	{ "getWidth", w_CompressedData_getWidth },

+ 1 - 0
src/modules/image/wrap_ImageData.cpp

@@ -296,6 +296,7 @@ static const luaL_Reg functions[] =
 {
 	// Data
 	{ "getString", w_Data_getString },
+	{ "getPointer", w_Data_getPointer },
 	{ "getSize", w_Data_getSize },
 
 	{ "getWidth", w_ImageData_getWidth },

+ 1 - 0
src/modules/sound/wrap_SoundData.cpp

@@ -102,6 +102,7 @@ static const luaL_Reg functions[] =
 {
 	// Data
 	{ "getString", w_Data_getString },
+	{ "getPointer", w_Data_getPointer },
 	{ "getSize", w_Data_getSize },
 
 	{ "getChannels", w_SoundData_getChannels },