mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Cleaned up some StrongRef-related code.
This commit is contained in:
@@ -108,13 +108,13 @@ int w_File_isOpen(lua_State *L)
|
||||
int w_File_read(lua_State *L)
|
||||
{
|
||||
File *file = luax_checkfile(L, 1);
|
||||
Data *d = 0;
|
||||
StrongRef<Data> d = nullptr;
|
||||
|
||||
int64 size = (int64) luaL_optnumber(L, 2, (lua_Number) File::ALL);
|
||||
|
||||
try
|
||||
{
|
||||
d = file->read(size);
|
||||
d.set(file->read(size), Acquire::NORETAIN);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
@@ -123,7 +123,6 @@ int w_File_read(lua_State *L)
|
||||
|
||||
lua_pushlstring(L, (const char *) d->getData(), d->getSize());
|
||||
lua_pushnumber(L, d->getSize());
|
||||
d->release();
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -223,17 +223,16 @@ int w_newFileData(lua_State *L)
|
||||
{
|
||||
File *file = luax_checkfile(L, 1);
|
||||
|
||||
FileData *data = 0;
|
||||
StrongRef<FileData> data;
|
||||
try
|
||||
{
|
||||
data = file->read();
|
||||
data.set(file->read(), Acquire::NORETAIN);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
return luax_ioError(L, "%s", e.what());
|
||||
}
|
||||
luax_pushtype(L, FILESYSTEM_FILE_DATA_ID, data);
|
||||
data->release();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user