mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Add Data:getFFIPointer. Similar to Data:getPointer but returns a cdata pointer directly (or nil if the FFI isn't available).
It should be preferred instead of Data:getPointer because the latter uses lightuserdata which can't store more all possible memory addresses on some new arm64 architectures, when LuaJIT is used.
This commit is contained in:
@@ -116,7 +116,9 @@ static const luaL_Reg w_CompressedImageData_functions[] =
|
||||
|
||||
extern "C" int luaopen_compressedimagedata(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, &CompressedImageData::type, data::w_Data_functions, w_CompressedImageData_functions, nullptr);
|
||||
int ret = luax_register_type(L, &CompressedImageData::type, data::w_Data_functions, w_CompressedImageData_functions, nullptr);
|
||||
love::data::luax_rundatawrapper(L, CompressedImageData::type);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // image
|
||||
|
||||
@@ -510,20 +510,8 @@ extern "C" int luaopen_imagedata(lua_State *L)
|
||||
|
||||
int ret = luax_register_type(L, &ImageData::type, data::w_Data_functions, w_ImageData_functions, nullptr);
|
||||
|
||||
luax_gettypemetatable(L, ImageData::type);
|
||||
|
||||
// Load and execute ImageData.lua, sending the metatable and the ffi
|
||||
// functions struct pointer as arguments.
|
||||
if (lua_istable(L, -1))
|
||||
{
|
||||
luaL_loadbuffer(L, imagedata_lua, sizeof(imagedata_lua), "ImageData.lua");
|
||||
lua_pushvalue(L, -2);
|
||||
lua_pushlightuserdata(L, &ffifuncs);
|
||||
lua_call(L, 2, 0);
|
||||
}
|
||||
|
||||
// Pop the metatable.
|
||||
lua_pop(L, 1);
|
||||
love::data::luax_rundatawrapper(L, ImageData::type);
|
||||
luax_runwrapper(L, imagedata_lua, sizeof(imagedata_lua), "ImageData.lua", ImageData::type, &ffifuncs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
--]]
|
||||
|
||||
local ImageData_mt, ffifuncspointer = ...
|
||||
local ImageData_mt, ffifuncspointer_str = ...
|
||||
local ImageData = ImageData_mt.__index
|
||||
|
||||
local tonumber, assert, error = tonumber, assert, error
|
||||
@@ -103,7 +103,7 @@ struct ImageData_Pixel_RG32F { float r, g; };
|
||||
struct ImageData_Pixel_RGBA32F { float r, g, b, a; };
|
||||
]])
|
||||
|
||||
local ffifuncs = ffi.cast("FFI_ImageData *", ffifuncspointer)
|
||||
local ffifuncs = ffi.cast("FFI_ImageData **", ffifuncspointer_str)[0]
|
||||
|
||||
local conversions = {
|
||||
r8 = {
|
||||
|
||||
Reference in New Issue
Block a user