Merge branch 'main' into 12.0-development

This commit is contained in:
Alex Szpakowski
2021-12-24 11:35:35 -04:00
37 changed files with 488 additions and 159 deletions
+38 -2
View File
@@ -29,6 +29,10 @@
#include "physfs/Filesystem.h"
#ifdef LOVE_ANDROID
#include "common/android.h"
#endif
// SDL
#include <SDL_loadso.h>
@@ -380,11 +384,22 @@ int w_newFileData(lua_State *L)
}
size_t length = 0;
const char *str = luaL_checklstring(L, 1, &length);
const void *ptr = nullptr;
if (luax_istype(L, 1, Data::type))
{
Data *data = data::luax_checkdata(L, 1);
ptr = data->getData();
length = data->getSize();
}
else if (lua_isstring(L, 1))
ptr = luaL_checklstring(L, 1, &length);
else
return luaL_argerror(L, 1, "string or Data expected");
const char *filename = luaL_checkstring(L, 2);
FileData *t = nullptr;
luax_catchexcept(L, [&](){ t = instance()->newFileData(str, length, filename); });
luax_catchexcept(L, [&](){ t = instance()->newFileData(ptr, length, filename); });
luax_pushtype(L, t);
t->release();
@@ -849,6 +864,23 @@ int extloader(lua_State *L)
void *handle = nullptr;
auto *inst = instance();
#ifdef LOVE_ANDROID
// Specifically Android, look the library path based on getCRequirePath first
std::string androidPath(love::android::getCRequirePath());
if (!androidPath.empty())
{
// Replace ? with just the dotted filename (not tokenized_name)
replaceAll(androidPath, "?", filename);
// Load directly, don't check for existence.
handle = SDL_LoadObject(androidPath.c_str());
}
if (!handle)
{
#endif // LOVE_ANDROID
for (const std::string &el : inst->getCRequirePath())
{
for (const char *ext : library_extensions)
@@ -878,6 +910,10 @@ int extloader(lua_State *L)
break;
}
#ifdef LOVE_ANDROID
} // if (!handle)
#endif
if (!handle)
{
lua_pushfstring(L, "\n\tno file '%s' in LOVE paths.", tokenized_name.c_str());